From 4aed32e786b544f0a2f6a2d1590d3955bd3f1a36 Mon Sep 17 00:00:00 2001 From: hbilel Date: Tue, 13 Jun 2017 09:49:17 +0200 Subject: [PATCH 1/7] [OAI-UE] slot0 / slot1 parallelization --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 119 +- .../PHY/LTE_TRANSPORT/dlsch_demodulation.c | 46 +- .../PHY/LTE_TRANSPORT/dlsch_llr_computation.c | 59 +- openair1/PHY/LTE_TRANSPORT/proto.h | 11 +- openair1/PHY/MODULATION/defs.h | 11 + openair1/PHY/MODULATION/slot_fep.c | 212 ++++ openair1/PHY/defs.h | 27 + openair1/PHY/impl_defs_lte.h | 4 + openair1/SCHED/defs.h | 2 + openair1/SCHED/phy_procedures_lte_ue.c | 1111 +++++++++++------ targets/RT/USER/lte-ue.c | 275 +++- 11 files changed, 1448 insertions(+), 429 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 990c3a1c26..0d933dfd74 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -5138,10 +5138,70 @@ int check_dci_format2_2a_coherency(DCI_format_t dci_format, return(1); } +void compute_llr_offset(LTE_DL_FRAME_PARMS *frame_parms, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, + LTE_DL_UE_HARQ_t *dlsch0_harq, + uint8_t nb_rb_alloc, + uint8_t subframe) +{ + uint32_t pbch_pss_sss_re; + uint32_t crs_re; + uint32_t granted_re; + uint32_t data_re; + uint32_t llr_offset; + uint8_t symbol; + uint8_t symbol_mod; + + pdsch_vars->llr_offset[pdcch_vars->num_pdcch_symbols] = 0; + + LOG_I(PHY,"compute_llr_offset: nb RB %d - Qm %d \n", nb_rb_alloc, dlsch0_harq->Qm); + + //dlsch0_harq->rb_alloc_even; + //dlsch0_harq->rb_alloc_odd; + + for(symbol=pdcch_vars->num_pdcch_symbols; symbolsymbols_per_tti; symbol++) + { + symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol; + if((symbol_mod == 0) || symbol_mod == (4-frame_parms->Ncp)) + { + if (frame_parms->mode1_flag==0) + crs_re = 4; + else + crs_re = 2; + } + else + { + crs_re = 0; + } + + granted_re = nb_rb_alloc * (12-crs_re); + pbch_pss_sss_re = adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,dlsch0_harq->Qm,subframe,symbol); + pbch_pss_sss_re = (double)pbch_pss_sss_re * ((double)(12-crs_re)/12); + data_re = granted_re - pbch_pss_sss_re; + llr_offset = data_re * dlsch0_harq->Qm * 2; + + pdsch_vars->llr_length[symbol] = data_re; + if(symbol < (frame_parms->symbols_per_tti-1)) + pdsch_vars->llr_offset[symbol+1] = pdsch_vars->llr_offset[symbol] + llr_offset; + + //LOG_I(PHY,"Granted Re subframe %d / symbol %d => %d (%d RBs)\n", subframe, symbol_mod, granted_re,dlsch0_harq->nb_rb); + //LOG_I(PHY,"Pbch/PSS/SSS Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, pbch_pss_sss_re); + //LOG_I(PHY,"CRS Re Per PRB subframe %d / symbol %d => %d \n", subframe, symbol_mod, crs_re); + //LOG_I(PHY,"Data Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, data_re); + + + + //LOG_I(PHY,"Data Re subframe %d-symbol %d => llr length %d, llr offset %d \n", subframe, symbol, + // pdsch_vars->llr_length[symbol], pdsch_vars->llr_offset[symbol]); + } +} void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, uint8_t N_RB_DL, DCI_INFO_EXTRACTED_t *pdci_info_extarcted, LTE_DL_FRAME_PARMS *frame_parms, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, uint8_t subframe, uint16_t rnti, uint16_t tc_rnti, @@ -5163,12 +5223,27 @@ void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, uint8_t dai = pdci_info_extarcted->dai; uint8_t NPRB = 0; + uint8_t nb_rb_alloc = 0; if(dci_format == format1A) { if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) { NPRB = (TPC&1) + 2; + switch (N_RB_DL) { + case 6: + nb_rb_alloc = RIV2nb_rb_LUT6[rballoc];//NPRB; + break; + case 25: + nb_rb_alloc = RIV2nb_rb_LUT25[rballoc];//NPRB; + break; + case 50: + nb_rb_alloc = RIV2nb_rb_LUT50[rballoc];//NPRB; + break; + case 100: + nb_rb_alloc = RIV2nb_rb_LUT100[rballoc];//NPRB; + break; + } } else { @@ -5186,6 +5261,7 @@ void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; break; } + nb_rb_alloc = NPRB; } } else // format1 @@ -5345,7 +5421,6 @@ void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, pdlsch0_harq->rb_alloc_odd[2]= pdlsch0_harq->rb_alloc_even[2]; pdlsch0_harq->rb_alloc_odd[3]= pdlsch0_harq->rb_alloc_even[3]; } - if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) { pdlsch0_harq->TBS = TBStable[mcs1][NPRB-1]; @@ -5359,11 +5434,20 @@ void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, pdlsch0_harq->Qm = get_Qm(mcs1); } } + + compute_llr_offset(frame_parms, + pdcch_vars, + pdsch_vars, + pdlsch0_harq, + nb_rb_alloc, + subframe); } void prepare_dl_decoding_format1C(uint8_t N_RB_DL, DCI_INFO_EXTRACTED_t *pdci_info_extarcted, LTE_DL_FRAME_PARMS *frame_parms, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, uint32_t rnti, uint32_t si_rnti, uint32_t ra_rnti, @@ -5466,6 +5550,14 @@ void prepare_dl_decoding_format1C(uint8_t N_RB_DL, AssertFatal(0,"Format 1C: Unknown N_RB_DL %d\n",frame_parms->N_RB_DL); break; } + + compute_llr_offset(frame_parms, + pdcch_vars, + pdsch_vars, + pdlsch0_harq, + pdlsch0_harq->nb_rb, + subframe); + } void compute_precoding_info_2cw(uint8_t tpmi, uint8_t tbswap, uint16_t pmi_alloc, LTE_DL_FRAME_PARMS *frame_parms, LTE_DL_UE_HARQ_t *dlsch0_harq, LTE_DL_UE_HARQ_t *dlsch1_harq) @@ -5639,6 +5731,8 @@ void compute_precoding_info_format2A(uint8_t tpmi, void prepare_dl_decoding_format2_2A(DCI_format_t dci_format, DCI_INFO_EXTRACTED_t *pdci_info_extarcted, LTE_DL_FRAME_PARMS *frame_parms, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, uint16_t rnti, uint8_t subframe, LTE_DL_UE_HARQ_t *dlsch0_harq, @@ -5890,9 +5984,16 @@ void prepare_dl_decoding_format2_2A(DCI_format_t dci_format, dlsch1_harq->Qm = (mcs2-28)<<1; } -//#ifdef DEBUG_HARQ + + compute_llr_offset(frame_parms, + pdcch_vars, + pdsch_vars, + dlsch0_harq, + dlsch0_harq->nb_rb, + subframe); +#ifdef DEBUG_HARQ printf("[DCI UE]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); -//#endif +#endif #ifdef DEBUG_HARQ if (dlsch0 != NULL && dlsch1 != NULL) @@ -5909,6 +6010,8 @@ int generate_ue_dlsch_params_from_dci(int frame, void *dci_pdu, uint16_t rnti, DCI_format_t dci_format, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, LTE_UE_DLSCH_t **dlsch, LTE_DL_FRAME_PARMS *frame_parms, PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, @@ -5998,6 +6101,8 @@ int generate_ue_dlsch_params_from_dci(int frame, frame_parms->N_RB_DL, &dci_info_extarcted, frame_parms, + pdcch_vars, + pdsch_vars, subframe, rnti, tc_rnti, @@ -6048,6 +6153,8 @@ int generate_ue_dlsch_params_from_dci(int frame, prepare_dl_decoding_format1C(frame_parms->N_RB_DL, &dci_info_extarcted, frame_parms, + pdcch_vars, + pdsch_vars, rnti, si_rnti, ra_rnti, @@ -6099,6 +6206,8 @@ int generate_ue_dlsch_params_from_dci(int frame, frame_parms->N_RB_DL, &dci_info_extarcted, frame_parms, + pdcch_vars, + pdsch_vars, subframe, rnti, tc_rnti, @@ -6153,6 +6262,8 @@ int generate_ue_dlsch_params_from_dci(int frame, prepare_dl_decoding_format2_2A(format2, &dci_info_extarcted, frame_parms, + pdcch_vars, + pdsch_vars, rnti, subframe, dlsch0_harq, @@ -6207,6 +6318,8 @@ int generate_ue_dlsch_params_from_dci(int frame, prepare_dl_decoding_format2_2A(format2A, &dci_info_extarcted, frame_parms, + pdcch_vars, + pdsch_vars, rnti, subframe, dlsch0_harq, diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c index 6761f6e335..f2a7438984 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c @@ -91,6 +91,7 @@ extern void print_shorts(char *s,int16_t *x); int rx_pdsch(PHY_VARS_UE *ue, + UE_rxtx_proc_t *proc, PDSCH_t type, unsigned char eNB_id, unsigned char eNB_id_i, //if this == ue->n_connected_eNB, we assume MU interference @@ -747,18 +748,35 @@ int rx_pdsch(PHY_VARS_UE *ue, } //printf("LLR dlsch0_harq->Qm %d rx_type %d cw0 %d cw1 %d symbol %d \n",dlsch0_harq->Qm,rx_type,codeword_TB0,codeword_TB1,symbol); + // compute LLRs + // -> // compute @pointer where llrs should filled for this ofdm-symbol + int8_t *pllr_symbol_cw0; + int8_t *pllr_symbol_cw1; + uint32_t llr_offset_symbol; + llr_offset_symbol = pdsch_vars[eNB_id]->llr_offset[symbol]; + pllr_symbol_cw0 = (int8_t*)pdsch_vars[eNB_id]->llr[0]; + pllr_symbol_cw1 = (int8_t*)pdsch_vars[eNB_id]->llr[1]; + pllr_symbol_cw0 += llr_offset_symbol; + pllr_symbol_cw1 += llr_offset_symbol; + + /*LOG_I(PHY,"compute LLRs [AbsSubframe %d.%d-%d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %x @LLR Buff(symb) %x\n", + proc->frame_rx, proc->subframe_rx,symbol, + nb_rb,dlsch0_harq->Qm, + pdsch_vars[eNB_id]->llr_length[symbol], + pdsch_vars[eNB_id]->llr_offset[symbol], + (int16_t*)pdsch_vars[eNB_id]->llr[0], + pllr_symbol);*/ switch (dlsch0_harq->Qm) { case 2 : if ((rx_type==rx_standard) || (codeword_TB0 == -1) || (codeword_TB1 == -1)) { dlsch_qpsk_llr(frame_parms, pdsch_vars[eNB_id]->rxdataF_comp0, - pdsch_vars[eNB_id]->llr[0], + (int16_t*)pllr_symbol_cw0, symbol, first_symbol_flag, nb_rb, adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol), - pdsch_vars[eNB_id]->llr128, beamforming_mode); } else if (rx_type >= rx_IC_single_stream) { @@ -918,12 +936,12 @@ int rx_pdsch(PHY_VARS_UE *ue, if ((rx_type==rx_standard) || (codeword_TB0 == -1) || (codeword_TB1 == -1)) { dlsch_64qam_llr(frame_parms, pdsch_vars[eNB_id]->rxdataF_comp0, - pdsch_vars[eNB_id]->llr[0], + (int16_t*)pllr_symbol_cw0, pdsch_vars[eNB_id]->dl_ch_mag0, pdsch_vars[eNB_id]->dl_ch_magb0, symbol,first_symbol_flag,nb_rb, adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol), - pdsch_vars[eNB_id]->llr128, + pdsch_vars[eNB_id]->llr_offset[symbol], beamforming_mode); } else if (rx_type >= rx_IC_single_stream) { @@ -980,10 +998,10 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->dl_ch_mag0, dl_ch_mag_ptr,//i pdsch_vars[eNB_id]->dl_ch_rho2_ext, - pdsch_vars[eNB_id]->llr[0], + (int16_t*)pllr_symbol_cw0, symbol,first_symbol_flag,nb_rb, adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol), - pdsch_vars[eNB_id]->llr128); + pdsch_vars[eNB_id]->llr_offset[symbol]); if (rx_type==rx_IC_dual_stream) { dlsch_64qam_64qam_llr(frame_parms, rxdataF_comp_ptr, @@ -991,10 +1009,10 @@ int rx_pdsch(PHY_VARS_UE *ue, dl_ch_mag_ptr, pdsch_vars[eNB_id]->dl_ch_mag0,//i pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round], - pdsch_vars[eNB_id]->llr[1], + (int16_t*)pllr_symbol_cw1, symbol,first_symbol_flag,nb_rb, adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,subframe,symbol), - pdsch_vars[eNB_id]->llr128_2ndstream); + pdsch_vars[eNB_id]->llr_offset[symbol]); } } } @@ -1010,10 +1028,9 @@ int rx_pdsch(PHY_VARS_UE *ue, if (rx_type==rx_standard) { dlsch_qpsk_llr(frame_parms, pdsch_vars[eNB_id]->rxdataF_comp0, - pdsch_vars[eNB_id]->llr[0], + (int16_t*)pllr_symbol_cw0, symbol,first_symbol_flag,nb_rb, adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,subframe,symbol), - pdsch_vars[eNB_id]->llr128, beamforming_mode); } break; @@ -1033,12 +1050,12 @@ int rx_pdsch(PHY_VARS_UE *ue, if (rx_type==rx_standard) { dlsch_64qam_llr(frame_parms, pdsch_vars[eNB_id]->rxdataF_comp0, - pdsch_vars[eNB_id]->llr[0], + (int16_t*)pllr_symbol_cw0, pdsch_vars[eNB_id]->dl_ch_mag0, pdsch_vars[eNB_id]->dl_ch_magb0, symbol,first_symbol_flag,nb_rb, adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,subframe,symbol), - pdsch_vars[eNB_id]->llr128, + pdsch_vars[eNB_id]->llr_offset[symbol], beamforming_mode); } break; @@ -1096,6 +1113,9 @@ int rx_pdsch(PHY_VARS_UE *ue, 2 * /* ulsch[UE_id]->harq_processes[harq_pid]->nb_rb */ frame_parms->N_RB_UL *12*frame_parms->symbols_per_tti*2)); #endif + if(symbol == (ue->frame_parms.symbols_per_tti>>1)) //(first_symbol_flag) + proc->first_symbol_available = 1; + return(0); } @@ -4604,7 +4624,7 @@ unsigned short dlsch_extract_rbs_dual(int **rxdataF, unsigned char subframe, uint32_t high_speed_flag, LTE_DL_FRAME_PARMS *frame_parms, - MIMO_mode_t mimo_mode) { + MIMO_mode_t mimo_mode) { int prb,nb_rb=0; int prb_off,prb_off2; diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c index e2de78f9ca..9e102a1c65 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_llr_computation.c @@ -636,7 +636,6 @@ int dlsch_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms, uint8_t first_symbol_flag, uint16_t nb_rb, uint16_t pbch_pss_sss_adjust, - int16_t **llr32p, uint8_t beamforming_mode) { @@ -645,12 +644,14 @@ int dlsch_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms, int i,len; uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol; + /* if (first_symbol_flag==1) { llr32 = (uint32_t*)dlsch_llr; } else { llr32 = (uint32_t*)(*llr32p); - } + }*/ + llr32 = (uint32_t*)dlsch_llr; if (!llr32) { msg("dlsch_qpsk_llr: llr is null, symbol %d, llr32=%p\n",symbol, llr32); return(-1); @@ -672,6 +673,13 @@ int dlsch_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms, //printf("dlsch_qpsk_llr: symbol %d,nb_rb %d, len %d,pbch_pss_sss_adjust %d\n",symbol,nb_rb,len,pbch_pss_sss_adjust); + /*LOG_I(PHY,"dlsch_qpsk_llr: [symb %d / FirstSym %d / Length %d]: @LLR Buff %x, @LLR Buff(symb) %x \n", + symbol, + first_symbol_flag, + len, + dlsch_llr, + llr32);*/ + //printf("ll32p=%p , dlsch_llr=%p, symbol=%d, flag=%d \n", llr32, dlsch_llr, symbol, first_symbol_flag); for (i=0; i=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; @@ -1085,6 +1101,15 @@ void dlsch_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms, len = (nb_rb*12) - pbch_pss_sss_adjust; } +// printf("dlsch_64qam_llr: symbol %d,nb_rb %d, len %d,pbch_pss_sss_adjust %d\n",symbol,nb_rb,len,pbch_pss_sss_adjust); + +/* LOG_I(PHY,"dlsch_64qam_llr [symb %d / FirstSym %d / Length %d]: @LLR Buff %x \n", + symbol, + first_symbol_flag, + len, + dlsch_llr, + pllr_symbol);*/ + llr2 = llr; llr += (len*6); @@ -1179,7 +1204,6 @@ void dlsch_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms, } - *llr_save = llr; #if defined(__x86_64__) || defined(__i386__) _mm_empty(); _m_empty(); @@ -8794,7 +8818,8 @@ int dlsch_64qam_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms, uint8_t first_symbol_flag, uint16_t nb_rb, uint16_t pbch_pss_sss_adjust, - int16_t **llr16p) + //int16_t **llr16p, + uint32_t llr_offset) { int16_t *rxF = (int16_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; @@ -8803,16 +8828,18 @@ int dlsch_64qam_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms, int16_t *ch_mag_i = (int16_t*)&dl_ch_mag_i[0][(symbol*frame_parms->N_RB_DL*12)]; int16_t *rho = (int16_t*)&rho_i[0][(symbol*frame_parms->N_RB_DL*12)]; int16_t *llr16; + int8_t *pllr_symbol; // pointer where llrs should filled for this ofdm symbol int len; uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol; //first symbol has different structure due to more pilots - if (first_symbol_flag == 1) { + /*if (first_symbol_flag == 1) { llr16 = (int16_t*)dlsch_llr; } else { llr16 = (int16_t*)(*llr16p); - } + }*/ + llr16 = (int16_t*)dlsch_llr; if (!llr16) { msg("dlsch_64qam_64qam_llr: llr is null, symbol %d\n",symbol); return(-1); @@ -8831,6 +8858,18 @@ int dlsch_64qam_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms, len = (nb_rb*12) - pbch_pss_sss_adjust; } + pllr_symbol = (int8_t*)dlsch_llr; + pllr_symbol += llr_offset; + //printf("dlsch_64qam_64qam_llr: symbol %d,nb_rb %d, len %d,pbch_pss_sss_adjust %d\n",symbol,nb_rb,len,pbch_pss_sss_adjust); + /*LOG_I(PHY,"dlsch_64qam_64qam_llr [symb %d / FirstSym %d / Length %d / LLR Offset %d]: @LLR Buff %x, @LLR Buff(symb) %x, , @Compute LLR Buff(symb) %x \n", + symbol, + first_symbol_flag, + len, + llr_offset, + (int16_t*)dlsch_llr, + llr16, + pllr_symbol);*/ + #ifdef __AVX2__ // Round length up to multiple of 16 words @@ -8864,6 +8903,7 @@ int dlsch_64qam_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms, (int32_t *) rho_256i, len); #endif + free16(rxF_256i, sizeof(rxF_256i)); free16(rxF_i_256i, sizeof(rxF_i_256i)); free16(ch_mag_256i, sizeof(ch_mag_256i)); @@ -8881,6 +8921,7 @@ int dlsch_64qam_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms, #endif llr16 += (6*len); - *llr16p = (short *)llr16; + //*llr16p = (short *)llr16; + return(0); } diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index 2100f07805..c4df9f79be 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -802,7 +802,8 @@ int dlsch_64qam_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms, unsigned char first_symbol_flag, unsigned short nb_rb, uint16_t pbch_pss_sss_adjust, - short **llr16p); + //short **llr16p, + uint32_t llr_offset); /** \brief This function generates log-likelihood ratios (decoder input) for single-stream QPSK received waveforms. @@ -823,7 +824,7 @@ int32_t dlsch_qpsk_llr(LTE_DL_FRAME_PARMS *frame_parms, uint8_t first_symbol_flag, uint16_t nb_rb, uint16_t pbch_pss_sss_adj, - int16_t **llr128p, + //int16_t **llr128p, uint8_t beamforming_mode); /** @@ -912,7 +913,8 @@ void dlsch_64qam_llr(LTE_DL_FRAME_PARMS *frame_parms, uint8_t first_symbol_flag, uint16_t nb_rb, uint16_t pbch_pss_sss_adjust, - int16_t **llr_save, + //int16_t **llr_save, + uint32_t llr_offset, uint8_t beamforming_mode); @@ -1297,6 +1299,7 @@ uint32_t dlsch_decoding_emul(PHY_VARS_UE *phy_vars_ue, @param i_mod Modulation order of the interfering stream */ int32_t rx_pdsch(PHY_VARS_UE *phy_vars_ue, + UE_rxtx_proc_t *proc, PDSCH_t type, uint8_t eNB_id, uint8_t eNB_id_i, @@ -1646,6 +1649,8 @@ int generate_ue_dlsch_params_from_dci(int frame, void *dci_pdu, rnti_t rnti, DCI_format_t dci_format, + LTE_UE_PDCCH *pdcch_vars, + LTE_UE_PDSCH *pdsch_vars, LTE_UE_DLSCH_t **dlsch, LTE_DL_FRAME_PARMS *frame_parms, PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, diff --git a/openair1/PHY/MODULATION/defs.h b/openair1/PHY/MODULATION/defs.h index da599114a9..d68c157445 100644 --- a/openair1/PHY/MODULATION/defs.h +++ b/openair1/PHY/MODULATION/defs.h @@ -78,6 +78,17 @@ int slot_fep_ul(LTE_DL_FRAME_PARMS *frame_parms, unsigned char eNb_id, int no_prefix); +int front_end_fft(PHY_VARS_UE *ue, + unsigned char l, + unsigned char Ns, + int sample_offset, + int no_prefix); + +int front_end_chanEst(PHY_VARS_UE *ue, + unsigned char l, + unsigned char Ns, + int reset_freq_est); + void normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,LTE_DL_FRAME_PARMS *frame_parms); void do_OFDM_mod(int32_t **txdataF, int32_t **txdata, uint32_t frame,uint16_t next_slot, LTE_DL_FRAME_PARMS *frame_parms); diff --git a/openair1/PHY/MODULATION/slot_fep.c b/openair1/PHY/MODULATION/slot_fep.c index 4fc1734841..6a9bbb354a 100644 --- a/openair1/PHY/MODULATION/slot_fep.c +++ b/openair1/PHY/MODULATION/slot_fep.c @@ -240,3 +240,215 @@ int slot_fep(PHY_VARS_UE *ue, #endif return(0); } + +int front_end_fft(PHY_VARS_UE *ue, + unsigned char l, + unsigned char Ns, + int sample_offset, + int no_prefix) +{ + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + LTE_UE_COMMON *common_vars = &ue->common_vars; + unsigned char aa; + unsigned char symbol = l+((7-frame_parms->Ncp)*(Ns&1)); ///symbol within sub-frame + unsigned int nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples); + unsigned int nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples0); + unsigned int subframe_offset;//,subframe_offset_F; + unsigned int slot_offset; + unsigned int frame_length_samples = frame_parms->samples_per_tti * 10; + unsigned int rx_offset; + + /*LTE_UE_DLSCH_t **dlsch_ue = phy_vars_ue->dlsch_ue[eNB_id]; + unsigned char harq_pid = dlsch_ue[0]->current_harq_pid; + LTE_DL_UE_HARQ_t *dlsch0_harq = dlsch_ue[0]->harq_processes[harq_pid]; + int uespec_pilot[9][1200];*/ + + void (*dft)(int16_t *,int16_t *, int); + int tmp_dft_in[2048] __attribute__ ((aligned (32))); // This is for misalignment issues for 6 and 15 PRBs + + switch (frame_parms->ofdm_symbol_size) { + case 128: + dft = dft128; + break; + + case 256: + dft = dft256; + break; + + case 512: + dft = dft512; + break; + + case 1024: + dft = dft1024; + break; + + case 1536: + dft = dft1536; + break; + + case 2048: + dft = dft2048; + break; + + default: + dft = dft512; + break; + } + + if (no_prefix) { + subframe_offset = frame_parms->ofdm_symbol_size * frame_parms->symbols_per_tti * (Ns>>1); + slot_offset = frame_parms->ofdm_symbol_size * (frame_parms->symbols_per_tti>>1) * (Ns%2); + } else { + subframe_offset = frame_parms->samples_per_tti * (Ns>>1); + slot_offset = (frame_parms->samples_per_tti>>1) * (Ns%2); + } + + // subframe_offset_F = frame_parms->ofdm_symbol_size * frame_parms->symbols_per_tti * (Ns>>1); + + + if (l<0 || l>=7-frame_parms->Ncp) { + printf("slot_fep: l must be between 0 and %d\n",7-frame_parms->Ncp); + return(-1); + } + + if (Ns<0 || Ns>=20) { + printf("slot_fep: Ns must be between 0 and 19\n"); + return(-1); + } + + + + for (aa=0; aanb_antennas_rx; aa++) { + memset(&common_vars->common_vars_rx_data_per_thread[(Ns>>1)&0x1].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],0,frame_parms->ofdm_symbol_size*sizeof(int)); + + rx_offset = sample_offset + slot_offset + nb_prefix_samples0 + subframe_offset - SOFFSET; + // Align with 256 bit + // rx_offset = rx_offset&0xfffffff8; + + if (l==0) { + + if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size)) + memcpy((short *)&common_vars->rxdata[aa][frame_length_samples], + (short *)&common_vars->rxdata[aa][0], + frame_parms->ofdm_symbol_size*sizeof(int)); + + if ((rx_offset&7)!=0) { // if input to dft is not 256-bit aligned, issue for size 6,15 and 25 PRBs + memcpy((void *)tmp_dft_in, + (void *)&common_vars->rxdata[aa][rx_offset % frame_length_samples], + frame_parms->ofdm_symbol_size*sizeof(int)); + dft((int16_t *)tmp_dft_in, + (int16_t *)&common_vars->common_vars_rx_data_per_thread[(Ns>>1)&0x1].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); + } else { // use dft input from RX buffer directly + start_meas(&ue->rx_dft_stats); + + dft((int16_t *)&common_vars->rxdata[aa][(rx_offset) % frame_length_samples], + (int16_t *)&common_vars->common_vars_rx_data_per_thread[(Ns>>1)&0x1].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); + stop_meas(&ue->rx_dft_stats); + + } + } else { + rx_offset += (frame_parms->ofdm_symbol_size+nb_prefix_samples)*l;// + + // (frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1); + +#ifdef DEBUG_FEP + // if (ue->frame <100) + LOG_I(PHY,"slot_fep: frame %d: slot %d, symbol %d, nb_prefix_samples %d, nb_prefix_samples0 %d, slot_offset %d, subframe_offset %d, sample_offset %d,rx_offset %d, frame_length_samples %d\n", ue->proc.proc_rxtx[(Ns>>1)&1].frame_rx,Ns, symbol, + nb_prefix_samples,nb_prefix_samples0,slot_offset,subframe_offset,sample_offset,rx_offset,frame_length_samples); +#endif + + if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size)) + memcpy((void *)&common_vars->rxdata[aa][frame_length_samples], + (void *)&common_vars->rxdata[aa][0], + frame_parms->ofdm_symbol_size*sizeof(int)); + + start_meas(&ue->rx_dft_stats); + + if ((rx_offset&7)!=0) { // if input to dft is not 128-bit aligned, issue for size 6 and 15 PRBs + memcpy((void *)tmp_dft_in, + (void *)&common_vars->rxdata[aa][(rx_offset) % frame_length_samples], + frame_parms->ofdm_symbol_size*sizeof(int)); + dft((int16_t *)tmp_dft_in, + (int16_t *)&common_vars->common_vars_rx_data_per_thread[(Ns>>1)&0x1].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); + } else { // use dft input from RX buffer directly + + dft((int16_t *)&common_vars->rxdata[aa][(rx_offset) % frame_length_samples], + (int16_t *)&common_vars->common_vars_rx_data_per_thread[(Ns>>1)&0x1].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); + } + + stop_meas(&ue->rx_dft_stats); + + + } + + #ifdef DEBUG_FEP + // if (ue->frame <100) + printf("slot_fep: frame %d: symbol %d rx_offset %d\n", ue->proc.proc_rxtx[(Ns>>1)&1].frame_rx, symbol,rx_offset); + #endif + } + return(0); +} + +int front_end_chanEst(PHY_VARS_UE *ue, + unsigned char l, + unsigned char Ns, + int reset_freq_est) +{ + LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + LTE_UE_COMMON *common_vars = &ue->common_vars; + uint8_t eNB_id = 0;//ue_common_vars->eNb_id; + unsigned char aa; + unsigned char symbol = l+((7-frame_parms->Ncp)*(Ns&1)); ///symbol within sub-frame + int i; + + /*LTE_UE_DLSCH_t **dlsch_ue = phy_vars_ue->dlsch_ue[eNB_id]; + unsigned char harq_pid = dlsch_ue[0]->current_harq_pid; + LTE_DL_UE_HARQ_t *dlsch0_harq = dlsch_ue[0]->harq_processes[harq_pid]; + int uespec_pilot[9][1200];*/ + + if (ue->perfect_ce == 0) { + if ((l==0) || (l==(4-frame_parms->Ncp))) { + for (aa=0; aanb_antenna_ports_eNB; aa++) { + +#ifdef DEBUG_FEP + printf("Channel estimation eNB %d, aatx %d, slot %d, symbol %d\n",eNB_id,aa,Ns,l); +#endif + start_meas(&ue->dlsch_channel_estimation_stats); + lte_dl_channel_estimation(ue,eNB_id,0, + Ns, + aa, + l, + symbol); + stop_meas(&ue->dlsch_channel_estimation_stats); + + for (i=0; imeasurements.n_adj_cells; i++) { + lte_dl_channel_estimation(ue,eNB_id,i+1, + Ns, + aa, + l, + symbol); + } + } + + + // do frequency offset estimation here! + // use channel estimates from current symbol (=ch_t) and last symbol (ch_{t-1}) +#ifdef DEBUG_FEP + printf("Frequency offset estimation\n"); +#endif + + if (l==(4-frame_parms->Ncp)) { + start_meas(&ue->dlsch_freq_offset_estimation_stats); + lte_est_freq_offset(common_vars->common_vars_rx_data_per_thread[(Ns>>1)&0x1].dl_ch_estimates[0], + frame_parms, + l, + &common_vars->freq_offset, + reset_freq_est); + stop_meas(&ue->dlsch_freq_offset_estimation_stats); + + } + } + + } + return(0); +} diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 2720510006..55a14923d3 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -392,6 +392,25 @@ typedef struct { pthread_mutex_t mutex_rxtx; /// scheduling parameters for RXn-TXnp4 thread struct sched_param sched_param_rxtx; + + /// internal This variable is protected by ref mutex_fep_slot1. + int instance_cnt_fep_slot1; + /// pthread descriptor fep_slot1 thread + pthread_t pthread_fep_slot1; + /// pthread attributes for fep_slot1 processing thread + pthread_attr_t attr_fep_slot1; + /// condition variable for UE fep_slot1 thread; + pthread_cond_t cond_fep_slot1; + /// mutex for UE synch thread + pthread_mutex_t mutex_fep_slot1; + // + uint8_t chan_est_pilot0_slot1_available; + uint8_t llr_slot1_available; + uint8_t dci_slot0_available; + uint8_t first_symbol_available; + /// scheduling parameters for fep_slot1 thread + struct sched_param sched_param_fep_slot1; + int sub_frame_start; int sub_frame_step; unsigned long long gotIQs; @@ -931,6 +950,14 @@ typedef struct { } PHY_VARS_UE; +/* this structure is used to pass both UE phy vars and + * proc to the function UE_thread_rxn_txnp4 + */ +struct rx_tx_thread_data { + PHY_VARS_UE *UE; + UE_rxtx_proc_t *proc; +}; + void exit_fun(const char* s); static inline int wait_on_condition(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) { diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h index 5707aedd27..f40e8ae3e4 100644 --- a/openair1/PHY/impl_defs_lte.h +++ b/openair1/PHY/impl_defs_lte.h @@ -925,6 +925,10 @@ typedef struct { //uint32_t *rb_alloc; //uint8_t Qm[2]; //MIMO_mode_t mimo_mode; + // llr offset per ofdm symbol + uint32_t llr_offset[14]; + // llr length per ofdm symbol + uint32_t llr_length[14]; } LTE_UE_PDSCH; typedef struct { diff --git a/openair1/SCHED/defs.h b/openair1/SCHED/defs.h index 10d9d69c52..bb71e0deb9 100644 --- a/openair1/SCHED/defs.h +++ b/openair1/SCHED/defs.h @@ -140,6 +140,8 @@ void phy_procedures_UE_TX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t */ int phy_procedures_UE_RX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode,relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn); +void *UE_thread_fep_slot1(void *arg); + /*! \brief Scheduling for UE TX procedures in TDD S-subframes. @param phy_vars_ue Pointer to UE variables on which to act @param eNB_id Local id of eNB on which to act diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index 389eb5a694..ef1db033e4 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -3166,6 +3166,8 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint (void *)&dci_alloc_rx[i].dci_pdu, ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->crnti, dci_alloc_rx[i].format, + ue->pdcch_vars[subframe_rx & 0x1][eNB_id], + ue->pdsch_vars[subframe_rx & 0x1][eNB_id], ue->dlsch[subframe_rx&0x1][eNB_id], &ue->frame_parms, ue->pdsch_config_dedicated, @@ -3222,6 +3224,8 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint (void *)&dci_alloc_rx[i].dci_pdu, SI_RNTI, dci_alloc_rx[i].format, + ue->pdcch_vars[subframe_rx & 0x1][eNB_id], + ue->pdsch_vars_SI[eNB_id], &ue->dlsch_SI[eNB_id], &ue->frame_parms, ue->pdsch_config_dedicated, @@ -3253,6 +3257,8 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint (void *)&dci_alloc_rx[i].dci_pdu, P_RNTI, dci_alloc_rx[i].format, + ue->pdcch_vars[subframe_rx & 0x1][eNB_id], + ue->pdsch_vars_p[eNB_id], &ue->dlsch_SI[eNB_id], &ue->frame_parms, ue->pdsch_config_dedicated, @@ -3289,6 +3295,8 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint (DCI1A_5MHz_TDD_1_6_t *)&dci_alloc_rx[i].dci_pdu, ue->prach_resources[eNB_id]->ra_RNTI, format1A, + ue->pdcch_vars[subframe_rx & 0x1][eNB_id], + ue->pdsch_vars_ra[eNB_id], &ue->dlsch_ra[eNB_id], &ue->frame_parms, ue->pdsch_config_dedicated, @@ -3647,6 +3655,7 @@ void ue_pdsch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, int eNB_id, PDSC #endif // process DLSCH received in first slot rx_pdsch(ue, + proc, pdsch, eNB_id, eNB_id_i, @@ -4136,19 +4145,72 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, } -int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode, - relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn) { - - int l,l2; - int pilot1; - int pmch_flag=0; - int frame_rx = proc->frame_rx; - int subframe_rx = proc->subframe_rx; - +#if 0 +/*! + * \brief This is the UE synchronize thread. + * It performs band scanning and synchonization. + * \param arg is a pointer to a \ref PHY_VARS_UE structure. + * \returns a pointer to an int. The storage is not on the heap and must not be freed. + */ +#define FIFO_PRIORITY 40 +void *UE_thread_fep_slot1(void *arg) { + + static __thread int UE_thread_rxtx_retval; + struct rx_tx_thread_data *rtd = arg; + UE_rxtx_proc_t *proc = rtd->proc; + PHY_VARS_UE *ue = rtd->UE; + + char threadname[256]; + proc->subframe_rx=proc->sub_frame_start; + sprintf(threadname,"UE_SLOT1_PROC_%d", proc->sub_frame_start); + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + if ( (proc->sub_frame_start+1)%2 == 0 ) + CPU_SET(0, &cpuset); + if ( (proc->sub_frame_start+1)%2 == 1 ) + CPU_SET(4, &cpuset); + init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset, + threadname); + + + uint8_t l; + uint8_t compute_llrs_slot1; + + proc->instance_cnt_fep_slot1=-1; + + while (!oai_exit) { + if (pthread_mutex_lock(&proc->mutex_fep_slot1) != 0) { + LOG_E( PHY, "[SCHED][UE] error locking mutex for UE FEP Slo1\n" ); + exit_fun("nothing to add"); + } + while (proc->instance_cnt_fep_slot1 < 0) { + // most of the time, the thread is waiting here + pthread_cond_wait( &proc->cond_fep_slot1, &proc->mutex_fep_slot1 ); + } + if (pthread_mutex_unlock(&proc->mutex_fep_slot1) != 0) { + LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE FEP Slo1\n" ); + exit_fun("nothing to add"); + } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); + // Start Thread Processing + LOG_I(PHY," [Th-Slave] ==> execute fep slot1 thread for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); +#if 1 + int frame_rx = proc->frame_rx; + int subframe_rx = proc->subframe_rx; + uint8_t pilot0; + uint8_t pilot1; + uint8_t slot1; + + slot1 = (subframe_rx<<1) + 1; + pilot0 = 0; + if (ue->frame_parms.Ncp == 0) { // normal prefix + pilot1 = 4; + } else { // extended prefix + pilot1 = 3; + } +<<<<<<< Updated upstream #if T_TRACER T(T_UE_PHY_DL_TICK, T_INT(ue->Mod_id), T_INT(frame_rx%1024), T_INT(subframe_rx)); @@ -4166,37 +4228,254 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin start_meas(&ue->phy_proc_rx[subframe_rx&0x1]); start_meas(&ue->generic_stat); #endif +======= + // do first symbol of next downlink subframe for channel estimation + int next_subframe_rx = (1+subframe_rx)%10; + uint8_t next_subframe_slot0 = next_subframe_rx<<1; + // 1- perform FFT for pilot ofdm symbols first (ofdmSym0 next subframe ofdmSym11) + if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) + { + //LOG_I(PHY,"[Th-Slave] FFT symbol %d slot %d \n", pilot0, next_subframe_slot0); + front_end_fft(ue, + pilot0, + next_subframe_slot0, + 0, + 0); + } + //LOG_I(PHY,"[Th-Slave]FFT symbol %d slot %d \n",pilot1,slot1); + front_end_fft(ue, + pilot1, + slot1, + 0, + 0); + // 2- perform FFT for other ofdm symbols other than pilots + for (l=1; lframe_parms.symbols_per_tti>>1; l++) + { + if( (l != pilot0) && (l != pilot1)) + { + //LOG_I(PHY,"[Th-Slave]FFT symbol %d slot %d\n",l,slot1); + start_meas(&ue->ofdm_demod_stats); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); + front_end_fft(ue, + l, + slot1, + 0, + 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); + stop_meas(&ue->ofdm_demod_stats); + } + } // for l=1..l2 - pmch_flag = is_pmch_subframe(frame_rx,subframe_rx,&ue->frame_parms) ? 1 : 0; + // 3- perform Channel Estimation for slot1 + for (l=1; lframe_parms.symbols_per_tti>>1; l++) + { + uint32_t wait=0; + if(l==pilot1) + { + LOG_I(PHY,"[Th-Slave] ==> wait pilot0 slot1 channel estimation is ready \n"); + while(proc->chan_est_pilot0_slot1_available==0) + { + //wait until channel estimation for pilot0/slot1 is available + usleep(1); + wait++; + } + } + front_end_chanEst(ue, + l, + slot1, + 0); + //LOG_I(PHY,"[Th-Slave]ChanEst symbol %d slot %d wait%d\n",l,slot1,wait); + ue_measurement_procedures(l-1,ue,proc,0,1+(subframe_rx<<1),0,ue->mode); + } + //LOG_I(PHY,"[Th-Slave]ChanEst symbol %d slot %d\n",0,next_subframe_slot0); + front_end_chanEst(ue, + 0, + next_subframe_slot0, + 0); - // deactivate reception until we scan pdcch - if (ue->dlsch[subframe_rx&0x1][eNB_id][0]) - ue->dlsch[subframe_rx&0x1][eNB_id][0]->active = 0; - if (ue->dlsch[subframe_rx&0x1][eNB_id][1]) - ue->dlsch[subframe_rx&0x1][eNB_id][1]->active = 0; + if ( (subframe_rx == 0) && (ue->decode_MIB == 1)) + { + ue_pbch_procedures(0,ue,proc,0); + } +#endif + LOG_I(PHY," [Th-Slave] ==> FFT/CHanEst Done for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); + + LOG_I(PHY," [Th-Slave] ==> Start LLR Comuptation slot1 for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); + +#if 1 + // wait until dci info are available + uint32_t wait=0; + while(proc->dci_slot0_available==0) // (proc->dci_slot0_available==0) + { + //wait until channel estimation for pilot0/slot1 is available + usleep(1); + wait++; + } + // check if a dl grant was received on a DCI + compute_llrs_slot1 = 0; + if(ue->dlsch[subframe_rx&0x1][0][0]->active || + ((ue->dlsch_SI[0]) && (ue->dlsch_SI[0]->active == 1)) || + ((ue->dlsch_p[0]) && (ue->dlsch_p[0]->active == 1)) || + ((ue->dlsch_ra[0]) && (ue->dlsch_ra[0]->active == 1)) + ) + { + compute_llrs_slot1 = 1; + } + else + { + proc->llr_slot1_available = 1; + } + LOG_I(PHY,"[Th-Slave] compute llrs slot-1 %d AbsSubframe %d.%d \n",compute_llrs_slot1,frame_rx%1024,subframe_rx); + + if(compute_llrs_slot1) + { + // wait until computation of first ofdm symbol is done + uint32_t wait=0; + while(proc->first_symbol_available==0) + { + //wait until channel estimation for pilot0/slot1 is available + usleep(1); + wait++; + } + + // start slave thread for Pdsch Procedure (slot1) + // do procedures for C-RNTI + //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure (slot1) wait %d \n",frame_rx%1024,subframe_rx,wait); + //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure PDSCH Active %d \n",frame_rx%1024,subframe_rx, ue->dlsch[subframe_rx&0x1][0][0]->active); + if (ue->dlsch[subframe_rx&0x1][0][0]->active == 1) { + //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure PDSCH \n",frame_rx%1024,subframe_rx); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); + start_meas(&ue->pdsch_procedures_stat); + ue_pdsch_procedures(ue, + proc, + 0, + PDSCH, + ue->dlsch[subframe_rx&0x1][0][0], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + 0); + stop_meas(&ue->pdsch_procedures_stat); + } + + // do procedures for SI-RNTI + if ((ue->dlsch_SI[0]) && (ue->dlsch_SI[0]->active == 1)) { + //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure SI-PDSCH \n",frame_rx%1024,subframe_rx); + ue_pdsch_procedures(ue, + proc, + 0, + SI_PDSCH, + ue->dlsch_SI[0], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + 0); + } + + // do procedures for P-RNTI + if ((ue->dlsch_p[0]) && (ue->dlsch_p[0]->active == 1)) { + //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure P-PDSCH \n",frame_rx%1024,subframe_rx); + ue_pdsch_procedures(ue, + proc, + 0, + P_PDSCH, + ue->dlsch_p[0], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + 0); + } + // do procedures for RA-RNTI + if ((ue->dlsch_ra[0]) && (ue->dlsch_ra[0]->active == 1)) { + //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure RA-PDSCH \n",frame_rx%1024,subframe_rx); + ue_pdsch_procedures(ue, + proc, + 0, + RA_PDSCH, + ue->dlsch_ra[0], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + 0); + } + + //LOG_I(PHY,"Set available llrs slot1 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); + proc->llr_slot1_available = 1; + } +#endif + + LOG_I(PHY," [Th-Slave] ==> End slot1 Thread for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); + + // End Thread Processing +>>>>>>> Stashed changes + + if (pthread_mutex_lock(&proc->mutex_fep_slot1) != 0) { + LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); + exit_fun("noting to add"); + } + proc->instance_cnt_fep_slot1--; + if (pthread_mutex_unlock(&proc->mutex_fep_slot1) != 0) { + LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE FEP Slo1\n" ); + exit_fun("noting to add"); + } + } - if (ue->dlsch_SI[eNB_id]) - ue->dlsch_SI[eNB_id]->active = 0; - if (ue->dlsch_p[eNB_id]) - ue->dlsch_p[eNB_id]->active = 0; - if (ue->dlsch_ra[eNB_id]) - ue->dlsch_ra[eNB_id]->active = 0; - -#ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[%s %d] Frame %d subframe %d: Doing phy_procedures_UE_RX\n", - (r_type == multicast_relay) ? "RN/UE" : "UE", - ue->Mod_id,frame_rx, subframe_rx); + // thread finished + free(arg); + return &UE_thread_rxtx_retval; + + +} #endif - if (ue->frame_parms.Ncp == 0) { // normal prefix - pilot1 = 4; - } else { // extended prefix - pilot1 = 3; - } - - +int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode, + relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn) { + + + int l,l2; + int pmch_flag=0; + int frame_rx = proc->frame_rx; + int subframe_rx = proc->subframe_rx; + uint8_t pilot0; + uint8_t pilot1; + uint8_t slot0; + uint8_t slot1; + uint8_t first_ofdm_sym; + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); + + #if T_TRACER + T(T_UE_PHY_DL_TICK, T_INT(ue->Mod_id), T_INT(frame_rx%1024), T_INT(subframe_rx)); + #endif + + + T(T_UE_PHY_INPUT_SIGNAL, T_INT(ue->Mod_id), T_INT(frame_rx%1024), T_INT(subframe_rx), T_INT(0), + T_BUFFER(&ue->common_vars.rxdata[0][subframe_rx*ue->frame_parms.samples_per_tti], + ue->frame_parms.samples_per_tti * 4)); + + // start timers + LOG_I(PHY," ****** start RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx); + start_meas(&ue->phy_proc_rx[subframe_rx&0x1]); + start_meas(&ue->generic_stat); + + pmch_flag = is_pmch_subframe(frame_rx,subframe_rx,&ue->frame_parms) ? 1 : 0; + + + // deactivate reception until we scan pdcch + if (ue->dlsch[subframe_rx&0x1][eNB_id][0]) + ue->dlsch[subframe_rx&0x1][eNB_id][0]->active = 0; + if (ue->dlsch[subframe_rx&0x1][eNB_id][1]) + ue->dlsch[subframe_rx&0x1][eNB_id][1]->active = 0; + + if (ue->dlsch_SI[eNB_id]) + ue->dlsch_SI[eNB_id]->active = 0; + if (ue->dlsch_p[eNB_id]) + ue->dlsch_p[eNB_id]->active = 0; + if (ue->dlsch_ra[eNB_id]) + ue->dlsch_ra[eNB_id]->active = 0; + if (subframe_select(&ue->frame_parms,subframe_rx) == SF_S) { // S-subframe, do first 5 symbols only l2 = 5; } else if (pmch_flag == 1) { // do first 2 symbols only @@ -4204,399 +4483,453 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin } else { // normal subframe, last symbol to be processed is the first of the second slot l2 = (ue->frame_parms.symbols_per_tti/2)-1; } - - int prev_subframe_rx = (subframe_rx - 1)<0? 9: (subframe_rx - 1); - if (subframe_select(&ue->frame_parms,prev_subframe_rx) != SF_DL) { - //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // RX processing of symbols l=0...l2 - //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - l=0; - } else { - //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // RX processing of symbols l=1...l2 (l=0 is done in last scheduling epoch) - //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - l=1; - } - - LOG_D(PHY," ------ slot 0 Processing: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); - LOG_D(PHY," ------ --> FFT/ChannelEst/PDCCH slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); - for (; l<=l2; l++) { - if (abstraction_flag == 0) { -#if UE_TIMING_TRACE - start_meas(&ue->ofdm_demod_stats); -#endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); - slot_fep(ue, - l, - (subframe_rx<<1), - 0, - 0, - 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); -#if UE_TIMING_TRACE - stop_meas(&ue->ofdm_demod_stats); -#endif - } - ue_measurement_procedures(l-1,ue,proc,eNB_id,(subframe_rx<<1),abstraction_flag,mode); - if ((l==pilot1) || - ((pmch_flag==1)&(l==l2))) { - LOG_D(PHY,"[UE %d] Frame %d: Calling pdcch procedures (eNB %d)\n",ue->Mod_id,frame_rx,eNB_id); - - if (ue_pdcch_procedures(eNB_id,ue,proc,abstraction_flag) == -1) { - LOG_E(PHY,"[UE %d] Frame %d, subframe %d: Error in pdcch procedures\n",ue->Mod_id,frame_rx,subframe_rx); - return(-1); - } - LOG_D(PHY,"num_pdcch_symbols %d\n",ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols); + int prev_subframe_rx = (subframe_rx - 1)<0? 9: (subframe_rx - 1); + if (subframe_select(&ue->frame_parms,prev_subframe_rx) != SF_DL) { + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // RX processing of symbols l=0...l2 + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + first_ofdm_sym = 0; + } else { + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // RX processing of symbols l=1...l2 (l=0 is done in last scheduling epoch) + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + first_ofdm_sym = 1; + } + slot0 = (subframe_rx<<1); + slot1 = (subframe_rx<<1) + 1; + pilot0 = 0; + if (ue->frame_parms.Ncp == 0) { // normal prefix + pilot1 = 4; + } else { // extended prefix + pilot1 = 3; } - - } // for l=1..l2 - ue_measurement_procedures(l-1,ue,proc,eNB_id,(subframe_rx<<1),abstraction_flag,mode); - - LOG_D(PHY," ------ end FFT/ChannelEst/PDCCH slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); - // If this is PMCH, call procedures and return - if (pmch_flag == 1) { - ue_pmch_procedures(ue,proc,eNB_id,abstraction_flag); - return 0; - } - - slot_fep(ue, - 0, - 1+(subframe_rx<<1), - 0, - 0, - 0); - // first slot has been processed (FFTs + Channel Estimation, PCFICH/PHICH/PDCCH) -#if UE_TIMING_TRACE - stop_meas(&ue->generic_stat); -#if DISABLE_LOG_X - printf("[SFN %d] Slot0: FFT + Channel Estimate + PCFICH/PHICH/PDCCH %5.2f \n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); -#else - LOG_D(PHY, "[SFN %d] Slot0: FFT + Channel Estimate + PCFICH/PHICH/PDCCH %5.2f \n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); -#endif + //LOG_I(PHY,"Set available channelEst to 0 AbsSubframe %d.%d \n",frame_rx,subframe_rx); + //LOG_I(PHY,"Set available llrs slot1 to 0 AbsSubframe %d.%d \n",frame_rx,subframe_rx); + //LOG_I(PHY,"Set available dci info slot0 to 0 AbsSubframe %d.%d \n",frame_rx,subframe_rx); + proc->chan_est_pilot0_slot1_available=0; + proc->llr_slot1_available=0; + proc->dci_slot0_available=0; + proc->first_symbol_available=0; + + + //LOG_I(PHY,"fep slot1 thread : instance_cnt %d \n", + // proc->instance_cnt_fep_slot1); + proc->instance_cnt_fep_slot1++; + if (proc->instance_cnt_fep_slot1 == 0) { + LOG_I(PHY,"unblock fep slot1 thread blocked on cond_fep_slot1 : instance_cnt_fep_slot1 %d \n", proc->instance_cnt_fep_slot1 ); + if (pthread_cond_signal(&proc->cond_fep_slot1) != 0) { + LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE FEP slot1 thread\n", ue->Mod_id); + exit_fun("nothing to add"); + } + } else { + LOG_E( PHY, "[SCHED][UE %d] UE RX thread busy (IC %d)!!\n", ue->Mod_id, proc->instance_cnt_fep_slot1); + if (proc->instance_cnt_fep_slot1 > 2) + exit_fun("instance_cnt_fep_slot1 > 2"); + } + AssertFatal(pthread_cond_signal(&proc->cond_fep_slot1) ==0 ,""); + AssertFatal(pthread_mutex_unlock(&proc->mutex_fep_slot1) ==0,""); + + /**** FFT Slot0 + Slot1 ****/ + // I- start main thread for FFT/ChanEst symbol: 0/1 --> 7 + + // 1- perform FFT for pilot ofdm symbols first (ofdmSym7 ofdmSym4 or (ofdmSym6 ofdmSym3)) + //LOG_I(PHY,"FFT symbol %d slot %d \n",pilot0,slot1); + front_end_fft(ue, + pilot0, + slot1, + 0, + 0); + //LOG_I(PHY,"FFT symbol %d slot %d \n",pilot1,slot0); + front_end_fft(ue, + pilot1, + slot0, + 0, + 0); + //LOG_I(PHY,"ChanEst symbol %d slot %d\n",pilot1,slot0); + front_end_chanEst(ue, + pilot1, + slot0, + 0); + //LOG_I(PHY,"ChanEst symbol %d slot %d\n",pilot0,slot1); + front_end_chanEst(ue, + pilot0, + slot1, + 0); + proc->chan_est_pilot0_slot1_available = 1; + //LOG_I(PHY,"Set available channelEst to 1 AbsSubframe %d.%d \n",frame_rx,subframe_rx); + // 2- perform FFT for other ofdm symbols other than pilots + for (l=first_ofdm_sym; l<=l2; l++) + { + if( (l != pilot0) && (l != pilot1)) + { + //LOG_I(PHY,"FFT symbol %d slot %d \n", l, slot0); + start_meas(&ue->ofdm_demod_stats); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); + front_end_fft(ue, + l, + slot0, + 0, + 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); + stop_meas(&ue->ofdm_demod_stats); + } + } // for l=1..l2 -#endif + // 3- perform Channel Estimation for slot0 + for (l=first_ofdm_sym; l<=l2; l++) + { + if( (l != pilot0) && (l != pilot1)) + { + //LOG_I(PHY,"ChanEst symbol %d slot %d\n",l,slot0); + front_end_chanEst(ue, + l, + slot0, + 0); + } + ue_measurement_procedures(l-1,ue,proc,eNB_id,(subframe_rx<<1),abstraction_flag,mode); + } - LOG_D(PHY," ------ --> PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); -#if UE_TIMING_TRACE - start_meas(&ue->generic_stat); -#endif - // do procedures for C-RNTI - if (ue->dlsch[subframe_rx&0x1][eNB_id][0]->active == 1) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); - ue_pdsch_procedures(ue, - proc, - eNB_id, - PDSCH, - ue->dlsch[subframe_rx&0x1][eNB_id][0], - NULL, - ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols, - ue->frame_parms.symbols_per_tti>>1, - abstraction_flag); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); - } + // PDCCH decoding + if (ue_pdcch_procedures(eNB_id,ue,proc,abstraction_flag) == -1) { + LOG_E(PHY,"[UE %d] Frame %d, subframe %d: Error in pdcch procedures\n",ue->Mod_id,frame_rx,subframe_rx); + return(-1); + } - LOG_D(PHY," ------ end PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); - // do procedures for SI-RNTI - if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_IN); - ue_pdsch_procedures(ue, - proc, - eNB_id, - SI_PDSCH, - ue->dlsch_SI[eNB_id], - NULL, - ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols, - ue->frame_parms.symbols_per_tti>>1, - abstraction_flag); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_OUT); - } + //LOG_I(PHY,"num_pdcch_symbols %d\n",ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols); + LOG_I(PHY,"Set available dci slot0 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); + proc->dci_slot0_available=1; - // do procedures for SI-RNTI - if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_IN); - ue_pdsch_procedures(ue, - proc, - eNB_id, - P_PDSCH, - ue->dlsch_p[eNB_id], - NULL, - ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols, - ue->frame_parms.symbols_per_tti>>1, - abstraction_flag); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_OUT); - } - // do procedures for RA-RNTI - if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_IN); - ue_pdsch_procedures(ue, - proc, - eNB_id, - RA_PDSCH, - ue->dlsch_ra[eNB_id], - NULL, - ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols, - ue->frame_parms.symbols_per_tti>>1, - abstraction_flag); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_OUT); - } - - LOG_D(PHY," ------ slot 1 Processing: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); - LOG_D(PHY," ------ --> FFT/ChannelEst/PDCCH slot 1: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); - - if (subframe_select(&ue->frame_parms,subframe_rx) != SF_S) { // do front-end processing for second slot, and first symbol of next subframe - for (l=1; lframe_parms.symbols_per_tti>>1; l++) { - if (abstraction_flag == 0) { -#if UE_TIMING_TRACE - start_meas(&ue->ofdm_demod_stats); -#endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); - slot_fep(ue, - l, - 1+(subframe_rx<<1), - 0, - 0, - 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); -#if UE_TIMING_TRACE - stop_meas(&ue->ofdm_demod_stats); -#endif - } - - ue_measurement_procedures(l-1,ue,proc,eNB_id,1+(subframe_rx<<1),abstraction_flag,mode); - - } // for l=1..l2 + // If this is PMCH, call procedures and return + if (pmch_flag == 1) { + ue_pmch_procedures(ue,proc,eNB_id,abstraction_flag); + return 0; + } +#if 1 + // II- start slave thread for FFT/ChanEst // do first symbol of next downlink subframe for channel estimation int next_subframe_rx = (1+subframe_rx)%10; + uint8_t next_subframe_slot0 = next_subframe_rx<<1; + // 1- perform FFT for pilot ofdm symbols first (ofdmSym0 next subframe ofdmSym11) if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) { - slot_fep(ue, - 0, - (next_subframe_rx<<1), - 0, - 0, - 0); + LOG_I(PHY,"FFT symbol %d slot %d \n", pilot0, next_subframe_slot0); + front_end_fft(ue, + pilot0, + next_subframe_slot0, + 0, + 0); } - } // not an S-subframe -#if UE_TIMING_TRACE - stop_meas(&ue->generic_stat); -#if DISABLE_LOG_X - printf("[SFN %d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); -#else - LOG_D(PHY, "[SFN %d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); -#endif - -#endif - - LOG_D(PHY," ------ end FFT/ChannelEst/PDCCH slot 1: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); - if ( (subframe_rx == 0) && (ue->decode_MIB == 1)) - { - ue_pbch_procedures(eNB_id,ue,proc,abstraction_flag); - } - - // do procedures for C-RNTI - LOG_D(PHY," ------ --> PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); - if (ue->dlsch[subframe_rx&0x1][eNB_id][0]->active == 1) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); -#if UE_TIMING_TRACE - start_meas(&ue->pdsch_procedures_stat); -#endif - ue_pdsch_procedures(ue, - proc, - eNB_id, - PDSCH, - ue->dlsch[subframe_rx&0x1][eNB_id][0], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); - - LOG_D(PHY," ------ end PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); - LOG_D(PHY," ------ --> PDSCH Turbo Decoder slot 0/1: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); -#if UE_TIMING_TRACE - stop_meas(&ue->pdsch_procedures_stat); - start_meas(&ue->dlsch_procedures_stat); -#endif - ue_dlsch_procedures(ue, - proc, - eNB_id, - PDSCH, - ue->dlsch[subframe_rx&0x1][eNB_id][0], - ue->dlsch[subframe_rx&0x1][eNB_id][1], - &ue->dlsch_errors[eNB_id], - mode, - abstraction_flag); -#if UE_TIMING_TRACE - stop_meas(&ue->dlsch_procedures_stat); -#if DISABLE_LOG_X - printf("[SFN %d] Slot1: Pdsch Proc %5.2f\n",subframe_rx,ue->pdsch_procedures_stat.p_time/(cpuf*1000.0)); - printf("[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",subframe_rx,ue->dlsch_procedures_stat.p_time/(cpuf*1000.0)); -#else - LOG_D(PHY, "[SFN %d] Slot1: Pdsch Proc %5.2f\n",subframe_rx,ue->pdsch_procedures_stat.p_time/(cpuf*1000.0)); - LOG_D(PHY, "[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",subframe_rx,ue->dlsch_procedures_stat.p_time/(cpuf*1000.0)); -#endif + LOG_I(PHY,"FFT symbol %d slot %d \n",pilot1,slot1); + front_end_fft(ue, + pilot1, + slot1, + 0, + 0); -#endif + // 2- perform FFT for other ofdm symbols other than pilots + for (l=1; lframe_parms.symbols_per_tti>>1; l++) + { + if( (l != pilot0) && (l != pilot1)) + { + LOG_I(PHY,"FFT symbol %d slot %d\n",l,slot1); + start_meas(&ue->ofdm_demod_stats); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); + front_end_fft(ue, + l, + slot1, + 0, + 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); + stop_meas(&ue->ofdm_demod_stats); + } + } // for l=1..l2 - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); + // 3- perform Channel Estimation for slot1 + for (l=1; lframe_parms.symbols_per_tti>>1; l++) + { + if(l == pilot0) + { + //wait until channel estimation for pilot0/slot1 is available + uint32_t wait = 0; + while(proc->chan_est_pilot0_slot1_available == 0) + { + wait++; + } + } + LOG_I(PHY,"ChanEst symbol %d slot %d\n",l,slot1); + front_end_chanEst(ue, + l, + slot1, + 0); + ue_measurement_procedures(l-1,ue,proc,eNB_id,1+(subframe_rx<<1),abstraction_flag,mode); + } + LOG_I(PHY,"ChanEst symbol %d slot %d\n",0,next_subframe_slot0); + front_end_chanEst(ue, + pilot0, + next_subframe_slot0, + 0); - } -#if UE_TIMING_TRACE - start_meas(&ue->generic_stat); + if ( (subframe_rx == 0) && (ue->decode_MIB == 1)) + { + ue_pbch_procedures(eNB_id,ue,proc,abstraction_flag); + } #endif -#if 0 - if(subframe_rx==5 && ue->dlsch[subframe_rx&0x1][eNB_id][0]->harq_processes[ue->dlsch[subframe_rx&0x1][eNB_id][0]->current_harq_pid]->nb_rb > 20){ - //write_output("decoder_llr.m","decllr",dlsch_llr,G,1,0); - //write_output("llr.m","llr", &ue->pdsch_vars[eNB_id]->llr[0][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0); + stop_meas(&ue->generic_stat); + printf("------Front-End PROC [SFN %d]: %5.2f ------\n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + /**** End Subframe FFT-ChannelEst ****/ + + + /**** Pdsch Procedure Slot0 + Slot1 ****/ + // start main thread for Pdsch Procedure (slot0) + // do procedures for C-RNTI + //LOG_I(PHY,"AbsSubframe %d.%d Pdsch Procedure (slot0)\n",frame_rx%1024,subframe_rx); + //LOG_I(PHY,"AbsSubframe %d.%d Pdsch Procedure PDSCH Active %d \n",frame_rx%1024,subframe_rx, ue->dlsch[subframe_rx&0x1][0][0]->active); + + start_meas(&ue->generic_stat); + if (ue->dlsch[subframe_rx&0x1][eNB_id][0]->active == 1) { + LOG_I(PHY,"AbsSubframe %d.%d Pdsch Procedure PDSCH \n",frame_rx%1024,subframe_rx); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); + ue_pdsch_procedures(ue, + proc, + eNB_id, + PDSCH, + ue->dlsch[subframe_rx&0x1][eNB_id][0], + NULL, + ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols, + ue->frame_parms.symbols_per_tti>>1, + abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); + } + + // do procedures for SI-RNTI + if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { + LOG_I(PHY,"AbsSubframe %d.%d Pdsch Procedure SI-PDSCH \n",frame_rx%1024,subframe_rx); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_IN); + ue_pdsch_procedures(ue, + proc, + eNB_id, + SI_PDSCH, + ue->dlsch_SI[eNB_id], + NULL, + ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols, + ue->frame_parms.symbols_per_tti>>1, + abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_OUT); + } + + // do procedures for SI-RNTI + if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { + LOG_I(PHY,"AbsSubframe %d.%d Pdsch Procedure P-PDSCH \n",frame_rx%1024,subframe_rx); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_IN); + ue_pdsch_procedures(ue, + proc, + eNB_id, + P_PDSCH, + ue->dlsch_p[eNB_id], + NULL, + ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols, + ue->frame_parms.symbols_per_tti>>1, + abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_OUT); + } - write_output("rxdataF0_current.m" , "rxdataF0", &ue->common_vars.common_vars_rx_data_per_thread[subframe_rx&0x1].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); - //write_output("rxdataF0_previous.m" , "rxdataF0_prev_sss", &ue->common_vars.common_vars_rx_data_per_thread[(subframe_rx+1)&0x1].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); + // do procedures for RA-RNTI + if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { + LOG_I(PHY,"AbsSubframe %d.%d Pdsch Procedure RA-PDSCH \n",frame_rx%1024,subframe_rx); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_IN); + ue_pdsch_procedures(ue, + proc, + eNB_id, + RA_PDSCH, + ue->dlsch_ra[eNB_id], + NULL, + ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols, + ue->frame_parms.symbols_per_tti>>1, + abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_OUT); + } - //write_output("rxdataF0_previous.m" , "rxdataF0_prev", &ue->common_vars.common_vars_rx_data_per_thread[(subframe+1)&0x1].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); + stop_meas(&ue->generic_stat); + printf("------LLR-Slot0 [SFN %d]: %5.2f ------\n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + +#if 1 + // start slave thread for Pdsch Procedure (slot1) + // do procedures for C-RNTI + + if (ue->dlsch[subframe_rx&0x1][eNB_id][0]->active == 1) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); + start_meas(&ue->pdsch_procedures_stat); + ue_pdsch_procedures(ue, + proc, + eNB_id, + PDSCH, + ue->dlsch[subframe_rx&0x1][eNB_id][0], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); + stop_meas(&ue->pdsch_procedures_stat); + } - write_output("dl_ch_estimates.m", "dl_ch_estimates_sfn5", &ue->common_vars.common_vars_rx_data_per_thread[subframe_rx&0x1].dl_ch_estimates[0][0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); - write_output("dl_ch_estimates_ext.m", "dl_ch_estimatesExt_sfn5", &ue->pdsch_vars[subframe_rx&0x1][0]->dl_ch_estimates_ext[0][0],14*ue->frame_parms.N_RB_DL*12,1,1); - write_output("rxdataF_comp00.m","rxdataF_comp00", &ue->pdsch_vars[subframe_rx&0x1][0]->rxdataF_comp0[0][0],14*ue->frame_parms.N_RB_DL*12,1,1); - //write_output("magDLFirst.m", "magDLFirst", &phy_vars_ue->pdsch_vars[subframe&0x1][0]->dl_ch_mag0[0][0],14*frame_parms->N_RB_DL*12,1,1); - //write_output("magDLSecond.m", "magDLSecond", &phy_vars_ue->pdsch_vars[subframe&0x1][0]->dl_ch_magb0[0][0],14*frame_parms->N_RB_DL*12,1,1); + // do procedures for SI-RNTI + if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { + ue_pdsch_procedures(ue, + proc, + eNB_id, + SI_PDSCH, + ue->dlsch_SI[eNB_id], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); + } - AssertFatal (0,""); - } + // do procedures for P-RNTI + if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { + ue_pdsch_procedures(ue, + proc, + eNB_id, + P_PDSCH, + ue->dlsch_p[eNB_id], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); + } + // do procedures for RA-RNTI + if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { + ue_pdsch_procedures(ue, + proc, + eNB_id, + RA_PDSCH, + ue->dlsch_ra[eNB_id], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); + } + proc->llr_slot1_available=1; #endif - // do procedures for SI-RNTI - if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { - ue_pdsch_procedures(ue, - proc, - eNB_id, - SI_PDSCH, - ue->dlsch_SI[eNB_id], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); - - ue_dlsch_procedures(ue, - proc, - eNB_id, - SI_PDSCH, - ue->dlsch_SI[eNB_id], - NULL, - &ue->dlsch_SI_errors[eNB_id], - mode, - abstraction_flag); - ue->dlsch_SI[eNB_id]->active = 0; - } - - // do procedures for P-RNTI - if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { - ue_pdsch_procedures(ue, - proc, - eNB_id, - P_PDSCH, - ue->dlsch_p[eNB_id], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); - - ue_dlsch_procedures(ue, - proc, - eNB_id, - P_PDSCH, - ue->dlsch_p[eNB_id], - NULL, - &ue->dlsch_p_errors[eNB_id], - mode, - abstraction_flag); - ue->dlsch_p[eNB_id]->active = 0; - } - // do procedures for RA-RNTI - if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { - ue_pdsch_procedures(ue, - proc, - eNB_id, - RA_PDSCH, - ue->dlsch_ra[eNB_id], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); - ue_dlsch_procedures(ue, - proc, - eNB_id, - RA_PDSCH, - ue->dlsch_ra[eNB_id], - NULL, - &ue->dlsch_ra_errors[eNB_id], - mode, - abstraction_flag); - ue->dlsch_ra[eNB_id]->active = 0; - } - - // duplicate harq structure - - uint8_t current_harq_pid = ue->dlsch[subframe_rx&0x1][eNB_id][0]->current_harq_pid; - LTE_DL_UE_HARQ_t *current_harq_processes = ue->dlsch[subframe_rx&0x1][eNB_id][0]->harq_processes[current_harq_pid]; - LTE_DL_UE_HARQ_t *harq_processes_dest = ue->dlsch[(subframe_rx+1)&0x1][eNB_id][0]->harq_processes[current_harq_pid]; + start_meas(&ue->generic_stat); + // wait until llr on slot1 are available + uint32_t wait=0; + while(proc->llr_slot1_available==0) + { + //wait until channel estimation for pilot0/slot1 is available + usleep(1); + wait++; + } + stop_meas(&ue->generic_stat); + printf("------ Waiting for LLR-Slot1 [SFN %d]: %5.2f ------\n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + + LOG_I(PHY,"==> Start Turbo Decoder wait %d\n", wait); + // Start Turbo decoder + if (ue->dlsch[subframe_rx&0x1][eNB_id][0]->active == 1) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); + start_meas(&ue->dlsch_procedures_stat); + ue_dlsch_procedures(ue, + proc, + eNB_id, + PDSCH, + ue->dlsch[subframe_rx&0x1][eNB_id][0], + ue->dlsch[subframe_rx&0x1][eNB_id][1], + &ue->dlsch_errors[eNB_id], + mode, + abstraction_flag); + stop_meas(&ue->dlsch_procedures_stat); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); + } + + // do procedures for SI-RNTI + if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { + ue_dlsch_procedures(ue, + proc, + eNB_id, + SI_PDSCH, + ue->dlsch_SI[eNB_id], + NULL, + &ue->dlsch_SI_errors[eNB_id], + mode, + abstraction_flag); + ue->dlsch_SI[eNB_id]->active = 0; + } + + // do procedures for P-RNTI + if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { + ue_dlsch_procedures(ue, + proc, + eNB_id, + P_PDSCH, + ue->dlsch_p[eNB_id], + NULL, + &ue->dlsch_p_errors[eNB_id], + mode, + abstraction_flag); + ue->dlsch_p[eNB_id]->active = 0; + } + // do procedures for RA-RNTI + if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { + ue_dlsch_procedures(ue, + proc, + eNB_id, + RA_PDSCH, + ue->dlsch_ra[eNB_id], + NULL, + &ue->dlsch_ra_errors[eNB_id], + mode, + abstraction_flag); + ue->dlsch_ra[eNB_id]->active = 0; + } + printf("------ Turbo Decoding [SFN %d]: %5.2f ------\n",subframe_rx,ue->dlsch_procedures_stat.p_time/(cpuf*1000.0)); + + /**** End Pdsch processing for this subframe ****/ + + if (subframe_rx==9) { + if (frame_rx % 10 == 0) { + if ((ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]) != 0) + ue->dlsch_fer[eNB_id] = (100*(ue->dlsch_errors[eNB_id] - ue->dlsch_errors_last[eNB_id]))/(ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]); + + ue->dlsch_errors_last[eNB_id] = ue->dlsch_errors[eNB_id]; + ue->dlsch_received_last[eNB_id] = ue->dlsch_received[eNB_id]; + } - harq_status_t *current_harq_ack = &ue->dlsch[subframe_rx&0x1][eNB_id][0]->harq_ack[subframe_rx]; - harq_status_t *harq_ack_dest = &ue->dlsch[(subframe_rx+1)&0x1][eNB_id][0]->harq_ack[subframe_rx]; - copy_harq_proc_struct(harq_processes_dest, current_harq_processes); - copy_ack_struct(harq_ack_dest, current_harq_ack); + ue->bitrate[eNB_id] = (ue->total_TBS[eNB_id] - ue->total_TBS_last[eNB_id])*100; + ue->total_TBS_last[eNB_id] = ue->total_TBS[eNB_id]; + LOG_D(PHY,"[UE %d] Calculating bitrate Frame %d: total_TBS = %d, total_TBS_last = %d, bitrate %f kbits\n", + ue->Mod_id,frame_rx,ue->total_TBS[eNB_id], + ue->total_TBS_last[eNB_id],(float) ue->bitrate[eNB_id]/1000.0); - if (subframe_rx==9) { - if (frame_rx % 10 == 0) { - if ((ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]) != 0) - ue->dlsch_fer[eNB_id] = (100*(ue->dlsch_errors[eNB_id] - ue->dlsch_errors_last[eNB_id]))/(ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]); + #if UE_AUTOTEST_TRACE + if ((frame_rx % 100 == 0)) { + LOG_I(PHY,"[UE %d] AUTOTEST Metric : UE_DLSCH_BITRATE = %5.2f kbps (frame = %d) \n", ue->Mod_id, (float) ue->bitrate[eNB_id]/1000.0, frame_rx); + } + #endif - ue->dlsch_errors_last[eNB_id] = ue->dlsch_errors[eNB_id]; - ue->dlsch_received_last[eNB_id] = ue->dlsch_received[eNB_id]; } + //printf("after tubo until end of Rx %5.2f \n",ue->generic_stat.p_time/(cpuf*1000.0)); - ue->bitrate[eNB_id] = (ue->total_TBS[eNB_id] - ue->total_TBS_last[eNB_id])*100; - ue->total_TBS_last[eNB_id] = ue->total_TBS[eNB_id]; - LOG_D(PHY,"[UE %d] Calculating bitrate Frame %d: total_TBS = %d, total_TBS_last = %d, bitrate %f kbits\n", - ue->Mod_id,frame_rx,ue->total_TBS[eNB_id], - ue->total_TBS_last[eNB_id],(float) ue->bitrate[eNB_id]/1000.0); - - #if UE_AUTOTEST_TRACE - if ((frame_rx % 100 == 0)) { - LOG_I(PHY,"[UE %d] AUTOTEST Metric : UE_DLSCH_BITRATE = %5.2f kbps (frame = %d) \n", ue->Mod_id, (float) ue->bitrate[eNB_id]/1000.0, frame_rx); - } + #ifdef EMOS + phy_procedures_emos_UE_RX(ue,slot,eNB_id); #endif - } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); + stop_meas(&ue->phy_proc_rx[subframe_rx&0x1]); -#if UE_TIMING_TRACE - stop_meas(&ue->generic_stat); - printf("after tubo until end of Rx %5.2f \n",ue->generic_stat.p_time/(cpuf*1000.0)); -#endif -#ifdef EMOS - phy_procedures_emos_UE_RX(ue,slot,eNB_id); -#endif + printf("------FULL RX PROC [SFN %d]: %5.2f ------\n",subframe_rx,ue->phy_proc_rx[subframe_rx&0x1].p_time/(cpuf*1000.0)); + LOG_I(PHY," ****** end RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); -#if UE_TIMING_TRACE - stop_meas(&ue->phy_proc_rx[subframe_rx&0x1]); -#if DISABLE_LOG_X - printf("------FULL RX PROC [SFN %d]: %5.2f ------\n",subframe_rx,ue->phy_proc_rx[subframe_rx&0x1].p_time/(cpuf*1000.0)); -#else - LOG_D(PHY, "------FULL RX PROC [SFN %d]: %5.2f ------\n",subframe_rx,ue->phy_proc_rx[subframe_rx&0x1].p_time/(cpuf*1000.0)); -#endif -#endif - LOG_D(PHY," ****** end RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx); - return (0); -} + return (0); + } #if defined(Rel10) || defined(Rel14) int phy_procedures_RN_UE_RX(uint8_t slot_rx, uint8_t next_slot, relaying_type_t r_type) diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 1ab22b6104..aab70aebaa 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -476,15 +476,6 @@ static void *UE_thread_synch(void *arg) { return &UE_thread_synch_retval; } - -/* this structure is used to pass both UE phy vars and - * proc to the function UE_thread_rxn_txnp4 - */ -struct rx_tx_thread_data { - PHY_VARS_UE *UE; - UE_rxtx_proc_t *proc; -}; - /*! * \brief This is the UE thread for RX subframe n and TX subframe n+4. * This thread performs the phy_procedures_UE_RX() on every received slot. @@ -508,9 +499,9 @@ static void *UE_thread_rxn_txnp4(void *arg) { cpu_set_t cpuset; CPU_ZERO(&cpuset); if ( (proc->sub_frame_start+1)%2 == 0 && threads.even != -1 ) - CPU_SET(threads.even, &cpuset); + CPU_SET(1, &cpuset); if ( (proc->sub_frame_start+1)%2 == 1 && threads.odd != -1 ) - CPU_SET(threads.odd, &cpuset); + CPU_SET(2, &cpuset); init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset, threadname); @@ -852,16 +843,273 @@ void *UE_thread(void *arg) { return NULL; } +void *UE_thread_fep_slot1(void *arg) { + + static __thread int UE_thread_rxtx_retval; + struct rx_tx_thread_data *rtd = arg; + UE_rxtx_proc_t *proc = rtd->proc; + PHY_VARS_UE *ue = rtd->UE; + + char threadname[256]; + proc->subframe_rx=proc->sub_frame_start; + sprintf(threadname,"UE_SLOT1_PROC_%d", proc->sub_frame_start); + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + if ( (proc->sub_frame_start+1)%2 == 0 ) + CPU_SET(0, &cpuset); + if ( (proc->sub_frame_start+1)%2 == 1 ) + CPU_SET(4, &cpuset); + init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset, + threadname); + + + uint8_t l; + uint8_t compute_llrs_slot1; + + proc->instance_cnt_fep_slot1=-1; + + while (!oai_exit) { + if (pthread_mutex_lock(&proc->mutex_fep_slot1) != 0) { + LOG_E( PHY, "[SCHED][UE] error locking mutex for UE FEP Slo1\n" ); + exit_fun("nothing to add"); + } + while (proc->instance_cnt_fep_slot1 < 0) { + // most of the time, the thread is waiting here + pthread_cond_wait( &proc->cond_fep_slot1, &proc->mutex_fep_slot1 ); + } + if (pthread_mutex_unlock(&proc->mutex_fep_slot1) != 0) { + LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE FEP Slo1\n" ); + exit_fun("nothing to add"); + } + + // Start Thread Processing + LOG_I(PHY," [Th-Slave] ==> execute fep slot1 thread for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); +#if 1 + int frame_rx = proc->frame_rx; + int subframe_rx = proc->subframe_rx; + uint8_t pilot0; + uint8_t pilot1; + uint8_t slot1; + + slot1 = (subframe_rx<<1) + 1; + pilot0 = 0; + if (ue->frame_parms.Ncp == 0) { // normal prefix + pilot1 = 4; + } else { // extended prefix + pilot1 = 3; + } + + // do first symbol of next downlink subframe for channel estimation + int next_subframe_rx = (1+subframe_rx)%10; + uint8_t next_subframe_slot0 = next_subframe_rx<<1; + // 1- perform FFT for pilot ofdm symbols first (ofdmSym0 next subframe ofdmSym11) + if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) + { + //LOG_I(PHY,"[Th-Slave] FFT symbol %d slot %d \n", pilot0, next_subframe_slot0); + front_end_fft(ue, + pilot0, + next_subframe_slot0, + 0, + 0); + } + //LOG_I(PHY,"[Th-Slave]FFT symbol %d slot %d \n",pilot1,slot1); + front_end_fft(ue, + pilot1, + slot1, + 0, + 0); + // 2- perform FFT for other ofdm symbols other than pilots + for (l=1; lframe_parms.symbols_per_tti>>1; l++) + { + if( (l != pilot0) && (l != pilot1)) + { + //LOG_I(PHY,"[Th-Slave]FFT symbol %d slot %d\n",l,slot1); + start_meas(&ue->ofdm_demod_stats); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); + front_end_fft(ue, + l, + slot1, + 0, + 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); + stop_meas(&ue->ofdm_demod_stats); + } + } // for l=1..l2 + + // 3- perform Channel Estimation for slot1 + for (l=1; lframe_parms.symbols_per_tti>>1; l++) + { + uint32_t wait=0; + if(l==pilot1) + { + LOG_I(PHY,"[Th-Slave] ==> wait pilot0 slot1 channel estimation is ready \n"); + while(proc->chan_est_pilot0_slot1_available==0) + { + //wait until channel estimation for pilot0/slot1 is available + usleep(1); + wait++; + } + } + front_end_chanEst(ue, + l, + slot1, + 0); + + //LOG_I(PHY,"[Th-Slave]ChanEst symbol %d slot %d wait%d\n",l,slot1,wait); + ue_measurement_procedures(l-1,ue,proc,0,1+(subframe_rx<<1),0,ue->mode); + } + //LOG_I(PHY,"[Th-Slave]ChanEst symbol %d slot %d\n",0,next_subframe_slot0); + front_end_chanEst(ue, + 0, + next_subframe_slot0, + 0); + + if ( (subframe_rx == 0) && (ue->decode_MIB == 1)) + { + ue_pbch_procedures(0,ue,proc,0); + } +#endif + LOG_I(PHY," [Th-Slave] ==> FFT/CHanEst Done for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); + + LOG_I(PHY," [Th-Slave] ==> Start LLR Comuptation slot1 for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); + +#if 1 + // wait until dci info are available + uint32_t wait=0; + while(proc->dci_slot0_available==0) // (proc->dci_slot0_available==0) + { + //wait until channel estimation for pilot0/slot1 is available + usleep(1); + wait++; + } + // check if a dl grant was received on a DCI + compute_llrs_slot1 = 0; + if(ue->dlsch[subframe_rx&0x1][0][0]->active || + ((ue->dlsch_SI[0]) && (ue->dlsch_SI[0]->active == 1)) || + ((ue->dlsch_p[0]) && (ue->dlsch_p[0]->active == 1)) || + ((ue->dlsch_ra[0]) && (ue->dlsch_ra[0]->active == 1)) + ) + { + compute_llrs_slot1 = 1; + } + else + { + proc->llr_slot1_available = 1; + } + LOG_I(PHY,"[Th-Slave] compute llrs slot-1 %d AbsSubframe %d.%d \n",compute_llrs_slot1,frame_rx%1024,subframe_rx); + + if(compute_llrs_slot1) + { + // wait until computation of first ofdm symbol is done + uint32_t wait=0; + while(proc->first_symbol_available==0) + { + //wait until channel estimation for pilot0/slot1 is available + usleep(1); + wait++; + } + + // start slave thread for Pdsch Procedure (slot1) + // do procedures for C-RNTI + //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure (slot1) wait %d \n",frame_rx%1024,subframe_rx,wait); + //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure PDSCH Active %d \n",frame_rx%1024,subframe_rx, ue->dlsch[subframe_rx&0x1][0][0]->active); + if (ue->dlsch[subframe_rx&0x1][0][0]->active == 1) { + //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure PDSCH \n",frame_rx%1024,subframe_rx); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); + start_meas(&ue->pdsch_procedures_stat); + ue_pdsch_procedures(ue, + proc, + 0, + PDSCH, + ue->dlsch[subframe_rx&0x1][0][0], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + 0); + stop_meas(&ue->pdsch_procedures_stat); + } + + // do procedures for SI-RNTI + if ((ue->dlsch_SI[0]) && (ue->dlsch_SI[0]->active == 1)) { + //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure SI-PDSCH \n",frame_rx%1024,subframe_rx); + ue_pdsch_procedures(ue, + proc, + 0, + SI_PDSCH, + ue->dlsch_SI[0], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + 0); + } + + // do procedures for P-RNTI + if ((ue->dlsch_p[0]) && (ue->dlsch_p[0]->active == 1)) { + //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure P-PDSCH \n",frame_rx%1024,subframe_rx); + ue_pdsch_procedures(ue, + proc, + 0, + P_PDSCH, + ue->dlsch_p[0], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + 0); + } + // do procedures for RA-RNTI + if ((ue->dlsch_ra[0]) && (ue->dlsch_ra[0]->active == 1)) { + //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure RA-PDSCH \n",frame_rx%1024,subframe_rx); + ue_pdsch_procedures(ue, + proc, + 0, + RA_PDSCH, + ue->dlsch_ra[0], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + 0); + } + + //LOG_I(PHY,"Set available llrs slot1 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); + proc->llr_slot1_available = 1; + } +#endif + + LOG_I(PHY," [Th-Slave] ==> End slot1 Thread for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); + + // End Thread Processing + + if (pthread_mutex_lock(&proc->mutex_fep_slot1) != 0) { + LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); + exit_fun("noting to add"); + } + proc->instance_cnt_fep_slot1--; + if (pthread_mutex_unlock(&proc->mutex_fep_slot1) != 0) { + LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE FEP Slo1\n" ); + exit_fun("noting to add"); + } + } + + + // thread finished + free(arg); + return &UE_thread_rxtx_retval; +} /*! * \brief Initialize the UE theads. * Creates the UE threads: * - UE_thread_rxtx0 * - UE_thread_rxtx1 * - UE_thread_synch + * - UE_thread_fep_slot0 + * - UE_thread_fep_slot1 + * - UE_thread_dlsch_proc_slot0 + * - UE_thread_dlsch_proc_slot1 * and the locking between them. */ void init_UE_threads(PHY_VARS_UE *UE) { struct rx_tx_thread_data *rtd; + struct fep_slot1_thread_data *fep_slot1_data; pthread_attr_init (&UE->proc.attr_ue); pthread_attr_setstacksize(&UE->proc.attr_ue,8192);//5*PTHREAD_STACK_MIN); @@ -881,9 +1129,12 @@ void init_UE_threads(PHY_VARS_UE *UE) { UE->proc.proc_rxtx[i].sub_frame_start=i; UE->proc.proc_rxtx[i].sub_frame_step=nb_threads; pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, UE_thread_rxn_txnp4, rtd); + + pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_fep_slot1,NULL); + pthread_cond_init(&UE->proc.proc_rxtx[i].cond_fep_slot1,NULL); + pthread_create(&UE->proc.proc_rxtx[i].pthread_fep_slot1,NULL,UE_thread_fep_slot1, rtd); } pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE); - } -- GitLab From d951795ae415fe63e2e8843208a402c8f0305811 Mon Sep 17 00:00:00 2001 From: fnabet Date: Wed, 21 Jun 2017 15:58:12 +0200 Subject: [PATCH 2/7] build fixes --- openair1/SCHED/defs.h | 3 +++ openair1/SCHED/phy_procedures_lte_ue.c | 3 ++- targets/RT/USER/lte-ue.c | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/openair1/SCHED/defs.h b/openair1/SCHED/defs.h index bb71e0deb9..73883ebc5e 100644 --- a/openair1/SCHED/defs.h +++ b/openair1/SCHED/defs.h @@ -43,6 +43,7 @@ enum THREAD_INDEX { OPENAIR_THREAD_INDEX = 0, #define OPENAIR_THREAD_STACK_SIZE PTHREAD_STACK_MIN //4096 //RTL_PTHREAD_STACK_MIN*6 //#define DLC_THREAD_STACK_SIZE 4096 //DLC stack size +//#define UE_SLOT_PARALLELISATION enum openair_SCHED_STATUS { openair_SCHED_STOPPED=1, @@ -140,7 +141,9 @@ void phy_procedures_UE_TX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t */ int phy_procedures_UE_RX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode,relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn); +#ifdef UE_SLOT_PARALLELISATION void *UE_thread_fep_slot1(void *arg); +#endif /*! \brief Scheduling for UE TX procedures in TDD S-subframes. @param phy_vars_ue Pointer to UE variables on which to act diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index ef1db033e4..8ad3ae27a2 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -73,6 +73,7 @@ fifo_dump_emos_UE emos_dump_UE; #define NS_PER_SLOT 500000 + extern int oai_exit; extern double cpuf; @@ -4146,7 +4147,7 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, } -#if 0 +#ifdef UE_SLOT_PARALLELISATION /*! * \brief This is the UE synchronize thread. * It performs band scanning and synchonization. diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index aab70aebaa..791c4778f0 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -843,6 +843,7 @@ void *UE_thread(void *arg) { return NULL; } +#ifdef UE_SLOT_PARALLELISATION void *UE_thread_fep_slot1(void *arg) { static __thread int UE_thread_rxtx_retval; @@ -1095,6 +1096,8 @@ void *UE_thread_fep_slot1(void *arg) { free(arg); return &UE_thread_rxtx_retval; } +#endif + /*! * \brief Initialize the UE theads. * Creates the UE threads: @@ -1109,7 +1112,9 @@ void *UE_thread_fep_slot1(void *arg) { */ void init_UE_threads(PHY_VARS_UE *UE) { struct rx_tx_thread_data *rtd; +#ifdef UE_SLOT_PARALLELISATION struct fep_slot1_thread_data *fep_slot1_data; +#endif pthread_attr_init (&UE->proc.attr_ue); pthread_attr_setstacksize(&UE->proc.attr_ue,8192);//5*PTHREAD_STACK_MIN); @@ -1130,9 +1135,12 @@ void init_UE_threads(PHY_VARS_UE *UE) { UE->proc.proc_rxtx[i].sub_frame_step=nb_threads; pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, UE_thread_rxn_txnp4, rtd); +#ifdef UE_SLOT_PARALLELISATION pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_fep_slot1,NULL); pthread_cond_init(&UE->proc.proc_rxtx[i].cond_fep_slot1,NULL); pthread_create(&UE->proc.proc_rxtx[i].pthread_fep_slot1,NULL,UE_thread_fep_slot1, rtd); +#endif + } pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE); } -- GitLab From bc2a93183d480b69847dc2001cd1c76da49d92d0 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Wed, 21 Jun 2017 17:49:56 +0200 Subject: [PATCH 3/7] ue fixes slot parallelisation --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 21 ++++++++-------- openair1/SCHED/phy_procedures_lte_ue.c | 34 +++++++++++++++----------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 0d933dfd74..d61dca4648 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -4773,15 +4773,15 @@ int check_dci_format1_1a_coherency(DCI_format_t dci_format, uint8_t mcs1 = pdci_info_extarcted->mcs1; uint8_t TPC = pdci_info_extarcted->TPC; uint8_t rah = pdci_info_extarcted->rah; -#ifdef DEBUG_DCI +//#ifdef DEBUG_DCI uint8_t rv1 = pdci_info_extarcted->rv1; uint8_t ndi1 = pdci_info_extarcted->ndi1; -#endif +//#endif uint8_t NPRB = 0; long long int RIV_max = 0; -#ifdef DEBUG_DCI +//#ifdef DEBUG_DCI LOG_I(PHY,"[DCI-FORMAT-1-1A] AbsSubframe %d.%d dci_format %d\n", frame, subframe, dci_format); LOG_I(PHY,"[DCI-FORMAT-1-1A] rnti %x\n", rnti); LOG_I(PHY,"[DCI-FORMAT-1-1A] harq_pid %d\n", harq_pid); @@ -4791,7 +4791,7 @@ int check_dci_format1_1a_coherency(DCI_format_t dci_format, LOG_I(PHY,"[DCI-FORMAT-1-1A] rv1 %d\n", rv1); LOG_I(PHY,"[DCI-FORMAT-1-1A] ndi1 %d\n", ndi1); LOG_I(PHY,"[DCI-FORMAT-1-1A] TPC %d\n", TPC); -#endif +//#endif // I- check dci content minimum coherency if( ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) && harq_pid > 0) @@ -5185,15 +5185,15 @@ void compute_llr_offset(LTE_DL_FRAME_PARMS *frame_parms, if(symbol < (frame_parms->symbols_per_tti-1)) pdsch_vars->llr_offset[symbol+1] = pdsch_vars->llr_offset[symbol] + llr_offset; - //LOG_I(PHY,"Granted Re subframe %d / symbol %d => %d (%d RBs)\n", subframe, symbol_mod, granted_re,dlsch0_harq->nb_rb); - //LOG_I(PHY,"Pbch/PSS/SSS Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, pbch_pss_sss_re); - //LOG_I(PHY,"CRS Re Per PRB subframe %d / symbol %d => %d \n", subframe, symbol_mod, crs_re); - //LOG_I(PHY,"Data Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, data_re); + LOG_I(PHY,"Granted Re subframe %d / symbol %d => %d (%d RBs)\n", subframe, symbol_mod, granted_re,dlsch0_harq->nb_rb); + LOG_I(PHY,"Pbch/PSS/SSS Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, pbch_pss_sss_re); + LOG_I(PHY,"CRS Re Per PRB subframe %d / symbol %d => %d \n", subframe, symbol_mod, crs_re); + LOG_I(PHY,"Data Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, data_re); - //LOG_I(PHY,"Data Re subframe %d-symbol %d => llr length %d, llr offset %d \n", subframe, symbol, - // pdsch_vars->llr_length[symbol], pdsch_vars->llr_offset[symbol]); + LOG_I(PHY,"Data Re subframe %d-symbol %d => llr length %d, llr offset %d \n", subframe, symbol, + pdsch_vars->llr_length[symbol], pdsch_vars->llr_offset[symbol]); } } void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, @@ -5267,6 +5267,7 @@ void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, else // format1 { NPRB = conv_nprb(rah, rballoc, N_RB_DL); + nb_rb_alloc = NPRB; } pdlsch0->current_harq_pid = harq_pid; diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index 8ad3ae27a2..bf59399f80 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -4178,13 +4178,16 @@ void *UE_thread_fep_slot1(void *arg) { uint8_t l; uint8_t compute_llrs_slot1; +#ifdef UE_SLOT_PARALLELISATION proc->instance_cnt_fep_slot1=-1; +#endif while (!oai_exit) { if (pthread_mutex_lock(&proc->mutex_fep_slot1) != 0) { LOG_E( PHY, "[SCHED][UE] error locking mutex for UE FEP Slo1\n" ); exit_fun("nothing to add"); } +#ifdef UE_SLOT_PARALLELISATION while (proc->instance_cnt_fep_slot1 < 0) { // most of the time, the thread is waiting here pthread_cond_wait( &proc->cond_fep_slot1, &proc->mutex_fep_slot1 ); @@ -4196,6 +4199,8 @@ void *UE_thread_fep_slot1(void *arg) { // Start Thread Processing LOG_I(PHY," [Th-Slave] ==> execute fep slot1 thread for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); +#endif + #if 1 int frame_rx = proc->frame_rx; int subframe_rx = proc->subframe_rx; @@ -4514,7 +4519,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin proc->dci_slot0_available=0; proc->first_symbol_available=0; - +#ifdef UE_SLOT_PARALLELISATION //LOG_I(PHY,"fep slot1 thread : instance_cnt %d \n", // proc->instance_cnt_fep_slot1); proc->instance_cnt_fep_slot1++; @@ -4531,41 +4536,42 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin } AssertFatal(pthread_cond_signal(&proc->cond_fep_slot1) ==0 ,""); AssertFatal(pthread_mutex_unlock(&proc->mutex_fep_slot1) ==0,""); +#endif /**** FFT Slot0 + Slot1 ****/ // I- start main thread for FFT/ChanEst symbol: 0/1 --> 7 // 1- perform FFT for pilot ofdm symbols first (ofdmSym7 ofdmSym4 or (ofdmSym6 ofdmSym3)) - //LOG_I(PHY,"FFT symbol %d slot %d \n",pilot0,slot1); + LOG_I(PHY,"FFT symbol %d slot %d \n",pilot0,slot1); front_end_fft(ue, pilot0, slot1, 0, 0); - //LOG_I(PHY,"FFT symbol %d slot %d \n",pilot1,slot0); + LOG_I(PHY,"FFT symbol %d slot %d \n",pilot1,slot0); front_end_fft(ue, pilot1, slot0, 0, 0); - //LOG_I(PHY,"ChanEst symbol %d slot %d\n",pilot1,slot0); + LOG_I(PHY,"ChanEst symbol %d slot %d\n",pilot1,slot0); front_end_chanEst(ue, pilot1, slot0, 0); - //LOG_I(PHY,"ChanEst symbol %d slot %d\n",pilot0,slot1); + LOG_I(PHY,"ChanEst symbol %d slot %d\n",pilot0,slot1); front_end_chanEst(ue, pilot0, slot1, 0); proc->chan_est_pilot0_slot1_available = 1; - //LOG_I(PHY,"Set available channelEst to 1 AbsSubframe %d.%d \n",frame_rx,subframe_rx); + LOG_I(PHY,"Set available channelEst to 1 AbsSubframe %d.%d \n",frame_rx,subframe_rx); // 2- perform FFT for other ofdm symbols other than pilots for (l=first_ofdm_sym; l<=l2; l++) { if( (l != pilot0) && (l != pilot1)) { - //LOG_I(PHY,"FFT symbol %d slot %d \n", l, slot0); + LOG_I(PHY,"FFT symbol %d slot %d \n", l, slot0); start_meas(&ue->ofdm_demod_stats); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); front_end_fft(ue, @@ -4583,7 +4589,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin { if( (l != pilot0) && (l != pilot1)) { - //LOG_I(PHY,"ChanEst symbol %d slot %d\n",l,slot0); + LOG_I(PHY,"ChanEst symbol %d slot %d\n",l,slot0); front_end_chanEst(ue, l, slot0, @@ -4598,7 +4604,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin return(-1); } - //LOG_I(PHY,"num_pdcch_symbols %d\n",ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols); + LOG_I(PHY,"num_pdcch_symbols %d\n",ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols); LOG_I(PHY,"Set available dci slot0 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); proc->dci_slot0_available=1; @@ -4682,7 +4688,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin #endif stop_meas(&ue->generic_stat); - printf("------Front-End PROC [SFN %d]: %5.2f ------\n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + //printf("------Front-End PROC [SFN %d]: %5.2f ------\n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); /**** End Subframe FFT-ChannelEst ****/ @@ -4757,7 +4763,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin } stop_meas(&ue->generic_stat); - printf("------LLR-Slot0 [SFN %d]: %5.2f ------\n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + //printf("------LLR-Slot0 [SFN %d]: %5.2f ------\n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); #if 1 // start slave thread for Pdsch Procedure (slot1) @@ -4828,7 +4834,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin wait++; } stop_meas(&ue->generic_stat); - printf("------ Waiting for LLR-Slot1 [SFN %d]: %5.2f ------\n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + //printf("------ Waiting for LLR-Slot1 [SFN %d]: %5.2f ------\n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); LOG_I(PHY,"==> Start Turbo Decoder wait %d\n", wait); // Start Turbo decoder @@ -4888,7 +4894,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin abstraction_flag); ue->dlsch_ra[eNB_id]->active = 0; } - printf("------ Turbo Decoding [SFN %d]: %5.2f ------\n",subframe_rx,ue->dlsch_procedures_stat.p_time/(cpuf*1000.0)); + //printf("------ Turbo Decoding [SFN %d]: %5.2f ------\n",subframe_rx,ue->dlsch_procedures_stat.p_time/(cpuf*1000.0)); /**** End Pdsch processing for this subframe ****/ @@ -4926,7 +4932,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin stop_meas(&ue->phy_proc_rx[subframe_rx&0x1]); - printf("------FULL RX PROC [SFN %d]: %5.2f ------\n",subframe_rx,ue->phy_proc_rx[subframe_rx&0x1].p_time/(cpuf*1000.0)); + //printf("------FULL RX PROC [SFN %d]: %5.2f ------\n",subframe_rx,ue->phy_proc_rx[subframe_rx&0x1].p_time/(cpuf*1000.0)); LOG_I(PHY," ****** end RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx); return (0); -- GitLab From 232f56b9e6e1d4b5e6903209026d110906619f59 Mon Sep 17 00:00:00 2001 From: fnabet Date: Mon, 26 Jun 2017 12:16:30 +0200 Subject: [PATCH 4/7] prepare for rebase from 2017.w25 --- openair1/SCHED/phy_procedures_lte_ue.c | 503 +++++++++++++++++++++++++ 1 file changed, 503 insertions(+) diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index bf59399f80..e998dd1754 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -4937,6 +4937,509 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin return (0); } + + + +static int phy_procedures_UE_RX_new(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode, + relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn) { + +int l,l2; +int pmch_flag=0; +int frame_rx = proc->frame_rx; +int subframe_rx = proc->subframe_rx; +uint8_t pilot0; +uint8_t pilot1; +uint8_t slot0; +uint8_t slot1; +uint8_t first_ofdm_sym; + +VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); + +#if T_TRACER +T(T_UE_PHY_DL_TICK, T_INT(ue->Mod_id), T_INT(frame_rx%1024), T_INT(subframe_rx)); +#endif + + +T(T_UE_PHY_INPUT_SIGNAL, T_INT(ue->Mod_id), T_INT(frame_rx%1024), T_INT(subframe_rx), T_INT(0), + T_BUFFER(&ue->common_vars.rxdata[0][subframe_rx*ue->frame_parms.samples_per_tti], + ue->frame_parms.samples_per_tti * 4)); + +// start timers +LOG_I(PHY," ****** start RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx); +start_meas(&ue->phy_proc_rx[subframe_rx&0x1]); +start_meas(&ue->generic_stat); + +pmch_flag = is_pmch_subframe(frame_rx,subframe_rx,&ue->frame_parms) ? 1 : 0; + + +// deactivate reception until we scan pdcch +if (ue->dlsch[subframe_rx&0x1][eNB_id][0]) + ue->dlsch[subframe_rx&0x1][eNB_id][0]->active = 0; +if (ue->dlsch[subframe_rx&0x1][eNB_id][1]) + ue->dlsch[subframe_rx&0x1][eNB_id][1]->active = 0; + +if (ue->dlsch_SI[eNB_id]) + ue->dlsch_SI[eNB_id]->active = 0; +if (ue->dlsch_p[eNB_id]) + ue->dlsch_p[eNB_id]->active = 0; +if (ue->dlsch_ra[eNB_id]) + ue->dlsch_ra[eNB_id]->active = 0; + +if (subframe_select(&ue->frame_parms,subframe_rx) == SF_S) { // S-subframe, do first 5 symbols only +l2 = 5; +} else if (pmch_flag == 1) { // do first 2 symbols only +l2 = 1; +} else { // normal subframe, last symbol to be processed is the first of the second slot +l2 = (ue->frame_parms.symbols_per_tti/2)-1; +} + +int prev_subframe_rx = (subframe_rx - 1)<0? 9: (subframe_rx - 1); +if (subframe_select(&ue->frame_parms,prev_subframe_rx) != SF_DL) { + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // RX processing of symbols l=0...l2 + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + first_ofdm_sym = 0; +} else { + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // RX processing of symbols l=1...l2 (l=0 is done in last scheduling epoch) + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + first_ofdm_sym = 1; +} +slot0 = (subframe_rx<<1); +slot1 = (subframe_rx<<1) + 1; +pilot0 = 0; +if (ue->frame_parms.Ncp == 0) { // normal prefix + pilot1 = 4; +} else { // extended prefix + pilot1 = 3; +} + +//LOG_I(PHY,"Set available channelEst to 0 AbsSubframe %d.%d \n",frame_rx,subframe_rx); +//LOG_I(PHY,"Set available llrs slot1 to 0 AbsSubframe %d.%d \n",frame_rx,subframe_rx); +//LOG_I(PHY,"Set available dci info slot0 to 0 AbsSubframe %d.%d \n",frame_rx,subframe_rx); +proc->chan_est_pilot0_slot1_available=0; +proc->llr_slot1_available=0; +proc->dci_slot0_available=0; +proc->first_symbol_available=0; + +#ifdef UE_SLOT_PARALLELISATION +//LOG_I(PHY,"fep slot1 thread : instance_cnt %d \n", +// proc->instance_cnt_fep_slot1); +proc->instance_cnt_fep_slot1++; +if (proc->instance_cnt_fep_slot1 == 0) { + LOG_I(PHY,"unblock fep slot1 thread blocked on cond_fep_slot1 : instance_cnt_fep_slot1 %d \n", proc->instance_cnt_fep_slot1 ); + if (pthread_cond_signal(&proc->cond_fep_slot1) != 0) { + LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE FEP slot1 thread\n", ue->Mod_id); + exit_fun("nothing to add"); + } +} else { + LOG_E( PHY, "[SCHED][UE %d] UE RX thread busy (IC %d)!!\n", ue->Mod_id, proc->instance_cnt_fep_slot1); + if (proc->instance_cnt_fep_slot1 > 2) + exit_fun("instance_cnt_fep_slot1 > 2"); +} +AssertFatal(pthread_cond_signal(&proc->cond_fep_slot1) ==0 ,""); +AssertFatal(pthread_mutex_unlock(&proc->mutex_fep_slot1) ==0,""); +#endif + +/**** FFT Slot0 + Slot1 ****/ +// I- start main thread for FFT/ChanEst symbol: 0/1 --> 7 + +// 1- perform FFT for pilot ofdm symbols first (ofdmSym7 ofdmSym4 or (ofdmSym6 ofdmSym3)) +LOG_I(PHY,"FFT symbol %d slot %d \n",pilot0,slot1); +front_end_fft(ue, + pilot0, + slot1, + 0, + 0); +LOG_I(PHY,"FFT symbol %d slot %d \n",pilot1,slot0); +front_end_fft(ue, + pilot1, + slot0, + 0, + 0); +LOG_I(PHY,"ChanEst symbol %d slot %d\n",pilot1,slot0); +front_end_chanEst(ue, + pilot1, + slot0, + 0); +LOG_I(PHY,"ChanEst symbol %d slot %d\n",pilot0,slot1); +front_end_chanEst(ue, + pilot0, + slot1, + 0); +proc->chan_est_pilot0_slot1_available = 1; +LOG_I(PHY,"Set available channelEst to 1 AbsSubframe %d.%d \n",frame_rx,subframe_rx); +// 2- perform FFT for other ofdm symbols other than pilots +for (l=first_ofdm_sym; l<=l2; l++) +{ + if( (l != pilot0) && (l != pilot1)) + { + LOG_I(PHY,"FFT symbol %d slot %d \n", l, slot0); + start_meas(&ue->ofdm_demod_stats); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); + front_end_fft(ue, + l, + slot0, + 0, + 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); + stop_meas(&ue->ofdm_demod_stats); + } +} // for l=1..l2 + +// 3- perform Channel Estimation for slot0 +for (l=first_ofdm_sym; l<=l2; l++) +{ + if( (l != pilot0) && (l != pilot1)) + { + LOG_I(PHY,"ChanEst symbol %d slot %d\n",l,slot0); + front_end_chanEst(ue, + l, + slot0, + 0); + } + ue_measurement_procedures(l-1,ue,proc,eNB_id,(subframe_rx<<1),abstraction_flag,mode); +} + +// PDCCH decoding +if (ue_pdcch_procedures(eNB_id,ue,proc,abstraction_flag) == -1) { + LOG_E(PHY,"[UE %d] Frame %d, subframe %d: Error in pdcch procedures\n",ue->Mod_id,frame_rx,subframe_rx); + return(-1); +} + +LOG_I(PHY,"num_pdcch_symbols %d\n",ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols); +LOG_I(PHY,"Set available dci slot0 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); +proc->dci_slot0_available=1; + + +// If this is PMCH, call procedures and return +if (pmch_flag == 1) { + ue_pmch_procedures(ue,proc,eNB_id,abstraction_flag); + return 0; +} + +#if 1 +// II- start slave thread for FFT/ChanEst +// do first symbol of next downlink subframe for channel estimation +int next_subframe_rx = (1+subframe_rx)%10; +uint8_t next_subframe_slot0 = next_subframe_rx<<1; +// 1- perform FFT for pilot ofdm symbols first (ofdmSym0 next subframe ofdmSym11) +if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) +{ + LOG_I(PHY,"FFT symbol %d slot %d \n", pilot0, next_subframe_slot0); + front_end_fft(ue, + pilot0, + next_subframe_slot0, + 0, + 0); +} + +LOG_I(PHY,"FFT symbol %d slot %d \n",pilot1,slot1); +front_end_fft(ue, + pilot1, + slot1, + 0, + 0); + +// 2- perform FFT for other ofdm symbols other than pilots +for (l=1; lframe_parms.symbols_per_tti>>1; l++) +{ + if( (l != pilot0) && (l != pilot1)) + { + LOG_I(PHY,"FFT symbol %d slot %d\n",l,slot1); + start_meas(&ue->ofdm_demod_stats); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); + front_end_fft(ue, + l, + slot1, + 0, + 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); + stop_meas(&ue->ofdm_demod_stats); + } +} // for l=1..l2 + +// 3- perform Channel Estimation for slot1 +for (l=1; lframe_parms.symbols_per_tti>>1; l++) +{ + if(l == pilot0) + { + //wait until channel estimation for pilot0/slot1 is available + uint32_t wait = 0; + while(proc->chan_est_pilot0_slot1_available == 0) + { + wait++; + } + } + LOG_I(PHY,"ChanEst symbol %d slot %d\n",l,slot1); + front_end_chanEst(ue, + l, + slot1, + 0); + ue_measurement_procedures(l-1,ue,proc,eNB_id,1+(subframe_rx<<1),abstraction_flag,mode); +} +LOG_I(PHY,"ChanEst symbol %d slot %d\n",0,next_subframe_slot0); +front_end_chanEst(ue, + pilot0, + next_subframe_slot0, + 0); + +if ( (subframe_rx == 0) && (ue->decode_MIB == 1)) +{ + ue_pbch_procedures(eNB_id,ue,proc,abstraction_flag); +} +#endif + +stop_meas(&ue->generic_stat); +//printf("------Front-End PROC [SFN %d]: %5.2f ------\n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); +/**** End Subframe FFT-ChannelEst ****/ + + +/**** Pdsch Procedure Slot0 + Slot1 ****/ +// start main thread for Pdsch Procedure (slot0) +// do procedures for C-RNTI +//LOG_I(PHY,"AbsSubframe %d.%d Pdsch Procedure (slot0)\n",frame_rx%1024,subframe_rx); +//LOG_I(PHY,"AbsSubframe %d.%d Pdsch Procedure PDSCH Active %d \n",frame_rx%1024,subframe_rx, ue->dlsch[subframe_rx&0x1][0][0]->active); + +start_meas(&ue->generic_stat); +if (ue->dlsch[subframe_rx&0x1][eNB_id][0]->active == 1) { + LOG_I(PHY,"AbsSubframe %d.%d Pdsch Procedure PDSCH \n",frame_rx%1024,subframe_rx); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); + ue_pdsch_procedures(ue, + proc, + eNB_id, + PDSCH, + ue->dlsch[subframe_rx&0x1][eNB_id][0], + NULL, + ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols, + ue->frame_parms.symbols_per_tti>>1, + abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); +} + +// do procedures for SI-RNTI +if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { + LOG_I(PHY,"AbsSubframe %d.%d Pdsch Procedure SI-PDSCH \n",frame_rx%1024,subframe_rx); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_IN); + ue_pdsch_procedures(ue, + proc, + eNB_id, + SI_PDSCH, + ue->dlsch_SI[eNB_id], + NULL, + ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols, + ue->frame_parms.symbols_per_tti>>1, + abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_OUT); +} + +// do procedures for SI-RNTI +if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { + LOG_I(PHY,"AbsSubframe %d.%d Pdsch Procedure P-PDSCH \n",frame_rx%1024,subframe_rx); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_IN); + ue_pdsch_procedures(ue, + proc, + eNB_id, + P_PDSCH, + ue->dlsch_p[eNB_id], + NULL, + ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols, + ue->frame_parms.symbols_per_tti>>1, + abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_OUT); +} + +// do procedures for RA-RNTI +if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { + LOG_I(PHY,"AbsSubframe %d.%d Pdsch Procedure RA-PDSCH \n",frame_rx%1024,subframe_rx); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_IN); + ue_pdsch_procedures(ue, + proc, + eNB_id, + RA_PDSCH, + ue->dlsch_ra[eNB_id], + NULL, + ue->pdcch_vars[subframe_rx & 0x1][eNB_id]->num_pdcch_symbols, + ue->frame_parms.symbols_per_tti>>1, + abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_OUT); +} + +stop_meas(&ue->generic_stat); +//printf("------LLR-Slot0 [SFN %d]: %5.2f ------\n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + +#if 1 +// start slave thread for Pdsch Procedure (slot1) +// do procedures for C-RNTI + +if (ue->dlsch[subframe_rx&0x1][eNB_id][0]->active == 1) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); + start_meas(&ue->pdsch_procedures_stat); + ue_pdsch_procedures(ue, + proc, + eNB_id, + PDSCH, + ue->dlsch[subframe_rx&0x1][eNB_id][0], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); + stop_meas(&ue->pdsch_procedures_stat); +} + +// do procedures for SI-RNTI +if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { + ue_pdsch_procedures(ue, + proc, + eNB_id, + SI_PDSCH, + ue->dlsch_SI[eNB_id], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); +} + +// do procedures for P-RNTI +if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { + ue_pdsch_procedures(ue, + proc, + eNB_id, + P_PDSCH, + ue->dlsch_p[eNB_id], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); +} +// do procedures for RA-RNTI +if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { + ue_pdsch_procedures(ue, + proc, + eNB_id, + RA_PDSCH, + ue->dlsch_ra[eNB_id], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); +} +proc->llr_slot1_available=1; +#endif + +start_meas(&ue->generic_stat); +// wait until llr on slot1 are available +uint32_t wait=0; +while(proc->llr_slot1_available==0) +{ + //wait until channel estimation for pilot0/slot1 is available + usleep(1); + wait++; +} +stop_meas(&ue->generic_stat); +//printf("------ Waiting for LLR-Slot1 [SFN %d]: %5.2f ------\n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + +LOG_I(PHY,"==> Start Turbo Decoder wait %d\n", wait); +// Start Turbo decoder +if (ue->dlsch[subframe_rx&0x1][eNB_id][0]->active == 1) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); + start_meas(&ue->dlsch_procedures_stat); + ue_dlsch_procedures(ue, + proc, + eNB_id, + PDSCH, + ue->dlsch[subframe_rx&0x1][eNB_id][0], + ue->dlsch[subframe_rx&0x1][eNB_id][1], + &ue->dlsch_errors[eNB_id], + mode, + abstraction_flag); + stop_meas(&ue->dlsch_procedures_stat); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); + } + + // do procedures for SI-RNTI + if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { + ue_dlsch_procedures(ue, + proc, + eNB_id, + SI_PDSCH, + ue->dlsch_SI[eNB_id], + NULL, + &ue->dlsch_SI_errors[eNB_id], + mode, + abstraction_flag); + ue->dlsch_SI[eNB_id]->active = 0; + } + + // do procedures for P-RNTI + if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { + ue_dlsch_procedures(ue, + proc, + eNB_id, + P_PDSCH, + ue->dlsch_p[eNB_id], + NULL, + &ue->dlsch_p_errors[eNB_id], + mode, + abstraction_flag); + ue->dlsch_p[eNB_id]->active = 0; + } + // do procedures for RA-RNTI + if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { + ue_dlsch_procedures(ue, + proc, + eNB_id, + RA_PDSCH, + ue->dlsch_ra[eNB_id], + NULL, + &ue->dlsch_ra_errors[eNB_id], + mode, + abstraction_flag); + ue->dlsch_ra[eNB_id]->active = 0; + } + //printf("------ Turbo Decoding [SFN %d]: %5.2f ------\n",subframe_rx,ue->dlsch_procedures_stat.p_time/(cpuf*1000.0)); + +/**** End Pdsch processing for this subframe ****/ + +if (subframe_rx==9) { + if (frame_rx % 10 == 0) { + if ((ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]) != 0) + ue->dlsch_fer[eNB_id] = (100*(ue->dlsch_errors[eNB_id] - ue->dlsch_errors_last[eNB_id]))/(ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]); + + ue->dlsch_errors_last[eNB_id] = ue->dlsch_errors[eNB_id]; + ue->dlsch_received_last[eNB_id] = ue->dlsch_received[eNB_id]; + } + + + ue->bitrate[eNB_id] = (ue->total_TBS[eNB_id] - ue->total_TBS_last[eNB_id])*100; + ue->total_TBS_last[eNB_id] = ue->total_TBS[eNB_id]; + LOG_D(PHY,"[UE %d] Calculating bitrate Frame %d: total_TBS = %d, total_TBS_last = %d, bitrate %f kbits\n", + ue->Mod_id,frame_rx,ue->total_TBS[eNB_id], + ue->total_TBS_last[eNB_id],(float) ue->bitrate[eNB_id]/1000.0); + +#if UE_AUTOTEST_TRACE + if ((frame_rx % 100 == 0)) { + LOG_I(PHY,"[UE %d] AUTOTEST Metric : UE_DLSCH_BITRATE = %5.2f kbps (frame = %d) \n", ue->Mod_id, (float) ue->bitrate[eNB_id]/1000.0, frame_rx); + } +#endif + +} + +//printf("after tubo until end of Rx %5.2f \n",ue->generic_stat.p_time/(cpuf*1000.0)); + +#ifdef EMOS +phy_procedures_emos_UE_RX(ue,slot,eNB_id); +#endif + +VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); +stop_meas(&ue->phy_proc_rx[subframe_rx&0x1]); + + +//printf("------FULL RX PROC [SFN %d]: %5.2f ------\n",subframe_rx,ue->phy_proc_rx[subframe_rx&0x1].p_time/(cpuf*1000.0)); +LOG_I(PHY," ****** end RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx); + +return (0); +} #if defined(Rel10) || defined(Rel14) int phy_procedures_RN_UE_RX(uint8_t slot_rx, uint8_t next_slot, relaying_type_t r_type) -- GitLab From 0b332b55363e963bc06af974b41a9ddc659035b0 Mon Sep 17 00:00:00 2001 From: tct-labo4 Date: Tue, 27 Jun 2017 17:03:16 +0200 Subject: [PATCH 5/7] rebase from 2017.w25 part2 --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 31 +++++++----- openair1/SCHED/phy_procedures_lte_ue.c | 70 +++++++++++++++++++------- 2 files changed, 70 insertions(+), 31 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index c39518690d..25cfa33190 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -5150,7 +5150,7 @@ void compute_llr_offset(LTE_DL_FRAME_PARMS *frame_parms, pdsch_vars->llr_offset[pdcch_vars->num_pdcch_symbols] = 0; - LOG_I(PHY,"compute_llr_offset: nb RB %d - Qm %d \n", nb_rb_alloc, dlsch0_harq->Qm); + //LOG_I(PHY,"compute_llr_offset: nb RB %d - Qm %d \n", nb_rb_alloc, dlsch0_harq->Qm); //dlsch0_harq->rb_alloc_even; //dlsch0_harq->rb_alloc_odd; @@ -5180,15 +5180,15 @@ void compute_llr_offset(LTE_DL_FRAME_PARMS *frame_parms, if(symbol < (frame_parms->symbols_per_tti-1)) pdsch_vars->llr_offset[symbol+1] = pdsch_vars->llr_offset[symbol] + llr_offset; - LOG_I(PHY,"Granted Re subframe %d / symbol %d => %d (%d RBs)\n", subframe, symbol_mod, granted_re,dlsch0_harq->nb_rb); - LOG_I(PHY,"Pbch/PSS/SSS Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, pbch_pss_sss_re); - LOG_I(PHY,"CRS Re Per PRB subframe %d / symbol %d => %d \n", subframe, symbol_mod, crs_re); - LOG_I(PHY,"Data Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, data_re); + //LOG_I(PHY,"Granted Re subframe %d / symbol %d => %d (%d RBs)\n", subframe, symbol_mod, granted_re,dlsch0_harq->nb_rb); + //LOG_I(PHY,"Pbch/PSS/SSS Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, pbch_pss_sss_re); + //LOG_I(PHY,"CRS Re Per PRB subframe %d / symbol %d => %d \n", subframe, symbol_mod, crs_re); + //LOG_I(PHY,"Data Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, data_re); - LOG_I(PHY,"Data Re subframe %d-symbol %d => llr length %d, llr offset %d \n", subframe, symbol, - pdsch_vars->llr_length[symbol], pdsch_vars->llr_offset[symbol]); + //LOG_I(PHY,"Data Re subframe %d-symbol %d => llr length %d, llr offset %d \n", subframe, symbol, + // pdsch_vars->llr_length[symbol], pdsch_vars->llr_offset[symbol]); } } void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, @@ -6114,12 +6114,15 @@ int generate_ue_dlsch_params_from_dci(int frame, &dci_info_extarcted, dlsch0_harq); if(status == 0) + { + printf("bad DCI 1A !!! \n"); return(-1); + } // dci is correct ==> update internal structure and prepare dl decoding -#ifdef DEBUG_DCI +//#ifdef DEBUG_DCI LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d prepare dl decoding \n", frame, subframe); -#endif +//#endif prepare_dl_decoding_format1_1A(format1A, frame_parms->N_RB_DL, &dci_info_extarcted, @@ -6219,12 +6222,16 @@ int generate_ue_dlsch_params_from_dci(int frame, &dci_info_extarcted, dlsch0_harq); if(status == 0) - return(-1); + { + printf("bad DCI 1 !!! \n"); + return(-1); + } + // dci is correct ==> update internal structure and prepare dl decoding -#ifdef DEBUG_DCI +//#ifdef DEBUG_DCI LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d prepare dl decoding \n", frame, subframe); -#endif +//#endif prepare_dl_decoding_format1_1A(format1, frame_parms->N_RB_DL, &dci_info_extarcted, diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index 71f244a04f..d0431a9545 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -3174,7 +3174,7 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint (dci_alloc_rx[i].rnti == ue->pdcch_vars[subframe_rx%RX_NB_TH][eNB_id]->crnti) && (dci_alloc_rx[i].format != format0)) { - LOG_D(PHY,"[UE %d][DCI][PDSCH %x] AbsSubframe %d.%d: format %d, num_pdcch_symbols %d, nCCE %d, total CCEs %d\n", + LOG_I(PHY,"[UE %d][DCI][PDSCH %x] AbsSubframe %d.%d: format %d, num_pdcch_symbols %d, nCCE %d, total CCEs %d\n", ue->Mod_id,dci_alloc_rx[i].rnti, frame_rx%1024,subframe_rx, dci_alloc_rx[i].format, @@ -3249,9 +3249,9 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint else if ((dci_alloc_rx[i].rnti == SI_RNTI) && ((dci_alloc_rx[i].format == format1A) || (dci_alloc_rx[i].format == format1C))) { -#ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[UE %d] subframe %d: Found rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); -#endif +//#ifdef DEBUG_PHY_PROC + LOG_I(PHY,"[UE %d] subframe %d: Found rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); +//#endif if (generate_ue_dlsch_params_from_dci(frame_rx, @@ -3273,7 +3273,7 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint ue->dlsch_SI_received[eNB_id]++; - LOG_D(PHY,"[UE %d] Frame %d, subframe %d : Generate UE DLSCH SI_RNTI format 1%s\n",ue->Mod_id,frame_rx,subframe_rx,dci_alloc_rx[i].format==format1A?"A":"C"); + LOG_I(PHY,"[UE %d] Frame %d, subframe %d : Generate UE DLSCH SI_RNTI format 1%s\n",ue->Mod_id,frame_rx,subframe_rx,dci_alloc_rx[i].format==format1A?"A":"C"); //dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); } @@ -3282,9 +3282,9 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint else if ((dci_alloc_rx[i].rnti == P_RNTI) && ((dci_alloc_rx[i].format == format1A) || (dci_alloc_rx[i].format == format1C))) { -#ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[UE %d] subframe %d: Found rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); -#endif +//#ifdef DEBUG_PHY_PROC + LOG_I(PHY,"[UE %d] subframe %d: Found rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); +//#endif if (generate_ue_dlsch_params_from_dci(frame_rx, @@ -3314,13 +3314,13 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint (dci_alloc_rx[i].rnti == ue->prach_resources[eNB_id]->ra_RNTI) && (dci_alloc_rx[i].format == format1A)) { -#ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[UE %d][RAPROC] subframe %d: Found RA rnti %x, format 1A, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,i); +//#ifdef DEBUG_PHY_PROC + LOG_I(PHY,"[UE %d][RAPROC] subframe %d: Found RA rnti %x, format 1A, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,i); //if (((frame_rx%100) == 0) || (frame_rx < 20)) //dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); //mac_xface->macphy_exit("so far so good...\n"); -#endif +//#endif if (generate_ue_dlsch_params_from_dci(frame_rx, @@ -4030,9 +4030,9 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, if (ret == (1+dlsch0->max_turbo_iterations)) { *dlsch_errors=*dlsch_errors+1; - if(dlsch0->rnti != 0xffff) + //if(dlsch0->rnti != 0xffff) { - LOG_D(PHY,"[UE %d][PDSCH %x/%d] AbsSubframe %d.%d : DLSCH CW0 in error (rv %d,round %d, mcs %d,TBS %d)\n", + LOG_I(PHY,"[UE %d][PDSCH %x/%d] AbsSubframe %d.%d : DLSCH CW0 in error (rv %d,round %d, mcs %d,TBS %d)\n", ue->Mod_id,dlsch0->rnti, harq_pid,frame_rx,subframe_rx, dlsch0->harq_processes[harq_pid]->rvidx, @@ -4043,9 +4043,9 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, } else { - if(dlsch0->rnti != 0xffff) + //if(dlsch0->rnti != 0xffff) { - LOG_D(PHY,"[UE %d][PDSCH %x/%d] AbsSubframe %d.%d : Received DLSCH CW0 (rv %d,round %d, mcs %d,TBS %d)\n", + LOG_I(PHY,"[UE %d][PDSCH %x/%d] AbsSubframe %d.%d : Received DLSCH CW0 (rv %d,round %d, mcs %d,TBS %d)\n", ue->Mod_id,dlsch0->rnti, harq_pid,frame_rx,subframe_rx, dlsch0->harq_processes[harq_pid]->rvidx, @@ -4317,20 +4317,24 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, start_meas(&ue->generic_stat); #endif // 1- perform FFT for pilot ofdm symbols first (ofdmSym7 ofdmSym4 or (ofdmSym6 ofdmSym3)) + LOG_I(PHY,"AbsSubframe %d.%d FFT slot1 symbol %d\n", frame_rx%1024, subframe_rx,pilot0); front_end_fft(ue, pilot0, slot1, 0, 0); + LOG_I(PHY,"AbsSubframe %d.%d FFT slot0 symbol %d\n", frame_rx%1024, subframe_rx,pilot1); front_end_fft(ue, pilot1, slot0, 0, 0); + LOG_I(PHY,"AbsSubframe %d.%d ChanEst slot0 symbol %d\n", frame_rx%1024, subframe_rx,pilot1); front_end_chanEst(ue, pilot1, slot0, 0); + LOG_I(PHY,"AbsSubframe %d.%d ChanEst slot1 symbol %d\n", frame_rx%1024, subframe_rx,pilot0); front_end_chanEst(ue, pilot0, slot1, @@ -4346,6 +4350,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, #if UE_TIMING_TRACE start_meas(&ue->ofdm_demod_stats); #endif + LOG_I(PHY,"AbsSubframe %d.%d FFT slot0 symbol %d\n", frame_rx%1024, subframe_rx,l); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); front_end_fft(ue, l, @@ -4364,6 +4369,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, { if( (l != pilot0) && (l != pilot1)) { + LOG_I(PHY,"AbsSubframe %d.%d ChanEst slot0 symbol %d\n", frame_rx%1024, subframe_rx,l); front_end_chanEst(ue, l, slot0, @@ -4373,7 +4379,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } if (do_pdcch_flag) { - LOG_D(PHY,"[UE %d] Frame %d: Calling pdcch procedures (eNB %d)\n",ue->Mod_id,frame_rx,eNB_id); + LOG_I(PHY,"[UE %d] Frame %d: Calling pdcch procedures (eNB %d)\n",ue->Mod_id,frame_rx,eNB_id); if (ue_pdcch_procedures(eNB_id,ue,proc,abstraction_flag) == -1) { LOG_E(PHY,"[UE %d] Frame %d, subframe %d: Error in pdcch procedures\n",ue->Mod_id,frame_rx,subframe_rx); @@ -4381,8 +4387,8 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } } - //LOG_I(PHY,"num_pdcch_symbols %d\n",ue->pdcch_vars[subframe_rx%RX_NB_TH][eNB_id]->num_pdcch_symbols); - //LOG_I(PHY,"Set available dci slot0 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); + LOG_I(PHY,"num_pdcch_symbols %d\n",ue->pdcch_vars[subframe_rx%RX_NB_TH][eNB_id]->num_pdcch_symbols); + LOG_I(PHY,"Set available dci slot0 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); proc->dci_slot0_available=1; // first slot has been processed (FFTs + Channel Estimation, PCFICH/PHICH/PDCCH) @@ -4413,6 +4419,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, // 1- perform FFT for pilot ofdm symbols first (ofdmSym0 next subframe ofdmSym11) if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) { + LOG_I(PHY,"AbsSubframe %d.%d FFT slot0 symbol %d\n", frame_rx%1024, subframe_rx,pilot0); front_end_fft(ue, pilot0, next_subframe_slot0, @@ -4420,6 +4427,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, 0); } + LOG_I(PHY,"AbsSubframe %d.%d FFT slot1 symbol %d\n", frame_rx%1024, subframe_rx,pilot1); front_end_fft(ue, pilot1, slot1, @@ -4434,6 +4442,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, #if UE_TIMING_TRACE start_meas(&ue->ofdm_demod_stats); #endif + LOG_I(PHY,"AbsSubframe %d.%d FFT slot1 symbol %d\n", frame_rx%1024, subframe_rx,l); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); front_end_fft(ue, l, @@ -4450,6 +4459,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, // 3- perform Channel Estimation for slot1 for (l=1; lframe_parms.symbols_per_tti>>1; l++) { +#if 0 if(l == pilot0) { //wait until channel estimation for pilot0/slot1 is available @@ -4459,12 +4469,15 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, wait++; } } +#endif + LOG_I(PHY,"AbsSubframe %d.%d ChanEst slot1 symbol %d\n", frame_rx%1024, subframe_rx,l); front_end_chanEst(ue, l, slot1, 0); ue_measurement_procedures(l-1,ue,proc,eNB_id,1+(subframe_rx<<1),abstraction_flag,mode); } + LOG_I(PHY,"AbsSubframe %d.%d ChanEst slot0 symbol %d\n", frame_rx%1024, subframe_rx,pilot0); front_end_chanEst(ue, pilot0, next_subframe_slot0, @@ -4498,6 +4511,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, start_meas(&ue->generic_stat); #endif if (ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->active == 1) { + LOG_I(PHY,"LLR Computation PDSCH slot0 \n"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, proc, @@ -4513,7 +4527,9 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } // do procedures for SI-RNTI + LOG_I(PHY,"LLR Computation SI_PDSCH slot0 active %d \n", ue->dlsch_SI[eNB_id]->active); if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { + LOG_I(PHY,"LLR Computation SI_PDSCH slot0 \n"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, proc, @@ -4529,6 +4545,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, // do procedures for SI-RNTI if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { + LOG_I(PHY,"LLR Computation P_PDSCH slot0 \n"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, proc, @@ -4544,6 +4561,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, // do procedures for RA-RNTI if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { + LOG_I(PHY,"LLR Computation RA_PDSCH slot0 \n"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, proc, @@ -4573,6 +4591,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, // start slave thread for Pdsch Procedure (slot1) // do procedures for C-RNTI if (ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->active == 1) { + LOG_I(PHY,"LLR Computation PDSCH slot1 \n"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); #if UE_TIMING_TRACE start_meas(&ue->pdsch_procedures_stat); @@ -4594,7 +4613,9 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } // do procedures for SI-RNTI + LOG_I(PHY,"LLR Computation SI_PDSCH slot1 active %d \n",ue->dlsch_SI[eNB_id]->active); if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { + LOG_I(PHY,"LLR Computation SI_PDSCH slot1 \n"); ue_pdsch_procedures(ue, proc, eNB_id, @@ -4608,6 +4629,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, // do procedures for P-RNTI if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { + LOG_I(PHY,"LLR Computation P_PDSCH slot1 \n"); ue_pdsch_procedures(ue, proc, eNB_id, @@ -4620,6 +4642,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } // do procedures for RA-RNTI if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { + LOG_I(PHY,"LLR Computation RA_PDSCH slot1 \n"); ue_pdsch_procedures(ue, proc, eNB_id, @@ -4667,6 +4690,8 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, #if UE_TIMING_TRACE start_meas(&ue->generic_stat); #endif + +#if 0 // wait until llr on slot1 are available uint32_t wait=0; while(proc->llr_slot1_available==0) @@ -4675,10 +4700,16 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, usleep(1); wait++; } +#if UE_TIMING_TRACE stop_meas(&ue->generic_stat); +#endif +#endif //printf("------ Waiting for LLR-Slot1 [SFN %d]: %5.2f ------\n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); - LOG_I(PHY,"==> Start Turbo Decoder wait %d\n", wait); + LOG_I(PHY,"==> Start Turbo Decoder active dlsch %d SI %d RA %d \n",ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->active, + ue->dlsch_SI[eNB_id]->active, + //ue->dlsch_p[eNB_id]->active, + ue->dlsch_ra[eNB_id]->active); // Start Turbo decoder if (ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->active == 1) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); @@ -4710,6 +4741,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } // do procedures for SI-RNTI + printf("dlsch procedures SI %d \n", ue->dlsch_SI[eNB_id]->active); if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { ue_dlsch_procedures(ue, proc, -- GitLab From bf7eb25cf58410fb4d8eea410cf96c54e2fb8fb0 Mon Sep 17 00:00:00 2001 From: tct-labo4 Date: Wed, 28 Jun 2017 12:15:25 +0200 Subject: [PATCH 6/7] [OAI-UE] timing measurements for slot0/slot1 parallelization --- openair1/PHY/defs.h | 14 +- openair1/PHY/impl_defs_lte.h | 2 + openair1/SCHED/phy_procedures_lte_ue.c | 183 +++++++++++++------------ 3 files changed, 108 insertions(+), 91 deletions(-) diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index df5fd25c23..4e16c26bda 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -894,9 +894,9 @@ typedef struct { /// Transmission mode per eNB uint8_t transmission_mode[NUMBER_OF_CONNECTED_eNB_MAX]; - time_stats_t phy_proc; + time_stats_t phy_proc[RX_NB_TH]; time_stats_t phy_proc_tx; - time_stats_t phy_proc_rx[2]; + time_stats_t phy_proc_rx[RX_NB_TH]; uint32_t use_ia_receiver; @@ -910,8 +910,12 @@ typedef struct { time_stats_t ulsch_multiplexing_stats; time_stats_t generic_stat; - time_stats_t pdsch_procedures_stat; - time_stats_t dlsch_procedures_stat; + time_stats_t ue_front_end_stat[RX_NB_TH]; + time_stats_t ue_front_end_per_slot_stat[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; + time_stats_t pdcch_procedures_stat[RX_NB_TH]; + time_stats_t pdsch_procedures_stat[RX_NB_TH]; + time_stats_t pdsch_procedures_per_slot_stat[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; + time_stats_t dlsch_procedures_stat[RX_NB_TH]; time_stats_t ofdm_demod_stats; time_stats_t dlsch_rx_pdcch_stats; @@ -923,7 +927,7 @@ typedef struct { time_stats_t dlsch_rate_unmatching_stats; time_stats_t dlsch_turbo_decoding_stats; time_stats_t dlsch_deinterleaving_stats; - time_stats_t dlsch_llr_stats; + time_stats_t dlsch_llr_stats[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; time_stats_t dlsch_unscrambling_stats; time_stats_t dlsch_rate_matching_stats; time_stats_t dlsch_turbo_encoding_stats; diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h index b3e9089163..edc97057ce 100644 --- a/openair1/PHY/impl_defs_lte.h +++ b/openair1/PHY/impl_defs_lte.h @@ -40,6 +40,8 @@ #define RX_NB_TH_MAX 2 #define RX_NB_TH 2 +#define LTE_SLOTS_PER_SUBFRAME 2 + #define LTE_NUMBER_OF_SUBFRAMES_PER_FRAME 10 #define LTE_SLOTS_PER_FRAME 20 #define LTE_CE_FILTER_LENGTH 5 diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index d0431a9545..e183e0bf37 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -3686,7 +3686,10 @@ void ue_pdsch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, int eNB_id, PDSC else first_symbol_flag = 0; #if UE_TIMING_TRACE - start_meas(&ue->dlsch_llr_stats); + uint8_t slot = 0; + if(m >= ue->frame_parms.symbols_per_tti>>1) + slot = 1; + start_meas(&ue->dlsch_llr_stats[subframe_rx%RX_NB_TH][slot]); #endif // process DLSCH received in first slot rx_pdsch(ue, @@ -3702,8 +3705,14 @@ void ue_pdsch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, int eNB_id, PDSC i_mod, dlsch0->current_harq_pid); #if UE_TIMING_TRACE - stop_meas(&ue->dlsch_llr_stats); + stop_meas(&ue->dlsch_llr_stats[subframe_rx%RX_NB_TH][slot]); +//#if DISABLE_LOG_X +// printf("[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",proc->frame_rx,subframe_rx,m,ue->dlsch_llr_stats[subframe_rx%RX_NB_TH][slot].p_time/(cpuf*1000.0)); +//#else +// LOG_D(PHY, "[AbsSFN %d.%d] LLR Computation Symbol %d %5.2fn %5.2f \n",proc->frame_rx,subframe_rx,m,ue->dlsch_llr_stats[subframe_rx%RX_NB_TH][slot].p_time/(cpuf*1000.0)); +//#endif #endif + } // CRNTI active } } @@ -4226,7 +4235,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, #if UE_TIMING_TRACE start_meas(&ue->phy_proc_rx[subframe_rx%RX_NB_TH]); - start_meas(&ue->generic_stat); + start_meas(&ue->ue_front_end_stat[subframe_rx%RX_NB_TH]); #endif pmch_flag = is_pmch_subframe(frame_rx,subframe_rx,&ue->frame_parms) ? 1 : 0; @@ -4314,27 +4323,23 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, /**** FFT Slot0 + Slot1 ****/ // I- start main thread for FFT/ChanEst symbol: 0/1 --> 7 #if UE_TIMING_TRACE - start_meas(&ue->generic_stat); + start_meas(&ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][0]); #endif // 1- perform FFT for pilot ofdm symbols first (ofdmSym7 ofdmSym4 or (ofdmSym6 ofdmSym3)) - LOG_I(PHY,"AbsSubframe %d.%d FFT slot1 symbol %d\n", frame_rx%1024, subframe_rx,pilot0); front_end_fft(ue, pilot0, slot1, 0, 0); - LOG_I(PHY,"AbsSubframe %d.%d FFT slot0 symbol %d\n", frame_rx%1024, subframe_rx,pilot1); front_end_fft(ue, pilot1, slot0, 0, 0); - LOG_I(PHY,"AbsSubframe %d.%d ChanEst slot0 symbol %d\n", frame_rx%1024, subframe_rx,pilot1); front_end_chanEst(ue, pilot1, slot0, 0); - LOG_I(PHY,"AbsSubframe %d.%d ChanEst slot1 symbol %d\n", frame_rx%1024, subframe_rx,pilot0); front_end_chanEst(ue, pilot0, slot1, @@ -4350,7 +4355,6 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, #if UE_TIMING_TRACE start_meas(&ue->ofdm_demod_stats); #endif - LOG_I(PHY,"AbsSubframe %d.%d FFT slot0 symbol %d\n", frame_rx%1024, subframe_rx,l); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); front_end_fft(ue, l, @@ -4369,7 +4373,6 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, { if( (l != pilot0) && (l != pilot1)) { - LOG_I(PHY,"AbsSubframe %d.%d ChanEst slot0 symbol %d\n", frame_rx%1024, subframe_rx,l); front_end_chanEst(ue, l, slot0, @@ -4379,25 +4382,42 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } if (do_pdcch_flag) { - LOG_I(PHY,"[UE %d] Frame %d: Calling pdcch procedures (eNB %d)\n",ue->Mod_id,frame_rx,eNB_id); - +#if UE_TIMING_TRACE + start_meas(&ue->pdcch_procedures_stat[subframe_rx%RX_NB_TH]); +#endif if (ue_pdcch_procedures(eNB_id,ue,proc,abstraction_flag) == -1) { LOG_E(PHY,"[UE %d] Frame %d, subframe %d: Error in pdcch procedures\n",ue->Mod_id,frame_rx,subframe_rx); +#if UE_TIMING_TRACE + stop_meas(&ue->pdcch_procedures_stat[subframe_rx%RX_NB_TH]); +#if DISABLE_LOG_X + printf("[AbsSFN %d.%d] Slot0: PDCCH %5.2f \n",frame_rx,subframe_rx,ue->pdcch_procedures_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); +#else + LOG_D(PHY, "[AbsSFN %d.%d] Slot0: PDCCH %5.2f \n",frame_rx,subframe_rx,ue->pdcch_procedures_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); +#endif +#endif return(-1); } +#if UE_TIMING_TRACE + stop_meas(&ue->pdcch_procedures_stat[subframe_rx%RX_NB_TH]); +#if DISABLE_LOG_X + printf("[AbsSFN %d.%d] Slot0: PDCCH %5.2f \n",frame_rx,subframe_rx,ue->pdcch_procedures_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); +#else + LOG_D(PHY, "[AbsSFN %d.%d] Slot0: PDCCH %5.2f \n",frame_rx,subframe_rx,ue->pdcch_procedures_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); +#endif +#endif } - LOG_I(PHY,"num_pdcch_symbols %d\n",ue->pdcch_vars[subframe_rx%RX_NB_TH][eNB_id]->num_pdcch_symbols); - LOG_I(PHY,"Set available dci slot0 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); + //LOG_I(PHY,"num_pdcch_symbols %d\n",ue->pdcch_vars[subframe_rx%RX_NB_TH][eNB_id]->num_pdcch_symbols); + //LOG_I(PHY,"Set available dci slot0 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); proc->dci_slot0_available=1; // first slot has been processed (FFTs + Channel Estimation, PCFICH/PHICH/PDCCH) #if UE_TIMING_TRACE - stop_meas(&ue->generic_stat); + stop_meas(&ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][0]); #if DISABLE_LOG_X - printf("[SFN %d] Slot0: FFT + Channel Estimate + PCFICH/PHICH/PDCCH %5.2f \n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + printf("[AbsSFN %d.%d] Slot0: FFT + Channel Estimate + PCFICH/PHICH/PDCCH %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][0].p_time/(cpuf*1000.0)); #else - LOG_D(PHY, "[SFN %d] Slot0: FFT + Channel Estimate + PCFICH/PHICH/PDCCH %5.2f \n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] Slot0: FFT + Channel Estimate + PCFICH/PHICH/PDCCH %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][0].p_time/(cpuf*1000.0)); #endif #endif @@ -4410,7 +4430,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, #if 1 #if UE_TIMING_TRACE - start_meas(&ue->generic_stat); + start_meas(&ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][1]); #endif // II- start slave thread for FFT/ChanEst // do first symbol of next downlink subframe for channel estimation @@ -4419,7 +4439,6 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, // 1- perform FFT for pilot ofdm symbols first (ofdmSym0 next subframe ofdmSym11) if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) { - LOG_I(PHY,"AbsSubframe %d.%d FFT slot0 symbol %d\n", frame_rx%1024, subframe_rx,pilot0); front_end_fft(ue, pilot0, next_subframe_slot0, @@ -4427,7 +4446,6 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, 0); } - LOG_I(PHY,"AbsSubframe %d.%d FFT slot1 symbol %d\n", frame_rx%1024, subframe_rx,pilot1); front_end_fft(ue, pilot1, slot1, @@ -4442,7 +4460,6 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, #if UE_TIMING_TRACE start_meas(&ue->ofdm_demod_stats); #endif - LOG_I(PHY,"AbsSubframe %d.%d FFT slot1 symbol %d\n", frame_rx%1024, subframe_rx,l); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); front_end_fft(ue, l, @@ -4470,14 +4487,12 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } } #endif - LOG_I(PHY,"AbsSubframe %d.%d ChanEst slot1 symbol %d\n", frame_rx%1024, subframe_rx,l); front_end_chanEst(ue, l, slot1, 0); ue_measurement_procedures(l-1,ue,proc,eNB_id,1+(subframe_rx<<1),abstraction_flag,mode); } - LOG_I(PHY,"AbsSubframe %d.%d ChanEst slot0 symbol %d\n", frame_rx%1024, subframe_rx,pilot0); front_end_chanEst(ue, pilot0, next_subframe_slot0, @@ -4489,14 +4504,23 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } #if UE_TIMING_TRACE - stop_meas(&ue->generic_stat); + stop_meas(&ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][1]); #if DISABLE_LOG_X - printf("[SFN %d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + printf("[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][1].p_time/(cpuf*1000.0)); #else - LOG_D(PHY, "[SFN %d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][1].p_time/(cpuf*1000.0)); #endif #endif +#endif + +#if UE_TIMING_TRACE + stop_meas(&ue->ue_front_end_stat[subframe_rx%RX_NB_TH]); +#if DISABLE_LOG_X + printf("[AbsSFN %d.%d] Full Front End Processing %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); +#else + LOG_D(PHY, "[AbsSFN %d.%d] Full Front End Processing %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); +#endif #endif /**** End Subframe FFT-ChannelEst ****/ @@ -4508,10 +4532,13 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, //LOG_I(PHY,"AbsSubframe %d.%d Pdsch Procedure PDSCH Active %d \n",frame_rx%1024,subframe_rx, ue->dlsch[subframe_rx%RX_NB_TH][0][0]->active); #if UE_TIMING_TRACE - start_meas(&ue->generic_stat); + start_meas(&ue->pdsch_procedures_stat[subframe_rx%RX_NB_TH]); +#endif + +#if UE_TIMING_TRACE + start_meas(&ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][0]); #endif if (ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->active == 1) { - LOG_I(PHY,"LLR Computation PDSCH slot0 \n"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, proc, @@ -4527,9 +4554,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } // do procedures for SI-RNTI - LOG_I(PHY,"LLR Computation SI_PDSCH slot0 active %d \n", ue->dlsch_SI[eNB_id]->active); if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { - LOG_I(PHY,"LLR Computation SI_PDSCH slot0 \n"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, proc, @@ -4545,7 +4570,6 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, // do procedures for SI-RNTI if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { - LOG_I(PHY,"LLR Computation P_PDSCH slot0 \n"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, proc, @@ -4561,7 +4585,6 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, // do procedures for RA-RNTI if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { - LOG_I(PHY,"LLR Computation RA_PDSCH slot0 \n"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, proc, @@ -4576,26 +4599,22 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } #if UE_TIMING_TRACE - stop_meas(&ue->generic_stat); + stop_meas(&ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][0]); #if DISABLE_LOG_X - printf("[SFN %d] Slot0: LLR Computation %5.2f \n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + printf("[AbsSFN %d.%d] Slot0: LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][0].p_time/(cpuf*1000.0)); #else - LOG_D(PHY, "[SFN %d] Slot0: LLR Computation %5.2f \n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] Slot0: LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][0].p_time/(cpuf*1000.0)); #endif #endif #if 1 #if UE_TIMING_TRACE - start_meas(&ue->generic_stat); + start_meas(&ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][1]); #endif // start slave thread for Pdsch Procedure (slot1) // do procedures for C-RNTI if (ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->active == 1) { - LOG_I(PHY,"LLR Computation PDSCH slot1 \n"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); -#if UE_TIMING_TRACE - start_meas(&ue->pdsch_procedures_stat); -#endif ue_pdsch_procedures(ue, proc, eNB_id, @@ -4607,15 +4626,10 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, abstraction_flag); LOG_D(PHY," ------ end PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); LOG_D(PHY," ------ --> PDSCH Turbo Decoder slot 0/1: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); -#if UE_TIMING_TRACE - stop_meas(&ue->pdsch_procedures_stat); -#endif } // do procedures for SI-RNTI - LOG_I(PHY,"LLR Computation SI_PDSCH slot1 active %d \n",ue->dlsch_SI[eNB_id]->active); if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { - LOG_I(PHY,"LLR Computation SI_PDSCH slot1 \n"); ue_pdsch_procedures(ue, proc, eNB_id, @@ -4629,7 +4643,6 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, // do procedures for P-RNTI if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { - LOG_I(PHY,"LLR Computation P_PDSCH slot1 \n"); ue_pdsch_procedures(ue, proc, eNB_id, @@ -4642,7 +4655,6 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } // do procedures for RA-RNTI if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { - LOG_I(PHY,"LLR Computation RA_PDSCH slot1 \n"); ue_pdsch_procedures(ue, proc, eNB_id, @@ -4655,17 +4667,26 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } proc->llr_slot1_available=1; #if UE_TIMING_TRACE - stop_meas(&ue->generic_stat); + stop_meas(&ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][1]); #if DISABLE_LOG_X - printf("[SFN %d] Slot1: LLR Computation %5.2f \n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + printf("[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][1].p_time/(cpuf*1000.0)); #else - LOG_D(PHY, "[SFN %d] Slot1: LLR Computation %5.2f \n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][1].p_time/(cpuf*1000.0)); #endif #endif #endif +#if UE_TIMING_TRACE + stop_meas(&ue->pdsch_procedures_stat[subframe_rx%RX_NB_TH]); +#if DISABLE_LOG_X + printf("[AbsSFN %d.%d] Full LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); +#else + LOG_D(PHY, "[AbsSFN %d.%d] Full LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); +#endif +#endif + #if 0 if(subframe_rx==5 && ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->harq_processes[ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->current_harq_pid]->nb_rb > 20){ //write_output("decoder_llr.m","decllr",dlsch_llr,G,1,0); @@ -4688,7 +4709,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, //=====================================================================// #if UE_TIMING_TRACE - start_meas(&ue->generic_stat); + start_meas(&ue->dlsch_procedures_stat[subframe_rx%RX_NB_TH]); #endif #if 0 @@ -4700,9 +4721,6 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, usleep(1); wait++; } -#if UE_TIMING_TRACE - stop_meas(&ue->generic_stat); -#endif #endif //printf("------ Waiting for LLR-Slot1 [SFN %d]: %5.2f ------\n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); @@ -4713,9 +4731,6 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, // Start Turbo decoder if (ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->active == 1) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); -#if UE_TIMING_TRACE - start_meas(&ue->dlsch_procedures_stat); -#endif ue_dlsch_procedures(ue, proc, eNB_id, @@ -4725,23 +4740,10 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, &ue->dlsch_errors[eNB_id], mode, abstraction_flag); -#if UE_TIMING_TRACE - stop_meas(&ue->dlsch_procedures_stat); -#if DISABLE_LOG_X - printf("[SFN %d] Slot1: Pdsch Proc %5.2f\n",subframe_rx,ue->pdsch_procedures_stat.p_time/(cpuf*1000.0)); - printf("[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",subframe_rx,ue->dlsch_procedures_stat.p_time/(cpuf*1000.0)); -#else - LOG_D(PHY, "[SFN %d] Slot1: Pdsch Proc %5.2f\n",subframe_rx,ue->pdsch_procedures_stat.p_time/(cpuf*1000.0)); - LOG_D(PHY, "[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",subframe_rx,ue->dlsch_procedures_stat.p_time/(cpuf*1000.0)); -#endif - -#endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); } // do procedures for SI-RNTI - printf("dlsch procedures SI %d \n", ue->dlsch_SI[eNB_id]->active); if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { ue_dlsch_procedures(ue, proc, @@ -4781,18 +4783,32 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, abstraction_flag); ue->dlsch_ra[eNB_id]->active = 0; } + #if UE_TIMING_TRACE - stop_meas(&ue->generic_stat); + stop_meas(&ue->dlsch_procedures_stat[subframe_rx%RX_NB_TH]); #if DISABLE_LOG_X - printf("[SFN %d] Channel Decoder: %5.2f \n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + printf("[AbsSFN %d.%d] Channel Decoder: %5.2f \n",frame_rx,subframe_rx,ue->dlsch_procedures_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); #else - LOG_D(PHY, "[SFN %d] Channel Decoder: %5.2f %5.2f \n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] Channel Decoder: %5.2f \n",frame_rx,subframe_rx,ue->dlsch_procedures_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); #endif + #endif - // duplicate harq structure - uint8_t current_harq_pid = ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->current_harq_pid; - LTE_DL_UE_HARQ_t *current_harq_processes = ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->harq_processes[current_harq_pid]; + // duplicate harq structure + uint8_t current_harq_pid = ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->current_harq_pid; + LTE_DL_UE_HARQ_t *current_harq_processes = ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->harq_processes[current_harq_pid]; + harq_status_t *current_harq_ack = &ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->harq_ack[subframe_rx]; + + for(uint8_t rx_th_idx=0; rx_th_idxdlsch[(subframe_rx+rx_th_idx)%RX_NB_TH][eNB_id][0]->harq_processes[current_harq_pid]; + harq_status_t *harq_ack_dest = &ue->dlsch[(subframe_rx+rx_th_idx)%RX_NB_TH][eNB_id][0]->harq_ack[subframe_rx]; + + copy_harq_proc_struct(harq_processes_dest, current_harq_processes); + copy_ack_struct(harq_ack_dest, current_harq_ack); + + } + /* LTE_DL_UE_HARQ_t *harq_processes_dest = ue->dlsch[(subframe_rx+1)%RX_NB_TH][eNB_id][0]->harq_processes[current_harq_pid]; LTE_DL_UE_HARQ_t *harq_processes_dest1 = ue->dlsch[(subframe_rx+2)%RX_NB_TH][eNB_id][0]->harq_processes[current_harq_pid]; @@ -4805,7 +4821,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, copy_harq_proc_struct(harq_processes_dest1, current_harq_processes); copy_ack_struct(harq_ack_dest1, current_harq_ack); - + */ if (subframe_rx==9) { if (frame_rx % 10 == 0) { if ((ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]) != 0) @@ -4830,11 +4846,6 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } -#if UE_TIMING_TRACE - stop_meas(&ue->generic_stat); - printf("after tubo until end of Rx %5.2f \n",ue->generic_stat.p_time/(cpuf*1000.0)); -#endif - #ifdef EMOS phy_procedures_emos_UE_RX(ue,slot,eNB_id); #endif @@ -4845,9 +4856,9 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, #if UE_TIMING_TRACE stop_meas(&ue->phy_proc_rx[subframe_rx%RX_NB_TH]); #if DISABLE_LOG_X - printf("------FULL RX PROC [SFN %d]: %5.2f ------\n",subframe_rx,ue->phy_proc_rx[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); + printf("------FULL RX PROC [AbsSFN %d.%d]: %5.2f ------\n",frame_rx,subframe_rx,ue->phy_proc_rx[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); #else - LOG_D(PHY, "------FULL RX PROC [SFN %d]: %5.2f ------\n",subframe_rx,ue->phy_proc_rx[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); + LOG_D(PHY, "------FULL RX PROC [AbsSFN %d.%d]: %5.2f ------\n",frame_rx,subframe_rx,ue->phy_proc_rx[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); #endif #endif @@ -5391,7 +5402,7 @@ void phy_procedures_UE_lte(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,u VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_LTE,1); #if UE_TIMING_TRACE - start_meas(&ue->phy_proc); + start_meas(&ue->phy_proc[subframe_rx%RX_NB_TH]); #endif #if defined(ENABLE_ITTI) @@ -5485,7 +5496,7 @@ void phy_procedures_UE_lte(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,u VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_LTE,0); #if UE_TIMING_TRACE - stop_meas(&ue->phy_proc); + stop_meas(&ue->phy_proc[subframe_rx%RX_NB_TH]); #endif } // slot } -- GitLab From ed145f57990cc2671693bd469694a29cda941968 Mon Sep 17 00:00:00 2001 From: tct-labo4 Date: Mon, 17 Jul 2017 15:11:40 +0200 Subject: [PATCH 7/7] [OAI-UE] slot0/1 parallelization part2 --- .../PHY/LTE_TRANSPORT/dlsch_demodulation.c | 99 ++- openair1/PHY/LTE_TRANSPORT/initial_sync.c | 18 +- openair1/PHY/defs.h | 18 +- openair1/SCHED/defs.h | 6 +- openair1/SCHED/phy_procedures_lte_ue.c | 686 +++++++++++------- targets/COMMON/threads_t.h | 3 + targets/RT/USER/lte-softmodem.c | 17 +- targets/RT/USER/lte-softmodem.h | 1 + targets/RT/USER/lte-ue.c | 275 +------ targets/SIMU/USER/oaisim.c | 2 +- 10 files changed, 564 insertions(+), 561 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c index ffc8d0405e..74caa92f9c 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c @@ -112,10 +112,12 @@ int rx_pdsch(PHY_VARS_UE *ue, int avg_0[2]; int avg_1[2]; + uint8_t slot = 0; + unsigned char aatx,aarx; unsigned short nb_rb = 0, round; - int avgs, rb; + int avgs = 0, rb; LTE_DL_UE_HARQ_t *dlsch0_harq,*dlsch1_harq = 0; uint8_t beamforming_mode; @@ -248,6 +250,11 @@ int rx_pdsch(PHY_VARS_UE *ue, return(-1); } } + + if(symbol > ue->frame_parms.symbols_per_tti>>1) + { + slot = 1; + } #ifdef DEBUG_HARQ printf("Demod dlsch0_harq->pmi_alloc %d\n", dlsch0_harq->pmi_alloc); #endif @@ -257,6 +264,9 @@ int rx_pdsch(PHY_VARS_UE *ue, LOG_I(PHY,"dlsch: using pmi %x (%p), rb_alloc %x\n",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc),dlsch[0],dlsch0_harq->rb_alloc_even[0]); #endif +#if UE_TIMING_TRACE + start_meas(&ue->generic_stat_bis[subframe%RX_NB_TH][slot]); +#endif nb_rb = dlsch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[subframe%RX_NB_TH].rxdataF, common_vars->common_vars_rx_data_per_thread[subframe%RX_NB_TH].dl_ch_estimates[eNB_id], pdsch_vars[eNB_id]->rxdataF_ext, @@ -364,12 +374,20 @@ int rx_pdsch(PHY_VARS_UE *ue, return(-1); } - -#ifdef DEBUG_PHY - LOG_D(PHY,"[DLSCH] nb_rb %d log2_maxh = %d (%d,%d)\n",nb_rb,pdsch_vars[eNB_id]->log2_maxh,avg[0],avgs); - LOG_D(PHY,"[DLSCH] mimo_mode = %d\n", dlsch0_harq->mimo_mode); +#if UE_TIMING_TRACE + stop_meas(&ue->generic_stat_bis[subframe%RX_NB_TH][slot]); +#if DISABLE_LOG_X + printf("[AbsSFN %d.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n",frame,subframe,slot, + symbol,ue->high_speed_flag,type,symbol,ue->generic_stat_bis[subframe%RX_NB_TH][slot].p_time/(cpuf*1000.0)); +#else + LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n",frame,subframe,slot,symbol, + ue->high_speed_flag,type,ue->generic_stat_bis[subframe%RX_NB_TH][slot].p_time/(cpuf*1000.0)); +#endif #endif +#if UE_TIMING_TRACE + start_meas(&ue->generic_stat_bis[subframe%RX_NB_TH][slot]); +#endif aatx = frame_parms->nb_antenna_ports_eNB; aarx = frame_parms->nb_antennas_rx; @@ -392,6 +410,18 @@ int rx_pdsch(PHY_VARS_UE *ue, nb_rb); } +#if UE_TIMING_TRACE + stop_meas(&ue->generic_stat_bis[subframe%RX_NB_TH][slot]); +#if DISABLE_LOG_X + printf("[AbsSFN %d.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[subframe%RX_NB_TH][slot].p_time/(cpuf*1000.0)); +#else + LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[subframe%RX_NB_TH][slot].p_time/(cpuf*1000.0)); +#endif +#endif + +#if UE_TIMING_TRACE + start_meas(&ue->generic_stat_bis[subframe%RX_NB_TH][slot]); +#endif if (first_symbol_flag==1) { if (beamforming_mode==0){ if (dlsch0_harq->mimo_modemimo_mode); #endif + + //wait until pdcch is decoded + proc->channel_level = 1; + } + + uint32_t wait = 0; + while(proc->channel_level == 0) + { + usleep(1); + wait++; } #if T_TRACER @@ -492,6 +532,19 @@ int rx_pdsch(PHY_VARS_UE *ue, } #endif +#if UE_TIMING_TRACE + stop_meas(&ue->generic_stat_bis[subframe%RX_NB_TH][slot]); +#if DISABLE_LOG_X + printf("[AbsSFN %d.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,subframe,slot,symbol,first_symbol_flag,ue->generic_stat_bis[subframe%RX_NB_TH][slot].p_time/(cpuf*1000.0)); +#else + LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,subframe,slot,symbol,first_symbol_flag,ue->generic_stat_bis[subframe%RX_NB_TH][slot].p_time/(cpuf*1000.0)); +#endif +#endif + + +#if UE_TIMING_TRACE + start_meas(&ue->generic_stat_bis[subframe%RX_NB_TH][slot]); +#endif // Now channel compensation if (dlsch0_harq->mimo_moderxdataF_ext, @@ -686,8 +739,18 @@ int rx_pdsch(PHY_VARS_UE *ue, measurements); // log2_maxh+I0_shift } +#if UE_TIMING_TRACE + stop_meas(&ue->generic_stat_bis[subframe%RX_NB_TH][slot]); +#if DISABLE_LOG_X + printf("[AbsSFN %d.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n",frame,subframe,slot,symbol,pdsch_vars[eNB_id]->log2_maxh,proc->channel_level,ue->generic_stat_bis[subframe%RX_NB_TH][slot].p_time/(cpuf*1000.0)); +#else + LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n",frame,subframe,slot,symbol,pdsch_vars[eNB_id]->log2_maxh,proc->channel_level,ue->generic_stat_bis[subframe%RX_NB_TH][slot].p_time/(cpuf*1000.0)); +#endif +#endif // MRC - +#if UE_TIMING_TRACE + start_meas(&ue->generic_stat_bis[subframe%RX_NB_TH][slot]); +#endif if (frame_parms->nb_antennas_rx > 1) { if ((dlsch0_harq->mimo_mode == LARGE_CDD) || @@ -755,6 +818,18 @@ int rx_pdsch(PHY_VARS_UE *ue, //i_mod should have been passed as a parameter } +#if UE_TIMING_TRACE + stop_meas(&ue->generic_stat_bis[subframe%RX_NB_TH][slot]); +#if DISABLE_LOG_X + printf("[AbsSFN %d.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[subframe%RX_NB_TH][slot].p_time/(cpuf*1000.0)); +#else + LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[subframe%RX_NB_TH][slot].p_time/(cpuf*1000.0)); +#endif +#endif + +#if UE_TIMING_TRACE + start_meas(&ue->generic_stat_bis[subframe%RX_NB_TH][slot]); +#endif //printf("LLR dlsch0_harq->Qm %d rx_type %d cw0 %d cw1 %d symbol %d \n",dlsch0_harq->Qm,rx_type,codeword_TB0,codeword_TB1,symbol); // compute LLRs // -> // compute @pointer where llrs should filled for this ofdm-symbol @@ -1102,6 +1177,14 @@ int rx_pdsch(PHY_VARS_UE *ue, } } +#if UE_TIMING_TRACE + stop_meas(&ue->generic_stat_bis[subframe%RX_NB_TH][slot]); +#if DISABLE_LOG_X + printf("[AbsSFN %d.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[subframe%RX_NB_TH][slot].p_time/(cpuf*1000.0)); +#else + LOG_I(PHY, "[AbsSFN %d.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,subframe,slot,symbol,ue->generic_stat_bis[subframe%RX_NB_TH][slot].p_time/(cpuf*1000.0)); +#endif +#endif // Please keep it: useful for debugging #if 0 if( (symbol == 13) && (subframe==0) && (dlsch0_harq->Qm == 6) /*&& (nb_rb==25)*/) @@ -1148,10 +1231,6 @@ int rx_pdsch(PHY_VARS_UE *ue, T_BUFFER(&pdsch_vars[eNB_id]->rxdataF_comp0[eNB_id][0], 2 * /* ulsch[UE_id]->harq_processes[harq_pid]->nb_rb */ frame_parms->N_RB_UL *12*frame_parms->symbols_per_tti*2)); #endif - - if(symbol == (ue->frame_parms.symbols_per_tti>>1)) //(first_symbol_flag) - proc->first_symbol_available = 1; - return(0); } diff --git a/openair1/PHY/LTE_TRANSPORT/initial_sync.c b/openair1/PHY/LTE_TRANSPORT/initial_sync.c index 19b0152946..e2c0ce3112 100644 --- a/openair1/PHY/LTE_TRANSPORT/initial_sync.c +++ b/openair1/PHY/LTE_TRANSPORT/initial_sync.c @@ -233,19 +233,17 @@ int pbch_detection(PHY_VARS_UE *ue, runmode_t mode) break; } - ue->proc.proc_rxtx[0].frame_rx = (((ue->pbch_vars[0]->decoded_output[2]&3)<<6) + (ue->pbch_vars[0]->decoded_output[1]>>2))<<2; - ue->proc.proc_rxtx[0].frame_rx += frame_mod4; - - ue->proc.proc_rxtx[1].frame_rx = (((ue->pbch_vars[0]->decoded_output[2]&3)<<6) + (ue->pbch_vars[0]->decoded_output[1]>>2))<<2; - ue->proc.proc_rxtx[1].frame_rx += frame_mod4; + for(int i=0; iproc.proc_rxtx[i].frame_rx = (((ue->pbch_vars[0]->decoded_output[2]&3)<<6) + (ue->pbch_vars[0]->decoded_output[1]>>2))<<2; + ue->proc.proc_rxtx[i].frame_rx = (((ue->pbch_vars[0]->decoded_output[2]&3)<<6) + (ue->pbch_vars[0]->decoded_output[1]>>2))<<2; #ifndef USER_MODE - // one frame delay - ue->proc.proc_rxtx[0].frame_rx ++; - ue->proc.proc_rxtx[1].frame_rx ++; + // one frame delay + ue->proc.proc_rxtx[i].frame_rx ++; #endif - ue->proc.proc_rxtx[0].frame_tx = ue->proc.proc_rxtx[0].frame_rx; - ue->proc.proc_rxtx[1].frame_tx = ue->proc.proc_rxtx[1].frame_rx; + ue->proc.proc_rxtx[i].frame_tx = ue->proc.proc_rxtx[0].frame_rx; + } #ifdef DEBUG_INITIAL_SYNCH LOG_I(PHY,"[UE%d] Initial sync: pbch decoded sucessfully mode1_flag %d, tx_ant %d, frame %d, N_RB_DL %d, phich_duration %d, phich_resource %s!\n", ue->Mod_id, diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 4e16c26bda..27d0b555d4 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -397,20 +397,27 @@ typedef struct { struct sched_param sched_param_rxtx; /// internal This variable is protected by ref mutex_fep_slot1. - int instance_cnt_fep_slot1; + //int instance_cnt_slot0_dl_processing; + int instance_cnt_slot1_dl_processing; /// pthread descriptor fep_slot1 thread - pthread_t pthread_fep_slot1; + //pthread_t pthread_slot0_dl_processing; + pthread_t pthread_slot1_dl_processing; /// pthread attributes for fep_slot1 processing thread - pthread_attr_t attr_fep_slot1; + // pthread_attr_t attr_slot0_dl_processing; + pthread_attr_t attr_slot1_dl_processing; /// condition variable for UE fep_slot1 thread; - pthread_cond_t cond_fep_slot1; + //pthread_cond_t cond_slot0_dl_processing; + pthread_cond_t cond_slot1_dl_processing; /// mutex for UE synch thread - pthread_mutex_t mutex_fep_slot1; + //pthread_mutex_t mutex_slot0_dl_processing; + pthread_mutex_t mutex_slot1_dl_processing; // uint8_t chan_est_pilot0_slot1_available; + uint8_t chan_est_slot1_available; uint8_t llr_slot1_available; uint8_t dci_slot0_available; uint8_t first_symbol_available; + uint8_t channel_level; /// scheduling parameters for fep_slot1 thread struct sched_param sched_param_fep_slot1; @@ -910,6 +917,7 @@ typedef struct { time_stats_t ulsch_multiplexing_stats; time_stats_t generic_stat; + time_stats_t generic_stat_bis[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; time_stats_t ue_front_end_stat[RX_NB_TH]; time_stats_t ue_front_end_per_slot_stat[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME]; time_stats_t pdcch_procedures_stat[RX_NB_TH]; diff --git a/openair1/SCHED/defs.h b/openair1/SCHED/defs.h index 3bcdb1d422..419dda4ea9 100644 --- a/openair1/SCHED/defs.h +++ b/openair1/SCHED/defs.h @@ -140,9 +140,11 @@ void phy_procedures_UE_TX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t @param phy_vars_rn pointer to RN variables */ int phy_procedures_UE_RX(PHY_VARS_UE *phy_vars_ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode,relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn); - +int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, + uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode, + relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn); #ifdef UE_SLOT_PARALLELISATION -void *UE_thread_fep_slot1(void *arg); +void *UE_thread_slot1_dl_processing(void *arg); #endif /*! \brief Scheduling for UE TX procedures in TDD S-subframes. diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index e183e0bf37..c98913578c 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -30,12 +30,16 @@ * \warning */ +#define _GNU_SOURCE + #include "assertions.h" #include "defs.h" #include "PHY/defs.h" #include "PHY/extern.h" #include "SCHED/defs.h" #include "SCHED/extern.h" +#include +#include "targets/RT/USER/lte-softmodem.h" #ifdef EMOS #include "SCHED/phy_procedures_emos.h" @@ -73,8 +77,6 @@ fifo_dump_emos_UE emos_dump_UE; #define NS_PER_SLOT 500000 -extern int oai_exit; - extern double cpuf; @@ -2950,16 +2952,18 @@ void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uin { ue->proc.proc_rxtx[th_id].frame_rx = proc->frame_rx; ue->proc.proc_rxtx[th_id].frame_tx = proc->frame_tx; + + printf("[UE %d] frame %d, subframe %d: Adjusting frame counter (PBCH ant_tx=%d, frame_tx=%d, phase %d, rx_offset %d) => new frame %d\n", + ue->Mod_id, + ue->proc.proc_rxtx[th_id].frame_rx, + subframe_rx, + pbch_tx_ant, + frame_tx, + pbch_phase, + ue->rx_offset, + proc->frame_rx); } - LOG_I(PHY,"[UE %d] frame %d, subframe %d: Adjusting frame counter (PBCH ant_tx=%d, frame_tx=%d, phase %d, rx_offset %d) => new frame %d\n", - ue->Mod_id, - frame_rx, - subframe_rx, - pbch_tx_ant, - frame_tx, - pbch_phase, - ue->rx_offset, - proc->frame_rx); + frame_rx = proc->frame_rx; @@ -3174,7 +3178,7 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint (dci_alloc_rx[i].rnti == ue->pdcch_vars[subframe_rx%RX_NB_TH][eNB_id]->crnti) && (dci_alloc_rx[i].format != format0)) { - LOG_I(PHY,"[UE %d][DCI][PDSCH %x] AbsSubframe %d.%d: format %d, num_pdcch_symbols %d, nCCE %d, total CCEs %d\n", + LOG_D(PHY,"[UE %d][DCI][PDSCH %x] AbsSubframe %d.%d: format %d, num_pdcch_symbols %d, nCCE %d, total CCEs %d\n", ue->Mod_id,dci_alloc_rx[i].rnti, frame_rx%1024,subframe_rx, dci_alloc_rx[i].format, @@ -3249,9 +3253,9 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint else if ((dci_alloc_rx[i].rnti == SI_RNTI) && ((dci_alloc_rx[i].format == format1A) || (dci_alloc_rx[i].format == format1C))) { -//#ifdef DEBUG_PHY_PROC - LOG_I(PHY,"[UE %d] subframe %d: Found rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); -//#endif +#ifdef DEBUG_PHY_PROC + LOG_D(PHY,"[UE %d] subframe %d: Found rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); +#endif if (generate_ue_dlsch_params_from_dci(frame_rx, @@ -3273,7 +3277,7 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint ue->dlsch_SI_received[eNB_id]++; - LOG_I(PHY,"[UE %d] Frame %d, subframe %d : Generate UE DLSCH SI_RNTI format 1%s\n",ue->Mod_id,frame_rx,subframe_rx,dci_alloc_rx[i].format==format1A?"A":"C"); + LOG_D(PHY,"[UE %d] Frame %d, subframe %d : Generate UE DLSCH SI_RNTI format 1%s\n",ue->Mod_id,frame_rx,subframe_rx,dci_alloc_rx[i].format==format1A?"A":"C"); //dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); } @@ -3282,9 +3286,9 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint else if ((dci_alloc_rx[i].rnti == P_RNTI) && ((dci_alloc_rx[i].format == format1A) || (dci_alloc_rx[i].format == format1C))) { -//#ifdef DEBUG_PHY_PROC - LOG_I(PHY,"[UE %d] subframe %d: Found rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); -//#endif +#ifdef DEBUG_PHY_PROC + LOG_D(PHY,"[UE %d] subframe %d: Found rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); +#endif if (generate_ue_dlsch_params_from_dci(frame_rx, @@ -3314,13 +3318,13 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint (dci_alloc_rx[i].rnti == ue->prach_resources[eNB_id]->ra_RNTI) && (dci_alloc_rx[i].format == format1A)) { -//#ifdef DEBUG_PHY_PROC - LOG_I(PHY,"[UE %d][RAPROC] subframe %d: Found RA rnti %x, format 1A, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,i); +#ifdef DEBUG_PHY_PROC + LOG_D(PHY,"[UE %d][RAPROC] subframe %d: Found RA rnti %x, format 1A, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,i); //if (((frame_rx%100) == 0) || (frame_rx < 20)) //dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); //mac_xface->macphy_exit("so far so good...\n"); -//#endif +#endif if (generate_ue_dlsch_params_from_dci(frame_rx, @@ -3682,9 +3686,9 @@ void ue_pdsch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, int eNB_id, PDSC } if ((m==s0) && (m<4)) - first_symbol_flag = 1; + first_symbol_flag = 1; else - first_symbol_flag = 0; + first_symbol_flag = 0; #if UE_TIMING_TRACE uint8_t slot = 0; if(m >= ue->frame_parms.symbols_per_tti>>1) @@ -3706,13 +3710,19 @@ void ue_pdsch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, int eNB_id, PDSC dlsch0->current_harq_pid); #if UE_TIMING_TRACE stop_meas(&ue->dlsch_llr_stats[subframe_rx%RX_NB_TH][slot]); -//#if DISABLE_LOG_X -// printf("[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",proc->frame_rx,subframe_rx,m,ue->dlsch_llr_stats[subframe_rx%RX_NB_TH][slot].p_time/(cpuf*1000.0)); -//#else -// LOG_D(PHY, "[AbsSFN %d.%d] LLR Computation Symbol %d %5.2fn %5.2f \n",proc->frame_rx,subframe_rx,m,ue->dlsch_llr_stats[subframe_rx%RX_NB_TH][slot].p_time/(cpuf*1000.0)); -//#endif +#if DISABLE_LOG_X + printf("[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",proc->frame_rx,subframe_rx,m,ue->dlsch_llr_stats[subframe_rx%RX_NB_TH][slot].p_time/(cpuf*1000.0)); +#else + LOG_D(PHY, "[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",proc->frame_rx,subframe_rx,m,ue->dlsch_llr_stats[subframe_rx%RX_NB_TH][slot].p_time/(cpuf*1000.0)); #endif +#endif + + if(first_symbol_flag) + { + proc->first_symbol_available = 1; + printf("Set first_symbol_available to 1 \n"); + } } // CRNTI active } } @@ -4039,9 +4049,9 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, if (ret == (1+dlsch0->max_turbo_iterations)) { *dlsch_errors=*dlsch_errors+1; - //if(dlsch0->rnti != 0xffff) + if(dlsch0->rnti != 0xffff) { - LOG_I(PHY,"[UE %d][PDSCH %x/%d] AbsSubframe %d.%d : DLSCH CW0 in error (rv %d,round %d, mcs %d,TBS %d)\n", + LOG_D(PHY,"[UE %d][PDSCH %x/%d] AbsSubframe %d.%d : DLSCH CW0 in error (rv %d,round %d, mcs %d,TBS %d)\n", ue->Mod_id,dlsch0->rnti, harq_pid,frame_rx,subframe_rx, dlsch0->harq_processes[harq_pid]->rvidx, @@ -4052,9 +4062,9 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, } else { - //if(dlsch0->rnti != 0xffff) + if(dlsch0->rnti != 0xffff) { - LOG_I(PHY,"[UE %d][PDSCH %x/%d] AbsSubframe %d.%d : Received DLSCH CW0 (rv %d,round %d, mcs %d,TBS %d)\n", + LOG_D(PHY,"[UE %d][PDSCH %x/%d] AbsSubframe %d.%d : Received DLSCH CW0 (rv %d,round %d, mcs %d,TBS %d)\n", ue->Mod_id,dlsch0->rnti, harq_pid,frame_rx,subframe_rx, dlsch0->harq_processes[harq_pid]->rvidx, @@ -4189,8 +4199,6 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, } -//Merge 2017.w25 -#ifdef UE_SLOT_PARALLELISATION /*! * \brief This is the UE synchronize thread. * It performs band scanning and synchonization. @@ -4198,15 +4206,297 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ #define FIFO_PRIORITY 40 -void *UE_thread_fep_slot1(void *arg) { +void *UE_thread_slot1_dl_processing(void *arg) { -} + static __thread int UE_dl_slot1_processing_retval; + struct rx_tx_thread_data *rtd = arg; + UE_rxtx_proc_t *proc = rtd->proc; + PHY_VARS_UE *ue = rtd->UE; + + int frame_rx; + uint8_t subframe_rx; + uint8_t pilot0; + uint8_t pilot1; + uint8_t slot1; + + uint8_t next_subframe_rx; + uint8_t next_subframe_slot0; + + proc->instance_cnt_slot1_dl_processing=-1; + proc->subframe_rx=proc->sub_frame_start; + + char threadname[256]; + sprintf(threadname,"UE_thread_slot1_dl_processing_%d", proc->sub_frame_start); + + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + if ( (proc->sub_frame_start+1)%RX_NB_TH == 0 && threads.slot1_proc_one != -1 ) + CPU_SET(threads.slot1_proc_one, &cpuset); + if ( (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.slot1_proc_two != -1 ) + CPU_SET(threads.slot1_proc_two, &cpuset); + if ( (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.slot1_proc_three != -1 ) + CPU_SET(threads.slot1_proc_three, &cpuset); + + init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset, + threadname); + + while (!oai_exit) { + if (pthread_mutex_lock(&proc->mutex_slot1_dl_processing) != 0) { + LOG_E( PHY, "[SCHED][UE] error locking mutex for UE slot1 dl processing\n" ); + exit_fun("nothing to add"); + } + while (proc->instance_cnt_slot1_dl_processing < 0) { + // most of the time, the thread is waiting here + pthread_cond_wait( &proc->cond_slot1_dl_processing, &proc->mutex_slot1_dl_processing ); + } + if (pthread_mutex_unlock(&proc->mutex_slot1_dl_processing) != 0) { + LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE slot1 dl processing \n" ); + exit_fun("nothing to add"); + } + + /*for(int th_idx=0; th_idx< RX_NB_TH; th_idx++) + { + frame_rx = ue->proc.proc_rxtx[0].frame_rx; + subframe_rx = ue->proc.proc_rxtx[0].subframe_rx; + printf("AbsSubframe %d.%d execute dl slot1 processing \n", frame_rx, subframe_rx); + }*/ + frame_rx = proc->frame_rx; + subframe_rx = proc->subframe_rx; + next_subframe_rx = (1+subframe_rx)%10; + next_subframe_slot0 = next_subframe_rx<<1; + + slot1 = (subframe_rx<<1) + 1; + pilot0 = 0; + + printf("AbsSubframe %d.%d execute dl slot1 processing \n", frame_rx, subframe_rx); + + if (ue->frame_parms.Ncp == 0) { // normal prefix + pilot1 = 4; + } else { // extended prefix + pilot1 = 3; + } + + /**** Slot1 FE Processing ****/ +#if UE_TIMING_TRACE + start_meas(&ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][1]); +#endif + // I- start dl slot1 processing + // do first symbol of next downlink subframe for channel estimation + /* + // 1- perform FFT for pilot ofdm symbols first (ofdmSym0 next subframe ofdmSym11) + if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) + { + front_end_fft(ue, + pilot0, + next_subframe_slot0, + 0, + 0); + } + + front_end_fft(ue, + pilot1, + slot1, + 0, + 0); + */ + // 1- perform FFT + for (int l=1; lframe_parms.symbols_per_tti>>1; l++) + { + //if( (l != pilot0) && (l != pilot1)) + { +#if UE_TIMING_TRACE + start_meas(&ue->ofdm_demod_stats); +#endif + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); + //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,subframe_rx,slot1,l); + front_end_fft(ue, + l, + slot1, + 0, + 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); +#if UE_TIMING_TRACE + stop_meas(&ue->ofdm_demod_stats); #endif + } + } // for l=1..l2 -#if 1 -int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, - uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode, - relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn) { + if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) + { + //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,subframe_rx,next_subframe_slot0,pilot0); + front_end_fft(ue, + pilot0, + next_subframe_slot0, + 0, + 0); + } + + // 2- perform Channel Estimation for slot1 + for (int l=1; lframe_parms.symbols_per_tti>>1; l++) + { + if(l == pilot1) + { + //wait until channel estimation for pilot0/slot1 is available + uint32_t wait = 0; + while(proc->chan_est_pilot0_slot1_available == 0) + { + usleep(1); + wait++; + } + printf("[slot1 dl processing] ChanEst symbol %d slot %d wait%d\n",l,slot1,wait); + } + //printf("AbsSubframe %d.%d ChanEst slot %d, symbol %d\n", frame_rx,subframe_rx,slot1,l); + front_end_chanEst(ue, + l, + slot1, + 0); + ue_measurement_procedures(l-1,ue,proc,0,1+(subframe_rx<<1),0,ue->mode); + } + //printf("AbsSubframe %d.%d ChanEst slot %d, symbol %d\n", frame_rx,subframe_rx,next_subframe_slot0,pilot0); + front_end_chanEst(ue, + pilot0, + next_subframe_slot0, + 0); + + if ( (subframe_rx == 0) && (ue->decode_MIB == 1)) + { + ue_pbch_procedures(0,ue,proc,0); + } + + proc->chan_est_slot1_available = 1; + printf("Set available slot 1channelEst to 1 AbsSubframe %d.%d \n",frame_rx,subframe_rx); + printf(" [slot1 dl processing] ==> FFT/CHanEst Done for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); + + //printf(" [slot1 dl processing] ==> Start LLR Comuptation slot1 for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); + + +#if UE_TIMING_TRACE + stop_meas(&ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][1]); +#if DISABLE_LOG_X + printf("[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][1].p_time/(cpuf*1000.0)); +#else + LOG_D(PHY, "[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][1].p_time/(cpuf*1000.0)); +#endif +#endif + + + //wait until pdcch is decoded + uint32_t wait = 0; + while(proc->dci_slot0_available == 0) + { + usleep(1); + wait++; + } + printf("[slot1 dl processing] AbsSubframe %d.%d LLR Computation Start wait DCI %d\n",frame_rx,subframe_rx,wait); + + + /**** Pdsch Procedure Slot1 ****/ + // start slot1 thread for Pdsch Procedure (slot1) + // do procedures for C-RNTI + printf("AbsSubframe %d.%d Pdsch Procedure (slot1)\n",frame_rx,subframe_rx); + + +#if UE_TIMING_TRACE + start_meas(&ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][1]); +#endif + // start slave thread for Pdsch Procedure (slot1) + // do procedures for C-RNTI + uint8_t eNB_id = 0; + uint8_t abstraction_flag = 0; + if (ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->active == 1) { + //wait until first ofdm symbol is processed + //wait = 0; + //while(proc->first_symbol_available == 0) + //{ + // usleep(1); + // wait++; + //} + //printf("[slot1 dl processing] AbsSubframe %d.%d LLR Computation Start wait First Ofdm Sym %d\n",frame_rx,subframe_rx,wait); + + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); + ue_pdsch_procedures(ue, + proc, + eNB_id, + PDSCH, + ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0], + NULL, + (ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); + LOG_D(PHY," ------ end PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); + LOG_D(PHY," ------ --> PDSCH Turbo Decoder slot 0/1: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); + } + + // do procedures for SI-RNTI + if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { + ue_pdsch_procedures(ue, + proc, + eNB_id, + SI_PDSCH, + ue->dlsch_SI[eNB_id], + NULL, + (ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); + } + + // do procedures for P-RNTI + if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { + ue_pdsch_procedures(ue, + proc, + eNB_id, + P_PDSCH, + ue->dlsch_p[eNB_id], + NULL, + (ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); + } + // do procedures for RA-RNTI + if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { + ue_pdsch_procedures(ue, + proc, + eNB_id, + RA_PDSCH, + ue->dlsch_ra[eNB_id], + NULL, + (ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); + } + + proc->llr_slot1_available=1; + printf("Set available LLR slot1 to 1 AbsSubframe %d.%d \n",frame_rx,subframe_rx); + +#if UE_TIMING_TRACE + stop_meas(&ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][1]); +#if DISABLE_LOG_X + printf("[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][1].p_time/(cpuf*1000.0)); +#else + LOG_D(PHY, "[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][1].p_time/(cpuf*1000.0)); +#endif +#endif + + + if (pthread_mutex_lock(&proc->mutex_slot1_dl_processing) != 0) { + LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); + exit_fun("noting to add"); + } + proc->instance_cnt_slot1_dl_processing--; + if (pthread_mutex_unlock(&proc->mutex_slot1_dl_processing) != 0) { + LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE FEP Slo1\n" ); + exit_fun("noting to add"); + } + } + // thread finished + free(arg); + return &UE_dl_slot1_processing_retval; +} + + +int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, + uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode, + relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn) { int l,l2; int pmch_flag=0; @@ -4300,58 +4590,74 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, proc->llr_slot1_available=0; proc->dci_slot0_available=0; proc->first_symbol_available=0; + proc->chan_est_slot1_available=0; + proc->channel_level=0; -#ifdef UE_SLOT_PARALLELISATION - //LOG_I(PHY,"fep slot1 thread : instance_cnt %d \n", - // proc->instance_cnt_fep_slot1); - proc->instance_cnt_fep_slot1++; - if (proc->instance_cnt_fep_slot1 == 0) { - LOG_I(PHY,"unblock fep slot1 thread blocked on cond_fep_slot1 : instance_cnt_fep_slot1 %d \n", proc->instance_cnt_fep_slot1 ); - if (pthread_cond_signal(&proc->cond_fep_slot1) != 0) { - LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE FEP slot1 thread\n", ue->Mod_id); + if (pthread_mutex_lock(&proc->mutex_slot1_dl_processing) != 0) { + LOG_E( PHY, "[SCHED][UE %d][Slot0] error locking mutex for UE slot1 dl processing\n",ue->Mod_id ); + exit_fun("nothing to add"); + } + + proc->instance_cnt_slot1_dl_processing++; + if (proc->instance_cnt_slot1_dl_processing == 0) + { + LOG_I(PHY,"unblock slot1 dl processing thread blocked on instance_cnt_slot1_dl_processing : %d \n", proc->instance_cnt_slot1_dl_processing ); + if (pthread_cond_signal(&proc->cond_slot1_dl_processing) != 0) { + LOG_E( PHY, "[SCHED][UE %d][Slot0] ERROR pthread_cond_signal for UE slot1 processing thread\n", ue->Mod_id); exit_fun("nothing to add"); } - } else { - LOG_E( PHY, "[SCHED][UE %d] UE RX thread busy (IC %d)!!\n", ue->Mod_id, proc->instance_cnt_fep_slot1); - if (proc->instance_cnt_fep_slot1 > 2) - exit_fun("instance_cnt_fep_slot1 > 2"); + if (pthread_mutex_unlock(&proc->mutex_slot1_dl_processing) != 0) { + LOG_E( PHY, "[SCHED][UE %d][Slot0] error unlocking mutex for UE slot1 dl processing \n",ue->Mod_id ); + exit_fun("nothing to add"); + } + + } else + { + LOG_E( PHY, "[SCHED][UE %d] UE RX thread busy (IC %d)!!\n", ue->Mod_id, proc->instance_cnt_slot1_dl_processing); + if (proc->instance_cnt_slot1_dl_processing > 2) + exit_fun("instance_cnt_slot1_dl_processing > 2"); } - AssertFatal(pthread_cond_signal(&proc->cond_fep_slot1) ==0 ,""); - AssertFatal(pthread_mutex_unlock(&proc->mutex_fep_slot1) ==0,""); -#endif + //AssertFatal(pthread_cond_signal(&proc->cond_slot1_dl_processing) ==0 ,""); + AssertFatal(pthread_mutex_unlock(&proc->mutex_slot1_dl_processing) ==0,""); - /**** FFT Slot0 + Slot1 ****/ + + /**** Slot0 FE Processing ****/ // I- start main thread for FFT/ChanEst symbol: 0/1 --> 7 #if UE_TIMING_TRACE start_meas(&ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][0]); #endif // 1- perform FFT for pilot ofdm symbols first (ofdmSym7 ofdmSym4 or (ofdmSym6 ofdmSym3)) + //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,subframe_rx,slot1,pilot0); front_end_fft(ue, pilot0, slot1, 0, 0); + //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,subframe_rx,slot0,pilot1); front_end_fft(ue, pilot1, slot0, 0, 0); + //printf("AbsSubframe %d.%d ChanEst slot %d, symbol %d\n", frame_rx,subframe_rx,slot0,pilot1); front_end_chanEst(ue, pilot1, slot0, 0); + //printf("AbsSubframe %d.%d ChanEst slot %d, symbol %d\n", frame_rx,subframe_rx,slot1,pilot0); front_end_chanEst(ue, pilot0, slot1, 0); proc->chan_est_pilot0_slot1_available = 1; - //LOG_I(PHY,"Set available channelEst to 1 AbsSubframe %d.%d \n",frame_rx,subframe_rx); + printf("Set available channelEst to 1 AbsSubframe %d.%d \n",frame_rx,subframe_rx); // 2- perform FFT for other ofdm symbols other than pilots for (l=first_ofdm_sym; l<=l2; l++) { if( (l != pilot0) && (l != pilot1)) { + //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,subframe_rx,slot0,l); #if UE_TIMING_TRACE start_meas(&ue->ofdm_demod_stats); #endif @@ -4373,6 +4679,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, { if( (l != pilot0) && (l != pilot1)) { + //printf("AbsSubframe %d.%d ChanEst slot %d, symbol %d\n", frame_rx,subframe_rx,slot0,l); front_end_chanEst(ue, l, slot0, @@ -4395,8 +4702,10 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, LOG_D(PHY, "[AbsSFN %d.%d] Slot0: PDCCH %5.2f \n",frame_rx,subframe_rx,ue->pdcch_procedures_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); #endif #endif + //proc->dci_slot0_available = 1; return(-1); } + //proc->dci_slot0_available=1; #if UE_TIMING_TRACE stop_meas(&ue->pdcch_procedures_stat[subframe_rx%RX_NB_TH]); #if DISABLE_LOG_X @@ -4407,9 +4716,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, #endif } - //LOG_I(PHY,"num_pdcch_symbols %d\n",ue->pdcch_vars[subframe_rx%RX_NB_TH][eNB_id]->num_pdcch_symbols); - //LOG_I(PHY,"Set available dci slot0 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); - proc->dci_slot0_available=1; + printf("num_pdcch_symbols %d\n",ue->pdcch_vars[subframe_rx%RX_NB_TH][eNB_id]->num_pdcch_symbols); // first slot has been processed (FFTs + Channel Estimation, PCFICH/PHICH/PDCCH) #if UE_TIMING_TRACE @@ -4421,115 +4728,36 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, #endif #endif - - // If this is PMCH, call procedures and return - if (pmch_flag == 1) { - ue_pmch_procedures(ue,proc,eNB_id,abstraction_flag); - return 0; - } - -#if 1 -#if UE_TIMING_TRACE - start_meas(&ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][1]); -#endif - // II- start slave thread for FFT/ChanEst - // do first symbol of next downlink subframe for channel estimation - int next_subframe_rx = (1+subframe_rx)%10; - uint8_t next_subframe_slot0 = next_subframe_rx<<1; - // 1- perform FFT for pilot ofdm symbols first (ofdmSym0 next subframe ofdmSym11) - if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) - { - front_end_fft(ue, - pilot0, - next_subframe_slot0, - 0, - 0); - } - - front_end_fft(ue, - pilot1, - slot1, - 0, - 0); - - // 2- perform FFT for other ofdm symbols other than pilots - for (l=1; lframe_parms.symbols_per_tti>>1; l++) - { - if( (l != pilot0) && (l != pilot1)) - { -#if UE_TIMING_TRACE - start_meas(&ue->ofdm_demod_stats); -#endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); - front_end_fft(ue, - l, - slot1, - 0, - 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); -#if UE_TIMING_TRACE - stop_meas(&ue->ofdm_demod_stats); -#endif - } - } // for l=1..l2 - - // 3- perform Channel Estimation for slot1 - for (l=1; lframe_parms.symbols_per_tti>>1; l++) - { -#if 0 - if(l == pilot0) - { - //wait until channel estimation for pilot0/slot1 is available - uint32_t wait = 0; - while(proc->chan_est_pilot0_slot1_available == 0) - { - wait++; - } - } -#endif - front_end_chanEst(ue, - l, - slot1, - 0); - ue_measurement_procedures(l-1,ue,proc,eNB_id,1+(subframe_rx<<1),abstraction_flag,mode); - } - front_end_chanEst(ue, - pilot0, - next_subframe_slot0, - 0); - - if ( (subframe_rx == 0) && (ue->decode_MIB == 1)) + //wait until slot1 FE is done + uint32_t wait = 0; + while(proc->chan_est_slot1_available == 0) { - ue_pbch_procedures(eNB_id,ue,proc,abstraction_flag); + usleep(1); + wait++; } #if UE_TIMING_TRACE - stop_meas(&ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][1]); + stop_meas(&ue->ue_front_end_stat[subframe_rx%RX_NB_TH]); #if DISABLE_LOG_X - printf("[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][1].p_time/(cpuf*1000.0)); + printf("[AbsSFN %d.%d] FULL FE Processing %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][0].p_time/(cpuf*1000.0)); #else - LOG_D(PHY, "[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][1].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %d.%d] FULL FE Processing %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[subframe_rx%RX_NB_TH][0].p_time/(cpuf*1000.0)); #endif #endif + /**** End Subframe FE Processing ****/ -#endif -#if UE_TIMING_TRACE - stop_meas(&ue->ue_front_end_stat[subframe_rx%RX_NB_TH]); -#if DISABLE_LOG_X - printf("[AbsSFN %d.%d] Full Front End Processing %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); -#else - LOG_D(PHY, "[AbsSFN %d.%d] Full Front End Processing %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); -#endif +#if 0 + //Trigger LLR parallelized for Slot 1 + proc->dci_slot0_available=1; + printf("Set available dci slot0 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); #endif - /**** End Subframe FFT-ChannelEst ****/ - - /**** Pdsch Procedure Slot0 + Slot1 ****/ + /**** Pdsch Procedure Slot0 ****/ // start main thread for Pdsch Procedure (slot0) // do procedures for C-RNTI - //LOG_I(PHY,"AbsSubframe %d.%d Pdsch Procedure (slot0)\n",frame_rx%1024,subframe_rx); - //LOG_I(PHY,"AbsSubframe %d.%d Pdsch Procedure PDSCH Active %d \n",frame_rx%1024,subframe_rx, ue->dlsch[subframe_rx%RX_NB_TH][0][0]->active); + printf("AbsSubframe %d.%d Pdsch Procedure (slot0)\n",frame_rx%1024,subframe_rx); + printf("AbsSubframe %d.%d Pdsch Procedure PDSCH Active %d \n",frame_rx%1024,subframe_rx, ue->dlsch[subframe_rx%RX_NB_TH][0][0]->active); #if UE_TIMING_TRACE start_meas(&ue->pdsch_procedures_stat[subframe_rx%RX_NB_TH]); @@ -4547,7 +4775,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0], NULL, ue->pdcch_vars[subframe_rx%RX_NB_TH][eNB_id]->num_pdcch_symbols, - ue->frame_parms.symbols_per_tti>>1, + (ue->frame_parms.symbols_per_tti>>1)-1, abstraction_flag); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); @@ -4563,7 +4791,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, ue->dlsch_SI[eNB_id], NULL, ue->pdcch_vars[subframe_rx%RX_NB_TH][eNB_id]->num_pdcch_symbols, - ue->frame_parms.symbols_per_tti>>1, + (ue->frame_parms.symbols_per_tti>>1)-1, abstraction_flag); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_OUT); } @@ -4578,7 +4806,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, ue->dlsch_p[eNB_id], NULL, ue->pdcch_vars[subframe_rx%RX_NB_TH][eNB_id]->num_pdcch_symbols, - ue->frame_parms.symbols_per_tti>>1, + (ue->frame_parms.symbols_per_tti>>1)-1, abstraction_flag); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_OUT); } @@ -4593,11 +4821,17 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, ue->dlsch_ra[eNB_id], NULL, ue->pdcch_vars[subframe_rx%RX_NB_TH][eNB_id]->num_pdcch_symbols, - ue->frame_parms.symbols_per_tti>>1, + (ue->frame_parms.symbols_per_tti>>1)-1, abstraction_flag); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_OUT); } +#if 1 + // LLR linear + proc->dci_slot0_available=1; + printf("Set available dci slot0 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); +#endif + #if UE_TIMING_TRACE stop_meas(&ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][0]); #if DISABLE_LOG_X @@ -4607,75 +4841,15 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, #endif #endif -#if 1 -#if UE_TIMING_TRACE - start_meas(&ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][1]); -#endif - // start slave thread for Pdsch Procedure (slot1) - // do procedures for C-RNTI - if (ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->active == 1) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); - ue_pdsch_procedures(ue, - proc, - eNB_id, - PDSCH, - ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); - LOG_D(PHY," ------ end PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); - LOG_D(PHY," ------ --> PDSCH Turbo Decoder slot 0/1: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); - } - - // do procedures for SI-RNTI - if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { - ue_pdsch_procedures(ue, - proc, - eNB_id, - SI_PDSCH, - ue->dlsch_SI[eNB_id], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); - } - // do procedures for P-RNTI - if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { - ue_pdsch_procedures(ue, - proc, - eNB_id, - P_PDSCH, - ue->dlsch_p[eNB_id], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); - } - // do procedures for RA-RNTI - if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { - ue_pdsch_procedures(ue, - proc, - eNB_id, - RA_PDSCH, - ue->dlsch_ra[eNB_id], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); + //wait until LLR Slot1 is done + wait = 0; + while(proc->llr_slot1_available == 0) + { + usleep(1); + wait++; } - proc->llr_slot1_available=1; -#if UE_TIMING_TRACE - stop_meas(&ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][1]); -#if DISABLE_LOG_X - printf("[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][1].p_time/(cpuf*1000.0)); -#else - LOG_D(PHY, "[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_per_slot_stat[subframe_rx%RX_NB_TH][1].p_time/(cpuf*1000.0)); -#endif -#endif -#endif #if UE_TIMING_TRACE @@ -4686,51 +4860,21 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, LOG_D(PHY, "[AbsSFN %d.%d] Full LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); #endif #endif + printf("[slot0 dl processing] AbsSubframe %d.%d Channel Decoder Start wait %d\n",frame_rx,subframe_rx,wait); -#if 0 - if(subframe_rx==5 && ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->harq_processes[ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->current_harq_pid]->nb_rb > 20){ - //write_output("decoder_llr.m","decllr",dlsch_llr,G,1,0); - //write_output("llr.m","llr", &ue->pdsch_vars[eNB_id]->llr[0][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0); - - write_output("rxdataF0_current.m" , "rxdataF0", &ue->common_vars.common_vars_rx_data_per_thread[subframe_rx%RX_NB_TH].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); - //write_output("rxdataF0_previous.m" , "rxdataF0_prev_sss", &ue->common_vars.common_vars_rx_data_per_thread[(subframe_rx+1)%RX_NB_TH].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); - - //write_output("rxdataF0_previous.m" , "rxdataF0_prev", &ue->common_vars.common_vars_rx_data_per_thread[(subframe+1)%RX_NB_TH].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); - - write_output("dl_ch_estimates.m", "dl_ch_estimates_sfn5", &ue->common_vars.common_vars_rx_data_per_thread[subframe_rx%RX_NB_TH].dl_ch_estimates[0][0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); - write_output("dl_ch_estimates_ext.m", "dl_ch_estimatesExt_sfn5", &ue->pdsch_vars[subframe_rx%RX_NB_TH][0]->dl_ch_estimates_ext[0][0],14*ue->frame_parms.N_RB_DL*12,1,1); - write_output("rxdataF_comp00.m","rxdataF_comp00", &ue->pdsch_vars[subframe_rx%RX_NB_TH][0]->rxdataF_comp0[0][0],14*ue->frame_parms.N_RB_DL*12,1,1); - //write_output("magDLFirst.m", "magDLFirst", &phy_vars_ue->pdsch_vars[subframe%RX_NB_TH][0]->dl_ch_mag0[0][0],14*frame_parms->N_RB_DL*12,1,1); - //write_output("magDLSecond.m", "magDLSecond", &phy_vars_ue->pdsch_vars[subframe%RX_NB_TH][0]->dl_ch_magb0[0][0],14*frame_parms->N_RB_DL*12,1,1); - - AssertFatal (0,""); - } -#endif //=====================================================================// #if UE_TIMING_TRACE start_meas(&ue->dlsch_procedures_stat[subframe_rx%RX_NB_TH]); #endif -#if 0 - // wait until llr on slot1 are available - uint32_t wait=0; - while(proc->llr_slot1_available==0) - { - //wait until channel estimation for pilot0/slot1 is available - usleep(1); - wait++; - } -#endif - //printf("------ Waiting for LLR-Slot1 [SFN %d]: %5.2f ------\n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); - LOG_I(PHY,"==> Start Turbo Decoder active dlsch %d SI %d RA %d \n",ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->active, ue->dlsch_SI[eNB_id]->active, //ue->dlsch_p[eNB_id]->active, ue->dlsch_ra[eNB_id]->active); // Start Turbo decoder if (ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->active == 1) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); ue_dlsch_procedures(ue, proc, eNB_id, @@ -4740,7 +4884,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, &ue->dlsch_errors[eNB_id], mode, abstraction_flag); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); } // do procedures for SI-RNTI @@ -4799,6 +4943,10 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, LTE_DL_UE_HARQ_t *current_harq_processes = ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->harq_processes[current_harq_pid]; harq_status_t *current_harq_ack = &ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->harq_ack[subframe_rx]; + // For Debug parallelisation + if (current_harq_ack->ack == 0) { + printf("[slot0 dl processing][End of Channel Decoding] AbsSubframe %d.%d Decode Fail for HarqId%d Round%d\n",frame_rx,subframe_rx,current_harq_pid,current_harq_processes->round); + } for(uint8_t rx_th_idx=0; rx_th_idxdlsch[(subframe_rx+rx_th_idx)%RX_NB_TH][eNB_id][0]->harq_processes[current_harq_pid]; @@ -4865,7 +5013,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, LOG_D(PHY," ****** end RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx); return (0); } -#else + int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode, @@ -5142,7 +5290,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, if (ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->active == 1) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); #if UE_TIMING_TRACE - start_meas(&ue->pdsch_procedures_stat); + start_meas(&ue->pdsch_procedures_stat[subframe_rx%RX_NB_TH]); #endif ue_pdsch_procedures(ue, proc, @@ -5156,8 +5304,8 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, LOG_D(PHY," ------ end PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); LOG_D(PHY," ------ --> PDSCH Turbo Decoder slot 0/1: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); #if UE_TIMING_TRACE - stop_meas(&ue->pdsch_procedures_stat); - start_meas(&ue->dlsch_procedures_stat); + stop_meas(&ue->pdsch_procedures_stat[subframe_rx%RX_NB_TH]); + start_meas(&ue->dlsch_procedures_stat[subframe_rx%RX_NB_TH]); #endif ue_dlsch_procedures(ue, proc, @@ -5169,13 +5317,13 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, mode, abstraction_flag); #if UE_TIMING_TRACE - stop_meas(&ue->dlsch_procedures_stat); + stop_meas(&ue->dlsch_procedures_stat[subframe_rx%RX_NB_TH]); #if DISABLE_LOG_X - printf("[SFN %d] Slot1: Pdsch Proc %5.2f\n",subframe_rx,ue->pdsch_procedures_stat.p_time/(cpuf*1000.0)); - printf("[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",subframe_rx,ue->dlsch_procedures_stat.p_time/(cpuf*1000.0)); + printf("[SFN %d] Slot1: Pdsch Proc %5.2f\n",subframe_rx,ue->pdsch_procedures_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); + printf("[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",subframe_rx,ue->dlsch_procedures_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); #else - LOG_D(PHY, "[SFN %d] Slot1: Pdsch Proc %5.2f\n",subframe_rx,ue->pdsch_procedures_stat.p_time/(cpuf*1000.0)); - LOG_D(PHY, "[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",subframe_rx,ue->dlsch_procedures_stat.p_time/(cpuf*1000.0)); + LOG_D(PHY, "[SFN %d] Slot1: Pdsch Proc %5.2f\n",subframe_rx,ue->pdsch_procedures_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",subframe_rx,ue->dlsch_procedures_stat[subframe_rx%RX_NB_TH].p_time/(cpuf*1000.0)); #endif #endif @@ -5343,8 +5491,6 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, return (0); } -#endif - #if defined(Rel10) || defined(Rel14) int phy_procedures_RN_UE_RX(uint8_t slot_rx, uint8_t next_slot, relaying_type_t r_type) diff --git a/targets/COMMON/threads_t.h b/targets/COMMON/threads_t.h index 99e3f7367a..ddc060e8c3 100644 --- a/targets/COMMON/threads_t.h +++ b/targets/COMMON/threads_t.h @@ -6,6 +6,9 @@ typedef struct threads_s { int one; int two; int three; + int slot1_proc_one; + int slot1_proc_two; + int slot1_proc_three; } threads_t; #endif /* _THREADS_T_H_ */ diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 5623231511..28c943b3d4 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -222,7 +222,7 @@ double cpuf; char uecap_xer[1024],uecap_xer_in=0; int oaisim_flag=0; -threads_t threads= {-1,-1,-1,-1}; +threads_t threads= {-1,-1,-1,-1,-1,-1,-1}; /* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed * this is very hackish - find a proper solution @@ -640,6 +640,9 @@ static void get_options (int argc, char **argv) { LONG_OPTION_THREADONESUBFRAME, LONG_OPTION_THREADTWOSUBFRAME, LONG_OPTION_THREADTHREESUBFRAME, + LONG_OPTION_THREADSLOT1PROCONE, + LONG_OPTION_THREADSLOT1PROCTWO, + LONG_OPTION_THREADSLOT1PROCTHREE, LONG_OPTION_DEMOD_SHIFT, #if T_TRACER LONG_OPTION_T_PORT, @@ -677,6 +680,9 @@ static void get_options (int argc, char **argv) { {"threadOneSubframe", required_argument, NULL, LONG_OPTION_THREADONESUBFRAME}, {"threadTwoSubframe", required_argument, NULL, LONG_OPTION_THREADTWOSUBFRAME}, {"threadThreeSubframe", required_argument, NULL, LONG_OPTION_THREADTHREESUBFRAME}, + {"threadSlot1ProcOne", required_argument, NULL, LONG_OPTION_THREADSLOT1PROCONE}, + {"threadSlot1ProcTwo", required_argument, NULL, LONG_OPTION_THREADSLOT1PROCTWO}, + {"threadSlot1ProcThree", required_argument, NULL, LONG_OPTION_THREADSLOT1PROCTHREE}, {"dlsch-demod-shift", required_argument, NULL, LONG_OPTION_DEMOD_SHIFT}, #if T_TRACER {"T_port", required_argument, 0, LONG_OPTION_T_PORT}, @@ -811,6 +817,15 @@ static void get_options (int argc, char **argv) { case LONG_OPTION_THREADTHREESUBFRAME: threads.three=atoi(optarg); break; + case LONG_OPTION_THREADSLOT1PROCONE: + threads.slot1_proc_one=atoi(optarg); + break; + case LONG_OPTION_THREADSLOT1PROCTWO: + threads.slot1_proc_two=atoi(optarg); + break; + case LONG_OPTION_THREADSLOT1PROCTHREE: + threads.slot1_proc_three=atoi(optarg); + break; case LONG_OPTION_DEMOD_SHIFT: { extern int16_t dlsch_demod_shift; dlsch_demod_shift = atof(optarg); diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index b438d9eee2..4d9d145c68 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -81,6 +81,7 @@ extern void kill_eNB_proc(int inst); extern int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg); extern void fill_ue_band_info(void); extern void init_UE(int); +extern void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_t *cpuset, char * name); extern void reset_opp_meas(void); extern void print_opp_meas(void); diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index fda1c53d7e..fb22f29961 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -498,12 +498,13 @@ static void *UE_thread_rxn_txnp4(void *arg) { sprintf(threadname,"UE_%d_proc_%d", UE->Mod_id, proc->sub_frame_start); cpu_set_t cpuset; CPU_ZERO(&cpuset); + if ( (proc->sub_frame_start+1)%RX_NB_TH == 0 && threads.one != -1 ) CPU_SET(threads.one, &cpuset); if ( (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.two != -1 ) CPU_SET(threads.two, &cpuset); if ( (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.three != -1 ) - CPU_SET(threads.three, &cpuset); + CPU_SET(threads.three, &cpuset); //CPU_SET(threads.three, &cpuset); init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset, threadname); @@ -549,7 +550,11 @@ static void *UE_thread_rxn_txnp4(void *arg) { (sf_type==SF_UL? "SF_UL" : (sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE")))); } +#ifdef UE_SLOT_PARALLELISATION + phy_procedures_slot_parallelization_UE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); +#else phy_procedures_UE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); +#endif } #if UE_TIMING_TRACE @@ -856,261 +861,6 @@ void *UE_thread(void *arg) { return NULL; } -#ifdef UE_SLOT_PARALLELISATION -void *UE_thread_fep_slot1(void *arg) { - - static __thread int UE_thread_rxtx_retval; - struct rx_tx_thread_data *rtd = arg; - UE_rxtx_proc_t *proc = rtd->proc; - PHY_VARS_UE *ue = rtd->UE; - - char threadname[256]; - proc->subframe_rx=proc->sub_frame_start; - sprintf(threadname,"UE_SLOT1_PROC_%d", proc->sub_frame_start); - cpu_set_t cpuset; - CPU_ZERO(&cpuset); - if ( (proc->sub_frame_start+1)%2 == 0 ) - CPU_SET(0, &cpuset); - if ( (proc->sub_frame_start+1)%2 == 1 ) - CPU_SET(4, &cpuset); - init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset, - threadname); - - - uint8_t l; - uint8_t compute_llrs_slot1; - - proc->instance_cnt_fep_slot1=-1; - - while (!oai_exit) { - if (pthread_mutex_lock(&proc->mutex_fep_slot1) != 0) { - LOG_E( PHY, "[SCHED][UE] error locking mutex for UE FEP Slo1\n" ); - exit_fun("nothing to add"); - } - while (proc->instance_cnt_fep_slot1 < 0) { - // most of the time, the thread is waiting here - pthread_cond_wait( &proc->cond_fep_slot1, &proc->mutex_fep_slot1 ); - } - if (pthread_mutex_unlock(&proc->mutex_fep_slot1) != 0) { - LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE FEP Slo1\n" ); - exit_fun("nothing to add"); - } - - // Start Thread Processing - LOG_I(PHY," [Th-Slave] ==> execute fep slot1 thread for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); -#if 1 - int frame_rx = proc->frame_rx; - int subframe_rx = proc->subframe_rx; - uint8_t pilot0; - uint8_t pilot1; - uint8_t slot1; - - slot1 = (subframe_rx<<1) + 1; - pilot0 = 0; - if (ue->frame_parms.Ncp == 0) { // normal prefix - pilot1 = 4; - } else { // extended prefix - pilot1 = 3; - } - - // do first symbol of next downlink subframe for channel estimation - int next_subframe_rx = (1+subframe_rx)%10; - uint8_t next_subframe_slot0 = next_subframe_rx<<1; - // 1- perform FFT for pilot ofdm symbols first (ofdmSym0 next subframe ofdmSym11) - if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) - { - //LOG_I(PHY,"[Th-Slave] FFT symbol %d slot %d \n", pilot0, next_subframe_slot0); - front_end_fft(ue, - pilot0, - next_subframe_slot0, - 0, - 0); - } - //LOG_I(PHY,"[Th-Slave]FFT symbol %d slot %d \n",pilot1,slot1); - front_end_fft(ue, - pilot1, - slot1, - 0, - 0); - // 2- perform FFT for other ofdm symbols other than pilots - for (l=1; lframe_parms.symbols_per_tti>>1; l++) - { - if( (l != pilot0) && (l != pilot1)) - { - //LOG_I(PHY,"[Th-Slave]FFT symbol %d slot %d\n",l,slot1); - start_meas(&ue->ofdm_demod_stats); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); - front_end_fft(ue, - l, - slot1, - 0, - 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); - stop_meas(&ue->ofdm_demod_stats); - } - } // for l=1..l2 - - // 3- perform Channel Estimation for slot1 - for (l=1; lframe_parms.symbols_per_tti>>1; l++) - { - uint32_t wait=0; - if(l==pilot1) - { - LOG_I(PHY,"[Th-Slave] ==> wait pilot0 slot1 channel estimation is ready \n"); - while(proc->chan_est_pilot0_slot1_available==0) - { - //wait until channel estimation for pilot0/slot1 is available - usleep(1); - wait++; - } - } - front_end_chanEst(ue, - l, - slot1, - 0); - - //LOG_I(PHY,"[Th-Slave]ChanEst symbol %d slot %d wait%d\n",l,slot1,wait); - ue_measurement_procedures(l-1,ue,proc,0,1+(subframe_rx<<1),0,ue->mode); - } - //LOG_I(PHY,"[Th-Slave]ChanEst symbol %d slot %d\n",0,next_subframe_slot0); - front_end_chanEst(ue, - 0, - next_subframe_slot0, - 0); - - if ( (subframe_rx == 0) && (ue->decode_MIB == 1)) - { - ue_pbch_procedures(0,ue,proc,0); - } -#endif - LOG_I(PHY," [Th-Slave] ==> FFT/CHanEst Done for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); - - LOG_I(PHY," [Th-Slave] ==> Start LLR Comuptation slot1 for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); - -#if 1 - // wait until dci info are available - uint32_t wait=0; - while(proc->dci_slot0_available==0) // (proc->dci_slot0_available==0) - { - //wait until channel estimation for pilot0/slot1 is available - usleep(1); - wait++; - } - // check if a dl grant was received on a DCI - compute_llrs_slot1 = 0; - if(ue->dlsch[subframe_rx&0x1][0][0]->active || - ((ue->dlsch_SI[0]) && (ue->dlsch_SI[0]->active == 1)) || - ((ue->dlsch_p[0]) && (ue->dlsch_p[0]->active == 1)) || - ((ue->dlsch_ra[0]) && (ue->dlsch_ra[0]->active == 1)) - ) - { - compute_llrs_slot1 = 1; - } - else - { - proc->llr_slot1_available = 1; - } - LOG_I(PHY,"[Th-Slave] compute llrs slot-1 %d AbsSubframe %d.%d \n",compute_llrs_slot1,frame_rx%1024,subframe_rx); - - if(compute_llrs_slot1) - { - // wait until computation of first ofdm symbol is done - uint32_t wait=0; - while(proc->first_symbol_available==0) - { - //wait until channel estimation for pilot0/slot1 is available - usleep(1); - wait++; - } - - // start slave thread for Pdsch Procedure (slot1) - // do procedures for C-RNTI - //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure (slot1) wait %d \n",frame_rx%1024,subframe_rx,wait); - //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure PDSCH Active %d \n",frame_rx%1024,subframe_rx, ue->dlsch[subframe_rx&0x1][0][0]->active); - if (ue->dlsch[subframe_rx&0x1][0][0]->active == 1) { - //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure PDSCH \n",frame_rx%1024,subframe_rx); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); - start_meas(&ue->pdsch_procedures_stat); - ue_pdsch_procedures(ue, - proc, - 0, - PDSCH, - ue->dlsch[subframe_rx&0x1][0][0], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - 0); - stop_meas(&ue->pdsch_procedures_stat); - } - - // do procedures for SI-RNTI - if ((ue->dlsch_SI[0]) && (ue->dlsch_SI[0]->active == 1)) { - //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure SI-PDSCH \n",frame_rx%1024,subframe_rx); - ue_pdsch_procedures(ue, - proc, - 0, - SI_PDSCH, - ue->dlsch_SI[0], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - 0); - } - - // do procedures for P-RNTI - if ((ue->dlsch_p[0]) && (ue->dlsch_p[0]->active == 1)) { - //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure P-PDSCH \n",frame_rx%1024,subframe_rx); - ue_pdsch_procedures(ue, - proc, - 0, - P_PDSCH, - ue->dlsch_p[0], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - 0); - } - // do procedures for RA-RNTI - if ((ue->dlsch_ra[0]) && (ue->dlsch_ra[0]->active == 1)) { - //LOG_I(PHY,"[Th-Slave] AbsSubframe %d.%d Pdsch Procedure RA-PDSCH \n",frame_rx%1024,subframe_rx); - ue_pdsch_procedures(ue, - proc, - 0, - RA_PDSCH, - ue->dlsch_ra[0], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - 0); - } - - //LOG_I(PHY,"Set available llrs slot1 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); - proc->llr_slot1_available = 1; - } -#endif - - LOG_I(PHY," [Th-Slave] ==> End slot1 Thread for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); - - // End Thread Processing - - if (pthread_mutex_lock(&proc->mutex_fep_slot1) != 0) { - LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); - exit_fun("noting to add"); - } - proc->instance_cnt_fep_slot1--; - if (pthread_mutex_unlock(&proc->mutex_fep_slot1) != 0) { - LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE FEP Slo1\n" ); - exit_fun("noting to add"); - } - } - - - // thread finished - free(arg); - return &UE_thread_rxtx_retval; -} -#endif - /*! * \brief Initialize the UE theads. * Creates the UE threads: @@ -1125,9 +875,6 @@ void *UE_thread_fep_slot1(void *arg) { */ void init_UE_threads(PHY_VARS_UE *UE) { struct rx_tx_thread_data *rtd; -#ifdef UE_SLOT_PARALLELISATION - struct fep_slot1_thread_data *fep_slot1_data; -#endif pthread_attr_init (&UE->proc.attr_ue); pthread_attr_setstacksize(&UE->proc.attr_ue,8192);//5*PTHREAD_STACK_MIN); @@ -1151,9 +898,13 @@ void init_UE_threads(PHY_VARS_UE *UE) { pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, UE_thread_rxn_txnp4, rtd); #ifdef UE_SLOT_PARALLELISATION - pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_fep_slot1,NULL); - pthread_cond_init(&UE->proc.proc_rxtx[i].cond_fep_slot1,NULL); - pthread_create(&UE->proc.proc_rxtx[i].pthread_fep_slot1,NULL,UE_thread_fep_slot1, rtd); + //pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot0_dl_processing,NULL); + //pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot0_dl_processing,NULL); + //pthread_create(&UE->proc.proc_rxtx[i].pthread_slot0_dl_processing,NULL,UE_thread_slot0_dl_processing, rtd); + + pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot1_dl_processing,NULL); + pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot1_dl_processing,NULL); + pthread_create(&UE->proc.proc_rxtx[i].pthread_slot1_dl_processing,NULL,UE_thread_slot1_dl_processing, rtd); #endif } diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index d07cd759d1..10366d5b34 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -184,7 +184,7 @@ extern LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; double cpuf; #include "threads_t.h" -threads_t threads= {-1,-1,-1}; +threads_t threads= {-1,-1,-1,-1,-1,-1,-1}; //#ifdef XFORMS int otg_enabled; -- GitLab