diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 34f20929c5950966796d160dda88e81a613940f7..f7bf468b08edf46d7e17981f9080bb5a58c13e05 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1722,7 +1722,7 @@ add_executable(lte-softmodem ${T_SOURCE} ) -target_link_libraries (lte-softmodem -ldl +target_link_libraries (lte-softmodem -ldl -Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS L2 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${MIH_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 -Wl,--end-group ) diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index 03baf1a58b954b09bab3e312afd3d6c91506052b..048a0a2b06b4116f60c130a8068a4eeb6cbc0871 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -97,14 +97,21 @@ void phy_config_request(PHY_Config_t *phy_config) { fp->nushift = fp->Nid_cell%6; fp->eutra_band = eutra_band; fp->Ncp = Ncp; + fp->Ncp_UL = Ncp; fp->nb_antenna_ports_eNB = p_eNB; + fp->threequarter_fs = 0; + AssertFatal(cfg->phich_config.phich_resource.value<4, "Illegal phich_Resource\n"); fp->phich_config_common.phich_resource = phich_resource_table[cfg->phich_config.phich_resource.value]; fp->phich_config_common.phich_duration = cfg->phich_config.phich_duration.value; fp->dl_CarrierFreq = from_earfcn(eutra_band,dl_CarrierFreq); - fp->ul_CarrierFreq = fp->dl_CarrierFreq - get_uldl_offset(eutra_band); + fp->ul_CarrierFreq = fp->dl_CarrierFreq - (get_uldl_offset(eutra_band)*100000); + + fp->tdd_config = 0; + fp->tdd_config_S = 0; + if (fp->dl_CarrierFreq==fp->ul_CarrierFreq) fp->frame_type = TDD; else @@ -177,16 +184,20 @@ void phy_config_request(PHY_Config_t *phy_config) { init_ul_hopping(fp); - fp->soundingrs_ul_config_common.enabled_flag = 1; + fp->soundingrs_ul_config_common.enabled_flag = 0;// 1; Don't know how to turn this off in NFAPI fp->soundingrs_ul_config_common.srs_BandwidthConfig = cfg->srs_config.bandwidth_configuration.value; fp->soundingrs_ul_config_common.srs_SubframeConfig = cfg->srs_config.srs_subframe_configuration.value; fp->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission = cfg->srs_config.srs_acknack_srs_simultaneous_transmission.value; fp->soundingrs_ul_config_common.srs_MaxUpPts = cfg->srs_config.max_up_pts.value; + fp->num_MBSFN_config = 0; + init_ncs_cell(fp,RC.eNB[Mod_id][CC_id]->ncs_cell); - init_ul_hopping(fp); + init_ul_hopping(fp); + RC.eNB[Mod_id][CC_id]->configured = 1; + LOG_I(PHY,"eNB %d/%d configured\n",Mod_id,CC_id); } void phy_config_sib1_ue(uint8_t Mod_id,int CC_id, @@ -1651,7 +1662,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, lte_gold(fp,eNB->lte_gold_table,fp->Nid_cell); generate_pcfich_reg_mapping(fp); generate_phich_reg_mapping(fp); - + for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { eNB->first_run_timing_advance[UE_id] = 1; ///This flag used to be static. With multiple eNBs this does no longer work, hence we put it in the structure. However it has to be initialized with 1, which is performed here. @@ -1668,6 +1679,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, if (abstraction_flag==0) { + common_vars->rxdata = (int32_t **)NULL; common_vars->txdataF = (int32_t **)malloc16(NB_ANTENNA_PORTS_ENB*sizeof(int32_t*)); common_vars->rxdataF = (int32_t **)malloc16(64*sizeof(int32_t*)); @@ -1683,17 +1695,17 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, - // Channel estimates for SRS - for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { - - srs_vars[UE_id].srs_ch_estimates = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); - srs_vars[UE_id].srs_ch_estimates_time = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) ); - - for (i=0; i<fp->nb_antennas_rx; i++) { - srs_vars[UE_id].srs_ch_estimates[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size ); - srs_vars[UE_id].srs_ch_estimates_time[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 ); - } - } //UE_id + // Channel estimates for SRS + for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { + + srs_vars[UE_id].srs_ch_estimates = (int32_t**)malloc16( 64*sizeof(int32_t*) ); + srs_vars[UE_id].srs_ch_estimates_time = (int32_t**)malloc16( 64*sizeof(int32_t*) ); + + for (i=0; i<64; i++) { + srs_vars[UE_id].srs_ch_estimates[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size ); + srs_vars[UE_id].srs_ch_estimates_time[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 ); + } + } //UE_id } // abstraction_flag = 0 else { //UPLINK abstraction = 1 eNB->sinr_dB = (double*) malloc16_clear( fp->N_RB_DL*12*sizeof(double) ); @@ -1732,28 +1744,28 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, pusch_vars[UE_id] = (LTE_eNB_PUSCH*)malloc16_clear( NUMBER_OF_UE_MAX*sizeof(LTE_eNB_PUSCH) ); if (abstraction_flag==0) { - for (eNB_id=0; eNB_id<3; eNB_id++) { - - pusch_vars[UE_id]->rxdataF_ext = (int32_t**)malloc16( 2*sizeof(int32_t*) ); - pusch_vars[UE_id]->rxdataF_ext2 = (int32_t**)malloc16( 2*sizeof(int32_t*) ); - pusch_vars[UE_id]->drs_ch_estimates = (int32_t**)malloc16( 2*sizeof(int32_t*) ); - pusch_vars[UE_id]->drs_ch_estimates_time = (int32_t**)malloc16( 2*sizeof(int32_t*) ); - pusch_vars[UE_id]->rxdataF_comp = (int32_t**)malloc16( 2*sizeof(int32_t*) ); - pusch_vars[UE_id]->ul_ch_mag = (int32_t**)malloc16( 2*sizeof(int32_t*) ); - pusch_vars[UE_id]->ul_ch_magb = (int32_t**)malloc16( 2*sizeof(int32_t*) ); - - for (i=0; i<2; i++) { - // RK 2 times because of output format of FFT! - // FIXME We should get rid of this - pusch_vars[UE_id]->rxdataF_ext[i] = (int32_t*)malloc16_clear( 2*sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); - pusch_vars[UE_id]->rxdataF_ext2[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); - pusch_vars[UE_id]->drs_ch_estimates[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); - pusch_vars[UE_id]->drs_ch_estimates_time[i] = (int32_t*)malloc16_clear( 2*2*sizeof(int32_t)*fp->ofdm_symbol_size ); - pusch_vars[UE_id]->rxdataF_comp[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); - pusch_vars[UE_id]->ul_ch_mag[i] = (int32_t*)malloc16_clear( fp->symbols_per_tti*sizeof(int32_t)*fp->N_RB_UL*12 ); - pusch_vars[UE_id]->ul_ch_magb[i] = (int32_t*)malloc16_clear( fp->symbols_per_tti*sizeof(int32_t)*fp->N_RB_UL*12 ); - } - } //eNB_id + pusch_vars[UE_id]->rxdataF_ext = (int32_t**)malloc16( 2*sizeof(int32_t*) ); + pusch_vars[UE_id]->rxdataF_ext2 = (int32_t**)malloc16( 2*sizeof(int32_t*) ); + pusch_vars[UE_id]->drs_ch_estimates = (int32_t**)malloc16( 2*sizeof(int32_t*) ); + pusch_vars[UE_id]->drs_ch_estimates_time = (int32_t**)malloc16( 2*sizeof(int32_t*) ); + pusch_vars[UE_id]->rxdataF_comp = (int32_t**)malloc16( 2*sizeof(int32_t*) ); + pusch_vars[UE_id]->ul_ch_mag = (int32_t**)malloc16( 2*sizeof(int32_t*) ); + pusch_vars[UE_id]->ul_ch_magb = (int32_t**)malloc16( 2*sizeof(int32_t*) ); + + AssertFatal(fp->ofdm_symbol_size > 127, "fp->ofdm_symbol_size %d<128\n",fp->ofdm_symbol_size); + AssertFatal(fp->symbols_per_tti > 11, "fp->symbols_per_tti %d < 12\n",fp->symbols_per_tti); + AssertFatal(fp->N_RB_UL > 5, "fp->N_RB_UL %d < 6\n",fp->N_RB_UL); + for (i=0; i<2; i++) { + // RK 2 times because of output format of FFT! + // FIXME We should get rid of this + pusch_vars[UE_id]->rxdataF_ext[i] = (int32_t*)malloc16_clear( 2*sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); + pusch_vars[UE_id]->rxdataF_ext2[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); + pusch_vars[UE_id]->drs_ch_estimates[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); + pusch_vars[UE_id]->drs_ch_estimates_time[i] = (int32_t*)malloc16_clear( 2*2*sizeof(int32_t)*fp->ofdm_symbol_size ); + pusch_vars[UE_id]->rxdataF_comp[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); + pusch_vars[UE_id]->ul_ch_mag[i] = (int32_t*)malloc16_clear( fp->symbols_per_tti*sizeof(int32_t)*fp->N_RB_UL*12 ); + pusch_vars[UE_id]->ul_ch_magb[i] = (int32_t*)malloc16_clear( fp->symbols_per_tti*sizeof(int32_t)*fp->N_RB_UL*12 ); + } pusch_vars[UE_id]->llr = (int16_t*)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); } // abstraction_flag diff --git a/openair1/PHY/LTE_ESTIMATION/freq_equalization.c b/openair1/PHY/LTE_ESTIMATION/freq_equalization.c index 3e513d49fc02bf158bf30531697f2c2e935896a2..11701aecedca389d7dcb14079555e646bdf27a23 100644 --- a/openair1/PHY/LTE_ESTIMATION/freq_equalization.c +++ b/openair1/PHY/LTE_ESTIMATION/freq_equalization.c @@ -304,6 +304,11 @@ void freq_equalization(LTE_DL_FRAME_PARMS *frame_parms, ul_ch_magb128 = (int16x8_t*)&ul_ch_magb[0][symbol*frame_parms->N_RB_DL*12]; #endif + AssertFatal(symbol<frame_parms->symbols_per_tti,"symbol %d >= %d\n", + symbol,frame_parms->symbols_per_tti); + AssertFatal(Msc_RS<frame_parms->N_RB_UL*12,"Msc_RS %d >= %d\n", + Msc_RS,frame_parms->N_RB_UL*12); + for (re=0; re<(Msc_RS>>2); re++) { amp=(*((int16_t*)&ul_ch_mag128[re])); diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c index 99cf55746dc2b1978a9f8bf29fe7049aa716becb..5d10cbf6802b5ff5d4c2b240a4493e596557341a 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c @@ -210,7 +210,9 @@ int lte_est_timing_advance_pusch(PHY_VARS_eNB* eNB,uint8_t UE_id) uint8_t cyclic_shift = 0; int sync_pos = (frame_parms->ofdm_symbol_size-cyclic_shift*frame_parms->ofdm_symbol_size/12)%(frame_parms->ofdm_symbol_size); - + AssertFatal(frame_parms->ofdm_symbol_size > 127,"frame_parms->ofdm_symbol_size %d<128\n",frame_parms->ofdm_symbol_size); + AssertFatal(frame_parms->nb_antennas_rx >0 && frame_parms->nb_antennas_rx<3,"frame_parms->nb_antennas_rx %d not in [0,1]\n", + frame_parms->nb_antennas_rx); for (i = 0; i < frame_parms->ofdm_symbol_size; i++) { temp = 0; @@ -236,9 +238,9 @@ int lte_est_timing_advance_pusch(PHY_VARS_eNB* eNB,uint8_t UE_id) } else max_pos_fil2 = ((max_pos_fil2 * coef) + (max_pos * ncoef)) >> 15; -#ifdef DEBUG_PHY - LOG_D(PHY,"frame %d: max_pos = %d, max_pos_fil = %d, sync_pos=%d\n",eNB->proc.frame_rx,max_pos,max_pos_fil2,sync_pos); -#endif //DEBUG_PHY + //#ifdef DEBUG_PHY + LOG_I(PHY,"frame %d: max_pos = %d, max_pos_fil = %d, sync_pos=%d\n",eNB->proc.frame_rx,max_pos,max_pos_fil2,sync_pos); + //#endif //DEBUG_PHY return(max_pos_fil2-sync_pos); } diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c index a8f646acb14b198c42c9644ed1f3e529386ddaf9..551a6b82f01510c6a6ae8063a18a208e7ef5196d 100755 --- a/openair1/PHY/LTE_TRANSPORT/dci.c +++ b/openair1/PHY/LTE_TRANSPORT/dci.c @@ -216,12 +216,14 @@ uint8_t *generate_dci0(uint8_t *dci, uint16_t coded_bits; uint8_t dci_flip[8]; - if (aggregation_level>3) { - printf("dci.c: generate_dci FATAL, illegal aggregation_level %d\n",aggregation_level); - return NULL; - } + AssertFatal((aggregation_level==1) || + (aggregation_level==2) || + (aggregation_level==4) || + (aggregation_level==8), + "generate_dci FATAL, illegal aggregation_level %d\n",aggregation_level); + - coded_bits = 72 * (1<<aggregation_level); + coded_bits = 72 * aggregation_level; /* @@ -1967,7 +1969,7 @@ void pdcch_unscrambling(LTE_DL_FRAME_PARMS *frame_parms, } } - +/* uint8_t get_num_pdcch_symbols(uint8_t num_dci, DCI_ALLOC_t *dci_alloc, LTE_DL_FRAME_PARMS *frame_parms, @@ -2036,8 +2038,10 @@ uint8_t get_num_pdcch_symbols(uint8_t num_dci, //exit(-1); return(0); } +*/ -uint8_t generate_dci_top(uint8_t num_dci, +uint8_t generate_dci_top(uint8_t num_pdcch_symbols, + uint8_t num_dci, DCI_ALLOC_t *dci_alloc, uint32_t n_rnti, int16_t amp, @@ -2046,7 +2050,7 @@ uint8_t generate_dci_top(uint8_t num_dci, uint32_t subframe) { - uint8_t *e_ptr,num_pdcch_symbols; + uint8_t *e_ptr; int8_t L; uint32_t i, lprime; uint32_t gain_lin_QPSK,kprime,kprime_mod12,mprime,nsymb,symbol_offset,tti_offset; @@ -2093,8 +2097,7 @@ uint8_t generate_dci_top(uint8_t num_dci, break; } - num_pdcch_symbols = get_num_pdcch_symbols(num_dci,dci_alloc,frame_parms,subframe); - + generate_pcfich(num_pdcch_symbols, amp, frame_parms, @@ -2115,13 +2118,13 @@ uint8_t generate_dci_top(uint8_t num_dci, // generate DCIs in order of decreasing aggregation level, then common/ue spec // MAC is assumed to have ordered the UE spec DCI according to the RNTI-based randomization - for (L=3; L>=0; L--) { + for (L=8; L>=1; L>>=1) { for (i=0; i<num_dci; i++) { if (dci_alloc[i].L == (uint8_t)L) { //#ifdef DEBUG_DCI_ENCODING - LOG_I(PHY,"Generating DCI %d/%d (nCCE %d) of length %d, aggregation %d (%x)\n",i,num_dci,dci_alloc[i].firstCCE,dci_alloc[i].dci_length,1<<dci_alloc[i].L, + LOG_I(PHY,"Generating DCI %d/%d (nCCE %d) of length %d, aggregation %d (%x)\n",i,num_dci,dci_alloc[i].firstCCE,dci_alloc[i].dci_length,dci_alloc[i].L, *(unsigned int*)dci_alloc[i].dci_pdu); dump_dci(frame_parms,&dci_alloc[i]); //#endif @@ -2360,10 +2363,8 @@ void dci_decoding(uint8_t DCI_LENGTH, int32_t i; #endif - if (aggregation_level>3) { - LOG_I(PHY," dci.c: dci_decoding FATAL, illegal aggregation_level %d\n",aggregation_level); - return; - } + AssertFatal(aggregation_level<4, + "dci_decoding FATAL, illegal aggregation_level %d\n",aggregation_level); coded_bits = 72 * (1<<aggregation_level); diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 07a274523e4daa1fc0ba190060b52822078af2e5..ab5676a31f35f698a4bfb8ee3f4004e013cdc9e6 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -802,9 +802,9 @@ int8_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type) uint8_t i; int8_t first_free_index=-1; - AssertFatal(eNB==NULL,"eNB is null\n"); + AssertFatal(eNB!=NULL,"eNB is null\n"); for (i=0; i<NUMBER_OF_UE_MAX; i++) { - AssertFatal(eNB->ulsch[i]==NULL,"eNB->dlsch[%d] is null\n",i); + AssertFatal(eNB->ulsch[i]!=NULL,"eNB->dlsch[%d] is null\n",i); if ((eNB->ulsch[i]->harq_mask >0) && (eNB->ulsch[i]->rnti==rnti)) return(i); else if ((eNB->ulsch[i]->harq_mask == 0) && (first_free_index==-1)) first_free_index=i; @@ -960,7 +960,7 @@ int fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_ ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->dai = rel8->downlink_assignment_index; // printf("TDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); } else { - dci_alloc->dci_length = sizeof_DCI1A_20MHz_FDD_t; + dci_alloc->dci_length = sizeof_DCI1A_10MHz_FDD_t; ((DCI1A_10MHz_FDD_t *)dci_pdu)->type = 1; ((DCI1A_10MHz_FDD_t *)dci_pdu)->vrb_type = rel8->virtual_resource_block_assignment_flag; ((DCI1A_10MHz_FDD_t *)dci_pdu)->mcs = rel8->mcs_1; @@ -7489,15 +7489,6 @@ int generate_ue_dlsch_params_from_dci(int frame, uint8_t subframe2harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe) { - /* - #ifdef DEBUG_DCI - if (frame_parms->frame_type == TDD) - printf("dci_tools.c: subframe2_harq_pid, subframe %d for TDD configuration %d\n",subframe,frame_parms->tdd_config); - else - printf("dci_tools.c: subframe2_harq_pid, subframe %d for FDD \n",subframe); - #endif - */ - uint8_t ret = 255; if (frame_parms->frame_type == FDD) { diff --git a/openair1/PHY/LTE_TRANSPORT/defs.h b/openair1/PHY/LTE_TRANSPORT/defs.h index e5f22d07335ff5f8394b435755b5b02a5b4ff56d..de6bfbcf1b94b70af232cbc7e47911a4c80a5828 100644 --- a/openair1/PHY/LTE_TRANSPORT/defs.h +++ b/openair1/PHY/LTE_TRANSPORT/defs.h @@ -374,8 +374,12 @@ typedef struct { uint8_t rar_alloc; /// Status Flag indicating for this ULSCH (idle,active,disabled) SCH_status_t status; - /// Subframe scheduling indicator (i.e. Transmission opportunity indicator) - uint8_t subframe_scheduling_flag; + /// Flag to indicate that eNB should decode UE Msg3 + uint8_t Msg3_flag; + /// Subframe for reception + uint8_t subframe; + /// Frame for reception + uint32_t frame; /// Subframe cba scheduling indicator (i.e. CBA Transmission opportunity indicator) uint8_t subframe_cba_scheduling_flag; /// PHICH active flag @@ -505,12 +509,6 @@ typedef struct { uint16_t beta_offset_harqack_times8; /// Flag to indicate that eNB awaits UE Msg3 uint8_t Msg3_active; - /// Flag to indicate that eNB should decode UE Msg3 - uint8_t Msg3_flag; - /// Subframe for Msg3 - uint8_t Msg3_subframe; - /// Frame for Msg3 - uint32_t Msg3_frame; /// RNTI attributed to this ULSCH uint16_t rnti; /// cyclic shift for DM RS diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index e88b1e7beb824a16ae9652202f9336b4402b5e59..2f4f7e2cc618469c03b0b8cca8c53c39d302499c 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -151,9 +151,9 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_ dlsch->Nsoft = Nsoft; for (layer=0; layer<4; layer++) { - dlsch->ue_spec_bf_weights[layer] = (int32_t**)malloc16(frame_parms->nb_antennas_tx*sizeof(int32_t*)); + dlsch->ue_spec_bf_weights[layer] = (int32_t**)malloc16(64*sizeof(int32_t*)); - for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) { + for (aa=0; aa<64; aa++) { dlsch->ue_spec_bf_weights[layer][aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t)); for (re=0;re<OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES; re++) { dlsch->ue_spec_bf_weights[layer][aa][re] = 0x00007fff; diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index 187535ef25ec3e581c3c21399aa8bcd7ef3d9c72..1e7951d96922a3148ca8601ec89b0f202ed5799d 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -2216,7 +2216,9 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, for (eNB_id=0;eNB_id<ru->num_eNB;eNB_id++){ if (phy_vars_eNB == ru->eNB_list[eNB_id]) { for (aa=0;aa<ru->nb_tx;aa++){ - memcpy(ru->beam_weights[eNB_id][5][aa],dlsch0->ue_spec_bf_weights[ru_id][0][aa],frame_parms->ofdm_symbol_size*sizeof(int32_t)); + memcpy(ru->beam_weights[eNB_id][5][aa], + dlsch0->ue_spec_bf_weights[ru_id][0], + frame_parms->ofdm_symbol_size*sizeof(int32_t)); } } } @@ -2454,6 +2456,7 @@ int dlsch_modulation_SIC(int32_t **sic_buffer, int G) { + AssertFatal(1==0,"This function needs to be reintegrated ...\n"); uint8_t harq_pid = -1;//dlsch0->current_harq_pid; LTE_DL_eNB_HARQ_t *dlsch0_harq = dlsch0->harq_processes[harq_pid]; uint32_t i,jj,re_allocated=0; diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 6a3941f40f436174c12d8a8af20d6c89bef3756a..d832d7498c7a4ca4abdf2ff41f297bd83cafc74d 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -385,14 +385,22 @@ void malloc_IF4p5_buffer(RU_t *ru) { int i; if (eth->flags == ETH_RAW_IF4p5_MODE) { - for (i=0;i<10;i++) + for (i=0;i<10;i++) { ru->ifbuffer.tx[i] = malloc(RAW_IF4p5_PRACH_SIZE_BYTES); + memset((void*)ru->ifbuffer.tx[i],0,RAW_IF4p5_PRACH_SIZE_BYTES); + } ru->ifbuffer.tx_prach = malloc(RAW_IF4p5_PRACH_SIZE_BYTES); + memset((void*)ru->ifbuffer.tx_prach,0,RAW_IF4p5_PRACH_SIZE_BYTES); ru->ifbuffer.rx = malloc(RAW_IF4p5_PRACH_SIZE_BYTES); + memset((void*)ru->ifbuffer.rx,0,RAW_IF4p5_PRACH_SIZE_BYTES); } else { - for (i=0;i<10;i++) + for (i=0;i<10;i++) { ru->ifbuffer.tx[i] = malloc(UDP_IF4p5_PRACH_SIZE_BYTES); + memset((void*)ru->ifbuffer.tx[i],0,UDP_IF4p5_PRACH_SIZE_BYTES); + } ru->ifbuffer.tx_prach = malloc(UDP_IF4p5_PRACH_SIZE_BYTES); + memset((void*)ru->ifbuffer.tx_prach,0,UDP_IF4p5_PRACH_SIZE_BYTES); ru->ifbuffer.rx = malloc(UDP_IF4p5_PRACH_SIZE_BYTES); + memset((void*)ru->ifbuffer.rx,0,UDP_IF4p5_PRACH_SIZE_BYTES); } } diff --git a/openair1/PHY/LTE_TRANSPORT/pcfich.c b/openair1/PHY/LTE_TRANSPORT/pcfich.c index 429e566b6df432863c31bd5e89a46b01f838ebd7..83b3f7331f6a038caab7f62eb7999efc9629d15f 100644 --- a/openair1/PHY/LTE_TRANSPORT/pcfich.c +++ b/openair1/PHY/LTE_TRANSPORT/pcfich.c @@ -67,9 +67,9 @@ void generate_pcfich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms) } -#ifdef DEBUG_PCFICH + //#ifdef DEBUG_PCFICH printf("pcfich_reg : %d,%d,%d,%d\n",pcfich_reg[0],pcfich_reg[1],pcfich_reg[2],pcfich_reg[3]); -#endif + //#endif } void pcfich_scrambling(LTE_DL_FRAME_PARMS *frame_parms, @@ -144,7 +144,8 @@ void generate_pcfich(uint8_t num_pdcch_symbols, int nushiftmod3 = frame_parms->nushift%3; #ifdef DEBUG_PCFICH - printf("[PHY] Generating PCFICH for %d PDCCH symbols, AMP %d\n",num_pdcch_symbols,amp); + LOG_D(PHY,"Generating PCFICH in subfrmae %d for %d PDCCH symbols, AMP %d, p %d, Ncp %d\n", + subframe,num_pdcch_symbols,amp,frame_parms->nb_antenna_ports_eNB,frame_parms->Ncp); #endif // scrambling @@ -199,7 +200,6 @@ void generate_pcfich(uint8_t num_pdcch_symbols, if (reg_offset>=frame_parms->ofdm_symbol_size) reg_offset=1 + reg_offset-frame_parms->ofdm_symbol_size; - // printf("mapping pcfich reg_offset %d\n",reg_offset); for (i=0; i<6; i++) { if ((i!=nushiftmod3)&&(i!=(nushiftmod3+3))) { txdataF[0][symbol_offset+reg_offset+i] = pcfich_d[0][m]; diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c index 558ff580de7c06358b954b1ba979bcec98557b75..121f9b84907727f7b3fd247d6f23736e9247b0d5 100644 --- a/openair1/PHY/LTE_TRANSPORT/phich.c +++ b/openair1/PHY/LTE_TRANSPORT/phich.c @@ -318,7 +318,7 @@ void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms) Ngroup_PHICH<<=1; } - // #ifdef DEBUG_PHICH +#ifdef DEBUG_PHICH LOG_I(PHY,"Ngroup_PHICH %d (phich_config_common.phich_resource %d,phich_config_common.phich_duration %s, NidCell %d,Ncp %d, frame_type %d), smallest pcfich REG %d, n0 %d, n1 %d (first PHICH REG %d)\n", ((frame_parms->Ncp == NORMAL)?Ngroup_PHICH:(Ngroup_PHICH>>1)), frame_parms->phich_config_common.phich_resource, @@ -328,7 +328,7 @@ void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms) n0, n1, ((frame_parms->Nid_cell))%n0); -//#endif +#endif // This is the algorithm from Section 6.9.3 in 36-211, it works only for normal PHICH duration for now ... @@ -382,9 +382,9 @@ void generate_phich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms) if (frame_parms->phich_reg[mprime][2]>=pcfich_reg[(frame_parms->pcfich_first_reg_idx+3)&3]) frame_parms->phich_reg[mprime][2]++; - #ifdef DEBUG_PHICH +#ifdef DEBUG_PHICH printf("phich_reg :%d => %d,%d,%d\n",mprime,frame_parms->phich_reg[mprime][0],frame_parms->phich_reg[mprime][1],frame_parms->phich_reg[mprime][2]); - #endif +#endif } else { // extended PHICH duration frame_parms->phich_reg[mprime<<1][0] = (frame_parms->Nid_cell + mprime)%n0; frame_parms->phich_reg[1+(mprime<<1)][0] = (frame_parms->Nid_cell + mprime)%n0; @@ -1473,7 +1473,7 @@ void rx_phich(PHY_VARS_UE *ue, // harqId-8 corresponds to the temporary struct. In total we have 8 harq process(0 ..7) + 1 temporary harq process() //ulsch->harq_processes[8] = ulsch->harq_processes[harq_pid]; - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag =0; + ulsch->harq_processes[harq_pid]->status = SCH_IDLE; ulsch->harq_processes[harq_pid]->round = 0; // inform MAC? @@ -1524,7 +1524,7 @@ void generate_phich_top(PHY_VARS_eNB *eNB, if ((ulsch[UE_id])&&(ulsch[UE_id]->rnti>0)) { if (ulsch[UE_id]->harq_processes[harq_pid]->phich_active == 1) { - LOG_D(PHY,"[eNB][PUSCH %d/%x] Frame %d subframe %d (pusch_subframe %d,pusch_frame %d) phich active %d\n", + LOG_I(PHY,"[eNB][PUSCH %d/%x] Frame %d subframe %d (pusch_subframe %d,pusch_frame %d) phich active %d\n", harq_pid,ulsch[UE_id]->rnti,proc->frame_tx,subframe,pusch_subframe,pusch_frame,ulsch[UE_id]->harq_processes[harq_pid]->phich_active); /* the HARQ process may have been reused by a new scheduling, so we use @@ -1542,7 +1542,7 @@ void generate_phich_top(PHY_VARS_eNB *eNB, nseq_PHICH = ((ulsch[UE_id]->harq_processes[harq_pid]->previous_first_rb/Ngroup_PHICH) + ulsch[UE_id]->harq_processes[harq_pid]->previous_n_DMRS)%(2*NSF_PHICH); - LOG_D(PHY,"[eNB %d][PUSCH %d] Frame %d subframe %d Generating PHICH, ngroup_PHICH %d/%d, nseq_PHICH %d : HI %d, first_rb %d dci_alloc %d)\n", + LOG_I(PHY,"[eNB %d][PUSCH %d] Frame %d subframe %d Generating PHICH, ngroup_PHICH %d/%d, nseq_PHICH %d : HI %d, first_rb %d dci_alloc %d)\n", eNB->Mod_id,harq_pid,proc->frame_tx, subframe,ngroup_PHICH,Ngroup_PHICH,nseq_PHICH, ulsch[UE_id]->harq_processes[harq_pid]->phich_ACK, @@ -1558,7 +1558,7 @@ void generate_phich_top(PHY_VARS_eNB *eNB, T_INT(ulsch[UE_id]->harq_processes[harq_pid]->previous_n_DMRS)); if (ulsch[UE_id]->Msg3_active == 1) { - LOG_D(PHY,"[eNB %d][PUSCH %d][RAPROC] Frame %d, subframe %d: Generating Msg3 PHICH for UE %d, ngroup_PHICH %d/%d, nseq_PHICH %d : HI %d, first_rb %d\n", + LOG_I(PHY,"[eNB %d][PUSCH %d][RAPROC] Frame %d, subframe %d: Generating Msg3 PHICH for UE %d, ngroup_PHICH %d/%d, nseq_PHICH %d : HI %d, first_rb %d\n", eNB->Mod_id,harq_pid,proc->frame_tx,subframe, UE_id,ngroup_PHICH,Ngroup_PHICH,nseq_PHICH,ulsch[UE_id]->harq_processes[harq_pid]->phich_ACK, ulsch[UE_id]->harq_processes[harq_pid]->previous_first_rb); @@ -1591,9 +1591,11 @@ void generate_phich_top(PHY_VARS_eNB *eNB, if (ulsch[UE_id]->harq_processes[harq_pid]->phich_ACK==0 ) { T(T_ENB_PHY_ULSCH_UE_NO_DCI_RETRANSMISSION, T_INT(eNB->Mod_id), T_INT(proc->frame_tx), T_INT(subframe), T_INT(UE_id), T_INT(ulsch[UE_id]->rnti), T_INT(harq_pid)); - LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d, subframe %d : PHICH NACK / (no format0 DCI) Setting subframe_scheduling_flag\n", + LOG_I(PHY,"[eNB %d][PUSCH %d] frame %d, subframe %d : PHICH NACK / (no format0 DCI) Setting subframe_scheduling_flag\n", eNB->Mod_id,harq_pid,proc->frame_tx,subframe); - ulsch[UE_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + // ulsch[UE_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 1; + ulsch[UE_id]->harq_processes[harq_pid]->subframe = (subframe + 4)%10; + if (subframe>5) ulsch[UE_id]->harq_processes[harq_pid]->frame++; ulsch[UE_id]->harq_processes[harq_pid]->rvidx = rv_table[ulsch[UE_id]->harq_processes[harq_pid]->round&3]; ulsch[UE_id]->harq_processes[harq_pid]->O_RI = 0; ulsch[UE_id]->harq_processes[harq_pid]->Or2 = 0; @@ -1601,9 +1603,9 @@ void generate_phich_top(PHY_VARS_eNB *eNB, ulsch[UE_id]->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; } else { - LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d PHICH ACK (no format0 DCI) Clearing subframe_scheduling_flag, setting round to 0\n", + LOG_I(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d PHICH ACK (no format0 DCI) Clearing subframe_scheduling_flag, setting round to 0\n", eNB->Mod_id,harq_pid,proc->frame_tx,subframe); - ulsch[UE_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + ulsch[UE_id]->harq_processes[harq_pid]->status = SCH_IDLE; ulsch[UE_id]->harq_processes[harq_pid]->round=0; } } diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index 950be1e9a868c2179caacd50ec89ff3635a612c6..c1e3148ee41970e3d25335d1a719b88b50a40f9d 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -1403,6 +1403,7 @@ void dci_encoding(uint8_t *a, uint16_t rnti); /*! \brief Top-level DCI entry point. This routine codes an set of DCI PDUs and performs PDCCH modulation, interleaving and mapping. + \param num_dci Number of pdcch symbols \param num_dci Number of DCI pdus to encode \param dci_alloc Allocation vectors for each DCI pdu \param n_rnti n_RNTI (see ) @@ -1412,7 +1413,8 @@ void dci_encoding(uint8_t *a, \param sub_frame_offset subframe offset in frame @returns Number of PDCCH symbols */ -uint8_t generate_dci_top(uint8_t num_dci, +uint8_t generate_dci_top(uint8_t num_pdcch_symbols, + uint8_t num_dci, DCI_ALLOC_t *dci_alloc, uint32_t n_rnti, int16_t amp, @@ -1679,11 +1681,10 @@ int32_t generate_eNB_dlsch_params_from_dci(int frame, uint16_t DL_pmi_single, uint8_t beamforming_mode); -int32_t generate_eNB_ulsch_params_from_rar(uint8_t *rar_pdu, - frame_t frame, - uint8_t subframe, - LTE_eNB_ULSCH_t *ulsch, - LTE_DL_FRAME_PARMS *frame_parms); +int generate_eNB_ulsch_params_from_rar(PHY_VARS_eNB *eNB, + unsigned char *rar_pdu, + uint32_t frame, + unsigned char subframe); int generate_ue_ulsch_params_from_dci(void *dci_pdu, rnti_t rnti, diff --git a/openair1/PHY/LTE_TRANSPORT/rar_tools.c b/openair1/PHY/LTE_TRANSPORT/rar_tools.c index fe552653cd571791ffc5f9012837ab49d6a7df6e..92f2851a6d57c1b7b8ee1cbdf4cdb59040da6c0d 100644 --- a/openair1/PHY/LTE_TRANSPORT/rar_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/rar_tools.c @@ -52,15 +52,15 @@ extern uint16_t RIV_max6,RIV_max25,RIV_max50,RIV_max100; //#define DEBUG_RAR -#ifdef OPENAIR2 -int generate_eNB_ulsch_params_from_rar(unsigned char *rar_pdu, + +int generate_eNB_ulsch_params_from_rar(PHY_VARS_eNB *eNB, + unsigned char *rar_pdu, uint32_t frame, - unsigned char subframe, - LTE_eNB_ULSCH_t *ulsch, - LTE_DL_FRAME_PARMS *frame_parms) -{ + unsigned char subframe){ + + LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; // RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *)rar_pdu; // RAR_PDU *rar = (RAR_PDU *)(rar_pdu+1); @@ -71,8 +71,20 @@ int generate_eNB_ulsch_params_from_rar(unsigned char *rar_pdu, uint16_t *RIV2nb_rb_LUT, *RIV2first_rb_LUT; uint16_t RIV_max; uint16_t use_srs=0; + uint16_t rnti; + LTE_eNB_ULSCH_t *ulsch; + LTE_UL_eNB_HARQ_t *ulsch_harq; + int8_t UE_id; + + LOG_I(PHY,"[eNB][RAPROC] generate_eNB_ulsch_params_from_rar: subframe %d (harq_pid %d)\n",subframe,harq_pid); + + rnti = (((uint16_t)rar[4])<<8)+rar[5]; - LOG_D(PHY,"[eNB][RAPROC] generate_eNB_ulsch_params_from_rar: subframe %d (harq_pid %d)\n",subframe,harq_pid); + AssertFatal((UE_id = find_ulsch(rnti,eNB,SEARCH_EXIST_OR_FREE))>=0, + "Cannot get UE id for RAR (rnti %x)\n",rnti); + + ulsch = eNB->ulsch[UE_id]; + ulsch_harq = ulsch->harq_processes[harq_pid]; switch (frame_parms->N_RB_DL) { case 6: @@ -104,7 +116,7 @@ int generate_eNB_ulsch_params_from_rar(unsigned char *rar_pdu, break; } - ulsch->harq_processes[harq_pid]->TPC = (rar[3]>>2)&7;//rar->TPC; + ulsch_harq->TPC = (rar[3]>>2)&7;//rar->TPC; rballoc = (((uint16_t)(rar[1]&7))<<7)|(rar[2]>>1); if (rballoc>RIV_max) { @@ -112,43 +124,44 @@ int generate_eNB_ulsch_params_from_rar(unsigned char *rar_pdu, return(-1); } - ulsch->harq_processes[harq_pid]->rar_alloc = 1; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT[rballoc]; - // ulsch->harq_processes[harq_pid]->Ndi = 1; + ulsch_harq->rar_alloc = 1; + ulsch_harq->first_rb = RIV2first_rb_LUT[rballoc]; + ulsch_harq->nb_rb = RIV2nb_rb_LUT[rballoc]; + // ulsch_harq->Ndi = 1; cqireq = rar[3]&1; if (cqireq==1) { - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; - ulsch->harq_processes[harq_pid]->O_RI = 1; + ulsch_harq->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; + ulsch_harq->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; + ulsch_harq->O_RI = 1; } else { - ulsch->harq_processes[harq_pid]->O_RI = 0;//1; - ulsch->harq_processes[harq_pid]->Or2 = 0; - ulsch->harq_processes[harq_pid]->Or1 = 0; + ulsch_harq->O_RI = 0;//1; + ulsch_harq->Or2 = 0; + ulsch_harq->Or1 = 0; } - ulsch->harq_processes[harq_pid]->O_ACK = 0;//2; + ulsch_harq->O_ACK = 0;//2; ulsch->beta_offset_cqi_times8 = 18; ulsch->beta_offset_ri_times8 = 10; ulsch->beta_offset_harqack_times8 = 16; - ulsch->rnti = (((uint16_t)rar[4])<<8)+rar[5]; - - if (ulsch->harq_processes[harq_pid]->round == 0) { - ulsch->harq_processes[harq_pid]->status = ACTIVE; - ulsch->harq_processes[harq_pid]->rvidx = 0; - ulsch->harq_processes[harq_pid]->mcs = ((rar[2]&1)<<3)|(rar[3]>>5); - //ulsch->harq_processes[harq_pid]->TBS = dlsch_tbs25[ulsch->harq_processes[harq_pid]->mcs][ulsch->harq_processes[harq_pid]->nb_rb-1]; - ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; - ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch->harq_processes[harq_pid]->nb_rb; - ulsch->harq_processes[harq_pid]->Nsymb_initial = 9; - ulsch->harq_processes[harq_pid]->round = 0; + ulsch->rnti = rnti; + ulsch->harq_mask = 1<<harq_pid; + + if (ulsch_harq->round == 0) { + ulsch_harq->status = ACTIVE; + ulsch_harq->rvidx = 0; + ulsch_harq->mcs = ((rar[2]&1)<<3)|(rar[3]>>5); + //ulsch_harq->TBS = dlsch_tbs25[ulsch_harq->mcs][ulsch_harq->nb_rb-1]; + ulsch_harq->TBS = TBStable[get_I_TBS_UL(ulsch_harq->mcs)][ulsch_harq->nb_rb-1]; + ulsch_harq->Msc_initial = 12*ulsch_harq->nb_rb; + ulsch_harq->Nsymb_initial = 9; + ulsch_harq->round = 0; } else { - ulsch->harq_processes[harq_pid]->rvidx = 0; - ulsch->harq_processes[harq_pid]->round++; + ulsch_harq->rvidx = 0; + ulsch_harq->round++; } @@ -157,23 +170,23 @@ int generate_eNB_ulsch_params_from_rar(unsigned char *rar_pdu, get_Msg3_alloc(frame_parms, subframe, frame, - &ulsch->Msg3_frame, - &ulsch->Msg3_subframe); + &ulsch_harq->frame, + &ulsch_harq->subframe); - use_srs = is_srs_occasion_common(frame_parms,ulsch->Msg3_frame,ulsch->Msg3_subframe); - ulsch->harq_processes[harq_pid]->Nsymb_pusch = 12-(frame_parms->Ncp<<1)-(use_srs==0?0:1); - ulsch->harq_processes[harq_pid]->srs_active = use_srs; + use_srs = is_srs_occasion_common(frame_parms,ulsch_harq->frame,ulsch_harq->subframe); + ulsch_harq->Nsymb_pusch = 12-(frame_parms->Ncp<<1)-(use_srs==0?0:1); + ulsch_harq->srs_active = use_srs; #ifdef DEBUG_RAR LOG_D(PHY,"ulsch ra (eNB): harq_pid %d\n",harq_pid); - LOG_D(PHY,"ulsch ra (eNB): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); - LOG_D(PHY,"ulsch ra (eNB): rballoc %x\n",ulsch->harq_processes[harq_pid]->first_rb); + LOG_D(PHY,"ulsch ra (eNB): NBRB %d\n",ulsch_harq->nb_rb); + LOG_D(PHY,"ulsch ra (eNB): rballoc %x\n",ulsch_harq->first_rb); LOG_D(PHY,"ulsch ra (eNB): harq_pid %d\n",harq_pid); - LOG_D(PHY,"ulsch ra (eNB): round %d\n",ulsch->harq_processes[harq_pid]->round); - LOG_D(PHY,"ulsch ra (eNB): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); - LOG_D(PHY,"ulsch ra (eNB): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); - LOG_D(PHY,"ulsch ra (eNB): Or1 %d\n",ulsch->harq_processes[harq_pid]->Or1); - LOG_D(PHY,"ulsch ra (eNB): ORI %d\n",ulsch->harq_processes[harq_pid]->O_RI); + LOG_D(PHY,"ulsch ra (eNB): round %d\n",ulsch_harq->round); + LOG_D(PHY,"ulsch ra (eNB): TBS %d\n",ulsch_harq->TBS); + LOG_D(PHY,"ulsch ra (eNB): mcs %d\n",ulsch_harq->mcs); + LOG_D(PHY,"ulsch ra (eNB): Or1 %d\n",ulsch_harq->Or1); + LOG_D(PHY,"ulsch ra (eNB): ORI %d\n",ulsch_harq->O_RI); #endif return(0); } @@ -337,4 +350,4 @@ int generate_ue_ulsch_params_from_rar(PHY_VARS_UE *ue, //#endif return(0); } -#endif + diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index c9cb1a18c02ed1b06d8e4c93bba03ad7496dbfd1..6ff4fd58fd5680671bf7ca5a30893d7f0b7440f9 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -146,8 +146,6 @@ LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uin else exit_flag=2; } - - ulsch->harq_processes[i]->subframe_scheduling_flag = 0; } } else { exit_flag=1; @@ -177,7 +175,6 @@ void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch) if (ulsch->harq_processes[i]) { // ulsch->harq_processes[i]->Ndi = 0; ulsch->harq_processes[i]->status = 0; - ulsch->harq_processes[i]->subframe_scheduling_flag = 0; //ulsch->harq_processes[i]->phich_active = 0; //this will be done later after transmission of PHICH ulsch->harq_processes[i]->phich_ACK = 0; ulsch->harq_processes[i]->round = 0; diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c index 0ef041a50eba0406fee958c6f55b7372c51470af..18f46adf8f8838dcb47ee963e79ab15c7d01405a 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c @@ -47,7 +47,6 @@ static short jitter[8] __attribute__ ((aligned(16))) = {1,0,0,1,0,1,1,0}; static short jitterc[8] __attribute__ ((aligned(16))) = {0,1,1,0,1,0,0,1}; -#ifndef OFDMA_ULSCH void lte_idft(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *z, uint16_t Msc_PUSCH) { #if defined(__x86_64__) || defined(__i386__) @@ -455,7 +454,7 @@ void lte_idft(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *z, uint16_t Msc_PUSCH) #endif } -#endif + @@ -726,6 +725,9 @@ void ulsch_extract_rbs_single(int32_t **rxdataF, //uint8_t symbol = l+Ns*frame_parms->symbols_per_tti/2; uint8_t symbol = l+((7-frame_parms->Ncp)*(Ns&1)); ///symbol within sub-frame + AssertFatal((frame_parms->nb_antennas_rx>0) && (frame_parms->nb_antennas_rx<3), + "nb_antennas_rx not in (1-2)\n"); + for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { @@ -744,20 +746,12 @@ void ulsch_extract_rbs_single(int32_t **rxdataF, rxF_ext += nb_rb1*6; if (nb_rb2) { - //#ifdef OFDMA_ULSCH - // rxF = &rxdataF[aarx][(1 + symbol*frame_parms->ofdm_symbol_size)*2]; - //#else rxF = &rxdataF[aarx][(symbol*frame_parms->ofdm_symbol_size)]; - //#endif memcpy(rxF_ext, rxF, nb_rb2*6*sizeof(int)); rxF_ext += nb_rb2*6; } } else { //there is only data in the second half - //#ifdef OFDMA_ULSCH - // rxF = &rxdataF[aarx][(1 + 6*(2*first_rb - frame_parms->N_RB_UL) + symbol*frame_parms->ofdm_symbol_size)*2]; - //#else rxF = &rxdataF[aarx][(6*(2*first_rb - frame_parms->N_RB_UL) + symbol*frame_parms->ofdm_symbol_size)]; - //#endif memcpy(rxF_ext, rxF, nb_rb2*6*sizeof(int)); rxF_ext += nb_rb2*6; } @@ -806,9 +800,6 @@ void ulsch_channel_compensation(int32_t **rxdataF_ext, __m128i *ul_ch128,*ul_ch_mag128,*ul_ch_mag128b,*rxdataF128,*rxdataF_comp128; uint8_t aarx;//,symbol_mod; __m128i mmtmpU0,mmtmpU1,mmtmpU2,mmtmpU3; -#ifdef OFDMA_ULSCH - __m128i QAM_amp128U,QAM_amp128bU; -#endif #elif defined(__arm__) @@ -817,35 +808,11 @@ void ulsch_channel_compensation(int32_t **rxdataF_ext, uint8_t aarx;//,symbol_mod; int32x4_t mmtmpU0,mmtmpU1,mmtmpU0b,mmtmpU1b; -#ifdef OFDMA_ULSCH - int16x8_t mmtmpU2,mmtmpU3; - int16x8_t QAM_amp128U,QAM_amp128bU; -#endif int16_t conj[4]__attribute__((aligned(16))) = {1,-1,1,-1}; int32x4_t output_shift128 = vmovq_n_s32(-(int32_t)output_shift); -#endif - -#ifdef OFDMA_ULSCH - -#if defined(__x86_64__) || defined(__i386__) - if (Qm == 4) - QAM_amp128U = _mm_set1_epi16(QAM16_n1); - else if (Qm == 6) { - QAM_amp128U = _mm_set1_epi16(QAM64_n1); - QAM_amp128bU = _mm_set1_epi16(QAM64_n2); - } -#elif defined(__arm__) - if (Qm == 4) - QAM_amp128U = vdupq_n_s16(QAM16_n1); - else if (Qm == 6) { - QAM_amp128U = vdupq_n_s16(QAM64_n1); - QAM_amp128bU = vdupq_n_s16(QAM64_n2); - } - -#endif #endif for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { @@ -870,76 +837,7 @@ void ulsch_channel_compensation(int32_t **rxdataF_ext, #endif for (rb=0; rb<nb_rb; rb++) { // printf("comp: symbol %d rb %d\n",symbol,rb); -#ifdef OFDMA_ULSCH - if (Qm>2) { - // get channel amplitude if not QPSK - -#if defined(__x86_64__) || defined(__i386__) - mmtmpU0 = _mm_madd_epi16(ul_ch128[0],ul_ch128[0]); - - mmtmpU0 = _mm_srai_epi32(mmtmpU0,output_shift); - - mmtmpU1 = _mm_madd_epi16(ul_ch128[1],ul_ch128[1]); - mmtmpU1 = _mm_srai_epi32(mmtmpU1,output_shift); - mmtmpU0 = _mm_packs_epi32(mmtmpU0,mmtmpU1); - - ul_ch_mag128[0] = _mm_unpacklo_epi16(mmtmpU0,mmtmpU0); - ul_ch_mag128b[0] = ul_ch_mag128[0]; - ul_ch_mag128[0] = _mm_mulhi_epi16(ul_ch_mag128[0],QAM_amp128U); - ul_ch_mag128[0] = _mm_slli_epi16(ul_ch_mag128[0],2); // 2 to compensate the scale channel estimate - ul_ch_mag128[1] = _mm_unpackhi_epi16(mmtmpU0,mmtmpU0); - ul_ch_mag128b[1] = ul_ch_mag128[1]; - ul_ch_mag128[1] = _mm_mulhi_epi16(ul_ch_mag128[1],QAM_amp128U); - ul_ch_mag128[1] = _mm_slli_epi16(ul_ch_mag128[1],2); // 2 to compensate the scale channel estimate - - mmtmpU0 = _mm_madd_epi16(ul_ch128[2],ul_ch128[2]); - mmtmpU0 = _mm_srai_epi32(mmtmpU0,output_shift); - mmtmpU1 = _mm_packs_epi32(mmtmpU0,mmtmpU0); - - ul_ch_mag128[2] = _mm_unpacklo_epi16(mmtmpU1,mmtmpU1); - ul_ch_mag128b[2] = ul_ch_mag128[2]; - - ul_ch_mag128[2] = _mm_mulhi_epi16(ul_ch_mag128[2],QAM_amp128U); - ul_ch_mag128[2] = _mm_slli_epi16(ul_ch_mag128[2],2); // 2 to compensate the scale channel estimate - - - ul_ch_mag128b[0] = _mm_mulhi_epi16(ul_ch_mag128b[0],QAM_amp128bU); - ul_ch_mag128b[0] = _mm_slli_epi16(ul_ch_mag128b[0],2); // 2 to compensate the scale channel estimate - - - ul_ch_mag128b[1] = _mm_mulhi_epi16(ul_ch_mag128b[1],QAM_amp128bU); - ul_ch_mag128b[1] = _mm_slli_epi16(ul_ch_mag128b[1],2); // 2 to compensate the scale channel estimate - - ul_ch_mag128b[2] = _mm_mulhi_epi16(ul_ch_mag128b[2],QAM_amp128bU); - ul_ch_mag128b[2] = _mm_slli_epi16(ul_ch_mag128b[2],2);// 2 to compensate the scale channel estimate - -#elif defined(__arm__) - mmtmpU0 = vmull_s16(ul_ch128[0], ul_ch128[0]); - mmtmpU0 = vqshlq_s32(vqaddq_s32(mmtmpU0,vrev64q_s32(mmtmpU0)),-output_shift128); - mmtmpU1 = vmull_s16(ul_ch128[1], ul_ch128[1]); - mmtmpU1 = vqshlq_s32(vqaddq_s32(mmtmpU1,vrev64q_s32(mmtmpU1)),-output_shift128); - mmtmpU2 = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1)); - mmtmpU0 = vmull_s16(ul_ch128[2], ul_ch128[2]); - mmtmpU0 = vqshlq_s32(vqaddq_s32(mmtmpU0,vrev64q_s32(mmtmpU0)),-output_shift128); - mmtmpU1 = vmull_s16(ul_ch128[3], ul_ch128[3]); - mmtmpU1 = vqshlq_s32(vqaddq_s32(mmtmpU1,vrev64q_s32(mmtmpU1)),-output_shift128); - mmtmpU3 = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1)); - mmtmpU0 = vmull_s16(ul_ch128[4], ul_ch128[4]); - mmtmpU0 = vqshlq_s32(vqaddq_s32(mmtmpU0,vrev64q_s32(mmtmpU0)),-output_shift128); - mmtmpU1 = vmull_s16(ul_ch128[5], ul_ch128[5]); - mmtmpU1 = vqshlq_s32(vqaddq_s32(mmtmpU1,vrev64q_s32(mmtmpU1)),-output_shift128); - mmtmpU4 = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1)); - - ul_ch_mag128b[0] = vqdmulhq_s16(mmtmpU2,QAM_amp128b); - ul_ch_mag128b[1] = vqdmulhq_s16(mmtmpU3,QAM_amp128b); - ul_ch_mag128[0] = vqdmulhq_s16(mmtmpU2,QAM_amp128); - ul_ch_mag128[1] = vqdmulhq_s16(mmtmpU3,QAM_amp128); - ul_ch_mag128b[2] = vqdmulhq_s16(mmtmpU4,QAM_amp128b); - ul_ch_mag128[2] = vqdmulhq_s16(mmtmpU4,QAM_amp128); -#endif - } -#else // SC-FDMA // just compute channel magnitude without scaling, this is done after equalization for SC-FDMA #if defined(__x86_64__) || defined(__i386__) @@ -965,30 +863,29 @@ void ulsch_channel_compensation(int32_t **rxdataF_ext, #elif defined(__arm__) - mmtmpU0 = vmull_s16(ul_ch128[0], ul_ch128[0]); - mmtmpU0 = vqshlq_s32(vqaddq_s32(mmtmpU0,vrev64q_s32(mmtmpU0)),-output_shift128); - mmtmpU1 = vmull_s16(ul_ch128[1], ul_ch128[1]); - mmtmpU1 = vqshlq_s32(vqaddq_s32(mmtmpU1,vrev64q_s32(mmtmpU1)),-output_shift128); - ul_ch_mag128[0] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1)); - mmtmpU0 = vmull_s16(ul_ch128[2], ul_ch128[2]); - mmtmpU0 = vqshlq_s32(vqaddq_s32(mmtmpU0,vrev64q_s32(mmtmpU0)),-output_shift128); - mmtmpU1 = vmull_s16(ul_ch128[3], ul_ch128[3]); - mmtmpU1 = vqshlq_s32(vqaddq_s32(mmtmpU1,vrev64q_s32(mmtmpU1)),-output_shift128); - ul_ch_mag128[1] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1)); - mmtmpU0 = vmull_s16(ul_ch128[4], ul_ch128[4]); - mmtmpU0 = vqshlq_s32(vqaddq_s32(mmtmpU0,vrev64q_s32(mmtmpU0)),-output_shift128); - mmtmpU1 = vmull_s16(ul_ch128[5], ul_ch128[5]); - mmtmpU1 = vqshlq_s32(vqaddq_s32(mmtmpU1,vrev64q_s32(mmtmpU1)),-output_shift128); - ul_ch_mag128[2] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1)); - -#endif + mmtmpU0 = vmull_s16(ul_ch128[0], ul_ch128[0]); + mmtmpU0 = vqshlq_s32(vqaddq_s32(mmtmpU0,vrev64q_s32(mmtmpU0)),-output_shift128); + mmtmpU1 = vmull_s16(ul_ch128[1], ul_ch128[1]); + mmtmpU1 = vqshlq_s32(vqaddq_s32(mmtmpU1,vrev64q_s32(mmtmpU1)),-output_shift128); + ul_ch_mag128[0] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1)); + mmtmpU0 = vmull_s16(ul_ch128[2], ul_ch128[2]); + mmtmpU0 = vqshlq_s32(vqaddq_s32(mmtmpU0,vrev64q_s32(mmtmpU0)),-output_shift128); + mmtmpU1 = vmull_s16(ul_ch128[3], ul_ch128[3]); + mmtmpU1 = vqshlq_s32(vqaddq_s32(mmtmpU1,vrev64q_s32(mmtmpU1)),-output_shift128); + ul_ch_mag128[1] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1)); + mmtmpU0 = vmull_s16(ul_ch128[4], ul_ch128[4]); + mmtmpU0 = vqshlq_s32(vqaddq_s32(mmtmpU0,vrev64q_s32(mmtmpU0)),-output_shift128); + mmtmpU1 = vmull_s16(ul_ch128[5], ul_ch128[5]); + mmtmpU1 = vqshlq_s32(vqaddq_s32(mmtmpU1,vrev64q_s32(mmtmpU1)),-output_shift128); + ul_ch_mag128[2] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1)); + #endif #if defined(__x86_64__) || defined(__i386__) // multiply by conjugated channel mmtmpU0 = _mm_madd_epi16(ul_ch128[0],rxdataF128[0]); // print_ints("re",&mmtmpU0); - + // mmtmpU0 contains real part of 4 consecutive outputs (32-bit) mmtmpU1 = _mm_shufflelo_epi16(ul_ch128[0],_MM_SHUFFLE(2,3,0,1)); mmtmpU1 = _mm_shufflehi_epi16(mmtmpU1,_MM_SHUFFLE(2,3,0,1)); @@ -1057,65 +954,65 @@ void ulsch_channel_compensation(int32_t **rxdataF_ext, rxdataF128+=3; rxdataF_comp128+=3; #elif defined(__arm__) - mmtmpU0 = vmull_s16(ul_ch128[0], rxdataF128[0]); - //mmtmpU0 = [Re(ch[0])Re(rx[0]) Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1]) Im(ch[1])Im(ch[1])] - mmtmpU1 = vmull_s16(ul_ch128[1], rxdataF128[1]); - //mmtmpU1 = [Re(ch[2])Re(rx[2]) Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3]) Im(ch[3])Im(ch[3])] - mmtmpU0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0),vget_high_s32(mmtmpU0)), - vpadd_s32(vget_low_s32(mmtmpU1),vget_high_s32(mmtmpU1))); - //mmtmpU0 = [Re(ch[0])Re(rx[0])+Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1])+Im(ch[1])Im(ch[1]) Re(ch[2])Re(rx[2])+Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3])+Im(ch[3])Im(ch[3])] - - mmtmpU0b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[0],*(int16x4_t*)conj)), rxdataF128[0]); - //mmtmpU0 = [-Im(ch[0])Re(rx[0]) Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1]) Re(ch[1])Im(rx[1])] - mmtmpU1b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[1],*(int16x4_t*)conj)), rxdataF128[1]); - //mmtmpU0 = [-Im(ch[2])Re(rx[2]) Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3]) Re(ch[3])Im(rx[3])] - mmtmpU1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0b),vget_high_s32(mmtmpU0b)), - vpadd_s32(vget_low_s32(mmtmpU1b),vget_high_s32(mmtmpU1b))); - //mmtmpU1 = [-Im(ch[0])Re(rx[0])+Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1])+Re(ch[1])Im(rx[1]) -Im(ch[2])Re(rx[2])+Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3])+Re(ch[3])Im(rx[3])] - - mmtmpU0 = vqshlq_s32(mmtmpU0,-output_shift128); - mmtmpU1 = vqshlq_s32(mmtmpU1,-output_shift128); - rxdataF_comp128[0] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1)); - mmtmpU0 = vmull_s16(ul_ch128[2], rxdataF128[2]); - mmtmpU1 = vmull_s16(ul_ch128[3], rxdataF128[3]); - mmtmpU0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0),vget_high_s32(mmtmpU0)), - vpadd_s32(vget_low_s32(mmtmpU1),vget_high_s32(mmtmpU1))); - mmtmpU0b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[2],*(int16x4_t*)conj)), rxdataF128[2]); - mmtmpU1b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[3],*(int16x4_t*)conj)), rxdataF128[3]); - mmtmpU1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0b),vget_high_s32(mmtmpU0b)), - vpadd_s32(vget_low_s32(mmtmpU1b),vget_high_s32(mmtmpU1b))); - mmtmpU0 = vqshlq_s32(mmtmpU0,-output_shift128); - mmtmpU1 = vqshlq_s32(mmtmpU1,-output_shift128); - rxdataF_comp128[1] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1)); - - mmtmpU0 = vmull_s16(ul_ch128[4], rxdataF128[4]); - mmtmpU1 = vmull_s16(ul_ch128[5], rxdataF128[5]); - mmtmpU0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0),vget_high_s32(mmtmpU0)), - vpadd_s32(vget_low_s32(mmtmpU1),vget_high_s32(mmtmpU1))); - - mmtmpU0b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[4],*(int16x4_t*)conj)), rxdataF128[4]); - mmtmpU1b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[5],*(int16x4_t*)conj)), rxdataF128[5]); - mmtmpU1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0b),vget_high_s32(mmtmpU0b)), - vpadd_s32(vget_low_s32(mmtmpU1b),vget_high_s32(mmtmpU1b))); - - - mmtmpU0 = vqshlq_s32(mmtmpU0,-output_shift128); - mmtmpU1 = vqshlq_s32(mmtmpU1,-output_shift128); - rxdataF_comp128[2] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1)); - - // Add a jitter to compensate for the saturation in "packs" resulting in a bias on the DC after IDFT - rxdataF_comp128[0] = vqaddq_s16(rxdataF_comp128[0],(*(int16x8_t*)&jitter[0])); - rxdataF_comp128[1] = vqaddq_s16(rxdataF_comp128[1],(*(int16x8_t*)&jitter[0])); - rxdataF_comp128[2] = vqaddq_s16(rxdataF_comp128[2],(*(int16x8_t*)&jitter[0])); - + mmtmpU0 = vmull_s16(ul_ch128[0], rxdataF128[0]); + //mmtmpU0 = [Re(ch[0])Re(rx[0]) Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1]) Im(ch[1])Im(ch[1])] + mmtmpU1 = vmull_s16(ul_ch128[1], rxdataF128[1]); + //mmtmpU1 = [Re(ch[2])Re(rx[2]) Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3]) Im(ch[3])Im(ch[3])] + mmtmpU0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0),vget_high_s32(mmtmpU0)), + vpadd_s32(vget_low_s32(mmtmpU1),vget_high_s32(mmtmpU1))); + //mmtmpU0 = [Re(ch[0])Re(rx[0])+Im(ch[0])Im(ch[0]) Re(ch[1])Re(rx[1])+Im(ch[1])Im(ch[1]) Re(ch[2])Re(rx[2])+Im(ch[2])Im(ch[2]) Re(ch[3])Re(rx[3])+Im(ch[3])Im(ch[3])] + + mmtmpU0b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[0],*(int16x4_t*)conj)), rxdataF128[0]); + //mmtmpU0 = [-Im(ch[0])Re(rx[0]) Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1]) Re(ch[1])Im(rx[1])] + mmtmpU1b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[1],*(int16x4_t*)conj)), rxdataF128[1]); + //mmtmpU0 = [-Im(ch[2])Re(rx[2]) Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3]) Re(ch[3])Im(rx[3])] + mmtmpU1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0b),vget_high_s32(mmtmpU0b)), + vpadd_s32(vget_low_s32(mmtmpU1b),vget_high_s32(mmtmpU1b))); + //mmtmpU1 = [-Im(ch[0])Re(rx[0])+Re(ch[0])Im(rx[0]) -Im(ch[1])Re(rx[1])+Re(ch[1])Im(rx[1]) -Im(ch[2])Re(rx[2])+Re(ch[2])Im(rx[2]) -Im(ch[3])Re(rx[3])+Re(ch[3])Im(rx[3])] - ul_ch128+=6; - ul_ch_mag128+=3; - ul_ch_mag128b+=3; - rxdataF128+=6; - rxdataF_comp128+=3; - + mmtmpU0 = vqshlq_s32(mmtmpU0,-output_shift128); + mmtmpU1 = vqshlq_s32(mmtmpU1,-output_shift128); + rxdataF_comp128[0] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1)); + mmtmpU0 = vmull_s16(ul_ch128[2], rxdataF128[2]); + mmtmpU1 = vmull_s16(ul_ch128[3], rxdataF128[3]); + mmtmpU0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0),vget_high_s32(mmtmpU0)), + vpadd_s32(vget_low_s32(mmtmpU1),vget_high_s32(mmtmpU1))); + mmtmpU0b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[2],*(int16x4_t*)conj)), rxdataF128[2]); + mmtmpU1b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[3],*(int16x4_t*)conj)), rxdataF128[3]); + mmtmpU1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0b),vget_high_s32(mmtmpU0b)), + vpadd_s32(vget_low_s32(mmtmpU1b),vget_high_s32(mmtmpU1b))); + mmtmpU0 = vqshlq_s32(mmtmpU0,-output_shift128); + mmtmpU1 = vqshlq_s32(mmtmpU1,-output_shift128); + rxdataF_comp128[1] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1)); + + mmtmpU0 = vmull_s16(ul_ch128[4], rxdataF128[4]); + mmtmpU1 = vmull_s16(ul_ch128[5], rxdataF128[5]); + mmtmpU0 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0),vget_high_s32(mmtmpU0)), + vpadd_s32(vget_low_s32(mmtmpU1),vget_high_s32(mmtmpU1))); + + mmtmpU0b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[4],*(int16x4_t*)conj)), rxdataF128[4]); + mmtmpU1b = vmull_s16(vrev32_s16(vmul_s16(ul_ch128[5],*(int16x4_t*)conj)), rxdataF128[5]); + mmtmpU1 = vcombine_s32(vpadd_s32(vget_low_s32(mmtmpU0b),vget_high_s32(mmtmpU0b)), + vpadd_s32(vget_low_s32(mmtmpU1b),vget_high_s32(mmtmpU1b))); + + + mmtmpU0 = vqshlq_s32(mmtmpU0,-output_shift128); + mmtmpU1 = vqshlq_s32(mmtmpU1,-output_shift128); + rxdataF_comp128[2] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1)); + + // Add a jitter to compensate for the saturation in "packs" resulting in a bias on the DC after IDFT + rxdataF_comp128[0] = vqaddq_s16(rxdataF_comp128[0],(*(int16x8_t*)&jitter[0])); + rxdataF_comp128[1] = vqaddq_s16(rxdataF_comp128[1],(*(int16x8_t*)&jitter[0])); + rxdataF_comp128[2] = vqaddq_s16(rxdataF_comp128[2],(*(int16x8_t*)&jitter[0])); + + + ul_ch128+=6; + ul_ch_mag128+=3; + ul_ch_mag128b+=3; + rxdataF128+=6; + rxdataF_comp128+=3; #endif + } } @@ -1669,7 +1566,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB, #endif - for (l=0; l<frame_parms->symbols_per_tti-ulsch[UE_id]->harq_processes[harq_pid]->srs_active; l++) { + for (l=0; l<(frame_parms->symbols_per_tti-ulsch[UE_id]->harq_processes[harq_pid]->srs_active); l++) { if (((frame_parms->Ncp == 0) && ((l==3) || (l==10)))|| // skip pilots ((frame_parms->Ncp == 1) && ((l==2) || (l==8)))) { @@ -1688,34 +1585,34 @@ void rx_ulsch(PHY_VARS_eNB *eNB, ulsch[UE_id]->harq_processes[harq_pid]->nb_rb, log2_maxh); // log2_maxh+I0_shift - } + - if (frame_parms->nb_antennas_rx > 1) - ulsch_detection_mrc(frame_parms, + if (frame_parms->nb_antennas_rx > 1) + ulsch_detection_mrc(frame_parms, + pusch_vars->rxdataF_comp, + pusch_vars->ul_ch_mag, + pusch_vars->ul_ch_magb, + l, + ulsch[UE_id]->harq_processes[harq_pid]->nb_rb); + + + + // if ((eNB->measurements.n0_power_dB[0]+3)<pusch_vars->ulsch_power[0]) { + if (23<pusch_vars->ulsch_power[0]) { + freq_equalization(frame_parms, pusch_vars->rxdataF_comp, pusch_vars->ul_ch_mag, pusch_vars->ul_ch_magb, l, - ulsch[UE_id]->harq_processes[harq_pid]->nb_rb); - -#ifndef OFDMA_ULSCH - - if ((eNB->measurements.n0_power_dB[0]+3)<pusch_vars->ulsch_power[0]) { - - freq_equalization(frame_parms, - pusch_vars->rxdataF_comp, - pusch_vars->ul_ch_mag, - pusch_vars->ul_ch_magb, - l, - ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12, - Qm); + ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12, + Qm); + } } -#endif -#ifndef OFDMA_ULSCH + //#ifdef DEBUG_ULSCH // Inverse-Transform equalized outputs @@ -1726,7 +1623,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB, // printf("Done\n"); //#endif //DEBUG_ULSCH -#endif + diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 7040bbaa9751e7917ae405a7d1c686db78f0f549..bffac5d7b16bd465638c5685de6f1e148e517a1d 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -803,6 +803,7 @@ typedef struct PHY_VARS_eNB_s { /// Module ID indicator for this instance module_id_t Mod_id; uint8_t CC_id; + uint8_t configured; eNB_proc_t proc; int single_thread_flag; int abstraction_flag; @@ -827,6 +828,9 @@ typedef struct PHY_VARS_eNB_s { PHY_MEASUREMENTS_eNB measurements; IF_Module_t *if_inst; UL_IND_t UL_INFO; + pthread_mutex_t UL_INFO_mutex; + nfapi_rx_indication_pdu_t rx_pdu_list[NFAPI_RX_IND_MAX_PDU]; + nfapi_crc_indication_pdu_t crc_pdu_list[NFAPI_CRC_IND_MAX_PDU]; Sched_Rsp_t Sched_INFO; LTE_eNB_PDCCH pdcch_vars[2]; LTE_eNB_COMMON common_vars; diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h index 9452c5f00e5a0b7f3611aea4543221f744205037..f37ec179cd438d9d4038c5aee17e87325367d910 100644 --- a/openair1/PHY/impl_defs_lte.h +++ b/openair1/PHY/impl_defs_lte.h @@ -35,6 +35,7 @@ #include "types.h" +#include "nfapi_interface.h" //#include "defs.h" #include "openair2/COMMON/platform_types.h" @@ -1048,6 +1049,8 @@ typedef struct { int16_t *prach; } LTE_UE_PRACH; +#define MAX_NUM_RX_PRACH_PREAMBLES 4 + typedef struct { /// \brief ?. /// first index: ? [0..1023] (hard coded) @@ -1060,6 +1063,8 @@ typedef struct { /// first index: rx antenna [0..63] (hard coded) \note Hard coded array size indexed by \c nb_antennas_rx. /// second index: ? [0..2047] (hard coded) int16_t *prach_ifft[64]; + /// NFAPI PRACH information + nfapi_preamble_pdu_t preamble_list[MAX_NUM_RX_PRACH_PREAMBLES]; } LTE_eNB_PRACH; typedef struct { diff --git a/openair1/SCHED/phy_procedures_lte_common.c b/openair1/SCHED/phy_procedures_lte_common.c index 5817d12b0311ca2bb4486f01495aace41072e437..7149ae1f03944e22aaa51e1087d4f829a9e345c1 100644 --- a/openair1/SCHED/phy_procedures_lte_common.c +++ b/openair1/SCHED/phy_procedures_lte_common.c @@ -951,6 +951,7 @@ int is_srs_occasion_common(LTE_DL_FRAME_PARMS *frame_parms,int frame_tx,int subf } LOG_D(PHY," ISTDD: %d, TSFC: %d, deltaTSFC: %d, AbsSubframeTX: %d.%d\n", frame_parms->frame_type, TSFC, deltaTSFC, frame_tx, subframe_tx); } + LOG_D(PHY," isSubframeSRS %d\n", isSubframeSRS); return(isSubframeSRS); } diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 95f823e2e7fcc08b7944383820a3c510d96645fa..16b7b02f55f0164cd512899ff38434287a11fc31 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -620,7 +620,6 @@ void generate_eNB_dlsch_params(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC } } -*/ void generate_eNB_ulsch_params(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc,const int UE_id) { @@ -628,12 +627,12 @@ void generate_eNB_ulsch_params(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; int frame = proc->frame_tx; int subframe = proc->subframe_tx; - /* - uint16_t srsPeriodicity=0; - uint16_t srsOffset=0; - uint16_t srsConfigIndex=0; - uint16_t do_srs=0; - */ + +// uint16_t srsPeriodicity=0; +// uint16_t srsOffset=0; +// uint16_t srsConfigIndex=0; +// uint16_t do_srs=0; + uint16_t is_srs_pos=0; LOG_I(PHY, @@ -651,18 +650,18 @@ void generate_eNB_ulsch_params(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC 1<<dci_alloc->L); is_srs_pos = is_srs_occasion_common(fp,pdcch_alloc2ul_frame(fp,frame,subframe),pdcch_alloc2ul_subframe(fp,subframe)); - /* - if (is_srs_pos && eNB->soundingrs_ul_config_dedicated[UE_id].srsConfigDedicatedSetup) { - srsConfigIndex = eNB->soundingrs_ul_config_dedicated[UE_id].srs_ConfigIndex; - compute_srs_pos(fp->frame_type, srsConfigIndex, &srsPeriodicity, &srsOffset); - if ((((10*pdcch_alloc2ul_frame(fp,frame,subframe)+pdcch_alloc2ul_subframe(fp,subframe)) % srsPeriodicity) == srsOffset)) { - do_srs = 1; - } - } - LOG_D(PHY,"frame %d (%d), subframe %d (%d), UE_id %d: is_srs_pos %d, do_SRS %d, index %d, period %d, offset %d \n", - frame,pdcch_alloc2ul_frame(fp,frame,subframe),subframe,pdcch_alloc2ul_subframe(fp,subframe), - UE_id,is_srs_pos,do_srs,srsConfigIndex,srsPeriodicity,srsOffset); - */ + +//if (is_srs_pos && eNB->soundingrs_ul_config_dedicated[UE_id].srsConfigDedicatedSetup) { +// srsConfigIndex = eNB->soundingrs_ul_config_dedicated[UE_id].srs_ConfigIndex; +// compute_srs_pos(fp->frame_type, srsConfigIndex, &srsPeriodicity, &srsOffset); +// if ((((10*pdcch_alloc2ul_frame(fp,frame,subframe)+pdcch_alloc2ul_subframe(fp,subframe)) % srsPeriodicity) == srsOffset)) { +// do_srs = 1; +// } +// } +// LOG_D(PHY,"frame %d (%d), subframe %d (%d), UE_id %d: is_srs_pos %d, do_SRS %d, index %d, period %d, offset %d \n", +// frame,pdcch_alloc2ul_frame(fp,frame,subframe),subframe,pdcch_alloc2ul_subframe(fp,subframe), +// UE_id,is_srs_pos,do_srs,srsConfigIndex,srsPeriodicity,srsOffset); +// generate_eNB_ulsch_params_from_dci(eNB, proc, @@ -698,6 +697,7 @@ void generate_eNB_ulsch_params(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC T_INT(dci_alloc->L), T_INT(dci_alloc->firstCCE)); } +*/ void pdsch_procedures(PHY_VARS_eNB *eNB, eNB_rxtx_proc_t *proc, @@ -922,6 +922,20 @@ void handle_nfapi_hi_dci0_dci_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, fill_dci_and_ulsch(eNB,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci],pdu); } +void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, + nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu); + + +void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, + nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) { + + nfapi_hi_dci0_hi_pdu *pdu = &hi_dci0_config_pdu->hi_pdu; + // copy dci configuration in to eNB structure + LOG_I(PHY,"Received HI PDU which 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); +} handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, nfapi_dl_config_request_pdu_t *dl_config_pdu, @@ -971,75 +985,128 @@ handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, } +handle_nfapi_ul_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, + nfapi_ul_config_request_pdu_t *ul_config_pdu) { + + nfapi_ul_config_ulsch_pdu_rel8_t *rel8 = &ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8; + int8_t UE_id; + // check if we have received a dci for this ue and ulsch descriptor is configured + + AssertFatal((UE_id = find_ulsch(rel8->rnti,eNB,SEARCH_EXIST))>=0, + "No existing UE ULSCH for rnti %x\n",rel8->rnti); + AssertFatal(eNB->ulsch[UE_id]->harq_mask > 0, + "ulsch for UE_id %d is not active\n",UE_id); + +} + void schedule_response(Sched_Rsp_t *Sched_INFO) { PHY_VARS_eNB *eNB; eNB_rxtx_proc_t *proc; // copy data from L2 interface into L1 structures - module_id_t Mod_id = Sched_INFO->module_id; - uint8_t CC_id = Sched_INFO->CC_id; - nfapi_dl_config_request_body_t *DL_req = Sched_INFO->DL_req; - nfapi_hi_dci0_request_body_t *HI_DCI0_req = Sched_INFO->HI_DCI0_req; - frame_t frame = Sched_INFO->frame; - sub_frame_t subframe = Sched_INFO->subframe; + module_id_t Mod_id = Sched_INFO->module_id; + uint8_t CC_id = Sched_INFO->CC_id; + nfapi_dl_config_request_t *DL_req = Sched_INFO->DL_req; + nfapi_hi_dci0_request_t *HI_DCI0_req = Sched_INFO->HI_DCI0_req; + nfapi_ul_config_request_t *UL_req = Sched_INFO->UL_req; + nfapi_tx_request_t *TX_req = Sched_INFO->TX_req; + frame_t frame = Sched_INFO->frame; + sub_frame_t subframe = Sched_INFO->subframe; + LTE_DL_FRAME_PARMS *fp; + int ul_subframe; + 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]; - proc = &eNB->proc.proc_rxtx[0]; + eNB = RC.eNB[Mod_id][CC_id]; + fp = &eNB->frame_parms; + proc = &eNB->proc.proc_rxtx[0]; + ul_subframe = pdcch_alloc2ul_subframe(fp,subframe); + ul_frame = pdcch_alloc2ul_frame(fp,frame,subframe); AssertFatal(proc->subframe_tx == subframe, "Current subframe %d != NFAPI subframe %d\n",proc->subframe_tx,subframe); AssertFatal(proc->subframe_tx == subframe, "Current frame %d != NFAPI frame %d\n",proc->frame_tx,frame); - uint8_t number_dl_pdu = DL_req->number_pdu; - uint8_t number_hi_dci0_pdu = HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi; - uint8_t number_pdsch_rnti = DL_req->number_pdsch_rnti; - uint8_t transmission_power_pcfich = DL_req->transmission_power_pcfich; + int8_t UE_id; + 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->ul_config_request_body.number_of_pdus; + uint8_t number_pdsch_rnti = DL_req->dl_config_request_body.number_pdsch_rnti; + uint8_t transmission_power_pcfich = DL_req->dl_config_request_body.transmission_power_pcfich; nfapi_dl_config_request_pdu_t *dl_config_pdu; - nfapi_hi_dci0_request_pdu_t *hi_dci0_req_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 = DL_req->number_pdcch_ofdm_symbols; + eNB->pdcch_vars[subframe&1].num_pdcch_symbols = DL_req->dl_config_request_body.number_pdcch_ofdm_symbols; eNB->pdcch_vars[subframe&1].num_dci = 0; - LOG_I(PHY,"NFAPI: received %d dl_pdu, %d tx_req\n",number_dl_pdu,Sched_INFO->TX_req->number_of_pdus); + LOG_I(PHY,"NFAPI: received %d dl_pdu, %d tx_req, %d hi_dci0_config_req, %d UL_config \n", + number_dl_pdu,TX_req->tx_request_body.number_of_pdus,number_hi_dci0_pdu,number_ul_pdu); + + + if ((subframe_select(fp,ul_subframe)==SF_UL) || + (fp->frame_type == FDD)) { + 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++) { + if (eNB->ulsch[i]) { + ulsch_harq = eNB->ulsch[i]->harq_processes[harq_pid]; + ulsch_harq->dci_alloc=0; + ulsch_harq->rar_alloc=0; + } + } + } for (i=0;i<number_dl_pdu;i++) { - dl_config_pdu = &DL_req->dl_config_pdu_list[i]; + dl_config_pdu = &DL_req->dl_config_request_body.dl_config_pdu_list[i]; LOG_I(PHY,"NFAPI: dl_pdu %d : type %d\n",i,dl_config_pdu->pdu_type); switch (dl_config_pdu->pdu_type) { case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: handle_nfapi_dci_dl_pdu(eNB,proc,dl_config_pdu); - eNB->pdcch_vars[subframe&1].num_dci++; + eNB->pdcch_vars[subframe&1].num_dci++; break; case NFAPI_DL_CONFIG_BCH_PDU_TYPE: - AssertFatal(dl_config_pdu->bch_pdu.bch_pdu_rel8.pdu_index<Sched_INFO->TX_req->number_of_pdus, + 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, - Sched_INFO->TX_req->number_of_pdus); + TX_req->tx_request_body.number_of_pdus); eNB->pbch_configured=1; - handle_nfapi_bch_pdu(eNB,proc,dl_config_pdu,Sched_INFO->TX_req->tx_pdu_list[dl_config_pdu->bch_pdu.bch_pdu_rel8.pdu_index].segments[0].segment_data); + 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: - AssertFatal(dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index<Sched_INFO->TX_req->number_of_pdus, + 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, - Sched_INFO->TX_req->number_of_pdus); + TX_req->tx_request_body.number_of_pdus); AssertFatal((dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks<3) && (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks>0), "dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = %d not in [1,2]\n", dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks); handle_nfapi_dlsch_pdu(eNB,proc,dl_config_pdu, dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks-1, - Sched_INFO->TX_req->tx_pdu_list[dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data); + TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data); + if (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti == eNB->prach_vars.preamble_list[0].preamble_rel8.rnti) {// is RAR pdu + + 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; case NFAPI_DL_CONFIG_PCH_PDU_TYPE: // handle_nfapi_pch_pdu(eNB,dl_config_pdu); @@ -1060,15 +1127,28 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) { } for (i=0;i<number_hi_dci0_pdu;i++) { - hi_dci0_req_pdu = &HI_DCI0_req->hi_dci0_pdu_list[i]; + hi_dci0_req_pdu = &HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list[i]; switch (hi_dci0_req_pdu->pdu_type) { case NFAPI_HI_DCI0_DCI_PDU_TYPE: handle_nfapi_hi_dci0_dci_pdu(eNB,proc,hi_dci0_req_pdu); eNB->pdcch_vars[subframe&1].num_dci++; break; + + case NFAPI_HI_DCI0_HI_PDU_TYPE: + handle_nfapi_hi_dci0_hi_pdu(eNB,proc,hi_dci0_req_pdu); + eNB->pdcch_vars[subframe&1].num_dci++; + break; } } + + for (i=0;i<number_ul_pdu;i++) { + ul_config_pdu = &UL_req->ul_config_request_body.ul_config_pdu_list[i]; + LOG_I(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, + "Optional UL_PDU type %d not supported\n",ul_config_pdu->pdu_type); + handle_nfapi_ul_pdu(eNB,proc,ul_config_pdu); + } } @@ -1090,6 +1170,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, uint8_t ul_subframe; uint32_t ul_frame; LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; + LTE_UL_eNB_HARQ_t *ulsch_harq; int offset = eNB->CC_id;//proc == &eNB->proc.proc_rxtx[0] ? 0 : 1; @@ -1173,17 +1254,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, ul_subframe = pdcch_alloc2ul_subframe(fp,subframe); ul_frame = pdcch_alloc2ul_frame(fp,frame,subframe); - if ((subframe_select(fp,ul_subframe)==SF_UL) || - (fp->frame_type == FDD)) { - 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++) - if (eNB->ulsch[i]) { - eNB->ulsch[i]->harq_processes[harq_pid]->dci_alloc=0; - eNB->ulsch[i]->harq_processes[harq_pid]->rar_alloc=0; - } - } // clear previous allocation information for all UEs for (i=0; i<NUMBER_OF_UE_MAX; i++) { @@ -1193,7 +1264,10 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, /* save old HARQ information needed for PHICH generation */ for (i=0; i<NUMBER_OF_UE_MAX; i++) { + 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 @@ -1214,11 +1288,8 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, */ if ((subframe_select(fp,ul_subframe)==SF_UL) || (fp->frame_type == FDD)) { - harq_pid = subframe2harq_pid(fp,ul_frame,ul_subframe); - eNB->ulsch[i]->harq_processes[harq_pid]->previous_first_rb = - eNB->ulsch[i]->harq_processes[harq_pid]->first_rb; - eNB->ulsch[i]->harq_processes[harq_pid]->previous_n_DMRS = - eNB->ulsch[i]->harq_processes[harq_pid]->n_DMRS; + ulsch_harq->previous_first_rb = ulsch_harq->first_rb; + ulsch_harq->previous_n_DMRS = ulsch_harq->n_DMRS; } } } @@ -1233,29 +1304,6 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, num_dci); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,num_pdcch_symbols); - // loop over all DCIs for this subframe to generate DLSCH allocations - /* - for (i=0; i<num_dci ; i++) { - dci_alloc = &eNB_pdcch_vars[subframe&1].dci_alloc[i]; - LOG_D(PHY,"[eNB] Subframe %d: DCI %d/%d : rnti %x, CCEind %d\n",subframe,i,num_dci,dci_alloc->rnti,dci_alloc->firstCCE); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,dci_alloc->rnti); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,dci_alloc->format); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,dci_alloc->firstCCE); - - - if ((dci_alloc->rnti<= P_RNTI) && - (dci_alloc->ra_flag!=1)) { - if (eNB->mac_enabled==1) - UE_id = find_ue((int16_t)dci_alloc->rnti,eNB); - else - UE_id = i; - } - else UE_id=0; - - generate_eNB_dlsch_params(eNB,proc,dci_alloc,UE_id); - - } - */ VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,(frame*10)+subframe); @@ -1263,100 +1311,22 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, // This is for UEs that have received this IE, which changes these DL and UL configuration, we apply after a delay for the eNodeB UL parameters phy_config_dedicated_eNB_step2(eNB); - // Now loop again over the DCIs for UL configuration - /* - for (i=0; i<DCI_pdu->Num_common_dci + DCI_pdu->Num_ue_spec_dci ; i++) { - dci_alloc = &DCI_pdu->dci_alloc[i]; - - if (dci_alloc->format == format0) { // this is a ULSCH allocation - if (eNB->mac_enabled==1) - UE_id = find_ue((int16_t)dci_alloc->rnti,eNB); - else - UE_id = i; - - if (UE_id<0) { // should not happen, log an error and exit, this is a fatal error - LOG_E(PHY,"[eNB %"PRIu8"] Frame %d: Unknown UE_id for rnti %"PRIx16"\n",eNB->Mod_id,frame,dci_alloc->rnti); - mac_xface->macphy_exit("FATAL\n"); - } - generate_eNB_ulsch_params(eNB,proc,dci_alloc,UE_id); - } - } - */ - - - - - // if we have DCI to generate do it now - /* - if (num_dci>0) { - - - } else { // for emulation!! - eNB->num_ue_spec_dci[(subframe)&1]=0; - eNB->num_common_dci[(subframe)&1]=0; - } - */ - - if (num_dci > 0) { + if (num_dci > 0) LOG_I(PHY,"[eNB %"PRIu8"] Frame %d, subframe %d: Calling generate_dci_top (pdcch) (num_dci %"PRIu8")\n",eNB->Mod_id,frame, subframe, num_dci); - - - num_pdcch_symbols = generate_dci_top(num_dci, - &eNB->pdcch_vars[subframe&1].dci_alloc[0], - 0, - AMP, - fp, - eNB->common_vars.txdataF, - subframe); - if (num_dci > 0) { - LOG_I(PHY,"[eNB %"PRIu8"] Frame %d, subframe %d: num_pdcch_symbols %d\n",eNB->Mod_id,frame, subframe, - num_pdcch_symbols); - } - } + generate_dci_top(num_pdcch_symbols, + num_dci, + &eNB->pdcch_vars[subframe&1].dci_alloc[0], + 0, + AMP, + fp, + eNB->common_vars.txdataF, + subframe); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,0); - // Check for SI activity - /* - if ((eNB->dlsch_SI) && (eNB->dlsch_SI->active == 1)) { - - pdsch_procedures(eNB, - proc, - 0, - eNB->dlsch_SI, - (LTE_eNB_DLSCH_t*)NULL, - (LTE_eNB_UE_stats*)NULL, - 0, - num_pdcch_symbols); - - } - */ - // Check for RA activity - /* - if ((eNB->dlsch_ra) && (eNB->dlsch_ra->active == 1)) { - - LOG_D(PHY,"[eNB %"PRIu8"][RAPROC] Frame %d, subframe %d: Calling generate_dlsch (RA),Msg3 frame %"PRIu32", Msg3 subframe %"PRIu8"\n", - eNB->Mod_id, - frame, subframe, - eNB->ulsch[(uint32_t)UE_id]->Msg3_frame, - eNB->ulsch[(uint32_t)UE_id]->Msg3_subframe); - - pdsch_procedures(eNB, - proc, - 0, - eNB->dlsch_ra, - (LTE_eNB_DLSCH_t*)NULL, - (LTE_eNB_UE_stats*)NULL, - 1, - num_pdcch_symbols); - - - eNB->dlsch_ra->active = 0; - } - */ - // Now scan UE specific DLSCH for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { @@ -1419,24 +1389,26 @@ void process_Msg3(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,uint8_t UE_id, uint8_t // this prepares the demodulation of the first PUSCH of a new user, containing Msg3 int subframe = proc->subframe_rx; int frame = proc->frame_rx; + LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id]; + LTE_UL_eNB_HARQ_t *ulsch_harq=ulsch->harq_processes[harq_pid]; LOG_D(PHY,"[eNB %d][RAPROC] frame %d : subframe %d : process_Msg3 UE_id %d (active %d, subframe %d, frame %d)\n", eNB->Mod_id, frame,subframe, - UE_id,eNB->ulsch[(uint32_t)UE_id]->Msg3_active, - eNB->ulsch[(uint32_t)UE_id]->Msg3_subframe, - eNB->ulsch[(uint32_t)UE_id]->Msg3_frame); - eNB->ulsch[(uint32_t)UE_id]->Msg3_flag = 0; + UE_id,ulsch->Msg3_active, + ulsch_harq->subframe, + ulsch_harq->frame); + + ulsch_harq->Msg3_flag = 0; - if ((eNB->ulsch[(uint32_t)UE_id]->Msg3_active == 1) && - (eNB->ulsch[(uint32_t)UE_id]->Msg3_subframe == subframe) && - (eNB->ulsch[(uint32_t)UE_id]->Msg3_frame == (uint32_t)frame)) { + if ((ulsch->Msg3_active == 1) && + (ulsch_harq->subframe == subframe) && + (ulsch_harq->frame == (uint32_t)frame)) { // harq_pid = 0; - eNB->ulsch[(uint32_t)UE_id]->Msg3_active = 0; - eNB->ulsch[(uint32_t)UE_id]->Msg3_flag = 1; - eNB->ulsch[(uint32_t)UE_id]->harq_processes[harq_pid]->subframe_scheduling_flag=1; + ulsch->Msg3_active = 0; + ulsch_harq->Msg3_flag = 1; LOG_D(PHY,"[eNB %d][RAPROC] frame %d, subframe %d: Setting subframe_scheduling_flag (Msg3) for UE %d\n", eNB->Mod_id, frame,subframe,UE_id); @@ -1869,7 +1841,6 @@ void prach_procedures(PHY_VARS_eNB *eNB) { uint16_t preamble_energy_list[64],preamble_delay_list[64]; uint16_t preamble_max,preamble_energy_max; uint16_t i; - int8_t UE_id; int subframe = eNB->proc.subframe_prach; int frame = eNB->proc.frame_prach; uint8_t CC_id = eNB->CC_id; @@ -1914,63 +1885,73 @@ void prach_procedures(PHY_VARS_eNB *eNB) { // UE_id = find_next_ue_index(eNB); - if (UE_id>=0) { - eNB->UE_stats[(uint32_t)UE_id].UE_timing_offset = preamble_delay_list[preamble_max]&0x1FFF; //limit to 13 (=11+2) bits + // if (UE_id>=0) { + // eNB->UE_stats[(uint32_t)UE_id].UE_timing_offset = preamble_delay_list[preamble_max]&0x1FFF; //limit to 13 (=11+2) bits - eNB->UE_stats[(uint32_t)UE_id].sector = 0; - LOG_I(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure (UE_id %d) with preamble %d, energy %d.%d dB, delay %d\n", - eNB->Mod_id, - eNB->CC_id, - frame, - subframe, - UE_id, - preamble_max, - preamble_energy_max/10, - preamble_energy_max%10, - preamble_delay_list[preamble_max]); - - T(T_ENB_PHY_INITIATE_RA_PROCEDURE, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(UE_id), - T_INT(preamble_max), T_INT(preamble_energy_max), T_INT(preamble_delay_list[preamble_max])); + // eNB->UE_stats[(uint32_t)UE_id].sector = 0; + 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, + preamble_max, + preamble_energy_max/10, + preamble_energy_max%10, + preamble_delay_list[preamble_max]); + + T(T_ENB_PHY_INITIATE_RA_PROCEDURE, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), 0, + T_INT(preamble_max), T_INT(preamble_energy_max), T_INT(preamble_delay_list[preamble_max])); - if (eNB->mac_enabled==1) { - uint8_t update_TA = 4; - uint8_t update_TA2 = 1; - switch (fp->N_RB_DL) { - case 6: - update_TA = 16; - break; - - case 25: - update_TA = 4; - break; - - case 50: - update_TA = 2; - break; - - case 75: - update_TA = 3; - update_TA2 = 2; - case 100: - update_TA = 1; - break; - } - /* + if (eNB->mac_enabled==1) { + LTE_eNB_PRACH *prach_vars = &eNB->prach_vars; + + uint8_t update_TA = 4; + uint8_t update_TA2 = 1; + switch (fp->N_RB_DL) { + case 6: + update_TA = 16; + break; + + case 25: + update_TA = 4; + break; + + case 50: + update_TA = 2; + break; + + case 75: + update_TA = 3; + update_TA2 = 2; + case 100: + update_TA = 1; + break; + } + pthread_mutex_lock(&eNB->UL_INFO_mutex); + eNB->UL_INFO.rach_ind.number_of_preambles = 1; + eNB->UL_INFO.rach_ind.preamble_list = prach_vars->preamble_list; + + prach_vars->preamble_list[0].preamble_rel8.timing_advance = preamble_delay_list[preamble_max]*update_TA/update_TA2; + prach_vars->preamble_list[0].preamble_rel8.preamble = preamble_max; + prach_vars->preamble_list[0].preamble_rel8.rnti = 1+subframe; // note: fid is implicitly 0 here + prach_vars->preamble_list[0].instance_length = 0; //don't know exactly what this is + pthread_mutex_unlock(&eNB->UL_INFO_mutex); + /* mac_xface->initiate_ra_proc(eNB->Mod_id, - eNB->CC_id, - frame, - preamble_max, - preamble_delay_list[preamble_max]*update_TA/update_TA2, - 0,subframe,0);*/ - - // fill eNB->UL_info with prach information - } - - } else { - MSC_LOG_EVENT(MSC_PHY_ENB, "0 RA Failed add user, too many"); - LOG_I(PHY,"[eNB %d][RAPROC] frame %d, subframe %d: Unable to add user, max user count reached\n", - eNB->Mod_id,frame, subframe); - } + eNB->CC_id, + frame, + preamble_max, + preamble_delay_list[preamble_max]*update_TA/update_TA2, + 0,subframe,0);*/ + + // fill eNB->UL_info with prach information + } + + /* } else { + MSC_LOG_EVENT(MSC_PHY_ENB, "0 RA Failed add user, too many"); + LOG_I(PHY,"[eNB %d][RAPROC] frame %d, subframe %d: Unable to add user, max user count reached\n", + eNB->Mod_id,frame, subframe); + }*/ } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PRACH_RX,0); } @@ -1990,7 +1971,8 @@ void pucch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,int UE_id,int harq if ((eNB->dlsch[UE_id][0]) && (eNB->dlsch[UE_id][0]->rnti>0) && - (eNB->ulsch[UE_id]->harq_processes[harq_pid]->subframe_scheduling_flag==0)) { + (eNB->ulsch[UE_id]->harq_processes[harq_pid]->frame != frame) && + (eNB->ulsch[UE_id]->harq_processes[harq_pid]->subframe != subframe)) { // check SR availability do_SR = is_SR_subframe(eNB,proc,UE_id); @@ -2324,6 +2306,88 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc){ */ +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 = subframe2harq_pid(&eNB->frame_parms, + frame,subframe); + + pthread_mutex_lock(&eNB->UL_INFO_mutex); + pdu = &eNB->UL_INFO.rx_ind.rx_pdu_list[eNB->UL_INFO.rx_ind.number_of_pdus]; + + // pdu->rx_ue_information.handle = eNB->ulsch[UE_id]->handle; + pdu->rx_ue_information.rnti = eNB->ulsch[UE_id]->rnti; + pdu->rx_indication_rel8.length = eNB->ulsch[UE_id]->harq_processes[harq_pid]->TBS>>3; + pdu->rx_indication_rel8.offset = 0; // filled in at the end of the UL_INFO formation + 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 + switch (eNB->frame_parms.N_RB_DL) { + case 6: + pdu->rx_indication_rel8.timing_advance = timing_advance_update; + break; + case 15: + pdu->rx_indication_rel8.timing_advance = timing_advance_update/2; + break; + case 25: + pdu->rx_indication_rel8.timing_advance = timing_advance_update/4; + break; + case 50: + pdu->rx_indication_rel8.timing_advance = timing_advance_update/8; + break; + case 75: + pdu->rx_indication_rel8.timing_advance = timing_advance_update/12; + break; + case 100: + pdu->rx_indication_rel8.timing_advance = timing_advance_update/16; + break; + } + // put timing advance command in 0..63 range + pdu->rx_indication_rel8.timing_advance += 31; + if (pdu->rx_indication_rel8.timing_advance < 0) pdu->rx_indication_rel8.timing_advance = 0; + if (pdu->rx_indication_rel8.timing_advance > 63) pdu->rx_indication_rel8.timing_advance = 63; + + // estimate UL_CQI for MAC (from antenna port 0 only) + int SNRtimes10 = dB_fixed_times10(eNB->pusch_vars[UE_id]->ulsch_power[0]) - 200;//(10*eNB->measurements.n0_power_dB[0]); + + if (SNRtimes10 < -640) pdu->rx_indication_rel8.ul_cqi=0; + else if (SNRtimes10 > 635) pdu->rx_indication_rel8.ul_cqi=255; + else pdu->rx_indication_rel8.ul_cqi=(640+SNRtimes10)/5; + + eNB->UL_INFO.rx_ind.number_of_pdus++; + 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) { + + pthread_mutex_lock(&eNB->UL_INFO_mutex); + nfapi_crc_indication_pdu_t *pdu = &eNB->UL_INFO.crc_ind.crc_pdu_list[eNB->UL_INFO.crc_ind.number_of_crcs]; + + pdu->instance_length = 0; // don't know what to do with this + // pdu->rx_ue_information.handle = handle; + pdu->rx_ue_information.rnti = eNB->ulsch[UE_id]->rnti; + pdu->crc_indication_rel8.crc_flag = crc_flag; + pthread_mutex_unlock(&eNB->UL_INFO_mutex); + + eNB->UL_INFO.crc_ind.number_of_crcs++; + pthread_mutex_unlock(&eNB->UL_INFO_mutex); +} + +void update_harq_scheduling(LTE_DL_FRAME_PARMS *fp,LTE_UL_eNB_HARQ_t *ulsch_harq,int frame,int subframe) { + if (fp->frame_type == FDD) { + ulsch_harq->frame += (ulsch_harq->subframe>1) ? 1 : 0; + ulsch_harq->subframe = (ulsch_harq->subframe + 8)%10; + } + else ulsch_harq->frame++; +} + + void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const relaying_type_t r_type) { //RX processing for ue-specific resources (i @@ -2335,6 +2399,8 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const uint16_t rnti=0; uint8_t access_mode; 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; @@ -2365,6 +2431,9 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const eNB->rb_mask_ul[2]=0; eNB->rb_mask_ul[3]=0; + eNB->UL_INFO.rx_ind.number_of_pdus = 0; + eNB->UL_INFO.crc_ind.number_of_crcs = 0; + // Check for active processes in current subframe harq_pid = subframe2harq_pid(fp, frame,subframe); @@ -2373,6 +2442,9 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const for (i=0; i<NUMBER_OF_UE_MAX; i++) { + ulsch = eNB->ulsch[i]; + ulsch_harq = ulsch->harq_processes[harq_pid]; + // 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 @@ -2394,7 +2466,7 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const LOG_E(PHY,"problem processing SRS\n"); } } - + // Do PUCCH processing pucch_procedures(eNB,proc,i,harq_pid, do_srs); @@ -2402,9 +2474,9 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const // check for Msg3 if (eNB->mac_enabled==1) { - if (eNB->UE_stats[i].mode == RA_RESPONSE) { + // if (eNB->UE_stats[i].mode == RA_RESPONSE) { process_Msg3(eNB,proc,i,harq_pid); - } + // } } @@ -2412,21 +2484,28 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const eNB->pusch_stats_round[i][(frame*10)+subframe] = 0; eNB->pusch_stats_mcs[i][(frame*10)+subframe] = -63; - if ((eNB->ulsch[i]) && + if ((ulsch) && + (eNB->ulsch[i]->rnti>0) && + (ulsch_harq->status = ACTIVE)) + LOG_I(PHY,"Frame %d Subframe UE %d/%x active: scheduled for (%d,%d)\n", + frame,i,eNB->ulsch[i]->rnti,ulsch_harq->frame,ulsch_harq->subframe); + if ((ulsch) && (eNB->ulsch[i]->rnti>0) && - (eNB->ulsch[i]->harq_processes[harq_pid]->subframe_scheduling_flag==1)) { + (ulsch_harq->status = ACTIVE) && + (ulsch_harq->subframe==subframe)&& + (ulsch_harq->frame==frame)) { // UE is has ULSCH scheduling - round = eNB->ulsch[i]->harq_processes[harq_pid]->round; + round = ulsch_harq->round; for (int rb=0; - rb<=eNB->ulsch[i]->harq_processes[harq_pid]->nb_rb; + rb<=ulsch_harq->nb_rb; rb++) { - int rb2 = rb+eNB->ulsch[i]->harq_processes[harq_pid]->first_rb; + int rb2 = rb+ulsch_harq->first_rb; eNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31)); } - if (eNB->ulsch[i]->Msg3_flag == 1) { + if (ulsch_harq->Msg3_flag == 1) { LOG_D(PHY,"[eNB %d] frame %d, subframe %d: Scheduling ULSCH Reception for Msg3 in Sector %d\n", eNB->Mod_id, frame, @@ -2446,38 +2525,38 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const nPRS = fp->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe<<1]; - eNB->ulsch[i]->cyclicShift = (eNB->ulsch[i]->harq_processes[harq_pid]->n_DMRS2 + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift + + ulsch->cyclicShift = (ulsch_harq->n_DMRS2 + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift + nPRS)%12; if (fp->frame_type == FDD ) { int sf = (subframe<4) ? (subframe+6) : (subframe-4); if (eNB->dlsch[i][0]->subframe_tx[sf]>0) { // we have downlink transmission - eNB->ulsch[i]->harq_processes[harq_pid]->O_ACK = 1; + ulsch_harq->O_ACK = 1; } else { - eNB->ulsch[i]->harq_processes[harq_pid]->O_ACK = 0; + ulsch_harq->O_ACK = 0; } } LOG_I(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, mcs %d, TBS %d, rv %d, cyclic_shift %d (n_DMRS2 %d, cyclicShift_common %d, nprs %d), O_ACK %d \n", eNB->Mod_id,harq_pid,frame,subframe, - eNB->ulsch[i]->harq_processes[harq_pid]->dci_alloc, - eNB->ulsch[i]->harq_processes[harq_pid]->rar_alloc, - eNB->ulsch[i]->harq_processes[harq_pid]->round, - eNB->ulsch[i]->harq_processes[harq_pid]->first_rb, - eNB->ulsch[i]->harq_processes[harq_pid]->nb_rb, - eNB->ulsch[i]->harq_processes[harq_pid]->mcs, - eNB->ulsch[i]->harq_processes[harq_pid]->TBS, - eNB->ulsch[i]->harq_processes[harq_pid]->rvidx, + ulsch_harq->dci_alloc, + ulsch_harq->rar_alloc, + ulsch_harq->round, + ulsch_harq->first_rb, + ulsch_harq->nb_rb, + ulsch_harq->mcs, + ulsch_harq->TBS, + ulsch_harq->rvidx, eNB->ulsch[i]->cyclicShift, - eNB->ulsch[i]->harq_processes[harq_pid]->n_DMRS2, + ulsch_harq->n_DMRS2, fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift, nPRS, - eNB->ulsch[i]->harq_processes[harq_pid]->O_ACK); - eNB->pusch_stats_rb[i][(frame*10)+subframe] = eNB->ulsch[i]->harq_processes[harq_pid]->nb_rb; - eNB->pusch_stats_round[i][(frame*10)+subframe] = eNB->ulsch[i]->harq_processes[harq_pid]->round; - eNB->pusch_stats_mcs[i][(frame*10)+subframe] = eNB->ulsch[i]->harq_processes[harq_pid]->mcs; + ulsch_harq->O_ACK); + eNB->pusch_stats_rb[i][(frame*10)+subframe] = ulsch_harq->nb_rb; + eNB->pusch_stats_round[i][(frame*10)+subframe] = ulsch_harq->round; + eNB->pusch_stats_mcs[i][(frame*10)+subframe] = ulsch_harq->mcs; start_meas(&eNB->ulsch_demodulation_stats); rx_ulsch(eNB,proc, @@ -2492,8 +2571,8 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const ret = ulsch_decoding(eNB,proc, i, 0, // control_only_flag - eNB->ulsch[i]->harq_processes[harq_pid]->V_UL_DAI, - eNB->ulsch[i]->harq_processes[harq_pid]->nb_rb>20 ? 1 : 0); + ulsch_harq->V_UL_DAI, + ulsch_harq->nb_rb>20 ? 1 : 0); @@ -2502,99 +2581,102 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const LOG_I(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d RNTI %x RX power (%d,%d) RSSI (%d,%d) N0 (%d,%d) dB ACK (%d,%d), decoding iter %d\n", eNB->Mod_id,harq_pid, frame,subframe, - eNB->ulsch[i]->rnti, + ulsch->rnti, dB_fixed(eNB->pusch_vars[i]->ulsch_power[0]), dB_fixed(eNB->pusch_vars[i]->ulsch_power[1]), eNB->UE_stats[i].UL_rssi[0], eNB->UE_stats[i].UL_rssi[1], - eNB->measurements.n0_power_dB[0], - eNB->measurements.n0_power_dB[1], - eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[0], - eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[1], + 20,//eNB->measurements.n0_power_dB[0], + 20,//eNB->measurements.n0_power_dB[1], + ulsch_harq->o_ACK[0], + ulsch_harq->o_ACK[1], ret); + //compute the expected ULSCH RX power (for the stats) eNB->ulsch[(uint32_t)i]->harq_processes[harq_pid]->delta_TF = get_hundred_times_delta_IF_eNB(eNB,i,harq_pid, 0); // 0 means bw_factor is not considered - eNB->UE_stats[i].ulsch_decoding_attempts[harq_pid][eNB->ulsch[i]->harq_processes[harq_pid]->round]++; + eNB->UE_stats[i].ulsch_decoding_attempts[harq_pid][ulsch_harq->round]++; #ifdef DEBUG_PHY_PROC LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d UE %d harq_pid %d Clearing subframe_scheduling_flag\n", eNB->Mod_id,harq_pid,frame,subframe,i,harq_pid); #endif - eNB->ulsch[i]->harq_processes[harq_pid]->subframe_scheduling_flag=0; - if (eNB->ulsch[i]->harq_processes[harq_pid]->cqi_crc_status == 1) { + if (ulsch_harq->cqi_crc_status == 1) { #ifdef DEBUG_PHY_PROC //if (((frame%10) == 0) || (frame < 50)) - print_CQI(eNB->ulsch[i]->harq_processes[harq_pid]->o,eNB->ulsch[i]->harq_processes[harq_pid]->uci_format,0,fp->N_RB_DL); + print_CQI(ulsch_harq->o,ulsch_harq->uci_format,0,fp->N_RB_DL); #endif - extract_CQI(eNB->ulsch[i]->harq_processes[harq_pid]->o, - eNB->ulsch[i]->harq_processes[harq_pid]->uci_format, + extract_CQI(ulsch_harq->o, + ulsch_harq->uci_format, &eNB->UE_stats[i], fp->N_RB_DL, &rnti, &access_mode); - eNB->UE_stats[i].rank = eNB->ulsch[i]->harq_processes[harq_pid]->o_RI[0]; + eNB->UE_stats[i].rank = ulsch_harq->o_RI[0]; } - if (eNB->ulsch[i]->Msg3_flag == 1) + if (ulsch_harq->Msg3_flag == 1) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_ULSCH_MSG3,0); 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(i), T_INT(eNB->ulsch[i]->rnti), + T(T_ENB_PHY_ULSCH_UE_NACK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(i), T_INT(ulsch->rnti), T_INT(harq_pid)); - eNB->UE_stats[i].ulsch_round_errors[harq_pid][eNB->ulsch[i]->harq_processes[harq_pid]->round]++; - eNB->ulsch[i]->harq_processes[harq_pid]->phich_active = 1; - eNB->ulsch[i]->harq_processes[harq_pid]->phich_ACK = 0; - eNB->ulsch[i]->harq_processes[harq_pid]->round++; + eNB->UE_stats[i].ulsch_round_errors[harq_pid][ulsch_harq->round]++; + ulsch_harq->phich_active = 1; + ulsch_harq->phich_ACK = 0; + ulsch_harq->round++; - LOG_D(PHY,"[eNB][PUSCH %d] Increasing to round %d\n",harq_pid,eNB->ulsch[i]->harq_processes[harq_pid]->round); + update_harq_scheduling(fp,ulsch_harq,frame,subframe); - if (eNB->ulsch[i]->Msg3_flag == 1) { + fill_crc_indication(eNB,i,frame,subframe,1); // indicate NAK to MAC - LOG_I(PHY,"[eNB %d/%d][RAPROC] frame %d, subframe %d, UE %d: Error receiving ULSCH (Msg3), round %d/%d\n", + LOG_D(PHY,"[eNB][PUSCH %d] Increasing to round %d\n",harq_pid,ulsch_harq->round); + + if (ulsch_harq->Msg3_flag == 1) { + + LOG_I(PHY,"[eNB %d/%d][RAPROC] frame %d, subframe %d, UE %d: Error receiving ULSCH (Msg3), round %d\n", eNB->Mod_id, eNB->CC_id, frame,subframe, i, - eNB->ulsch[i]->harq_processes[harq_pid]->round-1, - fp->maxHARQ_Msg3Tx-1); - /* + ulsch_harq->round-1); + dump_ulsch(eNB,proc,i); exit(-1); - */ + LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d RNTI %x RX power (%d,%d) RSSI (%d,%d) N0 (%d,%d) dB ACK (%d,%d), decoding iter %d\n", eNB->Mod_id,harq_pid, frame,subframe, - eNB->ulsch[i]->rnti, + ulsch->rnti, dB_fixed(eNB->pusch_vars[i]->ulsch_power[0]), dB_fixed(eNB->pusch_vars[i]->ulsch_power[1]), eNB->UE_stats[i].UL_rssi[0], eNB->UE_stats[i].UL_rssi[1], eNB->measurements.n0_power_dB[0], eNB->measurements.n0_power_dB[1], - eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[0], - eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[1], + ulsch_harq->o_ACK[0], + ulsch_harq->o_ACK[1], ret); - - if (eNB->ulsch[i]->harq_processes[harq_pid]->round == + /* + if (ulsch_harq->round == fp->maxHARQ_Msg3Tx) { LOG_D(PHY,"[eNB %d][RAPROC] maxHARQ_Msg3Tx reached, abandoning RA procedure for UE %d\n", eNB->Mod_id, i); eNB->UE_stats[i].mode = PRACH; - if (eNB->mac_enabled==1) { /* - mac_xface->cancel_ra_proc(eNB->Mod_id, - eNB->CC_id, - frame, - eNB->UE_stats[i].crnti); - */ - } +// if (eNB->mac_enabled==1) { +// mac_xface->cancel_ra_proc(eNB->Mod_id, +// eNB->CC_id, +// frame, +// eNB->UE_stats[i].crnti); +// +// } // mac_phy_remove_ue(eNB->Mod_id,eNB->UE_stats[i].crnti); eNB->ulsch[(uint32_t)i]->Msg3_active = 0; - //eNB->ulsch[i]->harq_processes[harq_pid]->phich_active = 0; + //ulsch_harq->phich_active = 0; } else { // activate retransmission for Msg3 (signalled to UE PHY by PHICH (not MAC/DCI) @@ -2603,17 +2685,20 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const get_Msg3_alloc_ret(fp, subframe, frame, - &eNB->ulsch[i]->Msg3_frame, - &eNB->ulsch[i]->Msg3_subframe); - /* - mac_xface->set_msg3_subframe(eNB->Mod_id, eNB->CC_id, frame, subframe, eNB->ulsch[i]->rnti, - eNB->ulsch[i]->Msg3_frame, eNB->ulsch[i]->Msg3_subframe); - */ + &ulsch_harq->frame, + &ulsch_harq->subframe); + + //mac_xface->set_msg3_subframe(eNB->Mod_id, eNB->CC_id, frame, subframe, eNB->ulsch[i]->rnti, + // eNB->ulsch[i]->Msg3_frame, eNB->ulsch[i]->Msg3_subframe); + T(T_ENB_PHY_MSG3_ALLOCATION, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), - T_INT(i), T_INT(eNB->ulsch[i]->rnti), T_INT(0 /* 0 is for retransmission*/), + T_INT(i), T_INT(ulsch->rnti), T_INT(0 + // 0 is for retransmission + ), T_INT(eNB->ulsch[i]->Msg3_frame), T_INT(eNB->ulsch[i]->Msg3_subframe)); } +*/ LOG_D(PHY,"[eNB] Frame %d, Subframe %d: Msg3 in error, i = %d \n", frame,subframe,i); } // This is Msg3 error @@ -2621,10 +2706,10 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const 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, - eNB->ulsch[i]->harq_processes[harq_pid]->round-1, - eNB->ulsch[i]->Mlimit, - eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[0], - eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[1]); + ulsch_harq->round-1, + ulsch->Mlimit, + ulsch_harq->o_ACK[0], + ulsch_harq->o_ACK[1]); #if defined(MESSAGE_CHART_GENERATOR_PHY) MSC_LOG_RX_DISCARDED_MESSAGE( @@ -2632,23 +2717,23 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const NULL,0, "%05u:%02u ULSCH received rnti %x harq id %u round %d", frame,subframe, - eNB->ulsch[i]->rnti,harq_pid, - eNB->ulsch[i]->harq_processes[harq_pid]->round-1 + ulsch->rnti,harq_pid, + ulsch_harq->round-1 ); #endif - if (eNB->ulsch[i]->harq_processes[harq_pid]->round== eNB->ulsch[i]->Mlimit) { + if (ulsch_harq->round== ulsch->Mlimit) { LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d UE %d ULSCH Mlimit %d reached\n", eNB->Mod_id,harq_pid, frame,subframe, i, - eNB->ulsch[i]->Mlimit); + ulsch->Mlimit); - eNB->ulsch[i]->harq_processes[harq_pid]->round=0; - eNB->ulsch[i]->harq_processes[harq_pid]->phich_active=0; + ulsch_harq->round=0; + ulsch_harq->phich_active=0; eNB->UE_stats[i].ulsch_errors[harq_pid]++; eNB->UE_stats[i].ulsch_consecutive_errors++; - /*if (eNB->ulsch[i]->harq_processes[harq_pid]->nb_rb > 20) { + /*if (ulsch_harq->nb_rb > 20) { dump_ulsch(eNB,proc,i); exit(-1); }*/ @@ -2658,13 +2743,12 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const mac_xface->rx_sdu(eNB->Mod_id, eNB->CC_id, frame,subframe, - eNB->ulsch[i]->rnti, + ulsch->rnti, NULL, 0, harq_pid, &eNB->ulsch[i]->Msg3_flag); */ - // Fill UL info } } } @@ -2672,26 +2756,27 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const else { - - T(T_ENB_PHY_ULSCH_UE_ACK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(i), T_INT(eNB->ulsch[i]->rnti), + fill_crc_indication(eNB,i,frame,subframe,0); // indicate ACK to MAC + fill_rx_indication(eNB,i,frame,subframe); // indicate SDU to MAC + T(T_ENB_PHY_ULSCH_UE_ACK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(i), T_INT(ulsch->rnti), T_INT(harq_pid)); - if (eNB->ulsch[i]->Msg3_flag == 1) { + if (ulsch_harq->Msg3_flag == 1) { LOG_D(PHY,"[eNB %d][PUSCH %d] Frame %d subframe %d ULSCH received, setting round to 0, PHICH ACK\n", eNB->Mod_id,harq_pid, frame,subframe); LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d RNTI %x RX power (%d,%d) RSSI (%d,%d) N0 (%d,%d) dB ACK (%d,%d), decoding iter %d\n", eNB->Mod_id,harq_pid, frame,subframe, - eNB->ulsch[i]->rnti, + ulsch->rnti, dB_fixed(eNB->pusch_vars[i]->ulsch_power[0]), dB_fixed(eNB->pusch_vars[i]->ulsch_power[1]), eNB->UE_stats[i].UL_rssi[0], eNB->UE_stats[i].UL_rssi[1], eNB->measurements.n0_power_dB[0], eNB->measurements.n0_power_dB[1], - eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[0], - eNB->ulsch[i]->harq_processes[harq_pid]->o_ACK[1], + ulsch_harq->o_ACK[0], + ulsch_harq->o_ACK[1], ret); } #if defined(MESSAGE_CHART_GENERATOR_PHY) @@ -2700,7 +2785,7 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const NULL,0, "%05u:%02u ULSCH received rnti %x harq id %u", frame,subframe, - eNB->ulsch[i]->rnti,harq_pid + ulsch->rnti,harq_pid ); #endif for (j=0; j<fp->nb_antennas_rx; j++) @@ -2708,18 +2793,18 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const eNB->UE_stats[i].UL_rssi[j] = dB_fixed(eNB->pusch_vars[i]->ulsch_power[j]* - (eNB->ulsch[i]->harq_processes[harq_pid]->nb_rb*12)/ + (ulsch_harq->nb_rb*12)/ fp->ofdm_symbol_size) - eNB->rx_total_gain_dB - - hundred_times_log10_NPRB[eNB->ulsch[i]->harq_processes[harq_pid]->nb_rb-1]/100 - + hundred_times_log10_NPRB[ulsch_harq->nb_rb-1]/100 - get_hundred_times_delta_IF_eNB(eNB,i,harq_pid, 0)/100; - eNB->ulsch[i]->harq_processes[harq_pid]->phich_active = 1; - eNB->ulsch[i]->harq_processes[harq_pid]->phich_ACK = 1; - eNB->ulsch[i]->harq_processes[harq_pid]->round = 0; + ulsch_harq->phich_active = 1; + ulsch_harq->phich_ACK = 1; + ulsch_harq->round = 0; eNB->UE_stats[i].ulsch_consecutive_errors = 0; - if (eNB->ulsch[i]->Msg3_flag == 1) { + if (ulsch_harq->Msg3_flag == 1) { if (eNB->mac_enabled==1) { LOG_I(PHY,"[eNB %d][RAPROC] Frame %d Terminating ra_proc for harq %d, UE %d\n", @@ -2731,15 +2816,15 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const eNB->CC_id, frame,subframe, eNB->ulsch[i]->rnti, - eNB->ulsch[i]->harq_processes[harq_pid]->b, - eNB->ulsch[i]->harq_processes[harq_pid]->TBS>>3, + ulsch_harq->b, + ulsch_harq->TBS>>3, harq_pid, - &eNB->ulsch[i]->Msg3_flag); + &ulsch->Msg3_flag); */ // Fill UL info } // one-shot msg3 detection by MAC: empty PDU (e.g. CRNTI) - if (eNB->ulsch[i]->Msg3_flag == 0 ) { + if (ulsch_harq->Msg3_flag == 0 ) { eNB->UE_stats[i].mode = PRACH; /* mac_xface->cancel_ra_proc(eNB->Mod_id, @@ -2755,7 +2840,7 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const } // mac_enabled==1 eNB->UE_stats[i].mode = PUSCH; - eNB->ulsch[i]->Msg3_flag = 0; + ulsch_harq->Msg3_flag = 0; LOG_D(PHY,"[eNB %d][RAPROC] Frame %d : RX Subframe %d Setting UE %d mode to PUSCH\n",eNB->Mod_id,frame,subframe,i); @@ -2770,7 +2855,7 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const eNB->UE_stats[i].ulsch_errors[k]=0; eNB->UE_stats[i].ulsch_consecutive_errors=0; - for (j=0; j<eNB->ulsch[i]->Mlimit; j++) { + for (j=0; j<ulsch->Mlimit; j++) { eNB->UE_stats[i].ulsch_decoding_attempts[k][j]=0; eNB->UE_stats[i].ulsch_decoding_attempts_last[k][j]=0; eNB->UE_stats[i].ulsch_round_errors[k][j]=0; @@ -2787,10 +2872,10 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const #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,eNB->ulsch[i]->harq_processes[harq_pid]->TBS>>3); + harq_pid,ulsch_harq->TBS>>3); - for (j=0; j<eNB->ulsch[i]->harq_processes[harq_pid]->TBS>>3; j++) - LOG_T(PHY,"%x.",eNB->ulsch[i]->harq_processes[harq_pid]->b[j]); + for (j=0; j<ulsch_harq->TBS>>3; j++) + LOG_T(PHY,"%x.",eNB->ulsch[i]->harq_processesyy[harq_pid]->b[j]); LOG_T(PHY,"\n"); #endif @@ -2801,7 +2886,7 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const mac_xface->rx_sdu(eNB->Mod_id, eNB->CC_id, frame,subframe, - eNB->ulsch[i]->rnti, + ulsch->rnti, eNB->ulsch[i]->harq_processes[harq_pid]->b, eNB->ulsch[i]->harq_processes[harq_pid]->TBS>>3, harq_pid, @@ -2812,9 +2897,6 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const } // mac_enabled==1 } // Msg3_flag == 0 - // estimate timing advance for MAC - sync_pos = lte_est_timing_advance_pusch(eNB,i); - eNB->UE_stats[i].timing_advance_update = sync_pos - fp->nb_prefix_samples/4; //to check #ifdef DEBUG_PHY_PROC @@ -2871,7 +2953,7 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const // update ULSCH statistics for tracing if ((frame % 100 == 0) && (subframe == 4)) { for (harq_idx=0; harq_idx<8; harq_idx++) { - for (round=0; round<eNB->ulsch[i]->Mlimit; round++) { + for (round=0; round<ulsch->Mlimit; round++) { if ((eNB->UE_stats[i].ulsch_decoding_attempts[harq_idx][round] - eNB->UE_stats[i].ulsch_decoding_attempts_last[harq_idx][round]) != 0) { eNB->UE_stats[i].ulsch_round_fer[harq_idx][round] = diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index d25017155b725e5356f4f56de3d8dec505c11eeb..046e37097c204f30018e117a77bda641cd0753a0 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -1679,7 +1679,6 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB proc->subframe_rx, ue->transmission_mode[eNB_id],0,0)==0, "ulsch_coding.c: FATAL ERROR: returning\n"); - return; stop_meas(&ue->ulsch_encoding_stats); @@ -1690,8 +1689,9 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB frame_tx, eNB_id); } + LOG_I(PHY,"Done Msg3 encoding\n"); } // Msg3_flag==1 - else { + else {// Msg3_flag==0 input_buffer_length = ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS/8; if (ue->mac_enabled==1) { @@ -1740,12 +1740,13 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB LOG_E(PHY,"ulsch_coding.c: FATAL ERROR: returning\n"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); stop_meas(&ue->phy_proc_tx); - return; + return; } - } + } // Msg3_flag==0 stop_meas(&ue->ulsch_encoding_stats); - + LOG_I(PHY,"Doing ULSCH modulation\n"); + if (ue->mac_enabled==1) { pusch_power_cntl(ue,proc,eNB_id,1, abstraction_flag); ue->tx_power_dBm[subframe_tx] = ue->ulsch[eNB_id]->Po_PUSCH; @@ -1767,7 +1768,7 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB T(T_UE_PHY_PUSCH_TX_POWER, T_INT(eNB_id),T_INT(Mod_id), T_INT(frame_tx%1024), T_INT(subframe_tx),T_INT(ue->tx_power_dBm[subframe_tx]), T_INT(tx_amp),T_INT(ue->ulsch[eNB_id]->f_pusch),T_INT(get_PL(Mod_id,0,eNB_id)),T_INT(nb_rb)); #endif - LOG_D(PHY,"[UE %d][PUSCH %d] AbsSubFrame %d.%d, generating PUSCH, Po_PUSCH: %d dBm (max %d dBm), amp %d\n", + LOG_I(PHY,"[UE %d][PUSCH %d] AbsSubFrame %d.%d, generating PUSCH, Po_PUSCH: %d dBm (max %d dBm), amp %d\n", Mod_id,harq_pid,frame_tx%1024,subframe_tx,ue->tx_power_dBm[subframe_tx],ue->tx_power_max_dBm, tx_amp); start_meas(&ue->ulsch_modulation_stats); ulsch_modulation(ue->common_vars.txdataF, diff --git a/openair1/SCHED/pusch_pc.c b/openair1/SCHED/pusch_pc.c index ba17358d321f6a78738325247fa2677107938b6d..f4ce761c31d3589f171a190d5f7a611a8d12c35f 100644 --- a/openair1/SCHED/pusch_pc.c +++ b/openair1/SCHED/pusch_pc.c @@ -76,7 +76,7 @@ int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint8_t UE_id,uint8_t h //#warning "This condition happens sometimes. Need more investigation" // navid //DevAssert( MPR_x100/6 < 100 ); - if (eNB->ul_power_control_dedicated[UE_id].deltaMCS_Enabled == 1) { + if (1==1) { //eNB->ul_power_control_dedicated[UE_id].deltaMCS_Enabled == 1) { // This is the formula from Section 5.1.1.1 in 36.213 10*log10(deltaIF_PUSCH = (2^(MPR*Ks)-1)*beta_offset_pusch) if (bw_factor == 1) { uint8_t nb_rb = eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb; diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index 7cce68c143cc265aafc3c373538df56413626344..4761fa08c1984ae177c6b989400b38f7cdfc6481 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -341,10 +341,9 @@ void *eNB_app_task(void *args_p) RC.rrc = (eNB_RRC_INST **)malloc(RC.nb_inst*sizeof(eNB_RRC_INST *)); for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) { - // configure_phy(enb_id);// RC.rrc[enb_id] = (eNB_RRC_INST*)malloc(sizeof(eNB_RRC_INST)); - - configure_rrc(enb_id);// + memset((void *)RC.rrc[enb_id],0,sizeof(eNB_RRC_INST)); + configure_rrc(enb_id); } #if defined (FLEXRAN_AGENT_SB_IF) diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 615199ba8f1ed4a067969938836e7ab544c583f0..eafe80411fce8f36e6b22e76f38e2042358616dc 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -471,7 +471,7 @@ void RCconfig_RU() { if (setting != NULL) { - if (RC.ru==NULL) RC.ru = (RU_t**)malloc(RC.nb_RU*sizeof(RU_t*)); + RC.ru = (RU_t**)malloc(RC.nb_RU*sizeof(RU_t*)); RC.ru_mask=(1<<NB_RU) - 1; @@ -551,10 +551,9 @@ void RCconfig_RU() { } printf("RU %d: Transport %s\n",j,tr_preference); - if (RC.ru[j]==NULL) { - RC.ru[j] = (RU_t*)malloc(sizeof(RU_t)); - memset((void*)RC.ru[j],0,sizeof(RU_t)); - } + RC.ru[j] = (RU_t*)malloc(sizeof(RU_t)); + memset((void*)RC.ru[j],0,sizeof(RU_t)); + RC.ru[j]->idx = j; RC.ru[j]->eth_params.local_if_name = strdup(if_name); RC.ru[j]->eth_params.my_addr = strdup(ipv4); @@ -680,6 +679,7 @@ void RCconfig_L1() { for (i=0;i<RC.nb_L1_CC[j];i++) { if (RC.eNB[j][i] == NULL) { RC.eNB[j][i] = (PHY_VARS_eNB *)malloc(sizeof(PHY_VARS_eNB)); + memset((void*)RC.eNB[j][i],0,sizeof(PHY_VARS_eNB)); LOG_I(PHY,"RC.eNB[%d][%d] = %p\n",j,i,RC.eNB[j][i]); RC.eNB[j][i]->Mod_id = j; RC.eNB[j][i]->CC_id = i; diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index c9cfed16b8b7f37261eb4ab6c09f796742623d83..664549bc2ee29468cf9178b6872086c6453cd60d 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -195,8 +195,11 @@ uint32_t from_earfcn(int eutra_bandP,uint32_t dl_earfcn) { } -int32_t get_uldl_offset(int eutra_band) { - return(-eutra_bandtable[eutra_band].dl_min + eutra_bandtable[eutra_band].ul_min); +int32_t get_uldl_offset(int eutra_bandP) { + int i; + + for (i=0;i<69 && eutra_bandtable[i].band!=eutra_bandP;i++); + return(eutra_bandtable[i].dl_min - eutra_bandtable[i].ul_min); } uint32_t bw_table[6] = {6*180,15*180,25*180,50*180,75*180,100*180}; @@ -414,6 +417,12 @@ void config_dedicated(int Mod_idP, } +void config_dedicated_scell(int Mod_idP, + uint16_t rnti, + SCellToAddMod_r10_t *sCellToAddMod_r10) { + +} + int rrc_mac_config_req_eNB(module_id_t Mod_idP, int CC_idP, int physCellId, @@ -424,6 +433,7 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, #ifdef Rel14 int pbch_repetition, #endif + rnti_t rntiP, BCCH_BCH_Message_t *mib, RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, #ifdef Rel14 @@ -462,6 +472,7 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN); + if (mib!=NULL) { if (RC.mac == NULL) l2_init_eNB(); @@ -520,6 +531,10 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, LOG_I(MAC,"[CONFIG]pusch_config_common.sequenceHoppingEnabled = %d\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled); LOG_I(MAC,"[CONFIG]pusch_config_common.cyclicShift = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift); + AssertFatal(radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx > 0, + "radioResourceconfigCommon %d == 0\n", + radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx); + RC.mac[Mod_idP]->common_channels[CC_idP].radioResourceConfigCommon = radioResourceConfigCommon; if (ul_CarrierFreq>0) RC.mac[Mod_idP]->common_channels[CC_idP].ul_CarrierFreq = ul_CarrierFreq; if (ul_Bandwidth) RC.mac[Mod_idP]->common_channels[CC_idP].ul_Bandwidth = *ul_Bandwidth; @@ -535,8 +550,11 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, } + // SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters->logicalChannelGroup if (logicalChannelConfig!= NULL) { // check for eMTC specific things + UE_id = find_UE_id(Mod_idP, rntiP); + if (UE_id == -1) { LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__); } else { @@ -549,6 +567,8 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, if (physicalConfigDedicated != NULL) { + UE_id = find_UE_id(Mod_idP, rntiP); + if (UE_id == -1) LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__); else @@ -561,11 +581,11 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, #if defined(Rel10) || defined(Rel14) if (sCellToAddMod_r10 != NULL) { - + UE_id = find_UE_id(Mod_idP, rntiP); if (UE_id == -1) LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__); else - config_dedicated_scell(Mod_idP,UE_RNTI(Mod_idP,UE_id),sCellToAddMod_r10,1); + config_dedicated_scell(Mod_idP,rntiP,sCellToAddMod_r10); } diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index c3979c556449546caab64423f6689972eabd3647..c9c37438e404c1196cf1e78d74007cb3c225867e 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -776,12 +776,13 @@ typedef struct { // resource scheduling information uint8_t harq_pid[MAX_NUM_CCs]; uint8_t round[MAX_NUM_CCs]; - uint8_t round_UL[MAX_NUM_CCs]; + uint8_t round_UL[8][MAX_NUM_CCs]; uint8_t dl_pow_off[MAX_NUM_CCs]; uint16_t pre_nb_available_rbs[MAX_NUM_CCs]; unsigned char rballoc_sub_UE[MAX_NUM_CCs][N_RBG_MAX]; uint16_t ta_timer; int16_t ta_update; + uint8_t ul_cqi; int32_t context_active_timer; int32_t cqi_req_timer; int32_t ul_inactivity_timer; @@ -817,6 +818,8 @@ typedef struct { uint8_t preamble_subframe; /// Subframe where Msg3 is to be sent uint8_t Msg3_subframe; + /// Subframe where Msg3 is to be sent + uint8_t Msg3_frame; /// Flag to indicate the eNB should generate Msg4 upon reception of SDU from RRC. This is triggered by first ULSCH reception at eNB for new user. uint8_t generate_Msg4; /// Flag to indicate that eNB is waiting for ACK that UE has received Msg3. @@ -833,6 +836,8 @@ typedef struct { int16_t timing_offset; /// Timeout for RRC connection int16_t RRC_timer; + /// Round of Msg3 HARQ + uint8_t msg3_round; } RA_TEMPLATE; @@ -957,20 +962,22 @@ typedef struct eNB_MAC_INST_s { /// Preallocated DL pdu list nfapi_dl_config_request_pdu_t dl_config_pdu_list[MAX_NUM_CCs][MAX_NUM_DL_PDU]; /// NFAPI DL Config Request Structure - nfapi_dl_config_request_body_t DL_req[MAX_NUM_CCs]; + nfapi_dl_config_request_t DL_req[MAX_NUM_CCs]; /// Preallocated UL pdu list nfapi_ul_config_request_pdu_t ul_config_pdu_list[MAX_NUM_CCs][MAX_NUM_UL_PDU]; + nfapi_ul_config_request_pdu_t ul_config_pdu_list_msg3[MAX_NUM_CCs]; /// NFAPI UL Config Request Structure - nfapi_ul_config_request_body_t UL_req[MAX_NUM_CCs]; + nfapi_ul_config_request_t UL_req[MAX_NUM_CCs]; /// Preallocated HI_DCI0 pdu list nfapi_hi_dci0_request_pdu_t hi_dci0_pdu_list[MAX_NUM_CCs][MAX_NUM_HI_DCI0_PDU]; /// NFAPI HI/DCI0 Config Request Structure - nfapi_hi_dci0_request_body_t HI_DCI0_req[MAX_NUM_CCs]; + nfapi_hi_dci0_request_t HI_DCI0_req[MAX_NUM_CCs]; /// Prealocated TX pdu list nfapi_tx_request_pdu_t tx_request_pdu[MAX_NUM_CCs][MAX_NUM_TX_REQUEST_PDU]; /// NFAPI DL PDU structure - nfapi_tx_request_body_t TX_req[MAX_NUM_CCs]; - + nfapi_tx_request_t TX_req[MAX_NUM_CCs]; + /// UL handle + uint32_t ul_handle; UE_list_t UE_list; ///subband bitmap configuration diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index e29f96b8f77a54b475492ac188ef98843d9924c9..6a4c1424a9bdcdc504bb5dcc02db6360222a98d5 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -74,7 +74,7 @@ void check_ul_failure(module_id_t module_idP,int CC_id,int UE_id, frame_t frameP, sub_frame_t subframeP) { UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; - nfapi_dl_config_request_body_t *DL_req = &RC.mac[module_idP]->DL_req[0]; + nfapi_dl_config_request_t *DL_req = &RC.mac[module_idP]->DL_req[0]; uint16_t rnti = UE_RNTI(module_idP,UE_id); eNB_UE_STATS *eNB_UE_stats = &RC.mac[module_idP]->UE_list.eNB_UE_stats[CC_id][UE_id]; COMMON_channels_t *cc = RC.mac[module_idP]->common_channels; @@ -88,10 +88,10 @@ void check_ul_failure(module_id_t module_idP,int CC_id,int UE_id, // add a format 1A dci for this UE to request an RA procedure (only one UE per subframe) LOG_D(MAC,"UE %d rnti %x: sending PDCCH order for RAPROC (failure timer %d) \n",UE_id,rnti,UE_list->UE_sched_ctrl[UE_id].ul_failure_timer); - nfapi_dl_config_request_pdu_t* dl_config_pdu = &DL_req[CC_id].dl_config_pdu_list[DL_req[CC_id].number_pdu]; + nfapi_dl_config_request_pdu_t* dl_config_pdu = &DL_req[CC_id].dl_config_request_body.dl_config_pdu_list[DL_req[CC_id].dl_config_request_body.number_pdu]; memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = 2+sizeof(nfapi_dl_config_dci_dl_pdu); + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP,CC_id),eNB_UE_stats->dl_cqi,format1A); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; @@ -101,9 +101,9 @@ void check_ul_failure(module_id_t module_idP,int CC_id,int UE_id, AssertFatal((cc[CC_id].mib->message.dl_Bandwidth >=0) && (cc[CC_id].mib->message.dl_Bandwidth<6), "illegal dl_Bandwidth %d\n",(int)cc[CC_id].mib->message.dl_Bandwidth); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = pdcch_order_table[cc[CC_id].mib->message.dl_Bandwidth]; - DL_req[CC_id].number_dci++; - DL_req[CC_id].number_pdu++; - + DL_req[CC_id].dl_config_request_body.number_dci++; + DL_req[CC_id].dl_config_request_body.number_pdu++; + /* add_ue_spec_dci(&DL_req[CC_id], rnti, @@ -146,18 +146,18 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, UE_list_t *UE_list=&RC.mac[module_idP]->UE_list; rnti_t rnti; - COMMON_channels_t *cc = RC.mac[module_idP]->common_channels; - nfapi_dl_config_request_body_t *DL_req = &RC.mac[module_idP]->DL_req[0]; - nfapi_ul_config_request_body_t *UL_req = &RC.mac[module_idP]->UL_req[0]; - nfapi_hi_dci0_request_body_t *HI_DCI0_req = &RC.mac[module_idP]->HI_DCI0_req[0]; - nfapi_tx_request_body_t *TX_req = &RC.mac[module_idP]->TX_req[0]; - eNB_UE_STATS *eNB_UE_stats; + COMMON_channels_t *cc = RC.mac[module_idP]->common_channels; + nfapi_dl_config_request_t *DL_req = &RC.mac[module_idP]->DL_req[0]; + nfapi_ul_config_request_t *UL_req = &RC.mac[module_idP]->UL_req[0]; + nfapi_hi_dci0_request_t *HI_DCI0_req = &RC.mac[module_idP]->HI_DCI0_req[0]; + nfapi_tx_request_t *TX_req = &RC.mac[module_idP]->TX_req[0]; + eNB_UE_STATS *eNB_UE_stats; #if defined(FLEXRAN_AGENT_SB_IF) Protocol__FlexranMessage *msg; #endif - LOG_I(MAC,"[eNB %d] Frame %d, Subframe %d, entering MAC scheduler (UE_list->head %d)\n",module_idP, frameP, subframeP,UE_list->head); + // LOG_I(MAC,"[eNB %d] Frame %d, Subframe %d, entering MAC scheduler (UE_list->head %d)\n",module_idP, frameP, subframeP,UE_list->head); 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); @@ -169,22 +169,20 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, // clear DL/UL info for new scheduling round - RC.mac[module_idP]->pdu_index[CC_id] = 0; - DL_req[CC_id].number_pdcch_ofdm_symbols = 1; - DL_req[CC_id].number_dci = 0; - DL_req[CC_id].number_pdu = 0; - DL_req[CC_id].number_pdsch_rnti = 0; - DL_req[CC_id].transmission_power_pcfich = 6000; - - HI_DCI0_req[CC_id].sfnsf = subframeP + (frameP<<3); - HI_DCI0_req[CC_id].number_of_dci = 0; - HI_DCI0_req[CC_id].number_of_hi = 0; + RC.mac[module_idP]->pdu_index[CC_id] = 0; + DL_req[CC_id].dl_config_request_body.number_pdcch_ofdm_symbols = 1; + DL_req[CC_id].dl_config_request_body.number_dci = 0; + DL_req[CC_id].dl_config_request_body.number_pdu = 0; + DL_req[CC_id].dl_config_request_body.number_pdsch_rnti = 0; + DL_req[CC_id].dl_config_request_body.transmission_power_pcfich = 6000; - UL_req[CC_id].number_of_pdus = 0; - UL_req[CC_id].rach_prach_frequency_resources = 0; // ignored, handled by PHY for now - UL_req[CC_id].srs_present = 0; // ignored, handled by PHY for now + HI_DCI0_req[CC_id].hi_dci0_request_body.sfnsf = subframeP + (frameP<<3); + HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci = 0; - TX_req[CC_id].number_of_pdus = 0; + UL_req[CC_id].ul_config_request_body.number_of_pdus = 0; + UL_req[CC_id].ul_config_request_body.rach_prach_frequency_resources = 0; // ignored, handled by PHY for now + UL_req[CC_id].ul_config_request_body.srs_present = 0; // ignored, handled by PHY for now + TX_req[CC_id].tx_request_body.number_of_pdus = 0; #if defined(Rel10) || defined(Rel14) cc[CC_id].mcch_active =0; #endif @@ -315,7 +313,10 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, } #endif - + LOG_I(MAC,"[eNB %d][before switch] Frame %d, Subframe %d CC_id %d RA 0 is active, Msg3 in (%d,%d), (%d,%d,%d,%d) UL_pdus %d\n", + module_idP,frameP,subframeP,CC_id,cc[0].RA_template[0].Msg3_frame,cc[0].RA_template[0].Msg3_subframe, + cc[0].RA_template[0].RA_active,cc[0].RA_template[1].RA_active,cc[0].RA_template[2].RA_active,cc[0].RA_template[3].RA_active, + RC.mac[module_idP]->UL_req[0].ul_config_request_body.number_of_pdus); switch (subframeP) { case 0: @@ -328,8 +329,8 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, LOG_I(MAC,"Scheduling MIB\n"); if ((frameP&3) == 0) schedule_mib(module_idP,frameP,subframeP); LOG_I(MAC,"NFAPI: number_of_pdus %d, number_of_TX_req %d\n", - DL_req[0].number_pdu, - TX_req[0].number_of_pdus); + DL_req[0].dl_config_request_body.number_pdu, + TX_req[0].tx_request_body.number_of_pdus); if (cc[0].tdd_Config == NULL) { //FDD schedule_ulsch(module_idP,frameP,cooperation_flag,0,4);//,calibration_flag); } else if ((cc[0].tdd_Config->subframeAssignment == 0) || @@ -1025,12 +1026,21 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, } - LOG_I(MAC,"FrameP %d, subframeP %d : Scheduling CCEs\n",frameP,subframeP); + LOG_I(MAC,"FrameP %d, subframeP %d : Scheduling CCEs/Msg3\n",frameP,subframeP); - // Allocate CCEs for good after scheduling is done - for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) + LOG_I(MAC,"[eNB %d][before] Frame %d, Subframe %d CC_id %d RA 0 is active, Msg3 in (%d,%d) (%d,%d,%d,%d) UL_pdus %d\n", + module_idP,frameP,subframeP,CC_id,cc[0].RA_template[0].Msg3_frame,cc[0].RA_template[0].Msg3_subframe, + cc[0].RA_template[0].RA_active,cc[0].RA_template[1].RA_active,cc[0].RA_template[2].RA_active,cc[0].RA_template[3].RA_active, + RC.mac[module_idP]->UL_req[0].ul_config_request_body.number_of_pdus); + // Allocate CCEs and Msg3 for good after scheduling is done + for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) { allocate_CCEs(module_idP,CC_id,subframeP,0); - + check_and_add_msg3(module_idP,frameP,subframeP); + } + LOG_I(MAC,"[eNB %d][after] Frame %d, Subframe %d CC_id 0 RA 0 is active, Msg3 in (%d,%d) (%d,%d,%d,%d) UL_pdus %d\n", + module_idP,frameP,subframeP,cc[0].RA_template[0].Msg3_frame,cc[0].RA_template[0].Msg3_subframe, + cc[0].RA_template[0].RA_active,cc[0].RA_template[1].RA_active,cc[0].RA_template[2].RA_active,cc[0].RA_template[3].RA_active, + RC.mac[module_idP]->UL_req[0].ul_config_request_body.number_of_pdus); #if defined(FLEXRAN_AGENT_SB_IF) #ifndef DISABLE_CONT_STATS //Send subframe trigger to the controller diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 53d2b694499b88b067373ee14b3f00b83903d4fd..d6e245d1805b9a6110ad3d4f1c153dd36ae00c2b 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -61,7 +61,6 @@ #include "SIMULATION/TOOLS/defs.h" // for taus #include "T.h" - // eMTC notes // Implements MSG2 and MSG4 // fill_rar for eMTC @@ -69,6 +68,87 @@ // resource allocation for format 1A (4->6 PRBs) // initiate_ra_proc: add detection of BR/CE UEs +void check_and_add_msg3(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP) { + + eNB_MAC_INST *eNB = RC.mac[module_idP]; + RA_TEMPLATE *RA_template; + COMMON_channels_t *cc = eNB->common_channels; + uint8_t i; + int msg3_prog_subframe,msg3_prog_frame; + int CC_id; + nfapi_ul_config_request_pdu_t *ul_config_pdu; + nfapi_ul_config_request_body_t *ul_req; + nfapi_hi_dci0_request_body_t *hi_dci0_req; + nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; + + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + hi_dci0_req = &eNB->HI_DCI0_req[CC_id].hi_dci0_request_body; + ul_req = &eNB->UL_req[CC_id].ul_config_request_body; + + for (i=0; i<NB_RA_PROC_MAX; i++) { + + RA_template = (RA_TEMPLATE *)&cc[CC_id].RA_template[i]; + + if (RA_template->RA_active == TRUE) { + + + msg3_prog_subframe = (RA_template->Msg3_subframe + 6)%10; + + if (RA_template->Msg3_subframe<4) msg3_prog_frame=(RA_template->Msg3_frame+1023)&1023; + else msg3_prog_frame=RA_template->Msg3_frame; + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d CC_id %d RA %d is active, Msg3 in (%d,%d), programmed in (%d,%d)\n", + module_idP,frameP,subframeP,CC_id,i,RA_template->Msg3_frame,RA_template->Msg3_subframe, + msg3_prog_frame,msg3_prog_subframe); + + if ((msg3_prog_frame==frameP) && + (msg3_prog_subframe==subframeP)) { + LOG_I(MAC,"Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d)\n", + frameP,subframeP,RA_template->Msg3_frame,RA_template->Msg3_subframe); + eNB->UL_req[CC_id].sfn_sf = (RA_template->Msg3_frame<<3) + RA_template->Msg3_subframe; + if (RA_template->msg3_round == 0) { // program ULSCH + 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_ULSCH_PDU_TYPE; + ul_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_ul_config_ulsch_pdu)); + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.handle = eNB->ul_handle++; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti = RA_template->rnti; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.resource_block_start = 1; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = 1; + 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 = 0; + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number = 0; + 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,ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks); + ul_req->number_of_pdus++; + } + else { // program HI + 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_HI_PDU_TYPE; + hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_hi_pdu); + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = 1; // note this is hard-coded like in fill_rar + 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->number_of_hi++; + + LOG_I(MAC,"[eNB %d][PUSCH-RA %x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) RA %d (mcs %d, first rb %d, nb_rb %d,round %d)\n", + module_idP,RA_template[i].rnti,CC_id,frameP,subframeP,i,10, + 1,1, + RA_template[i].msg3_round-1); + } + } + } + } + } +} + void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,unsigned char Msg3_subframe) { @@ -92,15 +172,15 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un nfapi_tx_request_pdu_t *TX_req; UE_list_t *UE_list=&eNB->UE_list; int round; + nfapi_dl_config_request_body_t *dl_req; start_meas(&eNB->schedule_ra); for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - - vrb_map = cc[CC_id].vrb_map; - dl_config_pdu = &eNB->DL_req[CC_id].dl_config_pdu_list[eNB->DL_req[CC_id].number_pdu]; + dl_req = &eNB->DL_req[CC_id].dl_config_request_body; + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; N_RB_DL = to_prb(cc[CC_id].mib->message.dl_Bandwidth); for (i=0; i<NB_RA_PROC_MAX; i++) { @@ -128,7 +208,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un 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 = 2+sizeof(nfapi_dl_config_dci_dl_pdu); + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = 4; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = RA_template->RA_rnti; @@ -142,25 +222,56 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un 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; - if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,2,RA_template->RA_rnti)) { + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = getRIV(N_RB_DL,first_rb,4); + + if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,RA_template->RA_rnti)) { LOG_D(MAC,"Frame %d: Subframe %d : Adding common DCI for RA_RNTI %x\n", frameP,subframeP,RA_template->RA_rnti); - eNB->DL_req[CC_id].number_dci++; - eNB->DL_req[CC_id].number_pdu++; + dl_req->number_dci++; + dl_req->number_pdu++; + + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dlsch_pdu)); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_id]; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = RA_template->RA_rnti; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL,first_rb,4); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;// first block + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB==1 ) ? 0 : 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB==1 ) ? 1 : 2; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; + dl_req->number_pdu++; + + // Program UL processing for Msg3 + get_Msg3alloc(&cc[CC_id],subframeP,frameP,&RA_template->Msg3_frame,&RA_template->Msg3_subframe); - /* this will be updated when PHY calls set_msg3_subframe */ - RA_template->Msg3_subframe = -1; fill_rar(module_idP,CC_id,frameP,cc[CC_id].RAR_pdu.payload,N_RB_DL,7); // DL request - - TX_req = &eNB->TX_req[CC_id].tx_pdu_list[eNB->TX_req[CC_id].number_of_pdus]; + eNB->TX_req[CC_id].sfn_sf = (frameP<<3)+subframeP; + TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus]; TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble TX_req->pdu_index = eNB->pdu_index[CC_id]++; TX_req->num_segments = 1; TX_req->segments[0].segment_length = 7; TX_req->segments[0].segment_data = cc[CC_id].RAR_pdu.payload; - eNB->TX_req[CC_id].number_of_pdus++; + eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; } } else if (RA_template->generate_Msg4 == 1) { @@ -168,25 +279,24 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un UE_id = find_UE_id(module_idP,RA_template->rnti); AssertFatal(UE_id>=0,"Can't find UE for t-crnti\n"); - if (Is_rrc_registered == 1) { - - // Get RRCConnectionSetup for Piggyback - rrc_sdu_length = mac_rrc_data_req(module_idP, - CC_id, - frameP, - CCCH, - 1, // 1 transport block - &cc[CC_id].CCCH_pdu.payload[0], - ENB_FLAG_YES, - module_idP, - 0); // not used in this case - AssertFatal(rrc_sdu_length>=0, + // Get RRCConnectionSetup for Piggyback + rrc_sdu_length = mac_rrc_data_req(module_idP, + CC_id, + frameP, + CCCH, + 1, // 1 transport block + &cc[CC_id].CCCH_pdu.payload[0], + ENB_FLAG_YES, + module_idP, + 0); // not used in this case + + AssertFatal(rrc_sdu_length>=0, "[MAC][eNB Scheduler] CCCH not allocated\n"); - } + - LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, Is_rrc_registered %d, rrc_sdu_length %d\n", - module_idP, CC_id, frameP, subframeP,UE_id, Is_rrc_registered,rrc_sdu_length); + LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n", + module_idP, CC_id, frameP, subframeP,UE_id, rrc_sdu_length); if (rrc_sdu_length>0) { LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RA proc %d, RNTI %x)\n", @@ -202,7 +312,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un 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 = 2+sizeof(nfapi_dl_config_dci_dl_pdu); + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = 4; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = RA_template->rnti; @@ -241,9 +351,9 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding= getRIV(N_RB_DL,first_rb,4); - if (!CCE_allocation_infeasible(module_idP,CC_id,0,subframeP,2,RA_template->rnti)) { - eNB->DL_req[CC_id].number_dci++; - eNB->DL_req[CC_id].number_pdu++; + if (!CCE_allocation_infeasible(module_idP,CC_id,0,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,RA_template->rnti)) { + dl_req->number_dci++; + dl_req->number_pdu++; RA_template->generate_Msg4=0; RA_template->wait_ack_Msg4=1; @@ -280,14 +390,14 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un rrc_sdu_length); // DL request - - TX_req = &eNB->TX_req[CC_id].tx_pdu_list[eNB->TX_req[CC_id].number_of_pdus]; + eNB->TX_req[CC_id].sfn_sf = (frameP<<3)+subframeP; + TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus]; TX_req->pdu_length = rrc_sdu_length; TX_req->pdu_index = eNB->pdu_index[CC_id]++; TX_req->num_segments = 1; TX_req->segments[0].segment_length = rrc_sdu_length; TX_req->segments[0].segment_data = eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0]; - eNB->TX_req[CC_id].number_of_pdus++; + eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(RA_template->rnti), T_INT(frameP), T_INT(subframeP), T_INT(0 /*harq_pid always 0?*/), T_BUFFER(&eNB->UE_list.DLSCH_pdu[CC_id][0][UE_id].payload[0], TBsize)); @@ -328,7 +438,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un 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 = 2+sizeof(nfapi_dl_config_dci_dl_pdu); + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = 4; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = RA_template->rnti; @@ -367,9 +477,9 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding= getRIV(N_RB_DL,first_rb,4); - if (!CCE_allocation_infeasible(module_idP,CC_id,0,subframeP,2,RA_template->rnti)) { - eNB->DL_req[CC_id].number_dci++; - eNB->DL_req[CC_id].number_pdu++; + if (!CCE_allocation_infeasible(module_idP,CC_id,0,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,RA_template->rnti)) { + dl_req->number_dci++; + dl_req->number_pdu++; LOG_I(MAC,"msg4 retransmission for rnti %x (round %d) fsf %d/%d\n", RA_template->rnti, round, frameP, subframeP); } @@ -393,8 +503,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un } // handles the event of MSG1 reception -void initiate_ra_proc(module_id_t module_idP, int CC_id,frame_t frameP, uint16_t preamble_index,int16_t timing_offset,uint8_t sect_id,sub_frame_t subframeP, - uint8_t f_id) +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) { uint8_t i; @@ -409,11 +518,12 @@ void initiate_ra_proc(module_id_t module_idP, int CC_id,frame_t frameP, uint16_t if (RA_template[i].RA_active==FALSE && RA_template[i].wait_ack_Msg4 == 0) { int loop = 0; - RA_template[i].RA_active=TRUE; - RA_template[i].generate_rar=1; - RA_template[i].generate_Msg4=0; - RA_template[i].wait_ack_Msg4=0; - RA_template[i].timing_offset=timing_offset; + RA_template[i].RA_active = TRUE; + RA_template[i].generate_rar = 1; + RA_template[i].generate_Msg4 = 0; + RA_template[i].wait_ack_Msg4 = 0; + RA_template[i].timing_offset = timing_offset; + RA_template[i].preamble_subframe = subframeP; /* TODO: find better procedure to allocate RNTI */ do { RA_template[i].rnti = taus(); @@ -426,7 +536,7 @@ void initiate_ra_proc(module_id_t module_idP, int CC_id,frame_t frameP, uint16_t /* 1024 and 60000 arbirarily chosen, not coming from standard */ RA_template[i].rnti >= 1024 && RA_template[i].rnti < 60000)); if (loop == 100) { printf("%s:%d:%s: FATAL ERROR! contact the authors\n", __FILE__, __LINE__, __FUNCTION__); abort(); } - RA_template[i].RA_rnti = 1+subframeP+(10*f_id); + RA_template[i].RA_rnti = ra_rnti; RA_template[i].preamble_index = preamble_index; LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Activating RAR generation for process %d, rnti %x, RA_active %d\n", module_idP,CC_id,frameP,i,RA_template[i].rnti, @@ -456,6 +566,7 @@ void cancel_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP, rnti_t rn RA_template[i].timing_offset=0; RA_template[i].RRC_timer=20; RA_template[i].rnti = 0; + RA_template[i].msg3_round = 0; } } } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_bch.c b/openair2/LAYER2/MAC/eNB_scheduler_bch.c index 6f0b277e4ecc3c0955c8a115e7b07118a392859d..e0cfff210dd14b5ab90ed7015b0d9f6b516e439a 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_bch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_bch.c @@ -82,14 +82,16 @@ schedule_SI( int N_RB_DL; nfapi_dl_config_request_pdu_t *dl_config_pdu; nfapi_tx_request_pdu_t *TX_req; - + nfapi_dl_config_request_body_t *dl_req; start_meas(&eNB->schedule_si); for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { cc = &eNB->common_channels[CC_id]; vrb_map = (void*)&cc->vrb_map; - N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); + N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); + dl_req = &eNB->DL_req[CC_id].dl_config_request_body; + bcch_sdu_length = mac_rrc_data_req(module_idP, CC_id, @@ -157,7 +159,9 @@ schedule_SI( } else if (bcch_sdu_length <= 49) { mcs=8; } - dl_config_pdu = &eNB->DL_req[CC_id].dl_config_pdu_list[eNB->DL_req[CC_id].number_pdu]; + + + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); @@ -175,12 +179,12 @@ schedule_SI( dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = getRIV(N_RB_DL,first_rb,4); - if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,2,SI_RNTI)) { + if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,SI_RNTI)) { LOG_I(MAC,"Frame %d: Subframe %d : Adding common DCI for S_RNTI\n", frameP,subframeP); - eNB->DL_req[CC_id].number_dci++; - eNB->DL_req[CC_id].number_pdu++; - dl_config_pdu = &eNB->DL_req[CC_id].dl_config_pdu_list[eNB->DL_req[CC_id].number_pdu]; + dl_req->number_dci++; + dl_req->number_pdu++; + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dlsch_pdu)); @@ -206,16 +210,16 @@ schedule_SI( 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 = ; - eNB->DL_req[CC_id].number_pdu++; + dl_req->number_pdu++; // Program TX Request - TX_req = &eNB->TX_req[CC_id].tx_pdu_list[eNB->TX_req[CC_id].number_of_pdus]; + TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus]; TX_req->pdu_length = bcch_sdu_length; TX_req->pdu_index = eNB->pdu_index[CC_id]++; TX_req->num_segments = 1; TX_req->segments[0].segment_length = bcch_sdu_length; TX_req->segments[0].segment_data = cc->BCCH_pdu.payload; - eNB->TX_req[CC_id].number_of_pdus++; + eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; } else { @@ -276,12 +280,14 @@ void schedule_mib(module_id_t module_idP, nfapi_tx_request_pdu_t *TX_req; int mib_sdu_length; int CC_id; + nfapi_dl_config_request_body_t *dl_req; AssertFatal(subframeP==0,"Subframe must be 0\n"); AssertFatal((frameP&3)==0,"Frame must be a multiple of 4\n"); for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + dl_req = &eNB->DL_req[CC_id].dl_config_request_body; cc = &eNB->common_channels[CC_id]; mib_sdu_length = mac_rrc_data_req(module_idP, @@ -299,28 +305,28 @@ void schedule_mib(module_id_t module_idP, if (mib_sdu_length > 0) { LOG_I(MAC,"Frame %d, subframe %d: Adding BCH PDU in position %d (length %d)\n", - frameP,subframeP,eNB->DL_req[CC_id].number_pdu,mib_sdu_length); + frameP,subframeP,dl_req->number_pdu,mib_sdu_length); - dl_config_pdu = &eNB->DL_req[CC_id].dl_config_pdu_list[eNB->DL_req[CC_id].number_pdu]; + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_BCH_PDU_TYPE, dl_config_pdu->pdu_size = 2+sizeof(nfapi_dl_config_bch_pdu); dl_config_pdu->bch_pdu.bch_pdu_rel8.length = mib_sdu_length; dl_config_pdu->bch_pdu.bch_pdu_rel8.pdu_index = eNB->pdu_index[CC_id]; dl_config_pdu->bch_pdu.bch_pdu_rel8.transmission_power = 6000; - eNB->DL_req[CC_id].number_pdu++; + dl_req->number_pdu++; LOG_I(MAC,"eNB->DL_req[0].number_pdu %d (%p)\n", - eNB->DL_req[CC_id].number_pdu,&eNB->DL_req[CC_id].number_pdu); + dl_req->number_pdu,&dl_req->number_pdu); // DL request - TX_req = &eNB->TX_req[CC_id].tx_pdu_list[eNB->TX_req[CC_id].number_of_pdus]; + TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus]; TX_req->pdu_length = 3; TX_req->pdu_index = eNB->pdu_index[CC_id]++; TX_req->num_segments = 1; TX_req->segments[0].segment_length = 0; TX_req->segments[0].segment_data = cc[CC_id].MIB_pdu.payload; - eNB->TX_req[CC_id].number_of_pdus++; + eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; } } } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 657ae108ee067ff24bdf09c92e0386362b6fd032..7b6a9f0ec8a123a94fb8f6dab213c9968d228526 100755 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -122,7 +122,7 @@ generate_dlsch_header( unsigned short *sdu_lengths, unsigned char *sdu_lcids, unsigned char drx_cmd, - short timing_advance_cmd, + unsigned short timing_advance_cmd, unsigned char *ue_cont_res_id, unsigned char short_padding, unsigned short post_padding @@ -183,7 +183,8 @@ generate_dlsch_header( last_size=1; // msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); ((TIMING_ADVANCE_CMD *)ce_ptr)->R=0; - ((TIMING_ADVANCE_CMD *)ce_ptr)->TA=(timing_advance_cmd+31)&0x3f; + AssertFatal(timing_advance_cmd < 64,"timing_advance_cmd %d > 63\n",timing_advance_cmd); + ((TIMING_ADVANCE_CMD *)ce_ptr)->TA=timing_advance_cmd;//(timing_advance_cmd+31)&0x3f; LOG_D(MAC,"timing advance =%d (%d)\n",timing_advance_cmd,((TIMING_ADVANCE_CMD *)ce_ptr)->TA); ce_ptr+=sizeof(TIMING_ADVANCE_CMD); //msg("offset %d\n",ce_ptr-mac_header_control_elements); @@ -452,6 +453,7 @@ schedule_ue_spec( int N_RB_DL[MAX_NUM_CCs]; int total_nb_available_rb[MAX_NUM_CCs]; int N_RBG[MAX_NUM_CCs]; + nfapi_dl_config_request_body_t *dl_req; nfapi_dl_config_request_pdu_t *dl_config_pdu; nfapi_tx_request_pdu_t *TX_req; @@ -501,6 +503,8 @@ schedule_ue_spec( for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { LOG_D(MAC, "doing schedule_ue_spec for CC_id %d\n",CC_id); + dl_req = &eNB->DL_req[CC_id].dl_config_request_body; + if (mbsfn_flag[CC_id]>0) continue; @@ -655,10 +659,10 @@ schedule_ue_spec( case 2: case 7: default: - dl_config_pdu = &eNB->DL_req[CC_id].dl_config_pdu_list[eNB->DL_req[CC_id].number_pdu]; + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = 2+sizeof(nfapi_dl_config_dci_dl_pdu); + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP,CC_id),eNB_UE_stats->dl_cqi,format1); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; @@ -686,8 +690,8 @@ schedule_ue_spec( if (!CCE_allocation_infeasible(module_idP,CC_id,0,subframeP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, rnti)) { - eNB->DL_req[CC_id].number_dci++; - eNB->DL_req[CC_id].number_pdu++; + dl_req->number_dci++; + dl_req->number_pdu++; } else { @@ -1115,10 +1119,10 @@ schedule_ue_spec( tpc = 1; //0 } - dl_config_pdu = &eNB->DL_req[CC_id].dl_config_pdu_list[eNB->DL_req[CC_id].number_pdu]; + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = 2+sizeof(nfapi_dl_config_dci_dl_pdu); + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP,CC_id),eNB_UE_stats->dl_cqi,format1); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; @@ -1144,8 +1148,8 @@ schedule_ue_spec( module_idP,CC_id,harq_pid,round,mcs); } - eNB->DL_req[CC_id].number_dci++; - eNB->DL_req[CC_id].number_pdu++; + dl_req->number_dci++; + dl_req->number_pdu++; // Toggle NDI for next time LOG_D(MAC,"CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", @@ -1156,13 +1160,14 @@ schedule_ue_spec( UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs; UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0; - TX_req = &eNB->TX_req[CC_id].tx_pdu_list[eNB->TX_req[CC_id].number_of_pdus]; + eNB->TX_req[CC_id].sfn_sf = (frameP<<3)+subframeP; + TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus]; TX_req->pdu_length = TBS; TX_req->pdu_index = eNB->pdu_index[CC_id]++; TX_req->num_segments = 1; TX_req->segments[0].segment_length = TBS; TX_req->segments[0].segment_data = eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[harq_pid]; - eNB->TX_req[CC_id].number_of_pdus++; + eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; } else { // There is no data from RLC or MAC header, so don't schedule @@ -1245,11 +1250,11 @@ fill_DLSCH_dci( rballoc_sub[i] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][i]; } - nfapi_dl_config_request_body_t *DL_req = &RC.mac[module_idP]->DL_req[0]; + nfapi_dl_config_request_t *DL_req = &RC.mac[module_idP]->DL_req[0]; nfapi_dl_config_request_pdu_t* dl_config_pdu; - for (i=0;i<DL_req[CC_id].number_pdu;i++) { - dl_config_pdu = &DL_req[CC_id].dl_config_pdu_list[i]; + for (i=0;i<DL_req[CC_id].dl_config_request_body.number_pdu;i++) { + dl_config_pdu = &DL_req[CC_id].dl_config_request_body.dl_config_pdu_list[i]; if ((dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)&& (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti == rnti)) { dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb,N_RB_DL,N_RBG,rballoc_sub); @@ -1308,13 +1313,13 @@ void update_ul_dci(module_id_t module_idP, //------------------------------------------------------------------------------ { - nfapi_hi_dci0_request_body_t *HI_DCI0_req = &RC.mac[module_idP]->HI_DCI0_req[CC_idP]; - nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[0]; + nfapi_hi_dci0_request_t *HI_DCI0_req = &RC.mac[module_idP]->HI_DCI0_req[CC_idP]; + nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list[0]; COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_idP]; int i; if (cc->tdd_Config != NULL) { // TDD - for (i=0; i<HI_DCI0_req->number_of_dci + HI_DCI0_req->number_of_dci; i++) { + for (i=0; i<HI_DCI0_req->hi_dci0_request_body.number_of_dci + HI_DCI0_req->hi_dci0_request_body.number_of_dci; i++) { if ((hi_dci0_pdu[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) && (hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.rnti == rntiP)) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index c50a666fcc79197e48cbf3f01a07bc5246869569..6961013983c681b6a00f23e9c6b2c1df4037c003 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -97,6 +97,310 @@ uint16_t mac_computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs) { return(RIV); } +void get_Msg3alloc(COMMON_channels_t *cc, + unsigned char current_subframe, + unsigned int current_frame, + unsigned int *frame, + unsigned char *subframe) +{ + + // Fill in other TDD Configuration!!!! + + if (cc->tdd_Config==NULL) { // FDD + *subframe = current_subframe+6; + + if (*subframe>9) { + *subframe = *subframe-10; + *frame = (current_frame+1) & 1023; + } else { + *frame=current_frame; + } + } else { // TDD + if (cc->tdd_Config->subframeAssignment == 1) { + switch (current_subframe) { + + case 0: + *subframe = 7; + *frame = current_frame; + break; + + case 4: + *subframe = 2; + *frame = (current_frame+1) & 1023; + break; + + case 5: + *subframe = 2; + *frame = (current_frame+1) & 1023; + break; + + case 9: + *subframe = 7; + *frame = (current_frame+1) & 1023; + break; + } + } else if (cc->tdd_Config->subframeAssignment == 3) { + switch (current_subframe) { + + case 0: + case 5: + case 6: + *subframe = 2; + *frame = (current_frame+1) & 1023; + break; + + case 7: + *subframe = 3; + *frame = (current_frame+1) & 1023; + break; + + case 8: + *subframe = 4; + *frame = (current_frame+1) & 1023; + break; + + case 9: + *subframe = 2; + *frame = (current_frame+2) & 1023; + break; + } + } else if (cc->tdd_Config->subframeAssignment == 4) { + switch (current_subframe) { + + case 0: + case 4: + case 5: + case 6: + *subframe = 2; + *frame = (current_frame+1) & 1023; + break; + + case 7: + *subframe = 3; + *frame = (current_frame+1) & 1023; + break; + + case 8: + case 9: + *subframe = 2; + *frame = (current_frame+2) & 1023; + break; + } + } else if (cc->tdd_Config->subframeAssignment == 5) { + switch (current_subframe) { + + case 0: + case 4: + case 5: + case 6: + *subframe = 2; + *frame = (current_frame+1) & 1023; + break; + + case 7: + case 8: + case 9: + *subframe = 2; + *frame = (current_frame+2) & 1023; + break; + } + } + } +} + +void get_Msg3allocret(COMMON_channels_t *cc, + unsigned char current_subframe, + unsigned int current_frame, + unsigned int *frame, + unsigned char *subframe) +{ + if (cc->tdd_Config == NULL) { //FDD + /* always retransmit in n+8 */ + *subframe = current_subframe + 8; + + if (*subframe > 9) { + *subframe = *subframe - 10; + *frame = (current_frame + 1) & 1023; + } else { + *frame = current_frame; + } + } else { + if (cc->tdd_Config->subframeAssignment == 1) { + // original PUSCH in 2, PHICH in 6 (S), ret in 2 + // original PUSCH in 3, PHICH in 9, ret in 3 + // original PUSCH in 7, PHICH in 1 (S), ret in 7 + // original PUSCH in 8, PHICH in 4, ret in 8 + *frame = (current_frame+1) & 1023; + } else if (cc->tdd_Config->subframeAssignment == 3) { + // original PUSCH in 2, PHICH in 8, ret in 2 next frame + // original PUSCH in 3, PHICH in 9, ret in 3 next frame + // original PUSCH in 4, PHICH in 0, ret in 4 next frame + *frame=(current_frame+1) & 1023; + } else if (cc->tdd_Config->subframeAssignment == 4) { + // original PUSCH in 2, PHICH in 8, ret in 2 next frame + // original PUSCH in 3, PHICH in 9, ret in 3 next frame + *frame=(current_frame+1) & 1023; + } else if (cc->tdd_Config->subframeAssignment == 5) { + // original PUSCH in 2, PHICH in 8, ret in 2 next frame + *frame=(current_frame+1) & 1023; + } + } +} + +uint8_t subframe2harqpid(COMMON_channels_t *cc,uint32_t frame,uint8_t subframe) +{ + uint8_t ret = 255; + + AssertFatal(cc!=NULL,"cc is null\n"); + + if (cc->tdd_Config == NULL) { // FDD + ret = (((frame<<1)+subframe)&7); + } else { + + switch (cc->tdd_Config->subframeAssignment) { + + case 1: + if ((subframe==2) || + (subframe==3) || + (subframe==7) || + (subframe==8)) + switch (subframe) { + case 2: + case 3: + ret = (subframe-2); + break; + + case 7: + case 8: + ret = (subframe-5); + break; + + default: + AssertFatal(1==0,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,(int)cc->tdd_Config->subframeAssignment); + break; + } + + break; + + case 2: + AssertFatal((subframe==2) || (subframe==7), + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,(int)cc->tdd_Config->subframeAssignment); + + ret = (subframe/7); + break; + + case 3: + AssertFatal((subframe>1) && (subframe<5), + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,(int)cc->tdd_Config->subframeAssignment); + ret = (subframe-2); + break; + + case 4: + AssertFatal((subframe>1) && (subframe<4), + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,(int)cc->tdd_Config->subframeAssignment); + ret = (subframe-2); + break; + + case 5: + AssertFatal(subframe==2, + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,(int)cc->tdd_Config->subframeAssignment); + ret = (subframe-2); + break; + + default: + AssertFatal(1==0,"subframe2_harq_pid, Unsupported TDD mode %d\n",(int)cc->tdd_Config->subframeAssignment); + } + } + return ret; +} + +uint8_t get_Msg3harqpid(COMMON_channels_t *cc, + uint32_t frame, + unsigned char current_subframe) +{ + + uint8_t ul_subframe=0; + uint32_t ul_frame=0; + + if (cc->tdd_Config == NULL) { // FDD + ul_subframe = (current_subframe>3) ? (current_subframe-4) : (current_subframe+6); + ul_frame = (current_subframe>3) ? ((frame+1)&1023) : frame; + } else { + switch (cc->tdd_Config->subframeAssignment) { + case 1: + switch (current_subframe) { + + case 9: + case 0: + ul_subframe = 7; + break; + + case 5: + case 7: + ul_subframe = 2; + break; + + } + + break; + + case 3: + switch (current_subframe) { + + case 0: + case 5: + case 6: + ul_subframe = 2; + break; + + case 7: + ul_subframe = 3; + break; + + case 8: + ul_subframe = 4; + break; + + case 9: + ul_subframe = 2; + break; + } + + break; + + case 4: + switch (current_subframe) { + + case 0: + case 5: + case 6: + case 8: + case 9: + ul_subframe = 2; + break; + + case 7: + ul_subframe = 3; + break; + } + + break; + + case 5: + ul_subframe =2; + break; + + default: + LOG_E(PHY,"get_Msg3_harq_pid: Unsupported TDD configuration %d\n",(int)cc->tdd_Config->subframeAssignment); + AssertFatal(1==0,"get_Msg3_harq_pid: Unsupported TDD configuration"); + break; + } + } + + return(subframe2harqpid(cc,ul_frame,ul_subframe)); + +} + //------------------------------------------------------------------------------ void init_ue_sched_info(void) //------------------------------------------------------------------------------ @@ -148,6 +452,24 @@ int find_UE_id(module_id_t mod_idP, rnti_t rntiP) return(-1); } +//------------------------------------------------------------------------------ +int find_RA_id(module_id_t mod_idP, int CC_idP, rnti_t rntiP) +//------------------------------------------------------------------------------ +{ + int RA_id; + AssertFatal(RC.mac[mod_idP],"RC.mac[%d] is null\n",mod_idP); + + RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&RC.mac[mod_idP]->common_channels[CC_idP].RA_template[0]; + + + + for (RA_id = 0; RA_id < NB_RA_PROC_MAX; RA_id++) + if (RA_template[RA_id].RA_active==TRUE && + RA_template[RA_id].wait_ack_Msg4 == 0 && + RA_template[RA_id].rnti == rntiP) return(RA_id); + return(-1); +} + //------------------------------------------------------------------------------ int UE_num_active_CC(UE_list_t *listP,int ue_idP) //------------------------------------------------------------------------------ @@ -274,7 +596,6 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP) for (i = 0; i < NUMBER_OF_UE_MAX; i++) { if (UE_list->active[i] == TRUE) continue; -printf("MAC: new UE id %d rnti %x\n", i, rntiP); UE_id = i; UE_list->UE_template[cc_idP][UE_id].rnti = rntiP; UE_list->UE_template[cc_idP][UE_id].configured = FALSE; @@ -286,6 +607,7 @@ printf("MAC: new UE id %d rnti %x\n", i, rntiP); UE_list->num_UEs++; UE_list->active[UE_id] = TRUE; memset((void*)&UE_list->UE_sched_ctrl[UE_id],0,sizeof(UE_sched_ctrl)); + memset((void*)&UE_list->eNB_UE_stats[cc_idP][UE_id],0,sizeof(eNB_UE_STATS)); for (j=0; j<8; j++) { UE_list->UE_template[cc_idP][UE_id].oldNDI[j] = (j==0)?1:0; // 1 because first transmission is with format1A (Msg4) for harq_pid 0 @@ -299,7 +621,7 @@ printf("MAC: new UE id %d rnti %x\n", i, rntiP); return(UE_id); } -printf("MAC: cannot add new UE for rnti %x\n", rntiP); + printf("MAC: cannot add new UE for rnti %x\n", rntiP); LOG_E(MAC,"error in add_new_ue(), could not find space in UE_list, Dumping UE list\n"); dump_ue_list(UE_list,0); return(-1); @@ -681,24 +1003,29 @@ uint8_t get_tmode(module_id_t module_idP,int CC_idP,int UE_idP) { struct PhysicalConfigDedicated *physicalConfigDedicated = eNB->UE_list.physicalConfigDedicated[CC_idP][UE_idP]; - AssertFatal(physicalConfigDedicated->antennaInfo!=NULL, - "antennaInfo is null for CCId %d, UEid %d\n",CC_idP,UE_idP); - - AssertFatal(physicalConfigDedicated->antennaInfo->present != PhysicalConfigDedicated__antennaInfo_PR_NOTHING, - "antennaInfo (mod_id %d, CC_id %d) is set to NOTHING\n",module_idP,CC_idP); - - if (physicalConfigDedicated->antennaInfo->present == PhysicalConfigDedicated__antennaInfo_PR_explicitValue) { - return(physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode); - } - else if (physicalConfigDedicated->antennaInfo->present == PhysicalConfigDedicated__antennaInfo_PR_defaultValue) { + if (physicalConfigDedicated == NULL ) { // RRCConnectionSetup not received by UE yet AssertFatal(cc->p_eNB<=2,"p_eNB is %d, should be <2\n",cc->p_eNB); return(cc->p_eNB); } - else AssertFatal(1==0,"Shouldn't be here\n"); - + else { + AssertFatal(physicalConfigDedicated->antennaInfo!=NULL, + "antennaInfo is null for CCId %d, UEid %d\n",CC_idP,UE_idP); + + AssertFatal(physicalConfigDedicated->antennaInfo->present != PhysicalConfigDedicated__antennaInfo_PR_NOTHING, + "antennaInfo (mod_id %d, CC_id %d) is set to NOTHING\n",module_idP,CC_idP); + + if (physicalConfigDedicated->antennaInfo->present == PhysicalConfigDedicated__antennaInfo_PR_explicitValue) { + return(physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode); + } + else if (physicalConfigDedicated->antennaInfo->present == PhysicalConfigDedicated__antennaInfo_PR_defaultValue) { + AssertFatal(cc->p_eNB<=2,"p_eNB is %d, should be <2\n",cc->p_eNB); + return(cc->p_eNB); + } + else AssertFatal(1==0,"Shouldn't be here\n"); + } } -int8_t get_UL_harq(module_id_t module_idP,int CC_idP,uint16_t frameP,uint8_t subframeP) { +int8_t get_ULharq(module_id_t module_idP,int CC_idP,uint16_t frameP,uint8_t subframeP) { uint8_t ret = -1; eNB_MAC_INST *eNB = RC.mac[module_idP]; @@ -727,48 +1054,39 @@ int8_t get_UL_harq(module_id_t module_idP,int CC_idP,uint16_t frameP,uint8_t sub break; default: - LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframeP,cc->tdd_Config->subframeAssignment); - ret = -1; + AssertFatal(1==0,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframeP,(int)cc->tdd_Config->subframeAssignment); break; } break; case 2: - if ((subframeP!=2) && (subframeP!=7)) { - LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframeP,cc->tdd_Config->subframeAssignment); - ret=-1; - } - else ret = (subframeP/7); + AssertFatal((subframeP==2) || (subframeP==7), + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframeP,(int)cc->tdd_Config->subframeAssignment); + ret = (subframeP/7); break; case 3: - if ((subframeP<2) || (subframeP>4)) { - LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframeP,cc->tdd_Config->subframeAssignment); - ret = -1; - } - else ret = (subframeP-2); + AssertFatal((subframeP>1) && (subframeP<5), + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframeP,(int)cc->tdd_Config->subframeAssignment); + ret = (subframeP-2); break; case 4: - if ((subframeP<2) || (subframeP>3)) { - LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframeP,cc->tdd_Config->subframeAssignment); - ret = -1; - } - else ret = (subframeP-2); + AssertFatal((subframeP>1) && (subframeP<4), + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframeP,(int)cc->tdd_Config->subframeAssignment); + ret = (subframeP-2); break; case 5: - if (subframeP!=2) { - LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframeP,cc->tdd_Config->subframeAssignment); - ret = -1; - } - else ret = (subframeP-2); + AssertFatal(subframeP==2, + "subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframeP,(int)cc->tdd_Config->subframeAssignment); + ret = (subframeP-2); break; default: - LOG_E(PHY,"subframe2_harq_pid, Unsupported TDD mode %d\n",cc->tdd_Config->subframeAssignment); - ret = -1; + AssertFatal(1==0,"subframe2_harq_pid, Unsupported TDD mode %d\n",(int)cc->tdd_Config->subframeAssignment); + break; } } @@ -1013,14 +1331,14 @@ int get_nCCE_offset(int *CCE_table, nb_candidates = (L==4) ? 4 : 2; nb_candidates = min(nb_candidates,nCCE/L); - // printf("Common DCI nb_candidates %d, L %d\n",nb_candidates,L); + printf("Common DCI nb_candidates %d, L %d\n",nb_candidates,L); for (m = nb_candidates-1 ; m >=0 ; m--) { search_space_free = 1; for (l=0; l<L; l++) { - // printf("CCE_table[%d] %d\n",(m*L)+l,CCE_table[(m*L)+l]); + printf("CCE_table[%d] %d\n",(m*L)+l,CCE_table[(m*L)+l]); if (CCE_table[(m*L) + l] == 1) { search_space_free = 0; break; @@ -1265,8 +1583,8 @@ int allocate_CCEs(int module_idP, int *CCE_table = RC.mac[module_idP]->CCE_table[CC_idP]; - nfapi_dl_config_request_body_t *DL_req = &RC.mac[module_idP]->DL_req[CC_idP]; - nfapi_hi_dci0_request_body_t *HI_DCI0_req = &RC.mac[module_idP]->HI_DCI0_req[CC_idP]; + nfapi_dl_config_request_body_t *DL_req = &RC.mac[module_idP]->DL_req[CC_idP].dl_config_request_body; + nfapi_hi_dci0_request_body_t *HI_DCI0_req = &RC.mac[module_idP]->HI_DCI0_req[CC_idP].hi_dci0_request_body; nfapi_dl_config_request_pdu_t *dl_config_pdu = &DL_req->dl_config_pdu_list[0]; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[0]; int nCCE_max = get_nCCE_max(&RC.mac[module_idP]->common_channels[CC_idP],1,subframeP); @@ -1471,9 +1789,9 @@ boolean_t CCE_allocation_infeasible(int module_idP, int aggregation, int rnti) { - nfapi_dl_config_request_body_t *DL_req = &RC.mac[module_idP]->DL_req[CC_idP]; + nfapi_dl_config_request_body_t *DL_req = &RC.mac[module_idP]->DL_req[CC_idP].dl_config_request_body; nfapi_dl_config_request_pdu_t* dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; - nfapi_hi_dci0_request_body_t *HI_DCI0_req = &RC.mac[module_idP]->HI_DCI0_req[CC_idP]; + nfapi_hi_dci0_request_body_t *HI_DCI0_req = &RC.mac[module_idP]->HI_DCI0_req[CC_idP].hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; //DCI_ALLOC_t *dci_alloc; int ret; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index f2f27ca380eadc9ee36624f6852702d3559cc750..660bd80adbd4d2fcd511597d8cfa09b4d6371c69 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -70,20 +70,24 @@ void rx_sdu(const module_id_t enb_mod_idP, const rnti_t rntiP, uint8_t *sduP, const uint16_t sdu_lenP, - const int harq_pidP, - uint8_t *msg3_flagP) -{ + const uint16_t timing_advance, + const uint8_t ul_cqi) { + unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr; unsigned char rx_lcids[NB_RB_MAX]; unsigned short rx_lengths[NB_RB_MAX]; int UE_id = find_UE_id(enb_mod_idP,rntiP); + int RA_id; int ii,j; eNB_MAC_INST *eNB = RC.mac[enb_mod_idP]; + int harq_pid = subframe2harqpid(&eNB->common_channels[CC_idP],frameP,subframeP); + UE_list_t *UE_list= &eNB->UE_list; int crnti_rx=0; int old_buffer_info; - + RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&RC.mac[enb_mod_idP]->common_channels[CC_idP].RA_template[0]; + start_meas(&eNB->rx_ulsch_sdu); if ((UE_id > NUMBER_OF_UE_MAX) || (UE_id == -1) ) @@ -97,32 +101,59 @@ void rx_sdu(const module_id_t enb_mod_idP, LOG_D(OPT,"[eNB %d][ULSCH] Frame %d rnti %x with size %d\n", enb_mod_idP, frameP, rntiP, sdu_lenP); } + - LOG_D(MAC,"[eNB %d] CC_id %d Received ULSCH sdu from PHY (rnti %x, UE_id %d), parsing header\n",enb_mod_idP,CC_idP,rntiP,UE_id); + if (UE_id!=-1) { - if (sduP==NULL) { // we've got an error after N rounds - UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1<<harq_pidP)); - return; - } + LOG_I(MAC,"[eNB %d] CC_id %d Received ULSCH sdu from PHY (rnti %x, UE_id %d)\n",enb_mod_idP,CC_idP,rntiP,UE_id); - if (UE_id!=-1) { - UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer=0; - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer =0; - UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1<<harq_pidP)); + UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer = 0; + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; + UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1<<harq_pid)); + UE_list->UE_sched_ctrl[UE_id].ta_update = timing_advance; + UE_list->UE_sched_ctrl[UE_id].ul_cqi = ul_cqi; if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync > 0) { UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync=0; mac_eNB_rrc_ul_in_sync(enb_mod_idP,CC_idP,frameP,subframeP,UE_RNTI(enb_mod_idP,UE_id)); } - } + if (sduP==NULL) { // we've got an error + LOG_I(MAC,"[eNB %d] CC_id %d ULSCH in error in round %d\n",enb_mod_idP,CC_idP,UE_list->UE_sched_ctrl[UE_id].round_UL[harq_pid][CC_idP]); + AssertFatal(1==0,"ulsch in error\n"); + if (UE_list->UE_sched_ctrl[UE_id].round_UL[harq_pid][CC_idP] == 7) + UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1<<harq_pid)); + return; + } + } + else { + AssertFatal((RA_id = find_RA_id(enb_mod_idP,CC_idP,rntiP))!=-1, + "Cannot find rnti %x in RA list\n",rntiP); + AssertFatal(eNB->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx>1, + "maxHARQ %d should be greater than 1\n", + (int)eNB->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx); + + if (sduP==NULL) { // we've got an error + LOG_I(MAC,"[eNB %d] CC_id %d, RA %d ULSCH in error in round %d/%d\n",enb_mod_idP,CC_idP,RA_id, + RA_template[RA_id].msg3_round, + (int)eNB->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx); + if (RA_template[RA_id].msg3_round == eNB->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx-1) { + cancel_ra_proc(enb_mod_idP,CC_idP,frameP,rntiP); + } + RA_template[RA_id].msg3_round++; + // prepare handling of retransmission + RA_template[RA_id].Msg3_frame += ((RA_template[RA_id].Msg3_subframe>1) ? 1 : 0); + RA_template[RA_id].Msg3_subframe = (RA_template[RA_id].Msg3_subframe+8)%10; + return; + } + } payload_ptr = parse_ulsch_header(sduP,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,sdu_lenP); T(T_ENB_MAC_UE_UL_PDU, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP), - T_INT(harq_pidP), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu)); + T_INT(harq_pid), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu)); T(T_ENB_MAC_UE_UL_PDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP), - T_INT(harq_pidP), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu), T_BUFFER(sduP, sdu_lenP)); + T_INT(harq_pid), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu), T_BUFFER(sduP, sdu_lenP)); eNB->eNB_stats[CC_idP].ulsch_bytes_rx=sdu_lenP; eNB->eNB_stats[CC_idP].total_ulsch_bytes_rx+=sdu_lenP; @@ -159,10 +190,11 @@ void rx_sdu(const module_id_t enb_mod_idP, } crnti_rx=1; payload_ptr+=2; - + /* if (msg3_flagP != NULL) { *msg3_flagP = 0; - } + }*/ + break; case TRUNCATED_BSR: @@ -336,7 +368,7 @@ void rx_sdu(const module_id_t enb_mod_idP, LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3: length %d, offset %ld\n", enb_mod_idP,CC_idP,frameP,rx_lengths[i],payload_ptr-sduP); - if ((UE_id=add_new_ue(enb_mod_idP,CC_idP,eNB->common_channels[CC_idP].RA_template[ii].rnti,harq_pidP)) == -1 ) { + if ((UE_id=add_new_ue(enb_mod_idP,CC_idP,eNB->common_channels[CC_idP].RA_template[ii].rnti,harq_pid)) == -1 ) { AssertFatal(1==0,"[MAC][eNB] Max user count reached\n"); // kill RA procedure } else @@ -348,20 +380,19 @@ void rx_sdu(const module_id_t enb_mod_idP, // kill RA procedure } - if (Is_rrc_registered == 1) - mac_rrc_data_ind( - enb_mod_idP, - CC_idP, - frameP,subframeP, - rntiP, - CCCH, - (uint8_t*)payload_ptr, - rx_lengths[i], - ENB_FLAG_YES, - enb_mod_idP, - 0); - - + mac_rrc_data_ind( + enb_mod_idP, + CC_idP, + frameP,subframeP, + rntiP, + CCCH, + (uint8_t*)payload_ptr, + rx_lengths[i], + ENB_FLAG_YES, + enb_mod_idP, + 0); + + if (num_ce >0) { // handle msg3 which is not RRCConnectionRequest // process_ra_message(msg3,num_ce,rx_lcids,rx_ces); } @@ -481,13 +512,13 @@ void 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; - + /* if (msg3_flagP != NULL) { if( *msg3_flagP == 1 ) { LOG_N(MAC,"[eNB %d] CC_id %d frame %d : false msg3 detection: signal phy to canceling RA and remove the UE\n", enb_mod_idP, CC_idP, frameP); *msg3_flagP=0; } - } + }*/ } else { if (UE_id != -1) { UE_list->eNB_UE_stats[CC_idP][UE_id].pdu_bytes_rx=sdu_lenP; @@ -658,6 +689,7 @@ void schedule_ulsch(module_id_t module_idP, // Msg3 is using 1 PRB so we need to increase first_rb accordingly // not sure about the break (can there be more than 1 active RA procedure?) + for (i=0; i<NB_RA_PROC_MAX; i++) { if ((eNB->common_channels[CC_id].RA_template[i].RA_active == TRUE) && (eNB->common_channels[CC_id].RA_template[i].generate_rar == 0) && @@ -665,7 +697,7 @@ void schedule_ulsch(module_id_t module_idP, (eNB->common_channels[CC_id].RA_template[i].wait_ack_Msg4 == 0) && (eNB->common_channels[CC_id].RA_template[i].Msg3_subframe == sched_subframe)) { first_rb[CC_id]++; - eNB->common_channels[CC_id].RA_template[i].Msg3_subframe = -1; + // eNB->common_channels[CC_id].RA_template[i].Msg3_subframe = -1; break; } } @@ -697,7 +729,7 @@ void schedule_ulsch_rnti(module_id_t module_idP, uint8_t status = 0; uint8_t rb_table_index = -1; uint16_t TBS = 0; - uint32_t cqi_req,cshift,ndi,mcs=0,rballoc,tpc; + uint32_t cqi_req,cshift,ndi,mcs=0,tpc; int32_t normalized_rx_power; int32_t target_rx_power=-90; static int32_t tpc_accumulated=0; @@ -710,11 +742,10 @@ void schedule_ulsch_rnti(module_id_t module_idP, UE_list_t *UE_list=&eNB->UE_list; UE_TEMPLATE *UE_template; UE_sched_ctrl *UE_sched_ctrl; - + nfapi_hi_dci0_request_body_t *hi_dci0_req = &eNB->HI_DCI0_req[CC_id].hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; LOG_D(MAC,"entering ulsch preprocesor\n"); - ulsch_scheduler_pre_processor(module_idP, frameP, subframeP, @@ -722,6 +753,9 @@ void schedule_ulsch_rnti(module_id_t module_idP, LOG_D(MAC,"exiting ulsch preprocesor\n"); + eNB->HI_DCI0_req[CC_id].sfn_sf = (frameP<<3)+subframeP; + hi_dci0_req->number_of_dci = 0; + hi_dci0_req->number_of_hi = 0; // loop over all active UEs for (UE_id=UE_list->head_ul; UE_id>=0; UE_id=UE_list->next_ul[UE_id]) { @@ -800,8 +834,8 @@ abort(); UE_template = &UE_list->UE_template[CC_id][UE_id]; UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; - harq_pid = get_UL_harq(frameP,subframeP); - round = UE_sched_ctrl->round_UL[CC_id]; + harq_pid = subframe2harqpid(&cc[CC_id],frameP,subframeP); + round = UE_sched_ctrl->round_UL[harq_pid][CC_id]; /* if (get_UL_harq_info(module_idP,CC_id,frameP,subframeP,&harq_pid,&round)<0) { LOG_W(MAC,"[eNB %d] Scheduler Frame %d, subframeP %d: candidate harq_pid from PHY for UE %d CC %d RNTI %x\n", @@ -896,10 +930,7 @@ abort(); 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=TBS; // buffer_occupancy -= TBS; - rballoc = getRIV(N_RB_UL, - first_rb[CC_id], - rb_table[rb_table_index]); - + 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(mcs), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), T_INT(TBS), T_INT(ndi)); @@ -931,8 +962,8 @@ abort(); // Cyclic shift for DM RS cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) // save it for a potential retransmission - UE_template->cshift[harq_pid] = cshift; - hi_dci0_pdu = &eNB->HI_DCI0_req[CC_id].hi_dci0_pdu_list[eNB->HI_DCI0_req[CC_id].number_of_dci+eNB->HI_DCI0_req[CC_id].number_of_hi]; + UE_template->cshift[harq_pid] = cshift; + hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci+eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_hi]; memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_dci_pdu); @@ -953,7 +984,7 @@ abort(); if (!CCE_allocation_infeasible(module_idP,CC_id,2,subframeP, aggregation, rnti)) - eNB->HI_DCI0_req[CC_id].number_of_dci++; + eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci++; add_ue_ulsch_info(module_idP, CC_id, @@ -964,25 +995,26 @@ abort(); 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 { + else { // round > 0 => retransmission T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), T_INT(mcs), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), T_INT(round)); // fill in NAK information - hi_dci0_pdu = &eNB->HI_DCI0_req[CC_id].hi_dci0_pdu_list[eNB->HI_DCI0_req[CC_id].number_of_dci+eNB->HI_DCI0_req[CC_id].number_of_hi]; + + 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_HI_PDU_TYPE; hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_hi_pdu); hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = UE_template->first_rb_ul[harq_pid]; hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = UE_template->cshift[harq_pid]; hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 0; - eNB->HI_DCI0_req[CC_id].number_of_hi++; + hi_dci0_req->number_of_hi++; - LOG_D(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d,round %d)\n", + LOG_D(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) UE %d (mcs %d, first rb %d, nb_rb %d, TBS %d, harq_pid %d,round %d)\n", module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,mcs, - first_rb[CC_id],rb_table[rb_table_index], - rb_table_index,TBS,harq_pid,round); + UE_template->first_rb_ul[harq_pid], UE_template->nb_rb_ul[harq_pid], + TBS,harq_pid,round); }/* else if (round > 0) { //we schedule a retransmission diff --git a/openair2/LAYER2/MAC/extern.h b/openair2/LAYER2/MAC/extern.h index 7058a98798a2f6317f0a42ad1ddffc6ad47fcc55..591fce4b4b3e97fd423539bd054d468d862c7cee 100644 --- a/openair2/LAYER2/MAC/extern.h +++ b/openair2/LAYER2/MAC/extern.h @@ -54,14 +54,13 @@ extern const uint8_t cqi2fmt2x_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE]; extern UE_RRC_INST *UE_rrc_inst; extern UE_MAC_INST *UE_mac_inst; -extern uint8_t Is_rrc_registered; + extern eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 extern eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 -extern uint8_t Is_rrc_registered; #ifndef PHYSIM #define NB_INST 1 diff --git a/openair2/LAYER2/MAC/main.c b/openair2/LAYER2/MAC/main.c index 3e9af4380a25d73a5a59b602ac507462bb232225..ef47b427361aa97738d4ec23f4a02c2500c0458e 100644 --- a/openair2/LAYER2/MAC/main.c +++ b/openair2/LAYER2/MAC/main.c @@ -172,10 +172,11 @@ int mac_top_init_eNB() LOG_D(MAC,"[MAIN] ALLOCATE %zu Bytes for %d eNB_MAC_INST @ %p\n",sizeof(eNB_MAC_INST),RC.nb_macrlc_inst,RC.mac); bzero(RC.mac[i],sizeof(eNB_MAC_INST)); for (j=0;j<MAX_NUM_CCs;j++) { - RC.mac[i]->DL_req[j].dl_config_pdu_list = RC.mac[i]->dl_config_pdu_list[j]; - RC.mac[i]->UL_req[j].ul_config_pdu_list = RC.mac[i]->ul_config_pdu_list[j]; - RC.mac[i]->HI_DCI0_req[j].hi_dci0_pdu_list = RC.mac[i]->hi_dci0_pdu_list[j]; - RC.mac[i]->TX_req[j].tx_pdu_list = RC.mac[i]->tx_request_pdu[j]; + RC.mac[i]->DL_req[j].dl_config_request_body.dl_config_pdu_list = RC.mac[i]->dl_config_pdu_list[j]; + RC.mac[i]->UL_req[j].ul_config_request_body.ul_config_pdu_list = RC.mac[i]->ul_config_pdu_list[j]; + RC.mac[i]->HI_DCI0_req[j].hi_dci0_request_body.hi_dci0_pdu_list = RC.mac[i]->hi_dci0_pdu_list[j]; + RC.mac[i]->TX_req[j].tx_request_body.tx_pdu_list = RC.mac[i]->tx_request_pdu[j]; + RC.mac[i]->ul_handle = 0; } } } else { diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 41fa379ae21b1fdeeb623c1781357fefafe4b24e..7c77bf87297f757a53f067b21f844ec8a01a13d6 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -189,11 +189,12 @@ void assign_rbs_required (module_id_t Mod_id, if (UE_list->active[UE_id] != TRUE) continue; pCCid = UE_PCCID(Mod_id,UE_id); - eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; + //update CQI information across component carriers for (n=0; n<UE_list->numactiveCCs[UE_id]; n++) { CC_id = UE_list->ordered_CCids[n][UE_id]; + eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; eNB_UE_stats->dlsch_mcs1=cqi_to_mcs[eNB_UE_stats->dl_cqi]; @@ -886,7 +887,7 @@ void dlsch_scheduler_pre_processor_reset (int module_idP, #endif - + LOG_I(MAC,"Running preprocessor for UE %d (%x)\n",UE_id,rnti); // initialize harq_pid and round /* @@ -1171,7 +1172,7 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, for (n=0; n<UE_list->numactiveULCCs[UE_id]; n++) { // This is the actual CC_id in the list CC_id = UE_list->ordered_ULCCids[n][UE_id]; - harq_pid = get_UL_harq(frameP,subframeP); + harq_pid = subframe2harqpid(&RC.mac[module_idP]->common_channels[CC_id],frameP,subframeP); // mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,openair_harq_UL); diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 0ad0b157e9aa44406a891b43bbaa9dc30a3e58ad..7f79a1c6a7fb41a8dc31172e746bb1e629991170 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -206,7 +206,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, uint8_t cooperation_flag, @param preamble_index index of the received RA request @param timing_offset Offset in samples of the received PRACH w.r.t. eNB timing. This is used to */ -void initiate_ra_proc(module_id_t module_idP,int CC_id,frame_t frameP, uint16_t preamble_index,int16_t timing_offset,uint8_t sect_id,sub_frame_t subframe,uint8_t f_id); +void initiate_ra_proc(module_id_t module_idP,int CC_id,frame_t frameP, sub_frame_t subframeP, uint16_t preamble_index,int16_t timing_offset,uint16_t rnti); /* \brief Function in eNB to fill RAR pdu when requested by PHY. This provides a single RAR SDU for the moment and returns the t-CRNTI. @param Mod_id Instance ID of eNB @@ -250,12 +250,23 @@ void set_msg3_subframe(module_id_t Mod_id, /* \brief Function to indicate a received SDU on ULSCH. @param Mod_id Instance ID of eNB -@param rnti RNTI of UE transmitting the SR +@param CC_id Component carrier index +@param rnti RNTI of UE transmitting the SDU @param sdu Pointer to received SDU -@param harq_pid Index of harq process corresponding to this sdu -@param msg3_flag flag indicating that this sdu is msg3 +@param sdu_len Length of SDU +@param timing_advance timing advance adjustment after this pdu +@param ul_cqi Uplink CQI estimate after this pdu (SNR quantized to 8 bits, -64 ... 63.5 dB in .5dB steps) */ -void rx_sdu(const module_id_t module_idP, const int CC_id,const frame_t frameP, const sub_frame_t subframeP, const rnti_t rnti, uint8_t *sdu, const uint16_t sdu_len, const int harq_pid,uint8_t *msg3_flag); +void rx_sdu(const module_id_t enb_mod_idP, + const int CC_idP, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rntiP, + uint8_t *sduP, + const uint16_t sdu_lenP, + const uint16_t timing_advance, + const uint8_t ul_cqi); + /* \brief Function to indicate a scheduled schduling request (SR) was received by eNB. @param Mod_id Instance ID of eNB @@ -706,7 +717,7 @@ unsigned char generate_dlsch_header(unsigned char *mac_header, unsigned short *sdu_lengths, unsigned char *sdu_lcids, unsigned char drx_cmd, - short timing_advance_cmd, + unsigned short timing_advance_cmd, unsigned char *ue_cont_res_id, unsigned char short_padding, unsigned short post_padding); @@ -715,6 +726,7 @@ unsigned char generate_dlsch_header(unsigned char *mac_header, @param Mod_id Instance ID of eNB @param CC_id Component Carrier of the eNB @param mib Pointer to MIB + @param radioResourceConfigCommon Structure from SIB2 for common radio parameters (if NULL keep existing configuration) @param physicalConfigDedicated Structure from RRCConnectionSetup or RRCConnectionReconfiguration for dedicated PHY parameters (if NULL keep existing configuration) @param measObj Structure from RRCConnectionReconfiguration for UE measurement procedures @@ -742,6 +754,7 @@ int rrc_mac_config_req_eNB(module_id_t module_idP, #ifdef Rel14 int pbch_repetition, #endif + rnti_t rntiP, BCCH_BCH_Message_t *mib, RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, #ifdef Rel14 @@ -839,5 +852,31 @@ uint16_t getRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs); int get_subbandsize(uint8_t dl_bandwidth); +uint8_t subframe2harqpid(COMMON_channels_t *cc,uint32_t frame,uint8_t subframe); + +void get_Msg3allocret(COMMON_channels_t *cc, + unsigned char current_subframe, + unsigned int current_frame, + unsigned int *frame, + unsigned char *subframe); + +void get_Msg3alloc(COMMON_channels_t *cc, + unsigned char current_subframe, + unsigned int current_frame, + unsigned int *frame, + unsigned char *subframe); + +uint16_t mac_computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs); + +int get_phich_resource_times6(COMMON_channels_t *cc); + +int to_rbg(int dl_Bandwidth); + +int to_prb(int dl_Bandwidth); + +uint8_t get_Msg3harqpid(COMMON_channels_t *cc, + uint32_t frame, + unsigned char current_subframe); + #endif /** @}*/ diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c index b9c5b7872405cfc4f2b8f54b0a19f23e87842a0a..b63acf76f8a4d48e75ce460fc5f65d8ed8b2cd72 100644 --- a/openair2/LAYER2/MAC/ra_procedures.c +++ b/openair2/LAYER2/MAC/ra_procedures.c @@ -307,224 +307,221 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, return(NULL); } - if (Is_rrc_registered == 1) { - - if (UE_mac_inst[module_idP].RA_active == 0) { - LOG_D(MAC,"RA not active\n"); - // check if RRC is ready to initiate the RA procedure - Size = mac_rrc_data_req(module_idP, - CC_id, - frameP, - CCCH,1, - &UE_mac_inst[module_idP].CCCH_pdu.payload[sizeof(SCH_SUBHEADER_SHORT)+1],0, - eNB_indexP, - 0); - Size16 = (uint16_t)Size; - - // LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size); - LOG_D(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_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size); - - if (Size>0) { - - UE_mac_inst[module_idP].RA_active = 1; - UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = 1; - UE_mac_inst[module_idP].RA_Msg3_size = Size+sizeof(SCH_SUBHEADER_SHORT)+sizeof(SCH_SUBHEADER_SHORT); - UE_mac_inst[module_idP].RA_prachMaskIndex = 0; - UE_mac_inst[module_idP].RA_prach_resources.Msg3 = UE_mac_inst[module_idP].CCCH_pdu.payload; - UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) - - AssertFatal(rach_ConfigCommon==NULL, - "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",module_idP,frameP); - UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; - - if (UE_mac_inst[module_idP].RA_window_cnt == 9) { - UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! - } - - UE_mac_inst[module_idP].RA_tx_frame = frameP; - UE_mac_inst[module_idP].RA_tx_subframe = subframeP; - UE_mac_inst[module_idP].RA_backoff_frame = frameP; - UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; - // Fill in preamble and PRACH resource - get_prach_resources(module_idP,CC_id,eNB_indexP,subframeP,1,NULL); - - generate_ulsch_header((uint8_t*)&UE_mac_inst[module_idP].CCCH_pdu.payload[0], // mac header - 1, // num sdus - 0, // short pading - &Size16, // sdu length - &lcid, // sdu lcid - NULL, // power headroom - NULL, // crnti - NULL, // truncated bsr - NULL, // short bsr - NULL, // long_bsr - 1); //post_padding - return(&UE_mac_inst[module_idP].RA_prach_resources); - - } else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] > 0) { - // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) - dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element - rlc_status = mac_rlc_status_ind(module_idP,UE_mac_inst[module_idP].crnti, eNB_indexP,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO, - DCCH, - 6); - - if (UE_mac_inst[module_idP].crnti_before_ho) - LOG_D(MAC, - "[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send throug PRACH (mac header len %d)\n", - module_idP,frameP, UE_mac_inst[module_idP].crnti,UE_mac_inst[module_idP].crnti_before_ho, rlc_status.bytes_in_buffer,dcch_header_len); - else - LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to send through PRACH(mac header len %d)\n", - module_idP,frameP, rlc_status.bytes_in_buffer,dcch_header_len); - - sdu_lengths[0] = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, - eNB_indexP, frameP,ENB_FLAG_NO, MBMS_FLAG_NO, - DCCH, - 6, //not used - (char *)&ulsch_buff[0]); - - LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",module_idP,sdu_lengths[0]); - update_bsr(module_idP, frameP, subframeP,eNB_indexP); - UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] = - locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]]); - - //TO DO: fill BSR infos in UL TBS - - //header_len +=2; - UE_mac_inst[module_idP].RA_active = 1; - UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = 1; - UE_mac_inst[module_idP].RA_Msg3_size = Size+dcch_header_len; - UE_mac_inst[module_idP].RA_prachMaskIndex = 0; - UE_mac_inst[module_idP].RA_prach_resources.Msg3 = ulsch_buff; - UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) - - AssertFatal(rach_ConfigCommon!=NULL, - "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",module_idP,frameP); - UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; - - if (UE_mac_inst[module_idP].RA_window_cnt == 9) { - UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! - } - - - UE_mac_inst[module_idP].RA_tx_frame = frameP; - UE_mac_inst[module_idP].RA_tx_subframe = subframeP; - UE_mac_inst[module_idP].RA_backoff_frame = frameP; - UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; - // Fill in preamble and PRACH resource - get_prach_resources(module_idP,CC_id,eNB_indexP,subframeP,1,NULL); - generate_ulsch_header((uint8_t*)ulsch_buff, // mac header - 1, // num sdus - 0, // short pading - &Size16, // sdu length - &lcid, // sdu lcid - NULL, // power headroom - &UE_mac_inst[module_idP].crnti, // crnti - NULL, // truncated bsr - NULL, // short bsr - NULL, // long_bsr - 0); //post_padding - - return(&UE_mac_inst[module_idP].RA_prach_resources); - } - } else { // RACH is active - LOG_D(MAC,"[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, window cnt %d (RA_tx_frame %d, RA_tx_subframe %d)\n",module_idP, - frameP,subframeP,UE_mac_inst[module_idP].RA_window_cnt, - UE_mac_inst[module_idP].RA_tx_frame,UE_mac_inst[module_idP].RA_tx_subframe); - - // compute backoff parameters - if (UE_mac_inst[module_idP].RA_backoff_cnt>0) { - frame_diff = (sframe_t)frameP - UE_mac_inst[module_idP].RA_backoff_frame; - - if (frame_diff < 0) { - frame_diff = -frame_diff; - } - - UE_mac_inst[module_idP].RA_backoff_cnt -= ((10*frame_diff) + (subframeP-UE_mac_inst[module_idP].RA_backoff_subframe)); - - UE_mac_inst[module_idP].RA_backoff_frame = frameP; - UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; - } - - // compute RA window parameters - if (UE_mac_inst[module_idP].RA_window_cnt>0) { - frame_diff = (frame_t)frameP - UE_mac_inst[module_idP].RA_tx_frame; - - if (frame_diff < 0) { - frame_diff = -frame_diff; - } - - UE_mac_inst[module_idP].RA_window_cnt -= ((10*frame_diff) + (subframeP-UE_mac_inst[module_idP].RA_tx_subframe)); - LOG_D(MAC,"[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, adjusted window cnt %d\n",module_idP, - frameP,subframeP,UE_mac_inst[module_idP].RA_window_cnt); - } - - if ((UE_mac_inst[module_idP].RA_window_cnt<=0) && - (UE_mac_inst[module_idP].RA_backoff_cnt<=0)) { - - UE_mac_inst[module_idP].RA_tx_frame = frameP; - UE_mac_inst[module_idP].RA_tx_subframe = subframeP; - UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER++; - UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER += - (rach_ConfigCommon->powerRampingParameters.powerRampingStep<<1); // 2dB increments in ASN.1 definition - int preambleTransMax = -1; - switch (rach_ConfigCommon->ra_SupervisionInfo.preambleTransMax) { - case PreambleTransMax_n3: - preambleTransMax = 3; - break; - case PreambleTransMax_n4: - preambleTransMax = 4; - break; - case PreambleTransMax_n5: - preambleTransMax = 5; - break; - case PreambleTransMax_n6: - preambleTransMax = 6; - break; - case PreambleTransMax_n7: - preambleTransMax = 7; - break; - case PreambleTransMax_n8: - preambleTransMax = 8; - break; - case PreambleTransMax_n10: - preambleTransMax = 10; - break; - case PreambleTransMax_n20: - preambleTransMax = 20; - break; - case PreambleTransMax_n50: - preambleTransMax = 50; - break; - case PreambleTransMax_n100: - preambleTransMax = 100; - break; - case PreambleTransMax_n200: - preambleTransMax = 200; - break; - } - - if (UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER == preambleTransMax) { - LOG_D(MAC,"[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n",module_idP,frameP,preambleTransMax); - // send message to RRC - UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER=1; - UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER = get_Po_NOMINAL_PUSCH(module_idP,CC_id); - } - - UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; - UE_mac_inst[module_idP].RA_backoff_cnt = 0; - - // Fill in preamble and PRACH resource - get_prach_resources(module_idP,CC_id,eNB_indexP,subframeP,0,NULL); - return(&UE_mac_inst[module_idP].RA_prach_resources); - } + 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(module_idP, + CC_id, + frameP, + CCCH,1, + &UE_mac_inst[module_idP].CCCH_pdu.payload[sizeof(SCH_SUBHEADER_SHORT)+1],0, + eNB_indexP, + 0); + Size16 = (uint16_t)Size; + + // LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size); + LOG_I(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_DATA_REQ (RRCConnectionRequest eNB %d) --->][MAC_UE][MOD %02d][]\n", + frameP, module_idP, eNB_indexP, module_idP); + LOG_I(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size); + + if (Size>0) { + + UE_mac_inst[module_idP].RA_active = 1; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = 1; + UE_mac_inst[module_idP].RA_Msg3_size = Size+sizeof(SCH_SUBHEADER_SHORT)+sizeof(SCH_SUBHEADER_SHORT); + UE_mac_inst[module_idP].RA_prachMaskIndex = 0; + UE_mac_inst[module_idP].RA_prach_resources.Msg3 = UE_mac_inst[module_idP].CCCH_pdu.payload; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) + + AssertFatal(rach_ConfigCommon!=NULL, + "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",module_idP,frameP); + UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; + + if (UE_mac_inst[module_idP].RA_window_cnt == 9) { + UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! + } + + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + // Fill in preamble and PRACH resource + get_prach_resources(module_idP,CC_id,eNB_indexP,subframeP,1,NULL); + + generate_ulsch_header((uint8_t*)&UE_mac_inst[module_idP].CCCH_pdu.payload[0], // mac header + 1, // num sdus + 0, // short pading + &Size16, // sdu length + &lcid, // sdu lcid + NULL, // power headroom + NULL, // crnti + NULL, // truncated bsr + NULL, // short bsr + NULL, // long_bsr + 1); //post_padding + return(&UE_mac_inst[module_idP].RA_prach_resources); + + } else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] > 0) { + // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) + dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element + rlc_status = mac_rlc_status_ind(module_idP,UE_mac_inst[module_idP].crnti, eNB_indexP,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO, + DCCH, + 6); + + if (UE_mac_inst[module_idP].crnti_before_ho) + LOG_D(MAC, + "[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send throug PRACH (mac header len %d)\n", + module_idP,frameP, UE_mac_inst[module_idP].crnti,UE_mac_inst[module_idP].crnti_before_ho, rlc_status.bytes_in_buffer,dcch_header_len); + else + LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to send through PRACH(mac header len %d)\n", + module_idP,frameP, rlc_status.bytes_in_buffer,dcch_header_len); + + sdu_lengths[0] = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, + eNB_indexP, frameP,ENB_FLAG_NO, MBMS_FLAG_NO, + DCCH, + 6, //not used + (char *)&ulsch_buff[0]); + + LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",module_idP,sdu_lengths[0]); + update_bsr(module_idP, frameP, subframeP,eNB_indexP); + UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] = + locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]]); + + //TO DO: fill BSR infos in UL TBS + + //header_len +=2; + UE_mac_inst[module_idP].RA_active = 1; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = 1; + UE_mac_inst[module_idP].RA_Msg3_size = Size+dcch_header_len; + UE_mac_inst[module_idP].RA_prachMaskIndex = 0; + UE_mac_inst[module_idP].RA_prach_resources.Msg3 = ulsch_buff; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) + + AssertFatal(rach_ConfigCommon!=NULL, + "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",module_idP,frameP); + UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; + + if (UE_mac_inst[module_idP].RA_window_cnt == 9) { + UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! + } + + + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + // Fill in preamble and PRACH resource + get_prach_resources(module_idP,CC_id,eNB_indexP,subframeP,1,NULL); + generate_ulsch_header((uint8_t*)ulsch_buff, // mac header + 1, // num sdus + 0, // short pading + &Size16, // sdu length + &lcid, // sdu lcid + NULL, // power headroom + &UE_mac_inst[module_idP].crnti, // crnti + NULL, // truncated bsr + NULL, // short bsr + NULL, // long_bsr + 0); //post_padding + + return(&UE_mac_inst[module_idP].RA_prach_resources); + } + } else { // RACH is active + LOG_D(MAC,"[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, window cnt %d (RA_tx_frame %d, RA_tx_subframe %d)\n",module_idP, + frameP,subframeP,UE_mac_inst[module_idP].RA_window_cnt, + UE_mac_inst[module_idP].RA_tx_frame,UE_mac_inst[module_idP].RA_tx_subframe); + + // compute backoff parameters + if (UE_mac_inst[module_idP].RA_backoff_cnt>0) { + frame_diff = (sframe_t)frameP - UE_mac_inst[module_idP].RA_backoff_frame; + + if (frame_diff < 0) { + frame_diff = -frame_diff; + } + + UE_mac_inst[module_idP].RA_backoff_cnt -= ((10*frame_diff) + (subframeP-UE_mac_inst[module_idP].RA_backoff_subframe)); + + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + } + + // compute RA window parameters + if (UE_mac_inst[module_idP].RA_window_cnt>0) { + frame_diff = (frame_t)frameP - UE_mac_inst[module_idP].RA_tx_frame; + + if (frame_diff < 0) { + frame_diff = -frame_diff; + } + + UE_mac_inst[module_idP].RA_window_cnt -= ((10*frame_diff) + (subframeP-UE_mac_inst[module_idP].RA_tx_subframe)); + LOG_D(MAC,"[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, adjusted window cnt %d\n",module_idP, + frameP,subframeP,UE_mac_inst[module_idP].RA_window_cnt); + } + + if ((UE_mac_inst[module_idP].RA_window_cnt<=0) && + (UE_mac_inst[module_idP].RA_backoff_cnt<=0)) { + + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER++; + UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER += + (rach_ConfigCommon->powerRampingParameters.powerRampingStep<<1); // 2dB increments in ASN.1 definition + int preambleTransMax = -1; + switch (rach_ConfigCommon->ra_SupervisionInfo.preambleTransMax) { + case PreambleTransMax_n3: + preambleTransMax = 3; + break; + case PreambleTransMax_n4: + preambleTransMax = 4; + break; + case PreambleTransMax_n5: + preambleTransMax = 5; + break; + case PreambleTransMax_n6: + preambleTransMax = 6; + break; + case PreambleTransMax_n7: + preambleTransMax = 7; + break; + case PreambleTransMax_n8: + preambleTransMax = 8; + break; + case PreambleTransMax_n10: + preambleTransMax = 10; + break; + case PreambleTransMax_n20: + preambleTransMax = 20; + break; + case PreambleTransMax_n50: + preambleTransMax = 50; + break; + case PreambleTransMax_n100: + preambleTransMax = 100; + break; + case PreambleTransMax_n200: + preambleTransMax = 200; + break; + } + + if (UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER == preambleTransMax) { + LOG_D(MAC,"[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n",module_idP,frameP,preambleTransMax); + // send message to RRC + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER=1; + UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER = get_Po_NOMINAL_PUSCH(module_idP,CC_id); + } + + UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; + + // Fill in preamble and PRACH resource + get_prach_resources(module_idP,CC_id,eNB_indexP,subframeP,0,NULL); + return(&UE_mac_inst[module_idP].RA_prach_resources); } } } else if (UE_mode == PUSCH) { LOG_D(MAC,"[UE %d] FATAL: Should not have checked for RACH in PUSCH yet ...",module_idP); AssertFatal(1==0,""); } - + return(NULL); } diff --git a/openair2/LAYER2/MAC/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c index 647fba659c66d586dd0a2d12391e9cd0adeca7f4..8ccfa81ceb83b849c32c752925a962e9dbe37535 100644 --- a/openair2/LAYER2/MAC/rar_tools.c +++ b/openair2/LAYER2/MAC/rar_tools.c @@ -99,7 +99,7 @@ unsigned short fill_rar( RC.mac[module_idP]->common_channels[CC_id].RA_template[ra_idx].timing_offset /= 16; //T_A = N_TA/16, where N_TA should be on a 30.72Msps rar[0] = (uint8_t)(RC.mac[module_idP]->common_channels[CC_id].RA_template[ra_idx].timing_offset>>(2+4)); // 7 MSBs of timing advance + divide by 4 rar[1] = (uint8_t)(RC.mac[module_idP]->common_channels[CC_id].RA_template[ra_idx].timing_offset<<(4-2))&0xf0; // 4 LSBs of timing advance + divide by 4 - rballoc = mac_computeRIV(N_RB_UL,26,1); // first PRB only for UL Grant + rballoc = mac_computeRIV(N_RB_UL,1,1); // first PRB only for UL Grant rar[1] |= (rballoc>>7)&7; // Hopping = 0 (bit 3), 3 MSBs of rballoc rar[2] = ((uint8_t)(rballoc&0xff))<<1; // 7 LSBs of rballoc mcs = 10; diff --git a/openair2/LAYER2/MAC/vars.h b/openair2/LAYER2/MAC/vars.h index 74c0e68bcf1af3980cb014444345f0069eed9e51..92e00eaaa70217aea51c7e9fccfb7cf244390b00 100644 --- a/openair2/LAYER2/MAC/vars.h +++ b/openair2/LAYER2/MAC/vars.h @@ -100,7 +100,6 @@ int pCC_id[NUMBER_OF_eNB_MAX]; eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8 -uint8_t Is_rrc_registered; #ifdef OPENAIR2 unsigned char NB_eNB_INST=0; diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c index afb521d2c0aa265882e36c957050a2eee3aaf6f7..4936be61d5c0a9f09b6fa4c3f4a0c960b8c51e0c 100644 --- a/openair2/PHY_INTERFACE/IF_Module.c +++ b/openair2/PHY_INTERFACE/IF_Module.c @@ -10,6 +10,63 @@ IF_Module_t *if_inst[MAX_IF_MODULES]; Sched_Rsp_t Sched_INFO[MAX_IF_MODULES][MAX_NUM_CCs]; +void handle_rach(UL_IND_t *UL_info) { + + if (UL_info->rach_ind.number_of_preambles>0) { + + AssertFatal(UL_info->rach_ind.number_of_preambles==1,"More than 1 preamble not supported\n"); + UL_info->rach_ind.number_of_preambles=0; + LOG_I(MAC,"Frame %d, Subframe %d Calling initiate_ra_proc\n",UL_info->frame,UL_info->subframe); + initiate_ra_proc(UL_info->module_id, + UL_info->CC_id, + UL_info->frame, + UL_info->subframe, + UL_info->rach_ind.preamble_list[0].preamble_rel8.preamble, + UL_info->rach_ind.preamble_list[0].preamble_rel8.timing_advance, + UL_info->rach_ind.preamble_list[0].preamble_rel8.rnti); + } +} + +void handle_ulsch(UL_IND_t *UL_info) { + + int i; + + for (i=0;i<UL_info->rx_ind.number_of_pdus;i++) { + + LOG_I(MAC,"Frame %d, Subframe %d Calling rx_sdu \n",UL_info->frame,UL_info->subframe); + rx_sdu(UL_info->module_id, + UL_info->CC_id, + UL_info->frame, + UL_info->subframe, + UL_info->rx_ind.rx_pdu_list[i].rx_ue_information.rnti, + UL_info->rx_ind.rx_pdu_list[i].data, + UL_info->rx_ind.rx_pdu_list[i].rx_indication_rel8.length, + UL_info->rx_ind.rx_pdu_list[i].rx_indication_rel8.timing_advance, + UL_info->rx_ind.rx_pdu_list[i].rx_indication_rel8.ul_cqi); + + } + UL_info->rx_ind.number_of_pdus=0; + + for (i=0;i<UL_info->crc_ind.number_of_crcs;i++) { + + if (UL_info->crc_ind.crc_pdu_list[i].crc_indication_rel8.crc_flag == 1) { // CRC error indication + LOG_I(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, + UL_info->frame, + UL_info->subframe, + UL_info->crc_ind.crc_pdu_list[i].rx_ue_information.rnti, + (uint8_t *)NULL, + 0, + 0, + 0); + } + + + } + UL_info->crc_ind.number_of_crcs=0; +} + void UL_indication(UL_IND_t *UL_info) { @@ -38,13 +95,13 @@ void UL_indication(UL_IND_t *UL_info) - // Call uplink indication function - AssertFatal(ifi->UL_indication!=NULL,"UL_indication is null (mod %d, cc %d)\n", - module_id, - CC_id); + handle_rach(UL_info); + + // clear HI prior to hanling ULSCH + mac->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_hi = 0; + + handle_ulsch(UL_info); - // ifi->UL_indication(UL_info); - if (ifi->CC_mask == ((1<<MAX_NUM_CCs)-1)) { eNB_dlsch_ulsch_scheduler(module_id, @@ -67,8 +124,8 @@ void UL_indication(UL_IND_t *UL_info) module_id, CC_id); ifi->schedule_response(sched_info); - LOG_I(PHY,"Schedule_response: frame %d, subframe %d (dl_pdus %d / %p)\n",sched_info->frame,sched_info->subframe,sched_info->DL_req->number_pdu, - &sched_info->DL_req->number_pdu); + LOG_I(PHY,"Schedule_response: frame %d, subframe %d (dl_pdus %d / %p)\n",sched_info->frame,sched_info->subframe,sched_info->DL_req->dl_config_request_body.number_pdu, + &sched_info->DL_req->dl_config_request_body.number_pdu); } } diff --git a/openair2/PHY_INTERFACE/IF_Module.h b/openair2/PHY_INTERFACE/IF_Module.h index 86933c22a68bab93de2e78583b5296620900e853..9a6915b7560c7bc03964ea0a8d2ed46d2a59410b 100644 --- a/openair2/PHY_INTERFACE/IF_Module.h +++ b/openair2/PHY_INTERFACE/IF_Module.h @@ -75,22 +75,22 @@ typedef struct{ sub_frame_t subframe; /// harq indication list - nfapi_harq_indication_body_t *harq_ind[MAX_NUM_HARQ_IND]; + nfapi_harq_indication_body_t harq_ind; /// crc indication list - nfapi_crc_indication_body_t *crc_ind[MAX_NUM_CRC_IND]; + nfapi_crc_indication_body_t crc_ind; /// SR indication list - nfapi_sr_indication_body_t sr_ind[MAX_NUM_SR_IND]; + nfapi_sr_indication_body_t sr_ind; /// CQI indication list - nfapi_cqi_indication_body_t cqi_ind[MAX_NUM_CQI_IND]; + nfapi_cqi_indication_body_t cqi_ind; /// RACH indication list - nfapi_rach_indication_body_t rach_ind[MAX_NUM_RACH_IND]; + nfapi_rach_indication_body_t rach_ind; /// SRS indication list - nfapi_srs_indication_body_t srs_ind[MAX_NUM_SRS_IND]; + nfapi_srs_indication_body_t srs_ind; /// RX indication nfapi_rx_indication_body_t rx_ind; @@ -110,13 +110,13 @@ typedef struct{ /// subframe sub_frame_t subframe; /// nFAPI DL Config Request - nfapi_dl_config_request_body_t *DL_req; + nfapi_dl_config_request_t *DL_req; /// nFAPI UL Config Request - nfapi_ul_config_request_body_t *UL_req; + nfapi_ul_config_request_t *UL_req; /// nFAPI HI_DCI Request - nfapi_hi_dci0_request_body_t *HI_DCI0_req; + nfapi_hi_dci0_request_t *HI_DCI0_req; /// Pointers to DL SDUs - nfapi_tx_request_body_t *TX_req; + nfapi_tx_request_t *TX_req; }Sched_Rsp_t; typedef struct { diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c index 5cf2bbcdf7a6997c195415571f28a649ada990df..7b58d9aa13a959c64909c4cceba33514e3594459 100644 --- a/openair2/RRC/LITE/L2_interface.c +++ b/openair2/RRC/LITE/L2_interface.c @@ -79,16 +79,24 @@ mac_rrc_data_req( SRB_INFO *Srb_info; uint8_t Sdu_size = 0; uint8_t sfn = (uint8_t)((frameP>>2)&0xff); - eNB_RRC_INST *rrc = RC.rrc[Mod_idP]; - rrc_eNB_carrier_data_t *carrier = &rrc->carrier[0]; - BCCH_BCH_Message_t *mib = &carrier->mib; + + + #ifdef DEBUG_RRC int i; LOG_T(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id); #endif + eNB_RRC_INST *rrc; + rrc_eNB_carrier_data_t *carrier; + BCCH_BCH_Message_t *mib; + if( enb_flagP == ENB_FLAG_YES) { + rrc = RC.rrc[Mod_idP]; + carrier = &rrc->carrier[0]; + mib = &carrier->mib; + if((Srb_id & RAB_OFFSET) == BCCH) { if(RC.rrc[Mod_idP]->carrier[CC_id].SI.Active==0) { return 0; @@ -188,8 +196,8 @@ mac_rrc_data_req( enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_BCH_Message, (void*)mib, carrier->MIB, - 100); - LOG_I(RRC,"Encoded MIB for frame %d (%p)\n",sfn,carrier->MIB); + 24); + LOG_I(RRC,"Encoded MIB for frame %d (%p), bits %lu\n",sfn,carrier->MIB,enc_rval.encoded); buffer_pP[0]=carrier->MIB[0]; buffer_pP[1]=carrier->MIB[1]; buffer_pP[2]=carrier->MIB[2]; @@ -298,6 +306,7 @@ mac_rrc_data_req( #endif //Rel10 || Rel14 } else { //This is an UE + LOG_D(RRC,"[UE %d] Frame %d Filling CCCH SRB_ID %d\n",Mod_idP,frameP,Srb_id); LOG_D(RRC,"[UE %d] Frame %d buffer_pP status %d,\n",Mod_idP,frameP, UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size); diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c index b313bcfdb858d103f1583f21cb60c06eace54080..70f27a7cf5be22cd9cbc95c9f5c13f87776fe6cd 100644 --- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c @@ -661,7 +661,7 @@ uint8_t do_SIB23(uint8_t Mod_id, #endif // SRS Config - if (configuration->srs_enable[CC_id]) { + if (configuration->srs_enable[CC_id]==1) { (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present = SoundingRS_UL_ConfigCommon_PR_setup; (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_BandwidthConfig @@ -678,7 +678,9 @@ uint8_t do_SIB23(uint8_t Mod_id, } else { (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts = NULL; } + RC.rrc[Mod_id]->srs_enable[CC_id] = 1; } else { + RC.rrc[Mod_id]->srs_enable[CC_id] = 0; (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present=SoundingRS_UL_ConfigCommon_PR_release; (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.release=0; } @@ -1363,7 +1365,7 @@ do_RRCConnectionSetup( physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH)); physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH)); physicalConfigDedicated2->cqi_ReportConfig = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig)); - if (rrc->srs_enable[CC_id]) + if (rrc->srs_enable[CC_id]==1) physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->soundingRS_UL_ConfigDedicated)); else physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = NULL; @@ -1455,7 +1457,7 @@ do_RRCConnectionSetup( */ //soundingRS-UL-ConfigDedicated - if (rrc->srs_enable[CC_id]) { + if (rrc->srs_enable[CC_id]==1) { physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->present = SoundingRS_UL_ConfigDedicated_PR_setup; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth = SoundingRS_UL_ConfigDedicated__setup__srs_Bandwidth_bw0; diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 1bc8af09b91dc8aa0760fa9f626f413929f0f5b0..46ec6ebc2ce101dee647aff518396780913c9a50 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -133,7 +133,7 @@ init_SI( int i; #endif - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MIB = (uint8_t*) malloc16(3); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MIB = (uint8_t*) malloc16(4); // copy basic parameters RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId = configuration->Nid_cell[CC_id]; RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB = configuration->nb_antenna_ports[CC_id]; @@ -255,7 +255,8 @@ init_SI( PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_Offset_r9); } - } + } + else memset((void*)&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13,0,sizeof(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13)); #endif LOG_D(RRC, @@ -271,6 +272,7 @@ init_SI( #ifdef Rel14 RC.rrc[ctxt_pP->module_id]->carrier[CC_id].pbch_repetition, #endif + 0, // rnti (BCCH_BCH_Message_t *) &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib, (RadioResourceConfigCommonSIB_t *) & @@ -369,6 +371,7 @@ init_MCCH( #ifdef Rel14 0, #endif + 0,//rnti (BCCH_BCH_Message_t *)NULL, (RadioResourceConfigCommonSIB_t *) NULL, (RadioResourceConfigCommonSIB_t *) NULL, @@ -542,8 +545,8 @@ rrc_eNB_get_next_free_ue_context( { struct rrc_eNB_ue_context_s* ue_context_p = NULL; ue_context_p = rrc_eNB_get_ue_context( - RC.rrc[ctxt_pP->module_id], - ctxt_pP->rnti); + RC.rrc[ctxt_pP->module_id], + ctxt_pP->rnti); if (ue_context_p == NULL) { RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { @@ -2729,6 +2732,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( #ifdef Rel14 0, #endif + ue_context_pP->ue_context.rnti, (BCCH_BCH_Message_t *) NULL, (RadioResourceConfigCommonSIB_t*) NULL, (RadioResourceConfigCommonSIB_t*) NULL, @@ -3307,6 +3311,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( #ifdef Rel14 0, #endif + ue_context_pP->ue_context.rnti, (BCCH_BCH_Message_t *) NULL, (RadioResourceConfigCommonSIB_t *) NULL, (RadioResourceConfigCommonSIB_t *) NULL, @@ -3608,6 +3613,7 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( #ifdef Rel14 0, #endif + ue_context_pP->ue_context.rnti, (BCCH_BCH_Message_t *) NULL, (RadioResourceConfigCommonSIB_t *) NULL, (RadioResourceConfigCommonSIB_t *) NULL, @@ -3659,6 +3665,7 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( #ifdef Rel14 0, #endif + ue_context_pP->ue_context.rnti, (BCCH_BCH_Message_t *) NULL, (RadioResourceConfigCommonSIB_t *) NULL, (RadioResourceConfigCommonSIB_t *) NULL, @@ -3711,7 +3718,7 @@ rrc_eNB_generate_RRCConnectionSetup( ue_context_pP, CC_id, (uint8_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload, - (uint8_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, //at this point we do not have the UE capability information, so it can only be TM1 or TM2 + (uint8_t) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, //at this point we do not have the UE capability information, so it can only be TM1 or TM2 rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), SRB_configList, &ue_context_pP->ue_context.physicalConfigDedicated); @@ -3755,6 +3762,7 @@ rrc_eNB_generate_RRCConnectionSetup( #ifdef Rel14 0, #endif + ue_context_pP->ue_context.rnti, (BCCH_BCH_Message_t *) NULL, (RadioResourceConfigCommonSIB_t *) NULL, (RadioResourceConfigCommonSIB_t *) NULL, @@ -3989,7 +3997,7 @@ rrc_eNB_decode_ccch( //memset(ul_ccch_msg,0,sizeof(UL_CCCH_Message_t)); - LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Decoding UL CCCH %x.%x.%x.%x.%x.%x (%p)\n", + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Decoding UL CCCH %x.%x.%x.%x.%x.%x (%p)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), ((uint8_t*) Srb_info->Rx_buffer.Payload)[0], ((uint8_t *) Srb_info->Rx_buffer.Payload)[1], @@ -4006,6 +4014,7 @@ rrc_eNB_decode_ccch( 0, 0); + /* #if defined(ENABLE_ITTI) # if defined(DISABLE_ITTI_XER_PRINT) { @@ -4034,6 +4043,7 @@ rrc_eNB_decode_ccch( } # endif #endif + */ for (i = 0; i < 8; i++) { LOG_T(RRC, "%x.", ((uint8_t *) & ul_ccch_msg)[i]); @@ -4963,13 +4973,19 @@ rrc_enb_task( CC_id = RRC_MAC_CCCH_DATA_IND(msg_p).CC_id; srb_info_p = &RC.rrc[instance]->carrier[CC_id].Srb0; + LOG_I(RRC,"Decoding CCCH : inst %d, CC_id %d, ctxt %p, sib_info_p->Rx_buffer.payload_size %d\n", + instance,CC_id,&ctxt, RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); + AssertFatal(RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size < RRC_BUFFER_SIZE_MAX, + "CCCH message has size %d > %d\n", + RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,RRC_BUFFER_SIZE_MAX); memcpy(srb_info_p->Rx_buffer.Payload, RRC_MAC_CCCH_DATA_IND(msg_p).sdu, RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); srb_info_p->Rx_buffer.payload_size = RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size; + rrc_eNB_decode_ccch(&ctxt, srb_info_p, CC_id); break; - + /* Messages from PDCP */ case RRC_DCCH_DATA_IND: PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, diff --git a/openair2/RRC/LITE/rrc_eNB_UE_context.c b/openair2/RRC/LITE/rrc_eNB_UE_context.c index c0243ca6bf6aa9eceb2fca52956e806b1c08cb1b..3672d23b7cd7bbf3ecc39987a4604bfe81203ce9 100644 --- a/openair2/RRC/LITE/rrc_eNB_UE_context.c +++ b/openair2/RRC/LITE/rrc_eNB_UE_context.c @@ -127,7 +127,7 @@ rrc_eNB_allocate_new_UE_context( //------------------------------------------------------------------------------ { struct rrc_eNB_ue_context_s* new_p; - new_p = malloc(sizeof(struct rrc_eNB_ue_context_s)); + new_p = (struct rrc_eNB_ue_context_s* )malloc(sizeof(struct rrc_eNB_ue_context_s)); if (new_p == NULL) { LOG_E(RRC, "Cannot allocate new ue context\n"); diff --git a/openair3/S1AP/s1ap_eNB_decoder.c b/openair3/S1AP/s1ap_eNB_decoder.c index c2cc3655d41889b27a8cd71d9d69400592697e30..12a494106ebd2cdbadb7a8cf1ab3687a725d82da 100644 --- a/openair3/S1AP/s1ap_eNB_decoder.c +++ b/openair3/S1AP/s1ap_eNB_decoder.c @@ -160,6 +160,7 @@ static int s1ap_eNB_decode_successful_outcome(s1ap_message *message, DevAssert(successfullOutcome_p != NULL); message_string = malloc(sizeof(char) * 10000); + memset((void*)message_string,0,sizeof(char) * 10000); s1ap_string_total_size = 0; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 23373d177baf0093d5ed1b6d14f780ccac90faca..4c3ffd5aeba75b5b98182d12f35db26ac213dac5 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -157,13 +157,14 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam // UE-specific RX processing for subframe n phy_procedures_eNB_uespec_RX(eNB, proc, no_relay ); - LOG_I(PHY,"uespec_RX complete: frame %d, subframe %d\n",proc->frame_rx,proc->subframe_rx); + + pthread_mutex_lock(&eNB->UL_INFO_mutex); eNB->UL_INFO.frame = proc->frame_rx; eNB->UL_INFO.subframe = proc->subframe_rx; eNB->UL_INFO.module_id = eNB->Mod_id; eNB->UL_INFO.CC_id = eNB->CC_id; eNB->if_inst->UL_indication(&eNB->UL_INFO); - + pthread_mutex_unlock(&eNB->UL_INFO_mutex); // ***************************************** // TX processing for subframe n+4 // run PHY TX procedures the one after the other for all CCs to avoid race conditions @@ -501,6 +502,7 @@ void init_eNB_proc(int inst) { proc->RU_mask=0; proc->RU_mask_prach=0; + pthread_mutex_init( &eNB->UL_INFO_mutex, NULL); pthread_mutex_init( &proc_rxtx[0].mutex_rxtx, NULL); pthread_mutex_init( &proc_rxtx[1].mutex_rxtx, NULL); pthread_cond_init( &proc_rxtx[0].cond_rxtx, NULL); @@ -531,17 +533,19 @@ void init_eNB_proc(int inst) { attr_te = &proc->attr_te; #endif - 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] ); + if (eNB->single_thread_flag==0) { + 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] ); + } pthread_create( &proc->pthread_prach, attr_prach, eNB_thread_prach, eNB ); char name[16]; - snprintf( name, sizeof(name), "RXTX0 %d", i ); - pthread_setname_np( proc_rxtx[0].pthread_rxtx, name ); - snprintf( name, sizeof(name), "RXTX1 %d", i ); - pthread_setname_np( proc_rxtx[1].pthread_rxtx, name ); - // snprintf( name, sizeof(name), "FH %d", i ); - // pthread_setname_np( proc->pthread_FH, name ); + if (eNB->single_thread_flag==0) { + snprintf( name, sizeof(name), "RXTX0 %d", i ); + pthread_setname_np( proc_rxtx[0].pthread_rxtx, name ); + snprintf( name, sizeof(name), "RXTX1 %d", i ); + pthread_setname_np( proc_rxtx[1].pthread_rxtx, name ); + } AssertFatal(proc->instance_cnt_prach == -1,"instance_cnt_prach = %d\n",proc->instance_cnt_prach); @@ -601,7 +605,7 @@ void kill_eNB_proc(int inst) { pthread_join( proc->pthread_prach, (void**)&status ); pthread_mutex_destroy( &proc->mutex_prach ); pthread_cond_destroy( &proc->cond_prach ); - + pthread_mutex_destroy(&eNB->UL_INFO_mutex); int i; for (i=0;i<2;i++) { pthread_join( proc_rxtx[i].pthread_rxtx, (void**)&status ); @@ -714,6 +718,7 @@ void init_eNB_afterRU() { // map antennas and PRACH signals to eNB RX AssertFatal(eNB->num_RU>0,"Number of RU attached to eNB %d is zero\n",eNB->Mod_id); LOG_I(PHY,"Mapping RX ports from %d RUs to eNB %d\n",eNB->num_RU,eNB->Mod_id); + eNB->frame_parms.nb_antennas_rx = 0; for (ru_id=0,aa=0;ru_id<eNB->num_RU;ru_id++) { eNB->frame_parms.nb_antennas_rx += eNB->RU_list[ru_id]->nb_rx; for (i=0;i<eNB->RU_list[ru_id]->nb_rx;aa++,i++) { @@ -722,6 +727,9 @@ void init_eNB_afterRU() { eNB->common_vars.rxdataF[aa] = eNB->RU_list[ru_id]->common.rxdataF[i]; } } + AssertFatal(eNB->frame_parms.nb_antennas_rx >0, + "inst %d, CC_id %d : nb_antennas_rx %d\n",inst,CC_id,eNB->frame_parms.nb_antennas_rx); + LOG_I(PHY,"inst %d, CC_id %d : nb_antennas_rx %d\n",inst,CC_id,eNB->frame_parms.nb_antennas_rx); AssertFatal(eNB->frame_parms.nb_antennas_rx <= sizeof(eNB->prach_vars.prach_ifft) / sizeof(eNB->prach_vars.prach_ifft[0]), "nb_antennas_rx too large"); @@ -736,8 +744,8 @@ void init_eNB_afterRU() { } for (ru_id=0;ru_id<RC.nb_RU;ru_id++) { - - if (RC.ru[ru_id]==NULL) RC.ru[ru_id] = (RU_t*)malloc(sizeof(RU_t)); + + AssertFatal(RC.ru[ru_id]!=NULL,"ru_id %d is null\n",ru_id); RC.ru[ru_id]->wakeup_rxtx = wakeup_rxtx; RC.ru[ru_id]->wakeup_prach_eNB = wakeup_prach_eNB; @@ -770,15 +778,20 @@ void init_eNB(int single_thread_flag,int wait_for_sync) { LOG_I(PHY,"Registering with MAC interface module\n"); - AssertFatal((eNB->if_inst = IF_Module_init(inst))!=NULL,"Cannot register interface"); - eNB->if_inst->schedule_response = schedule_response; - eNB->if_inst->PHY_config_req = phy_config_request; + AssertFatal((eNB->if_inst = IF_Module_init(inst))!=NULL,"Cannot register interface"); + eNB->if_inst->schedule_response = schedule_response; + eNB->if_inst->PHY_config_req = phy_config_request; + memset((void*)&eNB->UL_INFO,0,sizeof(eNB->UL_INFO)); + memset((void*)&eNB->Sched_INFO,0,sizeof(eNB->Sched_INFO)); + LOG_I(PHY,"Setting indication lists\n"); + eNB->UL_INFO.rx_ind.rx_pdu_list = eNB->rx_pdu_list; + eNB->UL_INFO.crc_ind.crc_pdu_list = eNB->crc_pdu_list; } } - LOG_D(PHY,"[lte-softmodem.c] eNB structure allocated\n"); + LOG_I(PHY,"[lte-softmodem.c] eNB structure allocated\n"); diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 953eb156c44d38a4c1b0c4eb0cf8d824143aa73a..7de92d9652ada27644e9c09f7a6973fdff2205b8 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -129,6 +129,7 @@ int attach_rru(RU_t *ru); int connect_rau(RU_t *ru); + /*************************************************************/ /* Functions to attach and configure RRU */ @@ -138,9 +139,11 @@ int attach_rru(RU_t *ru) { RRU_CONFIG_msg_t rru_config_msg; int received_capabilities=0; + wait_eNBs(ru); // Wait for capabilities while (received_capabilities==0) { + memset((void*)&rru_config_msg,0,sizeof(rru_config_msg)); rru_config_msg.type = RAU_tick; rru_config_msg.len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE; LOG_I(PHY,"Sending RAU tick to RRU %d\n",ru->idx); @@ -188,6 +191,7 @@ int attach_rru(RU_t *ru) { ((RRU_config_t *)&rru_config_msg.msg[0])->prach_FreqOffset[0], ((RRU_config_t *)&rru_config_msg.msg[0])->prach_ConfigIndex[0]); + AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1), "RU %d failed send configuration to remote radio\n",ru->idx); @@ -1542,7 +1546,9 @@ int check_capabilities(RU_t *ru,RRU_capabilities_t *cap) { char rru_format_options[4][20] = {"OAI_IF5_only","OAI_IF4p5_only","OAI_IF5_and_IF4p5","MBP_IF5"}; + char rru_formats[3][20] = {"OAI_IF5","MBP_IF5","OAI_IF4p5"}; +char ru_if_formats[4][20] = {"LOCAL_RF","REMOTE_OAI_IF5","REMOTE_MBP_IF5","REMOTE_OAI_IF4p5"}; void configure_ru(int idx, void *arg) { @@ -1558,7 +1564,8 @@ void configure_ru(int idx, if (capabilities->FH_fmt < MAX_FH_FMTs) LOG_I(PHY, "RU FH options %s\n",rru_format_options[capabilities->FH_fmt]); if ((ret=check_capabilities(ru,capabilities)) == 0) { // Pass configuration to RRU - LOG_I(PHY, "Using %s fronthaul, band %d \n",rru_formats[ru->if_south],ru->frame_parms.eutra_band); + LOG_I(PHY, "Using %s fronthaul (%d), band %d \n",ru_if_formats[ru->if_south],ru->if_south,ru->frame_parms.eutra_band); + // wait for configuration config->FH_fmt = ru->if_south; config->num_bands = 1; config->band_list[0] = ru->frame_parms.eutra_band; @@ -1572,6 +1579,9 @@ void configure_ru(int idx, if (ru->if_south==REMOTE_IF4p5) { config->prach_FreqOffset[0] = ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset; config->prach_ConfigIndex[0] = ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex; + LOG_I(PHY,"REMOTE_IF4p5: prach_FrequOffset %d, prach_ConfigIndex %d\n", + config->prach_FreqOffset[0],config->prach_ConfigIndex[0]); + } // take antenna capabilities of RRU ru->nb_tx = capabilities->nb_tx[0]; @@ -1601,6 +1611,8 @@ void configure_rru(int idx, ru->frame_parms.threequarter_fs = config->threequarter_fs[0]; ru->frame_parms.pdsch_config_common.referenceSignalPower = ru->max_pdschReferenceSignalPower-config->att_tx[0]; if (ru->function==NGFI_RRU_IF4p5) { + LOG_I(PHY,"Setting ru->function to NGFI_RRU_IF4p5, prach_FrequOffset %d, prach_ConfigIndex %d\n", + config->prach_FreqOffset[0],config->prach_ConfigIndex[0]); ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset = config->prach_FreqOffset[0]; ru->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex = config->prach_ConfigIndex[0]; } @@ -1656,10 +1668,12 @@ void init_RU(const char *rf_config_file) { pthread_mutex_init(&RC.ru_mutex,NULL); pthread_cond_init(&RC.ru_cond,NULL); - // read in configuration file + // read in configuration file) + printf("configuring RU from file\n"); RCconfig_RU(); + printf("number of L1 instaces %d, number of RU %d\n",RC.nb_L1_inst,RC.nb_RU); - for (i=0;i<RC.nb_inst;i++) + for (i=0;i<RC.nb_L1_inst;i++) for (CC_id=0;CC_id<RC.nb_CC[i];CC_id++) RC.eNB[i][CC_id]->num_RU=0; for (ru_id=0;ru_id<RC.nb_RU;ru_id++) { @@ -1679,7 +1693,7 @@ void init_RU(const char *rf_config_file) { eNB0 = ru->eNB_list[i]; eNB0->RU_list[eNB0->num_RU++] = ru; } - LOG_I(PHY,"Initializing RRU descriptor %d : (%s,%s,%d)\n",ru_id,ru_if_types[ru->if_south],eNB_timing[ru->if_timing],ru->function); + // LOG_I(PHY,"Initializing RRU descriptor %d : (%s,%s,%d)\n",ru_id,ru_if_types[ru->if_south],eNB_timing[ru->if_timing],ru->function); switch (ru->if_south) { diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index fedcb1b05a649bfc910ae44822330ead541dace4..f772736f0e52ac689537c1fc4f8b4f2eaee2a610 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1063,6 +1063,7 @@ static void get_options (int argc, char **argv) { if ((UE_flag == 0) && (conf_config_file_name != NULL)) { + memset((void*)&RC,0,sizeof(RC)); /* Read RC configuration file */ RCConfig(conf_config_file_name); @@ -1267,6 +1268,25 @@ void wait_RUs() { LOG_I(PHY,"RUs configured\n"); } +void wait_eNBs() { + + int i,j; + int waiting=1; + + + while (waiting==1) { + printf("Waiting for eNB L1 instances to all get configured ... sleeping 500ms (nb_L1_inst %d)\n",RC.nb_L1_inst); + usleep(500000); + waiting=0; + for (i=0;i<RC.nb_L1_inst;i++) + for (j=0;j<RC.nb_L1_CC[i];j++) + if (RC.eNB[i][j]->configured==0) { + waiting=1; + break; + } + } + printf("eNB L1 are configured\n"); +} int main( int argc, char **argv ) { @@ -1275,7 +1295,7 @@ int main( int argc, char **argv ) void *status; #endif - + int inst; int CC_id; int ru_id; uint8_t abstraction_flag=0; @@ -1668,10 +1688,15 @@ int main( int argc, char **argv ) } else { number_of_cards = 1; - if (RC.nb_inst > 0) { + if (RC.nb_L1_inst > 0) { printf("Initializing eNB threads\n"); init_eNB(single_thread_flag,wait_for_sync); + for (inst=0;inst<RC.nb_L1_inst;inst++) + for (CC_id=0;CC_id<RC.nb_L1_CC[inst];CC_id++) phy_init_lte_eNB(RC.eNB[inst][CC_id],0,0); } + + wait_eNBs(); + if (RC.nb_RU >0) { printf("Initializing RU threads\n"); init_RU(rf_config_file); @@ -1680,11 +1705,22 @@ int main( int argc, char **argv ) RC.ru[ru_id]->rf_map.chain=CC_id+chain_offset; } } - + + AssertFatal(RC.eNB[0][0]->UL_INFO.crc_ind.crc_pdu_list!=NULL, + "RC.eNB[0][0]->UL_INFO.crc_ind.crc_pdu_list is null\n"); + AssertFatal(RC.eNB[0][0]->UL_INFO.rx_ind.rx_pdu_list!=NULL, + "RC.eNB[0][0]->UL_INFO.rx_ind.rx_pdu_list is null\n"); wait_RUs(); - // once all RUs are ready intiailize the rest of the eNBs (dependence on final RU parameters after configuration) + AssertFatal(RC.eNB[0][0]->UL_INFO.crc_ind.crc_pdu_list!=NULL, + "RC.eNB[0][0]->UL_INFO.crc_ind.crc_pdu_list is null\n"); + AssertFatal(RC.eNB[0][0]->UL_INFO.rx_ind.rx_pdu_list!=NULL, + "RC.eNB[0][0]->UL_INFO.rx_ind.rx_pdu_list is null\n"); + // once all RUs are ready intiailize the rest of the eNBs ((dependence on final RU parameters after configuration) init_eNB_afterRU(); - + AssertFatal(RC.eNB[0][0]->UL_INFO.crc_ind.crc_pdu_list!=NULL, + "RC.eNB[0][0]->UL_INFO.crc_ind.crc_pdu_list is null\n"); + AssertFatal(RC.eNB[0][0]->UL_INFO.rx_ind.rx_pdu_list!=NULL, + "RC.eNB[0][0]->UL_INFO.rx_ind.rx_pdu_list is null\n"); } diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 022f993715b2e696c9c35506b6bdb4db192fba43..fdeeaea9a527d71d8e609fc718d31981a24cb106 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -144,7 +144,7 @@ PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, int i,j; PHY_VARS_UE* ue; - if (frame_parms!=(PHY_VARS_UE *)NULL) { // if we want to give initial frame parms, allocate the PHY_VARS_UE structure and put them in + if (frame_parms!=(LTE_DL_FRAME_PARMS *)NULL) { // if we want to give initial frame parms, allocate the PHY_VARS_UE structure and put them in ue = (PHY_VARS_UE *)malloc(sizeof(PHY_VARS_UE)); memset(ue,0,sizeof(PHY_VARS_UE)); memcpy(&(ue->frame_parms), frame_parms, sizeof(LTE_DL_FRAME_PARMS));