diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 7bd7ee60c0b3491e0797bd36c1b16ad314242eaa..7ff9e112977cef6aec473dd9454c4c5f43722611 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -664,12 +664,7 @@ add_boolean_option(PHY_TX_THREAD False "enable UE_EXPANSION w add_boolean_option(PRE_SCD_THREAD False "enable UE_EXPANSION with max 256 UE") add_boolean_option(UESIM_EXPANSION False "enable UESIM_EXPANSION with max 256 UE") -############################################################################# -# Flag for UE compilation to avoid issues in common eNB/UE PDCP/RLC functions -############################################################################# - -add_boolean_option(UETARGET False "set UE as target for compiler") - +######################## # Include order ########################## add_boolean_option(ENB_MODE True "Swap the include directories between openair2 and openair3" ) @@ -2292,6 +2287,7 @@ foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim pr ${T_SOURCE} ${CONFIG_SOURCES} ${SHLIB_LOADER_SOURCES} + ${NFAPI_USER_DIR}/nfapi.c ) target_link_libraries (${myExe} diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 887b3ebe2fe285638d54df572eeb397d7de902ad..9d8a6096714e704569f93930158907a4ba8569ab 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -70,7 +70,6 @@ DISABLE_LOG_X="False" USRP_REC_PLAY="False" BUILD_ECLIPSE=0 UE_NAS_USE_TUN="False" -UETARGET="False" BASIC_SIMULATOR=0 trap handle_ctrl_c INT @@ -219,7 +218,6 @@ function main() { shift;; --UE) UE=1 - UETARGET="True" echo_info "Will compile UE" shift;; --mu) @@ -549,9 +547,6 @@ function main() { echo "set (UE_TIMING_TRACE $UE_TIMING_TRACE)" >> $cmake_file echo "set (DISABLE_LOG_X $DISABLE_LOG_X)" >> $cmake_file echo "set (USRP_REC_PLAY $USRP_REC_PLAY)" >> $cmake_file - if [ "$UE" = 1 ] ; then - echo "set (UETARGET $UETARGET )" >> $cmake_file - fi if [ "$UE" = 1 -a "$NOS1" = "0" ] ; then echo_info "Compiling UE S1 build : enabling Linux and NETLINK" echo "set (LINUX True )" >> $cmake_file @@ -945,7 +940,6 @@ function main() { echo "set (USRP_REC_PLAY $USRP_REC_PLAY)" >> $cmake_file echo "set (LINUX True )" >> $cmake_file echo "set (PDCP_USE_NETLINK True )" >> $cmake_file - echo "set (UETARGET True )" >> $cmake_file echo "set (BASIC_SIMULATOR \"True\" )" >> $cmake_file # echo "set (UE_NAS_USE_TUN \"True\" )" >> $cmake_file echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.txt)' >> $cmake_file diff --git a/nfapi/oai_integration/nfapi.c b/nfapi/oai_integration/nfapi.c index 5a3bc804c1b7685ad1292413d71d3965a03339a1..4fc35fd951309bae126a53bf4818cfc7ccdf1352 100644 --- a/nfapi/oai_integration/nfapi.c +++ b/nfapi/oai_integration/nfapi.c @@ -21,31 +21,55 @@ #include <stdio.h> #include <pthread.h> +#include "nfapi/oai_integration/vendor_ext.h" +#include "common/utils/LOG/log.h" +static char nfapi_str_mode[6][24] = {"MONOLITHIC","PNF","VNF","UE_STUB_PNF","UE_STUB_OFFNET","<UNKNOWN NFAPI MODE>"}; -void set_thread_priority(int priority) -{ - //printf("%s(priority:%d)\n", __FUNCTION__, priority); +typedef struct { + nfapi_mode_t nfapi_mode; +} nfapi_params_t; - pthread_attr_t ptAttr; +static nfapi_params_t nfapi_params; +void set_thread_priority(int priority) { + //printf("%s(priority:%d)\n", __FUNCTION__, priority); + pthread_attr_t ptAttr; struct sched_param schedParam; schedParam.__sched_priority = priority; //79; - if(sched_setscheduler(0, SCHED_RR, &schedParam) != 0) - { + + if(sched_setscheduler(0, SCHED_RR, &schedParam) != 0) { printf("Failed to set scheduler to SCHED_RR\n"); } - if(pthread_attr_setschedpolicy(&ptAttr, SCHED_RR) != 0) - { + if(pthread_attr_setschedpolicy(&ptAttr, SCHED_RR) != 0) { printf("Failed to set pthread sched policy SCHED_RR\n"); } pthread_attr_setinheritsched(&ptAttr, PTHREAD_EXPLICIT_SCHED); - struct sched_param thread_params; thread_params.sched_priority = 20; - if(pthread_attr_setschedparam(&ptAttr, &thread_params) != 0) - { + + if(pthread_attr_setschedparam(&ptAttr, &thread_params) != 0) { printf("failed to set sched param\n"); } } + +char *nfapi_get_strmode(void) { + if (nfapi_params.nfapi_mode > NFAPI_MODE_UNKNOWN) + return nfapi_str_mode[NFAPI_MODE_UNKNOWN]; + + return nfapi_str_mode[nfapi_params.nfapi_mode]; +} + +void nfapi_logmode() { + LOG_I(ENB_APP,"nfapi running mode: %s\n",nfapi_get_strmode()); +} + +nfapi_mode_t nfapi_getmode(void) { + return nfapi_params.nfapi_mode; +} + +void nfapi_setmode(nfapi_mode_t nfapi_mode) { + nfapi_params.nfapi_mode = nfapi_mode; + nfapi_logmode(); +} diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index 62c5cc27754cf1c2b707b6f37f1a5bdf3bbbf743..a4b83e613b3c5685ab574ce84c30aad521916c67 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -28,6 +28,7 @@ #include <unistd.h> #include "debug.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "nfapi_pnf_interface.h" #include "nfapi.h" #include "nfapi_pnf.h" @@ -76,7 +77,7 @@ extern void handle_nfapi_hi_dci0_dci_pdu(PHY_VARS_eNB *eNB,int frame, int subfra extern void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,int frame, int subframe, L1_rxtx_proc_t *proc, nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu); extern void handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu, uint8_t *sdu); -extern uint8_t nfapi_mode; + nfapi_tx_request_pdu_t *tx_request_pdu[1023][10][10]; // [frame][subframe][max_num_pdus] @@ -485,7 +486,7 @@ int config_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfap // to keep only the necessary just to keep the nfapi FSM rolling by sending a dummy response. LTE_DL_FRAME_PARMS *fp; - if (nfapi_mode!=3) { + if (NFAPI_MODE!=NFAPI_UE_STUB_PNF) { struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0]; fp = &eNB->frame_parms; } else { @@ -647,7 +648,7 @@ int config_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfap num_tlv++; } - if(nfapi_mode!=3) { + if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) { printf("[PNF] CONFIG_REQUEST[num_tlv:%d] TLVs processed:%d\n", req->num_tlv, num_tlv); printf("[PNF] Simulating PHY CONFIG - DJP\n"); PHY_Config_t phy_config; @@ -672,7 +673,7 @@ int config_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfap nfapi_pnf_config_resp(config, &nfapi_resp); printf("[PNF] Sent NFAPI_CONFIG_RESPONSE phy_id:%d\n", phy_info->id); - if(nfapi_mode ==3) + if(NFAPI_MODE==NFAPI_UE_STUB_PNF) free(fp); return 0; @@ -1023,7 +1024,7 @@ int start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi p7_config->tx_req = &pnf_phy_tx_req; p7_config->lbt_dl_config_req = &pnf_phy_lbt_dl_config_req; - if (nfapi_mode==3) { + if (NFAPI_MODE==NFAPI_UE_STUB_PNF) { p7_config->dl_config_req = &memcpy_dl_config_req; p7_config->ul_config_req = &memcpy_ul_config_req; p7_config->hi_dci0_req = &memcpy_hi_dci0_req; @@ -1080,7 +1081,7 @@ int start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfapi //phy_init_RU(RC.ru[0]); printf("[PNF] About to call init_eNB_afterRU()\n"); - if (nfapi_mode != 3) { + if (NFAPI_MODE!=NFAPI_UE_STUB_PNF) { init_eNB_afterRU(); } @@ -1364,8 +1365,8 @@ void *pnf_start_thread(void *ptr) { void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port) { printf("%s() PNF\n\n\n\n\n\n", __FUNCTION__); - if(nfapi_mode!=3) { - nfapi_mode = 1; // PNF! + if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) { + nfapi_setmode(NFAPI_PNF); // PNF! } nfapi_pnf_config_t *config = nfapi_pnf_config_create(); diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index 4823a872a7efd9bc06f078887e0cadc579382c95..2752df3435d37090e4ddc3f2347e8a45896869ba 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -904,10 +904,10 @@ void vnf_start_thread(void *ptr) { } static vnf_info vnf; -extern uint8_t nfapi_mode; + /*------------------------------------------------------------------------------*/ void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port) { - nfapi_mode = 2; + nfapi_setmode(NFAPI_MODE_VNF); memset(&vnf, 0, sizeof(vnf)); memset(vnf.p7_vnfs, 0, sizeof(vnf.p7_vnfs)); vnf.p7_vnfs[0].timing_window = 32; diff --git a/nfapi/oai_integration/vendor_ext.h b/nfapi/oai_integration/vendor_ext.h index 0622432260060dc7ef3f4fc4d76f889a7e3860d8..f25aa703ccdb5a5f3eac99225585c6595309066d 100644 --- a/nfapi/oai_integration/vendor_ext.h +++ b/nfapi/oai_integration/vendor_ext.h @@ -1,12 +1,12 @@ /* * Copyright 2017 Cisco Systems, Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,48 +20,62 @@ #include "nfapi_interface.h" typedef enum { - P5_VENDOR_EXT_REQ = NFAPI_VENDOR_EXT_MSG_MIN, - P5_VENDOR_EXT_RSP, + P5_VENDOR_EXT_REQ = NFAPI_VENDOR_EXT_MSG_MIN, + P5_VENDOR_EXT_RSP, - P7_VENDOR_EXT_REQ, - P7_VENDOR_EXT_IND + P7_VENDOR_EXT_REQ, + P7_VENDOR_EXT_IND } vendor_ext_message_id_e; typedef struct { - nfapi_p4_p5_message_header_t header; - uint16_t dummy1; - uint16_t dummy2; + nfapi_p4_p5_message_header_t header; + uint16_t dummy1; + uint16_t dummy2; } vendor_ext_p5_req; typedef struct { - nfapi_p4_p5_message_header_t header; - uint16_t error_code; + nfapi_p4_p5_message_header_t header; + uint16_t error_code; } vendor_ext_p5_rsp; typedef struct { - nfapi_p7_message_header_t header; - uint16_t dummy1; - uint16_t dummy2; + nfapi_p7_message_header_t header; + uint16_t dummy1; + uint16_t dummy2; } vendor_ext_p7_req; typedef struct { - nfapi_p7_message_header_t header; - uint16_t error_code; + nfapi_p7_message_header_t header; + uint16_t error_code; } vendor_ext_p7_ind; typedef struct { - nfapi_tl_t tl; - uint32_t dummy; + nfapi_tl_t tl; + uint32_t dummy; } vendor_ext_tlv_1; #define VENDOR_EXT_TLV_1_TAG 0xF001 typedef struct { - nfapi_tl_t tl; - uint32_t dummy; + nfapi_tl_t tl; + uint32_t dummy; } vendor_ext_tlv_2; #define VENDOR_EXT_TLV_2_TAG 0xF002 +typedef enum { + NFAPI_MONOLITHIC=0, + NFAPI_MODE_PNF, + NFAPI_MODE_VNF, + NFAPI_UE_STUB_PNF, + NFAPI_UE_STUB_OFFNET, + NFAPI_MODE_UNKNOWN +} nfapi_mode_t; + +char *nfapi_get_strmode(void); +void nfapi_logmode(void); +nfapi_mode_t nfapi_getmode(void); +void nfapi_setmode(nfapi_mode_t nfapi_mode); +#define NFAPI_MODE (nfapi_getmode()) #endif // _VENDOR_EXT_ diff --git a/openair1/PHY/INIT/lte_init_ue.c b/openair1/PHY/INIT/lte_init_ue.c index bd3aefb1c36c847005bab1ab9918952e8f407170..99d4f89ace42db62ca526e50ffcdcf8bd9098bd2 100644 --- a/openair1/PHY/INIT/lte_init_ue.c +++ b/openair1/PHY/INIT/lte_init_ue.c @@ -34,19 +34,17 @@ #include "PHY/LTE_TRANSPORT/transport_common_proto.h" #include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" #include "PHY/LTE_REFSIG/lte_refsig.h" - +#include "nfapi/oai_integration/vendor_ext.h" void init_7_5KHz(void); uint8_t dmrs1_tab_ue[8] = {0,2,3,4,6,8,9,10}; -extern uint8_t nfapi_mode; + void phy_config_sib1_ue(module_id_t Mod_id,int CC_id, uint8_t eNB_id, LTE_TDD_Config_t *tdd_Config, uint8_t SIwindowsize, - uint16_t SIperiod) -{ - + uint16_t SIperiod) { LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][CC_id]->frame_parms; if (tdd_Config) { @@ -64,44 +62,29 @@ void phy_config_sib2_ue(module_id_t Mod_id,int CC_id, LTE_ARFCN_ValueEUTRA_t *ul_CarrierFreq, long *ul_Bandwidth, LTE_AdditionalSpectrumEmission_t *additionalSpectrumEmission, - struct LTE_MBSFN_SubframeConfigList *mbsfn_SubframeConfigList) -{ - + struct LTE_MBSFN_SubframeConfigList *mbsfn_SubframeConfigList) { PHY_VARS_UE *ue = PHY_vars_UE_g[Mod_id][CC_id]; LTE_DL_FRAME_PARMS *fp = &ue->frame_parms; int i; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_CONFIG_SIB2, VCD_FUNCTION_IN); - LOG_I(PHY,"[UE%d] Applying radioResourceConfigCommon from eNB%d\n",Mod_id,eNB_id); - fp->prach_config_common.rootSequenceIndex =radioResourceConfigCommon->prach_Config.rootSequenceIndex; - fp->prach_config_common.prach_Config_enabled=1; fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_ConfigIndex; fp->prach_config_common.prach_ConfigInfo.highSpeedFlag =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.highSpeedFlag; fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig; fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_FreqOffset; - compute_prach_seq(fp->prach_config_common.rootSequenceIndex, - fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, - fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig, - fp->prach_config_common.prach_ConfigInfo.highSpeedFlag, - fp->frame_type,ue->X_u); - - - + fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, + fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig, + fp->prach_config_common.prach_ConfigInfo.highSpeedFlag, + fp->frame_type,ue->X_u); fp->pucch_config_common.deltaPUCCH_Shift = 1+radioResourceConfigCommon->pucch_ConfigCommon.deltaPUCCH_Shift; fp->pucch_config_common.nRB_CQI = radioResourceConfigCommon->pucch_ConfigCommon.nRB_CQI; fp->pucch_config_common.nCS_AN = radioResourceConfigCommon->pucch_ConfigCommon.nCS_AN; fp->pucch_config_common.n1PUCCH_AN = radioResourceConfigCommon->pucch_ConfigCommon.n1PUCCH_AN; - - - fp->pdsch_config_common.referenceSignalPower = radioResourceConfigCommon->pdsch_ConfigCommon.referenceSignalPower; fp->pdsch_config_common.p_b = radioResourceConfigCommon->pdsch_ConfigCommon.p_b; - - fp->pusch_config_common.n_SB = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB; fp->pusch_config_common.hoppingMode = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode; fp->pusch_config_common.pusch_HoppingOffset = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset; @@ -110,8 +93,6 @@ void phy_config_sib2_ue(module_id_t Mod_id,int CC_id, fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH; fp->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled; fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = dmrs1_tab_ue[radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift]; - - init_ul_hopping(fp); fp->soundingrs_ul_config_common.enabled_flag = 0; @@ -127,8 +108,6 @@ void phy_config_sib2_ue(module_id_t Mod_id,int CC_id, fp->soundingrs_ul_config_common.srs_MaxUpPts = 0; } - - fp->ul_power_control_config_common.p0_NominalPUSCH = radioResourceConfigCommon->uplinkPowerControlCommon.p0_NominalPUSCH; fp->ul_power_control_config_common.alpha = radioResourceConfigCommon->uplinkPowerControlCommon.alpha; fp->ul_power_control_config_common.p0_NominalPUCCH = radioResourceConfigCommon->uplinkPowerControlCommon.p0_NominalPUCCH; @@ -138,16 +117,11 @@ void phy_config_sib2_ue(module_id_t Mod_id,int CC_id, fp->ul_power_control_config_common.deltaF_PUCCH_Format2 = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2; fp->ul_power_control_config_common.deltaF_PUCCH_Format2a = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2a; fp->ul_power_control_config_common.deltaF_PUCCH_Format2b = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b; - fp->maxHARQ_Msg3Tx = radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx; - // Now configure some of the Physical Channels - // PUCCH init_ncs_cell(fp,ue->ncs_cell); - init_ul_hopping(fp); - // PCH init_ue_paging_info(ue,radioResourceConfigCommon->pcch_Config.defaultPagingCycle,radioResourceConfigCommon->pcch_Config.nB); @@ -171,7 +145,6 @@ void phy_config_sib2_ue(module_id_t Mod_id,int CC_id, mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[2]| (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[1]<<8)| (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0]<<16); - LOG_I(PHY, "[CONFIG] LTE_MBSFN_SubframeConfig[%d] pattern is %x\n", i, fp->MBSFN_config[i].mbsfn_SubframeConfig); } @@ -179,16 +152,11 @@ void phy_config_sib2_ue(module_id_t Mod_id,int CC_id, } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_CONFIG_SIB2, VCD_FUNCTION_OUT); - } void phy_config_sib13_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id,int mbsfn_Area_idx, - long mbsfn_AreaId_r9) -{ - + long mbsfn_AreaId_r9) { LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][CC_id]->frame_parms; - - LOG_I(PHY,"[UE%d] Applying MBSFN_Area_id %ld for index %d\n",Mod_id,mbsfn_AreaId_r9,mbsfn_Area_idx); if (mbsfn_Area_idx == 0) { @@ -197,16 +165,13 @@ void phy_config_sib13_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id,int mbsfn_A } lte_gold_mbsfn(fp,PHY_vars_UE_g[Mod_id][CC_id]->lte_gold_mbsfn_table,fp->Nid_cell_mbsfn); - } /* * Configures UE MAC and PHY with radioResourceCommon received in mobilityControlInfo IE during Handover */ -void phy_config_afterHO_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_id, LTE_MobilityControlInfo_t *mobilityControlInfo, uint8_t ho_failed) -{ - +void phy_config_afterHO_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_id, LTE_MobilityControlInfo_t *mobilityControlInfo, uint8_t ho_failed) { if(mobilityControlInfo!=NULL) { LTE_RadioResourceConfigCommon_t *radioResourceConfigCommon = &mobilityControlInfo->radioResourceConfigCommon; LOG_I(PHY,"radioResourceConfigCommon %p\n", radioResourceConfigCommon); @@ -215,44 +180,35 @@ void phy_config_afterHO_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_id, LTE_ sizeof(LTE_DL_FRAME_PARMS)); PHY_vars_UE_g[Mod_id][CC_id]->ho_triggered = 1; //PHY_vars_UE_g[UE_id]->UE_mode[0] = PRACH; - LTE_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][CC_id]->frame_parms; // int N_ZC; // uint8_t prach_fmt; // int u; - LOG_I(PHY,"[UE%d] Handover triggered: Applying radioResourceConfigCommon from eNB %d\n", Mod_id,eNB_id); - fp->prach_config_common.rootSequenceIndex =radioResourceConfigCommon->prach_Config.rootSequenceIndex; fp->prach_config_common.prach_Config_enabled=1; fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->prach_ConfigIndex; fp->prach_config_common.prach_ConfigInfo.highSpeedFlag =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->highSpeedFlag; fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->zeroCorrelationZoneConfig; fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->prach_FreqOffset; - // prach_fmt = get_prach_fmt(radioResourceConfigCommon->prach_Config.prach_ConfigInfo->prach_ConfigIndex,fp->frame_type); // N_ZC = (prach_fmt <4)?839:139; // u = (prach_fmt < 4) ? prach_root_sequence_map0_3[fp->prach_config_common.rootSequenceIndex] : // prach_root_sequence_map4[fp->prach_config_common.rootSequenceIndex]; - //compute_prach_seq(u,N_ZC, PHY_vars_UE_g[Mod_id]->X_u); compute_prach_seq(PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.rootSequenceIndex, - PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex, - PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig, - PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.highSpeedFlag, + PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex, + PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig, + PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.highSpeedFlag, fp->frame_type, PHY_vars_UE_g[Mod_id][CC_id]->X_u); - - fp->pucch_config_common.deltaPUCCH_Shift = 1+radioResourceConfigCommon->pucch_ConfigCommon->deltaPUCCH_Shift; fp->pucch_config_common.nRB_CQI = radioResourceConfigCommon->pucch_ConfigCommon->nRB_CQI; fp->pucch_config_common.nCS_AN = radioResourceConfigCommon->pucch_ConfigCommon->nCS_AN; fp->pucch_config_common.n1PUCCH_AN = radioResourceConfigCommon->pucch_ConfigCommon->n1PUCCH_AN; fp->pdsch_config_common.referenceSignalPower = radioResourceConfigCommon->pdsch_ConfigCommon->referenceSignalPower; fp->pdsch_config_common.p_b = radioResourceConfigCommon->pdsch_ConfigCommon->p_b; - - fp->pusch_config_common.n_SB = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB; fp->pusch_config_common.hoppingMode = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode; fp->pusch_config_common.pusch_HoppingOffset = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset; @@ -261,7 +217,6 @@ void phy_config_afterHO_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_id, LTE_ fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH; fp->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled; fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift; - init_ul_hopping(fp); fp->soundingrs_ul_config_common.enabled_flag = 0; @@ -286,7 +241,6 @@ void phy_config_afterHO_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_id, LTE_ fp->ul_power_control_config_common.deltaF_PUCCH_Format2 = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format2; fp->ul_power_control_config_common.deltaF_PUCCH_Format2a = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format2a; fp->ul_power_control_config_common.deltaF_PUCCH_Format2b = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format2b; - fp->maxHARQ_Msg3Tx = radioResourceConfigCommon->rach_ConfigCommon->maxHARQ_Msg3Tx; // Now configure some of the Physical Channels @@ -304,20 +258,14 @@ void phy_config_afterHO_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_id, LTE_ //Target CellId fp->Nid_cell = mobilityControlInfo->targetPhysCellId; fp->nushift = fp->Nid_cell%6; - // PUCCH init_ncs_cell(fp,PHY_vars_UE_g[Mod_id][CC_id]->ncs_cell); - init_ul_hopping(fp); - // RNTI - - PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[0][eNB_id]->crnti = mobilityControlInfo->newUE_Identity.buf[0]|(mobilityControlInfo->newUE_Identity.buf[1]<<8); PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[1][eNB_id]->crnti = mobilityControlInfo->newUE_Identity.buf[0]|(mobilityControlInfo->newUE_Identity.buf[1]<<8); - LOG_I(PHY,"SET C-RNTI %x %x\n",PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[0][eNB_id]->crnti, - PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[1][eNB_id]->crnti); + PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[1][eNB_id]->crnti); } if(ho_failed) { @@ -327,12 +275,9 @@ void phy_config_afterHO_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_id, LTE_ } } -void phy_config_meas_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index,uint8_t n_adj_cells,unsigned int *adj_cell_id) -{ - +void phy_config_meas_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index,uint8_t n_adj_cells,unsigned int *adj_cell_id) { PHY_MEASUREMENTS *phy_meas = &PHY_vars_UE_g[Mod_id][CC_id]->measurements; int i; - LOG_I(PHY,"Configuring inter-cell measurements for %d cells, ids: \n",n_adj_cells); for (i=0; i<n_adj_cells; i++) { @@ -341,25 +286,20 @@ void phy_config_meas_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index,uint8 } phy_meas->n_adj_cells = n_adj_cells; - memcpy((void*)phy_meas->adj_cell_id,(void *)adj_cell_id,n_adj_cells*sizeof(unsigned int)); - + memcpy((void *)phy_meas->adj_cell_id,(void *)adj_cell_id,n_adj_cells*sizeof(unsigned int)); } #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) void phy_config_dedicated_scell_ue(uint8_t Mod_id, uint8_t eNB_index, LTE_SCellToAddMod_r10_t *sCellToAddMod_r10, - int CC_id) -{ - + int CC_id) { } #endif void phy_config_harq_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, - uint16_t max_harq_tx ) -{ - + uint16_t max_harq_tx ) { PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id][CC_id]; phy_vars_ue->ulsch[eNB_id]->Mlimit = max_harq_tx; } @@ -367,12 +307,9 @@ void phy_config_harq_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, extern uint16_t beta_cqi[16]; void phy_config_dedicated_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, - struct LTE_PhysicalConfigDedicated *physicalConfigDedicated ) -{ - + struct LTE_PhysicalConfigDedicated *physicalConfigDedicated ) { static uint8_t first_dedicated_configuration = 0; PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id][CC_id]; - phy_vars_ue->total_TBS[eNB_id]=0; phy_vars_ue->total_TBS_last[eNB_id]=0; phy_vars_ue->bitrate[eNB_id]=0; @@ -382,7 +319,6 @@ void phy_config_dedicated_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, phy_vars_ue->dlsch_received[eNB_id]=0; phy_vars_ue->dlsch_received_last[eNB_id]=0; phy_vars_ue->dlsch_fer[eNB_id]=0; - phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = -1; phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = -1; @@ -418,18 +354,14 @@ void phy_config_dedicated_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_ACK_Index; phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_RI_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index; phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index; - - LOG_D(PHY,"pusch_config_dedicated.betaOffset_ACK_Index %d\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index); LOG_D(PHY,"pusch_config_dedicated.betaOffset_RI_Index %d\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_RI_Index); - LOG_D(PHY,"pusch_config_dedicated.betaOffset_CQI_Index %d => %d)\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index,beta_cqi[phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index]); + LOG_D(PHY,"pusch_config_dedicated.betaOffset_CQI_Index %d => %d)\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index, + beta_cqi[phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index]); LOG_D(PHY,"\n"); - - } if (physicalConfigDedicated->uplinkPowerControlDedicated) { - phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUSCH = physicalConfigDedicated->uplinkPowerControlDedicated->p0_UE_PUSCH; phy_vars_ue->ul_power_control_dedicated[eNB_id].deltaMCS_Enabled= physicalConfigDedicated->uplinkPowerControlDedicated->deltaMCS_Enabled; phy_vars_ue->ul_power_control_dedicated[eNB_id].accumulationEnabled= physicalConfigDedicated->uplinkPowerControlDedicated->accumulationEnabled; @@ -448,32 +380,40 @@ void phy_config_dedicated_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, if (physicalConfigDedicated->antennaInfo) { phy_vars_ue->transmission_mode[eNB_id] = 1+(physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode); LOG_I(PHY,"Transmission Mode %d\n",phy_vars_ue->transmission_mode[eNB_id]); + switch(physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode) { - case LTE_AntennaInfoDedicated__transmissionMode_tm1: - phy_vars_ue->transmission_mode[eNB_id] = 1; - break; - case LTE_AntennaInfoDedicated__transmissionMode_tm2: - phy_vars_ue->transmission_mode[eNB_id] = 2; - break; - case LTE_AntennaInfoDedicated__transmissionMode_tm3: - phy_vars_ue->transmission_mode[eNB_id] = 3; - break; - case LTE_AntennaInfoDedicated__transmissionMode_tm4: - phy_vars_ue->transmission_mode[eNB_id] = 4; - break; - case LTE_AntennaInfoDedicated__transmissionMode_tm5: - phy_vars_ue->transmission_mode[eNB_id] = 5; - break; - case LTE_AntennaInfoDedicated__transmissionMode_tm6: - phy_vars_ue->transmission_mode[eNB_id] = 6; - break; - case LTE_AntennaInfoDedicated__transmissionMode_tm7: - lte_gold_ue_spec_port5(phy_vars_ue->lte_gold_uespec_port5_table, phy_vars_ue->frame_parms.Nid_cell, phy_vars_ue->pdcch_vars[0][eNB_id]->crnti); - phy_vars_ue->transmission_mode[eNB_id] = 7; - break; - default: - LOG_E(PHY,"Unknown transmission mode!\n"); - break; + case LTE_AntennaInfoDedicated__transmissionMode_tm1: + phy_vars_ue->transmission_mode[eNB_id] = 1; + break; + + case LTE_AntennaInfoDedicated__transmissionMode_tm2: + phy_vars_ue->transmission_mode[eNB_id] = 2; + break; + + case LTE_AntennaInfoDedicated__transmissionMode_tm3: + phy_vars_ue->transmission_mode[eNB_id] = 3; + break; + + case LTE_AntennaInfoDedicated__transmissionMode_tm4: + phy_vars_ue->transmission_mode[eNB_id] = 4; + break; + + case LTE_AntennaInfoDedicated__transmissionMode_tm5: + phy_vars_ue->transmission_mode[eNB_id] = 5; + break; + + case LTE_AntennaInfoDedicated__transmissionMode_tm6: + phy_vars_ue->transmission_mode[eNB_id] = 6; + break; + + case LTE_AntennaInfoDedicated__transmissionMode_tm7: + lte_gold_ue_spec_port5(phy_vars_ue->lte_gold_uespec_port5_table, phy_vars_ue->frame_parms.Nid_cell, phy_vars_ue->pdcch_vars[0][eNB_id]->crnti); + phy_vars_ue->transmission_mode[eNB_id] = 7; + break; + + default: + LOG_E(PHY,"Unknown transmission mode!\n"); + break; } } else { LOG_D(PHY,"[UE %d] Received NULL physicalConfigDedicated->antennaInfo from eNB %d\n",Mod_id, eNB_id); @@ -484,19 +424,17 @@ void phy_config_dedicated_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, phy_vars_ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex = physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex; phy_vars_ue->scheduling_request_config[eNB_id].sr_ConfigIndex=physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_ConfigIndex; phy_vars_ue->scheduling_request_config[eNB_id].dsr_TransMax=physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax; - LOG_D(PHY,"scheduling_request_config.sr_PUCCH_ResourceIndex %d\n",phy_vars_ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); LOG_D(PHY,"scheduling_request_config.sr_ConfigIndex %d\n",phy_vars_ue->scheduling_request_config[eNB_id].sr_ConfigIndex); LOG_D(PHY,"scheduling_request_config.dsr_TransMax %d\n",phy_vars_ue->scheduling_request_config[eNB_id].dsr_TransMax); } LOG_D(PHY,"------------------------------------------------------------\n"); - } if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated) { - phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srsConfigDedicatedSetup = 0; + if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated->present == LTE_SoundingRS_UL_ConfigDedicated_PR_setup) { phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srsConfigDedicatedSetup = 1; phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].duration = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.duration; @@ -506,34 +444,32 @@ void phy_config_dedicated_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_ConfigIndex = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex; phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_HoppingBandwidth = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth; phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].transmissionComb = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb; - - LOG_D(PHY,"soundingrs_ul_config_dedicated.srs_ConfigIndex %d\n",phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_ConfigIndex); } LOG_D(PHY,"------------------------------------------------------------\n"); - } - if (physicalConfigDedicated->cqi_ReportConfig) { if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic) { // configure PUSCH CQI reporting phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic = *physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic; + if ((phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm12) && (phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm30) && (phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm31)) LOG_E(PHY,"Unsupported Aperiodic CQI Feedback Mode : %d\n",phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic); } + if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic) { if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->present == LTE_CQI_ReportPeriodic_PR_setup) { - // configure PUCCH CQI reporting + // configure PUCCH CQI reporting phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PUCCH_ResourceIndex = physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex; phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex; + if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex) phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = *physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex; - } - else if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->present == LTE_CQI_ReportPeriodic_PR_release) { + } else if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->present == LTE_CQI_ReportPeriodic_PR_release) { // handle release phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = -1; phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = -1; @@ -559,28 +495,25 @@ void phy_config_dedicated_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, // fill cqi parameters for periodic CQI reporting get_cqipmiri_params(phy_vars_ue,eNB_id); - // disable MIB SIB decoding once we are on connected mode first_dedicated_configuration ++; - if(first_dedicated_configuration > 1) - { - LOG_I(PHY,"Disable SIB MIB decoding \n"); - phy_vars_ue->decode_SIB = 0; - phy_vars_ue->decode_MIB = 0; + + if(first_dedicated_configuration > 1) { + LOG_I(PHY,"Disable SIB MIB decoding \n"); + phy_vars_ue->decode_SIB = 0; + phy_vars_ue->decode_MIB = 0; } - if(nfapi_mode!=3){ + if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) { //phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti; if(phy_vars_ue->pdcch_vars[0][eNB_id]->crnti == 0x1234) - phy_vars_ue->pdcch_vars[0][eNB_id]->crnti = phy_vars_ue->pdcch_vars[1][eNB_id]->crnti; + phy_vars_ue->pdcch_vars[0][eNB_id]->crnti = phy_vars_ue->pdcch_vars[1][eNB_id]->crnti; else - phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti; + phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti; LOG_I(PHY,"C-RNTI %x %x \n", phy_vars_ue->pdcch_vars[0][eNB_id]->crnti, - phy_vars_ue->pdcch_vars[1][eNB_id]->crnti); + phy_vars_ue->pdcch_vars[1][eNB_id]->crnti); } - - } /*! \brief Helper function to allocate memory for DLSCH data structures. @@ -588,88 +521,71 @@ void phy_config_dedicated_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, * \param[in] frame_parms LTE_DL_FRAME_PARMS structure. * \note This function is optimistic in that it expects malloc() to succeed. */ -void phy_init_lte_ue__PDSCH( LTE_UE_PDSCH* const pdsch, const LTE_DL_FRAME_PARMS* const fp ) -{ +void phy_init_lte_ue__PDSCH( LTE_UE_PDSCH *const pdsch, const LTE_DL_FRAME_PARMS *const fp ) { AssertFatal( pdsch, "pdsch==0" ); - - pdsch->pmi_ext = (uint8_t*)malloc16_clear( fp->N_RB_DL ); - pdsch->llr[0] = (int16_t*)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); - pdsch->llr128 = (int16_t**)malloc16_clear( sizeof(int16_t*) ); + pdsch->pmi_ext = (uint8_t *)malloc16_clear( fp->N_RB_DL ); + pdsch->llr[0] = (int16_t *)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); + pdsch->llr128 = (int16_t **)malloc16_clear( sizeof(int16_t *) ); // FIXME! no further allocation for (int16_t*)pdsch->llr128 !!! expect SIGSEGV // FK, 11-3-2015: this is only as a temporary pointer, no memory is stored there - - - pdsch->rxdataF_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pdsch->rxdataF_uespec_pilots = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pdsch->rxdataF_comp0 = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pdsch->rho = (int32_t**)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t*) ); - pdsch->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pdsch->dl_bf_ch_estimates = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pdsch->dl_bf_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + pdsch->rxdataF_ext = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + pdsch->rxdataF_uespec_pilots = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + pdsch->rxdataF_comp0 = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + pdsch->rho = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) ); + pdsch->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + pdsch->dl_bf_ch_estimates = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + pdsch->dl_bf_ch_estimates_ext = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); //pdsch->dl_ch_rho_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); //pdsch->dl_ch_rho2_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pdsch->dl_ch_mag0 = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pdsch->dl_ch_magb0 = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - - + pdsch->dl_ch_mag0 = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + pdsch->dl_ch_magb0 = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); // the allocated memory size is fixed: AssertFatal( fp->nb_antennas_rx <= 2, "nb_antennas_rx > 2" ); for (int i=0; i<fp->nb_antennas_rx; i++) { - pdsch->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->N_RB_DL*12*7*2) ); + pdsch->rho[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(fp->N_RB_DL*12*7*2) ); for (int j=0; j<4; j++) { //fp->nb_antennas_tx; j++) const int idx = (j<<1)+i; const size_t num = 7*2*fp->N_RB_DL*12; - pdsch->rxdataF_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - pdsch->rxdataF_uespec_pilots[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * fp->N_RB_DL*12); - pdsch->rxdataF_comp0[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - pdsch->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - pdsch->dl_bf_ch_estimates[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * fp->ofdm_symbol_size*7*2); - pdsch->dl_bf_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + pdsch->rxdataF_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); + pdsch->rxdataF_uespec_pilots[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * fp->N_RB_DL*12); + pdsch->rxdataF_comp0[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); + pdsch->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); + pdsch->dl_bf_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * fp->ofdm_symbol_size*7*2); + pdsch->dl_bf_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); //pdsch->dl_ch_rho_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); //pdsch->dl_ch_rho2_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - pdsch->dl_ch_mag0[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - pdsch->dl_ch_magb0[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); + pdsch->dl_ch_mag0[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); + pdsch->dl_ch_magb0[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); } } } int init_lte_ue_signal(PHY_VARS_UE *ue, - int nb_connected_eNB, - uint8_t abstraction_flag) -{ - + int nb_connected_eNB, + uint8_t abstraction_flag) { // create shortcuts - LTE_DL_FRAME_PARMS* const fp = &ue->frame_parms; - LTE_UE_COMMON* const common_vars = &ue->common_vars; - LTE_UE_PDSCH** const pdsch_vars_SI = ue->pdsch_vars_SI; - LTE_UE_PDSCH** const pdsch_vars_ra = ue->pdsch_vars_ra; - LTE_UE_PDSCH** const pdsch_vars_p = ue->pdsch_vars_p; - LTE_UE_PDSCH** const pdsch_vars_mch = ue->pdsch_vars_MCH; + LTE_DL_FRAME_PARMS *const fp = &ue->frame_parms; + LTE_UE_COMMON *const common_vars = &ue->common_vars; + LTE_UE_PDSCH **const pdsch_vars_SI = ue->pdsch_vars_SI; + LTE_UE_PDSCH **const pdsch_vars_ra = ue->pdsch_vars_ra; + LTE_UE_PDSCH **const pdsch_vars_p = ue->pdsch_vars_p; + LTE_UE_PDSCH **const pdsch_vars_mch = ue->pdsch_vars_MCH; LTE_UE_PDSCH* (*pdsch_vars_th)[][NUMBER_OF_CONNECTED_eNB_MAX+1] = &ue->pdsch_vars; LTE_UE_PDCCH* (*pdcch_vars_th)[][NUMBER_OF_CONNECTED_eNB_MAX] = &ue->pdcch_vars; - LTE_UE_PBCH** const pbch_vars = ue->pbch_vars; - LTE_UE_PRACH** const prach_vars = ue->prach_vars; - - - + LTE_UE_PBCH **const pbch_vars = ue->pbch_vars; + LTE_UE_PRACH **const prach_vars = ue->prach_vars; int i,j,k,l; int eNB_id; int th_id; - LOG_D(PHY,"Initializing UE vars (abstraction %"PRIu8") for eNB TXant %"PRIu8", UE RXant %"PRIu8"\n",abstraction_flag,fp->nb_antennas_tx,fp->nb_antennas_rx); - - - init_dfts(); init_frame_parms(&ue->frame_parms,1); lte_sync_time_init(&ue->frame_parms); init_lte_top(&ue->frame_parms); init_7_5KHz(); init_ul_hopping(&ue->frame_parms); - - // many memory allocation sizes are hard coded AssertFatal( fp->nb_antennas_rx <= 2, "hard coded allocation for ue_common_vars->dl_ch_estimates[eNB_id]" ); AssertFatal( ue->n_connected_eNB <= NUMBER_OF_CONNECTED_eNB_MAX, "n_connected_eNB is too large" ); @@ -690,49 +606,44 @@ int init_lte_ue_signal(PHY_VARS_UE *ue, ue->total_received_bits[eNB_id] = 0; } - for (i=0;i<10;i++) + for (i=0; i<10; i++) ue->tx_power_dBm[i]=-127; - - // init TX buffers - - common_vars->txdata = (int32_t**)malloc16( fp->nb_antennas_tx*sizeof(int32_t*) ); - common_vars->txdataF = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t*) ); - + common_vars->txdata = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t *) ); + common_vars->txdataF = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t *) ); + for (i=0; i<fp->nb_antennas_tx; i++) { - - common_vars->txdata[i] = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) ); + common_vars->txdata[i] = (int32_t *)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) ); common_vars->txdataF[i] = (int32_t *)malloc16_clear( fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t) ); } - + // init RX buffers - - common_vars->rxdata = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); - common_vars->common_vars_rx_data_per_thread[0].rxdataF = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); - common_vars->common_vars_rx_data_per_thread[1].rxdataF = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); - + common_vars->rxdata = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + common_vars->common_vars_rx_data_per_thread[0].rxdataF = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + common_vars->common_vars_rx_data_per_thread[1].rxdataF = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + for (i=0; i<fp->nb_antennas_rx; i++) { - common_vars->rxdata[i] = (int32_t*) malloc16_clear( (fp->samples_per_tti*10+2048)*sizeof(int32_t) ); + common_vars->rxdata[i] = (int32_t *) malloc16_clear( (fp->samples_per_tti*10+2048)*sizeof(int32_t) ); LOG_I(PHY,"common_vars->rxdata[%d] %p\n",i,common_vars->rxdata[i]); - common_vars->common_vars_rx_data_per_thread[0].rxdataF[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->ofdm_symbol_size*14) ); - common_vars->common_vars_rx_data_per_thread[1].rxdataF[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->ofdm_symbol_size*14) ); + common_vars->common_vars_rx_data_per_thread[0].rxdataF[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(fp->ofdm_symbol_size*14) ); + common_vars->common_vars_rx_data_per_thread[1].rxdataF[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(fp->ofdm_symbol_size*14) ); } - // Channel estimates for (eNB_id=0; eNB_id<7; eNB_id++) { for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates[eNB_id] = (int32_t**)malloc16_clear(8*sizeof(int32_t*)); - common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates_time[eNB_id] = (int32_t**)malloc16_clear(8*sizeof(int32_t*)); + common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates[eNB_id] = (int32_t **)malloc16_clear(8*sizeof(int32_t *)); + common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates_time[eNB_id] = (int32_t **)malloc16_clear(8*sizeof(int32_t *)); } for (i=0; i<fp->nb_antennas_rx; i++) for (j=0; j<4; j++) { int idx = (j<<1) + i; + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates[eNB_id][idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->symbols_per_tti*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH) ); - common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates_time[eNB_id][idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 ); + common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates[eNB_id][idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->symbols_per_tti*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH) ); + common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates_time[eNB_id][idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 ); } } } @@ -740,11 +651,11 @@ int init_lte_ue_signal(PHY_VARS_UE *ue, // DLSCH for (eNB_id=0; eNB_id<ue->n_connected_eNB; eNB_id++) { for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id] = (LTE_UE_PDSCH *)malloc16_clear(sizeof(LTE_UE_PDSCH)); + (*pdsch_vars_th)[th_id][eNB_id] = (LTE_UE_PDSCH *)malloc16_clear(sizeof(LTE_UE_PDSCH)); } for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdcch_vars_th)[th_id][eNB_id] = (LTE_UE_PDCCH *)malloc16_clear(sizeof(LTE_UE_PDCCH)); + (*pdcch_vars_th)[th_id][eNB_id] = (LTE_UE_PDCCH *)malloc16_clear(sizeof(LTE_UE_PDCCH)); } pdsch_vars_SI[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear(sizeof(LTE_UE_PDSCH)); @@ -759,161 +670,159 @@ int init_lte_ue_signal(PHY_VARS_UE *ue, } for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id]->llr_shifts = (uint8_t*)malloc16_clear(7*2*fp->N_RB_DL*12); + (*pdsch_vars_th)[th_id][eNB_id]->llr_shifts = (uint8_t *)malloc16_clear(7*2*fp->N_RB_DL*12); (*pdsch_vars_th)[th_id][eNB_id]->llr_shifts_p = (*pdsch_vars_th)[0][eNB_id]->llr_shifts; - (*pdsch_vars_th)[th_id][eNB_id]->llr[1] = (int16_t*)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); - (*pdsch_vars_th)[th_id][eNB_id]->llr128_2ndstream = (int16_t**)malloc16_clear( sizeof(int16_t*) ); - (*pdsch_vars_th)[th_id][eNB_id]->rho = (int32_t**)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t*) ); + (*pdsch_vars_th)[th_id][eNB_id]->llr[1] = (int16_t *)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); + (*pdsch_vars_th)[th_id][eNB_id]->llr128_2ndstream = (int16_t **)malloc16_clear( sizeof(int16_t *) ); + (*pdsch_vars_th)[th_id][eNB_id]->rho = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t *) ); } - - for (int i=0; i<fp->nb_antennas_rx; i++){ + + for (int i=0; i<fp->nb_antennas_rx; i++) { for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id]->rho[i] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); + (*pdsch_vars_th)[th_id][eNB_id]->rho[i] = (int32_t *)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); } - } + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho2_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho2_ext = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); } - + for (i=0; i<fp->nb_antennas_rx; i++) for (j=0; j<4; j++) { - const int idx = (j<<1)+i; - const size_t num = 7*2*fp->N_RB_DL*12+4; - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho2_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - } - + const int idx = (j<<1)+i; + const size_t num = 7*2*fp->N_RB_DL*12+4; + + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho2_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); + } } - + //const size_t num = 7*2*fp->N_RB_DL*12+4; - for (k=0;k<8;k++) { //harq_pid - for (l=0;l<8;l++) { //round - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id]->rxdataF_comp1[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_mag1[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_magb1[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - } - - - for (int i=0; i<fp->nb_antennas_rx; i++) - for (int j=0; j<4; j++) { //frame_parms->nb_antennas_tx; j++) - const int idx = (j<<1)+i; - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); - (*pdsch_vars_th)[th_id][eNB_id]->rxdataF_comp1[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_mag1[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); - (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_magb1[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); - } - - } + for (k=0; k<8; k++) { //harq_pid + for (l=0; l<8; l++) { //round + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdsch_vars_th)[th_id][eNB_id]->rxdataF_comp1[k][l] = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[k][l] = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_mag1[k][l] = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_magb1[k][l] = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + } + + for (int i=0; i<fp->nb_antennas_rx; i++) + for (int j=0; j<4; j++) { //frame_parms->nb_antennas_tx; j++) + const int idx = (j<<1)+i; + + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[k][l][idx] = (int32_t *)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); + (*pdsch_vars_th)[th_id][eNB_id]->rxdataF_comp1[k][l][idx] = (int32_t *)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_mag1[k][l][idx] = (int32_t *)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); + (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_magb1[k][l][idx] = (int32_t *)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) ); + } + } } } + phy_init_lte_ue__PDSCH( pdsch_vars_SI[eNB_id], fp ); phy_init_lte_ue__PDSCH( pdsch_vars_ra[eNB_id], fp ); phy_init_lte_ue__PDSCH( pdsch_vars_p[eNB_id], fp ); phy_init_lte_ue__PDSCH( pdsch_vars_mch[eNB_id], fp ); - + // 100 PRBs * 12 REs/PRB * 4 PDCCH SYMBOLS * 2 LLRs/RE for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdcch_vars_th)[th_id][eNB_id]->llr = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); - (*pdcch_vars_th)[th_id][eNB_id]->llr16 = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); - (*pdcch_vars_th)[th_id][eNB_id]->wbar = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); - (*pdcch_vars_th)[th_id][eNB_id]->e_rx = (int8_t*)malloc16_clear( 4*2*100*12 ); - - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->rho = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); + (*pdcch_vars_th)[th_id][eNB_id]->llr = (uint16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); + (*pdcch_vars_th)[th_id][eNB_id]->llr16 = (uint16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); + (*pdcch_vars_th)[th_id][eNB_id]->wbar = (uint16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); + (*pdcch_vars_th)[th_id][eNB_id]->e_rx = (int8_t *)malloc16_clear( 4*2*100*12 ); + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + (*pdcch_vars_th)[th_id][eNB_id]->rho = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); } - + for (i=0; i<fp->nb_antennas_rx; i++) { //ue_pdcch_vars[eNB_id]->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->N_RB_DL*12*7*2) ); for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdcch_vars_th)[th_id][eNB_id]->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(100*12*4) ); + (*pdcch_vars_th)[th_id][eNB_id]->rho[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(100*12*4) ); } - + for (j=0; j<4; j++) { //fp->nb_antennas_tx; j++) - int idx = (j<<1)+i; - // size_t num = 7*2*fp->N_RB_DL*12; - size_t num = 4*100*12; // 4 symbols, 100 PRBs, 12 REs per PRB - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - } + int idx = (j<<1)+i; + // size_t num = 7*2*fp->N_RB_DL*12; + size_t num = 4*100*12; // 4 symbols, 100 PRBs, 12 REs per PRB + + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); + } } } + phy_init_lte_ue__PDSCH( pdsch_vars_SI[eNB_id], fp ); phy_init_lte_ue__PDSCH( pdsch_vars_ra[eNB_id], fp ); phy_init_lte_ue__PDSCH( pdsch_vars_p[eNB_id], fp ); phy_init_lte_ue__PDSCH( pdsch_vars_mch[eNB_id], fp ); - + // 100 PRBs * 12 REs/PRB * 4 PDCCH SYMBOLS * 2 LLRs/RE for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdcch_vars_th)[th_id][eNB_id]->llr = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); - (*pdcch_vars_th)[th_id][eNB_id]->llr16 = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); - (*pdcch_vars_th)[th_id][eNB_id]->wbar = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); - (*pdcch_vars_th)[th_id][eNB_id]->e_rx = (int8_t*)malloc16_clear( 4*2*100*12 ); - - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->rho = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - + (*pdcch_vars_th)[th_id][eNB_id]->llr = (uint16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); + (*pdcch_vars_th)[th_id][eNB_id]->llr16 = (uint16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); + (*pdcch_vars_th)[th_id][eNB_id]->wbar = (uint16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) ); + (*pdcch_vars_th)[th_id][eNB_id]->e_rx = (int8_t *)malloc16_clear( 4*2*100*12 ); + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + (*pdcch_vars_th)[th_id][eNB_id]->rho = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); (*pdcch_vars_th)[th_id][eNB_id]->dciFormat = 0; (*pdcch_vars_th)[th_id][eNB_id]->agregationLevel = 0xFF; } - + for (i=0; i<fp->nb_antennas_rx; i++) { //ue_pdcch_vars[eNB_id]->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->N_RB_DL*12*7*2) ); - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdcch_vars_th)[th_id][eNB_id]->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(100*12*4) ); + (*pdcch_vars_th)[th_id][eNB_id]->rho[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(100*12*4) ); } - + for (j=0; j<4; j++) { //fp->nb_antennas_tx; j++) - int idx = (j<<1)+i; - // size_t num = 7*2*fp->N_RB_DL*12; - size_t num = 4*100*12; // 4 symbols, 100 PRBs, 12 REs per PRB - for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num ); - } + int idx = (j<<1)+i; + // size_t num = 7*2*fp->N_RB_DL*12; + size_t num = 4*100*12; // 4 symbols, 100 PRBs, 12 REs per PRB + + for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); + (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); + (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num ); + } } } - + // PBCH - pbch_vars[eNB_id]->rxdataF_ext = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); - pbch_vars[eNB_id]->rxdataF_comp = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pbch_vars[eNB_id]->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) ); - pbch_vars[eNB_id]->llr = (int8_t*)malloc16_clear( 1920 ); - prach_vars[eNB_id]->prachF = (int16_t*)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); - prach_vars[eNB_id]->prach = (int16_t*)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); - + pbch_vars[eNB_id]->rxdataF_ext = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) ); + pbch_vars[eNB_id]->rxdataF_comp = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + pbch_vars[eNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 8*sizeof(int32_t *) ); + pbch_vars[eNB_id]->llr = (int8_t *)malloc16_clear( 1920 ); + prach_vars[eNB_id]->prachF = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); + prach_vars[eNB_id]->prach = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); + for (i=0; i<fp->nb_antennas_rx; i++) { - pbch_vars[eNB_id]->rxdataF_ext[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*6*12*4 ); - + pbch_vars[eNB_id]->rxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*6*12*4 ); + for (j=0; j<4; j++) {//fp->nb_antennas_tx;j++) { - int idx = (j<<1)+i; - pbch_vars[eNB_id]->rxdataF_comp[idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*6*12*4 ); - pbch_vars[eNB_id]->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*6*12*4 ); + int idx = (j<<1)+i; + pbch_vars[eNB_id]->rxdataF_comp[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*6*12*4 ); + pbch_vars[eNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*6*12*4 ); } } - - - pbch_vars[eNB_id]->decoded_output = (uint8_t*)malloc16_clear( 64 ); + + pbch_vars[eNB_id]->decoded_output = (uint8_t *)malloc16_clear( 64 ); } // initialization for the last instance of pdsch_vars (used for MU-MIMO) for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { - (*pdsch_vars_th)[th_id][eNB_id] = (LTE_UE_PDSCH *)malloc16_clear( sizeof(LTE_UE_PDSCH) ); + (*pdsch_vars_th)[th_id][eNB_id] = (LTE_UE_PDSCH *)malloc16_clear( sizeof(LTE_UE_PDSCH) ); } pdsch_vars_SI[eNB_id] = (LTE_UE_PDSCH *)malloc16_clear( sizeof(LTE_UE_PDSCH) ); @@ -922,13 +831,12 @@ int init_lte_ue_signal(PHY_VARS_UE *ue, for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) { phy_init_lte_ue__PDSCH( (*pdsch_vars_th)[th_id][eNB_id], fp ); - (*pdsch_vars_th)[th_id][eNB_id]->llr[1] = (int16_t*)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); + (*pdsch_vars_th)[th_id][eNB_id]->llr[1] = (int16_t *)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); } - - ue->sinr_CQI_dB = (double*) malloc16_clear( fp->N_RB_DL*12*sizeof(double) ); - + ue->sinr_CQI_dB = (double *) malloc16_clear( fp->N_RB_DL*12*sizeof(double) ); ue->init_averaging = 1; + // default value until overwritten by RRCConnectionReconfiguration if (fp->nb_antenna_ports_eNB==2) ue->pdsch_config_dedicated->p_a = dBm3; @@ -938,40 +846,30 @@ int init_lte_ue_signal(PHY_VARS_UE *ue, // set channel estimation to do linear interpolation in time ue->high_speed_flag = 1; ue->ch_est_alpha = 24576; - // enable MIB/SIB decoding by default ue->decode_MIB = 1; ue->decode_SIB = 1; - init_prach_tables(839); - - return 0; } void init_lte_ue_transport(PHY_VARS_UE *ue,int abstraction_flag) { - int i,j,k; for (i=0; i<NUMBER_OF_CONNECTED_eNB_MAX; i++) { for (j=0; j<2; j++) { for (k=0; k<2; k++) { - AssertFatal((ue->dlsch[k][i][j] = new_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_TURBO_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag))!=NULL,"Can't get ue dlsch structures\n"); - - LOG_D(PHY,"dlsch[%d][%d][%d] => %p\n",k,i,j,ue->dlsch[i][j]); + AssertFatal((ue->dlsch[k][i][j] = new_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_TURBO_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag))!=NULL,"Can't get ue dlsch structures\n"); + LOG_D(PHY,"dlsch[%d][%d][%d] => %p\n",k,i,j,ue->dlsch[i][j]); } } AssertFatal((ue->ulsch[i] = new_ue_ulsch(ue->frame_parms.N_RB_UL, abstraction_flag))!=NULL,"Can't get ue ulsch structures\n"); - ue->dlsch_SI[i] = new_ue_dlsch(1,1,NSOFT,MAX_TURBO_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag); ue->dlsch_ra[i] = new_ue_dlsch(1,1,NSOFT,MAX_TURBO_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag); - ue->transmission_mode[i] = ue->frame_parms.nb_antenna_ports_eNB==1 ? 1 : 2; } ue->frame_parms.pucch_config_common.deltaPUCCH_Shift = 1; - ue->dlsch_MCH[0] = new_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_TURBO_ITERATIONS_MBSFN,ue->frame_parms.N_RB_DL,0); - } \ No newline at end of file diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index 094f9722533968f5ebedb56f7a0520b44d87c0de..619760c869c9f60302aaff664ae1152dccd33b26 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -33,8 +33,7 @@ #include "PHY/defs_eNB.h" #include "PHY/LTE_TRANSPORT/transport_proto.h" #include "SCHED/sched_eNB.h" - -#include "nfapi_interface.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "nfapi_pnf_interface.h" #include "fapi_l1.h" @@ -43,42 +42,37 @@ int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req); int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req); int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req); -extern uint8_t nfapi_mode; - void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB, int frame, int subframe, L1_rxtx_proc_t *proc, - nfapi_dl_config_request_pdu_t *dl_config_pdu) -{ + nfapi_dl_config_request_pdu_t *dl_config_pdu) { int idx = subframe&1; LTE_eNB_PDCCH *pdcch_vars = &eNB->pdcch_vars[idx]; nfapi_dl_config_dci_dl_pdu *pdu = &dl_config_pdu->dci_dl_pdu; - if (nfapi_mode==2) return; - - LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populating pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",frame,subframe, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); + if (NFAPI_MODE==NFAPI_MODE_VNF) return; + LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populating pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",frame,subframe, pdcch_vars->num_dci, proc->subframe_tx, + idx, pdcch_vars->num_dci); // copy dci configuration into eNB structure fill_dci_and_dlsch(eNB,frame,subframe,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci],pdu); - - LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populated pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",proc->frame_tx,proc->subframe_tx, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); + LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populated pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",proc->frame_tx,proc->subframe_tx, pdcch_vars->num_dci, + proc->subframe_tx, idx, pdcch_vars->num_dci); } #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) void handle_nfapi_mpdcch_pdu(PHY_VARS_eNB *eNB, L1_rxtx_proc_t *proc, - nfapi_dl_config_request_pdu_t *dl_config_pdu) -{ + nfapi_dl_config_request_pdu_t *dl_config_pdu) { int idx = proc->subframe_tx&1; LTE_eNB_MPDCCH *mpdcch_vars = &eNB->mpdcch_vars[idx]; nfapi_dl_config_mpdcch_pdu *pdu = &dl_config_pdu->mpdcch_pdu; - if (nfapi_mode==2) return; + if (NFAPI_MODE==NFAPI_MODE_VNF) return; LOG_D(PHY,"Frame %d, Subframe %d: MDCI processing\n",proc->frame_tx,proc->subframe_tx); - // copy dci configuration into eNB structure fill_mdci_and_dlsch(eNB,proc,&mpdcch_vars->mdci_alloc[mpdcch_vars->num_dci],pdu); } @@ -86,15 +80,13 @@ void handle_nfapi_mpdcch_pdu(PHY_VARS_eNB *eNB, #endif void handle_nfapi_hi_dci0_dci_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc, - nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) -{ + nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) { int idx = subframe&1; LTE_eNB_PDCCH *pdcch_vars = &eNB->pdcch_vars[idx]; - if (nfapi_mode==2) return; + if (NFAPI_MODE==NFAPI_MODE_VNF) return; //LOG_D(PHY,"%s() SFN/SF:%04d%d Before num_dci:%d\n", __FUNCTION__,frame,subframe,pdcch_vars->num_dci); - // copy dci configuration in to eNB structure fill_dci0(eNB,frame,subframe,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci], &hi_dci0_config_pdu->dci_pdu); } @@ -102,11 +94,11 @@ void handle_nfapi_hi_dci0_dci_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rx void handle_nfapi_hi_dci0_mpdcch_dci_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, - nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) -{ + nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) { int idx = proc->subframe_tx&1; LTE_eNB_MPDCCH *pdcch_vars = &eNB->mpdcch_vars[idx]; - if (nfapi_mode==2) return; + + if (NFAPI_MODE==NFAPI_MODE_VNF) return; // copy dci configuration in to eNB structure fill_mpdcch_dci0(eNB,proc,&pdcch_vars->mdci_alloc[pdcch_vars->num_dci], &hi_dci0_config_pdu->mpdcch_dci_pdu); @@ -114,18 +106,16 @@ void handle_nfapi_hi_dci0_mpdcch_dci_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc, - nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) -{ + nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) { LTE_eNB_PHICH *phich = &eNB->phich_vars[subframe&1]; - if (nfapi_mode==2) return; + if (NFAPI_MODE==NFAPI_MODE_VNF) return; // copy dci configuration in to eNB structure LOG_D(PHY,"Received HI PDU with value %d (rbstart %d,cshift %d)\n", hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.hi_value, hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.resource_block_start, hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms); - // DJP - TODO FIXME - transmission power ignored phich->config[phich->num_hi].hi = hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.hi_value; phich->config[phich->num_hi].first_rb = hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.resource_block_start; @@ -136,38 +126,34 @@ void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxt void handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu, - uint8_t *sdu) -{ + uint8_t *sdu) { nfapi_dl_config_bch_pdu_rel8_t *rel8 = &dl_config_pdu->bch_pdu.bch_pdu_rel8; - if (nfapi_mode==2) return; + if (NFAPI_MODE==NFAPI_MODE_VNF) return; AssertFatal(rel8->length == 3, "BCH PDU has length %d != 3\n",rel8->length); - //LOG_D(PHY,"bch_pdu: %x,%x,%x\n",sdu[0],sdu[1],sdu[2]); eNB->pbch_pdu[0] = sdu[2]; eNB->pbch_pdu[1] = sdu[1]; eNB->pbch_pdu[2] = sdu[0]; - // adjust transmit amplitude here based on NFAPI info } #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) -extern uint32_t localRIV2alloc_LUT6[32]; -extern uint32_t localRIV2alloc_LUT25[512]; -extern uint32_t localRIV2alloc_LUT50_0[1600]; -extern uint32_t localRIV2alloc_LUT50_1[1600]; -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 localRIV2alloc_LUT6[32]; + extern uint32_t localRIV2alloc_LUT25[512]; + extern uint32_t localRIV2alloc_LUT50_0[1600]; + extern uint32_t localRIV2alloc_LUT50_1[1600]; + 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]; #endif void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu, uint8_t codeword_index, - uint8_t *sdu) -{ + uint8_t *sdu) { nfapi_dl_config_dlsch_pdu_rel8_t *rel8 = &dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8; #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) nfapi_dl_config_dlsch_pdu_rel10_t *rel10 = &dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10; @@ -180,58 +166,62 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro int UE_id; int harq_pid; - if (nfapi_mode==2) return; + if (NFAPI_MODE==NFAPI_MODE_VNF) return; UE_id = find_dlsch(rel8->rnti,eNB,SEARCH_EXIST_OR_FREE); - if( (UE_id<0) || (UE_id>=NUMBER_OF_UE_MAX) ){ + + if( (UE_id<0) || (UE_id>=NUMBER_OF_UE_MAX) ) { LOG_E(PHY,"illegal UE_id found!!! rnti %04x UE_id %d\n",rel8->rnti,UE_id); return; } + //AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n"); //AssertFatal(UE_id<NUMBER_OF_UE_MAX,"returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); - dlsch0 = eNB->dlsch[UE_id][0]; dlsch1 = eNB->dlsch[UE_id][1]; - #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) + if ((rel13->pdsch_payload_type < 2) && (rel13->ue_type>0)) dlsch0->harq_ids[proc->frame_tx%2][proc->subframe_tx] = 0; -#endif +#endif harq_pid = dlsch0->harq_ids[proc->frame_tx%2][proc->subframe_tx]; AssertFatal((harq_pid>=0) && (harq_pid<8),"harq_pid %d not in 0...7 frame:%d subframe:%d subframe(TX):%d rnti:%x UE_id:%d dlsch0[harq_ids:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d]\n", - harq_pid, - frame,subframe, - proc->subframe_tx,rel8->rnti,UE_id, - dlsch0->harq_ids[proc->frame_tx%2][0], - dlsch0->harq_ids[proc->frame_tx%2][1], - dlsch0->harq_ids[proc->frame_tx%2][2], - dlsch0->harq_ids[proc->frame_tx%2][3], - dlsch0->harq_ids[proc->frame_tx%2][4], - dlsch0->harq_ids[proc->frame_tx%2][5], - dlsch0->harq_ids[proc->frame_tx%2][6], - dlsch0->harq_ids[proc->frame_tx%2][7], - dlsch0->harq_ids[proc->frame_tx%2][8], - dlsch0->harq_ids[proc->frame_tx%2][9] - ); + harq_pid, + frame,subframe, + proc->subframe_tx,rel8->rnti,UE_id, + dlsch0->harq_ids[proc->frame_tx%2][0], + dlsch0->harq_ids[proc->frame_tx%2][1], + dlsch0->harq_ids[proc->frame_tx%2][2], + dlsch0->harq_ids[proc->frame_tx%2][3], + dlsch0->harq_ids[proc->frame_tx%2][4], + dlsch0->harq_ids[proc->frame_tx%2][5], + dlsch0->harq_ids[proc->frame_tx%2][6], + dlsch0->harq_ids[proc->frame_tx%2][7], + dlsch0->harq_ids[proc->frame_tx%2][8], + dlsch0->harq_ids[proc->frame_tx%2][9] + ); dlsch0_harq = dlsch0->harq_processes[harq_pid]; dlsch1_harq = dlsch1->harq_processes[harq_pid]; AssertFatal(dlsch0_harq!=NULL,"dlsch_harq is null\n"); - // compute DL power control parameters eNB->pdsch_config_dedicated[UE_id].p_a = rel8->pa; +#ifdef PHY_TX_THREAD -#ifdef PHY_TX_THREAD - if (dlsch0->active[proc->subframe_tx]){ + if (dlsch0->active[proc->subframe_tx]) { # else - if (dlsch0->active){ + + if (dlsch0->active) { #endif computeRhoA_eNB(rel8->pa, dlsch0,dlsch0_harq->dl_power_off, eNB->frame_parms.nb_antenna_ports_eNB); computeRhoB_eNB(rel8->pa,eNB->frame_parms.pdsch_config_common.p_b,eNB->frame_parms.nb_antenna_ports_eNB,dlsch0,dlsch0_harq->dl_power_off); } + #ifdef PHY_TX_THREAD - if (dlsch1->active[proc->subframe_tx]){ + + if (dlsch1->active[proc->subframe_tx]) { #else - if (dlsch1->active){ + + if (dlsch1->active) { #endif computeRhoA_eNB(rel8->pa, dlsch1,dlsch1_harq->dl_power_off, eNB->frame_parms.nb_antenna_ports_eNB); computeRhoB_eNB(rel8->pa,eNB->frame_parms.pdsch_config_common.p_b,eNB->frame_parms.nb_antenna_ports_eNB,dlsch1,dlsch1_harq->dl_power_off); @@ -241,25 +231,27 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro if (dlsch0_harq->round==0) { //get pointer to SDU if this a new SDU if(sdu == NULL) { - LOG_E(PHY,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d dlsch0_harq[round:%d SFN/SF:%d%d pdu:%p mcs:%d ndi:%d pdschstart:%d]\n", + LOG_E(PHY, + "NFAPI: SFN/SF:%04d%d proc:TX:[frame %d subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d dlsch0_harq[round:%d SFN/SF:%d%d pdu:%p mcs:%d ndi:%d pdschstart:%d]\n", frame,subframe, proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid, dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index,dlsch0_harq->round,dlsch0_harq->frame,dlsch0_harq->subframe,dlsch0_harq->pdu,dlsch0_harq->mcs,dlsch0_harq->ndi,dlsch0_harq->pdsch_start); return; } + //AssertFatal(sdu!=NULL,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d dlsch0_harq[round:%d SFN/SF:%d%d pdu:%p mcs:%d ndi:%d pdschstart:%d]\n", // frame,subframe, // proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid, // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index,dlsch0_harq->round,dlsch0_harq->frame,dlsch0_harq->subframe,dlsch0_harq->pdu,dlsch0_harq->mcs,dlsch0_harq->ndi,dlsch0_harq->pdsch_start); if (rel8->rnti != 0xFFFF) LOG_D(PHY,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d, subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d\n", - frame,subframe,proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid); + frame,subframe,proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid); + if (codeword_index == 0) dlsch0_harq->pdu = sdu; else dlsch1_harq->pdu = sdu; - } - else { + } else { if (rel8->rnti != 0xFFFF) LOG_D(PHY,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d, subframe %d]: programming dlsch for round %d, rnti %x, UE_id %d, harq_pid %d\n", - frame,subframe,proc->frame_tx,proc->subframe_tx,dlsch0_harq->round, - rel8->rnti,UE_id,harq_pid); + frame,subframe,proc->frame_tx,proc->subframe_tx,dlsch0_harq->round, + rel8->rnti,UE_id,harq_pid); } #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) @@ -273,55 +265,60 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro UE_id = find_dlsch(rel8->rnti,eNB,SEARCH_EXIST_OR_FREE); AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n"); AssertFatal(UE_id<NUMBER_OF_UE_MAX,"returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); - dlsch0 = eNB->dlsch[UE_id][0]; - dlsch0->harq_mask = 1; + dlsch0->harq_mask = 1; dlsch0_harq = dlsch0->harq_processes[0]; dlsch0_harq->pdu = sdu; if (proc->frame_tx < 200) LOG_D(PHY,"NFAPI: frame %d, subframe %d (TX %d.%d): Programming SI-BR (%d) => %d\n",frame,subframe,proc->frame_tx,proc->subframe_tx,rel13->pdsch_payload_type,UE_id); - + dlsch0->rnti = 0xFFFF; dlsch0->Kmimo = 1; dlsch0->Mdlharq = 4; dlsch0->Nsoft = 25344; - dlsch0->i0 = rel13->initial_transmission_sf_io; dlsch0_harq->pdsch_start = rel10->pdsch_start; dlsch0->harq_ids[proc->frame_tx%2][proc->subframe_rx] = 0; dlsch0_harq->frame = proc->frame_tx; dlsch0_harq->subframe = proc->subframe_tx; - - #ifdef PHY_TX_THREAD + if (rel13->pdsch_payload_type == 0) dlsch0_harq->sib1_br_flag=1; + #else + if (rel13->pdsch_payload_type == 0) dlsch0->sib1_br_flag=1; + #endif - // configure PDSCH + // configure PDSCH switch (eNB->frame_parms.N_RB_DL) { - case 6: - dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT6[rel8->resource_block_coding]; - break; - case 15: - AssertFatal(1==0,"15 PRBs not supported for now\n"); - break; - case 25: - dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT25[rel8->resource_block_coding]; - break; - case 50: - dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT50_0[rel8->resource_block_coding]; - dlsch0_harq->rb_alloc[1] = localRIV2alloc_LUT50_1[rel8->resource_block_coding]; - break; - case 75: - AssertFatal(1==0,"75 PRBs not supported for now\n"); - break; - case 100: - dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT100_0[rel8->resource_block_coding]; - dlsch0_harq->rb_alloc[1] = localRIV2alloc_LUT100_1[rel8->resource_block_coding]; - dlsch0_harq->rb_alloc[2] = localRIV2alloc_LUT100_2[rel8->resource_block_coding]; - dlsch0_harq->rb_alloc[3] = localRIV2alloc_LUT100_3[rel8->resource_block_coding]; + case 6: + dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT6[rel8->resource_block_coding]; + break; + + case 15: + AssertFatal(1==0,"15 PRBs not supported for now\n"); + break; + + case 25: + dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT25[rel8->resource_block_coding]; + break; + + case 50: + dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT50_0[rel8->resource_block_coding]; + dlsch0_harq->rb_alloc[1] = localRIV2alloc_LUT50_1[rel8->resource_block_coding]; + break; + + case 75: + AssertFatal(1==0,"75 PRBs not supported for now\n"); + break; + + case 100: + dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT100_0[rel8->resource_block_coding]; + dlsch0_harq->rb_alloc[1] = localRIV2alloc_LUT100_1[rel8->resource_block_coding]; + dlsch0_harq->rb_alloc[2] = localRIV2alloc_LUT100_2[rel8->resource_block_coding]; + dlsch0_harq->rb_alloc[3] = localRIV2alloc_LUT100_3[rel8->resource_block_coding]; } #ifdef PHY_TX_THREAD @@ -329,7 +326,6 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro #else dlsch0->active = 1; #endif - dlsch0_harq->nb_rb = 6; dlsch0_harq->vrb_type = LOCALIZED; dlsch0_harq->rvidx = rel8->redundancy_version; @@ -342,61 +338,58 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro dlsch0_harq->Qm = rel8->modulation; dlsch0_harq->codeword = 0; dlsch0_harq->pdsch_start = rel10->pdsch_start; - } - else + } else #endif - { + { UE_id = find_dlsch(rel8->rnti,eNB,SEARCH_EXIST_OR_FREE); AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n"); AssertFatal(UE_id<NUMBER_OF_UE_MAX,"returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); - dlsch0 = eNB->dlsch[UE_id][0]; dlsch1 = eNB->dlsch[UE_id][1]; - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) dlsch0->sib1_br_flag=0; dlsch0->i0 = 0xFFFF; #endif - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - LOG_D(PHY,"dlsch->i0:%04x dlsch0_harq[pdsch_start:%d nb_rb:%d vrb_type:%d rvidx:%d Nl:%d mimo_mode:%d dl_power_off:%d round:%d status:%d TBS:%d Qm:%d codeword:%d rb_alloc:%d] rel8[length:%d]\n", + LOG_D(PHY,"dlsch->i0:%04x dlsch0_harq[pdsch_start:%d nb_rb:%d vrb_type:%d rvidx:%d Nl:%d mimo_mode:%d dl_power_off:%d round:%d status:%d TBS:%d Qm:%d codeword:%d rb_alloc:%d] rel8[length:%d]\n", #ifdef PHY_TX_THREAD - dlsch0_harq->i0, + dlsch0_harq->i0, #else - dlsch0->i0, + dlsch0->i0, #endif - dlsch0_harq->pdsch_start, dlsch0_harq->nb_rb, dlsch0_harq->vrb_type, dlsch0_harq->rvidx, dlsch0_harq->Nl, dlsch0_harq->mimo_mode, dlsch0_harq->dl_power_off, dlsch0_harq->round, dlsch0_harq->status, dlsch0_harq->TBS, dlsch0_harq->Qm, dlsch0_harq->codeword, dlsch0_harq->rb_alloc[0], - rel8->length - ); + dlsch0_harq->pdsch_start, dlsch0_harq->nb_rb, dlsch0_harq->vrb_type, dlsch0_harq->rvidx, dlsch0_harq->Nl, dlsch0_harq->mimo_mode, dlsch0_harq->dl_power_off, dlsch0_harq->round, dlsch0_harq->status, + dlsch0_harq->TBS, dlsch0_harq->Qm, dlsch0_harq->codeword, dlsch0_harq->rb_alloc[0], + rel8->length + ); #else - LOG_D(PHY,"dlsch0_harq[pdsch_start:%d nb_rb:%d vrb_type:%d rvidx:%d Nl:%d mimo_mode:%d dl_power_off:%d round:%d status:%d TBS:%d Qm:%d codeword:%d rb_alloc:%d] rel8[length:%d]\n", - dlsch0_harq->pdsch_start, dlsch0_harq->nb_rb, dlsch0_harq->vrb_type, dlsch0_harq->rvidx, dlsch0_harq->Nl, dlsch0_harq->mimo_mode, dlsch0_harq->dl_power_off, dlsch0_harq->round, dlsch0_harq->status, dlsch0_harq->TBS, dlsch0_harq->Qm, dlsch0_harq->codeword, dlsch0_harq->rb_alloc[0], - rel8->length - ); + LOG_D(PHY,"dlsch0_harq[pdsch_start:%d nb_rb:%d vrb_type:%d rvidx:%d Nl:%d mimo_mode:%d dl_power_off:%d round:%d status:%d TBS:%d Qm:%d codeword:%d rb_alloc:%d] rel8[length:%d]\n", + dlsch0_harq->pdsch_start, dlsch0_harq->nb_rb, dlsch0_harq->vrb_type, dlsch0_harq->rvidx, dlsch0_harq->Nl, dlsch0_harq->mimo_mode, dlsch0_harq->dl_power_off, dlsch0_harq->round, dlsch0_harq->status, + dlsch0_harq->TBS, dlsch0_harq->Qm, dlsch0_harq->codeword, dlsch0_harq->rb_alloc[0], + rel8->length + ); #endif - dlsch0->active = 1; harq_pid = dlsch0->harq_ids[frame%2][proc->subframe_tx]; dlsch0->harq_mask |= (1<<harq_pid); - AssertFatal((harq_pid>=0) && (harq_pid<8),"subframe %d: harq_pid %d not in 0...7\n",proc->subframe_tx,harq_pid); dlsch0_harq = dlsch0->harq_processes[harq_pid]; dlsch1_harq = dlsch1->harq_processes[harq_pid]; AssertFatal(dlsch0_harq!=NULL,"dlsch_harq is null\n"); - // compute DL power control parameters + // compute DL power control parameters - - if (dlsch0->active){ + if (dlsch0->active) { computeRhoA_eNB(rel8->pa,dlsch0,dlsch0_harq->dl_power_off, eNB->frame_parms.nb_antenna_ports_eNB); computeRhoB_eNB(rel8->pa,eNB->frame_parms.pdsch_config_common.p_b,eNB->frame_parms.nb_antenna_ports_eNB,dlsch0,dlsch0_harq->dl_power_off); - } - if (dlsch1->active){ + } + + if (dlsch1->active) { computeRhoA_eNB(rel8->pa, dlsch1,dlsch1_harq->dl_power_off, eNB->frame_parms.nb_antenna_ports_eNB); computeRhoB_eNB(rel8->pa,eNB->frame_parms.pdsch_config_common.p_b,eNB->frame_parms.nb_antenna_ports_eNB,dlsch1,dlsch1_harq->dl_power_off); } #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + if (rel13->ue_type>0) dlsch0_harq->pdsch_start = rel10->pdsch_start; else @@ -407,36 +400,34 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro AssertFatal(sdu!=NULL,"NFAPI: frame %d, subframe %d: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d\n", proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid, dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index); + if (rel8->rnti != 0xFFFF) LOG_D(PHY,"NFAPI: frame %d, subframe %d: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d\n", - proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid); + proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid); + if (codeword_index == 0) dlsch0_harq->pdu = sdu; else dlsch1_harq->pdu = sdu; - } - else { + } else { if (rel8->rnti != 0xFFFF) LOG_D(PHY,"NFAPI: frame %d, subframe %d: programming dlsch for round %d, rnti %x, UE_id %d, harq_pid %d\n", - proc->frame_tx,proc->subframe_tx,dlsch0_harq->round, - rel8->rnti,UE_id,harq_pid); + proc->frame_tx,proc->subframe_tx,dlsch0_harq->round, + rel8->rnti,UE_id,harq_pid); } - } } -int16_t to_beta_offset_harqack[16]={16,20,25,32,40,50,64,80,101,127,160,248,400,640,1008,8}; +int16_t to_beta_offset_harqack[16]= {16,20,25,32,40,50,64,80,101,127,160,248,400,640,1008,8}; void handle_ulsch_harq_pdu( - PHY_VARS_eNB *eNB, - int UE_id, - nfapi_ul_config_request_pdu_t *ul_config_pdu, - nfapi_ul_config_ulsch_harq_information *harq_information, - uint16_t frame, - uint8_t subframe) -{ + PHY_VARS_eNB *eNB, + int UE_id, + nfapi_ul_config_request_pdu_t *ul_config_pdu, + nfapi_ul_config_ulsch_harq_information *harq_information, + uint16_t frame, + uint8_t subframe) { nfapi_ul_config_ulsch_pdu_rel8_t *rel8 = &ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8; - LTE_eNB_ULSCH_t *ulsch=eNB->ulsch[UE_id]; LTE_UL_eNB_HARQ_t *ulsch_harq; - if (nfapi_mode==2) return; + if (NFAPI_MODE==NFAPI_MODE_VNF) return; int harq_pid = rel8->harq_process_number; ulsch_harq = ulsch->harq_processes[harq_pid]; @@ -444,30 +435,31 @@ void handle_ulsch_harq_pdu( ulsch_harq->subframe = subframe; ulsch_harq->O_ACK = harq_information->harq_information_rel10.harq_size; ulsch->beta_offset_harqack_times8 = to_beta_offset_harqack[harq_information->harq_information_rel10.delta_offset_harq]; + if (eNB->frame_parms.frame_type == TDD) { if (harq_information->harq_information_rel10.ack_nack_mode==0) //bundling - ulsch->bundling = 1; - } + ulsch->bundling = 1; + } } -uint16_t to_beta_offset_ri[16]={9,13,16,20,25,32,40,50,64,80,101,127,160,0,0,0}; -uint16_t to_beta_offset_cqi[16]={0,0,9,10,11,13,14,16,18,20,23,25,28,32,40,50}; +uint16_t to_beta_offset_ri[16]= {9,13,16,20,25,32,40,50,64,80,101,127,160,0,0,0}; +uint16_t to_beta_offset_cqi[16]= {0,0,9,10,11,13,14,16,18,20,23,25,28,32,40,50}; -void handle_ulsch_cqi_ri_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu_t *ul_config_pdu,uint16_t frame,uint8_t subframe) -{ +void handle_ulsch_cqi_ri_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu_t *ul_config_pdu,uint16_t frame,uint8_t subframe) { nfapi_ul_config_cqi_ri_information_rel9_t *rel9 = &ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9; - LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id]; int harq_pid = ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number; LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid]; - if (nfapi_mode==2) return; + if (NFAPI_MODE==NFAPI_MODE_VNF) return; ulsch_harq->frame = frame; ulsch_harq->subframe = subframe; ulsch_harq->O_RI = rel9->aperiodic_cqi_pmi_ri_report.cc[0].ri_size; ulsch_harq->Or1 = rel9->aperiodic_cqi_pmi_ri_report.cc[0].dl_cqi_pmi_size[0]; + if (ulsch_harq->O_RI>1) ulsch_harq->Or2 = rel9->aperiodic_cqi_pmi_ri_report.cc[0].dl_cqi_pmi_size[1]; + ulsch->beta_offset_ri_times8 = to_beta_offset_ri[rel9->delta_offset_ri]; ulsch->beta_offset_cqi_times8 = to_beta_offset_cqi[rel9->delta_offset_cqi]; LOG_D(PHY,"Filling ulsch_cqi_ri information for frame %d, subframe %d : O_RI %d, Or1 %d, beta_offset_cqi_times8 %d (%d)\n", @@ -475,16 +467,14 @@ void handle_ulsch_cqi_ri_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request rel9->delta_offset_cqi); } -void handle_ulsch_cqi_harq_ri_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu_t *ul_config_pdu,uint16_t frame,uint8_t subframe) -{ +void handle_ulsch_cqi_harq_ri_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu_t *ul_config_pdu,uint16_t frame,uint8_t subframe) { nfapi_ul_config_cqi_ri_information_rel9_t *rel9 = &ul_config_pdu->ulsch_cqi_harq_ri_pdu.cqi_ri_information.cqi_ri_information_rel9; - LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id]; int harq_pid = ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number; LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid]; nfapi_ul_config_ulsch_harq_information *harq_information = &ul_config_pdu->ulsch_cqi_harq_ri_pdu.harq_information; - if (nfapi_mode==2) return; + if (NFAPI_MODE==NFAPI_MODE_VNF) return; ulsch_harq->frame = frame; ulsch_harq->subframe = subframe; @@ -499,14 +489,11 @@ void handle_ulsch_cqi_harq_ri_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_re ulsch->beta_offset_cqi_times8 = to_beta_offset_cqi[rel9->delta_offset_cqi]; } -void handle_uci_harq_information(PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci,nfapi_ul_config_harq_information *harq_information) -{ - - if (nfapi_mode==2) return; +void handle_uci_harq_information(PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci,nfapi_ul_config_harq_information *harq_information) { + if (NFAPI_MODE==NFAPI_MODE_VNF) return; if (eNB->frame_parms.frame_type == FDD) { uci->num_pucch_resources = harq_information->harq_information_rel9_fdd.number_of_pucch_resources; - LOG_D(PHY,"Programming UCI HARQ mode %d : size %d in (%d,%d)\n", harq_information->harq_information_rel9_fdd.ack_nack_mode, harq_information->harq_information_rel9_fdd.harq_size, @@ -517,23 +504,20 @@ void handle_uci_harq_information(PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci,nfapi_ul_co uci->pucch_fmt = pucch_format1a; uci->n_pucch_1[0][0] = harq_information->harq_information_rel9_fdd.n_pucch_1_0; uci->n_pucch_1[0][1] = harq_information->harq_information_rel11.n_pucch_2_0; - } - else if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 0) && - (harq_information->harq_information_rel9_fdd.harq_size == 2)) { + } else if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 0) && + (harq_information->harq_information_rel9_fdd.harq_size == 2)) { uci->pucch_fmt = pucch_format1b; uci->n_pucch_1[0][0] = harq_information->harq_information_rel9_fdd.n_pucch_1_0; uci->n_pucch_1[0][1] = harq_information->harq_information_rel11.n_pucch_2_0; - } - else if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 1) && - (harq_information->harq_information_rel9_fdd.harq_size == 2)) { + } else if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 1) && + (harq_information->harq_information_rel9_fdd.harq_size == 2)) { uci->pucch_fmt = pucch_format1b_csA2; uci->n_pucch_1[0][0] = harq_information->harq_information_rel9_fdd.n_pucch_1_0; uci->n_pucch_1[0][1] = harq_information->harq_information_rel11.n_pucch_2_0; uci->n_pucch_1[1][0] = harq_information->harq_information_rel9_fdd.n_pucch_1_1; uci->n_pucch_1[1][1] = harq_information->harq_information_rel11.n_pucch_2_1; - } - else if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 1) && - (harq_information->harq_information_rel9_fdd.harq_size == 3)) { + } else if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 1) && + (harq_information->harq_information_rel9_fdd.harq_size == 3)) { uci->pucch_fmt = pucch_format1b_csA3; uci->n_pucch_1[0][0] = harq_information->harq_information_rel9_fdd.n_pucch_1_0; uci->n_pucch_1[0][1] = harq_information->harq_information_rel11.n_pucch_2_0; @@ -541,9 +525,8 @@ void handle_uci_harq_information(PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci,nfapi_ul_co uci->n_pucch_1[1][1] = harq_information->harq_information_rel11.n_pucch_2_1; uci->n_pucch_1[2][0] = harq_information->harq_information_rel9_fdd.n_pucch_1_2; uci->n_pucch_1[2][1] = harq_information->harq_information_rel11.n_pucch_2_2; - } - else if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 1) && - (harq_information->harq_information_rel9_fdd.harq_size == 4)) { + } else if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 1) && + (harq_information->harq_information_rel9_fdd.harq_size == 4)) { uci->pucch_fmt = pucch_format1b_csA4; uci->n_pucch_1[0][0] = harq_information->harq_information_rel9_fdd.n_pucch_1_0; uci->n_pucch_1[0][1] = harq_information->harq_information_rel11.n_pucch_2_0; @@ -551,33 +534,27 @@ void handle_uci_harq_information(PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci,nfapi_ul_co uci->n_pucch_1[1][1] = harq_information->harq_information_rel11.n_pucch_2_1; uci->n_pucch_1[2][0] = harq_information->harq_information_rel9_fdd.n_pucch_1_2; uci->n_pucch_1[2][1] = harq_information->harq_information_rel11.n_pucch_2_2; - } - else if (harq_information->harq_information_rel9_fdd.ack_nack_mode == 2) { + } else if (harq_information->harq_information_rel9_fdd.ack_nack_mode == 2) { uci->pucch_fmt = pucch_format3; uci->n_pucch_3[0] = harq_information->harq_information_rel9_fdd.n_pucch_1_0; uci->n_pucch_3[1] = harq_information->harq_information_rel11.n_pucch_2_0; - } - else AssertFatal(1==0,"unsupported FDD HARQ mode %d size %d\n",harq_information->harq_information_rel9_fdd.ack_nack_mode,harq_information->harq_information_rel9_fdd.harq_size); - } - else { // TDD + } else AssertFatal(1==0,"unsupported FDD HARQ mode %d size %d\n",harq_information->harq_information_rel9_fdd.ack_nack_mode,harq_information->harq_information_rel9_fdd.harq_size); + } else { // TDD uci->num_pucch_resources = harq_information->harq_information_rel10_tdd.number_of_pucch_resources; if (harq_information->harq_information_rel10_tdd.ack_nack_mode == 0) {//bundling - uci->pucch_fmt = harq_information->harq_information_rel10_tdd.harq_size==1 ? pucch_format1a : pucch_format1b; uci->tdd_bundling = 1; uci->n_pucch_1[0][0] = harq_information->harq_information_rel10_tdd.n_pucch_1_0; uci->n_pucch_1[0][1] = harq_information->harq_information_rel11.n_pucch_2_0; - } - else if ((harq_information->harq_information_rel10_tdd.ack_nack_mode == 1) && //multiplexing - (uci->num_pucch_resources == 1)) { + } else if ((harq_information->harq_information_rel10_tdd.ack_nack_mode == 1) && //multiplexing + (uci->num_pucch_resources == 1)) { uci->pucch_fmt = harq_information->harq_information_rel10_tdd.harq_size==1 ? pucch_format1a : pucch_format1b; uci->tdd_bundling = 0; uci->n_pucch_1[0][0] = harq_information->harq_information_rel10_tdd.n_pucch_1_0; uci->n_pucch_1[0][1] = harq_information->harq_information_rel11.n_pucch_2_0; - } - else if ((harq_information->harq_information_rel10_tdd.ack_nack_mode == 1) && //multiplexing M>1 - (uci->num_pucch_resources > 1)) { + } else if ((harq_information->harq_information_rel10_tdd.ack_nack_mode == 1) && //multiplexing M>1 + (uci->num_pucch_resources > 1)) { uci->pucch_fmt = pucch_format1b; uci->tdd_bundling = 0; uci->n_pucch_1[0][0] = harq_information->harq_information_rel10_tdd.n_pucch_1_0; @@ -588,21 +565,18 @@ void handle_uci_harq_information(PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci,nfapi_ul_co uci->n_pucch_1[2][1] = harq_information->harq_information_rel11.n_pucch_2_2; uci->n_pucch_1[3][0] = harq_information->harq_information_rel10_tdd.n_pucch_1_3; uci->n_pucch_1[3][1] = harq_information->harq_information_rel11.n_pucch_2_3; - } - else if (harq_information->harq_information_rel10_tdd.ack_nack_mode == 2) { + } else if (harq_information->harq_information_rel10_tdd.ack_nack_mode == 2) { uci->pucch_fmt = pucch_format3; uci->n_pucch_3[0] = harq_information->harq_information_rel10_tdd.n_pucch_1_0; uci->n_pucch_3[1] = harq_information->harq_information_rel11.n_pucch_2_0; - } - else AssertFatal(1==0,"unsupported HARQ mode %d\n",harq_information->harq_information_rel10_tdd.ack_nack_mode); + } else AssertFatal(1==0,"unsupported HARQ mode %d\n",harq_information->harq_information_rel10_tdd.ack_nack_mode); } } -void handle_uci_sr_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu_t *ul_config_pdu,uint16_t frame,uint8_t subframe,uint8_t srs_active) -{ +void handle_uci_sr_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu_t *ul_config_pdu,uint16_t frame,uint8_t subframe,uint8_t srs_active) { LTE_eNB_UCI *uci = &eNB->uci_vars[UE_id]; - if (nfapi_mode==2) return; + if (NFAPI_MODE==NFAPI_MODE_VNF) return; uci->frame = frame; uci->subframe = subframe; @@ -623,11 +597,10 @@ void handle_uci_sr_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu_t uci->rnti,uci->n_pucch_1_0_sr[0],frame,subframe); } -void handle_uci_sr_harq_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu_t *ul_config_pdu,uint16_t frame,uint8_t subframe,uint8_t srs_active) -{ +void handle_uci_sr_harq_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu_t *ul_config_pdu,uint16_t frame,uint8_t subframe,uint8_t srs_active) { LTE_eNB_UCI *uci = &eNB->uci_vars[UE_id]; - if (nfapi_mode==2) return; + if (NFAPI_MODE==NFAPI_MODE_VNF) return; uci->frame = frame; uci->subframe = subframe; @@ -646,11 +619,10 @@ void handle_uci_sr_harq_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_ handle_uci_harq_information(eNB,uci,&ul_config_pdu->uci_sr_harq_pdu.harq_information); } -void handle_uci_harq_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu_t *ul_config_pdu,uint16_t frame,uint8_t subframe,uint8_t srs_active) -{ +void handle_uci_harq_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu_t *ul_config_pdu,uint16_t frame,uint8_t subframe,uint8_t srs_active) { LTE_eNB_UCI *uci = &eNB->uci_vars[UE_id]; - if (nfapi_mode==2) return; + if (NFAPI_MODE==NFAPI_MODE_VNF) return; LOG_D(PHY,"Frame %d, Subframe %d: Programming UCI_HARQ process (type %d)\n",frame,subframe,HARQ); uci->frame = frame; @@ -665,18 +637,15 @@ void handle_uci_harq_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu uci->total_repetitions = ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.total_number_of_repetitions; #endif handle_uci_harq_information(eNB,uci,&ul_config_pdu->uci_harq_pdu.harq_information); - uci->active=1; } -void handle_srs_pdu(PHY_VARS_eNB *eNB,nfapi_ul_config_request_pdu_t *ul_config_pdu,uint16_t frame,uint8_t subframe) -{ +void handle_srs_pdu(PHY_VARS_eNB *eNB,nfapi_ul_config_request_pdu_t *ul_config_pdu,uint16_t frame,uint8_t subframe) { int i; - if (nfapi_mode==2) return; - - for (i=0;i<NUMBER_OF_UE_MAX;i++) { + if (NFAPI_MODE==NFAPI_MODE_VNF) return; + for (i=0; i<NUMBER_OF_UE_MAX; i++) { if (eNB->soundingrs_ul_config_dedicated[i].active==1) continue; eNB->soundingrs_ul_config_dedicated[i].active = 1; @@ -691,94 +660,77 @@ void handle_srs_pdu(PHY_VARS_eNB *eNB,nfapi_ul_config_request_pdu_t *ul_config_p eNB->soundingrs_ul_config_dedicated[i].cyclicShift = ul_config_pdu->srs_pdu.srs_pdu_rel8.sounding_reference_cyclic_shift; break; } + AssertFatal(i<NUMBER_OF_UE_MAX,"No room for SRS processing\n"); } void handle_nfapi_ul_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, nfapi_ul_config_request_pdu_t *ul_config_pdu, - uint16_t frame,uint8_t subframe,uint8_t srs_present) -{ + uint16_t frame,uint8_t subframe,uint8_t srs_present) { nfapi_ul_config_ulsch_pdu_rel8_t *rel8 = &ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8; int16_t UE_id; - if (nfapi_mode==2) return; + if (NFAPI_MODE==NFAPI_MODE_VNF) return; // check if we have received a dci for this ue and ulsch descriptor is configured if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) { //if (UE_id == find_ulsch(ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE)<0) - //for (int i=0;i<16;i++) if (eNB->ulsch[i]->harq_mask>0) LOG_I(PHY,"rnti %x, mask %x\n",eNB->ulsch[i]->rnti,eNB->ulsch[i]->harq_mask >0); + //for (int i=0;i<16;i++) if (eNB->ulsch[i]->harq_mask>0) LOG_I(PHY,"rnti %x, mask %x\n",eNB->ulsch[i]->rnti,eNB->ulsch[i]->harq_mask >0); AssertFatal((UE_id = find_ulsch(ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE))>=0, "No existing UE ULSCH for rnti %x\n",rel8->rnti); - LOG_D(PHY,"Applying UL config for UE %d, rnti %x for frame %d, subframe %d, modulation %d, rvidx %d, first_rb %d, nb_rb %d\n", UE_id,rel8->rnti,frame,subframe,rel8->modulation_type,rel8->redundancy_version, -rel8->resource_block_start,rel8->number_of_resource_blocks); - + LOG_D(PHY,"Applying UL config for UE %d, rnti %x for frame %d, subframe %d, modulation %d, rvidx %d, first_rb %d, nb_rb %d\n", UE_id,rel8->rnti,frame,subframe,rel8->modulation_type, + rel8->redundancy_version, + rel8->resource_block_start,rel8->number_of_resource_blocks); fill_ulsch(eNB,UE_id,&ul_config_pdu->ulsch_pdu,frame,subframe); - - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE) { + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE) { AssertFatal((UE_id = find_ulsch(ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE))>=0, "No available UE ULSCH for rnti %x\n",ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti); - fill_ulsch(eNB,UE_id,&ul_config_pdu->ulsch_harq_pdu.ulsch_pdu,frame,subframe); handle_ulsch_harq_pdu(eNB, UE_id, ul_config_pdu, - &ul_config_pdu->ulsch_harq_pdu.harq_information, frame, subframe); - - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) { + &ul_config_pdu->ulsch_harq_pdu.harq_information, frame, subframe); + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) { AssertFatal((UE_id = find_ulsch(ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti, eNB,SEARCH_EXIST_OR_FREE))>=0, "No available UE ULSCH for rnti %x\n",ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti); fill_ulsch(eNB,UE_id,&ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu,frame,subframe); handle_ulsch_cqi_ri_pdu(eNB,UE_id,ul_config_pdu,frame,subframe); - - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE) { + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE) { AssertFatal((UE_id = find_ulsch(ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti, eNB,SEARCH_EXIST_OR_FREE))>=0, "No available UE ULSCH for rnti %x\n",ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti); fill_ulsch(eNB,UE_id,&ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu,frame,subframe); handle_ulsch_cqi_harq_ri_pdu(eNB,UE_id,ul_config_pdu,frame,subframe); handle_ulsch_harq_pdu(eNB, UE_id, ul_config_pdu, - &ul_config_pdu->ulsch_cqi_harq_ri_pdu.harq_information, frame, subframe); - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) { + &ul_config_pdu->ulsch_cqi_harq_ri_pdu.harq_information, frame, subframe); + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) { AssertFatal((UE_id = find_uci(ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti, proc->frame_tx,proc->subframe_tx,eNB,SEARCH_EXIST_OR_FREE))>=0, "No available UE UCI for rnti %x\n",ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti); LOG_D(PHY,"Applying UL UCI_HARQ config for UE %d, rnti %x for frame %d, subframe %d\n", UE_id,ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti,frame,subframe); - handle_uci_harq_pdu(eNB,UE_id,ul_config_pdu,frame,subframe,srs_present); - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE) { + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE) { AssertFatal(1==0,"NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE not handled yet\n"); - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE) { + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE) { AssertFatal(1==0,"NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE not handled yet\n"); - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE) { + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE) { AssertFatal(1==0,"NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE not handled yet\n"); - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE) { + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE) { AssertFatal((UE_id = find_uci(ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti, proc->frame_tx,proc->subframe_tx,eNB,SEARCH_EXIST_OR_FREE))>=0, "No available UE UCI for rnti %x\n",ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti); handle_uci_sr_pdu(eNB,UE_id,ul_config_pdu,frame,subframe,srs_present); - - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE) { + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE) { AssertFatal((UE_id = find_uci(rel8->rnti,proc->frame_tx,proc->subframe_tx,eNB,SEARCH_EXIST_OR_FREE))>=0, "No available UE UCI for rnti %x\n",ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti); handle_uci_sr_harq_pdu(eNB,UE_id,ul_config_pdu,frame,subframe,srs_present); - } - else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_SRS_PDU_TYPE) { + } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_SRS_PDU_TYPE) { handle_srs_pdu(eNB,ul_config_pdu,frame,subframe); } } -void schedule_response(Sched_Rsp_t *Sched_INFO) -{ +void schedule_response(Sched_Rsp_t *Sched_INFO) { PHY_VARS_eNB *eNB; L1_rxtx_proc_t *proc; // copy data from L2 interface into L1 structures @@ -795,70 +747,57 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) int ul_frame; int harq_pid; LTE_UL_eNB_HARQ_t *ulsch_harq; - AssertFatal(RC.eNB!=NULL,"RC.eNB is null\n"); AssertFatal(RC.eNB[Mod_id]!=NULL,"RC.eNB[%d] is null\n",Mod_id); AssertFatal(RC.eNB[Mod_id][CC_id]!=NULL,"RC.eNB[%d][%d] is null\n",Mod_id,CC_id); - - eNB = RC.eNB[Mod_id][CC_id]; fp = &eNB->frame_parms; proc = &eNB->proc.L1_proc; - /* TODO: check that following line is correct - in the meantime it is disabled */ //if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)==SF_UL)) return; - ul_subframe = pdcch_alloc2ul_subframe(fp,subframe); ul_frame = pdcch_alloc2ul_frame(fp,frame,subframe); - // DJP - subframe assert will fail - not sure why yet // DJP - AssertFatal(proc->subframe_tx == subframe, "Current subframe %d != NFAPI subframe %d\n",proc->subframe_tx,subframe); // DJP - AssertFatal(proc->subframe_tx == subframe, "Current frame %d != NFAPI frame %d\n",proc->frame_tx,frame); - uint8_t number_pdcch_ofdm_symbols = DL_req->dl_config_request_body.number_pdcch_ofdm_symbols; - uint8_t number_dl_pdu = DL_req->dl_config_request_body.number_pdu; uint8_t number_hi_dci0_pdu = HI_DCI0_req->hi_dci0_request_body.number_of_dci+HI_DCI0_req->hi_dci0_request_body.number_of_hi; uint8_t number_ul_pdu = UL_req!=NULL ? UL_req->ul_config_request_body.number_of_pdus : 0; - nfapi_dl_config_request_pdu_t *dl_config_pdu; nfapi_hi_dci0_request_pdu_t *hi_dci0_req_pdu; nfapi_ul_config_request_pdu_t *ul_config_pdu; - int i; - eNB->pdcch_vars[subframe&1].num_pdcch_symbols = number_pdcch_ofdm_symbols; eNB->pdcch_vars[subframe&1].num_dci = 0; eNB->phich_vars[subframe&1].num_hi = 0; #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) eNB->mpdcch_vars[subframe&1].num_dci = 0; #endif - LOG_D(PHY,"NFAPI: Sched_INFO:SFN/SF:%04d%d DL_req:SFN/SF:%04d%d:dl_pdu:%d tx_req:SFN/SF:%04d%d:pdus:%d\n", - frame,subframe, - NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf),number_dl_pdu, - NFAPI_SFNSF2SFN(TX_req->sfn_sf),NFAPI_SFNSF2SF(TX_req->sfn_sf),TX_req->tx_request_body.number_of_pdus + frame,subframe, + NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf),number_dl_pdu, + NFAPI_SFNSF2SFN(TX_req->sfn_sf),NFAPI_SFNSF2SF(TX_req->sfn_sf),TX_req->tx_request_body.number_of_pdus ); LOG_D(PHY,"NFAPI: hi_dci0:SFN/SF:%04d%d:pdus:%d\n", NFAPI_SFNSF2SFN(HI_DCI0_req->sfn_sf),NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf),number_hi_dci0_pdu ); + if(UL_req!=NULL) LOG_D(PHY,"NFAPI: ul_cfg:SFN/SF:%04d%d:pdus:%d num_pdcch_symbols:%d\n", NFAPI_SFNSF2SFN(UL_req->sfn_sf),NFAPI_SFNSF2SF(UL_req->sfn_sf),number_ul_pdu, eNB->pdcch_vars[subframe&1].num_pdcch_symbols); - int do_oai =0; int dont_send =0; + /* TODO: check the following test - in the meantime it is put back as it was before */ //if ((ul_subframe<10)&& // (subframe_select(fp,ul_subframe)==SF_UL)) { // This means that there is an ul_subframe that can be configured here if (ul_subframe<10) { // This means that there is an ul_subframe that can be configured here LOG_D(PHY,"NFAPI: Clearing dci allocations for potential UL subframe %d\n",ul_subframe); - harq_pid = subframe2harq_pid(fp,ul_frame,ul_subframe); - // clear DCI allocation maps for new subframe for (i=0; i<NUMBER_OF_UE_MAX; i++) { @@ -869,165 +808,160 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) } } } - for (i=0;i<number_dl_pdu;i++) { + + for (i=0; i<number_dl_pdu; i++) { dl_config_pdu = &DL_req->dl_config_request_body.dl_config_pdu_list[i]; + //LOG_D(PHY,"NFAPI: dl_pdu %d : type %d\n",i,dl_config_pdu->pdu_type); switch (dl_config_pdu->pdu_type) { - case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: - handle_nfapi_dci_dl_pdu(eNB,NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf),proc,dl_config_pdu); - eNB->pdcch_vars[NFAPI_SFNSF2SF(DL_req->sfn_sf)&1].num_dci++; - //LOG_E(PHY,"Incremented num_dci:%d but already set??? dl_config:num_dci:%d\n", eNB->pdcch_vars[subframe&1].num_dci, number_dci); - do_oai=1; - break; - case NFAPI_DL_CONFIG_BCH_PDU_TYPE: - AssertFatal(dl_config_pdu->bch_pdu.bch_pdu_rel8.pdu_index<TX_req->tx_request_body.number_of_pdus, - "bch_pdu_rel8.pdu_index>=TX_req->number_of_pdus (%d>%d)\n", - dl_config_pdu->bch_pdu.bch_pdu_rel8.pdu_index, - TX_req->tx_request_body.number_of_pdus); - eNB->pbch_configured=1; - do_oai=1; - //LOG_D(PHY,"%s() NFAPI_DL_CONFIG_BCH_PDU_TYPE TX:%d/%d RX:%d/%d TXREQ:%d/%d\n", - //__FUNCTION__, proc->frame_tx, proc->subframe_tx, proc->frame_rx, proc->subframe_rx, NFAPI_SFNSF2SFN(TX_req->sfn_sf), NFAPI_SFNSF2SF(TX_req->sfn_sf)); - - - handle_nfapi_bch_pdu(eNB,proc,dl_config_pdu, - TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->bch_pdu.bch_pdu_rel8.pdu_index].segments[0].segment_data); - break; - case NFAPI_DL_CONFIG_MCH_PDU_TYPE: - // handle_nfapi_mch_dl_pdu(eNB,dl_config_pdu); - break; - case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: - { + case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: + handle_nfapi_dci_dl_pdu(eNB,NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf),proc,dl_config_pdu); + eNB->pdcch_vars[NFAPI_SFNSF2SF(DL_req->sfn_sf)&1].num_dci++; + //LOG_E(PHY,"Incremented num_dci:%d but already set??? dl_config:num_dci:%d\n", eNB->pdcch_vars[subframe&1].num_dci, number_dci); + do_oai=1; + break; + + case NFAPI_DL_CONFIG_BCH_PDU_TYPE: + AssertFatal(dl_config_pdu->bch_pdu.bch_pdu_rel8.pdu_index<TX_req->tx_request_body.number_of_pdus, + "bch_pdu_rel8.pdu_index>=TX_req->number_of_pdus (%d>%d)\n", + dl_config_pdu->bch_pdu.bch_pdu_rel8.pdu_index, + TX_req->tx_request_body.number_of_pdus); + eNB->pbch_configured=1; + do_oai=1; + //LOG_D(PHY,"%s() NFAPI_DL_CONFIG_BCH_PDU_TYPE TX:%d/%d RX:%d/%d TXREQ:%d/%d\n", + //__FUNCTION__, proc->frame_tx, proc->subframe_tx, proc->frame_rx, proc->subframe_rx, NFAPI_SFNSF2SFN(TX_req->sfn_sf), NFAPI_SFNSF2SF(TX_req->sfn_sf)); + handle_nfapi_bch_pdu(eNB,proc,dl_config_pdu, + TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->bch_pdu.bch_pdu_rel8.pdu_index].segments[0].segment_data); + break; + + case NFAPI_DL_CONFIG_MCH_PDU_TYPE: + // handle_nfapi_mch_dl_pdu(eNB,dl_config_pdu); + break; + + case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: { nfapi_dl_config_dlsch_pdu_rel8_t *dlsch_pdu_rel8 = &dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8; uint16_t pdu_index = dlsch_pdu_rel8->pdu_index; uint16_t tx_pdus = TX_req->tx_request_body.number_of_pdus; uint16_t invalid_pdu = pdu_index == -1; uint8_t *sdu = invalid_pdu ? NULL : pdu_index >= tx_pdus ? NULL : TX_req->tx_request_body.tx_pdu_list[pdu_index].segments[0].segment_data; - - LOG_D(PHY,"%s() [PDU:%d] NFAPI_DL_CONFIG_DLSCH_PDU_TYPE SFN/SF:%04d%d TX:%d/%d RX:%d/%d transport_blocks:%d pdu_index:%d sdu:%p\n", - __FUNCTION__, i, - NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf), - proc->frame_tx, proc->subframe_tx, - proc->frame_rx, proc->subframe_rx, - dlsch_pdu_rel8->transport_blocks, pdu_index, sdu); - - /* - AssertFatal(dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index<TX_req->tx_request_body.number_of_pdus, - "dlsch_pdu_rel8.pdu_index>=TX_req->number_of_pdus (%d>%d)\n", - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index, - TX_req->tx_request_body.number_of_pdus); - */ - AssertFatal((dlsch_pdu_rel8->transport_blocks<3) && - (dlsch_pdu_rel8->transport_blocks>0), - "dlsch_pdu_rel8->transport_blocks = %d not in [1,2]\n", - dlsch_pdu_rel8->transport_blocks); - if (1)//sdu != NULL) - { - handle_nfapi_dlsch_pdu(eNB,NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf),proc,dl_config_pdu, dlsch_pdu_rel8->transport_blocks-1, sdu); - } - else - { - dont_send=1; - - LOG_E(MAC,"%s() NFAPI_DL_CONFIG_DLSCH_PDU_TYPE sdu is NULL DL_CFG:SFN/SF:%d:pdu_index:%d TX_REQ:SFN/SF:%d:pdus:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(DL_req->sfn_sf), pdu_index, NFAPI_SFNSF2DEC(TX_req->sfn_sf), tx_pdus); + LOG_D(PHY,"%s() [PDU:%d] NFAPI_DL_CONFIG_DLSCH_PDU_TYPE SFN/SF:%04d%d TX:%d/%d RX:%d/%d transport_blocks:%d pdu_index:%d sdu:%p\n", + __FUNCTION__, i, + NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf), + proc->frame_tx, proc->subframe_tx, + proc->frame_rx, proc->subframe_rx, + dlsch_pdu_rel8->transport_blocks, pdu_index, sdu); + /* + AssertFatal(dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index<TX_req->tx_request_body.number_of_pdus, + "dlsch_pdu_rel8.pdu_index>=TX_req->number_of_pdus (%d>%d)\n", + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index, + TX_req->tx_request_body.number_of_pdus); + */ + AssertFatal((dlsch_pdu_rel8->transport_blocks<3) && + (dlsch_pdu_rel8->transport_blocks>0), + "dlsch_pdu_rel8->transport_blocks = %d not in [1,2]\n", + dlsch_pdu_rel8->transport_blocks); + + if (1) { //sdu != NULL) + handle_nfapi_dlsch_pdu(eNB,NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf),proc,dl_config_pdu, dlsch_pdu_rel8->transport_blocks-1, sdu); + } else { + dont_send=1; + LOG_E(MAC,"%s() NFAPI_DL_CONFIG_DLSCH_PDU_TYPE sdu is NULL DL_CFG:SFN/SF:%d:pdu_index:%d TX_REQ:SFN/SF:%d:pdus:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(DL_req->sfn_sf), pdu_index, + NFAPI_SFNSF2DEC(TX_req->sfn_sf), tx_pdus); + } + + // Send the data first so that the DL_CONFIG can just pluck it out of the buffer + // DJP - OAI was here - moved to bottom + do_oai=1; + /* + if (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti == eNB->preamble_list[0].preamble_rel8.rnti) {// is RAR pdu + + LOG_D(PHY,"Frame %d, Subframe %d: Received LTE RAR pdu, programming based on UL Grant\n",frame,subframe); + generate_eNB_ulsch_params_from_rar(eNB, + TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, + frame, + subframe); + + } */ } + break; - // Send the data first so that the DL_CONFIG can just pluck it out of the buffer - // DJP - OAI was here - moved to bottom - do_oai=1; + case NFAPI_DL_CONFIG_PCH_PDU_TYPE: + // handle_nfapi_pch_pdu(eNB,dl_config_pdu); + break; - /* - if (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti == eNB->preamble_list[0].preamble_rel8.rnti) {// is RAR pdu + case NFAPI_DL_CONFIG_PRS_PDU_TYPE: + // handle_nfapi_prs_pdu(eNB,dl_config_pdu); + break; - LOG_D(PHY,"Frame %d, Subframe %d: Received LTE RAR pdu, programming based on UL Grant\n",frame,subframe); - generate_eNB_ulsch_params_from_rar(eNB, - TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data, - frame, - subframe); + case NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE: + // handle_nfapi_csi_rs_pdu(eNB,dl_config_pdu); + break; - } */ - } - break; - case NFAPI_DL_CONFIG_PCH_PDU_TYPE: - // handle_nfapi_pch_pdu(eNB,dl_config_pdu); - break; - case NFAPI_DL_CONFIG_PRS_PDU_TYPE: - // handle_nfapi_prs_pdu(eNB,dl_config_pdu); - break; - case NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE: - // handle_nfapi_csi_rs_pdu(eNB,dl_config_pdu); - break; - case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE: - // handle_nfapi_epdcch_pdu(eNB,dl_config_pdu); - break; + case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE: + // handle_nfapi_epdcch_pdu(eNB,dl_config_pdu); + break; #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE: - handle_nfapi_mpdcch_pdu(eNB,proc,dl_config_pdu); - eNB->mpdcch_vars[subframe&1].num_dci++; - break; -#endif + + case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE: + handle_nfapi_mpdcch_pdu(eNB,proc,dl_config_pdu); + eNB->mpdcch_vars[subframe&1].num_dci++; + break; +#endif } } - - if (nfapi_mode && do_oai && !dont_send) { - oai_nfapi_tx_req(Sched_INFO->TX_req); + if ((NFAPI_MODE!=NFAPI_MONOLITHIC) && do_oai && !dont_send) { + oai_nfapi_tx_req(Sched_INFO->TX_req); oai_nfapi_dl_config_req(Sched_INFO->DL_req); // DJP - .dl_config_request_body.dl_config_pdu_list[0]); // DJP - FIXME TODO - yuk - only copes with 1 pdu } - if (nfapi_mode && number_hi_dci0_pdu!=0) { + if ((NFAPI_MODE!=NFAPI_MONOLITHIC) && number_hi_dci0_pdu!=0) { oai_nfapi_hi_dci0_req(HI_DCI0_req); eNB->pdcch_vars[NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf)&1].num_dci=0; eNB->pdcch_vars[NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf)&1].num_pdcch_symbols=0; } - for (i=0;i<number_hi_dci0_pdu;i++) { - + for (i=0; i<number_hi_dci0_pdu; i++) { hi_dci0_req_pdu = &HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list[i]; - LOG_D(PHY,"NFAPI: hi_dci0_pdu %d : type %d\n",i,hi_dci0_req_pdu->pdu_type); switch (hi_dci0_req_pdu->pdu_type) { - - case NFAPI_HI_DCI0_DCI_PDU_TYPE: - - handle_nfapi_hi_dci0_dci_pdu(eNB,NFAPI_SFNSF2SFN(HI_DCI0_req->sfn_sf),NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf),proc,hi_dci0_req_pdu); - eNB->pdcch_vars[NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf)&1].num_dci++; - break; - - case NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE: - handle_nfapi_hi_dci0_mpdcch_dci_pdu(eNB,proc,hi_dci0_req_pdu); - eNB->mpdcch_vars[subframe&1].num_dci++; - break; - - case NFAPI_HI_DCI0_HI_PDU_TYPE: - handle_nfapi_hi_dci0_hi_pdu(eNB,NFAPI_SFNSF2SFN(HI_DCI0_req->sfn_sf),NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf),proc,hi_dci0_req_pdu); - break; + case NFAPI_HI_DCI0_DCI_PDU_TYPE: + handle_nfapi_hi_dci0_dci_pdu(eNB,NFAPI_SFNSF2SFN(HI_DCI0_req->sfn_sf),NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf),proc,hi_dci0_req_pdu); + eNB->pdcch_vars[NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf)&1].num_dci++; + break; + + case NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE: + handle_nfapi_hi_dci0_mpdcch_dci_pdu(eNB,proc,hi_dci0_req_pdu); + eNB->mpdcch_vars[subframe&1].num_dci++; + break; + + case NFAPI_HI_DCI0_HI_PDU_TYPE: + handle_nfapi_hi_dci0_hi_pdu(eNB,NFAPI_SFNSF2SFN(HI_DCI0_req->sfn_sf),NFAPI_SFNSF2SF(HI_DCI0_req->sfn_sf),proc,hi_dci0_req_pdu); + break; } } - if (nfapi_mode) { - if (number_ul_pdu>0) - { + if (NFAPI_MODE!=NFAPI_MONOLITHIC) { + if (number_ul_pdu>0) { //LOG_D(PHY, "UL_CONFIG to send to PNF\n"); oai_nfapi_ul_config_req(UL_req); UL_req->ul_config_request_body.number_of_pdus=0; number_ul_pdu=0; } - } - else { - for (i=0;i<number_ul_pdu;i++) { + } else { + for (i=0; i<number_ul_pdu; i++) { ul_config_pdu = &UL_req->ul_config_request_body.ul_config_pdu_list[i]; LOG_D(PHY,"NFAPI: ul_pdu %d : type %d\n",i,ul_config_pdu->pdu_type); AssertFatal(ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE || - ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE || - ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE || - ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE || - ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE || - ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE || - ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE - , - "Optional UL_PDU type %d not supported\n",ul_config_pdu->pdu_type); + ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE || + ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE || + ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE || + ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE || + ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE || + ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE + , + "Optional UL_PDU type %d not supported\n",ul_config_pdu->pdu_type); handle_nfapi_ul_pdu(eNB,proc,ul_config_pdu,UL_req->sfn_sf>>4,UL_req->sfn_sf&0xf,UL_req->ul_config_request_body.srs_present); } } @@ -1035,22 +969,18 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) /*Dummy functions*/ -int memcpy_dl_config_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request_t* req) -{ - return 0; +int memcpy_dl_config_req (nfapi_pnf_p7_config_t *pnf_p7, nfapi_dl_config_request_t *req) { + return 0; } -int memcpy_ul_config_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req) -{ - return 0; +int memcpy_ul_config_req (nfapi_pnf_p7_config_t *pnf_p7, nfapi_ul_config_request_t *req) { + return 0; } -int memcpy_hi_dci0_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_hi_dci0_request_t* req) -{ - return 0; +int memcpy_hi_dci0_req (nfapi_pnf_p7_config_t *pnf_p7, nfapi_hi_dci0_request_t *req) { + return 0; } -int memcpy_tx_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_tx_request_t* req) -{ - return 0; +int memcpy_tx_req (nfapi_pnf_p7_config_t *pnf_p7, nfapi_tx_request_t *req) { + return 0; } diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 2dc16ef1101b17ed4257c1bc5731ae5091266c1c..7e56c14045a4cd5c0fee7aaf8e401ed0551690f2 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -35,7 +35,7 @@ #include "SCHED/sched_eNB.h" #include "SCHED/sched_common_extern.h" #include "PHY/LTE_ESTIMATION/lte_estimation.h" -#include "nfapi_interface.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "fapi_l1.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" @@ -45,26 +45,18 @@ #include <time.h> -#if defined(ENABLE_ITTI) #include "intertask_interface.h" -#endif - -extern uint8_t nfapi_mode; -int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint16_t UE_id,uint8_t harq_pid, uint8_t bw_factor) -{ +int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint16_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; - + 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++) { @@ -82,10 +74,8 @@ int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint16_t UE_id,uint8_t 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 ); @@ -103,9 +93,7 @@ int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint16_t UE_id,uint8_t } -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_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])) { @@ -126,30 +114,21 @@ int16_t get_hundred_times_delta_IF_mac(module_id_t module_idP, uint8_t CC_id, rn 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) -{ - +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)); - } void pmch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { - - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) MCH_PDU *mch_pduP=NULL; // uint8_t sync_area=255; #endif - int subframe = proc->subframe_tx; - AssertFatal (1 == 0, "pmch not tested for the moment, exiting\n"); - // This is DL-Cell spec pilots in Control region generate_pilots_slot (eNB, eNB->common_vars.txdataF, AMP, subframe << 1, 1); - - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + // if mcch is active, send regardless of the node type: eNB or RN // when mcch is active, MAC sched does not allow MCCH and MTCH multiplexing /* @@ -160,15 +139,15 @@ void pmch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { */ 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); + 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"); + 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; } - + if (mch_pduP) { fill_eNB_dlsch_MCH (eNB, mch_pduP->mcs, 1, 0); // Generate PMCH @@ -181,26 +160,23 @@ void pmch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { } void common_signal_procedures (PHY_VARS_eNB *eNB,int frame, int subframe) { - LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; int **txdataF = eNB->common_vars.txdataF; uint8_t *pbch_pdu=&eNB->pbch_pdu[0]; - - //LOG_D(PHY,"common_signal_procedures: frame %d, subframe %d fdd:%s dir:%s\n",frame,subframe,fp->frame_type == FDD?"FDD":"TDD", subframe_select(fp,subframe) == SF_DL?"DL":"UL?"); - + //LOG_D(PHY,"common_signal_procedures: frame %d, subframe %d fdd:%s dir:%s\n",frame,subframe,fp->frame_type == FDD?"FDD":"TDD", subframe_select(fp,subframe) == SF_DL?"DL":"UL?"); // generate Cell-Specific Reference Signals for both slots VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_RS_TX,1); if(subframe_select(fp,subframe) == SF_S) generate_pilots_slot(eNB, - txdataF, - AMP, - subframe<<1,1); + txdataF, + AMP, + subframe<<1,1); else generate_pilots_slot(eNB, - txdataF, - AMP, - subframe<<1,0); + txdataF, + AMP, + subframe<<1,0); // check that 2nd slot is for DL if (subframe_select (fp, subframe) == SF_DL) @@ -208,35 +184,32 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,int frame, int subframe) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME (VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_RS_TX, 0); - // First half of PSS/SSS (FDD, slot 0) if (subframe == 0) { if (fp->frame_type == FDD) { generate_pss (txdataF, AMP, fp, (fp->Ncp == NORMAL) ? 6 : 5, 0); generate_sss (txdataF, AMP, fp, (fp->Ncp == NORMAL) ? 5 : 4, 0); - } - - /// First half of SSS (TDD, slot 1) if (fp->frame_type == TDD) { generate_sss (txdataF, AMP, fp, (fp->Ncp == NORMAL) ? 6 : 5, 1); } + // generate PBCH (Physical Broadcast CHannel) info /// generate PBCH if ((frame&3)==0) { //AssertFatal(eNB->pbch_configured==1,"PBCH was not configured by MAC\n"); if (eNB->pbch_configured!=1) return; + eNB->pbch_configured=0; } + T(T_ENB_PHY_MIB, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_BUFFER(pbch_pdu, 3)); - generate_pbch (&eNB->pbch, txdataF, AMP, fp, pbch_pdu, frame & 3); - } else if ((subframe == 1) && (fp->frame_type == TDD)) { generate_pss (txdataF, AMP, fp, 2, 2); } @@ -244,7 +217,6 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,int frame, int subframe) { else if ((subframe == 5) && (fp->frame_type == FDD)) { generate_pss (txdataF, AMP, &eNB->frame_parms, (fp->Ncp == NORMAL) ? 6 : 5, 10); generate_sss (txdataF, AMP, &eNB->frame_parms, (fp->Ncp == NORMAL) ? 5 : 4, 10); - } // Second-half of SSS (TDD, slot 11) else if ((subframe == 5) && (fp->frame_type == TDD)) { @@ -254,73 +226,68 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,int frame, int subframe) { else if ((subframe == 6) && (fp->frame_type == TDD)) { generate_pss (txdataF, AMP, fp, 2, 12); } - } void pdsch_procedures(PHY_VARS_eNB *eNB, - L1_rxtx_proc_t *proc, - int harq_pid, - LTE_eNB_DLSCH_t *dlsch, - LTE_eNB_DLSCH_t *dlsch1, - LTE_eNB_UE_stats *ue_stats, - int ra_flag) { - + L1_rxtx_proc_t *proc, + int harq_pid, + LTE_eNB_DLSCH_t *dlsch, + LTE_eNB_DLSCH_t *dlsch1, + LTE_eNB_UE_stats *ue_stats, + int ra_flag) { int frame=proc->frame_tx; int subframe=proc->subframe_tx; LTE_DL_eNB_HARQ_t *dlsch_harq=dlsch->harq_processes[harq_pid]; LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; if (dlsch->rnti == 0x02) {//frame < 200) { - LOG_D(PHY, - "[eNB %"PRIu8"][PDSCH %"PRIx16"/%"PRIu8"] Frame %d, subframe %d: Generating PDSCH/DLSCH with input size = %"PRIu16", pdsch_start %d, G %d, nb_rb %"PRIu16", rb0 %x, rb1 %x, TBS %"PRIu16", pmi_alloc %"PRIx64", rv %"PRIu8" (round %"PRIu8")\n", - eNB->Mod_id, dlsch->rnti,harq_pid, - frame, subframe, dlsch_harq->TBS/8, dlsch_harq->pdsch_start, - get_G(fp, - dlsch_harq->nb_rb, - dlsch_harq->rb_alloc, - dlsch_harq->Qm, - dlsch_harq->Nl, - dlsch_harq->pdsch_start, - frame, - subframe, - dlsch_harq->mimo_mode==TM7?7:0), - dlsch_harq->nb_rb, - dlsch_harq->rb_alloc[0], - dlsch_harq->rb_alloc[1], - dlsch_harq->TBS, - pmi2hex_2Ar1(dlsch_harq->pmi_alloc), - dlsch_harq->rvidx, - dlsch_harq->round); - } + "[eNB %"PRIu8"][PDSCH %"PRIx16"/%"PRIu8"] Frame %d, subframe %d: Generating PDSCH/DLSCH with input size = %"PRIu16", pdsch_start %d, G %d, nb_rb %"PRIu16", rb0 %x, rb1 %x, TBS %"PRIu16", pmi_alloc %"PRIx64", rv %"PRIu8" (round %"PRIu8")\n", + eNB->Mod_id, dlsch->rnti,harq_pid, + frame, subframe, dlsch_harq->TBS/8, dlsch_harq->pdsch_start, + get_G(fp, + dlsch_harq->nb_rb, + dlsch_harq->rb_alloc, + dlsch_harq->Qm, + dlsch_harq->Nl, + dlsch_harq->pdsch_start, + frame, + subframe, + dlsch_harq->mimo_mode==TM7?7:0), + dlsch_harq->nb_rb, + dlsch_harq->rb_alloc[0], + dlsch_harq->rb_alloc[1], + dlsch_harq->TBS, + pmi2hex_2Ar1(dlsch_harq->pmi_alloc), + dlsch_harq->rvidx, + dlsch_harq->round); + } MSC_LOG_TX_MESSAGE( - MSC_PHY_ENB,MSC_PHY_UE, - NULL,0, - "%05u:%02u PDSCH/DLSCH input size = %"PRIu16", G %d, nb_rb %"PRIu16", TBS %"PRIu16", pmi_alloc %"PRIx16", rv %"PRIu8" (round %"PRIu8")", - frame, subframe, - dlsch_harq->TBS/8, - get_G(fp, - dlsch_harq->nb_rb, - dlsch_harq->rb_alloc, - dlsch_harq->Qm, - dlsch_harq->Nl, - dlsch_harq->pdsch_start, - frame, - subframe, - dlsch_harq->mimo_mode==TM7?7:0), - dlsch_harq->nb_rb, - dlsch_harq->TBS, - pmi2hex_2Ar1(dlsch_harq->pmi_alloc), - dlsch_harq->rvidx, - dlsch_harq->round); - - - + MSC_PHY_ENB,MSC_PHY_UE, + NULL,0, + "%05u:%02u PDSCH/DLSCH input size = %"PRIu16", G %d, nb_rb %"PRIu16", TBS %"PRIu16", pmi_alloc %"PRIx16", rv %"PRIu8" (round %"PRIu8")", + frame, subframe, + dlsch_harq->TBS/8, + get_G(fp, + dlsch_harq->nb_rb, + dlsch_harq->rb_alloc, + dlsch_harq->Qm, + dlsch_harq->Nl, + dlsch_harq->pdsch_start, + frame, + subframe, + dlsch_harq->mimo_mode==TM7?7:0), + dlsch_harq->nb_rb, + dlsch_harq->TBS, + pmi2hex_2Ar1(dlsch_harq->pmi_alloc), + dlsch_harq->rvidx, + dlsch_harq->round); + if (ue_stats) ue_stats->dlsch_sliding_cnt++; - + if (dlsch_harq->round == 0) { if (ue_stats) ue_stats->dlsch_trials[harq_pid][0]++; @@ -333,87 +300,81 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, #endif } - if (dlsch->rnti!=0xffff) LOG_D(PHY,"Generating DLSCH/PDSCH pdu:%p pdsch_start:%d frame:%d subframe:%d nb_rb:%d rb_alloc:%d Qm:%d Nl:%d round:%d\n", - dlsch_harq->pdu,dlsch_harq->pdsch_start,frame,subframe,dlsch_harq->nb_rb,dlsch_harq->rb_alloc[0],dlsch_harq->Qm,dlsch_harq->Nl,dlsch_harq->round); - // 36-212 - if (nfapi_mode == 0 || nfapi_mode == 1) { // monolthic OR PNF - do not need turbo encoding on VNF + dlsch_harq->pdu,dlsch_harq->pdsch_start,frame,subframe,dlsch_harq->nb_rb,dlsch_harq->rb_alloc[0],dlsch_harq->Qm,dlsch_harq->Nl,dlsch_harq->round); - if (dlsch_harq->pdu==NULL){ - LOG_E(PHY,"dlsch_harq->pdu == NULL SFN/SF:%04d%d dlsch[rnti:%x] dlsch_harq[pdu:%p pdsch_start:%d Qm:%d Nl:%d round:%d nb_rb:%d rb_alloc[0]:%d]\n", frame,subframe,dlsch->rnti, dlsch_harq->pdu,dlsch_harq->pdsch_start,dlsch_harq->Qm,dlsch_harq->Nl,dlsch_harq->round,dlsch_harq->nb_rb,dlsch_harq->rb_alloc[0]); + // 36-212 + if (NFAPI_MODE==NFAPI_MONOLITHIC || NFAPI_MODE==NFAPI_MODE_PNF) { // monolthic OR PNF - do not need turbo encoding on VNF + if (dlsch_harq->pdu==NULL) { + LOG_E(PHY,"dlsch_harq->pdu == NULL SFN/SF:%04d%d dlsch[rnti:%x] dlsch_harq[pdu:%p pdsch_start:%d Qm:%d Nl:%d round:%d nb_rb:%d rb_alloc[0]:%d]\n", frame,subframe,dlsch->rnti, dlsch_harq->pdu, + dlsch_harq->pdsch_start,dlsch_harq->Qm,dlsch_harq->Nl,dlsch_harq->round,dlsch_harq->nb_rb,dlsch_harq->rb_alloc[0]); return; } start_meas(&eNB->dlsch_encoding_stats); - dlsch_encoding_all(eNB, - dlsch_harq->pdu, - dlsch_harq->pdsch_start, - dlsch, - frame, - subframe, - &eNB->dlsch_rate_matching_stats, - &eNB->dlsch_turbo_encoding_stats, - &eNB->dlsch_turbo_encoding_waiting_stats, - &eNB->dlsch_turbo_encoding_main_stats, - &eNB->dlsch_turbo_encoding_wakeup_stats0, - &eNB->dlsch_turbo_encoding_wakeup_stats1, - &eNB->dlsch_interleaving_stats); - + dlsch_harq->pdu, + dlsch_harq->pdsch_start, + dlsch, + frame, + subframe, + &eNB->dlsch_rate_matching_stats, + &eNB->dlsch_turbo_encoding_stats, + &eNB->dlsch_turbo_encoding_waiting_stats, + &eNB->dlsch_turbo_encoding_main_stats, + &eNB->dlsch_turbo_encoding_wakeup_stats0, + &eNB->dlsch_turbo_encoding_wakeup_stats1, + &eNB->dlsch_interleaving_stats); stop_meas(&eNB->dlsch_encoding_stats); - if(eNB->dlsch_encoding_stats.p_time>500*3000 && opp_enabled == 1) - { - print_meas_now(&eNB->dlsch_encoding_stats,"total coding",stderr); - } + + if(eNB->dlsch_encoding_stats.p_time>500*3000 && opp_enabled == 1) { + print_meas_now(&eNB->dlsch_encoding_stats,"total coding",stderr); + } + // 36-211 start_meas(&eNB->dlsch_scrambling_stats); dlsch_scrambling(fp, - 0, - dlsch, - harq_pid, - get_G(fp, - dlsch_harq->nb_rb, - dlsch_harq->rb_alloc, - dlsch_harq->Qm, - dlsch_harq->Nl, - dlsch_harq->pdsch_start, - frame,subframe, - 0), - 0, - frame, - subframe<<1); + 0, + dlsch, + harq_pid, + get_G(fp, + dlsch_harq->nb_rb, + dlsch_harq->rb_alloc, + dlsch_harq->Qm, + dlsch_harq->Nl, + dlsch_harq->pdsch_start, + frame,subframe, + 0), + 0, + frame, + subframe<<1); stop_meas(&eNB->dlsch_scrambling_stats); - start_meas(&eNB->dlsch_modulation_stats); - - dlsch_modulation(eNB, - eNB->common_vars.txdataF, - AMP, - frame, - subframe, - dlsch_harq->pdsch_start, - dlsch, - dlsch1); - + eNB->common_vars.txdataF, + AMP, + frame, + subframe, + dlsch_harq->pdsch_start, + dlsch, + dlsch1); stop_meas(&eNB->dlsch_modulation_stats); } + #ifdef PHY_TX_THREAD dlsch->active[subframe] = 0; #else dlsch->active = 0; #endif dlsch_harq->round++; - LOG_D(PHY,"Generating DLSCH/PDSCH dlsch_harq[round:%d]\n",dlsch_harq->round); } void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, - L1_rxtx_proc_t *proc, - int do_meas) -{ + L1_rxtx_proc_t *proc, + int do_meas) { int frame=proc->frame_tx; int subframe=proc->subframe_tx; uint32_t i,aa; @@ -429,149 +390,138 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; LTE_UL_eNB_HARQ_t *ulsch_harq; - - if ((fp->frame_type == TDD) && (subframe_select (fp, subframe) == SF_UL)) return; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+(eNB->CC_id),1); + if (do_meas==1) start_meas(&eNB->phy_proc_tx); + if (do_meas==1) start_meas(&eNB->dlsch_common_and_dci); // clear the transmit data array for the current subframe for (aa = 0; aa < fp->nb_antenna_ports_eNB; aa++) { memset (&eNB->common_vars.txdataF[aa][subframe * fp->ofdm_symbol_size * (fp->symbols_per_tti)], 0, fp->ofdm_symbol_size * (fp->symbols_per_tti) * sizeof (int32_t)); } - - - if (nfapi_mode == 0 || nfapi_mode == 1) { + + if (NFAPI_MODE==NFAPI_MONOLITHIC || NFAPI_MODE==NFAPI_MODE_PNF) { if (is_pmch_subframe(frame,subframe,fp)) { pmch_procedures(eNB,proc); - } - else { + } else { // this is not a pmch subframe, so generate PSS/SSS/PBCH common_signal_procedures(eNB,proc->frame_tx, proc->subframe_tx); } } - - + // clear existing ulsch dci allocations before applying info from MAC (this is table ul_subframe = pdcch_alloc2ul_subframe (fp, subframe); ul_frame = pdcch_alloc2ul_frame (fp, frame, subframe); - - - + // clear previous allocation information for all UEs for (i = 0; i < NUMBER_OF_UE_MAX; i++) { if (eNB->dlsch[i][0]) eNB->dlsch[i][0]->subframe_tx[subframe] = 0; } - - + /* TODO: check the following test - in the meantime it is put back as it was before */ //if ((ul_subframe < 10)&& // (subframe_select(fp,ul_subframe)==SF_UL)) { // This means that there is a potential UL subframe that will be scheduled here if (ul_subframe < 10) { // This means that there is a potential UL subframe that will be scheduled here for (i=0; i<NUMBER_OF_UE_MAX; i++) { #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + if (eNB->ulsch[i] && eNB->ulsch[i]->ue_type >0) harq_pid = 0; - else + else #endif - harq_pid = subframe2harq_pid(fp,ul_frame,ul_subframe); - + harq_pid = subframe2harq_pid(fp,ul_frame,ul_subframe); + if (eNB->ulsch[i]) { - ulsch_harq = eNB->ulsch[i]->harq_processes[harq_pid]; - - /* Store first_rb and n_DMRS for correct PHICH generation below. - * For PHICH generation we need "old" values of last scheduling - * for this HARQ process. 'generate_eNB_dlsch_params' below will - * overwrite first_rb and n_DMRS and 'generate_phich_top', done - * after 'generate_eNB_dlsch_params', would use the "new" values - * instead of the "old" ones. - * - * This has been tested for FDD only, may be wrong for TDD. - * - * TODO: maybe we should restructure the code to be sure it - * is done correctly. The main concern is if the code - * changes and first_rb and n_DMRS are modified before - * we reach here, then the PHICH processing will be wrong, - * using wrong first_rb and n_DMRS values to compute - * ngroup_PHICH and nseq_PHICH. - * - * TODO: check if that works with TDD. - */ - ulsch_harq->previous_first_rb = ulsch_harq->first_rb; - ulsch_harq->previous_n_DMRS = ulsch_harq->n_DMRS; - + ulsch_harq = eNB->ulsch[i]->harq_processes[harq_pid]; + /* Store first_rb and n_DMRS for correct PHICH generation below. + * For PHICH generation we need "old" values of last scheduling + * for this HARQ process. 'generate_eNB_dlsch_params' below will + * overwrite first_rb and n_DMRS and 'generate_phich_top', done + * after 'generate_eNB_dlsch_params', would use the "new" values + * instead of the "old" ones. + * + * This has been tested for FDD only, may be wrong for TDD. + * + * TODO: maybe we should restructure the code to be sure it + * is done correctly. The main concern is if the code + * changes and first_rb and n_DMRS are modified before + * we reach here, then the PHICH processing will be wrong, + * using wrong first_rb and n_DMRS values to compute + * ngroup_PHICH and nseq_PHICH. + * + * TODO: check if that works with TDD. + */ + ulsch_harq->previous_first_rb = ulsch_harq->first_rb; + ulsch_harq->previous_n_DMRS = ulsch_harq->n_DMRS; } } } - - + num_pdcch_symbols = eNB->pdcch_vars[subframe&1].num_pdcch_symbols; num_dci = eNB->pdcch_vars[subframe&1].num_dci; LOG_D(PHY,"num_pdcch_symbols %"PRIu8",number dci %"PRIu8"\n",num_pdcch_symbols, num_dci); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,num_pdcch_symbols); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME (VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO, (frame * 10) + subframe); - + if (num_dci > 0) LOG_D(PHY,"[eNB %"PRIu8"] Frame %d, subframe %d: Calling generate_dci_top (pdcch) (num_dci %"PRIu8") num_pdcch_symbols:%d\n",eNB->Mod_id,frame, subframe, num_dci, num_pdcch_symbols); - - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,1); - - if (nfapi_mode == 0 || nfapi_mode == 1) { + + if (NFAPI_MODE==NFAPI_MONOLITHIC || NFAPI_MODE==NFAPI_MODE_PNF) { generate_dci_top(num_pdcch_symbols, - num_dci, - &eNB->pdcch_vars[subframe&1].dci_alloc[0], - 0, - AMP, - fp, - eNB->common_vars.txdataF, - subframe); - + num_dci, + &eNB->pdcch_vars[subframe&1].dci_alloc[0], + 0, + AMP, + fp, + eNB->common_vars.txdataF, + subframe); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) num_mdci = eNB->mpdcch_vars[subframe &1].num_dci; + if (num_mdci > 0) { LOG_D (PHY, "[eNB %" PRIu8 "] Frame %d, subframe %d: Calling generate_mdci_top (mpdcch) (num_dci %" PRIu8 ")\n", eNB->Mod_id, frame, subframe, num_mdci); - generate_mdci_top (eNB, frame, subframe, AMP, eNB->common_vars.txdataF); - } + #endif } if (do_meas==1) stop_meas(&eNB->dlsch_common_and_dci); + if (do_meas==1) start_meas(&eNB->dlsch_ue_specific); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,1); // Now scan UE specific DLSCH LTE_eNB_DLSCH_t *dlsch0,*dlsch1; + for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { - dlsch0 = eNB->dlsch[(uint8_t)UE_id][0]; - dlsch1 = eNB->dlsch[(uint8_t)UE_id][1]; - + dlsch0 = eNB->dlsch[(uint8_t)UE_id][0]; + dlsch1 = eNB->dlsch[(uint8_t)UE_id][1]; + if ((dlsch0)&&(dlsch0->rnti>0)&& #ifdef PHY_TX_THREAD - (dlsch0->active[subframe] == 1) + (dlsch0->active[subframe] == 1) #else - (dlsch0->active == 1) + (dlsch0->active == 1) #endif - ){ - + ) { // get harq_pid harq_pid = dlsch0->harq_ids[frame%2][subframe]; AssertFatal(harq_pid>=0,"harq_pid is negative\n"); - - if (harq_pid>=8) { + if (harq_pid>=8) { #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - if (dlsch0->ue_type==0) + + if (dlsch0->ue_type==0) #endif - LOG_E(PHY,"harq_pid:%d corrupt must be 0-7 UE_id:%d frame:%d subframe:%d rnti:%x [ %1d.%1d.%1d.%1d.%1d.%1d.%1d.%1d\n", harq_pid,UE_id,frame,subframe,dlsch0->rnti, + LOG_E(PHY,"harq_pid:%d corrupt must be 0-7 UE_id:%d frame:%d subframe:%d rnti:%x [ %1d.%1d.%1d.%1d.%1d.%1d.%1d.%1d\n", harq_pid,UE_id,frame,subframe,dlsch0->rnti, dlsch0->harq_ids[frame%2][0], dlsch0->harq_ids[frame%2][1], dlsch0->harq_ids[frame%2][2], @@ -580,871 +530,801 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, dlsch0->harq_ids[frame%2][5], dlsch0->harq_ids[frame%2][6], dlsch0->harq_ids[frame%2][7]); - } else - { - // generate pdsch - - pdsch_procedures(eNB, - proc, - harq_pid, - dlsch0, - dlsch1, - &eNB->UE_stats[(uint32_t)UE_id], - 0); + } else { + // generate pdsch + pdsch_procedures(eNB, + proc, + harq_pid, + dlsch0, + dlsch1, + &eNB->UE_stats[(uint32_t)UE_id], + 0); } - - - } - - - else if ((dlsch0)&&(dlsch0->rnti>0)&& + } else if ((dlsch0)&&(dlsch0->rnti>0)&& #ifdef PHY_TX_THREAD - (dlsch0->active[subframe] == 0) + (dlsch0->active[subframe] == 0) #else - (dlsch0->active == 0) + (dlsch0->active == 0) #endif - ){ + ) { // clear subframe TX flag since UE is not scheduled for PDSCH in this subframe (so that we don't look for PUCCH later) dlsch0->subframe_tx[subframe]=0; } - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,0); - } - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_PHICH,1); generate_phich_top(eNB, - proc, - AMP); + proc, + AMP); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_PHICH,0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+(eNB->CC_id),0); + if (do_meas==1) stop_meas(&eNB->dlsch_ue_specific); + if (do_meas==1) stop_meas(&eNB->phy_proc_tx); - } void srs_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; const int subframe = proc->subframe_rx; const int frame = proc->frame_rx; - int i; - + if (is_srs_occasion_common (fp, frame, subframe)) { - - // Do SRS processing + // Do SRS processing // check if there is SRS and we have to use shortened format // TODO: check for exceptions in transmission of SRS together with ACK/NACK for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (eNB->soundingrs_ul_config_dedicated[i].active == 1) { - - - if (lte_srs_channel_estimation (fp, &eNB->common_vars, &eNB->srs_vars[i], &eNB->soundingrs_ul_config_dedicated[i], subframe, 0 /*eNB_id */ )) { - LOG_E (PHY, "problem processing SRS\n"); - } - eNB->soundingrs_ul_config_dedicated[i].active = 0; + if (lte_srs_channel_estimation (fp, &eNB->common_vars, &eNB->srs_vars[i], &eNB->soundingrs_ul_config_dedicated[i], subframe, 0 /*eNB_id */ )) { + LOG_E (PHY, "problem processing SRS\n"); + } + + eNB->soundingrs_ul_config_dedicated[i].active = 0; } } } } void fill_sr_indication(PHY_VARS_eNB *eNB,uint16_t rnti,int frame,int subframe,uint32_t stat) { - pthread_mutex_lock(&eNB->UL_INFO_mutex); nfapi_sr_indication_t *sr_ind = &eNB->UL_INFO.sr_ind; nfapi_sr_indication_body_t *sr_ind_body = &sr_ind->sr_indication_body; nfapi_sr_indication_pdu_t *pdu = &sr_ind_body->sr_pdu_list[sr_ind_body->number_of_srs]; - sr_ind->sfn_sf = frame<<4|subframe; sr_ind->header.message_id = NFAPI_RX_SR_INDICATION; - sr_ind_body->tl.tag = NFAPI_SR_INDICATION_BODY_TAG; - pdu->instance_length = 0; // don't know what to do with this // pdu->rx_ue_information.handle = handle; pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; pdu->rx_ue_information.rnti = rnti; - int SNRtimes10 = dB_fixed_times10(stat) - 300;//(10*eNB->measurements.n0_power_dB[0]); - - - pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; - + if (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi=0; else if (SNRtimes10 > 635) pdu->ul_cqi_information.ul_cqi=255; else pdu->ul_cqi_information.ul_cqi=(640+SNRtimes10)/5; + pdu->ul_cqi_information.channel = 0; - sr_ind_body->number_of_srs++; pthread_mutex_unlock(&eNB->UL_INFO_mutex); } -void uci_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) -{ +void uci_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; - uint8_t SR_payload = 0,pucch_b0b1[4][2]= {{0,0},{0,0},{0,0},{0,0}},harq_ack[4]={0,0,0,0}; - int32_t metric[4]={0,0,0,0},metric_SR=0,max_metric=0; + uint8_t SR_payload = 0,pucch_b0b1[4][2]= {{0,0},{0,0},{0,0},{0,0}},harq_ack[4]= {0,0,0,0}; + int32_t metric[4]= {0,0,0,0},metric_SR=0,max_metric=0; const int subframe = proc->subframe_rx; const int frame = proc->frame_rx; int i; LTE_eNB_UCI *uci; uint16_t tdd_multiplexing_mask=0; - - for (i=0;i<NUMBER_OF_UE_MAX;i++) { - - + + for (i=0; i<NUMBER_OF_UE_MAX; i++) { uci = &eNB->uci_vars[i]; + if ((uci->active == 1) && (uci->frame == frame) && (uci->subframe == subframe)) { - LOG_D (PHY, "Frame %d, subframe %d: Running uci procedures (type %d) for %d \n", frame, subframe, uci->type, i); uci->active = 0; - + // Null out PUCCH PRBs for noise measurement switch (fp->N_RB_UL) { - case 6: - eNB->rb_mask_ul[0] |= (0x1 | (1 << 5)); //position 5 - break; - case 15: - eNB->rb_mask_ul[0] |= (0x1 | (1 << 14)); // position 14 - break; - case 25: - eNB->rb_mask_ul[0] |= (0x1 | (1 << 24)); // position 24 - break; - case 50: - eNB->rb_mask_ul[0] |= 0x1; - eNB->rb_mask_ul[1] |= (1 << 17); // position 49 (49-32) - break; - case 75: - eNB->rb_mask_ul[0] |= 0x1; - eNB->rb_mask_ul[2] |= (1 << 10); // position 74 (74-64) - break; - case 100: - eNB->rb_mask_ul[0] |= 0x1; - eNB->rb_mask_ul[3] |= (1 << 3); // position 99 (99-96) - break; - default: - LOG_E (PHY, "Unknown number for N_RB_UL %d\n", fp->N_RB_UL); - break; + case 6: + eNB->rb_mask_ul[0] |= (0x1 | (1 << 5)); //position 5 + break; + + case 15: + eNB->rb_mask_ul[0] |= (0x1 | (1 << 14)); // position 14 + break; + + case 25: + eNB->rb_mask_ul[0] |= (0x1 | (1 << 24)); // position 24 + break; + + case 50: + eNB->rb_mask_ul[0] |= 0x1; + eNB->rb_mask_ul[1] |= (1 << 17); // position 49 (49-32) + break; + + case 75: + eNB->rb_mask_ul[0] |= 0x1; + eNB->rb_mask_ul[2] |= (1 << 10); // position 74 (74-64) + break; + + case 100: + eNB->rb_mask_ul[0] |= 0x1; + eNB->rb_mask_ul[3] |= (1 << 3); // position 99 (99-96) + break; + + default: + LOG_E (PHY, "Unknown number for N_RB_UL %d\n", fp->N_RB_UL); + break; } + SR_payload = 0; + switch (uci->type) { - case SR: - case HARQ_SR: - { - int pucch1_thres = (uci->ue_type == 0) ? eNB->pucch1_DTX_threshold : eNB->pucch1_DTX_threshold_emtc[0]; - metric_SR = rx_pucch(eNB, - uci->pucch_fmt, - i, - uci->n_pucch_1_0_sr[0], - 0, // n2_pucch - uci->srs_active, // shortened format - &SR_payload, - frame, - subframe, - pucch1_thres -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,uci->ue_type + case SR: + case HARQ_SR: { + int pucch1_thres = (uci->ue_type == 0) ? eNB->pucch1_DTX_threshold : eNB->pucch1_DTX_threshold_emtc[0]; + metric_SR = rx_pucch(eNB, + uci->pucch_fmt, + i, + uci->n_pucch_1_0_sr[0], + 0, // n2_pucch + uci->srs_active, // shortened format + &SR_payload, + frame, + subframe, + pucch1_thres +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + ,uci->ue_type #endif - ); - LOG_D(PHY,"[eNB %d][SR %x] Frame %d subframe %d Checking SR is %d (uci.type %d SR n1pucch is %d)\n", - eNB->Mod_id, - uci->rnti, - frame, - subframe, - SR_payload, - uci->type, - uci->n_pucch_1_0_sr[0]); - if (uci->type == SR) { - if (SR_payload == 1) { - fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR); - break; - } - else { - break; - } - } - } - case HARQ: - { - int pucch1ab_thres = (uci->ue_type == 0) ? eNB->pucch1ab_DTX_threshold : eNB->pucch1ab_DTX_threshold_emtc[0]; - if (fp->frame_type == FDD) { - LOG_D(PHY,"Frame %d Subframe %d Demodulating PUCCH (UCI %d) for ACK/NAK (uci->pucch_fmt %d,uci->type %d.uci->frame %d, uci->subframe %d): n1_pucch0 %d SR_payload %d\n", - frame,subframe,i, - uci->pucch_fmt,uci->type, - uci->frame,uci->subframe,uci->n_pucch_1[0][0], - SR_payload); - - metric[0] = rx_pucch(eNB, - uci->pucch_fmt, - i, - uci->n_pucch_1[0][0], - 0, //n2_pucch - uci->srs_active, // shortened format - pucch_b0b1[0], - frame, - subframe, - pucch1ab_thres -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,uci->ue_type + ); + LOG_D(PHY,"[eNB %d][SR %x] Frame %d subframe %d Checking SR is %d (uci.type %d SR n1pucch is %d)\n", + eNB->Mod_id, + uci->rnti, + frame, + subframe, + SR_payload, + uci->type, + uci->n_pucch_1_0_sr[0]); + + if (uci->type == SR) { + if (SR_payload == 1) { + fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR); + break; + } else { + break; + } + } + } + + case HARQ: { + int pucch1ab_thres = (uci->ue_type == 0) ? eNB->pucch1ab_DTX_threshold : eNB->pucch1ab_DTX_threshold_emtc[0]; + + if (fp->frame_type == FDD) { + LOG_D(PHY,"Frame %d Subframe %d Demodulating PUCCH (UCI %d) for ACK/NAK (uci->pucch_fmt %d,uci->type %d.uci->frame %d, uci->subframe %d): n1_pucch0 %d SR_payload %d\n", + frame,subframe,i, + uci->pucch_fmt,uci->type, + uci->frame,uci->subframe,uci->n_pucch_1[0][0], + SR_payload); + metric[0] = rx_pucch(eNB, + uci->pucch_fmt, + i, + uci->n_pucch_1[0][0], + 0, //n2_pucch + uci->srs_active, // shortened format + pucch_b0b1[0], + frame, + subframe, + pucch1ab_thres +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + ,uci->ue_type #endif - ); - //dump_ulsch(eNB,frame,subframe,0,0); exit(-1); - - - /* cancel SR detection if reception on n1_pucch0 is better than on SR PUCCH resource index, otherwise send it up to MAC */ - if (uci->type==HARQ_SR && metric[0] > metric_SR) SR_payload = 0; - else if (SR_payload == 1) fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR); - - if (uci->type==HARQ_SR && metric[0] <= metric_SR) { - /* when transmitting ACK/NACK on SR PUCCH resource index, SR payload is always 1 */ - SR_payload = 1; - - metric[0]=rx_pucch(eNB, - uci->pucch_fmt, - i, - uci->n_pucch_1_0_sr[0], - 0, //n2_pucch - uci->srs_active, // shortened format - pucch_b0b1[0], - frame, - subframe, - pucch1ab_thres -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,uci->ue_type + ); + + //dump_ulsch(eNB,frame,subframe,0,0); exit(-1); + + /* cancel SR detection if reception on n1_pucch0 is better than on SR PUCCH resource index, otherwise send it up to MAC */ + if (uci->type==HARQ_SR && metric[0] > metric_SR) SR_payload = 0; + else if (SR_payload == 1) fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR); + + if (uci->type==HARQ_SR && metric[0] <= metric_SR) { + /* when transmitting ACK/NACK on SR PUCCH resource index, SR payload is always 1 */ + SR_payload = 1; + metric[0]=rx_pucch(eNB, + uci->pucch_fmt, + i, + uci->n_pucch_1_0_sr[0], + 0, //n2_pucch + uci->srs_active, // shortened format + pucch_b0b1[0], + frame, + subframe, + pucch1ab_thres +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + ,uci->ue_type #endif - ); - } - - - LOG_D(PHY,"[eNB %d][PDSCH %x] Frame %d subframe %d pucch1a (FDD) payload %d (metric %d)\n", - eNB->Mod_id, - uci->rnti, - frame,subframe, - pucch_b0b1[0][0],metric[0]); - - uci->stat = metric[0]; - fill_uci_harq_indication(eNB,uci,frame,subframe,pucch_b0b1[0],0,0xffff); - - } - else { // frame_type == TDD - LOG_D(PHY,"Frame %d Subframe %d Demodulating PUCCH (UCI %d) for ACK/NAK (uci->pucch_fmt %d,uci->type %d.uci->frame %d, uci->subframe %d): n1_pucch0 %d SR_payload %d\n", - frame,subframe,i, - uci->pucch_fmt,uci->type, - uci->frame,uci->subframe,uci->n_pucch_1[0][0], - SR_payload); + ); + } + + LOG_D(PHY,"[eNB %d][PDSCH %x] Frame %d subframe %d pucch1a (FDD) payload %d (metric %d)\n", + eNB->Mod_id, + uci->rnti, + frame,subframe, + pucch_b0b1[0][0],metric[0]); + uci->stat = metric[0]; + fill_uci_harq_indication(eNB,uci,frame,subframe,pucch_b0b1[0],0,0xffff); + } else { // frame_type == TDD + LOG_D(PHY,"Frame %d Subframe %d Demodulating PUCCH (UCI %d) for ACK/NAK (uci->pucch_fmt %d,uci->type %d.uci->frame %d, uci->subframe %d): n1_pucch0 %d SR_payload %d\n", + frame,subframe,i, + uci->pucch_fmt,uci->type, + uci->frame,uci->subframe,uci->n_pucch_1[0][0], + SR_payload); #if 1 - metric[0] = rx_pucch(eNB, - uci->pucch_fmt, - i, - uci->n_pucch_1[0][0], - 0, //n2_pucch - uci->srs_active, // shortened format - pucch_b0b1[0], - frame, - subframe, - pucch1ab_thres -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,uci->ue_type + metric[0] = rx_pucch(eNB, + uci->pucch_fmt, + i, + uci->n_pucch_1[0][0], + 0, //n2_pucch + uci->srs_active, // shortened format + pucch_b0b1[0], + frame, + subframe, + pucch1ab_thres +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + ,uci->ue_type #endif - ); - - if (uci->type==HARQ_SR && metric[0] > metric_SR) SR_payload = 0; - else if (SR_payload == 1) fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR); - - if (uci->type==HARQ_SR && metric[0] <= metric_SR) { - SR_payload = 1; - metric[0] = rx_pucch(eNB, - pucch_format1b, - i, - uci->n_pucch_1_0_sr[0], - 0, //n2_pucch - uci->srs_active, // shortened format - pucch_b0b1[0], - frame, - subframe, - pucch1ab_thres -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,uci->ue_type + ); + + if (uci->type==HARQ_SR && metric[0] > metric_SR) SR_payload = 0; + else if (SR_payload == 1) fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR); + + if (uci->type==HARQ_SR && metric[0] <= metric_SR) { + SR_payload = 1; + metric[0] = rx_pucch(eNB, + pucch_format1b, + i, + uci->n_pucch_1_0_sr[0], + 0, //n2_pucch + uci->srs_active, // shortened format + pucch_b0b1[0], + frame, + subframe, + pucch1ab_thres +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + ,uci->ue_type #endif - ); - - } + ); + } + #else - // if SR was detected, use the n1_pucch from SR - if (SR_payload==1) { + + // if SR was detected, use the n1_pucch from SR + if (SR_payload==1) { #ifdef DEBUG_PHY_PROC - LOG_D (PHY, "[eNB %d][PDSCH %x] Frame %d subframe %d Checking ACK/NAK (%d,%d,%d,%d) format %d with SR\n", eNB->Mod_id, - eNB->dlsch[UE_id][0]->rnti, frame, subframe, n1_pucch0, n1_pucch1, n1_pucch2, n1_pucch3, format); + LOG_D (PHY, "[eNB %d][PDSCH %x] Frame %d subframe %d Checking ACK/NAK (%d,%d,%d,%d) format %d with SR\n", eNB->Mod_id, + eNB->dlsch[UE_id][0]->rnti, frame, subframe, n1_pucch0, n1_pucch1, n1_pucch2, n1_pucch3, format); #endif - - metric[0] = rx_pucch (eNB, pucch_format1b, i, uci->n_pucch_1_0_sr[0], 0, //n2_pucch - uci->srs_active, // shortened format - pucch_b0b1[0], frame, subframe, - pucch1ab_thres + metric[0] = rx_pucch (eNB, pucch_format1b, i, uci->n_pucch_1_0_sr[0], 0, //n2_pucch + uci->srs_active, // shortened format + pucch_b0b1[0], frame, subframe, + pucch1ab_thres #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,uci->ue_type + ,uci->ue_type #endif - ); - } else { //using assigned pucch resources + ); + } else { //using assigned pucch resources #ifdef DEBUG_PHY_PROC - LOG_D (PHY, "[eNB %d][PDSCH %x] Frame %d subframe %d Checking ACK/NAK M=%d (%d,%d,%d,%d) format %d\n", eNB->Mod_id, - eNB->dlsch[UE_id][0]->rnti, - frame, subframe, uci->num_pucch_resources, uci->n_pucch_1[res][0], uci->n_pucch_1[res][1], uci->n_pucch_1[res][2], uci->n_pucch_1[res][3], uci->pucch_fmt); + LOG_D (PHY, "[eNB %d][PDSCH %x] Frame %d subframe %d Checking ACK/NAK M=%d (%d,%d,%d,%d) format %d\n", eNB->Mod_id, + eNB->dlsch[UE_id][0]->rnti, + frame, subframe, uci->num_pucch_resources, uci->n_pucch_1[res][0], uci->n_pucch_1[res][1], uci->n_pucch_1[res][2], uci->n_pucch_1[res][3], uci->pucch_fmt); #endif - for (res = 0; res < uci->num_pucch_resources; res++) - metric[res] = rx_pucch (eNB, uci->pucch_fmt, i, uci->n_pucch_1[res][0], 0, // n2_pucch - uci->srs_active, // shortened format - pucch_b0b1[res], frame, subframe, - pucch1ab_thres + + for (res = 0; res < uci->num_pucch_resources; res++) + metric[res] = rx_pucch (eNB, uci->pucch_fmt, i, uci->n_pucch_1[res][0], 0, // n2_pucch + uci->srs_active, // shortened format + pucch_b0b1[res], frame, subframe, + pucch1ab_thres #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,uci->ue_type -#endif - ); - for (res=0;res<uci->num_pucch_resources;res++) - metric[res] = rx_pucch(eNB, - uci->pucch_fmt, - i, - uci->n_pucch_1[res][0], - 0, // n2_pucch - uci->srs_active, // shortened format - pucch_b0b1[res], - frame, - subframe, - pucch1ab_thres + ,uci->ue_type +#endif + ); + + for (res=0; res<uci->num_pucch_resources; res++) + metric[res] = rx_pucch(eNB, + uci->pucch_fmt, + i, + uci->n_pucch_1[res][0], + 0, // n2_pucch + uci->srs_active, // shortened format + pucch_b0b1[res], + frame, + subframe, + pucch1ab_thres #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,uci->ue_type -#endif - ); - } + ,uci->ue_type +#endif + ); + } + #ifdef DEBUG_PHY_PROC - LOG_D(PHY,"RNTI %x type %d SR_payload %d Frame %d Subframe %d pucch_b0b1[0][0] %d pucch_b0b1[0][1] %d pucch_b0b1[1][0] %d pucch_b0b1[1][1] %d \n", - uci->rnti,uci->type,SR_payload,frame,subframe,pucch_b0b1[0][0],pucch_b0b1[0][1],pucch_b0b1[1][0],pucch_b0b1[1][1]); + LOG_D(PHY,"RNTI %x type %d SR_payload %d Frame %d Subframe %d pucch_b0b1[0][0] %d pucch_b0b1[0][1] %d pucch_b0b1[1][0] %d pucch_b0b1[1][1] %d \n", + uci->rnti,uci->type,SR_payload,frame,subframe,pucch_b0b1[0][0],pucch_b0b1[0][1],pucch_b0b1[1][0],pucch_b0b1[1][1]); #endif #endif - if (SR_payload == 1) { // this implements Table 7.3.1 from 36.213 - if (pucch_b0b1[0][0] == 4) { // there isn't a likely transmission - harq_ack[0] = 4; // DTX - } - else if (pucch_b0b1[0][0] == 1 && pucch_b0b1[0][1] == 1) { // 1/4/7 ACKs - harq_ack[0] = 1; - } - else if (pucch_b0b1[0][0] == 1 && pucch_b0b1[0][1] != 1) { // 2/5/8 ACKs - harq_ack[0] = 2; - } - else if (pucch_b0b1[0][0] != 1 && pucch_b0b1[0][1] == 1) { // 3/6/9 ACKs - harq_ack[0] = 3; - } - else if (pucch_b0b1[0][0] != 1 && pucch_b0b1[0][1] != 1) { // 0 ACKs, or at least one DL assignment missed - harq_ack[0] = 0; - } - uci->stat = metric[0]; - fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,2,0xffff); // special_bundling mode - } - else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==2)){ // multiplexing + no SR, implement Table 10.1.3-5 (Rel14) for multiplexing with M=2 - if (pucch_b0b1[0][0] == 4 || - pucch_b0b1[1][0] == 4) { // there isn't a likely transmission - harq_ack[0] = 4; // DTX - harq_ack[1] = 6; // NACK/DTX - } - else { - if (metric[1]>metric[0]) { - if (pucch_b0b1[1][0] == 1 && pucch_b0b1[1][1] != 1){ - harq_ack[0] = 1; // ACK - harq_ack[1] = 1; // ACK - tdd_multiplexing_mask = 0x3; - } - else if (pucch_b0b1[1][0] != 1 && pucch_b0b1[1][1] == 1){ - harq_ack[0] = 6; // NACK/DTX - harq_ack[1] = 1; // ACK - tdd_multiplexing_mask = 0x2; - } - else { - harq_ack[0] = 4; // DTX - harq_ack[1] = 4; // DTX - } - } - else { - if (pucch_b0b1[0][0] == 1 && pucch_b0b1[0][1] == 1){ - harq_ack[0] = 1; // ACK - harq_ack[1] = 6; // NACK/DTX - tdd_multiplexing_mask = 0x1; - } - else if (pucch_b0b1[0][0] != 1 && pucch_b0b1[0][1] != 1){ - harq_ack[0] = 2; // NACK - harq_ack[1] = 6; // NACK/DTX - } - else { - harq_ack[0] = 4; // DTX - harq_ack[1] = 4; // DTX - } - } - } - uci->stat = max(metric[0],metric[1]); - fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode - } //else if ((uci->tdd_bundling == 0) && (res==2)) - else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==3)){ // multiplexing + no SR, implement Table 10.1.3-6 (Rel14) for multiplexing with M=3 - - if (harq_ack[0] == 4 || - harq_ack[1] == 4 || - harq_ack[2] == 4) { // there isn't a likely transmission - harq_ack[0] = 4; // DTX - harq_ack[1] = 6; // NACK/DTX - harq_ack[2] = 6; // NACK/DTX - max_metric = 0; - } - else { - - max_metric = max(metric[0],max(metric[1],metric[2])); - - if (metric[0]==max_metric) { - if (pucch_b0b1[0][0] == 1 && pucch_b0b1[0][1] == 1){ - harq_ack[0] = 1; // ACK - harq_ack[1] = 6; // NACK/DTX - harq_ack[2] = 6; // NACK/DTX - tdd_multiplexing_mask = 0x1; - } - else if (pucch_b0b1[0][0] != 1 && pucch_b0b1[0][1] != 1){ - harq_ack[0] = 2; // NACK - harq_ack[1] = 6; // NACK/DTX - harq_ack[2] = 6; // NACK/DTX - } - else { - harq_ack[0] = 4; // DTX - harq_ack[1] = 4; // DTX - harq_ack[2] = 4; // DTX - } - } // if (metric[0]==max_metric) { - else if (metric[1]==max_metric) { - - if (pucch_b0b1[1][0] == 1 && pucch_b0b1[1][1] != 1){ - harq_ack[0] = 1; // ACK - harq_ack[1] = 1; // ACK - harq_ack[2] = 6; // NACK/DTX - tdd_multiplexing_mask = 0x3; - } - else if (pucch_b0b1[1][0] != 1 && pucch_b0b1[1][1] == 1 ) { - harq_ack[0] = 6; // NACK/DTX - harq_ack[1] = 1; // ACK - harq_ack[2] = 6; // NACK/DTX - tdd_multiplexing_mask = 0x2; - } - else { - harq_ack[0] = 4; // DTX - harq_ack[1] = 4; // DTX - harq_ack[2] = 4; // DTX - } - } // if (metric[1]==max_metric) { - else { - if (pucch_b0b1[2][0] == 1 && pucch_b0b1[2][1] == 1){ - harq_ack[0] = 1; // ACK - harq_ack[1] = 1; // ACK - harq_ack[2] = 1; // ACK - tdd_multiplexing_mask = 0x7; - } - else if (pucch_b0b1[2][0] == 1 && pucch_b0b1[2][1] != 1 ) { - harq_ack[0] = 1; // ACK - harq_ack[1] = 6; // NACK/DTX - harq_ack[2] = 1; // ACK - tdd_multiplexing_mask = 0x5; - } - else if (pucch_b0b1[2][0] != 1 && pucch_b0b1[2][1] == 1 ) { - harq_ack[0] = 6; // NACK/DTX - harq_ack[1] = 1; // ACK - harq_ack[2] = 1; // ACK - tdd_multiplexing_mask = 0x6; - } - else if (pucch_b0b1[2][0] != 1 && pucch_b0b1[2][1] != 1 ) { - harq_ack[0] = 6; // NACK/DTX - harq_ack[1] = 6; // NACK/DTX - harq_ack[2] = 1; // ACK - tdd_multiplexing_mask = 0x4; - } - } - uci->stat = max_metric; - fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode - } - } //else if ((uci->tdd_bundling == 0) && (res==3)) - else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==4)){ // multiplexing + no SR, implement Table 10.1.3-7 (Rel14) for multiplexing with M=4 - if (pucch_b0b1[0][0] == 4 || - pucch_b0b1[1][0] == 4 || - pucch_b0b1[2][0] == 4 || - pucch_b0b1[3][0] == 4) { // there isn't a likely transmission - harq_ack[0] = 4; // DTX - harq_ack[1] = 6; // NACK/DTX - harq_ack[2] = 6; // NACK/DTX - harq_ack[3] = 6; // NACK/DTX - max_metric = 0; - } else { - - max_metric = max(metric[0],max(metric[1],max(metric[2],metric[3]))); - - if (metric[0]==max_metric) { - if (pucch_b0b1[0][0] == 1 && pucch_b0b1[0][1] != 1){ - harq_ack[0] = 2; // NACK - harq_ack[1] = 4; // DTX - harq_ack[2] = 4; // DTX - harq_ack[3] = 4; // DTX - } - else if (pucch_b0b1[0][0] != 1 && pucch_b0b1[0][1] == 1){ - harq_ack[0] = 1; // ACK - harq_ack[1] = 6; // NACK/DTX - harq_ack[2] = 6; // NACK/DTX - harq_ack[3] = 1; // ACK - tdd_multiplexing_mask = 0x9; - } - else if (pucch_b0b1[0][0] == 1 && pucch_b0b1[0][1] == 1){ - harq_ack[0] = 1; // ACK - harq_ack[1] = 6; // NACK/DTX - harq_ack[2] = 6; // NACK/DTX - harq_ack[3] = 6; // NACK/DTX - tdd_multiplexing_mask = 0x1; - } - else if (pucch_b0b1[0][0] != 1 && pucch_b0b1[0][1] != 1){ - harq_ack[0] = 2; // NACK - harq_ack[1] = 6; // NACK/DTX - harq_ack[2] = 6; // NACK/DTX - harq_ack[3] = 6; // NACK/DTX - } - - } - else if (metric[1]==max_metric) { - if (pucch_b0b1[1][0] == 1 && pucch_b0b1[1][1] == 1){ - harq_ack[0] = 1; // ACK - harq_ack[1] = 1; // ACK - harq_ack[2] = 1; // ACK - harq_ack[3] = 1; // ACK - tdd_multiplexing_mask = 0xF; - } - else if (pucch_b0b1[1][0] == 1 && pucch_b0b1[1][1] != 1 ) { - harq_ack[0] = 1; // ACK - harq_ack[1] = 1; // ACK - harq_ack[2] = 6; // NACK/DTX - harq_ack[3] = 6; // NACK/DTX - tdd_multiplexing_mask = 0x3; - } - else if (pucch_b0b1[1][0] != 1 && pucch_b0b1[1][1] != 1 ) { - harq_ack[0] = 6; // NACK/DTX - harq_ack[1] = 1; // ACK - harq_ack[2] = 1; // ACK - harq_ack[3] = 1; // ACK - tdd_multiplexing_mask = 0xE; - } - else if (pucch_b0b1[1][0] != 1 && pucch_b0b1[1][1] == 1 ) { - harq_ack[0] = 6; // NACK/DTX - harq_ack[1] = 1; // ACK - harq_ack[2] = 6; // NACK/DTX - harq_ack[3] = 6; // NACK/DTX - tdd_multiplexing_mask = 0x2; - } - } - else if (metric[2]==max_metric) { - if (pucch_b0b1[2][0] == 1 && pucch_b0b1[2][1] == 1){ - harq_ack[0] = 1; // ACK - harq_ack[1] = 1; // ACK - harq_ack[2] = 1; // ACK - harq_ack[3] = 6; // NACK/DTX - tdd_multiplexing_mask = 0x7; - } - else if (pucch_b0b1[2][0] == 1 && pucch_b0b1[2][1] != 1 ) { - harq_ack[0] = 1; // ACK - harq_ack[1] = 6; // NACK/DTX - harq_ack[2] = 1; // ACK - harq_ack[3] = 6; // NACK/DTX - tdd_multiplexing_mask = 0x5; - } - else if (pucch_b0b1[2][0] != 1 && pucch_b0b1[2][1] == 1 ) { - harq_ack[0] = 4; // NACK/DTX - harq_ack[1] = 1; // ACK - harq_ack[2] = 1; // ACK - harq_ack[3] = 4; // NACK/DTX - tdd_multiplexing_mask = 0x6; - } - else if (pucch_b0b1[2][0] != 1 && pucch_b0b1[2][1] != 1 ) { - harq_ack[0] = 4; // NACK/DTX - harq_ack[1] = 4; // NACK/DTX - harq_ack[2] = 1; // ACK - harq_ack[3] = 4; // NACK/DTX - tdd_multiplexing_mask = 0x4; - } - } - else { // max_metric[3]=max_metric - if (pucch_b0b1[2][0] == 1 && pucch_b0b1[2][1] == 1){ - harq_ack[0] = 1; // ACK - harq_ack[1] = 6; // NACK/DTX - harq_ack[2] = 1; // ACK - harq_ack[3] = 1; // ACK - tdd_multiplexing_mask = 0xD; - } - else if (pucch_b0b1[2][0] == 1 && pucch_b0b1[2][1] != 1 ) { - harq_ack[0] = 6; // NACK/DTX - harq_ack[1] = 1; // ACK - harq_ack[2] = 6; // NACK/DTX - harq_ack[3] = 1; // ACK - tdd_multiplexing_mask = 0xA; - } - else if (pucch_b0b1[2][0] != 1 && pucch_b0b1[2][1] == 1 ) { - harq_ack[0] = 6; // NACK/DTX - harq_ack[1] = 6; // NACK/DTX - harq_ack[2] = 1; // ACK - harq_ack[3] = 1; // ACK - tdd_multiplexing_mask = 0xC; - } - else if (pucch_b0b1[2][0] != 1 && pucch_b0b1[2][1] != 1 ) { - harq_ack[0] = 6; // NACK/DTX - harq_ack[1] = 6; // NACK/DTX - harq_ack[2] = 6; // NACK/DTX - harq_ack[3] = 1; // ACK - tdd_multiplexing_mask = 0x8; - } - } - } - uci->stat = max_metric; - fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode - } // else if ((uci->tdd_bundling == 0) && (res==4)) - else { // bundling - harq_ack[0] = pucch_b0b1[0][0]; - harq_ack[1] = pucch_b0b1[0][1]; - uci->stat = metric[0]; - LOG_D(PHY,"bundling: (%d,%d), metric %d\n",harq_ack[0],harq_ack[1],uci->stat); - fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,0,0xffff); // special_bundling mode - } - + + if (SR_payload == 1) { // this implements Table 7.3.1 from 36.213 + if (pucch_b0b1[0][0] == 4) { // there isn't a likely transmission + harq_ack[0] = 4; // DTX + } else if (pucch_b0b1[0][0] == 1 && pucch_b0b1[0][1] == 1) { // 1/4/7 ACKs + harq_ack[0] = 1; + } else if (pucch_b0b1[0][0] == 1 && pucch_b0b1[0][1] != 1) { // 2/5/8 ACKs + harq_ack[0] = 2; + } else if (pucch_b0b1[0][0] != 1 && pucch_b0b1[0][1] == 1) { // 3/6/9 ACKs + harq_ack[0] = 3; + } else if (pucch_b0b1[0][0] != 1 && pucch_b0b1[0][1] != 1) { // 0 ACKs, or at least one DL assignment missed + harq_ack[0] = 0; + } + + uci->stat = metric[0]; + fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,2,0xffff); // special_bundling mode + } else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==2)) { // multiplexing + no SR, implement Table 10.1.3-5 (Rel14) for multiplexing with M=2 + if (pucch_b0b1[0][0] == 4 || + pucch_b0b1[1][0] == 4) { // there isn't a likely transmission + harq_ack[0] = 4; // DTX + harq_ack[1] = 6; // NACK/DTX + } else { + if (metric[1]>metric[0]) { + if (pucch_b0b1[1][0] == 1 && pucch_b0b1[1][1] != 1) { + harq_ack[0] = 1; // ACK + harq_ack[1] = 1; // ACK + tdd_multiplexing_mask = 0x3; + } else if (pucch_b0b1[1][0] != 1 && pucch_b0b1[1][1] == 1) { + harq_ack[0] = 6; // NACK/DTX + harq_ack[1] = 1; // ACK + tdd_multiplexing_mask = 0x2; + } else { + harq_ack[0] = 4; // DTX + harq_ack[1] = 4; // DTX + } + } else { + if (pucch_b0b1[0][0] == 1 && pucch_b0b1[0][1] == 1) { + harq_ack[0] = 1; // ACK + harq_ack[1] = 6; // NACK/DTX + tdd_multiplexing_mask = 0x1; + } else if (pucch_b0b1[0][0] != 1 && pucch_b0b1[0][1] != 1) { + harq_ack[0] = 2; // NACK + harq_ack[1] = 6; // NACK/DTX + } else { + harq_ack[0] = 4; // DTX + harq_ack[1] = 4; // DTX + } + } + } + + uci->stat = max(metric[0],metric[1]); + fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode + } //else if ((uci->tdd_bundling == 0) && (res==2)) + else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==3)) { // multiplexing + no SR, implement Table 10.1.3-6 (Rel14) for multiplexing with M=3 + if (harq_ack[0] == 4 || + harq_ack[1] == 4 || + harq_ack[2] == 4) { // there isn't a likely transmission + harq_ack[0] = 4; // DTX + harq_ack[1] = 6; // NACK/DTX + harq_ack[2] = 6; // NACK/DTX + max_metric = 0; + } else { + max_metric = max(metric[0],max(metric[1],metric[2])); + + if (metric[0]==max_metric) { + if (pucch_b0b1[0][0] == 1 && pucch_b0b1[0][1] == 1) { + harq_ack[0] = 1; // ACK + harq_ack[1] = 6; // NACK/DTX + harq_ack[2] = 6; // NACK/DTX + tdd_multiplexing_mask = 0x1; + } else if (pucch_b0b1[0][0] != 1 && pucch_b0b1[0][1] != 1) { + harq_ack[0] = 2; // NACK + harq_ack[1] = 6; // NACK/DTX + harq_ack[2] = 6; // NACK/DTX + } else { + harq_ack[0] = 4; // DTX + harq_ack[1] = 4; // DTX + harq_ack[2] = 4; // DTX + } + } // if (metric[0]==max_metric) { + else if (metric[1]==max_metric) { + if (pucch_b0b1[1][0] == 1 && pucch_b0b1[1][1] != 1) { + harq_ack[0] = 1; // ACK + harq_ack[1] = 1; // ACK + harq_ack[2] = 6; // NACK/DTX + tdd_multiplexing_mask = 0x3; + } else if (pucch_b0b1[1][0] != 1 && pucch_b0b1[1][1] == 1 ) { + harq_ack[0] = 6; // NACK/DTX + harq_ack[1] = 1; // ACK + harq_ack[2] = 6; // NACK/DTX + tdd_multiplexing_mask = 0x2; + } else { + harq_ack[0] = 4; // DTX + harq_ack[1] = 4; // DTX + harq_ack[2] = 4; // DTX + } + } // if (metric[1]==max_metric) { + else { + if (pucch_b0b1[2][0] == 1 && pucch_b0b1[2][1] == 1) { + harq_ack[0] = 1; // ACK + harq_ack[1] = 1; // ACK + harq_ack[2] = 1; // ACK + tdd_multiplexing_mask = 0x7; + } else if (pucch_b0b1[2][0] == 1 && pucch_b0b1[2][1] != 1 ) { + harq_ack[0] = 1; // ACK + harq_ack[1] = 6; // NACK/DTX + harq_ack[2] = 1; // ACK + tdd_multiplexing_mask = 0x5; + } else if (pucch_b0b1[2][0] != 1 && pucch_b0b1[2][1] == 1 ) { + harq_ack[0] = 6; // NACK/DTX + harq_ack[1] = 1; // ACK + harq_ack[2] = 1; // ACK + tdd_multiplexing_mask = 0x6; + } else if (pucch_b0b1[2][0] != 1 && pucch_b0b1[2][1] != 1 ) { + harq_ack[0] = 6; // NACK/DTX + harq_ack[1] = 6; // NACK/DTX + harq_ack[2] = 1; // ACK + tdd_multiplexing_mask = 0x4; + } + } + + uci->stat = max_metric; + fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode + } + } //else if ((uci->tdd_bundling == 0) && (res==3)) + else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==4)) { // multiplexing + no SR, implement Table 10.1.3-7 (Rel14) for multiplexing with M=4 + if (pucch_b0b1[0][0] == 4 || + pucch_b0b1[1][0] == 4 || + pucch_b0b1[2][0] == 4 || + pucch_b0b1[3][0] == 4) { // there isn't a likely transmission + harq_ack[0] = 4; // DTX + harq_ack[1] = 6; // NACK/DTX + harq_ack[2] = 6; // NACK/DTX + harq_ack[3] = 6; // NACK/DTX + max_metric = 0; + } else { + max_metric = max(metric[0],max(metric[1],max(metric[2],metric[3]))); + + if (metric[0]==max_metric) { + if (pucch_b0b1[0][0] == 1 && pucch_b0b1[0][1] != 1) { + harq_ack[0] = 2; // NACK + harq_ack[1] = 4; // DTX + harq_ack[2] = 4; // DTX + harq_ack[3] = 4; // DTX + } else if (pucch_b0b1[0][0] != 1 && pucch_b0b1[0][1] == 1) { + harq_ack[0] = 1; // ACK + harq_ack[1] = 6; // NACK/DTX + harq_ack[2] = 6; // NACK/DTX + harq_ack[3] = 1; // ACK + tdd_multiplexing_mask = 0x9; + } else if (pucch_b0b1[0][0] == 1 && pucch_b0b1[0][1] == 1) { + harq_ack[0] = 1; // ACK + harq_ack[1] = 6; // NACK/DTX + harq_ack[2] = 6; // NACK/DTX + harq_ack[3] = 6; // NACK/DTX + tdd_multiplexing_mask = 0x1; + } else if (pucch_b0b1[0][0] != 1 && pucch_b0b1[0][1] != 1) { + harq_ack[0] = 2; // NACK + harq_ack[1] = 6; // NACK/DTX + harq_ack[2] = 6; // NACK/DTX + harq_ack[3] = 6; // NACK/DTX + } + } else if (metric[1]==max_metric) { + if (pucch_b0b1[1][0] == 1 && pucch_b0b1[1][1] == 1) { + harq_ack[0] = 1; // ACK + harq_ack[1] = 1; // ACK + harq_ack[2] = 1; // ACK + harq_ack[3] = 1; // ACK + tdd_multiplexing_mask = 0xF; + } else if (pucch_b0b1[1][0] == 1 && pucch_b0b1[1][1] != 1 ) { + harq_ack[0] = 1; // ACK + harq_ack[1] = 1; // ACK + harq_ack[2] = 6; // NACK/DTX + harq_ack[3] = 6; // NACK/DTX + tdd_multiplexing_mask = 0x3; + } else if (pucch_b0b1[1][0] != 1 && pucch_b0b1[1][1] != 1 ) { + harq_ack[0] = 6; // NACK/DTX + harq_ack[1] = 1; // ACK + harq_ack[2] = 1; // ACK + harq_ack[3] = 1; // ACK + tdd_multiplexing_mask = 0xE; + } else if (pucch_b0b1[1][0] != 1 && pucch_b0b1[1][1] == 1 ) { + harq_ack[0] = 6; // NACK/DTX + harq_ack[1] = 1; // ACK + harq_ack[2] = 6; // NACK/DTX + harq_ack[3] = 6; // NACK/DTX + tdd_multiplexing_mask = 0x2; + } + } else if (metric[2]==max_metric) { + if (pucch_b0b1[2][0] == 1 && pucch_b0b1[2][1] == 1) { + harq_ack[0] = 1; // ACK + harq_ack[1] = 1; // ACK + harq_ack[2] = 1; // ACK + harq_ack[3] = 6; // NACK/DTX + tdd_multiplexing_mask = 0x7; + } else if (pucch_b0b1[2][0] == 1 && pucch_b0b1[2][1] != 1 ) { + harq_ack[0] = 1; // ACK + harq_ack[1] = 6; // NACK/DTX + harq_ack[2] = 1; // ACK + harq_ack[3] = 6; // NACK/DTX + tdd_multiplexing_mask = 0x5; + } else if (pucch_b0b1[2][0] != 1 && pucch_b0b1[2][1] == 1 ) { + harq_ack[0] = 4; // NACK/DTX + harq_ack[1] = 1; // ACK + harq_ack[2] = 1; // ACK + harq_ack[3] = 4; // NACK/DTX + tdd_multiplexing_mask = 0x6; + } else if (pucch_b0b1[2][0] != 1 && pucch_b0b1[2][1] != 1 ) { + harq_ack[0] = 4; // NACK/DTX + harq_ack[1] = 4; // NACK/DTX + harq_ack[2] = 1; // ACK + harq_ack[3] = 4; // NACK/DTX + tdd_multiplexing_mask = 0x4; + } + } else { // max_metric[3]=max_metric + if (pucch_b0b1[2][0] == 1 && pucch_b0b1[2][1] == 1) { + harq_ack[0] = 1; // ACK + harq_ack[1] = 6; // NACK/DTX + harq_ack[2] = 1; // ACK + harq_ack[3] = 1; // ACK + tdd_multiplexing_mask = 0xD; + } else if (pucch_b0b1[2][0] == 1 && pucch_b0b1[2][1] != 1 ) { + harq_ack[0] = 6; // NACK/DTX + harq_ack[1] = 1; // ACK + harq_ack[2] = 6; // NACK/DTX + harq_ack[3] = 1; // ACK + tdd_multiplexing_mask = 0xA; + } else if (pucch_b0b1[2][0] != 1 && pucch_b0b1[2][1] == 1 ) { + harq_ack[0] = 6; // NACK/DTX + harq_ack[1] = 6; // NACK/DTX + harq_ack[2] = 1; // ACK + harq_ack[3] = 1; // ACK + tdd_multiplexing_mask = 0xC; + } else if (pucch_b0b1[2][0] != 1 && pucch_b0b1[2][1] != 1 ) { + harq_ack[0] = 6; // NACK/DTX + harq_ack[1] = 6; // NACK/DTX + harq_ack[2] = 6; // NACK/DTX + harq_ack[3] = 1; // ACK + tdd_multiplexing_mask = 0x8; + } + } + } + + uci->stat = max_metric; + fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode + } // else if ((uci->tdd_bundling == 0) && (res==4)) + else { // bundling + harq_ack[0] = pucch_b0b1[0][0]; + harq_ack[1] = pucch_b0b1[0][1]; + uci->stat = metric[0]; + LOG_D(PHY,"bundling: (%d,%d), metric %d\n",harq_ack[0],harq_ack[1],uci->stat); + fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,0,0xffff); // special_bundling mode + } + #ifdef DEBUG_PHY_PROC - LOG_D (PHY, "[eNB %d][PDSCH %x] Frame %d subframe %d ACK/NAK metric 0 %d, metric 1 %d, (%d,%d)\n", eNB->Mod_id, - eNB->dlsch[UE_id][0]->rnti, frame, subframe, metric0, metric1, pucch_b0b1[0], pucch_b0b1[1]); + LOG_D (PHY, "[eNB %d][PDSCH %x] Frame %d subframe %d ACK/NAK metric 0 %d, metric 1 %d, (%d,%d)\n", eNB->Mod_id, + eNB->dlsch[UE_id][0]->rnti, frame, subframe, metric0, metric1, pucch_b0b1[0], pucch_b0b1[1]); #endif - } - break; - default: - AssertFatal (1 == 0, "Unsupported UCI type %d\n", uci->type); - break; - } - - if (SR_payload == 1) { - LOG_D (PHY, "[eNB %d][SR %x] Frame %d subframe %d Got SR for PUSCH, transmitting to MAC\n", eNB->Mod_id, uci->rnti, frame, subframe); - - if (eNB->first_sr[i] == 1) { // this is the first request for uplink after Connection Setup, so clear HARQ process 0 use for Msg4 - eNB->first_sr[i] = 0; - eNB->dlsch[i][0]->harq_processes[0]->round = 0; - eNB->dlsch[i][0]->harq_processes[0]->status = SCH_IDLE; - LOG_D (PHY, "[eNB %d][SR %x] Frame %d subframe %d First SR\n", eNB->Mod_id, eNB->ulsch[i]->rnti, frame, subframe); - } - } + } + + break; + + default: + AssertFatal (1 == 0, "Unsupported UCI type %d\n", uci->type); + break; + } + + if (SR_payload == 1) { + LOG_D (PHY, "[eNB %d][SR %x] Frame %d subframe %d Got SR for PUSCH, transmitting to MAC\n", eNB->Mod_id, uci->rnti, frame, subframe); + + if (eNB->first_sr[i] == 1) { // this is the first request for uplink after Connection Setup, so clear HARQ process 0 use for Msg4 + eNB->first_sr[i] = 0; + eNB->dlsch[i][0]->harq_processes[0]->round = 0; + eNB->dlsch[i][0]->harq_processes[0]->status = SCH_IDLE; + LOG_D (PHY, "[eNB %d][SR %x] Frame %d subframe %d First SR\n", eNB->Mod_id, eNB->ulsch[i]->rnti, frame, subframe); + } + } } } } } -void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) -{ +void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { uint32_t ret=0,i; uint32_t harq_pid; uint8_t nPRS; LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; LTE_eNB_ULSCH_t *ulsch; LTE_UL_eNB_HARQ_t *ulsch_harq; - const int subframe = proc->subframe_rx; const int frame = proc->frame_rx; - uint32_t harq_pid0 = subframe2harq_pid(&eNB->frame_parms,frame,subframe); - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { ulsch = eNB->ulsch[i]; - if (ulsch->ue_type > 0) harq_pid = 0; else harq_pid=harq_pid0; - + + if (ulsch->ue_type > 0) harq_pid = 0; + else harq_pid=harq_pid0; + ulsch_harq = ulsch->harq_processes[harq_pid]; - + if (ulsch->rnti>0) LOG_D(PHY,"eNB->ulsch[%d]->harq_processes[harq_pid:%d] SFN/SF:%04d%d: PUSCH procedures, UE %d/%x ulsch_harq[status:%d SFN/SF:%04d%d handled:%d]\n", - i, harq_pid, frame,subframe,i,ulsch->rnti, - ulsch_harq->status, ulsch_harq->frame, ulsch_harq->subframe, ulsch_harq->handled); - + i, harq_pid, frame,subframe,i,ulsch->rnti, + ulsch_harq->status, ulsch_harq->frame, ulsch_harq->subframe, ulsch_harq->handled); + if ((ulsch) && - (ulsch->rnti>0) && - (ulsch_harq->status == ACTIVE) && - (ulsch_harq->frame == frame) && - (ulsch_harq->subframe == subframe) && - (ulsch_harq->handled == 0)) { - + (ulsch->rnti>0) && + (ulsch_harq->status == ACTIVE) && + (ulsch_harq->frame == frame) && + (ulsch_harq->subframe == subframe) && + (ulsch_harq->handled == 0)) { // UE has ULSCH scheduling for (int rb=0; - rb<=ulsch_harq->nb_rb; - rb++) { - int rb2 = rb+ulsch_harq->first_rb; - eNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31)); + rb<=ulsch_harq->nb_rb; + rb++) { + int rb2 = rb+ulsch_harq->first_rb; + eNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31)); } - + LOG_D(PHY,"[eNB %d] frame %d, subframe %d: Scheduling ULSCH Reception for UE %d \n", eNB->Mod_id, frame, subframe, i); - nPRS = fp->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe<<1]; - ulsch->cyclicShift = (ulsch_harq->n_DMRS2 + - fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift + - nPRS)%12; - AssertFatal(ulsch_harq->TBS>0,"illegal TBS %d\n",ulsch_harq->TBS); + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift + + nPRS)%12; + AssertFatal(ulsch_harq->TBS>0,"illegal TBS %d\n",ulsch_harq->TBS); LOG_D(PHY, - "[eNB %d][PUSCH %d] Frame %d Subframe %d Demodulating PUSCH: dci_alloc %d, rar_alloc %d, round %d, first_rb %d, nb_rb %d, Qm %d, TBS %d, rv %d, cyclic_shift %d (n_DMRS2 %d, cyclicShift_common %d, ), O_ACK %d, beta_cqi %d \n", - eNB->Mod_id,harq_pid,frame,subframe, - ulsch_harq->dci_alloc, - ulsch_harq->rar_alloc, - ulsch_harq->round, - ulsch_harq->first_rb, - ulsch_harq->nb_rb, - ulsch_harq->Qm, - ulsch_harq->TBS, - ulsch_harq->rvidx, - ulsch->cyclicShift, - ulsch_harq->n_DMRS2, - fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift, - ulsch_harq->O_ACK, - ulsch->beta_offset_cqi_times8); - + "[eNB %d][PUSCH %d] Frame %d Subframe %d Demodulating PUSCH: dci_alloc %d, rar_alloc %d, round %d, first_rb %d, nb_rb %d, Qm %d, TBS %d, rv %d, cyclic_shift %d (n_DMRS2 %d, cyclicShift_common %d, ), O_ACK %d, beta_cqi %d \n", + eNB->Mod_id,harq_pid,frame,subframe, + ulsch_harq->dci_alloc, + ulsch_harq->rar_alloc, + ulsch_harq->round, + ulsch_harq->first_rb, + ulsch_harq->nb_rb, + ulsch_harq->Qm, + ulsch_harq->TBS, + ulsch_harq->rvidx, + ulsch->cyclicShift, + ulsch_harq->n_DMRS2, + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift, + ulsch_harq->O_ACK, + ulsch->beta_offset_cqi_times8); start_meas(&eNB->ulsch_demodulation_stats); - rx_ulsch(eNB,proc, i); - stop_meas(&eNB->ulsch_demodulation_stats); - start_meas(&eNB->ulsch_decoding_stats); - ret = ulsch_decoding(eNB,proc, - i, - 0, // control_only_flag - ulsch_harq->V_UL_DAI, - ulsch_harq->nb_rb>20 ? 1 : 0); - + i, + 0, // control_only_flag + ulsch_harq->V_UL_DAI, + ulsch_harq->nb_rb>20 ? 1 : 0); stop_meas(&eNB->ulsch_decoding_stats); - - LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d RNTI %x RX power (%d,%d) N0 (%d,%d) dB ACK (%d,%d), decoding iter %d ulsch_harq->cqi_crc_status:%d ackBits:%d ulsch_decoding_stats[t:%lld max:%lld]\n", - eNB->Mod_id,harq_pid, - frame,subframe, - ulsch->rnti, - dB_fixed(eNB->pusch_vars[i]->ulsch_power[0]), - dB_fixed(eNB->pusch_vars[i]->ulsch_power[1]), - 30,//eNB->measurements.n0_power_dB[0], - 30,//eNB->measurements.n0_power_dB[1], - ulsch_harq->o_ACK[0], - ulsch_harq->o_ACK[1], - ret, - ulsch_harq->cqi_crc_status, - ulsch_harq->O_ACK, - eNB->ulsch_decoding_stats.p_time, eNB->ulsch_decoding_stats.max); - + LOG_D(PHY, + "[eNB %d][PUSCH %d] frame %d subframe %d RNTI %x RX power (%d,%d) N0 (%d,%d) dB ACK (%d,%d), decoding iter %d ulsch_harq->cqi_crc_status:%d ackBits:%d ulsch_decoding_stats[t:%lld max:%lld]\n", + eNB->Mod_id,harq_pid, + frame,subframe, + ulsch->rnti, + dB_fixed(eNB->pusch_vars[i]->ulsch_power[0]), + dB_fixed(eNB->pusch_vars[i]->ulsch_power[1]), + 30,//eNB->measurements.n0_power_dB[0], + 30,//eNB->measurements.n0_power_dB[1], + ulsch_harq->o_ACK[0], + ulsch_harq->o_ACK[1], + ret, + ulsch_harq->cqi_crc_status, + ulsch_harq->O_ACK, + eNB->ulsch_decoding_stats.p_time, eNB->ulsch_decoding_stats.max); //compute the expected ULSCH RX power (for the stats) ulsch_harq->delta_TF = get_hundred_times_delta_IF_eNB(eNB,i,harq_pid, 0); // 0 means bw_factor is not considered - + if (RC.mac != NULL) { /* ulsim dose not use RC.mac context. */ - if (ulsch_harq->cqi_crc_status == 1) { + if (ulsch_harq->cqi_crc_status == 1) { #ifdef DEBUG_PHY_PROC - //if (((frame%10) == 0) || (frame < 50)) - print_CQI(ulsch_harq->o,ulsch_harq->uci_format,0,fp->N_RB_DL); + //if (((frame%10) == 0) || (frame < 50)) + print_CQI(ulsch_harq->o,ulsch_harq->uci_format,0,fp->N_RB_DL); #endif - fill_ulsch_cqi_indication(eNB,frame,subframe,ulsch_harq,ulsch->rnti); - RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag &= (~(1 << subframe)); - } else { - if(RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag & (1 << subframe) ){ - RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag &= (~(1 << subframe)); - RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_timer=30; - LOG_D(PHY,"Frame %d,Subframe %d, We're supposed to get a cqi here. Set cqi_req_timer to 30.\n",frame,subframe); - } - } + fill_ulsch_cqi_indication(eNB,frame,subframe,ulsch_harq,ulsch->rnti); + RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag &= (~(1 << subframe)); + } else { + if(RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag & (1 << subframe) ) { + RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_flag &= (~(1 << subframe)); + RC.mac[eNB->Mod_id]->UE_list.UE_sched_ctrl[i].cqi_req_timer=30; + LOG_D(PHY,"Frame %d,Subframe %d, We're supposed to get a cqi here. Set cqi_req_timer to 30.\n",frame,subframe); + } + } } - + if (ret == (1+MAX_TURBO_ITERATIONS)) { - T(T_ENB_PHY_ULSCH_UE_NACK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(ulsch->rnti), - T_INT(harq_pid)); - - fill_crc_indication(eNB,i,frame,subframe,1); // indicate NAK to MAC - fill_rx_indication(eNB,i,frame,subframe); // indicate SDU to MAC - - LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d UE %d Error receiving ULSCH, round %d/%d (ACK %d,%d)\n", - eNB->Mod_id,harq_pid, - frame,subframe, i, - ulsch_harq->round, - ulsch->Mlimit, - ulsch_harq->o_ACK[0], - ulsch_harq->o_ACK[1]); - - if (ulsch_harq->round >= 3) { - ulsch_harq->status = SCH_IDLE; - ulsch_harq->handled = 0; - ulsch->harq_mask &= ~(1 << harq_pid); - ulsch_harq->round = 0; - } - - MSC_LOG_RX_DISCARDED_MESSAGE( - MSC_PHY_ENB,MSC_PHY_UE, - NULL,0, - "%05u:%02u ULSCH received rnti %x harq id %u round %d", - frame,subframe, - ulsch->rnti,harq_pid, - ulsch_harq->round-1 - ); - - /* Mark the HARQ process to release it later if max transmission reached - * (see below). - * MAC does not send the max transmission count, we have to deal with it - * locally in PHY. - */ - ulsch_harq->handled = 1; + T(T_ENB_PHY_ULSCH_UE_NACK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(ulsch->rnti), + T_INT(harq_pid)); + fill_crc_indication(eNB,i,frame,subframe,1); // indicate NAK to MAC + fill_rx_indication(eNB,i,frame,subframe); // indicate SDU to MAC + LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d UE %d Error receiving ULSCH, round %d/%d (ACK %d,%d)\n", + eNB->Mod_id,harq_pid, + frame,subframe, i, + ulsch_harq->round, + ulsch->Mlimit, + ulsch_harq->o_ACK[0], + ulsch_harq->o_ACK[1]); + + if (ulsch_harq->round >= 3) { + ulsch_harq->status = SCH_IDLE; + ulsch_harq->handled = 0; + ulsch->harq_mask &= ~(1 << harq_pid); + ulsch_harq->round = 0; + } + + MSC_LOG_RX_DISCARDED_MESSAGE( + MSC_PHY_ENB,MSC_PHY_UE, + NULL,0, + "%05u:%02u ULSCH received rnti %x harq id %u round %d", + frame,subframe, + ulsch->rnti,harq_pid, + ulsch_harq->round-1 + ); + /* Mark the HARQ process to release it later if max transmission reached + * (see below). + * MAC does not send the max transmission count, we have to deal with it + * locally in PHY. + */ + ulsch_harq->handled = 1; } // ulsch in error else { - fill_crc_indication(eNB,i,frame,subframe,0); // indicate ACK to MAC - fill_rx_indication(eNB,i,frame,subframe); // indicate SDU to MAC - ulsch_harq->status = SCH_IDLE; - ulsch->harq_mask &= ~(1 << harq_pid); - - T (T_ENB_PHY_ULSCH_UE_ACK, T_INT (eNB->Mod_id), T_INT (frame), T_INT (subframe), T_INT (ulsch->rnti), T_INT (harq_pid)); - - MSC_LOG_RX_MESSAGE( - MSC_PHY_ENB,MSC_PHY_UE, - NULL,0, - "%05u:%02u ULSCH received rnti %x harq id %u", - frame,subframe, - ulsch->rnti,harq_pid - ); - - + fill_crc_indication(eNB,i,frame,subframe,0); // indicate ACK to MAC + fill_rx_indication(eNB,i,frame,subframe); // indicate SDU to MAC + ulsch_harq->status = SCH_IDLE; + ulsch->harq_mask &= ~(1 << harq_pid); + T (T_ENB_PHY_ULSCH_UE_ACK, T_INT (eNB->Mod_id), T_INT (frame), T_INT (subframe), T_INT (ulsch->rnti), T_INT (harq_pid)); + MSC_LOG_RX_MESSAGE( + MSC_PHY_ENB,MSC_PHY_UE, + NULL,0, + "%05u:%02u ULSCH received rnti %x harq id %u", + frame,subframe, + ulsch->rnti,harq_pid + ); #ifdef DEBUG_PHY_PROC #ifdef DEBUG_ULSCH - LOG_D(PHY,"[eNB] Frame %d, Subframe %d : ULSCH SDU (RX harq_pid %d) %d bytes:",frame,subframe, - harq_pid,ulsch_harq->TBS>>3); - - for (j=0; j<ulsch_harq->TBS>>3; j++) - LOG_T(PHY,"%x.",ulsch->harq_processes[harq_pid]->b[j]); - - LOG_T(PHY,"\n"); + LOG_D(PHY,"[eNB] Frame %d, Subframe %d : ULSCH SDU (RX harq_pid %d) %d bytes:",frame,subframe, + harq_pid,ulsch_harq->TBS>>3); + + for (j=0; j<ulsch_harq->TBS>>3; j++) + LOG_T(PHY,"%x.",ulsch->harq_processes[harq_pid]->b[j]); + + LOG_T(PHY,"\n"); #endif #endif } // ulsch not in error - + if (ulsch_harq->O_ACK>0) fill_ulsch_harq_indication(eNB,ulsch_harq,ulsch->rnti,frame,subframe,ulsch->bundling); - + LOG_D(PHY,"[eNB %d] Frame %d subframe %d: received ULSCH harq_pid %d for UE %d, ret = %d, CQI CRC Status %d, ACK %d,%d, ulsch_errors %d/%d\n", - eNB->Mod_id,frame,subframe, - harq_pid, - i, - ret, - ulsch_harq->cqi_crc_status, - ulsch_harq->o_ACK[0], - ulsch_harq->o_ACK[1], - eNB->UE_stats[i].ulsch_errors[harq_pid], - eNB->UE_stats[i].ulsch_decoding_attempts[harq_pid][0]); + eNB->Mod_id,frame,subframe, + harq_pid, + i, + ret, + ulsch_harq->cqi_crc_status, + ulsch_harq->o_ACK[0], + ulsch_harq->o_ACK[1], + eNB->UE_stats[i].ulsch_errors[harq_pid], + eNB->UE_stats[i].ulsch_decoding_attempts[harq_pid][0]); } // if ((ulsch) && // (ulsch->rnti>0) && // (ulsch_harq->status == ACTIVE)) else if ((ulsch) && - (ulsch->rnti>0) && - (ulsch_harq->status == ACTIVE) && - (ulsch_harq->frame == frame) && - (ulsch_harq->subframe == subframe) && - (ulsch_harq->handled == 1)) { + (ulsch->rnti>0) && + (ulsch_harq->status == ACTIVE) && + (ulsch_harq->frame == frame) && + (ulsch_harq->subframe == subframe) && + (ulsch_harq->handled == 1)) { // this harq process is stale, kill it, this 1024 frames later (10s), consider reducing that ulsch_harq->status = SCH_IDLE; ulsch_harq->handled = 0; @@ -1459,26 +1339,18 @@ extern int oai_exit; extern void *td_thread (void *); void init_td_thread(PHY_VARS_eNB *eNB) { - L1_proc_t *proc = &eNB->proc; - proc->tdp.eNB = eNB; proc->instance_cnt_td = -1; - - pthread_attr_init( &proc->attr_td); + pthread_attr_init( &proc->attr_td); pthread_mutex_init( &proc->mutex_td, NULL); pthread_cond_init( &proc->cond_td, NULL); - - pthread_create(&proc->pthread_td, &proc->attr_td, td_thread, (void*)&proc->tdp); - + pthread_create(&proc->pthread_td, &proc->attr_td, td_thread, (void *)&proc->tdp); } void kill_td_thread(PHY_VARS_eNB *eNB) { - L1_proc_t *proc = &eNB->proc; - proc->instance_cnt_td = 0; pthread_cond_signal(&proc->cond_td); - pthread_join(proc->pthread_td, NULL); pthread_mutex_destroy( &proc->mutex_td ); pthread_cond_destroy( &proc->cond_td ); @@ -1487,26 +1359,22 @@ void kill_td_thread(PHY_VARS_eNB *eNB) { extern void *te_thread (void *); void init_te_thread(PHY_VARS_eNB *eNB) { - L1_proc_t *proc = &eNB->proc; - for(int i=0; i<3 ;i++){ + for(int i=0; i<3 ; i++) { proc->tep[i].eNB = eNB; proc->tep[i].instance_cnt_te = -1; - pthread_mutex_init( &proc->tep[i].mutex_te, NULL); pthread_cond_init( &proc->tep[i].cond_te, NULL); pthread_attr_init( &proc->tep[i].attr_te); - LOG_I(PHY,"Creating te_thread %d\n",i); - pthread_create(&proc->tep[i].pthread_te, &proc->tep[i].attr_te, te_thread, (void*)&proc->tep[i]); + pthread_create(&proc->tep[i].pthread_te, &proc->tep[i].attr_te, te_thread, (void *)&proc->tep[i]); } } void kill_te_thread(PHY_VARS_eNB *eNB) { - L1_proc_t *proc = &eNB->proc; - for(int i=0; i<3 ;i++){ + for(int i=0; i<3 ; i++) { proc->tep[i].instance_cnt_te = 0; pthread_cond_signal(&proc->tep[i].cond_te); pthread_join(proc->tep[i].pthread_te, NULL); @@ -1517,74 +1385,76 @@ void kill_te_thread(PHY_VARS_eNB *eNB) { void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe) { nfapi_rx_indication_pdu_t *pdu; - int timing_advance_update; int sync_pos; - uint32_t harq_pid; - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + if (eNB->ulsch[UE_id]->ue_type > 0) harq_pid = 0; else #endif - { - harq_pid = subframe2harq_pid (&eNB->frame_parms, - frame, subframe); - } - + { + harq_pid = subframe2harq_pid (&eNB->frame_parms, + frame, subframe); + } + pthread_mutex_lock(&eNB->UL_INFO_mutex); - eNB->UL_INFO.rx_ind.sfn_sf = frame<<4| subframe; eNB->UL_INFO.rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG; - pdu = &eNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list[eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus]; - // pdu->rx_ue_information.handle = eNB->ulsch[UE_id]->handle; pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; pdu->rx_ue_information.rnti = eNB->ulsch[UE_id]->rnti; pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; pdu->rx_indication_rel8.length = eNB->ulsch[UE_id]->harq_processes[harq_pid]->TBS>>3; pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation - pdu->data = eNB->ulsch[UE_id]->harq_processes[harq_pid]->b; + pdu->data = eNB->ulsch[UE_id]->harq_processes[harq_pid]->b; // estimate timing advance for MAC sync_pos = lte_est_timing_advance_pusch(eNB,UE_id); timing_advance_update = sync_pos; // - eNB->frame_parms.nb_prefix_samples/4; //to check - // if (timing_advance_update > 10) { dump_ulsch(eNB,frame,subframe,UE_id); exit(-1);} // if (timing_advance_update < -10) { dump_ulsch(eNB,frame,subframe,UE_id); exit(-1);} switch (eNB->frame_parms.N_RB_DL) { - case 6: /* nothing to do */ - break; - case 15: - timing_advance_update /= 2; - break; - case 25: - timing_advance_update /= 4; - break; - case 50: - timing_advance_update /= 8; - break; - case 75: - timing_advance_update /= 12; - break; - case 100: - timing_advance_update /= 16; - break; - default: - abort (); + case 6: /* nothing to do */ + break; + + case 15: + timing_advance_update /= 2; + break; + + case 25: + timing_advance_update /= 4; + break; + + case 50: + timing_advance_update /= 8; + break; + + case 75: + timing_advance_update /= 12; + break; + + case 100: + timing_advance_update /= 16; + break; + + default: + abort (); } + // put timing advance command in 0..63 range timing_advance_update += 31; + if (timing_advance_update < 0) timing_advance_update = 0; + if (timing_advance_update > 63) timing_advance_update = 63; + pdu->rx_indication_rel8.timing_advance = timing_advance_update; - // estimate UL_CQI for MAC (from antenna port 0 only) int SNRtimes10 = dB_fixed_times10(eNB->pusch_vars[UE_id]->ulsch_power[0]) - 300;//(10*eNB->measurements.n0_power_dB[0]); - if (SNRtimes10 < -640) pdu->rx_indication_rel8.ul_cqi = 0; @@ -1592,11 +1462,10 @@ void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe) { pdu->rx_indication_rel8.ul_cqi = 255; else pdu->rx_indication_rel8.ul_cqi = (640 + SNRtimes10) / 5; - + LOG_D(PHY,"[PUSCH %d] Frame %d Subframe %d Filling RX_indication with SNR %d (%d), timing_advance %d (update %d)\n", - harq_pid,frame,subframe,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,pdu->rx_indication_rel8.timing_advance, - timing_advance_update); - + harq_pid,frame,subframe,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,pdu->rx_indication_rel8.timing_advance, + timing_advance_update); eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus++; eNB->UL_INFO.rx_ind.sfn_sf = frame<<4 | subframe; pthread_mutex_unlock(&eNB->UL_INFO_mutex); @@ -1604,7 +1473,6 @@ void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe) { /* release the harq if its round is >= 'after_rounds' */ static void do_release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subframe,uint16_t mask, int after_rounds) { - LTE_eNB_DLSCH_t *dlsch0=NULL,*dlsch1=NULL; LTE_DL_eNB_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; int harq_pid; @@ -1614,75 +1482,78 @@ static void do_release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,ui AssertFatal (UE_id < NUMBER_OF_UE_MAX, "returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n", UE_id, NUMBER_OF_UE_MAX); dlsch0 = eNB->dlsch[UE_id][0]; dlsch1 = eNB->dlsch[UE_id][1]; - - if (eNB->frame_parms.frame_type == FDD) { + + if (eNB->frame_parms.frame_type == FDD) { subframe_tx = (subframe+6)%10; frame_tx = ul_ACK_subframe2_dl_frame(&eNB->frame_parms,frame,subframe,subframe_tx); harq_pid = dlsch0->harq_ids[frame_tx%2][subframe_tx]; // or just use 0 for fdd? - AssertFatal((harq_pid>=0) && (harq_pid<10),"harq_pid %d not in 0...9\n",harq_pid); dlsch0_harq = dlsch0->harq_processes[harq_pid]; dlsch1_harq = dlsch1->harq_processes[harq_pid]; AssertFatal(dlsch0_harq!=NULL,"dlsch0_harq is null\n"); - #if T_TRACER + if (after_rounds != -1) { T(T_ENB_PHY_DLSCH_UE_NACK, T_INT(0), T_INT(frame), T_INT(subframe), - T_INT(dlsch0->rnti), T_INT(harq_pid)); + T_INT(dlsch0->rnti), T_INT(harq_pid)); } else { T(T_ENB_PHY_DLSCH_UE_ACK, T_INT(0), T_INT(frame), T_INT(subframe), - T_INT(dlsch0->rnti), T_INT(harq_pid)); + T_INT(dlsch0->rnti), T_INT(harq_pid)); } + #endif - + if (dlsch0_harq->round >= after_rounds) { dlsch0_harq->status = SCH_IDLE; /*if ((dlsch1_harq == NULL)|| - ((dlsch1_harq!=NULL)&& - (dlsch1_harq->status == SCH_IDLE)))*/ + ((dlsch1_harq!=NULL)&& + (dlsch1_harq->status == SCH_IDLE)))*/ dlsch0->harq_mask &= ~(1<<harq_pid); } + LOG_D(PHY,"Frame %d, subframe %d: Releasing harq %d for UE %x\n",frame,subframe,harq_pid,dlsch0->rnti); - - } - else { // release all processes in the bundle that was acked, based on mask + } else { // release all processes in the bundle that was acked, based on mask // This is at most 4 for multiplexing and 9 for bundling/special bundling M=ul_ACK_subframe2_M(&eNB->frame_parms, - subframe); - + subframe); + for (m=0; m<M; m++) { subframe_tx = ul_ACK_subframe2_dl_subframe(&eNB->frame_parms, - subframe, - m); + subframe, + m); frame_tx = ul_ACK_subframe2_dl_frame(&eNB->frame_parms,frame,subframe,subframe_tx); + if (((1<<m)&mask) > 0) { - harq_pid = dlsch0->harq_ids[frame_tx%2][subframe_tx]; - if ((harq_pid>=0) && (harq_pid<dlsch0->Mdlharq)) { - dlsch0_harq = dlsch0->harq_processes[harq_pid]; - dlsch1_harq = dlsch1->harq_processes[harq_pid]; - AssertFatal(dlsch0_harq!=NULL,"dlsch0_harq is null\n"); - + harq_pid = dlsch0->harq_ids[frame_tx%2][subframe_tx]; + + if ((harq_pid>=0) && (harq_pid<dlsch0->Mdlharq)) { + dlsch0_harq = dlsch0->harq_processes[harq_pid]; + dlsch1_harq = dlsch1->harq_processes[harq_pid]; + AssertFatal(dlsch0_harq!=NULL,"dlsch0_harq is null\n"); #if T_TRACER - if (after_rounds != -1) { - T(T_ENB_PHY_DLSCH_UE_NACK, T_INT(0), T_INT(frame), T_INT(subframe), - T_INT(dlsch0->rnti), T_INT(harq_pid)); - } else { - T(T_ENB_PHY_DLSCH_UE_ACK, T_INT(0), T_INT(frame), T_INT(subframe), - T_INT(dlsch0->rnti), T_INT(harq_pid)); - } + + if (after_rounds != -1) { + T(T_ENB_PHY_DLSCH_UE_NACK, T_INT(0), T_INT(frame), T_INT(subframe), + T_INT(dlsch0->rnti), T_INT(harq_pid)); + } else { + T(T_ENB_PHY_DLSCH_UE_ACK, T_INT(0), T_INT(frame), T_INT(subframe), + T_INT(dlsch0->rnti), T_INT(harq_pid)); + } + #endif - if (dlsch0_harq->round >= after_rounds) { - dlsch0_harq->status = SCH_IDLE; - if ((dlsch1_harq == NULL)|| - ((dlsch1_harq!=NULL)&& - (dlsch1_harq->status == SCH_IDLE))) - dlsch0->harq_mask &= ~(1<<harq_pid); - } - } - + + if (dlsch0_harq->round >= after_rounds) { + dlsch0_harq->status = SCH_IDLE; + + if ((dlsch1_harq == NULL)|| + ((dlsch1_harq!=NULL)&& + (dlsch1_harq->status == SCH_IDLE))) + dlsch0->harq_mask &= ~(1<<harq_pid); + } + } } } - } + } } static void release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subframe,uint16_t mask, int is_ack) { @@ -1694,126 +1565,118 @@ static void release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8 } int getM(PHY_VARS_eNB *eNB,int frame,int subframe) { - int M,Mtx=0; LTE_eNB_DLSCH_t *dlsch0=NULL,*dlsch1=NULL; LTE_DL_eNB_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; int harq_pid; int subframe_tx,frame_tx; int m; - M=ul_ACK_subframe2_M(&eNB->frame_parms, - subframe); - + subframe); + for (m=0; m<M; m++) { subframe_tx = ul_ACK_subframe2_dl_subframe(&eNB->frame_parms, - subframe, - m); + subframe, + m); frame_tx = ul_ACK_subframe2_dl_frame(&eNB->frame_parms,frame, subframe,subframe_tx); + if (dlsch0 == NULL || dlsch1 == NULL) { - LOG_E(PHY, "dlsch0 and/or dlsch1 NULL, getM frame %i, subframe %i\n",frame,subframe); - return Mtx; + LOG_E(PHY, "dlsch0 and/or dlsch1 NULL, getM frame %i, subframe %i\n",frame,subframe); + return Mtx; } harq_pid = dlsch0->harq_ids[frame_tx%2][subframe_tx]; - + if (harq_pid>=0 && harq_pid<10) { dlsch0_harq = dlsch0->harq_processes[harq_pid]; dlsch1_harq = dlsch1->harq_processes[harq_pid]; AssertFatal(dlsch0_harq!=NULL,"dlsch0_harq is null\n"); + if (dlsch0_harq->status == ACTIVE|| - (dlsch1_harq!=NULL && dlsch1_harq->status == ACTIVE)) Mtx ++; + (dlsch1_harq!=NULL && dlsch1_harq->status == ACTIVE)) Mtx ++; } } + return (Mtx); } -void fill_ulsch_cqi_indication (PHY_VARS_eNB * eNB, uint16_t frame, uint8_t subframe, LTE_UL_eNB_HARQ_t * ulsch_harq, uint16_t rnti) { - +void fill_ulsch_cqi_indication (PHY_VARS_eNB *eNB, uint16_t frame, uint8_t subframe, LTE_UL_eNB_HARQ_t *ulsch_harq, uint16_t rnti) { pthread_mutex_lock (&eNB->UL_INFO_mutex); nfapi_cqi_indication_pdu_t *pdu = &eNB->UL_INFO.cqi_ind.cqi_pdu_list[eNB->UL_INFO.cqi_ind.number_of_cqis]; nfapi_cqi_indication_raw_pdu_t *raw_pdu = &eNB->UL_INFO.cqi_ind.cqi_raw_pdu_list[eNB->UL_INFO.cqi_ind.number_of_cqis]; - pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; pdu->rx_ue_information.rnti = rnti; + if (ulsch_harq->cqi_crc_status != 1) pdu->cqi_indication_rel9.data_offset = 0; else pdu->cqi_indication_rel9.data_offset = 1; // fill in after all cqi_indications have been generated when non-zero - - // by default set O to rank 1 value + // by default set O to rank 1 value pdu->cqi_indication_rel9.tl.tag = NFAPI_CQI_INDICATION_REL9_TAG; pdu->cqi_indication_rel9.length = (ulsch_harq->Or1>>3) + ((ulsch_harq->Or1&7) > 0 ? 1 : 0); pdu->cqi_indication_rel9.ri[0] = 0; + // if we have RI bits, set them and if rank2 overwrite O if (ulsch_harq->O_RI > 0) { pdu->cqi_indication_rel9.ri[0] = ulsch_harq->o_RI[0]; + if (ulsch_harq->o_RI[0] == 2) pdu->cqi_indication_rel9.length = (ulsch_harq->Or2 >> 3) + ((ulsch_harq->Or2 & 7) > 0 ? 1 : 0); + pdu->cqi_indication_rel9.timing_advance = 0; } - + pdu->cqi_indication_rel9.number_of_cc_reported = 1; pdu->ul_cqi_information.channel = 1; // PUSCH memcpy ((void *) raw_pdu->pdu, ulsch_harq->o, pdu->cqi_indication_rel9.length); eNB->UL_INFO.cqi_ind.number_of_cqis++; LOG_D(PHY,"eNB->UL_INFO.cqi_ind.number_of_cqis:%d\n", eNB->UL_INFO.cqi_ind.number_of_cqis); - pthread_mutex_unlock(&eNB->UL_INFO_mutex); - -} - -void fill_ulsch_harq_indication (PHY_VARS_eNB * eNB, LTE_UL_eNB_HARQ_t * ulsch_harq, uint16_t rnti, int frame, int subframe, int bundling) { +} +void fill_ulsch_harq_indication (PHY_VARS_eNB *eNB, LTE_UL_eNB_HARQ_t *ulsch_harq, uint16_t rnti, int frame, int subframe, int bundling) { int UE_id = find_dlsch(rnti,eNB,SEARCH_EXIST); - if( (UE_id<0) || (UE_id>=NUMBER_OF_UE_MAX) ){ + + if( (UE_id<0) || (UE_id>=NUMBER_OF_UE_MAX) ) { LOG_E(PHY,"illegal UE_id found!!! rnti %04x UE_id %d\n",rnti,UE_id); return; } + //AssertFatal(UE_id>=0,"UE_id doesn't exist\n"); - pthread_mutex_lock(&eNB->UL_INFO_mutex); nfapi_harq_indication_pdu_t *pdu = &eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list[eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs]; int M; int i; - eNB->UL_INFO.harq_ind.header.message_id = NFAPI_HARQ_INDICATION; eNB->UL_INFO.harq_ind.sfn_sf = frame<<4|subframe; - eNB->UL_INFO.harq_ind.harq_indication_body.tl.tag = NFAPI_HARQ_INDICATION_BODY_TAG; - pdu->instance_length = 0; // don't know what to do with this // pdu->rx_ue_information.handle = handle; pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; pdu->rx_ue_information.rnti = rnti; - + if (eNB->frame_parms.frame_type == FDD) { pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG; pdu->harq_indication_fdd_rel13.mode = 0; pdu->harq_indication_fdd_rel13.number_of_ack_nack = ulsch_harq->O_ACK; - + for (i = 0; i < ulsch_harq->O_ACK; i++) { AssertFatal (ulsch_harq->o_ACK[i] == 0 || ulsch_harq->o_ACK[i] == 1, "harq_ack[%d] is %d, should be 1,2 or 4\n", i, ulsch_harq->o_ACK[i]); - pdu->harq_indication_fdd_rel13.harq_tb_n[i] = 2 - ulsch_harq->o_ACK[i]; // release DLSCH if needed - release_harq(eNB,UE_id,i,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); - } } else { // TDD M = ul_ACK_subframe2_M (&eNB->frame_parms, subframe); - pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; pdu->harq_indication_tdd_rel13.mode = 1-bundling; pdu->harq_indication_tdd_rel13.number_of_ack_nack = ulsch_harq->O_ACK; - + for (i = 0; i < ulsch_harq->O_ACK; i++) { AssertFatal (ulsch_harq->o_ACK[i] == 0 || ulsch_harq->o_ACK[i] == 1, "harq_ack[%d] is %d, should be 1,2 or 4\n", i, ulsch_harq->o_ACK[i]); - pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 2-ulsch_harq->o_ACK[i]; // release DLSCH if needed /* TODO: review this code, it's most certainly wrong. @@ -1821,77 +1684,70 @@ void fill_ulsch_harq_indication (PHY_VARS_eNB * eNB, LTE_UL_eNB_HARQ_t * ulsch_h * Basically, call release_harq with 1 as last argument when ACK and 0 when NACK. */ release_harq(eNB,UE_id,i,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); + if (M==1 && ulsch_harq->O_ACK==1 && ulsch_harq->o_ACK[i] == 1) release_harq(eNB,UE_id,0,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); else if (M==1 && ulsch_harq->O_ACK==2 && ulsch_harq->o_ACK[i] == 1) release_harq(eNB,UE_id,i,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); else if (M>1 && ulsch_harq->o_ACK[i] == 1) { - // spatial bundling - release_harq(eNB,UE_id,0,frame,subframe,1<<i, ulsch_harq->o_ACK[i] == 1); - release_harq(eNB,UE_id,1,frame,subframe,1<<i, ulsch_harq->o_ACK[i] == 1); + // spatial bundling + release_harq(eNB,UE_id,0,frame,subframe,1<<i, ulsch_harq->o_ACK[i] == 1); + release_harq(eNB,UE_id,1,frame,subframe,1<<i, ulsch_harq->o_ACK[i] == 1); } } } //LOG_E(PHY,"eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs:%d\n", eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs); eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs++; - pthread_mutex_unlock(&eNB->UL_INFO_mutex); - } -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) { - +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) { int UE_id=find_dlsch(uci->rnti,eNB,SEARCH_EXIST); + //AssertFatal(UE_id>=0,"UE_id doesn't exist rnti:%x\n", uci->rnti); if (UE_id < 0) { LOG_E(PHY,"SFN/SF:%04d%d Unable to find rnti:%x do not send HARQ\n", frame, subframe, uci->rnti); return; } - + pthread_mutex_lock(&eNB->UL_INFO_mutex); - nfapi_harq_indication_t *ind = &eNB->UL_INFO.harq_ind; nfapi_harq_indication_body_t *body = &ind->harq_indication_body; nfapi_harq_indication_pdu_t *pdu = &body->harq_pdu_list[eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs]; - ind->sfn_sf = frame<<4|subframe; ind->header.message_id = NFAPI_HARQ_INDICATION; - body->tl.tag = NFAPI_HARQ_INDICATION_BODY_TAG; - pdu->instance_length = 0; // don't know what to do with this // pdu->rx_ue_information.handle = handle; pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; pdu->rx_ue_information.rnti = uci->rnti; - // estimate UL_CQI for MAC (from antenna port 0 only) pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG; int SNRtimes10 = dB_fixed_times10(uci->stat) - 300;//(10*eNB->measurements.n0_power_dB[0]); - + if (SNRtimes10 < -100) LOG_I (PHY, "uci->stat %d \n", uci->stat); - + if (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi = 0; else if (SNRtimes10 > 635) pdu->ul_cqi_information.ul_cqi = 255; else pdu->ul_cqi_information.ul_cqi = (640 + SNRtimes10) / 5; + pdu->ul_cqi_information.channel = 0; - + if (eNB->frame_parms.frame_type == FDD) { if (uci->pucch_fmt == pucch_format1a) { pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG; - pdu->harq_indication_fdd_rel13.mode = 0; + pdu->harq_indication_fdd_rel13.mode = 0; pdu->harq_indication_fdd_rel13.number_of_ack_nack = 1; - AssertFatal (harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n", harq_ack[0]); pdu->harq_indication_fdd_rel13.harq_tb_n[0] = harq_ack[0]; // release DLSCH if needed release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); - } - else if (uci->pucch_fmt == pucch_format1b) { + } else if (uci->pucch_fmt == pucch_format1b) { pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG; - pdu->harq_indication_fdd_rel13.mode = 0; + pdu->harq_indication_fdd_rel13.mode = 0; pdu->harq_indication_fdd_rel13.number_of_ack_nack = 2; AssertFatal (harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n", harq_ack[0]); AssertFatal (harq_ack[1] == 1 || harq_ack[1] == 2 || harq_ack[1] == 4, "harq_ack[1] is %d, should be 0,1 or 4\n", harq_ack[1]); @@ -1900,202 +1756,197 @@ void fill_uci_harq_indication (PHY_VARS_eNB * eNB, LTE_eNB_UCI * uci, int frame, // release DLSCH if needed release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); release_harq(eNB,UE_id,1,frame,subframe,0xffff, harq_ack[1] == 1); - } - else AssertFatal(1==0,"only format 1a/b for now, received %d\n",uci->pucch_fmt); - } - else { // TDD + } else AssertFatal(1==0,"only format 1a/b for now, received %d\n",uci->pucch_fmt); + } else { // TDD AssertFatal (tdd_mapping_mode == 0 || tdd_mapping_mode == 1 || tdd_mapping_mode == 2, "Illegal tdd_mapping_mode %d\n", tdd_mapping_mode); pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; - pdu->harq_indication_tdd_rel13.mode = tdd_mapping_mode; - LOG_D(PHY,"%s(eNB, uci_harq format %d, rnti:%04x, frame:%d, subframe:%d, tdd_mapping_mode:%d) harq_ack[0]:%d harq_ack[1]:%d\n", __FUNCTION__, uci->pucch_fmt,uci->rnti, frame, subframe, tdd_mapping_mode,harq_ack[0],harq_ack[1]); + pdu->harq_indication_tdd_rel13.mode = tdd_mapping_mode; + LOG_D(PHY,"%s(eNB, uci_harq format %d, rnti:%04x, frame:%d, subframe:%d, tdd_mapping_mode:%d) harq_ack[0]:%d harq_ack[1]:%d\n", __FUNCTION__, uci->pucch_fmt,uci->rnti, frame, subframe, + tdd_mapping_mode,harq_ack[0],harq_ack[1]); + switch (tdd_mapping_mode) { - case 0: // bundling - - if (uci->pucch_fmt == pucch_format1a) { - pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; - pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1; - LOG_D(PHY,"bundling, pucch1a, number of ack nack %d\n",pdu->harq_indication_tdd_rel13.number_of_ack_nack); - AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]); - pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = harq_ack[0]; - // release all bundled DLSCH if needed - release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); - } - else if (uci->pucch_fmt == pucch_format1b) { - pdu->harq_indication_tdd_rel13.number_of_ack_nack = 2; - AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n",harq_ack[0]); - AssertFatal(harq_ack[1] == 1 || harq_ack[1] == 2 || harq_ack[1] == 4, "harq_ack[1] is %d, should be 0,1 or 4\n",harq_ack[1]); - pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; - pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = harq_ack[0]; - pdu->harq_indication_tdd_rel13.harq_data[1].bundling.value_0 = harq_ack[1]; - // release all DLSCH if needed - release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); - release_harq(eNB,UE_id,1,frame,subframe,0xffff, harq_ack[1] == 1); - } - break; - case 1: // multiplexing - AssertFatal (uci->pucch_fmt == pucch_format1b, "uci->pucch_format %d is not format1b\n", uci->pucch_fmt); - - if (uci->num_pucch_resources == 1 && uci->pucch_fmt == pucch_format1a) { - pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; - pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1; - AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]); - pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0]; - // release all DLSCH if needed - release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); - } - else if (uci->num_pucch_resources == 1 && uci->pucch_fmt == pucch_format1b) { - pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; - pdu->harq_indication_tdd_rel13.number_of_ack_nack = 2; - AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n",harq_ack[0]); - AssertFatal(harq_ack[1] == 1 || harq_ack[1] == 2 || harq_ack[1] == 4, "harq_ack[1] is %d, should be 0,1 or 4\n",harq_ack[1]); - pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0]; - pdu->harq_indication_tdd_rel13.harq_data[1].multiplex.value_0 = harq_ack[1]; - // release all DLSCH if needed - release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); - release_harq(eNB,UE_id,1,frame,subframe,0xffff, harq_ack[1] == 1); - } - else { // num_pucch_resources (M) > 1 - pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; - pdu->harq_indication_tdd_rel13.number_of_ack_nack = uci->num_pucch_resources; - - pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0]; - pdu->harq_indication_tdd_rel13.harq_data[1].multiplex.value_0 = harq_ack[1]; - if (uci->num_pucch_resources == 3) pdu->harq_indication_tdd_rel13.harq_data[2].multiplex.value_0 = harq_ack[2]; - if (uci->num_pucch_resources == 4) pdu->harq_indication_tdd_rel13.harq_data[3].multiplex.value_0 = harq_ack[3]; - // spatial-bundling in this case so release both HARQ if necessary - release_harq(eNB,UE_id,0,frame,subframe,tdd_multiplexing_mask, 1 /* force release? previous code was unconditional */); - release_harq(eNB,UE_id,1,frame,subframe,tdd_multiplexing_mask, 1 /* force release? previous code was unconditional */); - } - break; - case 2: // special bundling (SR collision) - pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; - pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1; - pdu->harq_indication_tdd_rel13.mode = 0; - int tdd_config5_sf2scheds=0; - if (eNB->frame_parms.tdd_config==5) tdd_config5_sf2scheds = getM(eNB,frame,subframe); - - switch (harq_ack[0]) { - case 0: - case 4: - pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; - /* TODO: release_harq here? this whole code looks suspicious */ - break; - case 1: // check if M=1,4,7 - if (uci->num_pucch_resources == 1 || uci->num_pucch_resources == 4 || - tdd_config5_sf2scheds == 1 || tdd_config5_sf2scheds == 4 || tdd_config5_sf2scheds == 7) { - pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; - release_harq(eNB,UE_id,0,frame,subframe,0xffff, 1); - release_harq(eNB,UE_id,1,frame,subframe,0xffff, 1); - }else{ - pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; - } - break; - case 2: // check if M=2,5,8 - if (uci->num_pucch_resources == 2 || tdd_config5_sf2scheds == 2 || - tdd_config5_sf2scheds == 5 || tdd_config5_sf2scheds == 8) { - pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; - release_harq(eNB,UE_id,0,frame,subframe,0xffff, 1); - release_harq(eNB,UE_id,1,frame,subframe,0xffff, 1); - }else{ - pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; - } - break; - case 3: // check if M=3,6,9 - if (uci->num_pucch_resources == 3 || tdd_config5_sf2scheds == 3 || - tdd_config5_sf2scheds == 6 || tdd_config5_sf2scheds == 9) { - pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; - release_harq(eNB,UE_id,0,frame,subframe,0xffff, 1); - release_harq(eNB,UE_id,1,frame,subframe,0xffff, 1); - }else{ - pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; - } - break; - } - break; - + case 0: // bundling + if (uci->pucch_fmt == pucch_format1a) { + pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; + pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1; + LOG_D(PHY,"bundling, pucch1a, number of ack nack %d\n",pdu->harq_indication_tdd_rel13.number_of_ack_nack); + AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]); + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = harq_ack[0]; + // release all bundled DLSCH if needed + release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + } else if (uci->pucch_fmt == pucch_format1b) { + pdu->harq_indication_tdd_rel13.number_of_ack_nack = 2; + AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n",harq_ack[0]); + AssertFatal(harq_ack[1] == 1 || harq_ack[1] == 2 || harq_ack[1] == 4, "harq_ack[1] is %d, should be 0,1 or 4\n",harq_ack[1]); + pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = harq_ack[0]; + pdu->harq_indication_tdd_rel13.harq_data[1].bundling.value_0 = harq_ack[1]; + // release all DLSCH if needed + release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + release_harq(eNB,UE_id,1,frame,subframe,0xffff, harq_ack[1] == 1); + } + + break; + + case 1: // multiplexing + AssertFatal (uci->pucch_fmt == pucch_format1b, "uci->pucch_format %d is not format1b\n", uci->pucch_fmt); + + if (uci->num_pucch_resources == 1 && uci->pucch_fmt == pucch_format1a) { + pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; + pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1; + AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]); + pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0]; + // release all DLSCH if needed + release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + } else if (uci->num_pucch_resources == 1 && uci->pucch_fmt == pucch_format1b) { + pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; + pdu->harq_indication_tdd_rel13.number_of_ack_nack = 2; + AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n",harq_ack[0]); + AssertFatal(harq_ack[1] == 1 || harq_ack[1] == 2 || harq_ack[1] == 4, "harq_ack[1] is %d, should be 0,1 or 4\n",harq_ack[1]); + pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0]; + pdu->harq_indication_tdd_rel13.harq_data[1].multiplex.value_0 = harq_ack[1]; + // release all DLSCH if needed + release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + release_harq(eNB,UE_id,1,frame,subframe,0xffff, harq_ack[1] == 1); + } else { // num_pucch_resources (M) > 1 + pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; + pdu->harq_indication_tdd_rel13.number_of_ack_nack = uci->num_pucch_resources; + pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0]; + pdu->harq_indication_tdd_rel13.harq_data[1].multiplex.value_0 = harq_ack[1]; + + if (uci->num_pucch_resources == 3) pdu->harq_indication_tdd_rel13.harq_data[2].multiplex.value_0 = harq_ack[2]; + + if (uci->num_pucch_resources == 4) pdu->harq_indication_tdd_rel13.harq_data[3].multiplex.value_0 = harq_ack[3]; + + // spatial-bundling in this case so release both HARQ if necessary + release_harq(eNB,UE_id,0,frame,subframe,tdd_multiplexing_mask, 1 /* force release? previous code was unconditional */); + release_harq(eNB,UE_id,1,frame,subframe,tdd_multiplexing_mask, 1 /* force release? previous code was unconditional */); + } + + break; + + case 2: // special bundling (SR collision) + pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; + pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1; + pdu->harq_indication_tdd_rel13.mode = 0; + int tdd_config5_sf2scheds=0; + + if (eNB->frame_parms.tdd_config==5) tdd_config5_sf2scheds = getM(eNB,frame,subframe); + + switch (harq_ack[0]) { + case 0: + case 4: + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; + /* TODO: release_harq here? this whole code looks suspicious */ + break; + + case 1: // check if M=1,4,7 + if (uci->num_pucch_resources == 1 || uci->num_pucch_resources == 4 || + tdd_config5_sf2scheds == 1 || tdd_config5_sf2scheds == 4 || tdd_config5_sf2scheds == 7) { + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; + release_harq(eNB,UE_id,0,frame,subframe,0xffff, 1); + release_harq(eNB,UE_id,1,frame,subframe,0xffff, 1); + } else { + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; + } + + break; + + case 2: // check if M=2,5,8 + if (uci->num_pucch_resources == 2 || tdd_config5_sf2scheds == 2 || + tdd_config5_sf2scheds == 5 || tdd_config5_sf2scheds == 8) { + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; + release_harq(eNB,UE_id,0,frame,subframe,0xffff, 1); + release_harq(eNB,UE_id,1,frame,subframe,0xffff, 1); + } else { + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; + } + + break; + + case 3: // check if M=3,6,9 + if (uci->num_pucch_resources == 3 || tdd_config5_sf2scheds == 3 || + tdd_config5_sf2scheds == 6 || tdd_config5_sf2scheds == 9) { + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; + release_harq(eNB,UE_id,0,frame,subframe,0xffff, 1); + release_harq(eNB,UE_id,1,frame,subframe,0xffff, 1); + } else { + pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; + } + + break; + } + + break; } } //TDD - - + eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs++; LOG_D(PHY,"Incremented eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs:%d\n", eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs); - pthread_mutex_unlock(&eNB->UL_INFO_mutex); + pthread_mutex_unlock(&eNB->UL_INFO_mutex); } -void fill_crc_indication (PHY_VARS_eNB * eNB, int UE_id, int frame, int subframe, uint8_t crc_flag) { - +void fill_crc_indication (PHY_VARS_eNB *eNB, int UE_id, int frame, int subframe, uint8_t crc_flag) { pthread_mutex_lock(&eNB->UL_INFO_mutex); nfapi_crc_indication_pdu_t *pdu = &eNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list[eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs]; - eNB->UL_INFO.crc_ind.sfn_sf = frame<<4 | subframe; eNB->UL_INFO.crc_ind.header.message_id = NFAPI_CRC_INDICATION; eNB->UL_INFO.crc_ind.crc_indication_body.tl.tag = NFAPI_CRC_INDICATION_BODY_TAG; - pdu->instance_length = 0; // don't know what to do with this // pdu->rx_ue_information.handle = handle; - pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; pdu->rx_ue_information.rnti = eNB->ulsch[UE_id]->rnti; pdu->crc_indication_rel8.tl.tag = NFAPI_CRC_INDICATION_REL8_TAG; pdu->crc_indication_rel8.crc_flag = crc_flag; - eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs++; - //LOG_D(PHY, "%s() rnti:%04x crcs:%d crc_flag:%d\n", __FUNCTION__, pdu->rx_ue_information.rnti, eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs, crc_flag); - pthread_mutex_unlock(&eNB->UL_INFO_mutex); } -void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) -{ +void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { //RX processing for ue-specific resources (i LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; const int subframe = proc->subframe_rx; const int frame = proc->frame_rx; - /* TODO: use correct rxdata */ T (T_ENB_PHY_INPUT_SIGNAL, T_INT (eNB->Mod_id), T_INT (frame), T_INT (subframe), T_INT (0), T_BUFFER (&eNB->RU_list[0]->common.rxdata[0][subframe * eNB->frame_parms.samples_per_tti], eNB->frame_parms.samples_per_tti * 4)); - + if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)!=SF_UL)) return; - + T(T_ENB_PHY_UL_TICK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe)); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_UESPEC, 1 ); - LOG_D (PHY, "[eNB %d] Frame %d: Doing phy_procedures_eNB_uespec_RX(%d)\n", eNB->Mod_id, frame, subframe); - eNB->rb_mask_ul[0] = 0; eNB->rb_mask_ul[1] = 0; eNB->rb_mask_ul[2] = 0; eNB->rb_mask_ul[3] = 0; - // Fix me here, these should be locked eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus = 0; eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs = 0; // Call SRS first since all others depend on presence of SRS or lack thereof srs_procedures (eNB, proc); - eNB->first_run_I0_measurements = 0; - uci_procedures (eNB, proc); - - if (nfapi_mode == 0 || nfapi_mode == 1) { // If PNF or monolithic + + if (NFAPI_MODE==NFAPI_MONOLITHIC || NFAPI_MODE==NFAPI_MODE_PNF) { // If PNF or monolithic pusch_procedures(eNB,proc); } lte_eNB_I0_measurements (eNB, subframe, 0, eNB->first_run_I0_measurements); - int min_I0=1000,max_I0=0; - if ((frame==0) && (subframe==4)) { - for (int i=0;i<eNB->frame_parms.N_RB_UL;i++) { + + if ((frame==0) && (subframe==4)) { + for (int i=0; i<eNB->frame_parms.N_RB_UL; i++) { if (i==(eNB->frame_parms.N_RB_UL>>1) - 1) i+=2; - + if (eNB->measurements.n0_subband_power_tot_dB[i]<min_I0) min_I0 = eNB->measurements.n0_subband_power_tot_dB[i]; + if (eNB->measurements.n0_subband_power_tot_dB[i]>max_I0) max_I0 = eNB->measurements.n0_subband_power_tot_dB[i]; - } + LOG_I (PHY, "max_I0 %d, min_I0 %d\n", max_I0, min_I0); } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_UESPEC, 0 ); } diff --git a/openair1/SCHED/prach_procedures.c b/openair1/SCHED/prach_procedures.c index 534f67b16c3189dad756df50f3e29352ff996d58..18fc1e5313b3e958f1007e02a88dee6c66ac09cb 100644 --- a/openair1/SCHED/prach_procedures.c +++ b/openair1/SCHED/prach_procedures.c @@ -37,6 +37,7 @@ #include "fapi_l1.h" #include "nfapi_pnf.h" #include "common/utils/LOG/log.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "common/utils/LOG/vcd_signal_dumper.h" @@ -46,92 +47,86 @@ #include <time.h> #if defined(ENABLE_ITTI) -# include "intertask_interface.h" + #include "intertask_interface.h" #endif -extern uint32_t nfapi_mode; extern int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind); void prach_procedures(PHY_VARS_eNB *eNB #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , - int br_flag + , + int br_flag #endif - ) { + ) { uint16_t max_preamble[4],max_preamble_energy[4],max_preamble_delay[4]; uint16_t i; int frame,subframe; - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + if (br_flag==1) { subframe = eNB->proc.subframe_prach_br; frame = eNB->proc.frame_prach_br; pthread_mutex_lock(&eNB->UL_INFO_mutex); eNB->UL_INFO.rach_ind_br.rach_indication_body.number_of_preambles=0; pthread_mutex_unlock(&eNB->UL_INFO_mutex); - } - else + } else #endif - { - pthread_mutex_lock(&eNB->UL_INFO_mutex); - eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles=0; - pthread_mutex_unlock(&eNB->UL_INFO_mutex); - subframe = eNB->proc.subframe_prach; - frame = eNB->proc.frame_prach; - } + { + pthread_mutex_lock(&eNB->UL_INFO_mutex); + eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles=0; + pthread_mutex_unlock(&eNB->UL_INFO_mutex); + subframe = eNB->proc.subframe_prach; + frame = eNB->proc.frame_prach; + } + RU_t *ru; int aa=0; int ru_aa; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PRACH_RX,1); - - - for (i=0;i<eNB->num_RU;i++) { + for (i=0; i<eNB->num_RU; i++) { ru=eNB->RU_list[i]; - for (ru_aa=0,aa=0;ru_aa<ru->nb_rx;ru_aa++,aa++) { + + for (ru_aa=0,aa=0; ru_aa<ru->nb_rx; ru_aa++,aa++) { eNB->prach_vars.rxsigF[0][aa] = eNB->RU_list[i]->prach_rxsigF[ru_aa]; #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) int ce_level; if (br_flag==1) - for (ce_level=0;ce_level<4;ce_level++) eNB->prach_vars_br.rxsigF[ce_level][aa] = eNB->RU_list[i]->prach_rxsigF_br[ce_level][ru_aa]; + for (ce_level=0; ce_level<4; ce_level++) eNB->prach_vars_br.rxsigF[ce_level][aa] = eNB->RU_list[i]->prach_rxsigF_br[ce_level][ru_aa]; + #endif } } // run PRACH detection for CE-level 0 only for now when br_flag is set rx_prach(eNB, - eNB->RU_list[0], - &max_preamble[0], - &max_preamble_energy[0], - &max_preamble_delay[0], - frame, - 0 + eNB->RU_list[0], + &max_preamble[0], + &max_preamble_energy[0], + &max_preamble_delay[0], + frame, + 0 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,br_flag + ,br_flag #endif - ); - + ); LOG_D(PHY,"[RAPROC] Frame %d, subframe %d : BR %d Most likely preamble %d, energy %d dB delay %d (prach_energy counter %d)\n", frame,subframe,br_flag, max_preamble[0], max_preamble_energy[0]/10, max_preamble_delay[0], - eNB->prach_energy_counter); - + eNB->prach_energy_counter); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + if (br_flag==1) { int prach_mask; - prach_mask = is_prach_subframe (&eNB->frame_parms, eNB->proc.frame_prach_br, eNB->proc.subframe_prach_br); - eNB->UL_INFO.rach_ind_br.rach_indication_body.preamble_list = eNB->preamble_list_br; int ind = 0; int ce_level = 0; - /* Save for later, it doesn't work + /* Save for later, it doesn't work for (int ind=0,ce_level=0;ce_level<4;ce_level++) { if ((eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[ce_level]==1)&& @@ -144,7 +139,6 @@ void prach_procedures(PHY_VARS_eNB *eNB if (eNB->frame_parms.prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[0] == 1) { if ((eNB->prach_energy_counter == 100) && (max_preamble_energy[0] > eNB->measurements.prach_I0 + eNB->prach_DTX_threshold_emtc[0])) { eNB->UL_INFO.rach_ind_br.rach_indication_body.number_of_preambles++; - eNB->preamble_list_br[ind].preamble_rel8.timing_advance = max_preamble_delay[ind]; // eNB->preamble_list_br[ind].preamble_rel8.preamble = max_preamble[ind]; // note: fid is implicitly 0 here, this is the rule for eMTC RA-RNTI from 36.321, Section 5.1.4 @@ -159,69 +153,61 @@ void prach_procedures(PHY_VARS_eNB *eNB eNB->preamble_list_br[ind].preamble_rel8.preamble, eNB->preamble_list_br[ind].preamble_rel8.rnti, eNB->preamble_list_br[ind].preamble_rel13.rach_resource_type); } } - /* - ind++; - } - } */// ce_level - } - else -#endif - { - if ((eNB->prach_energy_counter == 100) && - (max_preamble_energy[0] > eNB->measurements.prach_I0+eNB->prach_DTX_threshold)) { - - LOG_I(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure with preamble %d, energy %d.%d dB, delay %d\n", - eNB->Mod_id, - eNB->CC_id, - frame, - subframe, - max_preamble[0], - max_preamble_energy[0]/10, - max_preamble_energy[0]%10, - max_preamble_delay[0]); - - T(T_ENB_PHY_INITIATE_RA_PROCEDURE, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), - T_INT(max_preamble[0]), T_INT(max_preamble_energy[0]), T_INT(max_preamble_delay[0])); - - pthread_mutex_lock(&eNB->UL_INFO_mutex); - - eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles = 1; - eNB->UL_INFO.rach_ind.rach_indication_body.preamble_list = &eNB->preamble_list[0]; - eNB->UL_INFO.rach_ind.rach_indication_body.tl.tag = NFAPI_RACH_INDICATION_BODY_TAG; - eNB->UL_INFO.rach_ind.header.message_id = NFAPI_RACH_INDICATION; - eNB->UL_INFO.rach_ind.sfn_sf = frame<<4 | subframe; - - eNB->preamble_list[0].preamble_rel8.tl.tag = NFAPI_PREAMBLE_REL8_TAG; - eNB->preamble_list[0].preamble_rel8.timing_advance = max_preamble_delay[0]; - eNB->preamble_list[0].preamble_rel8.preamble = max_preamble[0]; - eNB->preamble_list[0].preamble_rel8.rnti = 1+subframe; // note: fid is implicitly 0 here - eNB->preamble_list[0].preamble_rel13.rach_resource_type = 0; - eNB->preamble_list[0].instance_length = 0; //don't know exactly what this is - - if (nfapi_mode == 1) { // If NFAPI PNF then we need to send the message to the VNF - - LOG_D(PHY,"Filling NFAPI indication for RACH : SFN_SF:%d TA %d, Preamble %d, rnti %x, rach_resource_type %d\n", - NFAPI_SFNSF2DEC(eNB->UL_INFO.rach_ind.sfn_sf), - eNB->preamble_list[0].preamble_rel8.timing_advance, - eNB->preamble_list[0].preamble_rel8.preamble, - eNB->preamble_list[0].preamble_rel8.rnti, - eNB->preamble_list[0].preamble_rel13.rach_resource_type); - - oai_nfapi_rach_ind(&eNB->UL_INFO.rach_ind); - - eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles = 0; - } - - pthread_mutex_unlock(&eNB->UL_INFO_mutex); - - } // max_preamble_energy > prach_I0 + 100 - else { - eNB->measurements.prach_I0 = ((eNB->measurements.prach_I0*900)>>10) + ((max_preamble_energy[0]*124)>>10); - if (frame==0) LOG_I(PHY,"prach_I0 = %d.%d dB\n",eNB->measurements.prach_I0/10,eNB->measurements.prach_I0%10); - if (eNB->prach_energy_counter < 100) eNB->prach_energy_counter++; + /* + ind++; + } + } */// ce_level + } else +#endif + { + if ((eNB->prach_energy_counter == 100) && + (max_preamble_energy[0] > eNB->measurements.prach_I0+eNB->prach_DTX_threshold)) { + LOG_I(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure with preamble %d, energy %d.%d dB, delay %d\n", + eNB->Mod_id, + eNB->CC_id, + frame, + subframe, + max_preamble[0], + max_preamble_energy[0]/10, + max_preamble_energy[0]%10, + max_preamble_delay[0]); + T(T_ENB_PHY_INITIATE_RA_PROCEDURE, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), + T_INT(max_preamble[0]), T_INT(max_preamble_energy[0]), T_INT(max_preamble_delay[0])); + pthread_mutex_lock(&eNB->UL_INFO_mutex); + eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles = 1; + eNB->UL_INFO.rach_ind.rach_indication_body.preamble_list = &eNB->preamble_list[0]; + eNB->UL_INFO.rach_ind.rach_indication_body.tl.tag = NFAPI_RACH_INDICATION_BODY_TAG; + eNB->UL_INFO.rach_ind.header.message_id = NFAPI_RACH_INDICATION; + eNB->UL_INFO.rach_ind.sfn_sf = frame<<4 | subframe; + eNB->preamble_list[0].preamble_rel8.tl.tag = NFAPI_PREAMBLE_REL8_TAG; + eNB->preamble_list[0].preamble_rel8.timing_advance = max_preamble_delay[0]; + eNB->preamble_list[0].preamble_rel8.preamble = max_preamble[0]; + eNB->preamble_list[0].preamble_rel8.rnti = 1+subframe; // note: fid is implicitly 0 here + eNB->preamble_list[0].preamble_rel13.rach_resource_type = 0; + eNB->preamble_list[0].instance_length = 0; //don't know exactly what this is + + if (NFAPI_MODE==NFAPI_MODE_PNF) { // If NFAPI PNF then we need to send the message to the VNF + LOG_D(PHY,"Filling NFAPI indication for RACH : SFN_SF:%d TA %d, Preamble %d, rnti %x, rach_resource_type %d\n", + NFAPI_SFNSF2DEC(eNB->UL_INFO.rach_ind.sfn_sf), + eNB->preamble_list[0].preamble_rel8.timing_advance, + eNB->preamble_list[0].preamble_rel8.preamble, + eNB->preamble_list[0].preamble_rel8.rnti, + eNB->preamble_list[0].preamble_rel13.rach_resource_type); + oai_nfapi_rach_ind(&eNB->UL_INFO.rach_ind); + eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles = 0; } - } // else br_flag + + pthread_mutex_unlock(&eNB->UL_INFO_mutex); + } // max_preamble_energy > prach_I0 + 100 + else { + eNB->measurements.prach_I0 = ((eNB->measurements.prach_I0*900)>>10) + ((max_preamble_energy[0]*124)>>10); + + if (frame==0) LOG_I(PHY,"prach_I0 = %d.%d dB\n",eNB->measurements.prach_I0/10,eNB->measurements.prach_I0%10); + + if (eNB->prach_energy_counter < 100) eNB->prach_energy_counter++; + } + } // else br_flag VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PRACH_RX,0); } diff --git a/openair1/SCHED_UE/pusch_pc.c b/openair1/SCHED_UE/pusch_pc.c index fa38d42c60ab1ddc56505391168221a708d9eaf8..503d73005f25adcc5bd7afe8b8d2fe61ff0af2ea 100644 --- a/openair1/SCHED_UE/pusch_pc.c +++ b/openair1/SCHED_UE/pusch_pc.c @@ -36,12 +36,10 @@ #include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" #include "PHY/phy_extern_ue.h" #include "PHY/LTE_ESTIMATION/lte_estimation.h" +#include "nfapi/oai_integration/vendor_ext.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) -{ +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; @@ -51,9 +49,8 @@ int16_t get_hundred_times_delta_IF(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t harq_p 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; + 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) @@ -67,34 +64,24 @@ int16_t get_hundred_times_delta_IF(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t harq_p 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) -{ - - +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; + 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), @@ -104,10 +91,9 @@ void pusch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_ 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; + 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; @@ -126,13 +112,11 @@ void pusch_power_cntl(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_ 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 +int8_t get_PHR(uint8_t Mod_id, uint8_t CC_id,uint8_t eNB_index) { + if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) + return PHY_vars_UE_g[Mod_id][CC_id]->ulsch[eNB_index]->PHR; + else + return 40; // l1l2 simulator => ideal conditions } diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c index 5a5f9852b101f5a6b4881dd1d3c8ad10ac5c32c6..df9114336fcebaf8dcf54604bff864297b7843d0 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -92,11 +92,11 @@ static int tun_alloc(char *dev) { return fd; } -int netlink_init_tun(char *ifprefix) { +int netlink_init_tun(char *ifprefix, int num_if) { int ret; char ifname[64]; - for (int i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (int i = 0; i < num_if; i++) { sprintf(ifname, "oaitun_%.3s%d",ifprefix,i+1); nas_sock_fd[i] = tun_alloc(ifname); diff --git a/openair1/SIMULATION/ETH_TRANSPORT/proto.h b/openair1/SIMULATION/ETH_TRANSPORT/proto.h index d84322da31faacc25cacf54aa954b2a8642a1ab1..ff677d1580696f2f92a4ef07f38984ad77137968 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/proto.h +++ b/openair1/SIMULATION/ETH_TRANSPORT/proto.h @@ -62,6 +62,6 @@ int multicast_link_read_data_from_sock(uint8_t eNB_flag); void clear_eNB_transport_info(uint8_t); void clear_UE_transport_info(uint8_t); int netlink_init(void); -int netlink_init_tun(char *ifsuffix); +int netlink_init_tun(char *ifsuffix, int num_if); #endif /* EMU_PROTO_H_ */ diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index c7916b8dfc22a631251abe49f7838d4bdda748df..084d5b5cefefbde2c014d760d78f50d8f530a5f8 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -66,7 +66,7 @@ #include "SCHED_UE/sched_UE.h" #include "common/config/config_load_configmodule.h" #include "PHY/INIT/phy_init.h" - +#include "nfapi/oai_integration/vendor_ext.h" void feptx_ofdm(RU_t *ru); void feptx_prec(RU_t *ru); @@ -471,7 +471,7 @@ int n_users = 1; int subframe=7; int num_common_dci=0,num_ue_spec_dci=0,num_dci=0,num_pdcch_symbols=1; uint16_t n_rnti=0x1234; -int nfapi_mode=0; + int abstx=0; int Nid_cell=0; int N_RB_DL=25; diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index 3e9623dc2fa5059d9fec9a26315c0baebe9b60b7..588a96ca6d4a16f44b3c1f2c6dbbb61dcb69f26d 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -55,7 +55,7 @@ #include "PHY/TOOLS/lte_phy_scope.h" #include "dummy_functions.c" - +#include "nfapi/oai_integration/vendor_ext.h" #include "common/config/config_load_configmodule.h" double cpuf; #define inMicroS(a) (((double)(a))/(cpu_freq_GHz*1000.0)) @@ -81,7 +81,7 @@ double t_tx_min = 1000000000; /*!< \brief initial min process time for tx */ double t_rx_min = 1000000000; /*!< \brief initial min process time for tx */ int n_tx_dropped = 0; /*!< \brief initial max process time for tx */ int n_rx_dropped = 0; /*!< \brief initial max process time for rx */ -int nfapi_mode = 0; + extern void fep_full(RU_t *ru); extern void ru_fep_full_2thread(RU_t *ru); diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 189cf01e0e878b487792a09f83d0fbe2460ca864..55c08079c715abbf976ce7f965565bb592ce38b1 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -54,7 +54,7 @@ #include "common/config/config_userapi.h" #include "RRC_config_tools.h" #include "enb_paramdef.h" - +#include "proto_agent.h" #define RRC_INACTIVITY_THRESH 0 extern uint16_t sf_ahead; @@ -72,7 +72,6 @@ void RCconfig_flexran() { paramdef_t ENBSParams[] = ENBSPARAMS_DESC; config_get(ENBSParams, sizeof(ENBSParams)/sizeof(paramdef_t), NULL); uint16_t num_enbs = ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; - paramdef_t flexranParams[] = FLEXRANPARAMS_DESC; config_get(flexranParams, sizeof(flexranParams)/sizeof(paramdef_t), CONFIG_STRING_NETWORK_CONTROLLER_CONFIG); @@ -102,7 +101,6 @@ void RCconfig_flexran() { RC.flexran[i]->remote_port = *(flexranParams[FLEXRAN_PORT_IDX].uptr); RC.flexran[i]->cache_name = strdup(*(flexranParams[FLEXRAN_CACHE_IDX].strptr)); RC.flexran[i]->node_ctrl_state = strcasecmp(*(flexranParams[FLEXRAN_AWAIT_RECONF_IDX].strptr), "yes") == 0 ? ENB_WAIT : ENB_NORMAL_OPERATION; - RC.flexran[i]->mod_id = i; } } @@ -167,15 +165,16 @@ void RCconfig_L1(void) { RC.eNB[j][0]->eth_params_n .remote_portd); } else { // other midhaul } - // PRACH/PUCCH parameters + // PRACH/PUCCH parameters RC.eNB[j][0]->prach_DTX_threshold = *(L1_ParamList.paramarray[j][L1_PRACH_DTX_THRESHOLD_IDX].iptr); RC.eNB[j][0]->pucch1_DTX_threshold = *(L1_ParamList.paramarray[j][L1_PUCCH1_DTX_THRESHOLD_IDX].iptr); RC.eNB[j][0]->pucch1ab_DTX_threshold = *(L1_ParamList.paramarray[j][L1_PUCCH1AB_DTX_THRESHOLD_IDX].iptr); - for (int ce_level=0;ce_level<4;ce_level++) { - RC.eNB[j][0]->prach_DTX_threshold_emtc[ce_level] = *(L1_ParamList.paramarray[j][L1_PRACH_DTX_EMTC0_THRESHOLD_IDX+ce_level].iptr); - RC.eNB[j][0]->pucch1_DTX_threshold_emtc[ce_level] = *(L1_ParamList.paramarray[j][L1_PUCCH1_DTX_EMTC0_THRESHOLD_IDX+ce_level].iptr); - RC.eNB[j][0]->pucch1ab_DTX_threshold_emtc[ce_level] = *(L1_ParamList.paramarray[j][L1_PUCCH1AB_DTX_EMTC0_THRESHOLD_IDX+ce_level].iptr); + + for (int ce_level=0; ce_level<4; ce_level++) { + RC.eNB[j][0]->prach_DTX_threshold_emtc[ce_level] = *(L1_ParamList.paramarray[j][L1_PRACH_DTX_EMTC0_THRESHOLD_IDX+ce_level].iptr); + RC.eNB[j][0]->pucch1_DTX_threshold_emtc[ce_level] = *(L1_ParamList.paramarray[j][L1_PUCCH1_DTX_EMTC0_THRESHOLD_IDX+ce_level].iptr); + RC.eNB[j][0]->pucch1ab_DTX_threshold_emtc[ce_level] = *(L1_ParamList.paramarray[j][L1_PUCCH1AB_DTX_EMTC0_THRESHOLD_IDX+ce_level].iptr); } }// j=0..num_inst @@ -211,13 +210,11 @@ void RCconfig_macrlc(int macrlc_has_f1[MAX_MAC_INST]) { paramdef_t MacRLC_Params[] = MACRLCPARAMS_DESC; paramlist_def_t MacRLC_ParamList = {CONFIG_STRING_MACRLC_LIST,NULL,0}; config_getlist( &MacRLC_ParamList,MacRLC_Params,sizeof(MacRLC_Params)/sizeof(paramdef_t), NULL); - - config_getlist( &MacRLC_ParamList,MacRLC_Params,sizeof(MacRLC_Params)/sizeof(paramdef_t), NULL); + config_getlist( &MacRLC_ParamList,MacRLC_Params,sizeof(MacRLC_Params)/sizeof(paramdef_t), NULL); if ( MacRLC_ParamList.numelt > 0) { - - RC.nb_macrlc_inst=MacRLC_ParamList.numelt; - mac_top_init_eNB(); + RC.nb_macrlc_inst=MacRLC_ParamList.numelt; + mac_top_init_eNB(); RC.nb_mac_CC = (int *)malloc(RC.nb_macrlc_inst*sizeof(int)); for (j = 0; j < RC.nb_macrlc_inst; j++) { @@ -228,18 +225,18 @@ void RCconfig_macrlc(int macrlc_has_f1[MAX_MAC_INST]) { //printf("PHY_TEST = %d,%d\n", RC.mac[j]->phy_test, j); if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_RRC") == 0) { - // check number of instances is same as RRC/PDCP - printf("Configuring local RRC for MACRLC\n"); + // check number of instances is same as RRC/PDCP + printf("Configuring local RRC for MACRLC\n"); } else if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "f1") == 0) { - printf("Configuring F1 interfaces for MACRLC\n"); - RC.mac[j]->eth_params_n.local_if_name = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_IF_NAME_IDX].strptr)); - RC.mac[j]->eth_params_n.my_addr = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_ADDRESS_IDX].strptr)); - RC.mac[j]->eth_params_n.remote_addr = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_ADDRESS_IDX].strptr)); - RC.mac[j]->eth_params_n.my_portc = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTC_IDX].iptr); - RC.mac[j]->eth_params_n.remote_portc = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTC_IDX].iptr); - RC.mac[j]->eth_params_n.my_portd = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTD_IDX].iptr); - RC.mac[j]->eth_params_n.remote_portd = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTD_IDX].iptr);; - RC.mac[j]->eth_params_n.transp_preference = ETH_UDP_MODE; + printf("Configuring F1 interfaces for MACRLC\n"); + RC.mac[j]->eth_params_n.local_if_name = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_IF_NAME_IDX].strptr)); + RC.mac[j]->eth_params_n.my_addr = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_ADDRESS_IDX].strptr)); + RC.mac[j]->eth_params_n.remote_addr = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_ADDRESS_IDX].strptr)); + RC.mac[j]->eth_params_n.my_portc = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTC_IDX].iptr); + RC.mac[j]->eth_params_n.remote_portc = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTC_IDX].iptr); + RC.mac[j]->eth_params_n.my_portd = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTD_IDX].iptr); + RC.mac[j]->eth_params_n.remote_portd = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTD_IDX].iptr);; + RC.mac[j]->eth_params_n.transp_preference = ETH_UDP_MODE; macrlc_has_f1[j] = 1; } else { // other midhaul AssertFatal(1==0,"MACRLC %d: %s unknown northbound midhaul\n",j, *(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr)); @@ -275,6 +272,7 @@ void RCconfig_macrlc(int macrlc_has_f1[MAX_MAC_INST]) { } }// j=0..num_inst } /*else {// MacRLC_ParamList.numelt > 0 // ignore it + AssertFatal (0, "No " CONFIG_STRING_MACRLC_LIST " configuration found"); }*/ @@ -286,7 +284,6 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { int32_t enb_id = 0; int nb_cc = 0; MessageDef *msg_p = itti_alloc_new_message(TASK_RRC_ENB, RRC_CONFIGURATION_REQ); - ccparams_lte_t ccparams_lte; ccparams_sidelink_t SLconfig; ccparams_eMTC_t eMTCconfig; @@ -338,50 +335,41 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { enb_id = *(ENBParamList.paramarray[i][ENB_ENB_ID_IDX].uptr); } - LOG_I(RRC,"Instance %d: Southbound Transport %s\n",i,*(ENBParamList.paramarray[i][ENB_TRANSPORT_S_PREFERENCE_IDX].strptr)); - - if (strcmp(*(ENBParamList.paramarray[i][ENB_TRANSPORT_S_PREFERENCE_IDX].strptr), "f1") == 0) { - - paramdef_t SCTPParams[] = SCTPPARAMS_DESC; - char aprefix[MAX_OPTNAME_SIZE*2 + 8]; - - sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,i,ENB_CONFIG_STRING_SCTP_CONFIG); - config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix); - - rrc->node_id = *(ENBParamList.paramarray[0][ENB_ENB_ID_IDX].uptr); - LOG_I(ENB_APP,"F1AP: gNB_CU_id[%d] %d\n",k,rrc->node_id); - - rrc->node_name = strdup(*(ENBParamList.paramarray[0][ENB_ENB_NAME_IDX].strptr)); - LOG_I(ENB_APP,"F1AP: gNB_CU_name[%d] %s\n",k,rrc->node_name); - - rrc->eth_params_s.local_if_name = strdup(*(ENBParamList.paramarray[i][ENB_LOCAL_S_IF_NAME_IDX].strptr)); - rrc->eth_params_s.my_addr = strdup(*(ENBParamList.paramarray[i][ENB_LOCAL_S_ADDRESS_IDX].strptr)); - rrc->eth_params_s.remote_addr = strdup(*(ENBParamList.paramarray[i][ENB_REMOTE_S_ADDRESS_IDX].strptr)); - rrc->eth_params_s.my_portc = *(ENBParamList.paramarray[i][ENB_LOCAL_S_PORTC_IDX].uptr); - rrc->eth_params_s.remote_portc = *(ENBParamList.paramarray[i][ENB_REMOTE_S_PORTC_IDX].uptr); - rrc->eth_params_s.my_portd = *(ENBParamList.paramarray[i][ENB_LOCAL_S_PORTD_IDX].uptr); - rrc->eth_params_s.remote_portd = *(ENBParamList.paramarray[i][ENB_REMOTE_S_PORTD_IDX].uptr); - rrc->eth_params_s.transp_preference = ETH_UDP_MODE; - rrc->node_type = ngran_eNB_CU; - rrc->sctp_in_streams = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr); - rrc->sctp_out_streams = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr); - + LOG_I(RRC,"Instance %d: Southbound Transport %s\n",i,*(ENBParamList.paramarray[i][ENB_TRANSPORT_S_PREFERENCE_IDX].strptr)); + + if (strcmp(*(ENBParamList.paramarray[i][ENB_TRANSPORT_S_PREFERENCE_IDX].strptr), "f1") == 0) { + paramdef_t SCTPParams[] = SCTPPARAMS_DESC; + char aprefix[MAX_OPTNAME_SIZE*2 + 8]; + sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,i,ENB_CONFIG_STRING_SCTP_CONFIG); + config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix); + rrc->node_id = *(ENBParamList.paramarray[0][ENB_ENB_ID_IDX].uptr); + LOG_I(ENB_APP,"F1AP: gNB_CU_id[%d] %d\n",k,rrc->node_id); + rrc->node_name = strdup(*(ENBParamList.paramarray[0][ENB_ENB_NAME_IDX].strptr)); + LOG_I(ENB_APP,"F1AP: gNB_CU_name[%d] %s\n",k,rrc->node_name); + rrc->eth_params_s.local_if_name = strdup(*(ENBParamList.paramarray[i][ENB_LOCAL_S_IF_NAME_IDX].strptr)); + rrc->eth_params_s.my_addr = strdup(*(ENBParamList.paramarray[i][ENB_LOCAL_S_ADDRESS_IDX].strptr)); + rrc->eth_params_s.remote_addr = strdup(*(ENBParamList.paramarray[i][ENB_REMOTE_S_ADDRESS_IDX].strptr)); + rrc->eth_params_s.my_portc = *(ENBParamList.paramarray[i][ENB_LOCAL_S_PORTC_IDX].uptr); + rrc->eth_params_s.remote_portc = *(ENBParamList.paramarray[i][ENB_REMOTE_S_PORTC_IDX].uptr); + rrc->eth_params_s.my_portd = *(ENBParamList.paramarray[i][ENB_LOCAL_S_PORTD_IDX].uptr); + rrc->eth_params_s.remote_portd = *(ENBParamList.paramarray[i][ENB_REMOTE_S_PORTD_IDX].uptr); + rrc->eth_params_s.transp_preference = ETH_UDP_MODE; + rrc->node_type = ngran_eNB_CU; + rrc->sctp_in_streams = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr); + rrc->sctp_out_streams = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr); + } else { + // set to ngran_eNB for now, it will get set to ngran_eNB_DU if macrlc entity which uses F1 is present + // Note: we will have to handle the case of ngran_ng_eNB_DU + if (macrlc_has_f1 == 0) { + rrc->node_type = ngran_eNB; + LOG_I(RRC,"Setting node_type to ngran_eNB\n"); + } else { + rrc->node_type = ngran_eNB_DU; + LOG_I(RRC,"Setting node_type to ngran_eNB_DU\n"); } - - else { - // set to ngran_eNB for now, it will get set to ngran_eNB_DU if macrlc entity which uses F1 is present - // Note: we will have to handle the case of ngran_ng_eNB_DU - if (macrlc_has_f1 == 0) { - rrc->node_type = ngran_eNB; - LOG_I(RRC,"Setting node_type to ngran_eNB\n"); - } - else { - rrc->node_type = ngran_eNB_DU; - LOG_I(RRC,"Setting node_type to ngran_eNB_DU\n"); - } - } + } - rrc->nr_cellid = (uint64_t)*(ENBParamList.paramarray[i][ENB_NRCELLID_IDX].u64ptr); + rrc->nr_cellid = (uint64_t)*(ENBParamList.paramarray[i][ENB_NRCELLID_IDX].u64ptr); // search if in active list @@ -642,7 +630,7 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_HOPPINGMODE); else if (strcmp(ccparams_lte.pusch_hoppingMode,"interSubFrame")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_hoppingMode = LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_interSubFrame; - } else if (strcmp(ccparams_lte.pusch_hoppingMode,"intraAndInterSubFrame")==0) { + } else if (strcmp(ccparams_lte.pusch_hoppingMode,"intraAndInterSubFrame")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_hoppingMode = LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_intraAndInterSubFrame; } else AssertFatal (0, @@ -663,9 +651,9 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_ENABLE64QAM); else if (strcmp(ccparams_lte.pusch_enable64QAM, "ENABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_enable64QAM = TRUE; - } else if (strcmp(ccparams_lte.pusch_enable64QAM, "DISABLE") == 0) { + } else if (strcmp(ccparams_lte.pusch_enable64QAM, "DISABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_enable64QAM = FALSE; - } else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_enable64QAM choice: ENABLE,DISABLE!\n", RC.config_file_name, i, ccparams_lte.pusch_enable64QAM); @@ -676,9 +664,9 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN); else if (strcmp(ccparams_lte.pusch_groupHoppingEnabled, "ENABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_groupHoppingEnabled = TRUE; - } else if (strcmp(ccparams_lte.pusch_groupHoppingEnabled, "DISABLE") == 0) { + } else if (strcmp(ccparams_lte.pusch_groupHoppingEnabled, "DISABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_groupHoppingEnabled= FALSE; - } else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pusch_groupHoppingEnabled choice: ENABLE,DISABLE!\n", RC.config_file_name, i, ccparams_lte.pusch_groupHoppingEnabled); @@ -697,7 +685,7 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN); else if (strcmp(ccparams_lte.pusch_sequenceHoppingEnabled, "ENABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_sequenceHoppingEnabled = TRUE; - } else if (strcmp(ccparams_lte.pusch_sequenceHoppingEnabled, "DISABLE") == 0) { + } else if (strcmp(ccparams_lte.pusch_sequenceHoppingEnabled, "DISABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_sequenceHoppingEnabled = FALSE; } else AssertFatal (0, @@ -723,13 +711,13 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { if (strcmp(ccparams_lte.phich_resource,"ONESIXTH")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_oneSixth ; - } else if (strcmp(ccparams_lte.phich_resource,"HALF")==0) { + } else if (strcmp(ccparams_lte.phich_resource,"HALF")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_half; - } else if (strcmp(ccparams_lte.phich_resource,"ONE")==0) { + } else if (strcmp(ccparams_lte.phich_resource,"ONE")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_one; - } else if (strcmp(ccparams_lte.phich_resource,"TWO")==0) { + } else if (strcmp(ccparams_lte.phich_resource,"TWO")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_two; - } else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for phich_resource choice: ONESIXTH,HALF,ONE,TWO!\n", RC.config_file_name, i, ccparams_lte.phich_resource); @@ -740,9 +728,9 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { if (strcmp(ccparams_lte.srs_enable, "ENABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_enable= TRUE; - } else if (strcmp(ccparams_lte.srs_enable, "DISABLE") == 0) { + } else if (strcmp(ccparams_lte.srs_enable, "DISABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_enable= FALSE; - } else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n", RC.config_file_name, i, ccparams_lte.srs_enable); @@ -765,7 +753,7 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { if (strcmp(ccparams_lte.srs_ackNackST, "ENABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_ackNackST= TRUE; - } else if (strcmp(ccparams_lte.srs_ackNackST, "DISABLE") == 0) { + } else if (strcmp(ccparams_lte.srs_ackNackST, "DISABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_ackNackST= FALSE; } else AssertFatal (0, @@ -774,9 +762,9 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { if (strcmp(ccparams_lte.srs_MaxUpPts, "ENABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_MaxUpPts= TRUE; - } else if (strcmp(ccparams_lte.srs_MaxUpPts, "DISABLE") == 0) { + } else if (strcmp(ccparams_lte.srs_MaxUpPts, "DISABLE") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_MaxUpPts= FALSE; - } else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for srs_MaxUpPts choice: ENABLE,DISABLE !\n", RC.config_file_name, i, ccparams_lte.srs_MaxUpPts); @@ -794,19 +782,19 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { if (strcmp(ccparams_lte.pusch_alpha,"AL0")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al0; - } else if (strcmp(ccparams_lte.pusch_alpha,"AL04")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL04")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al04; - } else if (strcmp(ccparams_lte.pusch_alpha,"AL05")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL05")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al05; - } else if (strcmp(ccparams_lte.pusch_alpha,"AL06")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL06")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al06; - } else if (strcmp(ccparams_lte.pusch_alpha,"AL07")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL07")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al07; - } else if (strcmp(ccparams_lte.pusch_alpha,"AL08")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL08")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al08; - } else if (strcmp(ccparams_lte.pusch_alpha,"AL09")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL09")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al09; - } else if (strcmp(ccparams_lte.pusch_alpha,"AL1")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL1")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_UplinkPowerControlCommon__alpha_al1; } @@ -815,19 +803,19 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { if (strcmp(ccparams_lte.pusch_alpha,"AL0")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al0; - } else if (strcmp(ccparams_lte.pusch_alpha,"AL04")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL04")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al04; - } else if (strcmp(ccparams_lte.pusch_alpha,"AL05")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL05")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al05; - } else if (strcmp(ccparams_lte.pusch_alpha,"AL06")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL06")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al06; - } else if (strcmp(ccparams_lte.pusch_alpha,"AL07")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL07")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al07; - } else if (strcmp(ccparams_lte.pusch_alpha,"AL08")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL08")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al08; - } else if (strcmp(ccparams_lte.pusch_alpha,"AL09")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL09")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al09; - } else if (strcmp(ccparams_lte.pusch_alpha,"AL1")==0) { + } else if (strcmp(ccparams_lte.pusch_alpha,"AL1")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al1; } @@ -855,33 +843,33 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF_2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF_2; - } else if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF0")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF0")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF0; - } else if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF2")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF2; - } else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format1 choice: deltaF_2,dltaF0,deltaF2!\n", RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format1); if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF1")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF1; - } else if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF3")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF3")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF3; - } else if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF5")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF5")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF5; - } else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format1b choice: deltaF1,dltaF3,deltaF5!\n", RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format1b); if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF_2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF_2; - } else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF0")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF0")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF0; - } else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF1")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF1")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF1; - } else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF2")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF2; } else AssertFatal (0, @@ -890,22 +878,22 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF_2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2a= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF_2; - } else if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF0")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF0")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2a= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF0; - } else if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF2")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2a= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF2; - } else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2a choice: deltaF_2,dltaF0,deltaF2!\n", RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format2a); if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF_2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF_2; - } else if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF0")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF0")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF0; - } else if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF2")==0) { + } else if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF2")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF2; - } else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pucch_deltaF_Format2b choice: deltaF_2,dltaF0,deltaF2!\n", RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format2b); @@ -931,46 +919,46 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { RC.config_file_name, i, ccparams_lte.rach_sizeOfRA_PreamblesGroupA); switch (ccparams_lte.rach_messageSizeGroupA) { - case 56: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b56; - break; - - case 144: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b144; - break; - - case 208: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b208; - break; - - case 256: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b256; - break; - - default: - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_messageSizeGroupA choice: 56,144,208,256!\n", - RC.config_file_name, i, ccparams_lte.rach_messageSizeGroupA); - break; + case 56: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b56; + break; + + case 144: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b144; + break; + + case 208: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b208; + break; + + case 256: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b256; + break; + + default: + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_messageSizeGroupA choice: 56,144,208,256!\n", + RC.config_file_name, i, ccparams_lte.rach_messageSizeGroupA); + break; } if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"minusinfinity")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_minusinfinity; - } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB0")==0) { + } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB0")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB0; - } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB5")==0) { + } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB5")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB5; - } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB8")==0) { + } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB8")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB8; - } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB10")==0) { + } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB10")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB10; - } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB12")==0) { + } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB12")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB12; - } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB15")==0) { + } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB15")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB15; - } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB18")==0) { + } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB18")==0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB18; - } else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for rach_messagePowerOffsetGroupB choice: minusinfinity,dB0,dB5,dB8,dB10,dB12,dB15,dB18!\n", RC.config_file_name, i, ccparams_lte.rach_messagePowerOffsetGroupB); @@ -1002,101 +990,101 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { switch (ccparams_lte.rach_preambleTransMax) { #if (LTE_RRC_VERSION < MAKE_VERSION(14, 0, 0)) - case 3: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3; - break; + case 3: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3; + break; - case 4: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n4; - break; + case 4: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n4; + break; - case 5: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n5; - break; + case 5: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n5; + break; - case 6: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n6; - break; + case 6: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n6; + break; - case 7: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n7; - break; + case 7: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n7; + break; - case 8: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n8; - break; + case 8: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n8; + break; - case 10: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10; - break; + case 10: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10; + break; - case 20: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n20; - break; + case 20: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n20; + break; - case 50: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n50; - break; + case 50: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n50; + break; - case 100: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n100; - break; + case 100: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n100; + break; - case 200: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n200; - break; + case 200: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n200; + break; #else - case 3: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n3; - break; + case 3: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n3; + break; - case 4: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n4; - break; + case 4: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n4; + break; - case 5: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n5; - break; + case 5: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n5; + break; - case 6: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n6; - break; + case 6: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n6; + break; - case 7: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n7; - break; + case 7: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n7; + break; - case 8: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n8; - break; + case 8: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n8; + break; - case 10: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n10; - break; + case 10: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n10; + break; - case 20: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n20; - break; + case 20: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n20; + break; - case 50: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n50; - break; + case 50: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n50; + break; - case 100: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n100; - break; + case 100: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n100; + break; - case 200: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n200; - break; + case 200: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n200; + break; #endif - default: - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleTransMax choice: 3,4,5,6,7,8,10,20,50,100,200!\n", - RC.config_file_name, i, ccparams_lte.rach_preambleTransMax); - break; + default: + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for rach_preambleTransMax choice: 3,4,5,6,7,8,10,20,50,100,200!\n", + RC.config_file_name, i, ccparams_lte.rach_preambleTransMax); + break; } RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_raResponseWindowSize= (ccparams_lte.rach_raResponseWindowSize==10)?7:ccparams_lte.rach_raResponseWindowSize-2; @@ -1126,72 +1114,72 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { RC.config_file_name, i, ccparams_lte.rach_preambleTransMax); switch (ccparams_lte.pcch_defaultPagingCycle) { - case 32: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf32; - break; + case 32: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf32; + break; - case 64: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf64; - break; + case 64: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf64; + break; - case 128: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf128; - break; + case 128: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf128; + break; - case 256: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf256; - break; + case 256: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf256; + break; - default: - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pcch_defaultPagingCycle choice: 32,64,128,256!\n", - RC.config_file_name, i, ccparams_lte.pcch_defaultPagingCycle); - break; + default: + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for pcch_defaultPagingCycle choice: 32,64,128,256!\n", + RC.config_file_name, i, ccparams_lte.pcch_defaultPagingCycle); + break; } if (strcmp(ccparams_lte.pcch_nB, "fourT") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_fourT; - } else if (strcmp(ccparams_lte.pcch_nB, "twoT") == 0) { + } else if (strcmp(ccparams_lte.pcch_nB, "twoT") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_twoT; - } else if (strcmp(ccparams_lte.pcch_nB, "oneT") == 0) { + } else if (strcmp(ccparams_lte.pcch_nB, "oneT") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneT; - } else if (strcmp(ccparams_lte.pcch_nB, "halfT") == 0) { + } else if (strcmp(ccparams_lte.pcch_nB, "halfT") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_halfT; - } else if (strcmp(ccparams_lte.pcch_nB, "quarterT") == 0) { + } else if (strcmp(ccparams_lte.pcch_nB, "quarterT") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_quarterT; - } else if (strcmp(ccparams_lte.pcch_nB, "oneEighthT") == 0) { + } else if (strcmp(ccparams_lte.pcch_nB, "oneEighthT") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneEighthT; - } else if (strcmp(ccparams_lte.pcch_nB, "oneSixteenthT") == 0) { + } else if (strcmp(ccparams_lte.pcch_nB, "oneSixteenthT") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneSixteenthT; - } else if (strcmp(ccparams_lte.pcch_nB, "oneThirtySecondT") == 0) { + } else if (strcmp(ccparams_lte.pcch_nB, "oneThirtySecondT") == 0) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneThirtySecondT; - } else + } else AssertFatal (0, "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for pcch_nB choice: fourT,twoT,oneT,halfT,quarterT,oneighthT,oneSixteenthT,oneThirtySecondT !\n", RC.config_file_name, i, ccparams_lte.pcch_nB); switch (ccparams_lte.bcch_modificationPeriodCoeff) { - case 2: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n2; - break; + case 2: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n2; + break; - case 4: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n4; - break; + case 4: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n4; + break; - case 8: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n8; - break; + case 8: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n8; + break; - case 16: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n16; - break; + case 16: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n16; + break; - default: - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for bcch_modificationPeriodCoeff choice: 2,4,8,16", - RC.config_file_name, i, ccparams_lte.bcch_modificationPeriodCoeff); - break; + default: + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for bcch_modificationPeriodCoeff choice: 2,4,8,16", + RC.config_file_name, i, ccparams_lte.bcch_modificationPeriodCoeff); + break; } RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_t300= ccparams_lte.ue_TimersAndConstants_t300; @@ -1202,76 +1190,76 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_n311= ccparams_lte.ue_TimersAndConstants_n311; switch (ccparams_lte.ue_TransmissionMode) { - case 1: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm1; - break; + case 1: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm1; + break; - case 2: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm2; - break; + case 2: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm2; + break; - case 3: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm3; - break; + case 3: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm3; + break; - case 4: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm4; - break; + case 4: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm4; + break; - case 5: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm5; - break; + case 5: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm5; + break; - case 6: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm6; - break; + case 6: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm6; + break; - case 7: - RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm7; - break; + case 7: + RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm7; + break; - default: - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TransmissionMode choice: 1,2,3,4,5,6,7", - RC.config_file_name, i, ccparams_lte.ue_TransmissionMode); - break; + default: + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_TransmissionMode choice: 1,2,3,4,5,6,7", + RC.config_file_name, i, ccparams_lte.ue_TransmissionMode); + break; } RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_multiple_max= ccparams_lte.ue_multiple_max; switch (ccparams_lte.N_RB_DL) { - case 25: - if ((ccparams_lte.ue_multiple_max < 1) || - (ccparams_lte.ue_multiple_max > 4)) - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..4!\n", - RC.config_file_name, i, ccparams_lte.ue_multiple_max); + case 25: + if ((ccparams_lte.ue_multiple_max < 1) || + (ccparams_lte.ue_multiple_max > 4)) + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..4!\n", + RC.config_file_name, i, ccparams_lte.ue_multiple_max); - break; + break; - case 50: - if ((ccparams_lte.ue_multiple_max < 1) || - (ccparams_lte.ue_multiple_max > 8)) - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..8!\n", - RC.config_file_name, i, ccparams_lte.ue_multiple_max); + case 50: + if ((ccparams_lte.ue_multiple_max < 1) || + (ccparams_lte.ue_multiple_max > 8)) + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..8!\n", + RC.config_file_name, i, ccparams_lte.ue_multiple_max); - break; + break; - case 100: - if ((ccparams_lte.ue_multiple_max < 1) || - (ccparams_lte.ue_multiple_max > 16)) - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..16!\n", - RC.config_file_name, i, ccparams_lte.ue_multiple_max); + case 100: + if ((ccparams_lte.ue_multiple_max < 1) || + (ccparams_lte.ue_multiple_max > 16)) + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for ue_multiple_max choice: 1..16!\n", + RC.config_file_name, i, ccparams_lte.ue_multiple_max); - break; + break; - default: - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 25,50,100 !\n", - RC.config_file_name, i, ccparams_lte.N_RB_DL); - break; + default: + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 25,50,100 !\n", + RC.config_file_name, i, ccparams_lte.N_RB_DL); + break; } // eMBMS configuration @@ -1284,7 +1272,7 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { RRC_CONFIGURATION_REQ(msg_p).eMTC_configured = eMTCconfig.eMTC_configured&1; if (eMTCconfig.eMTC_configured > 0) fill_eMTC_configuration(msg_p,&eMTCconfig, i,j,RC.config_file_name,brparamspath); - else printf("No eMTC configuration, skipping it\n"); + else printf("No eMTC configuration, skipping it\n"); // Sidelink configuration char SLparamspath[MAX_OPTNAME_SIZE*2 + 16]; @@ -1304,148 +1292,148 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { config_get( SRB1Params,sizeof(SRB1Params)/sizeof(paramdef_t), srb1path); switch (srb1_params.srb1_max_retx_threshold) { - case 1: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t1; - break; + case 1: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t1; + break; - case 2: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t2; - break; + case 2: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t2; + break; - case 3: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t3; - break; + case 3: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t3; + break; - case 4: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t4; - break; + case 4: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t4; + break; - case 6: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t6; - break; + case 6: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t6; + break; - case 8: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t8; - break; + case 8: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t8; + break; - case 16: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t16; - break; + case 16: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t16; + break; - case 32: - rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t32; - break; + case 32: + rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t32; + break; - default: - AssertFatal (0, - "Bad config value when parsing eNB configuration file %s, enb %d srb1_max_retx_threshold %u!\n", - RC.config_file_name, i, srb1_params.srb1_max_retx_threshold); + default: + AssertFatal (0, + "Bad config value when parsing eNB configuration file %s, enb %d srb1_max_retx_threshold %u!\n", + RC.config_file_name, i, srb1_params.srb1_max_retx_threshold); } switch (srb1_params.srb1_poll_pdu) { - case 4: - rrc->srb1_poll_pdu = LTE_PollPDU_p4; - break; + case 4: + rrc->srb1_poll_pdu = LTE_PollPDU_p4; + break; - case 8: - rrc->srb1_poll_pdu = LTE_PollPDU_p8; - break; + case 8: + rrc->srb1_poll_pdu = LTE_PollPDU_p8; + break; - case 16: - rrc->srb1_poll_pdu = LTE_PollPDU_p16; - break; + case 16: + rrc->srb1_poll_pdu = LTE_PollPDU_p16; + break; - case 32: - rrc->srb1_poll_pdu = LTE_PollPDU_p32; - break; + case 32: + rrc->srb1_poll_pdu = LTE_PollPDU_p32; + break; - case 64: - rrc->srb1_poll_pdu = LTE_PollPDU_p64; - break; + case 64: + rrc->srb1_poll_pdu = LTE_PollPDU_p64; + break; - case 128: - rrc->srb1_poll_pdu = LTE_PollPDU_p128; - break; + case 128: + rrc->srb1_poll_pdu = LTE_PollPDU_p128; + break; - case 256: - rrc->srb1_poll_pdu = LTE_PollPDU_p256; - break; + case 256: + rrc->srb1_poll_pdu = LTE_PollPDU_p256; + break; - default: - if (srb1_params.srb1_poll_pdu >= 10000) - rrc->srb1_poll_pdu = LTE_PollPDU_pInfinity; - else - AssertFatal (0, - "Bad config value when parsing eNB configuration file %s, enb %d srb1_poll_pdu %u!\n", - RC.config_file_name, i, srb1_params.srb1_poll_pdu); + default: + if (srb1_params.srb1_poll_pdu >= 10000) + rrc->srb1_poll_pdu = LTE_PollPDU_pInfinity; + else + AssertFatal (0, + "Bad config value when parsing eNB configuration file %s, enb %d srb1_poll_pdu %u!\n", + RC.config_file_name, i, srb1_params.srb1_poll_pdu); } rrc->srb1_poll_byte = srb1_params.srb1_poll_byte; switch (srb1_params.srb1_poll_byte) { - case 25: - rrc->srb1_poll_byte = LTE_PollByte_kB25; - break; - - case 50: - rrc->srb1_poll_byte = LTE_PollByte_kB50; - break; + case 25: + rrc->srb1_poll_byte = LTE_PollByte_kB25; + break; - case 75: - rrc->srb1_poll_byte = LTE_PollByte_kB75; - break; + case 50: + rrc->srb1_poll_byte = LTE_PollByte_kB50; + break; - case 100: - rrc->srb1_poll_byte = LTE_PollByte_kB100; - break; + case 75: + rrc->srb1_poll_byte = LTE_PollByte_kB75; + break; - case 125: - rrc->srb1_poll_byte = LTE_PollByte_kB125; - break; + case 100: + rrc->srb1_poll_byte = LTE_PollByte_kB100; + break; - case 250: - rrc->srb1_poll_byte = LTE_PollByte_kB250; - break; + case 125: + rrc->srb1_poll_byte = LTE_PollByte_kB125; + break; - case 375: - rrc->srb1_poll_byte = LTE_PollByte_kB375; - break; + case 250: + rrc->srb1_poll_byte = LTE_PollByte_kB250; + break; - case 500: - rrc->srb1_poll_byte = LTE_PollByte_kB500; - break; + case 375: + rrc->srb1_poll_byte = LTE_PollByte_kB375; + break; - case 750: - rrc->srb1_poll_byte = LTE_PollByte_kB750; - break; + case 500: + rrc->srb1_poll_byte = LTE_PollByte_kB500; + break; - case 1000: - rrc->srb1_poll_byte = LTE_PollByte_kB1000; - break; + case 750: + rrc->srb1_poll_byte = LTE_PollByte_kB750; + break; - case 1250: - rrc->srb1_poll_byte = LTE_PollByte_kB1250; - break; + case 1000: + rrc->srb1_poll_byte = LTE_PollByte_kB1000; + break; - case 1500: - rrc->srb1_poll_byte = LTE_PollByte_kB1500; - break; + case 1250: + rrc->srb1_poll_byte = LTE_PollByte_kB1250; + break; - case 2000: - rrc->srb1_poll_byte = LTE_PollByte_kB2000; - break; + case 1500: + rrc->srb1_poll_byte = LTE_PollByte_kB1500; + break; - case 3000: - rrc->srb1_poll_byte = LTE_PollByte_kB3000; - break; + case 2000: + rrc->srb1_poll_byte = LTE_PollByte_kB2000; + break; - default: - if (srb1_params.srb1_poll_byte >= 10000) - rrc->srb1_poll_byte = LTE_PollByte_kBinfinity; - else - AssertFatal (0, - "Bad config value when parsing eNB configuration file %s, enb %d srb1_poll_byte %u!\n", - RC.config_file_name, i, srb1_params.srb1_poll_byte); + case 3000: + rrc->srb1_poll_byte = LTE_PollByte_kB3000; + break; + + default: + if (srb1_params.srb1_poll_byte >= 10000) + rrc->srb1_poll_byte = LTE_PollByte_kBinfinity; + else + AssertFatal (0, + "Bad config value when parsing eNB configuration file %s, enb %d srb1_poll_byte %u!\n", + RC.config_file_name, i, srb1_params.srb1_poll_byte); } if (srb1_params.srb1_timer_poll_retransmit <= 250) { @@ -1469,171 +1457,166 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) { } switch (srb1_params.srb1_timer_reordering) { - case 0: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms0; - break; + case 0: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms0; + break; - case 5: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms5; - break; + case 5: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms5; + break; - case 10: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms10; - break; + case 10: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms10; + break; - case 15: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms15; - break; + case 15: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms15; + break; - case 20: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms20; - break; + case 20: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms20; + break; - case 25: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms25; - break; + case 25: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms25; + break; - case 30: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms30; - break; + case 30: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms30; + break; - case 35: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms35; - break; + case 35: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms35; + break; - case 40: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms40; - break; + case 40: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms40; + break; - case 45: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms45; - break; + case 45: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms45; + break; - case 50: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms50; - break; + case 50: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms50; + break; - case 55: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms55; - break; + case 55: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms55; + break; - case 60: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms60; - break; + case 60: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms60; + break; - case 65: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms65; - break; + case 65: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms65; + break; - case 70: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms70; - break; + case 70: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms70; + break; - case 75: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms75; - break; + case 75: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms75; + break; - case 80: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms80; - break; + case 80: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms80; + break; - case 85: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms85; - break; + case 85: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms85; + break; - case 90: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms90; - break; + case 90: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms90; + break; - case 95: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms95; - break; + case 95: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms95; + break; - case 100: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms100; - break; + case 100: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms100; + break; - case 110: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms110; - break; + case 110: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms110; + break; - case 120: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms120; - break; + case 120: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms120; + break; - case 130: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms130; - break; + case 130: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms130; + break; - case 140: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms140; - break; + case 140: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms140; + break; - case 150: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms150; - break; + case 150: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms150; + break; - case 160: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms160; - break; + case 160: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms160; + break; - case 170: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms170; - break; + case 170: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms170; + break; - case 180: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms180; - break; + case 180: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms180; + break; - case 190: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms190; - break; + case 190: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms190; + break; - case 200: - rrc->srb1_timer_reordering = LTE_T_Reordering_ms200; - break; + case 200: + rrc->srb1_timer_reordering = LTE_T_Reordering_ms200; + break; - default: - AssertFatal (0, - "Bad config value when parsing eNB configuration file %s, enb %d srb1_timer_reordering %u!\n", - RC.config_file_name, i, srb1_params.srb1_timer_reordering); + default: + AssertFatal (0, + "Bad config value when parsing eNB configuration file %s, enb %d srb1_timer_reordering %u!\n", + RC.config_file_name, i, srb1_params.srb1_timer_reordering); } } } } } + memcpy(&rrc->configuration, &RRC_CONFIGURATION_REQ(msg_p), sizeof(RRC_CONFIGURATION_REQ(msg_p))); } - LOG_I(RRC,"Node type %d \n ", rrc->node_type); + LOG_I(RRC,"Node type %d \n ", rrc->node_type); return 0; } int RCconfig_DU_F1(MessageDef *msg_p, uint32_t i) { - int k; - paramdef_t ENBSParams[] = ENBSPARAMS_DESC; - paramdef_t ENBParams[] = ENBPARAMS_DESC; - paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST,NULL,0}; - - config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL); + paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST,NULL,0}; + config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL); int num_enbs = ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; AssertFatal (i<num_enbs, - "Failed to parse config file no %ith element in %s \n",i, ENB_CONFIG_STRING_ACTIVE_ENBS); + "Failed to parse config file no %ith element in %s \n",i, ENB_CONFIG_STRING_ACTIVE_ENBS); if (num_enbs>0) { // Output a list of all eNBs. - config_getlist( &ENBParamList,ENBParams,sizeof(ENBParams)/sizeof(paramdef_t),NULL); + config_getlist( &ENBParamList,ENBParams,sizeof(ENBParams)/sizeof(paramdef_t),NULL); AssertFatal(ENBParamList.paramarray[i][ENB_ENB_ID_IDX].uptr != NULL, - "eNB id %d is not defined in configuration file\n",i); - + "eNB id %d is not defined in configuration file\n",i); F1AP_SETUP_REQ (msg_p).num_cells_available = 0; for (k=0; k <num_enbs ; k++) { if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[k], *(ENBParamList.paramarray[i][ENB_ENB_NAME_IDX].strptr) )== 0) { - char aprefix[MAX_OPTNAME_SIZE*2 + 8]; sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k); paramdef_t PLMNParams[] = PLMNPARAMS_DESC; @@ -1643,65 +1626,50 @@ int RCconfig_DU_F1(MessageDef *msg_p, uint32_t i) { for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I) PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]); - config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix); + config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix); paramdef_t SCTPParams[] = SCTPPARAMS_DESC; - - F1AP_SETUP_REQ (msg_p).num_cells_available++; - + F1AP_SETUP_REQ (msg_p).num_cells_available++; F1AP_SETUP_REQ (msg_p).gNB_DU_id = *(ENBParamList.paramarray[0][ENB_ENB_ID_IDX].uptr); LOG_I(ENB_APP,"F1AP: gNB_DU_id[%d] %ld\n",k,F1AP_SETUP_REQ (msg_p).gNB_DU_id); - F1AP_SETUP_REQ (msg_p).gNB_DU_name = strdup(*(ENBParamList.paramarray[0][ENB_ENB_NAME_IDX].strptr)); LOG_I(ENB_APP,"F1AP: gNB_DU_name[%d] %s\n",k,F1AP_SETUP_REQ (msg_p).gNB_DU_name); - F1AP_SETUP_REQ (msg_p).tac[k] = *ENBParamList.paramarray[i][ENB_TRACKING_AREA_CODE_IDX].uptr; LOG_I(ENB_APP,"F1AP: tac[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).tac[k]); - F1AP_SETUP_REQ (msg_p).mcc[k] = *PLMNParamList.paramarray[0][ENB_MOBILE_COUNTRY_CODE_IDX].uptr; LOG_I(ENB_APP,"F1AP: mcc[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).mcc[k]); - F1AP_SETUP_REQ (msg_p).mnc[k] = *PLMNParamList.paramarray[0][ENB_MOBILE_NETWORK_CODE_IDX].uptr; LOG_I(ENB_APP,"F1AP: mnc[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).mnc[k]); - F1AP_SETUP_REQ (msg_p).mnc_digit_length[k] = *PLMNParamList.paramarray[0][ENB_MNC_DIGIT_LENGTH].u8ptr; LOG_I(ENB_APP,"F1AP: mnc_digit_length[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).mnc_digit_length[k]); - AssertFatal((F1AP_SETUP_REQ (msg_p).mnc_digit_length[k] == 2) || (F1AP_SETUP_REQ (msg_p).mnc_digit_length[k] == 3), "BAD MNC DIGIT LENGTH %d", F1AP_SETUP_REQ (msg_p).mnc_digit_length[k]); - - F1AP_SETUP_REQ (msg_p).nr_cellid[k] = (uint64_t)*(ENBParamList.paramarray[i][ENB_NRCELLID_IDX].u64ptr); + F1AP_SETUP_REQ (msg_p).nr_cellid[k] = (uint64_t)*(ENBParamList.paramarray[i][ENB_NRCELLID_IDX].u64ptr); LOG_I(ENB_APP,"F1AP: nr_cellid[%d] %ld\n",k,F1AP_SETUP_REQ (msg_p).nr_cellid[k]); - LOG_I(ENB_APP,"F1AP: CU_ip4_address in DU %s\n",RC.mac[k]->eth_params_n.remote_addr); LOG_I(ENB_APP,"FIAP: CU_ip4_address in DU %p, strlen %d\n",F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv4_address,(int)strlen(RC.mac[k]->eth_params_n.remote_addr)); - F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv6 = 0; F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv4 = 1; //strcpy(F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv6_address, ""); strcpy(F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv4_address, RC.mac[k]->eth_params_n.remote_addr); - LOG_I(ENB_APP,"F1AP: DU_ip4_address in DU %s\n",RC.mac[k]->eth_params_n.my_addr); LOG_I(ENB_APP,"FIAP: DU_ip4_address in DU %p, strlen %d\n",F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4_address,(int)strlen(RC.mac[k]->eth_params_n.my_addr)); - F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv6 = 0; F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4 = 1; //strcpy(F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv6_address, ""); strcpy(F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4_address, RC.mac[k]->eth_params_n.my_addr); - //strcpy(F1AP_SETUP_REQ (msg_p).CU_ip_address[l].ipv6_address,*(F1ParamList.paramarray[l][ENB_CU_IPV6_ADDRESS_IDX].strptr)); //F1AP_SETUP_REQ (msg_p).CU_port = RC.mac[k]->eth_params_n.remote_portc; // maybe we dont need it - sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_SCTP_CONFIG); - config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix); + config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix); F1AP_SETUP_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr); F1AP_SETUP_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr); - eNB_RRC_INST *rrc = RC.rrc[k]; // wait until RRC cell information is configured int cell_info_configured=0; + do { LOG_I(ENB_APP,"ngran_eNB_DU: Waiting for basic cell configuration\n"); usleep(100000); @@ -1710,22 +1678,18 @@ int RCconfig_DU_F1(MessageDef *msg_p, uint32_t i) { pthread_mutex_unlock(&rrc->cell_info_mutex); } while (cell_info_configured ==0); - rrc->configuration.mcc[0] = F1AP_SETUP_REQ (msg_p).mcc[k]; rrc->configuration.mnc[0] = F1AP_SETUP_REQ (msg_p).mnc[k]; rrc->configuration.tac = F1AP_SETUP_REQ (msg_p).tac[k]; rrc->nr_cellid = F1AP_SETUP_REQ (msg_p).nr_cellid[k]; - F1AP_SETUP_REQ (msg_p).nr_pci[k] = rrc->carrier[0].physCellId; F1AP_SETUP_REQ (msg_p).num_ssi[k] = 0; - if (rrc->carrier[0].sib1->tdd_Config) { - LOG_I(ENB_APP,"ngran_DU: Configuring Cell %d for TDD\n",k); F1AP_SETUP_REQ (msg_p).fdd_flag = 0; F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.nr_arfcn = freq_to_arfcn10(rrc->carrier[0].sib1->freqBandIndicator, - rrc->carrier[0].dl_CarrierFreq); + rrc->carrier[0].dl_CarrierFreq); // For LTE use scs field to carry prefix type and number of antennas F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.scs = (rrc->carrier[0].Ncp<<2)+rrc->carrier[0].p_eNB;; // use nrb field to hold LTE N_RB_DL (0...5) @@ -1734,12 +1698,11 @@ int RCconfig_DU_F1(MessageDef *msg_p, uint32_t i) { F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.num_frequency_bands = 1; F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.nr_band[0] = rrc->carrier[0].sib1->freqBandIndicator; F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.sul_active = 0; - } - else { + } else { LOG_I(ENB_APP,"ngran_DU: Configuring Cell %d for FDD\n",k); F1AP_SETUP_REQ (msg_p).fdd_flag = 1; F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_nr_arfcn = freq_to_arfcn10(rrc->carrier[0].sib1->freqBandIndicator, - rrc->carrier[0].dl_CarrierFreq); + rrc->carrier[0].dl_CarrierFreq); F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_nr_arfcn = F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_nr_arfcn; // For LTE use scs field to carry prefix type and number of antennas F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_scs = (rrc->carrier[0].Ncp<<2)+rrc->carrier[0].p_eNB;; @@ -1747,31 +1710,29 @@ int RCconfig_DU_F1(MessageDef *msg_p, uint32_t i) { // use nrb field to hold LTE N_RB_DL (0...5) F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_nrb = rrc->carrier[0].mib.message.dl_Bandwidth; F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_nrb = rrc->carrier[0].mib.message.dl_Bandwidth; - // RK: we need to check there value for FDD's frequency_bands DL/UL F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_num_frequency_bands = 1; F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_nr_band[0] = rrc->carrier[0].sib1->freqBandIndicator; F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_num_frequency_bands = 1; F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_nr_band[0] = rrc->carrier[0].sib1->freqBandIndicator; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_num_sul_frequency_bands = 0; F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_nr_sul_band[0] = rrc->carrier[0].sib1->freqBandIndicator; F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_num_sul_frequency_bands = 0; F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_nr_sul_band[0] = rrc->carrier[0].sib1->freqBandIndicator; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.sul_active = 0; } + F1AP_SETUP_REQ (msg_p).measurement_timing_information[k] = "0"; F1AP_SETUP_REQ (msg_p).ranac[k] = 0; F1AP_SETUP_REQ (msg_p).mib[k] = rrc->carrier[0].MIB; F1AP_SETUP_REQ (msg_p).sib1[k] = rrc->carrier[0].SIB1; F1AP_SETUP_REQ (msg_p).mib_length[k] = rrc->carrier[0].sizeof_MIB; F1AP_SETUP_REQ (msg_p).sib1_length[k] = rrc->carrier[0].sizeof_SIB1; - break; } // if } // for } // if + return 0; } @@ -1960,7 +1921,7 @@ int RCconfig_S1( default: { LOG_E(S1AP, "Default I-DRX value in conf file is invalid (%i). Should be 32, 64, 128 or 256. \ - Default DRX set to 32 in MME configuration\n", + Default DRX set to 32 in MME configuration\n", ccparams_lte.pcch_defaultPagingCycle); S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 0; } @@ -2070,8 +2031,8 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) { } AssertFatal(i < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt, - "Failed to parse config file %s, %uth attribute %s \n", - RC.config_file_name, i, ENB_CONFIG_STRING_ACTIVE_ENBS); + "Failed to parse config file %s, %uth attribute %s \n", + RC.config_file_name, i, ENB_CONFIG_STRING_ACTIVE_ENBS); if (ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt > 0) { // Output a list of all eNBs. @@ -2079,146 +2040,144 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) { if (ENBParamList.numelt > 0) { for (k = 0; k < ENBParamList.numelt; k++) { - if (ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr == NULL) { - // Calculate a default eNB ID + if (ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr == NULL) { + // Calculate a default eNB ID if (EPC_MODE_ENABLED) { - uint32_t hash; - hash = s1ap_generate_eNB_id (); - enb_id = k + (hash & 0xFFFF8); + uint32_t hash; + hash = s1ap_generate_eNB_id (); + enb_id = k + (hash & 0xFFFF8); } else { - enb_id = k; + enb_id = k; } - } else { - enb_id = *(ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr); - } - - // search if in active list - for (j = 0; j < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; j++) { - if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[j], *(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)) == 0) { - paramdef_t PLMNParams[] = PLMNPARAMS_DESC; - paramlist_def_t PLMNParamList = {ENB_CONFIG_STRING_PLMN_LIST, NULL, 0}; - /* map parameter checking array instances to parameter definition array instances */ - checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK; - - for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I) - PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]); - - paramdef_t X2Params[] = X2PARAMS_DESC; - paramlist_def_t X2ParamList = {ENB_CONFIG_STRING_TARGET_ENB_X2_IP_ADDRESS,NULL,0}; - paramdef_t SCTPParams[] = SCTPPARAMS_DESC; - paramdef_t NETParams[] = NETPARAMS_DESC; - /* TODO: fix the size - if set lower we have a crash (MAX_OPTNAME_SIZE was 64 when this code was written) */ - /* this is most probably a problem with the config module */ - char aprefix[MAX_OPTNAME_SIZE*80 + 8]; - sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k); - /* Some default/random parameters */ - X2AP_REGISTER_ENB_REQ (msg_p).eNB_id = enb_id; - - if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_MACRO_ENB") == 0) { - X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_MACRO_ENB; - } else if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_HOME_ENB") == 0) { - X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_HOME_ENB; - } else { - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n", - RC.config_file_name, i, *(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr)); - } - - X2AP_REGISTER_ENB_REQ (msg_p).eNB_name = strdup(*(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)); - X2AP_REGISTER_ENB_REQ (msg_p).tac = *ENBParamList.paramarray[k][ENB_TRACKING_AREA_CODE_IDX].uptr; - config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix); - - if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6) - AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n", - PLMNParamList.numelt); - - if (PLMNParamList.numelt > 1) - LOG_W(X2AP, "X2AP currently handles only one PLMN, ignoring the others!\n"); - - X2AP_REGISTER_ENB_REQ (msg_p).mcc = *PLMNParamList.paramarray[0][ENB_MOBILE_COUNTRY_CODE_IDX].uptr; - X2AP_REGISTER_ENB_REQ (msg_p).mnc = *PLMNParamList.paramarray[0][ENB_MOBILE_NETWORK_CODE_IDX].uptr; - X2AP_REGISTER_ENB_REQ (msg_p).mnc_digit_length = *PLMNParamList.paramarray[0][ENB_MNC_DIGIT_LENGTH].u8ptr; - AssertFatal(X2AP_REGISTER_ENB_REQ(msg_p).mnc_digit_length == 3 - || X2AP_REGISTER_ENB_REQ(msg_p).mnc < 100, - "MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n", - X2AP_REGISTER_ENB_REQ(msg_p).mnc); - /* CC params */ - config_getlist(&CCsParamList, NULL, 0, aprefix); - X2AP_REGISTER_ENB_REQ (msg_p).num_cc = CCsParamList.numelt; - - if (CCsParamList.numelt > 0) { - //char ccspath[MAX_OPTNAME_SIZE*2 + 16]; - for (J = 0; J < CCsParamList.numelt ; J++) { - sprintf(aprefix, "%s.[%i].%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k, ENB_CONFIG_STRING_COMPONENT_CARRIERS, J); - config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix); - X2AP_REGISTER_ENB_REQ (msg_p).eutra_band[J] = ccparams_lte.eutra_band; - X2AP_REGISTER_ENB_REQ (msg_p).downlink_frequency[J] = (uint32_t) ccparams_lte.downlink_frequency; - X2AP_REGISTER_ENB_REQ (msg_p).uplink_frequency_offset[J] = (unsigned int) ccparams_lte.uplink_frequency_offset; - X2AP_REGISTER_ENB_REQ (msg_p).Nid_cell[J]= ccparams_lte.Nid_cell; - - if (ccparams_lte.Nid_cell>503) { - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for Nid_cell choice: 0...503 !\n", - RC.config_file_name, k, ccparams_lte.Nid_cell); - } - - X2AP_REGISTER_ENB_REQ (msg_p).N_RB_DL[J]= ccparams_lte.N_RB_DL; - - if ((ccparams_lte.N_RB_DL!=6) && (ccparams_lte.N_RB_DL!=15) && (ccparams_lte.N_RB_DL!=25) && (ccparams_lte.N_RB_DL!=50) && (ccparams_lte.N_RB_DL!=75) && (ccparams_lte.N_RB_DL!=100)) { - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n", - RC.config_file_name, k, ccparams_lte.N_RB_DL); - } - - if (strcmp(ccparams_lte.frame_type, "FDD") == 0) { - X2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = FDD; - } else if (strcmp(ccparams_lte.frame_type, "TDD") == 0) { - X2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = TDD; - } else { - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n", - RC.config_file_name, k, ccparams_lte.frame_type); - } - - X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_DL[J] = to_earfcn_DL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency, ccparams_lte.N_RB_DL); - X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_UL[J] = to_earfcn_UL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency + ccparams_lte.uplink_frequency_offset, ccparams_lte.N_RB_DL); - } - } - - sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k); - config_getlist( &X2ParamList,X2Params,sizeof(X2Params)/sizeof(paramdef_t),aprefix); - AssertFatal(X2ParamList.numelt <= X2AP_MAX_NB_ENB_IP_ADDRESS, - "value of X2ParamList.numelt %d must be lower than X2AP_MAX_NB_ENB_IP_ADDRESS %d value: reconsider to increase X2AP_MAX_NB_ENB_IP_ADDRESS\n", - X2ParamList.numelt,X2AP_MAX_NB_ENB_IP_ADDRESS); - X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 = 0; - - for (l = 0; l < X2ParamList.numelt; l++) { - X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 += 1; - strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4_address,*(X2ParamList.paramarray[l][ENB_X2_IPV4_ADDRESS_IDX].strptr)); - strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6_address,*(X2ParamList.paramarray[l][ENB_X2_IPV6_ADDRESS_IDX].strptr)); - - if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv4") == 0) { - X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1; - X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 0; - } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv6") == 0) { - X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 0; - X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1; - } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "no") == 0) { - X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1; - X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1; - } - } + } else { + enb_id = *(ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr); + } + + // search if in active list + for (j = 0; j < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; j++) { + if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[j], *(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)) == 0) { + paramdef_t PLMNParams[] = PLMNPARAMS_DESC; + paramlist_def_t PLMNParamList = {ENB_CONFIG_STRING_PLMN_LIST, NULL, 0}; + /* map parameter checking array instances to parameter definition array instances */ + checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK; + + for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I) + PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]); + + paramdef_t X2Params[] = X2PARAMS_DESC; + paramlist_def_t X2ParamList = {ENB_CONFIG_STRING_TARGET_ENB_X2_IP_ADDRESS,NULL,0}; + paramdef_t SCTPParams[] = SCTPPARAMS_DESC; + paramdef_t NETParams[] = NETPARAMS_DESC; + /* TODO: fix the size - if set lower we have a crash (MAX_OPTNAME_SIZE was 64 when this code was written) */ + /* this is most probably a problem with the config module */ + char aprefix[MAX_OPTNAME_SIZE*80 + 8]; + sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k); + /* Some default/random parameters */ + X2AP_REGISTER_ENB_REQ (msg_p).eNB_id = enb_id; + + if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_MACRO_ENB") == 0) { + X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_MACRO_ENB; + } else if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_HOME_ENB") == 0) { + X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_HOME_ENB; + } else { + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n", + RC.config_file_name, i, *(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr)); + } + + X2AP_REGISTER_ENB_REQ (msg_p).eNB_name = strdup(*(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)); + X2AP_REGISTER_ENB_REQ (msg_p).tac = *ENBParamList.paramarray[k][ENB_TRACKING_AREA_CODE_IDX].uptr; + config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix); + + if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6) + AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n", + PLMNParamList.numelt); + + if (PLMNParamList.numelt > 1) + LOG_W(X2AP, "X2AP currently handles only one PLMN, ignoring the others!\n"); + + X2AP_REGISTER_ENB_REQ (msg_p).mcc = *PLMNParamList.paramarray[0][ENB_MOBILE_COUNTRY_CODE_IDX].uptr; + X2AP_REGISTER_ENB_REQ (msg_p).mnc = *PLMNParamList.paramarray[0][ENB_MOBILE_NETWORK_CODE_IDX].uptr; + X2AP_REGISTER_ENB_REQ (msg_p).mnc_digit_length = *PLMNParamList.paramarray[0][ENB_MNC_DIGIT_LENGTH].u8ptr; + AssertFatal(X2AP_REGISTER_ENB_REQ(msg_p).mnc_digit_length == 3 + || X2AP_REGISTER_ENB_REQ(msg_p).mnc < 100, + "MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n", + X2AP_REGISTER_ENB_REQ(msg_p).mnc); + /* CC params */ + config_getlist(&CCsParamList, NULL, 0, aprefix); + X2AP_REGISTER_ENB_REQ (msg_p).num_cc = CCsParamList.numelt; + + if (CCsParamList.numelt > 0) { + //char ccspath[MAX_OPTNAME_SIZE*2 + 16]; + for (J = 0; J < CCsParamList.numelt ; J++) { + sprintf(aprefix, "%s.[%i].%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k, ENB_CONFIG_STRING_COMPONENT_CARRIERS, J); + config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix); + X2AP_REGISTER_ENB_REQ (msg_p).eutra_band[J] = ccparams_lte.eutra_band; + X2AP_REGISTER_ENB_REQ (msg_p).downlink_frequency[J] = (uint32_t) ccparams_lte.downlink_frequency; + X2AP_REGISTER_ENB_REQ (msg_p).uplink_frequency_offset[J] = (unsigned int) ccparams_lte.uplink_frequency_offset; + X2AP_REGISTER_ENB_REQ (msg_p).Nid_cell[J]= ccparams_lte.Nid_cell; + + if (ccparams_lte.Nid_cell>503) { + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for Nid_cell choice: 0...503 !\n", + RC.config_file_name, k, ccparams_lte.Nid_cell); + } + + X2AP_REGISTER_ENB_REQ (msg_p).N_RB_DL[J]= ccparams_lte.N_RB_DL; + + if ((ccparams_lte.N_RB_DL!=6) && (ccparams_lte.N_RB_DL!=15) && (ccparams_lte.N_RB_DL!=25) && (ccparams_lte.N_RB_DL!=50) && (ccparams_lte.N_RB_DL!=75) && (ccparams_lte.N_RB_DL!=100)) { + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n", + RC.config_file_name, k, ccparams_lte.N_RB_DL); + } + + if (strcmp(ccparams_lte.frame_type, "FDD") == 0) { + X2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = FDD; + } else if (strcmp(ccparams_lte.frame_type, "TDD") == 0) { + X2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = TDD; + } else { + AssertFatal (0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n", + RC.config_file_name, k, ccparams_lte.frame_type); + } + + X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_DL[J] = to_earfcn_DL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency, ccparams_lte.N_RB_DL); + X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_UL[J] = to_earfcn_UL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency + ccparams_lte.uplink_frequency_offset, ccparams_lte.N_RB_DL); + } + } + + sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k); + config_getlist( &X2ParamList,X2Params,sizeof(X2Params)/sizeof(paramdef_t),aprefix); + AssertFatal(X2ParamList.numelt <= X2AP_MAX_NB_ENB_IP_ADDRESS, + "value of X2ParamList.numelt %d must be lower than X2AP_MAX_NB_ENB_IP_ADDRESS %d value: reconsider to increase X2AP_MAX_NB_ENB_IP_ADDRESS\n", + X2ParamList.numelt,X2AP_MAX_NB_ENB_IP_ADDRESS); + X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 = 0; + + for (l = 0; l < X2ParamList.numelt; l++) { + X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 += 1; + strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4_address,*(X2ParamList.paramarray[l][ENB_X2_IPV4_ADDRESS_IDX].strptr)); + strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6_address,*(X2ParamList.paramarray[l][ENB_X2_IPV6_ADDRESS_IDX].strptr)); + + if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv4") == 0) { + X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1; + X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 0; + } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv6") == 0) { + X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 0; + X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1; + } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "no") == 0) { + X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1; + X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1; + } + } // timers { int t_reloc_prep = 0; int tx2_reloc_overall = 0; - paramdef_t p[] = { { "t_reloc_prep", "t_reloc_prep", 0, iptr:&t_reloc_prep, defintval:0, TYPE_INT, 0 }, { "tx2_reloc_overall", "tx2_reloc_overall", 0, iptr:&tx2_reloc_overall, defintval:0, TYPE_INT, 0 } }; - config_get(p, sizeof(p)/sizeof(paramdef_t), aprefix); if (t_reloc_prep <= 0 || t_reloc_prep > 10000 || @@ -2227,38 +2186,37 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) { exit(1); } - X2AP_REGISTER_ENB_REQ (msg_p).t_reloc_prep = t_reloc_prep; - X2AP_REGISTER_ENB_REQ (msg_p).tx2_reloc_overall = tx2_reloc_overall; + X2AP_REGISTER_ENB_REQ (msg_p).t_reloc_prep = t_reloc_prep; + X2AP_REGISTER_ENB_REQ (msg_p).tx2_reloc_overall = tx2_reloc_overall; } - - // SCTP SETTING - X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS; - X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = SCTP_IN_STREAMS; + // SCTP SETTING + X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS; + X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = SCTP_IN_STREAMS; if (EPC_MODE_ENABLED) { - sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_SCTP_CONFIG); - config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix); - X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr); - X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr); + sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_SCTP_CONFIG); + config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix); + X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr); + X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr); } - sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG); - // NETWORK_INTERFACES - config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix); - X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C = (uint32_t)*(NETParams[ENB_PORT_FOR_X2C_IDX].uptr); - - if ((NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr == NULL) || (X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C == 0)) { - LOG_E(RRC,"Add eNB IPv4 address and/or port for X2C in the CONF file!\n"); - exit(1); - } - - cidr = *(NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr); - address = strtok(cidr, "/"); - X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv6 = 0; - X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4 = 1; - strcpy(X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4_address, address); - } - } + sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG); + // NETWORK_INTERFACES + config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix); + X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C = (uint32_t)*(NETParams[ENB_PORT_FOR_X2C_IDX].uptr); + + if ((NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr == NULL) || (X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C == 0)) { + LOG_E(RRC,"Add eNB IPv4 address and/or port for X2C in the CONF file!\n"); + exit(1); + } + + cidr = *(NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr); + address = strtok(cidr, "/"); + X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv6 = 0; + X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4 = 1; + strcpy(X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4_address, address); + } + } } } } @@ -2302,12 +2260,9 @@ void RCConfig(void) { paramlist_def_t MACRLCParamList = {CONFIG_STRING_MACRLC_LIST,NULL,0}; paramlist_def_t L1ParamList = {CONFIG_STRING_L1_LIST,NULL,0}; paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; - paramdef_t ENBSParams[] = ENBSPARAMS_DESC; paramlist_def_t CCsParamList = {ENB_CONFIG_STRING_COMPONENT_CARRIERS,NULL,0}; - - char aprefix[MAX_OPTNAME_SIZE*2 + 8]; - + char aprefix[MAX_OPTNAME_SIZE*2 + 8]; /* get global parameters, defined outside any section in the config file */ printf("Getting ENBSParams\n"); config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL); @@ -2323,34 +2278,29 @@ void RCConfig(void) { RC.nb_CC[i] = CCsParamList.numelt; } } - + config_getlist( &MACRLCParamList,NULL,0, NULL); RC.nb_macrlc_inst = MACRLCParamList.numelt; AssertFatal(RC.nb_macrlc_inst <= MAX_MAC_INST, "Too many macrlc instances %d\n",RC.nb_macrlc_inst); - // Get num L1 instances config_getlist( &L1ParamList,NULL,0, NULL); RC.nb_L1_inst = L1ParamList.numelt; - // Get num RU instances config_getlist( &RUParamList,NULL,0, NULL); RC.nb_RU = RUParamList.numelt; - RCconfig_parallel(); } int check_plmn_identity(rrc_eNB_carrier_data_t *carrier,uint16_t mcc,uint16_t mnc,uint8_t mnc_digit_length) { - AssertFatal(carrier->sib1->cellAccessRelatedInfo.plmn_IdentityList.list.count > 0, - "plmn info isn't there\n"); + "plmn info isn't there\n"); AssertFatal(mnc_digit_length ==2 || mnc_digit_length == 3, - "impossible mnc_digit_length %d\n",mnc_digit_length); - + "impossible mnc_digit_length %d\n",mnc_digit_length); LTE_PLMN_IdentityInfo_t *plmn_Identity_info = carrier->sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0]; // check if mcc is different and return failure if so - if (mcc != + if (mcc != (*plmn_Identity_info->plmn_Identity.mcc->list.array[0]*100)+ (*plmn_Identity_info->plmn_Identity.mcc->list.array[1]*10) + (*plmn_Identity_info->plmn_Identity.mcc->list.array[2])) return(0); @@ -2360,229 +2310,232 @@ int check_plmn_identity(rrc_eNB_carrier_data_t *carrier,uint16_t mcc,uint16_t mn // check that 2 digit mnc is different and return failure if so if (mnc_digit_length == 2 && - (mnc != + (mnc != (*plmn_Identity_info->plmn_Identity.mnc.list.array[0]*10) + (*plmn_Identity_info->plmn_Identity.mnc.list.array[1]))) return(0); else if (mnc_digit_length == 3 && - (mnc != - (*plmn_Identity_info->plmn_Identity.mnc.list.array[0]*100) + - (*plmn_Identity_info->plmn_Identity.mnc.list.array[1]*10) + - (*plmn_Identity_info->plmn_Identity.mnc.list.array[2]))) return(0); + (mnc != + (*plmn_Identity_info->plmn_Identity.mnc.list.array[0]*100) + + (*plmn_Identity_info->plmn_Identity.mnc.list.array[1]*10) + + (*plmn_Identity_info->plmn_Identity.mnc.list.array[2]))) return(0); // if we're here, the mcc/mnc match so return success return(1); - } void extract_and_decode_SI(int inst,int si_ind,uint8_t *si_container,int si_container_length) { - eNB_RRC_INST *rrc = RC.rrc[inst]; rrc_eNB_carrier_data_t *carrier = &rrc->carrier[0]; LTE_BCCH_DL_SCH_Message_t *bcch_message ; - AssertFatal(si_ind==0,"Can only handle a single SI block for now\n"); - LOG_I(ENB_APP, "rrc inst %d: Trying to decode SI block %d @ %p, length %d\n",inst,si_ind,si_container,si_container_length); // point to first SI block bcch_message = &carrier->systemInformation; asn_dec_rval_t dec_rval = uper_decode_complete( NULL, - &asn_DEF_LTE_BCCH_DL_SCH_Message, - (void **)&bcch_message, - (const void *)si_container, - si_container_length); - + &asn_DEF_LTE_BCCH_DL_SCH_Message, + (void **)&bcch_message, + (const void *)si_container, + si_container_length); + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { AssertFatal(1==0, "[ENB_APP][RRC inst %"PRIu8"] Failed to decode BCCH_DLSCH_MESSAGE (%zu bits)\n", - inst, - dec_rval.consumed ); + inst, + dec_rval.consumed ); } + if (bcch_message->message.present == LTE_BCCH_DL_SCH_MessageType_PR_c1) { switch (bcch_message->message.choice.c1.present) { - case LTE_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1: - AssertFatal(1==0,"Should have received SIB1 from CU\n"); - break; - case LTE_BCCH_DL_SCH_MessageType__c1_PR_systemInformation: - { - LTE_SystemInformation_t *si = &bcch_message->message.choice.c1.choice.systemInformation; - - - for (int i=0; i<si->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count; i++) { - LOG_I(ENB_APP,"Extracting SI %d/%d\n",i,si->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count); - struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member *typeandinfo; - typeandinfo = si->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.array[i]; - - switch(typeandinfo->present) { - case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2: - carrier->sib2 = &typeandinfo->choice.sib2; - carrier->SIB23 = (uint8_t*)malloc(64); - memcpy((void*)carrier->SIB23,(void*)si_container,si_container_length); - carrier->sizeof_SIB23 = si_container_length; - LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB2 in CU F1AP_SETUP_RESP message\n", inst); - break; - case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3: - carrier->sib3 = &typeandinfo->choice.sib3; - LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB3 in CU F1AP_SETUP_RESP message\n", inst); - break; - case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4: - //carrier->sib4 = &typeandinfo->choice.sib4; - LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB4 in CU F1AP_SETUP_RESP message\n", inst); - break; - case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5: - //carrier->sib5 = &typeandinfo->choice.sib5; - LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB5 in CU F1AP_SETUP_RESP message\n", inst); - break; - case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6: - //carrier->sib6 = &typeandinfo->choice.sib6; - LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB6 in CU F1AP_SETUP_RESP message\n", inst); - break; - case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7: - //carrier->sib7 = &typeandinfo->choice.sib7; - LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB7 in CU F1AP_SETUP_RESP message\n", inst); - break; - case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8: - //carrier->sib8 = &typeandinfo->choice.sib8; - LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB8 in CU F1AP_SETUP_RESP message\n", inst); - break; - case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9: - //carrier->sib9 = &typeandinfo->choice.sib9; - LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB9 in CU F1AP_SETUP_RESP message\n", inst); - break; - case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10: - //carrier->sib10 = &typeandinfo->choice.sib10; - LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB10 in CU F1AP_SETUP_RESP message\n", inst); - break; - case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11: - //carrier->sib11 = &typeandinfo->choice.sib11; - LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB11 in CU F1AP_SETUP_RESP message\n", inst); - break; - + case LTE_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1: + AssertFatal(1==0,"Should have received SIB1 from CU\n"); + break; + + case LTE_BCCH_DL_SCH_MessageType__c1_PR_systemInformation: { + LTE_SystemInformation_t *si = &bcch_message->message.choice.c1.choice.systemInformation; + + for (int i=0; i<si->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count; i++) { + LOG_I(ENB_APP,"Extracting SI %d/%d\n",i,si->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count); + struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member *typeandinfo; + typeandinfo = si->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.array[i]; + + switch(typeandinfo->present) { + case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2: + carrier->sib2 = &typeandinfo->choice.sib2; + carrier->SIB23 = (uint8_t *)malloc(64); + memcpy((void *)carrier->SIB23,(void *)si_container,si_container_length); + carrier->sizeof_SIB23 = si_container_length; + LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB2 in CU F1AP_SETUP_RESP message\n", inst); + break; + + case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3: + carrier->sib3 = &typeandinfo->choice.sib3; + LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB3 in CU F1AP_SETUP_RESP message\n", inst); + break; + + case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4: + //carrier->sib4 = &typeandinfo->choice.sib4; + LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB4 in CU F1AP_SETUP_RESP message\n", inst); + break; + + case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5: + //carrier->sib5 = &typeandinfo->choice.sib5; + LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB5 in CU F1AP_SETUP_RESP message\n", inst); + break; + + case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6: + //carrier->sib6 = &typeandinfo->choice.sib6; + LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB6 in CU F1AP_SETUP_RESP message\n", inst); + break; + + case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7: + //carrier->sib7 = &typeandinfo->choice.sib7; + LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB7 in CU F1AP_SETUP_RESP message\n", inst); + break; + + case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8: + //carrier->sib8 = &typeandinfo->choice.sib8; + LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB8 in CU F1AP_SETUP_RESP message\n", inst); + break; + + case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9: + //carrier->sib9 = &typeandinfo->choice.sib9; + LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB9 in CU F1AP_SETUP_RESP message\n", inst); + break; + + case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10: + //carrier->sib10 = &typeandinfo->choice.sib10; + LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB10 in CU F1AP_SETUP_RESP message\n", inst); + break; + + case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11: + //carrier->sib11 = &typeandinfo->choice.sib11; + LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB11 in CU F1AP_SETUP_RESP message\n", inst); + break; #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 2, 0)) - - case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib12_v920: - //carrier->sib12 = &typeandinfo->choice.sib12; - LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB12 in CU F1AP_SETUP_RESP message\n", inst); - break; - - case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920: - carrier->sib13 = &typeandinfo->choice.sib13_v920; - LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB13 in CU F1AP_SETUP_RESP message\n", inst); - break; + + case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib12_v920: + //carrier->sib12 = &typeandinfo->choice.sib12; + LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB12 in CU F1AP_SETUP_RESP message\n", inst); + break; + + case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920: + carrier->sib13 = &typeandinfo->choice.sib13_v920; + LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB13 in CU F1AP_SETUP_RESP message\n", inst); + break; #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - //SIB18 - case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib18_v1250: - carrier->sib18 = &typeandinfo->choice.sib18_v1250; - LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB18 in CU F1AP_SETUP_RESP message\n", inst); - break; - //SIB19 - case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib19_v1250: - carrier->sib19 = &typeandinfo->choice.sib19_v1250; - LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB19 in CU F1AP_SETUP_RESP message\n", inst); - break; - //SIB21 - case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib21_v1430: - carrier->sib21 = &typeandinfo->choice.sib21_v1430; - LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB21 in CU F1AP_SETUP_RESP message\n", inst); - break; + + //SIB18 + case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib18_v1250: + carrier->sib18 = &typeandinfo->choice.sib18_v1250; + LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB18 in CU F1AP_SETUP_RESP message\n", inst); + break; + + //SIB19 + case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib19_v1250: + carrier->sib19 = &typeandinfo->choice.sib19_v1250; + LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB19 in CU F1AP_SETUP_RESP message\n", inst); + break; + + //SIB21 + case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib21_v1430: + carrier->sib21 = &typeandinfo->choice.sib21_v1430; + LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB21 in CU F1AP_SETUP_RESP message\n", inst); + break; #endif - default: - AssertFatal(1==0,"Shouldn't have received this SI %d\n",typeandinfo->present); - break; - } - } - break; + + default: + AssertFatal(1==0,"Shouldn't have received this SI %d\n",typeandinfo->present); + break; + } + } + + break; } + case LTE_BCCH_DL_SCH_MessageType__c1_PR_NOTHING: AssertFatal(0, "Should have received SIB1 from CU\n"); break; } - } - - else AssertFatal(1==0,"No SI messages\n"); - - + } else AssertFatal(1==0,"No SI messages\n"); } void configure_du_mac(int inst) { - eNB_RRC_INST *rrc = RC.rrc[inst]; rrc_eNB_carrier_data_t *carrier = &rrc->carrier[0]; - LOG_I(ENB_APP,"Configuring MAC/L1 %d, carrier->sib2 %p\n",inst,&carrier->sib2->radioResourceConfigCommon); - rrc_mac_config_req_eNB(inst, 0, - carrier->physCellId, - carrier->p_eNB, - carrier->Ncp, - carrier->sib1->freqBandIndicator, - carrier->dl_CarrierFreq, + carrier->physCellId, + carrier->p_eNB, + carrier->Ncp, + carrier->sib1->freqBandIndicator, + carrier->dl_CarrierFreq, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - carrier->pbch_repetition, + carrier->pbch_repetition, #endif - 0, // rnti - (LTE_BCCH_BCH_Message_t *) &carrier->mib, - (LTE_RadioResourceConfigCommonSIB_t *) &carrier->sib2->radioResourceConfigCommon, + 0, // rnti + (LTE_BCCH_BCH_Message_t *) &carrier->mib, + (LTE_RadioResourceConfigCommonSIB_t *) &carrier->sib2->radioResourceConfigCommon, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - (LTE_RadioResourceConfigCommonSIB_t *) &carrier->sib2_BR->radioResourceConfigCommon, + (LTE_RadioResourceConfigCommonSIB_t *) &carrier->sib2_BR->radioResourceConfigCommon, #endif - (struct LTE_PhysicalConfigDedicated *)NULL, + (struct LTE_PhysicalConfigDedicated *)NULL, #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - (LTE_SCellToAddMod_r10_t *)NULL, - //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, + (LTE_SCellToAddMod_r10_t *)NULL, + //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, #endif - (LTE_MeasObjectToAddMod_t **) NULL, - (LTE_MAC_MainConfig_t *) NULL, 0, - (struct LTE_LogicalChannelConfig *)NULL, - (LTE_MeasGapConfig_t *) NULL, + (LTE_MeasObjectToAddMod_t **) NULL, + (LTE_MAC_MainConfig_t *) NULL, 0, + (struct LTE_LogicalChannelConfig *)NULL, + (LTE_MeasGapConfig_t *) NULL, carrier->sib1->tdd_Config, - NULL, - &carrier->sib1->schedulingInfoList, - carrier->ul_CarrierFreq, - carrier->sib2->freqInfo.ul_Bandwidth, - &carrier->sib2->freqInfo.additionalSpectrumEmission, - (LTE_MBSFN_SubframeConfigList_t*) carrier->sib2->mbsfn_SubframeConfigList + NULL, + &carrier->sib1->schedulingInfoList, + carrier->ul_CarrierFreq, + carrier->sib2->freqInfo.ul_Bandwidth, + &carrier->sib2->freqInfo.additionalSpectrumEmission, + (LTE_MBSFN_SubframeConfigList_t *) carrier->sib2->mbsfn_SubframeConfigList #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , - carrier->MBMS_flag, - (LTE_MBSFN_AreaInfoList_r9_t*) & carrier->sib13->mbsfn_AreaInfoList_r9, - (LTE_PMCH_InfoList_r9_t *) NULL + , + carrier->MBMS_flag, + (LTE_MBSFN_AreaInfoList_r9_t *) & carrier->sib13->mbsfn_AreaInfoList_r9, + (LTE_PMCH_InfoList_r9_t *) NULL #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - , - NULL + , + NULL #endif - ); - + ); } void handle_f1ap_setup_resp(f1ap_setup_resp_t *resp) { - - int i,j,si_ind; LOG_I(ENB_APP, "cells_to_activated %d, RRC instances %d\n", - resp->num_cells_to_activate,RC.nb_inst); - for (j=0;j<resp->num_cells_to_activate;j++) { - for (i=0;i<RC.nb_inst;i++) { + resp->num_cells_to_activate,RC.nb_inst); + + for (j=0; j<resp->num_cells_to_activate; j++) { + for (i=0; i<RC.nb_inst; i++) { rrc_eNB_carrier_data_t *carrier = &RC.rrc[i]->carrier[0]; // identify local index of cell j by nr_cellid, plmn identity and physical cell ID LOG_I(ENB_APP, "Checking cell %d, rrc inst %d : rrc->nr_cellid %lx, resp->nr_cellid %lx\n", - j,i,RC.rrc[i]->nr_cellid,resp->nr_cellid[j]); - if (RC.rrc[i]->nr_cellid == resp->nr_cellid[j] && - (check_plmn_identity(carrier, resp->mcc[j], resp->mnc[j], resp->mnc_digit_length[j])>0 && - resp->nrpci[j] == carrier->physCellId)) { - // copy system information and decode it - for (si_ind=0;si_ind<resp->num_SI[j];si_ind++) { + j,i,RC.rrc[i]->nr_cellid,resp->nr_cellid[j]); + + if (RC.rrc[i]->nr_cellid == resp->nr_cellid[j] && + (check_plmn_identity(carrier, resp->mcc[j], resp->mnc[j], resp->mnc_digit_length[j])>0 && + resp->nrpci[j] == carrier->physCellId)) { + // copy system information and decode it + for (si_ind=0; si_ind<resp->num_SI[j]; si_ind++) { //printf("SI %d size %d: ", si_ind, resp->SI_container_length[j][si_ind]); //for (int n=0;n<resp->SI_container_length[j][si_ind];n++) // printf("%02x ",resp->SI_container[j][si_ind][n]); //printf("\n"); - extract_and_decode_SI(i, - si_ind, - resp->SI_container[j][si_ind], - resp->SI_container_length[j][si_ind]); - } - // perform MAC/L1 common configuration - configure_du_mac(i); + extract_and_decode_SI(i, + si_ind, + resp->SI_container[j][si_ind], + resp->SI_container_length[j][si_ind]); + } + + // perform MAC/L1 common configuration + configure_du_mac(i); } else { LOG_E(ENB_APP, "F1 Setup Response not matching\n"); } @@ -2590,10 +2543,9 @@ void handle_f1ap_setup_resp(f1ap_setup_resp_t *resp) { } } -void read_config_and_init(void) -{ +void read_config_and_init(void) { int macrlc_has_f1[MAX_MAC_INST]; - memset(macrlc_has_f1, 0 , MAX_MAC_INST*sizeof(int)); + memset(macrlc_has_f1, 0, MAX_MAC_INST*sizeof(int)); if (RC.nb_macrlc_inst > 0) AssertFatal(RC.nb_macrlc_inst == RC.nb_inst, @@ -2602,7 +2554,6 @@ void read_config_and_init(void) RCconfig_L1(); LOG_I(PHY, "%s() RC.nb_L1_inst: %d\n", __FUNCTION__, RC.nb_L1_inst); - RCconfig_macrlc(macrlc_has_f1); LOG_I(MAC, "%s() RC.nb_macrlc_inst: %d\n", __FUNCTION__, RC.nb_macrlc_inst); @@ -2611,6 +2562,7 @@ void read_config_and_init(void) RC.rrc = malloc(RC.nb_inst * sizeof(eNB_RRC_INST *)); AssertFatal(RC.rrc, "could not allocate memory for RC.rrc\n"); + for (uint32_t enb_id = 0; enb_id < RC.nb_inst; enb_id++) { RC.rrc[enb_id] = malloc(sizeof(eNB_RRC_INST)); AssertFatal(RC.rrc[enb_id], "RRC context for eNB %d not allocated\n", enb_id); @@ -2618,6 +2570,11 @@ void read_config_and_init(void) RCconfig_RRC(enb_id, RC.rrc[enb_id],macrlc_has_f1[enb_id]); } - if (!NODE_IS_DU(RC.rrc[0]->node_type)) + if (!NODE_IS_DU(RC.rrc[0]->node_type)) { pdcp_layer_init(); + + if ( NODE_IS_CU(RC.rrc[0]->node_type) ) { + pdcp_set_rlc_funcptr((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req, (pdcp_data_ind_func_t)proto_agent_send_pdcp_data_ind); + } + } } diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 73d73c35566611e2da908b9f4d516e470fe22448..c547e497fa91b758862f8f7e20bd210b39f69d02 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -36,7 +36,7 @@ //#include "RadioResourceConfigCommonSIB.h" #include "LTE_RadioResourceConfigDedicated.h" #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) -#include "LTE_PRACH-ConfigSIB-v1310.h" + #include "LTE_PRACH-ConfigSIB-v1310.h" #endif #include "LTE_MeasGapConfig.h" #include "LTE_MeasObjectToAddModList.h" @@ -46,22 +46,21 @@ #include "mac_proto.h" #include "mac_extern.h" #include "common/utils/LOG/log.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "common/ran_context.h" -#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) #include "LTE_MBSFN-AreaInfoList-r9.h" #include "LTE_MBSFN-AreaInfo-r9.h" #include "LTE_MBSFN-SubframeConfigList.h" #include "LTE_PMCH-InfoList-r9.h" -#endif + extern RAN_CONTEXT_t RC; extern int l2_init_eNB(void); extern void mac_top_init_eNB(void); extern void mac_init_cell_params(int Mod_idP,int CC_idP); -extern uint8_t nfapi_mode; int32_t **rxdata; int32_t **txdata; @@ -222,138 +221,113 @@ int32_t get_uldl_offset(int eutra_bandP) { uint32_t bw_table[6] = {6*180,15*180,25*180,50*180,75*180,100*180}; void config_mib(int Mod_idP, - int CC_idP, - int eutra_bandP, - int dl_BandwidthP, - LTE_PHICH_Config_t *phich_configP, - int Nid_cellP, - int NcpP, - int p_eNBP, - uint32_t dl_CarrierFreqP, - uint32_t ul_CarrierFreqP + int CC_idP, + int eutra_bandP, + int dl_BandwidthP, + LTE_PHICH_Config_t *phich_configP, + int Nid_cellP, + int NcpP, + int p_eNBP, + uint32_t dl_CarrierFreqP, + uint32_t ul_CarrierFreqP #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , - uint32_t pbch_repetitionP + , + uint32_t pbch_repetitionP #endif - ) { - + ) { nfapi_config_request_t *cfg = &RC.mac[Mod_idP]->config[CC_idP]; - cfg->num_tlv=0; - cfg->subframe_config.pcfich_power_offset.value = 6000; // 0dB cfg->subframe_config.pcfich_power_offset.tl.tag = NFAPI_SUBFRAME_CONFIG_PCFICH_POWER_OFFSET_TAG; cfg->num_tlv++; - cfg->subframe_config.dl_cyclic_prefix_type.value = NcpP; cfg->subframe_config.dl_cyclic_prefix_type.tl.tag = NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG; cfg->num_tlv++; - cfg->subframe_config.ul_cyclic_prefix_type.value = NcpP; cfg->subframe_config.ul_cyclic_prefix_type.tl.tag = NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG; cfg->num_tlv++; - cfg->rf_config.dl_channel_bandwidth.value = to_prb(dl_BandwidthP); cfg->rf_config.dl_channel_bandwidth.tl.tag = NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG; cfg->num_tlv++; LOG_D(PHY,"%s() dl_BandwidthP:%d\n", __FUNCTION__, dl_BandwidthP); - cfg->rf_config.ul_channel_bandwidth.value = to_prb(dl_BandwidthP); cfg->rf_config.ul_channel_bandwidth.tl.tag = NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG; cfg->num_tlv++; - cfg->rf_config.tx_antenna_ports.value = p_eNBP; cfg->rf_config.tx_antenna_ports.tl.tag = NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG; cfg->num_tlv++; - cfg->rf_config.rx_antenna_ports.value = 2; cfg->rf_config.rx_antenna_ports.tl.tag = NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG; cfg->num_tlv++; - cfg->nfapi_config.earfcn.value = to_earfcn(eutra_bandP,dl_CarrierFreqP,bw_table[dl_BandwidthP]/100); cfg->nfapi_config.earfcn.tl.tag = NFAPI_NFAPI_EARFCN_TAG; cfg->num_tlv++; - cfg->nfapi_config.rf_bands.number_rf_bands = 1; - cfg->nfapi_config.rf_bands.rf_band[0] = eutra_bandP; + cfg->nfapi_config.rf_bands.rf_band[0] = eutra_bandP; cfg->nfapi_config.rf_bands.tl.tag = NFAPI_PHY_RF_BANDS_TAG; cfg->num_tlv++; - cfg->phich_config.phich_resource.value = phich_configP->phich_Resource; cfg->phich_config.phich_resource.tl.tag = NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG; cfg->num_tlv++; - cfg->phich_config.phich_duration.value = phich_configP->phich_Duration; cfg->phich_config.phich_duration.tl.tag = NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG; cfg->num_tlv++; - cfg->phich_config.phich_power_offset.value = 6000; // 0dB cfg->phich_config.phich_power_offset.tl.tag = NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG; cfg->num_tlv++; - cfg->sch_config.primary_synchronization_signal_epre_eprers.value = 6000; // 0dB cfg->sch_config.primary_synchronization_signal_epre_eprers.tl.tag = NFAPI_SCH_CONFIG_PRIMARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG; cfg->num_tlv++; - cfg->sch_config.secondary_synchronization_signal_epre_eprers.value = 6000; // 0dB cfg->sch_config.secondary_synchronization_signal_epre_eprers.tl.tag = NFAPI_SCH_CONFIG_SECONDARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG; cfg->num_tlv++; - cfg->sch_config.physical_cell_id.value = Nid_cellP; cfg->sch_config.physical_cell_id.tl.tag = NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG; cfg->num_tlv++; - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) cfg->emtc_config.pbch_repetitions_enable_r13.value = pbch_repetitionP; cfg->emtc_config.pbch_repetitions_enable_r13.tl.tag = NFAPI_EMTC_CONFIG_PBCH_REPETITIONS_ENABLE_R13_TAG; cfg->num_tlv++; -#endif +#endif LOG_I(MAC, - "%s() NFAPI_CONFIG_REQUEST(num_tlv:%u) DL_BW:%u UL_BW:%u Ncp %d,p_eNB %d,earfcn %d,band %d,phich_resource %u phich_duration %u phich_power_offset %u PSS %d SSS %d PCI %d" + "%s() NFAPI_CONFIG_REQUEST(num_tlv:%u) DL_BW:%u UL_BW:%u Ncp %d,p_eNB %d,earfcn %d,band %d,phich_resource %u phich_duration %u phich_power_offset %u PSS %d SSS %d PCI %d" #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - - " PBCH repetition %d" -#endif - "\n" - ,__FUNCTION__ - ,cfg->num_tlv - ,cfg->rf_config.dl_channel_bandwidth.value - ,cfg->rf_config.ul_channel_bandwidth.value - ,NcpP,p_eNBP - ,cfg->nfapi_config.earfcn.value - ,cfg->nfapi_config.rf_bands.rf_band[0] - ,cfg->phich_config.phich_resource.value - ,cfg->phich_config.phich_duration.value - ,cfg->phich_config.phich_power_offset.value - ,cfg->sch_config.primary_synchronization_signal_epre_eprers.value - ,cfg->sch_config.secondary_synchronization_signal_epre_eprers.value - ,cfg->sch_config.physical_cell_id.value + " PBCH repetition %d" +#endif + "\n" + ,__FUNCTION__ + ,cfg->num_tlv + ,cfg->rf_config.dl_channel_bandwidth.value + ,cfg->rf_config.ul_channel_bandwidth.value + ,NcpP,p_eNBP + ,cfg->nfapi_config.earfcn.value + ,cfg->nfapi_config.rf_bands.rf_band[0] + ,cfg->phich_config.phich_resource.value + ,cfg->phich_config.phich_duration.value + ,cfg->phich_config.phich_power_offset.value + ,cfg->sch_config.primary_synchronization_signal_epre_eprers.value + ,cfg->sch_config.secondary_synchronization_signal_epre_eprers.value + ,cfg->sch_config.physical_cell_id.value #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,cfg->emtc_config.pbch_repetitions_enable_r13.value -#endif - ); + ,cfg->emtc_config.pbch_repetitions_enable_r13.value +#endif + ); } -void config_sib1(int Mod_idP, int CC_idP, LTE_TDD_Config_t * tdd_ConfigP) -{ - - +void config_sib1(int Mod_idP, int CC_idP, LTE_TDD_Config_t *tdd_ConfigP) { nfapi_config_request_t *cfg = &RC.mac[Mod_idP]->config[CC_idP]; if (tdd_ConfigP) { //TDD cfg->subframe_config.duplex_mode.value = 0; cfg->subframe_config.duplex_mode.tl.tag = NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG; cfg->num_tlv++; - cfg->tdd_frame_structure_config.subframe_assignment.value = tdd_ConfigP->subframeAssignment; cfg->tdd_frame_structure_config.subframe_assignment.tl.tag = NFAPI_TDD_FRAME_STRUCTURE_SUBFRAME_ASSIGNMENT_TAG; cfg->num_tlv++; - cfg->tdd_frame_structure_config.special_subframe_patterns.value = tdd_ConfigP->specialSubframePatterns; cfg->tdd_frame_structure_config.special_subframe_patterns.tl.tag = NFAPI_TDD_FRAME_STRUCTURE_SPECIAL_SUBFRAME_PATTERNS_TAG; cfg->num_tlv++; - } - else { // FDD + } else { // FDD cfg->subframe_config.duplex_mode.value = 1; cfg->subframe_config.duplex_mode.tl.tag = NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG; cfg->num_tlv++; @@ -365,410 +339,358 @@ int power_off_dB[6] = { 78, 118, 140, 170, 188, 200 }; void config_sib2(int Mod_idP, - int CC_idP, - LTE_RadioResourceConfigCommonSIB_t * radioResourceConfigCommonP, + int CC_idP, + LTE_RadioResourceConfigCommonSIB_t *radioResourceConfigCommonP, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - LTE_RadioResourceConfigCommonSIB_t * radioResourceConfigCommon_BRP, + LTE_RadioResourceConfigCommonSIB_t *radioResourceConfigCommon_BRP, #endif LTE_ARFCN_ValueEUTRA_t *ul_CArrierFreqP, long *ul_BandwidthP, LTE_AdditionalSpectrumEmission_t *additionalSpectrumEmissionP, struct LTE_MBSFN_SubframeConfigList *mbsfn_SubframeConfigListP) { - nfapi_config_request_t *cfg = &RC.mac[Mod_idP]->config[CC_idP]; - cfg->subframe_config.pb.value = radioResourceConfigCommonP->pdsch_ConfigCommon.p_b; cfg->subframe_config.pb.tl.tag = NFAPI_SUBFRAME_CONFIG_PB_TAG; cfg->num_tlv++; - cfg->rf_config.reference_signal_power.value = radioResourceConfigCommonP->pdsch_ConfigCommon.referenceSignalPower; cfg->rf_config.reference_signal_power.tl.tag = NFAPI_RF_CONFIG_REFERENCE_SIGNAL_POWER_TAG; cfg->num_tlv++; - cfg->nfapi_config.max_transmit_power.value = cfg->rf_config.reference_signal_power.value + power_off_dB[cfg->rf_config.dl_channel_bandwidth.value]; cfg->nfapi_config.max_transmit_power.tl.tag = NFAPI_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG; cfg->num_tlv++; - cfg->prach_config.configuration_index.value = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.prach_ConfigIndex; cfg->prach_config.configuration_index.tl.tag = NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG; cfg->num_tlv++; - cfg->prach_config.root_sequence_index.value = radioResourceConfigCommonP->prach_Config.rootSequenceIndex; cfg->prach_config.root_sequence_index.tl.tag = NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG; cfg->num_tlv++; - cfg->prach_config.zero_correlation_zone_configuration.value = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig; cfg->prach_config.zero_correlation_zone_configuration.tl.tag = NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG; cfg->num_tlv++; - cfg->prach_config.high_speed_flag.value = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.highSpeedFlag; cfg->prach_config.high_speed_flag.tl.tag = NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG; cfg->num_tlv++; - cfg->prach_config.frequency_offset.value = radioResourceConfigCommonP->prach_Config.prach_ConfigInfo.prach_FreqOffset; cfg->prach_config.frequency_offset.tl.tag = NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG; cfg->num_tlv++; - - cfg->pusch_config.hopping_mode.value = radioResourceConfigCommonP->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode; cfg->pusch_config.hopping_mode.tl.tag = NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG; cfg->num_tlv++; - cfg->pusch_config.number_of_subbands.value = radioResourceConfigCommonP->pusch_ConfigCommon.pusch_ConfigBasic.n_SB; cfg->pusch_config.number_of_subbands.tl.tag = NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG; cfg->num_tlv++; - cfg->pusch_config.hopping_offset.value = radioResourceConfigCommonP->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset; cfg->pusch_config.hopping_offset.tl.tag = NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG; cfg->num_tlv++; - cfg->pucch_config.delta_pucch_shift.value = radioResourceConfigCommonP->pucch_ConfigCommon.deltaPUCCH_Shift; cfg->pucch_config.delta_pucch_shift.tl.tag = NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG; cfg->num_tlv++; - cfg->pucch_config.n_cqi_rb.value = radioResourceConfigCommonP->pucch_ConfigCommon.nRB_CQI; cfg->pucch_config.n_cqi_rb.tl.tag = NFAPI_PUCCH_CONFIG_N_CQI_RB_TAG; cfg->num_tlv++; - cfg->pucch_config.n_an_cs.value = radioResourceConfigCommonP->pucch_ConfigCommon.nCS_AN; cfg->pucch_config.n_an_cs.tl.tag = NFAPI_PUCCH_CONFIG_N_AN_CS_TAG; cfg->num_tlv++; - cfg->pucch_config.n1_pucch_an.value = radioResourceConfigCommonP->pucch_ConfigCommon.n1PUCCH_AN; cfg->pucch_config.n1_pucch_an.tl.tag = NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG; cfg->num_tlv++; if (radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled == true) { cfg->uplink_reference_signal_config.uplink_rs_hopping.value = 1; - } - else if (radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled == true) { + } else if (radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled == true) { cfg->uplink_reference_signal_config.uplink_rs_hopping.value = 2; - } - else { + } else { cfg->uplink_reference_signal_config.uplink_rs_hopping.value = 0; } + cfg->uplink_reference_signal_config.uplink_rs_hopping.tl.tag = NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG; cfg->num_tlv++; - cfg->uplink_reference_signal_config.group_assignment.value = radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH; cfg->uplink_reference_signal_config.group_assignment.tl.tag = NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG; cfg->num_tlv++; - cfg->uplink_reference_signal_config.cyclic_shift_1_for_drms.value = radioResourceConfigCommonP->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift; cfg->uplink_reference_signal_config.cyclic_shift_1_for_drms.tl.tag = NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG; cfg->num_tlv++; - // how to enable/disable SRS? if (radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.present== LTE_SoundingRS_UL_ConfigCommon_PR_setup) { cfg->srs_config.bandwidth_configuration.value = radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.srs_BandwidthConfig; cfg->srs_config.bandwidth_configuration.tl.tag = NFAPI_SRS_CONFIG_BANDWIDTH_CONFIGURATION_TAG; cfg->num_tlv++; - cfg->srs_config.srs_subframe_configuration.value = radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig; cfg->srs_config.srs_subframe_configuration.tl.tag = NFAPI_SRS_CONFIG_SRS_SUBFRAME_CONFIGURATION_TAG; cfg->num_tlv++; - cfg->srs_config.srs_acknack_srs_simultaneous_transmission.value = radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission; cfg->srs_config.srs_acknack_srs_simultaneous_transmission.tl.tag = NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG; cfg->num_tlv++; - + if (radioResourceConfigCommonP->soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts) { - cfg->srs_config.max_up_pts.value = 1; - } - else { - cfg->srs_config.max_up_pts.value = 0; + cfg->srs_config.max_up_pts.value = 1; + } else { + cfg->srs_config.max_up_pts.value = 0; } + cfg->srs_config.max_up_pts.tl.tag = NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG; cfg->num_tlv++; } #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + if (RC.mac[Mod_idP]->common_channels[CC_idP].mib->message.schedulingInfoSIB1_BR_r13 > 0) { AssertFatal(radioResourceConfigCommon_BRP != NULL, "radioResource rou is missing\n"); AssertFatal(radioResourceConfigCommon_BRP->ext4 != NULL, "ext4 is missing\n"); cfg->emtc_config.prach_catm_root_sequence_index.value = radioResourceConfigCommon_BRP->prach_Config.rootSequenceIndex; cfg->emtc_config.prach_catm_root_sequence_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_ROOT_SEQUENCE_INDEX_TAG; cfg->num_tlv++; - cfg->emtc_config.prach_catm_zero_correlation_zone_configuration.value = radioResourceConfigCommon_BRP->prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig; cfg->emtc_config.prach_catm_zero_correlation_zone_configuration.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG; cfg->num_tlv++; - cfg->emtc_config.prach_catm_high_speed_flag.value = radioResourceConfigCommon_BRP->prach_Config.prach_ConfigInfo.highSpeedFlag; cfg->emtc_config.prach_catm_high_speed_flag.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CATM_HIGH_SPEED_FLAG; cfg->num_tlv++; - struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach = radioResourceConfigCommon_BRP->ext4->prach_ConfigCommon_v1310; - LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; - LTE_PRACH_ParametersCE_r13_t *p; cfg->emtc_config.prach_ce_level_0_enable.value = 0; cfg->emtc_config.prach_ce_level_0_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG; cfg->num_tlv++; - cfg->emtc_config.prach_ce_level_1_enable.value = 0; cfg->emtc_config.prach_ce_level_1_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG; cfg->num_tlv++; - cfg->emtc_config.prach_ce_level_2_enable.value = 0; cfg->emtc_config.prach_ce_level_2_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG; cfg->num_tlv++; - cfg->emtc_config.prach_ce_level_3_enable.value = 0; cfg->emtc_config.prach_ce_level_3_enable.tl.tag=NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG; cfg->num_tlv++; - switch (prach_ParametersListCE_r13->list.count) { - case 4: - p = prach_ParametersListCE_r13->list.array[3]; - cfg->emtc_config.prach_ce_level_3_enable.value = 1; - cfg->emtc_config.prach_ce_level_3_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_3_configuration_index.value = p->prach_ConfigIndex_r13; - cfg->emtc_config.prach_ce_level_3_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_CONFIGURATION_INDEX_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_3_frequency_offset.value = p->prach_FreqOffset_r13; - cfg->emtc_config.prach_ce_level_3_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_FREQUENCY_OFFSET_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.value = 1<<p->numRepetitionPerPreambleAttempt_r13; - cfg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; - cfg->num_tlv++; - - if (p->prach_StartingSubframe_r13) { - cfg->emtc_config.prach_ce_level_3_starting_subframe_periodicity.value = 2<<*p->prach_StartingSubframe_r13; - cfg->emtc_config.prach_ce_level_3_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_STARTING_SUBFRAME_PERIODICITY_TAG; + case 4: + p = prach_ParametersListCE_r13->list.array[3]; + cfg->emtc_config.prach_ce_level_3_enable.value = 1; + cfg->emtc_config.prach_ce_level_3_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG; cfg->num_tlv++; - } - - - cfg->emtc_config.prach_ce_level_3_hopping_enable.value = p->prach_HoppingConfig_r13; - cfg->emtc_config.prach_ce_level_3_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_3_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; - cfg->emtc_config.prach_ce_level_3_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_OFFSET_TAG; - cfg->num_tlv++; - - case 3: - p = prach_ParametersListCE_r13->list.array[2]; - cfg->emtc_config.prach_ce_level_2_enable.value = 1; - cfg->emtc_config.prach_ce_level_2_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_2_configuration_index.value = p->prach_ConfigIndex_r13; - cfg->emtc_config.prach_ce_level_2_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_CONFIGURATION_INDEX_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_2_frequency_offset.value = p->prach_FreqOffset_r13; - cfg->emtc_config.prach_ce_level_2_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_FREQUENCY_OFFSET_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.value = 1<<p->numRepetitionPerPreambleAttempt_r13; - cfg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; - cfg->num_tlv++; - - if (p->prach_StartingSubframe_r13) { - cfg->emtc_config.prach_ce_level_2_starting_subframe_periodicity.value = 2<<*p->prach_StartingSubframe_r13; - cfg->emtc_config.prach_ce_level_2_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG; + cfg->emtc_config.prach_ce_level_3_configuration_index.value = p->prach_ConfigIndex_r13; + cfg->emtc_config.prach_ce_level_3_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_CONFIGURATION_INDEX_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_3_frequency_offset.value = p->prach_FreqOffset_r13; + cfg->emtc_config.prach_ce_level_3_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_FREQUENCY_OFFSET_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.value = 1<<p->numRepetitionPerPreambleAttempt_r13; + cfg->emtc_config.prach_ce_level_3_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; cfg->num_tlv++; - } - - cfg->emtc_config.prach_ce_level_2_hopping_enable.value = p->prach_HoppingConfig_r13; - cfg->emtc_config.prach_ce_level_2_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_ENABLE_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_2_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; - cfg->emtc_config.prach_ce_level_2_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_OFFSET_TAG; - cfg->num_tlv++; - - case 2: - p = prach_ParametersListCE_r13->list.array[1]; - cfg->emtc_config.prach_ce_level_1_enable.value = 1; - cfg->emtc_config.prach_ce_level_1_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_1_configuration_index.value = p->prach_ConfigIndex_r13; - cfg->emtc_config.prach_ce_level_1_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_CONFIGURATION_INDEX_TAG; - cfg->num_tlv++; - - cfg->emtc_config.prach_ce_level_1_frequency_offset.value = p->prach_FreqOffset_r13; - cfg->emtc_config.prach_ce_level_1_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_FREQUENCY_OFFSET_TAG; - cfg->num_tlv++; - cfg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.value = 1<<p->numRepetitionPerPreambleAttempt_r13; - cfg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; - cfg->num_tlv++; + if (p->prach_StartingSubframe_r13) { + cfg->emtc_config.prach_ce_level_3_starting_subframe_periodicity.value = 2<<*p->prach_StartingSubframe_r13; + cfg->emtc_config.prach_ce_level_3_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_STARTING_SUBFRAME_PERIODICITY_TAG; + cfg->num_tlv++; + } - if (p->prach_StartingSubframe_r13) { - cfg->emtc_config.prach_ce_level_1_starting_subframe_periodicity.value = 2<<*p->prach_StartingSubframe_r13; - cfg->emtc_config.prach_ce_level_1_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_STARTING_SUBFRAME_PERIODICITY_TAG; + cfg->emtc_config.prach_ce_level_3_hopping_enable.value = p->prach_HoppingConfig_r13; + cfg->emtc_config.prach_ce_level_3_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_3_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; + cfg->emtc_config.prach_ce_level_3_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_OFFSET_TAG; cfg->num_tlv++; - } - cfg->emtc_config.prach_ce_level_1_hopping_enable.value = p->prach_HoppingConfig_r13; - cfg->emtc_config.prach_ce_level_1_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_ENABLE_TAG; - cfg->num_tlv++; + case 3: + p = prach_ParametersListCE_r13->list.array[2]; + cfg->emtc_config.prach_ce_level_2_enable.value = 1; + cfg->emtc_config.prach_ce_level_2_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_2_configuration_index.value = p->prach_ConfigIndex_r13; + cfg->emtc_config.prach_ce_level_2_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_CONFIGURATION_INDEX_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_2_frequency_offset.value = p->prach_FreqOffset_r13; + cfg->emtc_config.prach_ce_level_2_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_FREQUENCY_OFFSET_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.value = 1<<p->numRepetitionPerPreambleAttempt_r13; + cfg->emtc_config.prach_ce_level_2_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; + cfg->num_tlv++; - cfg->emtc_config.prach_ce_level_1_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; - cfg->emtc_config.prach_ce_level_1_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_OFFSET_TAG; - cfg->num_tlv++; + if (p->prach_StartingSubframe_r13) { + cfg->emtc_config.prach_ce_level_2_starting_subframe_periodicity.value = 2<<*p->prach_StartingSubframe_r13; + cfg->emtc_config.prach_ce_level_2_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG; + cfg->num_tlv++; + } - case 1: - p = prach_ParametersListCE_r13->list.array[0]; - cfg->emtc_config.prach_ce_level_0_enable.value = 1; - cfg->emtc_config.prach_ce_level_0_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG; - cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_2_hopping_enable.value = p->prach_HoppingConfig_r13; + cfg->emtc_config.prach_ce_level_2_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_2_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; + cfg->emtc_config.prach_ce_level_2_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_OFFSET_TAG; + cfg->num_tlv++; - cfg->emtc_config.prach_ce_level_0_configuration_index.value = p->prach_ConfigIndex_r13; - cfg->emtc_config.prach_ce_level_0_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_CONFIGURATION_INDEX_TAG; - cfg->num_tlv++; + case 2: + p = prach_ParametersListCE_r13->list.array[1]; + cfg->emtc_config.prach_ce_level_1_enable.value = 1; + cfg->emtc_config.prach_ce_level_1_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_1_configuration_index.value = p->prach_ConfigIndex_r13; + cfg->emtc_config.prach_ce_level_1_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_CONFIGURATION_INDEX_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_1_frequency_offset.value = p->prach_FreqOffset_r13; + cfg->emtc_config.prach_ce_level_1_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_FREQUENCY_OFFSET_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.value = 1<<p->numRepetitionPerPreambleAttempt_r13; + cfg->emtc_config.prach_ce_level_1_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; + cfg->num_tlv++; - cfg->emtc_config.prach_ce_level_0_frequency_offset.value = p->prach_FreqOffset_r13; - cfg->emtc_config.prach_ce_level_0_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_FREQUENCY_OFFSET_TAG; - cfg->num_tlv++; + if (p->prach_StartingSubframe_r13) { + cfg->emtc_config.prach_ce_level_1_starting_subframe_periodicity.value = 2<<*p->prach_StartingSubframe_r13; + cfg->emtc_config.prach_ce_level_1_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_STARTING_SUBFRAME_PERIODICITY_TAG; + cfg->num_tlv++; + } - cfg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.value = 1<<p->numRepetitionPerPreambleAttempt_r13; - cfg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; - cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_1_hopping_enable.value = p->prach_HoppingConfig_r13; + cfg->emtc_config.prach_ce_level_1_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_1_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; + cfg->emtc_config.prach_ce_level_1_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_OFFSET_TAG; + cfg->num_tlv++; - if (p->prach_StartingSubframe_r13) { - cfg->emtc_config.prach_ce_level_0_starting_subframe_periodicity.value = 2<<*p->prach_StartingSubframe_r13; - cfg->emtc_config.prach_ce_level_0_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG; + case 1: + p = prach_ParametersListCE_r13->list.array[0]; + cfg->emtc_config.prach_ce_level_0_enable.value = 1; + cfg->emtc_config.prach_ce_level_0_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_0_configuration_index.value = p->prach_ConfigIndex_r13; + cfg->emtc_config.prach_ce_level_0_configuration_index.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_CONFIGURATION_INDEX_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_0_frequency_offset.value = p->prach_FreqOffset_r13; + cfg->emtc_config.prach_ce_level_0_frequency_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_FREQUENCY_OFFSET_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.value = 1<<p->numRepetitionPerPreambleAttempt_r13; + cfg->emtc_config.prach_ce_level_0_number_of_repetitions_per_attempt.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG; cfg->num_tlv++; - } - cfg->emtc_config.prach_ce_level_0_hopping_enable.value = p->prach_HoppingConfig_r13; - cfg->emtc_config.prach_ce_level_0_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_ENABLE_TAG; - cfg->num_tlv++; + if (p->prach_StartingSubframe_r13) { + cfg->emtc_config.prach_ce_level_0_starting_subframe_periodicity.value = 2<<*p->prach_StartingSubframe_r13; + cfg->emtc_config.prach_ce_level_0_starting_subframe_periodicity.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG; + cfg->num_tlv++; + } - cfg->emtc_config.prach_ce_level_0_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; - cfg->emtc_config.prach_ce_level_0_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_OFFSET_TAG; - cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_0_hopping_enable.value = p->prach_HoppingConfig_r13; + cfg->emtc_config.prach_ce_level_0_hopping_enable.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_ENABLE_TAG; + cfg->num_tlv++; + cfg->emtc_config.prach_ce_level_0_hopping_offset.value = cfg->rf_config.ul_channel_bandwidth.value - 6; + cfg->emtc_config.prach_ce_level_0_hopping_offset.tl.tag = NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_OFFSET_TAG; + cfg->num_tlv++; } - AssertFatal(cfg->emtc_config.prach_ce_level_0_enable.value>0,"CE_level0 is not enabled\n"); - struct LTE_FreqHoppingParameters_r13 *ext4_freqHoppingParameters = radioResourceConfigCommonP->ext4->freqHoppingParameters_r13; + if ((ext4_freqHoppingParameters) && - (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13)){ + (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13)) { switch(ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->present) { - case LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_NOTHING: /* No components present */ - break; - case LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_FDD_r13: - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->choice.interval_FDD_r13; - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG; - cfg->num_tlv++; - break; - case LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_TDD_r13: - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->choice.interval_TDD_r13; - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG; - cfg->num_tlv++; - break; + case LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_NOTHING: /* No components present */ + break; + + case LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_FDD_r13: + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->choice.interval_FDD_r13; + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG; + cfg->num_tlv++; + break; + + case LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeA_r13_PR_interval_TDD_r13: + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeA_r13->choice.interval_TDD_r13; + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodea.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG; + cfg->num_tlv++; + break; } } + if ((ext4_freqHoppingParameters) && - (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13)){ + (ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13)) { switch(ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13->present) { - case LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_NOTHING: /* No components present */ - break; - case LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_FDD_r13: - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13->choice.interval_FDD_r13; - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG; - cfg->num_tlv++; - break; - case LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_TDD_r13: - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13->choice.interval_TDD_r13; - cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG; - cfg->num_tlv++; - break; + case LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_NOTHING: /* No components present */ + break; + + case LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_FDD_r13: + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13->choice.interval_FDD_r13; + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG; + cfg->num_tlv++; + break; + + case LTE_FreqHoppingParameters_r13__interval_ULHoppingConfigCommonModeB_r13_PR_interval_TDD_r13: + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.value = ext4_freqHoppingParameters->interval_ULHoppingConfigCommonModeB_r13->choice.interval_TDD_r13; + cfg->emtc_config.pucch_interval_ulhoppingconfigcommonmodeb.tl.tag = NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG; + cfg->num_tlv++; + break; } } } -#endif +#endif } void config_dedicated(int Mod_idP, - int CC_idP, - uint16_t rnti, - struct LTE_PhysicalConfigDedicated *physicalConfigDedicated) -{ - + int CC_idP, + uint16_t rnti, + struct LTE_PhysicalConfigDedicated *physicalConfigDedicated) { } void config_dedicated_scell(int Mod_idP, - uint16_t rnti, - LTE_SCellToAddMod_r10_t * sCellToAddMod_r10) -{ - + uint16_t rnti, + LTE_SCellToAddMod_r10_t *sCellToAddMod_r10) { } int rrc_mac_config_req_eNB(module_id_t Mod_idP, - int CC_idP, - int physCellId, - int p_eNB, - int Ncp, int eutra_band, uint32_t dl_CarrierFreq, + int CC_idP, + int physCellId, + int p_eNB, + int Ncp, int eutra_band, uint32_t dl_CarrierFreq, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - int pbch_repetition, + int pbch_repetition, #endif - rnti_t rntiP, - LTE_BCCH_BCH_Message_t * mib, - LTE_RadioResourceConfigCommonSIB_t * - radioResourceConfigCommon, + rnti_t rntiP, + LTE_BCCH_BCH_Message_t *mib, + LTE_RadioResourceConfigCommonSIB_t * + radioResourceConfigCommon, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - LTE_RadioResourceConfigCommonSIB_t * - radioResourceConfigCommon_BR, + LTE_RadioResourceConfigCommonSIB_t * + radioResourceConfigCommon_BR, #endif - struct LTE_PhysicalConfigDedicated - *physicalConfigDedicated, + struct LTE_PhysicalConfigDedicated + *physicalConfigDedicated, #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - LTE_SCellToAddMod_r10_t * sCellToAddMod_r10, - //struct LTE_PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, + LTE_SCellToAddMod_r10_t *sCellToAddMod_r10, + //struct LTE_PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif - LTE_MeasObjectToAddMod_t ** measObj, - LTE_MAC_MainConfig_t * mac_MainConfig, - long logicalChannelIdentity, - LTE_LogicalChannelConfig_t * logicalChannelConfig, - LTE_MeasGapConfig_t * measGapConfig, - LTE_TDD_Config_t * tdd_Config, - LTE_MobilityControlInfo_t * mobilityControlInfo, - LTE_SchedulingInfoList_t * schedulingInfoList, - uint32_t ul_CarrierFreq, - long *ul_Bandwidth, - LTE_AdditionalSpectrumEmission_t * - additionalSpectrumEmission, - struct LTE_MBSFN_SubframeConfigList - *mbsfn_SubframeConfigList + LTE_MeasObjectToAddMod_t **measObj, + LTE_MAC_MainConfig_t *mac_MainConfig, + long logicalChannelIdentity, + LTE_LogicalChannelConfig_t *logicalChannelConfig, + LTE_MeasGapConfig_t *measGapConfig, + LTE_TDD_Config_t *tdd_Config, + LTE_MobilityControlInfo_t *mobilityControlInfo, + LTE_SchedulingInfoList_t *schedulingInfoList, + uint32_t ul_CarrierFreq, + long *ul_Bandwidth, + LTE_AdditionalSpectrumEmission_t * + additionalSpectrumEmission, + struct LTE_MBSFN_SubframeConfigList + *mbsfn_SubframeConfigList #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , uint8_t MBMS_Flag, - LTE_MBSFN_AreaInfoList_r9_t * mbsfn_AreaInfoList, - LTE_PMCH_InfoList_r9_t * pmch_InfoList + , uint8_t MBMS_Flag, + LTE_MBSFN_AreaInfoList_r9_t *mbsfn_AreaInfoList, + LTE_PMCH_InfoList_r9_t *pmch_InfoList #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - , - LTE_SystemInformationBlockType1_v1310_IEs_t * - sib1_v13ext + , + LTE_SystemInformationBlockType1_v1310_IEs_t * + sib1_v13ext #endif - ) { - + ) { int i; - int UE_id = -1; eNB_MAC_INST *eNB = RC.mac[Mod_idP]; UE_list_t *UE_list= &eNB->UE_list; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN); - LOG_D(MAC, "RC.mac:%p mib:%p\n", RC.mac, mib); if (mib != NULL) { @@ -776,129 +698,128 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, l2_init_eNB(); //mac_top_init_eNB(); - RC.mac[Mod_idP]->common_channels[CC_idP].mib = mib; RC.mac[Mod_idP]->common_channels[CC_idP].physCellId = physCellId; RC.mac[Mod_idP]->common_channels[CC_idP].p_eNB = p_eNB; RC.mac[Mod_idP]->common_channels[CC_idP].Ncp = Ncp; RC.mac[Mod_idP]->common_channels[CC_idP].eutra_band = eutra_band; RC.mac[Mod_idP]->common_channels[CC_idP].dl_CarrierFreq = dl_CarrierFreq; - LOG_I(MAC, - "Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d,Nid_cell %d,p %d,DL freq %u,phich_config.resource %d, phich_config.duration %d)\n", - Mod_idP, - CC_idP, - eutra_band, - to_prb((int)mib->message.dl_Bandwidth), - physCellId, - p_eNB, - dl_CarrierFreq, - (int)mib->message.phich_Config.phich_Resource, - (int)mib->message.phich_Config.phich_Duration); - + "Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d,Nid_cell %d,p %d,DL freq %u,phich_config.resource %d, phich_config.duration %d)\n", + Mod_idP, + CC_idP, + eutra_band, + to_prb((int)mib->message.dl_Bandwidth), + physCellId, + p_eNB, + dl_CarrierFreq, + (int)mib->message.phich_Config.phich_Resource, + (int)mib->message.phich_Config.phich_Duration); config_mib(Mod_idP,CC_idP, - eutra_band, - mib->message.dl_Bandwidth, - &mib->message.phich_Config, - physCellId, - Ncp, - p_eNB, - dl_CarrierFreq, - ul_CarrierFreq + eutra_band, + mib->message.dl_Bandwidth, + &mib->message.phich_Config, + physCellId, + Ncp, + p_eNB, + dl_CarrierFreq, + ul_CarrierFreq #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , pbch_repetition + , pbch_repetition #endif - ); - + ); mac_init_cell_params(Mod_idP,CC_idP); if (schedulingInfoList!=NULL) { - RC.mac[Mod_idP]->common_channels[CC_idP].tdd_Config = tdd_Config; - RC.mac[Mod_idP]->common_channels[CC_idP].schedulingInfoList = schedulingInfoList; + RC.mac[Mod_idP]->common_channels[CC_idP].tdd_Config = tdd_Config; + RC.mac[Mod_idP]->common_channels[CC_idP].schedulingInfoList = schedulingInfoList; config_sib1(Mod_idP,CC_idP,tdd_Config); } + #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) + if (sib1_v13ext != NULL) { RC.mac[Mod_idP]->common_channels[CC_idP].sib1_v13ext = sib1_v13ext; } + #endif AssertFatal(radioResourceConfigCommon != NULL, "radioResourceConfigCommon is null\n"); LOG_I(MAC, "[CONFIG]SIB2/3 Contents (partial)\n"); LOG_I(MAC, "[CONFIG]pusch_config_common.n_SB = %ld\n", - radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB); + radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB); LOG_I(MAC, "[CONFIG]pusch_config_common.hoppingMode = %ld\n", - radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode); + radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode); LOG_I(MAC, "[CONFIG]pusch_config_common.pusch_HoppingOffset = %ld\n", radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset); LOG_I(MAC, "[CONFIG]pusch_config_common.enable64QAM = %d\n", radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM); LOG_I(MAC, "[CONFIG]pusch_config_common.groupHoppingEnabled = %d\n", - radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled); + radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled); LOG_I(MAC, "[CONFIG]pusch_config_common.groupAssignmentPUSCH = %ld\n", radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH); LOG_I(MAC, "[CONFIG]pusch_config_common.sequenceHoppingEnabled = %d\n", - radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled); + radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled); LOG_I(MAC, "[CONFIG]pusch_config_common.cyclicShift = %ld\n", radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift); - AssertFatal(radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx > 0, "radioResourceconfigCommon %d == 0\n", - (int) radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx); - + (int) radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx); RC.mac[Mod_idP]->common_channels[CC_idP].radioResourceConfigCommon = radioResourceConfigCommon; RC.mac[Mod_idP]->common_channels[CC_idP].radioResourceConfigCommon_BR = radioResourceConfigCommon_BR; + if (ul_CarrierFreq > 0) RC.mac[Mod_idP]->common_channels[CC_idP].ul_CarrierFreq = ul_CarrierFreq; + if (ul_Bandwidth) RC.mac[Mod_idP]->common_channels[CC_idP].ul_Bandwidth = *ul_Bandwidth; else RC.mac[Mod_idP]->common_channels[CC_idP].ul_Bandwidth = RC.mac[Mod_idP]->common_channels[CC_idP].mib->message.dl_Bandwidth; - + config_sib2(Mod_idP, CC_idP, radioResourceConfigCommon, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) radioResourceConfigCommon_BR, #endif NULL, ul_Bandwidth, additionalSpectrumEmission, mbsfn_SubframeConfigList); - } // mib != NULL - if (mobilityControlInfo !=NULL){ - if ((UE_id = add_new_ue(Mod_idP, CC_idP, - rntiP, -1 + if (mobilityControlInfo !=NULL) { + if ((UE_id = add_new_ue(Mod_idP, CC_idP, + rntiP, -1 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , - 0 + , + 0 #endif - )) == -1) - { - LOG_E(MAC, "%s:%d: fatal\n", __FILE__, __LINE__); - abort(); - } + )) == -1) { + LOG_E(MAC, "%s:%d: fatal\n", __FILE__, __LINE__); + abort(); + } } // SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters->logicalChannelGroup - if (logicalChannelConfig != NULL) { // check for eMTC specific things + if (logicalChannelConfig != NULL) { // check for eMTC specific things UE_id = find_UE_id(Mod_idP, rntiP); if (UE_id<0) { LOG_E(MAC,"Configuration received for unknown UE (%x), shouldn't happen\n",rntiP); return(-1); } + if (logicalChannelConfig) { - UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = *logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup; - UE_list->UE_template[CC_idP][UE_id].lcgidpriority[logicalChannelIdentity] = logicalChannelConfig->ul_SpecificParameters->priority; + UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = *logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup; + UE_list->UE_template[CC_idP][UE_id].lcgidpriority[logicalChannelIdentity] = logicalChannelConfig->ul_SpecificParameters->priority; } else UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = 0; } if (physicalConfigDedicated != NULL) { UE_id = find_UE_id(Mod_idP, rntiP); + if (UE_id<0) { LOG_E(MAC,"Configuration received for unknown UE (%x), shouldn't happen\n",rntiP); return(-1); } + UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated = physicalConfigDedicated; LOG_I(MAC,"Added physicalConfigDedicated %p for %d.%d\n",physicalConfigDedicated,CC_idP,UE_id); } - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (sCellToAddMod_r10 != NULL) { @@ -906,106 +827,104 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, LOG_E(MAC,"Configuration received for unknown UE (%x), shouldn't happen\n",rntiP); return(-1); } + AssertFatal(UE_id>=0,"Configuration received for unknown UE (%x), shouldn't happen\n",rntiP); config_dedicated_scell(Mod_idP, rntiP, sCellToAddMod_r10); } + #endif if (mbsfn_SubframeConfigList != NULL) { LOG_I(MAC, - "[eNB %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", - Mod_idP, mbsfn_SubframeConfigList->list.count); + "[eNB %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", + Mod_idP, mbsfn_SubframeConfigList->list.count); RC.mac[Mod_idP]->common_channels[0].num_sf_allocation_pattern = mbsfn_SubframeConfigList->list.count; for (i = 0; i < mbsfn_SubframeConfigList->list.count; i++) { RC.mac[Mod_idP]->common_channels[0].mbsfn_SubframeConfig[i] = mbsfn_SubframeConfigList->list.array[i]; LOG_I(MAC, - "[eNB %d][CONFIG] MBSFN_SubframeConfig[%d] pattern is %x\n", - Mod_idP, i, - RC.mac[Mod_idP]-> - common_channels[0].mbsfn_SubframeConfig[i]-> - subframeAllocation.choice.oneFrame.buf[0]); + "[eNB %d][CONFIG] MBSFN_SubframeConfig[%d] pattern is %x\n", + Mod_idP, i, + RC.mac[Mod_idP]-> + common_channels[0].mbsfn_SubframeConfig[i]-> + subframeAllocation.choice.oneFrame.buf[0]); } #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) RC.mac[Mod_idP]->common_channels[0].MBMS_flag = MBMS_Flag; #endif } + #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (mbsfn_AreaInfoList != NULL) { // One eNB could be part of multiple mbsfn syc area, this could change over time so reset each time LOG_I(MAC,"[eNB %d][CONFIG] Received %d MBSFN Area Info\n", Mod_idP, mbsfn_AreaInfoList->list.count); RC.mac[Mod_idP]->common_channels[0].num_active_mbsfn_area = mbsfn_AreaInfoList->list.count; - + for (i =0; i< mbsfn_AreaInfoList->list.count; i++) { RC.mac[Mod_idP]->common_channels[0].mbsfn_AreaInfo[i] = mbsfn_AreaInfoList->list.array[i]; LOG_I(MAC,"[eNB %d][CONFIG] MBSFN_AreaInfo[%d]: MCCH Repetition Period = %ld\n", Mod_idP,i, - RC.mac[Mod_idP]->common_channels[0].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9); + RC.mac[Mod_idP]->common_channels[0].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9); // config_sib13(Mod_idP,0,i,RC.mac[Mod_idP]->common_channels[0].mbsfn_AreaInfo[i]->mbsfn_AreaId_r9); } - } + } if (pmch_InfoList != NULL) { - // LOG_I(MAC,"DUY: lcid when entering rrc_mac config_req is %02d\n",(pmch_InfoList->list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9)); - LOG_I(MAC, "[CONFIG] Number of PMCH in this MBSFN Area %d\n", - pmch_InfoList->list.count); - + pmch_InfoList->list.count); + for (i = 0; i < pmch_InfoList->list.count; i++) { RC.mac[Mod_idP]->common_channels[0].pmch_Config[i] = - &pmch_InfoList->list.array[i]->pmch_Config_r9; - + &pmch_InfoList->list.array[i]->pmch_Config_r9; LOG_I(MAC, - "[CONFIG] PMCH[%d]: This PMCH stop (sf_AllocEnd_r9) at subframe %ldth\n", - i, - RC.mac[Mod_idP]->common_channels[0]. - pmch_Config[i]->sf_AllocEnd_r9); + "[CONFIG] PMCH[%d]: This PMCH stop (sf_AllocEnd_r9) at subframe %ldth\n", + i, + RC.mac[Mod_idP]->common_channels[0]. + pmch_Config[i]->sf_AllocEnd_r9); LOG_I(MAC, "[CONFIG] PMCH[%d]: mch_Scheduling_Period = %ld\n", - i, - RC.mac[Mod_idP]->common_channels[0]. - pmch_Config[i]->mch_SchedulingPeriod_r9); + i, + RC.mac[Mod_idP]->common_channels[0]. + pmch_Config[i]->mch_SchedulingPeriod_r9); LOG_I(MAC, "[CONFIG] PMCH[%d]: dataMCS = %ld\n", i, - RC.mac[Mod_idP]->common_channels[0]. - pmch_Config[i]->dataMCS_r9); - + RC.mac[Mod_idP]->common_channels[0]. + pmch_Config[i]->dataMCS_r9); // MBMS session info list in each MCH RC.mac[Mod_idP]->common_channels[0].mbms_SessionList[i] = - &pmch_InfoList->list.array[i]->mbms_SessionInfoList_r9; + &pmch_InfoList->list.array[i]->mbms_SessionInfoList_r9; LOG_I(MAC, "PMCH[%d] Number of session (MTCH) is: %d\n", i, - RC.mac[Mod_idP]->common_channels[0]. - mbms_SessionList[i]->list.count); + RC.mac[Mod_idP]->common_channels[0]. + mbms_SessionList[i]->list.count); } } - -#endif - LOG_D(MAC, "%s() %s:%d RC.mac[Mod_idP]->if_inst->PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.mac[Mod_idP]->if_inst->PHY_config_req); - - // if in nFAPI mode - if ( - (nfapi_mode == 1 || nfapi_mode == 2) && - (RC.mac[Mod_idP]->if_inst->PHY_config_req == NULL) - ) { - while(RC.mac[Mod_idP]->if_inst->PHY_config_req == NULL) { - // DJP AssertFatal(RC.mac[Mod_idP]->if_inst->PHY_config_req != NULL,"if_inst->phy_config_request is null\n"); - usleep(100 * 1000); - printf("Waiting for PHY_config_req\n"); - } +#endif + LOG_D(MAC, "%s() %s:%d RC.mac[Mod_idP]->if_inst->PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.mac[Mod_idP]->if_inst->PHY_config_req); + + // if in nFAPI mode + if ( + (NFAPI_MODE == NFAPI_MODE_PNF ||NFAPI_MODE == NFAPI_MODE_VNF) && + (RC.mac[Mod_idP]->if_inst->PHY_config_req == NULL) + ) { + while(RC.mac[Mod_idP]->if_inst->PHY_config_req == NULL) { + // DJP AssertFatal(RC.mac[Mod_idP]->if_inst->PHY_config_req != NULL,"if_inst->phy_config_request is null\n"); + usleep(100 * 1000); + printf("Waiting for PHY_config_req\n"); } + } - if (radioResourceConfigCommon != NULL) { - PHY_Config_t phycfg; - phycfg.Mod_id = Mod_idP; - phycfg.CC_id = CC_idP; - phycfg.cfg = &RC.mac[Mod_idP]->config[CC_idP]; - - if (RC.mac[Mod_idP]->if_inst->PHY_config_req) RC.mac[Mod_idP]->if_inst->PHY_config_req(&phycfg); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT); - } - RC.mac[Mod_idP]->scheduler_mode = global_scheduler_mode; + if (radioResourceConfigCommon != NULL) { + PHY_Config_t phycfg; + phycfg.Mod_id = Mod_idP; + phycfg.CC_id = CC_idP; + phycfg.cfg = &RC.mac[Mod_idP]->config[CC_idP]; + + if (RC.mac[Mod_idP]->if_inst->PHY_config_req) RC.mac[Mod_idP]->if_inst->PHY_config_req(&phycfg); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT); + } - return(0); + RC.mac[Mod_idP]->scheduler_mode = global_scheduler_mode; + return(0); } diff --git a/openair2/LAYER2/MAC/config_ue.c b/openair2/LAYER2/MAC/config_ue.c index 19dc16c13ffb52d6dafd9207ba8ea841484fb207..ab66aebab8fff385c29b78688c54d6f7819066e1 100644 --- a/openair2/LAYER2/MAC/config_ue.c +++ b/openair2/LAYER2/MAC/config_ue.c @@ -32,12 +32,12 @@ #include "COMMON/platform_types.h" #include "COMMON/platform_constants.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "SCHED_UE/sched_UE.h" #include "LTE_SystemInformationBlockType2.h" -//#include "RadioResourceConfigCommonSIB.h" #include "LTE_RadioResourceConfigDedicated.h" #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) -#include "LTE_PRACH-ConfigSIB-v1310.h" + #include "LTE_PRACH-ConfigSIB-v1310.h" #endif #include "LTE_MeasGapConfig.h" #include "LTE_MeasObjectToAddModList.h" @@ -52,51 +52,38 @@ #include "common/ran_context.h" #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) -#include "LTE_MBSFN-AreaInfoList-r9.h" -#include "LTE_MBSFN-AreaInfo-r9.h" -#include "LTE_MBSFN-SubframeConfigList.h" -#include "LTE_PMCH-InfoList-r9.h" + #include "LTE_MBSFN-AreaInfoList-r9.h" + #include "LTE_MBSFN-AreaInfo-r9.h" + #include "LTE_MBSFN-SubframeConfigList.h" + #include "LTE_PMCH-InfoList-r9.h" #endif extern void mac_init_cell_params(int Mod_idP,int CC_idP); extern void phy_reset_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index); -extern uint8_t nfapi_mode; /* sec 5.9, 36.321: MAC Reset Procedure */ -void ue_mac_reset(module_id_t module_idP, uint8_t eNB_index) -{ - +void ue_mac_reset(module_id_t module_idP, uint8_t eNB_index) { //Resetting Bj UE_mac_inst[module_idP].scheduling_info.Bj[0] = 0; UE_mac_inst[module_idP].scheduling_info.Bj[1] = 0; UE_mac_inst[module_idP].scheduling_info.Bj[2] = 0; - //Stopping all timers - //timeAlignmentTimer expires - // PHY changes for UE MAC reset phy_reset_ue(module_idP, 0, eNB_index); - // notify RRC to relase PUCCH/SRS // cancel all pending SRs UE_mac_inst[module_idP].scheduling_info.SR_pending = 0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0; - //Set BSR Trigger Bmp and remove timer flags UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE; - // stop ongoing RACH procedure - // discard explicitly signaled ra_PreambleIndex and ra_RACH_MaskIndex, if any - UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = 0; // check! + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = 0; // check! UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0; - - - ue_init_mac(module_idP); //This will hopefully do the rest of the MAC reset procedure - + ue_init_mac(module_idP); //This will hopefully do the rest of the MAC reset procedure } int32_t **rxdata; @@ -105,209 +92,207 @@ int32_t **txdata; int rrc_mac_config_req_ue(module_id_t Mod_idP, - int CC_idP, - uint8_t eNB_index, - LTE_RadioResourceConfigCommonSIB_t * - radioResourceConfigCommon, - struct LTE_PhysicalConfigDedicated - *physicalConfigDedicated, + int CC_idP, + uint8_t eNB_index, + LTE_RadioResourceConfigCommonSIB_t * + radioResourceConfigCommon, + struct LTE_PhysicalConfigDedicated + *physicalConfigDedicated, #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - LTE_SCellToAddMod_r10_t * sCellToAddMod_r10, - //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, + LTE_SCellToAddMod_r10_t *sCellToAddMod_r10, + //struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10, #endif - LTE_MeasObjectToAddMod_t ** measObj, - LTE_MAC_MainConfig_t * mac_MainConfig, - long logicalChannelIdentity, - LTE_LogicalChannelConfig_t * logicalChannelConfig, - LTE_MeasGapConfig_t * measGapConfig, - LTE_TDD_Config_t * tdd_Config, - LTE_MobilityControlInfo_t * mobilityControlInfo, - uint8_t * SIwindowsize, - uint16_t * SIperiod, - LTE_ARFCN_ValueEUTRA_t * ul_CarrierFreq, - long *ul_Bandwidth, - LTE_AdditionalSpectrumEmission_t * - additionalSpectrumEmission, - struct LTE_MBSFN_SubframeConfigList - *mbsfn_SubframeConfigList + LTE_MeasObjectToAddMod_t **measObj, + LTE_MAC_MainConfig_t *mac_MainConfig, + long logicalChannelIdentity, + LTE_LogicalChannelConfig_t *logicalChannelConfig, + LTE_MeasGapConfig_t *measGapConfig, + LTE_TDD_Config_t *tdd_Config, + LTE_MobilityControlInfo_t *mobilityControlInfo, + uint8_t *SIwindowsize, + uint16_t *SIperiod, + LTE_ARFCN_ValueEUTRA_t *ul_CarrierFreq, + long *ul_Bandwidth, + LTE_AdditionalSpectrumEmission_t * + additionalSpectrumEmission, + struct LTE_MBSFN_SubframeConfigList + *mbsfn_SubframeConfigList #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , uint8_t MBMS_Flag, - LTE_MBSFN_AreaInfoList_r9_t * mbsfn_AreaInfoList, - LTE_PMCH_InfoList_r9_t * pmch_InfoList + , uint8_t MBMS_Flag, + LTE_MBSFN_AreaInfoList_r9_t *mbsfn_AreaInfoList, + LTE_PMCH_InfoList_r9_t *pmch_InfoList #endif #ifdef CBA - , uint8_t num_active_cba_groups, uint16_t cba_rnti + , uint8_t num_active_cba_groups, uint16_t cba_rnti #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ,config_action_t config_action - ,const uint32_t * const sourceL2Id - ,const uint32_t * const destinationL2Id + ,const uint32_t *const sourceL2Id + ,const uint32_t *const destinationL2Id #endif - ) -{ - + ) { int i; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN); - + (VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN); LOG_I(MAC, "[CONFIG][UE %d] Configuring MAC/PHY from eNB %d\n", - Mod_idP, eNB_index); + Mod_idP, eNB_index); if (tdd_Config != NULL) { UE_mac_inst[Mod_idP].tdd_Config = tdd_Config; } - if (tdd_Config && SIwindowsize && SIperiod) { phy_config_sib1_ue(Mod_idP, 0, eNB_index, tdd_Config, - *SIwindowsize, *SIperiod); + *SIwindowsize, *SIperiod); } if (radioResourceConfigCommon != NULL) { UE_mac_inst[Mod_idP].radioResourceConfigCommon = radioResourceConfigCommon; phy_config_sib2_ue(Mod_idP, 0, eNB_index, - radioResourceConfigCommon, ul_CarrierFreq, - ul_Bandwidth, additionalSpectrumEmission, - mbsfn_SubframeConfigList); + radioResourceConfigCommon, ul_CarrierFreq, + ul_Bandwidth, additionalSpectrumEmission, + mbsfn_SubframeConfigList); } + // SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters->logicalChannelGroup if (logicalChannelConfig != NULL) { LOG_I(MAC, - "[CONFIG][UE %d] Applying RRC logicalChannelConfig from eNB%d\n", - Mod_idP, eNB_index); + "[CONFIG][UE %d] Applying RRC logicalChannelConfig from eNB%d\n", + Mod_idP, eNB_index); UE_mac_inst[Mod_idP].logicalChannelConfig[logicalChannelIdentity] = logicalChannelConfig; - UE_mac_inst[Mod_idP].scheduling_info.Bj[logicalChannelIdentity] = 0; // initilize the bucket for this lcid - + UE_mac_inst[Mod_idP].scheduling_info.Bj[logicalChannelIdentity] = 0; // initilize the bucket for this lcid AssertFatal(logicalChannelConfig->ul_SpecificParameters != NULL, - "[UE %d] LCID %ld NULL ul_SpecificParameters\n", - Mod_idP, logicalChannelIdentity); - UE_mac_inst[Mod_idP].scheduling_info.bucket_size[logicalChannelIdentity] = logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate * logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration; // set the max bucket size + "[UE %d] LCID %ld NULL ul_SpecificParameters\n", + Mod_idP, logicalChannelIdentity); + UE_mac_inst[Mod_idP].scheduling_info.bucket_size[logicalChannelIdentity] = logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate * + logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration; // set the max bucket size + if (logicalChannelConfig->ul_SpecificParameters-> - logicalChannelGroup != NULL) { + logicalChannelGroup != NULL) { UE_mac_inst[Mod_idP].scheduling_info. - LCGID[logicalChannelIdentity] = - *logicalChannelConfig->ul_SpecificParameters-> - logicalChannelGroup; + LCGID[logicalChannelIdentity] = + *logicalChannelConfig->ul_SpecificParameters-> + logicalChannelGroup; LOG_D(MAC, - "[CONFIG][UE %d] LCID %ld is attached to the LCGID %ld\n", - Mod_idP, logicalChannelIdentity, - *logicalChannelConfig-> - ul_SpecificParameters->logicalChannelGroup); + "[CONFIG][UE %d] LCID %ld is attached to the LCGID %ld\n", + Mod_idP, logicalChannelIdentity, + *logicalChannelConfig-> + ul_SpecificParameters->logicalChannelGroup); } else { UE_mac_inst[Mod_idP].scheduling_info. - LCGID[logicalChannelIdentity] = MAX_NUM_LCGID; + LCGID[logicalChannelIdentity] = MAX_NUM_LCGID; } + UE_mac_inst[Mod_idP]. - scheduling_info.LCID_buffer_remain[logicalChannelIdentity] = 0; + scheduling_info.LCID_buffer_remain[logicalChannelIdentity] = 0; } if (mac_MainConfig != NULL) { LOG_I(MAC, - "[CONFIG][UE%d] Applying RRC macMainConfig from eNB%d\n", - Mod_idP, eNB_index); + "[CONFIG][UE%d] Applying RRC macMainConfig from eNB%d\n", + Mod_idP, eNB_index); UE_mac_inst[Mod_idP].macConfig = mac_MainConfig; UE_mac_inst[Mod_idP].measGapConfig = measGapConfig; if (mac_MainConfig->ul_SCH_Config) { - if (mac_MainConfig->ul_SCH_Config->periodicBSR_Timer) { - UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer = - (uint16_t) * - mac_MainConfig->ul_SCH_Config->periodicBSR_Timer; + UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer = + (uint16_t) * + mac_MainConfig->ul_SCH_Config->periodicBSR_Timer; } else { - UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer = + UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer = #if (LTE_RRC_VERSION < MAKE_VERSION(12, 0, 0)) - (uint16_t) - LTE_MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity + (uint16_t) + LTE_MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity #else - (uint16_t) LTE_PeriodicBSR_Timer_r12_infinity; + (uint16_t) LTE_PeriodicBSR_Timer_r12_infinity; #endif - ; + ; } if (mac_MainConfig->ul_SCH_Config->maxHARQ_Tx) { - UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx = - (uint16_t) * mac_MainConfig->ul_SCH_Config->maxHARQ_Tx; + UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx = + (uint16_t) * mac_MainConfig->ul_SCH_Config->maxHARQ_Tx; } else { - UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx = - (uint16_t) - LTE_MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; + UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx = + (uint16_t) + LTE_MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; } - if(nfapi_mode!=3) + + if(NFAPI_MODE != NFAPI_UE_STUB_PNF) phy_config_harq_ue(Mod_idP, 0, eNB_index, - UE_mac_inst[Mod_idP]. - scheduling_info.maxHARQ_Tx); + UE_mac_inst[Mod_idP]. + scheduling_info.maxHARQ_Tx); if (mac_MainConfig->ul_SCH_Config->retxBSR_Timer) { - UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer = - (uint16_t) mac_MainConfig->ul_SCH_Config-> - retxBSR_Timer; + UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer = + (uint16_t) mac_MainConfig->ul_SCH_Config-> + retxBSR_Timer; } else { #if (LTE_RRC_VERSION < MAKE_VERSION(12, 0, 0)) - UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer = - (uint16_t) - LTE_MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560; + UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer = + (uint16_t) + LTE_MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560; #else - UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer = - (uint16_t) LTE_RetxBSR_Timer_r12_sf2560; + UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer = + (uint16_t) LTE_RetxBSR_Timer_r12_sf2560; #endif } } + #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (mac_MainConfig->ext1 - && mac_MainConfig->ext1->sr_ProhibitTimer_r9) { + && mac_MainConfig->ext1->sr_ProhibitTimer_r9) { UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = - (uint16_t) * mac_MainConfig->ext1->sr_ProhibitTimer_r9; + (uint16_t) * mac_MainConfig->ext1->sr_ProhibitTimer_r9; } else { UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = 0; } if (mac_MainConfig->ext2 - && mac_MainConfig->ext2->mac_MainConfig_v1020) { + && mac_MainConfig->ext2->mac_MainConfig_v1020) { if (mac_MainConfig->ext2-> - mac_MainConfig_v1020->extendedBSR_Sizes_r10) { - UE_mac_inst[Mod_idP].scheduling_info. - extendedBSR_Sizes_r10 = - (uint16_t) * - mac_MainConfig->ext2-> - mac_MainConfig_v1020->extendedBSR_Sizes_r10; + mac_MainConfig_v1020->extendedBSR_Sizes_r10) { + UE_mac_inst[Mod_idP].scheduling_info. + extendedBSR_Sizes_r10 = + (uint16_t) * + mac_MainConfig->ext2-> + mac_MainConfig_v1020->extendedBSR_Sizes_r10; } else { - UE_mac_inst[Mod_idP].scheduling_info. - extendedBSR_Sizes_r10 = (uint16_t) 0; + UE_mac_inst[Mod_idP].scheduling_info. + extendedBSR_Sizes_r10 = (uint16_t) 0; } + if (mac_MainConfig->ext2->mac_MainConfig_v1020-> - extendedPHR_r10) { - UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = - (uint16_t) * - mac_MainConfig->ext2->mac_MainConfig_v1020-> - extendedPHR_r10; + extendedPHR_r10) { + UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = + (uint16_t) * + mac_MainConfig->ext2->mac_MainConfig_v1020-> + extendedPHR_r10; } else { - UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = - (uint16_t) 0; + UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = + (uint16_t) 0; } } else { UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = - (uint16_t) 0; + (uint16_t) 0; UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = - (uint16_t) 0; + (uint16_t) 0; } + #endif UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; - UE_mac_inst[Mod_idP].BSR_reporting_active = BSR_TRIGGER_NONE; - LOG_D(MAC, "[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n", - Mod_idP, - UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF, - UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF); - + Mod_idP, + UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF, + UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF); UE_mac_inst[Mod_idP].scheduling_info.drx_config = mac_MainConfig->drx_Config; UE_mac_inst[Mod_idP].scheduling_info.phr_config = @@ -315,62 +300,62 @@ rrc_mac_config_req_ue(module_id_t Mod_idP, if (mac_MainConfig->phr_Config) { UE_mac_inst[Mod_idP].PHR_state = - mac_MainConfig->phr_Config->present; + mac_MainConfig->phr_Config->present; UE_mac_inst[Mod_idP].PHR_reconfigured = 1; UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer = - mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer; + mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer; UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer = - mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer; + mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer; UE_mac_inst[Mod_idP].scheduling_info.PathlossChange = - mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange; + mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange; } else { UE_mac_inst[Mod_idP].PHR_reconfigured = 0; UE_mac_inst[Mod_idP].PHR_state = - LTE_MAC_MainConfig__phr_Config_PR_setup; + LTE_MAC_MainConfig__phr_Config_PR_setup; UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer = - LTE_MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; + LTE_MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer = - LTE_MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; + LTE_MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; UE_mac_inst[Mod_idP].scheduling_info.PathlossChange = - LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; + LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; } UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[Mod_idP]. - scheduling_info.periodicPHR_Timer); + scheduling_info.periodicPHR_Timer); UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[Mod_idP]. - scheduling_info.prohibitPHR_Timer); + scheduling_info.prohibitPHR_Timer); UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[Mod_idP]. - scheduling_info.PathlossChange); + scheduling_info.PathlossChange); UE_mac_inst[Mod_idP].PHR_reporting_active = 0; LOG_D(MAC, - "[UE %d] config PHR (%d): periodic %d (SF) prohibit %d (SF) pathlosschange %d (db) \n", - Mod_idP, - (mac_MainConfig->phr_Config) ? mac_MainConfig-> - phr_Config->present : -1, - UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF, - UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF, - UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db); + "[UE %d] config PHR (%d): periodic %d (SF) prohibit %d (SF) pathlosschange %d (db) \n", + Mod_idP, + (mac_MainConfig->phr_Config) ? mac_MainConfig-> + phr_Config->present : -1, + UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF, + UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF, + UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db); } - if (physicalConfigDedicated != NULL) { - if(nfapi_mode!=3) + if(NFAPI_MODE != NFAPI_UE_STUB_PNF) phy_config_dedicated_ue(Mod_idP, 0, eNB_index, - physicalConfigDedicated); - UE_mac_inst[Mod_idP].physicalConfigDedicated = physicalConfigDedicated; // for SR proc + physicalConfigDedicated); + + UE_mac_inst[Mod_idP].physicalConfigDedicated = physicalConfigDedicated; // for SR proc } + #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (sCellToAddMod_r10 != NULL) { - - phy_config_dedicated_scell_ue(Mod_idP, eNB_index, - sCellToAddMod_r10, 1); - UE_mac_inst[Mod_idP].physicalConfigDedicatedSCell_r10 = sCellToAddMod_r10->radioResourceConfigDedicatedSCell_r10->physicalConfigDedicatedSCell_r10; // using SCell index 0 + sCellToAddMod_r10, 1); + UE_mac_inst[Mod_idP].physicalConfigDedicatedSCell_r10 = sCellToAddMod_r10->radioResourceConfigDedicatedSCell_r10->physicalConfigDedicatedSCell_r10; // using SCell index 0 } + #endif if (measObj != NULL) { @@ -378,104 +363,104 @@ rrc_mac_config_req_ue(module_id_t Mod_idP, measObj[0]->measObject.present == LTE_MeasObjectToAddMod__measObject_PR_measObjectEUTRA && measObj[0]->measObject.choice.measObjectEUTRA.cellsToAddModList != NULL) { UE_mac_inst[Mod_idP].n_adj_cells = - measObj[0]->measObject.choice. - measObjectEUTRA.cellsToAddModList->list.count; + measObj[0]->measObject.choice. + measObjectEUTRA.cellsToAddModList->list.count; LOG_I(MAC, "Number of adjacent cells %d\n", - UE_mac_inst[Mod_idP].n_adj_cells); + UE_mac_inst[Mod_idP].n_adj_cells); for (i = 0; i < UE_mac_inst[Mod_idP].n_adj_cells; i++) { - UE_mac_inst[Mod_idP].adj_cell_id[i] = - measObj[0]->measObject.choice. - measObjectEUTRA.cellsToAddModList->list.array[i]-> - physCellId; - LOG_I(MAC, "Cell %d : Nid_cell %d\n", i, - UE_mac_inst[Mod_idP].adj_cell_id[i]); + UE_mac_inst[Mod_idP].adj_cell_id[i] = + measObj[0]->measObject.choice. + measObjectEUTRA.cellsToAddModList->list.array[i]-> + physCellId; + LOG_I(MAC, "Cell %d : Nid_cell %d\n", i, + UE_mac_inst[Mod_idP].adj_cell_id[i]); } phy_config_meas_ue(Mod_idP, 0, eNB_index, - UE_mac_inst[Mod_idP].n_adj_cells, - UE_mac_inst[Mod_idP].adj_cell_id); + UE_mac_inst[Mod_idP].n_adj_cells, + UE_mac_inst[Mod_idP].adj_cell_id); } } - if (mobilityControlInfo != NULL) { - LOG_D(MAC, "[UE%d] MAC Reset procedure triggered by RRC eNB %d \n", - Mod_idP, eNB_index); + Mod_idP, eNB_index); ue_mac_reset(Mod_idP, eNB_index); if (mobilityControlInfo->radioResourceConfigCommon. - rach_ConfigCommon) { + rach_ConfigCommon) { memcpy((void *) - &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> - rach_ConfigCommon, - (void *) mobilityControlInfo-> - radioResourceConfigCommon.rach_ConfigCommon, - sizeof(LTE_RACH_ConfigCommon_t)); + &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> + rach_ConfigCommon, + (void *) mobilityControlInfo-> + radioResourceConfigCommon.rach_ConfigCommon, + sizeof(LTE_RACH_ConfigCommon_t)); } memcpy((void *) &UE_mac_inst[Mod_idP]. - radioResourceConfigCommon->prach_Config.prach_ConfigInfo, - (void *) mobilityControlInfo-> - radioResourceConfigCommon.prach_Config.prach_ConfigInfo, - sizeof(LTE_PRACH_ConfigInfo_t)); + radioResourceConfigCommon->prach_Config.prach_ConfigInfo, + (void *) mobilityControlInfo-> + radioResourceConfigCommon.prach_Config.prach_ConfigInfo, + sizeof(LTE_PRACH_ConfigInfo_t)); UE_mac_inst[Mod_idP].radioResourceConfigCommon-> - prach_Config.rootSequenceIndex = + prach_Config.rootSequenceIndex = mobilityControlInfo->radioResourceConfigCommon. prach_Config.rootSequenceIndex; if (mobilityControlInfo->radioResourceConfigCommon. - pdsch_ConfigCommon) { + pdsch_ConfigCommon) { memcpy((void *) - &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> - pdsch_ConfigCommon, - (void *) mobilityControlInfo-> - radioResourceConfigCommon.pdsch_ConfigCommon, - sizeof(LTE_PDSCH_ConfigCommon_t)); + &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> + pdsch_ConfigCommon, + (void *) mobilityControlInfo-> + radioResourceConfigCommon.pdsch_ConfigCommon, + sizeof(LTE_PDSCH_ConfigCommon_t)); } + // not a pointer: mobilityControlInfo->radioResourceConfigCommon.pusch_ConfigCommon memcpy((void *) &UE_mac_inst[Mod_idP]. - radioResourceConfigCommon->pusch_ConfigCommon, - (void *) &mobilityControlInfo-> - radioResourceConfigCommon.pusch_ConfigCommon, - sizeof(LTE_PUSCH_ConfigCommon_t)); + radioResourceConfigCommon->pusch_ConfigCommon, + (void *) &mobilityControlInfo-> + radioResourceConfigCommon.pusch_ConfigCommon, + sizeof(LTE_PUSCH_ConfigCommon_t)); if (mobilityControlInfo->radioResourceConfigCommon.phich_Config) { /* memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->phich_Config, - (void *)mobilityControlInfo->radioResourceConfigCommon.phich_Config, - sizeof(LTE_PHICH_Config_t)); */ + (void *)mobilityControlInfo->radioResourceConfigCommon.phich_Config, + sizeof(LTE_PHICH_Config_t)); */ } if (mobilityControlInfo->radioResourceConfigCommon. - pucch_ConfigCommon) { + pucch_ConfigCommon) { memcpy((void *) - &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> - pucch_ConfigCommon, - (void *) mobilityControlInfo-> - radioResourceConfigCommon.pucch_ConfigCommon, - sizeof(LTE_PUCCH_ConfigCommon_t)); + &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> + pucch_ConfigCommon, + (void *) mobilityControlInfo-> + radioResourceConfigCommon.pucch_ConfigCommon, + sizeof(LTE_PUCCH_ConfigCommon_t)); } if (mobilityControlInfo-> - radioResourceConfigCommon.soundingRS_UL_ConfigCommon) { + radioResourceConfigCommon.soundingRS_UL_ConfigCommon) { memcpy((void *) - &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> - soundingRS_UL_ConfigCommon, - (void *) mobilityControlInfo-> - radioResourceConfigCommon.soundingRS_UL_ConfigCommon, - sizeof(LTE_SoundingRS_UL_ConfigCommon_t)); + &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> + soundingRS_UL_ConfigCommon, + (void *) mobilityControlInfo-> + radioResourceConfigCommon.soundingRS_UL_ConfigCommon, + sizeof(LTE_SoundingRS_UL_ConfigCommon_t)); } if (mobilityControlInfo-> - radioResourceConfigCommon.uplinkPowerControlCommon) { + radioResourceConfigCommon.uplinkPowerControlCommon) { memcpy((void *) - &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> - uplinkPowerControlCommon, - (void *) mobilityControlInfo-> - radioResourceConfigCommon.uplinkPowerControlCommon, - sizeof(LTE_UplinkPowerControlCommon_t)); + &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> + uplinkPowerControlCommon, + (void *) mobilityControlInfo-> + radioResourceConfigCommon.uplinkPowerControlCommon, + sizeof(LTE_UplinkPowerControlCommon_t)); } + //configure antennaInfoCommon somewhere here.. if (mobilityControlInfo->radioResourceConfigCommon.p_Max) { //to be configured @@ -483,97 +468,97 @@ rrc_mac_config_req_ue(module_id_t Mod_idP, if (mobilityControlInfo->radioResourceConfigCommon.tdd_Config) { UE_mac_inst[Mod_idP].tdd_Config = - mobilityControlInfo->radioResourceConfigCommon.tdd_Config; + mobilityControlInfo->radioResourceConfigCommon.tdd_Config; } if (mobilityControlInfo-> - radioResourceConfigCommon.ul_CyclicPrefixLength) { + radioResourceConfigCommon.ul_CyclicPrefixLength) { memcpy((void *) - &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> - ul_CyclicPrefixLength, - (void *) mobilityControlInfo-> - radioResourceConfigCommon.ul_CyclicPrefixLength, - sizeof(LTE_UL_CyclicPrefixLength_t)); + &UE_mac_inst[Mod_idP].radioResourceConfigCommon-> + ul_CyclicPrefixLength, + (void *) mobilityControlInfo-> + radioResourceConfigCommon.ul_CyclicPrefixLength, + sizeof(LTE_UL_CyclicPrefixLength_t)); } + // store the previous rnti in case of failure, and set thenew rnti UE_mac_inst[Mod_idP].crnti_before_ho = UE_mac_inst[Mod_idP].crnti; UE_mac_inst[Mod_idP].crnti = ((mobilityControlInfo-> - newUE_Identity.buf[0]) | (mobilityControlInfo-> - newUE_Identity.buf[1] << 8)); + newUE_Identity.buf[0]) | (mobilityControlInfo-> + newUE_Identity.buf[1] << 8)); LOG_I(MAC, "[UE %d] Received new identity %x from %d\n", Mod_idP, - UE_mac_inst[Mod_idP].crnti, eNB_index); + UE_mac_inst[Mod_idP].crnti, eNB_index); UE_mac_inst[Mod_idP].rach_ConfigDedicated = malloc(sizeof(*mobilityControlInfo->rach_ConfigDedicated)); if (mobilityControlInfo->rach_ConfigDedicated) { memcpy((void *) UE_mac_inst[Mod_idP].rach_ConfigDedicated, - (void *) mobilityControlInfo->rach_ConfigDedicated, - sizeof(*mobilityControlInfo->rach_ConfigDedicated)); + (void *) mobilityControlInfo->rach_ConfigDedicated, + sizeof(*mobilityControlInfo->rach_ConfigDedicated)); } phy_config_afterHO_ue(Mod_idP, 0, eNB_index, mobilityControlInfo, - 0); + 0); } - if (mbsfn_SubframeConfigList != NULL) { LOG_I(MAC, - "[UE %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", - Mod_idP, mbsfn_SubframeConfigList->list.count); + "[UE %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", + Mod_idP, mbsfn_SubframeConfigList->list.count); UE_mac_inst[Mod_idP].num_sf_allocation_pattern = mbsfn_SubframeConfigList->list.count; for (i = 0; i < mbsfn_SubframeConfigList->list.count; i++) { LOG_I(MAC, - "[UE %d] Configuring MBSFN_SubframeConfig %d from received SIB2 \n", - Mod_idP, i); + "[UE %d] Configuring MBSFN_SubframeConfig %d from received SIB2 \n", + Mod_idP, i); UE_mac_inst[Mod_idP].mbsfn_SubframeConfig[i] = - mbsfn_SubframeConfigList->list.array[i]; + mbsfn_SubframeConfigList->list.array[i]; // LOG_I("[UE %d] MBSFN_SubframeConfig[%d] pattern is %ld\n", Mod_idP, // UE_mac_inst[Mod_idP].mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]); } } + #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (mbsfn_AreaInfoList != NULL) { LOG_I(MAC, "[UE %d][CONFIG] Received %d MBSFN Area Info\n", - Mod_idP, mbsfn_AreaInfoList->list.count); + Mod_idP, mbsfn_AreaInfoList->list.count); UE_mac_inst[Mod_idP].num_active_mbsfn_area = mbsfn_AreaInfoList->list.count; for (i = 0; i < mbsfn_AreaInfoList->list.count; i++) { UE_mac_inst[Mod_idP].mbsfn_AreaInfo[i] = - mbsfn_AreaInfoList->list.array[i]; + mbsfn_AreaInfoList->list.array[i]; LOG_I(MAC, - "[UE %d] MBSFN_AreaInfo[%d]: MCCH Repetition Period = %ld\n", - Mod_idP, i, - UE_mac_inst[Mod_idP].mbsfn_AreaInfo[i]-> - mcch_Config_r9.mcch_RepetitionPeriod_r9); + "[UE %d] MBSFN_AreaInfo[%d]: MCCH Repetition Period = %ld\n", + Mod_idP, i, + UE_mac_inst[Mod_idP].mbsfn_AreaInfo[i]-> + mcch_Config_r9.mcch_RepetitionPeriod_r9); phy_config_sib13_ue(Mod_idP, 0, eNB_index, i, - UE_mac_inst[Mod_idP]. - mbsfn_AreaInfo[i]->mbsfn_AreaId_r9); + UE_mac_inst[Mod_idP]. + mbsfn_AreaInfo[i]->mbsfn_AreaId_r9); } } if (pmch_InfoList != NULL) { - // LOG_I(MAC,"DUY: lcid when entering rrc_mac config_req is %02d\n",(pmch_InfoList->list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9)); - LOG_I(MAC, "[UE %d] Configuring PMCH_config from MCCH MESSAGE \n", - Mod_idP); + Mod_idP); for (i = 0; i < pmch_InfoList->list.count; i++) { UE_mac_inst[Mod_idP].pmch_Config[i] = - &pmch_InfoList->list.array[i]->pmch_Config_r9; + &pmch_InfoList->list.array[i]->pmch_Config_r9; LOG_I(MAC, "[UE %d] PMCH[%d]: MCH_Scheduling_Period = %ld\n", - Mod_idP, i, - UE_mac_inst[Mod_idP]. - pmch_Config[i]->mch_SchedulingPeriod_r9); + Mod_idP, i, + UE_mac_inst[Mod_idP]. + pmch_Config[i]->mch_SchedulingPeriod_r9); } UE_mac_inst[Mod_idP].mcch_status = 1; } + #endif #ifdef CBA @@ -581,44 +566,53 @@ rrc_mac_config_req_ue(module_id_t Mod_idP, UE_mac_inst[Mod_idP].cba_rnti[num_active_cba_groups - 1] = cba_rnti; LOG_D(MAC, - "[UE %d] configure CBA group %d RNTI %x for eNB %d (total active cba group %d)\n", - Mod_idP, Mod_idP % num_active_cba_groups, cba_rnti, - eNB_index, num_active_cba_groups); + "[UE %d] configure CBA group %d RNTI %x for eNB %d (total active cba group %d)\n", + Mod_idP, Mod_idP % num_active_cba_groups, cba_rnti, + eNB_index, num_active_cba_groups); phy_config_cba_rnti(Mod_idP, CC_idP, eNB_flagP, eNB_index, - cba_rnti, num_active_cba_groups - 1, - num_active_cba_groups); + cba_rnti, num_active_cba_groups - 1, + num_active_cba_groups); } + #endif VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT); + (VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT); //for D2D - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - switch (config_action) { +#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + + switch (config_action) { case CONFIG_ACTION_ADD: - if (sourceL2Id){ - UE_mac_inst[Mod_idP].sourceL2Id = *sourceL2Id; - LOG_I(MAC,"[UE %d] Configure source L2Id 0x%08x \n", Mod_idP, *sourceL2Id ); - } - if (destinationL2Id) { - LOG_I(MAC,"[UE %d] Configure destination L2Id 0x%08x\n", Mod_idP, *destinationL2Id ); - int j = 0; - int i = 0; - for (i=0; i< MAX_NUM_DEST; i++) { - if ((UE_mac_inst[Mod_idP].destinationList[i] == 0) && (j == 0)) j = i+1; - if (UE_mac_inst[Mod_idP].destinationList[i] == *destinationL2Id) break; //destination already exists! - } - if ((i == MAX_NUM_DEST) && (j > 0)) UE_mac_inst[Mod_idP].destinationList[j-1] = *destinationL2Id; - UE_mac_inst[Mod_idP].numCommFlows++; - } - break; + if (sourceL2Id) { + UE_mac_inst[Mod_idP].sourceL2Id = *sourceL2Id; + LOG_I(MAC,"[UE %d] Configure source L2Id 0x%08x \n", Mod_idP, *sourceL2Id ); + } + + if (destinationL2Id) { + LOG_I(MAC,"[UE %d] Configure destination L2Id 0x%08x\n", Mod_idP, *destinationL2Id ); + int j = 0; + int i = 0; + + for (i=0; i< MAX_NUM_DEST; i++) { + if ((UE_mac_inst[Mod_idP].destinationList[i] == 0) && (j == 0)) j = i+1; + + if (UE_mac_inst[Mod_idP].destinationList[i] == *destinationL2Id) break; //destination already exists! + } + + if ((i == MAX_NUM_DEST) && (j > 0)) UE_mac_inst[Mod_idP].destinationList[j-1] = *destinationL2Id; + + UE_mac_inst[Mod_idP].numCommFlows++; + } + + break; + case CONFIG_ACTION_REMOVE: - //TODO - break; - default: - break; - } + //TODO + break; - #endif + default: + break; + } +#endif return (0); } diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index ab2856c40ce8c8d993c9fed51bbef4bea47ac980..8a9e3883d5476089b1dc92cf2bdf696d490bd256 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -36,6 +36,7 @@ #include "LAYER2/MAC/mac_proto.h" #include "common/utils/LOG/log.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" @@ -55,7 +56,7 @@ #include "eNB_scheduler_fairRR.h" #if defined(ENABLE_ITTI) -#include "intertask_interface.h" + #include "intertask_interface.h" #endif #include "assertions.h" @@ -70,10 +71,7 @@ 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) -{ - - +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; @@ -82,81 +80,84 @@ schedule_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) LTE_SoundingRS_UL_ConfigCommon_t *soundingRS_UL_ConfigCommon; struct LTE_SoundingRS_UL_ConfigDedicated *soundingRS_UL_ConfigDedicated; uint8_t TSFC; - uint16_t deltaTSFC; // bitmap + uint16_t deltaTSFC; // bitmap uint8_t srs_SubframeConfig; - // table for TSFC (Period) and deltaSFC (offset) - const uint16_t deltaTSFCTabType1[15][2] = { {1, 1}, {1, 2}, {2, 2}, {1, 5}, {2, 5}, {4, 5}, {8, 5}, {3, 5}, {12, 5}, {1, 10}, {2, 10}, {4, 10}, {8, 10}, {351, 10}, {383, 10} }; // Table 5.5.3.3-2 3GPP 36.211 FDD - const uint16_t deltaTSFCTabType2[14][2] = { {2, 5}, {6, 5}, {10, 5}, {18, 5}, {14, 5}, {22, 5}, {26, 5}, {30, 5}, {70, 10}, {74, 10}, {194, 10}, {326, 10}, {586, 10}, {210, 10} }; // Table 5.5.3.3-2 3GPP 36.211 TDD - + const uint16_t deltaTSFCTabType1[15][2] = { {1, 1}, {1, 2}, {2, 2}, {1, 5}, {2, 5}, {4, 5}, {8, 5}, {3, 5}, {12, 5}, {1, 10}, {2, 10}, {4, 10}, {8, 10}, {351, 10}, {383, 10} }; // Table 5.5.3.3-2 3GPP 36.211 FDD + const uint16_t deltaTSFCTabType2[14][2] = { {2, 5}, {6, 5}, {10, 5}, {18, 5}, {14, 5}, {22, 5}, {26, 5}, {30, 5}, {70, 10}, {74, 10}, {194, 10}, {326, 10}, {586, 10}, {210, 10} }; // Table 5.5.3.3-2 3GPP 36.211 TDD uint16_t srsPeriodicity, srsOffset; - + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { soundingRS_UL_ConfigCommon = &cc[CC_id].radioResourceConfigCommon->soundingRS_UL_ConfigCommon; + // check if SRS is enabled in this frame/subframe if (soundingRS_UL_ConfigCommon) { srs_SubframeConfig = soundingRS_UL_ConfigCommon->choice.setup.srs_SubframeConfig; - if (cc[CC_id].tdd_Config == NULL) { // FDD - deltaTSFC = deltaTSFCTabType1[srs_SubframeConfig][0]; - TSFC = deltaTSFCTabType1[srs_SubframeConfig][1]; - } else { // TDD - deltaTSFC = deltaTSFCTabType2[srs_SubframeConfig][0]; - TSFC = deltaTSFCTabType2[srs_SubframeConfig][1]; + + 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 == LTE_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 + // 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 == LTE_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) -{ +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; @@ -167,8 +168,8 @@ schedule_CSI(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) 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; @@ -178,67 +179,64 @@ schedule_CSI(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) 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); + 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 != LTE_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 ((cqi_ReportPeriodic = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic) != NULL + && (cqi_ReportPeriodic->present != LTE_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 (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - // PUT rel10-13 UCI options here + // PUT rel10-13 UCI options here #endif - } else - if ((cqi_ReportPeriodic->choice.setup.ri_ConfigIndex) - && ((((frameP * 10) + subframeP) % ((H * Npd) << (*cqi_ReportPeriodic->choice.setup.ri_ConfigIndex / 161))) == N_OFFSET_CQI + (*cqi_ReportPeriodic->choice.setup.ri_ConfigIndex % 161))) { // RI opportunity - // Program RI - nfapi_ul_config_request_pdu_t *ul_config_pdu = &ul_req->ul_config_pdu_list[ul_req->number_of_pdus]; - memset((void *) ul_config_pdu, 0, - sizeof(nfapi_ul_config_request_pdu_t)); - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE; - ul_config_pdu->pdu_size = 2 + (uint8_t) (2 + sizeof(nfapi_ul_config_uci_cqi_pdu)); - ul_config_pdu->uci_cqi_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; - ul_config_pdu->uci_cqi_pdu.ue_information.ue_information_rel8.rnti = UE_list->UE_template[CC_id][UE_id].rnti; - ul_config_pdu->uci_cqi_pdu.cqi_information.cqi_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL8_TAG; - ul_config_pdu->uci_cqi_pdu.cqi_information.cqi_information_rel8.pucch_index = cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex; - ul_config_pdu->uci_cqi_pdu.cqi_information.cqi_information_rel8.dl_cqi_pmi_size = (cc->p_eNB == 2) ? 1 : 2; - RC.mac[module_idP]->UL_req[CC_id].sfn_sf = (frameP << 4) + subframeP; - ul_req->number_of_pdus++; - ul_req->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - } - } // if ((cqi_ReportPeriodic = cqi_ReportConfig->cqi_ReportPeriodic)!=NULL) { - } // if (UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->cqi_ReportConfig) - } // for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { - } // for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + } else if ((cqi_ReportPeriodic->choice.setup.ri_ConfigIndex) + && ((((frameP * 10) + subframeP) % ((H * Npd) << (*cqi_ReportPeriodic->choice.setup.ri_ConfigIndex / 161))) == N_OFFSET_CQI + (*cqi_ReportPeriodic->choice.setup.ri_ConfigIndex % + 161))) { // RI opportunity + // Program RI + nfapi_ul_config_request_pdu_t *ul_config_pdu = &ul_req->ul_config_pdu_list[ul_req->number_of_pdus]; + memset((void *) ul_config_pdu, 0, + sizeof(nfapi_ul_config_request_pdu_t)); + ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE; + ul_config_pdu->pdu_size = 2 + (uint8_t) (2 + sizeof(nfapi_ul_config_uci_cqi_pdu)); + ul_config_pdu->uci_cqi_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; + ul_config_pdu->uci_cqi_pdu.ue_information.ue_information_rel8.rnti = UE_list->UE_template[CC_id][UE_id].rnti; + ul_config_pdu->uci_cqi_pdu.cqi_information.cqi_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL8_TAG; + ul_config_pdu->uci_cqi_pdu.cqi_information.cqi_information_rel8.pucch_index = cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex; + ul_config_pdu->uci_cqi_pdu.cqi_information.cqi_information_rel8.dl_cqi_pmi_size = (cc->p_eNB == 2) ? 1 : 2; + RC.mac[module_idP]->UL_req[CC_id].sfn_sf = (frameP << 4) + subframeP; + ul_req->number_of_pdus++; + ul_req->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + } + } // if ((cqi_ReportPeriodic = cqi_ReportConfig->cqi_ReportPeriodic)!=NULL) { + } // if (UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->cqi_ReportConfig) + } // for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) { + } // for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { } void -schedule_SR(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) -{ +schedule_SR(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) { eNB_MAC_INST *eNB = RC.mac[module_idP]; UE_list_t *UE_list = &eNB->UE_list; nfapi_ul_config_request_t *ul_req; @@ -266,91 +264,89 @@ schedule_SR(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) if (UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated== NULL) continue; if ((SRconfig = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->schedulingRequestConfig) != NULL) { - if (SRconfig->present == LTE_SchedulingRequestConfig_PR_setup) { - if (SRconfig->choice.setup.sr_ConfigIndex <= 4) { // 5 ms SR period - if ((subframeP % 5) != SRconfig->choice.setup.sr_ConfigIndex) continue; - } else if (SRconfig->choice.setup.sr_ConfigIndex <= 14) { // 10 ms SR period - if (subframeP != (SRconfig->choice.setup.sr_ConfigIndex - 5)) continue; - } else if (SRconfig->choice.setup.sr_ConfigIndex <= 34) { // 20 ms SR period - if ((10 * (frameP & 1) + subframeP) != (SRconfig->choice.setup.sr_ConfigIndex - 15)) continue; - } else if (SRconfig->choice.setup.sr_ConfigIndex <= 74) { // 40 ms SR period - if ((10 * (frameP & 3) + subframeP) != (SRconfig->choice.setup.sr_ConfigIndex - 35)) continue; - } else if (SRconfig->choice.setup.sr_ConfigIndex <= 154) { // 80 ms SR period - if ((10 * (frameP & 7) + subframeP) != (SRconfig->choice.setup.sr_ConfigIndex - 75)) continue; - } - } // SRconfig->present == SchedulingRequestConfig_PR_setup) - } // SRconfig = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->schedulingRequestConfig)!=NULL) + if (SRconfig->present == LTE_SchedulingRequestConfig_PR_setup) { + if (SRconfig->choice.setup.sr_ConfigIndex <= 4) { // 5 ms SR period + if ((subframeP % 5) != SRconfig->choice.setup.sr_ConfigIndex) continue; + } else if (SRconfig->choice.setup.sr_ConfigIndex <= 14) { // 10 ms SR period + if (subframeP != (SRconfig->choice.setup.sr_ConfigIndex - 5)) continue; + } else if (SRconfig->choice.setup.sr_ConfigIndex <= 34) { // 20 ms SR period + if ((10 * (frameP & 1) + subframeP) != (SRconfig->choice.setup.sr_ConfigIndex - 15)) continue; + } else if (SRconfig->choice.setup.sr_ConfigIndex <= 74) { // 40 ms SR period + if ((10 * (frameP & 3) + subframeP) != (SRconfig->choice.setup.sr_ConfigIndex - 35)) continue; + } else if (SRconfig->choice.setup.sr_ConfigIndex <= 154) { // 80 ms SR period + if ((10 * (frameP & 7) + subframeP) != (SRconfig->choice.setup.sr_ConfigIndex - 75)) continue; + } + } // SRconfig->present == SchedulingRequestConfig_PR_setup) + } // SRconfig = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->schedulingRequestConfig)!=NULL) // if we get here there is some PUCCH1 reception to schedule for SR - skip_ue = 0; is_harq = 0; + // check that there is no existing UL grant for ULSCH which overrides the SR for (i = 0; i < ul_req_body->number_of_pdus; i++) { - if (((ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) || - (ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE) || - (ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) || - (ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE)) && - (ul_req_body->ul_config_pdu_list[i].ulsch_pdu.ulsch_pdu_rel8.rnti == UE_list->UE_template[CC_id][UE_id].rnti)) { - skip_ue = 1; - break; - } - /* if there is already an HARQ pdu, convert to SR_HARQ */ - else if ((ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) && - (ul_req_body->ul_config_pdu_list[i].uci_harq_pdu.ue_information.ue_information_rel8.rnti == UE_list->UE_template[CC_id][UE_id].rnti)) { - is_harq = 1; - break; - } + if (((ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) || + (ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE) || + (ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) || + (ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE)) && + (ul_req_body->ul_config_pdu_list[i].ulsch_pdu.ulsch_pdu_rel8.rnti == UE_list->UE_template[CC_id][UE_id].rnti)) { + skip_ue = 1; + break; + } + /* if there is already an HARQ pdu, convert to SR_HARQ */ + else if ((ul_req_body->ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) && + (ul_req_body->ul_config_pdu_list[i].uci_harq_pdu.ue_information.ue_information_rel8.rnti == UE_list->UE_template[CC_id][UE_id].rnti)) { + is_harq = 1; + break; + } } // drop the allocation because ULSCH with handle it with BSR if (skip_ue == 1) continue; LOG_D(MAC,"Frame %d, Subframe %d : Scheduling SR for UE %d/%x is_harq:%d\n",frameP,subframeP,UE_id,UE_list->UE_template[CC_id][UE_id].rnti, is_harq); - // check Rel10 or Rel8 SR #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + if ((UE_list-> UE_template[CC_id][UE_id].physicalConfigDedicated->ext2) - && (UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->ext2->schedulingRequestConfig_v1020) - && (UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->ext2->schedulingRequestConfig_v1020)) { - sr.sr_information_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL10_TAG; - sr.sr_information_rel10.number_of_pucch_resources = 1; - sr.sr_information_rel10.pucch_index_p1 = *UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->ext2->schedulingRequestConfig_v1020->sr_PUCCH_ResourceIndexP1_r10; - LOG_D(MAC,"REL10 PUCCH INDEX P1:%d\n", sr.sr_information_rel10.pucch_index_p1); + && (UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->ext2->schedulingRequestConfig_v1020) + && (UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->ext2->schedulingRequestConfig_v1020)) { + sr.sr_information_rel10.tl.tag = NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL10_TAG; + sr.sr_information_rel10.number_of_pucch_resources = 1; + sr.sr_information_rel10.pucch_index_p1 = *UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->ext2->schedulingRequestConfig_v1020->sr_PUCCH_ResourceIndexP1_r10; + LOG_D(MAC,"REL10 PUCCH INDEX P1:%d\n", sr.sr_information_rel10.pucch_index_p1); } else #endif - { - sr.sr_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL8_TAG; - sr.sr_information_rel8.pucch_index = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex; - LOG_D(MAC,"REL8 PUCCH INDEX:%d\n", sr.sr_information_rel8.pucch_index); - } + { + sr.sr_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL8_TAG; + sr.sr_information_rel8.pucch_index = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex; + LOG_D(MAC,"REL8 PUCCH INDEX:%d\n", sr.sr_information_rel8.pucch_index); + } /* if there is already an HARQ pdu, convert to SR_HARQ */ if (is_harq) { - nfapi_ul_config_harq_information h = ul_req_body->ul_config_pdu_list[i].uci_harq_pdu.harq_information; - ul_req_body->ul_config_pdu_list[i].pdu_type = NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE; - ul_req_body->ul_config_pdu_list[i].uci_sr_harq_pdu.sr_information = sr; - ul_req_body->ul_config_pdu_list[i].uci_sr_harq_pdu.harq_information = h; + nfapi_ul_config_harq_information h = ul_req_body->ul_config_pdu_list[i].uci_harq_pdu.harq_information; + ul_req_body->ul_config_pdu_list[i].pdu_type = NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE; + ul_req_body->ul_config_pdu_list[i].uci_sr_harq_pdu.sr_information = sr; + ul_req_body->ul_config_pdu_list[i].uci_sr_harq_pdu.harq_information = h; } else { - ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].pdu_type = NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE; - ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; - ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel8.rnti = UE_list->UE_template[CC_id][UE_id].rnti; - ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel11.tl.tag = 0; - ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel13.tl.tag = 0; - ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.sr_information = sr; - ul_req_body->number_of_pdus++; - } /* if (is_harq) */ + ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].pdu_type = NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE; + ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; + ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel8.rnti = UE_list->UE_template[CC_id][UE_id].rnti; + ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel11.tl.tag = 0; + ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.ue_information.ue_information_rel13.tl.tag = 0; + ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus].uci_sr_pdu.sr_information = sr; + ul_req_body->number_of_pdus++; + } /* if (is_harq) */ + ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - } // for (UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) - } // for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) + } // 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++) } -extern uint8_t nfapi_mode; - void check_ul_failure(module_id_t module_idP, int CC_id, int UE_id, - frame_t frameP, sub_frame_t subframeP) -{ + frame_t frameP, sub_frame_t subframeP) { UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; nfapi_dl_config_request_t *DL_req = &RC.mac[module_idP]->DL_req[0]; uint16_t rnti = UE_RNTI(module_idP, UE_id); @@ -362,9 +358,9 @@ check_ul_failure(module_id_t module_idP, int CC_id, int UE_id, if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer == 1) LOG_I(MAC, "UE %d rnti %x: UL Failure timer %d \n", UE_id, rnti, UE_list->UE_sched_ctrl[UE_id].ul_failure_timer); + if (UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent == 0) { UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 1; - // add a format 1A dci for this UE to request an RA procedure (only one UE per subframe) nfapi_dl_config_request_pdu_t *dl_config_pdu = &DL_req[CC_id].dl_config_request_body.dl_config_pdu_list[DL_req[CC_id].dl_config_request_body.number_pdu]; memset((void *) dl_config_pdu, 0,sizeof(nfapi_dl_config_request_pdu_t)); @@ -373,34 +369,35 @@ check_ul_failure(module_id_t module_idP, int CC_id, int UE_id, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP, CC_id), - UE_list->UE_sched_ctrl[UE_id]. - dl_cqi[CC_id], format1A); + UE_list->UE_sched_ctrl[UE_id]. + dl_cqi[CC_id], format1A); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power AssertFatal((cc[CC_id].mib->message.dl_Bandwidth >= 0) && (cc[CC_id].mib->message.dl_Bandwidth < 6), - "illegal dl_Bandwidth %d\n", - (int) cc[CC_id].mib->message.dl_Bandwidth); + "illegal dl_Bandwidth %d\n", + (int) cc[CC_id].mib->message.dl_Bandwidth); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = pdcch_order_table[cc[CC_id].mib->message.dl_Bandwidth]; DL_req[CC_id].dl_config_request_body.number_dci++; DL_req[CC_id].dl_config_request_body.number_pdu++; DL_req[CC_id].dl_config_request_body.tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; LOG_D(MAC, - "UE %d rnti %x: sending PDCCH order for RAPROC (failure timer %d), resource_block_coding %d \n", - UE_id, rnti, - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer, - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.resource_block_coding); - } else { // ra_pdcch_sent==1 + "UE %d rnti %x: sending PDCCH order for RAPROC (failure timer %d), resource_block_coding %d \n", + UE_id, rnti, + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer, + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.resource_block_coding); + } else { // ra_pdcch_sent==1 LOG_D(MAC, - "UE %d rnti %x: sent PDCCH order for RAPROC waiting (failure timer %d) \n", - UE_id, rnti, - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer); - if ((UE_list->UE_sched_ctrl[UE_id].ul_failure_timer % 80) == 0) UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 0; // resend every 8 frames + "UE %d rnti %x: sent PDCCH order for RAPROC waiting (failure timer %d) \n", + UE_id, rnti, + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer); + + if ((UE_list->UE_sched_ctrl[UE_id].ul_failure_timer % 80) == 0) UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 0; // resend every 8 frames } UE_list->UE_sched_ctrl[UE_id].ul_failure_timer++; + // check threshold if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer > 4000) { // note: probably ul_failure_timer should be less than UE radio link failure time(see T310/N310/N311) @@ -415,113 +412,91 @@ check_ul_failure(module_id_t module_idP, int CC_id, int UE_id, } else { // inform RRC of failure and clear timer LOG_I(MAC, - "UE %d rnti %x: UL Failure after repeated PDCCH orders: Triggering RRC \n", - UE_id, rnti); + "UE %d rnti %x: UL Failure after repeated PDCCH orders: Triggering RRC \n", + UE_id, rnti); mac_eNB_rrc_ul_failure(module_idP, CC_id, frameP, subframeP,rnti); } + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 1; } - } // ul_failure_timer>0 + } // ul_failure_timer>0 } void -clear_nfapi_information(eNB_MAC_INST * eNB, int CC_idP, - frame_t frameP, sub_frame_t subframeP) -{ +clear_nfapi_information(eNB_MAC_INST *eNB, int CC_idP, + frame_t frameP, sub_frame_t subframeP) { nfapi_dl_config_request_t *DL_req = &eNB->DL_req[0]; nfapi_ul_config_request_t *UL_req = &eNB->UL_req[0]; nfapi_hi_dci0_request_t *HI_DCI0_req = &eNB->HI_DCI0_req[CC_idP][subframeP]; nfapi_tx_request_t *TX_req = &eNB->TX_req[0]; - eNB->pdu_index[CC_idP] = 0; - if (nfapi_mode==0 || nfapi_mode == 1) { // monolithic or PNF - + if (NFAPI_MODE == NFAPI_MODE_PNF || NFAPI_MODE == NFAPI_MONOLITHIC) { // monolithic or PNF DL_req[CC_idP].dl_config_request_body.number_pdcch_ofdm_symbols = 1; DL_req[CC_idP].dl_config_request_body.number_dci = 0; DL_req[CC_idP].dl_config_request_body.number_pdu = 0; DL_req[CC_idP].dl_config_request_body.number_pdsch_rnti = 0; DL_req[CC_idP].dl_config_request_body.transmission_power_pcfich = 6000; DL_req[CC_idP].sfn_sf = subframeP + (frameP<<4); - HI_DCI0_req->hi_dci0_request_body.sfnsf = subframeP + (frameP<<4); HI_DCI0_req->hi_dci0_request_body.number_of_dci = 0; - - UL_req[CC_idP].ul_config_request_body.number_of_pdus = 0; UL_req[CC_idP].ul_config_request_body.rach_prach_frequency_resources = 0; // ignored, handled by PHY for now UL_req[CC_idP].ul_config_request_body.srs_present = 0; // ignored, handled by PHY for now - TX_req[CC_idP].tx_request_body.number_of_pdus = 0; - } } void -copy_ulreq(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) -{ +copy_ulreq(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) { int CC_id; eNB_MAC_INST *mac = RC.mac[module_idP]; for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - nfapi_ul_config_request_t *ul_req_tmp = &mac->UL_req_tmp[CC_id][subframeP]; nfapi_ul_config_request_t *ul_req = &mac->UL_req[CC_id]; nfapi_ul_config_request_pdu_t *ul_req_pdu = ul_req->ul_config_request_body.ul_config_pdu_list; - *ul_req = *ul_req_tmp; - // Restore the pointer ul_req->ul_config_request_body.ul_config_pdu_list = ul_req_pdu; ul_req->sfn_sf = (frameP<<4) + subframeP; ul_req_tmp->ul_config_request_body.number_of_pdus = 0; - if (ul_req->ul_config_request_body.number_of_pdus>0) - { - LOG_D(PHY, "%s() active NOW (frameP:%d subframeP:%d) pdus:%d\n", __FUNCTION__, frameP, subframeP, ul_req->ul_config_request_body.number_of_pdus); - } + if (ul_req->ul_config_request_body.number_of_pdus>0) { + LOG_D(PHY, "%s() active NOW (frameP:%d subframeP:%d) pdus:%d\n", __FUNCTION__, frameP, subframeP, ul_req->ul_config_request_body.number_of_pdus); + } - memcpy((void*)ul_req->ul_config_request_body.ul_config_pdu_list, - (void*)ul_req_tmp->ul_config_request_body.ul_config_pdu_list, - ul_req->ul_config_request_body.number_of_pdus*sizeof(nfapi_ul_config_request_pdu_t)); + memcpy((void *)ul_req->ul_config_request_body.ul_config_pdu_list, + (void *)ul_req_tmp->ul_config_request_body.ul_config_pdu_list, + ul_req->ul_config_request_body.number_of_pdus*sizeof(nfapi_ul_config_request_pdu_t)); } } void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, - sub_frame_t subframeP) -{ - + sub_frame_t subframeP) { int mbsfn_status[MAX_NUM_CCs]; protocol_ctxt_t ctxt; - int CC_id, i = -1; UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; rnti_t rnti; - COMMON_channels_t *cc = RC.mac[module_idP]->common_channels; - start_meas(&RC.mac[module_idP]->eNB_scheduler); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER, - VCD_FUNCTION_IN); - + (VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER, + VCD_FUNCTION_IN); RC.mac[module_idP]->frame = frameP; RC.mac[module_idP]->subframe = subframeP; for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { mbsfn_status[CC_id] = 0; - // clear vrb_maps memset(cc[CC_id].vrb_map, 0, 100); memset(cc[CC_id].vrb_map_UL, 0, 100); - - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) cc[CC_id].mcch_active = 0; #endif - clear_nfapi_information(RC.mac[module_idP], CC_id, frameP, subframeP); } @@ -530,105 +505,115 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, 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], - (5*UE_list->UE_sched_ctrl[i].pusch_snr[CC_id] - 640) / 10, - (5*UE_list->UE_sched_ctrl[i].pucch1_snr[CC_id] - 640) / 10); + 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], + (5*UE_list->UE_sched_ctrl[i].pusch_snr[CC_id] - 640) / 10, + (5*UE_list->UE_sched_ctrl[i].pucch1_snr[CC_id] - 640) / 10); } - + RC.eNB[module_idP][CC_id]->pusch_stats_bsr[i][(frameP * 10) + - subframeP] = -63; + 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]); + 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); + 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; + 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; + //clear reestablish_rnti_map - if(RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer_thres >20){ - 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; - } - } + if(RC.mac[module_idP]->UE_list.UE_sched_ctrl[i].ue_reestablishment_reject_timer_thres >20) { + 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; + } + } PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, rnti, 0, 0,module_idP); rrc_rlc_remove_ue(&ctxt); pdcp_remove_UE(&ctxt); } - // 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)){ + + // 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)) { void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); - LOG_I(MAC, "clean_eNb_ulsch UE %x \n", rnti); - clean_eNb_ulsch(ulsch); - } - } - 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_ulsch UE %x \n", rnti); + clean_eNb_ulsch(ulsch); + } + } + + 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)) { void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch); - LOG_I(MAC, "clean_eNb_dlsch UE %x \n", rnti); - clean_eNb_dlsch(dlsch); - } - } - - for(int j = 0; j < 10; j++){ - nfapi_ul_config_request_body_t *ul_req_tmp = NULL; - ul_req_tmp = &RC.mac[module_idP]->UL_req_tmp[CC_id][j].ul_config_request_body; - if(ul_req_tmp){ - int pdu_number = ul_req_tmp->number_of_pdus; - for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){ - if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti){ - LOG_I(MAC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number); - if(pdu_index < pdu_number -1){ - memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); - } - ul_req_tmp->number_of_pdus--; - } - } - } - } - rrc_mac_remove_ue(module_idP,rnti); - } + LOG_I(MAC, "clean_eNb_dlsch UE %x \n", rnti); + clean_eNb_dlsch(dlsch); + } + } + + for(int j = 0; j < 10; j++) { + nfapi_ul_config_request_body_t *ul_req_tmp = NULL; + ul_req_tmp = &RC.mac[module_idP]->UL_req_tmp[CC_id][j].ul_config_request_body; + + if(ul_req_tmp) { + int pdu_number = ul_req_tmp->number_of_pdus; + + for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--) { + if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) { + LOG_I(MAC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number); + + if(pdu_index < pdu_number -1) { + memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); + } + + ul_req_tmp->number_of_pdus--; + } + } + } + } + + rrc_mac_remove_ue(module_idP,rnti); + } } } } #if (!defined(PRE_SCD_THREAD)) PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, - NOT_A_RNTI, frameP, subframeP, - module_idP); + NOT_A_RNTI, frameP, subframeP, + module_idP); pdcp_run(&ctxt); - rrc_rx_tx(&ctxt, CC_id); #endif - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { @@ -640,27 +625,29 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, } #endif - static int debug_flag=0; void (*schedule_ulsch_p)(module_id_t module_idP, frame_t frameP, sub_frame_t subframe)=NULL; void (*schedule_ue_spec_p)(module_id_t module_idP, frame_t frameP, sub_frame_t subframe, int *mbsfn_flag)=NULL; - if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_DEFAULT){ + + if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_DEFAULT) { schedule_ulsch_p = schedule_ulsch; schedule_ue_spec_p = schedule_dlsch; - }else if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){ + } else if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR) { memset(dlsch_ue_select, 0, sizeof(dlsch_ue_select)); schedule_ulsch_p = schedule_ulsch_fairRR; schedule_ue_spec_p = schedule_ue_spec_fairRR; } - if(debug_flag==0){ + + if(debug_flag==0) { LOG_E(MAC,"SCHED_MODE=%d\n",RC.mac[module_idP]->scheduler_mode); debug_flag=1; } // This schedules MIB if ((subframeP == 0) && (frameP & 3) == 0) - schedule_mib(module_idP, frameP, subframeP); - if (get_softmodem_params()->phy_test == 0){ + schedule_mib(module_idP, frameP, subframeP); + + if (get_softmodem_params()->phy_test == 0) { // This schedules SI for legacy LTE and eMTC starting in subframeP schedule_SI(module_idP, frameP, subframeP); // This schedules Paging in subframeP @@ -671,12 +658,14 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, copy_ulreq(module_idP, frameP, subframeP); // This schedules SRS in subframeP schedule_SRS(module_idP, frameP, subframeP); + // This schedules ULSCH in subframeP (dci0) if (schedule_ulsch_p != NULL) { - schedule_ulsch_p(module_idP, frameP, subframeP); + schedule_ulsch_p(module_idP, frameP, subframeP); } else { - LOG_E(MAC," %s %d: schedule_ulsch_p is NULL, function not called\n",__FILE__,__LINE__); + LOG_E(MAC," %s %d: schedule_ulsch_p is NULL, function not called\n",__FILE__,__LINE__); } + // This schedules UCI_SR in subframeP schedule_SR(module_idP, frameP, subframeP); // This schedules UCI_CSI in subframeP @@ -685,15 +674,14 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, // This schedules DLSCH in subframeP schedule_ue_spec_br(module_idP, frameP, subframeP); #endif + // This schedules DLSCH in subframeP if (schedule_ue_spec_p != NULL) { - schedule_ue_spec_p(module_idP, frameP, subframeP, mbsfn_status); + schedule_ue_spec_p(module_idP, frameP, subframeP, mbsfn_status); } else { - LOG_E(MAC," %s %d: schedule_ue_spec_p is NULL, function not called\n",__FILE__,__LINE__); + LOG_E(MAC," %s %d: schedule_ue_spec_p is NULL, function not called\n",__FILE__,__LINE__); } - - } - else{ + } else { schedule_ulsch_phy_test(module_idP,frameP,subframeP); schedule_ue_spec_phy_test(module_idP,frameP,subframeP,mbsfn_status); } @@ -709,8 +697,7 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, } stop_meas(&RC.mac[module_idP]->eNB_scheduler); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER, - VCD_FUNCTION_OUT); + (VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER, + VCD_FUNCTION_OUT); } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 79d791c55850a39e64251282babc25ae94dabb91..fa0aaec3f00bd8c10676eab020ceac11c19aa26f 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -41,6 +41,7 @@ #include "LAYER2/MAC/mac_proto.h" #include "common/utils/LOG/log.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" @@ -55,10 +56,10 @@ #include "pdcp.h" #if defined(ENABLE_ITTI) -#include "intertask_interface.h" + #include "intertask_interface.h" #endif -#include "SIMULATION/TOOLS/sim.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus #include "T.h" @@ -67,68 +68,58 @@ 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); -void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset) -{ - *frameP = (*frameP + ((*subframeP + offset) / 10)) % 1024; +extern int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req); - *subframeP = ((*subframeP + offset) % 10); +void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset) { + *frameP = (*frameP + ((*subframeP + offset) / 10)) % 1024; + *subframeP = ((*subframeP + offset) % 10); } -uint16_t sfnsf_add_subframe(uint16_t frameP, uint16_t subframeP, int offset) -{ +uint16_t sfnsf_add_subframe(uint16_t frameP, uint16_t subframeP, int offset) { add_subframe(&frameP, &subframeP, offset); return frameP<<4|subframeP; } -void subtract_subframe(uint16_t *frameP, uint16_t *subframeP, int offset) -{ - if (*subframeP < offset) - { +void subtract_subframe(uint16_t *frameP, uint16_t *subframeP, int offset) { + if (*subframeP < offset) { *frameP = (*frameP+1024-1)%1024; } + *subframeP = (*subframeP+10-offset)%10; } -uint16_t sfnsf_subtract_subframe(uint16_t frameP, uint16_t subframeP, int offset) -{ +uint16_t sfnsf_subtract_subframe(uint16_t frameP, uint16_t subframeP, int offset) { subtract_subframe(&frameP, &subframeP, offset); return frameP<<4|subframeP; } void -add_msg3(module_id_t module_idP, int CC_id, RA_t * ra, frame_t frameP, - sub_frame_t subframeP) -{ - eNB_MAC_INST *mac = RC.mac[module_idP]; - COMMON_channels_t *cc = &mac->common_channels[CC_id]; - uint8_t j; - nfapi_ul_config_request_t *ul_req; - nfapi_ul_config_request_body_t *ul_req_body; - nfapi_ul_config_request_pdu_t *ul_config_pdu; - nfapi_hi_dci0_request_t *hi_dci0_req; - nfapi_hi_dci0_request_body_t *hi_dci0_req_body; - nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; - uint8_t sf_ahead_dl; - uint8_t rvseq[4] = {0, 2, 3, 1}; - - - ul_req = &mac->UL_req_tmp[CC_id][ra->Msg3_subframe]; - ul_req_body = &ul_req->ul_config_request_body; - AssertFatal(ra->state != IDLE, "RA is not active for RA %X\n", - ra->rnti); - +add_msg3(module_id_t module_idP, int CC_id, RA_t *ra, frame_t frameP, + sub_frame_t subframeP) { + eNB_MAC_INST *mac = RC.mac[module_idP]; + COMMON_channels_t *cc = &mac->common_channels[CC_id]; + uint8_t j; + nfapi_ul_config_request_t *ul_req; + nfapi_ul_config_request_body_t *ul_req_body; + nfapi_ul_config_request_pdu_t *ul_config_pdu; + nfapi_hi_dci0_request_t *hi_dci0_req; + nfapi_hi_dci0_request_body_t *hi_dci0_req_body; + nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; + uint8_t sf_ahead_dl; + uint8_t rvseq[4] = {0, 2, 3, 1}; + ul_req = &mac->UL_req_tmp[CC_id][ra->Msg3_subframe]; + ul_req_body = &ul_req->ul_config_request_body; + AssertFatal(ra->state != IDLE, "RA is not active for RA %X\n", + ra->rnti); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + if (ra->rach_resource_type > 0) { LOG_D (MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d CE level %d is active, Msg3 in (%d,%d)\n", module_idP, frameP, subframeP, CC_id, ra->rach_resource_type - 1, ra->Msg3_frame, ra->Msg3_subframe); LOG_D (MAC, "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d)\n", frameP, subframeP, ra->Msg3_frame, ra->Msg3_subframe, ra->msg3_nb_rb, ra->msg3_round); - ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus]; - memset ((void *) ul_config_pdu, 0, sizeof (nfapi_ul_config_request_pdu_t)); ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE; ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_ul_config_ulsch_pdu)); @@ -156,127 +147,117 @@ add_msg3(module_id_t module_idP, int CC_id, RA_t * ra, frame_t frameP, } // if (ra->rach_resource_type>0) { else #endif - { - LOG_D(MAC, - "[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA is active, Msg3 in (%d,%d)\n", - module_idP, frameP, subframeP, CC_id, ra->Msg3_frame, - ra->Msg3_subframe); - - LOG_D(MAC, - "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d) for rnti: %d\n", - frameP, subframeP, ra->Msg3_frame, ra->Msg3_subframe, - ra->msg3_nb_rb, ra->msg3_first_rb, ra->msg3_round, ra->rnti); - - ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus]; - - memset((void *) ul_config_pdu, 0, sizeof(nfapi_ul_config_request_pdu_t)); - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE; - ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_ul_config_ulsch_pdu)); - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.handle = mac->ul_handle++; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti = ra->rnti; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.resource_block_start = ra->msg3_first_rb; - AssertFatal(ra->msg3_nb_rb > 0, "nb_rb = 0\n"); - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = ra->msg3_nb_rb; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 2; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_enabled_flag = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.new_data_indication = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.redundancy_version = rvseq[ra->msg3_round]; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number = subframe2harqpid(cc, ra->Msg3_frame, ra->Msg3_subframe); - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.current_tx_nb = 0; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.n_srs = 1; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size = get_TBS_UL(10, ra->msg3_nb_rb); - ul_req_body->number_of_pdus++; - ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - ul_req->sfn_sf = ra->Msg3_frame<<4|ra->Msg3_subframe; - ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; - // save UL scheduling information for preprocessor - for (j = 0; j < ra->msg3_nb_rb; j++) - cc->vrb_map_UL[ra->msg3_first_rb + j] = 1; - - LOG_D(MAC, "MSG3: UL_CONFIG SFN/SF:%d number_of_pdus:%d ra->msg3_round:%d\n", NFAPI_SFNSF2DEC(ul_req->sfn_sf), ul_req_body->number_of_pdus, ra->msg3_round); - - if (ra->msg3_round != 0) { // program HI too - sf_ahead_dl = ul_subframe2_k_phich(cc, subframeP); - hi_dci0_req = &mac->HI_DCI0_req[CC_id][(subframeP+sf_ahead_dl)%10]; - hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; - hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; - memset((void *) hi_dci0_pdu, 0, - sizeof(nfapi_hi_dci0_request_pdu_t)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; - hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_hi_pdu); - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = ra->msg3_first_rb; - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = 0; - hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 0; - hi_dci0_req_body->number_of_hi++; - - hi_dci0_req_body->sfnsf = sfnsf_add_subframe(ra->Msg3_frame, ra->Msg3_subframe, 0); - hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; - - hi_dci0_req->sfn_sf = sfnsf_add_subframe(frameP, subframeP, sf_ahead_dl); - hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; - - if (nfapi_mode) { - oai_nfapi_hi_dci0_req(hi_dci0_req); - hi_dci0_req_body->number_of_hi=0; - } - - LOG_D(MAC, "MSG3: HI_DCI0 SFN/SF:%d number_of_dci:%d number_of_hi:%d\n", NFAPI_SFNSF2DEC(hi_dci0_req->sfn_sf), hi_dci0_req_body->number_of_dci, hi_dci0_req_body->number_of_hi); - - // save UL scheduling information for preprocessor - for (j = 0; j < ra->msg3_nb_rb; j++) - cc->vrb_map_UL[ra->msg3_first_rb + j] = 1; - - LOG_D(MAC, - "[eNB %d][PUSCH-RA %x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) RA (mcs %d, first rb %d, nb_rb %d,round %d)\n", - module_idP, ra->rnti, CC_id, frameP, subframeP, 10, 1, 1, - ra->msg3_round - 1); - } // if (ra->msg3_round != 0) { // program HI too - } // non-BL/CE UE case + { + LOG_D(MAC, + "[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA is active, Msg3 in (%d,%d)\n", + module_idP, frameP, subframeP, CC_id, ra->Msg3_frame, + ra->Msg3_subframe); + LOG_D(MAC, + "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d) for rnti: %d\n", + frameP, subframeP, ra->Msg3_frame, ra->Msg3_subframe, + ra->msg3_nb_rb, ra->msg3_first_rb, ra->msg3_round, ra->rnti); + ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus]; + memset((void *) ul_config_pdu, 0, sizeof(nfapi_ul_config_request_pdu_t)); + ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE; + ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_ul_config_ulsch_pdu)); + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.handle = mac->ul_handle++; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti = ra->rnti; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.resource_block_start = ra->msg3_first_rb; + AssertFatal(ra->msg3_nb_rb > 0, "nb_rb = 0\n"); + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = ra->msg3_nb_rb; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 2; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_enabled_flag = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.new_data_indication = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.redundancy_version = rvseq[ra->msg3_round]; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number = subframe2harqpid(cc, ra->Msg3_frame, ra->Msg3_subframe); + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.current_tx_nb = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.n_srs = 1; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size = get_TBS_UL(10, ra->msg3_nb_rb); + ul_req_body->number_of_pdus++; + ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + ul_req->sfn_sf = ra->Msg3_frame<<4|ra->Msg3_subframe; + ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; + + // save UL scheduling information for preprocessor + for (j = 0; j < ra->msg3_nb_rb; j++) + cc->vrb_map_UL[ra->msg3_first_rb + j] = 1; + + LOG_D(MAC, "MSG3: UL_CONFIG SFN/SF:%d number_of_pdus:%d ra->msg3_round:%d\n", NFAPI_SFNSF2DEC(ul_req->sfn_sf), ul_req_body->number_of_pdus, ra->msg3_round); + + if (ra->msg3_round != 0) { // program HI too + sf_ahead_dl = ul_subframe2_k_phich(cc, subframeP); + hi_dci0_req = &mac->HI_DCI0_req[CC_id][(subframeP+sf_ahead_dl)%10]; + hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; + hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; + memset((void *) hi_dci0_pdu, 0, + sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; + hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_hi_pdu); + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = ra->msg3_first_rb; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = 0; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 0; + hi_dci0_req_body->number_of_hi++; + hi_dci0_req_body->sfnsf = sfnsf_add_subframe(ra->Msg3_frame, ra->Msg3_subframe, 0); + hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; + hi_dci0_req->sfn_sf = sfnsf_add_subframe(frameP, subframeP, sf_ahead_dl); + hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; + + if (NFAPI_MODE != NFAPI_MONOLITHIC) { + oai_nfapi_hi_dci0_req(hi_dci0_req); + hi_dci0_req_body->number_of_hi=0; + } + + LOG_D(MAC, "MSG3: HI_DCI0 SFN/SF:%d number_of_dci:%d number_of_hi:%d\n", NFAPI_SFNSF2DEC(hi_dci0_req->sfn_sf), hi_dci0_req_body->number_of_dci, hi_dci0_req_body->number_of_hi); + + // save UL scheduling information for preprocessor + for (j = 0; j < ra->msg3_nb_rb; j++) + cc->vrb_map_UL[ra->msg3_first_rb + j] = 1; + + LOG_D(MAC, + "[eNB %d][PUSCH-RA %x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) RA (mcs %d, first rb %d, nb_rb %d,round %d)\n", + module_idP, ra->rnti, CC_id, frameP, subframeP, 10, 1, 1, + ra->msg3_round - 1); + } // if (ra->msg3_round != 0) { // program HI too + } // non-BL/CE UE case } //------------------------------------------------------------------------------ /* * Generate the RAR (message2) */ -void generate_Msg2(module_id_t module_idP, - int CC_idP, - frame_t frameP, - sub_frame_t subframeP, - RA_t *ra) +void generate_Msg2(module_id_t module_idP, + int CC_idP, + frame_t frameP, + sub_frame_t subframeP, + RA_t *ra) //------------------------------------------------------------------------------ { eNB_MAC_INST *mac = RC.mac[module_idP]; COMMON_channels_t *cc = mac->common_channels; - uint8_t *vrb_map = NULL; int first_rb = 0; int N_RB_DL = 0; - nfapi_dl_config_request_pdu_t *dl_config_pdu = NULL; nfapi_tx_request_pdu_t *TX_req = NULL; nfapi_dl_config_request_body_t *dl_req_body = NULL; - vrb_map = cc[CC_idP].vrb_map; dl_req_body = &mac->DL_req[CC_idP].dl_config_request_body; dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth); - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) int rmax = 0; int rep = 0; int reps = 0; int num_nb = 0; - first_rb = 0; struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach = NULL; LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = NULL; LTE_PRACH_ParametersCE_r13_t *p[4] = { NULL, NULL, NULL, NULL }; - uint16_t absSF = (10 * frameP) + subframeP; uint16_t absSF_Msg2 = (10 * ra->Msg2_frame) + ra->Msg2_subframe; @@ -289,18 +270,22 @@ void generate_Msg2(module_id_t module_idP, prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; switch (prach_ParametersListCE_r13->list.count) { - case 4: - p[3] = prach_ParametersListCE_r13->list.array[3]; - case 3: - p[2] = prach_ParametersListCE_r13->list.array[2]; - case 2: - p[1] = prach_ParametersListCE_r13->list.array[1]; - case 1: - p[0] = prach_ParametersListCE_r13->list.array[0]; - break; - default: - AssertFatal (1 == 0, "Illegal count for prach_ParametersListCE_r13 %d\n", (int) prach_ParametersListCE_r13->list.count); - break; + case 4: + p[3] = prach_ParametersListCE_r13->list.array[3]; + + case 3: + p[2] = prach_ParametersListCE_r13->list.array[2]; + + case 2: + p[1] = prach_ParametersListCE_r13->list.array[1]; + + case 1: + p[0] = prach_ParametersListCE_r13->list.array[0]; + break; + + default: + AssertFatal (1 == 0, "Illegal count for prach_ParametersListCE_r13 %d\n", (int) prach_ParametersListCE_r13->list.count); + break; } } @@ -313,17 +298,13 @@ void generate_Msg2(module_id_t module_idP, * if CELevel = 2,3 => Table 9.1.5-2b for MPDCCH candidates * distributed transmission */ - /* rmax from SIB2 information */ AssertFatal (rmax < 9, "rmax > 8!\n"); // not sure of this assertion rmax = 1 << p[ra->rach_resource_type - 1]->mpdcch_NumRepetition_RA_r13; - /* Choose r1 by default for RAR (Table 9.1.5-5) */ rep = 0; - /* Get actual repetition count from Table 9.1.5-3 */ reps = (rmax <= 8) ? (1 << rep) : (rmax >> (3 - rep)); - /* Get narrowband according to higher-layer config */ num_nb = p[ra->rach_resource_type - 1]->mpdcch_NarrowbandsToMonitor_r13.list.count; ra->msg2_narrowband = *p[ra->rach_resource_type - 1]->mpdcch_NarrowbandsToMonitor_r13.list.array[ra->preamble_index % num_nb] - 1; @@ -331,17 +312,14 @@ void generate_Msg2(module_id_t module_idP, if ((ra->msg2_mpdcch_repetition_cnt == 0) && (mpdcch_sf_condition(mac, CC_idP, frameP, subframeP, rmax, TYPE2, -1) > 0)) { ra->msg2_mpdcch_done = 0; - /* MPDCCH configuration for RAR */ - LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2 for CE Level %d, Programming MPDCCH %d repetitions\n", - module_idP, - frameP, - subframeP, + LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2 for CE Level %d, Programming MPDCCH %d repetitions\n", + module_idP, + frameP, + subframeP, ra->rach_resource_type - 1, reps); - memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE; dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu)); dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = (ra->rach_resource_type > 1) ? 11 : 10; @@ -349,9 +327,7 @@ void generate_Msg2(module_id_t module_idP, dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = 6; dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = 1; // imposed (9.1.5 in 213) for Type 2 Common search space - AssertFatal (cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 != NULL, "cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n"); - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13; dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0; // Note: this should be dynamic dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 24; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4 @@ -361,7 +337,7 @@ void generate_Msg2(module_id_t module_idP, dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = cc[CC_idP].physCellId; dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP; dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000; // 0dB - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV(6, 0, 6) | (ra->msg2_narrowband<<5); + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV(6, 0, 6) | (ra->msg2_narrowband<<5); dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = 0; // adjust according to size of RAR, 208 bits with N1A_PRB=3 dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 0; // fix to 4 for now dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = 0; @@ -388,7 +364,6 @@ void generate_Msg2(module_id_t module_idP, dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0; dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1; - ra->msg2_mpdcch_repetition_cnt++; dl_req_body->number_pdu++; ra->Msg2_subframe = (ra->Msg2_subframe + 9) % 10; @@ -396,7 +371,7 @@ void generate_Msg2(module_id_t module_idP, if (ra->msg2_mpdcch_repetition_cnt > 0) { // we're in a stream of repetitions if ((ra->msg2_mpdcch_repetition_cnt == reps) && (ra->msg2_mpdcch_done == 0)) { // this is the last mpdcch repetition - ra->msg2_mpdcch_done = 1; + ra->msg2_mpdcch_done = 1; if (cc[CC_idP].tdd_Config == NULL) { // FDD case // wait 2 subframes for PDSCH transmission @@ -404,38 +379,34 @@ void generate_Msg2(module_id_t module_idP, ra->Msg2_frame = (frameP + 1) & 1023; else ra->Msg2_frame = frameP; + ra->Msg2_subframe = (subframeP + 2) % 10; // +2 is the "n+x" from Section 7.1.11 in 36.213 - - LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, programmed Msg2 for %d.%d\n", - module_idP, - frameP, - subframeP, + LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, programmed Msg2 for %d.%d\n", + module_idP, + frameP, + subframeP, ra->Msg2_frame, - ra->Msg2_subframe); + ra->Msg2_subframe); } else { AssertFatal(1 == 0, "TDD case not done yet\n"); } } else if (ra->msg2_mpdcch_done == 0) { // mpdcch_repetition_count != reps - LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, MPDCCH repetition %d\n", - module_idP, - frameP, - subframeP, - ra->msg2_mpdcch_repetition_cnt); - + LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, MPDCCH repetition %d\n", + module_idP, + frameP, + subframeP, + ra->msg2_mpdcch_repetition_cnt); ra->msg2_mpdcch_repetition_cnt++; } if((ra->Msg2_frame == frameP) && (ra->Msg2_subframe == subframeP)) { /* Program PDSCH */ - LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming PDSCH\n", - module_idP, - frameP, + LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming PDSCH\n", + module_idP, + frameP, subframeP); - dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; - memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_dlsch_pdu)); dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = mac->pdu_index[CC_idP]; @@ -460,31 +431,24 @@ void generate_Msg2(module_id_t module_idP, dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; - /* Rel10 fields */ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13; - /* Rel13 fields */ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (ra->rach_resource_type < 3) ? 1 : 2;; dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not SI message dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10 * frameP) + subframeP; dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0; dl_req_body->number_pdu++; - - fill_rar_br(mac, CC_idP, ra, frameP, subframeP, cc[CC_idP].RAR_pdu.payload, ra->rach_resource_type - 1); - + fill_rar_br(mac, CC_idP, ra, frameP, subframeP, cc[CC_idP].RAR_pdu.payload, ra->rach_resource_type - 1); /* Program UL processing for Msg3, same as regular LTE */ get_Msg3alloc (&cc[CC_idP], subframeP, frameP, &ra->Msg3_frame, &ra->Msg3_subframe); add_msg3 (module_idP, CC_idP, ra, frameP, subframeP); - - ra->state = WAITMSG3; - + ra->state = WAITMSG3; /* DL request */ - LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming TX Req\n", - module_idP, - frameP, + LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming TX Req\n", + module_idP, + frameP, subframeP); - mac->TX_req[CC_idP].sfn_sf = (frameP << 4) + subframeP; TX_req = &mac->TX_req[CC_idP].tx_request_body.tx_pdu_list[mac->TX_req[CC_idP].tx_request_body.number_of_pdus]; TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble @@ -496,115 +460,104 @@ void generate_Msg2(module_id_t module_idP, } } } else - #endif - { + { + if ((ra->Msg2_frame == frameP) && (ra->Msg2_subframe == subframeP)) { + LOG_D(MAC, + "[eNB %d] CC_id %d Frame %d, subframeP %d: Generating RAR DCI, state %d\n", + module_idP, CC_idP, frameP, subframeP, ra->state); + // Allocate 4 PRBS starting in RB 0 + first_rb = 0; + vrb_map[first_rb] = 1; + vrb_map[first_rb + 1] = 1; + vrb_map[first_rb + 2] = 1; + vrb_map[first_rb + 3] = 1; + memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu)); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = 4; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = ra->RA_rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 2; // RA-RNTI : see Table 4-10 from SCF082 - nFAPI specifications + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // no TPC + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 4); + + // This checks if the above DCI allocation is feasible in current subframe + if (!CCE_allocation_infeasible(module_idP, CC_idP, 0, subframeP, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, ra->RA_rnti)) { + LOG_D(MAC, + "Frame %d: Subframe %d : Adding common DCI for RA_RNTI %x\n", + frameP, subframeP, ra->RA_rnti); + dl_req_body->number_dci++; + dl_req_body->number_pdu++; + dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; + memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; + dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu)); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = mac->pdu_index[CC_idP]; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = ra->RA_rnti; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 4); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1; // first block + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB == 1) ? 0 : 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB == 1) ? 1 : 2; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; + dl_req_body->number_pdu++; + mac->DL_req[CC_idP].sfn_sf = frameP<<4 | subframeP; + // Program UL processing for Msg3 + get_Msg3alloc(&cc[CC_idP], subframeP, frameP,&ra->Msg3_frame, &ra->Msg3_subframe); + LOG_D(MAC, + "Frame %d, Subframe %d: Setting Msg3 reception for Frame %d Subframe %d\n", + frameP, subframeP, ra->Msg3_frame, + ra->Msg3_subframe); + fill_rar(module_idP, CC_idP, ra, frameP, cc[CC_idP].RAR_pdu.payload, N_RB_DL, 7); + add_msg3(module_idP, CC_idP, ra, frameP, subframeP); + ra->state = WAITMSG3; + LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:WAITMSG3\n", module_idP, frameP, subframeP); + T(T_ENB_MAC_UE_DL_RAR_PDU_WITH_DATA, T_INT(module_idP), + T_INT(CC_idP), T_INT(ra->RA_rnti), T_INT(frameP), + T_INT(subframeP), T_INT(0 /*harq_pid always 0? */ ), + T_BUFFER(cc[CC_idP].RAR_pdu.payload, 7)); + // DL request + mac->TX_req[CC_idP].sfn_sf = (frameP << 4) + subframeP; + TX_req = + &mac->TX_req[CC_idP].tx_request_body.tx_pdu_list[mac->TX_req[CC_idP].tx_request_body.number_of_pdus]; + TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble + TX_req->pdu_index = mac->pdu_index[CC_idP]++; + TX_req->num_segments = 1; + TX_req->segments[0].segment_length = 7; + TX_req->segments[0].segment_data = + cc[CC_idP].RAR_pdu.payload; + mac->TX_req[CC_idP].tx_request_body.number_of_pdus++; - if ((ra->Msg2_frame == frameP) && (ra->Msg2_subframe == subframeP)) { - LOG_D(MAC, - "[eNB %d] CC_id %d Frame %d, subframeP %d: Generating RAR DCI, state %d\n", - module_idP, CC_idP, frameP, subframeP, ra->state); - - // Allocate 4 PRBS starting in RB 0 - first_rb = 0; - vrb_map[first_rb] = 1; - vrb_map[first_rb + 1] = 1; - vrb_map[first_rb + 2] = 1; - vrb_map[first_rb + 3] = 1; - - memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu)); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = 4; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = ra->RA_rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 2; // RA-RNTI : see Table 4-10 from SCF082 - nFAPI specifications - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = 0; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // no TPC - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = 0; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = 0; - - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 4); - - // This checks if the above DCI allocation is feasible in current subframe - if (!CCE_allocation_infeasible(module_idP, CC_idP, 0, subframeP, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, ra->RA_rnti)) { - LOG_D(MAC, - "Frame %d: Subframe %d : Adding common DCI for RA_RNTI %x\n", - frameP, subframeP, ra->RA_rnti); - dl_req_body->number_dci++; - dl_req_body->number_pdu++; - - dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; - memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu)); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = mac->pdu_index[CC_idP]; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = ra->RA_rnti; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 4); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1; // first block - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB == 1) ? 0 : 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB == 1) ? 1 : 2; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; - dl_req_body->number_pdu++; - mac->DL_req[CC_idP].sfn_sf = frameP<<4 | subframeP; - - // Program UL processing for Msg3 - get_Msg3alloc(&cc[CC_idP], subframeP, frameP,&ra->Msg3_frame, &ra->Msg3_subframe); - - LOG_D(MAC, - "Frame %d, Subframe %d: Setting Msg3 reception for Frame %d Subframe %d\n", - frameP, subframeP, ra->Msg3_frame, - ra->Msg3_subframe); - - fill_rar(module_idP, CC_idP, ra, frameP, cc[CC_idP].RAR_pdu.payload, N_RB_DL, 7); - add_msg3(module_idP, CC_idP, ra, frameP, subframeP); - ra->state = WAITMSG3; - LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:WAITMSG3\n", module_idP, frameP, subframeP); - - T(T_ENB_MAC_UE_DL_RAR_PDU_WITH_DATA, T_INT(module_idP), - T_INT(CC_idP), T_INT(ra->RA_rnti), T_INT(frameP), - T_INT(subframeP), T_INT(0 /*harq_pid always 0? */ ), - T_BUFFER(cc[CC_idP].RAR_pdu.payload, 7)); - - // DL request - mac->TX_req[CC_idP].sfn_sf = (frameP << 4) + subframeP; - TX_req = - &mac->TX_req[CC_idP].tx_request_body.tx_pdu_list[mac->TX_req[CC_idP].tx_request_body.number_of_pdus]; - TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble - TX_req->pdu_index = mac->pdu_index[CC_idP]++; - TX_req->num_segments = 1; - TX_req->segments[0].segment_length = 7; - TX_req->segments[0].segment_data = - cc[CC_idP].RAR_pdu.payload; - mac->TX_req[CC_idP].tx_request_body.number_of_pdus++; - if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){ - set_dl_ue_select_msg2(CC_idP, 4, -1, ra->rnti); - } - } // PDCCH CCE allocation is feasible - } // Msg2 frame/subframe condition - } // else BL/CE + if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR) { + set_dl_ue_select_msg2(CC_idP, 4, -1, ra->rnti); + } + } // PDCCH CCE allocation is feasible + } // Msg2 frame/subframe condition + } // else BL/CE } //------------------------------------------------------------------------------ @@ -612,17 +565,16 @@ void generate_Msg2(module_id_t module_idP, * Generate message 4 of RA procedure (RRC connection setup) */ void -generate_Msg4(module_id_t module_idP, - int CC_idP, +generate_Msg4(module_id_t module_idP, + int CC_idP, frame_t frameP, - sub_frame_t subframeP, - RA_t * ra) + sub_frame_t subframeP, + RA_t *ra) //------------------------------------------------------------------------------ { eNB_MAC_INST *mac = RC.mac[module_idP]; COMMON_channels_t *cc = mac->common_channels; UE_list_t *UE_list = &(mac->UE_list); - int16_t rrc_sdu_length = 0; uint16_t msg4_padding = 0; uint16_t msg4_post_padding = 0; @@ -633,22 +585,17 @@ generate_Msg4(module_id_t module_idP, uint8_t lcid = 0; uint8_t offset = 0; uint8_t *vrb_map = NULL; - nfapi_dl_config_request_pdu_t *dl_config_pdu = NULL; nfapi_ul_config_request_pdu_t *ul_config_pdu = NULL; nfapi_tx_request_pdu_t *TX_req = NULL; - nfapi_dl_config_request_t *dl_req = NULL; nfapi_dl_config_request_body_t *dl_req_body = NULL; nfapi_ul_config_request_body_t *ul_req_body = NULL; - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) int rmax = 0; int rep = 0; int reps = 0; - first_rb = 0; - struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach = NULL; struct LTE_PUCCH_ConfigCommon_v1310 *ext4_pucch = NULL; LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = NULL; @@ -658,90 +605,80 @@ generate_Msg4(module_id_t module_idP, int n1pucchan[4] = { 0, 0, 0, 0 }; if (cc[CC_idP].mib->message.schedulingInfoSIB1_BR_r13 > 0 && cc[CC_idP].radioResourceConfigCommon_BR) { - ext4_prach = cc[CC_idP].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310; prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; - ext4_pucch = cc[CC_idP].radioResourceConfigCommon_BR->ext4->pucch_ConfigCommon_v1310; pucch_N1PUCCH_AN_InfoList_r13 = ext4_pucch->n1PUCCH_AN_InfoList_r13; - AssertFatal (prach_ParametersListCE_r13 != NULL, "prach_ParametersListCE_r13 is null\n"); AssertFatal (pucch_N1PUCCH_AN_InfoList_r13 != NULL, "pucch_N1PUCCH_AN_InfoList_r13 is null\n"); - /* Check to verify CE-Level compatibility in SIB2_BR */ AssertFatal (prach_ParametersListCE_r13->list.count == pucch_N1PUCCH_AN_InfoList_r13->list.count, "prach_ParametersListCE_r13->list.count!= pucch_N1PUCCH_AN_InfoList_r13->list.count\n"); switch (prach_ParametersListCE_r13->list.count) { - case 4: - p[3] = prach_ParametersListCE_r13->list.array[3]; - n1pucchan[3] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[3]; + case 4: + p[3] = prach_ParametersListCE_r13->list.array[3]; + n1pucchan[3] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[3]; AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level3 shouldn't be NULL\n"); - pucchreps[3] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13); + pucchreps[3] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13); - case 3: - p[2] = prach_ParametersListCE_r13->list.array[2]; - n1pucchan[2] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[2]; + case 3: + p[2] = prach_ParametersListCE_r13->list.array[2]; + n1pucchan[2] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[2]; AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level2 shouldn't be NULL\n"); - pucchreps[2] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13); - case 2: - p[1] = prach_ParametersListCE_r13->list.array[1]; - n1pucchan[1] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[1]; + pucchreps[2] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13); + + case 2: + p[1] = prach_ParametersListCE_r13->list.array[1]; + n1pucchan[1] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[1]; AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level1 shouldn't be NULL\n"); - pucchreps[1] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13); - case 1: - p[0] = prach_ParametersListCE_r13->list.array[0]; - n1pucchan[0] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[0]; + pucchreps[1] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13); + + case 1: + p[0] = prach_ParametersListCE_r13->list.array[0]; + n1pucchan[0] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[0]; AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level0 shouldn't be NULL\n"); - pucchreps[0] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13); - break; - default: + pucchreps[0] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13); + break; + + default: AssertFatal(1 == 0, "Illegal count for prach_ParametersListCE_r13 %d\n", prach_ParametersListCE_r13->list.count); } } #endif + vrb_map = cc[CC_idP].vrb_map; + dl_req = &mac->DL_req[CC_idP]; + dl_req_body = &dl_req->dl_config_request_body; + dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; + N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth); + UE_id = find_UE_id(module_idP, ra->rnti); - vrb_map = cc[CC_idP].vrb_map; - - dl_req = &mac->DL_req[CC_idP]; - dl_req_body = &dl_req->dl_config_request_body; - dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; - - N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth); - - UE_id = find_UE_id(module_idP, ra->rnti); - - if (UE_id < 0) { - LOG_E(MAC, "Can't find UE for t-crnti %x, kill RA procedure for this UE\n", - ra->rnti); - - cancel_ra_proc(module_idP, CC_idP, frameP, ra->rnti); - return; - } - - // set HARQ process round to 0 for this UE - - ra->harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); - - /* // Get RRCConnectionSetup for Piggyback - rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block - &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case - if(rrc_sdu_length <= 0) { - LOG_D(MAC,"[MAC][eNB Scheduler] CCCH not allocated (%d)\n",rrc_sdu_length); - return; - } - //AssertFatal(rrc_sdu_length > 0, - //"[MAC][eNB Scheduler] CCCH not allocated\n"); - - - LOG_D(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n", - module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length);*/ - + if (UE_id < 0) { + LOG_E(MAC, "Can't find UE for t-crnti %x, kill RA procedure for this UE\n", + ra->rnti); + cancel_ra_proc(module_idP, CC_idP, frameP, ra->rnti); + return; + } + // set HARQ process round to 0 for this UE + ra->harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP,subframeP); + /* // Get RRCConnectionSetup for Piggyback + rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block + &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case + if(rrc_sdu_length <= 0) { + LOG_D(MAC,"[MAC][eNB Scheduler] CCCH not allocated (%d)\n",rrc_sdu_length); + return; + } + //AssertFatal(rrc_sdu_length > 0, + //"[MAC][eNB Scheduler] CCCH not allocated\n"); + + + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n", + module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length);*/ #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - if (ra->rach_resource_type > 0) { + if (ra->rach_resource_type > 0) { ra->harq_pid = 0; // Generate DCI + repetitions first // This uses an MPDCCH Type 2 allocation according to Section 9.1.5 36-213, Type2 common allocation according to Table 7.1-8 (36-213) @@ -751,11 +688,8 @@ generate_Msg4(module_id_t module_idP, // if CELevel = 0,1 => Table 9.1.5-1b for MPDCCH candidates // if CELevel = 2,3 => Table 9.1.5-2b for MPDCCH candidates // distributed transmission - // rmax from SIB2 information rmax = 1<<p[ra->rach_resource_type - 1]->mpdcch_NumRepetition_RA_r13; - - // choose r3 by default for Msg4 (this is ok from table 9.1.5-3 for rmax = >=4, if we choose rmax <4 it has to be less rep = 0; // get actual repetition count from Table 9.1.5-3 @@ -766,14 +700,11 @@ generate_Msg4(module_id_t module_idP, if ((ra->msg4_mpdcch_repetition_cnt == 0) && (mpdcch_sf_condition (mac, CC_idP, frameP, subframeP, rmax, TYPE2, -1) > 0)) { // Get RRCConnectionSetup for Piggyback ra->msg4_rrc_sdu_length = mac_rrc_data_req (module_idP, CC_idP, frameP, CCCH, - UE_RNTI(module_idP, UE_id), 1, // 1 transport block - &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case - + UE_RNTI(module_idP, UE_id), 1, // 1 transport block + &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case AssertFatal (ra->msg4_rrc_sdu_length > 0, "[MAC][eNB Scheduler] CCCH not allocated\n"); - - - LOG_D (MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d, dl_req->num_pdu %d\n", module_idP, CC_idP, frameP, subframeP, UE_id, ra->msg4_rrc_sdu_length,dl_req_body->number_pdu); - + LOG_D (MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d, dl_req->num_pdu %d\n", module_idP, CC_idP, frameP, subframeP, UE_id, ra->msg4_rrc_sdu_length, + dl_req_body->number_pdu); // MPDCCH configuration for Msg4 ra->msg4_mpdcch_done=0; memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t)); @@ -821,44 +752,41 @@ generate_Msg4(module_id_t module_idP, dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0; dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1; - ra->msg4_mpdcch_repetition_cnt++; dl_req_body->number_pdu++; ra->msg4_TBsize = get_TBS_DL(dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs, - 6); + 6); } //repetition_count==0 && SF condition met if ((ra->msg4_mpdcch_repetition_cnt > 0)&& - (ra->msg4_mpdcch_done==0)) { // we're in a stream of repetitions + (ra->msg4_mpdcch_done==0)) { // we're in a stream of repetitions LOG_D(MAC,"SFN.SF %d.%d : msg4 mpdcch repetition number %d/%d\n", - frameP,subframeP,ra->msg4_mpdcch_repetition_cnt,reps); + frameP,subframeP,ra->msg4_mpdcch_repetition_cnt,reps); + if (ra->msg4_mpdcch_repetition_cnt == reps) { // this is the last mpdcch repetition ra->msg4_mpdcch_done = 1; - if (cc[CC_idP].tdd_Config == NULL) { // FDD case + + if (cc[CC_idP].tdd_Config == NULL) { // FDD case // wait 2 subframes for PDSCH transmission if (subframeP > 7) ra->Msg4_frame = (frameP + 1) & 1023; else ra->Msg4_frame = frameP; + ra->Msg4_subframe = (subframeP + 2) % 10; - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Set Msg4 PDSCH in %d.%d\n", - module_idP, CC_idP, frameP, subframeP, ra->Msg4_frame,ra->Msg4_subframe); + LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Set Msg4 PDSCH in %d.%d\n", + module_idP, CC_idP, frameP, subframeP, ra->Msg4_frame,ra->Msg4_subframe); } else { AssertFatal (1 == 0, "TDD case not done yet\n"); } - } - else if (ra->msg4_mpdcch_done==0) - ra->msg4_mpdcch_repetition_cnt++; + } else if (ra->msg4_mpdcch_done==0) + ra->msg4_mpdcch_repetition_cnt++; } -// mpdcch_repetition_count == reps + // mpdcch_repetition_count == reps else if ((ra->Msg4_frame == frameP) && (ra->Msg4_subframe == subframeP)) { - // Program PDSCH - LOG_D (MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 BR with RRC Piggyback (ce_level %d RNTI %x)\n", - module_idP, CC_idP, frameP, subframeP, ra->rach_resource_type - 1, ra->rnti); - - + module_idP, CC_idP, frameP, subframeP, ra->rach_resource_type - 1, ra->rnti); dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t)); dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; @@ -885,47 +813,40 @@ generate_Msg4(module_id_t module_idP, dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (ra->rach_resource_type < 3) ? 1 : 2; dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not SI message dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10 * frameP) + subframeP; dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0; dl_req_body->number_pdu++; - - ra->state = WAITMSG4ACK; - lcid = 0; - UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid] = 0; msg4_header = 1 + 6 + 1; // CR header, CR CE, SDU header AssertFatal((ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header)>=0, - "msg4_TBS %d is too small, change mcs to increase by %d bytes\n",ra->msg4_TBsize,ra->msg4_rrc_sdu_length+msg4_header-ra->msg4_TBsize); + "msg4_TBS %d is too small, change mcs to increase by %d bytes\n",ra->msg4_TBsize,ra->msg4_rrc_sdu_length+msg4_header-ra->msg4_TBsize); + if ((ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header) <= 2) { - msg4_padding = ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header; - msg4_post_padding = 0; + msg4_padding = ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header; + msg4_post_padding = 0; } else { - msg4_padding = 0; - msg4_post_padding = ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header - 1; + msg4_padding = 0; + msg4_post_padding = ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header - 1; } LOG_D (MAC, "[eNB %d][RAPROC] CC_id %d Frame %d subframeP %d Msg4 : TBS %d, sdu_len %d, msg4_header %d, msg4_padding %d, msg4_post_padding %d\n", - module_idP, CC_idP, frameP, subframeP, ra->msg4_TBsize, ra->msg4_rrc_sdu_length, msg4_header, msg4_padding, msg4_post_padding); + module_idP, CC_idP, frameP, subframeP, ra->msg4_TBsize, ra->msg4_rrc_sdu_length, msg4_header, msg4_padding, msg4_post_padding); DevAssert (UE_id != UE_INDEX_INVALID); // FIXME not sure how to gracefully return // CHECK THIS: &cc[CC_idP].CCCH_pdu.payload[0] offset = generate_dlsch_header ((unsigned char *) mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0], 1, //num_sdus - (unsigned short *) &ra->msg4_rrc_sdu_length, // - &lcid, // sdu_lcid - 255, // no drx - 31, // no timing advance - ra->cont_res_id, // contention res id - msg4_padding, // no padding - msg4_post_padding); - + (unsigned short *) &ra->msg4_rrc_sdu_length, // + &lcid, // sdu_lcid + 255, // no drx + 31, // no timing advance + ra->cont_res_id, // contention res id + msg4_padding, // no padding + msg4_post_padding); memcpy ((void *) &mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0][(unsigned char) offset], &cc[CC_idP].CCCH_pdu.payload[0], ra->msg4_rrc_sdu_length); - // DL request mac->TX_req[CC_idP].sfn_sf = (frameP << 4) + subframeP; TX_req = &mac->TX_req[CC_idP].tx_request_body.tx_pdu_list[mac->TX_req[CC_idP].tx_request_body.number_of_pdus]; @@ -935,7 +856,6 @@ generate_Msg4(module_id_t module_idP, TX_req->segments[0].segment_length = ra->msg4_TBsize; TX_req->segments[0].segment_data = mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0]; mac->TX_req[CC_idP].tx_request_body.number_of_pdus++; - // Program ACK/NAK for Msg4 PDSCH int absSF = (frameP * 10) + subframeP; // see Section 10.2 from 36.213 @@ -943,7 +863,6 @@ generate_Msg4(module_id_t module_idP, AssertFatal (reps == 1, "Have to handle programming of ACK when PDSCH repetitions is > 1\n"); ul_req_body = &mac->UL_req_tmp[CC_idP][ackNAK_absSF % 10].ul_config_request_body; ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus]; - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE; ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_ul_config_uci_harq_pdu)); ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.handle = 0; // don't know how to use this @@ -952,671 +871,614 @@ generate_Msg4(module_id_t module_idP, ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.empty_symbols = 0; ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.total_number_of_repetitions = pucchreps[ra->rach_resource_type - 1]; ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.repetition_number = 0; + // Note need to keep sending this across reptitions!!!! Not really for PUCCH, to ask small-cell forum, we'll see for the other messages, maybe parameters change across repetitions and FAPI has to provide for that if (cc[CC_idP].tdd_Config == NULL) { // FDD case - ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.n_pucch_1_0 = n1pucchan[ra->rach_resource_type - 1]; - // NOTE: How to fill in the rest of the n_pucch_1_0 information 213 Section 10.1.2.1 in the general case - // = N_ECCE_q + Delta_ARO + n1pucchan[ce_level] - // higher in the MPDCCH configuration, N_ECCE_q is hard-coded to 0, and harq resource offset to 0 => - // Delta_ARO = 0 from Table 10.1.2.1-1 - ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.harq_size = 1; // 1-bit ACK/NAK - ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.number_of_pucch_resources = 1; + ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.n_pucch_1_0 = n1pucchan[ra->rach_resource_type - 1]; + // NOTE: How to fill in the rest of the n_pucch_1_0 information 213 Section 10.1.2.1 in the general case + // = N_ECCE_q + Delta_ARO + n1pucchan[ce_level] + // higher in the MPDCCH configuration, N_ECCE_q is hard-coded to 0, and harq resource offset to 0 => + // Delta_ARO = 0 from Table 10.1.2.1-1 + ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.harq_size = 1; // 1-bit ACK/NAK + ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.number_of_pucch_resources = 1; } else { - AssertFatal (1 == 0, "PUCCH configuration for ACK/NAK not handled yet for TDD BL/CE case\n"); + AssertFatal (1 == 0, "PUCCH configuration for ACK/NAK not handled yet for TDD BL/CE case\n"); } + ul_req_body->number_of_pdus++; T (T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT (module_idP), T_INT (CC_idP), T_INT (ra->rnti), T_INT (frameP), T_INT (subframeP), - T_INT (0 /*harq_pid always 0? */ ), T_BUFFER (&mac->UE_list.DLSCH_pdu[CC_idP][0][UE_id].payload[0], ra->msg4_TBsize)); + T_INT (0 /*harq_pid always 0? */ ), T_BUFFER (&mac->UE_list.DLSCH_pdu[CC_idP][0][UE_id].payload[0], ra->msg4_TBsize)); if (opt_enabled == 1) { - trace_pdu (1, (uint8_t *) mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0], ra->msg4_rrc_sdu_length, UE_id, 3, UE_RNTI (module_idP, UE_id), mac->frame, mac->subframe, 0, 0); - LOG_D (OPT, "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n", module_idP, CC_idP, frameP, UE_RNTI (module_idP, UE_id), ra->msg4_rrc_sdu_length); + trace_pdu (1, (uint8_t *) mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0], ra->msg4_rrc_sdu_length, UE_id, 3, UE_RNTI (module_idP, UE_id), mac->frame, mac->subframe, 0, 0); + LOG_D (OPT, "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n", module_idP, CC_idP, frameP, UE_RNTI (module_idP, UE_id), ra->msg4_rrc_sdu_length); } } // Msg4 frame/subframe } // rach_resource_type > 0 else #endif - { + { // This is normal LTE case - LOG_I(MAC, "generate_Msg4 ra->Msg4_frame SFN/SF: %d.%d, frameP SFN/SF: %d.%d FOR eNB_Mod: %d \n", ra->Msg4_frame, ra->Msg4_subframe, frameP, subframeP, module_idP); - if ((ra->Msg4_frame == frameP) && (ra->Msg4_subframe == subframeP)) { - - // Get RRCConnectionSetup for Piggyback - /*rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block - &cc[CC_idP].CCCH_pdu.payload[0], ENB_FLAG_YES, module_idP, 0); // not used in this case*/ - - // check if there's data on the CCCH to send with Msg4 - rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, - UE_RNTI(module_idP,UE_id),1, // 1 transport block - &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case - - if (rrc_sdu_length > 0) { - LOG_D(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n", - module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length); - - // AssertFatal(rrc_sdu_length > 0, - // "[MAC][eNB Scheduler] CCCH not allocated, rrc_sdu_length: %d\n", rrc_sdu_length); - - - - LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RNTI %x)\n", - module_idP, CC_idP, frameP, subframeP, ra->rnti); - - /// Choose first 4 RBs for Msg4, should really check that these are free! - first_rb = 0; - - vrb_map[first_rb] = 1; - vrb_map[first_rb + 1] = 1; - vrb_map[first_rb + 2] = 1; - vrb_map[first_rb + 3] = 1; - - - // Compute MCS/TBS for 3 PRB (coded on 4 vrb) - msg4_header = 1 + 6 + 1; // CR header, CR CE, SDU header - - if ((rrc_sdu_length + msg4_header) <= 22) { - ra->msg4_mcs = 4; - ra->msg4_TBsize = 22; - } else if ((rrc_sdu_length + msg4_header) <= 28) { - ra->msg4_mcs = 5; - ra->msg4_TBsize = 28; - } else if ((rrc_sdu_length + msg4_header) <= 32) { - ra->msg4_mcs = 6; - ra->msg4_TBsize = 32; - } else if ((rrc_sdu_length + msg4_header) <= 41) { - ra->msg4_mcs = 7; - ra->msg4_TBsize = 41; - } else if ((rrc_sdu_length + msg4_header) <= 49) { - ra->msg4_mcs = 8; - ra->msg4_TBsize = 49; - } else if ((rrc_sdu_length + msg4_header) <= 57) { - ra->msg4_mcs = 9; - ra->msg4_TBsize = 57; - } - - fill_nfapi_dl_dci_1A(dl_config_pdu, 4, // aggregation_level - ra->rnti, // rnti - 1, // rnti_type, CRNTI - ra->harq_pid, // harq_process - 1, // tpc, none - getRIV(N_RB_DL, first_rb, 4), // resource_block_coding - ra->msg4_mcs, // mcs - 1, // ndi - 0, // rv - 0); // vrb_flag - - LOG_D(MAC, - "Frame %d, subframe %d: Msg4 DCI pdu_num %d (rnti %x,rnti_type %d,harq_pid %d, resource_block_coding (%p) %d\n", - frameP, subframeP, dl_req_body->number_pdu, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process, - &dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding); - AssertFatal(dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.resource_block_coding < 8192, - "resource_block_coding %u < 8192\n", - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.resource_block_coding); - if (!CCE_allocation_infeasible(module_idP, CC_idP, 1, subframeP, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, ra->rnti)) { - dl_req_body->number_dci++; - dl_req_body->number_pdu++; - - ra->state = WAITMSG4ACK; - LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:WAITMSG4ACK\n", module_idP, frameP, subframeP); - - // increment Absolute subframe by 8 for Msg4 retransmission - LOG_D(MAC, - "Frame %d, Subframe %d: Preparing for Msg4 retransmission currently %d.%d\n", - frameP, subframeP, ra->Msg4_frame, - ra->Msg4_subframe); - get_retransmission_timing(mac->common_channels[CC_idP].tdd_Config,&ra->Msg4_frame,&ra->Msg4_subframe); - - LOG_D(MAC, - "Frame %d, Subframe %d: Msg4 retransmission in %d.%d\n", - frameP, subframeP, ra->Msg4_frame, - ra->Msg4_subframe); - lcid = 0; - - // put HARQ process round to 0 - ra->harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); - UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid] = 0; - - if ((ra->msg4_TBsize - rrc_sdu_length - msg4_header) <= 2) { - msg4_padding = ra->msg4_TBsize - rrc_sdu_length - msg4_header; - msg4_post_padding = 0; - } else { - msg4_padding = 0; - msg4_post_padding = ra->msg4_TBsize - rrc_sdu_length - msg4_header - 1; - } - - LOG_D(MAC, - "[eNB %d][RAPROC] CC_idP %d Frame %d subframeP %d Msg4 : TBS %d, sdu_len %d, msg4_header %d, msg4_padding %d, msg4_post_padding %d\n", - module_idP, CC_idP, frameP, subframeP, - ra->msg4_TBsize, rrc_sdu_length, msg4_header, - msg4_padding, msg4_post_padding); - DevAssert(UE_id != UE_INDEX_INVALID); // FIXME not sure how to gracefully return - // CHECK THIS: &cc[CC_idP].CCCH_pdu.payload[0] - int num_sdus = rrc_sdu_length > 0 ? 1 : 0; - offset = generate_dlsch_header((unsigned char *) mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0], - num_sdus, //num_sdus - (unsigned short *) &rrc_sdu_length, // - &lcid, // sdu_lcid - 255, // no drx - 31, // no timing advance - ra->cont_res_id, // contention res id - msg4_padding, // no padding - msg4_post_padding); - - memcpy((void *) &mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0][(unsigned char)offset], - &cc[CC_idP].CCCH_pdu.payload[0], rrc_sdu_length); - - // DLSCH Config - fill_nfapi_dlsch_config(mac, dl_req_body, ra->msg4_TBsize, mac->pdu_index[CC_idP], ra->rnti, 2, // resource_allocation_type : format 1A/1B/1D - 0, // virtual_resource_block_assignment_flag : localized - getRIV(N_RB_DL, first_rb, 4), // resource_block_coding : RIV, 4 PRB - 2, // modulation: QPSK - 0, // redundancy version - 1, // transport_blocks - 0, // transport_block_to_codeword_swap_flag (0) - (cc->p_eNB == 1) ? 0 : 1, // transmission_scheme - 1, // number of layers - 1, // number of subbands - //0, // codebook index - 1, // ue_category_capacity - 4, // pa: 0 dB - 0, // delta_power_offset_index - 0, // ngap - 1, // NPRB = 3 like in DCI - (cc->p_eNB == 1) ? 1 : 2, // transmission mode - 1, // num_bf_prb_per_subband - 1); // num_bf_vector - LOG_D(MAC, - "Filled DLSCH config, pdu number %d, non-dci pdu_index %d\n", - dl_req_body->number_pdu, mac->pdu_index[CC_idP]); - - // Tx request - mac->TX_req[CC_idP].sfn_sf = - fill_nfapi_tx_req(&mac->TX_req[CC_idP].tx_request_body, - (frameP * 10) + subframeP, - rrc_sdu_length, - mac->pdu_index[CC_idP], - mac->UE_list. - DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0]); - mac->pdu_index[CC_idP]++; - - dl_req->sfn_sf = mac->TX_req[CC_idP].sfn_sf; - - LOG_D(MAC, "Filling UCI ACK/NAK information, cce_idx %d\n", - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); - // Program PUCCH1a for ACK/NAK - // Program ACK/NAK for Msg4 PDSCH - fill_nfapi_uci_acknak(module_idP, - CC_idP, - ra->rnti, - (frameP * 10) + subframeP, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); - - - T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), - T_INT(CC_idP), T_INT(ra->rnti), T_INT(frameP), - T_INT(subframeP), T_INT(0 /*harq_pid always 0? */ ), - T_BUFFER(&mac->UE_list.DLSCH_pdu[CC_idP][0][UE_id]. - payload[0], ra->msg4_TBsize)); - - if (opt_enabled == 1) { - trace_pdu(DIRECTION_DOWNLINK, - (uint8_t *) mac-> - UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0], - rrc_sdu_length, UE_id, WS_C_RNTI, - UE_RNTI(module_idP, UE_id), mac->frame, - mac->subframe, 0, 0); - LOG_D(OPT, - "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n", - module_idP, CC_idP, frameP, UE_RNTI(module_idP, - UE_id), - rrc_sdu_length); - } - if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){ - set_dl_ue_select_msg4(CC_idP, 4, UE_id, ra->rnti); - } - } // CCE Allocation feasible - } - else { - LOG_I(MAC, - "eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Delaying Msg4 for RRC Piggyback (RNTI %x)\n", - module_idP, CC_idP, frameP, subframeP, ra->rnti); - ra->Msg4_subframe ++; - ra->Msg4_delay_cnt++; - if (ra->Msg4_delay_cnt==10) cancel_ra_proc(module_idP, CC_idP, frameP, ra->rnti); - - if (ra->Msg4_subframe == 10) { - ra->Msg4_frame++; - ra->Msg4_frame&=1023; - ra->Msg4_subframe = 0; - } - } - } // msg4 frame/subframe - } // else rach_resource_type + LOG_I(MAC, "generate_Msg4 ra->Msg4_frame SFN/SF: %d.%d, frameP SFN/SF: %d.%d FOR eNB_Mod: %d \n", ra->Msg4_frame, ra->Msg4_subframe, frameP, subframeP, module_idP); + + if ((ra->Msg4_frame == frameP) && (ra->Msg4_subframe == subframeP)) { + // Get RRCConnectionSetup for Piggyback + /*rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block + &cc[CC_idP].CCCH_pdu.payload[0], ENB_FLAG_YES, module_idP, 0); // not used in this case*/ + // check if there's data on the CCCH to send with Msg4 + rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, + UE_RNTI(module_idP,UE_id),1, // 1 transport block + &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case + + if (rrc_sdu_length > 0) { + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n", + module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length); + // AssertFatal(rrc_sdu_length > 0, + // "[MAC][eNB Scheduler] CCCH not allocated, rrc_sdu_length: %d\n", rrc_sdu_length); + LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RNTI %x)\n", + module_idP, CC_idP, frameP, subframeP, ra->rnti); + /// Choose first 4 RBs for Msg4, should really check that these are free! + first_rb = 0; + vrb_map[first_rb] = 1; + vrb_map[first_rb + 1] = 1; + vrb_map[first_rb + 2] = 1; + vrb_map[first_rb + 3] = 1; + // Compute MCS/TBS for 3 PRB (coded on 4 vrb) + msg4_header = 1 + 6 + 1; // CR header, CR CE, SDU header + + if ((rrc_sdu_length + msg4_header) <= 22) { + ra->msg4_mcs = 4; + ra->msg4_TBsize = 22; + } else if ((rrc_sdu_length + msg4_header) <= 28) { + ra->msg4_mcs = 5; + ra->msg4_TBsize = 28; + } else if ((rrc_sdu_length + msg4_header) <= 32) { + ra->msg4_mcs = 6; + ra->msg4_TBsize = 32; + } else if ((rrc_sdu_length + msg4_header) <= 41) { + ra->msg4_mcs = 7; + ra->msg4_TBsize = 41; + } else if ((rrc_sdu_length + msg4_header) <= 49) { + ra->msg4_mcs = 8; + ra->msg4_TBsize = 49; + } else if ((rrc_sdu_length + msg4_header) <= 57) { + ra->msg4_mcs = 9; + ra->msg4_TBsize = 57; + } + + fill_nfapi_dl_dci_1A(dl_config_pdu, 4, // aggregation_level + ra->rnti, // rnti + 1, // rnti_type, CRNTI + ra->harq_pid, // harq_process + 1, // tpc, none + getRIV(N_RB_DL, first_rb, 4), // resource_block_coding + ra->msg4_mcs, // mcs + 1, // ndi + 0, // rv + 0); // vrb_flag + LOG_D(MAC, + "Frame %d, subframe %d: Msg4 DCI pdu_num %d (rnti %x,rnti_type %d,harq_pid %d, resource_block_coding (%p) %d\n", + frameP, subframeP, dl_req_body->number_pdu, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process, + &dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding); + AssertFatal(dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.resource_block_coding < 8192, + "resource_block_coding %u < 8192\n", + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.resource_block_coding); + + if (!CCE_allocation_infeasible(module_idP, CC_idP, 1, subframeP, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, ra->rnti)) { + dl_req_body->number_dci++; + dl_req_body->number_pdu++; + ra->state = WAITMSG4ACK; + LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:WAITMSG4ACK\n", module_idP, frameP, subframeP); + // increment Absolute subframe by 8 for Msg4 retransmission + LOG_D(MAC, + "Frame %d, Subframe %d: Preparing for Msg4 retransmission currently %d.%d\n", + frameP, subframeP, ra->Msg4_frame, + ra->Msg4_subframe); + get_retransmission_timing(mac->common_channels[CC_idP].tdd_Config,&ra->Msg4_frame,&ra->Msg4_subframe); + LOG_D(MAC, + "Frame %d, Subframe %d: Msg4 retransmission in %d.%d\n", + frameP, subframeP, ra->Msg4_frame, + ra->Msg4_subframe); + lcid = 0; + // put HARQ process round to 0 + ra->harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP,subframeP); + UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid] = 0; + + if ((ra->msg4_TBsize - rrc_sdu_length - msg4_header) <= 2) { + msg4_padding = ra->msg4_TBsize - rrc_sdu_length - msg4_header; + msg4_post_padding = 0; + } else { + msg4_padding = 0; + msg4_post_padding = ra->msg4_TBsize - rrc_sdu_length - msg4_header - 1; + } + + LOG_D(MAC, + "[eNB %d][RAPROC] CC_idP %d Frame %d subframeP %d Msg4 : TBS %d, sdu_len %d, msg4_header %d, msg4_padding %d, msg4_post_padding %d\n", + module_idP, CC_idP, frameP, subframeP, + ra->msg4_TBsize, rrc_sdu_length, msg4_header, + msg4_padding, msg4_post_padding); + DevAssert(UE_id != UE_INDEX_INVALID); // FIXME not sure how to gracefully return + // CHECK THIS: &cc[CC_idP].CCCH_pdu.payload[0] + int num_sdus = rrc_sdu_length > 0 ? 1 : 0; + offset = generate_dlsch_header((unsigned char *) mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0], + num_sdus, //num_sdus + (unsigned short *) &rrc_sdu_length, // + &lcid, // sdu_lcid + 255, // no drx + 31, // no timing advance + ra->cont_res_id, // contention res id + msg4_padding, // no padding + msg4_post_padding); + memcpy((void *) &mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0][(unsigned char)offset], + &cc[CC_idP].CCCH_pdu.payload[0], rrc_sdu_length); + // DLSCH Config + fill_nfapi_dlsch_config(mac, dl_req_body, ra->msg4_TBsize, mac->pdu_index[CC_idP], ra->rnti, 2, // resource_allocation_type : format 1A/1B/1D + 0, // virtual_resource_block_assignment_flag : localized + getRIV(N_RB_DL, first_rb, 4), // resource_block_coding : RIV, 4 PRB + 2, // modulation: QPSK + 0, // redundancy version + 1, // transport_blocks + 0, // transport_block_to_codeword_swap_flag (0) + (cc->p_eNB == 1) ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + //0, // codebook index + 1, // ue_category_capacity + 4, // pa: 0 dB + 0, // delta_power_offset_index + 0, // ngap + 1, // NPRB = 3 like in DCI + (cc->p_eNB == 1) ? 1 : 2, // transmission mode + 1, // num_bf_prb_per_subband + 1); // num_bf_vector + LOG_D(MAC, + "Filled DLSCH config, pdu number %d, non-dci pdu_index %d\n", + dl_req_body->number_pdu, mac->pdu_index[CC_idP]); + // Tx request + mac->TX_req[CC_idP].sfn_sf = + fill_nfapi_tx_req(&mac->TX_req[CC_idP].tx_request_body, + (frameP * 10) + subframeP, + rrc_sdu_length, + mac->pdu_index[CC_idP], + mac->UE_list. + DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0]); + mac->pdu_index[CC_idP]++; + dl_req->sfn_sf = mac->TX_req[CC_idP].sfn_sf; + LOG_D(MAC, "Filling UCI ACK/NAK information, cce_idx %d\n", + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); + // Program PUCCH1a for ACK/NAK + // Program ACK/NAK for Msg4 PDSCH + fill_nfapi_uci_acknak(module_idP, + CC_idP, + ra->rnti, + (frameP * 10) + subframeP, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); + T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), + T_INT(CC_idP), T_INT(ra->rnti), T_INT(frameP), + T_INT(subframeP), T_INT(0 /*harq_pid always 0? */ ), + T_BUFFER(&mac->UE_list.DLSCH_pdu[CC_idP][0][UE_id]. + payload[0], ra->msg4_TBsize)); + + if (opt_enabled == 1) { + trace_pdu(DIRECTION_DOWNLINK, + (uint8_t *) mac-> + UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0], + rrc_sdu_length, UE_id, WS_C_RNTI, + UE_RNTI(module_idP, UE_id), mac->frame, + mac->subframe, 0, 0); + LOG_D(OPT, + "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n", + module_idP, CC_idP, frameP, UE_RNTI(module_idP, + UE_id), + rrc_sdu_length); + } + + if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR) { + set_dl_ue_select_msg4(CC_idP, 4, UE_id, ra->rnti); + } + } // CCE Allocation feasible + } else { + LOG_I(MAC, + "eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Delaying Msg4 for RRC Piggyback (RNTI %x)\n", + module_idP, CC_idP, frameP, subframeP, ra->rnti); + ra->Msg4_subframe ++; + ra->Msg4_delay_cnt++; + + if (ra->Msg4_delay_cnt==10) cancel_ra_proc(module_idP, CC_idP, frameP, ra->rnti); + + if (ra->Msg4_subframe == 10) { + ra->Msg4_frame++; + ra->Msg4_frame&=1023; + ra->Msg4_subframe = 0; + } + } + } // msg4 frame/subframe + } // else rach_resource_type } void check_Msg4_retransmission(module_id_t module_idP, int CC_idP, - frame_t frameP, sub_frame_t subframeP, RA_t * ra) -{ - - eNB_MAC_INST *mac = RC.mac[module_idP]; - COMMON_channels_t *cc = mac->common_channels; - int UE_id = -1; - uint8_t *vrb_map; - int first_rb; - int N_RB_DL; - nfapi_dl_config_request_pdu_t *dl_config_pdu; - UE_list_t *UE_list = &mac->UE_list; - nfapi_dl_config_request_t *dl_req; - nfapi_dl_config_request_body_t *dl_req_body; - - int round; - /* - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - COMMON_channels_t *cc = mac->common_channels; - - int rmax = 0; - int rep = 0; - int reps = 0; - - first_rb = 0; - struct PRACH_ConfigSIB_v1310 *ext4_prach; - PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13; - PRACH_ParametersCE_r13_t *p[4]; - - if (cc[CC_idP].radioResourceConfigCommon_BR) { - - ext4_prach = cc[CC_idP].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310; - prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; - - switch (prach_ParametersListCE_r13->list.count) { - case 4: - p[3]=prach_ParametersListCE_r13->list.array[3]; - case 3: - p[2]=prach_ParametersListCE_r13->list.array[2]; - case 2: - p[1]=prach_ParametersListCE_r13->list.array[1]; - case 1: - p[0]=prach_ParametersListCE_r13->list.array[0]; - default: - AssertFatal(1==0,"Illegal count for prach_ParametersListCE_r13 %d\n",prach_ParametersListCE_r13->list.count); - } - } - #endif - */ - - // check HARQ status and retransmit if necessary - - - UE_id = find_UE_id(module_idP, ra->rnti); - AssertFatal(UE_id >= 0, "Can't find UE for t-crnti\n"); - - round = UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid]; - vrb_map = cc[CC_idP].vrb_map; - - dl_req = &mac->DL_req[CC_idP]; - dl_req_body = &dl_req->dl_config_request_body; - dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; - N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth); - - LOG_D(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Checking if Msg4 for harq_pid %d was acknowledged (round %d), UE_id: %d \n", - module_idP, CC_idP, frameP, subframeP, ra->harq_pid, round, UE_id); - - if (round != 8) { + frame_t frameP, sub_frame_t subframeP, RA_t *ra) { + eNB_MAC_INST *mac = RC.mac[module_idP]; + COMMON_channels_t *cc = mac->common_channels; + int UE_id = -1; + uint8_t *vrb_map; + int first_rb; + int N_RB_DL; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + UE_list_t *UE_list = &mac->UE_list; + nfapi_dl_config_request_t *dl_req; + nfapi_dl_config_request_body_t *dl_req_body; + int round; + /* + #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + COMMON_channels_t *cc = mac->common_channels; + + int rmax = 0; + int rep = 0; + int reps = 0; + + first_rb = 0; + struct PRACH_ConfigSIB_v1310 *ext4_prach; + PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13; + PRACH_ParametersCE_r13_t *p[4]; + + if (cc[CC_idP].radioResourceConfigCommon_BR) { + + ext4_prach = cc[CC_idP].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310; + prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; + + switch (prach_ParametersListCE_r13->list.count) { + case 4: + p[3]=prach_ParametersListCE_r13->list.array[3]; + case 3: + p[2]=prach_ParametersListCE_r13->list.array[2]; + case 2: + p[1]=prach_ParametersListCE_r13->list.array[1]; + case 1: + p[0]=prach_ParametersListCE_r13->list.array[0]; + default: + AssertFatal(1==0,"Illegal count for prach_ParametersListCE_r13 %d\n",prach_ParametersListCE_r13->list.count); + } + } + #endif + */ + // check HARQ status and retransmit if necessary + UE_id = find_UE_id(module_idP, ra->rnti); + AssertFatal(UE_id >= 0, "Can't find UE for t-crnti\n"); + round = UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid]; + vrb_map = cc[CC_idP].vrb_map; + dl_req = &mac->DL_req[CC_idP]; + dl_req_body = &dl_req->dl_config_request_body; + dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; + N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth); + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Checking if Msg4 for harq_pid %d was acknowledged (round %d), UE_id: %d \n", + module_idP, CC_idP, frameP, subframeP, ra->harq_pid, round, UE_id); + if (round != 8) { #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - if (ra->rach_resource_type > 0 && round > 0) { - AssertFatal(1 == 0, - "Msg4 Retransmissions not handled yet for BL/CE UEs, Frame %d, subframeP %d harq_pid %d round %d, UE_id: %d \n", - frameP, subframeP, ra->harq_pid, round, UE_id); - } else + + if (ra->rach_resource_type > 0 && round > 0) { + AssertFatal(1 == 0, + "Msg4 Retransmissions not handled yet for BL/CE UEs, Frame %d, subframeP %d harq_pid %d round %d, UE_id: %d \n", + frameP, subframeP, ra->harq_pid, round, UE_id); + } else #endif - { - if ((ra->Msg4_frame == frameP) - && (ra->Msg4_subframe == subframeP)) { - - //ra->wait_ack_Msg4++; - // we have to schedule a retransmission - - dl_req->sfn_sf = frameP<<4 | subframeP; - - first_rb = 0; - vrb_map[first_rb] = 1; - vrb_map[first_rb + 1] = 1; - vrb_map[first_rb + 2] = 1; - vrb_map[first_rb + 3] = 1; - - fill_nfapi_dl_dci_1A(dl_config_pdu, 4, // aggregation_level - ra->rnti, // rnti - 1, // rnti_type, CRNTI - ra->harq_pid, // harq_process - 1, // tpc, none - getRIV(N_RB_DL, first_rb, 4), // resource_block_coding - ra->msg4_mcs, // mcs - 1, // ndi - round & 3, // rv - 0); // vrb_flag - - if (!CCE_allocation_infeasible - (module_idP, CC_idP, 1, subframeP, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. - aggregation_level, ra->rnti)) { - dl_req_body->number_dci++; - dl_req_body->number_pdu++; - dl_req_body->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - LOG_D(MAC, - "msg4 retransmission for rnti %x (round %d) fsf %d/%d\n", - ra->rnti, round, frameP, subframeP); - // DLSCH Config - //DJP - fix this pdu_index = -1 - LOG_D(MAC, "check_Msg4_retransmission() before fill_nfapi_dlsch_config() with pdu_index = -1 \n"); - fill_nfapi_dlsch_config(mac, dl_req_body, ra->msg4_TBsize, - -1 - /* retransmission, no pdu_index */ - , ra->rnti, 2, // resource_allocation_type : format 1A/1B/1D - 0, // virtual_resource_block_assignment_flag : localized - getRIV(N_RB_DL, first_rb, 4), // resource_block_coding : RIV, 4 PRB - 2, // modulation: QPSK - round & 3, // redundancy version - 1, // transport_blocks - 0, // transport_block_to_codeword_swap_flag (0) - (cc->p_eNB == 1) ? 0 : 1, // transmission_scheme - 1, // number of layers - 1, // number of subbands - //0, // codebook index - 1, // ue_category_capacity - 4, // pa: 0 dB - 0, // delta_power_offset_index - 0, // ngap - 1, // NPRB = 3 like in DCI - (cc->p_eNB == 1) ? 1 : 2, // transmission mode - 1, // num_bf_prb_per_subband - 1); // num_bf_vector - if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){ - set_dl_ue_select_msg4(CC_idP, 4, UE_id, ra->rnti); - } - } else - LOG_D(MAC, - "msg4 retransmission for rnti %x (round %d) fsf %d/%d CCE allocation failed!\n", - ra->rnti, round, frameP, subframeP); - - - // Program PUCCH1a for ACK/NAK - - - fill_nfapi_uci_acknak(module_idP, CC_idP, - ra->rnti, - (frameP * 10) + subframeP, - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.cce_idx); - - // prepare frame for retransmission - get_retransmission_timing(mac->common_channels[CC_idP].tdd_Config,&ra->Msg4_frame,&ra->Msg4_subframe); - - LOG_W(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Msg4 not acknowledged, adding ue specific dci (rnti %x) for RA (Msg4 Retransmission round %d in %d.%d)\n", - module_idP, CC_idP, frameP, subframeP, ra->rnti, - round, ra->Msg4_frame, ra->Msg4_subframe); - - } // Msg4 frame/subframe - } // regular LTE case - } else { - LOG_D(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d : Msg4 acknowledged\n", - module_idP, CC_idP, frameP, subframeP); - ra->state = IDLE; - LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:IDLE\n", module_idP, frameP, subframeP); - UE_id = find_UE_id(module_idP, ra->rnti); - DevAssert(UE_id != -1); - mac->UE_list.UE_template[UE_PCCID(module_idP, UE_id)][UE_id].configured = TRUE; - cancel_ra_proc(module_idP, CC_idP, frameP, ra->rnti); - } + { + if ((ra->Msg4_frame == frameP) + && (ra->Msg4_subframe == subframeP)) { + //ra->wait_ack_Msg4++; + // we have to schedule a retransmission + dl_req->sfn_sf = frameP<<4 | subframeP; + first_rb = 0; + vrb_map[first_rb] = 1; + vrb_map[first_rb + 1] = 1; + vrb_map[first_rb + 2] = 1; + vrb_map[first_rb + 3] = 1; + fill_nfapi_dl_dci_1A(dl_config_pdu, 4, // aggregation_level + ra->rnti, // rnti + 1, // rnti_type, CRNTI + ra->harq_pid, // harq_process + 1, // tpc, none + getRIV(N_RB_DL, first_rb, 4), // resource_block_coding + ra->msg4_mcs, // mcs + 1, // ndi + round & 3, // rv + 0); // vrb_flag + + if (!CCE_allocation_infeasible + (module_idP, CC_idP, 1, subframeP, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + aggregation_level, ra->rnti)) { + dl_req_body->number_dci++; + dl_req_body->number_pdu++; + dl_req_body->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + LOG_D(MAC, + "msg4 retransmission for rnti %x (round %d) fsf %d/%d\n", + ra->rnti, round, frameP, subframeP); + // DLSCH Config + //DJP - fix this pdu_index = -1 + LOG_D(MAC, "check_Msg4_retransmission() before fill_nfapi_dlsch_config() with pdu_index = -1 \n"); + fill_nfapi_dlsch_config(mac, dl_req_body, ra->msg4_TBsize, + -1 + /* retransmission, no pdu_index */ + , ra->rnti, 2, // resource_allocation_type : format 1A/1B/1D + 0, // virtual_resource_block_assignment_flag : localized + getRIV(N_RB_DL, first_rb, 4), // resource_block_coding : RIV, 4 PRB + 2, // modulation: QPSK + round & 3, // redundancy version + 1, // transport_blocks + 0, // transport_block_to_codeword_swap_flag (0) + (cc->p_eNB == 1) ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + //0, // codebook index + 1, // ue_category_capacity + 4, // pa: 0 dB + 0, // delta_power_offset_index + 0, // ngap + 1, // NPRB = 3 like in DCI + (cc->p_eNB == 1) ? 1 : 2, // transmission mode + 1, // num_bf_prb_per_subband + 1); // num_bf_vector + + if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR) { + set_dl_ue_select_msg4(CC_idP, 4, UE_id, ra->rnti); + } + } else + LOG_D(MAC, + "msg4 retransmission for rnti %x (round %d) fsf %d/%d CCE allocation failed!\n", + ra->rnti, round, frameP, subframeP); + + // Program PUCCH1a for ACK/NAK + fill_nfapi_uci_acknak(module_idP, CC_idP, + ra->rnti, + (frameP * 10) + subframeP, + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.cce_idx); + // prepare frame for retransmission + get_retransmission_timing(mac->common_channels[CC_idP].tdd_Config,&ra->Msg4_frame,&ra->Msg4_subframe); + LOG_W(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Msg4 not acknowledged, adding ue specific dci (rnti %x) for RA (Msg4 Retransmission round %d in %d.%d)\n", + module_idP, CC_idP, frameP, subframeP, ra->rnti, + round, ra->Msg4_frame, ra->Msg4_subframe); + } // Msg4 frame/subframe + } // regular LTE case + } else { + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d : Msg4 acknowledged\n", + module_idP, CC_idP, frameP, subframeP); + ra->state = IDLE; + LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:IDLE\n", module_idP, frameP, subframeP); + UE_id = find_UE_id(module_idP, ra->rnti); + DevAssert(UE_id != -1); + mac->UE_list.UE_template[UE_PCCID(module_idP, UE_id)][UE_id].configured = TRUE; + cancel_ra_proc(module_idP, CC_idP, frameP, ra->rnti); + } } void -schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) -{ - - int CC_id; - eNB_MAC_INST *mac = RC.mac[module_idP]; - COMMON_channels_t *cc = mac->common_channels; - RA_t *ra; - uint8_t i; - - - start_meas(&mac->schedule_ra); - - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - // skip UL component carriers if TDD - if (is_UL_sf(&cc[CC_id], subframeP) == 1) - continue; - - for (i = 0; i < NB_RA_PROC_MAX; i++) { - - ra = (RA_t *) & cc[CC_id].ra[i]; +schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) { + int CC_id; + eNB_MAC_INST *mac = RC.mac[module_idP]; + COMMON_channels_t *cc = mac->common_channels; + RA_t *ra; + uint8_t i; + start_meas(&mac->schedule_ra); - //LOG_D(MAC,"RA[state:%d]\n",ra->state); + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + // skip UL component carriers if TDD + if (is_UL_sf(&cc[CC_id], subframeP) == 1) + continue; - if (ra->state == MSG2) - generate_Msg2(module_idP, CC_id, frameP, subframeP, ra); - else if (ra->state == MSG4 && ra->Msg4_frame == frameP && ra->Msg4_subframe == subframeP ) - generate_Msg4(module_idP, CC_id, frameP, subframeP, ra); - else if (ra->state == WAITMSG4ACK) - check_Msg4_retransmission(module_idP, CC_id, frameP, - subframeP, ra); + for (i = 0; i < NB_RA_PROC_MAX; i++) { + ra = (RA_t *) & cc[CC_id].ra[i]; - } // for i=0 .. N_RA_PROC-1 - } // CC_id + //LOG_D(MAC,"RA[state:%d]\n",ra->state); - stop_meas(&mac->schedule_ra); + if (ra->state == MSG2) + generate_Msg2(module_idP, CC_id, frameP, subframeP, ra); + else if (ra->state == MSG4 && ra->Msg4_frame == frameP && ra->Msg4_subframe == subframeP ) + generate_Msg4(module_idP, CC_id, frameP, subframeP, ra); + else if (ra->state == WAITMSG4ACK) + check_Msg4_retransmission(module_idP, CC_id, frameP, + subframeP, ra); + } // for i=0 .. N_RA_PROC-1 + } // CC_id + stop_meas(&mac->schedule_ra); } // handles the event of MSG1 reception void initiate_ra_proc(module_id_t module_idP, - int CC_id, - frame_t frameP, - sub_frame_t subframeP, - uint16_t preamble_index, - int16_t timing_offset, uint16_t ra_rnti + int CC_id, + frame_t frameP, + sub_frame_t subframeP, + uint16_t preamble_index, + int16_t timing_offset, uint16_t ra_rnti #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , uint8_t rach_resource_type + , uint8_t rach_resource_type #endif - ) -{ - - uint8_t i; - - COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_id]; - RA_t *ra = &cc->ra[0]; + ) { + uint8_t i; + COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_id]; + RA_t *ra = &cc->ra[0]; #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach = NULL; + LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = NULL; - - struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach = NULL; - LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = NULL; - - - - if (cc->mib->message.schedulingInfoSIB1_BR_r13>0) { - AssertFatal(cc->radioResourceConfigCommon_BR != NULL,"radioResourceConfigCommon_BR is null\n"); - AssertFatal(cc->radioResourceConfigCommon_BR->ext4 != NULL, "radioResourceConfigCommon_BR->ext4 is null\n"); - ext4_prach = cc->radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310; - AssertFatal(ext4_prach!=NULL,"ext4_prach is null\n"); - prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; - } + if (cc->mib->message.schedulingInfoSIB1_BR_r13>0) { + AssertFatal(cc->radioResourceConfigCommon_BR != NULL,"radioResourceConfigCommon_BR is null\n"); + AssertFatal(cc->radioResourceConfigCommon_BR->ext4 != NULL, "radioResourceConfigCommon_BR->ext4 is null\n"); + ext4_prach = cc->radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310; + AssertFatal(ext4_prach!=NULL,"ext4_prach is null\n"); + prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; + } #endif /* #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) */ - - LOG_D(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d Initiating RA procedure for preamble index %d\n", - module_idP, CC_id, frameP, subframeP, preamble_index); + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d Initiating RA procedure for preamble index %d\n", + module_idP, CC_id, frameP, subframeP, preamble_index); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - LOG_D(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d PRACH resource type %d\n", - module_idP, CC_id, frameP, subframeP, rach_resource_type); + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d PRACH resource type %d\n", + module_idP, CC_id, frameP, subframeP, rach_resource_type); #endif - - uint16_t msg2_frame = frameP; - uint16_t msg2_subframe = subframeP; - int offset; - - static uint8_t failure_cnt = 0 ; - + uint16_t msg2_frame = frameP; + uint16_t msg2_subframe = subframeP; + int offset; + static uint8_t failure_cnt = 0 ; #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - if (prach_ParametersListCE_r13 && - prach_ParametersListCE_r13->list.count < rach_resource_type) { - LOG_E(MAC, - "[eNB %d][RAPROC] CC_id %d Received impossible PRACH resource type %d, only %d CE levels configured\n", - module_idP, CC_id, rach_resource_type, - (int) prach_ParametersListCE_r13->list.count); - return; - } + if (prach_ParametersListCE_r13 && + prach_ParametersListCE_r13->list.count < rach_resource_type) { + LOG_E(MAC, + "[eNB %d][RAPROC] CC_id %d Received impossible PRACH resource type %d, only %d CE levels configured\n", + module_idP, CC_id, rach_resource_type, + (int) prach_ParametersListCE_r13->list.count); + return; + } #endif /* #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) */ + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 0); - - for (i = 0; i < NB_RA_PROC_MAX; i++) { - if (ra[i].state == IDLE) { - int loop = 0; - LOG_D(MAC, "Frame %d, Subframe %d: Activating RA process %d\n", - frameP, subframeP, i); - ra[i].state = MSG2; - ra[i].Msg4_delay_cnt=0; - ra[i].timing_offset = timing_offset; - ra[i].preamble_subframe = subframeP; + for (i = 0; i < NB_RA_PROC_MAX; i++) { + if (ra[i].state == IDLE) { + int loop = 0; + LOG_D(MAC, "Frame %d, Subframe %d: Activating RA process %d\n", + frameP, subframeP, i); + ra[i].state = MSG2; + ra[i].Msg4_delay_cnt=0; + ra[i].timing_offset = timing_offset; + ra[i].preamble_subframe = subframeP; #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ra[i].rach_resource_type = rach_resource_type; - ra[i].msg2_mpdcch_repetition_cnt = 0; - ra[i].msg4_mpdcch_repetition_cnt = 0; + ra[i].rach_resource_type = rach_resource_type; + ra[i].msg2_mpdcch_repetition_cnt = 0; + ra[i].msg4_mpdcch_repetition_cnt = 0; #endif + //TODO Fill in other TDD config. What about nfapi_mode? + if(cc->tdd_Config!=NULL) { + switch(cc->tdd_Config->subframeAssignment) { + default: + printf("%s:%d: TODO\n", __FILE__, __LINE__); + abort(); + case 1 : + offset = 6; + break; + } + } else { //FDD + // DJP - this is because VNF is 2 subframes ahead of PNF and TX needs 4 subframes + if (NFAPI_MODE != NFAPI_MONOLITHIC) + offset = 7; + else + offset = 5; + } - //TODO Fill in other TDD config. What about nfapi_mode? - if(cc->tdd_Config!=NULL){ - switch(cc->tdd_Config->subframeAssignment){ - default: printf("%s:%d: TODO\n", __FILE__, __LINE__); abort(); - case 1 : - offset = 6; - break; - } - }else{//FDD - // DJP - this is because VNF is 2 subframes ahead of PNF and TX needs 4 subframes - if (nfapi_mode) - offset = 7; - else - offset = 5; - } - - add_subframe(&msg2_frame, &msg2_subframe, offset); + add_subframe(&msg2_frame, &msg2_subframe, offset); + ra[i].Msg2_frame = msg2_frame; + ra[i].Msg2_subframe = msg2_subframe; + LOG_D(MAC,"%s() Msg2[%04d%d] SFN/SF:%04d%d offset:%d\n", __FUNCTION__,ra[i].Msg2_frame,ra[i].Msg2_subframe,frameP,subframeP,offset); + ra[i].Msg2_subframe = (subframeP + offset) % 10; - ra[i].Msg2_frame = msg2_frame; - ra[i].Msg2_subframe = msg2_subframe; + /* TODO: find better procedure to allocate RNTI */ + do { +#if defined(USRP_REC_PLAY) // deterministic rnti in usrp record/playback mode + 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 < MAX_MOBILES_PER_ENB; j++) { + if (UE_RNTI(module_idP, j) > 0) { + nb_ue++; + } else { + break; + } + } - LOG_D(MAC,"%s() Msg2[%04d%d] SFN/SF:%04d%d offset:%d\n", __FUNCTION__,ra[i].Msg2_frame,ra[i].Msg2_subframe,frameP,subframeP,offset); + if (nb_ue >= MAX_MOBILES_PER_ENB) { + printf("No more free RNTI available, increase MAX_MOBILES_PER_ENB\n"); + abort(); + } - ra[i].Msg2_subframe = (subframeP + offset) % 10; - /* TODO: find better procedure to allocate RNTI */ - do { -#if defined(USRP_REC_PLAY) // deterministic rnti in usrp record/playback mode - static int drnti[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 < MAX_MOBILES_PER_ENB; j++) { - if (UE_RNTI(module_idP, j) > 0) { - nb_ue++; - } else { - break; - } - } - 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]; -#else - ra[i].rnti = taus(); + ra[i].rnti = drnti[nb_ue]; +#else + ra[i].rnti = taus(); #endif - loop++; - } - while (loop != 100 && - /* TODO: this is not correct, the rnti may be in use without - * being in the MAC yet. To be refined. - */ - !(find_UE_id(module_idP, ra[i].rnti) == -1 && - /* 1024 and 60000 arbirarily chosen, not coming from standard */ - ra[i].rnti >= 1024 && ra[i].rnti < 60000)); - if (loop == 100) { - printf("%s:%d:%s: FATAL ERROR! contact the authors\n", - __FILE__, __LINE__, __FUNCTION__); - abort(); - } - ra[i].RA_rnti = ra_rnti; - ra[i].preamble_index = preamble_index; - failure_cnt = 0; - LOG_D(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d Activating RAR generation in Frame %d, subframe %d for process %d, rnti %x, state %d\n", - module_idP, CC_id, frameP, ra[i].Msg2_frame, - ra[i].Msg2_subframe, i, ra[i].rnti, ra[i].state); - - return; - } - } + loop++; + } while (loop != 100 && + /* TODO: this is not correct, the rnti may be in use without + * being in the MAC yet. To be refined. + */ + !(find_UE_id(module_idP, ra[i].rnti) == -1 && + /* 1024 and 60000 arbirarily chosen, not coming from standard */ + ra[i].rnti >= 1024 && ra[i].rnti < 60000)); + + if (loop == 100) { + printf("%s:%d:%s: FATAL ERROR! contact the authors\n", + __FILE__, __LINE__, __FUNCTION__); + abort(); + } - LOG_E(MAC, - "[eNB %d][RAPROC] FAILURE: CC_id %d Frame %d Initiating RA procedure for preamble index %d\n", - module_idP, CC_id, frameP, preamble_index); - - failure_cnt++; - if(failure_cnt > 20) { - LOG_E(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Clear Random access information\n", module_idP, CC_id, frameP); - clear_ra_proc(module_idP, CC_id, frameP); + ra[i].RA_rnti = ra_rnti; + ra[i].preamble_index = preamble_index; + failure_cnt = 0; + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d Activating RAR generation in Frame %d, subframe %d for process %d, rnti %x, state %d\n", + module_idP, CC_id, frameP, ra[i].Msg2_frame, + ra[i].Msg2_subframe, i, ra[i].rnti, ra[i].state); + return; } - + } + + LOG_E(MAC, + "[eNB %d][RAPROC] FAILURE: CC_id %d Frame %d Initiating RA procedure for preamble index %d\n", + module_idP, CC_id, frameP, preamble_index); + failure_cnt++; + + if(failure_cnt > 20) { + LOG_E(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Clear Random access information\n", module_idP, CC_id, frameP); + clear_ra_proc(module_idP, CC_id, frameP); + } } void cancel_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP, - rnti_t rnti) -{ - unsigned char i; - RA_t *ra = (RA_t *) & RC.mac[module_idP]->common_channels[CC_id].ra[0]; - - MSC_LOG_EVENT(MSC_PHY_ENB, "RA Cancelling procedure ue %" PRIx16 " ", - rnti); - LOG_D(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d Cancelling RA procedure for UE rnti %x\n", - module_idP, CC_id, frameP, rnti); + rnti_t rnti) { + unsigned char i; + RA_t *ra = (RA_t *) & RC.mac[module_idP]->common_channels[CC_id].ra[0]; + MSC_LOG_EVENT(MSC_PHY_ENB, "RA Cancelling procedure ue %" PRIx16 " ", + rnti); + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d Cancelling RA procedure for UE rnti %x\n", + module_idP, CC_id, frameP, rnti); - for (i = 0; i < NB_RA_PROC_MAX; i++) { - if (rnti == ra[i].rnti) { - ra[i].state = IDLE; - ra[i].timing_offset = 0; - ra[i].RRC_timer = 20; - ra[i].rnti = 0; - ra[i].msg3_round = 0; - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Canceled RA procedure for UE rnti %x\n", module_idP, CC_id, frameP, rnti); - } + for (i = 0; i < NB_RA_PROC_MAX; i++) { + if (rnti == ra[i].rnti) { + ra[i].state = IDLE; + ra[i].timing_offset = 0; + ra[i].RRC_timer = 20; + ra[i].rnti = 0; + ra[i].msg3_round = 0; + LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Canceled RA procedure for UE rnti %x\n", module_idP, CC_id, frameP, rnti); } + } } -void clear_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP) -{ +void clear_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP) { unsigned char i; RA_t *ra = (RA_t *) & RC.mac[module_idP]->common_channels[CC_id].ra[0]; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 274b169bf650b0c366fb87d7681222221e8e551e..bf5cfef0c3209dd142e130200bb4767cc0e5d50e 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -35,6 +35,7 @@ #include "LAYER2/MAC/mac_proto.h" #include "LAYER2/MAC/mac_extern.h" #include "common/utils/LOG/log.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" @@ -64,7 +65,7 @@ #include "common/ran_context.h" extern RAN_CONTEXT_t RC; -extern uint8_t nfapi_mode; + //------------------------------------------------------------------------------ void @@ -155,6 +156,7 @@ generate_dlsch_header(unsigned char *mac_header, } else { first_element = 1; } + mac_header_ptr->R = 0; mac_header_ptr->E = 0; mac_header_ptr->LCID = DRX_CMD; @@ -168,6 +170,7 @@ generate_dlsch_header(unsigned char *mac_header, } else { first_element = 1; } + mac_header_ptr->R = 0; mac_header_ptr->E = 0; mac_header_ptr->LCID = TIMING_ADV_CMD; @@ -435,25 +438,15 @@ schedule_dlsch(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, in // changes to pre-processor for eMTC //------------------------------------------------------------------------------ -void getRepetition(UE_TEMPLATE * pue_template,unsigned int *maxRep , unsigned int *narrowBandindex){ - LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11; - - AssertFatal(pue_template->physicalConfigDedicated !=NULL, "no RRC physical configuration for this UE ") ; - AssertFatal(pue_template->physicalConfigDedicated->ext4 !=NULL, "no RRC physical configuration for this UE ") ; - - AssertFatal(pue_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.count > 0 ,"epdcch config list is empty") ; - - epdcch_setconfig_r11 = pue_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0] ; - - AssertFatal(epdcch_setconfig_r11->ext2 !=NULL && epdcch_setconfig_r11->ext2->mpdcch_config_r13 !=NULL," mpdcch config not found") ; - -*maxRep = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_NumRepetition_r13 ; - - *narrowBandindex = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 ; - - - - +void getRepetition(UE_TEMPLATE *pue_template,unsigned int *maxRep, unsigned int *narrowBandindex) { + LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11; + AssertFatal(pue_template->physicalConfigDedicated !=NULL, "no RRC physical configuration for this UE ") ; + AssertFatal(pue_template->physicalConfigDedicated->ext4 !=NULL, "no RRC physical configuration for this UE ") ; + AssertFatal(pue_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.count > 0,"epdcch config list is empty") ; + epdcch_setconfig_r11 = pue_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0] ; + AssertFatal(epdcch_setconfig_r11->ext2 !=NULL && epdcch_setconfig_r11->ext2->mpdcch_config_r13 !=NULL," mpdcch config not found") ; + *maxRep = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_NumRepetition_r13 ; + *narrowBandindex = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 ; } //------------------------------------------------------------------------------ @@ -510,7 +503,6 @@ schedule_ue_spec(module_id_t module_idP, rrc_eNB_ue_context_t *ue_contextP = NULL; int nb_mac_CC = RC.nb_mac_CC[module_idP]; long dl_Bandwidth; - start_meas(&eNB->schedule_dlsch); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_IN); @@ -658,14 +650,14 @@ schedule_ue_spec(module_id_t module_idP, case 2: case 7: aggregation = get_aggregation(get_bw_index(module_idP, - CC_id), + CC_id), ue_sched_ctrl->dl_cqi[CC_id], format1); break; case 3: aggregation = get_aggregation(get_bw_index(module_idP, - CC_id), + CC_id), ue_sched_ctrl->dl_cqi[CC_id], format2A); break; @@ -743,7 +735,7 @@ schedule_ue_spec(module_id_t module_idP, (eNB_UE_stats->dl_cqi > MAX_CQI_VALUE)), eNB_UE_stats->dl_cqi, MIN_CQI_VALUE, MAX_CQI_VALUE); */ - if (nfapi_mode) { + if (NFAPI_MODE != NFAPI_MONOLITHIC) { eNB_UE_stats->dlsch_mcs1 = 10; // cqi_to_mcs[ue_sched_ctrl->dl_cqi[CC_id]]; } else { // this operation is also done in the preprocessor eNB_UE_stats->dlsch_mcs1 = cmin(eNB_UE_stats->dlsch_mcs1, @@ -764,7 +756,7 @@ schedule_ue_spec(module_id_t module_idP, CC_id, rnti, harq_pid, - round, + round, nb_available_rb, ue_sched_ctrl->dl_cqi[CC_id], eNB_UE_stats->dlsch_mcs1, @@ -806,11 +798,12 @@ schedule_ue_spec(module_id_t module_idP, LOG_W(MAC, "WARN: rballoc_subband not free for retrans?\n"); ue_template->rballoc_subband[harq_pid][j] = ue_sched_ctrl->rballoc_sub_UE[CC_id][j]; - nb_rb_temp -= min_rb_unit[CC_id]; + if ((j == N_RBG[CC_id] - 1) && (N_RB_DL[CC_id] == 25 || N_RB_DL[CC_id] == 50)) nb_rb_temp++; } + j++; } } @@ -908,7 +901,6 @@ schedule_ue_spec(module_id_t module_idP, cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode 0, //number of PRBs treated as one subband, not used here 0); // number of beamforming vectors, not used here - LOG_D(MAC, "Filled NFAPI configuration for DCI/DLSCH %d, retransmission round %d\n", eNB->pdu_index[CC_id], round); @@ -962,6 +954,7 @@ schedule_ue_spec(module_id_t module_idP, if (ta_update != 31) { ue_sched_ctrl->ta_timer = 20; } + /* reset ta_update */ ue_sched_ctrl->ta_update = 31; } else { @@ -1008,7 +1001,7 @@ schedule_ue_spec(module_id_t module_idP, , 0 , 0 #endif - ); + ); pthread_mutex_lock(&rrc_release_freelist); if((rrc_release_info.num_UEs > 0) && (rlc_am_mui.rrc_mui_num > 0)) { @@ -1101,10 +1094,12 @@ schedule_ue_spec(module_id_t module_idP, module_idP, CC_id, sdu_lengths[0]); + for (j = 0; j < sdu_lengths[0]; ++j) { LOG_T(MAC, "%x ", dlsch_buffer[j]); } + LOG_T(MAC, "\n"); #endif } @@ -1125,7 +1120,7 @@ schedule_ue_spec(module_id_t module_idP, , 0 , 0 #endif - ); + ); // DCCH SDU sdu_lengths[num_sdus] = 0; @@ -1134,18 +1129,18 @@ schedule_ue_spec(module_id_t module_idP, module_idP, frameP, CC_id, TBS - ta_len - header_length_total - sdu_length_total - 3); sdu_lengths[num_sdus] += mac_rlc_data_req(module_idP, - rnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, DCCH + 1, - TBS, //not used - (char *) &dlsch_buffer[sdu_length_total] + rnti, + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, DCCH + 1, + TBS, //not used + (char *) &dlsch_buffer[sdu_length_total] #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , 0 - , 0 + , 0 + , 0 #endif - ); + ); T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), @@ -1169,10 +1164,12 @@ schedule_ue_spec(module_id_t module_idP, module_idP, CC_id, sdu_lengths[num_sdus]); + for (j = 0; j < sdu_lengths[num_sdus]; ++j) { LOG_T(MAC, "%x ", dlsch_buffer[j]); } + LOG_T(MAC, "\n"); #endif } @@ -1202,7 +1199,7 @@ schedule_ue_spec(module_id_t module_idP, , 0 , 0 #endif - ); + ); if (rlc_status.bytes_in_buffer > 0) { LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", @@ -1212,19 +1209,19 @@ schedule_ue_spec(module_id_t module_idP, lcid, header_length_total); sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, - rnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS, //not used - (char *) &dlsch_buffer[sdu_length_total] + rnti, + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS, //not used + (char *) &dlsch_buffer[sdu_length_total] #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , 0 - , 0 + , 0 + , 0 #endif - ); + ); T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), @@ -1395,10 +1392,12 @@ schedule_ue_spec(module_id_t module_idP, //#endif #ifdef DEBUG_eNB_SCHEDULER LOG_T(MAC, "[eNB %d] First 16 bytes of DLSCH : \n"); + for (i = 0; i < 16; i++) { LOG_T(MAC, "%x.", dlsch_buffer[i]); } + LOG_T(MAC, "\n"); #endif // cycle through SDUs and place in dlsch_buffer @@ -1522,7 +1521,7 @@ schedule_ue_spec(module_id_t module_idP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP, - CC_id), + CC_id), ue_sched_ctrl->dl_cqi[CC_id], format1); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; @@ -1608,12 +1607,11 @@ schedule_ue_spec(module_id_t module_idP, cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode 0, //number of PRBs treated as one subband, not used here 0); // number of beamforming vectors, not used here - eNB->TX_req[CC_id].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_id].tx_request_body, - (frameP * 10) + subframeP, - TBS, - eNB->pdu_index[CC_id], - dlsch_pdu->payload[0]); + (frameP * 10) + subframeP, + TBS, + eNB->pdu_index[CC_id], + dlsch_pdu->payload[0]); LOG_D(MAC, "Filled NFAPI configuration for DCI/DLSCH/TXREQ %d, new SDU\n", eNB->pdu_index[CC_id]); eNB->pdu_index[CC_id]++; @@ -1818,6 +1816,7 @@ dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, } } } + return; } @@ -1858,12 +1857,12 @@ void dlsch_scheduler_qos_multiplexing(module_id_t Mod_id, int frameP, sub_frame_ */ void schedule_ue_spec_br(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP) -//------------------------------------------------------------------------------ + frame_t frameP, + sub_frame_t subframeP) +//------------------------------------------------------------------------------ { int CC_id = 0; - int UE_id = -1; + int UE_id = -1; int rvseq[4] = {0,2,3,1}; int mcs = 0; int round_DL = 0; @@ -1878,13 +1877,11 @@ schedule_ue_spec_br(module_id_t module_idP, uint16_t padding = 0; uint16_t post_padding = 0; uint16_t sdu_length_total = 0; - mac_rlc_status_resp_t rlc_status; rrc_eNB_ue_context_t *ue_contextP = NULL; - unsigned char header_len_dcch = 0; unsigned char header_len_dcch_tmp = 0; - unsigned char header_len_dtch = 0; + unsigned char header_len_dtch = 0; unsigned char header_len_dtch_tmp = 0; unsigned char header_len_dtch_last = 0; unsigned char ta_len = 0; @@ -1892,19 +1889,16 @@ schedule_ue_spec_br(module_id_t module_idP, unsigned char lcid = 0; unsigned char offset,num_sdus=0; unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; - eNB_MAC_INST *mac = RC.mac[module_idP]; COMMON_channels_t *cc = mac->common_channels; UE_list_t *UE_list = &mac->UE_list; UE_TEMPLATE *UE_template = NULL; UE_sched_ctrl *ue_sched_ctl = NULL; - nfapi_dl_config_request_pdu_t *dl_config_pdu = NULL; nfapi_ul_config_request_pdu_t *ul_config_pdu = NULL; nfapi_tx_request_pdu_t *TX_req = NULL; nfapi_dl_config_request_body_t *dl_req = NULL; nfapi_ul_config_request_body_t *ul_req = NULL; - struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach = NULL; struct LTE_PUCCH_ConfigCommon_v1310 *ext4_pucch = NULL; LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = NULL; @@ -1913,7 +1907,6 @@ schedule_ue_spec_br(module_id_t module_idP, int n1pucchan[4] = { 0, 0, 0, 0 }; uint32_t ackNAK_absSF; int first_rb; - dl_req = &(mac->DL_req[CC_id].dl_config_request_body); dl_config_pdu = &(dl_req->dl_config_pdu_list[dl_req->number_pdu]); @@ -1931,39 +1924,40 @@ schedule_ue_spec_br(module_id_t module_idP, ext4_pucch = cc[CC_id].radioResourceConfigCommon_BR->ext4->pucch_ConfigCommon_v1310; prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13; pucch_N1PUCCH_AN_InfoList_r13 = ext4_pucch->n1PUCCH_AN_InfoList_r13; - AssertFatal (prach_ParametersListCE_r13 != NULL, "prach_ParametersListCE_r13 is null\n"); AssertFatal (pucch_N1PUCCH_AN_InfoList_r13 != NULL, "pucch_N1PUCCH_AN_InfoList_r13 is null\n"); /* Check to verify CE-Level compatibility in SIB2_BR */ AssertFatal (prach_ParametersListCE_r13->list.count == pucch_N1PUCCH_AN_InfoList_r13->list.count, "prach_ParametersListCE_r13->list.count!= pucch_N1PUCCH_AN_InfoList_r13->list.count\n"); switch (prach_ParametersListCE_r13->list.count) { - case 4: - n1pucchan[3] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[3]; - AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level3 shouldn't be NULL\n"); - pucchreps[3] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13); + case 4: + n1pucchan[3] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[3]; + AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level3 shouldn't be NULL\n"); + pucchreps[3] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13); - case 3: - n1pucchan[2] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[2]; - AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level2 shouldn't be NULL\n"); - pucchreps[2] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13); - case 2: - n1pucchan[1] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[1]; - AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level1 shouldn't be NULL\n"); - pucchreps[1] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13); - case 1: - n1pucchan[0] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[0]; - AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level0 shouldn't be NULL\n"); - pucchreps[0] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13); - break; - default: - AssertFatal (1 == 0, "Illegal count for prach_ParametersListCE_r13 %d\n", prach_ParametersListCE_r13->list.count); + case 3: + n1pucchan[2] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[2]; + AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level2 shouldn't be NULL\n"); + pucchreps[2] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13); + + case 2: + n1pucchan[1] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[1]; + AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level1 shouldn't be NULL\n"); + pucchreps[1] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13); + + case 1: + n1pucchan[0] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[0]; + AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level0 shouldn't be NULL\n"); + pucchreps[0] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13); + break; + + default: + AssertFatal (1 == 0, "Illegal count for prach_ParametersListCE_r13 %d\n", prach_ParametersListCE_r13->list.count); } } for (UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { int harq_pid = 0; - rnti = UE_RNTI(module_idP, UE_id); if (rnti==NOT_A_RNTI) { @@ -1984,26 +1978,23 @@ schedule_ue_spec_br(module_id_t module_idP, } round_DL = ue_sched_ctl->round[CC_id][harq_pid]; - AssertFatal (UE_template->physicalConfigDedicated != NULL, "UE_template->physicalConfigDedicated is null\n"); AssertFatal (UE_template->physicalConfigDedicated->ext4 != NULL, "UE_template->physicalConfigDedicated->ext4 is null\n"); AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 != NULL, "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 is null\n"); AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present == LTE_EPDCCH_Config_r11__config_r11_PR_setup, - "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present != setup\n"); + "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present != setup\n"); AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 != NULL, - "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = NULL\n"); - + "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = NULL\n"); LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11 = UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0]; - AssertFatal(epdcch_setconfig_r11 != NULL, "epdcch_setconfig_r11 is null\n"); AssertFatal(epdcch_setconfig_r11->ext2 != NULL, "epdcch_setconfig_r11->ext2 is null\n"); AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13 != NULL, "epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null"); AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13 != NULL, "epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null"); - AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->present == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup, - "epdcch_setconfig_r11->ext2->mpdcch_config_r13->present is not setup\n"); + AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->present == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup, + "epdcch_setconfig_r11->ext2->mpdcch_config_r13->present is not setup\n"); AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 != NULL, "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 is null"); - AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present == LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup, - "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present is not setup\n"); + AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present == LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup, + "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present is not setup\n"); /* Simple scheduler for 1 repetition, 1 HARQ */ if (subframeP == 5) { // MPDCCH @@ -2011,21 +2002,21 @@ schedule_ue_spec_br(module_id_t module_idP, if (round_DL == 8) { rlc_status.bytes_in_buffer = 0; - /* Now check RLC information to compute number of required RBs */ - /* Get maximum TBS size for RLC request */ TBS = get_TBS_DL(9,6); - + /* Check first for RLC data on DCCH */ - + /* Add the length for all the control elements (timing adv, drx, etc) : header + payload */ if (ue_sched_ctl->ta_timer == 0) { ta_update = ue_sched_ctl->ta_update; + /* If we send TA then set timer to not send it for a while */ if (ta_update != 31) ue_sched_ctl->ta_timer = 20; + /* Reset ta_update */ ue_sched_ctl->ta_update = 31; } else { @@ -2033,60 +2024,53 @@ schedule_ue_spec_br(module_id_t module_idP, } ta_len = (ta_update != 31) ? 2 : 0; - header_len_dcch = 2; // 2 bytes DCCH SDU subheader if (TBS - ta_len-header_len_dcch > 0 ) { LOG_D(MAC, "Calling mac_rlc_status_ind for DCCH\n"); - rlc_status = mac_rlc_status_ind(module_idP, - rnti, - module_idP, - frameP, - subframeP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - DCCH, + rnti, + module_idP, + frameP, + subframeP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + DCCH, (TBS-ta_len-header_len_dcch), 0, 0); // transport block set size - sdu_lengths[0] = 0; if (rlc_status.bytes_in_buffer > 0) { // There is DCCH to transmit LOG_D(MAC, "[eNB %d] Frame %d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - module_idP, + module_idP, frameP, CC_id, TBS-header_len_dcch); - sdu_lengths[0] = mac_rlc_data_req(module_idP, - rnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - DCCH, - TBS, //not used + rnti, + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + DCCH, + TBS, //not used (char *)&dlsch_buffer[0], 0, 0); - - T(T_ENB_MAC_UE_DL_SDU, - T_INT(module_idP), - T_INT(CC_id), - T_INT(rnti), - T_INT(frameP), + T(T_ENB_MAC_UE_DL_SDU, + T_INT(module_idP), + T_INT(CC_id), + T_INT(rnti), + T_INT(frameP), T_INT(subframeP), - T_INT(harq_pid), - T_INT(DCCH), + T_INT(harq_pid), + T_INT(DCCH), T_INT(sdu_lengths[0])); - LOG_D(MAC,"[eNB %d][DCCH] CC_id %d Got %d bytes from RLC\n", module_idP, CC_id, sdu_lengths[0]); - sdu_length_total = sdu_lengths[0]; sdu_lcids[0] = DCCH; UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH]+=1; @@ -2101,192 +2085,183 @@ schedule_ue_spec_br(module_id_t module_idP, /* Check for DCCH1 and update header information (assume 2 byte sub-header) */ if (TBS - ta_len-header_len_dcch - sdu_length_total > 0) { rlc_status = mac_rlc_status_ind(module_idP, - rnti, - module_idP, - frameP, - subframeP, - ENB_FLAG_YES, - MBMS_FLAG_NO, + rnti, + module_idP, + frameP, + subframeP, + ENB_FLAG_YES, + MBMS_FLAG_NO, DCCH + 1, (TBS-ta_len-header_len_dcch-sdu_length_total), - 0, + 0, 0); // transport block set size less allocations for timing advance and DCCH SDU - - sdu_lengths[num_sdus] = 0; + sdu_lengths[num_sdus] = 0; if (rlc_status.bytes_in_buffer > 0) { LOG_D(MAC,"[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - module_idP, + module_idP, frameP, CC_id, TBS-header_len_dcch - sdu_length_total); - sdu_lengths[num_sdus] += mac_rlc_data_req(module_idP, - rnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - DCCH+1, - TBS, //not used - (char *)&dlsch_buffer[sdu_length_total], - 0, - 0); - - T(T_ENB_MAC_UE_DL_SDU, - T_INT(module_idP), - T_INT(CC_id), - T_INT(rnti), - T_INT(frameP), + rnti, + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + DCCH+1, + TBS, //not used + (char *)&dlsch_buffer[sdu_length_total], + 0, + 0); + T(T_ENB_MAC_UE_DL_SDU, + T_INT(module_idP), + T_INT(CC_id), + T_INT(rnti), + T_INT(frameP), T_INT(subframeP), - T_INT(harq_pid), - T_INT(DCCH+1), + T_INT(harq_pid), + T_INT(DCCH+1), T_INT(sdu_lengths[num_sdus])); - sdu_lcids[num_sdus] = DCCH1; sdu_length_total += sdu_lengths[num_sdus]; header_len_dcch += 2; UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH1] += 1; UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1] += sdu_lengths[num_sdus]; - num_sdus++; - } + num_sdus++; + } } - /* Assume the max dtch header size, and adjust it later */ - header_len_dtch = 0; - header_len_dtch_last = 0; // the header length of the last mac sdu - - /* lcid has to be sorted before the actual allocation (similar struct as ue_list) */ - for (lcid = NB_RB_MAX-1; lcid >= DTCH ; lcid--){ - /* TBD: check if the lcid is active */ - header_len_dtch += 3; - header_len_dtch_last = 3; - - LOG_D(MAC,"[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", - module_idP, - frameP, - lcid, - TBS, - TBS - ta_len-header_len_dcch - sdu_length_total - header_len_dtch); - - if (TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch > 0) { // NN: > 2 ? - rlc_status = mac_rlc_status_ind(module_idP, - rnti, - module_idP, - frameP, - subframeP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch, - 0, - 0); + /* Assume the max dtch header size, and adjust it later */ + header_len_dtch = 0; + header_len_dtch_last = 0; // the header length of the last mac sdu - if (rlc_status.bytes_in_buffer > 0) { - /* RRC inactivity LTE-M */ - /* Reset RRC inactivity timer after uplane activity */ - ue_contextP = rrc_eNB_get_ue_context(RC.rrc[module_idP], rnti); + /* lcid has to be sorted before the actual allocation (similar struct as ue_list) */ + for (lcid = NB_RB_MAX-1; lcid >= DTCH ; lcid--) { + /* TBD: check if the lcid is active */ + header_len_dtch += 3; + header_len_dtch_last = 3; + LOG_D(MAC,"[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", + module_idP, + frameP, + lcid, + TBS, + TBS - ta_len-header_len_dcch - sdu_length_total - header_len_dtch); - if (ue_contextP != NULL) { - ue_contextP->ue_context.ue_rrc_inactivity_timer = 1; - } else { - LOG_E(MAC, "[eNB %d] CC_id %d Couldn't find the context associated to UE (RNTI %d) and reset RRC inactivity timer\n", - module_idP, - CC_id, - rnti); - } - - LOG_D(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", - module_idP, - frameP, - TBS - header_len_dcch - sdu_length_total - header_len_dtch, - lcid, - header_len_dtch); - - sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, - rnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS, //not used - (char*) &dlsch_buffer[sdu_length_total], - 0, - 0); - - T(T_ENB_MAC_UE_DL_SDU, - T_INT(module_idP), - T_INT(CC_id), - T_INT(rnti), - T_INT(frameP), - T_INT(subframeP), - T_INT(harq_pid), - T_INT(lcid), - T_INT(sdu_lengths[num_sdus])); + if (TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch > 0) { // NN: > 2 ? + rlc_status = mac_rlc_status_ind(module_idP, + rnti, + module_idP, + frameP, + subframeP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch, + 0, + 0); - LOG_D(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", - module_idP, - sdu_lengths[num_sdus], - lcid); + if (rlc_status.bytes_in_buffer > 0) { + /* RRC inactivity LTE-M */ + /* Reset RRC inactivity timer after uplane activity */ + ue_contextP = rrc_eNB_get_ue_context(RC.rrc[module_idP], rnti); - sdu_lcids[num_sdus] = lcid; - sdu_length_total += sdu_lengths[num_sdus]; + if (ue_contextP != NULL) { + ue_contextP->ue_context.ue_rrc_inactivity_timer = 1; + } else { + LOG_E(MAC, "[eNB %d] CC_id %d Couldn't find the context associated to UE (RNTI %d) and reset RRC inactivity timer\n", + module_idP, + CC_id, + rnti); + } + + LOG_D(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", + module_idP, + frameP, + TBS - header_len_dcch - sdu_length_total - header_len_dtch, + lcid, + header_len_dtch); + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, + rnti, + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS, //not used + (char *) &dlsch_buffer[sdu_length_total], + 0, + 0); + T(T_ENB_MAC_UE_DL_SDU, + T_INT(module_idP), + T_INT(CC_id), + T_INT(rnti), + T_INT(frameP), + T_INT(subframeP), + T_INT(harq_pid), + T_INT(lcid), + T_INT(sdu_lengths[num_sdus])); + LOG_D(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", + module_idP, + sdu_lengths[num_sdus], + lcid); + sdu_lcids[num_sdus] = lcid; + sdu_length_total += sdu_lengths[num_sdus]; - if (sdu_lengths[num_sdus] < 128) { - header_len_dtch--; - header_len_dtch_last--; - } + if (sdu_lengths[num_sdus] < 128) { + header_len_dtch--; + header_len_dtch_last--; + } - num_sdus++; - } else { // no data for this LCID + num_sdus++; + } else { // no data for this LCID + header_len_dtch -= 3; + } + } else { // no TBS left header_len_dtch -= 3; - } - } else { // no TBS left - header_len_dtch -= 3; - break; - } - } // for loop LCID - - if (header_len_dtch == 0) { - header_len_dtch_last = 0; - } - - /* There is at least one SDU */ - if ((sdu_length_total + header_len_dcch + header_len_dtch) > 0) { - /* Now compute number of required RBs for total sdu length */ - /* Assume RAH format 2 */ - /* Adjust header lengths */ - header_len_dcch_tmp = header_len_dcch; - header_len_dtch_tmp = header_len_dtch; - - if (header_len_dtch == 0) { - header_len_dcch = (header_len_dcch > 0) ? 1 : 0; // remove length field - } else { - header_len_dtch_last -= 1; // now use it to find how many bytes has to be removed for the last MAC SDU - header_len_dtch = (header_len_dtch > 0) ? header_len_dtch - header_len_dtch_last : header_len_dtch; // remove length field for the last SDU - } + break; + } + } // for loop LCID + + if (header_len_dtch == 0) { + header_len_dtch_last = 0; + } + + /* There is at least one SDU */ + if ((sdu_length_total + header_len_dcch + header_len_dtch) > 0) { + /* Now compute number of required RBs for total sdu length */ + /* Assume RAH format 2 */ + /* Adjust header lengths */ + header_len_dcch_tmp = header_len_dcch; + header_len_dtch_tmp = header_len_dtch; + + if (header_len_dtch == 0) { + header_len_dcch = (header_len_dcch > 0) ? 1 : 0; // remove length field + } else { + header_len_dtch_last -= 1; // now use it to find how many bytes has to be removed for the last MAC SDU + header_len_dtch = (header_len_dtch > 0) ? header_len_dtch - header_len_dtch_last : header_len_dtch; // remove length field for the last SDU + } mcs = 9; - /* Decrease mcs until TBS falls below required length */ + /* Decrease mcs until TBS falls below required length */ while ((TBS > (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && (mcs>0)) { mcs--; TBS = get_TBS_DL(mcs,6); } - /* If we have decreased too much or we don't have enough RBs, increase MCS */ + /* If we have decreased too much or we don't have enough RBs, increase MCS */ while (TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) { mcs++; TBS = get_TBS_DL(mcs,6); } - LOG_D(MAC, "[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n", - module_idP, - CC_id, - mcs, - TBS, - 6); + LOG_D(MAC, "[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n", + module_idP, + CC_id, + mcs, + TBS, + 6); if ((TBS - header_len_dcch - header_len_dtch - sdu_length_total - ta_len) <= 2) { padding = (TBS - header_len_dcch - header_len_dtch - sdu_length_total - ta_len); @@ -2294,17 +2269,17 @@ schedule_ue_spec_br(module_id_t module_idP, } else { padding = 0; - /* Adjust the header len */ - if (header_len_dtch == 0) { + /* Adjust the header len */ + if (header_len_dtch == 0) { header_len_dcch = header_len_dcch_tmp; - } else { // if ((header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2))) + } else { // if ((header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2))) header_len_dtch = header_len_dtch_tmp; } - post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len; // 1 is for the postpadding header + post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len; // 1 is for the postpadding header } - offset = generate_dlsch_header((unsigned char*)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], + offset = generate_dlsch_header((unsigned char *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], num_sdus, //num_sdus sdu_lengths, // sdu_lcids, @@ -2314,188 +2289,175 @@ schedule_ue_spec_br(module_id_t module_idP, padding, post_padding); - if (ta_update != 31) { - LOG_D(MAC,"[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n", - module_idP, - frameP, - UE_id, - CC_id, - sdu_length_total, - num_sdus, - sdu_lengths[0], - sdu_lcids[0], - offset, - ta_update, - padding, - post_padding, - mcs, - TBS, - 6, - header_len_dcch, - header_len_dtch); - } - - /* Cycle through SDUs and place in dlsch_buffer */ - memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset], dlsch_buffer, sdu_length_total); - - /* Fill remainder of DLSCH with random data */ - for (j = 0; j < (TBS - sdu_length_total - offset); j++) { - UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset + sdu_length_total + j] = (char)(taus()&0xff); + LOG_D(MAC, + "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n", + module_idP, + frameP, + UE_id, + CC_id, + sdu_length_total, + num_sdus, + sdu_lengths[0], + sdu_lcids[0], + offset, + ta_update, + padding, + post_padding, + mcs, + TBS, + 6, + header_len_dcch, + header_len_dtch); } - if (opt_enabled == 1) { - trace_pdu(1, - (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], - TBS, - module_idP, - 3, - UE_RNTI(module_idP,UE_id), - mac->frame, - mac->subframe, - 0, - 0); + /* Cycle through SDUs and place in dlsch_buffer */ + memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset], dlsch_buffer, sdu_length_total); + /* Fill remainder of DLSCH with random data */ + for (j = 0; j < (TBS - sdu_length_total - offset); j++) { + UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset + sdu_length_total + j] = (char)(taus()&0xff); + } + + if (opt_enabled == 1) { + trace_pdu(1, + (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], + TBS, + module_idP, + 3, + UE_RNTI(module_idP,UE_id), + mac->frame, + mac->subframe, + 0, + 0); LOG_D(OPT,"[eNB %d][DLSCH] CC_id %d Frame %d rnti %x with size %d\n", - module_idP, - CC_id, - frameP, - UE_RNTI(module_idP, UE_id), - TBS); + module_idP, + CC_id, + frameP, + UE_RNTI(module_idP, UE_id), + TBS); } - T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, - T_INT(module_idP), - T_INT(CC_id), - T_INT(rnti), - T_INT(frameP), - T_INT(subframeP), - T_INT(harq_pid), - T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS)); - - /* Do PUCCH power control */ - /* This is the normalized RX power */ + T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, + T_INT(module_idP), + T_INT(CC_id), + T_INT(rnti), + T_INT(frameP), + T_INT(subframeP), + T_INT(harq_pid), + T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS)); + /* Do PUCCH power control */ + /* This is the normalized RX power */ /* TODO: fix how we deal with power, unit is not dBm, it's special from nfapi */ - normalized_rx_power = (5 * ue_sched_ctl->pucch1_snr[CC_id]-640) / 10 + 30; - target_rx_power = mac->puCch10xSnr / 10 + 30; - - /* This assumes accumulated tpc */ - /* Make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out */ - int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame * 10 + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; - - if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || // normal case - ((framex10psubframe > (frameP * 10 + subframeP)) && - (((10240 - framex10psubframe +frameP * 10 + subframeP) >= 10)))) { // frame wrap-around - if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) { - ue_sched_ctl->pucch1_cqi_update[CC_id] = 0; - - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frameP; - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframeP; - - if (normalized_rx_power > (target_rx_power + 4)) { - tpc = 0; //-1 - } else if (normalized_rx_power<(target_rx_power - 4)) { - tpc = 2; //+1 - } else { - tpc = 1; //0 - } - - LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, normalized/target rx power %d/%d\n", - module_idP, - frameP, - subframeP, - harq_pid, - tpc, - normalized_rx_power, - target_rx_power); - } else { // Po_PUCCH has been updated - tpc = 1; // 0 - } - } else { // time to do TPC update - tpc = 1; //0 - } - - // Toggle NDI in first round - UE_template->oldNDI[harq_pid] = 1 - UE_template->oldNDI[harq_pid]; - ue_sched_ctl->round[CC_id][harq_pid] = 0; - round_DL = 0; - } // if ((sdu_length_total + header_len_dcch + header_len_dtch) > 0) - } - - if (round_DL < 8) { - /* Fill in MDPDCCH */ - memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t)); - - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu)); - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = (UE_template->rach_resource_type > 1) ? 11 : 10; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = 6; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = epdcch_setconfig_r11->transmissionType_r11; - - AssertFatal(UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 != NULL, - "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 is null\n"); - - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0; // Note: this should be dynamic - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 24; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4 - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = 4; // t-CRNTI - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti = rnti; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = (UE_template->rach_resource_type < 3) ? 1 : 2; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000; // 0dB - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV (6, 0, 6) | ((epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1)<<5); - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = mcs; // adjust according to size of RAR, 208 bits with N1A_PRB=3 - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 0; // fix to 4 for now - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = rvseq[round_DL&3]; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = UE_template->oldNDI[harq_pid]; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpc = 3; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.srs_request = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0; - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in - dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1; - dl_req->number_pdu++; - UE_template->mcs[harq_pid] = dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs; + normalized_rx_power = (5 * ue_sched_ctl->pucch1_snr[CC_id]-640) / 10 + 30; + target_rx_power = mac->puCch10xSnr / 10 + 30; + /* This assumes accumulated tpc */ + /* Make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out */ + int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame * 10 + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; + + if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || // normal case + ((framex10psubframe > (frameP * 10 + subframeP)) && + (((10240 - framex10psubframe +frameP * 10 + subframeP) >= 10)))) { // frame wrap-around + if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) { + ue_sched_ctl->pucch1_cqi_update[CC_id] = 0; + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frameP; + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframeP; + + if (normalized_rx_power > (target_rx_power + 4)) { + tpc = 0; //-1 + } else if (normalized_rx_power<(target_rx_power - 4)) { + tpc = 2; //+1 + } else { + tpc = 1; //0 + } + + LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, normalized/target rx power %d/%d\n", + module_idP, + frameP, + subframeP, + harq_pid, + tpc, + normalized_rx_power, + target_rx_power); + } else { // Po_PUCCH has been updated + tpc = 1; // 0 + } + } else { // time to do TPC update + tpc = 1; //0 + } + + // Toggle NDI in first round + UE_template->oldNDI[harq_pid] = 1 - UE_template->oldNDI[harq_pid]; + ue_sched_ctl->round[CC_id][harq_pid] = 0; + round_DL = 0; + } // if ((sdu_length_total + header_len_dcch + header_len_dtch) > 0) + } + + if (round_DL < 8) { + /* Fill in MDPDCCH */ + memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE; + dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu)); + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = (UE_template->rach_resource_type > 1) ? 11 : 10; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = 6; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = epdcch_setconfig_r11->transmissionType_r11; + AssertFatal(UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 != NULL, + "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 is null\n"); + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0; // Note: this should be dynamic + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 24; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4 + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = 4; // t-CRNTI + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti = rnti; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = (UE_template->rach_resource_type < 3) ? 1 : 2; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000; // 0dB + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV (6, 0, 6) | ((epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1)<<5); + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = mcs; // adjust according to size of RAR, 208 bits with N1A_PRB=3 + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 0; // fix to 4 for now + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = rvseq[round_DL&3]; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = UE_template->oldNDI[harq_pid]; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpc = 3; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.srs_request = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0; + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in + dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1; + dl_req->number_pdu++; + UE_template->mcs[harq_pid] = dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs; } - } else if ((subframeP == 7) && (round_DL < 8)) { // DLSCH - LOG_D(MAC, "DLSCH round_DL = %d in frame %d subframe %d\n", round_DL, frameP, subframeP); - - int absSF = (frameP * 10) + subframeP; - - /* Have to check that MPDCCH was generated */ - LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating DLSCH (ce_level %d RNTI %x)\n", - module_idP, - CC_id, - frameP, - subframeP, - UE_template->rach_resource_type - 1, - rnti); - - first_rb = narrowband_to_first_rb(&cc[CC_id], epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1); - - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - - memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t)); - + } else if ((subframeP == 7) && (round_DL < 8)) { // DLSCH + LOG_D(MAC, "DLSCH round_DL = %d in frame %d subframe %d\n", round_DL, frameP, subframeP); + int absSF = (frameP * 10) + subframeP; + /* Have to check that MPDCCH was generated */ + LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating DLSCH (ce_level %d RNTI %x)\n", + module_idP, + CC_id, + frameP, + subframeP, + UE_template->rach_resource_type - 1, + rnti); + first_rb = narrowband_to_first_rb(&cc[CC_id], epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1); + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t)); dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_dlsch_pdu)); dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = mac->pdu_index[CC_id]; @@ -2526,21 +2488,18 @@ schedule_ue_spec_br(module_id_t module_idP, dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10 * frameP) + subframeP; dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0; dl_req->number_pdu++; - // DL request mac->TX_req[CC_id].sfn_sf = (frameP << 4) + subframeP; TX_req = &mac->TX_req[CC_id].tx_request_body.tx_pdu_list[mac->TX_req[CC_id].tx_request_body.number_of_pdus]; - TX_req->pdu_length = get_TBS_DL(UE_template->mcs[harq_pid], 6); + TX_req->pdu_length = get_TBS_DL(UE_template->mcs[harq_pid], 6); TX_req->pdu_index = mac->pdu_index[CC_id]++; TX_req->num_segments = 1; TX_req->segments[0].segment_length = TX_req->pdu_length; TX_req->segments[0].segment_data = mac->UE_list.DLSCH_pdu[CC_id][0][(unsigned char) UE_id].payload[0]; mac->TX_req[CC_id].tx_request_body.number_of_pdus++; - ackNAK_absSF = absSF + 4; ul_req = &mac->UL_req_tmp[CC_id][ackNAK_absSF % 10].ul_config_request_body; ul_config_pdu = &ul_req->ul_config_pdu_list[ul_req->number_of_pdus]; - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE; ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_ul_config_uci_harq_pdu)); ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.handle = 0; // don't know how to use this @@ -2551,47 +2510,45 @@ schedule_ue_spec_br(module_id_t module_idP, ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.repetition_number = 0; if (cc[CC_id].tdd_Config == NULL) { // FDD case - ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.n_pucch_1_0 = n1pucchan[UE_template->rach_resource_type - 1]; - // NOTE: How to fill in the rest of the n_pucch_1_0 information 213 Section 10.1.2.1 in the general case - // = N_ECCE_q + Delta_ARO + n1pucchan[ce_level] - // higher in the MPDCCH configuration, N_ECCE_q is hard-coded to 0, and harq resource offset to 0 => - // Delta_ARO = 0 from Table 10.1.2.1-1 - ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.harq_size = 1; // 1-bit ACK/NAK - ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.number_of_pucch_resources = 1; + ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.n_pucch_1_0 = n1pucchan[UE_template->rach_resource_type - 1]; + // NOTE: How to fill in the rest of the n_pucch_1_0 information 213 Section 10.1.2.1 in the general case + // = N_ECCE_q + Delta_ARO + n1pucchan[ce_level] + // higher in the MPDCCH configuration, N_ECCE_q is hard-coded to 0, and harq resource offset to 0 => + // Delta_ARO = 0 from Table 10.1.2.1-1 + ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.harq_size = 1; // 1-bit ACK/NAK + ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.number_of_pucch_resources = 1; } else { - AssertFatal (1 == 0, "PUCCH configuration for ACK/NAK not handled yet for TDD BL/CE case\n"); + AssertFatal (1 == 0, "PUCCH configuration for ACK/NAK not handled yet for TDD BL/CE case\n"); } ul_req->number_of_pdus++; - - T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, - T_INT (module_idP), - T_INT (CC_id), - T_INT (rnti), - T_INT (frameP), + T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, + T_INT (module_idP), + T_INT (CC_id), + T_INT (rnti), + T_INT (frameP), T_INT (subframeP), - T_INT (0 /* harq_pid always 0? */ ), + T_INT (0 /* harq_pid always 0? */ ), T_BUFFER (&mac->UE_list.DLSCH_pdu[CC_id][0][UE_id].payload[0], TX_req->pdu_length)); if (opt_enabled == 1) { - trace_pdu(1, - (uint8_t *) mac->UE_list.DLSCH_pdu[CC_id][0][(unsigned char) UE_id].payload[0], - TX_req->pdu_length, - UE_id, - 3, - rnti, - frameP, - subframeP, - 0, + trace_pdu(1, + (uint8_t *) mac->UE_list.DLSCH_pdu[CC_id][0][(unsigned char) UE_id].payload[0], + TX_req->pdu_length, + UE_id, + 3, + rnti, + frameP, + subframeP, + 0, 0); - - LOG_D(OPT, "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n", - module_idP, - CC_id, - frameP, - rnti, + LOG_D(OPT, "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n", + module_idP, + CC_id, + frameP, + rnti, TX_req->pdu_length); - } + } } // end else if ((subframeP == 7) && (round_DL < 8)) } // end loop on UE_id } @@ -2623,7 +2580,6 @@ fill_DLSCH_dci(module_id_t module_idP, COMMON_channels_t *cc; eNB_DLSCH_INFO *dlsch_info; UE_TEMPLATE *ue_template; - start_meas(&eNB->fill_DLSCH_dci); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI, VCD_FUNCTION_IN); @@ -2671,17 +2627,17 @@ fill_DLSCH_dci(module_id_t module_idP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti == rnti && dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format != 1) { dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb, - N_RB_DL, - N_RBG, - rballoc_sub); + N_RB_DL, + N_RBG, + rballoc_sub); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type = 0; } else if (dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti == rnti && dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type == 0) { dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb, - N_RB_DL, - N_RBG, - rballoc_sub); + N_RB_DL, + N_RBG, + rballoc_sub); } } } @@ -2757,11 +2713,13 @@ update_ul_dci(module_id_t module_idP, nfapi_hi_dci0_request_t *HI_DCI0_req = &eNB->HI_DCI0_req[CC_idP][subframe]; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list[0]; int limit = HI_DCI0_req->hi_dci0_request_body.number_of_dci + HI_DCI0_req->hi_dci0_request_body.number_of_hi; + for (int i = 0; i < limit; i++, hi_dci0_pdu++) { if (hi_dci0_pdu->pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE && hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti == rntiP) hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = (daiP - 1) & 3; } } + return; } @@ -2838,8 +2796,7 @@ set_ue_dai(sub_frame_t subframeP, void schedule_PCH(module_id_t module_idP, frame_t frameP, - sub_frame_t subframeP) -{ + sub_frame_t subframeP) { /* DCI:format 1A/1C P-RNTI:0xFFFE */ /* PDU:eNB_rrc_inst[Mod_idP].common_channels[CC_id].PCCH_pdu.payload */ uint16_t pcch_sdu_length; @@ -2873,7 +2830,6 @@ schedule_PCH(module_id_t module_idP, uint8_t Lcrbs = 0; uint16_t rb_bit = 168; /* RB bit number value is unsure */ #endif - start_meas(&eNB->schedule_pch); for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) { @@ -2884,6 +2840,7 @@ schedule_PCH(module_id_t module_idP, for (uint16_t i = 0; i < MAX_MOBILES_PER_ENB; i++) { ue_pf_po = &UE_PF_PO[CC_id][i]; + if (ue_pf_po->enable_flag != TRUE) { continue; } @@ -2913,8 +2870,8 @@ schedule_PCH(module_id_t module_idP, CC_id, i, pcch_sdu_length); - #ifdef FORMAT1C + //NO SIB if ((subframeP == 0 || subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) || (subframeP == 5 && ((frameP % 2) != 0 && (frameP % 8) != 1))) { @@ -3109,8 +3066,8 @@ schedule_PCH(module_id_t module_idP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 1; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = getRIV(n_rb_dl, - first_rb, - 4); + first_rb, + 4); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = 0; #endif dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = 4; @@ -3133,7 +3090,6 @@ schedule_PCH(module_id_t module_idP, dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void *)dl_config_pdu, 0, @@ -3145,13 +3101,13 @@ schedule_PCH(module_id_t module_idP, #ifdef FORMAT1C dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 3; // format 1C dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(n_vrb_dl / n_rb_step, - first_rb / n_rb_step, - Lcrbs / n_rb_step); + first_rb / n_rb_step, + Lcrbs / n_rb_step); #else dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(n_rb_dl, - first_rb, - 4); + first_rb, + 4); dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized #endif dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK @@ -3249,8 +3205,7 @@ schedule_PCH(module_id_t module_idP, static int slice_priority_compare(const void *_a, const void *_b, - void *_c) -{ + void *_c) { const int slice_id1 = *(const int *) _a; const int slice_id2 = *(const int *) _b; const module_id_t Mod_id = *(int *) _c; @@ -3265,10 +3220,10 @@ slice_priority_compare(const void *_a, void slice_priority_sort(module_id_t Mod_id, - int slice_list[MAX_NUM_SLICES]) -{ + int slice_list[MAX_NUM_SLICES]) { int i; int n_dl = RC.mac[Mod_id]->slice_info.n_dl; + for (i = 0; i < n_dl; i++) { slice_list[i] = i; } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c index 4657493e5912b1b2eacf1846815059d9535e3460..724710b370319dbb2f8b840294841aa0ba25e553 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c @@ -40,6 +40,7 @@ #include "LAYER2/MAC/mac_extern.h" #include "LAYER2/MAC/eNB_scheduler_fairRR.h" #include "common/utils/LOG/log.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" @@ -49,7 +50,7 @@ #include "T.h" -extern uint8_t nfapi_mode; + #ifdef PHY_TX_THREAD extern volatile int16_t phy_tx_txdataF_end; extern int oai_exit; @@ -841,7 +842,6 @@ schedule_ue_spec_fairRR(module_id_t module_idP, #ifdef DEBUG_eNB_SCHEDULER int k; #endif - start_meas(&eNB->schedule_dlsch); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME (VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_IN); @@ -1012,7 +1012,7 @@ schedule_ue_spec_fairRR(module_id_t module_idP, DevCheck(((eNB_UE_stats->dl_cqi < MIN_CQI_VALUE) || (eNB_UE_stats->dl_cqi > MAX_CQI_VALUE)), eNB_UE_stats->dl_cqi, MIN_CQI_VALUE, MAX_CQI_VALUE); */ - if (nfapi_mode) { + if (NFAPI_MODE != NFAPI_MONOLITHIC) { eNB_UE_stats->dlsch_mcs1 = 10;//cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; } else { eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 1488209dd772176a778e11f216bab16faccf9e6e..0d6b319f9b552bf30b2c6d152b29baee0de3deab 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -36,6 +36,7 @@ #include "LAYER2/MAC/mac_proto.h" #include "common/utils/LOG/log.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" @@ -61,7 +62,7 @@ extern uint16_t frame_cnt; #include "SCHED/sched_common.h" extern RAN_CONTEXT_t RC; -extern uint8_t nfapi_mode; + //------------------------------------------------------------------------------ int @@ -165,6 +166,7 @@ mac_computeRIV(uint16_t N_RB_DL, if (Lcrbs <= (1 + (N_RB_DL >> 1))) { return (N_RB_DL * (Lcrbs - 1)) + RBstart; } + return (N_RB_DL * (N_RB_DL + 1 - Lcrbs)) + (N_RB_DL - 1 - RBstart); } @@ -175,6 +177,7 @@ getQm(uint8_t mcs) { if (mcs < 10) return (2); else if (mcs < 17) return (4); + return (6); } @@ -201,6 +204,7 @@ get_Msg3alloc(COMMON_channels_t *cc, } } else { // TDD subframeAssignment = (int) cc->tdd_Config->subframeAssignment; + if (subframeAssignment == 1) { switch (current_subframe) { case 0: @@ -287,6 +291,7 @@ get_Msg3alloc(COMMON_channels_t *cc, } } } + return; } @@ -313,6 +318,7 @@ get_Msg3allocret(COMMON_channels_t *cc, } } else { subframeAssignment = (int) cc->tdd_Config->subframeAssignment; + if (subframeAssignment == 1) { // original PUSCH in 2, PHICH in 6 (S), ret in 2 // original PUSCH in 3, PHICH in 9, ret in 3 @@ -333,6 +339,7 @@ get_Msg3allocret(COMMON_channels_t *cc, *frame = (current_frame + 1) & 1023; } } + return; } @@ -370,6 +377,7 @@ subframe2harqpid(COMMON_channels_t *cc, break; } } + break; case 2: @@ -519,11 +527,11 @@ pdcchalloc2ulframe(COMMON_channels_t *ccP, } } } + LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, n, ul_frame); - return ul_frame; } @@ -617,6 +625,7 @@ is_UL_sf(COMMON_channels_t *ccP, subframeP, (int) ccP->tdd_Config->subframeAssignment); break; } + return 0; } @@ -664,6 +673,7 @@ ul_subframe2_k_phich(COMMON_channels_t *cc, return 4; else if(ul_subframe == 3 || ul_subframe == 8) return 6; + return 255; case 2: @@ -698,8 +708,10 @@ get_pucch1_absSF(COMMON_channels_t *cc, case 0: if (sf == 0 || sf == 5) return ((10 * f) + sf + 4) % 10240; // ACK/NAK in SF 4,9 same frame + if (sf == 6) return ((10 * nextf) + 2) % 10240; // ACK/NAK in SF 2 next frame + if (sf == 1) return ((10 * f) + 7) % 10240; // ACK/NAK in SF 7 same frame @@ -708,10 +720,13 @@ get_pucch1_absSF(COMMON_channels_t *cc, case 1: if (sf == 5 || sf == 6) return ((10 * nextf) + 2) % 10240; // ACK/NAK in SF 2 next frame + if (sf == 9) return ((10 * nextf) + 3) % 10240; // ACK/NAK in SF 3 next frame + if ((sf == 0) || (sf == 1)) return ((10 * f) + 7) % 10240; // ACK/NAK in SF 7 same frame + if (sf == 4) return ((10 * f) + 8) % 10240; // ACK/NAK in SF 8 same frame @@ -720,8 +735,10 @@ get_pucch1_absSF(COMMON_channels_t *cc, case 2: if (sf == 4 || sf == 5 || sf == 6 || sf == 8) return ((10 * nextf) + 2) % 10240; // ACK/NAK in SF 2 next frame + if (sf == 9) return ((10 * nextf) + 7) % 10240; // ACK/NAK in SF 7 next frame + if (sf == 0 || sf == 1 || sf == 3) return ((10 * f) + 7)% 10240; // ACK/NAK in SF 7 same frame @@ -730,8 +747,10 @@ get_pucch1_absSF(COMMON_channels_t *cc, case 3: if (sf == 5 || sf == 6 || sf == 7 || sf == 8 || sf == 9) return ((10 * nextf) + ((sf - 1) >> 1)) % 10240; // ACK/NAK in 2,3,4 resp. next frame + if (sf == 1) return ((10 * nextf) + 2) % 10240; // ACK/NAK in 2 next frame + if (sf == 0) return ((10 * f) + 4) % 10240; // ACK/NAK in 4 same frame @@ -748,6 +767,7 @@ get_pucch1_absSF(COMMON_channels_t *cc, case 5: if (sf == 0 || sf == 1 || sf == 3 || sf == 4 || sf == 5 || sf == 6 || sf == 7 || sf == 8) return ((10 * nextf) + 2) % 10240; // ACK/NAK in SF 3 next frame + if (sf == 9) return ((10 * (1 + nextf)) + 2) % 10240; // ACK/NAK in SF 2 next frame @@ -756,8 +776,10 @@ get_pucch1_absSF(COMMON_channels_t *cc, case 6: if (sf == 5 || sf == 6) return ((10 * f) + sf + 7) % 10240; // ACK/NAK in SF 2,3 next frame + if (sf == 9) return ((10 * nextf) + 4) % 10240; // ACK/NAK in SF 4 next frame + if (sf == 1 || sf == 0) return ((10 * f) + sf + 7) % 10240; // ACK/NAK in SF 7 same frame @@ -837,6 +859,7 @@ get_srs_pos(COMMON_channels_t *cc, AssertFatal(isrs <= 636, "Isrs out of range %d>636\n", isrs); } + return; } @@ -850,7 +873,6 @@ get_csi_params(COMMON_channels_t *cc, //------------------------------------------------------------------------------ { AssertFatal(cqi_ReportPeriodic != NULL, "cqi_ReportPeriodic is null!\n"); - uint16_t cqi_PMI_ConfigIndex = cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex; uint8_t Jtab[6] = { 0, 2, 2, 3, 4, 4 }; @@ -919,6 +941,7 @@ get_csi_params(COMMON_channels_t *cc, } else { *H = 1; } + return; } @@ -934,7 +957,6 @@ get_dl_cqi_pmi_size_pusch(COMMON_channels_t *cc, int N = Ntab[cc->mib->message.dl_Bandwidth]; int Ltab_uesel[6] = { 0, 6, 9, 13, 15, 18 }; int L = Ltab_uesel[cc->mib->message.dl_Bandwidth]; - AssertFatal(cqi_ReportModeAperiodic != NULL, "cqi_ReportPeriodic is null!\n"); switch (*cqi_ReportModeAperiodic) { @@ -945,10 +967,13 @@ get_dl_cqi_pmi_size_pusch(COMMON_channels_t *cc, if (ri == 1 && cc->p_eNB == 2) return (4 + (N << 1)); + if (ri == 2 && cc->p_eNB == 2) return (8 + N); + if (ri == 1 && cc->p_eNB == 4) return (4 + (N << 2)); + if (ri > 1 && cc->p_eNB == 4) return (8 + (N << 2)); @@ -997,16 +1022,19 @@ get_dl_cqi_pmi_size_pusch(COMMON_channels_t *cc, if (ri == 1 && cc->p_eNB == 2) return (4 + (N << 1) + 0 + 0 + 2); + if (ri == 2 && cc->p_eNB == 2) return (4 + (N << 1) + 4 + (N << 1) + 1); + if (ri == 1 && cc->p_eNB == 4) return (4 + (N << 1) + 0 + 0 + 4); + if (ri >= 2 && cc->p_eNB == 4) return (4 + (N << 1) + 4 + (N << 1) + 4); break; - #if (LTE_RRC_VERSION >= MAKE_VERSION(12, 5, 0)) + case LTE_CQI_ReportModeAperiodic_rm32_v1250: AssertFatal(tmode == 4 || tmode == 6 || tmode == 8 || tmode == 9 || tmode == 10, "Illegal TM (%d) for CQI_ReportModeAperiodic_rm32\n", tmode); @@ -1018,6 +1046,7 @@ get_dl_cqi_pmi_size_pusch(COMMON_channels_t *cc, // Table 5.2.2.6.1-1F/G (36.212) if (ri == 1) return 4; // F + return 7; // G case LTE_CQI_ReportModeAperiodic_rm11_v1310: @@ -1028,16 +1057,18 @@ get_dl_cqi_pmi_size_pusch(COMMON_channels_t *cc, if (ri == 1 && cc->p_eNB == 2) return (4 + 0 + 2); + if (ri == 2 && cc->p_eNB == 2) return (4 + 4 + 1); + if (ri == 1 && cc->p_eNB == 4) return (4 + 0 + 4); + if (ri > 1 && cc->p_eNB == 4) return (4 + 4 + 4); break; #endif /* #if (LTE_RRC_VERSION >= MAKE_VERSION(12, 5, 0)) */ - } AssertFatal(1 == 0, "Shouldn't get here\n"); @@ -1057,7 +1088,6 @@ get_rel8_dl_cqi_pmi_size(UE_sched_ctrl *sched_ctl, // Ltab[6] = {0,log2(15/4/2),log2(25/4/2),log2(50/6/3),log2(75/8/4),log2(100/8/4)}; uint8_t Ltab[6] = { 0, 1, 2, 2, 2, 2 }; uint8_t ri = sched_ctl->periodic_ri_received[CC_idP]; - AssertFatal(cqi_ReportPeriodic != NULL, "cqi_ReportPeriodic is null!\n"); AssertFatal(cqi_ReportPeriodic->present != LTE_CQI_ReportPeriodic_PR_NOTHING, "cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_NOTHING!\n"); AssertFatal(cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present != LTE_CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_NOTHING, @@ -1081,16 +1111,22 @@ get_rel8_dl_cqi_pmi_size(UE_sched_ctrl *sched_ctl, sched_ctl->feedback_cnt[CC_idP] == 0) { // send wideband report every opportunity if wideband reporting mode is selected, else every H opportunities if (no_pmi == 1) return 4; + if (cc->p_eNB == 2 && ri == 1) return 6; + if (cc->p_eNB == 2 && ri == 2) return 8; + if (cc->p_eNB == 4 && ri == 1) return 8; + if (cc->p_eNB == 4 && ri == 2) return 11; + AssertFatal(1 == 0, "illegal combination p %d, ri %d, no_pmi %d\n", cc->p_eNB, ri, no_pmi); } else if (cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present == LTE_CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI) { if (no_pmi == 1 || ri == 1) return (4 + Ltab[cc->mib->message.dl_Bandwidth]); + return (7 + Ltab[cc->mib->message.dl_Bandwidth]); } @@ -1115,7 +1151,6 @@ fill_nfapi_dl_dci_1A(nfapi_dl_config_request_pdu_t *dl_config_pdu, //------------------------------------------------------------------------------ { memset((void *) dl_config_pdu, 0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu)); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; @@ -1155,6 +1190,7 @@ program_dlsch_acknak(module_id_t module_idP, nfapi_ul_config_harq_information *harq_information = NULL; #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 2, 0)) struct LTE_PhysicalConfigDedicated__ext2 *ext2 = UE_list->UE_template[CC_idP][UE_idP].physicalConfigDedicated->ext2; + if (ext2 && ext2->pucch_ConfigDedicated_v1020 && ext2->pucch_ConfigDedicated_v1020->simultaneousPUCCH_PUSCH_r10 && @@ -1297,6 +1333,7 @@ program_dlsch_acknak(module_id_t module_idP, ulsch_harq_information, subframeP); } + if (harq_information) { fill_nfapi_harq_information(module_idP, CC_idP, @@ -1304,6 +1341,7 @@ program_dlsch_acknak(module_id_t module_idP, harq_information, cce_idx); } + return; } @@ -1341,19 +1379,15 @@ fill_nfapi_ulsch_harq_information(module_id_t module_ COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; UE_list_t *UE_list = &eNB->UE_list; int UE_id = find_UE_id(module_idP, rntiP); - nfapi_ul_config_ulsch_harq_information_rel10_t* harq_information_rel10 = &harq_information->harq_information_rel10; - + nfapi_ul_config_ulsch_harq_information_rel10_t *harq_information_rel10 = &harq_information->harq_information_rel10; AssertFatal(UE_id >= 0, "UE_id cannot be found, impossible\n"); AssertFatal(UE_list != NULL, "UE_list is null\n"); - LTE_PhysicalConfigDedicated_t *physicalConfigDedicated = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated; AssertFatal(physicalConfigDedicated != NULL, "physicalConfigDedicated for rnti %x is null\n", rntiP); - struct LTE_PUSCH_ConfigDedicated *puschConfigDedicated = physicalConfigDedicated->pusch_ConfigDedicated; AssertFatal(puschConfigDedicated != NULL, "physicalConfigDedicated->puschConfigDedicated for rnti %x is null\n", rntiP); - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 2, 0)) /* if (UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext2) puschConfigDedicated_v1020 = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext2->pusch_ConfigDedicated_v1020; #endif @@ -1365,10 +1399,8 @@ fill_nfapi_ulsch_harq_information(module_id_t module_ #endif */ #endif - harq_information_rel10->delta_offset_harq = puschConfigDedicated->betaOffset_ACK_Index; harq_information_rel10->tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL10_TAG; - struct LTE_PUCCH_ConfigDedicated *pucch_ConfigDedicated = physicalConfigDedicated->pucch_ConfigDedicated; AssertFatal(pucch_ConfigDedicated != NULL, "pucch_ConfigDedicated is null!\n"); @@ -1389,9 +1421,9 @@ fill_nfapi_ulsch_harq_information(module_id_t module_ else { if (harq_information_rel10->ack_nack_mode == 1) harq_information_rel10->harq_size = get_V_UL_DAI(module_idP, - CC_idP, - rntiP, - subframeP); + CC_idP, + rntiP, + subframeP); else harq_information_rel10->harq_size = 1; } @@ -1404,15 +1436,16 @@ fill_nfapi_ulsch_harq_information(module_id_t module_ } else { if (harq_information_rel10->ack_nack_mode == 1) harq_information_rel10->harq_size = get_V_UL_DAI(module_idP, - CC_idP, - rntiP, - subframeP); + CC_idP, + rntiP, + subframeP); else harq_information_rel10->harq_size = 2; } break; } // get Tmode + return; } @@ -1439,11 +1472,13 @@ getNp(int dl_Bandwidth, AssertFatal(dl_Bandwidth < 6, "dl_Bandwidth %d>5\n", dl_Bandwidth); if (nCCE >= Np[dl_Bandwidth][2]) { - return(Np[dl_Bandwidth][2+plus1]); + return(Np[dl_Bandwidth][2+plus1]); } - if (nCCE >= Np[dl_Bandwidth][1]) { + + if (nCCE >= Np[dl_Bandwidth][1]) { return(Np[dl_Bandwidth][1+plus1]); } + return(Np[dl_Bandwidth][0+plus1]); } @@ -1459,17 +1494,15 @@ fill_nfapi_harq_information(module_id_t module_idP, eNB_MAC_INST *eNB = RC.mac[module_idP]; COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; UE_list_t *UE_list = &eNB->UE_list; - int UE_id = find_UE_id(module_idP, rntiP); - AssertFatal(UE_id >= 0, "UE_id cannot be found, impossible\n"); AssertFatal(UE_list != NULL, "UE_list is null\n"); harq_information->harq_information_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL11_TAG; harq_information->harq_information_rel11.num_ant_ports = 1; - LTE_PhysicalConfigDedicated_t *physicalConfigDedicated = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated; struct LTE_PUCCH_ConfigDedicated *pucch_ConfigDedicated = NULL; + if (physicalConfigDedicated != NULL) pucch_ConfigDedicated = physicalConfigDedicated->pucch_ConfigDedicated; switch (get_tmode(module_idP, @@ -1531,6 +1564,7 @@ fill_nfapi_harq_information(module_id_t module_idP, break; } // get Tmode + return; } @@ -1550,13 +1584,11 @@ fill_nfapi_uci_acknak(module_id_t module_idP, nfapi_ul_config_request_body_t *ul_req_body = &ul_req->ul_config_request_body; nfapi_ul_config_request_pdu_t *ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus]; memset((void *) ul_config_pdu, 0, sizeof(nfapi_ul_config_request_pdu_t)); - ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE; ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_ul_config_uci_harq_pdu)); ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG; ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.handle = 0; // don't know how to use this ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti = rntiP; - fill_nfapi_harq_information(module_idP, CC_idP, rntiP, @@ -1570,7 +1602,6 @@ fill_nfapi_uci_acknak(module_id_t module_idP, ackNAK_absSF % 10, cce_idxP, ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.n_pucch_1_0); - ul_req_body->number_of_pdus++; ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; @@ -1609,7 +1640,6 @@ fill_nfapi_dlsch_config(eNB_MAC_INST *eNB, { nfapi_dl_config_request_pdu_t *dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu)); dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG; @@ -1635,7 +1665,6 @@ fill_nfapi_dlsch_config(eNB_MAC_INST *eNB, dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = transmission_mode; dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = num_bf_prb_per_subband; dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = num_bf_vector; - dl_req->number_pdu++; return; } @@ -1650,11 +1679,9 @@ fill_nfapi_tx_req(nfapi_tx_request_body_t *tx_req_body, //------------------------------------------------------------------------------ { nfapi_tx_request_pdu_t *TX_req = &tx_req_body->tx_pdu_list[tx_req_body->number_of_pdus]; - LOG_D(MAC, "Filling TX_req %d for pdu length %d\n", tx_req_body->number_of_pdus, pdu_length); - TX_req->pdu_length = pdu_length; TX_req->pdu_index = pdu_index; TX_req->num_segments = 1; @@ -1686,10 +1713,8 @@ fill_nfapi_ulsch_config_request_rel8(nfapi_ul_config_request_pdu_t *ul_config_pd uint8_t ul_tx_mode, uint8_t current_tx_nb, uint8_t n_srs, - uint16_t size) -{ + uint16_t size) { uint8_t ri_size = 0; - memset((void *) ul_config_pdu, 0, sizeof(nfapi_ul_config_request_pdu_t)); ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE; ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_ul_config_ulsch_pdu)); @@ -1728,14 +1753,14 @@ fill_nfapi_ulsch_config_request_rel8(nfapi_ul_config_request_pdu_t *ul_config_pd if (cc->p_eNB <= 2 && (tmode == 3 || tmode == 4 || tmode == 8 || tmode == 9 || tmode == 10)) ri_size = 1; else if (cc->p_eNB <= 2) ri_size = 0; else if (cc->p_eNB == 4) ri_size = 2; - ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].ri_size = ri_size; + ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].ri_size = ri_size; AssertFatal(physicalConfigDedicated->cqi_ReportConfig != NULL,"physicalConfigDedicated->cqi_ReportConfig is null!\n"); AssertFatal(physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic != NULL,"physicalConfigDedicated->cqi_ReportModeAperiodic is null!\n"); AssertFatal(physicalConfigDedicated->pusch_ConfigDedicated != NULL,"physicalConfigDedicated->puschConfigDedicated is null!\n"); - nfapi_ul_config_cqi_ri_information_rel9_t *ri_information = &ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9; int max_ri = (1 << ri_information->aperiodic_cqi_pmi_ri_report.cc[0].ri_size); + for (int ri = 0; ri < max_ri; ri++) { ri_information->aperiodic_cqi_pmi_ri_report.cc[0].dl_cqi_pmi_size[ri] = get_dl_cqi_pmi_size_pusch(cc, @@ -1743,9 +1768,11 @@ fill_nfapi_ulsch_config_request_rel8(nfapi_ul_config_request_pdu_t *ul_config_pd 1 + ri, physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic); } + ri_information->delta_offset_cqi = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index; ri_information->delta_offset_ri = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index; } + return; } @@ -1862,6 +1889,7 @@ mpdcch_sf_condition(eNB_MAC_INST *eNB, AssertFatal(T > 0, "T is 0!\n"); if (((10 * frameP) + subframeP) % T == 0) return 1; + return 0; } @@ -1884,16 +1912,19 @@ narrowband_to_first_rb(COMMON_channels_t *cc, case 1: // 15 PRBs N_NB=2, i_0=1 if (nb_index > 0) return 1; + return 0; case 2: // 25 PRBs, N_NB=4, i_0=0 if (nb_index > 1) return (1 + (6 * nb_index)); + return ((6 * nb_index)); case 4: // 75 PRBs, N_NB=12, i_0=1 if (nb_index > 5) return (2 + (6 * nb_index)); + return (1 + (6 * nb_index)); default: @@ -1901,6 +1932,7 @@ narrowband_to_first_rb(COMMON_channels_t *cc, (int) cc->mib->message.dl_Bandwidth); break; } + return 0; } #endif @@ -1927,6 +1959,7 @@ init_ue_sched_info(void) } } } + return; } @@ -2011,7 +2044,7 @@ UE_RNTI(module_id_t mod_idP, if (!RC.mac || !RC.mac[mod_idP]) return 0; rnti_t rnti = RC.mac[mod_idP]->UE_list.UE_template[UE_PCCID(mod_idP, - ue_idP)][ue_idP].rnti; + ue_idP)][ue_idP].rnti; if (rnti > 0) { return (rnti); @@ -2076,7 +2109,6 @@ get_aggregation(uint8_t bw_index, cqi, bw_index, dci_fmt); - return 1 << aggregation; } @@ -2101,6 +2133,7 @@ dump_ue_list(UE_list_t *listP, listP->next_ul[j]); } } + return; } @@ -2111,22 +2144,20 @@ add_new_ue(module_id_t mod_idP, rnti_t rntiP, int harq_pidP #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , uint8_t rach_resource_type + , uint8_t rach_resource_type #endif - ) + ) //------------------------------------------------------------------------------ { int UE_id; int i, j; UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; - LOG_D(MAC, "[eNB %d, CC_id %d] Adding UE with rnti %x (next avail %d, num_UEs %d)\n", mod_idP, cc_idP, rntiP, UE_list->avail, UE_list->num_UEs); - dump_ue_list(UE_list, 0); for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { @@ -2135,7 +2166,6 @@ add_new_ue(module_id_t mod_idP, UE_id = i; memset(&UE_list->UE_template[cc_idP][UE_id], 0, sizeof(UE_TEMPLATE)); - UE_list->UE_template[cc_idP][UE_id].rnti = rntiP; UE_list->UE_template[cc_idP][UE_id].configured = FALSE; UE_list->numactiveCCs[UE_id] = 1; @@ -2145,14 +2175,12 @@ add_new_ue(module_id_t mod_idP, UE_list->ordered_ULCCids[0][UE_id] = cc_idP; UE_list->num_UEs++; UE_list->active[UE_id] = TRUE; - #if defined(USRP_REC_PLAY) // not specific to record/playback ? UE_list->UE_template[cc_idP][UE_id].pre_assigned_mcs_ul = 0; #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) UE_list->UE_template[cc_idP][UE_id].rach_resource_type = rach_resource_type; #endif - memset((void *) &UE_list->UE_sched_ctrl[UE_id], 0, sizeof(UE_sched_ctrl)); @@ -2223,13 +2251,13 @@ rrc_mac_remove_ue(module_id_t mod_idP, if (UE_list->head == UE_id) UE_list->head = UE_list->next[UE_id]; else UE_list->next[prev(UE_list, - UE_id, - 0)] = UE_list->next[UE_id]; + UE_id, + 0)] = UE_list->next[UE_id]; if (UE_list->head_ul == UE_id) UE_list->head_ul = UE_list->next_ul[UE_id]; else UE_list->next_ul[prev(UE_list, - UE_id, - 0)] = UE_list->next_ul[UE_id]; + UE_id, + 0)] = UE_list->next_ul[UE_id]; // clear all remaining pending transmissions /* UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID0] = 0; @@ -2244,7 +2272,6 @@ rrc_mac_remove_ue(module_id_t mod_idP, memset (&UE_list->UE_template[pCC_id][UE_id], 0, sizeof(UE_TEMPLATE)); - ue_stats = &UE_list->eNB_UE_stats[pCC_id][UE_id]; ue_stats->total_rbs_used = 0; ue_stats->total_rbs_used_retx = 0; @@ -2513,6 +2540,7 @@ UE_is_to_be_scheduled(module_id_t module_idP, UE_template->ul_buffer_info[LCGID0], UE_template->ul_SR); return 1; } + return 0; } @@ -2537,9 +2565,8 @@ get_tmode(module_id_t module_idP, "antennaInfo (mod_id %d) is null for CCId %d, UEid %d, physicalConfigDedicated %p\n", module_idP, CC_idP, - UE_idP, + UE_idP, physicalConfigDedicated); - AssertFatal(physicalConfigDedicated->antennaInfo->present != LTE_PhysicalConfigDedicated__antennaInfo_PR_NOTHING, "antennaInfo (mod_id %d, CC_id %d) is set to NOTHING\n", module_idP, @@ -2799,6 +2826,7 @@ allocate_prbs_sub(int nb_rb, } else { nb_rb -= 2; } + break; case 50: @@ -2807,6 +2835,7 @@ allocate_prbs_sub(int nb_rb, } else { nb_rb -= 3; } + break; case 100: @@ -2888,8 +2917,7 @@ init_CCE_table(int module_idP, } */ void -init_CCE_table(int *CCE_table) -{ +init_CCE_table(int *CCE_table) { memset(CCE_table, 0, 800 * sizeof(int)); } @@ -2935,12 +2963,14 @@ get_nCCE_offset(int *CCE_table, for (l = 0; l < L; l++) { CCE_table[(m * L) + l] = 1; } + return (m * L); } } return -1; } + // Find first available in ue specific search space // according to procedure in Section 9.1.1 of 36.213 (v. 8.6) // compute Yk @@ -2949,6 +2979,7 @@ get_nCCE_offset(int *CCE_table, for (i = 0; i <= subframe; i++) { Yk = (Yk * 39827) % 65537; } + Yk = Yk % (nCCE / L); switch (L) { @@ -2992,6 +3023,7 @@ get_nCCE_offset(int *CCE_table, for (l = 0; l < L; l++) { CCE_table[(((Yk + m) % (nCCE / L)) * L) + l] = 1; } + return (((Yk + m) % (nCCE / L)) * L); } } @@ -3025,6 +3057,7 @@ dump_CCE_table(int *CCE_table, for (i = 0; i <= subframe; i++) { Yk = (Yk * 39827) % 65537; } + Yk = Yk % (nCCE / L); switch (L) { @@ -3044,11 +3077,11 @@ dump_CCE_table(int *CCE_table, } LOG_I(PHY, "rnti %x, Yk*L = %u, nCCE %d (nCCE/L %d),nb_cand*L %d\n", - rnti, - Yk * L, - nCCE, - nCCE / L, - nb_candidates * L); + rnti, + Yk * L, + nCCE, + nCCE / L, + nb_candidates * L); } //------------------------------------------------------------------------------ @@ -3068,6 +3101,7 @@ getnquad(COMMON_channels_t *cc, if (((phich_resource * N_RB_DL) % 48) > 0) { Ngroup_PHICH++; } + if (cc->Ncp == 1) { Ngroup_PHICH <<= 1; } @@ -3131,36 +3165,42 @@ getmi(COMMON_channels_t *cc, if (subframe == 0 || subframe == 5) { return 2; } + return 1; case 1: if (subframe == 0 || subframe == 5) { return 0; } + return 1; case 2: if (subframe == 3 || subframe == 8) { return 0; } + return 1; case 3: if (subframe == 0 || subframe == 8 || subframe == 9) { return 1; } + return 0; case 4: if (subframe == 8 || subframe == 9) { return 1; } + return 0; case 5: if (subframe == 8) { return 1; } + return 0; case 6: @@ -3169,6 +3209,7 @@ getmi(COMMON_channels_t *cc, default: break; } + return 0; } @@ -3225,14 +3266,13 @@ allocate_CCEs(int module_idP, DL_req->number_dci, HI_DCI0_req->number_of_dci); DL_req->number_pdcch_ofdm_symbols = 1; - try_again: - init_CCE_table(CCE_table); nCCE = 0; for (i = 0, idci = 0; i < DL_req->number_pdu; i++) { dl_config_pduLoop = &dl_config_pdu[i]; + // allocate DL common DCIs first if (dl_config_pduLoop->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE && dl_config_pduLoop->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 2) { @@ -3274,6 +3314,7 @@ try_again: for (j = 0; j <= i; j++) { dl_config_pduLoop = &dl_config_pdu[j]; + if (dl_config_pduLoop->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) LOG_D(MAC, "DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", j, @@ -3285,6 +3326,7 @@ try_again: dl_config_pduLoop->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, nCCE, nCCE_max, DL_req->number_pdcch_ofdm_symbols); } + //dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,1<<dci_alloc->L); return -1; } @@ -3316,6 +3358,7 @@ try_again: // no try to allocate UL DCIs for (i = 0; i < HI_DCI0_req->number_of_dci + HI_DCI0_req->number_of_hi; i++) { hi_dci0_pduLoop = &hi_dci0_pdu[i]; + // allocate UL DCIs if (hi_dci0_pdu[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) { LOG_D(MAC, "Trying to allocate format 0 DCI %d/%d (%d,%d) : rnti %x, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", @@ -3355,6 +3398,7 @@ try_again: for (j = 0; j <= i; j++) { hi_dci0_pduLoop = &hi_dci0_pdu[j]; + if (hi_dci0_pdu[j].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) LOG_D(MAC, "DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", j, @@ -3366,6 +3410,7 @@ try_again: hi_dci0_pduLoop->dci_pdu.dci_pdu_rel8.aggregation_level, nCCE, nCCE_max, DL_req->number_pdcch_ofdm_symbols); } + //dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,1<<dci_alloc->L); return -1; } @@ -3395,6 +3440,7 @@ try_again: for (i = 0; i < DL_req->number_pdu; i++) { dl_config_pduLoop = &dl_config_pdu[i]; + // allocate DL UE specific DCIs if ((dl_config_pdu[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) && (dl_config_pduLoop->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 1)) { @@ -3435,6 +3481,7 @@ try_again: for (j = 0; j <= i; j++) { dl_config_pduLoop = &dl_config_pdu[j]; + if (dl_config_pduLoop->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) LOG_D(MAC, "DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", j, @@ -3448,6 +3495,7 @@ try_again: nCCE_max, DL_req->number_pdcch_ofdm_symbols); } + //dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,1<<dci_alloc->L); return -1; } @@ -3489,6 +3537,7 @@ try_again: idci++; } } // for i = 0 ... num_DL_DCIs + return 0; } @@ -3503,7 +3552,6 @@ has_ul_grant(module_id_t module_idP, nfapi_ul_config_request_body_t *ul_req = &RC.mac[module_idP]->UL_req_tmp[CC_idP][absSFP % 10].ul_config_request_body; nfapi_ul_config_request_pdu_t *ul_config_pdu = &ul_req->ul_config_pdu_list[0]; uint8_t pdu_type; - LOG_D(MAC, "Checking for rnti %x UL grant in subframeP %d (num pdu %d)\n", rnti, absSFP % 10, @@ -3593,6 +3641,7 @@ CCE_allocation_infeasible(int module_idP, if (allocate_CCEs(module_idP, CC_idP, 0, subframe, 0) != -1) res = FALSE; + DL_req->number_pdu--; } } else { // ue-specific UL DCI @@ -3607,6 +3656,7 @@ CCE_allocation_infeasible(int module_idP, if (allocate_CCEs(module_idP, CC_idP, 0, subframe, 0) != -1) res = FALSE; + HI_DCI0_req->number_of_dci--; } } @@ -3625,6 +3675,7 @@ get_retransmission_timing(LTE_TDD_Config_t *tdd_Config, if (*subframeP > 1) { *frameP = (*frameP + 1) % 1024; } + *subframeP = (*subframeP + 8) % 10; } else { switch (tdd_Config->subframeAssignment) { //TODO fill in other TDD configs @@ -3649,9 +3700,11 @@ get_retransmission_timing(LTE_TDD_Config_t *tdd_Config, *subframeP, tdd_Config->subframeAssignment); } + break; } } + return; } @@ -3717,34 +3770,39 @@ ul_ACK_subframe2M(LTE_TDD_Config_t *tdd_Config, if (tdd_Config == NULL) { return 1; } + switch (tdd_Config->subframeAssignment) { case 1: return 1; // don't ACK special subframe for now - /* - if (subframe == 2) { // ACK subframes 5 and 6 - return(2); - } else if (subframe == 3) { // ACK subframe 9 - return(1); // To be updated - } else if (subframe == 7) { // ACK subframes 0 and 1 - return(2); // To be updated - } else if (subframe == 8) { // ACK subframe 4 - return(1); // To be updated - } else { - AssertFatal(1==0,"illegal subframe %d for tdd_config %ld\n", - subframe,tdd_Config->subframeAssignment); - } - break; - */ + + /* + if (subframe == 2) { // ACK subframes 5 and 6 + return(2); + } else if (subframe == 3) { // ACK subframe 9 + return(1); // To be updated + } else if (subframe == 7) { // ACK subframes 0 and 1 + return(2); // To be updated + } else if (subframe == 8) { // ACK subframe 4 + return(1); // To be updated + } else { + AssertFatal(1==0,"illegal subframe %d for tdd_config %ld\n", + subframe,tdd_Config->subframeAssignment); + } + break; + */ case 3: if (subframe == 2) { // ACK subframes 5 and 6 return 2; // should be 3 } + if (subframe == 3) { // ACK subframes 7 and 8 return 2; // To be updated } + if (subframe == 4) { // ACK subframes 9 and 0 return 2; } + AssertFatal(1==0,"illegal subframe %d for tdd_config %ld\n", subframe, tdd_Config->subframeAssignment); @@ -3754,9 +3812,11 @@ ul_ACK_subframe2M(LTE_TDD_Config_t *tdd_Config, if (subframe == 2) { // ACK subframes 0,4 and 5 return 3; // should be 4 } + if (subframe == 3) { // ACK subframes 6,7,8 and 9 return 4; } + AssertFatal(1==0,"illegal subframe %d for tdd_config %ld\n", subframe, tdd_Config->subframeAssignment); @@ -3766,6 +3826,7 @@ ul_ACK_subframe2M(LTE_TDD_Config_t *tdd_Config, if (subframe == 2) { // ACK subframes 0,3,4,5,6,7,8 and 9 return 8; // should be 3 } + AssertFatal(1==0,"illegal subframe %d for tdd_config %ld\n", subframe, tdd_Config->subframeAssignment); @@ -3790,14 +3851,18 @@ ul_ACK_subframe2dl_subframe(LTE_TDD_Config_t *tdd_Config, case 3: if (subframe == 2) { // ACK subframes 5 and 6 if (ACK_index == 2) return 1; + return (5 + ACK_index); } + if (subframe == 3) { // ACK subframes 7 and 8 return (7 + ACK_index); // To be updated } + if (subframe == 4) { // ACK subframes 9 and 0 return ((9 + ACK_index) % 10); } + AssertFatal(1==0, "illegal subframe %d for tdd_config->subframeAssignment %ld\n", subframe, tdd_Config->subframeAssignment); @@ -3808,11 +3873,14 @@ ul_ACK_subframe2dl_subframe(LTE_TDD_Config_t *tdd_Config, //if (ACK_index==2) // return(1); TBC if (ACK_index == 2) return 0; + return (4 + ACK_index); } + if (subframe == 3) { // ACK subframes 6, 7 8 and 9 return (6 + ACK_index); // To be updated } + AssertFatal(1 == 0, "illegal subframe %d for tdd_config %ld\n", subframe, tdd_Config->subframeAssignment); @@ -3822,20 +3890,25 @@ ul_ACK_subframe2dl_subframe(LTE_TDD_Config_t *tdd_Config, if (subframe == 2) { // ACK subframes 5 and 6 return (5 + ACK_index); } + if (subframe == 3) { // ACK subframe 9 return 9; // To be updated } + if (subframe == 7) { // ACK subframes 0 and 1 return ACK_index; // To be updated } + if (subframe == 8) { // ACK subframe 4 return 4; // To be updated } + AssertFatal(1 == 0, "illegal subframe %d for tdd_config %ld\n", subframe, tdd_Config->subframeAssignment); break; } + return 0; } @@ -3867,15 +3940,16 @@ extract_harq(module_id_t mod_idP, sub_frame_t subframe_tx; int frame_tx; uint8_t harq_pid; - #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) LTE_PhysicalConfigDedicated_t *physicalConfigDedicated = UE_list->UE_template[pCCid][UE_id].physicalConfigDedicated; + if (physicalConfigDedicated != NULL && physicalConfigDedicated->pucch_ConfigDedicated != NULL && physicalConfigDedicated->ext7 != NULL && physicalConfigDedicated->ext7->pucch_ConfigDedicated_r13 != NULL && ((physicalConfigDedicated->ext7->pucch_ConfigDedicated_r13->spatialBundlingPUCCH_r13 && format == 0) || (physicalConfigDedicated->ext7->pucch_ConfigDedicated_r13->spatialBundlingPUSCH_r13 && format == 1))) { spatial_bundling = 1; } + #endif for (i = 0; i < numCC; i++) { @@ -3883,6 +3957,7 @@ extract_harq(module_id_t mod_idP, i, UE_id); } + if (cc->tdd_Config) { harq_indication_tdd = (nfapi_harq_indication_tdd_rel13_t *) harq_indication; // pdu = &harq_indication_tdd->harq_tb_n[0]; @@ -3897,8 +3972,8 @@ extract_harq(module_id_t mod_idP, for (m=0; m<M; m++) { subframe_tx = ul_ACK_subframe2dl_subframe(cc->tdd_Config, - subframeP, - m); + subframeP, + m); if (frameP==1023&&subframeP>5) frame_tx=-1; else frame_tx = subframeP < 4 ? frameP -1 : frameP; @@ -3943,8 +4018,8 @@ extract_harq(module_id_t mod_idP, LOG_I(RRC, "put UE %x into freeList\n", rnti); put_UE_in_freelist(mod_idP, - rnti, - 1); + rnti, + 1); } } } @@ -3973,6 +4048,7 @@ extract_harq(module_id_t mod_idP, ra[ra_i].rnti); } } + break; } } @@ -4017,7 +4093,7 @@ extract_harq(module_id_t mod_idP, // In case of nFAPI, sometimes timing of eNB and UE become different. // So if nfapi_mode == 2(VNF), this function don't check assertion to avoid process exit. - if (nfapi_mode != 2) { + if (NFAPI_MODE != NFAPI_MODE_VNF) { AssertFatal(sched_ctl->round[CC_idP][harq_pid] < 8, "Got ACK/NAK for inactive harq_pid %d for UE %d/%x\n", harq_pid, UE_id, @@ -4037,11 +4113,9 @@ extract_harq(module_id_t mod_idP, harq_pid, UE_id, rnti); - LOG_D(MAC, "Received %d for harq_pid %d\n", pdu[0], harq_pid); - RA_t *ra = &eNB->common_channels[CC_idP].ra[0]; for (uint8_t ra_i = 0; ra_i < NB_RA_PROC_MAX; ra_i++) { @@ -4066,6 +4140,7 @@ extract_harq(module_id_t mod_idP, ra[ra_i].rnti); } } + break; } } @@ -4441,6 +4516,7 @@ extract_harq(module_id_t mod_idP, UE_id, rnti); } + j++; } else { AssertFatal(1 == 0, "Illegal value for spatial_bundling %d\n", @@ -4460,6 +4536,7 @@ extract_harq(module_id_t mod_idP, break; } } + return; } @@ -4481,7 +4558,6 @@ extract_pucch_csi(module_id_t mod_idP, uint8_t Ltab[6] = { 0, 2, 4, 4, 4, 4 }; uint8_t Jtab[6] = { 0, 2, 2, 3, 4, 4 }; int feedback_cnt; - AssertFatal(UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated != NULL, "physicalConfigDedicated is null for UE %d\n", UE_id); AssertFatal(UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->cqi_ReportConfig != NULL, "cqi_ReportConfig is null for UE %d\n", @@ -4496,7 +4572,6 @@ extract_pucch_csi(module_id_t mod_idP, uint16_t Npd, N_OFFSET_CQI; int H, K, bandwidth_part, L, Lmask; int ri = sched_ctl->periodic_ri_received[CC_idP]; - get_csi_params(cc, cqi_ReportPeriodic, &Npd, @@ -4530,7 +4605,7 @@ extract_pucch_csi(module_id_t mod_idP, // note: need to check TM8-10 without PMI/RI or with 1 antenna port (see Section 5.2.3.3.1 from 36.213) no_pmi = 0; break; -} + } if (cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present == LTE_CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_widebandCQI || feedback_cnt == 0) { @@ -4572,6 +4647,7 @@ extract_pucch_csi(module_id_t mod_idP, sched_ctl->periodic_subband_cqi[CC_idP][(bandwidth_part * L) + ((pdu[0] >> 7) & Lmask)] = pdu[0] & 0xF; } } + return; } @@ -4760,7 +4836,6 @@ extract_pusch_csi(module_id_t mod_idP, } sched_ctl->dl_cqi[CC_idP] = sched_ctl->aperiodic_wideband_cqi0[CC_idP]; - break; case LTE_CQI_ReportModeAperiodic_rm31: @@ -4835,8 +4910,8 @@ extract_pusch_csi(module_id_t mod_idP, } break; - #if (LTE_RRC_VERSION >= MAKE_VERSION(12, 5, 0)) + case LTE_CQI_ReportModeAperiodic_rm32_v1250: AssertFatal(tmode == 4 || tmode == 5 || tmode == 6 || tmode == 8 || tmode == 9 || tmode == 10, "Illegal transmission mode %d for CQI_ReportModeAperiodic_rm32\n", @@ -4844,8 +4919,8 @@ extract_pusch_csi(module_id_t mod_idP, AssertFatal(1 == 0, "CQI_ReportModeAperiodic_rm32 to be done\n"); break; #endif - #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 1, 0)) + case LTE_CQI_ReportModeAperiodic_rm10_v1310: AssertFatal(tmode == 1 || tmode == 2 || tmode == 3 || tmode == 7, "Illegal transmission mode %d for CQI_ReportModeAperiodic_rm10\n", tmode); @@ -4859,8 +4934,8 @@ extract_pusch_csi(module_id_t mod_idP, AssertFatal(1 == 0, "CQI_ReportModeAperiodic_rm11 to be done\n"); break; #endif /* #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 1, 0)) */ - } + return; } @@ -4929,6 +5004,7 @@ cqi_indication(module_id_t mod_idP, sched_ctl->timing_advance = rel9->timing_advance; sched_ctl->timing_advance_r9 = rel9->timing_advance_r9; } + return; } @@ -4961,6 +5037,7 @@ SR_indication(module_id_t mod_idP, UE_id, cc_idP); } + UE_list->UE_template[cc_idP][UE_id].ul_SR = 1; UE_list->UE_template[cc_idP][UE_id].ul_active = TRUE; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SR_INDICATION, 1); @@ -4976,6 +5053,7 @@ SR_indication(module_id_t mod_idP, UE_id, cc_idP); } + return; } @@ -5031,14 +5109,17 @@ nack_or_dtx_reported(COMMON_channels_t *cc, if (hi->harq_data[0].bundling.value_0 != 1) //only bundling is used for tdd for now return 1; } + return 0; } nfapi_harq_indication_fdd_rel13_t *hi = &harq_pdu->harq_indication_fdd_rel13; + for (i = 0; i < hi->number_of_ack_nack; hi++) { if (hi->harq_tb_n[i] != 1) return 1; } + return 0; } @@ -5082,8 +5163,7 @@ harq_indication(module_id_t mod_idP, subframeP, (void *) &harq_pdu->harq_indication_tdd_rel13, channel); - } - else { + } else { extract_harq(mod_idP, CC_idP, UE_id, @@ -5092,12 +5172,14 @@ harq_indication(module_id_t mod_idP, (void *) &harq_pdu->harq_indication_fdd_rel13, channel); } + /* don't care about cqi reporting if NACK/DTX is there */ if (channel == 0 && !nack_or_dtx_reported(cc, - harq_pdu)) { + harq_pdu)) { sched_ctl->pucch1_snr[CC_idP] = ul_cqi; sched_ctl->pucch1_cqi_update[CC_idP] = 1; } + return; } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index efe60be84f2997dee3b2ef958cf96484a33f419e..7d24cc2494c37ac4277dd274e89c36a84ea4c177 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -36,6 +36,7 @@ #include "LAYER2/MAC/mac_extern.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" @@ -70,7 +71,7 @@ extern int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req); extern void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset); extern uint16_t sfnsf_add_subframe(uint16_t frameP, uint16_t subframeP, int offset); extern int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req); -extern uint8_t nfapi_mode; + // This table holds the allowable PRB sizes for ULSCH transmissions uint8_t rb_table[34] = { @@ -120,7 +121,6 @@ rx_sdu(const module_id_t enb_mod_idP, eNB_MAC_INST *mac = NULL; UE_list_t *UE_list = NULL; rrc_eNB_ue_context_t *ue_contextP = NULL; - /* Init */ current_rnti = rntiP; UE_id = find_UE_id(enb_mod_idP, current_rnti); @@ -130,19 +130,16 @@ rx_sdu(const module_id_t enb_mod_idP, memset(rx_ces, 0, MAX_NUM_CE * sizeof(unsigned char)); memset(rx_lcids, 0, NB_RB_MAX * sizeof(unsigned char)); memset(rx_lengths, 0, NB_RB_MAX * sizeof(unsigned short)); - start_meas(&mac->rx_ulsch_sdu); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU, 1); if (opt_enabled == 1) { trace_pdu(DIRECTION_UPLINK, sduP, sdu_lenP, 0, WS_C_RNTI, current_rnti, frameP, subframeP, 0, 0); - LOG_D(OPT, "[eNB %d][ULSCH] Frame %d rnti %x with size %d\n", - enb_mod_idP, - frameP, - current_rnti, - sdu_lenP); + enb_mod_idP, + frameP, + current_rnti, + sdu_lenP); } if (UE_id != -1) { @@ -156,7 +153,6 @@ rx_sdu(const module_id_t enb_mod_idP, current_rnti, UE_id, ul_cqi); - AssertFatal(UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] < 8, "round >= 8\n"); if (sduP != NULL) { @@ -171,7 +167,6 @@ rx_sdu(const module_id_t enb_mod_idP, UE_list->UE_sched_ctrl[UE_id].ta_update = (UE_list->UE_sched_ctrl[UE_id].ta_update * 3 + timing_advance) / 4; UE_list->UE_sched_ctrl[UE_id].pusch_snr[CC_idP] = ul_cqi; UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors = 0; - first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync > 0) { @@ -185,18 +180,17 @@ rx_sdu(const module_id_t enb_mod_idP, if (UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes < 0) { UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes = 0; } - } else { // sduP == NULL => error LOG_W(MAC, "[eNB %d][PUSCH %d] CC_id %d %d.%d ULSCH in error in round %d, ul_cqi %d, UE_id %d, RNTI %x\n", - enb_mod_idP, - harq_pid, - CC_idP, - frameP, - subframeP, - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], - ul_cqi, - UE_id, - current_rnti); + enb_mod_idP, + harq_pid, + CC_idP, + frameP, + subframeP, + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], + ul_cqi, + UE_id, + current_rnti); if (ul_cqi > 200) { // too high energy pattern UE_list->UE_sched_ctrl[UE_id].pusch_snr[CC_idP] = ul_cqi; @@ -221,28 +215,22 @@ rx_sdu(const module_id_t enb_mod_idP, if (find_RA_id(enb_mod_idP, CC_idP, current_rnti) != -1) { cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); } - } else { UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid]++; } first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; - /* Program NACK for PHICH */ LOG_D(MAC, "Programming PHICH NACK for rnti %x harq_pid %d (first_rb %d)\n", - current_rnti, - harq_pid, - first_rb); - + current_rnti, + harq_pid, + first_rb); nfapi_hi_dci0_request_t *hi_dci0_req = NULL; uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_idP], subframeP); hi_dci0_req = &mac->HI_DCI0_req[CC_idP][(subframeP + sf_ahead_dl) % 10]; - nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; - memset((void *) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_hi_pdu); hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; @@ -256,46 +244,43 @@ rx_sdu(const module_id_t enb_mod_idP, hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; return; } - // if UE_id == -1 - } else if ((RA_id = find_RA_id(enb_mod_idP, CC_idP, current_rnti)) != -1) { // Check if this is an RA process for the rnti + // if UE_id == -1 + } else if ((RA_id = find_RA_id(enb_mod_idP, CC_idP, current_rnti)) != -1) { // Check if this is an RA process for the rnti RA_t *ra = (RA_t *) &(mac->common_channels[CC_idP].ra[RA_id]); - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + if (ra->rach_resource_type > 0) { harq_pid = 0; } -#endif +#endif AssertFatal(mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx > 1, "maxHARQ %d should be greater than 1\n", (int) mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx); - LOG_D(MAC, "[eNB %d][PUSCH %d] CC_id %d [RAPROC Msg3] Received ULSCH sdu round %d from PHY (rnti %x, RA_id %d) ul_cqi %d\n", - enb_mod_idP, - harq_pid, - CC_idP, - ra->msg3_round, - current_rnti, - RA_id, - ul_cqi); - + enb_mod_idP, + harq_pid, + CC_idP, + ra->msg3_round, + current_rnti, + RA_id, + ul_cqi); first_rb = ra->msg3_first_rb; if (sduP == NULL) { // we've got an error on Msg3 LOG_D(MAC, "[eNB %d] CC_id %d, RA %d ULSCH in error in round %d/%d\n", - enb_mod_idP, - CC_idP, - RA_id, - ra->msg3_round, - (int) mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx); + enb_mod_idP, + CC_idP, + RA_id, + ra->msg3_round, + (int) mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx); if (ra->msg3_round >= mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx - 1) { cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); } else { // first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; // UE_id = -1 !!!! ra->msg3_round++; - /* Prepare handling of retransmission */ get_Msg3allocret(&mac->common_channels[CC_idP], ra->Msg3_subframe, @@ -303,7 +288,6 @@ rx_sdu(const module_id_t enb_mod_idP, &ra->Msg3_frame, &ra->Msg3_subframe); // prepare handling of retransmission - add_msg3(enb_mod_idP, CC_idP, ra, frameP, subframeP); } @@ -312,7 +296,6 @@ rx_sdu(const module_id_t enb_mod_idP, } } else { LOG_W(MAC, "Cannot find UE or RA corresponding to ULSCH rnti %x, dropping it\n", current_rnti); - return; } @@ -320,12 +303,11 @@ rx_sdu(const module_id_t enb_mod_idP, if (payload_ptr == NULL) { LOG_E(MAC,"[eNB %d][PUSCH %d] CC_id %d ulsch header unknown lcid(rnti %x, UE_id %d)\n", - enb_mod_idP, - harq_pid, - CC_idP, - current_rnti, - UE_id); - + enb_mod_idP, + harq_pid, + CC_idP, + current_rnti, + UE_id); return; } @@ -339,7 +321,6 @@ rx_sdu(const module_id_t enb_mod_idP, T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu)); - T(T_ENB_MAC_UE_UL_PDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), @@ -351,10 +332,10 @@ rx_sdu(const module_id_t enb_mod_idP, T_INT(num_ce), T_INT(num_sdu), T_BUFFER(sduP, sdu_lenP)); - mac->eNB_stats[CC_idP].ulsch_bytes_rx = sdu_lenP; mac->eNB_stats[CC_idP].total_ulsch_bytes_rx += sdu_lenP; mac->eNB_stats[CC_idP].total_ulsch_pdus_rx += 1; + if (UE_id != -1) { UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] = 0; } @@ -379,33 +360,30 @@ rx_sdu(const module_id_t enb_mod_idP, } LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received PHR PH = %d (db)\n", - enb_mod_idP, - CC_idP, - rx_ces[i], - UE_list->UE_template[CC_idP][UE_id].phr_info); - + enb_mod_idP, + CC_idP, + rx_ces[i], + UE_list->UE_template[CC_idP][UE_id].phr_info); UE_list->UE_template[CC_idP][UE_id].phr_info_configured = 1; UE_list->UE_sched_ctrl[UE_id].phr_received = 1; } payload_ptr += sizeof(POWER_HEADROOM_CMD); - break; case CRNTI: old_rnti = (((uint16_t) payload_ptr[0]) << 8) + payload_ptr[1]; old_UE_id = find_UE_id(enb_mod_idP, old_rnti); - LOG_D(MAC, "[eNB %d] Frame %d, Subframe %d CC_id %d MAC CE_LCID %d (ce %d/%d): CRNTI %x (UE_id %d) in Msg3\n", - enb_mod_idP, - frameP, - subframeP, - CC_idP, - rx_ces[i], - i, - num_ce, - old_rnti, - old_UE_id); + enb_mod_idP, + frameP, + subframeP, + CC_idP, + rx_ces[i], + i, + num_ce, + old_rnti, + old_UE_id); /* Receiving CRNTI means that the current rnti has to go away */ if (old_UE_id != -1) { @@ -496,27 +474,22 @@ rx_sdu(const module_id_t enb_mod_idP, crnti_rx = 1; payload_ptr += 2; // sizeof(CRNTI) - break; case TRUNCATED_BSR: - case SHORT_BSR: lcgid = (payload_ptr[0] >> 6); - LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n", - enb_mod_idP, - CC_idP, - rx_ces[i], - lcgid, - payload_ptr[0] & 0x3f); + enb_mod_idP, + CC_idP, + rx_ces[i], + lcgid, + payload_ptr[0] & 0x3f); if (UE_id != -1) { int bsr = 0; - bsr = payload_ptr[0] & 0x3f; lcgid_updated[lcgid] = 1; - /* Update buffer info */ UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid] = BSR_TABLE[bsr]; UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = @@ -524,7 +497,6 @@ rx_sdu(const module_id_t enb_mod_idP, UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]; - RC.eNB[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP * 10) + subframeP] = (payload_ptr[0] & 0x3f); if (UE_id == UE_list->head) { @@ -537,19 +509,17 @@ rx_sdu(const module_id_t enb_mod_idP, if (mac_eNB_get_rrc_status(enb_mod_idP,UE_RNTI(enb_mod_idP, UE_id)) < RRC_CONNECTED) { LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : estimated_ul_buffer = %d (lcg increment %d)\n", - enb_mod_idP, - CC_idP, - rx_ces[i], - UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer, - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]); + enb_mod_idP, + CC_idP, + rx_ces[i], + UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer, + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]); } - } else { /* Need error message */ } payload_ptr += 1; // sizeof(SHORT_BSR) - break; case LONG_BSR: @@ -558,38 +528,34 @@ rx_sdu(const module_id_t enb_mod_idP, int bsr1 = ((payload_ptr[0] & 0x03) << 4) | ((payload_ptr[1] & 0xF0) >> 4); int bsr2 = ((payload_ptr[1] & 0x0F) << 2) | ((payload_ptr[2] & 0xC0) >> 6); int bsr3 = payload_ptr[2] & 0x3F; - lcgid_updated[LCGID0] = 1; lcgid_updated[LCGID1] = 1; lcgid_updated[LCGID2] = 1; lcgid_updated[LCGID3] = 1; - /* Update buffer info */ UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] = BSR_TABLE[bsr0]; UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] = BSR_TABLE[bsr1]; UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] = BSR_TABLE[bsr2]; UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3] = BSR_TABLE[bsr3]; - UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]; - LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR. Size is LCGID0 = %u LCGID1 = %u LCGID2 = %u LCGID3 = %u\n", - enb_mod_idP, - CC_idP, - rx_ces[i], - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0], - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1], - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2], - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]); + enb_mod_idP, + CC_idP, + rx_ces[i], + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0], + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1], + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2], + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]); if (crnti_rx == 1) { LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d: Received CRNTI.\n", - enb_mod_idP, - CC_idP, - rx_ces[i]); + enb_mod_idP, + CC_idP, + rx_ces[i]); } for(int lcgid = 0; lcgid <= LCGID3; lcgid++) { @@ -606,21 +572,18 @@ rx_sdu(const module_id_t enb_mod_idP, default: LOG_E(MAC, "[eNB %d] CC_id %d Received unknown MAC header (0x%02x)\n", - enb_mod_idP, - CC_idP, - rx_ces[i]); - + enb_mod_idP, + CC_idP, + rx_ces[i]); break; - } // end switch on control element } // end for loop on control element for (int i = 0; i < num_sdu; i++) { LOG_D(MAC, "SDU Number %d MAC Subheader SDU_LCID %d, length %d\n", - i, - rx_lcids[i], - rx_lengths[i]); - + i, + rx_lcids[i], + rx_lengths[i]); T(T_ENB_MAC_UE_UL_SDU, T_INT(enb_mod_idP), T_INT(CC_idP), @@ -629,7 +592,6 @@ rx_sdu(const module_id_t enb_mod_idP, T_INT(subframeP), T_INT(rx_lcids[i]), T_INT(rx_lengths[i])); - T(T_ENB_MAC_UE_UL_SDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), @@ -644,58 +606,51 @@ rx_sdu(const module_id_t enb_mod_idP, case CCCH: if (rx_lengths[i] > CCCH_PAYLOAD_SIZE_MAX) { LOG_E(MAC, "[eNB %d/%d] frame %d received CCCH of size %d (too big, maximum allowed is %d, sdu_len %d), dropping packet\n", - enb_mod_idP, - CC_idP, - frameP, - rx_lengths[i], - CCCH_PAYLOAD_SIZE_MAX, - sdu_lenP); - + enb_mod_idP, + CC_idP, + frameP, + rx_lengths[i], + CCCH_PAYLOAD_SIZE_MAX, + sdu_lenP); break; } LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, Received CCCH: %x.%x.%x.%x.%x.%x, Terminating RA procedure for UE rnti %x\n", - enb_mod_idP, - CC_idP, - frameP, - payload_ptr[0], payload_ptr[1], payload_ptr[2], payload_ptr[3], payload_ptr[4], payload_ptr[5], - current_rnti); - + enb_mod_idP, + CC_idP, + frameP, + payload_ptr[0], payload_ptr[1], payload_ptr[2], payload_ptr[3], payload_ptr[4], payload_ptr[5], + current_rnti); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC, 1); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC, 0); - RA_id = find_RA_id(enb_mod_idP, CC_idP, current_rnti); if (RA_id != -1) { RA_t *ra = &(mac->common_channels[CC_idP].ra[RA_id]); - LOG_D(MAC, "[mac %d][RAPROC] CC_id %d Checking proc %d : rnti (%x, %x), state %d\n", - enb_mod_idP, - CC_idP, - RA_id, - ra->rnti, - current_rnti, - ra->state); + enb_mod_idP, + CC_idP, + RA_id, + ra->rnti, + current_rnti, + ra->state); if (UE_id < 0) { memcpy(&(ra->cont_res_id[0]), payload_ptr, 6); - LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3: length %d, offset %ld\n", - enb_mod_idP, - CC_idP, - frameP, - rx_lengths[i], - payload_ptr - sduP); + enb_mod_idP, + CC_idP, + frameP, + rx_lengths[i], + payload_ptr - sduP); if ((UE_id = add_new_ue(enb_mod_idP, CC_idP, ra->rnti, harq_pid #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) , ra->rach_resource_type #endif - )) == -1) { + )) == -1) { LOG_E(MAC,"[MAC][eNB] Max user count reached\n"); - cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); // send Connection Reject ??? - break; // kill RA proc } else { @@ -718,18 +673,18 @@ rx_sdu(const module_id_t enb_mod_idP, } mac_rrc_data_ind(enb_mod_idP, - CC_idP, - frameP, subframeP, - UE_id, - current_rnti, - CCCH, - (uint8_t *) payload_ptr, - rx_lengths[i], - 0 + CC_idP, + frameP, subframeP, + UE_id, + current_rnti, + CCCH, + (uint8_t *) payload_ptr, + rx_lengths[i], + 0 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,ra->rach_resource_type > 0 + ,ra->rach_resource_type > 0 #endif - ); + ); if (num_ce > 0) { // handle msg3 which is not RRCConnectionRequest // process_ra_message(msg3,num_ce,rx_lcids,rx_ces); @@ -764,9 +719,7 @@ rx_sdu(const module_id_t enb_mod_idP, break; case DCCH: - case DCCH1: - #if defined(ENABLE_MAC_PAYLOAD_DEBUG) LOG_T(MAC, "offset: %d\n", (unsigned char) ((unsigned char *) payload_ptr - sduP)); @@ -857,12 +810,11 @@ rx_sdu(const module_id_t enb_mod_idP, mac_rlc_data_ind(enb_mod_idP, current_rnti, enb_mod_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, rx_lcids[i], (char *) payload_ptr, rx_lengths[i], 1, NULL); UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]] += 1; UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]] += rx_lengths[i]; - /* Clear uplane_inactivity_timer */ UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; - /* Reset RRC inactivity timer after uplane activity */ ue_contextP = rrc_eNB_get_ue_context(RC.rrc[enb_mod_idP], current_rnti); + if (ue_contextP != NULL) { ue_contextP->ue_context.ue_rrc_inactivity_timer = 1; } else { @@ -871,10 +823,8 @@ rx_sdu(const module_id_t enb_mod_idP, CC_idP, current_rnti); } - } else { /* rx_length[i] Max size */ UE_list->eNB_UE_stats[CC_idP][UE_id].num_errors_rx += 1; - LOG_E(MAC, "[eNB %d] CC_id %d Frame %d : Max size of transport block reached LCID %d from UE %d ", enb_mod_idP, CC_idP, @@ -891,6 +841,7 @@ rx_sdu(const module_id_t enb_mod_idP, UE_id); } } + break; } @@ -899,21 +850,16 @@ rx_sdu(const module_id_t enb_mod_idP, /* Program ACK for PHICH */ LOG_D(MAC, "Programming PHICH ACK for rnti %x harq_pid %d (first_rb %d)\n", - current_rnti, - harq_pid, - first_rb); - + current_rnti, + harq_pid, + first_rb); nfapi_hi_dci0_request_t *hi_dci0_req; - uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_idP], subframeP); - hi_dci0_req = &mac->HI_DCI0_req[CC_idP][(subframeP+sf_ahead_dl)%10]; nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + - hi_dci0_req_body->number_of_hi]; - + hi_dci0_req_body->number_of_hi]; memset((void *) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE; hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_hi_pdu); hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; @@ -930,7 +876,6 @@ rx_sdu(const module_id_t enb_mod_idP, if ((num_sdu == 0) && (num_ce == 0)) { if (UE_id != -1) UE_list->eNB_UE_stats[CC_idP][UE_id].total_num_errors_rx += 1; - } else { if (UE_id != -1) { UE_list->eNB_UE_stats[CC_idP][UE_id].pdu_bytes_rx = sdu_lenP; @@ -970,10 +915,10 @@ bytes_to_bsr_index(int32_t nbytes) */ void add_ue_ulsch_info(module_id_t module_idP, - int CC_id, - int UE_id, - sub_frame_t subframeP, - UE_ULSCH_STATUS status) + int CC_id, + int UE_id, + sub_frame_t subframeP, + UE_ULSCH_STATUS status) //----------------------------------------------------------------------------- { eNB_ulsch_info[module_idP][CC_id][UE_id].rnti = UE_RNTI(module_idP, UE_id); @@ -988,12 +933,12 @@ add_ue_ulsch_info(module_id_t module_idP, */ unsigned char * parse_ulsch_header(unsigned char *mac_header, - unsigned char *num_ce, - unsigned char *num_sdu, - unsigned char *rx_ces, - unsigned char *rx_lcids, - unsigned short *rx_lengths, - unsigned short tb_length) + unsigned char *num_ce, + unsigned char *num_sdu, + unsigned char *rx_ces, + unsigned char *rx_lcids, + unsigned short *rx_lengths, + unsigned short tb_length) //----------------------------------------------------------------------------- { unsigned char not_done = 1; @@ -1003,7 +948,6 @@ parse_ulsch_header(unsigned char *mac_header, unsigned char num_sdu_cnt = 0; unsigned char *mac_header_ptr = NULL; unsigned short length, ce_len = 0; - /* Init */ mac_header_ptr = mac_header; @@ -1028,22 +972,20 @@ parse_ulsch_header(unsigned char *mac_header, mac_header_ptr += 2; //sizeof(SCH_SUBHEADER_SHORT); } else { // F = 1 length = ((((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB & 0x7f) << 8) | - (((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB & 0xff); + (((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB & 0xff); mac_header_ptr += 3; //sizeof(SCH_SUBHEADER_LONG); } } LOG_D(MAC, "[eNB] sdu %d lcid %d tb_length %d length %d (offset now %ld)\n", - num_sdus, - lcid, - tb_length, - length, - mac_header_ptr - mac_header); - + num_sdus, + lcid, + tb_length, + length, + mac_header_ptr - mac_header); rx_lcids[num_sdus] = lcid; rx_lengths[num_sdus] = length; num_sdus++; - } else { // This is a control element subheader POWER_HEADROOM, BSR and CRNTI if (lcid == SHORT_PADDING) { mac_header_ptr++; @@ -1081,16 +1023,15 @@ parse_ulsch_header(unsigned char *mac_header, */ void set_msg3_subframe(module_id_t mod_id, - int CC_id, - int frame, // Not used, remove? - int subframe, // Not used, remove? - int rnti, - int Msg3_frame, // Not used, remove? - int Msg3_subframe) + int CC_id, + int frame, // Not used, remove? + int subframe, // Not used, remove? + int rnti, + int Msg3_frame, // Not used, remove? + int Msg3_subframe) //----------------------------------------------------------------------------- { int RA_id = 0; - /* Init */ RA_id = find_RA_id(mod_id, CC_id, rnti); // state == WAITMSG3 instead of state != IDLE (?) @@ -1109,26 +1050,22 @@ set_msg3_subframe(module_id_t mod_id, */ void schedule_ulsch(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP) + frame_t frameP, + sub_frame_t subframeP) //----------------------------------------------------------------------------- { uint16_t first_rb[NFAPI_CC_MAX]; eNB_MAC_INST *mac = NULL; slice_info_t *sli = NULL; COMMON_channels_t *cc = NULL; - /* Init */ mac = RC.mac[module_idP]; sli = &(mac->slice_info); memset(first_rb, 0, NFAPI_CC_MAX * sizeof(uint16_t)); - start_meas(&(mac->schedule_ulsch)); - /* Second setup step */ int sched_subframe = 0; int sched_frame = 0; - /* Second init step */ sched_subframe = (subframeP + 4) % 10; sched_frame = frameP; @@ -1237,13 +1174,11 @@ schedule_ulsch(module_id_t module_idP, /* Note: RC.nb_mac_CC[module_idP] should be lower than or equal to NFAPI_CC_MAX */ for (int CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++, cc++) { first_rb[CC_id] = 1; // leave out first RB for PUCCH - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) first_rb[CC_id] = (emtc_active[CC_id] == 1) ? 7 : 1; #else first_rb[CC_id] = 1; #endif - RA_t *ra_ptr = cc->ra; /* From Louis-Adrien to François: @@ -1282,6 +1217,7 @@ schedule_ulsch(module_id_t module_idP, if (first_rb[CC_id] < ra_ptr->msg3_first_rb + ra_ptr->msg3_nb_rb) { first_rb[CC_id] = ra_ptr->msg3_first_rb + ra_ptr->msg3_nb_rb; } + /* Louis-Adrien: I couldn't find an interdiction of multiple Msg3 scheduling * on the same time resources. Also the performance improvement of breaking is low, * since we will loop until the end, most of the time. @@ -1307,11 +1243,11 @@ schedule_ulsch(module_id_t module_idP, */ void schedule_ulsch_rnti(module_id_t module_idP, - int slice_idx, - frame_t frameP, - sub_frame_t subframeP, - unsigned char sched_subframeP, - uint16_t *first_rb) + int slice_idx, + frame_t frameP, + sub_frame_t subframeP, + unsigned char sched_subframeP, + uint16_t *first_rb) //----------------------------------------------------------------------------- { rnti_t rnti = -1; @@ -1341,7 +1277,6 @@ schedule_ulsch_rnti(module_id_t module_idP, int rvidx_tab[4] = {0, 2, 3, 1}; int first_rb_slice[NFAPI_CC_MAX]; int n_rb_ul_tab[NFAPI_CC_MAX]; - /* Init */ mac = RC.mac[module_idP]; cc = mac->common_channels; @@ -1362,7 +1297,6 @@ schedule_ulsch_rnti(module_id_t module_idP, nfapi_ul_config_request_t *ul_req_tmp = &(mac->UL_req_tmp[CC_id][sched_subframeP]); nfapi_ul_config_request_body_t *ul_req_tmp_body = &(ul_req_tmp->ul_config_request_body); nfapi_ul_config_ulsch_harq_information *ulsch_harq_information; - hi_dci0_req->sfn_sf = (frameP << 4) + subframeP; /* Note: RC.nb_mac_CC[module_idP] should be lower than or equal to NFAPI_CC_MAX */ @@ -1387,16 +1321,16 @@ schedule_ulsch_rnti(module_id_t module_idP, if (!ue_ul_slice_membership(module_idP, UE_id, slice_idx)) { continue; } + if (UE_list->UE_template[UE_PCCID(module_idP, UE_id)][UE_id].rach_resource_type > 0) continue; // don't schedule if Msg5 is not received yet if (UE_list->UE_template[UE_PCCID(module_idP, UE_id)][UE_id].configured == FALSE) { LOG_D(MAC, "[eNB %d] frame %d, subframe %d, UE %d: not configured, skipping UE scheduling \n", - module_idP, - frameP, - subframeP, - UE_id); - + module_idP, + frameP, + subframeP, + UE_id); continue; } @@ -1404,11 +1338,10 @@ schedule_ulsch_rnti(module_id_t module_idP, if (rnti == NOT_A_RNTI) { LOG_W(MAC, "[eNB %d] frame %d, subframe %d, UE %d: no RNTI \n", - module_idP, - frameP, - subframeP, - UE_id); - + module_idP, + frameP, + subframeP, + UE_id); continue; } @@ -1420,13 +1353,12 @@ schedule_ulsch_rnti(module_id_t module_idP, /* Be sure that there are some free RBs */ if (first_rb_slice[CC_id] >= n_rb_ul_tab[CC_id] - 1) { LOG_W(MAC, "[eNB %d] frame %d, subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", - module_idP, - frameP, - subframeP, - UE_id, - rnti, - CC_id); - + module_idP, + frameP, + subframeP, + UE_id, + rnti, + CC_id); continue; } @@ -1434,13 +1366,12 @@ schedule_ulsch_rnti(module_id_t module_idP, /* This test seems to be way too long, can we provide an optimization? */ if (CCE_allocation_infeasible(module_idP, CC_id, 1, subframeP, aggregation, rnti)) { LOG_W(MAC, "[eNB %d] frame %d, subframe %d, UE %d/%x CC %d: not enough CCE\n", - module_idP, - frameP, - subframeP, - UE_id, - rnti, - CC_id); - + module_idP, + frameP, + subframeP, + UE_id, + rnti, + CC_id); continue; } @@ -1449,25 +1380,22 @@ schedule_ulsch_rnti(module_id_t module_idP, UE_sched_ctrl_ptr = &(UE_list->UE_sched_ctrl[UE_id]); harq_pid = subframe2harqpid(&cc[CC_id], sched_frame, sched_subframeP); round_index = UE_sched_ctrl_ptr->round_UL[CC_id][harq_pid]; - AssertFatal(round_index < 8, "round %d > 7 for UE %d/%x\n", - round_index, - UE_id, - rnti); - + round_index, + UE_id, + rnti); LOG_D(MAC, "[eNB %d] frame %d subframe %d (sched_frame %d, sched_subframe %d), Checking PUSCH %d for UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n", - module_idP, - frameP, - subframeP, - sched_frame, - sched_subframeP, - harq_pid, - UE_id, - rnti, - CC_id, - aggregation, - n_rb_ul_tab[CC_id]); - + module_idP, + frameP, + subframeP, + sched_frame, + sched_subframeP, + harq_pid, + UE_id, + rnti, + CC_id, + aggregation, + n_rb_ul_tab[CC_id]); /* Seems unused, only for debug */ RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP * 10) + subframeP] = UE_template_ptr->estimated_ul_buffer; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO, UE_template_ptr->estimated_ul_buffer); @@ -1479,18 +1407,17 @@ schedule_ulsch_rnti(module_id_t module_idP, /* Shouldn't this test be done earlier?? */ if (UE_is_to_be_scheduled(module_idP, CC_id, UE_id) > 0 || round_index > 0) { LOG_D(MAC, "[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x in round %d(SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n", - module_idP, - harq_pid, - frameP, - subframeP, - UE_id, - rnti, - round_index, - UE_template_ptr->ul_SR, - UE_sched_ctrl_ptr->ul_inactivity_timer, - UE_sched_ctrl_ptr->ul_failure_timer, - UE_sched_ctrl_ptr->cqi_req_timer); - + module_idP, + harq_pid, + frameP, + subframeP, + UE_id, + rnti, + round_index, + UE_template_ptr->ul_SR, + UE_sched_ctrl_ptr->ul_inactivity_timer, + UE_sched_ctrl_ptr->ul_failure_timer, + UE_sched_ctrl_ptr->cqi_req_timer); // reset the scheduling request UE_template_ptr->ul_SR = 0; status = mac_eNB_get_rrc_status(module_idP, rnti); @@ -1500,7 +1427,7 @@ schedule_ulsch_rnti(module_id_t module_idP, /* These aperiodic reports behave as periodic ones... */ if (status >= RRC_CONNECTED && UE_sched_ctrl_ptr->cqi_req_timer > 30) { if (UE_sched_ctrl_ptr->cqi_received == 0) { - if (nfapi_mode) { + if (NFAPI_MODE != NFAPI_MONOLITHIC) { cqi_req = 0; } else { cqi_req = 1; @@ -1512,12 +1439,14 @@ schedule_ulsch_rnti(module_id_t module_idP, if(subframeP == 1 || subframeP == 6) { cqi_req=0; } + break; case 3: if(subframeP == 1) { cqi_req=0; } + break; default: @@ -1546,7 +1475,6 @@ schedule_ulsch_rnti(module_id_t module_idP, */ normalized_rx_power = ((5 * UE_sched_ctrl_ptr->pusch_snr[CC_id] - 640) / 10) + 30; target_rx_power = (mac->puSch10xSnr / 10) + 30; - /* * This assumes accumulated tpc * Make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out @@ -1555,7 +1483,6 @@ schedule_ulsch_rnti(module_id_t module_idP, if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || // normal case ((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) { //frame wrap-around - UE_template_ptr->pusch_tpc_tx_frame = frameP; UE_template_ptr->pusch_tpc_tx_subframe = subframeP; @@ -1574,14 +1501,14 @@ schedule_ulsch_rnti(module_id_t module_idP, if (tpc != 1) { LOG_D(MAC, "[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", - module_idP, - frameP, - subframeP, - harq_pid, - tpc, - tpc_accumulated, - normalized_rx_power, - target_rx_power); + module_idP, + frameP, + subframeP, + harq_pid, + tpc, + tpc_accumulated, + normalized_rx_power, + target_rx_power); } /* New transmission */ @@ -1611,7 +1538,6 @@ schedule_ulsch_rnti(module_id_t module_idP, UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx += rb_table[rb_table_index]; UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS = UE_template_ptr->TBS_UL[harq_pid]; UE_list->eNB_UE_stats[CC_id][UE_id].total_ulsch_TBS += UE_template_ptr->TBS_UL[harq_pid]; - T(T_ENB_MAC_UE_UL_SCHEDULE, T_INT(module_idP), T_INT(CC_id), @@ -1624,7 +1550,6 @@ schedule_ulsch_rnti(module_id_t module_idP, T_INT(rb_table[rb_table_index]), T_INT(UE_template_ptr->TBS_UL[harq_pid]), T_INT(ndi)); - /* Store information for possible retransmission */ UE_template_ptr->nb_rb_ul[harq_pid] = rb_table[rb_table_index]; UE_template_ptr->first_rb_ul[harq_pid] = first_rb_slice[CC_id]; @@ -1636,24 +1561,19 @@ schedule_ulsch_rnti(module_id_t module_idP, /* Adjust scheduled UL bytes by TBS, wait for UL sdus to do final update */ LOG_D(MAC, "[eNB %d] CC_id %d UE %d/%x : adjusting scheduled_ul_bytes, old %d, TBS %d\n", - module_idP, - CC_id, - UE_id, - rnti, - UE_template_ptr->scheduled_ul_bytes, - UE_template_ptr->TBS_UL[harq_pid]); - + module_idP, + CC_id, + UE_id, + rnti, + UE_template_ptr->scheduled_ul_bytes, + UE_template_ptr->TBS_UL[harq_pid]); UE_template_ptr->scheduled_ul_bytes += UE_template_ptr->TBS_UL[harq_pid]; - LOG_D(MAC, "scheduled_ul_bytes, new %d\n", - UE_template_ptr->scheduled_ul_bytes); - + UE_template_ptr->scheduled_ul_bytes); /* Cyclic shift for DM-RS */ cshift = 0; // values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) - /* Save it for a potential retransmission */ UE_template_ptr->cshift[harq_pid] = cshift; - /* Setting DCI0 NFAPI struct */ hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; memset((void *) hi_dci0_pdu, 0,sizeof(nfapi_hi_dci0_request_pdu_t)); @@ -1679,65 +1599,60 @@ schedule_ulsch_rnti(module_id_t module_idP, hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; hi_dci0_req->sfn_sf = frameP << 4 | subframeP; hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; - LOG_D(MAC, "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", - harq_pid, - frameP, - subframeP, - UE_id, - rnti, - sched_frame, - sched_subframeP); - + harq_pid, + frameP, + subframeP, + UE_id, + rnti, + sched_frame, + sched_subframeP); ul_req_index = 0; dlsch_flag = 0; for(ul_req_index = 0; ul_req_index < ul_req_tmp_body->number_of_pdus; ul_req_index++) { if(ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE && - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) { - + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) { dlsch_flag = 1; - LOG_D(MAC, "Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n", - frameP, - subframeP, - rnti, - ul_req_index); - + frameP, + subframeP, + rnti, + ul_req_index); break; } } /* Add UL_config PDUs */ fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], - cqi_req, - cc, - UE_template_ptr->physicalConfigDedicated, - get_tmode(module_idP, CC_id, UE_id), - mac->ul_handle, - rnti, - first_rb_slice[CC_id], // resource_block_start - rb_table[rb_table_index], // number_of_resource_blocks - UE_template_ptr->mcs_UL[harq_pid], - cshift, // cyclic_shift_2_for_drms - 0, // frequency_hopping_enabled_flag - 0, // frequency_hopping_bits - ndi, // new_data_indication - 0, // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - get_TBS_UL(UE_template_ptr->mcs_UL[harq_pid], rb_table[rb_table_index])); - + cqi_req, + cc, + UE_template_ptr->physicalConfigDedicated, + get_tmode(module_idP, CC_id, UE_id), + mac->ul_handle, + rnti, + first_rb_slice[CC_id], // resource_block_start + rb_table[rb_table_index], // number_of_resource_blocks + UE_template_ptr->mcs_UL[harq_pid], + cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + ndi, // new_data_indication + 0, // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + get_TBS_UL(UE_template_ptr->mcs_UL[harq_pid], rb_table[rb_table_index])); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + /* This is a BL/CE UE allocation */ if (UE_template_ptr->rach_resource_type > 0) { fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], - UE_template_ptr->rach_resource_type > 2 ? 2 : 1, - 1, // total_number_of_repetitions - 1, // repetition_number - (frameP * 10) + subframeP); + UE_template_ptr->rach_resource_type > 2 ? 2 : 1, + 1, // total_number_of_repetitions + 1, // repetition_number + (frameP * 10) + subframeP); } #endif @@ -1746,19 +1661,21 @@ schedule_ulsch_rnti(module_id_t module_idP, if (cqi_req == 1) { ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = + rb_table[rb_table_index]; } else { ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; } fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); - } else { ul_req_tmp_body->number_of_pdus++; } @@ -1767,29 +1684,24 @@ schedule_ulsch_rnti(module_id_t module_idP, ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; mac->ul_handle++; ul_req_tmp->sfn_sf = sched_frame << 4 | sched_subframeP; - add_ue_ulsch_info(module_idP, CC_id, UE_id, subframeP, S_UL_SCHEDULED); - LOG_D(MAC, "[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", - module_idP, - CC_id, - frameP, - subframeP, - UE_id); - + module_idP, + CC_id, + frameP, + subframeP, + UE_id); LOG_D(MAC, "[PUSCH %d] SFN/SF:%04d%d UL_CFG:SFN/SF:%04d%d CQI:%d for UE %d/%x\n", - harq_pid, - frameP, - subframeP, - sched_frame, - sched_subframeP, - cqi_req, - UE_id, - rnti); - + harq_pid, + frameP, + subframeP, + sched_frame, + sched_subframeP, + cqi_req, + UE_id, + rnti); /* Increment first rb for next UE allocation */ first_rb_slice[CC_id] += rb_table[rb_table_index]; - } else { // round_index > 0 => retransmission T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, T_INT(module_idP), @@ -1802,66 +1714,60 @@ schedule_ulsch_rnti(module_id_t module_idP, T_INT(first_rb_slice[CC_id]), T_INT(rb_table[rb_table_index]), T_INT(round_index)); - /* Add UL_config PDUs */ LOG_D(MAC, "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", - harq_pid, - frameP, - subframeP, - UE_id, - rnti, - sched_frame, - sched_subframeP); - + harq_pid, + frameP, + subframeP, + UE_id, + rnti, + sched_frame, + sched_subframeP); ul_req_index = 0; dlsch_flag = 0; for(ul_req_index = 0; ul_req_index < ul_req_tmp_body->number_of_pdus; ul_req_index++) { if(ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE && - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) { - + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) { dlsch_flag = 1; - LOG_D(MAC, "Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n", - frameP, - subframeP, - rnti, - ul_req_index); - + frameP, + subframeP, + rnti, + ul_req_index); break; } } fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], - cqi_req, - cc, - UE_template_ptr->physicalConfigDedicated, - get_tmode(module_idP, CC_id, UE_id), - mac->ul_handle, - rnti, - UE_template_ptr->first_rb_ul[harq_pid], // resource_block_start - UE_template_ptr->nb_rb_ul[harq_pid], // number_of_resource_blocks - UE_template_ptr->mcs_UL[harq_pid], - cshift, // cyclic_shift_2_for_drms - 0, // frequency_hopping_enabled_flag - 0, // frequency_hopping_bits - UE_template_ptr->oldNDI_UL[harq_pid], // new_data_indication - rvidx_tab[round_index & 3], // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - UE_template_ptr->TBS_UL[harq_pid]); - + cqi_req, + cc, + UE_template_ptr->physicalConfigDedicated, + get_tmode(module_idP, CC_id, UE_id), + mac->ul_handle, + rnti, + UE_template_ptr->first_rb_ul[harq_pid], // resource_block_start + UE_template_ptr->nb_rb_ul[harq_pid], // number_of_resource_blocks + UE_template_ptr->mcs_UL[harq_pid], + cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + UE_template_ptr->oldNDI_UL[harq_pid], // new_data_indication + rvidx_tab[round_index & 3], // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + UE_template_ptr->TBS_UL[harq_pid]); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) /* This is a BL/CE UE allocation */ if (UE_template_ptr->rach_resource_type > 0) { fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], - UE_template_ptr->rach_resource_type > 2 ? 2 : 1, - 1, // total_number_of_repetitions - 1, // repetition_number - (frameP * 10) + subframeP); + UE_template_ptr->rach_resource_type > 2 ? 2 : 1, + 1, // total_number_of_repetitions + 1, // repetition_number + (frameP * 10) + subframeP); } #endif @@ -1886,7 +1792,6 @@ schedule_ulsch_rnti(module_id_t module_idP, } fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information, subframeP); - } else { ul_req_tmp_body->number_of_pdus++; } @@ -1895,16 +1800,15 @@ schedule_ulsch_rnti(module_id_t module_idP, ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; ul_req_tmp->sfn_sf = sched_frame<<4|sched_subframeP; ul_req_tmp->header.message_id = NFAPI_UL_CONFIG_REQUEST; - LOG_D(MAC, "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d cqi_req %d\n", - harq_pid, - frameP, - subframeP, - UE_id, - rnti, - sched_frame, - sched_subframeP, - cqi_req); + harq_pid, + frameP, + subframeP, + UE_id, + rnti, + sched_frame, + sched_subframeP, + cqi_req); } // end of round > 0 } // UE_is_to_be_scheduled } // loop over all active CC_ids @@ -1917,10 +1821,10 @@ schedule_ulsch_rnti(module_id_t module_idP, * default ULSCH scheduler for LTE-M */ void schedule_ulsch_rnti_emtc(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - unsigned char sched_subframeP, - int *emtc_active) + frame_t frameP, + sub_frame_t subframeP, + unsigned char sched_subframeP, + int *emtc_active) //----------------------------------------------------------------------------- { int UE_id = -1; @@ -1947,11 +1851,10 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, if (sched_subframeP < subframeP) { sched_frame++; - } + } nfapi_hi_dci0_request_body_t *hi_dci0_req = &(eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body); nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = NULL; - nfapi_ul_config_request_body_t *ul_req_tmp = &(eNB->UL_req_tmp[CC_id][sched_subframeP].ul_config_request_body); /* If frameP odd don't schedule */ @@ -1979,12 +1882,11 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, rnti = UE_RNTI(module_idP, UE_id); if (rnti == NOT_A_RNTI) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d: no RNTI \n", + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d: no RNTI \n", module_idP, frameP, subframeP, UE_id); - continue; } @@ -1993,18 +1895,14 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, /* This is the actual CC_id in the list */ CC_id = UE_list->ordered_ULCCids[n][UE_id]; N_RB_UL = to_prb(cc[CC_id].ul_Bandwidth); - UE_template = &(UE_list->UE_template[CC_id][UE_id]); UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; - harq_pid = 0; round_UL = UE_sched_ctrl->round_UL[CC_id][harq_pid]; - AssertFatal(round_UL < 8,"round_UL %d > 7 for UE %d/%x\n", round_UL, UE_id, rnti); - LOG_D(MAC,"[eNB %d] frame %d subframe %d,Checking PUSCH %d for BL/CE UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n", module_idP, frameP, @@ -2012,22 +1910,20 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, harq_pid, UE_id, rnti, - CC_id, + CC_id, 24, // agregation level N_RB_UL); - RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->estimated_ul_buffer; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO, UE_template->estimated_ul_buffer); //if ((UE_is_to_be_scheduled(module_idP, CC_id, UE_id) > 0) && (subframeP == 5)) { if ((UE_template->ul_SR > 0 || round_UL > 0 || status < RRC_CONNECTED) && (subframeP == 5)) { - /* + /* * if there is information on bsr of DCCH, DTCH, - * or if there is UL_SR, - * or if there is a packet to retransmit, + * or if there is UL_SR, + * or if there is a packet to retransmit, * or we want to schedule a periodic feedback every frame */ - LOG_D(MAC,"[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x in round_UL %d(SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n", module_idP, harq_pid, @@ -2039,42 +1935,40 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, UE_template->ul_SR, UE_sched_ctrl->ul_inactivity_timer, UE_sched_ctrl->ul_failure_timer, - UE_sched_ctrl->cqi_req_timer); - + UE_sched_ctrl->cqi_req_timer); /* Reset the scheduling request */ emtc_active[CC_id] = 1; - UE_template->ul_SR = 0; - status = mac_eNB_get_rrc_status(module_idP,rnti); - cqi_req = 0; - + UE_template->ul_SR = 0; + status = mac_eNB_get_rrc_status(module_idP,rnti); + cqi_req = 0; /* Power control: compute the expected ULSCH RX power (for the stats) */ /* This is the normalized RX power and this should be constant (regardless of mcs) */ - normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id]; - target_rx_power = 178; - + normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id]; + target_rx_power = 178; /* This assumes accumulated tpc */ /* Make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out */ int32_t framex10psubframe = UE_template->pusch_tpc_tx_frame * 10 + UE_template->pusch_tpc_tx_subframe; + if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || // normal case - ((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) // frame wrap-around - { - UE_template->pusch_tpc_tx_frame = frameP; - UE_template->pusch_tpc_tx_subframe = subframeP; - if (normalized_rx_power > (target_rx_power + 4)) { - tpc = 0; //-1 - UE_sched_ctrl->tpc_accumulated[CC_id]--; - } else if (normalized_rx_power < (target_rx_power - 4)) { - tpc = 2; //+1 - UE_sched_ctrl->tpc_accumulated[CC_id]++; - } else { - tpc = 1; //0 - } - } else { + ((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) { // frame wrap-around + UE_template->pusch_tpc_tx_frame = frameP; + UE_template->pusch_tpc_tx_subframe = subframeP; + + if (normalized_rx_power > (target_rx_power + 4)) { + tpc = 0; //-1 + UE_sched_ctrl->tpc_accumulated[CC_id]--; + } else if (normalized_rx_power < (target_rx_power - 4)) { + tpc = 2; //+1 + UE_sched_ctrl->tpc_accumulated[CC_id]++; + } else { tpc = 1; //0 } + } else { + tpc = 1; //0 + } if (tpc != 1) { - LOG_D(MAC,"[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", + LOG_D(MAC,"[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", module_idP, frameP, subframeP, @@ -2083,38 +1977,34 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, UE_sched_ctrl->tpc_accumulated[CC_id], normalized_rx_power, target_rx_power); - } + } /* New transmission */ if (round_UL == 0) { ndi = 1 - UE_template->oldNDI_UL[harq_pid]; - UE_template->oldNDI_UL[harq_pid] = ndi; - UE_template->mcs_UL[harq_pid] = 4; + UE_template->mcs_UL[harq_pid] = 4; UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid], 6); - UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power = normalized_rx_power; UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power = target_rx_power; UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1 = 4; UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2 = UE_template->mcs_UL[harq_pid]; UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx += 6; UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS = UE_template->TBS_UL[harq_pid]; - - T(T_ENB_MAC_UE_UL_SCHEDULE, - T_INT(module_idP), - T_INT(CC_id), - T_INT(rnti), + T(T_ENB_MAC_UE_UL_SCHEDULE, + T_INT(module_idP), + T_INT(CC_id), + T_INT(rnti), T_INT(frameP), - T_INT(subframeP), - T_INT(harq_pid), - T_INT(UE_template->mcs_UL[harq_pid]), - T_INT(0), + T_INT(subframeP), + T_INT(harq_pid), + T_INT(UE_template->mcs_UL[harq_pid]), + T_INT(0), T_INT(6), - T_INT(UE_template->TBS_UL[harq_pid]), + T_INT(UE_template->TBS_UL[harq_pid]), T_INT(ndi)); - /* Store for possible retransmission */ - UE_template->nb_rb_ul[harq_pid] = 6; + UE_template->nb_rb_ul[harq_pid] = 6; UE_sched_ctrl->ul_scheduled |= (1 << harq_pid); if (UE_id == UE_list->head) { @@ -2122,34 +2012,28 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, } /* Adjust total UL buffer status by TBS, wait for UL sdus to do final update */ - UE_template->scheduled_ul_bytes += UE_template->TBS_UL[harq_pid]; - - LOG_D(MAC, "scheduled_ul_bytes, new %d\n", UE_template->scheduled_ul_bytes); - + UE_template->scheduled_ul_bytes += UE_template->TBS_UL[harq_pid]; + LOG_D(MAC, "scheduled_ul_bytes, new %d\n", UE_template->scheduled_ul_bytes); /* Cyclic shift for DMRS */ cshift = 0; // values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) /* save it for a potential retransmission */ - UE_template->cshift[harq_pid] = cshift; - + UE_template->cshift[harq_pid] = cshift; AssertFatal (UE_template->physicalConfigDedicated != NULL, "UE_template->physicalConfigDedicated is null\n"); AssertFatal (UE_template->physicalConfigDedicated->ext4 != NULL, "UE_template->physicalConfigDedicated->ext4 is null\n"); AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 != NULL, "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 is null\n"); - AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present == LTE_EPDCCH_Config_r11__config_r11_PR_setup, - "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present != setup\n"); - AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 != NULL, - "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = NULL\n"); - - LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11 = UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0]; - - AssertFatal(epdcch_setconfig_r11 != NULL, "epdcch_setconfig_r11 is null\n"); + AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present == LTE_EPDCCH_Config_r11__config_r11_PR_setup, + "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present != setup\n"); + AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 != NULL, + "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = NULL\n"); + LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11 = UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0]; + AssertFatal(epdcch_setconfig_r11 != NULL, "epdcch_setconfig_r11 is null\n"); AssertFatal(epdcch_setconfig_r11->ext2 != NULL, "epdcch_setconfig_r11->ext2 is null\n"); AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13 != NULL, "epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null"); - AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->present == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup, - "epdcch_setconfig_r11->ext2->mpdcch_config_r13->present is not setup\n"); + AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->present == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup, + "epdcch_setconfig_r11->ext2->mpdcch_config_r13->present is not setup\n"); AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 != NULL, "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 is null"); - AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present == LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup, - "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present is not setup\n"); - + AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present == LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup, + "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present is not setup\n"); LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL 6-0A MPDCCH for BL/CE UE %d/%x, ulsch_frame %d, ulsch_subframe %d, UESS MPDCCH Narrowband %d\n", harq_pid, frameP, @@ -2159,58 +2043,49 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, sched_frame, sched_subframeP, (int)epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1); - UE_template->first_rb_ul[harq_pid] = narrowband_to_first_rb (cc, epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1); - hi_dci0_pdu = &(hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci + hi_dci0_req->number_of_hi]); - memset((void*) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t)); - - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE; - hi_dci0_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu)); - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_format = (UE_template->rach_resource_type > 1) ? 5 : 4; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type > 1) ? 2 : 1; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_narrowband = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_prb_pairs = 6; // checked above that it has to be this - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_transmission_type = epdcch_setconfig_r11->transmissionType_r11; // distibuted - + memset((void *) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE; + hi_dci0_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu)); + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_format = (UE_template->rach_resource_type > 1) ? 5 : 4; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type > 1) ? 2 : 1; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_narrowband = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_prb_pairs = 6; // checked above that it has to be this + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_transmission_type = epdcch_setconfig_r11->transmissionType_r11; // distibuted AssertFatal(UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 != NULL, - "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 is null\n"); - - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.start_symbol = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ecce_index = 0; // Note: this should be dynamic - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.aggreagation_level = 24; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4 - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti_type = 4; // other - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti = rnti; + "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 is null\n"); + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.start_symbol = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ecce_index = 0; // Note: this should be dynamic + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.aggreagation_level = 24; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4 + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti_type = 4; // other + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti = rnti; hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type < 3) ? 1 : 2; // already set above... - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.drms_scrambling_init = epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.transmission_power = 6000; // 0dB - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_start = UE_template->first_rb_ul[harq_pid]; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_resource_blocks = 6; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.drms_scrambling_init = epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.transmission_power = 6000; // 0dB + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_start = UE_template->first_rb_ul[harq_pid]; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_resource_blocks = 6; hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mcs = 4; // adjust according to size of RAR, 208 bits with N1A_PRB = 3 - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.pusch_repetition_levels = 0; - + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.pusch_repetition_levels = 0; AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13 == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13__setup__mpdcch_pdsch_HoppingConfig_r13_off, - "epdcch_setconfig_r11->ext2->mpdcch_config_r13->mpdcch_pdsch_HoppingConfig_r13 is not off\n"); - + "epdcch_setconfig_r11->ext2->mpdcch_config_r13->mpdcch_pdsch_HoppingConfig_r13 is not off\n"); hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.frequency_hopping_flag = 1 - epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.redudency_version = 0; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.new_data_indication = UE_template->oldNDI_UL[harq_pid]; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.harq_process = 0; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tpc = tpc; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.csi_request = cqi_req; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ul_inex = 0; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dai_presence_flag = 0; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dl_assignment_index = 0; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.srs_request = 0; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_subframe_repetition_number = 0; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tcp_bitmap = 0; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.total_dci_length_include_padding = 29; // hard-coded for 10 MHz - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_tx_antenna_ports = 1; - - hi_dci0_req->number_of_dci++; - + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.redudency_version = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.new_data_indication = UE_template->oldNDI_UL[harq_pid]; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.harq_process = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tpc = tpc; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.csi_request = cqi_req; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ul_inex = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dai_presence_flag = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dl_assignment_index = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.srs_request = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_subframe_repetition_number = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tcp_bitmap = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.total_dci_length_include_padding = 29; // hard-coded for 10 MHz + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_tx_antenna_ports = 1; + hi_dci0_req->number_of_dci++; LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG. Request for BL/CE UE %d/%x, ulsch_frame %d, ulsch_subframe %d, UESS mpdcch narrowband %d\n", harq_pid, frameP, @@ -2220,179 +2095,157 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, sched_frame, sched_subframeP, (int)epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1); - - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus], - cqi_req, - cc, - UE_template->physicalConfigDedicated, - get_tmode(module_idP,CC_id,UE_id), - eNB->ul_handle, - rnti, - UE_template->first_rb_ul[harq_pid], // resource_block_start - UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks - UE_template->mcs_UL[harq_pid], - cshift, // cyclic_shift_2_for_drms - 0, // frequency_hopping_enabled_flag - 0, // frequency_hopping_bits - UE_template->oldNDI_UL[harq_pid], // new_data_indication - rvidx_tab[round_UL&3], // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - UE_template->TBS_UL[harq_pid] - ); - + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus], + cqi_req, + cc, + UE_template->physicalConfigDedicated, + get_tmode(module_idP,CC_id,UE_id), + eNB->ul_handle, + rnti, + UE_template->first_rb_ul[harq_pid], // resource_block_start + UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks + UE_template->mcs_UL[harq_pid], + cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + UE_template->oldNDI_UL[harq_pid], // new_data_indication + rvidx_tab[round_UL&3], // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + UE_template->TBS_UL[harq_pid] + ); fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus], - UE_template->rach_resource_type > 2 ? 2 : 1, - 1, // total_number_of_repetitions - 1, // repetition_number - (frameP * 10) + subframeP); - - ul_req_tmp->number_of_pdus++; - eNB->ul_handle++; - - add_ue_ulsch_info(module_idP, - CC_id, - UE_id, - subframeP, - S_UL_SCHEDULED); - - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", + UE_template->rach_resource_type > 2 ? 2 : 1, + 1, // total_number_of_repetitions + 1, // repetition_number + (frameP * 10) + subframeP); + ul_req_tmp->number_of_pdus++; + eNB->ul_handle++; + add_ue_ulsch_info(module_idP, + CC_id, + UE_id, + subframeP, + S_UL_SCHEDULED); + LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP, CC_id, frameP, subframeP, UE_id); - } else { // round_UL > 0 => retransmission - /* In LTE-M the UL HARQ process is asynchronous */ - T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, - T_INT(module_idP), - T_INT(CC_id), - T_INT(rnti), + /* In LTE-M the UL HARQ process is asynchronous */ + T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, + T_INT(module_idP), + T_INT(CC_id), + T_INT(rnti), T_INT(frameP), - T_INT(subframeP), - T_INT(harq_pid), - T_INT(UE_template->mcs_UL[harq_pid]), - T_INT(0), + T_INT(subframeP), + T_INT(harq_pid), + T_INT(UE_template->mcs_UL[harq_pid]), + T_INT(0), T_INT(6), T_INT(round_UL)); - AssertFatal (UE_template->physicalConfigDedicated != NULL, "UE_template->physicalConfigDedicated is null\n"); AssertFatal (UE_template->physicalConfigDedicated->ext4 != NULL, "UE_template->physicalConfigDedicated->ext4 is null\n"); AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 != NULL, "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 is null\n"); - AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present == LTE_EPDCCH_Config_r11__config_r11_PR_setup, - "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present != setup\n"); - AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 != NULL, - "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = NULL\n"); - - LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11 = UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0]; - - AssertFatal(epdcch_setconfig_r11 != NULL, "epdcch_setconfig_r11 is null\n"); + AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present == LTE_EPDCCH_Config_r11__config_r11_PR_setup, + "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present != setup\n"); + AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 != NULL, + "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = NULL\n"); + LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11 = UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0]; + AssertFatal(epdcch_setconfig_r11 != NULL, "epdcch_setconfig_r11 is null\n"); AssertFatal(epdcch_setconfig_r11->ext2 != NULL, "epdcch_setconfig_r11->ext2 is null\n"); AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13 != NULL, "epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null"); AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13 != NULL, "epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null"); - AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->present == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup, - "epdcch_setconfig_r11->ext2->mpdcch_config_r13->present is not setup\n"); + AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->present == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup, + "epdcch_setconfig_r11->ext2->mpdcch_config_r13->present is not setup\n"); AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 != NULL, "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 is null"); - AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present == LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup, - "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present is not setup\n"); - + AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present == LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup, + "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present is not setup\n"); LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL 6-0A MPDCCH for BL/CE UE %d/%x, ulsch_frame %d, ulsch_subframe %d,UESS MPDCCH Narrowband %d\n", - harq_pid, - frameP, - subframeP, - UE_id, - rnti, - sched_frame, - sched_subframeP, - (int)epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1); - - UE_template->first_rb_ul[harq_pid] = narrowband_to_first_rb(cc, epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1); - + harq_pid, + frameP, + subframeP, + UE_id, + rnti, + sched_frame, + sched_subframeP, + (int)epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1); + UE_template->first_rb_ul[harq_pid] = narrowband_to_first_rb(cc, epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1); hi_dci0_pdu = &(hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi]); - - memset((void*) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t)); - - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE; - hi_dci0_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu)); - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_format = (UE_template->rach_resource_type > 1) ? 5 : 4; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type > 1) ? 2 : 1; + memset((void *) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE; + hi_dci0_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu)); + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_format = (UE_template->rach_resource_type > 1) ? 5 : 4; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type > 1) ? 2 : 1; hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_narrowband = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_prb_pairs = 6; // checked above that it has to be this - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_transmission_type = epdcch_setconfig_r11->transmissionType_r11; // distibuted - + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_prb_pairs = 6; // checked above that it has to be this + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_transmission_type = epdcch_setconfig_r11->transmissionType_r11; // distibuted AssertFatal(UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 != NULL, - "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 is null\n"); - - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.start_symbol = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ecce_index = 0; // Note: this should be dynamic - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.aggreagation_level = 24; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4 - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti_type = 4; // other - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti = rnti; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type < 3) ? 1 : 2; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.drms_scrambling_init = epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.transmission_power = 6000; // 0dB - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_start = UE_template->first_rb_ul[harq_pid]; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_resource_blocks = 6; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mcs = 4; // adjust according to size of RAR, 208 bits with N1A_PRB=3 - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.pusch_repetition_levels = 0; - + "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 is null\n"); + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.start_symbol = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ecce_index = 0; // Note: this should be dynamic + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.aggreagation_level = 24; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4 + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti_type = 4; // other + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti = rnti; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type < 3) ? 1 : 2; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.drms_scrambling_init = epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.transmission_power = 6000; // 0dB + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_start = UE_template->first_rb_ul[harq_pid]; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_resource_blocks = 6; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mcs = 4; // adjust according to size of RAR, 208 bits with N1A_PRB=3 + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.pusch_repetition_levels = 0; AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13 == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13__setup__mpdcch_pdsch_HoppingConfig_r13_off, - "epdcch_setconfig_r11->ext2->mpdcch_config_r13->mpdcch_pdsch_HoppingConfig_r13 is not off\n"); - + "epdcch_setconfig_r11->ext2->mpdcch_config_r13->mpdcch_pdsch_HoppingConfig_r13 is not off\n"); hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.frequency_hopping_flag = 1 - epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13; hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.redudency_version = rvidx_tab[round_UL&3]; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.new_data_indication = UE_template->oldNDI_UL[harq_pid]; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.harq_process = harq_pid; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tpc = tpc; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.csi_request = cqi_req; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ul_inex = 0; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dai_presence_flag = 0; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dl_assignment_index = 0; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.srs_request = 0; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_subframe_repetition_number = 0; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tcp_bitmap = 0; - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.total_dci_length_include_padding = 29; // hard-coded for 10 MHz - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_tx_antenna_ports = 1; - - hi_dci0_req->number_of_dci++; - - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus], - cqi_req, - cc, - UE_template->physicalConfigDedicated, - get_tmode(module_idP,CC_id,UE_id), - eNB->ul_handle, - rnti, - UE_template->first_rb_ul[harq_pid], // resource_block_start - UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks - UE_template->mcs_UL[harq_pid], - cshift, // cyclic_shift_2_for_drms - 0, // frequency_hopping_enabled_flag - 0, // frequency_hopping_bits - UE_template->oldNDI_UL[harq_pid], // new_data_indication - rvidx_tab[round_UL&3], // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - UE_template->TBS_UL[harq_pid] - ); - - fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus], - UE_template->rach_resource_type>2 ? 2 : 1, - 1, //total_number_of_repetitions - 1, //repetition_number - (frameP * 10) + subframeP); - - ul_req_tmp->number_of_pdus++; - eNB->ul_handle++; - } - } // UE_is_to_be_scheduled + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.new_data_indication = UE_template->oldNDI_UL[harq_pid]; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.harq_process = harq_pid; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tpc = tpc; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.csi_request = cqi_req; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ul_inex = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dai_presence_flag = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dl_assignment_index = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.srs_request = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_subframe_repetition_number = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tcp_bitmap = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.total_dci_length_include_padding = 29; // hard-coded for 10 MHz + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_tx_antenna_ports = 1; + hi_dci0_req->number_of_dci++; + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus], + cqi_req, + cc, + UE_template->physicalConfigDedicated, + get_tmode(module_idP,CC_id,UE_id), + eNB->ul_handle, + rnti, + UE_template->first_rb_ul[harq_pid], // resource_block_start + UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks + UE_template->mcs_UL[harq_pid], + cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + UE_template->oldNDI_UL[harq_pid], // new_data_indication + rvidx_tab[round_UL&3], // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + UE_template->TBS_UL[harq_pid] + ); + fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus], + UE_template->rach_resource_type>2 ? 2 : 1, + 1, //total_number_of_repetitions + 1, //repetition_number + (frameP * 10) + subframeP); + ul_req_tmp->number_of_pdus++; + eNB->ul_handle++; + } + } // UE_is_to_be_scheduled } // ULCCs } // loop over UE_id } diff --git a/openair2/LAYER2/MAC/main_ue.c b/openair2/LAYER2/MAC/main_ue.c index bf4af9f5a9225aed83d6720a6cf1345c59da0056..f482806e1d198ef7ed98a3e97f6cf6c1192e5ab2 100644 --- a/openair2/LAYER2/MAC/main_ue.c +++ b/openair2/LAYER2/MAC/main_ue.c @@ -39,12 +39,12 @@ #include "LAYER2/PDCP_v10.1.0/pdcp.h" #include "RRC/LTE/rrc_defs.h" #include "common/utils/LOG/log.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "common/ran_context.h" extern FILL_UL_INFO_MUTEX_t fill_ul_mutex; -extern uint8_t nfapi_mode; extern void openair_rrc_top_init_ue( int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active); void dl_phy_sync_success(module_id_t module_idP, frame_t frameP, unsigned char eNB_index, uint8_t first_sync) { //init as MR @@ -91,7 +91,7 @@ mac_top_init_ue(int eMBMS_active, char *uecap_xer, } // mutex below are used for multiple UE's L2 FAPI simulation. - if (nfapi_mode == 3) { + if (NFAPI_MODE == NFAPI_UE_STUB_PNF) { pthread_mutex_init(&fill_ul_mutex.rx_mutex,NULL); pthread_mutex_init(&fill_ul_mutex.crc_mutex,NULL); pthread_mutex_init(&fill_ul_mutex.sr_mutex,NULL); diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c index d139c8bd472de11fe9350090f0f451c11d32db03..70cee3e24bc26f41a600f6cb0d1083ae6508e501 100644 --- a/openair2/LAYER2/MAC/ra_procedures.c +++ b/openair2/LAYER2/MAC/ra_procedures.c @@ -40,585 +40,586 @@ #include "RRC/LTE/rrc_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "common/utils/LOG/log.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "UTIL/OPT/opt.h" #include "OCG.h" #include "OCG_extern.h" -#include "SIMULATION/TOOLS/sim.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus #include "PHY/LTE_TRANSPORT/transport_common_proto.h" #include "PHY/LTE_ESTIMATION/lte_estimation.h" -extern uint8_t nfapi_mode; + extern UE_MODE_t get_ue_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); /// This routine implements Section 5.1.2 (UE Random Access Resource Selection) from 36.321 void get_prach_resources(module_id_t module_idP, - int CC_id, - uint8_t eNB_index, - uint8_t t_id, - uint8_t first_Msg3, - LTE_RACH_ConfigDedicated_t * rach_ConfigDedicated) -{ - uint8_t Msg3_size = UE_mac_inst[module_idP].RA_Msg3_size; - PRACH_RESOURCES_t *prach_resources = - &UE_mac_inst[module_idP].RA_prach_resources; - LTE_RACH_ConfigCommon_t *rach_ConfigCommon = NULL; - uint8_t noGroupB = 0; - uint8_t f_id = 0, num_prach = 0; - int numberOfRA_Preambles; - int messageSizeGroupA; - int sizeOfRA_PreamblesGroupA; - int messagePowerOffsetGroupB; - int PLThreshold; - - AssertFatal(CC_id == 0, - "Transmission on secondary CCs is not supported yet\n"); - AssertFatal(UE_mac_inst[module_idP].radioResourceConfigCommon != NULL, - "[UE %d] FATAL radioResourceConfigCommon is NULL !!!\n", - module_idP); - - rach_ConfigCommon = - &UE_mac_inst[module_idP].radioResourceConfigCommon-> - rach_ConfigCommon; - numberOfRA_Preambles = - (1 + rach_ConfigCommon->preambleInfo.numberOfRA_Preambles) << 2; - - if (rach_ConfigDedicated) { // This is for network controlled Mobility, later - if (rach_ConfigDedicated->ra_PRACH_MaskIndex != 0) { - prach_resources->ra_PreambleIndex = - rach_ConfigDedicated->ra_PreambleIndex; - prach_resources->ra_RACH_MaskIndex = - rach_ConfigDedicated->ra_PRACH_MaskIndex; - return; - } + int CC_id, + uint8_t eNB_index, + uint8_t t_id, + uint8_t first_Msg3, + LTE_RACH_ConfigDedicated_t *rach_ConfigDedicated) { + uint8_t Msg3_size = UE_mac_inst[module_idP].RA_Msg3_size; + PRACH_RESOURCES_t *prach_resources = + &UE_mac_inst[module_idP].RA_prach_resources; + LTE_RACH_ConfigCommon_t *rach_ConfigCommon = NULL; + uint8_t noGroupB = 0; + uint8_t f_id = 0, num_prach = 0; + int numberOfRA_Preambles; + int messageSizeGroupA; + int sizeOfRA_PreamblesGroupA; + int messagePowerOffsetGroupB; + int PLThreshold; + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + AssertFatal(UE_mac_inst[module_idP].radioResourceConfigCommon != NULL, + "[UE %d] FATAL radioResourceConfigCommon is NULL !!!\n", + module_idP); + rach_ConfigCommon = + &UE_mac_inst[module_idP].radioResourceConfigCommon-> + rach_ConfigCommon; + numberOfRA_Preambles = + (1 + rach_ConfigCommon->preambleInfo.numberOfRA_Preambles) << 2; + + if (rach_ConfigDedicated) { // This is for network controlled Mobility, later + if (rach_ConfigDedicated->ra_PRACH_MaskIndex != 0) { + prach_resources->ra_PreambleIndex = + rach_ConfigDedicated->ra_PreambleIndex; + prach_resources->ra_RACH_MaskIndex = + rach_ConfigDedicated->ra_PRACH_MaskIndex; + return; + } + } + + /* TODO: gcc warns if this variable is not always set, let's put -1 for no more warning */ + messageSizeGroupA = -1; + + if (!rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) { + noGroupB = 1; + } else { + sizeOfRA_PreamblesGroupA = + (rach_ConfigCommon->preambleInfo. + preamblesGroupAConfig->sizeOfRA_PreamblesGroupA + 1) << 2; + + switch (rach_ConfigCommon->preambleInfo. + preamblesGroupAConfig->messageSizeGroupA) { + case 0: + messageSizeGroupA = 56; + break; + + case 1: + messageSizeGroupA = 144; + break; + + case 2: + messageSizeGroupA = 208; + break; + + case 3: + messageSizeGroupA = 256; + break; } - /* TODO: gcc warns if this variable is not always set, let's put -1 for no more warning */ - messageSizeGroupA = -1; + /* TODO: what value to use as default? */ + messagePowerOffsetGroupB = -9999; - if (!rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) { - noGroupB = 1; - } else { - sizeOfRA_PreamblesGroupA = - (rach_ConfigCommon->preambleInfo. - preamblesGroupAConfig->sizeOfRA_PreamblesGroupA + 1) << 2; - switch (rach_ConfigCommon->preambleInfo. - preamblesGroupAConfig->messageSizeGroupA) { - case 0: - messageSizeGroupA = 56; - break; - case 1: - messageSizeGroupA = 144; - break; - case 2: - messageSizeGroupA = 208; - break; - case 3: - messageSizeGroupA = 256; - break; - } - - /* TODO: what value to use as default? */ - messagePowerOffsetGroupB = -9999; - switch (rach_ConfigCommon->preambleInfo. - preamblesGroupAConfig->messagePowerOffsetGroupB) { - case 0: - messagePowerOffsetGroupB = -9999; - break; - case 1: - messagePowerOffsetGroupB = 0; - break; - case 2: - messagePowerOffsetGroupB = 5; - break; - case 3: - messagePowerOffsetGroupB = 8; - break; - case 4: - messagePowerOffsetGroupB = 10; - break; - case 5: - messagePowerOffsetGroupB = 12; - break; - case 6: - messagePowerOffsetGroupB = 15; - break; - case 7: - messagePowerOffsetGroupB = 18; - break; - } - - PLThreshold = - 0 - get_DELTA_PREAMBLE(module_idP, - CC_id) - - get_Po_NOMINAL_PUSCH(module_idP, - CC_id) - messagePowerOffsetGroupB; - // Note Pcmax is set to 0 here, we have to fix this - - if (sizeOfRA_PreamblesGroupA == numberOfRA_Preambles) { - noGroupB = 1; - } + switch (rach_ConfigCommon->preambleInfo. + preamblesGroupAConfig->messagePowerOffsetGroupB) { + case 0: + messagePowerOffsetGroupB = -9999; + break; + + case 1: + messagePowerOffsetGroupB = 0; + break; + + case 2: + messagePowerOffsetGroupB = 5; + break; + + case 3: + messagePowerOffsetGroupB = 8; + break; + + case 4: + messagePowerOffsetGroupB = 10; + break; + + case 5: + messagePowerOffsetGroupB = 12; + break; + + case 6: + messagePowerOffsetGroupB = 15; + break; + + case 7: + messagePowerOffsetGroupB = 18; + break; } - if (first_Msg3 == 1) { - if (noGroupB == 1) { - // use Group A procedure - UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = - (taus()) % numberOfRA_Preambles; - UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = - 0; - UE_mac_inst[module_idP].RA_usedGroupA = 1; - } else if ((Msg3_size < messageSizeGroupA) || - (get_PL(module_idP, 0, eNB_index) > PLThreshold)) { - // use Group A procedure - UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = - (taus()) % sizeOfRA_PreamblesGroupA; - UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = - 0; - UE_mac_inst[module_idP].RA_usedGroupA = 1; - } else { // use Group B - UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = - sizeOfRA_PreamblesGroupA + - (taus()) % (numberOfRA_Preambles - - sizeOfRA_PreamblesGroupA); - UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = - 0; - UE_mac_inst[module_idP].RA_usedGroupA = 0; - } - - UE_mac_inst[module_idP]. - RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER = - get_Po_NOMINAL_PUSCH(module_idP, CC_id); - } else { // Msg3 is being retransmitted - if (UE_mac_inst[module_idP].RA_usedGroupA == 1) { - if (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) { - UE_mac_inst[module_idP].RA_prach_resources. - ra_PreambleIndex = - (taus()) % - rach_ConfigCommon->preambleInfo. - preamblesGroupAConfig->sizeOfRA_PreamblesGroupA; - } else { - UE_mac_inst[module_idP].RA_prach_resources. - ra_PreambleIndex = (taus()) & 0x3f; - } - - UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = - 0; - } else { - // FIXME rach_ConfigCommon->preambleInfo.preamblesGroupAConfig may be zero - UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = - rach_ConfigCommon->preambleInfo. - preamblesGroupAConfig->sizeOfRA_PreamblesGroupA + - (taus()) % - (rach_ConfigCommon->preambleInfo.numberOfRA_Preambles - - rach_ConfigCommon->preambleInfo. - preamblesGroupAConfig->sizeOfRA_PreamblesGroupA); - UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = - 0; - } + PLThreshold = + 0 - get_DELTA_PREAMBLE(module_idP, + CC_id) - + get_Po_NOMINAL_PUSCH(module_idP, + CC_id) - messagePowerOffsetGroupB; + // Note Pcmax is set to 0 here, we have to fix this + + if (sizeOfRA_PreamblesGroupA == numberOfRA_Preambles) { + noGroupB = 1; + } + } + + if (first_Msg3 == 1) { + if (noGroupB == 1) { + // use Group A procedure + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = + (taus()) % numberOfRA_Preambles; + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = + 0; + UE_mac_inst[module_idP].RA_usedGroupA = 1; + } else if ((Msg3_size < messageSizeGroupA) || + (get_PL(module_idP, 0, eNB_index) > PLThreshold)) { + // use Group A procedure + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = + (taus()) % sizeOfRA_PreamblesGroupA; + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = + 0; + UE_mac_inst[module_idP].RA_usedGroupA = 1; + } else { // use Group B + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = + sizeOfRA_PreamblesGroupA + + (taus()) % (numberOfRA_Preambles - + sizeOfRA_PreamblesGroupA); + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = + 0; + UE_mac_inst[module_idP].RA_usedGroupA = 0; } - // choose random PRACH resource in TDD - if (UE_mac_inst[module_idP].tdd_Config) { - num_prach = get_num_prach_tdd(module_idP); + UE_mac_inst[module_idP]. + RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER = + get_Po_NOMINAL_PUSCH(module_idP, CC_id); + } else { // Msg3 is being retransmitted + if (UE_mac_inst[module_idP].RA_usedGroupA == 1) { + if (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) { + UE_mac_inst[module_idP].RA_prach_resources. + ra_PreambleIndex = + (taus()) % + rach_ConfigCommon->preambleInfo. + preamblesGroupAConfig->sizeOfRA_PreamblesGroupA; + } else { + UE_mac_inst[module_idP].RA_prach_resources. + ra_PreambleIndex = (taus()) & 0x3f; + } + + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = + 0; + } else { + // FIXME rach_ConfigCommon->preambleInfo.preamblesGroupAConfig may be zero + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = + rach_ConfigCommon->preambleInfo. + preamblesGroupAConfig->sizeOfRA_PreamblesGroupA + + (taus()) % + (rach_ConfigCommon->preambleInfo.numberOfRA_Preambles - + rach_ConfigCommon->preambleInfo. + preamblesGroupAConfig->sizeOfRA_PreamblesGroupA); + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = + 0; + } + } - if ((num_prach > 0) && (num_prach < 6)) { - UE_mac_inst[module_idP].RA_prach_resources.ra_TDD_map_index = - (taus() % num_prach); - } + // choose random PRACH resource in TDD + if (UE_mac_inst[module_idP].tdd_Config) { + num_prach = get_num_prach_tdd(module_idP); - f_id = get_fid_prach_tdd(module_idP, - UE_mac_inst - [module_idP].RA_prach_resources. - ra_TDD_map_index); + if ((num_prach > 0) && (num_prach < 6)) { + UE_mac_inst[module_idP].RA_prach_resources.ra_TDD_map_index = + (taus() % num_prach); } - // choose RA-RNTI - UE_mac_inst[module_idP].RA_prach_resources.ra_RNTI = - 1 + t_id + 10 * f_id; + + f_id = get_fid_prach_tdd(module_idP, + UE_mac_inst + [module_idP].RA_prach_resources. + ra_TDD_map_index); + } + + // choose RA-RNTI + UE_mac_inst[module_idP].RA_prach_resources.ra_RNTI = + 1 + t_id + 10 * f_id; } void Msg1_transmitted(module_id_t module_idP, uint8_t CC_id, - frame_t frameP, uint8_t eNB_id) -{ - - AssertFatal(CC_id == 0, - "Transmission on secondary CCs is not supported yet\n"); - // start contention resolution timer - UE_mac_inst[module_idP].RA_attempt_number++; - - if (opt_enabled) { - trace_pdu(DIRECTION_UPLINK, NULL, 0, module_idP, WS_NO_RNTI, - UE_mac_inst[module_idP].RA_prach_resources. - ra_PreambleIndex, UE_mac_inst[module_idP].txFrame, - UE_mac_inst[module_idP].txSubframe, 0, - UE_mac_inst[module_idP].RA_attempt_number); - LOG_D(OPT, - "[UE %d][RAPROC] TX MSG1 Frame %d trace pdu for rnti %x with size %d\n", - module_idP, frameP, 1, UE_mac_inst[module_idP].RA_Msg3_size); - } - + frame_t frameP, uint8_t eNB_id) { + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + // start contention resolution timer + UE_mac_inst[module_idP].RA_attempt_number++; + + if (opt_enabled) { + trace_pdu(DIRECTION_UPLINK, NULL, 0, module_idP, WS_NO_RNTI, + UE_mac_inst[module_idP].RA_prach_resources. + ra_PreambleIndex, UE_mac_inst[module_idP].txFrame, + UE_mac_inst[module_idP].txSubframe, 0, + UE_mac_inst[module_idP].RA_attempt_number); + LOG_D(OPT, + "[UE %d][RAPROC] TX MSG1 Frame %d trace pdu for rnti %x with size %d\n", + module_idP, frameP, 1, UE_mac_inst[module_idP].RA_Msg3_size); + } } void Msg3_transmitted(module_id_t module_idP, uint8_t CC_id, - frame_t frameP, uint8_t eNB_id) -{ - - AssertFatal(CC_id == 0, - "Transmission on secondary CCs is not supported yet\n"); - - // start contention resolution timer - LOG_D(MAC, - "[UE %d][RAPROC] Frame %d : Msg3_tx: Setting contention resolution timer\n", - module_idP, frameP); - UE_mac_inst[module_idP].RA_contention_resolution_cnt = 0; - UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 1; - - if (opt_enabled) { // msg3 - trace_pdu(DIRECTION_UPLINK , &UE_mac_inst[module_idP].CCCH_pdu.payload[0], - UE_mac_inst[module_idP].RA_Msg3_size, module_idP, WS_C_RNTI, - UE_mac_inst[module_idP].crnti, - UE_mac_inst[module_idP].txFrame, - UE_mac_inst[module_idP].txSubframe, 0, 0); - LOG_D(OPT, - "[UE %d][RAPROC] MSG3 Frame %d trace pdu Preamble %d with size %d\n", - module_idP, frameP, UE_mac_inst[module_idP].crnti - /*UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex */ - , UE_mac_inst[module_idP].RA_Msg3_size); - } - + frame_t frameP, uint8_t eNB_id) { + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + // start contention resolution timer + LOG_D(MAC, + "[UE %d][RAPROC] Frame %d : Msg3_tx: Setting contention resolution timer\n", + module_idP, frameP); + UE_mac_inst[module_idP].RA_contention_resolution_cnt = 0; + UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 1; + + if (opt_enabled) { // msg3 + trace_pdu(DIRECTION_UPLINK, &UE_mac_inst[module_idP].CCCH_pdu.payload[0], + UE_mac_inst[module_idP].RA_Msg3_size, module_idP, WS_C_RNTI, + UE_mac_inst[module_idP].crnti, + UE_mac_inst[module_idP].txFrame, + UE_mac_inst[module_idP].txSubframe, 0, 0); + LOG_D(OPT, + "[UE %d][RAPROC] MSG3 Frame %d trace pdu Preamble %d with size %d\n", + module_idP, frameP, UE_mac_inst[module_idP].crnti + /*UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex */ + , UE_mac_inst[module_idP].RA_Msg3_size); + } } PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP, int CC_id, - frame_t frameP, uint8_t eNB_indexP, - sub_frame_t subframeP) -{ - - uint8_t Size = 0; - UE_MODE_t UE_mode; - // Modification for phy_stub_ue operation - if(nfapi_mode == 3) { // phy_stub_ue mode - UE_mode = UE_mac_inst[module_idP].UE_mode[0]; - LOG_D(MAC, "ue_get_rach , UE_mode: %d", UE_mode); - } - else { // Full stack mode - UE_mode = get_ue_mode(module_idP,0,eNB_indexP); + frame_t frameP, uint8_t eNB_indexP, + sub_frame_t subframeP) { + uint8_t Size = 0; + UE_MODE_t UE_mode; + + // Modification for phy_stub_ue operation + if(NFAPI_MODE == NFAPI_UE_STUB_PNF) { // phy_stub_ue mode + UE_mode = UE_mac_inst[module_idP].UE_mode[0]; + LOG_D(MAC, "ue_get_rach , UE_mode: %d", UE_mode); + } else { // Full stack mode + UE_mode = get_ue_mode(module_idP,0,eNB_indexP); + } + + uint8_t lcid = CCCH; + uint16_t Size16; + struct LTE_RACH_ConfigCommon *rach_ConfigCommon = + (struct LTE_RACH_ConfigCommon *) NULL; + int32_t frame_diff = 0; + uint8_t dcch_header_len = 0; + uint16_t sdu_lengths; + uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + + if (UE_mode == PRACH) { + LOG_D(MAC, "ue_get_rach 3, RA_active value: %d", UE_mac_inst[module_idP].RA_active); + + if (UE_mac_inst[module_idP].radioResourceConfigCommon) { + rach_ConfigCommon = + &UE_mac_inst[module_idP]. + radioResourceConfigCommon->rach_ConfigCommon; + } else { + return (NULL); } - - uint8_t lcid = CCCH; - uint16_t Size16; - struct LTE_RACH_ConfigCommon *rach_ConfigCommon = - (struct LTE_RACH_ConfigCommon *) NULL; - int32_t frame_diff = 0; - uint8_t dcch_header_len = 0; - uint16_t sdu_lengths; - uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; - - AssertFatal(CC_id == 0, - "Transmission on secondary CCs is not supported yet\n"); - - if (UE_mode == PRACH) { - LOG_D(MAC, "ue_get_rach 3, RA_active value: %d", UE_mac_inst[module_idP].RA_active); - if (UE_mac_inst[module_idP].radioResourceConfigCommon) { - rach_ConfigCommon = - &UE_mac_inst[module_idP]. - radioResourceConfigCommon->rach_ConfigCommon; - } else { - return (NULL); - } - - if (UE_mac_inst[module_idP].RA_active == 0) { - LOG_I(MAC, "RA not active\n"); - // check if RRC is ready to initiate the RA procedure - Size = mac_rrc_data_req_ue(module_idP, - CC_id, - frameP, - CCCH, 1, - &UE_mac_inst[module_idP]. - CCCH_pdu.payload[sizeof - (SCH_SUBHEADER_SHORT) - + 1], eNB_indexP, - 0); - Size16 = (uint16_t) Size; - - // LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size); - LOG_I(RRC, - "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_DATA_REQ (RRCConnectionRequest eNB %d) --->][MAC_UE][MOD %02d][]\n", - frameP, module_idP, eNB_indexP, module_idP); - LOG_I(MAC, - "[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n", - module_idP, frameP, Size); - - if (Size > 0) { - UE_mac_inst[module_idP].RA_active = 1; - UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = - 1; - UE_mac_inst[module_idP].RA_Msg3_size = - Size + sizeof(SCH_SUBHEADER_SHORT) + - sizeof(SCH_SUBHEADER_SHORT); - UE_mac_inst[module_idP].RA_prachMaskIndex = 0; - UE_mac_inst[module_idP].RA_prach_resources.Msg3 = - UE_mac_inst[module_idP].CCCH_pdu.payload; - UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) - - AssertFatal(rach_ConfigCommon != NULL, - "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n", - module_idP, frameP); - UE_mac_inst[module_idP].RA_window_cnt = - 2 + - rach_ConfigCommon->ra_SupervisionInfo. - ra_ResponseWindowSize; - - if (UE_mac_inst[module_idP].RA_window_cnt == 9) { - UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! - } - - UE_mac_inst[module_idP].RA_tx_frame = frameP; - UE_mac_inst[module_idP].RA_tx_subframe = subframeP; - UE_mac_inst[module_idP].RA_backoff_frame = frameP; - UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; - // Fill in preamble and PRACH resource - get_prach_resources(module_idP, CC_id, eNB_indexP, - subframeP, 1, NULL); - - generate_ulsch_header((uint8_t *) & UE_mac_inst[module_idP].CCCH_pdu.payload[0], // mac header - 1, // num sdus - 0, // short pading - &Size16, // sdu length - &lcid, // sdu lcid - NULL, // power headroom - NULL, // crnti - NULL, // truncated bsr - NULL, // short bsr - NULL, // long_bsr - 1); //post_padding - return (&UE_mac_inst[module_idP].RA_prach_resources); - - } else if (UE_mac_inst[module_idP]. - scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. - scheduling_info.LCGID - [DCCH]] > 0) { - // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) - dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element - LOG_USEDINLOG_VAR(mac_rlc_status_resp_t,rlc_status)=mac_rlc_status_ind(module_idP, - UE_mac_inst[module_idP].crnti, - eNB_indexP, frameP, subframeP, - ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, 6 + if (UE_mac_inst[module_idP].RA_active == 0) { + LOG_I(MAC, "RA not active\n"); + // check if RRC is ready to initiate the RA procedure + Size = mac_rrc_data_req_ue(module_idP, + CC_id, + frameP, + CCCH, 1, + &UE_mac_inst[module_idP]. + CCCH_pdu.payload[sizeof + (SCH_SUBHEADER_SHORT) + + 1], eNB_indexP, + 0); + Size16 = (uint16_t) Size; + // LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size); + LOG_I(RRC, + "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_DATA_REQ (RRCConnectionRequest eNB %d) --->][MAC_UE][MOD %02d][]\n", + frameP, module_idP, eNB_indexP, module_idP); + LOG_I(MAC, + "[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n", + module_idP, frameP, Size); + + if (Size > 0) { + UE_mac_inst[module_idP].RA_active = 1; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = + 1; + UE_mac_inst[module_idP].RA_Msg3_size = + Size + sizeof(SCH_SUBHEADER_SHORT) + + sizeof(SCH_SUBHEADER_SHORT); + UE_mac_inst[module_idP].RA_prachMaskIndex = 0; + UE_mac_inst[module_idP].RA_prach_resources.Msg3 = + UE_mac_inst[module_idP].CCCH_pdu.payload; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) + AssertFatal(rach_ConfigCommon != NULL, + "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n", + module_idP, frameP); + UE_mac_inst[module_idP].RA_window_cnt = + 2 + + rach_ConfigCommon->ra_SupervisionInfo. + ra_ResponseWindowSize; + + if (UE_mac_inst[module_idP].RA_window_cnt == 9) { + UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! + } + + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + // Fill in preamble and PRACH resource + get_prach_resources(module_idP, CC_id, eNB_indexP, + subframeP, 1, NULL); + generate_ulsch_header((uint8_t *) & UE_mac_inst[module_idP].CCCH_pdu.payload[0], // mac header + 1, // num sdus + 0, // short pading + &Size16, // sdu length + &lcid, // sdu lcid + NULL, // power headroom + NULL, // crnti + NULL, // truncated bsr + NULL, // short bsr + NULL, // long_bsr + 1); //post_padding + return (&UE_mac_inst[module_idP].RA_prach_resources); + } else if (UE_mac_inst[module_idP]. + scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. + scheduling_info.LCGID + [DCCH]] > 0) { + // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) + dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element + LOG_USEDINLOG_VAR(mac_rlc_status_resp_t,rlc_status)=mac_rlc_status_ind(module_idP, + UE_mac_inst[module_idP].crnti, + eNB_indexP, frameP, subframeP, + ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, 6 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); - - if (UE_mac_inst[module_idP].crnti_before_ho) - LOG_D(MAC, - "[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send throug PRACH (mac header len %d)\n", - module_idP, frameP, - UE_mac_inst[module_idP].crnti, - UE_mac_inst[module_idP].crnti_before_ho, - rlc_status.bytes_in_buffer, dcch_header_len); - else - LOG_D(MAC, - "[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to send through PRACH(mac header len %d)\n", - module_idP, frameP, rlc_status.bytes_in_buffer, - dcch_header_len); - - sdu_lengths = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, eNB_indexP, frameP, ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, 6, //not used - (char *) &ulsch_buff[0] + ); + + if (UE_mac_inst[module_idP].crnti_before_ho) + LOG_D(MAC, + "[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send throug PRACH (mac header len %d)\n", + module_idP, frameP, + UE_mac_inst[module_idP].crnti, + UE_mac_inst[module_idP].crnti_before_ho, + rlc_status.bytes_in_buffer, dcch_header_len); + else + LOG_D(MAC, + "[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to send through PRACH(mac header len %d)\n", + module_idP, frameP, rlc_status.bytes_in_buffer, + dcch_header_len); + + sdu_lengths = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, eNB_indexP, frameP, ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, 6, //not used + (char *) &ulsch_buff[0] #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, - 0 + ,0, + 0 #endif - ); - - if(sdu_lengths > 0) - LOG_D(MAC, "[UE %d] TX Got %d bytes for DCCH\n", - module_idP, sdu_lengths); - else - LOG_E(MAC, "[UE %d] TX DCCH error\n", - module_idP ); - - update_bsr(module_idP, frameP, subframeP, eNB_indexP); - UE_mac_inst[module_idP]. - scheduling_info.BSR[UE_mac_inst[module_idP]. - scheduling_info.LCGID[DCCH]] = - locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, - UE_mac_inst - [module_idP].scheduling_info.BSR_bytes - [UE_mac_inst - [module_idP].scheduling_info.LCGID - [DCCH]]); - - //TO DO: fill BSR infos in UL TBS - - //header_len +=2; - UE_mac_inst[module_idP].RA_active = 1; - UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = - 1; - UE_mac_inst[module_idP].RA_Msg3_size = - Size + dcch_header_len; - UE_mac_inst[module_idP].RA_prachMaskIndex = 0; - UE_mac_inst[module_idP].RA_prach_resources.Msg3 = - ulsch_buff; - UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) - - AssertFatal(rach_ConfigCommon != NULL, - "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n", - module_idP, frameP); - UE_mac_inst[module_idP].RA_window_cnt = - 2 + - rach_ConfigCommon->ra_SupervisionInfo. - ra_ResponseWindowSize; - - if (UE_mac_inst[module_idP].RA_window_cnt == 9) { - UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! - } - - - UE_mac_inst[module_idP].RA_tx_frame = frameP; - UE_mac_inst[module_idP].RA_tx_subframe = subframeP; - UE_mac_inst[module_idP].RA_backoff_frame = frameP; - UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; - // Fill in preamble and PRACH resource - get_prach_resources(module_idP, CC_id, eNB_indexP, - subframeP, 1, NULL); - generate_ulsch_header((uint8_t *) ulsch_buff, // mac header - 1, // num sdus - 0, // short pading - &Size16, // sdu length - &lcid, // sdu lcid - NULL, // power headroom - &UE_mac_inst[module_idP].crnti, // crnti - NULL, // truncated bsr - NULL, // short bsr - NULL, // long_bsr - 0); //post_padding - - return (&UE_mac_inst[module_idP].RA_prach_resources); - } - } else { // RACH is active - LOG_D(MAC, - "[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, window cnt %d (RA_tx_frame %d, RA_tx_subframe %d)\n", - module_idP, frameP, subframeP, - UE_mac_inst[module_idP].RA_window_cnt, - UE_mac_inst[module_idP].RA_tx_frame, - UE_mac_inst[module_idP].RA_tx_subframe); - - // compute backoff parameters - if (UE_mac_inst[module_idP].RA_backoff_cnt > 0) { - frame_diff = - (sframe_t) frameP - - UE_mac_inst[module_idP].RA_backoff_frame; - - if (frame_diff < 0) { - frame_diff = -frame_diff; - } - - UE_mac_inst[module_idP].RA_backoff_cnt -= - ((10 * frame_diff) + - (subframeP - - UE_mac_inst[module_idP].RA_backoff_subframe)); - - UE_mac_inst[module_idP].RA_backoff_frame = frameP; - UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; - } - // compute RA window parameters - if (UE_mac_inst[module_idP].RA_window_cnt > 0) { - frame_diff = - (frame_t) frameP - UE_mac_inst[module_idP].RA_tx_frame; - - if (frame_diff < 0) { - frame_diff = -frame_diff; - } - - UE_mac_inst[module_idP].RA_window_cnt -= - ((10 * frame_diff) + - (subframeP - UE_mac_inst[module_idP].RA_tx_subframe)); - LOG_D(MAC, - "[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, adjusted window cnt %d\n", - module_idP, frameP, subframeP, - UE_mac_inst[module_idP].RA_window_cnt); - } - - if ((UE_mac_inst[module_idP].RA_window_cnt <= 0) && - (UE_mac_inst[module_idP].RA_backoff_cnt <= 0)) { - - UE_mac_inst[module_idP].RA_tx_frame = frameP; - UE_mac_inst[module_idP].RA_tx_subframe = subframeP; - UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER++; - UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER += (rach_ConfigCommon->powerRampingParameters.powerRampingStep << 1); // 2dB increments in ASN.1 definition - int preambleTransMax = -1; - switch (rach_ConfigCommon->ra_SupervisionInfo. - preambleTransMax) { - case LTE_PreambleTransMax_n3: - preambleTransMax = 3; - break; - case LTE_PreambleTransMax_n4: - preambleTransMax = 4; - break; - case LTE_PreambleTransMax_n5: - preambleTransMax = 5; - break; - case LTE_PreambleTransMax_n6: - preambleTransMax = 6; - break; - case LTE_PreambleTransMax_n7: - preambleTransMax = 7; - break; - case LTE_PreambleTransMax_n8: - preambleTransMax = 8; - break; - case LTE_PreambleTransMax_n10: - preambleTransMax = 10; - break; - case LTE_PreambleTransMax_n20: - preambleTransMax = 20; - break; - case LTE_PreambleTransMax_n50: - preambleTransMax = 50; - break; - case LTE_PreambleTransMax_n100: - preambleTransMax = 100; - break; - case LTE_PreambleTransMax_n200: - preambleTransMax = 200; - break; - } - - if (UE_mac_inst[module_idP]. - RA_PREAMBLE_TRANSMISSION_COUNTER == preambleTransMax) { - LOG_D(MAC, - "[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n", - module_idP, frameP, preambleTransMax); - // send message to RRC - UE_mac_inst[module_idP]. - RA_PREAMBLE_TRANSMISSION_COUNTER = 1; - UE_mac_inst[module_idP]. - RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER - = get_Po_NOMINAL_PUSCH(module_idP, CC_id); - } - - UE_mac_inst[module_idP].RA_window_cnt = - 2 + - rach_ConfigCommon->ra_SupervisionInfo. - ra_ResponseWindowSize; - UE_mac_inst[module_idP].RA_backoff_cnt = 0; - - // Fill in preamble and PRACH resource - get_prach_resources(module_idP, CC_id, eNB_indexP, - subframeP, 0, NULL); - return (&UE_mac_inst[module_idP].RA_prach_resources); - } - } - } else if (UE_mode == PUSCH) { - LOG_D(MAC, - "[UE %d] FATAL: Should not have checked for RACH in PUSCH yet ...", - module_idP); - AssertFatal(1 == 0, ""); + ); + + if(sdu_lengths > 0) + LOG_D(MAC, "[UE %d] TX Got %d bytes for DCCH\n", + module_idP, sdu_lengths); + else + LOG_E(MAC, "[UE %d] TX DCCH error\n", + module_idP ); + + update_bsr(module_idP, frameP, subframeP, eNB_indexP); + UE_mac_inst[module_idP]. + scheduling_info.BSR[UE_mac_inst[module_idP]. + scheduling_info.LCGID[DCCH]] = + locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, + UE_mac_inst + [module_idP].scheduling_info.BSR_bytes + [UE_mac_inst + [module_idP].scheduling_info.LCGID + [DCCH]]); + //TO DO: fill BSR infos in UL TBS + //header_len +=2; + UE_mac_inst[module_idP].RA_active = 1; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = + 1; + UE_mac_inst[module_idP].RA_Msg3_size = + Size + dcch_header_len; + UE_mac_inst[module_idP].RA_prachMaskIndex = 0; + UE_mac_inst[module_idP].RA_prach_resources.Msg3 = + ulsch_buff; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) + AssertFatal(rach_ConfigCommon != NULL, + "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n", + module_idP, frameP); + UE_mac_inst[module_idP].RA_window_cnt = + 2 + + rach_ConfigCommon->ra_SupervisionInfo. + ra_ResponseWindowSize; + + if (UE_mac_inst[module_idP].RA_window_cnt == 9) { + UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! + } + + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + // Fill in preamble and PRACH resource + get_prach_resources(module_idP, CC_id, eNB_indexP, + subframeP, 1, NULL); + generate_ulsch_header((uint8_t *) ulsch_buff, // mac header + 1, // num sdus + 0, // short pading + &Size16, // sdu length + &lcid, // sdu lcid + NULL, // power headroom + &UE_mac_inst[module_idP].crnti, // crnti + NULL, // truncated bsr + NULL, // short bsr + NULL, // long_bsr + 0); //post_padding + return (&UE_mac_inst[module_idP].RA_prach_resources); + } + } else { // RACH is active + LOG_D(MAC, + "[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, window cnt %d (RA_tx_frame %d, RA_tx_subframe %d)\n", + module_idP, frameP, subframeP, + UE_mac_inst[module_idP].RA_window_cnt, + UE_mac_inst[module_idP].RA_tx_frame, + UE_mac_inst[module_idP].RA_tx_subframe); + + // compute backoff parameters + if (UE_mac_inst[module_idP].RA_backoff_cnt > 0) { + frame_diff = + (sframe_t) frameP - + UE_mac_inst[module_idP].RA_backoff_frame; + + if (frame_diff < 0) { + frame_diff = -frame_diff; + } + + UE_mac_inst[module_idP].RA_backoff_cnt -= + ((10 * frame_diff) + + (subframeP - + UE_mac_inst[module_idP].RA_backoff_subframe)); + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + } + + // compute RA window parameters + if (UE_mac_inst[module_idP].RA_window_cnt > 0) { + frame_diff = + (frame_t) frameP - UE_mac_inst[module_idP].RA_tx_frame; + + if (frame_diff < 0) { + frame_diff = -frame_diff; + } + + UE_mac_inst[module_idP].RA_window_cnt -= + ((10 * frame_diff) + + (subframeP - UE_mac_inst[module_idP].RA_tx_subframe)); + LOG_D(MAC, + "[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, adjusted window cnt %d\n", + module_idP, frameP, subframeP, + UE_mac_inst[module_idP].RA_window_cnt); + } + + if ((UE_mac_inst[module_idP].RA_window_cnt <= 0) && + (UE_mac_inst[module_idP].RA_backoff_cnt <= 0)) { + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER++; + UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER += (rach_ConfigCommon->powerRampingParameters.powerRampingStep << 1); // 2dB increments in ASN.1 definition + int preambleTransMax = -1; + + switch (rach_ConfigCommon->ra_SupervisionInfo. + preambleTransMax) { + case LTE_PreambleTransMax_n3: + preambleTransMax = 3; + break; + + case LTE_PreambleTransMax_n4: + preambleTransMax = 4; + break; + + case LTE_PreambleTransMax_n5: + preambleTransMax = 5; + break; + + case LTE_PreambleTransMax_n6: + preambleTransMax = 6; + break; + + case LTE_PreambleTransMax_n7: + preambleTransMax = 7; + break; + + case LTE_PreambleTransMax_n8: + preambleTransMax = 8; + break; + + case LTE_PreambleTransMax_n10: + preambleTransMax = 10; + break; + + case LTE_PreambleTransMax_n20: + preambleTransMax = 20; + break; + + case LTE_PreambleTransMax_n50: + preambleTransMax = 50; + break; + + case LTE_PreambleTransMax_n100: + preambleTransMax = 100; + break; + + case LTE_PreambleTransMax_n200: + preambleTransMax = 200; + break; + } + + if (UE_mac_inst[module_idP]. + RA_PREAMBLE_TRANSMISSION_COUNTER == preambleTransMax) { + LOG_D(MAC, + "[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n", + module_idP, frameP, preambleTransMax); + // send message to RRC + UE_mac_inst[module_idP]. + RA_PREAMBLE_TRANSMISSION_COUNTER = 1; + UE_mac_inst[module_idP]. + RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER + = get_Po_NOMINAL_PUSCH(module_idP, CC_id); + } + + UE_mac_inst[module_idP].RA_window_cnt = + 2 + + rach_ConfigCommon->ra_SupervisionInfo. + ra_ResponseWindowSize; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; + // Fill in preamble and PRACH resource + get_prach_resources(module_idP, CC_id, eNB_indexP, + subframeP, 0, NULL); + return (&UE_mac_inst[module_idP].RA_prach_resources); + } } + } else if (UE_mode == PUSCH) { + LOG_D(MAC, + "[UE %d] FATAL: Should not have checked for RACH in PUSCH yet ...", + module_idP); + AssertFatal(1 == 0, ""); + } - return (NULL); + return (NULL); } diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 7d77cb62c3ab07e49166c1cead754d4a1f00b2bb..6561cbf6259bcd7d6512629b124544ea20e0ea14 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -30,7 +30,7 @@ */ #ifdef EXMIMO -#include <pthread.h> + #include <pthread.h> #endif #include "mac_extern.h" @@ -46,6 +46,7 @@ #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "RRC/LTE/rrc_extern.h" #include "common/utils/LOG/log.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "OCG.h" @@ -55,12 +56,12 @@ #include "pdcp.h" #if defined(ENABLE_ITTI) -#include "intertask_interface.h" + #include "intertask_interface.h" #endif #include "assertions.h" -#include "SIMULATION/TOOLS/sim.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus #define DEBUG_HEADER_PARSING 1 #define ENABLE_MAC_PAYLOAD_DEBUG 1 @@ -68,7 +69,7 @@ extern UL_IND_t *UL_INFO; -extern uint8_t nfapi_mode; + extern int next_ra_frame; extern module_id_t next_Mod_id; @@ -80,854 +81,812 @@ extern module_id_t next_Mod_id; */ mapping BSR_names[] = { - {"NONE", 0}, - {"SHORT BSR", 1}, - {"TRUNCATED BSR", 2}, - {"LONG BSR", 3}, - {"PADDING BSR", 4}, - {NULL, -1} + {"NONE", 0}, + {"SHORT BSR", 1}, + {"TRUNCATED BSR", 2}, + {"LONG BSR", 3}, + {"PADDING BSR", 4}, + {NULL, -1} }; -void ue_init_mac(module_id_t module_idP) -{ - - int i; - // default values as deined in 36.331 sec 9.2.2 - LOG_I(MAC, "[UE%d] Applying default macMainConfig\n", module_idP); - //UE_mac_inst[module_idP].scheduling_info.macConfig=NULL; - UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer = - LTE_RetxBSR_Timer_r12_sf10240; - UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer = - LTE_PeriodicBSR_Timer_r12_infinity; - UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer = - LTE_MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; - UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer = - LTE_MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; - UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = - LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; - UE_mac_inst[module_idP].PHR_state = - LTE_MAC_MainConfig__phr_Config_PR_setup; - UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0; - UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer = 0; - UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running = 0; - UE_mac_inst[module_idP].scheduling_info.maxHARQ_Tx = - LTE_MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; - UE_mac_inst[module_idP].scheduling_info.ttiBundling = 0; - UE_mac_inst[module_idP].scheduling_info.extendedBSR_Sizes_r10 = 0; - UE_mac_inst[module_idP].scheduling_info.extendedPHR_r10 = 0; - UE_mac_inst[module_idP].scheduling_info.drx_config = NULL; - UE_mac_inst[module_idP].scheduling_info.phr_config = NULL; - // set init value 0xFFFF, make sure periodic timer and retx time counters are NOT active, after bsr transmission set the value configured by the NW. - UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = - MAC_UE_BSR_TIMER_NOT_RUNNING; - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = - MAC_UE_BSR_TIMER_NOT_RUNNING; - UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE; - - UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = - get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP]. - scheduling_info.periodicPHR_Timer); - UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = - get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP]. - scheduling_info.prohibitPHR_Timer); - UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = - get_db_dl_PathlossChange(UE_mac_inst[module_idP]. - scheduling_info.PathlossChange); - UE_mac_inst[module_idP].PHR_reporting_active = 0; +void ue_init_mac(module_id_t module_idP) { + int i; + // default values as deined in 36.331 sec 9.2.2 + LOG_I(MAC, "[UE%d] Applying default macMainConfig\n", module_idP); + //UE_mac_inst[module_idP].scheduling_info.macConfig=NULL; + UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer = + LTE_RetxBSR_Timer_r12_sf10240; + UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer = + LTE_PeriodicBSR_Timer_r12_infinity; + UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer = + LTE_MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; + UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer = + LTE_MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; + UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = + LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; + UE_mac_inst[module_idP].PHR_state = + LTE_MAC_MainConfig__phr_Config_PR_setup; + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0; + UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer = 0; + UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running = 0; + UE_mac_inst[module_idP].scheduling_info.maxHARQ_Tx = + LTE_MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; + UE_mac_inst[module_idP].scheduling_info.ttiBundling = 0; + UE_mac_inst[module_idP].scheduling_info.extendedBSR_Sizes_r10 = 0; + UE_mac_inst[module_idP].scheduling_info.extendedPHR_r10 = 0; + UE_mac_inst[module_idP].scheduling_info.drx_config = NULL; + UE_mac_inst[module_idP].scheduling_info.phr_config = NULL; + // set init value 0xFFFF, make sure periodic timer and retx time counters are NOT active, after bsr transmission set the value configured by the NW. + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = + MAC_UE_BSR_TIMER_NOT_RUNNING; + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = + MAC_UE_BSR_TIMER_NOT_RUNNING; + UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE; + UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = + get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP]. + scheduling_info.periodicPHR_Timer); + UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = + get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP]. + scheduling_info.prohibitPHR_Timer); + UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = + get_db_dl_PathlossChange(UE_mac_inst[module_idP]. + scheduling_info.PathlossChange); + UE_mac_inst[module_idP].PHR_reporting_active = 0; + + for (i = 0; i < MAX_NUM_LCID; i++) { + LOG_D(MAC, + "[UE%d] Applying default logical channel config for LCGID %d\n", + module_idP, i); + UE_mac_inst[module_idP].scheduling_info.Bj[i] = -1; + UE_mac_inst[module_idP].scheduling_info.bucket_size[i] = -1; - for (i = 0; i < MAX_NUM_LCID; i++) { - LOG_D(MAC, - "[UE%d] Applying default logical channel config for LCGID %d\n", - module_idP, i); - UE_mac_inst[module_idP].scheduling_info.Bj[i] = -1; - UE_mac_inst[module_idP].scheduling_info.bucket_size[i] = -1; - - if (i < DTCH) { // initilize all control channels lcgid to 0 - UE_mac_inst[module_idP].scheduling_info.LCGID[i] = 0; - } else { // initialize all the data channels lcgid to 1 - UE_mac_inst[module_idP].scheduling_info.LCGID[i] = 1; - } - - UE_mac_inst[module_idP].scheduling_info.LCID_status[i] = - LCID_EMPTY; - UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[i] = 0; + if (i < DTCH) { // initilize all control channels lcgid to 0 + UE_mac_inst[module_idP].scheduling_info.LCGID[i] = 0; + } else { // initialize all the data channels lcgid to 1 + UE_mac_inst[module_idP].scheduling_info.LCGID[i] = 1; } - if(nfapi_mode == 3) { - pthread_mutex_init(&UE_mac_inst[module_idP].UL_INFO_mutex,NULL); - UE_mac_inst[module_idP].UE_mode[0] = NOT_SYNCHED; //PRACH; - UE_mac_inst[module_idP].first_ULSCH_Tx =0; - UE_mac_inst[module_idP].SI_Decoded = 0; - next_ra_frame = 0; - next_Mod_id = 0; - tx_request_pdu_list = NULL; - tx_req_num_elems = 0; - + UE_mac_inst[module_idP].scheduling_info.LCID_status[i] = + LCID_EMPTY; + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[i] = 0; + } + if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { + pthread_mutex_init(&UE_mac_inst[module_idP].UL_INFO_mutex,NULL); + UE_mac_inst[module_idP].UE_mode[0] = NOT_SYNCHED; //PRACH; + UE_mac_inst[module_idP].first_ULSCH_Tx =0; + UE_mac_inst[module_idP].SI_Decoded = 0; + next_ra_frame = 0; + next_Mod_id = 0; + tx_request_pdu_list = NULL; + tx_req_num_elems = 0; } #ifdef CBA - for (i = 0; i < NUM_MAX_CBA_GROUP; i++) { - UE_mac_inst[module_idP].cba_last_access[i] = - round(uniform_rngen(1, 30)); - } + for (i = 0; i < NUM_MAX_CBA_GROUP; i++) { + UE_mac_inst[module_idP].cba_last_access[i] = + round(uniform_rngen(1, 30)); + } #endif } unsigned char *parse_header(unsigned char *mac_header, - unsigned char *num_ce, - unsigned char *num_sdu, - unsigned char *rx_ces, - unsigned char *rx_lcids, - unsigned short *rx_lengths, - unsigned short tb_length) -{ - - unsigned char not_done = 1, num_ces = 0, num_cont_res = - 0, num_padding = 0, num_sdus = 0, lcid, num_sdu_cnt; - unsigned char *mac_header_ptr = mac_header; - unsigned short length, ce_len = 0; - - while (not_done == 1) { - - if (((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E == 0) { - // printf("E=0\n"); - not_done = 0; - } - - lcid = ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID; - - if (lcid < UE_CONT_RES) { - //printf("[MAC][UE] header %x.%x.%x\n",mac_header_ptr[0],mac_header_ptr[1],mac_header_ptr[2]); - if (not_done == 0) { // last MAC SDU, length is implicit - mac_header_ptr++; - length = - tb_length - (mac_header_ptr - mac_header) - ce_len; - - for (num_sdu_cnt = 0; num_sdu_cnt < num_sdus; - num_sdu_cnt++) { - length -= rx_lengths[num_sdu_cnt]; - } - } else { - if (((SCH_SUBHEADER_LONG *) mac_header_ptr)->F == 1) { - length = - ((((SCH_SUBHEADER_LONG *) mac_header_ptr)-> - L_MSB & 0x7f) - << 8) | (((SCH_SUBHEADER_LONG *) mac_header_ptr)-> - L_LSB & 0xff); - mac_header_ptr += 3; + unsigned char *num_ce, + unsigned char *num_sdu, + unsigned char *rx_ces, + unsigned char *rx_lcids, + unsigned short *rx_lengths, + unsigned short tb_length) { + unsigned char not_done = 1, num_ces = 0, num_cont_res = + 0, num_padding = 0, num_sdus = 0, lcid, num_sdu_cnt; + unsigned char *mac_header_ptr = mac_header; + unsigned short length, ce_len = 0; + + while (not_done == 1) { + if (((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E == 0) { + // printf("E=0\n"); + not_done = 0; + } + + lcid = ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID; + + if (lcid < UE_CONT_RES) { + //printf("[MAC][UE] header %x.%x.%x\n",mac_header_ptr[0],mac_header_ptr[1],mac_header_ptr[2]); + if (not_done == 0) { // last MAC SDU, length is implicit + mac_header_ptr++; + length = + tb_length - (mac_header_ptr - mac_header) - ce_len; + + for (num_sdu_cnt = 0; num_sdu_cnt < num_sdus; + num_sdu_cnt++) { + length -= rx_lengths[num_sdu_cnt]; + } + } else { + if (((SCH_SUBHEADER_LONG *) mac_header_ptr)->F == 1) { + length = + ((((SCH_SUBHEADER_LONG *) mac_header_ptr)-> + L_MSB & 0x7f) + << 8) | (((SCH_SUBHEADER_LONG *) mac_header_ptr)-> + L_LSB & 0xff); + mac_header_ptr += 3; #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC, "[UE] parse long sdu, size %x \n", length); + LOG_D(MAC, "[UE] parse long sdu, size %x \n", length); #endif - - } else { //if (((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0) { - length = ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L; - mac_header_ptr += 2; - } - } + } else { //if (((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0) { + length = ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L; + mac_header_ptr += 2; + } + } #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC, "[UE] sdu %d lcid %d length %d (offset now %ld)\n", - num_sdus, lcid, length, mac_header_ptr - mac_header); + LOG_D(MAC, "[UE] sdu %d lcid %d length %d (offset now %ld)\n", + num_sdus, lcid, length, mac_header_ptr - mac_header); #endif - rx_lcids[num_sdus] = lcid; - rx_lengths[num_sdus] = length; - num_sdus++; - } else { // This is a control element subheader - if (lcid == SHORT_PADDING) { - num_padding++; - mac_header_ptr++; - } else { - rx_ces[num_ces] = lcid; - num_ces++; - mac_header_ptr++; - - if (lcid == TIMING_ADV_CMD) { - ce_len++; - } else if (lcid == UE_CONT_RES) { - - // FNA: check MAC Header is one of thoses defined in Annex B of 36.321 - // Check there is only 1 Contention Resolution - if (num_cont_res) { - LOG_W(MAC, - "[UE] Msg4 Wrong received format: More than 1 Contention Resolution\n"); - // exit parsing - return NULL; - - } - // UE_CONT_RES shall never be the last subheader unless this is the only MAC subheader - if ((not_done == 0) - && ((num_sdus) || (num_ces > 1) || (num_padding))) { - LOG_W(MAC, - "[UE] Msg4 Wrong received format: Contention Resolution after num_ces=%d num_sdus=%d num_padding=%d\n", - num_ces, num_sdus, num_padding); - // exit parsing - return NULL; - } - num_cont_res++; - ce_len += 6; - } - } + rx_lcids[num_sdus] = lcid; + rx_lengths[num_sdus] = length; + num_sdus++; + } else { // This is a control element subheader + if (lcid == SHORT_PADDING) { + num_padding++; + mac_header_ptr++; + } else { + rx_ces[num_ces] = lcid; + num_ces++; + mac_header_ptr++; + + if (lcid == TIMING_ADV_CMD) { + ce_len++; + } else if (lcid == UE_CONT_RES) { + // FNA: check MAC Header is one of thoses defined in Annex B of 36.321 + // Check there is only 1 Contention Resolution + if (num_cont_res) { + LOG_W(MAC, + "[UE] Msg4 Wrong received format: More than 1 Contention Resolution\n"); + // exit parsing + return NULL; + } + + // UE_CONT_RES shall never be the last subheader unless this is the only MAC subheader + if ((not_done == 0) + && ((num_sdus) || (num_ces > 1) || (num_padding))) { + LOG_W(MAC, + "[UE] Msg4 Wrong received format: Contention Resolution after num_ces=%d num_sdus=%d num_padding=%d\n", + num_ces, num_sdus, num_padding); + // exit parsing + return NULL; + } + + num_cont_res++; + ce_len += 6; + } + } #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC, "[UE] ce %d lcid %d (offset now %ld)\n", num_ces, - lcid, mac_header_ptr - mac_header); + LOG_D(MAC, "[UE] ce %d lcid %d (offset now %ld)\n", num_ces, + lcid, mac_header_ptr - mac_header); #endif - } } + } - *num_ce = num_ces; - *num_sdu = num_sdus; - - return (mac_header_ptr); + *num_ce = num_ces; + *num_sdu = num_sdus; + return (mac_header_ptr); } uint32_t ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, - uint8_t eNB_id, uint16_t rnti, sub_frame_t subframe) -{ + uint8_t eNB_id, uint16_t rnti, sub_frame_t subframe) { + // no UL-SCH resources available for this tti && UE has a valid PUCCH resources for SR configuration for this tti + // int MGL=6;// measurement gap length in ms + int MGRP = 0; // measurement gap repetition period in ms + int gapOffset = -1; + int T = 0; + DevCheck(module_idP < (int) NB_UE_INST, module_idP, NB_UE_INST, 0); + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + + // determin the measurement gap + if (UE_mac_inst[module_idP].measGapConfig != NULL) { + if (UE_mac_inst[module_idP].measGapConfig->choice.setup. + gapOffset.present == LTE_MeasGapConfig__setup__gapOffset_PR_gp0) { + MGRP = 40; + gapOffset = + UE_mac_inst[module_idP].measGapConfig->choice. + setup.gapOffset.choice.gp0; + } else if (UE_mac_inst[module_idP].measGapConfig->choice. + setup.gapOffset.present == + LTE_MeasGapConfig__setup__gapOffset_PR_gp1) { + MGRP = 80; + gapOffset = + UE_mac_inst[module_idP].measGapConfig->choice. + setup.gapOffset.choice.gp1; + } else { + LOG_W(MAC, "Measurement GAP offset is unknown\n"); + } - // no UL-SCH resources available for this tti && UE has a valid PUCCH resources for SR configuration for this tti - // int MGL=6;// measurement gap length in ms - int MGRP = 0; // measurement gap repetition period in ms - int gapOffset = -1; - int T = 0; - - DevCheck(module_idP < (int) NB_UE_INST, module_idP, NB_UE_INST, 0); - - AssertFatal(CC_id == 0, - "Transmission on secondary CCs is not supported yet\n"); - - // determin the measurement gap - if (UE_mac_inst[module_idP].measGapConfig != NULL) { - if (UE_mac_inst[module_idP].measGapConfig->choice.setup. - gapOffset.present == LTE_MeasGapConfig__setup__gapOffset_PR_gp0) { - MGRP = 40; - gapOffset = - UE_mac_inst[module_idP].measGapConfig->choice. - setup.gapOffset.choice.gp0; - } else if (UE_mac_inst[module_idP].measGapConfig->choice. - setup.gapOffset.present == - LTE_MeasGapConfig__setup__gapOffset_PR_gp1) { - MGRP = 80; - gapOffset = - UE_mac_inst[module_idP].measGapConfig->choice. - setup.gapOffset.choice.gp1; - } else { - LOG_W(MAC, "Measurement GAP offset is unknown\n"); - } - - T = MGRP / 10; - DevAssert(T != 0); - - //check the measurement gap and sr prohibit timer - if ((subframe == gapOffset % 10) - && ((frameP % T) == (floor(gapOffset / 10))) - && (UE_mac_inst[module_idP]. - scheduling_info.sr_ProhibitTimer_Running == 0)) { - UE_mac_inst[module_idP].scheduling_info.SR_pending = 1; - return (0); - } + T = MGRP / 10; + DevAssert(T != 0); + + //check the measurement gap and sr prohibit timer + if ((subframe == gapOffset % 10) + && ((frameP % T) == (floor(gapOffset / 10))) + && (UE_mac_inst[module_idP]. + scheduling_info.sr_ProhibitTimer_Running == 0)) { + UE_mac_inst[module_idP].scheduling_info.SR_pending = 1; + return (0); } + } - if ((UE_mac_inst[module_idP].physicalConfigDedicated != NULL) && - (UE_mac_inst[module_idP].scheduling_info.SR_pending == 1) && - (UE_mac_inst[module_idP].scheduling_info.SR_COUNTER < - (1 << - (2 + - UE_mac_inst[module_idP]. - physicalConfigDedicated->schedulingRequestConfig->choice.setup. - dsr_TransMax)))) { - LOG_D(MAC, - "[UE %d][SR %x] Frame %d subframe %d PHY asks for SR (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n", - module_idP, rnti, frameP, subframe, - UE_mac_inst[module_idP].scheduling_info.SR_COUNTER, - (1 << - (2 + - UE_mac_inst[module_idP]. - physicalConfigDedicated->schedulingRequestConfig->choice. - setup.dsr_TransMax)), - UE_mac_inst[module_idP].scheduling_info.SR_pending); - - UE_mac_inst[module_idP].scheduling_info.SR_COUNTER++; - - // start the sr-prohibittimer : rel 9 and above - if (UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer > 0) { // timer configured - UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer--; - UE_mac_inst[module_idP].scheduling_info. - sr_ProhibitTimer_Running = 1; - } else { - UE_mac_inst[module_idP].scheduling_info. - sr_ProhibitTimer_Running = 0; - } - - LOG_D(MAC, - "[UE %d][SR %x] Frame %d subframe %d send SR indication (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n", - module_idP, rnti, frameP, subframe, - UE_mac_inst[module_idP].scheduling_info.SR_COUNTER, - (1 << - (2 + - UE_mac_inst[module_idP]. - physicalConfigDedicated->schedulingRequestConfig->choice. - setup.dsr_TransMax)), - UE_mac_inst[module_idP].scheduling_info.SR_pending); - - //UE_mac_inst[module_idP].ul_active =1; - return (1); //instruct phy to signal SR + if ((UE_mac_inst[module_idP].physicalConfigDedicated != NULL) && + (UE_mac_inst[module_idP].scheduling_info.SR_pending == 1) && + (UE_mac_inst[module_idP].scheduling_info.SR_COUNTER < + (1 << + (2 + + UE_mac_inst[module_idP]. + physicalConfigDedicated->schedulingRequestConfig->choice.setup. + dsr_TransMax)))) { + LOG_D(MAC, + "[UE %d][SR %x] Frame %d subframe %d PHY asks for SR (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n", + module_idP, rnti, frameP, subframe, + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER, + (1 << + (2 + + UE_mac_inst[module_idP]. + physicalConfigDedicated->schedulingRequestConfig->choice. + setup.dsr_TransMax)), + UE_mac_inst[module_idP].scheduling_info.SR_pending); + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER++; + + // start the sr-prohibittimer : rel 9 and above + if (UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer > 0) { // timer configured + UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer--; + UE_mac_inst[module_idP].scheduling_info. + sr_ProhibitTimer_Running = 1; } else { - // notify RRC to relase PUCCH/SRS - // clear any configured dl/ul - // initiate RA - if (UE_mac_inst[module_idP].scheduling_info.SR_pending) { - // release all pucch resource - UE_mac_inst[module_idP].physicalConfigDedicated = NULL; - UE_mac_inst[module_idP].ul_active = 0; - UE_mac_inst[module_idP].BSR_reporting_active = - BSR_TRIGGER_NONE; - - LOG_I(MAC, "[UE %d] Release all SRs \n", module_idP); - } - UE_mac_inst[module_idP].scheduling_info.SR_pending = 0; - UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0; - return (0); + UE_mac_inst[module_idP].scheduling_info. + sr_ProhibitTimer_Running = 0; + } + + LOG_D(MAC, + "[UE %d][SR %x] Frame %d subframe %d send SR indication (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n", + module_idP, rnti, frameP, subframe, + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER, + (1 << + (2 + + UE_mac_inst[module_idP]. + physicalConfigDedicated->schedulingRequestConfig->choice. + setup.dsr_TransMax)), + UE_mac_inst[module_idP].scheduling_info.SR_pending); + //UE_mac_inst[module_idP].ul_active =1; + return (1); //instruct phy to signal SR + } else { + // notify RRC to relase PUCCH/SRS + // clear any configured dl/ul + // initiate RA + if (UE_mac_inst[module_idP].scheduling_info.SR_pending) { + // release all pucch resource + UE_mac_inst[module_idP].physicalConfigDedicated = NULL; + UE_mac_inst[module_idP].ul_active = 0; + UE_mac_inst[module_idP].BSR_reporting_active = + BSR_TRIGGER_NONE; + LOG_I(MAC, "[UE %d] Release all SRs \n", module_idP); } + + UE_mac_inst[module_idP].scheduling_info.SR_pending = 0; + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0; + return (0); + } } //------------------------------------------------------------------------------ void ue_send_sdu(module_id_t module_idP, - uint8_t CC_id, - frame_t frameP, - sub_frame_t subframeP, - uint8_t * sdu, uint16_t sdu_len, uint8_t eNB_index) + uint8_t CC_id, + frame_t frameP, + sub_frame_t subframeP, + uint8_t *sdu, uint16_t sdu_len, uint8_t eNB_index) //------------------------------------------------------------------------------ { - - unsigned char rx_ces[MAX_NUM_CE], num_ce, num_sdu, i, *payload_ptr; - unsigned char rx_lcids[NB_RB_MAX]; - unsigned short rx_lengths[NB_RB_MAX]; - unsigned char *tx_sdu; + unsigned char rx_ces[MAX_NUM_CE], num_ce, num_sdu, i, *payload_ptr; + unsigned char rx_lcids[NB_RB_MAX]; + unsigned short rx_lengths[NB_RB_MAX]; + unsigned char *tx_sdu; #if UE_TIMING_TRACE - start_meas(&UE_mac_inst[module_idP].rx_dlsch_sdu); + start_meas(&UE_mac_inst[module_idP].rx_dlsch_sdu); #endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_IN); - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_IN); //LOG_D(MAC,"sdu: %x.%x.%x\n",sdu[0],sdu[1],sdu[2]); - if (opt_enabled) { - trace_pdu(DIRECTION_DOWNLINK, sdu, sdu_len, module_idP, WS_C_RNTI, - UE_mac_inst[module_idP].crnti, frameP, subframeP, 0, 0); - LOG_D(OPT, - "[UE %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n", - module_idP, frameP, UE_mac_inst[module_idP].crnti, sdu_len); - } - - payload_ptr = - parse_header(sdu, &num_ce, &num_sdu, rx_ces, rx_lcids, rx_lengths, - sdu_len); + if (opt_enabled) { + trace_pdu(DIRECTION_DOWNLINK, sdu, sdu_len, module_idP, WS_C_RNTI, + UE_mac_inst[module_idP].crnti, frameP, subframeP, 0, 0); + LOG_D(OPT, + "[UE %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n", + module_idP, frameP, UE_mac_inst[module_idP].crnti, sdu_len); + } + payload_ptr = + parse_header(sdu, &num_ce, &num_sdu, rx_ces, rx_lcids, rx_lengths, + sdu_len); #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC, - "[UE %d] ue_send_sdu : Frame %d eNB_index %d : num_ce %d num_sdu %d\n", - module_idP, frameP, eNB_index, num_ce, num_sdu); + LOG_D(MAC, + "[UE %d] ue_send_sdu : Frame %d eNB_index %d : num_ce %d num_sdu %d\n", + module_idP, frameP, eNB_index, num_ce, num_sdu); #endif - #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - LOG_T(MAC, "[UE %d] First 32 bytes of DLSCH : \n", module_idP); + LOG_T(MAC, "[UE %d] First 32 bytes of DLSCH : \n", module_idP); - for (i = 0; i < 32; i++) { - LOG_T(MAC, "%x.", sdu[i]); - } + for (i = 0; i < 32; i++) { + LOG_T(MAC, "%x.", sdu[i]); + } - LOG_T(MAC, "\n"); + LOG_T(MAC, "\n"); #endif - if (payload_ptr != NULL) { - - for (i = 0; i < num_ce; i++) { - // printf("ce %d : %d\n",i,rx_ces[i]); - switch (rx_ces[i]) { - case UE_CONT_RES: - - LOG_I(MAC, - "[UE %d][RAPROC] Frame %d : received contention resolution msg: %x.%x.%x.%x.%x.%x, Terminating RA procedure\n", - module_idP, frameP, payload_ptr[0], payload_ptr[1], - payload_ptr[2], payload_ptr[3], payload_ptr[4], - payload_ptr[5]); - - if (UE_mac_inst[module_idP].RA_active == 1) { - LOG_I(MAC, - "[UE %d][RAPROC] Frame %d : Clearing RA_active flag\n", - module_idP, frameP); - UE_mac_inst[module_idP].RA_active = 0; - // check if RA procedure has finished completely (no contention) - tx_sdu = &UE_mac_inst[module_idP].CCCH_pdu.payload[3]; - - //Note: 3 assumes sizeof(SCH_SUBHEADER_SHORT) + PADDING CE, which is when UL-Grant has TBS >= 9 (64 bits) - // (other possibility is 1 for TBS=7 (SCH_SUBHEADER_FIXED), or 2 for TBS=8 (SCH_SUBHEADER_FIXED+PADDING or SCH_SUBHEADER_SHORT) - for (i = 0; i < 6; i++) - if (tx_sdu[i] != payload_ptr[i]) { - LOG_E(MAC, - "[UE %d][RAPROC] Contention detected, RA failed\n", - module_idP); - if(nfapi_mode == 3) { // phy_stub mode - // Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to - // PRACH state. - LOG_I(MAC, "nfapi_mode3: Setting UE_mode BACK to PRACH 1\n"); - UE_mac_inst[module_idP].UE_mode[eNB_index] = PRACH; - //ra_failed(module_idP,CC_id,eNB_index);UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0; - } - else{ - ra_failed(module_idP, CC_id, eNB_index); - } - UE_mac_inst - [module_idP]. - RA_contention_resolution_timer_active = 0; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, - VCD_FUNCTION_OUT); - return; - } - - LOG_I(MAC, - "[UE %d][RAPROC] Frame %d : Clearing contention resolution timer\n", - module_idP, frameP); - UE_mac_inst - [module_idP]. - RA_contention_resolution_timer_active = 0; - if(nfapi_mode == 3) // phy_stub mode - { - // Modification for phy_stub mode operation here. We only need to change the ue_mode to PUSCH - UE_mac_inst[module_idP].UE_mode[eNB_index] = PUSCH; - } - else { // Full stack mode - ra_succeeded(module_idP,CC_id,eNB_index); - } - } - - payload_ptr += 6; - break; - - case TIMING_ADV_CMD: + if (payload_ptr != NULL) { + for (i = 0; i < num_ce; i++) { + // printf("ce %d : %d\n",i,rx_ces[i]); + switch (rx_ces[i]) { + case UE_CONT_RES: + LOG_I(MAC, + "[UE %d][RAPROC] Frame %d : received contention resolution msg: %x.%x.%x.%x.%x.%x, Terminating RA procedure\n", + module_idP, frameP, payload_ptr[0], payload_ptr[1], + payload_ptr[2], payload_ptr[3], payload_ptr[4], + payload_ptr[5]); + + if (UE_mac_inst[module_idP].RA_active == 1) { + LOG_I(MAC, + "[UE %d][RAPROC] Frame %d : Clearing RA_active flag\n", + module_idP, frameP); + UE_mac_inst[module_idP].RA_active = 0; + // check if RA procedure has finished completely (no contention) + tx_sdu = &UE_mac_inst[module_idP].CCCH_pdu.payload[3]; + + //Note: 3 assumes sizeof(SCH_SUBHEADER_SHORT) + PADDING CE, which is when UL-Grant has TBS >= 9 (64 bits) + // (other possibility is 1 for TBS=7 (SCH_SUBHEADER_FIXED), or 2 for TBS=8 (SCH_SUBHEADER_FIXED+PADDING or SCH_SUBHEADER_SHORT) + for (i = 0; i < 6; i++) + if (tx_sdu[i] != payload_ptr[i]) { + LOG_E(MAC, + "[UE %d][RAPROC] Contention detected, RA failed\n", + module_idP); + + if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { // phy_stub mode + // Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to + // PRACH state. + LOG_I(MAC, "nfapi_mode3: Setting UE_mode BACK to PRACH 1\n"); + UE_mac_inst[module_idP].UE_mode[eNB_index] = PRACH; + //ra_failed(module_idP,CC_id,eNB_index);UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0; + } else { + ra_failed(module_idP, CC_id, eNB_index); + } + + UE_mac_inst + [module_idP]. + RA_contention_resolution_timer_active = 0; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, + VCD_FUNCTION_OUT); + return; + } + + LOG_I(MAC, + "[UE %d][RAPROC] Frame %d : Clearing contention resolution timer\n", + module_idP, frameP); + UE_mac_inst + [module_idP]. + RA_contention_resolution_timer_active = 0; + + if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { // phy_stub mode + // Modification for phy_stub mode operation here. We only need to change the ue_mode to PUSCH + UE_mac_inst[module_idP].UE_mode[eNB_index] = PUSCH; + } else { // Full stack mode + ra_succeeded(module_idP,CC_id,eNB_index); + } + } + + payload_ptr += 6; + break; + + case TIMING_ADV_CMD: #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC, "[UE] CE %d : UE Timing Advance : %d\n", i, - payload_ptr[0]); + LOG_D(MAC, "[UE] CE %d : UE Timing Advance : %d\n", i, + payload_ptr[0]); #endif - // Eliminate call to process_timing_advance for the phy_stub UE operation mode. Is this correct? - if (nfapi_mode!=3) - { - process_timing_advance(module_idP,CC_id,payload_ptr[0]); - } - payload_ptr++; - break; + // Eliminate call to process_timing_advance for the phy_stub UE operation mode. Is this correct? + if (NFAPI_MODE!=NFAPI_UE_STUB_PNF) { + process_timing_advance(module_idP,CC_id,payload_ptr[0]); + } - case DRX_CMD: + payload_ptr++; + break; + + case DRX_CMD: #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC, "[UE] CE %d : UE DRX :", i); + LOG_D(MAC, "[UE] CE %d : UE DRX :", i); #endif - payload_ptr++; - break; - } - } + payload_ptr++; + break; + } + } - for (i = 0; i < num_sdu; i++) { + for (i = 0; i < num_sdu; i++) { #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC, "[UE] SDU %d : LCID %d, length %d\n", i, - rx_lcids[i], rx_lengths[i]); + LOG_D(MAC, "[UE] SDU %d : LCID %d, length %d\n", i, + rx_lcids[i], rx_lengths[i]); #endif - if (rx_lcids[i] == CCCH) { - - LOG_D(MAC, - "[UE %d] rnti %x Frame %d : DLSCH -> DL-CCCH, RRC message (eNB %d, %d bytes)\n", - module_idP, UE_mac_inst[module_idP].crnti, frameP, - eNB_index, rx_lengths[i]); + if (rx_lcids[i] == CCCH) { + LOG_D(MAC, + "[UE %d] rnti %x Frame %d : DLSCH -> DL-CCCH, RRC message (eNB %d, %d bytes)\n", + module_idP, UE_mac_inst[module_idP].crnti, frameP, + eNB_index, rx_lengths[i]); #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - int j; + int j; - for (j = 0; j < rx_lengths[i]; j++) { - LOG_T(MAC, "%x.", (uint8_t) payload_ptr[j]); - } + for (j = 0; j < rx_lengths[i]; j++) { + LOG_T(MAC, "%x.", (uint8_t) payload_ptr[j]); + } - LOG_T(MAC, "\n"); + LOG_T(MAC, "\n"); #endif + mac_rrc_data_ind_ue(module_idP, + CC_id, + frameP,subframeP, + UE_mac_inst[module_idP].crnti, + CCCH, + (uint8_t *)payload_ptr, + rx_lengths[i], + eNB_index, + 0 + ); + } else if ((rx_lcids[i] == DCCH) || (rx_lcids[i] == DCCH1)) { + LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", module_idP, frameP, rx_lcids[i],eNB_index,rx_lengths[i]); + mac_rlc_data_ind(module_idP, + UE_mac_inst[module_idP].crnti, + eNB_index, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, + rx_lcids[i], + (char *)payload_ptr, + rx_lengths[i], + 1, + NULL); + } else if ((rx_lcids[i] < NB_RB_MAX) && (rx_lcids[i] > DCCH1 )) { + LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DTCH%d (eNB %d, %d bytes)\n", module_idP, frameP,rx_lcids[i], eNB_index,rx_lengths[i]); +#if defined(ENABLE_MAC_PAYLOAD_DEBUG) + int j; - mac_rrc_data_ind_ue(module_idP, - CC_id, - frameP,subframeP, - UE_mac_inst[module_idP].crnti, - CCCH, - (uint8_t*)payload_ptr, - rx_lengths[i], - eNB_index, - 0 - ); - - } else if ((rx_lcids[i] == DCCH) || (rx_lcids[i] == DCCH1)) { - LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", module_idP, frameP, rx_lcids[i],eNB_index,rx_lengths[i]); - mac_rlc_data_ind(module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, - rx_lcids[i], - (char *)payload_ptr, - rx_lengths[i], - 1, - NULL); - - } else if ((rx_lcids[i] < NB_RB_MAX) && (rx_lcids[i] > DCCH1 )) { - - LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DTCH%d (eNB %d, %d bytes)\n", module_idP, frameP,rx_lcids[i], eNB_index,rx_lengths[i]); + for (j = 0; j < rx_lengths[i]; j++) + LOG_T(MAC, "%x.", (unsigned char) payload_ptr[j]); -#if defined(ENABLE_MAC_PAYLOAD_DEBUG) - int j; - for (j = 0; j < rx_lengths[i]; j++) - LOG_T(MAC, "%x.", (unsigned char) payload_ptr[j]); - LOG_T(MAC, "\n"); + LOG_T(MAC, "\n"); #endif - mac_rlc_data_ind(module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, - rx_lcids[i], - (char *) payload_ptr, rx_lengths[i], 1, - NULL); - } else { - LOG_E(MAC, "[UE %d] Frame %d : unknown LCID %d (eNB %d)\n", - module_idP, frameP, rx_lcids[i], eNB_index); - } - payload_ptr += rx_lengths[i]; - } - } // end if (payload_ptr != NULL) + mac_rlc_data_ind(module_idP, + UE_mac_inst[module_idP].crnti, + eNB_index, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, + rx_lcids[i], + (char *) payload_ptr, rx_lengths[i], 1, + NULL); + } else { + LOG_E(MAC, "[UE %d] Frame %d : unknown LCID %d (eNB %d)\n", + module_idP, frameP, rx_lcids[i], eNB_index); + } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_OUT); + payload_ptr += rx_lengths[i]; + } + } // end if (payload_ptr != NULL) + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].rx_dlsch_sdu); + stop_meas(&UE_mac_inst[module_idP].rx_dlsch_sdu); #endif } void ue_decode_si(module_id_t module_idP, int CC_id, frame_t frameP, - uint8_t eNB_index, void *pdu, uint16_t len) -{ + uint8_t eNB_index, void *pdu, uint16_t len) { #if UE_TIMING_TRACE - start_meas(&UE_mac_inst[module_idP].rx_si); + start_meas(&UE_mac_inst[module_idP].rx_si); #endif - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_IN); - - LOG_D(MAC, "[UE %d] Frame %d Sending SI to RRC (LCID Id %d,len %d)\n", - module_idP, frameP, BCCH, len); - - mac_rrc_data_ind_ue(module_idP, CC_id, frameP, 0, // unknown subframe - SI_RNTI, - BCCH, (uint8_t *) pdu, len, eNB_index, - 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_OUT); - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_IN); + LOG_D(MAC, "[UE %d] Frame %d Sending SI to RRC (LCID Id %d,len %d)\n", + module_idP, frameP, BCCH, len); + mac_rrc_data_ind_ue(module_idP, CC_id, frameP, 0, // unknown subframe + SI_RNTI, + BCCH, (uint8_t *) pdu, len, eNB_index, + 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].rx_si); + stop_meas(&UE_mac_inst[module_idP].rx_si); #endif - if (opt_enabled == 1) { - trace_pdu(DIRECTION_UPLINK, - (uint8_t *) pdu, - len, - module_idP, - WS_SI_RNTI, - 0xffff, - UE_mac_inst[module_idP].rxFrame, - UE_mac_inst[module_idP].rxSubframe, 0, 0); - LOG_D(OPT, - "[UE %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", - module_idP, frameP, CC_id, 0xffff, len); - } + + if (opt_enabled == 1) { + trace_pdu(DIRECTION_UPLINK, + (uint8_t *) pdu, + len, + module_idP, + WS_SI_RNTI, + 0xffff, + UE_mac_inst[module_idP].rxFrame, + UE_mac_inst[module_idP].rxSubframe, 0, 0); + LOG_D(OPT, + "[UE %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", + module_idP, frameP, CC_id, 0xffff, len); + } } void ue_decode_p(module_id_t module_idP, int CC_id, frame_t frameP, - uint8_t eNB_index, void *pdu, uint16_t len) -{ + uint8_t eNB_index, void *pdu, uint16_t len) { #if UE_TIMING_TRACE - start_meas(&UE_mac_inst[module_idP].rx_p); + start_meas(&UE_mac_inst[module_idP].rx_p); #endif - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_IN); - - LOG_D(MAC, - "[UE %d] Frame %d Sending Paging message to RRC (LCID Id %d,len %d)\n", - module_idP, frameP, PCCH, len); - - mac_rrc_data_ind_ue(module_idP, CC_id, frameP, 0, // unknown subframe - P_RNTI, - PCCH, (uint8_t *) pdu, len, eNB_index, - 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_OUT); - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_IN); + LOG_D(MAC, + "[UE %d] Frame %d Sending Paging message to RRC (LCID Id %d,len %d)\n", + module_idP, frameP, PCCH, len); + mac_rrc_data_ind_ue(module_idP, CC_id, frameP, 0, // unknown subframe + P_RNTI, + PCCH, (uint8_t *) pdu, len, eNB_index, + 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].rx_p); + stop_meas(&UE_mac_inst[module_idP].rx_p); #endif - if (opt_enabled == 1) { - trace_pdu(DIRECTION_UPLINK , - (uint8_t *) pdu, - len, - module_idP, - WS_SI_RNTI, - P_RNTI, - UE_mac_inst[module_idP].rxFrame, - UE_mac_inst[module_idP].rxSubframe, 0, 0); - LOG_D(OPT, - "[UE %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", - module_idP, frameP, CC_id, P_RNTI, len); - } + + if (opt_enabled == 1) { + trace_pdu(DIRECTION_UPLINK, + (uint8_t *) pdu, + len, + module_idP, + WS_SI_RNTI, + P_RNTI, + UE_mac_inst[module_idP].rxFrame, + UE_mac_inst[module_idP].rxSubframe, 0, 0); + LOG_D(OPT, + "[UE %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", + module_idP, frameP, CC_id, P_RNTI, len); + } } #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) unsigned char *parse_mch_header(unsigned char *mac_header, - unsigned char *num_sdu, - unsigned char *rx_lcids, - unsigned short *rx_lengths, - unsigned short tb_length) -{ - unsigned char not_done = 1, num_sdus = 0, lcid, i; - unsigned char *mac_header_ptr = mac_header; - unsigned short length; - - while (not_done == 1) { - if (((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E == 0) { - not_done = 0; - } - - lcid = ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID; - - if (lcid < SHORT_PADDING) { // subheader for MSI, MCCH or MTCH - if (not_done == 0) { // last MAC SDU, length is implicit - mac_header_ptr++; - length = tb_length - (mac_header_ptr - mac_header); - - for (i = 0; i < num_sdus; i++) { - length -= rx_lengths[i]; - } - } else { // not the last MAC SDU - if (((SCH_SUBHEADER_LONG *) mac_header_ptr)->F == 1) { // subheader has length of 3octets - // length = ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L; - length = - ((((SCH_SUBHEADER_LONG *) mac_header_ptr)-> - L_MSB & 0x7f) - << 8) | (((SCH_SUBHEADER_LONG *) mac_header_ptr)-> - L_LSB & 0xff); - mac_header_ptr += 3; - } else { // subheader has length of 2octets - length = ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L; - mac_header_ptr += 2; - } - } - - rx_lcids[num_sdus] = lcid; - rx_lengths[num_sdus] = length; - num_sdus++; - } else { // subheader for padding - // if (lcid == SHORT_PADDING) - mac_header_ptr++; - } + unsigned char *num_sdu, + unsigned char *rx_lcids, + unsigned short *rx_lengths, + unsigned short tb_length) { + unsigned char not_done = 1, num_sdus = 0, lcid, i; + unsigned char *mac_header_ptr = mac_header; + unsigned short length; + + while (not_done == 1) { + if (((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E == 0) { + not_done = 0; + } + + lcid = ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID; + + if (lcid < SHORT_PADDING) { // subheader for MSI, MCCH or MTCH + if (not_done == 0) { // last MAC SDU, length is implicit + mac_header_ptr++; + length = tb_length - (mac_header_ptr - mac_header); + + for (i = 0; i < num_sdus; i++) { + length -= rx_lengths[i]; + } + } else { // not the last MAC SDU + if (((SCH_SUBHEADER_LONG *) mac_header_ptr)->F == 1) { // subheader has length of 3octets + // length = ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L; + length = + ((((SCH_SUBHEADER_LONG *) mac_header_ptr)-> + L_MSB & 0x7f) + << 8) | (((SCH_SUBHEADER_LONG *) mac_header_ptr)-> + L_LSB & 0xff); + mac_header_ptr += 3; + } else { // subheader has length of 2octets + length = ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L; + mac_header_ptr += 2; + } + } + + rx_lcids[num_sdus] = lcid; + rx_lengths[num_sdus] = length; + num_sdus++; + } else { // subheader for padding + // if (lcid == SHORT_PADDING) + mac_header_ptr++; } + } - *num_sdu = num_sdus; - return (mac_header_ptr); + *num_sdu = num_sdus; + return (mac_header_ptr); } // this function is for sending mch_sdu from phy to mac void ue_send_mch_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frameP, - uint8_t * sdu, uint16_t sdu_len, uint8_t eNB_index, - uint8_t sync_area) -{ - - unsigned char num_sdu, i, j, *payload_ptr; - unsigned char rx_lcids[NB_RB_MAX]; - unsigned short rx_lengths[NB_RB_MAX]; + uint8_t *sdu, uint16_t sdu_len, uint8_t eNB_index, + uint8_t sync_area) { + unsigned char num_sdu, i, j, *payload_ptr; + unsigned char rx_lcids[NB_RB_MAX]; + unsigned short rx_lengths[NB_RB_MAX]; #if UE_TIMING_TRACE - start_meas(&UE_mac_inst[module_idP].rx_mch_sdu); + start_meas(&UE_mac_inst[module_idP].rx_mch_sdu); #endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_MCH_SDU, VCD_FUNCTION_IN); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_MCH_SDU, VCD_FUNCTION_IN); + LOG_D(MAC, + "[UE %d] Frame %d : process the mch PDU for sync area %d \n", + module_idP, frameP, sync_area); + LOG_D(MAC, "[UE %d] sdu: %x.%x\n", module_idP, sdu[0], sdu[1]); + LOG_D(MAC, "[UE %d] parse_mch_header, demultiplex\n", module_idP); + payload_ptr = + parse_mch_header(sdu, &num_sdu, rx_lcids, rx_lengths, sdu_len); + LOG_D(MAC, "[UE %d] parse_mch_header, found %d sdus\n", module_idP, + num_sdu); + + for (i = 0; i < num_sdu; i++) { + if (rx_lcids[i] == MCH_SCHDL_INFO) { + if (rx_lengths[i] & 0x01) { + LOG_E(MAC,"MCH Scheduling Information MAC Control Element should have an even size\n"); + } - LOG_D(MAC, - "[UE %d] Frame %d : process the mch PDU for sync area %d \n", - module_idP, frameP, sync_area); - LOG_D(MAC, "[UE %d] sdu: %x.%x\n", module_idP, sdu[0], sdu[1]); - LOG_D(MAC, "[UE %d] parse_mch_header, demultiplex\n", module_idP); + LOG_D(MAC,"MCH Scheduling Information, len(%d)\n",rx_lengths[i]); - payload_ptr = - parse_mch_header(sdu, &num_sdu, rx_lcids, rx_lengths, sdu_len); - LOG_D(MAC, "[UE %d] parse_mch_header, found %d sdus\n", module_idP, - num_sdu); + for (j=0; j<rx_lengths[i]/2; j++) { + uint16_t stop_mtch_val = ((uint16_t)(payload_ptr[2*j] & 0x07) << 8) | (uint16_t)payload_ptr[2*j+1]; + UE_mac_inst[module_idP].pmch_lcids[j] = (payload_ptr[2*j] & 0xF8) >> 3; + UE_mac_inst[module_idP].pmch_stop_mtch[j] = stop_mtch_val; + LOG_D(MAC,"lcid(%d),stop_mtch_val %d frameP(%d)\n", UE_mac_inst[module_idP].pmch_lcids[j], stop_mtch_val, frameP); - for (i = 0; i < num_sdu; i++) { - if (rx_lcids[i] == MCH_SCHDL_INFO) { - if (rx_lengths[i] & 0x01) { - LOG_E(MAC,"MCH Scheduling Information MAC Control Element should have an even size\n"); + if ((stop_mtch_val >= 2043) && (stop_mtch_val <= 2046)) { + LOG_D(MAC,"(reserved)\n"); } - LOG_D(MAC,"MCH Scheduling Information, len(%d)\n",rx_lengths[i]); - - for (j=0; j<rx_lengths[i]/2; j++) { - uint16_t stop_mtch_val = ((uint16_t)(payload_ptr[2*j] & 0x07) << 8) | (uint16_t)payload_ptr[2*j+1]; - - UE_mac_inst[module_idP].pmch_lcids[j] = (payload_ptr[2*j] & 0xF8) >> 3; - UE_mac_inst[module_idP].pmch_stop_mtch[j] = stop_mtch_val; - LOG_D(MAC,"lcid(%d),stop_mtch_val %d frameP(%d)\n", UE_mac_inst[module_idP].pmch_lcids[j], stop_mtch_val, frameP); + UE_mac_inst[module_idP].msi_status_v[j] = 0; - if ((stop_mtch_val >= 2043) && (stop_mtch_val <= 2046)) { - LOG_D(MAC,"(reserved)\n"); - } - - UE_mac_inst[module_idP].msi_status_v[j] = 0; + if (UE_mac_inst[module_idP].mcch_status==1) { + LOG_D(MAC,"[UE %d] Frame %d : MCH->MSI for sync area %d (eNB %d, %d bytes), i(%d)\n", module_idP, frameP, sync_area, eNB_index, rx_lengths[i], UE_mac_inst[module_idP].pmch_stop_mtch[j]); - if (UE_mac_inst[module_idP].mcch_status==1) { - LOG_D(MAC,"[UE %d] Frame %d : MCH->MSI for sync area %d (eNB %d, %d bytes), i(%d)\n", module_idP, frameP, sync_area, eNB_index, rx_lengths[i], UE_mac_inst[module_idP].pmch_stop_mtch[j]); - if (UE_mac_inst[module_idP].pmch_stop_mtch[j] < 2043) { - UE_mac_inst[module_idP].pmch_stop_mtch[j] += UE_mac_inst[module_idP].msi_current_alloc; - UE_mac_inst[module_idP].msi_status_v[j] = 1; - } + if (UE_mac_inst[module_idP].pmch_stop_mtch[j] < 2043) { + UE_mac_inst[module_idP].pmch_stop_mtch[j] += UE_mac_inst[module_idP].msi_current_alloc; + UE_mac_inst[module_idP].msi_status_v[j] = 1; } } - } else if (rx_lcids[i] == MCCH_LCHANID) { - LOG_D(MAC,"[UE %d] Frame %d : SDU %d MCH->MCCH for sync area %d (eNB %d, %d bytes)\n",module_idP,frameP, i, sync_area, eNB_index, rx_lengths[i]); - mac_rrc_data_ind_ue(module_idP, - CC_id, - frameP,0, // unknown subframe - M_RNTI, - MCCH, - payload_ptr + 1, // Skip RLC layer 1st byte - rx_lengths[i] - 1, - eNB_index, - sync_area); - } else if (rx_lcids[i] <= 28) { - for (j=0; j<28; j++) { - if (rx_lcids[i] == UE_mac_inst[module_idP].pmch_lcids[j]) - break; - } - - if (j<28 && UE_mac_inst[module_idP].msi_status_v[j]==1) { - LOG_D(MAC,"[UE %d] Frame %d : MCH->MTCH for sync area %d (eNB %d, %d bytes), j=%d\n", module_idP, frameP, sync_area, eNB_index, rx_lengths[i], j); - - mac_rlc_data_ind( - module_idP, - UE_mac_inst[module_idP].crnti, - eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_YES, - rx_lcids[i], /*+ (maxDRB + 3),*/ - (char *)payload_ptr, - rx_lengths[i], - 1, - NULL); - - } - } else { - LOG_W(MAC, - "[UE %d] Frame %d : unknown sdu %d rx_lcids[%d]=%d mcch status %d eNB %d \n", - module_idP, frameP, rx_lengths[i], i, rx_lcids[i], - UE_mac_inst[module_idP].mcch_status, eNB_index); + } + } else if (rx_lcids[i] == MCCH_LCHANID) { + LOG_D(MAC,"[UE %d] Frame %d : SDU %d MCH->MCCH for sync area %d (eNB %d, %d bytes)\n",module_idP,frameP, i, sync_area, eNB_index, rx_lengths[i]); + mac_rrc_data_ind_ue(module_idP, + CC_id, + frameP,0, // unknown subframe + M_RNTI, + MCCH, + payload_ptr + 1, // Skip RLC layer 1st byte + rx_lengths[i] - 1, + eNB_index, + sync_area); + } else if (rx_lcids[i] <= 28) { + for (j=0; j<28; j++) { + if (rx_lcids[i] == UE_mac_inst[module_idP].pmch_lcids[j]) + break; } - payload_ptr += rx_lengths[i]; + if (j<28 && UE_mac_inst[module_idP].msi_status_v[j]==1) { + LOG_D(MAC,"[UE %d] Frame %d : MCH->MTCH for sync area %d (eNB %d, %d bytes), j=%d\n", module_idP, frameP, sync_area, eNB_index, rx_lengths[i], j); + mac_rlc_data_ind( + module_idP, + UE_mac_inst[module_idP].crnti, + eNB_index, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_YES, + rx_lcids[i], /*+ (maxDRB + 3),*/ + (char *)payload_ptr, + rx_lengths[i], + 1, + NULL); + } + } else { + LOG_W(MAC, + "[UE %d] Frame %d : unknown sdu %d rx_lcids[%d]=%d mcch status %d eNB %d \n", + module_idP, frameP, rx_lengths[i], i, rx_lcids[i], + UE_mac_inst[module_idP].mcch_status, eNB_index); } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_MCH_SDU, VCD_FUNCTION_OUT); + payload_ptr += rx_lengths[i]; + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_MCH_SDU, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].rx_mch_sdu); + stop_meas(&UE_mac_inst[module_idP].rx_mch_sdu); #endif } void ue_send_sl_sdu(module_id_t module_idP, - uint8_t CC_id, - frame_t frameP, - sub_frame_t subframeP, - uint8_t* sdu, - uint16_t sdu_len, - uint8_t eNB_index, - sl_discovery_flag_t sl_discovery_flag - ) { - + uint8_t CC_id, + frame_t frameP, + sub_frame_t subframeP, + uint8_t *sdu, + uint16_t sdu_len, + uint8_t eNB_index, + sl_discovery_flag_t sl_discovery_flag + ) { int rlc_sdu_len; char *rlc_sdu; uint32_t destinationL2Id =0x00000000; if (sl_discovery_flag == SL_DISCOVERY_FLAG_NO) { - - // Notes: 1. no control elements are supported yet - // 2. we exit with error if LCID != 3 - // 3. we exit with error if E=1 (more than one SDU/CE) - // extract header - SLSCH_SUBHEADER_24_Bit_DST_LONG *longh = (SLSCH_SUBHEADER_24_Bit_DST_LONG *)sdu; - AssertFatal(longh->E==0,"E is non-zero\n"); - AssertFatal(((longh->LCID==3)|(longh->LCID==10)),"LCID is %d (not 3 or 10)\n",longh->LCID); - //filter incoming packet based on destination address - destinationL2Id = (longh->DST07<<16) | (longh->DST815 <<8) | (longh->DST1623); - LOG_I( MAC, "[DestinationL2Id: 0x%08x] \n", destinationL2Id ); - //in case of 1-n communication, verify that UE belongs to that group - int i=0; - for (i=0; i< MAX_NUM_DEST; i++) - if (UE_mac_inst[module_idP].destinationList[i] == destinationL2Id) break; - //match the destinationL2Id with UE L2Id or groupL2ID - if (!((destinationL2Id == UE_mac_inst[module_idP].sourceL2Id) | (i < MAX_NUM_DEST))){ - LOG_I( MAC, "[Destination Id is neither matched with Source Id nor with Group Id, drop the packet!!! \n"); - return; - } - - - if (longh->F==1) { - rlc_sdu_len = ((longh->L_MSB<<8)&0x7F00)|(longh->L_LSB&0xFF); - rlc_sdu = (char *)sdu+sizeof(SLSCH_SUBHEADER_24_Bit_DST_LONG); - } - else { - rlc_sdu_len = ((SLSCH_SUBHEADER_24_Bit_DST_SHORT *)sdu)->L; - rlc_sdu = (char *)sdu+sizeof(SLSCH_SUBHEADER_24_Bit_DST_SHORT); - } - mac_rlc_data_ind( - module_idP, - 0x1234, - eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, - longh->LCID, //3/10 - rlc_sdu, - rlc_sdu_len, - 1, - NULL); + // Notes: 1. no control elements are supported yet + // 2. we exit with error if LCID != 3 + // 3. we exit with error if E=1 (more than one SDU/CE) + // extract header + SLSCH_SUBHEADER_24_Bit_DST_LONG *longh = (SLSCH_SUBHEADER_24_Bit_DST_LONG *)sdu; + AssertFatal(longh->E==0,"E is non-zero\n"); + AssertFatal(((longh->LCID==3)|(longh->LCID==10)),"LCID is %d (not 3 or 10)\n",longh->LCID); + //filter incoming packet based on destination address + destinationL2Id = (longh->DST07<<16) | (longh->DST815 <<8) | (longh->DST1623); + LOG_I( MAC, "[DestinationL2Id: 0x%08x] \n", destinationL2Id ); + //in case of 1-n communication, verify that UE belongs to that group + int i=0; + + for (i=0; i< MAX_NUM_DEST; i++) + if (UE_mac_inst[module_idP].destinationList[i] == destinationL2Id) break; + + //match the destinationL2Id with UE L2Id or groupL2ID + if (!((destinationL2Id == UE_mac_inst[module_idP].sourceL2Id) | (i < MAX_NUM_DEST))) { + LOG_I( MAC, "[Destination Id is neither matched with Source Id nor with Group Id, drop the packet!!! \n"); + return; + } + + if (longh->F==1) { + rlc_sdu_len = ((longh->L_MSB<<8)&0x7F00)|(longh->L_LSB&0xFF); + rlc_sdu = (char *)sdu+sizeof(SLSCH_SUBHEADER_24_Bit_DST_LONG); + } else { + rlc_sdu_len = ((SLSCH_SUBHEADER_24_Bit_DST_SHORT *)sdu)->L; + rlc_sdu = (char *)sdu+sizeof(SLSCH_SUBHEADER_24_Bit_DST_SHORT); + } + + mac_rlc_data_ind( + module_idP, + 0x1234, + eNB_index, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, + longh->LCID, //3/10 + rlc_sdu, + rlc_sdu_len, + 1, + NULL); } else { //SL_DISCOVERY - uint16_t len = sdu_len; - LOG_I( MAC, "SL DISCOVERY \n"); - mac_rrc_data_ind_ue(module_idP, - CC_id, - frameP,subframeP, - UE_mac_inst[module_idP].crnti, - SL_DISCOVERY, - sdu, //(uint8_t*)&UE_mac_inst[Mod_id].SL_Discovery[0].Rx_buffer.Payload[0], - len, - eNB_index, - 0); - + uint16_t len = sdu_len; + LOG_I( MAC, "SL DISCOVERY \n"); + mac_rrc_data_ind_ue(module_idP, + CC_id, + frameP,subframeP, + UE_mac_inst[module_idP].crnti, + SL_DISCOVERY, + sdu, //(uint8_t*)&UE_mac_inst[Mod_id].SL_Discovery[0].Rx_buffer.Payload[0], + len, + eNB_index, + 0); } } @@ -935,26 +894,26 @@ void ue_send_sl_sdu(module_id_t module_idP, int8_t ue_get_mbsfn_sf_alloction (module_id_t module_idP, uint8_t mbsfn_sync_area, unsigned char eNB_index) { - // currently there is one-to-one mapping between sf allocation pattern and sync area - if (mbsfn_sync_area >= MAX_MBSFN_AREA) { - LOG_W(MAC, - "[UE %" PRIu8 "] MBSFN synchronization area %" PRIu8 - " out of range for eNB %" PRIu8 "\n", module_idP, - mbsfn_sync_area, eNB_index); - return -1; - } else if (UE_mac_inst[module_idP]. - mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) { - return mbsfn_sync_area; - } else { - LOG_W(MAC, - "[UE %" PRIu8 "] MBSFN Subframe Config pattern %" PRIu8 - " not found \n", module_idP, mbsfn_sync_area); - return -1; - } + // currently there is one-to-one mapping between sf allocation pattern and sync area + if (mbsfn_sync_area >= MAX_MBSFN_AREA) { + LOG_W(MAC, + "[UE %" PRIu8 "] MBSFN synchronization area %" PRIu8 + " out of range for eNB %" PRIu8 "\n", module_idP, + mbsfn_sync_area, eNB_index); + return -1; + } else if (UE_mac_inst[module_idP]. + mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) { + return mbsfn_sync_area; + } else { + LOG_W(MAC, + "[UE %" PRIu8 "] MBSFN Subframe Config pattern %" PRIu8 + " not found \n", module_idP, mbsfn_sync_area); + return -1; + } } -int ue_query_p_mch_info(module_id_t module_idP, uint32_t frameP, uint32_t subframe, int commonSFAlloc_period, int commonSFAlloc_offset, int num_sf_alloc, int *mtch_active, int *msi_active, uint8_t *mch_lcid) -{ +int ue_query_p_mch_info(module_id_t module_idP, uint32_t frameP, uint32_t subframe, int commonSFAlloc_period, int commonSFAlloc_offset, int num_sf_alloc, int *mtch_active, int *msi_active, + uint8_t *mch_lcid) { int i, mtch_mcs = -1; int mtch_flag = 0; int msi_flag = 0; @@ -976,16 +935,18 @@ int ue_query_p_mch_info(module_id_t module_idP, uint32_t frameP, uint32_t subfra //msi and mtch are mutally excluded then the break is safe if ((num_sf_alloc == 0) && (sf_AllocEnd_r9 >= 1)) { msi_flag = 1; - LOG_D(MAC,"msi(%d) should be allocated:frame(%d),submframe(%d),num_sf_alloc(%d),sf_AllocEnd_r9(%d),common_num_sf_alloc(%d)\n",i,frameP,subframe,num_sf_alloc,sf_AllocEnd_r9,UE_mac_inst[module_idP].common_num_sf_alloc); + LOG_D(MAC,"msi(%d) should be allocated:frame(%d),submframe(%d),num_sf_alloc(%d),sf_AllocEnd_r9(%d),common_num_sf_alloc(%d)\n",i,frameP,subframe,num_sf_alloc,sf_AllocEnd_r9, + UE_mac_inst[module_idP].common_num_sf_alloc); UE_mac_inst[module_idP].msi_current_alloc = num_sf_alloc; UE_mac_inst[module_idP].msi_pmch = i; } } else { //more that one MCH ?? check better this condition //msi and mtch are mutally excluded then the break is safe if ((num_sf_alloc == UE_mac_inst[module_idP].pmch_Config[i-1]->sf_AllocEnd_r9 + 1) && (sf_AllocEnd_r9 >= (num_sf_alloc+1))) { - //msi should be just after + //msi should be just after msi_flag = 1; - LOG_D(MAC,"msi(%d) should be allocated:frame(%d),submframe(%d),num_sf_alloc(%d),sf_AllocEnd_r9(%d),common_num_sf_alloc(%d)\n",i,frameP,subframe,num_sf_alloc,sf_AllocEnd_r9,UE_mac_inst[module_idP].common_num_sf_alloc); + LOG_D(MAC,"msi(%d) should be allocated:frame(%d),submframe(%d),num_sf_alloc(%d),sf_AllocEnd_r9(%d),common_num_sf_alloc(%d)\n",i,frameP,subframe,num_sf_alloc,sf_AllocEnd_r9, + UE_mac_inst[module_idP].common_num_sf_alloc); UE_mac_inst[module_idP].msi_current_alloc = num_sf_alloc; UE_mac_inst[module_idP].msi_pmch = i; } @@ -997,12 +958,15 @@ int ue_query_p_mch_info(module_id_t module_idP, uint32_t frameP, uint32_t subfra if (UE_mac_inst[module_idP].pmch_stop_mtch[i] >= num_sf_alloc) { if (UE_mac_inst[module_idP].pmch_stop_mtch[i] != 2047) { mtch_flag = 1; + if (UE_mac_inst[module_idP].pmch_Config[UE_mac_inst[module_idP].msi_pmch] != NULL) mtch_mcs = UE_mac_inst[module_idP].pmch_Config[UE_mac_inst[module_idP].msi_pmch]->dataMCS_r9; else mtch_mcs = -1; + *mch_lcid = (uint8_t)i; - LOG_D(MAC,"mtch should be allocated:frame(%d),submframe(%d),num_sf_alloc(%d),mtch_mcs(%d),pmch_stop_mtch(%d),lcid(%d),msi_pmch(%d)\n",frameP,subframe,num_sf_alloc,mtch_mcs,UE_mac_inst[module_idP].pmch_stop_mtch[i],UE_mac_inst[module_idP].pmch_lcids[i],UE_mac_inst[module_idP].msi_pmch); + LOG_D(MAC,"mtch should be allocated:frame(%d),submframe(%d),num_sf_alloc(%d),mtch_mcs(%d),pmch_stop_mtch(%d),lcid(%d),msi_pmch(%d)\n",frameP,subframe,num_sf_alloc,mtch_mcs, + UE_mac_inst[module_idP].pmch_stop_mtch[i],UE_mac_inst[module_idP].pmch_lcids[i],UE_mac_inst[module_idP].msi_pmch); break; } } @@ -1010,17 +974,15 @@ int ue_query_p_mch_info(module_id_t module_idP, uint32_t frameP, uint32_t subfra *mtch_active = mtch_flag; *msi_active = msi_flag; - return mtch_mcs; } -int ue_query_p_mch(module_id_t module_idP, uint32_t frameP, uint32_t subframe, int *mtch_active, int *msi_active, uint8_t *mch_lcid) -{ +int ue_query_p_mch(module_id_t module_idP, uint32_t frameP, uint32_t subframe, int *mtch_active, int *msi_active, uint8_t *mch_lcid) { int i, j, mtch_mcs = -1; int mtch_flag = 0; - // Acount for sf_allocable in CSA int num_sf_alloc = 0; + for (i = 0; i < 8; i++) { if (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i] == NULL) continue; @@ -1030,8 +992,9 @@ int ue_query_p_mch(module_id_t module_idP, uint32_t frameP, uint32_t subframe, i // four-frameP format uint32_t common_mbsfn_SubframeConfig = UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[2] | - (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[1]<<8) | - (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]<<16); + (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[1]<<8) | + (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]<<16); + for (j = 0; j < 24; j++) num_sf_alloc += ((common_mbsfn_SubframeConfig & (0x800000 >> j)) == (0x800000 >> j)); } @@ -1047,84 +1010,92 @@ int ue_query_p_mch(module_id_t module_idP, uint32_t frameP, uint32_t subframe, i int common_mbsfn_alloc_offset = UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->radioframeAllocationOffset; int common_mbsfn_period = 1 << UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->radioframeAllocationPeriod; int commonSF_AllocPeriod = 4 << UE_mac_inst[module_idP].commonSF_AllocPeriod_r9; - uint32_t common_mbsfn_SubframeConfig = UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[2] | - (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[1]<<8) | - (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]<<16); - + (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[1]<<8) | + (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]<<16); int jj = frameP % 4; + if ((frameP % common_mbsfn_period) != (common_mbsfn_alloc_offset + jj)) continue; - if(UE_mac_inst[module_idP].tdd_Config == NULL){ + if(UE_mac_inst[module_idP].tdd_Config == NULL) { switch (subframe) { - case 1: - if ((common_mbsfn_SubframeConfig & (0x800000 >> (jj*6))) == (0x800000 >> (jj*6))) { - mtch_flag = 1; - mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid); - UE_mac_inst[module_idP].common_num_sf_alloc++; - UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48; - } - break; - case 2: - if ((common_mbsfn_SubframeConfig & (0x400000 >> (jj*6))) == (0x400000 >> (jj*6))) { - mtch_flag = 1; - mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid); - UE_mac_inst[module_idP].common_num_sf_alloc++; - UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48; - } - break; - case 3: - if ((common_mbsfn_SubframeConfig & (0x200000 >> (jj*6))) == (0x200000 >> (jj*6))) { - mtch_flag = 1; - mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid); - UE_mac_inst[module_idP].common_num_sf_alloc++; - UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48; - } - break; - case 6: - if ((common_mbsfn_SubframeConfig & (0x100000 >> (jj*6))) == (0x100000 >> (jj*6))) { - mtch_flag = 1; - mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid); - UE_mac_inst[module_idP].common_num_sf_alloc++; - UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48; - } - break; - case 7: - if ((common_mbsfn_SubframeConfig & (0x80000 >> (jj*6))) == (0x80000 >> (jj*6))) { - mtch_flag = 1; - mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid); - UE_mac_inst[module_idP].common_num_sf_alloc++; - UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48; - } - break; - case 8: - if ((common_mbsfn_SubframeConfig & (0x40000 >> (jj*6))) == (0x40000 >> (jj*6))) { - mtch_flag = 1; - mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid); - UE_mac_inst[module_idP].common_num_sf_alloc++; - UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc% ( num_sf_alloc*commonSF_AllocPeriod/common_mbsfn_period);//48; - } - break; + case 1: + if ((common_mbsfn_SubframeConfig & (0x800000 >> (jj*6))) == (0x800000 >> (jj*6))) { + mtch_flag = 1; + mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid); + UE_mac_inst[module_idP].common_num_sf_alloc++; + UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48; + } + + break; + + case 2: + if ((common_mbsfn_SubframeConfig & (0x400000 >> (jj*6))) == (0x400000 >> (jj*6))) { + mtch_flag = 1; + mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid); + UE_mac_inst[module_idP].common_num_sf_alloc++; + UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48; + } + + break; + + case 3: + if ((common_mbsfn_SubframeConfig & (0x200000 >> (jj*6))) == (0x200000 >> (jj*6))) { + mtch_flag = 1; + mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid); + UE_mac_inst[module_idP].common_num_sf_alloc++; + UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48; + } + + break; + + case 6: + if ((common_mbsfn_SubframeConfig & (0x100000 >> (jj*6))) == (0x100000 >> (jj*6))) { + mtch_flag = 1; + mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid); + UE_mac_inst[module_idP].common_num_sf_alloc++; + UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48; + } + + break; + + case 7: + if ((common_mbsfn_SubframeConfig & (0x80000 >> (jj*6))) == (0x80000 >> (jj*6))) { + mtch_flag = 1; + mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid); + UE_mac_inst[module_idP].common_num_sf_alloc++; + UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48; + } + + break; + + case 8: + if ((common_mbsfn_SubframeConfig & (0x40000 >> (jj*6))) == (0x40000 >> (jj*6))) { + mtch_flag = 1; + mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid); + UE_mac_inst[module_idP].common_num_sf_alloc++; + UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc% ( num_sf_alloc*commonSF_AllocPeriod/common_mbsfn_period);//48; + } + + break; } } else { // TODO TDD } + if (mtch_flag == 1) break; } - return mtch_mcs; + return mtch_mcs; } -int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_t subframe, uint8_t eNB_index,uint8_t *sync_area, uint8_t *mcch_active) -{ - +int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_t subframe, uint8_t eNB_index,uint8_t *sync_area, uint8_t *mcch_active) { int i = 0, j = 0, ii = 0, jj = 0, msi_pos = 0, mcch_mcs = -1, mtch_mcs = -1; int mcch_flag = 0, mtch_flag = 0, msi_flag = 0; long mch_scheduling_period = -1; uint8_t mch_lcid = 0; - #if UE_TIMING_TRACE start_meas(&UE_mac_inst[module_idP].ue_query_mch); #endif @@ -1135,8 +1106,7 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ for (i = 0; i < UE_mac_inst[module_idP].num_active_mbsfn_area; - i++ ) - { + i++ ) { // assume, that there is always a mapping if ((j = ue_get_mbsfn_sf_alloction(module_idP,i,eNB_index)) == -1) { return -1; // continue; @@ -1144,12 +1114,10 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ ii = 0; msi_pos = 0; - long mbsfn_period = 1 << UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationPeriod; long mbsfn_alloc_offset = UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset; long mcch_period = 32 << UE_mac_inst[module_idP].mbsfn_AreaInfo[j]->mcch_Config_r9.mcch_RepetitionPeriod_r9; long mcch_offset = UE_mac_inst[module_idP].mbsfn_AreaInfo[j]->mcch_Config_r9.mcch_Offset_r9; - LOG_D(MAC, "[UE %d] Frame %d subframe %d: Checking MBSFN Sync Area %d/%d with SF allocation %d/%d for MCCH and MTCH (mbsfn period %ld, mcch period %ld,mac sched period (%ld,%ld))\n", module_idP,frameP, subframe,i,UE_mac_inst[module_idP].num_active_mbsfn_area, @@ -1158,26 +1126,25 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ // get the real MCS value switch (UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.signallingMCS_r9) { - case 0: - mcch_mcs = 2; - break; + case 0: + mcch_mcs = 2; + break; - case 1: - mcch_mcs = 7; - break; + case 1: + mcch_mcs = 7; + break; - case 2: - mcch_mcs = 13; - break; + case 2: + mcch_mcs = 13; + break; - case 3: - mcch_mcs = 19; - break; + case 3: + mcch_mcs = 19; + break; } if (UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.present == LTE_MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame) { // one-frameP format if (frameP % mbsfn_period == mbsfn_alloc_offset) { // MBSFN frameP - if (UE_mac_inst[module_idP].pmch_Config[0]) { // Find the first subframe in this MCH to transmit MSI if (frameP % mch_scheduling_period == mbsfn_alloc_offset) { @@ -1190,192 +1157,193 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ // Check if the subframe is for MSI, MCCH or MTCHs and Set the correspoding flag to 1 switch (subframe) { - case 1: - if (UE_mac_inst[module_idP].tdd_Config == NULL) { - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) { - if (msi_pos == 1) { - msi_flag = 1; + case 1: + if (UE_mac_inst[module_idP].tdd_Config == NULL) { + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) { + if (msi_pos == 1) { + msi_flag = 1; + } + + if ((frameP % mcch_period == mcch_offset) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1)) { + mcch_flag = 1; + } + + mtch_flag = 1; } + } - if ((frameP % mcch_period == mcch_offset) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1)) { - mcch_flag = 1; - } + break; - mtch_flag = 1; + case 2: + if (UE_mac_inst[module_idP].tdd_Config == NULL) { + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) { + if (msi_pos == 2) { + msi_flag = 1; + } + + if ((frameP % mcch_period == mcch_offset) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } } - } - break; + break; - case 2: - if (UE_mac_inst[module_idP].tdd_Config == NULL) { - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) { - if (msi_pos == 2) { - msi_flag = 1; + case 3: + if (UE_mac_inst[module_idP].tdd_Config != NULL) { // TDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) { + if (msi_pos == 1) { + msi_flag = 1; + } + + if ((frameP % mcch_period == mcch_offset) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3)) { + mcch_flag = 1; + } + + mtch_flag = 1; } - - if ((frameP % mcch_period == mcch_offset) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2)) { - mcch_flag = 1; + } else { // FDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) { + if (msi_pos == 3) { + msi_flag = 1; + } + + if ((frameP % mcch_period == mcch_offset) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3)) { + mcch_flag = 1; + } + + mtch_flag = 1; } - - mtch_flag = 1; } - } - break; + break; - case 3: - if (UE_mac_inst[module_idP].tdd_Config != NULL) { // TDD - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) { - if (msi_pos == 1) { - msi_flag = 1; - } + case 4: + if (UE_mac_inst[module_idP].tdd_Config != NULL) { + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) { + if (msi_pos == 2) { + msi_flag = 1; + } - if ((frameP % mcch_period == mcch_offset) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3)) { - mcch_flag = 1; - } + if ((frameP % mcch_period == mcch_offset) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4)) { + mcch_flag = 1; + } - mtch_flag = 1; - } - } else { // FDD - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) { - if (msi_pos == 3) { - msi_flag = 1; + mtch_flag = 1; } + } - if ((frameP % mcch_period == mcch_offset) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3)) { - mcch_flag = 1; - } + break; - mtch_flag = 1; + case 6: + if (UE_mac_inst[module_idP].tdd_Config == NULL) { + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) { + if (msi_pos == 4) { + msi_flag = 1; + } + + if ((frameP % mcch_period == mcch_offset) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6)) { + mcch_flag = 1; + } + + mtch_flag = 1; + } } - } - break; - - case 4: - if (UE_mac_inst[module_idP].tdd_Config != NULL) { - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) { - if (msi_pos == 2) { - msi_flag = 1; - } - - if ((frameP % mcch_period == mcch_offset) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4)) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; - - case 6: - if (UE_mac_inst[module_idP].tdd_Config == NULL) { - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) { - if (msi_pos == 4) { - msi_flag = 1; - } - - if ((frameP % mcch_period == mcch_offset) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6)) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } - - break; + break; - case 7: - if (UE_mac_inst[module_idP].tdd_Config != NULL) { // TDD - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) { - if (msi_pos == 3) { - msi_flag = 1; + case 7: + if (UE_mac_inst[module_idP].tdd_Config != NULL) { // TDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) { + if (msi_pos == 3) { + msi_flag = 1; + } + + if ((frameP % mcch_period == mcch_offset) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7)) { + mcch_flag = 1; + } + + mtch_flag = 1; } - - if ((frameP % mcch_period == mcch_offset) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7)) { - mcch_flag = 1; + } else { // FDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) { + if (msi_pos == 5) { + msi_flag = 1; + } + + if ((frameP % mcch_period == mcch_offset) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7)) { + mcch_flag = 1; + } + + mtch_flag = 1; } - - mtch_flag = 1; } - } else { // FDD - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) { - if (msi_pos == 5) { - msi_flag = 1; - } - - if ((frameP % mcch_period == mcch_offset) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7)) { - mcch_flag = 1; - } - mtch_flag = 1; - } - } - - break; + break; - case 8: - if (UE_mac_inst[module_idP].tdd_Config != NULL) { //TDD - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) { - if (msi_pos == 4) { - msi_flag = 1; + case 8: + if (UE_mac_inst[module_idP].tdd_Config != NULL) { //TDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) { + if (msi_pos == 4) { + msi_flag = 1; + } + + if ((frameP % mcch_period == mcch_offset) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8)) { + mcch_flag = 1; + } + + mtch_flag = 1; } - - if ((frameP % mcch_period == mcch_offset) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8)) { - mcch_flag = 1; + } else { // FDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) { + if (msi_pos == 6) { + msi_flag = 1; + } + + if ((frameP % mcch_period == mcch_offset) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8)) { + mcch_flag = 1; + } + + mtch_flag = 1; } - - mtch_flag = 1; } - } else { // FDD - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) { - if (msi_pos == 6) { - msi_flag = 1; - } - if ((frameP % mcch_period == mcch_offset) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8)) { - mcch_flag = 1; - } - - mtch_flag = 1; - } - } + break; - break; + case 9: + if (UE_mac_inst[module_idP].tdd_Config != NULL) { + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) { + if (msi_pos == 5) { + msi_flag = 1; + } - case 9: - if (UE_mac_inst[module_idP].tdd_Config != NULL) { - if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) { - if (msi_pos == 5) { - msi_flag = 1; - } + if ((frameP % mcch_period == mcch_offset) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9)) { + mcch_flag = 1; + } - if ((frameP % mcch_period == mcch_offset) && - ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9)) { - mcch_flag = 1; + mtch_flag = 1; } - - mtch_flag = 1; } - } - break; + break; }// end switch // Acount for sf_allocable in CSA int num_sf_alloc = 0; + for (i = 0; i < 8; i++) { if (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i] == NULL) continue; @@ -1384,6 +1352,7 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ continue; uint32_t common_mbsfn_SubframeConfig = UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]; + for (j = 0; j < 6; j++) num_sf_alloc += ((common_mbsfn_SubframeConfig & (0x80 >> j)) == (0x80 >> j)); } @@ -1395,6 +1364,7 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ mtch_mcs = UE_mac_inst[module_idP].pmch_Config[UE_mac_inst[module_idP].msi_pmch]->dataMCS_r9; else mtch_mcs = -1; + mch_lcid = (uint8_t)i; break; } @@ -1405,89 +1375,107 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ if ((msi_flag==1) || (mcch_flag==1) || (mtch_flag==1)) { LOG_D(MAC,"[UE %d] Frame %d Subframe %d: sync area %d SF alloc %d: msi flag %d, mcch flag %d, mtch flag %d\n", module_idP, frameP, subframe,i,j,msi_flag,mcch_flag,mtch_flag); - *sync_area=i; break; } } } else { // four-frameP format uint32_t mbsfn_SubframeConfig = UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[2] | - (UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[1]<<8) | - (UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0]<<16); + (UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[1]<<8) | + (UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0]<<16); uint32_t MCCH_mbsfn_SubframeConfig = /* UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[2] | (UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[1]<<8) | */ - (UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0]<<16); - + (UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0]<<16); jj=frameP%4; + if ((frameP % mbsfn_period) == (mbsfn_alloc_offset+jj)) { if (UE_mac_inst[module_idP].tdd_Config == NULL) { switch (subframe) { - case 1: - if ((mbsfn_SubframeConfig & (0x800000>>(jj*6))) == (0x800000>>(jj*6))) { - if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x800000>>(jj*6))) == (0x800000>>(jj*6)))) { - mcch_flag=1; - LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n", - frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x800000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc); - if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL) - UE_mac_inst[module_idP].common_num_sf_alloc++; + case 1: + if ((mbsfn_SubframeConfig & (0x800000>>(jj*6))) == (0x800000>>(jj*6))) { + if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x800000>>(jj*6))) == (0x800000>>(jj*6)))) { + mcch_flag=1; + LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n", + frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x800000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc); + + if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL) + UE_mac_inst[module_idP].common_num_sf_alloc++; + } } - } - break; - case 2: - if ((mbsfn_SubframeConfig & (0x400000>>(jj*6))) == (0x400000>>(jj*6))) { - if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x400000>>(jj*6))) == (0x400000>>(jj*6)))) { - mcch_flag=1; - LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n", - frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x400000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc); - if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL) - UE_mac_inst[module_idP].common_num_sf_alloc++; + + break; + + case 2: + if ((mbsfn_SubframeConfig & (0x400000>>(jj*6))) == (0x400000>>(jj*6))) { + if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x400000>>(jj*6))) == (0x400000>>(jj*6)))) { + mcch_flag=1; + LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n", + frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x400000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc); + + if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL) + UE_mac_inst[module_idP].common_num_sf_alloc++; + } } - } - break; - case 3: - if ((mbsfn_SubframeConfig & (0x200000>>(jj*6))) == (0x200000>>(jj*6))) { - if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x200000>>(jj*6))) == (0x200000>>(jj*6)))) { - LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n", - frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x200000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc); - mcch_flag=1; - if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL) - UE_mac_inst[module_idP].common_num_sf_alloc++; + + break; + + case 3: + if ((mbsfn_SubframeConfig & (0x200000>>(jj*6))) == (0x200000>>(jj*6))) { + if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x200000>>(jj*6))) == (0x200000>>(jj*6)))) { + LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n", + frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x200000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc); + mcch_flag=1; + + if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL) + UE_mac_inst[module_idP].common_num_sf_alloc++; + } } - } - break; - case 6: - if ((mbsfn_SubframeConfig & (0x100000>>(jj*6))) == (0x100000>>(jj*6))) { - if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x100000>>(jj*6))) == (0x100000>>(jj*6)))) { - LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n", - frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x100000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc); - mcch_flag=1; - if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL) - UE_mac_inst[module_idP].common_num_sf_alloc++; + + break; + + case 6: + if ((mbsfn_SubframeConfig & (0x100000>>(jj*6))) == (0x100000>>(jj*6))) { + if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x100000>>(jj*6))) == (0x100000>>(jj*6)))) { + LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n", + frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x100000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc); + mcch_flag=1; + + if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL) + UE_mac_inst[module_idP].common_num_sf_alloc++; + } } - } - break; - case 7: - if ((mbsfn_SubframeConfig & (0x80000>>(jj*6))) == (0x80000>>(jj*6))) { - if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x80000>>(jj*6))) == (0x80000>>(jj*6)))) { - LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n", - frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x80000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc); - if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL) - UE_mac_inst[module_idP].common_num_sf_alloc++; - mcch_flag=1; + + break; + + case 7: + if ((mbsfn_SubframeConfig & (0x80000>>(jj*6))) == (0x80000>>(jj*6))) { + if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x80000>>(jj*6))) == (0x80000>>(jj*6)))) { + LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n", + frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x80000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc); + + if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL) + UE_mac_inst[module_idP].common_num_sf_alloc++; + + mcch_flag=1; + } } - } - break; - case 8: - if ((mbsfn_SubframeConfig & (0x40000>>(jj*6))) == (0x40000>>(jj*6))) { - if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x40000>>(jj*6))) == (0x40000>>(jj*6)))) { - LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n", - frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x40000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc); - if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL) - UE_mac_inst[module_idP].common_num_sf_alloc++; - mcch_flag=1; + + break; + + case 8: + if ((mbsfn_SubframeConfig & (0x40000>>(jj*6))) == (0x40000>>(jj*6))) { + if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x40000>>(jj*6))) == (0x40000>>(jj*6)))) { + LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n", + frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x40000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc); + + if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL) + UE_mac_inst[module_idP].common_num_sf_alloc++; + + mcch_flag=1; + } } - } - break; + + break; }// end switch } else { // TODO TDD @@ -1510,7 +1498,7 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ stop_meas(&UE_mac_inst[module_idP].ue_query_mch); #endif - if ((mcch_flag == 1)) { // || (msi_flag==1)) + if ((mcch_flag == 1)) { // || (msi_flag==1)) *mcch_active = 1; } @@ -1518,9 +1506,11 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ if (msi_flag!=1) { for (i=0; i<8; i++) UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i] = NULL; + for (i=0; i<15; i++) UE_mac_inst[module_idP].pmch_Config[i] = NULL; - for (i=0; i<28 ;i++) { + + for (i=0; i<28 ; i++) { UE_mac_inst[module_idP].pmch_lcids[i] = -1; UE_mac_inst[module_idP].pmch_stop_mtch[i] = 2047; UE_mac_inst[module_idP].msi_status_v[i] = 0; @@ -1532,6 +1522,7 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ UE_mac_inst[module_idP].msi_status_v[i] = 0; } } + return mcch_mcs; } else if ((mtch_flag==1) && (UE_mac_inst[module_idP].msi_status_v[(mch_lcid > 27) ? 27 : mch_lcid] == 1)) { return mtch_mcs; @@ -1543,949 +1534,905 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_ #endif unsigned char -generate_ulsch_header(uint8_t * mac_header, - uint8_t num_sdus, - uint8_t short_padding, - uint16_t * sdu_lengths, - uint8_t * sdu_lcids, - POWER_HEADROOM_CMD * power_headroom, - uint16_t * crnti, - BSR_SHORT * truncated_bsr, - BSR_SHORT * short_bsr, - BSR_LONG * long_bsr, unsigned short post_padding) -{ - - SCH_SUBHEADER_FIXED *mac_header_ptr = - (SCH_SUBHEADER_FIXED *) mac_header; - unsigned char first_element = 0, last_size = 0, i; - unsigned char mac_header_control_elements[16], *ce_ptr; - - LOG_D(MAC, "[UE] Generate ULSCH : num_sdus %d\n", num_sdus); +generate_ulsch_header(uint8_t *mac_header, + uint8_t num_sdus, + uint8_t short_padding, + uint16_t *sdu_lengths, + uint8_t *sdu_lcids, + POWER_HEADROOM_CMD *power_headroom, + uint16_t *crnti, + BSR_SHORT *truncated_bsr, + BSR_SHORT *short_bsr, + BSR_LONG *long_bsr, unsigned short post_padding) { + SCH_SUBHEADER_FIXED *mac_header_ptr = + (SCH_SUBHEADER_FIXED *) mac_header; + unsigned char first_element = 0, last_size = 0, i; + unsigned char mac_header_control_elements[16], *ce_ptr; + LOG_D(MAC, "[UE] Generate ULSCH : num_sdus %d\n", num_sdus); #ifdef DEBUG_HEADER_PARSING - for (i = 0; i < num_sdus; i++) { - LOG_T(MAC, "[UE] sdu %d : lcid %d length %d", i, sdu_lcids[i], - sdu_lengths[i]); - } + for (i = 0; i < num_sdus; i++) { + LOG_T(MAC, "[UE] sdu %d : lcid %d length %d", i, sdu_lcids[i], + sdu_lengths[i]); + } - LOG_T(MAC, "\n"); + LOG_T(MAC, "\n"); #endif - ce_ptr = &mac_header_control_elements[0]; - - if ((short_padding == 1) || (short_padding == 2)) { - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_PADDING; - first_element = 1; - last_size = 1; - } + ce_ptr = &mac_header_control_elements[0]; + + if ((short_padding == 1) || (short_padding == 2)) { + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_PADDING; + first_element = 1; + last_size = 1; + } - if (short_padding == 2) { - mac_header_ptr->E = 1; - mac_header_ptr++; - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_PADDING; - last_size = 1; - } + if (short_padding == 2) { + mac_header_ptr->E = 1; + mac_header_ptr++; + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_PADDING; + last_size = 1; + } - if (power_headroom) { - if (first_element > 0) { - mac_header_ptr->E = 1; - mac_header_ptr++; - } else { - first_element = 1; - } - - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = POWER_HEADROOM; - last_size = 1; - *((POWER_HEADROOM_CMD *) ce_ptr) = (*power_headroom); - ce_ptr += sizeof(POWER_HEADROOM_CMD); - LOG_D(MAC, "phr header size %zu\n", sizeof(POWER_HEADROOM_CMD)); + if (power_headroom) { + if (first_element > 0) { + mac_header_ptr->E = 1; + mac_header_ptr++; + } else { + first_element = 1; } - if (crnti) { + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = POWER_HEADROOM; + last_size = 1; + *((POWER_HEADROOM_CMD *) ce_ptr) = (*power_headroom); + ce_ptr += sizeof(POWER_HEADROOM_CMD); + LOG_D(MAC, "phr header size %zu\n", sizeof(POWER_HEADROOM_CMD)); + } + + if (crnti) { #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC, "[UE] CRNTI : %x (first_element %d)\n", *crnti, - first_element); + LOG_D(MAC, "[UE] CRNTI : %x (first_element %d)\n", *crnti, + first_element); #endif - if (first_element > 0) { - mac_header_ptr->E = 1; - mac_header_ptr++; - } else { - first_element = 1; - } - - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = CRNTI; - last_size = 1; - *((uint16_t *) ce_ptr) = (*crnti); - ce_ptr += sizeof(uint16_t); - // printf("offset %d\n",ce_ptr-mac_header_control_elements); + if (first_element > 0) { + mac_header_ptr->E = 1; + mac_header_ptr++; + } else { + first_element = 1; } - if (truncated_bsr) { - if (first_element > 0) { - mac_header_ptr->E = 1; - /* - printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - */ - mac_header_ptr++; - } else { - first_element = 1; - } + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = CRNTI; + last_size = 1; + *((uint16_t *) ce_ptr) = (*crnti); + ce_ptr += sizeof(uint16_t); + // printf("offset %d\n",ce_ptr-mac_header_control_elements); + } + + if (truncated_bsr) { + if (first_element > 0) { + mac_header_ptr->E = 1; + /* + printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + */ + mac_header_ptr++; + } else { + first_element = 1; + } #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC, "[UE] Scheduler Truncated BSR Header\n"); + LOG_D(MAC, "[UE] Scheduler Truncated BSR Header\n"); #endif - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = TRUNCATED_BSR; - last_size = 1; - *((BSR_TRUNCATED *) ce_ptr) = (*truncated_bsr); - ce_ptr += sizeof(BSR_TRUNCATED); - // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); - - } else if (short_bsr) { - if (first_element > 0) { - mac_header_ptr->E = 1; - /* - printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - */ - mac_header_ptr++; - } else { - first_element = 1; - } + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = TRUNCATED_BSR; + last_size = 1; + *((BSR_TRUNCATED *) ce_ptr) = (*truncated_bsr); + ce_ptr += sizeof(BSR_TRUNCATED); + // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); + } else if (short_bsr) { + if (first_element > 0) { + mac_header_ptr->E = 1; + /* + printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + */ + mac_header_ptr++; + } else { + first_element = 1; + } #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC, "[UE] Scheduler SHORT BSR Header\n"); + LOG_D(MAC, "[UE] Scheduler SHORT BSR Header\n"); #endif - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_BSR; - last_size = 1; - *((BSR_SHORT *) ce_ptr) = (*short_bsr); - ce_ptr += sizeof(BSR_SHORT); - - // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); - } else if (long_bsr) { - if (first_element > 0) { - mac_header_ptr->E = 1; - /* - printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - */ - mac_header_ptr++; - } else { - first_element = 1; - } + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_BSR; + last_size = 1; + *((BSR_SHORT *) ce_ptr) = (*short_bsr); + ce_ptr += sizeof(BSR_SHORT); + // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); + } else if (long_bsr) { + if (first_element > 0) { + mac_header_ptr->E = 1; + /* + printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + */ + mac_header_ptr++; + } else { + first_element = 1; + } #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC, "[UE] Scheduler Long BSR Header\n"); + LOG_D(MAC, "[UE] Scheduler Long BSR Header\n"); #endif - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = LONG_BSR; - last_size = 1; - - *(ce_ptr) = - (long_bsr-> - Buffer_size0 << 2) | ((long_bsr->Buffer_size1 & 0x30) >> 4); - *(ce_ptr + 1) = - ((long_bsr->Buffer_size1 & 0x0F) << 4) | ((long_bsr-> - Buffer_size2 & 0x3C) - >> 2); - *(ce_ptr + 2) = - ((long_bsr-> - Buffer_size2 & 0x03) << 2) | (long_bsr->Buffer_size3 & 0x3F); - ce_ptr += BSR_LONG_SIZE; - - // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); - } - // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = LONG_BSR; + last_size = 1; + *(ce_ptr) = + (long_bsr-> + Buffer_size0 << 2) | ((long_bsr->Buffer_size1 & 0x30) >> 4); + *(ce_ptr + 1) = + ((long_bsr->Buffer_size1 & 0x0F) << 4) | ((long_bsr-> + Buffer_size2 & 0x3C) + >> 2); + *(ce_ptr + 2) = + ((long_bsr-> + Buffer_size2 & 0x03) << 2) | (long_bsr->Buffer_size3 & 0x3F); + ce_ptr += BSR_LONG_SIZE; + // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); + } + + // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); - for (i = 0; i < num_sdus; i++) { + for (i = 0; i < num_sdus; i++) { #ifdef DEBUG_HEADER_PARSING - LOG_T(MAC, "[UE] sdu subheader %d (lcid %d, %d bytes)\n", i, - sdu_lcids[i], sdu_lengths[i]); + LOG_T(MAC, "[UE] sdu subheader %d (lcid %d, %d bytes)\n", i, + sdu_lcids[i], sdu_lengths[i]); #endif - if ((i == (num_sdus - 1)) - && ((short_padding) || (post_padding == 0))) { - if (first_element > 0) { - mac_header_ptr->E = 1; + if ((i == (num_sdus - 1)) + && ((short_padding) || (post_padding == 0))) { + if (first_element > 0) { + mac_header_ptr->E = 1; #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC, "[UE] last subheader : %x (R%d,E%d,LCID%d)\n", - *(unsigned char *) mac_header_ptr, - ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID); + LOG_D(MAC, "[UE] last subheader : %x (R%d,E%d,LCID%d)\n", + *(unsigned char *) mac_header_ptr, + ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID); #endif - mac_header_ptr += last_size; - } - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = sdu_lcids[i]; - } else { - if ((first_element > 0)) { - mac_header_ptr->E = 1; + mac_header_ptr += last_size; + } + + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = sdu_lcids[i]; + } else { + if ((first_element > 0)) { + mac_header_ptr->E = 1; #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC, "[UE] last subheader : %x (R%d,E%d,LCID%d)\n", - *(unsigned char *) mac_header_ptr, - ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID); + LOG_D(MAC, "[UE] last subheader : %x (R%d,E%d,LCID%d)\n", + *(unsigned char *) mac_header_ptr, + ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID); #endif - mac_header_ptr += last_size; - // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); - } else { - first_element = 1; - - } - - if (sdu_lengths[i] < 128) { - ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->R = 0; // 3 - ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->E = 0; - ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F = 0; - ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->LCID = - sdu_lcids[i]; - ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L = - (unsigned char) sdu_lengths[i]; - last_size = 2; + mac_header_ptr += last_size; + // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); + } else { + first_element = 1; + } + + if (sdu_lengths[i] < 128) { + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->R = 0; // 3 + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->E = 0; + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F = 0; + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->LCID = + sdu_lcids[i]; + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L = + (unsigned char) sdu_lengths[i]; + last_size = 2; #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC, "[UE] short sdu\n"); - LOG_T(MAC, - "[UE] last subheader : %x (R%d,E%d,LCID%d,F%d,L%d)\n", - ((uint16_t *) mac_header_ptr)[0], - ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->R, - ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->E, - ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->LCID, - ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F, - ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L); + LOG_D(MAC, "[UE] short sdu\n"); + LOG_T(MAC, + "[UE] last subheader : %x (R%d,E%d,LCID%d,F%d,L%d)\n", + ((uint16_t *) mac_header_ptr)[0], + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->R, + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->E, + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->LCID, + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F, + ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L); #endif - } else { - ((SCH_SUBHEADER_LONG *) mac_header_ptr)->R = 0; - ((SCH_SUBHEADER_LONG *) mac_header_ptr)->E = 0; - ((SCH_SUBHEADER_LONG *) mac_header_ptr)->F = 1; - ((SCH_SUBHEADER_LONG *) mac_header_ptr)->LCID = - sdu_lcids[i]; - ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB = - ((unsigned short) sdu_lengths[i] >> 8) & 0x7f; - ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB = - (unsigned short) sdu_lengths[i] & 0xff; - ((SCH_SUBHEADER_LONG *) mac_header_ptr)->padding = 0x00; - last_size = 3; + } else { + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->R = 0; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->E = 0; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->F = 1; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->LCID = + sdu_lcids[i]; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB = + ((unsigned short) sdu_lengths[i] >> 8) & 0x7f; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB = + (unsigned short) sdu_lengths[i] & 0xff; + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->padding = 0x00; + last_size = 3; #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC, "[UE] long sdu\n"); + LOG_D(MAC, "[UE] long sdu\n"); #endif - } - } + } } + } - if (post_padding > 0) { // we have lots of padding at the end of the packet - mac_header_ptr->E = 1; - mac_header_ptr += last_size; - // add a padding element - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_PADDING; - mac_header_ptr++; - } else { // no end of packet padding - // last SDU subhead is of fixed type (sdu length implicitly to be computed at UE) - mac_header_ptr++; - //mac_header_ptr=last_size; // FIXME: should be ++ - } + if (post_padding > 0) { // we have lots of padding at the end of the packet + mac_header_ptr->E = 1; + mac_header_ptr += last_size; + // add a padding element + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_PADDING; + mac_header_ptr++; + } else { // no end of packet padding + // last SDU subhead is of fixed type (sdu length implicitly to be computed at UE) + mac_header_ptr++; + //mac_header_ptr=last_size; // FIXME: should be ++ + } + if ((ce_ptr - mac_header_control_elements) > 0) { + memcpy((void *) mac_header_ptr, mac_header_control_elements, + ce_ptr - mac_header_control_elements); + mac_header_ptr += + (unsigned char) (ce_ptr - mac_header_control_elements); + } - if ((ce_ptr - mac_header_control_elements) > 0) { - memcpy((void *) mac_header_ptr, mac_header_control_elements, - ce_ptr - mac_header_control_elements); - mac_header_ptr += - (unsigned char) (ce_ptr - mac_header_control_elements); - } #ifdef DEBUG_HEADER_PARSING - LOG_T(MAC, " [UE] header : "); + LOG_T(MAC, " [UE] header : "); - for (i = 0; i < ((unsigned char *) mac_header_ptr - mac_header); i++) { - LOG_T(MAC, "%2x.", mac_header[i]); - } + for (i = 0; i < ((unsigned char *) mac_header_ptr - mac_header); i++) { + LOG_T(MAC, "%2x.", mac_header[i]); + } - LOG_T(MAC, "\n"); + LOG_T(MAC, "\n"); #endif - return ((unsigned char *) mac_header_ptr - mac_header); - + return ((unsigned char *) mac_header_ptr - mac_header); } void ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, - sub_frame_t subframe, uint8_t eNB_index, - uint8_t * ulsch_buffer, uint16_t buflen, uint8_t * access_mode) -{ - - uint8_t total_rlc_pdu_header_len = 0, rlc_pdu_header_len_last = 0; - uint16_t buflen_remain = 0; - uint8_t bsr_len = 0, bsr_ce_len = 0, bsr_header_len = 0; - uint8_t phr_header_len = 0, phr_ce_len = 0, phr_len = 0; - uint8_t lcid = 0, lcid_rlc_pdu_count = 0; - boolean_t is_lcid_processed = FALSE; - boolean_t is_all_lcid_processed = FALSE; - uint16_t sdu_lengths[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - uint8_t sdu_lcids[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - uint8_t payload_offset = 0, num_sdus = 0; - uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; - uint16_t sdu_length_total = 0; - BSR_SHORT bsr_short, bsr_truncated; - BSR_LONG bsr_long; - BSR_SHORT *bsr_s = &bsr_short; - BSR_LONG *bsr_l = &bsr_long; - BSR_SHORT *bsr_t = &bsr_truncated; - POWER_HEADROOM_CMD phr; - POWER_HEADROOM_CMD *phr_p = &phr; - unsigned short short_padding = 0, post_padding = 0, padding_len = 0; - int j; // used for padding - // Compute header length - int lcg_id = 0; - int lcg_id_bsr_trunc = 0; - int highest_priority = 16; - int num_lcg_id_with_data = 0; - rlc_buffer_occupancy_t lcid_buffer_occupancy_old = - 0, lcid_buffer_occupancy_new = 0; - - LOG_D(MAC, - "[UE %d] MAC PROCESS UL TRANSPORT BLOCK at frame%d subframe %d TBS=%d\n", - module_idP, frameP, subframe, buflen); - - - AssertFatal(CC_id == 0, - "Transmission on secondary CCs is not supported yet\n"); - + sub_frame_t subframe, uint8_t eNB_index, + uint8_t *ulsch_buffer, uint16_t buflen, uint8_t *access_mode) { + uint8_t total_rlc_pdu_header_len = 0, rlc_pdu_header_len_last = 0; + uint16_t buflen_remain = 0; + uint8_t bsr_len = 0, bsr_ce_len = 0, bsr_header_len = 0; + uint8_t phr_header_len = 0, phr_ce_len = 0, phr_len = 0; + uint8_t lcid = 0, lcid_rlc_pdu_count = 0; + boolean_t is_lcid_processed = FALSE; + boolean_t is_all_lcid_processed = FALSE; + uint16_t sdu_lengths[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + uint8_t sdu_lcids[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + uint8_t payload_offset = 0, num_sdus = 0; + uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; + uint16_t sdu_length_total = 0; + BSR_SHORT bsr_short, bsr_truncated; + BSR_LONG bsr_long; + BSR_SHORT *bsr_s = &bsr_short; + BSR_LONG *bsr_l = &bsr_long; + BSR_SHORT *bsr_t = &bsr_truncated; + POWER_HEADROOM_CMD phr; + POWER_HEADROOM_CMD *phr_p = &phr; + unsigned short short_padding = 0, post_padding = 0, padding_len = 0; + int j; // used for padding + // Compute header length + int lcg_id = 0; + int lcg_id_bsr_trunc = 0; + int highest_priority = 16; + int num_lcg_id_with_data = 0; + rlc_buffer_occupancy_t lcid_buffer_occupancy_old = + 0, lcid_buffer_occupancy_new = 0; + LOG_D(MAC, + "[UE %d] MAC PROCESS UL TRANSPORT BLOCK at frame%d subframe %d TBS=%d\n", + module_idP, frameP, subframe, buflen); + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); #if UE_TIMING_TRACE - start_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); + start_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); #endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_IN); - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_IN); #ifdef CBA - if (*access_mode == CBA_ACCESS) { - LOG_D(MAC, "[UE %d] frameP %d subframe %d try CBA transmission\n", - module_idP, frameP, subframe); - - //if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DTCH] == LCID_EMPTY) - if (cba_access(module_idP, frameP, subframe, eNB_index, buflen) == - 0) { - *access_mode = POSTPONED_ACCESS; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); - return; - } - - LOG_I(MAC, - "[UE %d] frameP %d subframe %d CBA transmission oppurtunity, tbs %d\n", - module_idP, frameP, subframe, buflen); + if (*access_mode == CBA_ACCESS) { + LOG_D(MAC, "[UE %d] frameP %d subframe %d try CBA transmission\n", + module_idP, frameP, subframe); + + //if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DTCH] == LCID_EMPTY) + if (cba_access(module_idP, frameP, subframe, eNB_index, buflen) == + 0) { + *access_mode = POSTPONED_ACCESS; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); + return; } + + LOG_I(MAC, + "[UE %d] frameP %d subframe %d CBA transmission oppurtunity, tbs %d\n", + module_idP, frameP, subframe, buflen); + } + #endif - bsr_header_len = 0; - phr_header_len = 1; //sizeof(SCH_SUBHEADER_FIXED); - - while (lcg_id < MAX_NUM_LCGID) { - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]) { - num_lcg_id_with_data++; - } - lcg_id++; + bsr_header_len = 0; + phr_header_len = 1; //sizeof(SCH_SUBHEADER_FIXED); + + while (lcg_id < MAX_NUM_LCGID) { + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]) { + num_lcg_id_with_data++; } - if (num_lcg_id_with_data) { - LOG_D(MAC, - "[UE %d] MAC Tx data pending at frame%d subframe %d nb LCG =%d Bytes for LCG0=%d LCG1=%d LCG2=%d LCG3=%d BSR Trigger status =%d TBS=%d\n", - module_idP, frameP, subframe, num_lcg_id_with_data, - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0], - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[1], - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[2], - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[3], - UE_mac_inst[module_idP].BSR_reporting_active, buflen); + lcg_id++; + } - } - //Restart ReTxBSR Timer at new grant indication (36.321) - if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != - MAC_UE_BSR_TIMER_NOT_RUNNING) { - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = - get_sf_retxBSRTimer(UE_mac_inst[module_idP]. - scheduling_info.retxBSR_Timer); - } - // periodicBSR-Timer expires, trigger BSR - if ((UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer != - LTE_PeriodicBSR_Timer_r12_infinity) - && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF == 0)) { - // Trigger BSR Periodic - UE_mac_inst[module_idP].BSR_reporting_active |= - BSR_TRIGGER_PERIODIC; - - LOG_D(MAC, - "[UE %d] MAC BSR Triggered PeriodicBSR Timer expiry at frame%d subframe %d TBS=%d\n", - module_idP, frameP, subframe, buflen); + if (num_lcg_id_with_data) { + LOG_D(MAC, + "[UE %d] MAC Tx data pending at frame%d subframe %d nb LCG =%d Bytes for LCG0=%d LCG1=%d LCG2=%d LCG3=%d BSR Trigger status =%d TBS=%d\n", + module_idP, frameP, subframe, num_lcg_id_with_data, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[1], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[2], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[3], + UE_mac_inst[module_idP].BSR_reporting_active, buflen); + } - } - //Compute BSR Length if Regular or Periodic BSR is triggered - //WARNING: if BSR long is computed, it may be changed to BSR short during or after multiplexing if there remains less than 1 LCGROUP with data after Tx - if (UE_mac_inst[module_idP].BSR_reporting_active) { - - AssertFatal((UE_mac_inst[module_idP].BSR_reporting_active & - BSR_TRIGGER_PADDING) == 0, - "Inconsistent BSR Trigger=%d !\n", - UE_mac_inst[module_idP].BSR_reporting_active); - - if (buflen >= 4) { - //A Regular or Periodic BSR can only be sent if TBS >= 4 as transmitting only a BSR is not allowed if UE has data to transmit - bsr_header_len = 1; - - if (num_lcg_id_with_data <= 1) { - bsr_ce_len = sizeof(BSR_SHORT); //1 byte - } else { - bsr_ce_len = BSR_LONG_SIZE; //3 bytes - } - } - } + //Restart ReTxBSR Timer at new grant indication (36.321) + if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != + MAC_UE_BSR_TIMER_NOT_RUNNING) { + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = + get_sf_retxBSRTimer(UE_mac_inst[module_idP]. + scheduling_info.retxBSR_Timer); + } - bsr_len = bsr_ce_len + bsr_header_len; - - phr_ce_len = - (UE_mac_inst[module_idP].PHR_reporting_active == - 1) ? 1 /* sizeof(POWER_HEADROOM_CMD) */ : 0; - if ((phr_ce_len > 0) - && ((phr_ce_len + phr_header_len + bsr_len) <= buflen)) { - phr_len = phr_ce_len + phr_header_len; - LOG_D(MAC, - "[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n", - module_idP, phr_len, phr_ce_len, phr_header_len, buflen); - } else { - phr_len = 0; - phr_header_len = 0; - phr_ce_len = 0; + // periodicBSR-Timer expires, trigger BSR + if ((UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer != + LTE_PeriodicBSR_Timer_r12_infinity) + && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF == 0)) { + // Trigger BSR Periodic + UE_mac_inst[module_idP].BSR_reporting_active |= + BSR_TRIGGER_PERIODIC; + LOG_D(MAC, + "[UE %d] MAC BSR Triggered PeriodicBSR Timer expiry at frame%d subframe %d TBS=%d\n", + module_idP, frameP, subframe, buflen); + } + + //Compute BSR Length if Regular or Periodic BSR is triggered + //WARNING: if BSR long is computed, it may be changed to BSR short during or after multiplexing if there remains less than 1 LCGROUP with data after Tx + if (UE_mac_inst[module_idP].BSR_reporting_active) { + AssertFatal((UE_mac_inst[module_idP].BSR_reporting_active & + BSR_TRIGGER_PADDING) == 0, + "Inconsistent BSR Trigger=%d !\n", + UE_mac_inst[module_idP].BSR_reporting_active); + + if (buflen >= 4) { + //A Regular or Periodic BSR can only be sent if TBS >= 4 as transmitting only a BSR is not allowed if UE has data to transmit + bsr_header_len = 1; + + if (num_lcg_id_with_data <= 1) { + bsr_ce_len = sizeof(BSR_SHORT); //1 byte + } else { + bsr_ce_len = BSR_LONG_SIZE; //3 bytes + } } + } - // check for UL bandwidth requests and add SR control element - - // check for UL bandwidth requests and add SR control element - - // Check for DCCH first -// TO DO: Multiplex in the order defined by the logical channel prioritization - for (lcid = DCCH; - (lcid < MAX_NUM_LCID) && (is_all_lcid_processed == FALSE); lcid++) - { - if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == - LCID_NOT_EMPTY) { - - lcid_rlc_pdu_count = 0; - is_lcid_processed = FALSE; - lcid_buffer_occupancy_old = - mac_rlc_get_buffer_occupancy_ind(module_idP, - UE_mac_inst[module_idP]. - crnti, eNB_index, frameP, - subframe, ENB_FLAG_NO, - lcid); - - lcid_buffer_occupancy_new = lcid_buffer_occupancy_old; - - AssertFatal(lcid_buffer_occupancy_new == - UE_mac_inst[module_idP]. - scheduling_info.LCID_buffer_remain[lcid], - "LCID=%d RLC has BO %d bytes but MAC has stored %d bytes\n", - lcid, lcid_buffer_occupancy_new, - UE_mac_inst[module_idP]. - scheduling_info.LCID_buffer_remain[lcid]); - - AssertFatal(lcid_buffer_occupancy_new <= - UE_mac_inst[module_idP]. - scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. - scheduling_info.LCGID - [lcid]], - "LCID=%d RLC has more BO %d bytes than BSR = %d bytes\n", - lcid, lcid_buffer_occupancy_new, - UE_mac_inst[module_idP]. - scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. - scheduling_info.LCGID - [lcid]]); - - - //Multiplex all available DCCH RLC PDUs considering to multiplex the last PDU each time for maximize the data - //Adjust at the end of the loop - while ((!is_lcid_processed) && (lcid_buffer_occupancy_new) - && (bsr_len + phr_len + total_rlc_pdu_header_len + - sdu_length_total + MIN_MAC_HDR_RLC_SIZE <= buflen)) - { - - // Workaround for issue in OAI eNB or EPC which are not able to process SRB2 message multiplexed with SRB1 on the same MAC PDU - if (( get_softmodem_params()->usim_test == 0) && (lcid == DCCH1) - && (lcid_rlc_pdu_count == 0) && (num_sdus)) { - - // Skip SRB2 multiplex if at least one SRB1 SDU is already multiplexed - break; - } - - buflen_remain = - buflen - (bsr_len + phr_len + - total_rlc_pdu_header_len + sdu_length_total + - 1); - - - LOG_D(MAC, - "[UE %d] Frame %d : UL-DXCH -> ULSCH, RLC %d has %d bytes to " - "send (Transport Block size %d BSR size=%d PHR=%d SDU Length Total %d , mac header len %d BSR byte before Tx=%d)\n", - module_idP, frameP, lcid, lcid_buffer_occupancy_new, - buflen, bsr_len, phr_len, sdu_length_total, - total_rlc_pdu_header_len, - UE_mac_inst[module_idP]. - scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. - scheduling_info.LCGID - [lcid]]); - - - sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, - UE_mac_inst - [module_idP]. - crnti, eNB_index, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, - lcid, - buflen_remain, - (char *)&ulsch_buff[sdu_length_total] + bsr_len = bsr_ce_len + bsr_header_len; + phr_ce_len = + (UE_mac_inst[module_idP].PHR_reporting_active == + 1) ? 1 /* sizeof(POWER_HEADROOM_CMD) */ : 0; + + if ((phr_ce_len > 0) + && ((phr_ce_len + phr_header_len + bsr_len) <= buflen)) { + phr_len = phr_ce_len + phr_header_len; + LOG_D(MAC, + "[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n", + module_idP, phr_len, phr_ce_len, phr_header_len, buflen); + } else { + phr_len = 0; + phr_header_len = 0; + phr_ce_len = 0; + } + + // check for UL bandwidth requests and add SR control element + + // check for UL bandwidth requests and add SR control element + + // Check for DCCH first + // TO DO: Multiplex in the order defined by the logical channel prioritization + for (lcid = DCCH; + (lcid < MAX_NUM_LCID) && (is_all_lcid_processed == FALSE); lcid++) { + if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == + LCID_NOT_EMPTY) { + lcid_rlc_pdu_count = 0; + is_lcid_processed = FALSE; + lcid_buffer_occupancy_old = + mac_rlc_get_buffer_occupancy_ind(module_idP, + UE_mac_inst[module_idP]. + crnti, eNB_index, frameP, + subframe, ENB_FLAG_NO, + lcid); + lcid_buffer_occupancy_new = lcid_buffer_occupancy_old; + AssertFatal(lcid_buffer_occupancy_new == + UE_mac_inst[module_idP]. + scheduling_info.LCID_buffer_remain[lcid], + "LCID=%d RLC has BO %d bytes but MAC has stored %d bytes\n", + lcid, lcid_buffer_occupancy_new, + UE_mac_inst[module_idP]. + scheduling_info.LCID_buffer_remain[lcid]); + AssertFatal(lcid_buffer_occupancy_new <= + UE_mac_inst[module_idP]. + scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. + scheduling_info.LCGID + [lcid]], + "LCID=%d RLC has more BO %d bytes than BSR = %d bytes\n", + lcid, lcid_buffer_occupancy_new, + UE_mac_inst[module_idP]. + scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. + scheduling_info.LCGID + [lcid]]); + + //Multiplex all available DCCH RLC PDUs considering to multiplex the last PDU each time for maximize the data + //Adjust at the end of the loop + while ((!is_lcid_processed) && (lcid_buffer_occupancy_new) + && (bsr_len + phr_len + total_rlc_pdu_header_len + + sdu_length_total + MIN_MAC_HDR_RLC_SIZE <= buflen)) { + // Workaround for issue in OAI eNB or EPC which are not able to process SRB2 message multiplexed with SRB1 on the same MAC PDU + if (( get_softmodem_params()->usim_test == 0) && (lcid == DCCH1) + && (lcid_rlc_pdu_count == 0) && (num_sdus)) { + // Skip SRB2 multiplex if at least one SRB1 SDU is already multiplexed + break; + } + + buflen_remain = + buflen - (bsr_len + phr_len + + total_rlc_pdu_header_len + sdu_length_total + + 1); + LOG_D(MAC, + "[UE %d] Frame %d : UL-DXCH -> ULSCH, RLC %d has %d bytes to " + "send (Transport Block size %d BSR size=%d PHR=%d SDU Length Total %d , mac header len %d BSR byte before Tx=%d)\n", + module_idP, frameP, lcid, lcid_buffer_occupancy_new, + buflen, bsr_len, phr_len, sdu_length_total, + total_rlc_pdu_header_len, + UE_mac_inst[module_idP]. + scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. + scheduling_info.LCGID + [lcid]]); + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, + UE_mac_inst + [module_idP]. + crnti, eNB_index, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, + lcid, + buflen_remain, + (char *)&ulsch_buff[sdu_length_total] #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, - 0 + ,0, + 0 #endif - ); - - - - AssertFatal(buflen_remain >= sdu_lengths[num_sdus], - "LCID=%d RLC has segmented %d bytes but MAC has max=%d\n", - lcid, sdu_lengths[num_sdus], buflen_remain); - - - if (sdu_lengths[num_sdus]) { - sdu_length_total += sdu_lengths[num_sdus]; - sdu_lcids[num_sdus] = lcid; - LOG_I(MAC, - "[UE %d] TX Multiplex RLC PDU TX Got %d bytes for LcId%d\n", - module_idP, sdu_lengths[num_sdus], lcid); - - if (buflen == - (bsr_len + phr_len + total_rlc_pdu_header_len + - sdu_length_total + 1)) { - //No more remaining TBS after this PDU - //exit the function - rlc_pdu_header_len_last = 1; - is_lcid_processed = TRUE; - is_all_lcid_processed = TRUE; - } else { - rlc_pdu_header_len_last = - (sdu_lengths[num_sdus] > 128) ? 3 : 2; - - //Change to 1 byte if it does not fit in the TBS, ie last PDU - if (buflen <= - (bsr_len + phr_len + total_rlc_pdu_header_len + - rlc_pdu_header_len_last + sdu_length_total)) { - rlc_pdu_header_len_last = 1; - is_lcid_processed = TRUE; - is_all_lcid_processed = TRUE; - } - } - - //Update number of SDU - num_sdus++; - - //Update total MAC Header size for RLC PDUs and save last one - total_rlc_pdu_header_len += rlc_pdu_header_len_last; - - lcid_rlc_pdu_count++; - } else { - /* avoid infinite loop ... */ - is_lcid_processed = TRUE; - } - - /* Get updated BO after multiplexing this PDU */ - lcid_buffer_occupancy_new = - mac_rlc_get_buffer_occupancy_ind(module_idP, - UE_mac_inst - [module_idP].crnti, - eNB_index, frameP, - subframe, ENB_FLAG_NO, - lcid); - - is_lcid_processed = (is_lcid_processed) - || (lcid_buffer_occupancy_new <= 0); - } - - //Update Buffer remain and BSR bytes after transmission - - AssertFatal(lcid_buffer_occupancy_new <= - lcid_buffer_occupancy_old, - "MAC UE Tx error : Buffer Occupancy After Tx=%d greater than before=%d BO! for LCID=%d RLC PDU nb=%d Frame %d Subrame %d\n", - lcid_buffer_occupancy_new, - lcid_buffer_occupancy_old, lcid, - lcid_rlc_pdu_count, frameP, subframe); - - UE_mac_inst[module_idP].scheduling_info. - LCID_buffer_remain[lcid] = lcid_buffer_occupancy_new; - UE_mac_inst[module_idP]. - scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. - scheduling_info.LCGID[lcid]] += - (lcid_buffer_occupancy_new - lcid_buffer_occupancy_old); - - //Update the number of LCGID with data as BSR shall reflect status after BSR transmission - if ((num_lcg_id_with_data > 1) - && (UE_mac_inst[module_idP]. - scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. - scheduling_info.LCGID[lcid]] - == 0)) { - num_lcg_id_with_data--; - // Change BSR size to BSR SHORT if num_lcg_id_with_data becomes to 1 - if ((bsr_len) && (num_lcg_id_with_data == 1)) { - bsr_ce_len = sizeof(BSR_SHORT); - bsr_len = bsr_ce_len + bsr_header_len; - } - } - - - UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = - LCID_EMPTY; - } - } + ); + AssertFatal(buflen_remain >= sdu_lengths[num_sdus], + "LCID=%d RLC has segmented %d bytes but MAC has max=%d\n", + lcid, sdu_lengths[num_sdus], buflen_remain); + + if (sdu_lengths[num_sdus]) { + sdu_length_total += sdu_lengths[num_sdus]; + sdu_lcids[num_sdus] = lcid; + LOG_I(MAC, + "[UE %d] TX Multiplex RLC PDU TX Got %d bytes for LcId%d\n", + module_idP, sdu_lengths[num_sdus], lcid); + + if (buflen == + (bsr_len + phr_len + total_rlc_pdu_header_len + + sdu_length_total + 1)) { + //No more remaining TBS after this PDU + //exit the function + rlc_pdu_header_len_last = 1; + is_lcid_processed = TRUE; + is_all_lcid_processed = TRUE; + } else { + rlc_pdu_header_len_last = + (sdu_lengths[num_sdus] > 128) ? 3 : 2; + + //Change to 1 byte if it does not fit in the TBS, ie last PDU + if (buflen <= + (bsr_len + phr_len + total_rlc_pdu_header_len + + rlc_pdu_header_len_last + sdu_length_total)) { + rlc_pdu_header_len_last = 1; + is_lcid_processed = TRUE; + is_all_lcid_processed = TRUE; + } + } + //Update number of SDU + num_sdus++; + //Update total MAC Header size for RLC PDUs and save last one + total_rlc_pdu_header_len += rlc_pdu_header_len_last; + lcid_rlc_pdu_count++; + } else { + /* avoid infinite loop ... */ + is_lcid_processed = TRUE; + } + /* Get updated BO after multiplexing this PDU */ + lcid_buffer_occupancy_new = + mac_rlc_get_buffer_occupancy_ind(module_idP, + UE_mac_inst + [module_idP].crnti, + eNB_index, frameP, + subframe, ENB_FLAG_NO, + lcid); + is_lcid_processed = (is_lcid_processed) + || (lcid_buffer_occupancy_new <= 0); + } - // Compute BSR Values and update Nb LCGID with data after multiplexing - num_lcg_id_with_data = 0; - lcg_id_bsr_trunc = 0; - for (lcg_id = 0; lcg_id < MAX_NUM_LCGID; lcg_id++) { - UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = - locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, - UE_mac_inst - [module_idP].scheduling_info. - BSR_bytes[lcg_id]); + //Update Buffer remain and BSR bytes after transmission + AssertFatal(lcid_buffer_occupancy_new <= + lcid_buffer_occupancy_old, + "MAC UE Tx error : Buffer Occupancy After Tx=%d greater than before=%d BO! for LCID=%d RLC PDU nb=%d Frame %d Subrame %d\n", + lcid_buffer_occupancy_new, + lcid_buffer_occupancy_old, lcid, + lcid_rlc_pdu_count, frameP, subframe); + UE_mac_inst[module_idP].scheduling_info. + LCID_buffer_remain[lcid] = lcid_buffer_occupancy_new; + UE_mac_inst[module_idP]. + scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. + scheduling_info.LCGID[lcid]] += + (lcid_buffer_occupancy_new - lcid_buffer_occupancy_old); + + //Update the number of LCGID with data as BSR shall reflect status after BSR transmission + if ((num_lcg_id_with_data > 1) + && (UE_mac_inst[module_idP]. + scheduling_info.BSR_bytes[UE_mac_inst[module_idP]. + scheduling_info.LCGID[lcid]] + == 0)) { + num_lcg_id_with_data--; + + // Change BSR size to BSR SHORT if num_lcg_id_with_data becomes to 1 + if ((bsr_len) && (num_lcg_id_with_data == 1)) { + bsr_ce_len = sizeof(BSR_SHORT); + bsr_len = bsr_ce_len + bsr_header_len; + } + } - if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]) { - num_lcg_id_with_data++; - lcg_id_bsr_trunc = lcg_id; - } + UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = + LCID_EMPTY; } + } + // Compute BSR Values and update Nb LCGID with data after multiplexing + num_lcg_id_with_data = 0; + lcg_id_bsr_trunc = 0; - if (bsr_ce_len) { - //Print updated BSR when sent - LOG_D(MAC, - "[UE %d] Remaining Buffer after Tx frame%d subframe %d nb LCG =%d Bytes for LCG0=%d LCG1=%d LCG2=%d LCG3=%d BSR Trigger status =%d TBS=%d\n", - module_idP, frameP, subframe, num_lcg_id_with_data, - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0], - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[1], - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[2], - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[3], - UE_mac_inst[module_idP].BSR_reporting_active, buflen); - - LOG_D(MAC, - "[UE %d] Frame %d Subframe %d TX BSR Regular or Periodic size=%d BSR0=%d BSR1=%d BSR2=%d BSR3=%d\n", - module_idP, frameP, subframe, bsr_ce_len, - UE_mac_inst[module_idP].scheduling_info.BSR[0], - UE_mac_inst[module_idP].scheduling_info.BSR[1], - UE_mac_inst[module_idP].scheduling_info.BSR[2], - UE_mac_inst[module_idP].scheduling_info.BSR[3]); - } - // build PHR and update the timers - if (phr_ce_len == sizeof(POWER_HEADROOM_CMD)) { - if(nfapi_mode ==3){ - //Substitute with a static value for the MAC layer abstraction (phy_stub mode) - phr_p->PH = 40; - } - else{ - phr_p->PH = get_phr_mapping(module_idP, CC_id, eNB_index); - } - - - phr_p->R = 0; - LOG_D(MAC, - "[UE %d] Frame %d report PHR with mapping (%d->%d) for LCID %d\n", - module_idP, frameP, get_PHR(module_idP, CC_id, eNB_index), - phr_p->PH, POWER_HEADROOM); - update_phr(module_idP, CC_id); - } else { - phr_p = NULL; + for (lcg_id = 0; lcg_id < MAX_NUM_LCGID; lcg_id++) { + UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = + locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, + UE_mac_inst + [module_idP].scheduling_info. + BSR_bytes[lcg_id]); + + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]) { + num_lcg_id_with_data++; + lcg_id_bsr_trunc = lcg_id; } + } - LOG_T(MAC, "[UE %d] Frame %d: bsr s %p bsr_l %p, phr_p %p\n", - module_idP, frameP, bsr_s, bsr_l, phr_p); - - // Check BSR padding: it is done after PHR according to Logical Channel Prioritization order - // Check for max padding size, ie MAC Hdr for last RLC PDU = 1 - /* For Padding BSR: - - if the number of padding bits is equal to or larger than the size of the Short BSR plus its subheader but smaller than the size of the Long BSR plus its subheader: - - if more than one LCG has data available for transmission in the TTI where the BSR is transmitted: report Truncated BSR of the LCG with the highest priority logical channel with data available for transmission; - - else report Short BSR. - - else if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR. - */ - if (sdu_length_total) { - padding_len = - buflen - (bsr_len + phr_len + total_rlc_pdu_header_len - - rlc_pdu_header_len_last + sdu_length_total + 1); + if (bsr_ce_len) { + //Print updated BSR when sent + LOG_D(MAC, + "[UE %d] Remaining Buffer after Tx frame%d subframe %d nb LCG =%d Bytes for LCG0=%d LCG1=%d LCG2=%d LCG3=%d BSR Trigger status =%d TBS=%d\n", + module_idP, frameP, subframe, num_lcg_id_with_data, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[1], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[2], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[3], + UE_mac_inst[module_idP].BSR_reporting_active, buflen); + LOG_D(MAC, + "[UE %d] Frame %d Subframe %d TX BSR Regular or Periodic size=%d BSR0=%d BSR1=%d BSR2=%d BSR3=%d\n", + module_idP, frameP, subframe, bsr_ce_len, + UE_mac_inst[module_idP].scheduling_info.BSR[0], + UE_mac_inst[module_idP].scheduling_info.BSR[1], + UE_mac_inst[module_idP].scheduling_info.BSR[2], + UE_mac_inst[module_idP].scheduling_info.BSR[3]); + } + + // build PHR and update the timers + if (phr_ce_len == sizeof(POWER_HEADROOM_CMD)) { + if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { + //Substitute with a static value for the MAC layer abstraction (phy_stub mode) + phr_p->PH = 40; } else { - padding_len = buflen - (bsr_len + phr_len); + phr_p->PH = get_phr_mapping(module_idP, CC_id, eNB_index); } + phr_p->R = 0; + LOG_D(MAC, + "[UE %d] Frame %d report PHR with mapping (%d->%d) for LCID %d\n", + module_idP, frameP, get_PHR(module_idP, CC_id, eNB_index), + phr_p->PH, POWER_HEADROOM); + update_phr(module_idP, CC_id); + } else { + phr_p = NULL; + } + + LOG_T(MAC, "[UE %d] Frame %d: bsr s %p bsr_l %p, phr_p %p\n", + module_idP, frameP, bsr_s, bsr_l, phr_p); + + // Check BSR padding: it is done after PHR according to Logical Channel Prioritization order + // Check for max padding size, ie MAC Hdr for last RLC PDU = 1 + /* For Padding BSR: + - if the number of padding bits is equal to or larger than the size of the Short BSR plus its subheader but smaller than the size of the Long BSR plus its subheader: + - if more than one LCG has data available for transmission in the TTI where the BSR is transmitted: report Truncated BSR of the LCG with the highest priority logical channel with data available for transmission; + - else report Short BSR. + - else if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR. + */ + if (sdu_length_total) { + padding_len = + buflen - (bsr_len + phr_len + total_rlc_pdu_header_len - + rlc_pdu_header_len_last + sdu_length_total + 1); + } else { + padding_len = buflen - (bsr_len + phr_len); + } - if ((padding_len) && (bsr_len == 0)) { - /* if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR */ - if (padding_len >= (1 + BSR_LONG_SIZE)) { - bsr_ce_len = BSR_LONG_SIZE; - bsr_header_len = 1; - // Trigger BSR Padding - UE_mac_inst[module_idP].BSR_reporting_active |= - BSR_TRIGGER_PADDING; - - - } else if (padding_len >= (1 + sizeof(BSR_SHORT))) { - bsr_ce_len = sizeof(BSR_SHORT); - bsr_header_len = 1; - - if (num_lcg_id_with_data > 1) { - // REPORT TRUNCATED BSR - //Get LCGID of highest priority LCID with data - for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) { - if (UE_mac_inst[module_idP]. - logicalChannelConfig[lcid] != NULL) { - lcg_id = - UE_mac_inst[module_idP].scheduling_info. - LCGID[lcid]; - - if ((lcg_id < MAX_NUM_LCGID) - && (UE_mac_inst[module_idP]. - scheduling_info.BSR_bytes[lcg_id]) - && - (UE_mac_inst[module_idP].logicalChannelConfig - [lcid]->ul_SpecificParameters->priority <= - highest_priority)) { - highest_priority = - UE_mac_inst[module_idP]. - logicalChannelConfig[lcid]-> - ul_SpecificParameters->priority; - lcg_id_bsr_trunc = lcg_id; - } - } - } - } else { - //Report SHORT BSR, clear bsr_t - bsr_t = NULL; - } - - // Trigger BSR Padding - UE_mac_inst[module_idP].BSR_reporting_active |= - BSR_TRIGGER_PADDING; - } - bsr_len = bsr_header_len + bsr_ce_len; - } - //Fill BSR Infos - if (bsr_ce_len == 0) { - bsr_s = NULL; - bsr_l = NULL; - bsr_t = NULL; - } else if (bsr_ce_len == BSR_LONG_SIZE) { - bsr_s = NULL; - bsr_t = NULL; - bsr_l->Buffer_size0 = - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]; - bsr_l->Buffer_size1 = - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]; - bsr_l->Buffer_size2 = - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; - bsr_l->Buffer_size3 = - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; - - LOG_D(MAC, - "[UE %d] Frame %d subframe %d BSR Trig=%d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", - module_idP, frameP, subframe, - UE_mac_inst[module_idP].BSR_reporting_active, - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], - UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); - - } else if (bsr_ce_len == sizeof(BSR_SHORT)) { - bsr_l = NULL; - if ((bsr_t != NULL) - && (UE_mac_inst[module_idP].BSR_reporting_active & - BSR_TRIGGER_PADDING)) { - //Truncated BSR - bsr_s = NULL; - bsr_t->LCGID = lcg_id_bsr_trunc; - bsr_t->Buffer_size = - UE_mac_inst[module_idP].scheduling_info. - BSR[lcg_id_bsr_trunc]; - - LOG_D(MAC, - "[UE %d] Frame %d subframe %d BSR Trig=%d report TRUNCATED BSR with level %d for LCGID %d\n", - module_idP, frameP, subframe, - UE_mac_inst[module_idP].BSR_reporting_active, - UE_mac_inst[module_idP]. - scheduling_info.BSR[lcg_id_bsr_trunc], lcg_id_bsr_trunc); - - } else { - bsr_t = NULL; - bsr_s->LCGID = lcg_id_bsr_trunc; - bsr_s->Buffer_size = - UE_mac_inst[module_idP].scheduling_info. - BSR[lcg_id_bsr_trunc]; - - LOG_D(MAC, - "[UE %d] Frame %d subframe %d BSR Trig=%d report SHORT BSR with level %d for LCGID %d\n", - module_idP, frameP, subframe, - UE_mac_inst[module_idP].BSR_reporting_active, - UE_mac_inst[module_idP]. - scheduling_info.BSR[lcg_id_bsr_trunc], lcg_id_bsr_trunc); - } + if ((padding_len) && (bsr_len == 0)) { + /* if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR */ + if (padding_len >= (1 + BSR_LONG_SIZE)) { + bsr_ce_len = BSR_LONG_SIZE; + bsr_header_len = 1; + // Trigger BSR Padding + UE_mac_inst[module_idP].BSR_reporting_active |= + BSR_TRIGGER_PADDING; + } else if (padding_len >= (1 + sizeof(BSR_SHORT))) { + bsr_ce_len = sizeof(BSR_SHORT); + bsr_header_len = 1; + + if (num_lcg_id_with_data > 1) { + // REPORT TRUNCATED BSR + //Get LCGID of highest priority LCID with data + for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) { + if (UE_mac_inst[module_idP]. + logicalChannelConfig[lcid] != NULL) { + lcg_id = + UE_mac_inst[module_idP].scheduling_info. + LCGID[lcid]; + + if ((lcg_id < MAX_NUM_LCGID) + && (UE_mac_inst[module_idP]. + scheduling_info.BSR_bytes[lcg_id]) + && + (UE_mac_inst[module_idP].logicalChannelConfig + [lcid]->ul_SpecificParameters->priority <= + highest_priority)) { + highest_priority = + UE_mac_inst[module_idP]. + logicalChannelConfig[lcid]-> + ul_SpecificParameters->priority; + lcg_id_bsr_trunc = lcg_id; + } + } + } + } else { + //Report SHORT BSR, clear bsr_t + bsr_t = NULL; + } + + // Trigger BSR Padding + UE_mac_inst[module_idP].BSR_reporting_active |= + BSR_TRIGGER_PADDING; } -// 1-bit padding or 2-bit padding special padding subheader -// Check for max padding size, ie MAC Hdr for last RLC PDU = 1 - if (sdu_length_total) { - padding_len = - buflen - (bsr_len + phr_len + total_rlc_pdu_header_len - - rlc_pdu_header_len_last + sdu_length_total + 1); + + bsr_len = bsr_header_len + bsr_ce_len; + } + + //Fill BSR Infos + if (bsr_ce_len == 0) { + bsr_s = NULL; + bsr_l = NULL; + bsr_t = NULL; + } else if (bsr_ce_len == BSR_LONG_SIZE) { + bsr_s = NULL; + bsr_t = NULL; + bsr_l->Buffer_size0 = + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]; + bsr_l->Buffer_size1 = + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]; + bsr_l->Buffer_size2 = + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; + bsr_l->Buffer_size3 = + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; + LOG_D(MAC, + "[UE %d] Frame %d subframe %d BSR Trig=%d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", + module_idP, frameP, subframe, + UE_mac_inst[module_idP].BSR_reporting_active, + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); + } else if (bsr_ce_len == sizeof(BSR_SHORT)) { + bsr_l = NULL; + + if ((bsr_t != NULL) + && (UE_mac_inst[module_idP].BSR_reporting_active & + BSR_TRIGGER_PADDING)) { + //Truncated BSR + bsr_s = NULL; + bsr_t->LCGID = lcg_id_bsr_trunc; + bsr_t->Buffer_size = + UE_mac_inst[module_idP].scheduling_info. + BSR[lcg_id_bsr_trunc]; + LOG_D(MAC, + "[UE %d] Frame %d subframe %d BSR Trig=%d report TRUNCATED BSR with level %d for LCGID %d\n", + module_idP, frameP, subframe, + UE_mac_inst[module_idP].BSR_reporting_active, + UE_mac_inst[module_idP]. + scheduling_info.BSR[lcg_id_bsr_trunc], lcg_id_bsr_trunc); } else { - padding_len = buflen - (bsr_len + phr_len); + bsr_t = NULL; + bsr_s->LCGID = lcg_id_bsr_trunc; + bsr_s->Buffer_size = + UE_mac_inst[module_idP].scheduling_info. + BSR[lcg_id_bsr_trunc]; + LOG_D(MAC, + "[UE %d] Frame %d subframe %d BSR Trig=%d report SHORT BSR with level %d for LCGID %d\n", + module_idP, frameP, subframe, + UE_mac_inst[module_idP].BSR_reporting_active, + UE_mac_inst[module_idP]. + scheduling_info.BSR[lcg_id_bsr_trunc], lcg_id_bsr_trunc); } + } - if (padding_len <= 2) { - short_padding = padding_len; - // only add padding header - post_padding = 0; - //update total MAC Hdr size for RLC data - if (sdu_length_total) { - total_rlc_pdu_header_len = - total_rlc_pdu_header_len - rlc_pdu_header_len_last + 1; - rlc_pdu_header_len_last = 1; - } - } else if (sdu_length_total) { - post_padding = - buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + - sdu_length_total + 1); - // If by adding MAC Hdr for last RLC PDU the padding is 0 then set MAC Hdr for last RLC PDU = 1 and compute 1 or 2 byte padding - if (post_padding == 0) { - total_rlc_pdu_header_len -= rlc_pdu_header_len_last; - padding_len = - buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + - sdu_length_total + 1); - short_padding = padding_len; - total_rlc_pdu_header_len++; - } - } else { - if (padding_len == buflen) { // nona mac pdu - *access_mode = CANCELED_ACCESS; - } + // 1-bit padding or 2-bit padding special padding subheader + // Check for max padding size, ie MAC Hdr for last RLC PDU = 1 + if (sdu_length_total) { + padding_len = + buflen - (bsr_len + phr_len + total_rlc_pdu_header_len - + rlc_pdu_header_len_last + sdu_length_total + 1); + } else { + padding_len = buflen - (bsr_len + phr_len); + } - short_padding = 0; + if (padding_len <= 2) { + short_padding = padding_len; + // only add padding header + post_padding = 0; - post_padding = - buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + - sdu_length_total + 1); + //update total MAC Hdr size for RLC data + if (sdu_length_total) { + total_rlc_pdu_header_len = + total_rlc_pdu_header_len - rlc_pdu_header_len_last + 1; + rlc_pdu_header_len_last = 1; + } + } else if (sdu_length_total) { + post_padding = + buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + + sdu_length_total + 1); + + // If by adding MAC Hdr for last RLC PDU the padding is 0 then set MAC Hdr for last RLC PDU = 1 and compute 1 or 2 byte padding + if (post_padding == 0) { + total_rlc_pdu_header_len -= rlc_pdu_header_len_last; + padding_len = + buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + + sdu_length_total + 1); + short_padding = padding_len; + total_rlc_pdu_header_len++; + } + } else { + if (padding_len == buflen) { // nona mac pdu + *access_mode = CANCELED_ACCESS; } - // Generate header - // if (num_sdus>0) { + short_padding = 0; + post_padding = + buflen - (bsr_len + phr_len + total_rlc_pdu_header_len + + sdu_length_total + 1); + } - payload_offset = generate_ulsch_header(ulsch_buffer, // mac header - num_sdus, // num sdus - short_padding, // short pading - sdu_lengths, // sdu length - sdu_lcids, // sdu lcid - phr_p, // power headroom - NULL, // crnti - bsr_t, // truncated bsr - bsr_s, // short bsr - bsr_l, post_padding); // long_bsr + // Generate header + // if (num_sdus>0) { + payload_offset = generate_ulsch_header(ulsch_buffer, // mac header + num_sdus, // num sdus + short_padding, // short pading + sdu_lengths, // sdu length + sdu_lcids, // sdu lcid + phr_p, // power headroom + NULL, // crnti + bsr_t, // truncated bsr + bsr_s, // short bsr + bsr_l, post_padding); // long_bsr + LOG_D(MAC, + "[UE %d] Generate header :bufflen %d sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d, total_rlc_pdu_header_len %d, padding %d,post_padding %d, bsr len %d, phr len %d, reminder %d \n", + module_idP, buflen, sdu_length_total, num_sdus, sdu_lengths[0], + sdu_lcids[0], payload_offset, total_rlc_pdu_header_len, + short_padding, post_padding, bsr_len, phr_len, + buflen - sdu_length_total - payload_offset); + + // cycle through SDUs and place in ulsch_buffer + if (sdu_length_total) { + memcpy(&ulsch_buffer[payload_offset], ulsch_buff, + sdu_length_total); + } - LOG_D(MAC, - "[UE %d] Generate header :bufflen %d sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d, total_rlc_pdu_header_len %d, padding %d,post_padding %d, bsr len %d, phr len %d, reminder %d \n", - module_idP, buflen, sdu_length_total, num_sdus, sdu_lengths[0], - sdu_lcids[0], payload_offset, total_rlc_pdu_header_len, - short_padding, post_padding, bsr_len, phr_len, - buflen - sdu_length_total - payload_offset); - // cycle through SDUs and place in ulsch_buffer - if (sdu_length_total) { - memcpy(&ulsch_buffer[payload_offset], ulsch_buff, - sdu_length_total); - } - // fill remainder of DLSCH with random data - if (post_padding) { - for (j = 0; j < (buflen - sdu_length_total - payload_offset); j++) { - ulsch_buffer[payload_offset + sdu_length_total + j] = - (char) (taus() & 0xff); - } + // fill remainder of DLSCH with random data + if (post_padding) { + for (j = 0; j < (buflen - sdu_length_total - payload_offset); j++) { + ulsch_buffer[payload_offset + sdu_length_total + j] = + (char) (taus() & 0xff); } - LOG_D(MAC, - "[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n", - module_idP); - UE_mac_inst[module_idP].scheduling_info.SR_pending = 0; - UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0; + } + + LOG_D(MAC, + "[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n", + module_idP); + UE_mac_inst[module_idP].scheduling_info.SR_pending = 0; + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0; - /* Actions when a BSR is sent */ - if (bsr_ce_len) { - LOG_D(MAC, - "[UE %d] MAC BSR Sent !! bsr (ce%d,hdr%d) buff_len %d\n", - module_idP, bsr_ce_len, bsr_header_len, buflen); - - // Reset ReTx BSR Timer - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = - get_sf_retxBSRTimer(UE_mac_inst[module_idP]. - scheduling_info.retxBSR_Timer); - - LOG_D(MAC, "[UE %d] MAC ReTx BSR Timer Reset =%d\n", module_idP, - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF); - - // Reset Periodic Timer except when BSR is truncated - if ((bsr_t == NULL) - && (UE_mac_inst[module_idP].scheduling_info. - periodicBSR_Timer != LTE_PeriodicBSR_Timer_r12_infinity)) { - UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = - get_sf_periodicBSRTimer(UE_mac_inst - [module_idP].scheduling_info. - periodicBSR_Timer); - - LOG_D(MAC, "[UE %d] MAC Periodic BSR Timer Reset =%d\n", - module_idP, - UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF); - - } - // Reset BSR Trigger flags - UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE; + /* Actions when a BSR is sent */ + if (bsr_ce_len) { + LOG_D(MAC, + "[UE %d] MAC BSR Sent !! bsr (ce%d,hdr%d) buff_len %d\n", + module_idP, bsr_ce_len, bsr_header_len, buflen); + // Reset ReTx BSR Timer + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = + get_sf_retxBSRTimer(UE_mac_inst[module_idP]. + scheduling_info.retxBSR_Timer); + LOG_D(MAC, "[UE %d] MAC ReTx BSR Timer Reset =%d\n", module_idP, + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF); + + // Reset Periodic Timer except when BSR is truncated + if ((bsr_t == NULL) + && (UE_mac_inst[module_idP].scheduling_info. + periodicBSR_Timer != LTE_PeriodicBSR_Timer_r12_infinity)) { + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = + get_sf_periodicBSRTimer(UE_mac_inst + [module_idP].scheduling_info. + periodicBSR_Timer); + LOG_D(MAC, "[UE %d] MAC Periodic BSR Timer Reset =%d\n", + module_idP, + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF); } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); + // Reset BSR Trigger flags + UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE; + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); + stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); #endif - if (opt_enabled) { - trace_pdu(DIRECTION_UPLINK, ulsch_buffer, buflen, module_idP, WS_C_RNTI, - UE_mac_inst[module_idP].crnti, - UE_mac_inst[module_idP].txFrame, - UE_mac_inst[module_idP].txSubframe, 0, 0); - LOG_D(OPT, - "[UE %d][ULSCH] Frame %d subframe %d trace pdu for rnti %x with size %d\n", - module_idP, frameP, subframe, UE_mac_inst[module_idP].crnti, - buflen); - } + if (opt_enabled) { + trace_pdu(DIRECTION_UPLINK, ulsch_buffer, buflen, module_idP, WS_C_RNTI, + UE_mac_inst[module_idP].crnti, + UE_mac_inst[module_idP].txFrame, + UE_mac_inst[module_idP].txSubframe, 0, 0); + LOG_D(OPT, + "[UE %d][ULSCH] Frame %d subframe %d trace pdu for rnti %x with size %d\n", + module_idP, frameP, subframe, UE_mac_inst[module_idP].crnti, + buflen); + } } @@ -2500,515 +2447,498 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, UE_L2_STATE_t ue_scheduler(const module_id_t module_idP, - const frame_t rxFrameP, - const sub_frame_t rxSubframeP, - const frame_t txFrameP, - const sub_frame_t txSubframeP, - const lte_subframe_t directionP, - const uint8_t eNB_indexP, const int CC_id) + const frame_t rxFrameP, + const sub_frame_t rxSubframeP, + const frame_t txFrameP, + const sub_frame_t txSubframeP, + const lte_subframe_t directionP, + const uint8_t eNB_indexP, const int CC_id) //------------------------------------------------------------------------------ { - int lcid; // lcid index - int TTI = 1; - int bucketsizeduration = -1; - int bucketsizeduration_max = -1; - // mac_rlc_status_resp_t rlc_status[MAX_NUM_LCGID]; // 4 - // int8_t lcg_id; - struct LTE_RACH_ConfigCommon *rach_ConfigCommon = - (struct LTE_RACH_ConfigCommon *) NULL; - protocol_ctxt_t ctxt; - + int lcid; // lcid index + int TTI = 1; + int bucketsizeduration = -1; + int bucketsizeduration_max = -1; + // mac_rlc_status_resp_t rlc_status[MAX_NUM_LCGID]; // 4 + // int8_t lcg_id; + struct LTE_RACH_ConfigCommon *rach_ConfigCommon = + (struct LTE_RACH_ConfigCommon *) NULL; + protocol_ctxt_t ctxt; #if defined(ENABLE_ITTI) - MessageDef *msg_p; - int result; + MessageDef *msg_p; + int result; #endif #if UE_TIMING_TRACE - start_meas(&UE_mac_inst[module_idP].ue_scheduler); + start_meas(&UE_mac_inst[module_idP].ue_scheduler); #endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_IN); - - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_NO, - UE_mac_inst[module_idP].crnti, txFrameP, - txSubframeP, eNB_indexP); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_IN); + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_NO, + UE_mac_inst[module_idP].crnti, txFrameP, + txSubframeP, eNB_indexP); #if defined(ENABLE_ITTI) - if(module_idP == 0){ - do { - // Checks if a message has been sent to MAC sub-task - itti_poll_msg(TASK_MAC_UE, &msg_p); - - if (msg_p != NULL) { - - switch (ITTI_MSG_ID(msg_p)) { - case RRC_MAC_CCCH_DATA_REQ: - LOG_I(MAC, - "Received %s from %s: instance %d, frameP %d, eNB_index %d\n", - ITTI_MSG_NAME(msg_p), ITTI_MSG_ORIGIN_NAME(msg_p), ITTI_MSG_INSTANCE(msg_p), - RRC_MAC_CCCH_DATA_REQ(msg_p).frame, - RRC_MAC_CCCH_DATA_REQ(msg_p).enb_index); - - // TODO process CCCH data req. - break; - - - default: - LOG_E(MAC, "Received unexpected message %s\n", ITTI_MSG_NAME(msg_p)); - break; - } - - result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), msg_p); - AssertFatal(result == EXIT_SUCCESS, - "Failed to free memory (%d)!\n", result); - } + + if(module_idP == 0) { + do { + // Checks if a message has been sent to MAC sub-task + itti_poll_msg(TASK_MAC_UE, &msg_p); + + if (msg_p != NULL) { + switch (ITTI_MSG_ID(msg_p)) { + case RRC_MAC_CCCH_DATA_REQ: + LOG_I(MAC, + "Received %s from %s: instance %d, frameP %d, eNB_index %d\n", + ITTI_MSG_NAME(msg_p), ITTI_MSG_ORIGIN_NAME(msg_p), ITTI_MSG_INSTANCE(msg_p), + RRC_MAC_CCCH_DATA_REQ(msg_p).frame, + RRC_MAC_CCCH_DATA_REQ(msg_p).enb_index); + // TODO process CCCH data req. + break; + + default: + LOG_E(MAC, "Received unexpected message %s\n", ITTI_MSG_NAME(msg_p)); + break; + } + + result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), msg_p); + AssertFatal(result == EXIT_SUCCESS, + "Failed to free memory (%d)!\n", result); } - while (msg_p != NULL); - } + } while (msg_p != NULL); + } + #endif - //Mac_rlc_xface->frameP=frameP; - //Rrc_xface->Frame_index=Mac_rlc_xface->frameP; - //if (subframe%5 == 0) - //LG#ifdef EXMIMO + //Mac_rlc_xface->frameP=frameP; + //Rrc_xface->Frame_index=Mac_rlc_xface->frameP; + //if (subframe%5 == 0) + //LG#ifdef EXMIMO - // data to/from NETLINK is treated in pdcp_run. - // one socket is used in multiple UE's L2 FAPI simulator and - // only first UE need to do this. - if (UE_NAS_USE_TUN) { + // data to/from NETLINK is treated in pdcp_run. + // one socket is used in multiple UE's L2 FAPI simulator and + // only first UE need to do this. + if (UE_NAS_USE_TUN) { + pdcp_run(&ctxt); + } else { + if(module_idP == 0) { pdcp_run(&ctxt); - } else { - if(module_idP == 0){ - pdcp_run(&ctxt); - } } - //#endif - UE_mac_inst[module_idP].txFrame = txFrameP; - UE_mac_inst[module_idP].txSubframe = txSubframeP; - UE_mac_inst[module_idP].rxFrame = rxFrameP; - UE_mac_inst[module_idP].rxSubframe = rxSubframeP; + } + //#endif + UE_mac_inst[module_idP].txFrame = txFrameP; + UE_mac_inst[module_idP].txSubframe = txSubframeP; + UE_mac_inst[module_idP].rxFrame = rxFrameP; + UE_mac_inst[module_idP].rxSubframe = rxSubframeP; #ifdef CELLULAR - rrc_rx_tx_ue(module_idP, txFrameP, 0, eNB_indexP); + rrc_rx_tx_ue(module_idP, txFrameP, 0, eNB_indexP); #else - switch (rrc_rx_tx_ue(&ctxt, eNB_indexP, CC_id)) { + switch (rrc_rx_tx_ue(&ctxt, eNB_indexP, CC_id)) { case RRC_OK: - break; + break; case RRC_ConnSetup_failed: - LOG_E(MAC, "RRCConnectionSetup failed, returning to IDLE state\n"); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); + LOG_E(MAC, "RRCConnectionSetup failed, returning to IDLE state\n"); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].ue_scheduler); + stop_meas(&UE_mac_inst[module_idP].ue_scheduler); #endif - return (CONNECTION_LOST); - break; + return (CONNECTION_LOST); + break; case RRC_PHY_RESYNCH: - LOG_E(MAC, "RRC Loss of synch, returning PHY_RESYNCH\n"); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); + LOG_E(MAC, "RRC Loss of synch, returning PHY_RESYNCH\n"); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].ue_scheduler); + stop_meas(&UE_mac_inst[module_idP].ue_scheduler); #endif - return (PHY_RESYNCH); + return (PHY_RESYNCH); case RRC_Handover_failed: - LOG_I(MAC, "Handover failure for UE %d eNB_index %d\n", module_idP, - eNB_indexP); - //Invalid...need to add another MAC UE state for re-connection procedure - phy_config_afterHO_ue(module_idP, 0, eNB_indexP, - (LTE_MobilityControlInfo_t *) NULL, 1); - //return(3); - break; + LOG_I(MAC, "Handover failure for UE %d eNB_index %d\n", module_idP, + eNB_indexP); + //Invalid...need to add another MAC UE state for re-connection procedure + phy_config_afterHO_ue(module_idP, 0, eNB_indexP, + (LTE_MobilityControlInfo_t *) NULL, 1); + //return(3); + break; case RRC_HO_STARTED: - LOG_I(MAC, - "RRC handover, Instruct PHY to start the contention-free PRACH and synchronization\n"); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); + LOG_I(MAC, + "RRC handover, Instruct PHY to start the contention-free PRACH and synchronization\n"); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].ue_scheduler); + stop_meas(&UE_mac_inst[module_idP].ue_scheduler); #endif - return (PHY_HO_PRACH); + return (PHY_HO_PRACH); default: - break; - } + break; + } #endif - // Check Contention resolution timer (put in a function later) - if (UE_mac_inst[module_idP].RA_contention_resolution_timer_active == 1) { - - if (UE_mac_inst[module_idP].radioResourceConfigCommon) { - rach_ConfigCommon = - &UE_mac_inst[module_idP]. - radioResourceConfigCommon->rach_ConfigCommon; - } else { - LOG_E(MAC, "FATAL: radioResourceConfigCommon is NULL!!!\n"); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, - VCD_FUNCTION_OUT); - - stop_meas(&UE_mac_inst[module_idP].ue_scheduler); - AssertFatal(1 == 0, ""); - + // Check Contention resolution timer (put in a function later) + if (UE_mac_inst[module_idP].RA_contention_resolution_timer_active == 1) { + if (UE_mac_inst[module_idP].radioResourceConfigCommon) { + rach_ConfigCommon = + &UE_mac_inst[module_idP]. + radioResourceConfigCommon->rach_ConfigCommon; + } else { + LOG_E(MAC, "FATAL: radioResourceConfigCommon is NULL!!!\n"); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, + VCD_FUNCTION_OUT); + stop_meas(&UE_mac_inst[module_idP].ue_scheduler); + AssertFatal(1 == 0, ""); #if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].ue_scheduler); + stop_meas(&UE_mac_inst[module_idP].ue_scheduler); #endif + //return(RRC_OK); + } + + LOG_I(MAC, "Frame %d: Contention resolution timer %d/%ld\n", + txFrameP, + UE_mac_inst[module_idP].RA_contention_resolution_cnt, + ((1 + + rach_ConfigCommon-> + ra_SupervisionInfo.mac_ContentionResolutionTimer) << 3)); + UE_mac_inst[module_idP].RA_contention_resolution_cnt++; + + if (UE_mac_inst[module_idP].RA_contention_resolution_cnt == + ((1 + + rach_ConfigCommon-> + ra_SupervisionInfo.mac_ContentionResolutionTimer) << 3)) { + UE_mac_inst[module_idP].RA_active = 0; + UE_mac_inst[module_idP].RA_contention_resolution_timer_active = + 0; + // Signal PHY to quit RA procedure + LOG_E(MAC, + "Module id %u Contention resolution timer expired, RA failed\n", + module_idP); + + if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { // phy_stub mode + // Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to + // PRACH state. + LOG_I(MAC, "nfapi_mode3: Setting UE_mode to PRACH 2 \n"); + UE_mac_inst[module_idP].UE_mode[eNB_indexP] = PRACH; + //ra_failed(module_idP,CC_id,eNB_index);UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0; + } else { + ra_failed(module_idP, CC_id, eNB_indexP); + } - //return(RRC_OK); - } - - LOG_I(MAC, "Frame %d: Contention resolution timer %d/%ld\n", - txFrameP, - UE_mac_inst[module_idP].RA_contention_resolution_cnt, - ((1 + - rach_ConfigCommon-> - ra_SupervisionInfo.mac_ContentionResolutionTimer) << 3)); - - UE_mac_inst[module_idP].RA_contention_resolution_cnt++; - - if (UE_mac_inst[module_idP].RA_contention_resolution_cnt == - ((1 + - rach_ConfigCommon-> - ra_SupervisionInfo.mac_ContentionResolutionTimer) << 3)) { - UE_mac_inst[module_idP].RA_active = 0; - UE_mac_inst[module_idP].RA_contention_resolution_timer_active = - 0; - // Signal PHY to quit RA procedure - LOG_E(MAC, - "Module id %u Contention resolution timer expired, RA failed\n", - module_idP); - if(nfapi_mode == 3) { // phy_stub mode - // Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to - // PRACH state. - LOG_I(MAC, "nfapi_mode3: Setting UE_mode to PRACH 2 \n"); - UE_mac_inst[module_idP].UE_mode[eNB_indexP] = PRACH; - //ra_failed(module_idP,CC_id,eNB_index);UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0; - } - else{ - ra_failed(module_idP, CC_id, eNB_indexP); - } - //ra_failed(module_idP, 0, eNB_indexP); - } - } - // Get RLC status info and update Bj for all lcids that are active - for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) { - if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]) { - // meausre the Bj - if ((directionP == SF_UL) - && (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] >= 0)) { - if (UE_mac_inst[module_idP]. - logicalChannelConfig[lcid]->ul_SpecificParameters) { - bucketsizeduration = - UE_mac_inst[module_idP].logicalChannelConfig - [lcid]->ul_SpecificParameters->prioritisedBitRate * - TTI; - bucketsizeduration_max = - get_ms_bucketsizeduration(UE_mac_inst - [module_idP].logicalChannelConfig - [lcid]->ul_SpecificParameters->bucketSizeDuration); - } else { - LOG_E(MAC, - "[UE %d] lcid %d, NULL ul_SpecificParameters\n", - module_idP, lcid); - AssertFatal(1 == 0, ""); - } - - if (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] > - bucketsizeduration_max) { - UE_mac_inst[module_idP].scheduling_info.Bj[lcid] = - bucketsizeduration_max; - } else { - UE_mac_inst[module_idP].scheduling_info.Bj[lcid] = - bucketsizeduration; - } - } - - - /* - if (lcid == DCCH) { - LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d Pending data for SRB1=%d for LCGID %d \n", - module_idP, txFrameP,txSubframeP,UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], - // UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); - } - */ - } + //ra_failed(module_idP, 0, eNB_indexP); } + } + + // Get RLC status info and update Bj for all lcids that are active + for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) { + if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]) { + // meausre the Bj + if ((directionP == SF_UL) + && (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] >= 0)) { + if (UE_mac_inst[module_idP]. + logicalChannelConfig[lcid]->ul_SpecificParameters) { + bucketsizeduration = + UE_mac_inst[module_idP].logicalChannelConfig + [lcid]->ul_SpecificParameters->prioritisedBitRate * + TTI; + bucketsizeduration_max = + get_ms_bucketsizeduration(UE_mac_inst + [module_idP].logicalChannelConfig + [lcid]->ul_SpecificParameters->bucketSizeDuration); + } else { + LOG_E(MAC, + "[UE %d] lcid %d, NULL ul_SpecificParameters\n", + module_idP, lcid); + AssertFatal(1 == 0, ""); + } - // Call BSR procedure as described in Section 5.4.5 in 36.321 + if (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] > + bucketsizeduration_max) { + UE_mac_inst[module_idP].scheduling_info.Bj[lcid] = + bucketsizeduration_max; + } else { + UE_mac_inst[module_idP].scheduling_info.Bj[lcid] = + bucketsizeduration; + } + } - // First check ReTxBSR Timer because it is always configured - // Decrement ReTxBSR Timer if it is running and not null - if ((UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != - MAC_UE_BSR_TIMER_NOT_RUNNING) - && (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != 0)) { - UE_mac_inst[module_idP].scheduling_info.retxBSR_SF--; - } - // Decrement Periodic Timer if it is running and not null - if ((UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF != - MAC_UE_BSR_TIMER_NOT_RUNNING) - && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF != 0)) { - UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF--; - } - //Check whether Regular BSR is triggered - if (update_bsr(module_idP, txFrameP, txSubframeP, eNB_indexP) == TRUE) { - // call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures - // outlined in Sections 5.4.4 an 5.4.5 of 36.321 - UE_mac_inst[module_idP].scheduling_info.SR_pending = 1; - // Regular BSR trigger - UE_mac_inst[module_idP].BSR_reporting_active |= - BSR_TRIGGER_REGULAR; - LOG_D(MAC, - "[UE %d][BSR] Regular BSR Triggered Frame %d subframe %d SR for PUSCH is pending\n", - module_idP, txFrameP, txSubframeP); - } - // UE has no valid phy config dedicated || no valid/released SR - if ((UE_mac_inst[module_idP].physicalConfigDedicated == NULL)) { - // cancel all pending SRs - UE_mac_inst[module_idP].scheduling_info.SR_pending = 0; - UE_mac_inst[module_idP].ul_active = 0; - LOG_T(MAC, "[UE %d] Release all SRs \n", module_idP); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); -#if UE_TIMING_TRACE - stop_meas(&UE_mac_inst[module_idP].ue_scheduler); -#endif - return (CONNECTION_OK); + /* + if (lcid == DCCH) { + LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d Pending data for SRB1=%d for LCGID %d \n", + module_idP, txFrameP,txSubframeP,UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], + // UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); + } + */ } + } - if ((UE_mac_inst[module_idP]. - physicalConfigDedicated->schedulingRequestConfig == NULL) - || (UE_mac_inst[module_idP]. - physicalConfigDedicated->schedulingRequestConfig->present == - LTE_SchedulingRequestConfig_PR_release)) { + // Call BSR procedure as described in Section 5.4.5 in 36.321 - // initiate RA with CRNTI included in msg3 (no contention) as descibed in 36.321 sec 5.1.5 + // First check ReTxBSR Timer because it is always configured + // Decrement ReTxBSR Timer if it is running and not null + if ((UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != + MAC_UE_BSR_TIMER_NOT_RUNNING) + && (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != 0)) { + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF--; + } - // cancel all pending SRs - UE_mac_inst[module_idP].scheduling_info.SR_pending = 0; - UE_mac_inst[module_idP].ul_active = 0; - LOG_T(MAC, "[UE %d] Release all SRs \n", module_idP); - } - // Put this in a function - // Call PHR procedure as described in Section 5.4.6 in 36.321 - if (UE_mac_inst[module_idP].PHR_state == LTE_MAC_MainConfig__phr_Config_PR_setup) { // normal operation - - if (UE_mac_inst[module_idP].PHR_reconfigured == 1) { // upon (re)configuration of the power headroom reporting functionality by upper layers - UE_mac_inst[module_idP].PHR_reporting_active = 1; - UE_mac_inst[module_idP].PHR_reconfigured = 0; - } else { - //LOG_D(MAC,"PHR normal operation %d active %d \n", UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF, UE_mac_inst[module_idP].PHR_reporting_active); - if ((UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF <= - 0) - && - ((get_PL(module_idP, 0, eNB_indexP) < - UE_mac_inst[module_idP].scheduling_info. - PathlossChange_db) - || (UE_mac_inst[module_idP].power_backoff_db[eNB_indexP] > - UE_mac_inst[module_idP]. - scheduling_info.PathlossChange_db))) - // trigger PHR and reset the timer later when the PHR report is sent - { - UE_mac_inst[module_idP].PHR_reporting_active = 1; - } else if (UE_mac_inst[module_idP].PHR_reporting_active == 0) { - UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF--; - } - - if (UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF <= - 0) - // trigger PHR and reset the timer later when the PHR report is sent - { - UE_mac_inst[module_idP].PHR_reporting_active = 1; - } else if (UE_mac_inst[module_idP].PHR_reporting_active == 0) { - UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF--; - } - } - } else { // release / nothing - UE_mac_inst[module_idP].PHR_reporting_active = 0; // release PHR - } + // Decrement Periodic Timer if it is running and not null + if ((UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF != + MAC_UE_BSR_TIMER_NOT_RUNNING) + && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF != 0)) { + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF--; + } + + //Check whether Regular BSR is triggered + if (update_bsr(module_idP, txFrameP, txSubframeP, eNB_indexP) == TRUE) { + // call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures + // outlined in Sections 5.4.4 an 5.4.5 of 36.321 + UE_mac_inst[module_idP].scheduling_info.SR_pending = 1; + // Regular BSR trigger + UE_mac_inst[module_idP].BSR_reporting_active |= + BSR_TRIGGER_REGULAR; + LOG_D(MAC, + "[UE %d][BSR] Regular BSR Triggered Frame %d subframe %d SR for PUSCH is pending\n", + module_idP, txFrameP, txSubframeP); + } - //If the UE has UL resources allocated for new transmission for this TTI here: + // UE has no valid phy config dedicated || no valid/released SR + if ((UE_mac_inst[module_idP].physicalConfigDedicated == NULL)) { + // cancel all pending SRs + UE_mac_inst[module_idP].scheduling_info.SR_pending = 0; + UE_mac_inst[module_idP].ul_active = 0; + LOG_T(MAC, "[UE %d] Release all SRs \n", module_idP); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE stop_meas(&UE_mac_inst[module_idP].ue_scheduler); #endif return (CONNECTION_OK); + } + + if ((UE_mac_inst[module_idP]. + physicalConfigDedicated->schedulingRequestConfig == NULL) + || (UE_mac_inst[module_idP]. + physicalConfigDedicated->schedulingRequestConfig->present == + LTE_SchedulingRequestConfig_PR_release)) { + // initiate RA with CRNTI included in msg3 (no contention) as descibed in 36.321 sec 5.1.5 + // cancel all pending SRs + UE_mac_inst[module_idP].scheduling_info.SR_pending = 0; + UE_mac_inst[module_idP].ul_active = 0; + LOG_T(MAC, "[UE %d] Release all SRs \n", module_idP); + } + + // Put this in a function + // Call PHR procedure as described in Section 5.4.6 in 36.321 + if (UE_mac_inst[module_idP].PHR_state == LTE_MAC_MainConfig__phr_Config_PR_setup) { // normal operation + if (UE_mac_inst[module_idP].PHR_reconfigured == 1) { // upon (re)configuration of the power headroom reporting functionality by upper layers + UE_mac_inst[module_idP].PHR_reporting_active = 1; + UE_mac_inst[module_idP].PHR_reconfigured = 0; + } else { + //LOG_D(MAC,"PHR normal operation %d active %d \n", UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF, UE_mac_inst[module_idP].PHR_reporting_active); + if ((UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF <= + 0) + && + ((get_PL(module_idP, 0, eNB_indexP) < + UE_mac_inst[module_idP].scheduling_info. + PathlossChange_db) + || (UE_mac_inst[module_idP].power_backoff_db[eNB_indexP] > + UE_mac_inst[module_idP]. + scheduling_info.PathlossChange_db))) + // trigger PHR and reset the timer later when the PHR report is sent + { + UE_mac_inst[module_idP].PHR_reporting_active = 1; + } else if (UE_mac_inst[module_idP].PHR_reporting_active == 0) { + UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF--; + } + + if (UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF <= + 0) + // trigger PHR and reset the timer later when the PHR report is sent + { + UE_mac_inst[module_idP].PHR_reporting_active = 1; + } else if (UE_mac_inst[module_idP].PHR_reporting_active == 0) { + UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF--; + } + } + } else { // release / nothing + UE_mac_inst[module_idP].PHR_reporting_active = 0; // release PHR + } + + //If the UE has UL resources allocated for new transmission for this TTI here: + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); +#if UE_TIMING_TRACE + stop_meas(&UE_mac_inst[module_idP].ue_scheduler); +#endif + return (CONNECTION_OK); } // to be improved #ifdef CBA extern int cba_backoff; -double uniform_rngen(int min, int max) -{ - double random = (double) taus() / ((double) 0xffffffff); - return (max - min) * random + min; +double uniform_rngen(int min, int max) { + double random = (double) taus() / ((double) 0xffffffff); + return (max - min) * random + min; } int cba_access(module_id_t module_idP, frame_t frameP, - sub_frame_t subframe, uint8_t eNB_index, uint16_t buflen) -{ - - mac_rlc_status_resp_t rlc_status; - int header_offset = 4; - int rv = 0; - - /* - if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]<64)) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]<64)) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) ) - // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive - && (UE_mac_inst[module_idP].cba_last_access[0] <= 0) ) { // backoff - // LOG_D(MAC,"[UE %d] Frame %d Subframe %d: the current CBA backoff is %d \n", module_idP, frameP, subframe, - // UE_mac_inst[module_idP].cba_last_access[0] ); - - UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,40)); - LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); - - rv=1; - } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]> 0 )) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]> 0 )) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]> 0 )) ) - // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive - && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){ - - UE_mac_inst[module_idP].cba_last_access[0]-=1; - LOG_D(MAC,"[UE %d] Frame %d Subframe %d: CBA backoff is decreased by one to %d UL active state %d \n", - module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); - - } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] == 0 )) && - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] == 0 )) && - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] == 0 )) ) - && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){ - UE_mac_inst[module_idP].cba_last_access[0]-=1; - } */ - - if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] > 0) - && (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] < 64)) { - return 0; - } - - if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] <= 0) && - (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] <= 0) && - (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] <= 0)) { - return 0; - } + sub_frame_t subframe, uint8_t eNB_index, uint16_t buflen) { + mac_rlc_status_resp_t rlc_status; + int header_offset = 4; + int rv = 0; + + /* + if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]<64)) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]<64)) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) ) + // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive + && (UE_mac_inst[module_idP].cba_last_access[0] <= 0) ) { // backoff + // LOG_D(MAC,"[UE %d] Frame %d Subframe %d: the current CBA backoff is %d \n", module_idP, frameP, subframe, + // UE_mac_inst[module_idP].cba_last_access[0] ); + + UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,40)); + LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); + + rv=1; + } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]> 0 )) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]> 0 )) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]> 0 )) ) + // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive + && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){ + + UE_mac_inst[module_idP].cba_last_access[0]-=1; + LOG_D(MAC,"[UE %d] Frame %d Subframe %d: CBA backoff is decreased by one to %d UL active state %d \n", + module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); + + } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] == 0 )) && + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] == 0 )) && + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] == 0 )) ) + && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){ + UE_mac_inst[module_idP].cba_last_access[0]-=1; + } */ + + if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] > 0) + && (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] < 64)) { + return 0; + } - if (cba_backoff == 0) { // apply probablisitc method - UE_mac_inst[module_idP].cba_last_access[0] = uniform_rngen(0, 1); + if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] <= 0) && + (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] <= 0) && + (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] <= 0)) { + return 0; + } - if (uniform_rngen(0, 1) > 0.6) { - LOG_I(MAC, - "[UE %d] Frame %d Subframe %d: CBA probability-based backoff (%d), UL active state %d \n", - module_idP, frameP, subframe, cba_backoff, - UE_mac_inst[module_idP].ul_active); + if (cba_backoff == 0) { // apply probablisitc method + UE_mac_inst[module_idP].cba_last_access[0] = uniform_rngen(0, 1); - rv = 1; - } + if (uniform_rngen(0, 1) > 0.6) { + LOG_I(MAC, + "[UE %d] Frame %d Subframe %d: CBA probability-based backoff (%d), UL active state %d \n", + module_idP, frameP, subframe, cba_backoff, + UE_mac_inst[module_idP].ul_active); + rv = 1; + } + } else { + if (UE_mac_inst[module_idP].cba_last_access[0] <= 0) { + UE_mac_inst[module_idP].cba_last_access[0] = + round(uniform_rngen(1, cba_backoff)); + LOG_I(MAC, + "[UE %d] Frame %d Subframe %d: start a new CBA backoff %d/%d UL active state %d \n", + module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], cba_backoff, + UE_mac_inst[module_idP].ul_active); + rv = 1; + /* + rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index + DTCH, + 0); + + if (( + // (rlc_status.pdus_in_buffer > 0 ) && + // (UE_mac_inst[module_idP].ul_active == 0) && // check if the ul is acrtive + (rlc_status.head_sdu_is_segmented == 0 ) && + ((rlc_status.head_sdu_remaining_size_to_send + header_offset ) <= buflen ) + )){ + rv = 1; + + UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,30)); + LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); + */ } else { - - if (UE_mac_inst[module_idP].cba_last_access[0] <= 0) { - UE_mac_inst[module_idP].cba_last_access[0] = - round(uniform_rngen(1, cba_backoff)); - - LOG_I(MAC, - "[UE %d] Frame %d Subframe %d: start a new CBA backoff %d/%d UL active state %d \n", - module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], cba_backoff, - UE_mac_inst[module_idP].ul_active); - - rv = 1; - /* - rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index - DTCH, - 0); - - if (( - // (rlc_status.pdus_in_buffer > 0 ) && - // (UE_mac_inst[module_idP].ul_active == 0) && // check if the ul is acrtive - (rlc_status.head_sdu_is_segmented == 0 ) && - ((rlc_status.head_sdu_remaining_size_to_send + header_offset ) <= buflen ) - )){ - rv = 1; - - UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,30)); - LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); - */ - } else { - UE_mac_inst[module_idP].cba_last_access[0] -= 1; - LOG_D(MAC, - "[UE %d] Frame %d Subframe %d: wait for backoff to expire (%d) CBA UL active state %d \n", - module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], - UE_mac_inst[module_idP].ul_active); - } + UE_mac_inst[module_idP].cba_last_access[0] -= 1; + LOG_D(MAC, + "[UE %d] Frame %d Subframe %d: wait for backoff to expire (%d) CBA UL active state %d \n", + module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], + UE_mac_inst[module_idP].ul_active); } + } - return rv; - /* - if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]<64)) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]<64)) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) ) - // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive - && (UE_mac_inst[module_idP].cba_last_access[0] <= 0) ) { - - UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,cba_backoff)); - - LOG_I(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d/%d UL active state %d \n", module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], cba_backoff,UE_mac_inst[module_idP].ul_active); - - rv = 1; - - rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index - DTCH, - 0); - - if (( - // (rlc_status.pdus_in_buffer > 0 ) && - // (UE_mac_inst[module_idP].ul_active == 0) && // check if the ul is acrtive - (rlc_status.head_sdu_is_segmented == 0 ) && - ((rlc_status.head_sdu_remaining_size_to_send + header_offset ) <= buflen ) - )){ - rv = 1; - - UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,30)); - LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); - } else - UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,5)); - - - } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]> 0 )) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]> 0 )) || - ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]> 0 )) ) - // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive - && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ) - { - - UE_mac_inst[module_idP].cba_last_access[0]-=1; - LOG_D(MAC,"[UE %d] Frame %d Subframe %d: wait for backoff to expire (%d) CBA UL active state %d \n", - module_idP, frameP, subframe, - UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); - } - } - */ - + return rv; + /* + if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]<64)) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]<64)) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) ) + // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive + && (UE_mac_inst[module_idP].cba_last_access[0] <= 0) ) { + + UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,cba_backoff)); + + LOG_I(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d/%d UL active state %d \n", module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], cba_backoff,UE_mac_inst[module_idP].ul_active); + + rv = 1; + + rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index + DTCH, + 0); + + if (( + // (rlc_status.pdus_in_buffer > 0 ) && + // (UE_mac_inst[module_idP].ul_active == 0) && // check if the ul is acrtive + (rlc_status.head_sdu_is_segmented == 0 ) && + ((rlc_status.head_sdu_remaining_size_to_send + header_offset ) <= buflen ) + )){ + rv = 1; + + UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,30)); + LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); + } else + UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,5)); + + + } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]> 0 )) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]> 0 )) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]> 0 )) ) + // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive + && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ) + { + + UE_mac_inst[module_idP].cba_last_access[0]-=1; + LOG_D(MAC,"[UE %d] Frame %d Subframe %d: wait for backoff to expire (%d) CBA UL active state %d \n", + module_idP, frameP, subframe, + UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); + } + } + */ } #endif boolean_t update_bsr(module_id_t module_idP, frame_t frameP, - sub_frame_t subframeP, eNB_index_t eNB_index) -{ - + sub_frame_t subframeP, eNB_index_t eNB_index) { mac_rlc_status_resp_t rlc_status; boolean_t bsr_regular_triggered = FALSE; uint8_t lcid; @@ -3022,537 +2952,493 @@ update_bsr(module_id_t module_idP, frame_t frameP, uint8_t pos_next = 0; uint8_t highest_priority = 16; uint8_t array_index = 0; - // Reset All BSR Infos lcid_bytes_in_buffer[0] = 0; - for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++) - { - // Reset transmission status - lcid_bytes_in_buffer[lcid] = 0; - UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid]=LCID_EMPTY; + + for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++) { + // Reset transmission status + lcid_bytes_in_buffer[lcid] = 0; + UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid]=LCID_EMPTY; } - for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++) - { - // Reset Buffer Info - UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]=0; - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid]=0; + for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++) { + // Reset Buffer Info + UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]=0; + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid]=0; } //Get Buffer Occupancy and fill lcid_reordered_array - for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++) - { - if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]) - { - lcgid = UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]; - - // Store already available data to transmit per Group - if (lcgid < MAX_NUM_LCGID) - { - lcgid_buffer_remain[lcgid] += UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid]; - } - - rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,eNB_index,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO, - lcid, - 0xFFFF //TBS is not used in RLC at this step, set a special value for debug + for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++) { + if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]) { + lcgid = UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]; + + // Store already available data to transmit per Group + if (lcgid < MAX_NUM_LCGID) { + lcgid_buffer_remain[lcgid] += UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid]; + } + + rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,eNB_index,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO, + lcid, + 0xFFFF //TBS is not used in RLC at this step, set a special value for debug #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); - - lcid_bytes_in_buffer[lcid] = rlc_status.bytes_in_buffer; - - if (rlc_status.bytes_in_buffer > 0) - { - LOG_D(MAC,"[UE %d] PDCCH Tick : LCID%d LCGID%d has data to transmit =%d bytes at frame %d subframe %d\n", - module_idP, lcid,lcgid,rlc_status.bytes_in_buffer,frameP,subframeP); - - UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY; - //Update BSR_bytes and position in lcid_reordered_array only if Group is defined - if (lcgid < MAX_NUM_LCGID) - { - num_lcid_with_data ++; - // sum lcid buffer which has same lcgid - UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] += rlc_status.bytes_in_buffer; - - //Fill in the array - array_index = 0; - do - { - if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]->ul_SpecificParameters->priority <= highest_priority) - { - //Insert if priority is higher or equal (lower or equal in value) - for (pos_next=num_lcid_with_data-1; pos_next > array_index; pos_next--) - { - lcid_reordered_array[pos_next] = lcid_reordered_array[pos_next - 1]; - - } - lcid_reordered_array[array_index] = lcid; - break; - - } - array_index ++; - } - while ((array_index < num_lcid_with_data) && (array_index < MAX_NUM_LCID)); - } - } - } + ); + lcid_bytes_in_buffer[lcid] = rlc_status.bytes_in_buffer; + + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC,"[UE %d] PDCCH Tick : LCID%d LCGID%d has data to transmit =%d bytes at frame %d subframe %d\n", + module_idP, lcid,lcgid,rlc_status.bytes_in_buffer,frameP,subframeP); + UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY; + + //Update BSR_bytes and position in lcid_reordered_array only if Group is defined + if (lcgid < MAX_NUM_LCGID) { + num_lcid_with_data ++; + // sum lcid buffer which has same lcgid + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] += rlc_status.bytes_in_buffer; + //Fill in the array + array_index = 0; + + do { + if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]->ul_SpecificParameters->priority <= highest_priority) { + //Insert if priority is higher or equal (lower or equal in value) + for (pos_next=num_lcid_with_data-1; pos_next > array_index; pos_next--) { + lcid_reordered_array[pos_next] = lcid_reordered_array[pos_next - 1]; + } - } + lcid_reordered_array[array_index] = lcid; + break; + } - // Check whether a regular BSR can be triggered according to the first cases in 36.321 - if (num_lcid_with_data) { - LOG_D(MAC, - "[UE %d] PDCCH Tick at frame %d subframe %d: NumLCID with data=%d Reordered LCID0=%d LCID1=%d LCID2=%d\n", - module_idP, frameP, subframeP, num_lcid_with_data, - lcid_reordered_array[0], lcid_reordered_array[1], - lcid_reordered_array[2]); - - for (array_index = 0; array_index < num_lcid_with_data; - array_index++) { - lcid = lcid_reordered_array[array_index]; - /* UL data, for a logical channel which belongs to a LCG, becomes available for transmission in the RLC entity - either the data belongs to a logical channel with higher priority than the priorities of the logical channels - which belong to any LCG and for which data is already available for transmission - */ - if ((UE_mac_inst[module_idP]. - scheduling_info.LCID_buffer_remain[lcid] == 0) - /* or there is no data available for any of the logical channels which belong to a LCG */ - || - (lcgid_buffer_remain - [UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] == - 0)) { - bsr_regular_triggered = TRUE; - - LOG_D(MAC, - "[UE %d] PDCCH Tick : MAC BSR Triggered LCID%d LCGID%d data become available at frame %d subframe %d\n", - module_idP, lcid, - UE_mac_inst[module_idP].scheduling_info.LCGID[lcid], - frameP, subframeP); - - break; - } - } - - // Trigger Regular BSR if ReTxBSR Timer has expired and UE has data for transmission - if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF == 0) { - bsr_regular_triggered = TRUE; - - if ((UE_mac_inst[module_idP].BSR_reporting_active & - BSR_TRIGGER_REGULAR) == 0) { - LOG_I(MAC, - "[UE %d] PDCCH Tick : MAC BSR Triggered ReTxBSR Timer expiry at frame %d subframe %d\n", - module_idP, frameP, subframeP); - } - - } - } - //Store Buffer Occupancy in remain buffers for next TTI - for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) { - UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] = - lcid_bytes_in_buffer[lcid]; + array_index ++; + } while ((array_index < num_lcid_with_data) && (array_index < MAX_NUM_LCID)); + } + } } + } - return bsr_regular_triggered; -} - -uint8_t -locate_BsrIndexByBufferSize(const uint32_t * table, int size, int value) -{ - - uint8_t ju, jm, jl; - int ascend; + // Check whether a regular BSR can be triggered according to the first cases in 36.321 + if (num_lcid_with_data) { + LOG_D(MAC, + "[UE %d] PDCCH Tick at frame %d subframe %d: NumLCID with data=%d Reordered LCID0=%d LCID1=%d LCID2=%d\n", + module_idP, frameP, subframeP, num_lcid_with_data, + lcid_reordered_array[0], lcid_reordered_array[1], + lcid_reordered_array[2]); + + for (array_index = 0; array_index < num_lcid_with_data; + array_index++) { + lcid = lcid_reordered_array[array_index]; + + /* UL data, for a logical channel which belongs to a LCG, becomes available for transmission in the RLC entity + either the data belongs to a logical channel with higher priority than the priorities of the logical channels + which belong to any LCG and for which data is already available for transmission + */ + if ((UE_mac_inst[module_idP]. + scheduling_info.LCID_buffer_remain[lcid] == 0) + /* or there is no data available for any of the logical channels which belong to a LCG */ + || + (lcgid_buffer_remain + [UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] == + 0)) { + bsr_regular_triggered = TRUE; + LOG_D(MAC, + "[UE %d] PDCCH Tick : MAC BSR Triggered LCID%d LCGID%d data become available at frame %d subframe %d\n", + module_idP, lcid, + UE_mac_inst[module_idP].scheduling_info.LCGID[lcid], + frameP, subframeP); + break; + } + } - DevAssert(size > 0); - DevAssert(size <= 256); + // Trigger Regular BSR if ReTxBSR Timer has expired and UE has data for transmission + if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF == 0) { + bsr_regular_triggered = TRUE; - if (value == 0) { - return 0; //elseif (value > 150000) return 63; + if ((UE_mac_inst[module_idP].BSR_reporting_active & + BSR_TRIGGER_REGULAR) == 0) { + LOG_I(MAC, + "[UE %d] PDCCH Tick : MAC BSR Triggered ReTxBSR Timer expiry at frame %d subframe %d\n", + module_idP, frameP, subframeP); + } } + } + + //Store Buffer Occupancy in remain buffers for next TTI + for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) { + UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] = + lcid_bytes_in_buffer[lcid]; + } - jl = 0; // lower bound - ju = size - 1; // upper bound - ascend = (table[ju] >= table[jl]) ? 1 : 0; // determine the order of the the table: 1 if ascending order of table, 0 otherwise + return bsr_regular_triggered; +} - while (ju - jl > 1) { //If we are not yet done, - jm = (ju + jl) >> 1; //compute a midpoint, +uint8_t +locate_BsrIndexByBufferSize(const uint32_t *table, int size, int value) { + uint8_t ju, jm, jl; + int ascend; + DevAssert(size > 0); + DevAssert(size <= 256); + + if (value == 0) { + return 0; //elseif (value > 150000) return 63; + } - if ((value >= table[jm]) == ascend) { - jl = jm; // replace the lower limit - } else { - ju = jm; //replace the upper limit - } + jl = 0; // lower bound + ju = size - 1; // upper bound + ascend = (table[ju] >= table[jl]) ? 1 : 0; // determine the order of the the table: 1 if ascending order of table, 0 otherwise - LOG_T(MAC, - "[UE] searching BSR index %d for (BSR TABLE %d < value %d)\n", - jm, table[jm], value); - } + while (ju - jl > 1) { //If we are not yet done, + jm = (ju + jl) >> 1; //compute a midpoint, - if (value == table[jl]) { - return jl; + if ((value >= table[jm]) == ascend) { + jl = jm; // replace the lower limit } else { - return jl + 1; //equally ju + ju = jm; //replace the upper limit } -} + LOG_T(MAC, + "[UE] searching BSR index %d for (BSR TABLE %d < value %d)\n", + jm, table[jm], value); + } -int get_sf_periodicBSRTimer(uint8_t sf_offset) -{ + if (value == table[jl]) { + return jl; + } else { + return jl + 1; //equally ju + } +} - switch (sf_offset) { +int get_sf_periodicBSRTimer(uint8_t sf_offset) { + switch (sf_offset) { case LTE_PeriodicBSR_Timer_r12_sf5: - return 5; - break; + return 5; + break; case LTE_PeriodicBSR_Timer_r12_sf10: - return 10; - break; + return 10; + break; case LTE_PeriodicBSR_Timer_r12_sf16: - return 16; - break; + return 16; + break; case LTE_PeriodicBSR_Timer_r12_sf20: - return 20; - break; + return 20; + break; case LTE_PeriodicBSR_Timer_r12_sf32: - return 32; - break; + return 32; + break; case LTE_PeriodicBSR_Timer_r12_sf40: - return 40; - break; + return 40; + break; case LTE_PeriodicBSR_Timer_r12_sf64: - return 64; - break; + return 64; + break; case LTE_PeriodicBSR_Timer_r12_sf80: - return 80; - break; + return 80; + break; case LTE_PeriodicBSR_Timer_r12_sf128: - return 128; - break; + return 128; + break; case LTE_PeriodicBSR_Timer_r12_sf160: - return 160; - break; + return 160; + break; case LTE_PeriodicBSR_Timer_r12_sf320: - return 320; - break; + return 320; + break; case LTE_PeriodicBSR_Timer_r12_sf640: - return 640; - break; + return 640; + break; case LTE_PeriodicBSR_Timer_r12_sf1280: - return 1280; - break; + return 1280; + break; case LTE_PeriodicBSR_Timer_r12_sf2560: - return 2560; - break; + return 2560; + break; case LTE_PeriodicBSR_Timer_r12_infinity: default: - return 0xFFFF; - break; - } + return 0xFFFF; + break; + } } -int get_sf_retxBSRTimer(uint8_t sf_offset) -{ - - switch (sf_offset) { +int get_sf_retxBSRTimer(uint8_t sf_offset) { + switch (sf_offset) { case LTE_RetxBSR_Timer_r12_sf320: - return 320; - break; + return 320; + break; case LTE_RetxBSR_Timer_r12_sf640: - return 640; - break; + return 640; + break; case LTE_RetxBSR_Timer_r12_sf1280: - return 1280; - break; + return 1280; + break; case LTE_RetxBSR_Timer_r12_sf2560: - return 2560; - break; + return 2560; + break; case LTE_RetxBSR_Timer_r12_sf5120: - return 5120; - break; + return 5120; + break; case LTE_RetxBSR_Timer_r12_sf10240: - return 10240; - break; + return 10240; + break; default: - return -1; - break; - } + return -1; + break; + } } -int get_ms_bucketsizeduration(uint8_t bucketsizeduration) -{ - - switch (bucketsizeduration) { +int get_ms_bucketsizeduration(uint8_t bucketsizeduration) { + switch (bucketsizeduration) { case LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50: - return - 50; - break; + return + 50; + break; case LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms100: - return - 100; - break; + return + 100; + break; case LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms150: - return - 150; - break; + return + 150; + break; case LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms300: - return - 300; - break; + return + 300; + break; case LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms500: - return - 500; - break; + return + 500; + break; case LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms1000: - return - 1000; - break; + return + 1000; + break; default: - return 0; - break; - } + return 0; + break; + } } -void update_phr(module_id_t module_idP, int CC_id) -{ - - AssertFatal(CC_id == 0, - "Transmission on secondary CCs is not supported yet\n"); - - UE_mac_inst[module_idP].PHR_reporting_active = 0; - UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = - get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP]. - scheduling_info.periodicPHR_Timer); - UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = - get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP]. - scheduling_info.prohibitPHR_Timer); - // LOG_D(MAC,"phr %d %d\n ",UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF, UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF); +void update_phr(module_id_t module_idP, int CC_id) { + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + UE_mac_inst[module_idP].PHR_reporting_active = 0; + UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = + get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP]. + scheduling_info.periodicPHR_Timer); + UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = + get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP]. + scheduling_info.prohibitPHR_Timer); + // LOG_D(MAC,"phr %d %d\n ",UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF, UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF); } uint8_t -get_phr_mapping(module_id_t module_idP, int CC_id, uint8_t eNB_index) -{ - - AssertFatal(CC_id == 0, - "Transmission on secondary CCs is not supported yet\n"); - - //power headroom reporting range is from -23 ...+40 dB, as described in 36313 - //note: mac_xface->get_Po_NOMINAL_PUSCH(module_idP) is float - if (get_PHR(module_idP, CC_id, eNB_index) < -23) { - return 0; - } else if (get_PHR(module_idP, CC_id, eNB_index) >= 40) { - return 63; - } else { // -23 to 40 - return (uint8_t) get_PHR(module_idP, CC_id, - eNB_index) + PHR_MAPPING_OFFSET; - - } +get_phr_mapping(module_id_t module_idP, int CC_id, uint8_t eNB_index) { + AssertFatal(CC_id == 0, + "Transmission on secondary CCs is not supported yet\n"); + + //power headroom reporting range is from -23 ...+40 dB, as described in 36313 + //note: mac_xface->get_Po_NOMINAL_PUSCH(module_idP) is float + if (get_PHR(module_idP, CC_id, eNB_index) < -23) { + return 0; + } else if (get_PHR(module_idP, CC_id, eNB_index) >= 40) { + return 63; + } else { // -23 to 40 + return (uint8_t) get_PHR(module_idP, CC_id, + eNB_index) + PHR_MAPPING_OFFSET; + } } -int get_sf_perioidicPHR_Timer(uint8_t perioidicPHR_Timer) -{ - return (perioidicPHR_Timer + 1) * 10; +int get_sf_perioidicPHR_Timer(uint8_t perioidicPHR_Timer) { + return (perioidicPHR_Timer + 1) * 10; } -int get_sf_prohibitPHR_Timer(uint8_t prohibitPHR_Timer) -{ - return (prohibitPHR_Timer) * 10; +int get_sf_prohibitPHR_Timer(uint8_t prohibitPHR_Timer) { + return (prohibitPHR_Timer) * 10; } -int get_db_dl_PathlossChange(uint8_t dl_PathlossChange) -{ - switch (dl_PathlossChange) { +int get_db_dl_PathlossChange(uint8_t dl_PathlossChange) { + switch (dl_PathlossChange) { case LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1: - return 1; - break; + return 1; + break; case LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB3: - return 3; - break; + return 3; + break; case LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB6: - return 6; - break; + return 6; + break; case LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_infinity: default: - return -1; - break; - } + return -1; + break; + } } SLSS_t *ue_get_slss(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t subframe_tx) { - - return((SLSS_t*)NULL); + return((SLSS_t *)NULL); } SLDCH_t *ue_get_sldch(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t subframe_tx) { - - //UE_MAC_INST *ue = &UE_mac_inst[Mod_id]; - SLDCH_t *sldch = &UE_mac_inst[Mod_id].sldch; - - sldch->payload_length = mac_rrc_data_req_ue(Mod_id, - CC_id, - frame_tx, - SL_DISCOVERY, - 1, - (uint8_t*)(sldch->payload), //&UE_mac_inst[Mod_id].SL_Discovery[0].Tx_buffer.Payload[0], - 0, //eNB_indexP - 0); - - - - if (sldch->payload_length >0 ) { - LOG_I(MAC,"Got %d bytes from RRC for SLDCH @ %p\n",sldch->payload_length,sldch); - return (sldch); - } - else - - return((SLDCH_t*)NULL); + //UE_MAC_INST *ue = &UE_mac_inst[Mod_id]; + SLDCH_t *sldch = &UE_mac_inst[Mod_id].sldch; + sldch->payload_length = mac_rrc_data_req_ue(Mod_id, + CC_id, + frame_tx, + SL_DISCOVERY, + 1, + (uint8_t *)(sldch->payload), //&UE_mac_inst[Mod_id].SL_Discovery[0].Tx_buffer.Payload[0], + 0, //eNB_indexP + 0); + + if (sldch->payload_length >0 ) { + LOG_I(MAC,"Got %d bytes from RRC for SLDCH @ %p\n",sldch->payload_length,sldch); + return (sldch); + } else + return((SLDCH_t *)NULL); } SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subframeP) { + mac_rlc_status_resp_t rlc_status; //, rlc_status_data; + uint32_t absSF = (frameP*10)+subframeP; + UE_MAC_INST *ue = &UE_mac_inst[module_idP]; + int rvtab[4] = {0,2,3,1}; + int sdu_length; + //uint8_t sl_lcids[2] = {3, 10}; //list of lcids for SL - hardcoded + int i = 0; + // Note: this is hard-coded for now for the default SL configuration (4 SF PSCCH, 36 SF PSSCH) + SLSCH_t *slsch = &UE_mac_inst[module_idP].slsch; + LOG_D(MAC,"Checking SLSCH for absSF %d\n",absSF); + + if ((absSF%40) == 0) { // fill PSCCH data later in first subframe of SL period + ue->sltx_active = 0; - mac_rlc_status_resp_t rlc_status; //, rlc_status_data; - uint32_t absSF = (frameP*10)+subframeP; - UE_MAC_INST *ue = &UE_mac_inst[module_idP]; - int rvtab[4] = {0,2,3,1}; - int sdu_length; - //uint8_t sl_lcids[2] = {3, 10}; //list of lcids for SL - hardcoded - int i = 0; - - // Note: this is hard-coded for now for the default SL configuration (4 SF PSCCH, 36 SF PSSCH) - SLSCH_t *slsch = &UE_mac_inst[module_idP].slsch; - - LOG_D(MAC,"Checking SLSCH for absSF %d\n",absSF); - if ((absSF%40) == 0) { // fill PSCCH data later in first subframe of SL period - ue->sltx_active = 0; - - for (i = 0; i < MAX_NUM_LCID; i++){ - if (ue->SL_LCID[i] > 0) { - for (int j = 0; j < ue->numCommFlows; j++){ - if ((ue->sourceL2Id > 0) && (ue->destinationList[j] >0) ){ - rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO, - ue->SL_LCID[i], 0xFFFF, ue->sourceL2Id, ue->destinationList[j]); - if (rlc_status.bytes_in_buffer > 2){ - LOG_I(MAC,"SFN.SF %d.%d: Scheduling for %d bytes in Sidelink buffer\n",frameP,subframeP,rlc_status.bytes_in_buffer); - // Fill in group id for off-network communications - ue->sltx_active = 1; - //store LCID, destinationL2Id - ue->slsch_lcid = ue->SL_LCID[i]; - ue->destinationL2Id = ue->destinationList[j]; - break; - } - } + for (i = 0; i < MAX_NUM_LCID; i++) { + if (ue->SL_LCID[i] > 0) { + for (int j = 0; j < ue->numCommFlows; j++) { + if ((ue->sourceL2Id > 0) && (ue->destinationList[j] >0) ) { + rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO, + ue->SL_LCID[i], 0xFFFF, ue->sourceL2Id, ue->destinationList[j]); + + if (rlc_status.bytes_in_buffer > 2) { + LOG_I(MAC,"SFN.SF %d.%d: Scheduling for %d bytes in Sidelink buffer\n",frameP,subframeP,rlc_status.bytes_in_buffer); + // Fill in group id for off-network communications + ue->sltx_active = 1; + //store LCID, destinationL2Id + ue->slsch_lcid = ue->SL_LCID[i]; + ue->destinationL2Id = ue->destinationList[j]; + break; } - } - if ( ue->sltx_active == 1) break; + } + } } - } // we're not in the SCCH period - else if (((absSF & 3) == 0 ) && - (ue->sltx_active == 1)) { // every 4th subframe, check for new data from RLC - // 10 PRBs, mcs 19 - int TBS = 4584/8; - int req; - - - if (TBS <= rlc_status.bytes_in_buffer) req = TBS; - else req = rlc_status.bytes_in_buffer; - - if (req>0) { - sdu_length = mac_rlc_data_req(module_idP, - 0x1234, - 0, - frameP, - ENB_FLAG_NO, - MBMS_FLAG_NO, - ue->slsch_lcid, - req, - (char*)(ue->slsch_pdu.payload + sizeof(SLSCH_SUBHEADER_24_Bit_DST_LONG)) + + if ( ue->sltx_active == 1) break; + } + } // we're not in the SCCH period + else if (((absSF & 3) == 0 ) && + (ue->sltx_active == 1)) { // every 4th subframe, check for new data from RLC + // 10 PRBs, mcs 19 + int TBS = 4584/8; + int req; + + if (TBS <= rlc_status.bytes_in_buffer) req = TBS; + else req = rlc_status.bytes_in_buffer; + + if (req>0) { + sdu_length = mac_rlc_data_req(module_idP, + 0x1234, + 0, + frameP, + ENB_FLAG_NO, + MBMS_FLAG_NO, + ue->slsch_lcid, + req, + (char *)(ue->slsch_pdu.payload + sizeof(SLSCH_SUBHEADER_24_Bit_DST_LONG)) #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,ue->sourceL2Id, - ue->destinationL2Id + ,ue->sourceL2Id, + ue->destinationL2Id #endif - ); - - // Notes: 1. hard-coded to 24-bit destination format for now - if (sdu_length > 0) { - - LOG_I(MAC,"SFN.SF %d.%d : got %d bytes from Sidelink buffer (%d requested)\n",frameP,subframeP,sdu_length,req); - LOG_I(MAC,"sourceL2Id: 0x%08x \n",ue->sourceL2Id); - LOG_I(MAC,"groupL2Id/destinationL2Id: 0x%08x \n",ue->destinationL2Id); - - slsch->payload = (unsigned char*)ue->slsch_pdu.payload; - if (sdu_length < 128) { - slsch->payload++; - SLSCH_SUBHEADER_24_Bit_DST_SHORT *shorth= (SLSCH_SUBHEADER_24_Bit_DST_SHORT *)slsch->payload; - shorth->F = 0; - shorth->L = sdu_length; - shorth->E = 0; - shorth->LCID = ue->slsch_lcid; - shorth->SRC07 = (ue->sourceL2Id>>16) & 0x000000ff; - shorth->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff; - shorth->SRC1623 = ue->sourceL2Id & 0x000000ff; - shorth->DST07 = (ue->destinationL2Id >>16) & 0x000000ff; - shorth->DST815 = (ue->destinationL2Id >>8) & 0x000000ff; - shorth->DST1623 = ue->destinationL2Id & 0x000000ff; - shorth->V = 0x1; - } - else { - SLSCH_SUBHEADER_24_Bit_DST_LONG *longh= (SLSCH_SUBHEADER_24_Bit_DST_LONG *)slsch->payload; - longh->F = 1; - longh->L_LSB = sdu_length&0xff; - longh->L_MSB = (sdu_length>>8)&0x7f; - longh->E = 0; - longh->LCID = ue->slsch_lcid; - longh->SRC07 = (ue->sourceL2Id >>16) & 0x000000ff; - longh->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff; - longh->SRC1623 = ue->sourceL2Id & 0x000000ff; - longh->DST07 = (ue->destinationL2Id >>16) & 0x000000ff; - longh->DST815 = (ue->destinationL2Id>>8) & 0x000000ff; - longh->DST1623 = ue->destinationL2Id & 0x000000ff; - longh->V = 0x1; - } - slsch->rvidx = 0; - slsch->payload_length = TBS; - // fill in SLSCH configuration - return(&ue->slsch); - } - else ue->sltx_active = 0; - } + ); + + // Notes: 1. hard-coded to 24-bit destination format for now + if (sdu_length > 0) { + LOG_I(MAC,"SFN.SF %d.%d : got %d bytes from Sidelink buffer (%d requested)\n",frameP,subframeP,sdu_length,req); + LOG_I(MAC,"sourceL2Id: 0x%08x \n",ue->sourceL2Id); + LOG_I(MAC,"groupL2Id/destinationL2Id: 0x%08x \n",ue->destinationL2Id); + slsch->payload = (unsigned char *)ue->slsch_pdu.payload; + + if (sdu_length < 128) { + slsch->payload++; + SLSCH_SUBHEADER_24_Bit_DST_SHORT *shorth= (SLSCH_SUBHEADER_24_Bit_DST_SHORT *)slsch->payload; + shorth->F = 0; + shorth->L = sdu_length; + shorth->E = 0; + shorth->LCID = ue->slsch_lcid; + shorth->SRC07 = (ue->sourceL2Id>>16) & 0x000000ff; + shorth->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff; + shorth->SRC1623 = ue->sourceL2Id & 0x000000ff; + shorth->DST07 = (ue->destinationL2Id >>16) & 0x000000ff; + shorth->DST815 = (ue->destinationL2Id >>8) & 0x000000ff; + shorth->DST1623 = ue->destinationL2Id & 0x000000ff; + shorth->V = 0x1; + } else { + SLSCH_SUBHEADER_24_Bit_DST_LONG *longh= (SLSCH_SUBHEADER_24_Bit_DST_LONG *)slsch->payload; + longh->F = 1; + longh->L_LSB = sdu_length&0xff; + longh->L_MSB = (sdu_length>>8)&0x7f; + longh->E = 0; + longh->LCID = ue->slsch_lcid; + longh->SRC07 = (ue->sourceL2Id >>16) & 0x000000ff; + longh->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff; + longh->SRC1623 = ue->sourceL2Id & 0x000000ff; + longh->DST07 = (ue->destinationL2Id >>16) & 0x000000ff; + longh->DST815 = (ue->destinationL2Id>>8) & 0x000000ff; + longh->DST1623 = ue->destinationL2Id & 0x000000ff; + longh->V = 0x1; + } - } else if ((absSF%40)>3 && ue->sltx_active == 1) { // handle retransmission of SDU - LOG_I(MAC,"SFN.SF %d.%d : retransmission\n",frameP,subframeP); - slsch->rvidx = rvtab[absSF&3]; - return(&ue->slsch); - } + slsch->rvidx = 0; + slsch->payload_length = TBS; + // fill in SLSCH configuration + return(&ue->slsch); + } else ue->sltx_active = 0; + } + } else if ((absSF%40)>3 && ue->sltx_active == 1) { // handle retransmission of SDU + LOG_I(MAC,"SFN.SF %d.%d : retransmission\n",frameP,subframeP); + slsch->rvidx = rvtab[absSF&3]; + return(&ue->slsch); + } return(NULL); } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index b72f26780c57941eb1f5e5e73e35ae733198f312..22a18a6659c4fc56139f83dc28507c6448a7da50 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -46,10 +46,12 @@ #include "common/utils/LOG/log.h" #include <inttypes.h> #include "platform_constants.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "msc.h" #include "common/ngran_types.h" #include "targets/COMMON/openairinterface5g_limits.h" +#include "targets/RT/USER/lte-softmodem.h" #include "SIMULATION/ETH_TRANSPORT/proto.h" #include "UTIL/OSA/osa_defs.h" #include "openair2/RRC/NAS/nas_config.h" @@ -60,9 +62,8 @@ # include "gtpv1u.h" #include "ENB_APP/enb_config.h" -#ifndef UETARGET -#include "LAYER2/PROTO_AGENT/proto_agent.h" -#endif + + extern int otg_enabled; extern uint8_t nfapi_mode; @@ -83,7 +84,7 @@ hash_table_t *pdcp_coll_p = NULL; /* pdcp module parameters and related functions*/ -static pdcp_params_t pdcp_params= {0}; +static pdcp_params_t pdcp_params= {0,NULL}; uint64_t get_pdcp_optmask(void) { return pdcp_params.optmask; @@ -190,22 +191,9 @@ boolean_t pdcp_data_req( sdu_buffer_sizeP); LOG_UI(PDCP, "Before rlc_data_req 1, srb_flagP: %d, rb_idP: %d \n", srb_flagP, rb_idP); } -#ifndef UETARGET - if (NODE_IS_CU(RC.rrc[ctxt_pP->module_id]->node_type)) { - /* currently, there is no support to send also the source/destinationL2Id */ - proto_agent_send_rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, muiP, - confirmP, sdu_buffer_sizeP, pdcp_pdu_p); - /* assume good status */ - rlc_status = RLC_OP_STATUS_OK; - - } else -#endif - { - rlc_status = rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_YES, rb_idP, muiP, - confirmP, sdu_buffer_sizeP, pdcp_pdu_p - ,NULL, NULL - ); - } + + rlc_status = pdcp_params.send_rlc_data_req_func(ctxt_pP, srb_flagP, NODE_IS_CU(RC.rrc[ctxt_pP->module_id]->node_type)?MBMS_FLAG_NO:MBMS_FLAG_YES, rb_idP, muiP, + confirmP, sdu_buffer_sizeP, pdcp_pdu_p,NULL,NULL); } else { rlc_status = RLC_OP_STATUS_OUT_OF_RESSOURCES; LOG_E(PDCP,PROTOCOL_CTXT_FMT" PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n", @@ -364,74 +352,55 @@ boolean_t pdcp_data_req( */ LOG_DUMPMSG(PDCP,DEBUG_PDCP,(char *)pdcp_pdu_p->data,pdcp_pdu_size, "[MSG] PDCP DL %s PDU on rb_id %d\n",(srb_flagP)? "CONTROL" : "DATA", rb_idP); - - if ((pdcp_pdu_p!=NULL) && (srb_flagP == 0) && (ctxt_pP->enb_flag == 1)) - { -#ifndef UETARGET - LOG_D(PDCP, "pdcp data req on drb %d, size %d, rnti %x, node_type %d \n", + if ((pdcp_pdu_p!=NULL) && (srb_flagP == 0) && (ctxt_pP->enb_flag == 1)) { + LOG_D(PDCP, "pdcp data req on drb %d, size %d, rnti %x, node_type %d \n", rb_idP, pdcp_pdu_size, ctxt_pP->rnti, RC.rrc[ctxt_pP->module_id]->node_type); - if (NODE_IS_CU(RC.rrc[ctxt_pP->module_id]->node_type)) { - /* currently, there is no support to send also the source/destinationL2Id */ - proto_agent_send_rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, muiP, - confirmP, pdcp_pdu_size, pdcp_pdu_p); - /* assume good status */ - rlc_status = RLC_OP_STATUS_OK; - ret = TRUE; - LOG_D(PDCP, "proto_agent_send_rlc_data_req for UE RNTI %x, rb %d, pdu size %d \n", - ctxt_pP->rnti, rb_idP, pdcp_pdu_size); - - } else if (NODE_IS_DU(RC.rrc[ctxt_pP->module_id]->node_type)){ + if (ctxt_pP->enb_flag == ENB_FLAG_YES && NODE_IS_DU(RC.rrc[ctxt_pP->module_id]->node_type)) { LOG_E(PDCP, "Can't be DU, bad node type %d \n", RC.rrc[ctxt_pP->module_id]->node_type); ret=FALSE; - } else -#endif - { - rlc_status = rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, muiP, - confirmP, pdcp_pdu_size, pdcp_pdu_p, sourceL2Id, - destinationL2Id - ); - switch (rlc_status) { - case RLC_OP_STATUS_OK: - LOG_D(PDCP, "Data sending request over RLC succeeded!\n"); - ret=TRUE; - break; + } else { + rlc_status = pdcp_params.send_rlc_data_req_func(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, muiP, + confirmP, pdcp_pdu_size, pdcp_pdu_p,sourceL2Id, + destinationL2Id); - case RLC_OP_STATUS_BAD_PARAMETER: - LOG_W(PDCP, "Data sending request over RLC failed with 'Bad Parameter' reason!\n"); - ret= FALSE; - break; + switch (rlc_status) { + case RLC_OP_STATUS_OK: + LOG_D(PDCP, "Data sending request over RLC succeeded!\n"); + ret=TRUE; + break; - case RLC_OP_STATUS_INTERNAL_ERROR: - LOG_W(PDCP, "Data sending request over RLC failed with 'Internal Error' reason!\n"); - ret= FALSE; - break; + case RLC_OP_STATUS_BAD_PARAMETER: + LOG_W(PDCP, "Data sending request over RLC failed with 'Bad Parameter' reason!\n"); + ret= FALSE; + break; - case RLC_OP_STATUS_OUT_OF_RESSOURCES: - LOG_W(PDCP, "Data sending request over RLC failed with 'Out of Resources' reason!\n"); - ret= FALSE; - break; + case RLC_OP_STATUS_INTERNAL_ERROR: + LOG_W(PDCP, "Data sending request over RLC failed with 'Internal Error' reason!\n"); + ret= FALSE; + break; - default: - LOG_W(PDCP, "RLC returned an unknown status code after PDCP placed the order to send some data (Status Code:%d)\n", rlc_status); - ret= FALSE; - break; - } // switch case - } /* end if node_type is CU */ - } - else // SRB - { + case RLC_OP_STATUS_OUT_OF_RESSOURCES: + LOG_W(PDCP, "Data sending request over RLC failed with 'Out of Resources' reason!\n"); + ret= FALSE; + break; -#ifndef UETARGET - if (NODE_IS_CU(RC.rrc[ctxt_pP->module_id]->node_type)) { + default: + LOG_W(PDCP, "RLC returned an unknown status code after PDCP placed the order to send some data (Status Code:%d)\n", rlc_status); + ret= FALSE; + break; + } // switch case + } /* end if node_type is not DU */ + } else { // SRB + if (ctxt_pP->enb_flag == ENB_FLAG_YES && NODE_IS_CU(RC.rrc[ctxt_pP->module_id]->node_type)) { // DL transfer MessageDef *message_p; // Note: the acyual task must be TASK_PDCP_ENB, but this task is not created message_p = itti_alloc_new_message (TASK_PDCP_ENB, F1AP_DL_RRC_MESSAGE); F1AP_DL_RRC_MESSAGE (message_p).rrc_container = &pdcp_pdu_p->data[0] ; F1AP_DL_RRC_MESSAGE (message_p).rrc_container_length = pdcp_pdu_size; - F1AP_DL_RRC_MESSAGE (message_p).gNB_CU_ue_id = 0; + F1AP_DL_RRC_MESSAGE (message_p).gNB_CU_ue_id = 0; F1AP_DL_RRC_MESSAGE (message_p).gNB_DU_ue_id = 0; F1AP_DL_RRC_MESSAGE (message_p).old_gNB_DU_ue_id = 0xFFFFFFFF; // unknown F1AP_DL_RRC_MESSAGE (message_p).rnti = ctxt_pP->rnti; @@ -442,10 +411,7 @@ boolean_t pdcp_data_req( //CU_send_DL_RRC_MESSAGE_TRANSFER(ctxt_pP->module_id, message_p); LOG_I(PDCP, "Send F1AP_DL_RRC_MESSAGE with ITTI\n"); ret=TRUE; - - } else -#endif - { + } else { rlc_status = rlc_data_req(ctxt_pP , srb_flagP , MBMS_FLAG_NO @@ -454,11 +420,10 @@ boolean_t pdcp_data_req( , confirmP , pdcp_pdu_size , pdcp_pdu_p -#ifdef Rel14 ,NULL ,NULL -#endif - ); + ); + switch (rlc_status) { case RLC_OP_STATUS_OK: LOG_D(PDCP, "Data sending request over RLC succeeded!\n"); @@ -719,13 +684,13 @@ pdcp_data_ind( } security_ok = pdcp_validate_security(ctxt_pP, - pdcp_p, - srb_flagP, - rb_idP, - pdcp_header_len, + pdcp_p, + srb_flagP, + rb_idP, + pdcp_header_len, rx_hfn_for_count, pdcp_sn_for_count, - sdu_buffer_pP->data, + sdu_buffer_pP->data, sdu_buffer_sizeP - pdcp_tailer_len) == 0; if (ctxt_pP->enb_flag == ENB_FLAG_NO) { @@ -788,156 +753,156 @@ pdcp_data_ind( payload_offset=pdcp_header_len;// PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE; switch (pdcp_p->rlc_mode) { - case RLC_MODE_AM: { - /* process as described in 36.323 5.1.2.1.2 */ - int reordering_window; + case RLC_MODE_AM: { + /* process as described in 36.323 5.1.2.1.2 */ + int reordering_window; - if (pdcp_p->seq_num_size == 7) - reordering_window = REORDERING_WINDOW_SN_7BIT; - else - reordering_window = REORDERING_WINDOW_SN_12BIT; - - if (sequence_number - pdcp_p->last_submitted_pdcp_rx_sn > reordering_window || - (pdcp_p->last_submitted_pdcp_rx_sn - sequence_number >= 0 && - pdcp_p->last_submitted_pdcp_rx_sn - sequence_number < reordering_window)) { - /* TODO: specs say to decipher and do header decompression */ - LOG_W(PDCP, - PROTOCOL_PDCP_CTXT_FMT"discard PDU, out of\n", - PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); - LOG_W(PDCP, "Ignoring PDU...\n"); - free_mem_block(sdu_buffer_pP, __func__); - /* TODO: indicate integrity verification failure to upper layer */ - return FALSE; - } else if (pdcp_p->next_pdcp_rx_sn - sequence_number > reordering_window) { - pdcp_p->rx_hfn++; - rx_hfn_for_count = pdcp_p->rx_hfn; - pdcp_sn_for_count = sequence_number; - pdcp_p->next_pdcp_rx_sn = sequence_number + 1; - } else if (sequence_number - pdcp_p->next_pdcp_rx_sn >= reordering_window) { - rx_hfn_for_count = pdcp_p->rx_hfn - 1; - pdcp_sn_for_count = sequence_number; - } else if (sequence_number >= pdcp_p->next_pdcp_rx_sn) { - rx_hfn_for_count = pdcp_p->rx_hfn; - pdcp_sn_for_count = sequence_number; - pdcp_p->next_pdcp_rx_sn = sequence_number + 1; - - if (pdcp_p->next_pdcp_rx_sn > pdcp_p->maximum_pdcp_rx_sn) { - pdcp_p->next_pdcp_rx_sn = 0; + if (pdcp_p->seq_num_size == 7) + reordering_window = REORDERING_WINDOW_SN_7BIT; + else + reordering_window = REORDERING_WINDOW_SN_12BIT; + + if (sequence_number - pdcp_p->last_submitted_pdcp_rx_sn > reordering_window || + (pdcp_p->last_submitted_pdcp_rx_sn - sequence_number >= 0 && + pdcp_p->last_submitted_pdcp_rx_sn - sequence_number < reordering_window)) { + /* TODO: specs say to decipher and do header decompression */ + LOG_W(PDCP, + PROTOCOL_PDCP_CTXT_FMT"discard PDU, out of\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); + LOG_W(PDCP, "Ignoring PDU...\n"); + free_mem_block(sdu_buffer_pP, __func__); + /* TODO: indicate integrity verification failure to upper layer */ + return FALSE; + } else if (pdcp_p->next_pdcp_rx_sn - sequence_number > reordering_window) { pdcp_p->rx_hfn++; + rx_hfn_for_count = pdcp_p->rx_hfn; + pdcp_sn_for_count = sequence_number; + pdcp_p->next_pdcp_rx_sn = sequence_number + 1; + } else if (sequence_number - pdcp_p->next_pdcp_rx_sn >= reordering_window) { + rx_hfn_for_count = pdcp_p->rx_hfn - 1; + pdcp_sn_for_count = sequence_number; + } else if (sequence_number >= pdcp_p->next_pdcp_rx_sn) { + rx_hfn_for_count = pdcp_p->rx_hfn; + pdcp_sn_for_count = sequence_number; + pdcp_p->next_pdcp_rx_sn = sequence_number + 1; + + if (pdcp_p->next_pdcp_rx_sn > pdcp_p->maximum_pdcp_rx_sn) { + pdcp_p->next_pdcp_rx_sn = 0; + pdcp_p->rx_hfn++; + } + } else { /* sequence_number < pdcp_p->next_pdcp_rx_sn */ + rx_hfn_for_count = pdcp_p->rx_hfn; + pdcp_sn_for_count = sequence_number; } - } else { /* sequence_number < pdcp_p->next_pdcp_rx_sn */ - rx_hfn_for_count = pdcp_p->rx_hfn; - pdcp_sn_for_count = sequence_number; - } - if (pdcp_p->security_activated == 1) { - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); - } else { - start_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); - } - - security_ok = pdcp_validate_security(ctxt_pP, - pdcp_p, - srb_flagP, - rb_idP, - pdcp_header_len, - rx_hfn_for_count, - pdcp_sn_for_count, - sdu_buffer_pP->data, - sdu_buffer_sizeP - pdcp_tailer_len) == 0; + if (pdcp_p->security_activated == 1) { + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); + } else { + start_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + } - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); - } else { - stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); - } - } else { - security_ok = 1; - } + security_ok = pdcp_validate_security(ctxt_pP, + pdcp_p, + srb_flagP, + rb_idP, + pdcp_header_len, + rx_hfn_for_count, + pdcp_sn_for_count, + sdu_buffer_pP->data, + sdu_buffer_sizeP - pdcp_tailer_len) == 0; - if (security_ok == 0) { - LOG_W(PDCP, - PROTOCOL_PDCP_CTXT_FMT"security not validated for incoming PDPC DRB RLC/AM PDU\n", - PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); - LOG_W(PDCP, "Ignoring PDU...\n"); - free_mem_block(sdu_buffer_pP, __func__); - /* TODO: indicate integrity verification failure to upper layer */ - return FALSE; - } + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + } + } else { + security_ok = 1; + } - /* TODO: specs say we have to store this PDU in a list and then deliver - * stored packets to upper layers according to a well defined - * procedure. The code below that deals with delivery is today - * too complex to do this properly, so we only send the current - * received packet. This is not correct and has to be fixed - * some day. - * In the meantime, let's pretend the last submitted PDCP SDU - * is the current one. - * TODO: we also have to deal with re-establishment PDU (control PDUs) - * that contain no SDU. - */ - pdcp_p->last_submitted_pdcp_rx_sn = sequence_number; - break; - } /* case RLC_MODE_AM */ + if (security_ok == 0) { + LOG_W(PDCP, + PROTOCOL_PDCP_CTXT_FMT"security not validated for incoming PDPC DRB RLC/AM PDU\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); + LOG_W(PDCP, "Ignoring PDU...\n"); + free_mem_block(sdu_buffer_pP, __func__); + /* TODO: indicate integrity verification failure to upper layer */ + return FALSE; + } - case RLC_MODE_UM: + /* TODO: specs say we have to store this PDU in a list and then deliver + * stored packets to upper layers according to a well defined + * procedure. The code below that deals with delivery is today + * too complex to do this properly, so we only send the current + * received packet. This is not correct and has to be fixed + * some day. + * In the meantime, let's pretend the last submitted PDCP SDU + * is the current one. + * TODO: we also have to deal with re-establishment PDU (control PDUs) + * that contain no SDU. + */ + pdcp_p->last_submitted_pdcp_rx_sn = sequence_number; + break; + } /* case RLC_MODE_AM */ - /* process as described in 36.323 5.1.2.1.3 */ - if (sequence_number < pdcp_p->next_pdcp_rx_sn) { - pdcp_p->rx_hfn++; - } + case RLC_MODE_UM: - rx_hfn_for_count = pdcp_p->rx_hfn; - pdcp_sn_for_count = sequence_number; - pdcp_p->next_pdcp_rx_sn = sequence_number + 1; + /* process as described in 36.323 5.1.2.1.3 */ + if (sequence_number < pdcp_p->next_pdcp_rx_sn) { + pdcp_p->rx_hfn++; + } - if (pdcp_p->next_pdcp_rx_sn > pdcp_p->maximum_pdcp_rx_sn) { - pdcp_p->next_pdcp_rx_sn = 0; - pdcp_p->rx_hfn++; - } + rx_hfn_for_count = pdcp_p->rx_hfn; + pdcp_sn_for_count = sequence_number; + pdcp_p->next_pdcp_rx_sn = sequence_number + 1; - if (pdcp_p->security_activated == 1) { - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); - } else { - start_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + if (pdcp_p->next_pdcp_rx_sn > pdcp_p->maximum_pdcp_rx_sn) { + pdcp_p->next_pdcp_rx_sn = 0; + pdcp_p->rx_hfn++; } - security_ok = pdcp_validate_security(ctxt_pP, - pdcp_p, - srb_flagP, - rb_idP, - pdcp_header_len, - rx_hfn_for_count, - pdcp_sn_for_count, - sdu_buffer_pP->data, - sdu_buffer_sizeP - pdcp_tailer_len) == 0; + if (pdcp_p->security_activated == 1) { + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); + } else { + start_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + } - if (ctxt_pP->enb_flag == ENB_FLAG_NO) { - stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); + security_ok = pdcp_validate_security(ctxt_pP, + pdcp_p, + srb_flagP, + rb_idP, + pdcp_header_len, + rx_hfn_for_count, + pdcp_sn_for_count, + sdu_buffer_pP->data, + sdu_buffer_sizeP - pdcp_tailer_len) == 0; + + if (ctxt_pP->enb_flag == ENB_FLAG_NO) { + stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security); + } else { + stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + } } else { - stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security); + security_ok = 1; } - } else { - security_ok = 1; - } - if (security_ok == 0) { - LOG_W(PDCP, - PROTOCOL_PDCP_CTXT_FMT"security not validated for incoming PDPC DRB RLC/UM PDU\n", - PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); - LOG_W(PDCP, "Ignoring PDU...\n"); - free_mem_block(sdu_buffer_pP, __func__); - /* TODO: indicate integrity verification failure to upper layer */ - return FALSE; - } + if (security_ok == 0) { + LOG_W(PDCP, + PROTOCOL_PDCP_CTXT_FMT"security not validated for incoming PDPC DRB RLC/UM PDU\n", + PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); + LOG_W(PDCP, "Ignoring PDU...\n"); + free_mem_block(sdu_buffer_pP, __func__); + /* TODO: indicate integrity verification failure to upper layer */ + return FALSE; + } - break; + break; - default: - LOG_E(PDCP, "bad RLC mode, cannot happen.\n"); - exit(1); + default: + LOG_E(PDCP, "bad RLC mode, cannot happen.\n"); + exit(1); } /* switch (pdcp_p->rlc_mode) */ } else { /* MBMS_flagP == 0 */ payload_offset=0; @@ -966,37 +931,36 @@ pdcp_data_ind( */ if (LINK_ENB_PDCP_TO_GTPV1U) { - if ((TRUE == ctxt_pP->enb_flag) && (FALSE == srb_flagP)) { - LOG_D(PDCP, "Sending packet to GTP, Calling GTPV1U_ENB_TUNNEL_DATA_REQ ue %x rab %u len %u\n", + if ((TRUE == ctxt_pP->enb_flag) && (FALSE == srb_flagP)) { + LOG_D(PDCP, "Sending packet to GTP, Calling GTPV1U_ENB_TUNNEL_DATA_REQ ue %x rab %u len %u\n", ctxt_pP->rnti, rb_id + 4, sdu_buffer_sizeP - payload_offset ); - - MSC_LOG_TX_MESSAGE( - MSC_PDCP_ENB, - MSC_GTPU_ENB, - NULL,0, - "0 GTPV1U_ENB_TUNNEL_DATA_REQ ue %x rab %u len %u", - ctxt_pP->rnti, - rb_id + 4, - sdu_buffer_sizeP - payload_offset); - //LOG_T(PDCP,"Sending to GTPV1U %d bytes\n", sdu_buffer_sizeP - payload_offset); - gtpu_buffer_p = itti_malloc(TASK_PDCP_ENB, TASK_GTPV1_U, - sdu_buffer_sizeP - payload_offset + GTPU_HEADER_OVERHEAD_MAX); - AssertFatal(gtpu_buffer_p != NULL, "OUT OF MEMORY"); - memcpy(>pu_buffer_p[GTPU_HEADER_OVERHEAD_MAX], &sdu_buffer_pP->data[payload_offset], sdu_buffer_sizeP - payload_offset); - message_p = itti_alloc_new_message(TASK_PDCP_ENB, GTPV1U_ENB_TUNNEL_DATA_REQ); - AssertFatal(message_p != NULL, "OUT OF MEMORY"); - GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p; - GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).length = sdu_buffer_sizeP - payload_offset; - GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX; - GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ctxt_pP->rnti; - GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4; - itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p); - packet_forwarded = TRUE; - } + MSC_LOG_TX_MESSAGE( + MSC_PDCP_ENB, + MSC_GTPU_ENB, + NULL,0, + "0 GTPV1U_ENB_TUNNEL_DATA_REQ ue %x rab %u len %u", + ctxt_pP->rnti, + rb_id + 4, + sdu_buffer_sizeP - payload_offset); + //LOG_T(PDCP,"Sending to GTPV1U %d bytes\n", sdu_buffer_sizeP - payload_offset); + gtpu_buffer_p = itti_malloc(TASK_PDCP_ENB, TASK_GTPV1_U, + sdu_buffer_sizeP - payload_offset + GTPU_HEADER_OVERHEAD_MAX); + AssertFatal(gtpu_buffer_p != NULL, "OUT OF MEMORY"); + memcpy(>pu_buffer_p[GTPU_HEADER_OVERHEAD_MAX], &sdu_buffer_pP->data[payload_offset], sdu_buffer_sizeP - payload_offset); + message_p = itti_alloc_new_message(TASK_PDCP_ENB, GTPV1U_ENB_TUNNEL_DATA_REQ); + AssertFatal(message_p != NULL, "OUT OF MEMORY"); + GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p; + GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).length = sdu_buffer_sizeP - payload_offset; + GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX; + GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ctxt_pP->rnti; + GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4; + itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p); + packet_forwarded = TRUE; + } } else { - packet_forwarded = FALSE; + packet_forwarded = FALSE; } #ifdef MBMS_MULTICAST_OUT @@ -1035,28 +999,28 @@ pdcp_data_ind( ((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_id; if (EPC_MODE_ENABLED) { - /* for the UE compiled in S1 mode, we need 1 here - * for the UE compiled in noS1 mode, we need 0 - * TODO: be sure of this - */ - if (nfapi_mode == 3) { + /* for the UE compiled in S1 mode, we need 1 here + * for the UE compiled in noS1 mode, we need 0 + * TODO: be sure of this + */ + if (NFAPI_MODE == NFAPI_UE_STUB_PNF ) { #ifdef UESIM_EXPANSION if (UE_NAS_USE_TUN) { ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id; } else { - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 0; + ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 0; } #else - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id; + ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id; #endif } else { // nfapi_mode if (UE_NAS_USE_TUN) { ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id; - } else { - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 1; - } + } else { + ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 1; + } } // nfapi_mode } } else { @@ -1065,9 +1029,9 @@ pdcp_data_ind( } if( LOG_DEBUGFLAG(DEBUG_PDCP) ) { - static uint32_t pdcp_inst = 0; - ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = pdcp_inst++; - LOG_D(PDCP, "inst=%d size=%d\n", ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst, ((pdcp_data_ind_header_t *) new_sdu_p->data)->data_size); + static uint32_t pdcp_inst = 0; + ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = pdcp_inst++; + LOG_D(PDCP, "inst=%d size=%d\n", ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst, ((pdcp_data_ind_header_t *) new_sdu_p->data)->data_size); } memcpy(&new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], @@ -1082,35 +1046,23 @@ pdcp_data_ind( sdu_buffer_sizeP - payload_offset); //util_print_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); //util_flush_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); - -#if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) - /* This was an "orphan else" in tag 2019.w07 and discovered during merge. - * Commenting so it could be reintegrated. */ - //else { - // AssertFatal(0, PROTOCOL_PDCP_CTXT_FMT" PDCP_DATA_IND SDU DROPPED, OUT OF MEMORY \n", - // PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p)); - //} - -#endif } /* Update PDCP statistics */ - 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 ){ + 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; } - } - + } + Pdcp_stats_rx[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; Pdcp_stats_rx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset); - Pdcp_stats_rx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=sequence_number; Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]); Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_enb[ctxt_pP->module_id].sfn; - free_mem_block(sdu_buffer_pP, __func__); if (ctxt_pP->enb_flag) { @@ -1296,8 +1248,7 @@ pdcp_run ( VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_OUT); } -void pdcp_init_stats_UE(module_id_t mod, uint16_t uid) -{ +void pdcp_init_stats_UE(module_id_t mod, uint16_t uid) { Pdcp_stats_tx_window_ms[mod][uid] = 100; Pdcp_stats_rx_window_ms[mod][uid] = 100; @@ -1314,7 +1265,6 @@ void pdcp_init_stats_UE(module_id_t mod, uint16_t uid) Pdcp_stats_tx_aiat_w[mod][uid][i] = 0; Pdcp_stats_tx_aiat_tmp_w[mod][uid][i] = 0; Pdcp_stats_tx_iat[mod][uid][i] = 0; - Pdcp_stats_rx[mod][uid][i] = 0; Pdcp_stats_rx_w[mod][uid][i] = 0; Pdcp_stats_rx_tmp_w[mod][uid][i] = 0; @@ -2186,6 +2136,16 @@ rrc_pdcp_config_req ( } } +pdcp_data_ind_func_t get_pdcp_data_ind_func() { + return pdcp_params.pdcp_data_ind_func; +} + +void pdcp_set_rlc_funcptr(send_rlc_data_req_func_t send_rlc_data_req, + pdcp_data_ind_func_t pdcp_data_ind) { + pdcp_params.send_rlc_data_req_func = send_rlc_data_req; + pdcp_params.pdcp_data_ind_func = pdcp_data_ind; +} + uint64_t pdcp_module_init( uint64_t pdcp_optmask ) { /* temporary enforce netlink when UE_NAS_USE_TUN is set, this is while switching from noS1 as build option @@ -2203,10 +2163,11 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask ) { nas_getparams(); if(UE_NAS_USE_TUN) { - netlink_init_tun("ue"); + int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 )?MAX_NUMBER_NETIF:1; + netlink_init_tun("ue",num_if); LOG_I(PDCP, "UE pdcp will use tun interface\n"); } else if(ENB_NAS_USE_TUN) { - netlink_init_tun("enb"); + netlink_init_tun("enb",1); nas_config(1, 1, 1, "enb"); LOG_I(PDCP, "ENB pdcp will use tun interface\n"); } else { @@ -2215,6 +2176,8 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask ) { } } + /* default interface with rlc (will be modified if CU) */ + pdcp_set_rlc_funcptr((send_rlc_data_req_func_t)rlc_data_req, pdcp_data_ind); return pdcp_params.optmask ; } @@ -2301,6 +2264,7 @@ void pdcp_layer_init(void) memset(pdcp_enb, 0, sizeof(pdcp_enb_t)); 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_eNB; i++) { for (j = 0; j < MAX_MOBILES_PER_ENB; j++) { Pdcp_stats_tx_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 ce62893170397dab8f664f9656615ccd364288ae..305b8ab2b4229d4b8b5a051ac774e00fb777e3b1 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -26,7 +26,7 @@ * \version 1.0 */ -/** @defgroup _pdcp PDCP +/** @defgroup _pdcp PDCP * @ingroup _oai2 * @{ */ @@ -51,6 +51,17 @@ #include "LTE_PMCH-InfoList-r9.h" #endif +typedef rlc_op_status_t (*send_rlc_data_req_func_t)(const protocol_ctxt_t *const, + const srb_flag_t, const MBMS_flag_t, + const rb_id_t, const mui_t, + confirm_t, sdu_size_t, mem_block_t *,const uint32_t *const, const uint32_t *const); +typedef boolean_t (*pdcp_data_ind_func_t)( const protocol_ctxt_t *, const srb_flag_t, + const MBMS_flag_t, const rb_id_t, const sdu_size_t, + mem_block_t *,const uint32_t *const, const uint32_t *const); +/* maximum number of tun interfaces that will be created to emulates UEs */ +/* UEs beyond that will be multiplexed on the same tun */ +#define MAX_NUMBER_NETIF 16 + #define PDCP_USE_NETLINK_BIT (1<< 11) #define LINK_ENB_PDCP_TO_IP_DRIVER_BIT (1<< 13) #define LINK_ENB_PDCP_TO_GTPV1U_BIT (1<< 14) @@ -58,8 +69,12 @@ #define ENB_NAS_USE_TUN_BIT (1<< 16) typedef struct { uint64_t optmask; + send_rlc_data_req_func_t send_rlc_data_req_func; + pdcp_data_ind_func_t pdcp_data_ind_func; } pdcp_params_t; + + #define PDCP_USE_NETLINK ( get_pdcp_optmask() & PDCP_USE_NETLINK_BIT) #define LINK_ENB_PDCP_TO_IP_DRIVER ( get_pdcp_optmask() & LINK_ENB_PDCP_TO_IP_DRIVER_BIT) #define LINK_ENB_PDCP_TO_GTPV1U ( get_pdcp_optmask() & LINK_ENB_PDCP_TO_GTPV1U_BIT) @@ -76,8 +91,8 @@ extern int pdcp_instance_cnt; #define PROTOCOL_PDCP_CTXT_FMT PROTOCOL_CTXT_FMT"[%s %02u] " #define PROTOCOL_PDCP_CTXT_ARGS(CTXT_Pp, pDCP_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp),\ - (pDCP_Pp->is_srb) ? "SRB" : "DRB",\ - pDCP_Pp->rb_id + (pDCP_Pp->is_srb) ? "SRB" : "DRB",\ + pDCP_Pp->rb_id int init_pdcp_thread(void); void cleanup_pdcp_thread(void); @@ -121,12 +136,12 @@ typedef struct pdcp_enb_s { uint16_t uid[MAX_MOBILES_PER_ENB]; rnti_t rnti[MAX_MOBILES_PER_ENB]; uint16_t num_ues; - + uint64_t sfn; frame_t frame; sub_frame_t subframe; - -} pdcp_enb_t; + +} pdcp_enb_t; pdcp_enb_t pdcp_enb[MAX_NUM_CCs]; @@ -151,7 +166,7 @@ typedef struct pdcp_s { boolean_t is_ue; boolean_t is_srb; - /* Configured security algorithms */ + /* Configured security algorithms */ uint8_t cipheringAlgorithm; uint8_t integrityProtAlgorithm; @@ -202,10 +217,6 @@ typedef struct pdcp_s { * which is not also a valid sequence number */ short int first_missing_pdu; - /* - * decipher using a different rx_hfn - */ - } pdcp_t; @@ -239,13 +250,13 @@ typedef struct pdcp_mbms_s { */ boolean_t pdcp_data_req( protocol_ctxt_t *ctxt_pP, - const srb_flag_t srb_flagP, - const rb_id_t rb_id, - const mui_t muiP, - const confirm_t confirmP, \ - const sdu_size_t sdu_buffer_size, + const srb_flag_t srb_flagP, + const rb_id_t rb_id, + const mui_t muiP, + const confirm_t confirmP, \ + const sdu_size_t sdu_buffer_size, unsigned char *const sdu_buffer, - const pdcp_transmission_mode_t mode + const pdcp_transmission_mode_t mode #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ,const uint32_t *const sourceL2Id ,const uint32_t *const destinationL2Id @@ -267,10 +278,10 @@ boolean_t pdcp_data_req( */ boolean_t pdcp_data_ind( const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_id, - const sdu_size_t sdu_buffer_size, + const srb_flag_t srb_flagP, + const MBMS_flag_t MBMS_flagP, + const rb_id_t rb_id, + const sdu_size_t sdu_buffer_size, mem_block_t *const sdu_buffer); /*! \fn void rrc_pdcp_config_req(const protocol_ctxt_t* const ,uint32_t,rb_id_t,uint8_t) @@ -285,10 +296,10 @@ boolean_t pdcp_data_ind( */ void rrc_pdcp_config_req ( const protocol_ctxt_t *const ctxt_pP, - const srb_flag_t srb_flagP, - const uint32_t actionP, - const rb_id_t rb_idP, - const uint8_t security_modeP); + const srb_flag_t srb_flagP, + const uint32_t actionP, + const rb_id_t rb_idP, + const uint8_t security_modeP); /*! \fn bool rrc_pdcp_config_asn1_req (const protocol_ctxt_t* const , SRB_ToAddModList_t* srb2add_list, DRB_ToAddModList_t* drb2add_list, DRB_ToReleaseList_t* drb2release_list) * \brief Function for RRC to configure a Radio Bearer. @@ -306,17 +317,17 @@ void rrc_pdcp_config_req ( */ boolean_t rrc_pdcp_config_asn1_req ( const protocol_ctxt_t *const ctxt_pP, - LTE_SRB_ToAddModList_t *const srb2add_list, - LTE_DRB_ToAddModList_t *const drb2add_list, - LTE_DRB_ToReleaseList_t *const drb2release_list, - const uint8_t security_modeP, - uint8_t *const kRRCenc, - uint8_t *const kRRCint, - uint8_t *const kUPenc + LTE_SRB_ToAddModList_t *const srb2add_list, + LTE_DRB_ToAddModList_t *const drb2add_list, + LTE_DRB_ToReleaseList_t *const drb2release_list, + const uint8_t security_modeP, + uint8_t *const kRRCenc, + uint8_t *const kRRCint, + uint8_t *const kUPenc #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - ,LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9 + ,LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9 #endif - ,rb_id_t *const defaultDRB + ,rb_id_t *const defaultDRB ); /*! \fn boolean_t pdcp_config_req_asn1 (const protocol_ctxt_t* const ctxt_pP, srb_flag_t srb_flagP, uint32_t action, rb_id_t rb_id, uint8_t rb_sn, uint8_t rb_report, uint16_t header_compression_profile, uint8_t security_mode) @@ -341,20 +352,20 @@ boolean_t rrc_pdcp_config_asn1_req ( */ boolean_t pdcp_config_req_asn1 ( const protocol_ctxt_t *const ctxt_pP, - pdcp_t *const pdcp_pP, - const srb_flag_t srb_flagP, - const rlc_mode_t rlc_mode, - const uint32_t action, - const uint16_t lc_id, - const uint16_t mch_id, - const rb_id_t rb_id, - const uint8_t rb_sn, - const uint8_t rb_report, - const uint16_t header_compression_profile, - const uint8_t security_mode, - uint8_t *const kRRCenc, - uint8_t *const kRRCint, - uint8_t *const kUPenc); + pdcp_t *const pdcp_pP, + const srb_flag_t srb_flagP, + const rlc_mode_t rlc_mode, + const uint32_t action, + const uint16_t lc_id, + const uint16_t mch_id, + const rb_id_t rb_id, + const uint8_t rb_sn, + const uint8_t rb_report, + const uint16_t header_compression_profile, + const uint8_t security_mode, + uint8_t *const kRRCenc, + uint8_t *const kRRCint, + uint8_t *const kUPenc); /*! \fn void pdcp_add_UE(const protocol_ctxt_t* const ctxt_pP) * \brief Function (for RRC) to add a new UE in PDCP module @@ -362,9 +373,9 @@ boolean_t pdcp_config_req_asn1 ( * \return A status about the processing, OK or error code. */ void pdcp_add_UE(const protocol_ctxt_t *const ctxt_pP); - + /*! \fn boolean_t pdcp_remove_UE(const protocol_ctxt_t* const ctxt_pP) -* \brief Function for RRC to remove UE from PDCP module hashtable +* \brief Function for RRC to remove UE from PDCP module hashtable * \param[in] ctxt_pP Running context. * \return A status about the processing, OK or error code. */ @@ -401,7 +412,9 @@ int pdcp_fifo_flush_sdus ( const protocol_ctxt_t *const ct int pdcp_fifo_read_input_sdus_remaining_bytes ( const protocol_ctxt_t *const ctxt_pP); int pdcp_fifo_read_input_sdus ( const protocol_ctxt_t *const ctxt_pP); void pdcp_fifo_read_input_sdus_from_otg ( const protocol_ctxt_t *const ctxt_pP); - +void pdcp_set_rlc_funcptr(send_rlc_data_req_func_t send_rlc_data_req, + pdcp_data_ind_func_t pdcp_data_ind); +pdcp_data_ind_func_t get_pdcp_data_ind_func(void); //----------------------------------------------------------------------------- /* @@ -449,26 +462,26 @@ struct sockaddr_in pdcp_sin; void pdcp_pc5_socket_init(void); typedef struct { - rb_id_t rb_id; - sdu_size_t data_size; - signed int inst; - ip_traffic_type_t traffic_type; - uint32_t sourceL2Id; - uint32_t destinationL2Id; + rb_id_t rb_id; + sdu_size_t data_size; + signed int inst; + ip_traffic_type_t traffic_type; + uint32_t sourceL2Id; + uint32_t destinationL2Id; } __attribute__((__packed__)) pc5s_header_t; //new PC5S-message typedef struct { - unsigned char bytes[PC5_SIGNALLING_PAYLOAD_SIZE]; + unsigned char bytes[PC5_SIGNALLING_PAYLOAD_SIZE]; } __attribute__((__packed__)) PC5SignallingMessage ; //example of PC5-S messages typedef struct { - pc5s_header_t pc5s_header; - union { - uint8_t status; - PC5SignallingMessage pc5_signalling_message; - } pc5sPrimitive; + pc5s_header_t pc5s_header; + union { + uint8_t status; + PC5SignallingMessage pc5_signalling_message; + } pc5sPrimitive; } __attribute__((__packed__)) sidelink_pc5s_element; @@ -513,33 +526,33 @@ sdu_size_t pdcp_input_sdu_size_read; sdu_size_t pdcp_input_sdu_remaining_size_to_read; #define PDCP_COLL_KEY_VALUE(mODULE_iD, rNTI, iS_eNB, rB_iD, iS_sRB) \ - ((hash_key_t)mODULE_iD | \ - (((hash_key_t)(rNTI)) << 8) | \ - (((hash_key_t)(iS_eNB)) << 24) | \ - (((hash_key_t)(rB_iD)) << 25) | \ - (((hash_key_t)(iS_sRB)) << 33) | \ - (((hash_key_t)(0x55)) << 34)) + ((hash_key_t)mODULE_iD | \ + (((hash_key_t)(rNTI)) << 8) | \ + (((hash_key_t)(iS_eNB)) << 24) | \ + (((hash_key_t)(rB_iD)) << 25) | \ + (((hash_key_t)(iS_sRB)) << 33) | \ + (((hash_key_t)(0x55)) << 34)) // hash key to the same PDCP as indexed by PDCP_COLL_KEY_VALUE(... rB_iD, iS_sRB=0) where rB_iD // is the default DRB ID. The hidden code 0x55 indicates the key is indexed by (rB_iD,is_sRB) // whereas the hidden code 0xaa indicates the key is for default DRB only #define PDCP_COLL_KEY_DEFAULT_DRB_VALUE(mODULE_iD, rNTI, iS_eNB) \ - ((hash_key_t)mODULE_iD | \ - (((hash_key_t)(rNTI)) << 8) | \ - (((hash_key_t)(iS_eNB)) << 24) | \ - (((hash_key_t)(0xff)) << 25) | \ - (((hash_key_t)(0x00)) << 33) | \ - (((hash_key_t)(0xaa)) << 34)) + ((hash_key_t)mODULE_iD | \ + (((hash_key_t)(rNTI)) << 8) | \ + (((hash_key_t)(iS_eNB)) << 24) | \ + (((hash_key_t)(0xff)) << 25) | \ + (((hash_key_t)(0x00)) << 33) | \ + (((hash_key_t)(0xaa)) << 34)) // service id max val is maxServiceCount = 16 (asn1_constants.h) #define PDCP_COLL_KEY_MBMS_VALUE(mODULE_iD, rNTI, iS_eNB, sERVICE_ID, sESSION_ID) \ - ((hash_key_t)mODULE_iD | \ - (((hash_key_t)(rNTI)) << 8) | \ - (((hash_key_t)(iS_eNB)) << 24) | \ - (((hash_key_t)(sERVICE_ID)) << 32) | \ - (((hash_key_t)(sESSION_ID)) << 37) | \ - (((hash_key_t)(0x0000000000000001)) << 63)) + ((hash_key_t)mODULE_iD | \ + (((hash_key_t)(rNTI)) << 8) | \ + (((hash_key_t)(iS_eNB)) << 24) | \ + (((hash_key_t)(sERVICE_ID)) << 32) | \ + (((hash_key_t)(sESSION_ID)) << 37) | \ + (((hash_key_t)(0x0000000000000001)) << 63)) extern hash_table_t *pdcp_coll_p; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 7324a7c7ea9f6f42d17f87750b237ba19c6ee915..17d386343b9c0d499f21268f33566b6e41b8c956 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -54,6 +54,7 @@ extern int otg_enabled; #include "UTIL/OCG/OCG_extern.h" #include "common/utils/LOG/log.h" #include "UTIL/OTG/otg_tx.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "UTIL/FIFO/pad_list.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "platform_constants.h" @@ -80,7 +81,7 @@ extern struct msghdr nas_msg_tx; extern struct msghdr nas_msg_rx; -extern uint8_t nfapi_mode; + #ifdef UESIM_EXPANSION extern uint16_t inst_pdcp_list[NUMBER_OF_UE_MAX]; #endif @@ -106,19 +107,19 @@ void debug_pdcp_pc5s_sdu(sidelink_pc5s_element *sl_pc5s_msg, char *title) { //----------------------------------------------------------------------------- int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) { mem_block_t *sdu_p; - int pdcp_nb_sdu_sent = 0; + int pdcp_nb_sdu_sent = 0; int ret=0; while ((sdu_p = list_get_head (&pdcp_sdu_list)) != NULL && ((pdcp_data_ind_header_t *)(sdu_p->data))->inst == ctxt_pP->module_id) { ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0; - int rb_id = ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id; + int rb_id = ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id; int sizeToWrite= sizeof (pdcp_data_ind_header_t) + ((pdcp_data_ind_header_t *) sdu_p->data)->data_size; - if (rb_id == 10) { //hardcoded for PC5-Signaling + if (rb_id == 10) { //hardcoded for PC5-Signaling if( LOG_DEBUGFLAG(DEBUG_PDCP) ) { debug_pdcp_pc5s_sdu((sidelink_pc5s_element *)&(sdu_p->data[sizeof(pdcp_data_ind_header_t)]), - "pdcp_fifo_flush_sdus received aPC5S message"); + "pdcp_fifo_flush_sdus sends a aPC5S message"); } ret = sendto(pdcp_pc5_sockfd, &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]), @@ -134,52 +135,48 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) { } // PDCP_USE_NETLINK AssertFatal(ret >= 0,"[PDCP_FIFOS] pdcp_fifo_flush_sdus (errno: %d %s)\n", errno, strerror(errno)); - list_remove_head (&pdcp_sdu_list); - free_mem_block (sdu_p, __func__); + list_remove_head (&pdcp_sdu_list); + free_mem_block (sdu_p, __func__); pdcp_nb_sdu_sent ++; - } + } - return pdcp_nb_sdu_sent; + return pdcp_nb_sdu_sent; } -//----------------------------------------------------------------------------- -int pdcp_fifo_read_input_sdus (const protocol_ctxt_t *const ctxt_pP) { - pdcp_data_req_header_t pdcp_read_header_g; - - if (UE_NAS_USE_TUN || ENB_NAS_USE_TUN) { +int pdcp_fifo_read_input_sdus_fromtun (const protocol_ctxt_t *const ctxt_pP) { protocol_ctxt_t ctxt = *ctxt_pP; hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; - pdcp_t *pdcp_p = NULL; + pdcp_t *pdcp_p = NULL; int len; rb_id_t rab_id = DEFAULT_RAB_ID; do { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 ); - len = read(UE_NAS_USE_TUN?nas_sock_fd[ctxt_pP->module_id]:nas_sock_fd[0], &nl_rx_buf, NL_MAX_PAYLOAD); + len = read(UE_NAS_USE_TUN?nas_sock_fd[ctxt_pP->module_id]:nas_sock_fd[0], &nl_rx_buf, NL_MAX_PAYLOAD); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); if (len<=0) continue; - if (UE_NAS_USE_TUN) { - key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + if (UE_NAS_USE_TUN) { + key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); - } else { - ctxt.rnti=pdcp_eNB_UE_instance_to_rnti[0]; - ctxt.enb_flag=ENB_FLAG_YES; - ctxt.module_id=0; - key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_YES); - h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); - } + } else { // => ENB_NAS_USE_TUN + ctxt.rnti=pdcp_eNB_UE_instance_to_rnti[0]; + ctxt.enb_flag=ENB_FLAG_YES; + ctxt.module_id=0; + key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_YES); + h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); + } - LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", - ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag); if (h_rc == HASH_TABLE_OK) { LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d on Rab %d \n", ctxt.frame, ctxt.instance, len, rab_id); - LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %04x][RB %u]\n", + LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %04x][RB %u]\n", ctxt.frame, ctxt.instance, rab_id, len, ctxt.module_id, ctxt.rnti, rab_id); MSC_LOG_RX_MESSAGE((ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, @@ -195,15 +192,15 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t *const ctxt_pP) { ); } else { MSC_LOG_RX_DISCARDED_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ctxt.instance, rab_id, rab_id, len); + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ctxt.instance, rab_id, rab_id, len); LOG_D(PDCP, - "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %04x][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", + "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %04x][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", ctxt.frame, ctxt.instance, rab_id, len, ctxt.module_id, ctxt.rnti, rab_id, key); } @@ -211,307 +208,149 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t *const ctxt_pP) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 ); return len; - } else { /* UE_NAS_USE_TUN */ - if (PDCP_USE_NETLINK) { - protocol_ctxt_t ctxt_cpy = *ctxt_pP; - protocol_ctxt_t ctxt; - hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; - hashtable_rc_t h_rc; - struct pdcp_netlink_element_s *data_p = NULL; - /* avoid gcc warnings */ - (void)data_p; - module_id_t ue_id = 0; - pdcp_t *pdcp_p = NULL; - //TTN for D2D (PC5S) - int prose_addr_len; - char send_buf[BUFSIZE], receive_buf[BUFSIZE]; - //int optval; - int bytes_received; - sidelink_pc5s_element *sl_pc5s_msg_recv = NULL; - sidelink_pc5s_element *sl_pc5s_msg_send = NULL; - //uint32_t sourceL2Id; - //uint32_t groupL2Id; - //module_id_t module_id = 0; - pc5s_header_t *pc5s_header; - static unsigned char pdcp_read_state_g =0; - int len = 1; - int msg_len; - rb_id_t rab_id = 0; - int rlc_data_req_flag = 3; - //TTN for D2D (PC5S) - prose_addr_len = sizeof(prose_pdcp_addr); - // receive a message from ProSe App - memset(receive_buf, 0, BUFSIZE); - bytes_received = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, 0, - (struct sockaddr *) &prose_pdcp_addr, (socklen_t *)&prose_addr_len); - - // if (bytes_received < 0){ - // LOG_E(RRC, "ERROR: Failed to receive from ProSe App\n"); - // exit(EXIT_FAILURE); - // } - if (bytes_received > 0) { - pc5s_header = calloc(1, sizeof(pc5s_header_t)); - memcpy((void *)pc5s_header, (void *)receive_buf, sizeof(pc5s_header_t)); - - if (pc5s_header->traffic_type == TRAFFIC_PC5S_SESSION_INIT) { - //send reply to ProSe app - LOG_D(PDCP,"Received a request to open PDCP socket and establish a new PDCP session ... send response to ProSe App \n"); - memset(send_buf, 0, BUFSIZE); - sl_pc5s_msg_send = calloc(1, sizeof(sidelink_pc5s_element)); - sl_pc5s_msg_send->pc5s_header.traffic_type = TRAFFIC_PC5S_SESSION_INIT; - sl_pc5s_msg_send->pc5sPrimitive.status = 1; - memcpy((void *)send_buf, (void *)sl_pc5s_msg_send, sizeof(sidelink_pc5s_element)); - int prose_addr_len = sizeof(prose_pdcp_addr); - int bytes_sent = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_pdcp_addr, prose_addr_len); - - if (bytes_sent < 0) { - LOG_E(PDCP, "ERROR: Failed to send to ProSe App\n"); - exit(EXIT_FAILURE); - } - } else if (pc5s_header->traffic_type == TRAFFIC_PC5S_SIGNALLING) { //if containing PC5-S message -> send to other UE - LOG_D(PDCP,"Received PC5-S message ... send to the other UE\n"); - LOG_D(PDCP,"Received PC5-S message, traffic_type: %d)\n", pc5s_header->traffic_type); - LOG_D(PDCP,"Received PC5-S message, rbid: %d)\n", pc5s_header->rb_id); - LOG_D(PDCP,"Received PC5-S message, data_size: %d)\n", pc5s_header->data_size); - LOG_D(PDCP,"Received PC5-S message, inst: %d)\n", pc5s_header->inst); - LOG_D(PDCP,"Received PC5-S message,sourceL2Id: 0x%08x\n)\n", pc5s_header->sourceL2Id); - LOG_D(PDCP,"Received PC5-S message,destinationL1Id: 0x%08x\n)\n", pc5s_header->destinationL2Id); -#ifdef OAI_EMU - - // overwrite function input parameters, because only one netlink socket for all instances - if (pc5s_header->inst < oai_emulation.info.nb_enb_local) { - ctxt.frame = ctxt_cpy.frame; - ctxt.enb_flag = ENB_FLAG_YES; - ctxt.module_id = pc5s_header.inst + oai_emulation.info.first_enb_local; - ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id ][pc5s_header->rb_id / LTE_maxDRB + oai_emulation.info.first_ue_local]; - rab_id = pc5s_header->rb_id % LTE_maxDRB; - } else { - ctxt.frame = ctxt_cpy.frame; - ctxt.enb_flag = ENB_FLAG_NO; - ctxt.module_id = pc5s_header->inst - oai_emulation.info.nb_enb_local + oai_emulation.info.first_ue_local; - ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; - rab_id = pc5s_header->rb_id % LTE_maxDRB; - } - - CHECK_CTXT_ARGS(&ctxt); - AssertFatal (rab_id < LTE_maxDRB, "RB id is too high (%u/%d)!\n", rab_id, LTE_maxDRB); - /*LGpdcp_read_header.inst = (pc5s_header.inst >= oai_emulation.info.nb_enb_local) ? \ - pc5s_header.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local : - pc5s_header.inst + oai_emulation.info.first_enb_local;*/ -#else // OAI_EMU - /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */ - // pc5s_header.inst = 0; - //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id" - ctxt.frame = ctxt_cpy.frame; - ctxt.enb_flag = ctxt_cpy.enb_flag; - LOG_I(PDCP, "[PDCP] pc5s_header->rb_id = %d\n", pc5s_header->rb_id); - - if (ctxt_cpy.enb_flag) { - ctxt.module_id = 0; - rab_id = pc5s_header->rb_id % LTE_maxDRB; - ctxt.rnti = pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index]; - } else { - ctxt.module_id = 0; - rab_id = pc5s_header->rb_id % LTE_maxDRB; - ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; - } +} -#endif +int pdcp_fifo_read_input_sdus_fromnetlinksock (const protocol_ctxt_t *const ctxt_pP) { + int len = 1; + int rlc_data_req_flag = 3; + + while ((len > 0) && (rlc_data_req_flag !=0)) { + pdcp_data_req_header_t pdcp_read_header_g; + protocol_ctxt_t ctxt_cpy = *ctxt_pP; + protocol_ctxt_t ctxt; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_rc; + module_id_t ue_id = 0; + pdcp_t *pdcp_p = NULL; + static unsigned char pdcp_read_state_g =0; + rb_id_t rab_id = 0; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 ); + len = recvmsg(nas_sock_fd[0], &nas_msg_rx, 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); - //UE - if (!ctxt.enb_flag) { - if (rab_id != 0) { - if (rab_id == UE_IP_DEFAULT_RAB_ID) { - LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", - ctxt.module_id, ctxt.rnti, ctxt.enb_flag); - key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); - h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); - LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n", - (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); - } else { - rab_id = rab_id % LTE_maxDRB; - LOG_I(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n", - ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); - key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); - h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); - LOG_I(PDCP,"request key %x : (%d,%x,%d,%d)\n", - (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); - } + if (len > 0) { + for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf; + NLMSG_OK (nas_nlh_rx, len); + nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, len)) { + if (nas_nlh_rx->nlmsg_type == NLMSG_DONE) { + LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_DONE\n"); + //return; + } + + if (nas_nlh_rx->nlmsg_type == NLMSG_ERROR) { + LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_ERROR\n"); + } + + if (pdcp_read_state_g == 0) { + if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) { + pdcp_read_state_g = 1; //get + memcpy((void *)&pdcp_read_header_g, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t)); + LOG_D(PDCP, "[PDCP][NETLINK] RX pdcp_data_req_header_t inst %u, rb_id %u data_size %d, source L2Id 0x%08x, destination L2Id 0x%08x\n", + pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size,pdcp_read_header_g.sourceL2Id, pdcp_read_header_g.destinationL2Id ); + } else { + LOG_E(PDCP, "[PDCP][NETLINK] WRONG size %d should be sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)\n", + nas_nlh_rx->nlmsg_len); + } + } else { + pdcp_read_state_g = 0; + // print_active_requests() + LOG_D(PDCP, "[PDCP][NETLINK] Something in socket, length %zu\n", + nas_nlh_rx->nlmsg_len - sizeof(struct nlmsghdr)); + /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */ + // pdcp_read_header_g.inst = 0; + //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id" + ctxt.frame = ctxt_cpy.frame; + ctxt.enb_flag = ctxt_cpy.enb_flag; + LOG_D(PDCP, "[PDCP][NETLINK] pdcp_read_header_g.rb_id = %d, source L2Id = 0x%08x, destination L2Id = 0x%08x \n", pdcp_read_header_g.rb_id, pdcp_read_header_g.sourceL2Id, + pdcp_read_header_g.destinationL2Id); - if (h_rc == HASH_TABLE_OK) { - rab_id = pdcp_p->rb_id; - LOG_I(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d on Rab %d \n", - ctxt.frame, - pc5s_header->inst, - bytes_received, - pc5s_header->rb_id); - LOG_I(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", - ctxt.frame, - pc5s_header->inst, - pc5s_header->rb_id, - pc5s_header->data_size, - ctxt.module_id, - ctxt.rnti, - rab_id); - MSC_LOG_RX_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pc5s_header->inst, - pc5s_header->rb_id, - rab_id, - pc5s_header->data_size); - pdcp_data_req( - &ctxt, - SRB_FLAG_NO, - rab_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pc5s_header->data_size, - (unsigned char *)receive_buf, - PDCP_TRANSMISSION_MODE_DATA, - &pc5s_header->sourceL2Id, - &pc5s_header->destinationL2Id - ); - } else { - MSC_LOG_RX_DISCARDED_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pc5s_header->inst, - pc5s_header->rb_id, - rab_id, - pc5s_header->data_size); - LOG_D(PDCP, - "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", + if (ctxt.enb_flag) { + ctxt.module_id = 0; + rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB; + ctxt.rnti = pdcp_eNB_UE_instance_to_rnti[pdcp_read_header_g.rb_id / LTE_maxDRB]; + + if (rab_id != 0) { + rab_id = rab_id % LTE_maxDRB; + key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); + + if (h_rc == HASH_TABLE_OK) { + LOG_D(PDCP, "[FRAME %5u][eNB][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", + ctxt.frame, + pdcp_read_header_g.inst, + len, + nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), + pdcp_read_header_g.rb_id); + MSC_LOG_RX_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + rab_id, + pdcp_read_header_g.data_size); + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u]UE %u][RB %u]\n", + ctxt_cpy.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + rab_id); + pdcp_data_req(&ctxt, + SRB_FLAG_NO, + rab_id, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_TRANSMISSION_MODE_DATA + ,NULL, NULL + ); + } else { + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n", + ctxt.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + rab_id); + } + } else { // rb_id =0, thus interpreated as broadcast and transported as multiple unicast + // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs + //#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES + for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) { + if (oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) { + ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id]; + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", ctxt.frame, - pc5s_header->inst, - pc5s_header->rb_id, - pc5s_header->data_size, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, ctxt.module_id, ctxt.rnti, - rab_id, - key); - } - } else { //if (rab_id == 0) - LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", - ctxt.frame, - pc5s_header->inst, - pc5s_header->rb_id, - pc5s_header->data_size, - ctxt.module_id, - ctxt.rnti, - DEFAULT_RAB_ID); - MSC_LOG_RX_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL,0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pc5s_header->inst, - pc5s_header->rb_id, - DEFAULT_RAB_ID, - pc5s_header->data_size); - pdcp_data_req ( - &ctxt, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pc5s_header->data_size, - (unsigned char *)receive_buf, - PDCP_TRANSMISSION_MODE_DATA, - &pc5s_header->sourceL2Id, - &pc5s_header->destinationL2Id - ); - } - } - - free (sl_pc5s_msg_recv); - free (sl_pc5s_msg_send); - } - } - - while ((len > 0) && (rlc_data_req_flag !=0)) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 ); - len = recvmsg(nas_sock_fd[0], &nas_msg_rx, 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); - - if (len<=0) { - // nothing in pdcp NAS socket - //LOG_D(PDCP, "[PDCP][NETLINK] Nothing in socket, length %d \n", len); - } else { - msg_len = len; - - for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf; - NLMSG_OK (nas_nlh_rx, msg_len); - nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, msg_len)) { - if (nas_nlh_rx->nlmsg_type == NLMSG_DONE) { - LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_DONE\n"); - //return; - } - - if (nas_nlh_rx->nlmsg_type == NLMSG_ERROR) { - LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_ERROR\n"); + DEFAULT_RAB_ID); + pdcp_data_req ( + &ctxt, + SRB_FLAG_NO, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_TRANSMISSION_MODE_DATA + ,NULL, NULL + ); + } + } } - - if (pdcp_read_state_g == 0) { - if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) { - pdcp_read_state_g = 1; //get - memcpy((void *)&pdcp_read_header_g, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t)); - LOG_D(PDCP, "[PDCP][NETLINK] RX pdcp_data_req_header_t inst %u, rb_id %u data_size %d, source L2Id 0x%08x, destination L2Id 0x%08x\n", - pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size,pdcp_read_header_g.sourceL2Id, pdcp_read_header_g.destinationL2Id ); - } else { - LOG_E(PDCP, "[PDCP][NETLINK] WRONG size %d should be sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)\n", - nas_nlh_rx->nlmsg_len); - } - } else { - pdcp_read_state_g = 0; - // print_active_requests() - LOG_D(PDCP, "[PDCP][NETLINK] Something in socket, length %zu\n", - nas_nlh_rx->nlmsg_len - sizeof(struct nlmsghdr)); -#ifdef OAI_EMU - - // overwrite function input parameters, because only one netlink socket for all instances - if (pdcp_read_header_g.inst < oai_emulation.info.nb_enb_local) { - ctxt.frame = ctxt_cpy.frame; - ctxt.enb_flag = ENB_FLAG_YES; - ctxt.module_id = pdcp_read_header_g.inst + oai_emulation.info.first_enb_local; - ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id ][pdcp_read_header_g.rb_id / LTE_maxDRB + oai_emulation.info.first_ue_local]; - rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB; - } else { - ctxt.frame = ctxt_cpy.frame; - ctxt.enb_flag = ENB_FLAG_NO; - ctxt.module_id = pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local + oai_emulation.info.first_ue_local; - ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; - rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB; - } - - CHECK_CTXT_ARGS(&ctxt); - AssertFatal (rab_id < LTE_maxDRB, "RB id is too high (%u/%d)!\n", rab_id, LTE_maxDRB); -#else // OAI_EMU - /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */ - // pdcp_read_header_g.inst = 0; - //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id" - ctxt.frame = ctxt_cpy.frame; - ctxt.enb_flag = ctxt_cpy.enb_flag; - LOG_D(PDCP, "[PDCP][NETLINK] pdcp_read_header_g.rb_id = %d, source L2Id = 0x%08x, destination L2Id = 0x%08x \n", pdcp_read_header_g.rb_id, pdcp_read_header_g.sourceL2Id, - pdcp_read_header_g.destinationL2Id); - - if (ctxt_cpy.enb_flag) { - ctxt.module_id = 0; - rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB; - ctxt.rnti = pdcp_eNB_UE_instance_to_rnti[pdcp_read_header_g.rb_id / LTE_maxDRB]; - } else { - if (nfapi_mode == 3) { + } else { // ctxt.enb_flag => UE + if (NFAPI_MODE == NFAPI_UE_STUB_PNF) { #ifdef UESIM_EXPANSION ctxt.module_id = inst_pdcp_list[pdcp_read_header_g.inst]; #else @@ -523,249 +362,336 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t *const ctxt_pP) { rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB; ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; - } - -#endif - if (ctxt.enb_flag) { if (rab_id != 0) { + if (rab_id == UE_IP_DEFAULT_RAB_ID) { + LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); + LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n", + (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); + } else { + rab_id = rab_id % LTE_maxDRB; + LOG_D(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); + h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); + LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n", + (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); + } + + if (h_rc == HASH_TABLE_OK) { + rab_id = pdcp_p->rb_id; + LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", + ctxt.frame, + pdcp_read_header_g.inst, + len, + nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), + pdcp_read_header_g.rb_id); + LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", + ctxt.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + rab_id); + MSC_LOG_RX_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + rab_id, + pdcp_read_header_g.data_size); + pdcp_data_req( + &ctxt, + SRB_FLAG_NO, + rab_id, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_TRANSMISSION_MODE_DATA, + (NFAPI_MODE == NFAPI_UE_STUB_PNF)?NULL:&pdcp_read_header_g.sourceL2Id, + (NFAPI_MODE == NFAPI_UE_STUB_PNF)?NULL:&pdcp_read_header_g.destinationL2Id + ); + } else { /* else of h_rc == HASH_TABLE_OK */ + MSC_LOG_RX_DISCARDED_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + rab_id, + pdcp_read_header_g.data_size); + LOG_D(PDCP, + "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", + ctxt.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + rab_id, + key); + } /* h_rc != HASH_TABLE_OK */ + } else {/* else of rab_id != 0 */ + LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", + ctxt.frame, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + ctxt.module_id, + ctxt.rnti, + DEFAULT_RAB_ID); + MSC_LOG_RX_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL,0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + DEFAULT_RAB_ID, + pdcp_read_header_g.data_size); + pdcp_data_req ( + &ctxt, + SRB_FLAG_NO, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_TRANSMISSION_MODE_DATA, + (NFAPI_MODE == NFAPI_UE_STUB_PNF) ? NULL :&pdcp_read_header_g.sourceL2Id, + (NFAPI_MODE == NFAPI_UE_STUB_PNF) ? NULL :&pdcp_read_header_g.destinationL2Id + ); + } /* rab_id == 0 */ + } /*pdcp_read_state_g != 0 */ + } /* UE */ + } /* for loop on netlink buffers */ + + return len; + } /* len > 0 */ + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 ); + } /* while loop on reading from netlink socket */ + + return 0; +} /* pdcp_fifo_read_input_sdus_fromnetlinksock */ + +void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP) { + protocol_ctxt_t ctxt_cpy = *ctxt_pP; + protocol_ctxt_t ctxt; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_rc; + struct pdcp_netlink_element_s *data_p = NULL; + /* avoid gcc warnings */ + (void)data_p; + pdcp_t *pdcp_p = NULL; + //TTN for D2D (PC5S) + int prose_addr_len; + char send_buf[BUFSIZE], receive_buf[BUFSIZE]; + //int optval; + int bytes_received; + sidelink_pc5s_element *sl_pc5s_msg_send = NULL; + pc5s_header_t *pc5s_header; + rb_id_t rab_id = 0; + //TTN for D2D (PC5S) + // receive a message from ProSe App + memset(receive_buf, 0, BUFSIZE); + bytes_received = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, 0, + (struct sockaddr *) &prose_pdcp_addr, (socklen_t *)&prose_addr_len); + + if (bytes_received > 0) { + pc5s_header = calloc(1, sizeof(pc5s_header_t)); + memcpy((void *)pc5s_header, (void *)receive_buf, sizeof(pc5s_header_t)); + + switch(pc5s_header->traffic_type) { + case TRAFFIC_PC5S_SESSION_INIT : + //send reply to ProSe app + LOG_D(PDCP,"Received a request to open PDCP socket and establish a new PDCP session ... send response to ProSe App \n"); + memset(send_buf, 0, BUFSIZE); + sl_pc5s_msg_send = calloc(1, sizeof(sidelink_pc5s_element)); + sl_pc5s_msg_send->pc5s_header.traffic_type = TRAFFIC_PC5S_SESSION_INIT; + sl_pc5s_msg_send->pc5sPrimitive.status = 1; + memcpy((void *)send_buf, (void *)sl_pc5s_msg_send, sizeof(sidelink_pc5s_element)); + int prose_addr_len = sizeof(prose_pdcp_addr); + int bytes_sent = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_pdcp_addr, prose_addr_len); + free (sl_pc5s_msg_send); + + if (bytes_sent < 0) { + LOG_E(PDCP, "ERROR: Failed to send to ProSe App\n"); + exit(EXIT_FAILURE); + } + + break; + + case TRAFFIC_PC5S_SIGNALLING: /* PC5-S message -> send to other UE */ + if( LOG_DEBUGFLAG(DEBUG_PDCP) ) { + debug_pdcp_pc5s_sdu((sidelink_pc5s_element *)send_buf, + "pdcp_fifo_read_input_sdus received aPC5S message"); + } + + /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */ + // pc5s_header.inst = 0; + //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id" + ctxt.frame = ctxt_cpy.frame; + ctxt.enb_flag = ctxt_cpy.enb_flag; + LOG_I(PDCP, "[PDCP] pc5s_header->rb_id = %d\n", pc5s_header->rb_id); + + if (ctxt_cpy.enb_flag) { + ctxt.module_id = 0; + rab_id = pc5s_header->rb_id % LTE_maxDRB; + ctxt.rnti = pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index]; + } else { + ctxt.module_id = 0; + rab_id = pc5s_header->rb_id % LTE_maxDRB; + ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id]; + } + + //UE + if (!ctxt.enb_flag) { + if (rab_id != 0) { + if (rab_id == UE_IP_DEFAULT_RAB_ID) { + LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); + LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n", + (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); + } else { rab_id = rab_id % LTE_maxDRB; + LOG_I(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); - h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); - - if (h_rc == HASH_TABLE_OK) { - LOG_D(PDCP, "[FRAME %5u][eNB][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", - ctxt.frame, - pdcp_read_header_g.inst, - len, - nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), - pdcp_read_header_g.rb_id); - MSC_LOG_RX_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - rab_id, - pdcp_read_header_g.data_size); - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u]UE %u][RB %u]\n", - ctxt_cpy.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - rab_id); - pdcp_data_req(&ctxt, - SRB_FLAG_NO, - rab_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header_g.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA - ,NULL, NULL - ); - } else { - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n", - ctxt.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - rab_id); - } - } else { // rb_id =0, thus interpreated as broadcast and transported as multiple unicast - // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs - //#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES - for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) { - if (oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) { - ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id]; - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", - ctxt.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - DEFAULT_RAB_ID); - pdcp_data_req ( - &ctxt, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header_g.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA - ,NULL, NULL - ); - } - } - } - } else { // enb_flag - if (rab_id != 0) { - if (rab_id == UE_IP_DEFAULT_RAB_ID) { - LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", - ctxt.module_id, ctxt.rnti, ctxt.enb_flag); - key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); - h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); - LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n", - (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); - } else { - rab_id = rab_id % LTE_maxDRB; - LOG_D(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n", - ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); - key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); - h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); - LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n", - (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); - } - - if (h_rc == HASH_TABLE_OK) { - rab_id = pdcp_p->rb_id; - LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n", - ctxt.frame, - pdcp_read_header_g.inst, - len, - nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), - pdcp_read_header_g.rb_id); - LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", - ctxt.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - rab_id); - MSC_LOG_RX_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - rab_id, - pdcp_read_header_g.data_size); - - if(nfapi_mode == 3) { - pdcp_data_req( - &ctxt, - SRB_FLAG_NO, - rab_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header_g.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA, - NULL, - NULL - ); - } else { - pdcp_data_req( - &ctxt, - SRB_FLAG_NO, - rab_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header_g.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA, - &pdcp_read_header_g.sourceL2Id, - &pdcp_read_header_g.destinationL2Id - ); - } - } else { - MSC_LOG_RX_DISCARDED_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL, - 0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - rab_id, - pdcp_read_header_g.data_size); - LOG_D(PDCP, - "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", - ctxt.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - rab_id, - key); - } - } else { - LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); - LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", - ctxt.frame, - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - pdcp_read_header_g.data_size, - ctxt.module_id, - ctxt.rnti, - DEFAULT_RAB_ID); - MSC_LOG_RX_MESSAGE( - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, - (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, - NULL,0, - MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - pdcp_read_header_g.inst, - pdcp_read_header_g.rb_id, - DEFAULT_RAB_ID, - pdcp_read_header_g.data_size); - - if(nfapi_mode == 3) { - pdcp_data_req ( - &ctxt, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header_g.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA, - NULL, - NULL - ); - } else { - pdcp_data_req ( - &ctxt, - SRB_FLAG_NO, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header_g.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_TRANSMISSION_MODE_DATA, - &pdcp_read_header_g.sourceL2Id, - &pdcp_read_header_g.destinationL2Id - ); - } - } - } + h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); + LOG_I(PDCP,"request key %x : (%d,%x,%d,%d)\n", + (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id); } - } - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 ); - } + if (h_rc == HASH_TABLE_OK) { + rab_id = pdcp_p->rb_id; + LOG_I(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d on Rab %d \n", + ctxt.frame, + pc5s_header->inst, + bytes_received, + pc5s_header->rb_id); + LOG_I(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", + ctxt.frame, + pc5s_header->inst, + pc5s_header->rb_id, + pc5s_header->data_size, + ctxt.module_id, + ctxt.rnti, + rab_id); + MSC_LOG_RX_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pc5s_header->inst, + pc5s_header->rb_id, + rab_id, + pc5s_header->data_size); + pdcp_data_req( + &ctxt, + SRB_FLAG_NO, + rab_id, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pc5s_header->data_size, + (unsigned char *)receive_buf, + PDCP_TRANSMISSION_MODE_DATA, + &pc5s_header->sourceL2Id, + &pc5s_header->destinationL2Id + ); + } else { /* else of h_rc == HASH_TABLE_OK */ + MSC_LOG_RX_DISCARDED_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pc5s_header->inst, + pc5s_header->rb_id, + rab_id, + pc5s_header->data_size); + LOG_D(PDCP, + "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", + ctxt.frame, + pc5s_header->inst, + pc5s_header->rb_id, + pc5s_header->data_size, + ctxt.module_id, + ctxt.rnti, + rab_id, + key); + } + } else { /* else of if (rab_id == 0) */ + LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n", + ctxt.frame, + pc5s_header->inst, + pc5s_header->rb_id, + pc5s_header->data_size, + ctxt.module_id, + ctxt.rnti, + DEFAULT_RAB_ID); + MSC_LOG_RX_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL,0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + pc5s_header->inst, + pc5s_header->rb_id, + DEFAULT_RAB_ID, + pc5s_header->data_size); + pdcp_data_req ( + &ctxt, + SRB_FLAG_NO, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pc5s_header->data_size, + (unsigned char *)receive_buf, + PDCP_TRANSMISSION_MODE_DATA, + &pc5s_header->sourceL2Id, + &pc5s_header->destinationL2Id + ); + } + } /* end of !ctxt.enb_flag */ + + default: + LOG_D(PDCP, "pc5s message type %d, unknown...\n", pc5s_header->traffic_type); + break; + } /* end of switch */ + }/* end of bytes_received > 0 */ +} /* pdcp_fifo_read_input_sdus_frompc5s */ - return len; - } else { /* PDCP_USE_NETLINK */ - return 0; - } // else PDCP_USE_NETLINK - } /* #else UE_NAS_USE_TUN */ +//----------------------------------------------------------------------------- +int pdcp_fifo_read_input_sdus (const protocol_ctxt_t *const ctxt_pP) { + if (UE_NAS_USE_TUN || ENB_NAS_USE_TUN) { + return pdcp_fifo_read_input_sdus_fromtun (ctxt_pP); + } else if (PDCP_USE_NETLINK) { + pdcp_fifo_read_input_sdus_frompc5s (ctxt_pP); + return pdcp_fifo_read_input_sdus_fromnetlinksock(ctxt_pP); + } /* PDCP_USE_NETLINK */ + + return 0; } @@ -790,37 +716,36 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t *const ctxt_pP) } } - //TTN for D2D (PC5S) void pdcp_pc5_socket_init() { - //pthread_attr_t attr; - //struct sched_param sched_param; - int optval; // flag value for setsockopt - //int n; // message byte size - //create PDCP socket - pdcp_pc5_sockfd = socket(AF_INET, SOCK_DGRAM, 0); + //pthread_attr_t attr; + //struct sched_param sched_param; + int optval; // flag value for setsockopt + //int n; // message byte size + //create PDCP socket + pdcp_pc5_sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (pdcp_pc5_sockfd < 0) { - LOG_E(PDCP,"[pdcp_pc5_socket_init] Error opening socket %d (%d:%s)\n",pdcp_pc5_sockfd,errno, strerror(errno)); - exit(EXIT_FAILURE); - } + LOG_E(PDCP,"[pdcp_pc5_socket_init] Error opening socket %d (%d:%s)\n",pdcp_pc5_sockfd,errno, strerror(errno)); + exit(EXIT_FAILURE); + } - optval = 1; - setsockopt(pdcp_pc5_sockfd, SOL_SOCKET, SO_REUSEADDR, + optval = 1; + setsockopt(pdcp_pc5_sockfd, SOL_SOCKET, SO_REUSEADDR, (const void *)&optval, sizeof(int)); - fcntl(pdcp_pc5_sockfd,F_SETFL,O_NONBLOCK); - bzero((char *) &pdcp_sin, sizeof(pdcp_sin)); - pdcp_sin.sin_family = AF_INET; - pdcp_sin.sin_addr.s_addr = htonl(INADDR_ANY); - pdcp_sin.sin_port = htons(PDCP_SOCKET_PORT_NO); - - // associate the parent socket with a port - if (bind(pdcp_pc5_sockfd, (struct sockaddr *) &pdcp_sin, - sizeof(pdcp_sin)) < 0) { - LOG_E(PDCP,"[pdcp_pc5_socket_init] ERROR: Failed on binding the socket\n"); - exit(1); - } + fcntl(pdcp_pc5_sockfd,F_SETFL,O_NONBLOCK); + bzero((char *) &pdcp_sin, sizeof(pdcp_sin)); + pdcp_sin.sin_family = AF_INET; + pdcp_sin.sin_addr.s_addr = htonl(INADDR_ANY); + pdcp_sin.sin_port = htons(PDCP_SOCKET_PORT_NO); + + // associate the parent socket with a port + if (bind(pdcp_pc5_sockfd, (struct sockaddr *) &pdcp_sin, + sizeof(pdcp_sin)) < 0) { + LOG_E(PDCP,"[pdcp_pc5_socket_init] ERROR: Failed on binding the socket\n"); + exit(1); + } } diff --git a/openair2/LAYER2/PROTO_AGENT/proto_agent.c b/openair2/LAYER2/PROTO_AGENT/proto_agent.c index 4b2c0218ead90f205d23cb3482ad57588e64997e..7cc0db24a7604a0e766d6140bab8c7b3b8499a17 100644 --- a/openair2/LAYER2/PROTO_AGENT/proto_agent.c +++ b/openair2/LAYER2/PROTO_AGENT/proto_agent.c @@ -39,7 +39,7 @@ #include "proto_agent.h" #include "assertions.h" #include "proto_agent_net_comm.h" -#include "proto_agent_async.h" +#include "proto_agent_async.h" #include <pthread.h> @@ -49,58 +49,53 @@ proto_agent_instance_t proto_agent[MAX_DU]; pthread_t new_thread(void *(*f)(void *), void *b); -Protocol__FlexsplitMessage *proto_agent_timeout_fsp(void* args); +Protocol__FlexsplitMessage *proto_agent_timeout_fsp(void *args); #define TEST_MOD 0 #define ECHO -/* Server side function; upon a new connection +/* Server side function; upon a new connection reception, sends the hello packets */ -int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p) -{ +int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p) { int channel_id; - // RS: CUDU does not work! //DevAssert(p->local_interface); //DevAssert(p->local_ipv4_address); //DevAssert(p->local_port > 1024); // "unprivileged" port //DevAssert(p->remote_ipv4_address); //DevAssert(p->remote_port > 1024); // "unprivileged" port - proto_agent[mod_id].mod_id = mod_id; proto_agent[mod_id].exit = 0; - /* Initialize the channel container */ - /* TODO only initialize the first time */ proto_agent_init_channel_container(); - /*Create the async channel info*/ proto_agent_async_channel_t *channel_info; channel_info = proto_agent_async_channel_info(mod_id, p->local_ipv4_address, p->local_port, - p->remote_ipv4_address, p->remote_port); + p->remote_ipv4_address, p->remote_port); + if (!channel_info) goto error; - + /* Create a channel using the async channel info */ channel_id = proto_agent_create_channel((void *) channel_info, - proto_agent_async_msg_send, - proto_agent_async_msg_recv, - proto_agent_async_release); + proto_agent_async_msg_send, + proto_agent_async_msg_recv, + proto_agent_async_release); + if (channel_id <= 0) goto error; proto_agent_channel_t *channel = proto_agent_get_channel(channel_id); + if (!channel) goto error; - proto_agent[mod_id].channel = channel; + proto_agent[mod_id].channel = channel; /* Register the channel for all underlying agents (use ENB_AGENT_MAX) */ proto_agent_register_channel(mod_id, channel, ENB_AGENT_MAX); - // Code for sending the HELLO/ECHO_REQ message once a connection is established //uint8_t *msg = NULL; //Protocol__FlexsplitMessage *init_msg=NULL; - //if (udp == 0) //{ // // If the comm is not UDP, allow the server to send the first packet over the channel @@ -112,7 +107,6 @@ int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p) // int msgsize = 0; // if (init_msg != NULL) // msg = proto_agent_pack_message(init_msg, &msgsize); - // if (msg!= NULL) // { // LOG_D(PROTO_AGENT, "Server sending the message over the async channel\n"); @@ -122,23 +116,18 @@ int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p) // the server thread blocks until it reads any data // over the channel // */ - //} - proto_agent[mod_id].recv_thread = new_thread(proto_agent_receive, &proto_agent[mod_id]); - fprintf(stderr, "[PROTO_AGENT] server started at port %s:%d\n", p->local_ipv4_address, p->local_port); return 0; - error: LOG_E(PROTO_AGENT, "there was an error\n"); return 1; - } -void proto_agent_stop(mod_id_t mod_id) -{ +void proto_agent_stop(mod_id_t mod_id) { if (!proto_agent[mod_id].channel) return; + /* unlock the independent read thread proto_agent_receive() */ proto_agent[mod_id].exit = 1; proto_agent_async_msg_recv_unlock(proto_agent[mod_id].channel->channel_info); @@ -171,22 +160,19 @@ void proto_agent_stop(mod_id_t mod_id) //} -void -proto_agent_send_rlc_data_req(const protocol_ctxt_t* const ctxt_pP, - const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_idP, const mui_t muiP, - confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP) -{ + +rlc_op_status_t proto_agent_send_rlc_data_req(const protocol_ctxt_t *const ctxt_pP, + const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, + const rb_id_t rb_idP, const mui_t muiP, + confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP) { uint8_t *msg = NULL; Protocol__FlexsplitMessage *init_msg=NULL; int msg_flag = 0; int msgsize = 0; mod_id_t mod_id = ctxt_pP->module_id; data_req_args args; - DevAssert(proto_agent[mod_id].channel); DevAssert(proto_agent[mod_id].channel->channel_info); - args.ctxt = ctxt_pP; args.srb_flag = srb_flagP; args.MBMS_flag = MBMS_flagP; @@ -195,112 +181,103 @@ proto_agent_send_rlc_data_req(const protocol_ctxt_t* const ctxt_pP, args.confirm = confirmP; args.sdu_size = sdu_sizeP; args.sdu_p = sdu_pP; - msg_flag = proto_agent_pdcp_data_req(mod_id, (void *) &args, &init_msg); + if (msg_flag != 0 || !init_msg) goto error; - + msg = proto_agent_pack_message(init_msg, &msgsize); + if (!msg) goto error; - - proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, proto_agent[mod_id].channel->channel_info); + proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, proto_agent[mod_id].channel->channel_info); free_mem_block(sdu_pP, __func__); - - return; + return 0; error: LOG_E(PROTO_AGENT, "PROTO_AGENT there was an error\n"); - return; - + return -1; } - + void -proto_agent_send_pdcp_data_ind(const protocol_ctxt_t* const ctxt_pP, const srb_flag_t srb_flagP, - const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP) -{ +proto_agent_send_pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, const srb_flag_t srb_flagP, + const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP) { uint8_t *msg = NULL; Protocol__FlexsplitMessage *init_msg = NULL; int msg_flag = 0; int msgsize = 0; mod_id_t mod_id = ctxt_pP->module_id; data_req_args args; - DevAssert(proto_agent[mod_id].channel); DevAssert(proto_agent[mod_id].channel->channel_info); - args.ctxt = ctxt_pP; args.srb_flag = srb_flagP; args.MBMS_flag = MBMS_flagP; args.rb_id = rb_idP; args.sdu_size = sdu_sizeP; args.sdu_p = sdu_pP; - msg_flag = proto_agent_pdcp_data_ind(mod_id, (void *) &args, &init_msg); + if (msg_flag != 0 || !init_msg) goto error; msg = proto_agent_pack_message(init_msg, &msgsize); + if (!msg) goto error; proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, proto_agent[mod_id].channel->channel_info); - free_mem_block(sdu_pP, __func__); - return; - error: LOG_E(PROTO_AGENT, "there was an error in %s\n", __func__); return; - } void * -proto_agent_receive(void *args) -{ +proto_agent_receive(void *args) { proto_agent_instance_t *inst = args; void *data = NULL; int size; int priority; err_code_t err_code; - pthread_setname_np(pthread_self(), "proto_rx"); Protocol__FlexsplitMessage *msg; uint8_t *ser_msg; - + while (1) { - msg = NULL; ser_msg = NULL; - - if ((size = proto_agent_async_msg_recv(&data, &priority, inst->channel->channel_info)) < 0){ + + if ((size = proto_agent_async_msg_recv(&data, &priority, inst->channel->channel_info)) < 0) { err_code = PROTOCOL__FLEXSPLIT_ERR__MSG_ENQUEUING; goto error; } + if (inst->exit) break; LOG_D(PROTO_AGENT, "Server side Received message with size %d and priority %d, calling message handle\n", size, priority); - msg = proto_agent_handle_message(inst->mod_id, data, size); + if (!msg) { LOG_D(PROTO_AGENT, "msg to send back is NULL\n"); continue; } ser_msg = proto_agent_pack_message(msg, &size); + if (!ser_msg) { continue; } - + LOG_D(PROTO_AGENT, "Server sending the reply message over the async channel\n"); - if (proto_agent_async_msg_send((void *)ser_msg, (int) size, 1, inst->channel->channel_info)){ + + if (proto_agent_async_msg_send((void *)ser_msg, (int) size, 1, inst->channel->channel_info)) { err_code = PROTOCOL__FLEXSPLIT_ERR__MSG_ENQUEUING; goto error; } - LOG_D(PROTO_AGENT, "sent message with size %d\n", size); + LOG_D(PROTO_AGENT, "sent message with size %d\n", size); } - - return NULL; + return NULL; error: LOG_E(PROTO_AGENT, "proto_agent_receive(): error %d occured\n",err_code); return NULL; diff --git a/openair2/LAYER2/PROTO_AGENT/proto_agent.h b/openair2/LAYER2/PROTO_AGENT/proto_agent.h index 0c5cd3fa8d2245ca9db9c5651a6e30f26f6b2edd..674bd245e2e01dc2c1086400f457c94ce7a9ff3b 100644 --- a/openair2/LAYER2/PROTO_AGENT/proto_agent.h +++ b/openair2/LAYER2/PROTO_AGENT/proto_agent.h @@ -29,7 +29,7 @@ *******************************************************************************/ /*! \file proto_agent.h - * \brief top level protocol agent + * \brief top level protocol agent * \author Navid Nikaein and Xenofon Foukas * \date 2016 * \version 0.1 @@ -41,18 +41,18 @@ #include "proto_agent_common.h" -void * proto_agent_receive(void *args); +void *proto_agent_receive(void *args); int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p); void proto_agent_stop(mod_id_t mod_id); -void proto_agent_send_rlc_data_req( const protocol_ctxt_t* const ctxt_pP, +rlc_op_status_t proto_agent_send_rlc_data_req( const protocol_ctxt_t *const ctxt_pP, const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, const mui_t muiP, confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP); -void proto_agent_send_pdcp_data_ind(const protocol_ctxt_t* const ctxt_pP, - const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, - const rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP); +void proto_agent_send_pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, + const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP, + const rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP); #endif diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c index 96803652e806aa1dc58114e65bbd2038d6f325d5..7454e253b5fe6bc6787eb39f99457fc344d2a71f 100644 --- a/openair2/LAYER2/RLC/rlc.c +++ b/openair2/LAYER2/RLC/rlc.c @@ -330,8 +330,6 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP, #endif ) { //----------------------------------------------------------------------------- - - mem_block_t *new_sdu_p = NULL; rlc_mode_t rlc_mode = RLC_MODE_NONE; rlc_union_t *rlc_union_p = NULL; @@ -599,34 +597,27 @@ void rlc_data_ind ( rb_idP, sdu_sizeP); rlc_util_print_hex_octets(RLC, (unsigned char *)sdu_pP->data, sdu_sizeP); -#if T_TRACER - if (ctxt_pP->enb_flag) + if (ctxt_pP->enb_flag) { +#if T_TRACER T(T_ENB_RLC_UL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_sizeP)); - #endif + const ngran_node_t type = RC.rrc[ctxt_pP->module_id]->node_type; + AssertFatal(type != ngran_eNB_CU && type != ngran_ng_eNB_CU && type != ngran_gNB_CU, + "Can't be CU, bad node type %d\n", type); + + if (NODE_IS_DU(type) && srb_flagP == 1) { + MessageDef *msg = itti_alloc_new_message(TASK_RLC_ENB, F1AP_UL_RRC_MESSAGE); + F1AP_UL_RRC_MESSAGE(msg).rnti = ctxt_pP->rnti; + F1AP_UL_RRC_MESSAGE(msg).srb_id = rb_idP; + F1AP_UL_RRC_MESSAGE(msg).rrc_container = sdu_pP->data; + F1AP_UL_RRC_MESSAGE(msg).rrc_container_length = sdu_sizeP; + itti_send_msg_to_task(TASK_DU_F1, ENB_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), msg); + return; + } + } // case monolithic eNodeB or UE -#ifndef UETARGET - const ngran_node_t type = RC.rrc[ctxt_pP->module_id]->node_type; - AssertFatal(type != ngran_eNB_CU && type != ngran_ng_eNB_CU && type != ngran_gNB_CU, - "Can't be CU, bad node type %d\n", type); - - if (NODE_IS_DU(type)) { - if (srb_flagP == 1) { - MessageDef *msg = itti_alloc_new_message(TASK_RLC_ENB, F1AP_UL_RRC_MESSAGE); - F1AP_UL_RRC_MESSAGE(msg).rnti = ctxt_pP->rnti; - F1AP_UL_RRC_MESSAGE(msg).srb_id = rb_idP; - F1AP_UL_RRC_MESSAGE(msg).rrc_container = sdu_pP->data; - F1AP_UL_RRC_MESSAGE(msg).rrc_container_length = sdu_sizeP; - itti_send_msg_to_task(TASK_DU_F1, ENB_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), msg); - } else { - proto_agent_send_pdcp_data_ind (ctxt_pP, srb_flagP, MBMS_flagP, rb_idP, sdu_sizeP, sdu_pP); - } - } else -#endif - { // case monolithic eNodeB or UE - pdcp_data_ind(ctxt_pP, srb_flagP, MBMS_flagP, rb_idP, sdu_sizeP, sdu_pP); - } + get_pdcp_data_ind_func()(ctxt_pP, srb_flagP, MBMS_flagP, rb_idP, sdu_sizeP, sdu_pP,NULL,NULL); } //----------------------------------------------------------------------------- void rlc_data_conf (const protocol_ctxt_t *const ctxt_pP, @@ -671,12 +662,12 @@ rlc_module_init (void) { } } - for (k=0; k < RLC_MAX_MBMS_LC; k++) { + for (k=0; k < RLC_MAX_MBMS_LC; k++) { rlc_mbms_lcid2service_session_id_eNB[0][k].service_id = 0; rlc_mbms_lcid2service_session_id_eNB[0][k].session_id = 0; - } + } - for (k=0; k < NB_RB_MBMS_MAX; k++) { + for (k=0; k < NB_RB_MBMS_MAX; k++) { rlc_mbms_rbid2lcid_eNB[0][k] = RLC_LC_UNALLOCATED; } diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c index 8d08b956cf2df5da90f6d5f32e774a2618aa0803..fb2baa951107a96986de5a45e4b08ca45eb0cb5f 100644 --- a/openair2/PHY_INTERFACE/IF_Module.c +++ b/openair2/PHY_INTERFACE/IF_Module.c @@ -4,7 +4,7 @@ #include "LAYER2/MAC/mac_extern.h" #include "LAYER2/MAC/mac_proto.h" #include "common/ran_context.h" - +#include "nfapi/oai_integration/vendor_ext.h" #define MAX_IF_MODULES 100 IF_Module_t *if_inst[MAX_IF_MODULES]; @@ -15,216 +15,194 @@ extern int oai_nfapi_crc_indication(nfapi_crc_indication_t *crc_ind); extern int oai_nfapi_cqi_indication(nfapi_cqi_indication_t *cqi_ind); extern int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind); extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind); -extern uint8_t nfapi_mode; + extern uint16_t sf_ahead; uint16_t frame_cnt=0; void handle_rach(UL_IND_t *UL_info) { int i; if (UL_info->rach_ind.rach_indication_body.number_of_preambles>0) { - AssertFatal(UL_info->rach_ind.rach_indication_body.number_of_preambles==1,"More than 1 preamble not supported\n"); UL_info->rach_ind.rach_indication_body.number_of_preambles=0; LOG_D(MAC,"UL_info[Frame %d, Subframe %d] Calling initiate_ra_proc RACH:SFN/SF:%d\n",UL_info->frame,UL_info->subframe, NFAPI_SFNSF2DEC(UL_info->rach_ind.sfn_sf)); initiate_ra_proc(UL_info->module_id, - UL_info->CC_id, - NFAPI_SFNSF2SFN(UL_info->rach_ind.sfn_sf), - NFAPI_SFNSF2SF(UL_info->rach_ind.sfn_sf), - UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble, - UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance, - UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti + UL_info->CC_id, + NFAPI_SFNSF2SFN(UL_info->rach_ind.sfn_sf), + NFAPI_SFNSF2SF(UL_info->rach_ind.sfn_sf), + UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble, + UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance, + UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0 + ,0 #endif - ); + ); } #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - if (UL_info->rach_ind_br.rach_indication_body.number_of_preambles>0) { + if (UL_info->rach_ind_br.rach_indication_body.number_of_preambles>0) { AssertFatal(UL_info->rach_ind_br.rach_indication_body.number_of_preambles<5,"More than 4 preambles not supported\n"); - for (i=0;i<UL_info->rach_ind_br.rach_indication_body.number_of_preambles;i++) { + + for (i=0; i<UL_info->rach_ind_br.rach_indication_body.number_of_preambles; i++) { AssertFatal(UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type>0, - "Got regular PRACH preamble, not BL/CE\n"); + "Got regular PRACH preamble, not BL/CE\n"); LOG_D(MAC,"Frame %d, Subframe %d Calling initiate_ra_proc (CE_level %d)\n",UL_info->frame,UL_info->subframe, - - UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type-1); + UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type-1); UL_info->rach_ind_br.rach_indication_body.number_of_preambles=0; - initiate_ra_proc(UL_info->module_id, - UL_info->CC_id, - UL_info->frame, - UL_info->subframe, - UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.preamble, - UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.timing_advance, - UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.rnti, - UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type); + UL_info->CC_id, + UL_info->frame, + UL_info->subframe, + UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.preamble, + UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.timing_advance, + UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.rnti, + UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type); } + UL_info->rach_ind_br.rach_indication_body.number_of_preambles=0; } + #endif } void handle_sr(UL_IND_t *UL_info) { - int i; - if (nfapi_mode == 1) // PNF - { - if (UL_info->sr_ind.sr_indication_body.number_of_srs>0) - { + if (NFAPI_MODE == NFAPI_MODE_PNF) { // PNF + if (UL_info->sr_ind.sr_indication_body.number_of_srs>0) { oai_nfapi_sr_indication(&UL_info->sr_ind); } - } - else - { - for (i=0;i<UL_info->sr_ind.sr_indication_body.number_of_srs;i++) + } else { + for (i=0; i<UL_info->sr_ind.sr_indication_body.number_of_srs; i++) SR_indication(UL_info->module_id, - UL_info->CC_id, - UL_info->frame, - UL_info->subframe, - UL_info->sr_ind.sr_indication_body.sr_pdu_list[i].rx_ue_information.rnti, - UL_info->sr_ind.sr_indication_body.sr_pdu_list[i].ul_cqi_information.ul_cqi); + UL_info->CC_id, + UL_info->frame, + UL_info->subframe, + UL_info->sr_ind.sr_indication_body.sr_pdu_list[i].rx_ue_information.rnti, + UL_info->sr_ind.sr_indication_body.sr_pdu_list[i].ul_cqi_information.ul_cqi); } UL_info->sr_ind.sr_indication_body.number_of_srs=0; } void handle_cqi(UL_IND_t *UL_info) { - int i; - if (nfapi_mode == 1) - { - if (UL_info->cqi_ind.number_of_cqis>0) - { + if (NFAPI_MODE==NFAPI_MODE_PNF) { + if (UL_info->cqi_ind.number_of_cqis>0) { LOG_D(PHY,"UL_info->cqi_ind.number_of_cqis:%d\n", UL_info->cqi_ind.number_of_cqis); nfapi_cqi_indication_t ind; - ind.header.message_id = NFAPI_RX_CQI_INDICATION; ind.sfn_sf = UL_info->frame<<4 | UL_info->subframe; ind.cqi_indication_body = UL_info->cqi_ind; - oai_nfapi_cqi_indication(&ind); - UL_info->cqi_ind.number_of_cqis=0; } - } - else - { - for (i=0;i<UL_info->cqi_ind.number_of_cqis;i++) + } else { + for (i=0; i<UL_info->cqi_ind.number_of_cqis; i++) cqi_indication(UL_info->module_id, - UL_info->CC_id, - UL_info->frame, - UL_info->subframe, - UL_info->cqi_ind.cqi_pdu_list[i].rx_ue_information.rnti, - &UL_info->cqi_ind.cqi_pdu_list[i].cqi_indication_rel9, - UL_info->cqi_ind.cqi_raw_pdu_list[i].pdu, - &UL_info->cqi_ind.cqi_pdu_list[i].ul_cqi_information); + UL_info->CC_id, + UL_info->frame, + UL_info->subframe, + UL_info->cqi_ind.cqi_pdu_list[i].rx_ue_information.rnti, + &UL_info->cqi_ind.cqi_pdu_list[i].cqi_indication_rel9, + UL_info->cqi_ind.cqi_raw_pdu_list[i].pdu, + &UL_info->cqi_ind.cqi_pdu_list[i].ul_cqi_information); UL_info->cqi_ind.number_of_cqis=0; } } void handle_harq(UL_IND_t *UL_info) { - int i; - if (nfapi_mode == 1 && UL_info->harq_ind.harq_indication_body.number_of_harqs>0) // PNF - { + if (NFAPI_MODE == NFAPI_MODE_PNF && UL_info->harq_ind.harq_indication_body.number_of_harqs>0) { // PNF //LOG_D(PHY, "UL_info->harq_ind.harq_indication_body.number_of_harqs:%d Send to VNF\n", UL_info->harq_ind.harq_indication_body.number_of_harqs); - int retval = oai_nfapi_harq_indication(&UL_info->harq_ind); - if (retval!=0) - { + if (retval!=0) { LOG_E(PHY, "Failed to encode NFAPI HARQ_IND retval:%d\n", retval); } UL_info->harq_ind.harq_indication_body.number_of_harqs = 0; - } - else - { - for (i=0;i<UL_info->harq_ind.harq_indication_body.number_of_harqs;i++) + } else { + for (i=0; i<UL_info->harq_ind.harq_indication_body.number_of_harqs; i++) harq_indication(UL_info->module_id, - UL_info->CC_id, - NFAPI_SFNSF2SFN(UL_info->harq_ind.sfn_sf), - NFAPI_SFNSF2SF(UL_info->harq_ind.sfn_sf), - &UL_info->harq_ind.harq_indication_body.harq_pdu_list[i]); + UL_info->CC_id, + NFAPI_SFNSF2SFN(UL_info->harq_ind.sfn_sf), + NFAPI_SFNSF2SF(UL_info->harq_ind.sfn_sf), + &UL_info->harq_ind.harq_indication_body.harq_pdu_list[i]); UL_info->harq_ind.harq_indication_body.number_of_harqs=0; } } void handle_ulsch(UL_IND_t *UL_info) { - int i,j; - if(nfapi_mode == 1) - { - if (UL_info->crc_ind.crc_indication_body.number_of_crcs>0) - { + if(NFAPI_MODE == NFAPI_MODE_PNF) { + if (UL_info->crc_ind.crc_indication_body.number_of_crcs>0) { //LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.number_of_crcs:%d CRC_IND:SFN/SF:%d\n", UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf)); - oai_nfapi_crc_indication(&UL_info->crc_ind); - UL_info->crc_ind.crc_indication_body.number_of_crcs = 0; } - if (UL_info->rx_ind.rx_indication_body.number_of_pdus>0) - { + if (UL_info->rx_ind.rx_indication_body.number_of_pdus>0) { //LOG_D(PHY,"UL_info->rx_ind.number_of_pdus:%d RX_IND:SFN/SF:%d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf)); oai_nfapi_rx_ind(&UL_info->rx_ind); UL_info->rx_ind.rx_indication_body.number_of_pdus = 0; } - } - else - { + } else { if (UL_info->rx_ind.rx_indication_body.number_of_pdus>0 && UL_info->crc_ind.crc_indication_body.number_of_crcs>0) { - for (i=0;i<UL_info->rx_ind.rx_indication_body.number_of_pdus;i++) { - for (j=0;j<UL_info->crc_ind.crc_indication_body.number_of_crcs;j++) { + for (i=0; i<UL_info->rx_ind.rx_indication_body.number_of_pdus; i++) { + for (j=0; j<UL_info->crc_ind.crc_indication_body.number_of_crcs; j++) { // find crc_indication j corresponding rx_indication i - LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].rx_ue_information.rnti:%04x UL_info->rx_ind.rx_indication_body.rx_pdu_list[%d].rx_ue_information.rnti:%04x\n", j, UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].rx_ue_information.rnti, i, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti); + LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].rx_ue_information.rnti:%04x UL_info->rx_ind.rx_indication_body.rx_pdu_list[%d].rx_ue_information.rnti:%04x\n", j, + UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].rx_ue_information.rnti, i, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti); + if (UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].rx_ue_information.rnti == UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti) { LOG_D(PHY, "UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].crc_indication_rel8.crc_flag:%d\n", j, UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].crc_indication_rel8.crc_flag); + if (UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].crc_indication_rel8.crc_flag == 1) { // CRC error indication LOG_D(MAC,"Frame %d, Subframe %d Calling rx_sdu (CRC error) \n",UL_info->frame,UL_info->subframe); rx_sdu(UL_info->module_id, - UL_info->CC_id, - NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame, - NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti, - (uint8_t *)NULL, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi); - } - else { + UL_info->CC_id, + NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame, + NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti, + (uint8_t *)NULL, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi); + } else { LOG_D(MAC,"Frame %d, Subframe %d Calling rx_sdu (CRC ok) \n",UL_info->frame,UL_info->subframe); rx_sdu(UL_info->module_id, - UL_info->CC_id, - NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame, - NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].data, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance, - UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi); + UL_info->CC_id, + NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame, + NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].data, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance, + UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi); } + break; } //if (UL_info->crc_ind.crc_pdu_list[j].rx_ue_information.rnti == + // UL_info->rx_ind.rx_pdu_list[i].rx_ue_information.rnti) } // for (j=0;j<UL_info->crc_ind.crc_indication_body.number_of_crcs;j++) } // for (i=0;i<UL_info->rx_ind.number_of_pdus;i++) + UL_info->crc_ind.crc_indication_body.number_of_crcs=0; UL_info->rx_ind.rx_indication_body.number_of_pdus = 0; } // UL_info->rx_ind.rx_indication_body.number_of_pdus>0 && UL_info->subframe && UL_info->crc_ind.crc_indication_body.number_of_crcs>0 else if (UL_info->rx_ind.rx_indication_body.number_of_pdus!=0 || UL_info->crc_ind.crc_indication_body.number_of_crcs!=0) { LOG_E(PHY,"hoping not to have mis-match between CRC ind and RX ind - hopefully the missing message is coming shortly rx_ind:%d(SFN/SF:%05d) crc_ind:%d(SFN/SF:%05d) UL_info(SFN/SF):%04d%d\n", - UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf), - UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf), - UL_info->frame, UL_info->subframe); + UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf), + UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf), + UL_info->frame, UL_info->subframe); } } } @@ -246,257 +224,334 @@ static char s[SMAX]; static int size; static int maxsize = SMAX; -static void put(char x) -{ - if (size == maxsize) { printf("incrase SMAX\n"); exit(1); } +static void put(char x) { + if (size == maxsize) { + printf("incrase SMAX\n"); + exit(1); + } + s[size++] = x; } -static void append_string(char *t) -{ +static void append_string(char *t) { size--; + while (*t) put(*t++); + put(0); } -static void dump_ul(UL_IND_t *u) -{ +static void dump_ul(UL_IND_t *u) { int i; - C; A("XXXX UL mod %d CC %d f.sf %d.%d\n", u->module_id, u->CC_id, u->frame, u->subframe); - A("XXXX harq_ind %d\n", u->harq_ind.harq_indication_body.number_of_harqs); - for (i = 0; i < u->harq_ind.harq_indication_body.number_of_harqs; i++) { - nfapi_harq_indication_pdu_t *v = &u->harq_ind.harq_indication_body.harq_pdu_list[i]; - A("XXXX harq ind %d\n", i); - A("XXXX rnti %d\n", v->rx_ue_information.rnti); - A("XXXX tb1 %d tb2 %d\n", v->harq_indication_fdd_rel8.harq_tb1, - v->harq_indication_fdd_rel8.harq_tb2); - A("XXXX number_of_ack_nack %d\n", - v->harq_indication_fdd_rel9.number_of_ack_nack); - A("XXXX harq[0] = %d\n", - v->harq_indication_fdd_rel9.harq_tb_n[0]); - A("XXXX harq ul_cqi %d channel %d\n", v->ul_cqi_information.ul_cqi, - v->ul_cqi_information.channel); - } - A("XXXX crc_ind %d\n", u->crc_ind.crc_indication_body.number_of_crcs); + for (i = 0; i < u->harq_ind.harq_indication_body.number_of_harqs; i++) { + nfapi_harq_indication_pdu_t *v = &u->harq_ind.harq_indication_body.harq_pdu_list[i]; + A("XXXX harq ind %d\n", i); + A("XXXX rnti %d\n", v->rx_ue_information.rnti); + A("XXXX tb1 %d tb2 %d\n", v->harq_indication_fdd_rel8.harq_tb1, + v->harq_indication_fdd_rel8.harq_tb2); + A("XXXX number_of_ack_nack %d\n", + v->harq_indication_fdd_rel9.number_of_ack_nack); + A("XXXX harq[0] = %d\n", + v->harq_indication_fdd_rel9.harq_tb_n[0]); + A("XXXX harq ul_cqi %d channel %d\n", v->ul_cqi_information.ul_cqi, + v->ul_cqi_information.channel); + } + A("XXXX crc_ind %d\n", u->crc_ind.crc_indication_body.number_of_crcs); A("XXXX sr_ind %d\n", u->sr_ind.sr_indication_body.number_of_srs); - A("XXXX cqi_ind %d\n", u->cqi_ind.number_of_cqis); - for (i = 0; i < u->cqi_ind.number_of_cqis; i++) { - nfapi_cqi_indication_pdu_t *v = &u->cqi_ind.cqi_pdu_list[i]; - A("XXXX cqi ind %d\n", i); - A("XXXX cqi ul_cqi %d channel %d\n", v->ul_cqi_information.ul_cqi, - v->ul_cqi_information.channel); - } - A("XXXX rach_ind %d\n", u->rach_ind.rach_indication_body.number_of_preambles); + for (i = 0; i < u->cqi_ind.number_of_cqis; i++) { + nfapi_cqi_indication_pdu_t *v = &u->cqi_ind.cqi_pdu_list[i]; + A("XXXX cqi ind %d\n", i); + A("XXXX cqi ul_cqi %d channel %d\n", v->ul_cqi_information.ul_cqi, + v->ul_cqi_information.channel); + } + A("XXXX rach_ind %d\n", u->rach_ind.rach_indication_body.number_of_preambles); A("XXXX rx_ind %d\n", u->rx_ind.rx_indication_body.number_of_pdus); - for (i = 0; i < u->rx_ind.rx_indication_body.number_of_pdus; i++) { - nfapi_rx_indication_pdu_t *v = &u->rx_ind.rx_indication_body.rx_pdu_list[i]; - A("XXXX rx ind %d\n", i); - A("XXXX timing_advance %d\n", - v->rx_indication_rel8.timing_advance); - A("XXXX rx ul_cqi %d\n", v->rx_indication_rel8.ul_cqi); - } + + for (i = 0; i < u->rx_ind.rx_indication_body.number_of_pdus; i++) { + nfapi_rx_indication_pdu_t *v = &u->rx_ind.rx_indication_body.rx_pdu_list[i]; + A("XXXX rx ind %d\n", i); + A("XXXX timing_advance %d\n", + v->rx_indication_rel8.timing_advance); + A("XXXX rx ul_cqi %d\n", v->rx_indication_rel8.ul_cqi); + } LOG_I(PHY, "XXXX UL\nXXXX UL\n%s", s); } -static char *DL_PDU_TYPE(int x) -{ +static char *DL_PDU_TYPE(int x) { switch (x) { - case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: return "NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE"; - case NFAPI_DL_CONFIG_BCH_PDU_TYPE: return "NFAPI_DL_CONFIG_BCH_PDU_TYPE"; - case NFAPI_DL_CONFIG_MCH_PDU_TYPE: return "NFAPI_DL_CONFIG_MCH_PDU_TYPE"; - case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: return "NFAPI_DL_CONFIG_DLSCH_PDU_TYPE"; - case NFAPI_DL_CONFIG_PCH_PDU_TYPE: return "NFAPI_DL_CONFIG_PCH_PDU_TYPE"; - case NFAPI_DL_CONFIG_PRS_PDU_TYPE: return "NFAPI_DL_CONFIG_PRS_PDU_TYPE"; - case NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE: return "NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE"; - case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE: return "NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE"; - case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE: return "NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE"; - case NFAPI_DL_CONFIG_NBCH_PDU_TYPE: return "NFAPI_DL_CONFIG_NBCH_PDU_TYPE"; - case NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE: return "NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE"; - case NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE: return "NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE"; + case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: + return "NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE"; + + case NFAPI_DL_CONFIG_BCH_PDU_TYPE: + return "NFAPI_DL_CONFIG_BCH_PDU_TYPE"; + + case NFAPI_DL_CONFIG_MCH_PDU_TYPE: + return "NFAPI_DL_CONFIG_MCH_PDU_TYPE"; + + case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: + return "NFAPI_DL_CONFIG_DLSCH_PDU_TYPE"; + + case NFAPI_DL_CONFIG_PCH_PDU_TYPE: + return "NFAPI_DL_CONFIG_PCH_PDU_TYPE"; + + case NFAPI_DL_CONFIG_PRS_PDU_TYPE: + return "NFAPI_DL_CONFIG_PRS_PDU_TYPE"; + + case NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE: + return "NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE"; + + case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE: + return "NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE"; + + case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE: + return "NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE"; + + case NFAPI_DL_CONFIG_NBCH_PDU_TYPE: + return "NFAPI_DL_CONFIG_NBCH_PDU_TYPE"; + + case NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE: + return "NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE"; + + case NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE: + return "NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE"; } + return "UNKNOWN"; } -static char *UL_PDU_TYPE(int x) -{ +static char *UL_PDU_TYPE(int x) { switch (x) { - case NFAPI_UL_CONFIG_ULSCH_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_PDU_TYPE"; - case NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE"; - case NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE"; - case NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE"; - case NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE"; - case NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE"; - case NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE"; - case NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE"; - case NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE"; - case NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE"; - case NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE"; - case NFAPI_UL_CONFIG_SRS_PDU_TYPE: return "NFAPI_UL_CONFIG_SRS_PDU_TYPE"; - case NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE: return "NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE"; - case NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE"; - case NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE"; - case NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE"; - case NFAPI_UL_CONFIG_NULSCH_PDU_TYPE: return "NFAPI_UL_CONFIG_NULSCH_PDU_TYPE"; - case NFAPI_UL_CONFIG_NRACH_PDU_TYPE: return "NFAPI_UL_CONFIG_NRACH_PDU_TYPE"; + case NFAPI_UL_CONFIG_ULSCH_PDU_TYPE: + return "NFAPI_UL_CONFIG_ULSCH_PDU_TYPE"; + + case NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE: + return "NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE"; + + case NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE: + return "NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE"; + + case NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE: + return "NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE"; + + case NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE: + return "NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE"; + + case NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE: + return "NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE"; + + case NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE: + return "NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE"; + + case NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE: + return "NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE"; + + case NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE: + return "NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE"; + + case NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE: + return "NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE"; + + case NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE: + return "NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE"; + + case NFAPI_UL_CONFIG_SRS_PDU_TYPE: + return "NFAPI_UL_CONFIG_SRS_PDU_TYPE"; + + case NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE: + return "NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE"; + + case NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE: + return "NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE"; + + case NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE: + return "NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE"; + + case NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE: + return "NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE"; + + case NFAPI_UL_CONFIG_NULSCH_PDU_TYPE: + return "NFAPI_UL_CONFIG_NULSCH_PDU_TYPE"; + + case NFAPI_UL_CONFIG_NRACH_PDU_TYPE: + return "NFAPI_UL_CONFIG_NRACH_PDU_TYPE"; } + return "UNKNOWN"; } -static char *HI_DCI0_PDU_TYPE(int x) -{ +static char *HI_DCI0_PDU_TYPE(int x) { switch (x) { - case NFAPI_HI_DCI0_HI_PDU_TYPE: return "NFAPI_HI_DCI0_HI_PDU_TYPE"; - case NFAPI_HI_DCI0_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_DCI_PDU_TYPE"; - case NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE"; - case NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE"; - case NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE"; + case NFAPI_HI_DCI0_HI_PDU_TYPE: + return "NFAPI_HI_DCI0_HI_PDU_TYPE"; + + case NFAPI_HI_DCI0_DCI_PDU_TYPE: + return "NFAPI_HI_DCI0_DCI_PDU_TYPE"; + + case NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE: + return "NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE"; + + case NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE: + return "NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE"; + + case NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE: + return "NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE"; } + return "UNKNOWN"; } -static void dump_dl(Sched_Rsp_t *d) -{ +static void dump_dl(Sched_Rsp_t *d) { int i; - C; A("XXXX DL mod %d CC %d f.sf %d.%d\n", d->module_id, d->CC_id, d->frame, d->subframe); - if (d->DL_req != NULL) { - nfapi_dl_config_request_body_t *v=&d->DL_req->dl_config_request_body; - nfapi_dl_config_request_pdu_t *p = v->dl_config_pdu_list; - A("XXXX DL_req sfnsf %d\n", d->DL_req->sfn_sf); - A("XXXX PDCCH size %d\n", v->number_pdcch_ofdm_symbols); - A("XXXX DCIs %d\n", v->number_dci); - A("XXXX PDUs %d\n", v->number_pdu); - A("XXXX rntis %d\n", v->number_pdsch_rnti); - A("XXXX pcfich power %d\n", v->transmission_power_pcfich); - for (i = 0; i < v->number_pdu; i++) { - A("XXXX pdu %d\n", i); - A("XXXX type %d %s\n", p[i].pdu_type, DL_PDU_TYPE(p[i].pdu_type)); - switch (p[i].pdu_type) { - case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: { - nfapi_dl_config_dci_dl_pdu_rel8_t *q = - &p[i].dci_dl_pdu.dci_dl_pdu_rel8; - A("XXXX dci format %d\n", q->dci_format); - A("XXXX cce idx %d\n", q->cce_idx); - A("XXXX agg lvl %d\n", q->aggregation_level); - A("XXXX rnti %d\n", q->rnti); - A("XXXX rb coding %8.8x\n", q->resource_block_coding); - A("XXXX mcs_1 %d\n", q->mcs_1); - A("XXXX rv_1 %d\n", q->redundancy_version_1); - A("XXXX ndi_1 %d\n", q->new_data_indicator_1); - A("XXXX harq pid %d\n", q->harq_process); - A("XXXX tpc %d\n", q->tpc); - A("XXXX tbs idx %d\n", q->transport_block_size_index); - A("XXXX dl pow off %d\n", q->downlink_power_offset); - A("XXXX rnti type %d\n", q->rnti_type); - A("XXXX xmit pow %d\n", q->transmission_power); - break; - } - case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: { - nfapi_dl_config_dlsch_pdu_rel8_t *q = - &p[i].dlsch_pdu.dlsch_pdu_rel8; - A("XXXX pdu_index %d\n", q->pdu_index); - A("XXXX rnti %d\n", q->rnti); - A("XXXX rv %d\n", q->redundancy_version); - A("XXXX mcs %d\n", q->modulation); - A("XXXX pa %d\n", q->pa); - break; - }} + if (d->DL_req != NULL) { + nfapi_dl_config_request_body_t *v=&d->DL_req->dl_config_request_body; + nfapi_dl_config_request_pdu_t *p = v->dl_config_pdu_list; + A("XXXX DL_req sfnsf %d\n", d->DL_req->sfn_sf); + A("XXXX PDCCH size %d\n", v->number_pdcch_ofdm_symbols); + A("XXXX DCIs %d\n", v->number_dci); + A("XXXX PDUs %d\n", v->number_pdu); + A("XXXX rntis %d\n", v->number_pdsch_rnti); + A("XXXX pcfich power %d\n", v->transmission_power_pcfich); + + for (i = 0; i < v->number_pdu; i++) { + A("XXXX pdu %d\n", i); + A("XXXX type %d %s\n", p[i].pdu_type, DL_PDU_TYPE(p[i].pdu_type)); + + switch (p[i].pdu_type) { + case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: { + nfapi_dl_config_dci_dl_pdu_rel8_t *q = + &p[i].dci_dl_pdu.dci_dl_pdu_rel8; + A("XXXX dci format %d\n", q->dci_format); + A("XXXX cce idx %d\n", q->cce_idx); + A("XXXX agg lvl %d\n", q->aggregation_level); + A("XXXX rnti %d\n", q->rnti); + A("XXXX rb coding %8.8x\n", q->resource_block_coding); + A("XXXX mcs_1 %d\n", q->mcs_1); + A("XXXX rv_1 %d\n", q->redundancy_version_1); + A("XXXX ndi_1 %d\n", q->new_data_indicator_1); + A("XXXX harq pid %d\n", q->harq_process); + A("XXXX tpc %d\n", q->tpc); + A("XXXX tbs idx %d\n", q->transport_block_size_index); + A("XXXX dl pow off %d\n", q->downlink_power_offset); + A("XXXX rnti type %d\n", q->rnti_type); + A("XXXX xmit pow %d\n", q->transmission_power); + break; } - } - if (d->HI_DCI0_req != NULL) { - nfapi_hi_dci0_request_body_t *v=&d->HI_DCI0_req->hi_dci0_request_body; - A("XXXX up HI_DCI0_req sfnsf %d (%d.%d)\n", d->HI_DCI0_req->sfn_sf, - d->HI_DCI0_req->sfn_sf/16, d->HI_DCI0_req->sfn_sf%16); - A("XXXX up sfnsf %d\n", v->sfnsf); - A("XXXX up DCIs %d\n", v->number_of_dci); - A("XXXX up HIs %d\n", v->number_of_hi); - for (i = 0; i < v->number_of_dci + v->number_of_hi; i++) { - nfapi_hi_dci0_request_pdu_t *p = &v->hi_dci0_pdu_list[i]; - A("XXXX up pdu %d\n", i); - A("XXXX up type %d %s\n",p->pdu_type,HI_DCI0_PDU_TYPE(p->pdu_type)); - if (p->pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) { - nfapi_hi_dci0_dci_pdu_rel8_t *q = &p->dci_pdu.dci_pdu_rel8; - A("XXXX up dci_format %d\n", q->dci_format); - A("XXXX up cce_index %d\n", q->cce_index); - A("XXXX up aggregation_level %d\n", q->aggregation_level); - A("XXXX up rnti %d\n", q->rnti); - A("XXXX up rb start %d\n", q->resource_block_start); - A("XXXX up # rb %d\n", q->number_of_resource_block); - A("XXXX up mcs_1 %d\n", q->mcs_1); - A("XXXX up cshift_2_for_drms %d\n", q->cyclic_shift_2_for_drms); - A("XXXX up freq hop enabled %d\n", q->frequency_hopping_enabled_flag); - A("XXXX up fre hop bits %d\n", q->frequency_hopping_bits); - A("XXXX up NDI_1 %d\n", q->new_data_indication_1); - A("XXXX up tx_antenna_seleciton %d\n", q->ue_tx_antenna_seleciton); - A("XXXX up tpc %d\n", q->tpc); - A("XXXX up cqi_csi_request %d\n", q->cqi_csi_request); - A("XXXX up ul_index %d\n", q->ul_index); - A("XXXX up dl_assignment_index %d\n", q->dl_assignment_index); - A("XXXX up tpc_bitmap %d\n", q->tpc_bitmap); - A("XXXX up transmission_power %d\n", q->transmission_power); - } - if (p->pdu_type == NFAPI_HI_DCI0_HI_PDU_TYPE) { - nfapi_hi_dci0_hi_pdu_rel8_t *q = &p->hi_pdu.hi_pdu_rel8; - A("XXXX up rb start %d\n", q->resource_block_start); - A("XXXX up cs2_drms %d\n", q->cyclic_shift_2_for_drms); - A("XXXX up ack %d\n", q->hi_value); - A("XXXX up i_phich %d\n", q->i_phich); - A("XXXX up power %d\n", q->transmission_power); - } + case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: { + nfapi_dl_config_dlsch_pdu_rel8_t *q = + &p[i].dlsch_pdu.dlsch_pdu_rel8; + A("XXXX pdu_index %d\n", q->pdu_index); + A("XXXX rnti %d\n", q->rnti); + A("XXXX rv %d\n", q->redundancy_version); + A("XXXX mcs %d\n", q->modulation); + A("XXXX pa %d\n", q->pa); + break; } } + } + } + + if (d->HI_DCI0_req != NULL) { + nfapi_hi_dci0_request_body_t *v=&d->HI_DCI0_req->hi_dci0_request_body; + A("XXXX up HI_DCI0_req sfnsf %d (%d.%d)\n", d->HI_DCI0_req->sfn_sf, + d->HI_DCI0_req->sfn_sf/16, d->HI_DCI0_req->sfn_sf%16); + A("XXXX up sfnsf %d\n", v->sfnsf); + A("XXXX up DCIs %d\n", v->number_of_dci); + A("XXXX up HIs %d\n", v->number_of_hi); + + for (i = 0; i < v->number_of_dci + v->number_of_hi; i++) { + nfapi_hi_dci0_request_pdu_t *p = &v->hi_dci0_pdu_list[i]; + A("XXXX up pdu %d\n", i); + A("XXXX up type %d %s\n",p->pdu_type,HI_DCI0_PDU_TYPE(p->pdu_type)); + + if (p->pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) { + nfapi_hi_dci0_dci_pdu_rel8_t *q = &p->dci_pdu.dci_pdu_rel8; + A("XXXX up dci_format %d\n", q->dci_format); + A("XXXX up cce_index %d\n", q->cce_index); + A("XXXX up aggregation_level %d\n", q->aggregation_level); + A("XXXX up rnti %d\n", q->rnti); + A("XXXX up rb start %d\n", q->resource_block_start); + A("XXXX up # rb %d\n", q->number_of_resource_block); + A("XXXX up mcs_1 %d\n", q->mcs_1); + A("XXXX up cshift_2_for_drms %d\n", q->cyclic_shift_2_for_drms); + A("XXXX up freq hop enabled %d\n", q->frequency_hopping_enabled_flag); + A("XXXX up fre hop bits %d\n", q->frequency_hopping_bits); + A("XXXX up NDI_1 %d\n", q->new_data_indication_1); + A("XXXX up tx_antenna_seleciton %d\n", q->ue_tx_antenna_seleciton); + A("XXXX up tpc %d\n", q->tpc); + A("XXXX up cqi_csi_request %d\n", q->cqi_csi_request); + A("XXXX up ul_index %d\n", q->ul_index); + A("XXXX up dl_assignment_index %d\n", q->dl_assignment_index); + A("XXXX up tpc_bitmap %d\n", q->tpc_bitmap); + A("XXXX up transmission_power %d\n", q->transmission_power); + } - if (d->UL_req != NULL) { - nfapi_ul_config_request_body_t *v=&d->UL_req->ul_config_request_body; - A("XXXX UL_req sfnsf %d (%d.%d)\n", d->UL_req->sfn_sf, - d->UL_req->sfn_sf/16, d->UL_req->sfn_sf%16); - A("XXXX PDUs %d\n", v->number_of_pdus); - A("XXXX ra freq %d\n", v->rach_prach_frequency_resources); - A("XXXX srs? %d\n", v->srs_present); - for (i = 0; i < v->number_of_pdus; i++) { - nfapi_ul_config_request_pdu_t *p = &v->ul_config_pdu_list[i]; - A("XXXX pdu %d\n", i); - A("XXXX type %d %s\n", p->pdu_type, UL_PDU_TYPE(p->pdu_type)); - switch(p->pdu_type) { - case NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE: { - nfapi_ul_config_uci_harq_pdu *q = &p->uci_harq_pdu; - nfapi_ul_config_harq_information_rel9_fdd_t *h = - &q->harq_information.harq_information_rel9_fdd; - A("XXXX rnti %d\n", - q->ue_information.ue_information_rel8.rnti); - A("XXXX harq size %d\n", h->harq_size); - A("XXXX ack_nack_mode %d\n", h->ack_nack_mode); - A("XXXX # pucch res %d\n", h->number_of_pucch_resources); - A("XXXX n_pucch_1_0 %d\n", h->n_pucch_1_0); - A("XXXX n_pucch_1_1 %d\n", h->n_pucch_1_1); - A("XXXX n_pucch_1_2 %d\n", h->n_pucch_1_2); - A("XXXX n_pucch_1_3 %d\n", h->n_pucch_1_3); - break; - } - case NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE: { - nfapi_ul_config_uci_sr_pdu *q = &p->uci_sr_pdu; - nfapi_ul_config_sr_information_rel8_t *h = - &q->sr_information.sr_information_rel8; - A("XXXX rnti %d\n", - q->ue_information.ue_information_rel8.rnti); - A("XXXX pucch_index %d\n", h->pucch_index); - }} + if (p->pdu_type == NFAPI_HI_DCI0_HI_PDU_TYPE) { + nfapi_hi_dci0_hi_pdu_rel8_t *q = &p->hi_pdu.hi_pdu_rel8; + A("XXXX up rb start %d\n", q->resource_block_start); + A("XXXX up cs2_drms %d\n", q->cyclic_shift_2_for_drms); + A("XXXX up ack %d\n", q->hi_value); + A("XXXX up i_phich %d\n", q->i_phich); + A("XXXX up power %d\n", q->transmission_power); + } + } + } + + if (d->UL_req != NULL) { + nfapi_ul_config_request_body_t *v=&d->UL_req->ul_config_request_body; + A("XXXX UL_req sfnsf %d (%d.%d)\n", d->UL_req->sfn_sf, + d->UL_req->sfn_sf/16, d->UL_req->sfn_sf%16); + A("XXXX PDUs %d\n", v->number_of_pdus); + A("XXXX ra freq %d\n", v->rach_prach_frequency_resources); + A("XXXX srs? %d\n", v->srs_present); + + for (i = 0; i < v->number_of_pdus; i++) { + nfapi_ul_config_request_pdu_t *p = &v->ul_config_pdu_list[i]; + A("XXXX pdu %d\n", i); + A("XXXX type %d %s\n", p->pdu_type, UL_PDU_TYPE(p->pdu_type)); + + switch(p->pdu_type) { + case NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE: { + nfapi_ul_config_uci_harq_pdu *q = &p->uci_harq_pdu; + nfapi_ul_config_harq_information_rel9_fdd_t *h = + &q->harq_information.harq_information_rel9_fdd; + A("XXXX rnti %d\n", + q->ue_information.ue_information_rel8.rnti); + A("XXXX harq size %d\n", h->harq_size); + A("XXXX ack_nack_mode %d\n", h->ack_nack_mode); + A("XXXX # pucch res %d\n", h->number_of_pucch_resources); + A("XXXX n_pucch_1_0 %d\n", h->n_pucch_1_0); + A("XXXX n_pucch_1_1 %d\n", h->n_pucch_1_1); + A("XXXX n_pucch_1_2 %d\n", h->n_pucch_1_2); + A("XXXX n_pucch_1_3 %d\n", h->n_pucch_1_3); + break; + } + + case NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE: { + nfapi_ul_config_uci_sr_pdu *q = &p->uci_sr_pdu; + nfapi_ul_config_sr_information_rel8_t *h = + &q->sr_information.sr_information_rel8; + A("XXXX rnti %d\n", + q->ue_information.ue_information_rel8.rnti); + A("XXXX pucch_index %d\n", h->pucch_index); } } + } + } LOG_I(PHY, "XXXX DL\nXXXX DL\n%s", s); } @@ -510,81 +565,69 @@ static void dump_dl(Sched_Rsp_t *d) /* debug utility functions end */ /****************************************************************************/ -void UL_indication(UL_IND_t *UL_info) -{ - +void UL_indication(UL_IND_t *UL_info) { AssertFatal(UL_info!=NULL,"UL_INFO is null\n"); - #ifdef DUMP_FAPI dump_ul(UL_info); #endif - module_id_t module_id = UL_info->module_id; int CC_id = UL_info->CC_id; Sched_Rsp_t *sched_info = &Sched_INFO[module_id][CC_id]; IF_Module_t *ifi = if_inst[module_id]; eNB_MAC_INST *mac = RC.mac[module_id]; - LOG_D(PHY,"SFN/SF:%d%d module_id:%d CC_id:%d UL_info[rx_ind:%d harqs:%d crcs:%d cqis:%d preambles:%d sr_ind:%d]\n", UL_info->frame,UL_info->subframe, module_id,CC_id, - UL_info->rx_ind.rx_indication_body.number_of_pdus, UL_info->harq_ind.harq_indication_body.number_of_harqs, UL_info->crc_ind.crc_indication_body.number_of_crcs, UL_info->cqi_ind.number_of_cqis, UL_info->rach_ind.rach_indication_body.number_of_preambles, UL_info->sr_ind.sr_indication_body.number_of_srs); - if(UL_info->frame==1023&&UL_info->subframe==6){ // dl scheduling (0,0) - frame_cnt= (frame_cnt + 1)%7; // to prevent frame_cnt get too big - LOG_D(MAC,"current (%d,%d) frame count dl is %d\n",UL_info->frame,UL_info->subframe,frame_cnt); + UL_info->rx_ind.rx_indication_body.number_of_pdus, UL_info->harq_ind.harq_indication_body.number_of_harqs, UL_info->crc_ind.crc_indication_body.number_of_crcs, UL_info->cqi_ind.number_of_cqis, + UL_info->rach_ind.rach_indication_body.number_of_preambles, UL_info->sr_ind.sr_indication_body.number_of_srs); + + if(UL_info->frame==1023&&UL_info->subframe==6) { // dl scheduling (0,0) + frame_cnt= (frame_cnt + 1)%7; // to prevent frame_cnt get too big + LOG_D(MAC,"current (%d,%d) frame count dl is %d\n",UL_info->frame,UL_info->subframe,frame_cnt); } - if (nfapi_mode != 1) - { + if (NFAPI_MODE != NFAPI_MODE_PNF) { if (ifi->CC_mask==0) { ifi->current_frame = UL_info->frame; ifi->current_subframe = UL_info->subframe; - } - else { + } else { AssertFatal(UL_info->frame != ifi->current_frame,"CC_mask %x is not full and frame has changed\n",ifi->CC_mask); AssertFatal(UL_info->subframe != ifi->current_subframe,"CC_mask %x is not full and subframe has changed\n",ifi->CC_mask); } + ifi->CC_mask |= (1<<CC_id); } - // clear DL/UL info for new scheduling round clear_nfapi_information(RC.mac[module_id],CC_id, - UL_info->frame,UL_info->subframe); - + UL_info->frame,UL_info->subframe); handle_rach(UL_info); - handle_sr(UL_info); - handle_cqi(UL_info); - handle_harq(UL_info); - // clear HI prior to handling ULSCH - uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_id] , UL_info->subframe); - if(sf_ahead_dl!=255){ - mac->HI_DCI0_req[CC_id][(UL_info->subframe+sf_ahead_dl)%10].hi_dci0_request_body.number_of_hi = 0; - LOG_D(MAC,"current (%d,%d) clear HI_DCI0_req[0][%d]\n",UL_info->frame,UL_info->subframe,(UL_info->subframe+sf_ahead_dl)%10); + uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_id], UL_info->subframe); + + if(sf_ahead_dl!=255) { + mac->HI_DCI0_req[CC_id][(UL_info->subframe+sf_ahead_dl)%10].hi_dci0_request_body.number_of_hi = 0; + LOG_D(MAC,"current (%d,%d) clear HI_DCI0_req[0][%d]\n",UL_info->frame,UL_info->subframe,(UL_info->subframe+sf_ahead_dl)%10); } - + handle_ulsch(UL_info); - if (nfapi_mode != 1) - { + if (NFAPI_MODE != NFAPI_MODE_PNF) { if (ifi->CC_mask == ((1<<MAX_NUM_CCs)-1)) { - eNB_dlsch_ulsch_scheduler(module_id, - (UL_info->frame+((UL_info->subframe>(9-sf_ahead))?1:0)) % 1024, - (UL_info->subframe+sf_ahead)%10); - + (UL_info->frame+((UL_info->subframe>(9-sf_ahead))?1:0)) % 1024, + (UL_info->subframe+sf_ahead)%10); ifi->CC_mask = 0; - sched_info->module_id = module_id; sched_info->CC_id = CC_id; sched_info->frame = (UL_info->frame + ((UL_info->subframe>(9-sf_ahead)) ? 1 : 0)) % 1024; sched_info->subframe = (UL_info->subframe+sf_ahead)%10; sched_info->DL_req = &mac->DL_req[CC_id]; sched_info->HI_DCI0_req = &mac->HI_DCI0_req[CC_id][sched_info->subframe]; + if ((mac->common_channels[CC_id].tdd_Config==NULL) || (is_UL_sf(&mac->common_channels[CC_id],sched_info->subframe)>0)) sched_info->UL_req = &mac->UL_req[CC_id]; @@ -592,17 +635,15 @@ void UL_indication(UL_IND_t *UL_info) sched_info->UL_req = NULL; sched_info->TX_req = &mac->TX_req[CC_id]; - #ifdef DUMP_FAPI dump_dl(sched_info); #endif - if (ifi->schedule_response) - { + if (ifi->schedule_response) { AssertFatal(ifi->schedule_response!=NULL, - "schedule_response is null (mod %d, cc %d)\n", - module_id, - CC_id); + "schedule_response is null (mod %d, cc %d)\n", + module_id, + CC_id); ifi->schedule_response(sched_info); } @@ -611,28 +652,24 @@ void UL_indication(UL_IND_t *UL_info) } } -IF_Module_t *IF_Module_init(int Mod_id){ - +IF_Module_t *IF_Module_init(int Mod_id) { AssertFatal(Mod_id<MAX_MODULES,"Asking for Module %d > %d\n",Mod_id,MAX_IF_MODULES); - LOG_D(PHY,"Installing callbacks for IF_Module - UL_indication\n"); if (if_inst[Mod_id]==NULL) { - if_inst[Mod_id] = (IF_Module_t*)malloc(sizeof(IF_Module_t)); - memset((void*)if_inst[Mod_id],0,sizeof(IF_Module_t)); - + if_inst[Mod_id] = (IF_Module_t *)malloc(sizeof(IF_Module_t)); + memset((void *)if_inst[Mod_id],0,sizeof(IF_Module_t)); if_inst[Mod_id]->CC_mask=0; if_inst[Mod_id]->UL_indication = UL_indication; - AssertFatal(pthread_mutex_init(&if_inst[Mod_id]->if_mutex,NULL)==0, - "allocation of if_inst[%d]->if_mutex fails\n",Mod_id); + "allocation of if_inst[%d]->if_mutex fails\n",Mod_id); } + return if_inst[Mod_id]; } void IF_Module_kill(int Mod_id) { - AssertFatal(Mod_id>MAX_MODULES,"Asking for Module %d > %d\n",Mod_id,MAX_IF_MODULES); - if (if_inst[Mod_id]!=NULL) free(if_inst[Mod_id]); + if (if_inst[Mod_id]!=NULL) free(if_inst[Mod_id]); } diff --git a/openair2/RRC/LTE/L2_interface_common.c b/openair2/RRC/LTE/L2_interface_common.c index c17318d6018098c7e7e9b624c490b2bc8b99380c..b5cc99bc3a78fa1fba0dfbb1d40ab9d15545f66c 100644 --- a/openair2/RRC/LTE/L2_interface_common.c +++ b/openair2/RRC/LTE/L2_interface_common.c @@ -38,7 +38,7 @@ #include "common/ran_context.h" #if defined(ENABLE_ITTI) -# include "intertask_interface.h" + #include "intertask_interface.h" #endif //#define RRC_DATA_REQ_DEBUG @@ -49,21 +49,21 @@ extern RAN_CONTEXT_t RC; //------------------------------------------------------------------------------ uint8_t rrc_data_req( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const rb_id_t rb_idP, const mui_t muiP, const confirm_t confirmP, const sdu_size_t sdu_sizeP, - uint8_t* const buffer_pP, + uint8_t *const buffer_pP, const pdcp_transmission_mode_t modeP ) //------------------------------------------------------------------------------ { - if(sdu_sizeP == 255) - { + if(sdu_sizeP == 255) { LOG_I(RRC,"sdu_sizeP == 255"); return FALSE; } + MSC_LOG_TX_MESSAGE( ctxt_pP->enb_flag ? MSC_RRC_ENB : MSC_RRC_UE, ctxt_pP->enb_flag ? MSC_PDCP_ENB : MSC_PDCP_UE, @@ -74,71 +74,49 @@ rrc_data_req( ctxt_pP->rnti, muiP, sdu_sizeP); - -#if defined(ENABLE_ITTI) - { - MessageDef *message_p; - // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). - uint8_t *message_buffer; - - message_buffer = itti_malloc ( - ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, - ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, - sdu_sizeP); - - memcpy (message_buffer, buffer_pP, sdu_sizeP); - - message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, RRC_DCCH_DATA_REQ); - RRC_DCCH_DATA_REQ (message_p).frame = ctxt_pP->frame; - RRC_DCCH_DATA_REQ (message_p).enb_flag = ctxt_pP->enb_flag; - RRC_DCCH_DATA_REQ (message_p).rb_id = rb_idP; - RRC_DCCH_DATA_REQ (message_p).muip = muiP; - RRC_DCCH_DATA_REQ (message_p).confirmp = confirmP; - RRC_DCCH_DATA_REQ (message_p).sdu_size = sdu_sizeP; - RRC_DCCH_DATA_REQ (message_p).sdu_p = message_buffer; - //memcpy (RRC_DCCH_DATA_REQ (message_p).sdu_p, buffer_pP, sdu_sizeP); - - RRC_DCCH_DATA_REQ (message_p).mode = modeP; - RRC_DCCH_DATA_REQ (message_p).module_id = ctxt_pP->module_id; - RRC_DCCH_DATA_REQ (message_p).rnti = ctxt_pP->rnti; - RRC_DCCH_DATA_REQ (message_p).eNB_index = ctxt_pP->eNB_index; - - itti_send_msg_to_task ( - ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, - ctxt_pP->instance, - message_p); - LOG_I(RRC,"sent RRC_DCCH_DATA_REQ to TASK_PDCP_ENB\n"); -#ifndef UETARGET - /* Hack: only trigger PDCP if in CU, otherwise it is triggered by RU threads - * Ideally, PDCP would not neet to be triggered like this but react to ITTI - * messages automatically */ - if (NODE_IS_CU(RC.rrc[ctxt_pP->module_id]->node_type)) - pdcp_run(ctxt_pP); -#endif - - return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway. - - } -#else - return pdcp_data_req ( - ctxt_pP, - SRB_FLAG_YES, - rb_idP, - muiP, - confirmP, - sdu_sizeP, - buffer_pP, - modeP); -#endif + MessageDef *message_p; + // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). + uint8_t *message_buffer; + message_buffer = itti_malloc ( + ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, + ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, + sdu_sizeP); + memcpy (message_buffer, buffer_pP, sdu_sizeP); + message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, RRC_DCCH_DATA_REQ); + RRC_DCCH_DATA_REQ (message_p).frame = ctxt_pP->frame; + RRC_DCCH_DATA_REQ (message_p).enb_flag = ctxt_pP->enb_flag; + RRC_DCCH_DATA_REQ (message_p).rb_id = rb_idP; + RRC_DCCH_DATA_REQ (message_p).muip = muiP; + RRC_DCCH_DATA_REQ (message_p).confirmp = confirmP; + RRC_DCCH_DATA_REQ (message_p).sdu_size = sdu_sizeP; + RRC_DCCH_DATA_REQ (message_p).sdu_p = message_buffer; + //memcpy (RRC_DCCH_DATA_REQ (message_p).sdu_p, buffer_pP, sdu_sizeP); + RRC_DCCH_DATA_REQ (message_p).mode = modeP; + RRC_DCCH_DATA_REQ (message_p).module_id = ctxt_pP->module_id; + RRC_DCCH_DATA_REQ (message_p).rnti = ctxt_pP->rnti; + RRC_DCCH_DATA_REQ (message_p).eNB_index = ctxt_pP->eNB_index; + itti_send_msg_to_task ( + ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, + ctxt_pP->instance, + message_p); + LOG_I(RRC,"sent RRC_DCCH_DATA_REQ to TASK_PDCP_ENB\n"); + + /* Hack: only trigger PDCP if in CU, otherwise it is triggered by RU threads + * Ideally, PDCP would not neet to be triggered like this but react to ITTI + * messages automatically */ + if (ctxt_pP->enb_flag && NODE_IS_CU(RC.rrc[ctxt_pP->module_id]->node_type)) + pdcp_run(ctxt_pP); + + return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway. } //------------------------------------------------------------------------------ void rrc_data_ind( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const rb_id_t Srb_id, const sdu_size_t sdu_sizeP, - const uint8_t* const buffer_pP + const uint8_t *const buffer_pP ) //------------------------------------------------------------------------------ { @@ -162,10 +140,8 @@ rrc_data_ind( MessageDef *message_p; // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). uint8_t *message_buffer; - message_buffer = itti_malloc (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, sdu_sizeP); memcpy (message_buffer, buffer_pP, sdu_sizeP); - message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, RRC_DCCH_DATA_IND); RRC_DCCH_DATA_IND (message_p).frame = ctxt_pP->frame; RRC_DCCH_DATA_IND (message_p).dcch_index = DCCH_index; @@ -174,16 +150,13 @@ rrc_data_ind( RRC_DCCH_DATA_IND (message_p).rnti = ctxt_pP->rnti; RRC_DCCH_DATA_IND (message_p).module_id = ctxt_pP->module_id; RRC_DCCH_DATA_IND (message_p).eNB_index = ctxt_pP->eNB_index; - itti_send_msg_to_task (ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, ctxt_pP->instance, message_p); } #else - - rrc_eNB_decode_dcch( - ctxt_pP, - DCCH_index, - buffer_pP, - sdu_sizeP); - + rrc_eNB_decode_dcch( + ctxt_pP, + DCCH_index, + buffer_pP, + sdu_sizeP); #endif } diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index a00bc5375928859fc566afda17f261142729bb47..4b7e76524170bbdd14acf1420747cfbbcf69e6b5 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -801,42 +801,33 @@ rrc_ue_establish_drb( (void)ip_addr_offset4; LOG_I(RRC,"[UE %d] Frame %d: processing RRCConnectionReconfiguration: reconfiguring DRB %ld/LCID %d\n", ue_mod_idP, frameP, DRB_config->drb_Identity, (int)*DRB_config->logicalChannelIdentity); - /* - rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD, - (eNB_index * NB_RB_MAX) + *DRB_config->logicalChannelIdentity, UNDEF_SECURITY_MODE); - rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD, - (eNB_index * NB_RB_MAX) + *DRB_config->logicalChannelIdentity, - RADIO_ACCESS_BEARER,Rlc_info_um); - */ - // if(!EPC_MODE_ENABLED) { - //# if !defined(OAI_NW_DRIVER_TYPE_ETHERNET) && !defined(EXMIMO) && !defined(OAI_USRP) && !defined(OAI_BLADERF) && !defined(ETHERNET) && !defined(LINK_ENB_PDCP_TO_GTPV1U) - ip_addr_offset3 = 0; - ip_addr_offset4 = 1; - LOG_I(OIP,"[UE %d] trying to bring up the OAI interface oip%d, IP 10.0.%d.%d\n", ue_mod_idP, ip_addr_offset3+ue_mod_idP, - ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1); - oip_ifup=nas_config(ip_addr_offset3+ue_mod_idP+1, // interface_id - ip_addr_offset3+ue_mod_idP+1, // third_octet - ip_addr_offset4+ue_mod_idP+1, // fourth_octet - "oip"); // interface suffix - - if (oip_ifup == 0 && (!UE_NAS_USE_TUN)) { // interface is up --> send a config the DRB - LOG_I(OIP,"[UE %d] Config the ue net interface %d to send/receive pkt on DRB %ld to/from the protocol stack\n", - ue_mod_idP, - ip_addr_offset3+ue_mod_idP, - (long int)((eNB_index * LTE_maxDRB) + DRB_config->drb_Identity)); - rb_conf_ipv4(0,//add - ue_mod_idP,//cx align with the UE index - ip_addr_offset3+ue_mod_idP,//inst num_enb+ue_index - (eNB_index * LTE_maxDRB) + DRB_config->drb_Identity,//rb - 0,//dscp - ipv4_address(ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1),//saddr - ipv4_address(ip_addr_offset3+ue_mod_idP+1,eNB_index+1));//daddr - LOG_D(RRC,"[UE %d] State = Attached (eNB %d)\n",ue_mod_idP,eNB_index); - } + if(!EPC_MODE_ENABLED) { + ip_addr_offset3 = 0; + ip_addr_offset4 = 1; + LOG_I(OIP,"[UE %d] trying to bring up the OAI interface %d, IP X.Y.%d.%d\n", ue_mod_idP, ip_addr_offset3+ue_mod_idP, + ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1); + oip_ifup=nas_config(ip_addr_offset3+ue_mod_idP+1, // interface_id + UE_NAS_USE_TUN?1:(ip_addr_offset3+ue_mod_idP+1), // third_octet + ip_addr_offset4+ue_mod_idP+1, // fourth_octet + "oip"); // interface suffix (when using kernel module) + + if (oip_ifup == 0 && (!UE_NAS_USE_TUN)) { // interface is up --> send a config the DRB + LOG_I(OIP,"[UE %d] Config the ue net interface %d to send/receive pkt on DRB %ld to/from the protocol stack\n", + ue_mod_idP, + ip_addr_offset3+ue_mod_idP, + (long int)((eNB_index * LTE_maxDRB) + DRB_config->drb_Identity)); + rb_conf_ipv4(0,//add + ue_mod_idP,//cx align with the UE index + ip_addr_offset3+ue_mod_idP,//inst num_enb+ue_index + (eNB_index * LTE_maxDRB) + DRB_config->drb_Identity,//rb + 0,//dscp + ipv4_address(ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1),//saddr + ipv4_address(ip_addr_offset3+ue_mod_idP+1,eNB_index+1));//daddr + LOG_D(RRC,"[UE %d] State = Attached (eNB %d)\n",ue_mod_idP,eNB_index); + } + } // !EPC_MODE_ENABLED - //# endif - // } return(0); } @@ -2656,11 +2647,6 @@ int decode_BCCH_DLSCH_Message( } } - // if ((rrc_get_sub_state(ctxt_pP->module_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) - //#if defined(ENABLE_USE_MME) - // && (UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data != NULL) - //#endif - // ) { if (rrc_get_sub_state(ctxt_pP->module_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) { if ( (UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data != NULL) || (!EPC_MODE_ENABLED)) { rrc_ue_generate_RRCConnectionRequest(ctxt_pP, 0); diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index 61909df5ec4c744be1684a88347181188aa20eb5..240ea06f473105bb2f22844f5ad2ae3278144c4a 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -236,8 +236,8 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifname) char broadcastAddress[20]; char interfaceName[20]; int returnValue; - sprintf(ipAddress, "10.0.%d.%d", thirdOctet,fourthOctet); - sprintf(broadcastAddress, "10.0.%d.255", thirdOctet); + sprintf(ipAddress, "%s.%d.%d", baseNetAddress,thirdOctet,fourthOctet); + sprintf(broadcastAddress, "%s.%d.255",baseNetAddress, thirdOctet); sprintf(interfaceName, "%s%s%d", (UE_NAS_USE_TUN || ENB_NAS_USE_TUN)?"oaitun_":ifname, UE_NAS_USE_TUN?"ue": (ENB_NAS_USE_TUN?"enb":""),interface_id); bringInterfaceUp(interfaceName, 0); diff --git a/openair3/NAS/UE/ESM/esm_ebr_context.c b/openair3/NAS/UE/ESM/esm_ebr_context.c index 5830518df0f8b8bfd40b2ba9a3d846d326109b14..cd493dd09e54466cf784b0ec675eac917dc5e68e 100644 --- a/openair3/NAS/UE/ESM/esm_ebr_context.c +++ b/openair3/NAS/UE/ESM/esm_ebr_context.c @@ -50,7 +50,7 @@ Description Defines functions used to handle EPS bearer contexts. #include "system.h" #include "assertions.h" #include "pdcp.h" - +#include "nfapi/oai_integration/vendor_ext.h" #include <sys/socket.h> #include <netinet/in.h> @@ -59,7 +59,6 @@ Description Defines functions used to handle EPS bearer contexts. #include "openairinterface5g_limits.h" extern uint16_t inst_pdcp_list[NUMBER_OF_UE_MAX]; #endif -extern uint8_t nfapi_mode; /****************************************************************************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/ @@ -268,7 +267,7 @@ int esm_ebr_context_create( strcpy(broadcast, ipv4_addr); } - if(nfapi_mode ==3) { + if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { // this is for L2 FAPI simulator. // change for multiple UE's like 256UEs. // if it's made too many tables , OS may crush so we use one table. diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index bcc9e8cfc50f81ad5f4148bc96dbeec471803703..8ae3d8956c9f7154b45cc1cb9dc7772313d93026 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -48,7 +48,7 @@ #include "PHY/defs_eNB.h" #include "SCHED/sched_eNB.h" #include "PHY/LTE_TRANSPORT/transport_proto.h" - +#include "nfapi/oai_integration/vendor_ext.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 @@ -139,7 +139,7 @@ void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); #endif -extern uint8_t nfapi_mode; + extern void oai_subframe_ind(uint16_t sfn, uint16_t sf); extern void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset); @@ -160,7 +160,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, char *thread_name return -1; } - if (nfapi_mode == 1) { + if (NFAPI_MODE==NFAPI_MODE_PNF) { // I am a PNF and I need to let nFAPI know that we have a (sub)frame tick uint16_t frame = proc->frame_rx; uint16_t subframe = proc->subframe_rx; @@ -188,7 +188,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, char *thread_name } } - if (nfapi_mode == 1 && eNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols == 0) { + if (NFAPI_MODE==NFAPI_MODE_PNF && eNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols == 0) { LOG_E(PHY, "eNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols == 0"); return 0; } @@ -208,14 +208,14 @@ static inline int rxtx(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, char *thread_name release_UE_in_freeList(eNB->Mod_id); // UE-specific RX processing for subframe n - if (nfapi_mode == 0 || nfapi_mode == 1) { + if (NFAPI_MODE==NFAPI_MONOLITHIC || NFAPI_MODE==NFAPI_MODE_PNF) { phy_procedures_eNB_uespec_RX(eNB, proc); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER, 1 ); #if defined(PRE_SCD_THREAD) - if (nfapi_mode == 2) { + if (NFAPI_MODE==NFAPI_MODE_VNF) { new_dlsch_ue_select_tbl_in_use = dlsch_ue_select_tbl_in_use; dlsch_ue_select_tbl_in_use = !dlsch_ue_select_tbl_in_use; // L2-emulator can work only one eNB. @@ -365,7 +365,7 @@ static void *L1_thread( void *param ) { L1_rxtx_proc_t *proc; // Working - if(nfapi_mode ==2) { + if(NFAPI_MODE==NFAPI_MODE_VNF) { proc = (L1_rxtx_proc_t *)param; } else { L1_proc_t *eNB_proc = (L1_proc_t *)param; @@ -406,7 +406,7 @@ static void *L1_thread( void *param ) { if (release_thread(&proc->mutex,&proc->instance_cnt,thread_name)<0) break; - if (nfapi_mode!=2) { + if (NFAPI_MODE!=NFAPI_MODE_VNF) { if(get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) wakeup_tx(eNB); else if(get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT) wakeup_txfh(proc,eNB); } @@ -908,10 +908,10 @@ void init_eNB_proc(int inst) { LOG_I(PHY,"eNB->single_thread_flag:%d\n", eNB->single_thread_flag); - if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && nfapi_mode!=2) { + if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && NFAPI_MODE!=NFAPI_MODE_VNF) { pthread_create( &L1_proc->pthread, attr0, L1_thread, proc ); pthread_create( &L1_proc_tx->pthread, attr1, L1_thread_tx, proc); - } else if (nfapi_mode == 2) { // this is neccesary in VNF or L2 FAPI simulator. + } else if (NFAPI_MODE==NFAPI_MODE_VNF) { // this is neccesary in VNF or L2 FAPI simulator. // Original Code from Fujitsu w/ old structure/field name //pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, &proc_rxtx[0] ); //pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, eNB_thread_rxtx, &proc_rxtx[1] ); @@ -974,7 +974,7 @@ void kill_eNB_proc(int inst) { LOG_I(PHY, "Killing TX CC_id %d inst %d\n", CC_id, inst ); - if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && nfapi_mode!=2) { + if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && NFAPI_MODE!=NFAPI_MODE_VNF) { pthread_mutex_lock(&L1_proc->mutex); L1_proc->instance_cnt = 0; pthread_cond_signal(&L1_proc->cond); @@ -1006,7 +1006,7 @@ void kill_eNB_proc(int inst) { LOG_I(PHY, "Destroying UL_INFO mutex\n"); pthread_mutex_destroy(&eNB->UL_INFO_mutex); - if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && nfapi_mode!=2) { + if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && NFAPI_MODE!=NFAPI_MODE_VNF) { LOG_I(PHY, "Joining L1_proc mutex/cond\n"); pthread_join( L1_proc->pthread, (void **)&status ); LOG_I(PHY, "Joining L1_proc_tx mutex/cond\n"); diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index d4c53441d64bf267f303eadf24bff417485abf3c..93a2440b9453cd43ebd4b371a9a521ff25ee246a 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -75,6 +75,7 @@ #include "PHY_INTERFACE/phy_interface.h" #include "common/utils/LOG/log.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "UTIL/OTG/otg_tx.h" #include "UTIL/OTG/otg_externs.h" #include "UTIL/MATH/oml.h" @@ -109,7 +110,7 @@ extern int emulate_rf; extern int numerology; extern clock_source_t clock_source; extern uint8_t dlsch_ue_select_tbl_in_use; -extern uint8_t nfapi_mode; + extern PARALLEL_CONF_t get_thread_parallel_conf(void); extern WORKER_CONF_t get_thread_worker_conf(void); @@ -1869,7 +1870,7 @@ void *pre_scd_thread( void *param ) { RU_t *ru = (RU_t *)param; // L2-emulator can work only one eNB - if( nfapi_mode == 2) + if( NFAPI_MODE==NFAPI_MODE_VNF) Mod_id = 0; else Mod_id = ru->eNB_list[0]->Mod_id; diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index aa8d832ed3e97f97e51c2e8bc89a0d51c359b030..fbfcf9020b1ed26b97fc89d5e181b26b6e75b544 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -64,7 +64,7 @@ #include "LAYER2/MAC/mac_proto.h" #include "RRC/LTE/rrc_vars.h" #include "PHY_INTERFACE/phy_interface_vars.h" - +#include "nfapi/oai_integration/vendor_ext.h" #ifdef SMBV #include "PHY/TOOLS/smbv.h" unsigned short config_frames[4] = {2,9,11,13}; @@ -112,7 +112,6 @@ pthread_cond_t nfapi_sync_cond; pthread_mutex_t nfapi_sync_mutex; int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex -uint8_t nfapi_mode = 0; // Default to monolithic mode uint16_t sf_ahead=4; @@ -133,7 +132,7 @@ int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; int UE_scan = 1; int UE_scan_carrier = 0; runmode_t mode = normal_txrx; -int simL1flag; + FILE *input_fd=NULL; @@ -657,21 +656,22 @@ int main( int argc, char **argv ) { /* Read configuration */ if (RC.nb_inst > 0) read_config_and_init(); - + /* Start the agent. If it is turned off in the configuration, it won't start */ RCconfig_flexran(); + for (i = 0; i < RC.nb_inst; i++) { flexran_agent_start(i); } uint32_t pdcp_initmask = ( IS_SOFTMODEM_NOS1 )? ( PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT; + if ( IS_SOFTMODEM_NOS1) pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT ; pdcp_module_init(pdcp_initmask); if (RC.nb_inst > 0) { - if (create_tasks(1) < 0) { printf("cannot create ITTI tasks\n"); exit(-1); @@ -682,8 +682,7 @@ int main( int argc, char **argv ) { RRC_CONFIGURATION_REQ(msg_p) = RC.rrc[enb_id]->configuration; itti_send_msg_to_task (TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); } - } - else { + } else { printf("No ITTI, Initializing L1\n"); RCconfig_L1(); } @@ -705,7 +704,6 @@ int main( int argc, char **argv ) { mlockall(MCL_CURRENT | MCL_FUTURE); pthread_cond_init(&sync_cond,NULL); pthread_mutex_init(&sync_mutex, NULL); - #ifdef XFORMS int UE_id; printf("XFORMS\n"); @@ -740,46 +738,24 @@ int main( int argc, char **argv ) { printf("Scope thread created, ret=%d\n",ret); } + #endif - rt_sleep_ns(10*100000000ULL); - if (nfapi_mode) { - LOG_I(ENB_APP,"NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n"); + if (NFAPI_MODE!=NFAPI_MONOLITHIC) { + LOG_I(ENB_APP,"NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n"); pthread_cond_init(&sync_cond,NULL); pthread_mutex_init(&sync_mutex, NULL); } - const char *nfapi_mode_str = "<UNKNOWN>"; - - switch(nfapi_mode) { - case 0: - nfapi_mode_str = "MONOLITHIC"; - break; - - case 1: - nfapi_mode_str = "PNF"; - break; - - case 2: - nfapi_mode_str = "VNF"; - break; - - default: - nfapi_mode_str = "<UNKNOWN NFAPI MODE>"; - break; - } - - LOG_I(ENB_APP,"NFAPI MODE:%s\n", nfapi_mode_str); - - if (nfapi_mode==2) {// VNF + if (NFAPI_MODE==NFAPI_MODE_VNF) {// VNF #if defined(PRE_SCD_THREAD) init_ru_vnf(); // ru pointer is necessary for pre_scd. #endif wait_nfapi_init("main?"); } - LOG_I(ENB_APP,"START MAIN THREADS\n"); + LOG_I(ENB_APP,"START MAIN THREADS\n"); // start the main threads number_of_cards = 1; printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst); @@ -798,11 +774,11 @@ int main( int argc, char **argv ) { // RU thread and some L1 procedure aren't necessary in VNF or L2 FAPI simulator. // but RU thread deals with pre_scd and this is necessary in VNF and simulator. // some initialization is necessary and init_ru_vnf do this. - if (RC.nb_RU >0 && nfapi_mode != 2) { + if (RC.nb_RU >0 && NFAPI_MODE!=NFAPI_MODE_VNF) { printf("Initializing RU threads\n"); init_RU(get_softmodem_params()->rf_config_file); - for (ru_id=0; ru_id<RC.nb_RU; ru_id++) { + for (ru_id=0; ru_id<RC.nb_RU; ru_id++) { RC.ru[ru_id]->rf_map.card=0; RC.ru[ru_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); } @@ -810,7 +786,7 @@ int main( int argc, char **argv ) { config_sync_var=0; - if (nfapi_mode==1) { // PNF + if (NFAPI_MODE==NFAPI_MODE_PNF) { // PNF wait_nfapi_init("main?"); } @@ -818,21 +794,21 @@ int main( int argc, char **argv ) { fflush(stdout); fflush(stderr); wait_RUs(); - LOG_I(ENB_APP,"RC.nb_RU:%d\n", RC.nb_RU); + LOG_I(ENB_APP,"RC.nb_RU:%d\n", RC.nb_RU); // once all RUs are ready intiailize the rest of the eNBs ((dependence on final RU parameters after configuration) printf("ALL RUs ready - init eNBs\n"); - if (nfapi_mode != 1 && nfapi_mode != 2) { - LOG_I(ENB_APP,"Not NFAPI mode - call init_eNB_afterRU()\n"); + if (NFAPI_MODE!=NFAPI_MODE_PNF && NFAPI_MODE!=NFAPI_MODE_VNF) { + LOG_I(ENB_APP,"Not NFAPI mode - call init_eNB_afterRU()\n"); init_eNB_afterRU(); } else { - LOG_I(ENB_APP,"NFAPI mode - DO NOT call init_eNB_afterRU()\n"); + LOG_I(ENB_APP,"NFAPI mode - DO NOT call init_eNB_afterRU()\n"); } - LOG_UI(ENB_APP,"ALL RUs ready - ALL eNBs ready\n"); + LOG_UI(ENB_APP,"ALL RUs ready - ALL eNBs ready\n"); // connect the TX/RX buffers sleep(1); /* wait for thread activation */ - LOG_I(ENB_APP,"Sending sync to all threads\n"); + LOG_I(ENB_APP,"Sending sync to all threads\n"); pthread_mutex_lock(&sync_mutex); sync_var=0; pthread_cond_broadcast(&sync_cond); @@ -848,7 +824,6 @@ int main( int argc, char **argv ) { LOG_I(ENB_APP,"oai_exit=%d\n",oai_exit); // stop threads - if (RC.nb_inst == 0 || !NODE_IS_CU(RC.rrc[0]->node_type)) { int UE_id; #ifdef XFORMS @@ -868,11 +843,12 @@ int main( int argc, char **argv ) { } } } -#endif +#endif LOG_I(ENB_APP,"stopping MODEM threads\n"); stop_eNB(NB_eNB_INST); stop_RU(RC.nb_RU); + /* release memory used by the RU/eNB threads (incomplete), after all * threads have been stopped (they partially use the same memory) */ for (int inst = 0; inst < NB_eNB_INST; inst++) { @@ -881,9 +857,11 @@ int main( int argc, char **argv ) { phy_free_lte_eNB(RC.eNB[inst][cc_id]); } } + for (int inst = 0; inst < RC.nb_RU; inst++) { phy_free_RU(RC.ru[inst]); } + free_lte_top(); end_configmodule(); pthread_cond_destroy(&sync_cond); @@ -891,12 +869,13 @@ int main( int argc, char **argv ) { pthread_cond_destroy(&nfapi_sync_cond); pthread_mutex_destroy(&nfapi_sync_mutex); pthread_mutex_destroy(&ue_pf_po_mutex); - + for(ru_id=0; ru_id<RC.nb_RU; ru_id++) { if (RC.ru[ru_id]->rfdevice.trx_end_func) { RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); RC.ru[ru_id]->rfdevice.trx_end_func = NULL; } + if (RC.ru[ru_id]->ifdevice.trx_end_func) { RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); RC.ru[ru_id]->ifdevice.trx_end_func = NULL; diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 9b820e6e19e1f95f9f4ca199a2122af5ad149610..2d05ca174e70c12ca2fdeea34f224e49bec27810 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -243,6 +243,7 @@ #define SOFTMODEM_NONBIOT_BIT (1<<2) #define SOFTMODEM_RFSIM_BIT (1<<10) #define SOFTMODEM_BASICSIM_BIT (1<<11) +#define SOFTMODEM_SIML1_BIT (1<<12) typedef struct { uint64_t optmask; THREAD_STRUCT thread_struct; @@ -265,6 +266,7 @@ typedef struct { #define IS_SOFTMODEM_NONBIOT ( get_softmodem_optmask() & SOFTMODEM_NONBIOT_BIT) #define IS_SOFTMODEM_RFSIM ( get_softmodem_optmask() & SOFTMODEM_RFSIM_BIT) #define IS_SOFTMODEM_BASICSIM ( get_softmodem_optmask() & SOFTMODEM_BASICSIM_BIT) +#define IS_SOFTMODEM_SIML1 ( get_softmodem_optmask() & SOFTMODEM_SIML1_BIT) extern uint64_t get_softmodem_optmask(void); extern uint64_t set_softmodem_optmask(uint64_t bitmask); extern void get_common_options(void); diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index bb2319774c5b8d64400538f409882f6977a231b1..4efe974b750831705b743d63f6cb58c74d8002d5 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -53,6 +53,7 @@ #include <inttypes.h> #include "common/utils/LOG/log.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "UTIL/OTG/otg_tx.h" #include "UTIL/OTG/otg_externs.h" #include "UTIL/MATH/oml.h" @@ -63,7 +64,7 @@ #include "T.h" extern double cpuf; -extern uint8_t nfapi_mode; + #define FRAME_PERIOD 100000000ULL #define DAQ_PERIOD 66667ULL @@ -93,7 +94,7 @@ extern int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind); extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind); extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP); -extern int simL1flag; + extern uint16_t sf_ahead; //extern int tx_req_UE_MAC1(); @@ -192,7 +193,7 @@ PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, ue->mac_enabled = 1; // In phy_stub_UE (MAC-to-MAC) mode these init functions don't need to get called. Is this correct? - if (nfapi_mode!=3) { + if (NFAPI_MODE!=NFAPI_UE_STUB_PNF) { // initialize all signal buffers init_lte_ue_signal(ue,1,abstraction_flag); // intialize transport @@ -266,7 +267,7 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correcti LOG_I(PHY,"Allocating UE context %d\n",inst); - if (simL1flag == 0) PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0); + if ( !IS_SOFTMODEM_SIML1 ) PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0); else { // needed for memcopy below. these are not used in the RU, but needed for UE RC.ru[0]->frame_parms.nb_antennas_rx = fp0->nb_antennas_rx; @@ -354,12 +355,12 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correcti */ UE->N_TA_offset = 0; - if (simL1flag == 1) init_ue_devices(UE); + if (IS_SOFTMODEM_SIML1 ) init_ue_devices(UE); LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]); init_UE_threads(inst); - if (simL1flag == 0) { + if (!IS_SOFTMODEM_SIML1 ) { ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]); if (ret !=0) { @@ -397,7 +398,7 @@ void init_UE_stub_single_thread(int nb_inst,int eMBMS_active, int uecap_xer_in, printf("UE threads created \n"); LOG_I(PHY,"Starting multicast link on %s\n",emul_iface); - if(nfapi_mode!=3) + if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) multicast_link_start(ue_stub_rx_handler,0,emul_iface); } @@ -427,7 +428,7 @@ void init_UE_stub(int nb_inst,int eMBMS_active, int uecap_xer_in, char *emul_ifa printf("UE threads created \n"); LOG_I(PHY,"Starting multicast link on %s\n",emul_iface); - if(nfapi_mode !=3) + if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) multicast_link_start(ue_stub_rx_handler,0,emul_iface); } @@ -1123,7 +1124,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) { hi_dci0_req_UE_MAC(hi_dci0_req, ue_Mod_id); } - if(nfapi_mode!=3) + if(NFAPI_MODE!=NFAPI_UE_STUB_PNF) phy_procedures_UE_SL_TX(UE,proc); } @@ -1405,7 +1406,7 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) { hi_dci0_req = NULL; } - if (nfapi_mode != 3) + if (NFAPI_MODE!=NFAPI_UE_STUB_PNF) phy_procedures_UE_SL_TX(UE,proc); } @@ -1858,7 +1859,7 @@ void init_UE_single_thread_stub(int nb_inst) { AssertFatal(PHY_vars_UE_g[i]!=NULL,"PHY_vars_UE_g[inst] is NULL\n"); AssertFatal(PHY_vars_UE_g[i][0]!=NULL,"PHY_vars_UE_g[inst][0] is NULL\n"); - if(nfapi_mode == 3) { + if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { #ifdef NAS_UE MessageDef *message_p; message_p = itti_alloc_new_message(TASK_NAS_UE, INITIALIZE_MESSAGE); @@ -2040,7 +2041,7 @@ static void *timer_thread( void *param ) { opp_enabled = 1; // first check if we are receiving timing indications - if(nfapi_mode==4) { + if(NFAPI_MODE==NFAPI_UE_STUB_OFFNET) { usleep(10000); if (UE->instance_cnt_timer > 0) { @@ -2128,7 +2129,7 @@ static void *timer_thread( void *param ) { pdu.header.packet_type = TTI_SYNC; pdu.header.absSF = (timer_frame*10)+timer_subframe; - if (nfapi_mode!=3) { + if (NFAPI_MODE != NFAPI_UE_STUB_PNF) { multicast_link_write_sock(0, (char *)&pdu, sizeof(UE_tport_header_t)); diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 159cde39ae2b0f9ccb5ecf7ba10a30afa08a82e8..3ae3e22ef02985f9e320db7d833914bd1ba779b0 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -68,6 +68,7 @@ #include "PHY_INTERFACE/phy_interface_vars.h" #include "common/utils/LOG/log.h" +#include "nfapi/oai_integration/vendor_ext.h" #include "UTIL/OTG/otg_tx.h" #include "UTIL/OTG/otg_externs.h" #include "UTIL/MATH/oml.h" @@ -109,7 +110,7 @@ pthread_cond_t nfapi_sync_cond; pthread_mutex_t nfapi_sync_mutex; int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex -uint8_t nfapi_mode = 0; + #ifdef UESIM_EXPANSION uint16_t inst_pdcp_list[NUMBER_OF_UE_MAX]; #endif @@ -141,7 +142,7 @@ int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; int UE_scan = 1; int UE_scan_carrier = 0; -int simL1flag = 0; + int snr_dB=25; runmode_t mode = normal_txrx; @@ -321,12 +322,10 @@ void exit_function(const char *file, const char *function, const int line, const } sleep(1); //allow lte-softmodem threads to exit first -#if defined(ENABLE_ITTI) if(PHY_vars_UE_g != NULL ) itti_terminate_tasks (TASK_UNKNOWN); -#endif exit(1); } @@ -403,6 +402,8 @@ static void get_options(void) { char *loopfile=NULL; int dumpframe; int timingadv; + uint8_t nfapi_mode; + int simL1flag ; set_default_frame_parms(frame_parms); CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP); /* unknown parameters on command line will be checked in main @@ -413,6 +414,10 @@ static void get_options(void) { paramdef_t cmdline_ueparams[] =CMDLINE_UEPARAMS_DESC; config_process_cmdline( cmdline_uemodeparams,sizeof(cmdline_uemodeparams)/sizeof(paramdef_t),NULL); config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL); + nfapi_setmode(nfapi_mode); + + if (simL1flag) + set_softmodem_optmask(SOFTMODEM_SIML1_BIT); if (loopfile != NULL) { printf("Input file for hardware emulation: %s",loopfile); @@ -445,7 +450,7 @@ static void get_options(void) { } UE_scan=0; - + if (tddflag > 0) { for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { frame_parms[CC_id]->frame_type = TDD; @@ -487,16 +492,6 @@ static void get_options(void) { rx_gain[0][CC_id] = rx_gain[0][0]; tx_gain[0][CC_id] = tx_gain[0][0]; } - - /* - if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) && (!(CONFIG_ISFLAGSET(CONFIG_NOOOPT))) ) { - // Here the configuration file is the XER encoded UE capabilities - // Read it in and store in asn1c data structures - sprintf(uecap_xer,"%stargets/PROJECTS/GENERIC-LTE-EPC/CONF/UE_config.xml",getenv("OPENAIR_HOME")); - printf("%s\n",uecap_xer); - if(nfapi_mode!=3) - uecap_xer_in=1; - } *//* UE with config file */ } @@ -634,10 +629,7 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { - -#if defined(ENABLE_ITTI) -/* - * helper function to terminate a certain ITTI task +/* helper function to terminate a certain ITTI task */ void terminate_task(task_id_t task_id, module_id_t mod_id) { LOG_I(ENB_APP, "sending TERMINATE_MESSAGE to task %s (%d)\n", itti_get_task_name(task_id), task_id); @@ -647,11 +639,6 @@ void terminate_task(task_id_t task_id, module_id_t mod_id) { } - -#endif - - - static inline void wait_nfapi_init(char *thread_name) { printf( "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name); pthread_mutex_lock( &nfapi_sync_mutex ); @@ -712,13 +699,11 @@ int main( int argc, char **argv ) { EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1; printf("Running with %d UE instances\n",NB_UE_INST); - if (NB_UE_INST > 1 && simL1flag != 1 && nfapi_mode != 3) { + if (NB_UE_INST > 1 && (!IS_SOFTMODEM_SIML1) && NFAPI_MODE!=NFAPI_UE_STUB_PNF) { printf("Running with more than 1 UE instance and simL1 is not active, this will result in undefined behaviour for now, exiting.\n"); abort(); } - printf("NFAPI_MODE value: %d \n", nfapi_mode); - // Checking option of nums_ue_thread. if(NB_THREAD_INST < 1) { printf("Running with 0 UE rxtx thread, exiting.\n"); @@ -731,17 +716,6 @@ int main( int argc, char **argv ) { abort(); } - // Not sure if the following is needed here - /*if (CONFIG_ISFLAGSET(CONFIG_ABORT)) { - if (UE_flag == 0) { - fprintf(stderr,"Getting configuration failed\n"); - exit(-1); - } - else { - printf("Setting nfapi mode to UE_STUB_OFFNET\n"); - nfapi_mode = 4; - } - }*/ #if T_TRACER T_Config_Init(); #endif @@ -762,7 +736,7 @@ int main( int argc, char **argv ) { init_opt(); uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1 )? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT); - if ( IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM || (nfapi_mode == 3) ) { + if ( IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM || (nfapi_getmode()==NFAPI_UE_STUB_PNF) ) { pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT; } @@ -795,7 +769,7 @@ int main( int argc, char **argv ) { NB_INST=1; - if(nfapi_mode == 3) { + if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE **)*NB_UE_INST); for (int i=0; i<NB_UE_INST; i++) { @@ -811,7 +785,7 @@ int main( int argc, char **argv ) { } } else init_openair0(frame_parms[0],(int)rx_gain[0][0]); - if (simL1flag==1) { + if (IS_SOFTMODEM_SIML1 ) { RCConfig_sim(); } @@ -858,62 +832,30 @@ int main( int argc, char **argv ) { LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity); #endif -#if defined(ENABLE_ITTI) if (create_tasks_ue(NB_UE_INST) < 0) { printf("cannot create ITTI tasks\n"); exit(-1); // need a softer mode } - if(nfapi_mode==3) { // Here we should add another nfapi_mode for the case of Supervised LTE-D2D + if (NFAPI_MODE==NFAPI_UE_STUB_PNF) { // UE-STUB-PNF UE_config_stub_pnf(); } printf("ITTI tasks created\n"); -#endif mlockall(MCL_CURRENT | MCL_FUTURE); rt_sleep_ns(10*100000000ULL); - const char *nfapi_mode_str = "<UNKNOWN>"; - // start the main UE threads int eMBMS_active = 0; - switch(nfapi_mode) { - case 0: - nfapi_mode_str = "MONOLITHIC"; - break; - - case 1: - nfapi_mode_str = "PNF"; - break; - - case 2: - nfapi_mode_str = "VNF"; - break; - - case 3: - nfapi_mode_str = "UE_STUB_PNF"; - break; - - case 4: - nfapi_mode_str = "UE_STUB_OFFNET"; - break; - - default: - nfapi_mode_str = "<UNKNOWN NFAPI MODE>"; - break; - } - - printf("NFAPI MODE:%s\n", nfapi_mode_str); - - if (nfapi_mode==3) { // UE-STUB-PNF - config_sync_var=0; - wait_nfapi_init("main?"); - //Panos: Temporarily we will be using single set of threads for multiple UEs. - //init_UE_stub(1,eMBMS_active,uecap_xer_in,emul_iface); - init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface); + if (NFAPI_MODE==NFAPI_UE_STUB_PNF) { // UE-STUB-PNF + config_sync_var=0; + wait_nfapi_init("main?"); + //Panos: Temporarily we will be using single set of threads for multiple UEs. + //init_UE_stub(1,eMBMS_active,uecap_xer_in,emul_iface); + init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface); } else { - init_UE(NB_UE_INST,eMBMS_active,uecap_xer_in,0,get_softmodem_params()->phy_test,UE_scan,UE_scan_carrier,mode,(int)rx_gain[0][0],tx_max_power[0], - frame_parms[0]); + init_UE(NB_UE_INST,eMBMS_active,uecap_xer_in,0,get_softmodem_params()->phy_test,UE_scan,UE_scan_carrier,mode,(int)rx_gain[0][0],tx_max_power[0], + frame_parms[0]); } if (get_softmodem_params()->phy_test==0) { @@ -922,25 +864,14 @@ int main( int argc, char **argv ) { dl_phy_sync_success (0, 0, 0, 1); } - if (nfapi_mode!=3) { - number_of_cards = 1; + if (NFAPI_MODE != NFAPI_UE_STUB_PNF) { + number_of_cards = 1; - for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - PHY_vars_UE_g[0][CC_id]->rf_map.card=0; - PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); - } - } - - // connect the TX/RX buffers - - /* - if(nfapi_mode!=3) { - if (setup_ue_buffers(PHY_vars_UE_g[0],&openair0_cfg[0])!=0) { - printf("Error setting up eNB buffer\n"); - exit(-1); + for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + PHY_vars_UE_g[0][CC_id]->rf_map.card=0; + PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); } } - */ if (input_fd) { printf("Reading in from file to antenna buffer %d\n",0); @@ -954,7 +885,7 @@ int main( int argc, char **argv ) { //p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX; - if (simL1flag==1) { + if (IS_SOFTMODEM_SIML1 ) { init_ocm((double)snr_dB,0); PHY_vars_UE_g[0][0]->no_timing_correction = 1; }