diff --git a/doc/FEATURE_SET.md b/doc/FEATURE_SET.md index d08c1e9b2a..cd543412d1 100644 --- a/doc/FEATURE_SET.md +++ b/doc/FEATURE_SET.md @@ -359,6 +359,7 @@ The following features are valid for the gNB and the 5G-NR UE. - Support for master cell group configuration - Interface with NGAP for the interactions with the AMF - Interface with F1AP for CU/DU split deployment option + - Periodic RRC measurements of serving cell (no A/B events) **gNB X2AP** - Integration of X2AP messages and procedures for the exchanges with the eNB over X2 interface supporting the NSA setup according to 36.423 Rel. 15 diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 8b022adc62..3fdb18eaae 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -646,7 +646,7 @@ void UE_processing(nr_rxtx_thread_data_t *rxtxD) { UE_nr_rxtx_proc_t *proc = &rxtxD->proc; PHY_VARS_NR_UE *UE = rxtxD->UE; uint8_t gNB_id = 0; - NR_UE_PDCCH_CONFIG phy_pdcch_config={0}; + nr_phy_data_t phy_data = {0}; if (IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa) { /* send tick to RLC and PDCP every ms */ @@ -662,7 +662,7 @@ void UE_processing(nr_rxtx_thread_data_t *rxtxD) { if(UE->if_inst != NULL && UE->if_inst->dl_indication != NULL) { nr_downlink_indication_t dl_indication; - nr_fill_dl_indication(&dl_indication, NULL, NULL, proc, UE, gNB_id, &phy_pdcch_config); + nr_fill_dl_indication(&dl_indication, NULL, NULL, proc, UE, gNB_id, &phy_data); UE->if_inst->dl_indication(&dl_indication, NULL); } @@ -671,7 +671,7 @@ void UE_processing(nr_rxtx_thread_data_t *rxtxD) { phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, no_relay, NULL ); #else uint64_t a=rdtsc_oai(); - phy_procedures_nrUE_RX(UE, proc, gNB_id, &phy_pdcch_config, &rxtxD->txFifo); + phy_procedures_nrUE_RX(UE, proc, gNB_id, &phy_data, &rxtxD->txFifo); LOG_D(PHY, "In %s: slot %d, time %llu\n", __FUNCTION__, proc->nr_slot_rx, (rdtsc_oai()-a)/3500); #endif @@ -798,10 +798,10 @@ void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { int computeSamplesShift(PHY_VARS_NR_UE *UE) { int samples_shift = -(UE->rx_offset>>1); - UE->rx_offset = 0; // reset so that it is not applied falsely in case of SSB being only in every second frame - UE->max_pos_fil = 0; // reset IIR filter when sample shift is applied if (samples_shift != 0) { LOG_I(NR_PHY,"Adjusting frame in time by %i samples\n", samples_shift); + UE->rx_offset = 0; // reset so that it is not applied falsely in case of SSB being only in every second frame + UE->max_pos_fil += samples_shift << 15; // reset IIR filter when sample shift is applied } return samples_shift; } @@ -889,7 +889,7 @@ void *UE_thread(void *arg) { continue; } - if (start_rx_stream==0) { + if (start_rx_stream == 0) { start_rx_stream=1; syncInFrame(UE, ×tamp); UE->rx_offset=0; diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 99c9b956e2..0a9afc5f9a 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -413,12 +413,6 @@ int main( int argc, char **argv ) { if (set_exe_prio) set_priority(79); - if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) - { - fprintf(stderr, "mlockall: %s\n", strerror(errno)); - return EXIT_FAILURE; - } - //uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2; PHY_VARS_NR_UE *UE[MAX_NUM_CCs]; start_background_system(); @@ -529,7 +523,6 @@ int main( int argc, char **argv ) { pthread_mutex_init(&ue_pf_po_mutex, NULL); memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*NUMBER_OF_UE_MAX*MAX_NUM_CCs); set_latency_target(); - mlockall(MCL_CURRENT | MCL_FUTURE); if(IS_SOFTMODEM_DOSCOPE) { load_softscope("nr",PHY_vars_UE_g[0][0]); diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 1b6441f922..a27a4abe17 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -34,6 +34,7 @@ #include "PHY/NR_REFSIG/nr_refsig.h" #include "PHY/MODULATION/nr_modulation.h" #include "openair2/COMMON/prs_nr_paramdef.h" +#include "SCHED_NR_UE/harq_nr.h" extern uint16_t beta_cqi[16]; @@ -627,21 +628,74 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) } } +void free_nr_ue_dl_harq(NR_DL_UE_HARQ_t* harq_list, int number_of_processes, int num_rb) { + + uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS; + if (num_rb != 273) { + a_segments = a_segments*num_rb; + a_segments = (a_segments/273)+1; + } + + for (int i=0; iframe_parms.N_RB_DL; + int num_cw = NR_MAX_NB_LAYERS > 4? 2:1; for (int i = 0; i < NUMBER_OF_CONNECTED_gNB_MAX; i++) { - for (int j = 0; j < 2; j++) { - free_nr_ue_dlsch(&ue->dlsch[i][j], N_RB_DL); - if (j==0) - free_nr_ue_ulsch(&ue->ulsch[i], N_RB_DL, &ue->frame_parms); + for (int j = 0; j < num_cw; j++) { + free_nr_ue_dl_harq(ue->dl_harq_processes[j], NR_MAX_DLSCH_HARQ_PROCESSES, N_RB_DL); + free_nr_ue_ulsch(&ue->ulsch[i], N_RB_DL, &ue->frame_parms); } + } +} - free_nr_ue_dlsch(&ue->dlsch_SI[i], N_RB_DL); - free_nr_ue_dlsch(&ue->dlsch_ra[i], N_RB_DL); +void nr_init_harq_processes(NR_DL_UE_HARQ_t* harq_list, int number_of_processes, int num_rb) { + + int a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS; //number of segments to be allocated + if (num_rb != 273) { + a_segments = a_segments*num_rb; + a_segments = (a_segments/273)+1; } - free_nr_ue_dlsch(&ue->dlsch_MCH[0], N_RB_DL); + uint32_t dlsch_bytes = a_segments*1056; // allocated bytes per segment + + for (int i=0; idlsch[i][j] = new_nr_ue_dlsch(1,NR_MAX_DLSCH_HARQ_PROCESSES,NSOFT,ue->max_ldpc_iterations,ue->frame_parms.N_RB_DL))!=NULL,"Can't get ue dlsch structures\n"); - LOG_D(PHY,"dlsch[%d][%d] => %p\n",i,j,ue->dlsch[i][j]); + nr_init_harq_processes(ue->dl_harq_processes[j], NR_MAX_DLSCH_HARQ_PROCESSES, ue->frame_parms.N_RB_DL); if (j==0) { AssertFatal((ue->ulsch[i] = new_nr_ue_ulsch(ue->frame_parms.N_RB_UL, NR_MAX_ULSCH_HARQ_PROCESSES,&ue->frame_parms))!=NULL,"Can't get ue ulsch structures\n"); LOG_D(PHY,"ulsch[%d] => %p\n",i,ue->ulsch[i]); } } - - ue->dlsch_SI[i] = new_nr_ue_dlsch(1,1,NSOFT,ue->max_ldpc_iterations,ue->frame_parms.N_RB_DL); - ue->dlsch_ra[i] = new_nr_ue_dlsch(1,1,NSOFT,ue->max_ldpc_iterations,ue->frame_parms.N_RB_DL); } - //ue->frame_parms.pucch_config_common.deltaPUCCH_Shift = 1; - ue->dlsch_MCH[0] = new_nr_ue_dlsch(1,NR_MAX_DLSCH_HARQ_PROCESSES,NSOFT,MAX_LDPC_ITERATIONS_MBSFN,ue->frame_parms.N_RB_DL); - for(int i=0; i<5; i++) ue->dl_stats[i] = 0; } diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h index 2b11371de8..40d9d12d3c 100644 --- a/openair1/PHY/INIT/phy_init.h +++ b/openair1/PHY/INIT/phy_init.h @@ -418,6 +418,8 @@ void reset_DLSCH_struct(const PHY_VARS_gNB *gNB, processingData_L1tx_t *msg); void RCconfig_nrUE_prs(void *cfg); void init_nr_prs_ue_vars(PHY_VARS_NR_UE *ue); +void nr_init_harq_processes(NR_DL_UE_HARQ_t* harq_list, int number_of_processes, int num_rb); +void free_nr_ue_dl_harq(NR_DL_UE_HARQ_t* harq_list, int number_of_processes, int num_rb); /** @} */ #endif diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c index e56a4607e2..e9fcd35f6b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c @@ -74,13 +74,12 @@ void nr_fill_ulsch(PHY_VARS_gNB *gNB, harq->slot=slot; harq->handled = 0; harq->status= NR_ACTIVE; - harq->new_rx = harq->ndi != ulsch_pdu->pusch_data.new_data_indicator; - if (harq->new_rx) { - harq->ndi = ulsch_pdu->pusch_data.new_data_indicator; + harq->new_rx = ulsch_pdu->pusch_data.new_data_indicator; + LOG_D(PHY,"ULSCH ID %d RNTI %x HARQ PID %d new data indicator %d\n",ulsch_id, ulsch_pdu->rnti, harq_pid, ulsch_pdu->pusch_data.new_data_indicator); + if (harq->new_rx) harq->round = 0; - } else { + else harq->round++; - } memcpy((void*)&ulsch->harq_processes[harq_pid]->ulsch_pdu, (void*)ulsch_pdu, sizeof(nfapi_nr_pusch_pdu_t)); diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index 4118145f64..c51ec29b77 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -104,7 +104,6 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL) ulsch->max_ldpc_iterations = max_ldpc_iterations; for (i=0; iharq_processes[i] = (NR_UL_gNB_HARQ_t *)malloc16_clear(sizeof(NR_UL_gNB_HARQ_t)); ulsch->harq_processes[i]->b = (uint8_t*)malloc16_clear(ulsch_bytes); ulsch->harq_processes[i]->c = (uint8_t**)malloc16_clear(a_segments*sizeof(uint8_t *)); @@ -442,30 +441,16 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING,1); harq_process->TBS = pusch_pdu->pusch_data.tb_size; - harq_process->round = nr_rv_to_round(pusch_pdu->pusch_data.rv_index); - harq_process->new_rx = false; // flag to indicate if this is a new reception for this harq (initialized to false) dtx_det = 0; - if (harq_process->round == 0) { - harq_process->new_rx = true; - harq_process->ndi = pusch_pdu->pusch_data.new_data_indicator; - } - - // this happens if there was a DTX in round 0 - if (harq_process->ndi != pusch_pdu->pusch_data.new_data_indicator) { - harq_process->new_rx = true; - harq_process->ndi = pusch_pdu->pusch_data.new_data_indicator; - - LOG_D(PHY,"Missed ULSCH detection. NDI toggled but rv %d does not correspond to first reception\n",pusch_pdu->pusch_data.rv_index); - } A = (harq_process->TBS)<<3; // target_code_rate is in 0.1 units float Coderate = (float) pusch_pdu->target_code_rate / 10240.0f; - LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, Coderate %f RV %d round %d\n", - harq_pid, A, G, mcs, n_layers, nb_rb, Qm, Coderate, pusch_pdu->pusch_data.rv_index, harq_process->round); + LOG_D(PHY,"ULSCH Decoding, harq_pid %d rnti %x TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, Coderate %f RV %d round %d new RX %d\n", + harq_pid, ulsch->rnti, A, G, mcs, n_layers, nb_rb, Qm, Coderate, pusch_pdu->pusch_data.rv_index, harq_process->round, harq_process->new_rx); p_decParams->BG = pusch_pdu->maintenance_parms_v3.ldpcBaseGraph; int kc; @@ -701,7 +686,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for slot %d TBS %d\n", phy_vars_gNB->Mod_id,harq_process->slot,harq_process->TBS); harq_process->status = SCH_IDLE; - harq_process->round = 0; + harq_process->round = 0; ulsch->harq_mask &= ~(1 << harq_pid); LOG_D(PHY, "ULSCH received ok \n"); diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c index 045197adc1..c387c7f38b 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c @@ -27,7 +27,7 @@ #include "executables/softmodem-common.h" #include "common/utils/LOG/vcd_signal_dumper.h" -#define DEBUG_PHY +//#define DEBUG_PHY // Adjust location synchronization point to account for drift // The adjustment is performed once per frame based on the @@ -75,14 +75,14 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, // filter position to reduce jitter if (clear == 1) - ue->max_pos_fil = max_pos; + ue->max_pos_fil = max_pos << 15; else - ue->max_pos_fil = ((ue->max_pos_fil * coef) + (max_pos * ncoef)) >> 15; + ue->max_pos_fil = ((ue->max_pos_fil * coef) >> 15) + (max_pos * ncoef); // do not filter to have proactive timing adjustment - //ue->max_pos_fil = max_pos; + //ue->max_pos_fil = max_pos << 15; - int diff = ue->max_pos_fil - sync_pos; + int diff = (ue->max_pos_fil >> 15) - sync_pos; if (frame_parms->freq_range==nr_FR2) sync_offset = 2; @@ -118,7 +118,7 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, } #ifdef DEBUG_PHY - LOG_D(PHY,"AbsSubframe %d: diff = %i, rx_offset (final) = %i : clear = %d, max_pos = %d, max_pos_fil = %d, max_val = %d, sync_pos %d\n", + LOG_I(PHY,"AbsSubframe %d: diff = %i, rx_offset (final) = %i : clear = %d, max_pos = %d, max_pos_fil = %d, max_val = %d, sync_pos %d\n", subframe, diff, ue->rx_offset, diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index f15b99fb1c..8c016b862a 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -27,6 +27,7 @@ #include "PHY/NR_REFSIG/nr_refsig.h" #include "PHY/NR_REFSIG/dmrs_nr.h" #include "PHY/NR_REFSIG/ptrs_nr.h" +#include "PHY/NR_REFSIG/nr_mod_table.h" #include "PHY/NR_TRANSPORT/nr_sch_dmrs.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "common/utils/nr/nr_common.h" @@ -39,7 +40,26 @@ //#define DEBUG_PBCH //#define DEBUG_PRS_CHEST // To enable PRS Matlab dumps //#define DEBUG_PRS_PRINTS // To enable PRS channel estimation debug logs -extern short nr_qpsk_mod_table[8]; + +#define CH_INTERP 0 +#define NO_INTERP 1 + +/* Generic function to find the peak of channel estimation buffer */ +void peak_estimator(int32_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t *peak_val) +{ + int32_t max_val = 0, max_idx = 0, abs_val = 0; + for(int k = 0; k < buf_len; k++) + { + abs_val = squaredMod(((c16_t*)buffer)[k]); + if(abs_val > max_val) + { + max_val = abs_val; + max_idx = k; + } + } + *peak_val = max_val; + *peak_idx = max_idx; +} int nr_prs_channel_estimation(uint8_t gNB_id, uint8_t rsc_id, @@ -545,29 +565,6 @@ int nr_prs_channel_estimation(uint8_t gNB_id, return(0); } -#define CH_INTERP 0 -#define NO_INTERP 1 - -/* Generic function to find the peak of channel estimation buffer */ -void peak_estimator(int32_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t *peak_val) -{ - int32_t max_val = 0, max_idx = 0, abs_val = 0; - for(int k = 0; k < buf_len; k++) - { - abs_val = squaredMod(((c16_t*)buffer)[k]); - if(abs_val > max_val) - { - max_val = abs_val; - max_idx = k; - } - } - *peak_val = max_val; - *peak_idx = max_idx; -} - -#define CH_INTERP 0 -#define NO_INTERP 1 - int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, @@ -990,7 +987,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, } if (dmrss == 2) - UEscopeCopy(ue, pbchDlChEstimateTime, (void*)dl_ch_estimates_time, sizeof(struct complex16), ue->frame_parms.nb_antennas_rx, idftsizeidx); + UEscopeCopy(ue, pbchDlChEstimateTime, (void*)dl_ch_estimates_time, sizeof(struct complex16), ue->frame_parms.nb_antennas_rx, ue->frame_parms.ofdm_symbol_size); return(0); } @@ -1223,6 +1220,10 @@ void nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = ch_sum[0] / 3; ch[1] = ch_sum[1] / 3; multadd_real_vector_complex_scalar(filt16a_1, ch, dl_ch, 16); +#ifdef DEBUG_PDCCH + for (int m =0; m<12; m++) + printf("data : dl_ch -> (%d,%d)\n",dl_ch[0+2*m],dl_ch[1+2*m]); +#endif dl_ch += 24; ch_sum[0] = 0; ch_sum[1] = 0; @@ -2206,7 +2207,7 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, unsigned char symbol, uint32_t nb_re_pdsch, uint16_t rnti, - RX_type_t rx_type) + NR_UE_DLSCH_t dlsch[2]) { //#define DEBUG_DL_PTRS 1 int32_t *ptrs_re_symbol = NULL; @@ -2225,30 +2226,30 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, uint16_t *nb_rb = NULL; if(dlsch0_harq->status == ACTIVE) { - symbInSlot = dlsch0_harq->start_symbol + dlsch0_harq->nb_symbols; - startSymbIndex = &dlsch0_harq->start_symbol; - nbSymb = &dlsch0_harq->nb_symbols; - L_ptrs = &dlsch0_harq->PTRSTimeDensity; - K_ptrs = &dlsch0_harq->PTRSFreqDensity; - dmrsSymbPos = &dlsch0_harq->dlDmrsSymbPos; - ptrsSymbPos = &dlsch0_harq->ptrs_symbols; - ptrsSymbIdx = &dlsch0_harq->ptrs_symbol_index; - ptrsReOffset = &dlsch0_harq->PTRSReOffset; - dmrsConfigType = &dlsch0_harq->dmrsConfigType; - nb_rb = &dlsch0_harq->nb_rb; + symbInSlot = dlsch[0].dlsch_config.start_symbol + dlsch[0].dlsch_config.number_symbols; + startSymbIndex = &dlsch[0].dlsch_config.start_symbol; + nbSymb = &dlsch[0].dlsch_config.number_symbols; + L_ptrs = &dlsch[0].dlsch_config.PTRSTimeDensity; + K_ptrs = &dlsch[0].dlsch_config.PTRSFreqDensity; + dmrsSymbPos = &dlsch[0].dlsch_config.dlDmrsSymbPos; + ptrsReOffset = &dlsch[0].dlsch_config.PTRSReOffset; + dmrsConfigType = &dlsch[0].dlsch_config.dmrsConfigType; + nb_rb = &dlsch[0].dlsch_config.number_rbs; + ptrsSymbPos = &dlsch[0].ptrs_symbols; + ptrsSymbIdx = &dlsch[0].ptrs_symbol_index; } if(dlsch1_harq) { - symbInSlot = dlsch1_harq->start_symbol + dlsch0_harq->nb_symbols; - startSymbIndex = &dlsch1_harq->start_symbol; - nbSymb = &dlsch1_harq->nb_symbols; - L_ptrs = &dlsch1_harq->PTRSTimeDensity; - K_ptrs = &dlsch1_harq->PTRSFreqDensity; - dmrsSymbPos = &dlsch1_harq->dlDmrsSymbPos; - ptrsSymbPos = &dlsch1_harq->ptrs_symbols; - ptrsSymbIdx = &dlsch1_harq->ptrs_symbol_index; - ptrsReOffset = &dlsch1_harq->PTRSReOffset; - dmrsConfigType = &dlsch1_harq->dmrsConfigType; - nb_rb = &dlsch1_harq->nb_rb; + symbInSlot = dlsch[1].dlsch_config.start_symbol + dlsch[1].dlsch_config.number_symbols; + startSymbIndex = &dlsch[1].dlsch_config.start_symbol; + nbSymb = &dlsch[1].dlsch_config.number_symbols; + L_ptrs = &dlsch[1].dlsch_config.PTRSTimeDensity; + K_ptrs = &dlsch[1].dlsch_config.PTRSFreqDensity; + dmrsSymbPos = &dlsch[1].dlsch_config.dlDmrsSymbPos; + ptrsReOffset = &dlsch[1].dlsch_config.PTRSReOffset; + dmrsConfigType = &dlsch[1].dlsch_config.dmrsConfigType; + nb_rb = &dlsch[1].dlsch_config.number_rbs; + ptrsSymbPos = &dlsch[1].ptrs_symbols; + ptrsSymbIdx = &dlsch[1].ptrs_symbol_index; } /* loop over antennas */ for (int aarx=0; aarxnb_antennas_rx; aarx++) { diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index f01a2af606..d1cab858c7 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -107,7 +107,8 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, void nr_ue_measurements(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t slot); + uint8_t slot, + NR_UE_DLSCH_t *dlsch); void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue, uint8_t gNB_index, @@ -134,7 +135,7 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, unsigned char symbol, uint32_t nb_re_pdsch, uint16_t rnti, - RX_type_t rx_type); + NR_UE_DLSCH_t dlsch[2]); float_t get_nr_RSRP(module_id_t Mod_id,uint8_t CC_id,uint8_t gNB_index); diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c index b0756282a3..69a1a88916 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c @@ -112,14 +112,13 @@ float_t get_nr_RSRP(module_id_t Mod_id,uint8_t CC_id,uint8_t gNB_index) void nr_ue_measurements(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - uint8_t slot) + uint8_t slot, + NR_UE_DLSCH_t *dlsch) { int aarx, aatx, gNB_id = 0; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; int ch_offset = frame_parms->ofdm_symbol_size*2; - NR_UE_DLSCH_t *dlsch = ue->dlsch[gNB_id][0]; - uint8_t harq_pid = dlsch->current_harq_pid; - int N_RB_DL = dlsch->harq_processes[harq_pid]->nb_rb; + int N_RB_DL = dlsch->dlsch_config.number_rbs; ue->measurements.nb_antennas_rx = frame_parms->nb_antennas_rx; diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index cf237ef1fe..315519bf99 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -682,18 +682,22 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, int32_t avgs; int32_t avgP[4]; int n_rb,rb_offset; + get_coreset_rballoc(rel15->coreset.frequency_domain_resource,&n_rb,&rb_offset); // Pointers to extracted PDCCH symbols in frequency-domain. - int32_t rx_size = 4*273*12; - __attribute__ ((aligned(32))) int32_t rxdataF_ext[4*frame_parms->nb_antennas_rx][rx_size]; - __attribute__ ((aligned(32))) int32_t rxdataF_comp[4*frame_parms->nb_antennas_rx][rx_size]; - __attribute__ ((aligned(32))) int32_t pdcch_dl_ch_estimates_ext[4*frame_parms->nb_antennas_rx][rx_size]; + int32_t rx_size = 4*n_rb*12; + __attribute__ ((aligned(32))) int32_t rxdataF_ext[frame_parms->nb_antennas_rx][rx_size]; + __attribute__ ((aligned(32))) int32_t rxdataF_comp[frame_parms->nb_antennas_rx][rx_size]; + __attribute__ ((aligned(32))) int32_t pdcch_dl_ch_estimates_ext[frame_parms->nb_antennas_rx][rx_size]; + + memset(rxdataF_comp, 0, sizeof(rxdataF_comp)); // Pointer to llrs, 4-bit resolution. - int32_t llr_size = 2*4*100*12; + int32_t llr_size = 2*4*n_rb*9; int16_t llr[llr_size]; - get_coreset_rballoc(rel15->coreset.frequency_domain_resource,&n_rb,&rb_offset); + memset(llr, 0, sizeof(llr)); + LOG_D(PHY,"pdcch coreset: freq %x, n_rb %d, rb_offset %d\n", rel15->coreset.frequency_domain_resource[0],n_rb,rb_offset); for (int s=rel15->coreset.StartSymbolIndex; s<(rel15->coreset.StartSymbolIndex+rel15->coreset.duration); s++) { @@ -863,8 +867,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int16_t *pdcch_e_rx, fapi_nr_dci_indication_t *dci_ind, - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, - NR_UE_PDCCH_CONFIG *phy_pdcch_config) { + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) { //int gNB_id = 0; int16_t tmp_e[16*108]; @@ -941,7 +944,6 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, } e_rx_cand_idx += 9*L*6*2; //e_rx index for next candidate (L CCEs, 6 REGs per CCE and 9 REs per REG and 2 uint16_t per RE) } - phy_pdcch_config->nb_search_space = 0; return(dci_ind->number_of_dcis); } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index e858e8d564..dc4a28aff2 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -57,107 +57,12 @@ notifiedFIFO_t freeBlocks_dl; notifiedFIFO_elt_t *msgToPush_dl; int nbDlProcessing =0; -void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlschptr, uint16_t N_RB_DL) { - - uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS; - - NR_UE_DLSCH_t *dlsch=*dlschptr; - - if (dlsch) { - if (N_RB_DL != 273) { - a_segments = a_segments*N_RB_DL; - a_segments = a_segments/273 +1; - } - - for (int i=0; iMdlharq; i++) { - if (dlsch->harq_processes[i]) { - if (dlsch->harq_processes[i]->b) { - free16(dlsch->harq_processes[i]->b,a_segments*1056); - dlsch->harq_processes[i]->b = NULL; - } - - for (int r=0; rharq_processes[i]->c[r],1056); - dlsch->harq_processes[i]->c[r] = NULL; - free16(dlsch->harq_processes[i]->d[r],5*8448); - dlsch->harq_processes[i]->d[r] = NULL; - } - free16(dlsch->harq_processes[i]->c,a_segments); - free16(dlsch->harq_processes[i]->d,a_segments); - - free16(dlsch->harq_processes[i],sizeof(NR_DL_UE_HARQ_t)); - dlsch->harq_processes[i] = NULL; - } - } - - free16(dlsch,sizeof(NR_UE_DLSCH_t)); - dlsch = NULL; - } -} - - -NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_ldpc_iterations,uint16_t N_RB_DL) { - - NR_UE_DLSCH_t *dlsch; - uint8_t exit_flag = 0; - - uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS; //number of segments to be allocated - - if (N_RB_DL != 273) { - a_segments = a_segments*N_RB_DL; - a_segments = (a_segments/273)+1; - } - - uint32_t dlsch_bytes = a_segments*1056; // allocated bytes per segment - dlsch = (NR_UE_DLSCH_t *)malloc16(sizeof(NR_UE_DLSCH_t)); - - if (dlsch) { - memset(dlsch,0,sizeof(NR_UE_DLSCH_t)); - dlsch->Kmimo = Kmimo; - dlsch->Mdlharq = Mdlharq; - dlsch->number_harq_processes_for_pdsch = Mdlharq; - dlsch->Nsoft = Nsoft; +void nr_ue_dlsch_init(NR_UE_DLSCH_t *dlsch_list, int num_dlsch, uint8_t max_ldpc_iterations) { + for (int i=0; i < num_dlsch; i++) { + NR_UE_DLSCH_t *dlsch = dlsch_list + i; + memset(dlsch, 0, sizeof(NR_UE_DLSCH_t)); dlsch->max_ldpc_iterations = max_ldpc_iterations; - - for (int i=0; iharq_processes[i] = (NR_DL_UE_HARQ_t *)malloc16(sizeof(NR_DL_UE_HARQ_t)); - - if (dlsch->harq_processes[i]) { - memset(dlsch->harq_processes[i],0,sizeof(NR_DL_UE_HARQ_t)); - init_downlink_harq_status(dlsch->harq_processes[i]); - dlsch->harq_processes[i]->first_rx=1; - dlsch->harq_processes[i]->b = (uint8_t *)malloc16(dlsch_bytes); - - if (dlsch->harq_processes[i]->b) - memset(dlsch->harq_processes[i]->b,0,dlsch_bytes); - else - exit_flag=3; - - dlsch->harq_processes[i]->c = (uint8_t **)malloc16(a_segments*sizeof(uint8_t *)); - dlsch->harq_processes[i]->d = (int16_t **)malloc16(a_segments*sizeof(int16_t *)); - for (int r=0; rharq_processes[i]->c[r] = (uint8_t *)malloc16(1056); - dlsch->harq_processes[i]->d[r] = (int16_t *)malloc16(5*8448*sizeof(int16_t)); - if (dlsch->harq_processes[i]->c[r]) - memset(dlsch->harq_processes[i]->c[r],0,1056); - if (dlsch->harq_processes[i]->d[r]) - memset(dlsch->harq_processes[i]->d[r],0,5*8448); - else - exit_flag=2; - - } - } else { - exit_flag=1; - } - } - - if (exit_flag==0) - return(dlsch); } - - LOG_D(PHY,"new_ue_dlsch with size %zu: exit_flag = %u\n",sizeof(NR_DL_UE_HARQ_t), exit_flag); - free_nr_ue_dlsch(&dlsch,N_RB_DL); - return(NULL); } void nr_dlsch_unscrambling(int16_t *llr, uint32_t size, uint8_t q, uint32_t Nid, uint32_t n_RNTI) @@ -300,7 +205,7 @@ void nr_processDLSegment(void* arg) { harq_process->d[r], w, harq_process->C, - harq_process->rvidx, + dlsch->dlsch_config.rv, harq_process->first_rx, E, harq_process->F, @@ -400,8 +305,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, uint32_t frame, uint16_t nb_symb_sch, uint8_t nr_slot_rx, - uint8_t harq_pid, - uint8_t is_crnti) { + uint8_t harq_pid) { uint32_t A,E; uint32_t G; uint32_t ret,offset; @@ -416,20 +320,20 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, // HARQ stats phy_vars_ue->dl_stats[harq_process->DLround]++; - LOG_D(PHY,"Round %d RV idx %d\n",harq_process->DLround,harq_process->rvidx); + LOG_D(PHY,"Round %d RV idx %d\n",harq_process->DLround,dlsch->dlsch_config.rv); uint8_t kc; uint16_t nb_rb;// = 30; - uint8_t dmrs_Type = harq_process->dmrsConfigType; + uint8_t dmrs_Type = dlsch->dlsch_config.dmrsConfigType; AssertFatal(dmrs_Type == 0 || dmrs_Type == 1, "Illegal dmrs_type %d\n", dmrs_Type); uint8_t nb_re_dmrs; if (dmrs_Type==NFAPI_NR_DMRS_TYPE1) { - nb_re_dmrs = 6*harq_process->n_dmrs_cdm_groups; + nb_re_dmrs = 6*dlsch->dlsch_config.n_dmrs_cdm_groups; } else { - nb_re_dmrs = 4*harq_process->n_dmrs_cdm_groups; + nb_re_dmrs = 4*dlsch->dlsch_config.n_dmrs_cdm_groups; } - uint16_t dmrs_length = get_num_dmrs(harq_process->dlDmrsSymbPos); + uint16_t dmrs_length = get_num_dmrs(dlsch->dlsch_config.dlDmrsSymbPos); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_SEGMENTATION, VCD_FUNCTION_IN); //NR_DL_UE_HARQ_t *harq_process = dlsch->harq_processes[0]; @@ -466,18 +370,18 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, return(max_ldpc_iterations + 1); } */ - nb_rb = harq_process->nb_rb; - A = harq_process->TBS; + nb_rb = dlsch->dlsch_config.number_rbs; + A = dlsch->dlsch_config.TBS; ret = dlsch->max_ldpc_iterations + 1; dlsch->last_iteration_cnt = ret; - harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, dmrs_length, harq_process->Qm,harq_process->Nl); + harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, dmrs_length, dlsch->dlsch_config.qamModOrder,dlsch->Nl); G = harq_process->G; // target_code_rate is in 0.1 units - float Coderate = (float) harq_process->R / 10240.0f; + float Coderate = (float) dlsch->dlsch_config.targetCodeRate / 10240.0f; LOG_D(PHY,"%d.%d DLSCH Decoding, harq_pid %d TBS %d (%d) G %d nb_re_dmrs %d length dmrs %d mcs %d Nl %d nb_symb_sch %d nb_rb %d Qm %d Coderate %f\n", - frame,nr_slot_rx,harq_pid,A,A/8,G, nb_re_dmrs, dmrs_length, harq_process->mcs, harq_process->Nl, nb_symb_sch, nb_rb, harq_process->Qm, Coderate); + frame,nr_slot_rx,harq_pid,A,A/8,G, nb_re_dmrs, dmrs_length, dlsch->dlsch_config.mcs, dlsch->Nl, nb_symb_sch, nb_rb, dlsch->dlsch_config.qamModOrder, Coderate); if ((A <=292) || ((A <= NR_MAX_PDSCH_TBS) && (Coderate <= 0.6667)) || Coderate <= 0.25) { p_decParams->BG = 2; @@ -503,13 +407,13 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, &harq_process->F, p_decParams->BG); - if (harq_process->C>MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*harq_process->Nl) { + if (harq_process->C>MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*dlsch->Nl) { LOG_E(PHY,"nr_segmentation.c: too many segments %d, B %d\n",harq_process->C,harq_process->B); return(-1); } if (LOG_DEBUGFLAG(DEBUG_DLSCH_DECOD) && (!frame%100)) - LOG_I(PHY,"K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, harq_process->Z, harq_process->Nl); + LOG_I(PHY,"K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, harq_process->Z, dlsch->Nl); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_SEGMENTATION, VCD_FUNCTION_OUT); @@ -519,7 +423,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, p_decParams->numMaxIter = dlsch->max_ldpc_iterations; p_decParams->outMode= 0; r_offset = 0; - uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*harq_process->Nl; //number of segments to be allocated + uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*dlsch->Nl; //number of segments to be allocated if (nb_rb != 273) { a_segments = a_segments*nb_rb; @@ -542,7 +446,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, initNotifiedFIFO(&nf); for (r=0; rC; r++) { //printf("start rx segment %d\n",r); - E = nr_get_E(G, harq_process->C, harq_process->Qm, harq_process->Nl, r); + E = nr_get_E(G, harq_process->C, dlsch->dlsch_config.qamModOrder, dlsch->Nl, r); union ldpcReqUnion id = {.s={dlsch->rnti,frame,nr_slot_rx,0,0}}; notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(ldpcDecode_ue_t), id.p, &nf, nr_processDLSegment_ptr); ldpcDecode_ue_t * rdata=(ldpcDecode_ue_t *) NotifiedFifoData(req); @@ -557,11 +461,11 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, rdata->nbSegments = harq_process->C; rdata->E = E; rdata->A = A; - rdata->Qm = harq_process->Qm; + rdata->Qm = dlsch->dlsch_config.qamModOrder; rdata->r_offset = r_offset; rdata->Kr_bytes = Kr_bytes; - rdata->rv_index = harq_process->rvidx; - rdata->Tbslbrm = harq_process->tbslbrm; + rdata->rv_index = dlsch->dlsch_config.rv; + rdata->Tbslbrm = dlsch->dlsch_config.tbslbrm; rdata->offset = offset; rdata->dlsch = dlsch; rdata->dlsch_id = 0; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 75e3717c36..2a3de5a9bc 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -110,7 +110,6 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, int32_t **dl_ch_mag_ptr, NR_DL_UE_HARQ_t *dlsch0_harq, NR_DL_UE_HARQ_t *dlsch1_harq, - RX_type_t rx_type, unsigned char harq_pid, unsigned char gNB_id, unsigned char gNB_id_i, @@ -121,21 +120,19 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, int32_t codeword_TB1, uint32_t len, uint8_t nr_slot_rx, - uint8_t beamforming_mode); + NR_UE_DLSCH_t *dlsch); /* Main Function */ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - PDSCH_t type, + NR_UE_DLSCH_t *dlsch, unsigned char gNB_id, unsigned char gNB_id_i, uint32_t frame, uint8_t nr_slot_rx, unsigned char symbol, unsigned char first_symbol_flag, - RX_type_t rx_type, - unsigned char i_mod, unsigned char harq_pid) { @@ -143,7 +140,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, NR_UE_PDSCH **pdsch_vars; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; PHY_NR_MEASUREMENTS *measurements = &ue->measurements; - NR_UE_DLSCH_t **dlsch; int avg[16]; // int avg_0[2]; @@ -156,8 +152,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, int avgs = 0;// rb; NR_DL_UE_HARQ_t *dlsch0_harq, *dlsch1_harq = NULL; - uint8_t beamforming_mode = 0; - int32_t **rxdataF_comp_ptr; int32_t **dl_ch_mag_ptr; int32_t codeword_TB0 = -1; @@ -175,44 +169,20 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, uint16_t nbSymb=0; uint16_t pduBitmap=0x0; - switch (type) { - case SI_PDSCH: - pdsch_vars = ue->pdsch_vars; - dlsch = &ue->dlsch_SI[gNB_id]; - dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; - - break; - - case RA_PDSCH: - pdsch_vars = ue->pdsch_vars; - dlsch = &ue->dlsch_ra[gNB_id]; - dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; - - break; - - case PDSCH: - pdsch_vars = ue->pdsch_vars; - dlsch = ue->dlsch[gNB_id]; - dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; - if (NR_MAX_NB_LAYERS>4) - dlsch1_harq = dlsch[1]->harq_processes[harq_pid]; - break; - - default: - LOG_E(PHY, "[UE][FATAL] nr_slot_rx %d: Unknown PDSCH format %d\n", nr_slot_rx, type); - return -1; - break; - } + pdsch_vars = ue->pdsch_vars; + dlsch0_harq = &ue->dl_harq_processes[0][harq_pid]; + if (NR_MAX_NB_LAYERS>4) + dlsch1_harq = &ue->dl_harq_processes[1][harq_pid]; if (dlsch0_harq && dlsch1_harq){ LOG_D(PHY,"AbsSubframe %d.%d / Sym %d harq_pid %d, harq status %d.%d \n", frame, nr_slot_rx, symbol, harq_pid, dlsch0_harq->status, dlsch1_harq->status); if ((dlsch0_harq->status == ACTIVE) && (dlsch1_harq->status == ACTIVE)){ - codeword_TB0 = dlsch0_harq->codeword; + codeword_TB0 = dlsch0_harq->codeword; // SV: where is this set? revisit for DL MIMO. codeword_TB1 = dlsch1_harq->codeword; - dlsch0_harq = dlsch[codeword_TB0]->harq_processes[harq_pid]; - dlsch1_harq = dlsch[codeword_TB1]->harq_processes[harq_pid]; + dlsch0_harq = &ue->dl_harq_processes[codeword_TB0][harq_pid]; + dlsch1_harq = &ue->dl_harq_processes[codeword_TB1][harq_pid]; #ifdef DEBUG_HARQ printf("[DEMOD] I am assuming both TBs are active, in cw0 %d and cw1 %d \n", codeword_TB0, codeword_TB1); @@ -220,7 +190,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } else if ((dlsch0_harq->status == ACTIVE) && (dlsch1_harq->status != ACTIVE) ) { codeword_TB0 = dlsch0_harq->codeword; - dlsch0_harq = dlsch[codeword_TB0]->harq_processes[harq_pid]; + dlsch0_harq = &ue->dl_harq_processes[codeword_TB0][harq_pid]; dlsch1_harq = NULL; #ifdef DEBUG_HARQ @@ -230,7 +200,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } else if ((dlsch0_harq->status != ACTIVE) && (dlsch1_harq->status == ACTIVE)){ codeword_TB1 = dlsch1_harq->codeword; dlsch0_harq = NULL; - dlsch1_harq = dlsch[codeword_TB1]->harq_processes[harq_pid]; + dlsch1_harq = &ue->dl_harq_processes[codeword_TB1][harq_pid]; #ifdef DEBUG_HARQ printf("[DEMOD] I am assuming only TB1 is active, it is in cw %d\n", codeword_TB1); @@ -246,7 +216,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } else if (dlsch0_harq) { if (dlsch0_harq->status == ACTIVE) { codeword_TB0 = dlsch0_harq->codeword; - dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; + dlsch0_harq = &ue->dl_harq_processes[0][harq_pid]; #ifdef DEBUG_HARQ printf("[DEMOD] I am assuming only TB0 is active\n"); @@ -265,8 +235,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, printf("[DEMOD] cw for TB0 = %d, cw for TB1 = %d\n", codeword_TB0, codeword_TB1); #endif - start_rb = dlsch0_harq->start_rb; - nb_rb_pdsch = dlsch0_harq->nb_rb; + start_rb = dlsch[0].dlsch_config.start_rb; + nb_rb_pdsch = dlsch[0].dlsch_config.number_rbs; DevAssert(dlsch0_harq); @@ -281,11 +251,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, return(-1); } - if (!dlsch[0]) { - LOG_W(PHY,"dlsch_demodulation.c: Null dlsch_ue pointer\n"); - return(-1); - } - if (!pdsch_vars) { LOG_W(PHY,"dlsch_demodulation.c: Null pdsch_vars pointer\n"); return(-1); @@ -301,8 +266,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, slot = 1; } - uint8_t pilots = (dlsch0_harq->dlDmrsSymbPos >> symbol) & 1; - uint8_t config_type = dlsch0_harq->dmrsConfigType; + uint8_t pilots = (dlsch[0].dlsch_config.dlDmrsSymbPos >> symbol) & 1; + uint8_t config_type = dlsch[0].dlsch_config.dmrsConfigType; //---------------------------------------------------------- //--------------------- RBs extraction --------------------- //---------------------------------------------------------- @@ -314,21 +279,21 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, symbol, pilots, config_type, - start_rb + dlsch0_harq->BWPStart, + start_rb + dlsch[0].dlsch_config.BWPStart, nb_rb_pdsch, - dlsch0_harq->n_dmrs_cdm_groups, - dlsch0_harq->Nl, + dlsch[0].dlsch_config.n_dmrs_cdm_groups, + dlsch[0].Nl, frame_parms, - dlsch0_harq->dlDmrsSymbPos, + dlsch[0].dlsch_config.dlDmrsSymbPos, ue->chest_time); stop_meas(&ue->generic_stat_bis[slot]); if (cpumeas(CPUMEAS_GETSTATE)) - LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d type %d: Pilot/Data extraction %5.2f \n", - frame,nr_slot_rx,slot,symbol,type,ue->generic_stat_bis[slot].p_time/(cpuf*1000.0)); + LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Pilot/Data extraction %5.2f \n", + frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[slot].p_time/(cpuf*1000.0)); - int nl = dlsch0_harq->Nl; + int nl = dlsch[0].Nl; int n_rx = frame_parms->nb_antennas_rx; - nb_re_pdsch = (pilots==1)? ((config_type==NFAPI_NR_DMRS_TYPE1)?nb_rb_pdsch*(12-6*dlsch0_harq->n_dmrs_cdm_groups): nb_rb_pdsch*(12-4*dlsch0_harq->n_dmrs_cdm_groups)) : (nb_rb_pdsch*12); + nb_re_pdsch = (pilots==1)? ((config_type==NFAPI_NR_DMRS_TYPE1)?nb_rb_pdsch*(12-6*dlsch[0].dlsch_config.n_dmrs_cdm_groups): nb_rb_pdsch*(12-4*dlsch[0].dlsch_config.n_dmrs_cdm_groups)) : (nb_rb_pdsch*12); //---------------------------------------------------------- //--------------------- Channel Scaling -------------------- //---------------------------------------------------------- @@ -337,7 +302,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, frame_parms, nl, n_rx, - dlsch, symbol, pilots, nb_re_pdsch, @@ -368,7 +332,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, //LOG_I(PHY, "avgs Power per SC is %d\n", avgs); median[(aatx*n_rx)+aarx] = avg[(aatx*n_rx)+aarx]; } - if (dlsch0_harq->Nl > 1) { + if (dlsch[0].Nl > 1) { nr_dlsch_channel_level_median(pdsch_vars[gNB_id]->dl_ch_estimates_ext, median, nl, @@ -395,11 +359,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, stop_meas(&ue->generic_stat_bis[slot]); #if T_TRACER - if (type == PDSCH) - { - T(T_UE_PHY_PDSCH_ENERGY, T_INT(gNB_id), T_INT(0), T_INT(frame%1024), T_INT(nr_slot_rx), - T_INT(avg[0]), T_INT(avg[1]), T_INT(avg[2]), T_INT(avg[3])); - } + T(T_UE_PHY_PDSCH_ENERGY, T_INT(gNB_id), T_INT(0), T_INT(frame%1024), T_INT(nr_slot_rx), + T_INT(avg[0]), T_INT(avg[1]), T_INT(avg[2]), T_INT(avg[3])); #endif if (cpumeas(CPUMEAS_GETSTATE)) @@ -424,7 +385,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, symbol, nb_re_pdsch, first_symbol_flag, - dlsch0_harq->Qm, + dlsch[0].dlsch_config.qamModOrder, nb_rb_pdsch, pdsch_vars[gNB_id]->log2_maxh, measurements); // log2_maxh+I0_shift @@ -454,7 +415,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, nb_rb_pdsch, n_rx, nl, - dlsch0_harq->Qm, + dlsch[0].dlsch_config.qamModOrder, pdsch_vars[gNB_id]->log2_maxh, symbol, nb_re_pdsch); @@ -473,18 +434,18 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[gNB_id]->dl_valid_re[symbol-1] = nb_re_pdsch; if(dlsch0_harq->status == ACTIVE) { - startSymbIdx = dlsch0_harq->start_symbol; - nbSymb = dlsch0_harq->nb_symbols; - pduBitmap = dlsch0_harq->pduBitmap; + startSymbIdx = dlsch[0].dlsch_config.start_symbol; + nbSymb = dlsch[0].dlsch_config.number_symbols; + pduBitmap = dlsch[0].dlsch_config.pduBitmap; } if(dlsch1_harq) { - startSymbIdx = dlsch1_harq->start_symbol; - nbSymb = dlsch1_harq->nb_symbols; - pduBitmap = dlsch1_harq->pduBitmap; + startSymbIdx = dlsch[1].dlsch_config.start_symbol; + nbSymb = dlsch[1].dlsch_config.number_symbols; + pduBitmap = dlsch[1].dlsch_config.pduBitmap; } /* Check for PTRS bitmap and process it respectively */ - if((pduBitmap & 0x1) && (type == PDSCH)) { + if((pduBitmap & 0x1) && (dlsch[0].rnti_type == _C_RNTI_)) { nr_pdsch_ptrs_processing(ue, pdsch_vars, frame_parms, @@ -494,7 +455,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, nr_slot_rx, symbol, (nb_rb_pdsch*12), - dlsch[0]->rnti,rx_type); + dlsch[0].rnti,dlsch); pdsch_vars[gNB_id]->dl_valid_re[symbol-1] -= pdsch_vars[gNB_id]->ptrs_re_per_slot[0][symbol]; } @@ -512,33 +473,35 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, nr_dlsch_llr(pdsch_vars, frame_parms, rxdataF_comp_ptr, dl_ch_mag_ptr, dlsch0_harq, dlsch1_harq, - rx_type, harq_pid, + harq_pid, gNB_id, gNB_id_i, first_symbol_flag, i, nb_rb_pdsch, codeword_TB0, codeword_TB1, pdsch_vars[gNB_id]->dl_valid_re[i-1], - nr_slot_rx, beamforming_mode); + nr_slot_rx, dlsch); } - int dmrs_type = dlsch[0]->harq_processes[harq_pid]->dmrsConfigType; + int dmrs_type = dlsch[0].dlsch_config.dmrsConfigType; uint8_t nb_re_dmrs; - uint16_t dmrs_len = get_num_dmrs(dlsch[0]->harq_processes[harq_pid]->dlDmrsSymbPos); + uint16_t dmrs_len = get_num_dmrs(dlsch[0].dlsch_config.dlDmrsSymbPos); if (dmrs_type==NFAPI_NR_DMRS_TYPE1) { - nb_re_dmrs = 6*dlsch[0]->harq_processes[harq_pid]->n_dmrs_cdm_groups; + nb_re_dmrs = 6*dlsch[0].dlsch_config.n_dmrs_cdm_groups; } else { - nb_re_dmrs = 4*dlsch[0]->harq_processes[harq_pid]->n_dmrs_cdm_groups; + nb_re_dmrs = 4*dlsch[0].dlsch_config.n_dmrs_cdm_groups; } - dlsch[0]->harq_processes[harq_pid]->G = nr_get_G(dlsch[0]->harq_processes[harq_pid]->nb_rb, - dlsch[0]->harq_processes[harq_pid]->nb_symbols, - nb_re_dmrs, - dmrs_len, - dlsch[0]->harq_processes[harq_pid]->Qm, - dlsch[0]->harq_processes[harq_pid]->Nl); + + dlsch0_harq->G = nr_get_G(dlsch[0].dlsch_config.number_rbs, + dlsch[0].dlsch_config.number_symbols, + nb_re_dmrs, + dmrs_len, + dlsch[0].dlsch_config.qamModOrder, + dlsch[0].Nl); + nr_dlsch_layer_demapping(pdsch_vars[gNB_id]->llr, - dlsch[0]->harq_processes[harq_pid]->Nl, - dlsch[0]->harq_processes[harq_pid]->Qm, - dlsch[0]->harq_processes[harq_pid]->G, + dlsch[0].Nl, + dlsch[0].dlsch_config.qamModOrder, + dlsch0_harq->G, codeword_TB0, codeword_TB1, pdsch_vars[gNB_id]->layer_llr); @@ -1345,7 +1308,6 @@ void nr_dlsch_scale_channel(int **dl_ch_estimates_ext, NR_DL_FRAME_PARMS *frame_parms, uint8_t n_tx, uint8_t n_rx, - NR_UE_DLSCH_t **dlsch_ue, uint8_t symbol, uint8_t pilots, uint32_t len, @@ -2387,7 +2349,6 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, int32_t **dl_ch_mag_ptr, NR_DL_UE_HARQ_t *dlsch0_harq, NR_DL_UE_HARQ_t *dlsch1_harq, - RX_type_t rx_type, unsigned char harq_pid, unsigned char gNB_id, unsigned char gNB_id_i, @@ -2398,7 +2359,7 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, int32_t codeword_TB1, uint32_t len, uint8_t nr_slot_rx, - uint8_t beamforming_mode) + NR_UE_DLSCH_t *dlsch) { uint32_t llr_offset_symbol; @@ -2406,133 +2367,78 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, pdsch_vars[gNB_id]->llr_offset[symbol-1] = 0; llr_offset_symbol = pdsch_vars[gNB_id]->llr_offset[symbol-1]; - pdsch_vars[gNB_id]->llr_offset[symbol] = len*dlsch0_harq->Qm + llr_offset_symbol; + pdsch_vars[gNB_id]->llr_offset[symbol] = len*dlsch->dlsch_config.qamModOrder + llr_offset_symbol; - /*LOG_I(PHY,"compute LLRs [symbol %d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %x @LLR Buff(symb) %x\n", - symbol, - nb_rb,dlsch0_harq->Qm, - pdsch_vars[gNB_id]->llr_length[symbol], - pdsch_vars[gNB_id]->llr_offset[symbol], - (int16_t*)pdsch_vars[gNB_id]->llr[0], - pllr_symbol_cw0);*/ + switch (dlsch[0].dlsch_config.qamModOrder) { + case 2 : + for(int l=0; l < dlsch[0].Nl; l++) + nr_dlsch_qpsk_llr(frame_parms, + pdsch_vars[gNB_id]->rxdataF_comp0[l*frame_parms->nb_antennas_rx], + pdsch_vars[gNB_id]->layer_llr[l]+llr_offset_symbol, + symbol, + len, + first_symbol_flag, + nb_rb); + break; - switch (dlsch0_harq->Qm) { - case 2 : - switch (rx_type) { - case rx_standard : - for(int l =0; lNl; l++) - nr_dlsch_qpsk_llr(frame_parms, + case 4 : + for(int l=0; l < dlsch[0].Nl; l++) + nr_dlsch_16qam_llr(frame_parms, + pdsch_vars[gNB_id]->rxdataF_comp0[l*frame_parms->nb_antennas_rx], + pdsch_vars[gNB_id]->layer_llr[l]+llr_offset_symbol, + pdsch_vars[gNB_id]->dl_ch_mag0[0], + symbol, + len, + first_symbol_flag, + nb_rb); + break; + + case 6 : + for(int l=0; l < dlsch[0].Nl; l++) + nr_dlsch_64qam_llr(frame_parms, + pdsch_vars[gNB_id]->rxdataF_comp0[l*frame_parms->nb_antennas_rx], + pdsch_vars[gNB_id]->layer_llr[l]+llr_offset_symbol, + pdsch_vars[gNB_id]->dl_ch_mag0[0], + pdsch_vars[gNB_id]->dl_ch_magb0[0], + symbol, + len, + first_symbol_flag, + nb_rb); + break; + + case 8: + for(int l=0; l < dlsch[0].Nl; l++) + nr_dlsch_256qam_llr(frame_parms, pdsch_vars[gNB_id]->rxdataF_comp0[l*frame_parms->nb_antennas_rx], pdsch_vars[gNB_id]->layer_llr[l]+llr_offset_symbol, + pdsch_vars[gNB_id]->dl_ch_mag0[0], + pdsch_vars[gNB_id]->dl_ch_magb0[0], + pdsch_vars[gNB_id]->dl_ch_magr0[0], symbol, len, first_symbol_flag, - nb_rb, - beamforming_mode); - break; - case rx_IC_single_stream ://From LTE Code!! - //not implemented yet - break; - case rx_IC_dual_stream : - //not implemented yet - break; - case rx_SIC_dual_stream : - //not implemented yet - break; - } - break; - case 4 : - switch (rx_type) { - case rx_standard : - for(int l =0; lNl; l++) - nr_dlsch_16qam_llr(frame_parms, - pdsch_vars[gNB_id]->rxdataF_comp0[l*frame_parms->nb_antennas_rx], - pdsch_vars[gNB_id]->layer_llr[l]+llr_offset_symbol, - pdsch_vars[gNB_id]->dl_ch_mag0[0], - symbol, - len, - first_symbol_flag, - nb_rb, - beamforming_mode); - break; - case rx_IC_single_stream ://not implemented yet - break; - case rx_IC_dual_stream ://not implemented yet - break; - case rx_SIC_dual_stream ://not implemented yet - break; - } - break; - case 6 : - switch (rx_type) { - case rx_standard : - for(int l =0; lNl; l++) - nr_dlsch_64qam_llr(frame_parms, - pdsch_vars[gNB_id]->rxdataF_comp0[l*frame_parms->nb_antennas_rx], - pdsch_vars[gNB_id]->layer_llr[l]+llr_offset_symbol, - pdsch_vars[gNB_id]->dl_ch_mag0[0], - pdsch_vars[gNB_id]->dl_ch_magb0[0], - symbol, - len, - first_symbol_flag, - nb_rb, - beamforming_mode); - break; - case rx_IC_single_stream ://not implemented yet - break; - case rx_IC_dual_stream ://not implemented yet - break; - case rx_SIC_dual_stream ://not implemented yet - break; - } + nb_rb); + break; - break; - case 8: - switch (rx_type) { - case rx_standard : - for(int l =0; lNl; l++) - nr_dlsch_256qam_llr(frame_parms, - pdsch_vars[gNB_id]->rxdataF_comp0[l*frame_parms->nb_antennas_rx], - pdsch_vars[gNB_id]->layer_llr[l]+llr_offset_symbol, - pdsch_vars[gNB_id]->dl_ch_mag0[0], - pdsch_vars[gNB_id]->dl_ch_magb0[0], - pdsch_vars[gNB_id]->dl_ch_magr0[0], - symbol, - len, - first_symbol_flag, - nb_rb, - beamforming_mode); - break; - case rx_IC_single_stream ://not implemented yet - break; - case rx_IC_dual_stream ://not implemented yet - break; - case rx_SIC_dual_stream ://not implemented yet - break; - } - break; - default: - LOG_W(PHY,"rx_dlsch.c : Unknown mod_order!!!!\n"); - return(-1); - break; + default: + LOG_W(PHY,"rx_dlsch.c : Unknown mod_order!!!!\n"); + return(-1); + break; } if (dlsch1_harq) { - switch (dlsch1_harq->Qm) { - case 2 : - if (rx_type==rx_standard) { + switch (dlsch[1].dlsch_config.qamModOrder) { + case 2 : nr_dlsch_qpsk_llr(frame_parms, pdsch_vars[gNB_id]->rxdataF_comp0[0], pdsch_vars[gNB_id]->layer_llr[0]+llr_offset_symbol, symbol, len, first_symbol_flag, - nb_rb, - beamforming_mode); - } - break; - case 4: - if (rx_type==rx_standard) { + nb_rb); + break; + + case 4: nr_dlsch_16qam_llr(frame_parms, pdsch_vars[gNB_id]->rxdataF_comp0[0], pdsch_vars[gNB_id]->layer_llr[0]+llr_offset_symbol, @@ -2540,12 +2446,10 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, symbol, len, first_symbol_flag, - nb_rb, - beamforming_mode); - } - break; - case 6 : - if (rx_type==rx_standard) { + nb_rb); + break; + + case 6 : nr_dlsch_64qam_llr(frame_parms, pdsch_vars[gNB_id]->rxdataF_comp0[0], pdsch_vars[gNB_id]->layer_llr[0]+llr_offset_symbol, @@ -2554,12 +2458,10 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, symbol, len, first_symbol_flag, - nb_rb, - beamforming_mode); - } + nb_rb); break; - case 8 : - if (rx_type==rx_standard) { + + case 8 : nr_dlsch_256qam_llr(frame_parms, pdsch_vars[gNB_id]->rxdataF_comp0[0], pdsch_vars[gNB_id]->layer_llr[0]+llr_offset_symbol, @@ -2569,10 +2471,9 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, symbol, len, first_symbol_flag, - nb_rb, - beamforming_mode); - } + nb_rb); break; + default: LOG_W(PHY,"rx_dlsch.c : Unknown mod_order!!!!\n"); return(-1); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c index 6f8ec17f58..d97cef81fd 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c @@ -634,8 +634,7 @@ int nr_dlsch_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, uint8_t symbol, uint32_t len, uint8_t first_symbol_flag, - uint16_t nb_rb, - uint8_t beamforming_mode) + uint16_t nb_rb) { c16_t *rxF = (c16_t *)&rxdataF_comp[((int32_t)symbol*nb_rb*12)]; @@ -677,8 +676,7 @@ void nr_dlsch_16qam_llr(NR_DL_FRAME_PARMS *frame_parms, uint8_t symbol, uint32_t len, uint8_t first_symbol_flag, - uint16_t nb_rb, - uint8_t beamforming_mode) + uint16_t nb_rb) { #if defined(__x86_64__) || defined(__i386__) @@ -780,8 +778,7 @@ void nr_dlsch_64qam_llr(NR_DL_FRAME_PARMS *frame_parms, uint8_t symbol, uint32_t len, uint8_t first_symbol_flag, - uint16_t nb_rb, - uint8_t beamforming_mode) + uint16_t nb_rb) { #if defined(__x86_64__) || defined(__i386__) __m128i *rxF = (__m128i*)&rxdataF_comp[(symbol*nb_rb*12)]; @@ -923,8 +920,7 @@ void nr_dlsch_256qam_llr(NR_DL_FRAME_PARMS *frame_parms, uint8_t symbol, uint32_t len, uint8_t first_symbol_flag, - uint16_t nb_rb, - uint8_t beamforming_mode) + uint16_t nb_rb) { __m128i *rxF = (__m128i*)&rxdataF_comp[(symbol*nb_rb*12)]; __m128i *ch_mag,*ch_magb,*ch_magr; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 6bf425974d..e87062de55 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -51,7 +51,7 @@ extern openair0_config_t openair0_cfg[]; int cnt=0; #define DEBUG_INITIAL_SYNCH - +#define DUMP_PBCH_CH_ESTIMATES 0 // create a new node of SSB structure NR_UE_SSB* create_ssb_node(uint8_t i, uint8_t h) { @@ -101,7 +101,7 @@ void free_list(NR_UE_SSB *node) { } -int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_initial_symbol, NR_UE_PDCCH_CONFIG *phy_pdcch_config) +int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_initial_symbol, nr_phy_data_t *phy_data) { NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; int ret =-1; @@ -165,9 +165,14 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini 0, temp_ptr->i_ssb, SISO, - phy_pdcch_config, + phy_data, &result); + if (DUMP_PBCH_CH_ESTIMATES && (ret == 0)) { + write_output("pbch_ch_estimates.m", "pbch_ch_estimates", dl_ch_estimates, frame_parms->nb_antennas_rx*estimateSz, 1, 1); + write_output("pbch_ch_estimates_time.m", "pbch_ch_estimates_time", dl_ch_estimates_time, frame_parms->nb_antennas_rx*frame_parms->ofdm_symbol_size, 1, 1); + } + temp_ptr=temp_ptr->next_ssb; } @@ -216,7 +221,8 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, int ret=-1; int rx_power=0; //aarx, - NR_UE_PDCCH_CONFIG phy_pdcch_config={0}; + nr_phy_data_t phy_data = {0}; + NR_UE_PDCCH_CONFIG *phy_pdcch_config = &phy_data.phy_pdcch_config; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_INITIAL_UE_SYNC, VCD_FUNCTION_IN); @@ -246,52 +252,51 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, /* process pss search on received buffer */ sync_pos = pss_synchro_nr(ue, is, NO_RATE_CHANGE); + if (sync_pos < fp->nb_prefix_samples) + continue; - if (sync_pos >= fp->nb_prefix_samples) - ue->ssb_offset = sync_pos - fp->nb_prefix_samples; - else - ue->ssb_offset = sync_pos + (fp->samples_per_subframe * 10) - fp->nb_prefix_samples; + ue->ssb_offset = sync_pos - fp->nb_prefix_samples; #ifdef DEBUG_INITIAL_SYNCH LOG_I(PHY,"[UE%d] Initial sync : Estimated PSS position %d, Nid2 %d\n", ue->Mod_id, sync_pos,ue->common_vars.eNb_id); LOG_I(PHY,"sync_pos %d ssb_offset %d \n",sync_pos,ue->ssb_offset); #endif - // digital compensation of FFO for SSB symbols - if (ue->UE_fo_compensation){ - double s_time = 1/(1.0e3*fp->samples_per_subframe); // sampling time - double off_angle = -2*M_PI*s_time*(ue->common_vars.freq_offset); // offset rotation angle compensation per sample + /* check that SSS/PBCH block is continuous inside the received buffer */ + if (ue->ssb_offset + NR_N_SYMBOLS_SSB * (fp->ofdm_symbol_size + fp->nb_prefix_samples) < fp->samples_per_frame) { - // In SA we need to perform frequency offset correction until the end of buffer because we need to decode SIB1 - // and we do not know yet in which slot it goes. + // digital compensation of FFO for SSB symbols + if (ue->UE_fo_compensation){ + double s_time = 1/(1.0e3*fp->samples_per_subframe); // sampling time + double off_angle = -2*M_PI*s_time*(ue->common_vars.freq_offset); // offset rotation angle compensation per sample - // start for offset correction - int start = sa ? is*fp->samples_per_frame : is*fp->samples_per_frame + ue->ssb_offset; + // In SA we need to perform frequency offset correction until the end of buffer because we need to decode SIB1 + // and we do not know yet in which slot it goes. - // loop over samples - int end = sa ? n_frames*fp->samples_per_frame-1 : start + NR_N_SYMBOLS_SSB*(fp->ofdm_symbol_size + fp->nb_prefix_samples); + // start for offset correction + int start = is*fp->samples_per_frame; - for(int n=start; nnb_antennas_rx; ar++) { - re = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n]); - im = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n+1]); - ((short *)ue->common_vars.rxdata[ar])[2*n] = (short)(round(re*cos(n*off_angle) - im*sin(n*off_angle))); - ((short *)ue->common_vars.rxdata[ar])[2*n+1] = (short)(round(re*sin(n*off_angle) + im*cos(n*off_angle))); + // loop over samples + int end = start + fp->samples_per_frame; + + for(int n=start; nnb_antennas_rx; ar++) { + re = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n]); + im = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n+1]); + ((short *)ue->common_vars.rxdata[ar])[2*n] = (short)(round(re*cos(n*off_angle) - im*sin(n*off_angle))); + ((short *)ue->common_vars.rxdata[ar])[2*n+1] = (short)(round(re*sin(n*off_angle) + im*cos(n*off_angle))); + } } } - } - /* check that SSS/PBCH block is continuous inside the received buffer */ - if (sync_pos < (NR_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_subframe - (NB_SYMBOLS_PBCH * fp->ofdm_symbol_size))) { - - /* slop_fep function works for lte and takes into account begining of frame with prefix for subframe 0 */ - /* for NR this is not the case but slot_fep is still used for computing FFT of samples */ - /* in order to achieve correct processing for NR prefix samples is forced to 0 and then restored after function call */ - /* symbol number are from beginning of SS/PBCH blocks as below: */ - /* Signal PSS PBCH SSS PBCH */ - /* symbol number 0 1 2 3 */ - /* time samples in buffer rxdata are used as input of FFT -> FFT results are stored in the frequency buffer rxdataF */ - /* rxdataF stores SS/PBCH from beginning of buffers in the same symbol order as in time domain */ + /* slop_fep function works for lte and takes into account begining of frame with prefix for subframe 0 */ + /* for NR this is not the case but slot_fep is still used for computing FFT of samples */ + /* in order to achieve correct processing for NR prefix samples is forced to 0 and then restored after function call */ + /* symbol number are from beginning of SS/PBCH blocks as below: */ + /* Signal PSS PBCH SSS PBCH */ + /* symbol number 0 1 2 3 */ + /* time samples in buffer rxdata are used as input of FFT -> FFT results are stored in the frequency buffer rxdataF */ + /* rxdataF stores SS/PBCH from beginning of buffers in the same symbol order as in time domain */ for(int i=0; i<4;i++) nr_slot_fep_init_sync(ue, @@ -317,10 +322,10 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, // and we do not know yet in which slot it goes. // start for offset correction - int start = sa ? is*fp->samples_per_frame : is*fp->samples_per_frame + ue->ssb_offset; + int start = is*fp->samples_per_frame; // loop over samples - int end = sa ? n_frames*fp->samples_per_frame-1 : start + NR_N_SYMBOLS_SSB*(fp->ofdm_symbol_size + fp->nb_prefix_samples); + int end = start + fp->samples_per_frame; for(int n=start; nnb_antennas_rx; ar++) { @@ -336,7 +341,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, if (ret==0) { //we got sss channel nr_gold_pbch(ue); - ret = nr_pbch_detection(proc, ue, 1, &phy_pdcch_config); // start pbch detection at first symbol after pss + ret = nr_pbch_detection(proc, ue, 1, &phy_data); // start pbch detection at first symbol after pss } if (ret == 0) { @@ -518,6 +523,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, // if stand alone and sync on ssb do sib1 detection as part of initial sync if (sa==1 && ret==0) { + nr_ue_dlsch_init(phy_data.dlsch, 1, ue->max_ldpc_iterations); bool dec = false; int gnb_id = 0; //FIXME @@ -525,65 +531,59 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, int32_t pdcch_est_size = ((((fp->symbols_per_slot*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH))+15)/16)*16); __attribute__ ((aligned(16))) int32_t pdcch_dl_ch_estimates[4*fp->nb_antennas_rx][pdcch_est_size]; - for(int n_ss = 0; n_ssnr_slot_rx = phy_pdcch_config.slot; // setting PDCCH slot to proc - uint8_t nb_symb_pdcch = phy_pdcch_config.pdcch_config[n_ss].coreset.duration; - int start_symb = phy_pdcch_config.pdcch_config[n_ss].coreset.StartSymbolIndex; + for(int n_ss = 0; n_ssnb_search_space; n_ss++) { + proc->nr_slot_rx = phy_pdcch_config->slot; // setting PDCCH slot to proc + uint8_t nb_symb_pdcch = phy_pdcch_config->pdcch_config[n_ss].coreset.duration; + int start_symb = phy_pdcch_config->pdcch_config[n_ss].coreset.StartSymbolIndex; for (uint16_t l=start_symb; lsamples_per_frame+phy_pdcch_config.sfn*fp->samples_per_frame+ue->rx_offset, + phy_pdcch_config->slot, + is*fp->samples_per_frame+phy_pdcch_config->sfn*fp->samples_per_frame+ue->rx_offset, true); nr_pdcch_channel_estimation(ue, proc, 0, - phy_pdcch_config.slot, + phy_pdcch_config->slot, l, - &phy_pdcch_config.pdcch_config[n_ss].coreset, + &phy_pdcch_config->pdcch_config[n_ss].coreset, fp->first_carrier_offset, - phy_pdcch_config.pdcch_config[n_ss].BWPStart, + phy_pdcch_config->pdcch_config[n_ss].BWPStart, pdcch_est_size, pdcch_dl_ch_estimates); } - int dci_cnt = nr_ue_pdcch_procedures(gnb_id, ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, &phy_pdcch_config, n_ss); + int dci_cnt = nr_ue_pdcch_procedures(gnb_id, ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, &phy_data, n_ss); if (dci_cnt>0){ - NR_UE_DLSCH_t *dlsch = ue->dlsch_SI[gnb_id]; - if (dlsch && (dlsch->active == 1)) { - uint8_t harq_pid = dlsch->current_harq_pid; - NR_DL_UE_HARQ_t *dlsch0_harq = dlsch->harq_processes[harq_pid]; - uint16_t nb_symb_sch = dlsch0_harq->nb_symbols; - uint16_t start_symb_sch = dlsch0_harq->start_symbol; + NR_UE_DLSCH_t *dlsch = phy_data.dlsch; + if (dlsch[0].active == 1) { + uint16_t nb_symb_sch = dlsch->dlsch_config.number_symbols; + uint16_t start_symb_sch = dlsch->dlsch_config.start_symbol; for (uint16_t m=start_symb_sch;m<(nb_symb_sch+start_symb_sch) ; m++){ nr_slot_fep_init_sync(ue, proc, m, - phy_pdcch_config.slot, // same slot and offset as pdcch - is*fp->samples_per_frame+phy_pdcch_config.sfn*fp->samples_per_frame+ue->rx_offset, + phy_pdcch_config->slot, // same slot and offset as pdcch + is*fp->samples_per_frame+phy_pdcch_config->sfn*fp->samples_per_frame+ue->rx_offset, true); } int ret = nr_ue_pdsch_procedures(ue, proc, gnb_id, - SI_PDSCH, - ue->dlsch_SI[gnb_id], - NULL); + dlsch); if (ret >= 0) dec = nr_ue_dlsch_procedures(ue, proc, gnb_id, - SI_PDSCH, - ue->dlsch_SI[gnb_id], - NULL, - &ue->dlsch_SI_errors[gnb_id]); + dlsch, + NULL); // deactivate dlsch once dlsch proc is done - ue->dlsch_SI[gnb_id]->active = 0; + dlsch->active = 0; } } } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 7e9af83fe8..2a037d1e70 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -391,7 +391,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t i_ssb, MIMO_mode_t mimo_mode, - NR_UE_PDCCH_CONFIG *phy_pdcch_config, + nr_phy_data_t *phy_data, fapiPbch_t *result) { NR_UE_COMMON *nr_ue_common_vars = &ue->common_vars; @@ -580,7 +580,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, fapi_nr_rx_indication_t *rx_ind=calloc(sizeof(*rx_ind),1); uint16_t number_pdus = 1; - nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, phy_pdcch_config); + nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, phy_data); nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SSB, gNB_id, ue, NULL, NULL, number_pdus, proc,(void *)result); if (ue->if_inst && ue->if_inst->dl_indication) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index 48426a1774..8e9bfd6201 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -47,22 +47,10 @@ * @{ */ -/** \fn free_ue_dlsch(NR_UE_DLSCH_t *dlsch) - \brief This function frees memory allocated for a particular DLSCH at UE - @param dlsch Pointer to DLSCH to be removed -*/ -void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlsch, uint16_t N_RB_DL); - -/** \fn new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft) - \brief This function allocates structures for a particular DLSCH at UE - @returns Pointer to DLSCH to be removed - @param Kmimo Kmimo factor from 36-212/36-213 - @param Mdlharq Maximum number of HARQ rounds (36-212/36-213) - @param Nsoft Soft-LLR buffer size from UE-Category - @params N_RB_DL total number of resource blocks (determine the operating BW) +/** \brief This function initialises structures for DLSCH at UE */ -NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint16_t N_RB_DL); +void nr_ue_dlsch_init(NR_UE_DLSCH_t *dlsch_list, int num_dlsch, uint8_t max_ldpc_iterations); void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr, uint16_t N_RB_UL, @@ -478,8 +466,7 @@ int32_t nr_dlsch_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, uint8_t symbol, uint32_t len, uint8_t first_symbol_flag, - uint16_t nb_rb, - uint8_t beamforming_mode); + uint16_t nb_rb); /** \brief This function generates log-likelihood ratios (decoder input) for single-stream 16QAM received waveforms @@ -502,8 +489,7 @@ void nr_dlsch_16qam_llr(NR_DL_FRAME_PARMS *frame_parms, uint8_t symbol, uint32_t len, uint8_t first_symbol_flag, - uint16_t nb_rb, - uint8_t beamforming_mode); + uint16_t nb_rb); /** \brief This function generates log-likelihood ratios (decoder input) for single-stream 16QAM received waveforms @param frame_parms Frame descriptor structure @@ -526,8 +512,7 @@ void nr_dlsch_64qam_llr(NR_DL_FRAME_PARMS *frame_parms, uint8_t symbol, uint32_t len, uint8_t first_symbol_flag, - uint16_t nb_rb, - uint8_t beamforming_mode); + uint16_t nb_rb); void nr_dlsch_256qam_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t *rxdataF_comp, @@ -538,8 +523,7 @@ void nr_dlsch_256qam_llr(NR_DL_FRAME_PARMS *frame_parms, uint8_t symbol, uint32_t len, uint8_t first_symbol_flag, - uint16_t nb_rb, - uint8_t beamforming_mode); + uint16_t nb_rb); /** \fn dlsch_extract_rbs(int32_t **rxdataF, @@ -683,7 +667,6 @@ void nr_dlsch_scale_channel(int32_t **dl_ch_estimates_ext, NR_DL_FRAME_PARMS *frame_parms, uint8_t n_tx, uint8_t n_rx, - NR_UE_DLSCH_t **dlsch_ue, uint8_t symbol, uint8_t start_symbol, uint32_t len, @@ -718,8 +701,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, uint32_t frame, uint16_t nb_symb_sch, uint8_t nr_slot_rx, - uint8_t harq_pid, - uint8_t is_crnti); + uint8_t harq_pid); int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, NR_UE_ULSCH_t *ulsch, @@ -800,13 +782,13 @@ int nr_rx_pbch(PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t i_ssb, MIMO_mode_t mimo_mode, - NR_UE_PDCCH_CONFIG *phy_pdcch_config, + nr_phy_data_t *phy_data, fapiPbch_t* result); int nr_pbch_detection(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, int pbch_initial_symbol, - NR_UE_PDCCH_CONFIG *phy_pdcch_config); + nr_phy_data_t *phy_data); #ifndef modOrder @@ -865,8 +847,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int16_t *pdcch_e_rx, fapi_nr_dci_indication_t *dci_ind, - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, - NR_UE_PDCCH_CONFIG *phy_pdcch_config); + fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); /** \brief This function is the top-level entry point to PDSCH demodulation, after frequency-domain transformation and channel estimation. It performs @@ -884,21 +865,17 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, @param nr_slot_rx Slot number @param symbol Symbol on which to act (within sub-frame) @param first_symbol_flag set to 1 on first DLSCH symbol - @param rx_type. rx_type=RX_IC_single_stream will enable interference cancellation of a second stream when decoding the first stream. In case of TM1, 2, 5, and this can cancel interference from a neighbouring cell given by eNB_id_i. In case of TM5, eNB_id_i should be set to n_connected_eNB to perform multi-user interference cancellation. In case of TM3, eNB_id_i should be set to eNB_id to perform co-channel interference cancellation; this option should be used together with an interference cancellation step [...]. In case of TM3, if rx_type=RX_IC_dual_stream, both streams will be decoded by applying the IC single stream receiver twice. - @param i_mod Modulation order of the interfering stream */ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, - UE_nr_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 - uint32_t frame, - uint8_t nr_slot_rx, - unsigned char symbol, - unsigned char first_symbol_flag, - RX_type_t rx_type, - unsigned char i_mod, - unsigned char harq_pid); + UE_nr_rxtx_proc_t *proc, + NR_UE_DLSCH_t *dlsch, + unsigned char gNB_id, + unsigned char gNB_id_i, //if this == ue->n_connected_eNB, we assume MU interference + uint32_t frame, + uint8_t nr_slot_rx, + unsigned char symbol, + unsigned char first_symbol_flag, + unsigned char harq_pid); int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int frame, uint8_t slot); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index dc9ca67de4..b91ad2b9cd 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -183,16 +183,6 @@ typedef struct { int16_t **d; /// Index of current HARQ round for this DLSCH uint8_t DLround; - /// MCS table for this DLSCH - uint8_t mcs_table; - /// MCS format for this DLSCH - uint8_t mcs; - /// Qm (modulation order) for this DLSCH - uint8_t Qm; - /// target code rate R x 1024 - uint16_t R; - /// Redundancy-version of the current sub-frame - uint8_t rvidx; /// MIMO mode for this DLSCH MIMO_nrmode_t mimo_mode; /// Number of code segments @@ -203,32 +193,10 @@ typedef struct { uint32_t F; /// LDPC lifting factor uint32_t Z; - /// Number of MIMO layers (streams) - uint8_t Nl; /// current delta_pucch int8_t delta_PUCCH; /// Number of soft channel bits uint32_t G; - /// Start PRB of BWP - uint16_t BWPStart; - /// Number of PRBs in BWP - uint16_t BWPSize; - /// Current Number of RBs - uint16_t nb_rb; - /// Starting RB number - uint16_t start_rb; - /// Number of Symbols - uint16_t nb_symbols; - /// DMRS symbol positions - uint16_t dlDmrsSymbPos; - /// DMRS Configuration Type - uint8_t dmrsConfigType; - // Number of DMRS CDM groups with no data - uint8_t n_dmrs_cdm_groups; - /// DMRS ports bitmap - uint16_t dmrs_ports; - /// Starting Symbol number - uint16_t start_symbol; /// Current subband PMI allocation uint16_t pmi_alloc; /// Current RB allocation (even slots) @@ -243,22 +211,6 @@ typedef struct { uint8_t codeword; /// HARQ-ACKs uint8_t ack; - /// PTRS Frequency Density - uint8_t PTRSFreqDensity; - /// PTRS Time Density - uint8_t PTRSTimeDensity; - uint8_t PTRSPortIndex ; - uint8_t nEpreRatioOfPDSCHToPTRS; - uint8_t PTRSReOffset; - /// bit mask of PT-RS ofdm symbol indicies - uint16_t ptrs_symbols; - // PTRS symbol index, to be updated every PTRS symbol within a slot. - uint8_t ptrs_symbol_index; - uint32_t tbslbrm; - uint8_t nscid; - uint16_t dlDmrsScramblingId; - /// PDU BITMAP - uint16_t pduBitmap; /// Last index of LLR buffer that contains information. /// Used for computing LDPC decoder R int llrLen; @@ -270,17 +222,13 @@ typedef struct { /// RNTI type uint8_t rnti_type; /// Active flag for DLSCH demodulation - uint8_t active; - /// accumulated tx power adjustment for PUCCH - int8_t g_pucch; + bool active; /// Transmission mode uint8_t mode1_flag; /// amplitude of PDSCH (compared to RS) in symbols without pilots int16_t sqrt_rho_a; /// amplitude of PDSCH (compared to RS) in symbols containing pilots int16_t sqrt_rho_b; - /// Current HARQ process id threadRx Odd and threadRx Even - uint8_t current_harq_pid; /// Current subband antenna selection uint32_t antenna_alloc; /// Current subband RI allocation @@ -291,24 +239,22 @@ typedef struct { uint32_t cqi_alloc2; /// saved subband PMI allocation from last PUSCH/PUCCH report uint16_t pmi_alloc; - /// Pointers to up to HARQ processes - NR_DL_UE_HARQ_t *harq_processes[NR_MAX_DLSCH_HARQ_PROCESSES]; - // DL number of harq processes - uint8_t number_harq_processes_for_pdsch; + /// Structure to hold dlsch config from MAC + fapi_nr_dl_config_dlsch_pdu_rel15_t dlsch_config; /* higher layer parameter for reception of two transport blocks TS 38.213 9.1.3.1 Type-2 HARQ-ACK codebook dtermination */ uint8_t Number_MCS_HARQ_DL_DCI; /* spatial bundling of PUCCH */ uint8_t HARQ_ACK_spatial_bundling_PUCCH; - /// Maximum number of HARQ processes(for definition see 36-212 V8.6 2009-03, p.17 - uint8_t Mdlharq; - /// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17) - uint8_t Kmimo; - /// Nsoft parameter related to UE Category - uint32_t Nsoft; + /// Number of MIMO layers (streams) + uint8_t Nl; /// Maximum number of LDPC iterations uint8_t max_ldpc_iterations; /// number of iterations used in last turbo decoding uint8_t last_iteration_cnt; + /// bit mask of PT-RS ofdm symbol indicies + uint16_t ptrs_symbols; + // PTRS symbol index, to be updated every PTRS symbol within a slot. + uint8_t ptrs_symbol_index; } NR_UE_DLSCH_t; typedef enum {format0_0, diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 77b8548d83..b551a259af 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -239,7 +239,6 @@ typedef struct { uint32_t slot; /// Index of current HARQ round for this DLSCH uint8_t round; - uint8_t ndi; bool new_rx; /// Last TPC command uint8_t TPC; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 7533ca685f..8a73a4fb86 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -538,14 +538,10 @@ typedef struct { NR_UE_CSI_IM *csiim_vars[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_CSI_RS *csirs_vars[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_SRS *srs_vars[NUMBER_OF_CONNECTED_gNB_MAX]; - NR_UE_DLSCH_t *dlsch[NUMBER_OF_CONNECTED_gNB_MAX][NR_MAX_NB_LAYERS>4 ? 2:1]; NR_UE_ULSCH_t *ulsch[NUMBER_OF_CONNECTED_gNB_MAX]; - NR_UE_DLSCH_t *dlsch_SI[NUMBER_OF_CONNECTED_gNB_MAX]; - NR_UE_DLSCH_t *dlsch_ra[NUMBER_OF_CONNECTED_gNB_MAX]; - NR_UE_DLSCH_t *dlsch_p[NUMBER_OF_CONNECTED_gNB_MAX]; - NR_UE_DLSCH_t *dlsch_MCH[NUMBER_OF_CONNECTED_gNB_MAX]; NR_UE_PRS *prs_vars[NR_MAX_PRS_COMB_SIZE]; uint8_t prs_active_gNBs; + NR_DL_UE_HARQ_t dl_harq_processes[NR_MAX_NB_LAYERS>4 ? 2:1][NR_MAX_DLSCH_HARQ_PROCESSES]; //Paging parameters uint32_t IMSImod1024; @@ -760,6 +756,8 @@ typedef struct { typedef struct nr_phy_data_s { NR_UE_PUCCH pucch_vars; + NR_UE_PDCCH_CONFIG phy_pdcch_config; + NR_UE_DLSCH_t dlsch[NR_MAX_NB_LAYERS>4 ? 2:1]; } nr_phy_data_t; /* this structure is used to pass both UE phy vars and * proc to the function UE_thread_rxn_txnp4 diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index 9ba3ac74b1..51749889c9 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -96,7 +96,7 @@ typedef struct { @param proc Pointer to RXn-TXnp4 proc information @param eNB_id Local id of eNB on which to act */ -void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t eNB_id); +void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id); /*! \brief Scheduling for UE RX procedures in normal subframes. @param ue Pointer to UE variables on which to act @@ -109,10 +109,10 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, - NR_UE_PDCCH_CONFIG *phy_pdcch_config, + nr_phy_data_t *phy_data, notifiedFIFO_t *txFifo); -int phy_procedures_slot_parallelization_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t eNB_id, uint8_t abstraction_flag, uint8_t do_pdcch_flag, relaying_type_t r_type); +int phy_procedures_slot_parallelization_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, uint8_t abstraction_flag, uint8_t do_pdcch_flag, relaying_type_t r_type); void processSlotTX(void *arg); @@ -176,22 +176,20 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_id, - PDSCH_t pdsch, NR_UE_DLSCH_t *dlsch0, - NR_UE_DLSCH_t *dlsch1, - int *dlsch_errors); + NR_UE_DLSCH_t *dlsch1); int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - int eNB_id, PDSCH_t pdsch, - NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1); + int gNB_id, + NR_UE_DLSCH_t *dlsch); int nr_ue_pdcch_procedures(uint8_t gNB_id, PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int32_t pdcch_est_size, int32_t pdcch_dl_ch_estimates[][pdcch_est_size], - NR_UE_PDCCH_CONFIG *phy_pdcch_config, + nr_phy_data_t *phy_data, int n_ss); int nr_ue_csi_im_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id); diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index cb4ffbe66c..54ad012718 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -289,61 +289,32 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response void configure_dlsch(NR_UE_DLSCH_t *dlsch0, + NR_DL_UE_HARQ_t *harq_list, fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, module_id_t module_id, int rnti) { const uint8_t current_harq_pid = dlsch_config_pdu->harq_process_nbr; - dlsch0->current_harq_pid = current_harq_pid; - dlsch0->active = 1; + dlsch0->active = true; dlsch0->rnti = rnti; LOG_D(PHY,"current_harq_pid = %d\n", current_harq_pid); - NR_DL_UE_HARQ_t *dlsch0_harq = dlsch0->harq_processes[current_harq_pid]; - AssertFatal(dlsch0_harq, "no harq_process for HARQ PID %d\n", current_harq_pid); + NR_DL_UE_HARQ_t *dlsch0_harq = &harq_list[current_harq_pid]; - dlsch0_harq->BWPStart = dlsch_config_pdu->BWPStart; - dlsch0_harq->BWPSize = dlsch_config_pdu->BWPSize; - dlsch0_harq->nb_rb = dlsch_config_pdu->number_rbs; - dlsch0_harq->start_rb = dlsch_config_pdu->start_rb; - dlsch0_harq->nb_symbols = dlsch_config_pdu->number_symbols; - dlsch0_harq->start_symbol = dlsch_config_pdu->start_symbol; - dlsch0_harq->dlDmrsSymbPos = dlsch_config_pdu->dlDmrsSymbPos; - dlsch0_harq->dmrsConfigType = dlsch_config_pdu->dmrsConfigType; - dlsch0_harq->n_dmrs_cdm_groups = dlsch_config_pdu->n_dmrs_cdm_groups; - dlsch0_harq->dmrs_ports = dlsch_config_pdu->dmrs_ports; - dlsch0_harq->mcs = dlsch_config_pdu->mcs; - dlsch0_harq->rvidx = dlsch_config_pdu->rv; - dlsch0->g_pucch = dlsch_config_pdu->accumulated_delta_PUCCH; - dlsch0_harq->R = dlsch_config_pdu->targetCodeRate; - dlsch0_harq->Qm = dlsch_config_pdu->qamModOrder; - dlsch0_harq->TBS = dlsch_config_pdu->TBS; - dlsch0_harq->tbslbrm = dlsch_config_pdu->tbslbrm; - dlsch0_harq->nscid = dlsch_config_pdu->nscid; - dlsch0_harq->dlDmrsScramblingId = dlsch_config_pdu->dlDmrsScramblingId; //get nrOfLayers from DCI info uint8_t Nl = 0; for (int i = 0; i < 12; i++) { // max 12 ports if ((dlsch_config_pdu->dmrs_ports>>i)&0x01) Nl += 1; } - dlsch0_harq->Nl = Nl; - dlsch0_harq->mcs_table=dlsch_config_pdu->mcs_table; - downlink_harq_process(dlsch0_harq, dlsch0->current_harq_pid, dlsch_config_pdu->ndi, dlsch_config_pdu->rv, dlsch0->rnti_type); + dlsch0->Nl = Nl; + downlink_harq_process(dlsch0_harq, current_harq_pid, dlsch_config_pdu->ndi, dlsch_config_pdu->rv, dlsch0->rnti_type); if (dlsch0_harq->status != ACTIVE) { // dlsch0_harq->status not ACTIVE due to false retransmission // Reset the following flag to skip PDSCH procedures in that case and retrasmit harq status - dlsch0->active = 0; - update_harq_status(module_id,dlsch0->current_harq_pid,dlsch0_harq->ack); + dlsch0->active = false; + update_harq_status(module_id, current_harq_pid, dlsch0_harq->ack); } - /* PTRS */ - dlsch0_harq->PTRSFreqDensity = dlsch_config_pdu->PTRSFreqDensity; - dlsch0_harq->PTRSTimeDensity = dlsch_config_pdu->PTRSTimeDensity; - dlsch0_harq->PTRSPortIndex = dlsch_config_pdu->PTRSPortIndex; - dlsch0_harq->nEpreRatioOfPDSCHToPTRS = dlsch_config_pdu->nEpreRatioOfPDSCHToPTRS; - dlsch0_harq->PTRSReOffset = dlsch_config_pdu->PTRSReOffset; - dlsch0_harq->pduBitmap = dlsch_config_pdu->pduBitmap; - LOG_D(MAC, ">>>> \tdlsch0->g_pucch = %d\tdlsch0_harq.mcs = %d\n", dlsch0->g_pucch, dlsch0_harq->mcs); } @@ -357,7 +328,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ int slot = scheduled_response->slot; // Note: we have to handle the thread IDs for this. To be revisited completely. - NR_UE_DLSCH_t *dlsch0 = NULL; + NR_UE_DLSCH_t *dlsch0 = &((nr_phy_data_t *)scheduled_response->phy_data)->dlsch[0]; NR_UE_ULSCH_t *ulsch = PHY_vars_UE_g[module_id][cc_id]->ulsch[0]; NR_UE_PUCCH *pucch_vars = &((nr_phy_data_t *)scheduled_response->phy_data)->pucch_vars; NR_UE_CSI_IM *csiim_vars = PHY_vars_UE_g[module_id][cc_id]->csiim_vars[0]; @@ -380,7 +351,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ switch(dl_config->dl_config_list[i].pdu_type) { case FAPI_NR_DL_CONFIG_TYPE_DCI: if (NULL == phy_pdcch_config) { - phy_pdcch_config = (NR_UE_PDCCH_CONFIG *)scheduled_response->phy_data; + phy_pdcch_config = &((nr_phy_data_t *)scheduled_response->phy_data)->phy_pdcch_config; phy_pdcch_config->nb_search_space = 0; } pdcch_config = &dl_config->dl_config_list[i].dci_config_pdu.dci_config_rel15; @@ -402,24 +373,23 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ break; case FAPI_NR_DL_CONFIG_TYPE_RA_DLSCH: dlsch_config_pdu = &dl_config->dl_config_list[i].dlsch_config_pdu.dlsch_config_rel15; - dlsch0 = PHY_vars_UE_g[module_id][cc_id]->dlsch_ra[0]; dlsch0->rnti_type = _RA_RNTI_; - dlsch0->harq_processes[dlsch_config_pdu->harq_process_nbr]->status = ACTIVE; - configure_dlsch(dlsch0, dlsch_config_pdu, module_id, + dlsch0->dlsch_config = *dlsch_config_pdu; + configure_dlsch(dlsch0, PHY_vars_UE_g[module_id][cc_id]->dl_harq_processes[0], dlsch_config_pdu, module_id, dl_config->dl_config_list[i].dlsch_config_pdu.rnti); break; case FAPI_NR_DL_CONFIG_TYPE_SI_DLSCH: dlsch_config_pdu = &dl_config->dl_config_list[i].dlsch_config_pdu.dlsch_config_rel15; - dlsch0 = PHY_vars_UE_g[module_id][cc_id]->dlsch_SI[0]; dlsch0->rnti_type = _SI_RNTI_; - dlsch0->harq_processes[dlsch_config_pdu->harq_process_nbr]->status = ACTIVE; - configure_dlsch(dlsch0, dlsch_config_pdu, module_id, + dlsch0->dlsch_config = *dlsch_config_pdu; + configure_dlsch(dlsch0, PHY_vars_UE_g[module_id][cc_id]->dl_harq_processes[0], dlsch_config_pdu, module_id, dl_config->dl_config_list[i].dlsch_config_pdu.rnti); break; case FAPI_NR_DL_CONFIG_TYPE_DLSCH: dlsch_config_pdu = &dl_config->dl_config_list[i].dlsch_config_pdu.dlsch_config_rel15; - dlsch0 = PHY_vars_UE_g[module_id][cc_id]->dlsch[0][0]; - configure_dlsch(dlsch0, dlsch_config_pdu, module_id, + dlsch0->rnti_type = _C_RNTI_; + dlsch0->dlsch_config = *dlsch_config_pdu; + configure_dlsch(dlsch0, PHY_vars_UE_g[module_id][cc_id]->dl_harq_processes[0], dlsch_config_pdu, module_id, dl_config->dl_config_list[i].dlsch_config_pdu.rnti); break; } diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 697638f6cf..fb4a737da1 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -130,39 +130,34 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, LOG_E(PHY, "In %s: multiple number of DL PDUs not supported yet...\n", __FUNCTION__); } - if (pdu_type != FAPI_NR_RX_PDU_TYPE_SSB) + NR_DL_UE_HARQ_t *dl_harq0 = NULL; + + if ((pdu_type != FAPI_NR_RX_PDU_TYPE_SSB) && dlsch0) { + dl_harq0 = &ue->dl_harq_processes[0][dlsch0->dlsch_config.harq_process_nbr]; trace_NRpdu(DIRECTION_DOWNLINK, - dlsch0->harq_processes[dlsch0->current_harq_pid]->b, - dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS / 8, + dl_harq0->b, + dlsch0->dlsch_config.TBS / 8, WS_C_RNTI, dlsch0->rnti, proc->frame_rx, proc->nr_slot_rx, 0,0); + } switch (pdu_type){ case FAPI_NR_RX_PDU_TYPE_SIB: - rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.harq_pid = dlsch0->current_harq_pid; - rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.ack_nack = dlsch0->harq_processes[dlsch0->current_harq_pid]->ack; - rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.pdu = dlsch0->harq_processes[dlsch0->current_harq_pid]->b; - rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.pdu_length = dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS / 8; - break; + case FAPI_NR_RX_PDU_TYPE_RAR: case FAPI_NR_RX_PDU_TYPE_DLSCH: if(dlsch0) { - rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.harq_pid = dlsch0->current_harq_pid; - rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.ack_nack = dlsch0->harq_processes[dlsch0->current_harq_pid]->ack; - rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.pdu = dlsch0->harq_processes[dlsch0->current_harq_pid]->b; - rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.pdu_length = dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS / 8; + dl_harq0 = &ue->dl_harq_processes[0][dlsch0->dlsch_config.harq_process_nbr]; + rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.harq_pid = dlsch0->dlsch_config.harq_process_nbr; + rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.ack_nack = dl_harq0->ack; + rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.pdu = dl_harq0->b; + rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.pdu_length = dlsch0->dlsch_config.TBS / 8; } if(dlsch1) { AssertFatal(1==0,"Second codeword currently not supported\n"); } break; - case FAPI_NR_RX_PDU_TYPE_RAR: - rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.harq_pid = dlsch0->current_harq_pid; - rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.ack_nack = dlsch0->harq_processes[dlsch0->current_harq_pid]->ack; - rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.pdu = dlsch0->harq_processes[dlsch0->current_harq_pid]->b; - rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.pdu_length = dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS / 8; - break; case FAPI_NR_RX_PDU_TYPE_SSB: rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.pdu=malloc(sizeof(((fapiPbch_t*)typeSpecific)->decoded_output)); memcpy(rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.pdu, @@ -312,7 +307,8 @@ void nr_ue_measurement_procedures(uint16_t l, PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, - uint16_t slot){ + uint16_t slot, + NR_UE_DLSCH_t *dlsch){ NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; int frame_rx = proc->frame_rx; @@ -327,7 +323,7 @@ void nr_ue_measurement_procedures(uint16_t l, nr_slot_rx, ue->common_vars.rxdata); - nr_ue_measurements(ue, proc, nr_slot_rx); + nr_ue_measurements(ue, proc, nr_slot_rx, dlsch); #if T_TRACER if(slot == 0) @@ -365,7 +361,7 @@ static void nr_ue_pbch_procedures(uint8_t gNB_id, UE_nr_rxtx_proc_t *proc, int estimateSz, struct complex16 dl_ch_estimates[][estimateSz], - NR_UE_PDCCH_CONFIG *phy_pdcch_config) { + nr_phy_data_t *phy_data) { int ret = 0; DevAssert(ue); @@ -384,7 +380,7 @@ static void nr_ue_pbch_procedures(uint8_t gNB_id, gNB_id, (ue->frame_parms.ssb_index)&7, SISO, - phy_pdcch_config, + phy_data, &result); if (ret==0) { @@ -493,7 +489,7 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, UE_nr_rxtx_proc_t *proc, int32_t pdcch_est_size, int32_t pdcch_dl_ch_estimates[][pdcch_est_size], - NR_UE_PDCCH_CONFIG *phy_pdcch_config, + nr_phy_data_t *phy_data, int n_ss) { int frame_rx = proc->frame_rx; @@ -501,6 +497,7 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, unsigned int dci_cnt=0; fapi_nr_dci_indication_t *dci_ind = calloc(1, sizeof(*dci_ind)); nr_downlink_indication_t dl_indication; + NR_UE_PDCCH_CONFIG *phy_pdcch_config = &phy_data->phy_pdcch_config; fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &phy_pdcch_config->pdcch_config[n_ss]; @@ -522,7 +519,7 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, n_ss); #endif - dci_cnt = nr_dci_decoding_procedure(ue, proc, pdcch_e_rx, dci_ind, rel15, phy_pdcch_config); + dci_cnt = nr_dci_decoding_procedure(ue, proc, pdcch_e_rx, dci_ind, rel15); #ifdef NR_PDCCH_SCHED_DEBUG LOG_I(PHY,"<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Ending function nr_dci_decoding_procedure() -> dci_cnt=%u\n",dci_cnt); @@ -543,7 +540,7 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, dci_ind->number_of_dcis = dci_cnt; // fill dl_indication message - nr_fill_dl_indication(&dl_indication, dci_ind, NULL, proc, ue, gNB_id, phy_pdcch_config); + nr_fill_dl_indication(&dl_indication, dci_ind, NULL, proc, ue, gNB_id, phy_data); // send to mac ue->if_inst->dl_indication(&dl_indication, NULL); @@ -555,47 +552,51 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, } #endif // NR_PDCCH_SCHED -int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_id, PDSCH_t pdsch, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1) { +int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_id, NR_UE_DLSCH_t *dlsch) { int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; int m; - int i_mod,gNB_id_i,dual_stream_UE; + int gNB_id_i; int first_symbol_flag=0; - if (!dlsch0) - return 0; - if (dlsch0->active == 0) + if (!dlsch[0].active) return 0; - if (!dlsch1) { - int harq_pid = dlsch0->current_harq_pid; - NR_DL_UE_HARQ_t *dlsch0_harq = dlsch0->harq_processes[harq_pid]; - uint16_t BWPStart = dlsch0_harq->BWPStart; - uint16_t pdsch_start_rb = dlsch0_harq->start_rb; - uint16_t pdsch_nb_rb = dlsch0_harq->nb_rb; - uint16_t s0 = dlsch0_harq->start_symbol; - uint16_t s1 = dlsch0_harq->nb_symbols; + NR_UE_DLSCH_t *dlsch1 = NULL; + + if (NR_MAX_NB_LAYERS > 4) + dlsch1 = &dlsch[1]; + + if (!dlsch1) { + NR_UE_DLSCH_t *dlsch0 = &dlsch[0]; + int harq_pid = dlsch0->dlsch_config.harq_process_nbr; + NR_DL_UE_HARQ_t *dlsch0_harq = ue->dl_harq_processes[harq_pid]; + uint16_t BWPStart = dlsch0->dlsch_config.BWPStart; + uint16_t pdsch_start_rb = dlsch0->dlsch_config.start_rb; + uint16_t pdsch_nb_rb = dlsch0->dlsch_config.number_rbs; + uint16_t s0 = dlsch0->dlsch_config.start_symbol; + uint16_t s1 = dlsch0->dlsch_config.number_symbols; bool is_SI = dlsch0->rnti_type == _SI_RNTI_; - LOG_D(PHY,"[UE %d] PDSCH type %d active in nr_slot_rx %d, harq_pid %d (%d), rb_start %d, nb_rb %d, symbol_start %d, nb_symbols %d, DMRS mask %x, Nl %d\n", - ue->Mod_id,pdsch,nr_slot_rx,harq_pid,dlsch0_harq->status,pdsch_start_rb,pdsch_nb_rb,s0,s1,dlsch0_harq->dlDmrsSymbPos, dlsch0_harq->Nl); + LOG_D(PHY,"[UE %d] nr_slot_rx %d, harq_pid %d (%d), rb_start %d, nb_rb %d, symbol_start %d, nb_symbols %d, DMRS mask %x, Nl %d\n", + ue->Mod_id,nr_slot_rx,harq_pid,dlsch0_harq->status,pdsch_start_rb,pdsch_nb_rb,s0,s1,dlsch0->dlsch_config.dlDmrsSymbPos, dlsch0->Nl); for (m = s0; m < (s0 +s1); m++) { - if (dlsch0_harq->dlDmrsSymbPos & (1 << m)) { - for (uint8_t aatx=0; aatxNl; aatx++) {//for MIMO Config: it shall loop over no_layers + if (dlsch0->dlsch_config.dlDmrsSymbPos & (1 << m)) { + for (uint8_t aatx=0; aatxNl; aatx++) {//for MIMO Config: it shall loop over no_layers LOG_D(PHY,"PDSCH Channel estimation gNB id %d, PDSCH antenna port %d, slot %d, symbol %d\n",0,aatx,nr_slot_rx,m); nr_pdsch_channel_estimation(ue, proc, gNB_id, is_SI, nr_slot_rx, - get_dmrs_port(aatx,dlsch0_harq->dmrs_ports), + get_dmrs_port(aatx,dlsch0->dlsch_config.dmrs_ports), m, - dlsch0_harq->nscid, - dlsch0_harq->dlDmrsScramblingId, + dlsch0->dlsch_config.nscid, + dlsch0->dlsch_config.dlDmrsScramblingId, BWPStart, - dlsch0_harq->dmrsConfigType, + dlsch0->dlsch_config.dmrsConfigType, ue->frame_parms.first_carrier_offset+(BWPStart + pdsch_start_rb)*12, pdsch_nb_rb); #if 0 @@ -615,30 +616,28 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ if (ue->chest_time == 1) { // averaging time domain channel estimates nr_chest_time_domain_avg(&ue->frame_parms, ue->pdsch_vars[gNB_id]->dl_ch_estimates, - dlsch0_harq->nb_symbols, - dlsch0_harq->start_symbol, - dlsch0_harq->dlDmrsSymbPos, + dlsch0->dlsch_config.number_symbols, + dlsch0->dlsch_config.start_symbol, + dlsch0->dlsch_config.dlDmrsSymbPos, pdsch_nb_rb); } uint16_t first_symbol_with_data = s0; uint32_t dmrs_data_re; - if (dlsch0_harq->dmrsConfigType == NFAPI_NR_DMRS_TYPE1) - dmrs_data_re = 12 - 6 * dlsch0_harq->n_dmrs_cdm_groups; + if (dlsch0->dlsch_config.dmrsConfigType == NFAPI_NR_DMRS_TYPE1) + dmrs_data_re = 12 - 6 * dlsch0->dlsch_config.n_dmrs_cdm_groups; else - dmrs_data_re = 12 - 4 * dlsch0_harq->n_dmrs_cdm_groups; + dmrs_data_re = 12 - 4 * dlsch0->dlsch_config.n_dmrs_cdm_groups; - while ((dmrs_data_re == 0) && (dlsch0_harq->dlDmrsSymbPos & (1 << first_symbol_with_data))) { + while ((dmrs_data_re == 0) && (dlsch0->dlsch_config.dlDmrsSymbPos & (1 << first_symbol_with_data))) { first_symbol_with_data++; } start_meas(&ue->rx_pdsch_stats); for (m = s0; m < (s1 + s0); m++) { - dual_stream_UE = 0; gNB_id_i = gNB_id+1; - i_mod = 0; if (m==first_symbol_with_data) first_symbol_flag = 1; else @@ -650,21 +649,17 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ start_meas(&ue->dlsch_llr_stats_parallelization[slot]); // process DLSCH received symbols in the slot // symbol by symbol processing (if data/DMRS are multiplexed is checked inside the function) - if (pdsch == PDSCH || pdsch == SI_PDSCH || pdsch == RA_PDSCH) { - if (nr_rx_pdsch(ue, - proc, - pdsch, - gNB_id, - gNB_id_i, - frame_rx, - nr_slot_rx, - m, - first_symbol_flag, - dual_stream_UE, - i_mod, - harq_pid) < 0) - return -1; - } else AssertFatal(1==0,"Not RA_PDSCH, SI_PDSCH or PDSCH\n"); + if (nr_rx_pdsch(ue, + proc, + dlsch, + gNB_id, + gNB_id_i, + frame_rx, + nr_slot_rx, + m, + first_symbol_flag, + harq_pid) < 0) + return -1; stop_meas(&ue->dlsch_llr_stats_parallelization[slot]); if (cpumeas(CPUMEAS_GETSTATE)) @@ -681,357 +676,304 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_id, - PDSCH_t pdsch, NR_UE_DLSCH_t *dlsch0, - NR_UE_DLSCH_t *dlsch1, - int *dlsch_errors) { + NR_UE_DLSCH_t *dlsch1) { if (dlsch0==NULL) AssertFatal(0,"dlsch0 should be defined at this level \n"); bool dec = false; - int harq_pid = dlsch0->current_harq_pid; + int harq_pid = dlsch0->dlsch_config.harq_process_nbr; int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; uint32_t ret = UINT32_MAX, ret1 = UINT32_MAX; NR_UE_PDSCH *pdsch_vars; - uint16_t dmrs_len = get_num_dmrs(dlsch0->harq_processes[dlsch0->current_harq_pid]->dlDmrsSymbPos); + NR_DL_UE_HARQ_t *dl_harq0 = &ue->dl_harq_processes[0][harq_pid]; + NR_DL_UE_HARQ_t *dl_harq1 = &ue->dl_harq_processes[NR_MAX_NB_LAYERS>4 ? 1:0][harq_pid]; + uint16_t dmrs_len = get_num_dmrs(dlsch0->dlsch_config.dlDmrsSymbPos); nr_downlink_indication_t dl_indication; fapi_nr_rx_indication_t *rx_ind = calloc(1, sizeof(*rx_ind)); uint16_t number_pdus = 1; // params for UL time alignment procedure NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &ue->ul_time_alignment[gNB_id]; - uint8_t is_cw0_active = dlsch0->harq_processes[harq_pid]->status; - uint16_t nb_symb_sch = dlsch0->harq_processes[harq_pid]->nb_symbols; - uint16_t start_symbol = dlsch0->harq_processes[harq_pid]->start_symbol; - uint8_t dmrs_type = dlsch0->harq_processes[harq_pid]->dmrsConfigType; + uint8_t is_cw0_active = dl_harq0->status; + uint16_t nb_symb_sch = dlsch0->dlsch_config.number_symbols; + uint16_t start_symbol = dlsch0->dlsch_config.start_symbol; + uint8_t dmrs_type = dlsch0->dlsch_config.dmrsConfigType; uint8_t nb_re_dmrs; if (dmrs_type==NFAPI_NR_DMRS_TYPE1) { - nb_re_dmrs = 6*dlsch0->harq_processes[harq_pid]->n_dmrs_cdm_groups; + nb_re_dmrs = 6*dlsch0->dlsch_config.n_dmrs_cdm_groups; } else { - nb_re_dmrs = 4*dlsch0->harq_processes[harq_pid]->n_dmrs_cdm_groups; + nb_re_dmrs = 4*dlsch0->dlsch_config.n_dmrs_cdm_groups; } uint8_t is_cw1_active = 0; if(dlsch1) - is_cw1_active = dlsch1->harq_processes[harq_pid]->status; + is_cw1_active = dl_harq1->status; LOG_D(PHY,"AbsSubframe %d.%d Start LDPC Decoder for CW0 [harq_pid %d] ? %d \n", frame_rx%1024, nr_slot_rx, harq_pid, is_cw0_active); LOG_D(PHY,"AbsSubframe %d.%d Start LDPC Decoder for CW1 [harq_pid %d] ? %d \n", frame_rx%1024, nr_slot_rx, harq_pid, is_cw1_active); - if(is_cw0_active && is_cw1_active) - { - dlsch0->Kmimo = 2; - dlsch1->Kmimo = 2; - } - else - { - dlsch0->Kmimo = 1; - } - if (1) { - switch (pdsch) { - case SI_PDSCH: - case RA_PDSCH: - case P_PDSCH: - case PDSCH: - pdsch_vars = ue->pdsch_vars[gNB_id]; + pdsch_vars = ue->pdsch_vars[gNB_id]; + + // exit dlsch procedures as there are no active dlsch + if (is_cw0_active != ACTIVE && is_cw1_active != ACTIVE) + return false; + + // start ldpc decode for CW 0 + dl_harq0->G = nr_get_G(dlsch0->dlsch_config.number_rbs, + nb_symb_sch, + nb_re_dmrs, + dmrs_len, + dlsch0->dlsch_config.qamModOrder, + dlsch0->Nl); + + start_meas(&ue->dlsch_unscrambling_stats); + nr_dlsch_unscrambling(pdsch_vars->llr[0], + dl_harq0->G, + 0, + ue->frame_parms.Nid_cell, + dlsch0->rnti); + + + stop_meas(&ue->dlsch_unscrambling_stats); + + start_meas(&ue->dlsch_decoding_stats); + + ret = nr_dlsch_decoding(ue, + proc, + gNB_id, + pdsch_vars->llr[0], + &ue->frame_parms, + dlsch0, + dl_harq0, + frame_rx, + nb_symb_sch, + nr_slot_rx, + harq_pid); + + LOG_T(PHY,"dlsch decoding, ret = %d\n", ret); + + + if(retmax_ldpc_iterations+1) + dec = true; + + int ind_type = -1; + switch(dlsch0->rnti_type) { + case _RA_RNTI_: + ind_type = FAPI_NR_RX_PDU_TYPE_RAR; break; - case PMCH: - case PDSCH1: - LOG_E(PHY,"Illegal PDSCH %d for ue_pdsch_procedures\n",pdsch); - pdsch_vars = NULL; - return false; + + case _SI_RNTI_: + ind_type = FAPI_NR_RX_PDU_TYPE_SIB; break; + + case _C_RNTI_: + ind_type = FAPI_NR_RX_PDU_TYPE_DLSCH; + break; + default: - pdsch_vars = NULL; - return false; + AssertFatal(true, "Invalid DLSCH type %d\n", dlsch0->rnti_type); break; + } - } - if (frame_rx < *dlsch_errors) - *dlsch_errors=0; + nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL); + nr_fill_rx_indication(rx_ind, ind_type, gNB_id, ue, dlsch0, NULL, number_pdus, proc, NULL); - // exit dlsch procedures as there are no active dlsch - if (is_cw0_active != ACTIVE && is_cw1_active != ACTIVE) - return false; + LOG_D(PHY, "In %s DL PDU length in bits: %d, in bytes: %d \n", __FUNCTION__, dlsch0->dlsch_config.TBS, dlsch0->dlsch_config.TBS / 8); - // start ldpc decode for CW 0 - dlsch0->harq_processes[harq_pid]->G = nr_get_G(dlsch0->harq_processes[harq_pid]->nb_rb, - nb_symb_sch, - nb_re_dmrs, - dmrs_len, - dlsch0->harq_processes[harq_pid]->Qm, - dlsch0->harq_processes[harq_pid]->Nl); + stop_meas(&ue->dlsch_decoding_stats); + if (cpumeas(CPUMEAS_GETSTATE)) { + LOG_D(PHY, " --> Unscrambling for CW0 %5.3f\n", + (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0)); + LOG_D(PHY, "AbsSubframe %d.%d --> LDPC Decoding for CW0 %5.3f\n", + frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats.p_time)/(cpuf*1000.0)); + } + if(is_cw1_active) { + // start ldpc decode for CW 1 + dl_harq1->G = nr_get_G(dlsch1->dlsch_config.number_rbs, + nb_symb_sch, + nb_re_dmrs, + dmrs_len, + dlsch1->dlsch_config.qamModOrder, + dlsch1->Nl); start_meas(&ue->dlsch_unscrambling_stats); - nr_dlsch_unscrambling(pdsch_vars->llr[0], - dlsch0->harq_processes[harq_pid]->G, + nr_dlsch_unscrambling(pdsch_vars->llr[1], + dl_harq1->G, 0, ue->frame_parms.Nid_cell, - dlsch0->rnti); - - + dlsch1->rnti); stop_meas(&ue->dlsch_unscrambling_stats); + start_meas(&ue->dlsch_decoding_stats); -#if 0 - LOG_I(PHY," ------ start ldpc decoder for AbsSubframe %d.%d / %d ------ \n", frame_rx, nr_slot_rx, harq_pid); - LOG_I(PHY,"start ldpc decode for CW 0 for AbsSubframe %d.%d / %d --> nb_rb %d \n", frame_rx, nr_slot_rx, harq_pid, dlsch0->harq_processes[harq_pid]->nb_rb); - LOG_I(PHY,"start ldpc decode for CW 0 for AbsSubframe %d.%d / %d --> rb_alloc_even %x \n", frame_rx, nr_slot_rx, harq_pid, dlsch0->harq_processes[harq_pid]->rb_alloc_even); - LOG_I(PHY,"start ldpc decode for CW 0 for AbsSubframe %d.%d / %d --> Qm %d \n", frame_rx, nr_slot_rx, harq_pid, dlsch0->harq_processes[harq_pid]->Qm); - LOG_I(PHY,"start ldpc decode for CW 0 for AbsSubframe %d.%d / %d --> Nl %d \n", frame_rx, nr_slot_rx, harq_pid, dlsch0->harq_processes[harq_pid]->Nl); - LOG_I(PHY,"start ldpc decode for CW 0 for AbsSubframe %d.%d / %d --> G %d \n", frame_rx, nr_slot_rx, harq_pid, dlsch0->harq_processes[harq_pid]->G); - LOG_I(PHY,"start ldpc decode for CW 0 for AbsSubframe %d.%d / %d --> Kmimo %d \n", frame_rx, nr_slot_rx, harq_pid, dlsch0->Kmimo); - LOG_I(PHY,"start ldpc decode for CW 0 for AbsSubframe %d.%d / %d --> Pdcch Sym %d \n", frame_rx, nr_slot_rx, harq_pid, ue->pdcch_vars[gNB_id]->num_pdcch_symbols); -#endif - - - start_meas(&ue->dlsch_decoding_stats); - - ret = nr_dlsch_decoding(ue, - proc, - gNB_id, - pdsch_vars->llr[0], - &ue->frame_parms, - dlsch0, - dlsch0->harq_processes[harq_pid], - frame_rx, - nb_symb_sch, - nr_slot_rx, - harq_pid, - pdsch==PDSCH); - - LOG_T(PHY,"dlsch decoding, ret = %d\n", ret); - - - if(retmax_ldpc_iterations+1) - dec = true; - - switch (pdsch) { - case RA_PDSCH: - nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL); - nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_RAR, gNB_id, ue, dlsch0, NULL, number_pdus, proc, NULL); - ue->UE_mode[gNB_id] = RA_RESPONSE; - break; - case PDSCH: - nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL); - nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_DLSCH, gNB_id, ue, dlsch0, NULL, number_pdus, proc, NULL); - break; - case SI_PDSCH: - nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id, NULL); - nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SIB, gNB_id, ue, dlsch0, NULL, number_pdus, proc, NULL); - break; - default: - break; - } - - LOG_D(PHY, "In %s DL PDU length in bits: %d, in bytes: %d \n", __FUNCTION__, dlsch0->harq_processes[harq_pid]->TBS, dlsch0->harq_processes[harq_pid]->TBS / 8); + ret1 = nr_dlsch_decoding(ue, + proc, + gNB_id, + pdsch_vars->llr[1], + &ue->frame_parms, + dlsch1, + dl_harq1, + frame_rx, + nb_symb_sch, + nr_slot_rx, + harq_pid); + LOG_T(PHY,"CW dlsch decoding, ret1 = %d\n", ret1); stop_meas(&ue->dlsch_decoding_stats); - if (cpumeas(CPUMEAS_GETSTATE)) { - LOG_D(PHY, " --> Unscrambling for CW0 %5.3f\n", + if (cpumeas(CPUMEAS_GETSTATE)) { + LOG_D(PHY, " --> Unscrambling for CW1 %5.3f\n", (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0)); - LOG_D(PHY, "AbsSubframe %d.%d --> LDPC Decoding for CW0 %5.3f\n", + LOG_D(PHY, "AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n", frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats.p_time)/(cpuf*1000.0)); + } + LOG_D(PHY, "harq_pid: %d, TBS expected dlsch1: %d \n", harq_pid, dlsch0->dlsch_config.TBS); + } + // send to mac + if (ue->if_inst && ue->if_inst->dl_indication) { + ue->if_inst->dl_indication(&dl_indication, ul_time_alignment); + } + + if (ue->mac_enabled == 1) { // TODO: move this from PHY to MAC layer! + + /* Time Alignment procedure + // - UE processing capability 1 + // - Setting the TA update to be applied after the reception of the TA command + // - Timing adjustment computed according to TS 38.213 section 4.2 + // - Durations of N1 and N2 symbols corresponding to PDSCH and PUSCH are + // computed according to sections 5.3 and 6.4 of TS 38.214 */ + const int numerology = ue->frame_parms.numerology_index; + const int ofdm_symbol_size = ue->frame_parms.ofdm_symbol_size; + const int nb_prefix_samples = ue->frame_parms.nb_prefix_samples; + const int samples_per_subframe = ue->frame_parms.samples_per_subframe; + const int slots_per_frame = ue->frame_parms.slots_per_frame; + const int slots_per_subframe = ue->frame_parms.slots_per_subframe; + + const double tc_factor = 1.0 / samples_per_subframe; + const uint16_t bw_scaling = get_bw_scaling(ofdm_symbol_size); + + const int Ta_max = 3846; // Max value of 12 bits TA Command + const double N_TA_max = Ta_max * bw_scaling * tc_factor; + + NR_UE_MAC_INST_t *mac = get_mac_inst(0); + NR_BWP_Id_t dl_bwp = mac->DL_BWP_Id; + NR_BWP_Id_t ul_bwp = mac->UL_BWP_Id; + + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; + if(ul_bwp){ + if (mac->ULbwp[ul_bwp-1] && + mac->ULbwp[ul_bwp-1]->bwp_Dedicated && + mac->ULbwp[ul_bwp-1]->bwp_Dedicated->pusch_Config && + mac->ULbwp[ul_bwp-1]->bwp_Dedicated->pusch_Config->choice.setup && + mac->ULbwp[ul_bwp-1]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = mac->ULbwp[ul_bwp-1]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList->choice.setup; + } + else if (mac->ULbwp[ul_bwp-1] && + mac->ULbwp[ul_bwp-1]->bwp_Common && + mac->ULbwp[ul_bwp-1]->bwp_Common->pusch_ConfigCommon && + mac->ULbwp[ul_bwp-1]->bwp_Common->pusch_ConfigCommon->choice.setup && + mac->ULbwp[ul_bwp-1]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = mac->ULbwp[ul_bwp-1]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } } - - if(is_cw1_active) { - // start ldpc decode for CW 1 - dlsch1->harq_processes[harq_pid]->G = nr_get_G(dlsch1->harq_processes[harq_pid]->nb_rb, - nb_symb_sch, - nb_re_dmrs, - dmrs_len, - dlsch1->harq_processes[harq_pid]->Qm, - dlsch1->harq_processes[harq_pid]->Nl); - start_meas(&ue->dlsch_unscrambling_stats); - nr_dlsch_unscrambling(pdsch_vars->llr[1], - dlsch1->harq_processes[harq_pid]->G, - 0, - ue->frame_parms.Nid_cell, - dlsch1->rnti); - stop_meas(&ue->dlsch_unscrambling_stats); - -#if 0 - LOG_I(PHY,"start ldpc decode for CW 1 for AbsSubframe %d.%d / %d --> nb_rb %d \n", frame_rx, nr_slot_rx, harq_pid, dlsch1->harq_processes[harq_pid]->nb_rb); - LOG_I(PHY,"start ldpc decode for CW 1 for AbsSubframe %d.%d / %d --> rb_alloc_even %x \n", frame_rx, nr_slot_rx, harq_pid, dlsch1->harq_processes[harq_pid]->rb_alloc_even); - LOG_I(PHY,"start ldpc decode for CW 1 for AbsSubframe %d.%d / %d --> Qm %d \n", frame_rx, nr_slot_rx, harq_pid, dlsch1->harq_processes[harq_pid]->Qm); - LOG_I(PHY,"start ldpc decode for CW 1 for AbsSubframe %d.%d / %d --> Nl %d \n", frame_rx, nr_slot_rx, harq_pid, dlsch1->harq_processes[harq_pid]->Nl); - LOG_I(PHY,"start ldpc decode for CW 1 for AbsSubframe %d.%d / %d --> G %d \n", frame_rx, nr_slot_rx, harq_pid, dlsch1->harq_processes[harq_pid]->G); - LOG_I(PHY,"start ldpc decode for CW 1 for AbsSubframe %d.%d / %d --> Kmimo %d \n", frame_rx, nr_slot_rx, harq_pid, dlsch1->Kmimo); - LOG_I(PHY,"start ldpc decode for CW 1 for AbsSubframe %d.%d / %d --> Pdcch Sym %d \n", frame_rx, nr_slot_rx, harq_pid, ue->pdcch_vars[gNB_id]->num_pdcch_symbols); -#endif - - start_meas(&ue->dlsch_decoding_stats); - - - ret1 = nr_dlsch_decoding(ue, - proc, - gNB_id, - pdsch_vars->llr[1], - &ue->frame_parms, - dlsch1, - dlsch1->harq_processes[harq_pid], - frame_rx, - nb_symb_sch, - nr_slot_rx, - harq_pid, - pdsch==PDSCH);//proc->decoder_switch - LOG_T(PHY,"CW dlsch decoding, ret1 = %d\n", ret1); - - stop_meas(&ue->dlsch_decoding_stats); - if (cpumeas(CPUMEAS_GETSTATE)) { - LOG_D(PHY, " --> Unscrambling for CW1 %5.3f\n", - (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0)); - LOG_D(PHY, "AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n", - frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats.p_time)/(cpuf*1000.0)); - } - LOG_D(PHY, "harq_pid: %d, TBS expected dlsch1: %d \n", harq_pid, dlsch1->harq_processes[harq_pid]->TBS); + else if (mac->scc_SIB && + mac->scc_SIB->uplinkConfigCommon && + mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon && + mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup && + mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; } - // send to mac - if (ue->if_inst && ue->if_inst->dl_indication) { - ue->if_inst->dl_indication(&dl_indication, ul_time_alignment); + long mapping_type_ul = pusch_TimeDomainAllocationList ? pusch_TimeDomainAllocationList->list.array[0]->mappingType : NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeA; + + NR_PDSCH_Config_t *pdsch_Config = NULL; + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; + if(dl_bwp){ + pdsch_Config = (mac->DLbwp[dl_bwp-1] && mac->DLbwp[dl_bwp-1]->bwp_Dedicated->pdsch_Config->choice.setup) ? mac->DLbwp[dl_bwp-1]->bwp_Dedicated->pdsch_Config->choice.setup : NULL; + if (mac->DLbwp[dl_bwp-1] && mac->DLbwp[dl_bwp-1]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList) + pdsch_TimeDomainAllocationList = pdsch_Config->pdsch_TimeDomainAllocationList->choice.setup; + else if (mac->DLbwp[dl_bwp-1] && mac->DLbwp[dl_bwp-1]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList) + pdsch_TimeDomainAllocationList = mac->DLbwp[dl_bwp-1]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; } + else if (mac->scc_SIB && mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup) + pdsch_TimeDomainAllocationList = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + long mapping_type_dl = pdsch_TimeDomainAllocationList ? pdsch_TimeDomainAllocationList->list.array[0]->mappingType : NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - if (ue->mac_enabled == 1) { // TODO: move this from PHY to MAC layer! - - /* Time Alignment procedure - // - UE processing capability 1 - // - Setting the TA update to be applied after the reception of the TA command - // - Timing adjustment computed according to TS 38.213 section 4.2 - // - Durations of N1 and N2 symbols corresponding to PDSCH and PUSCH are - // computed according to sections 5.3 and 6.4 of TS 38.214 */ - const int numerology = ue->frame_parms.numerology_index; - const int ofdm_symbol_size = ue->frame_parms.ofdm_symbol_size; - const int nb_prefix_samples = ue->frame_parms.nb_prefix_samples; - const int samples_per_subframe = ue->frame_parms.samples_per_subframe; - const int slots_per_frame = ue->frame_parms.slots_per_frame; - const int slots_per_subframe = ue->frame_parms.slots_per_subframe; - - const double tc_factor = 1.0 / samples_per_subframe; - const uint16_t bw_scaling = get_bw_scaling(ofdm_symbol_size); - - const int Ta_max = 3846; // Max value of 12 bits TA Command - const double N_TA_max = Ta_max * bw_scaling * tc_factor; - - NR_UE_MAC_INST_t *mac = get_mac_inst(0); - NR_BWP_Id_t dl_bwp = mac->DL_BWP_Id; - NR_BWP_Id_t ul_bwp = mac->UL_BWP_Id; - - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; - if(ul_bwp){ - if (mac->ULbwp[ul_bwp-1] && - mac->ULbwp[ul_bwp-1]->bwp_Dedicated && - mac->ULbwp[ul_bwp-1]->bwp_Dedicated->pusch_Config && - mac->ULbwp[ul_bwp-1]->bwp_Dedicated->pusch_Config->choice.setup && - mac->ULbwp[ul_bwp-1]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = mac->ULbwp[ul_bwp-1]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList->choice.setup; - } - else if (mac->ULbwp[ul_bwp-1] && - mac->ULbwp[ul_bwp-1]->bwp_Common && - mac->ULbwp[ul_bwp-1]->bwp_Common->pusch_ConfigCommon && - mac->ULbwp[ul_bwp-1]->bwp_Common->pusch_ConfigCommon->choice.setup && - mac->ULbwp[ul_bwp-1]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = mac->ULbwp[ul_bwp-1]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } - } - else if (mac->scc_SIB && - mac->scc_SIB->uplinkConfigCommon && - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon && - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup && - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } - long mapping_type_ul = pusch_TimeDomainAllocationList ? pusch_TimeDomainAllocationList->list.array[0]->mappingType : NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeA; - - NR_PDSCH_Config_t *pdsch_Config = NULL; - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; - if(dl_bwp){ - pdsch_Config = (mac->DLbwp[dl_bwp-1] && mac->DLbwp[dl_bwp-1]->bwp_Dedicated->pdsch_Config->choice.setup) ? mac->DLbwp[dl_bwp-1]->bwp_Dedicated->pdsch_Config->choice.setup : NULL; - if (mac->DLbwp[dl_bwp-1] && mac->DLbwp[dl_bwp-1]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = pdsch_Config->pdsch_TimeDomainAllocationList->choice.setup; - else if (mac->DLbwp[dl_bwp-1] && mac->DLbwp[dl_bwp-1]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = mac->DLbwp[dl_bwp-1]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } - else if (mac->scc_SIB && mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup) - pdsch_TimeDomainAllocationList = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - long mapping_type_dl = pdsch_TimeDomainAllocationList ? pdsch_TimeDomainAllocationList->list.array[0]->mappingType : NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; - - NR_DMRS_DownlinkConfig_t *NR_DMRS_dlconfig = NULL; - if (pdsch_Config) { - if (mapping_type_dl == NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA) - NR_DMRS_dlconfig = (NR_DMRS_DownlinkConfig_t *)pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup; - else - NR_DMRS_dlconfig = (NR_DMRS_DownlinkConfig_t *)pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup; - } - - pdsch_dmrs_AdditionalPosition_t add_pos_dl = pdsch_dmrs_pos2; - if (NR_DMRS_dlconfig && NR_DMRS_dlconfig->dmrs_AdditionalPosition) - add_pos_dl = *NR_DMRS_dlconfig->dmrs_AdditionalPosition; - - /* PDSCH decoding time N_1 for processing capability 1 */ - int N_1; - - if (add_pos_dl == pdsch_dmrs_pos0) - N_1 = pdsch_N_1_capability_1[numerology][1]; - else if (add_pos_dl == pdsch_dmrs_pos1 || add_pos_dl == pdsch_dmrs_pos2) - N_1 = pdsch_N_1_capability_1[numerology][2]; - else - N_1 = pdsch_N_1_capability_1[numerology][3]; - - /* PUSCH preapration time N_2 for processing capability 1 */ - const int N_2 = pusch_N_2_timing_capability_1[numerology][1]; - - /* d_1_1 depending on the number of PDSCH symbols allocated */ - const int d = 0; // TODO number of overlapping symbols of the scheduling PDCCH and the scheduled PDSCH - int d_1_1 = 0; + NR_DMRS_DownlinkConfig_t *NR_DMRS_dlconfig = NULL; + if (pdsch_Config) { if (mapping_type_dl == NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA) - if (nb_symb_sch + start_symbol < 7) - d_1_1 = 7 - (nb_symb_sch + start_symbol); - else - d_1_1 = 0; - else // mapping type B - switch (nb_symb_sch){ - case 7: d_1_1 = 0; break; - case 4: d_1_1 = 3; break; - case 2: d_1_1 = 3 + d; break; - default: break; - } - - /* d_2_1 */ - int d_2_1; - if (mapping_type_ul == NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB && start_symbol != 0) - d_2_1 = 0; + NR_DMRS_dlconfig = (NR_DMRS_DownlinkConfig_t *)pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup; else - d_2_1 = 1; + NR_DMRS_dlconfig = (NR_DMRS_DownlinkConfig_t *)pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup; + } - /* d_2_2 */ - const double d_2_2 = pusch_d_2_2_timing_capability_1[numerology][1]; + pdsch_dmrs_AdditionalPosition_t add_pos_dl = pdsch_dmrs_pos2; + if (NR_DMRS_dlconfig && NR_DMRS_dlconfig->dmrs_AdditionalPosition) + add_pos_dl = *NR_DMRS_dlconfig->dmrs_AdditionalPosition; - /* N_t_1 time duration in msec of N_1 symbols corresponding to a PDSCH reception time - // N_t_2 time duration in msec of N_2 symbols corresponding to a PUSCH preparation time */ - double N_t_1 = (N_1 + d_1_1) * (ofdm_symbol_size + nb_prefix_samples) * tc_factor; - double N_t_2 = (N_2 + d_2_1) * (ofdm_symbol_size + nb_prefix_samples) * tc_factor; - if (N_t_2 < d_2_2) N_t_2 = d_2_2; + /* PDSCH decoding time N_1 for processing capability 1 */ + int N_1; - /* Time alignment procedure */ - // N_t_1 + N_t_2 + N_TA_max must be in msec - const double t_subframe = 1.0; // subframe duration of 1 msec - const int ul_tx_timing_adjustment = 1 + (int)ceil(slots_per_subframe*(N_t_1 + N_t_2 + N_TA_max + 0.5)/t_subframe); + if (add_pos_dl == pdsch_dmrs_pos0) + N_1 = pdsch_N_1_capability_1[numerology][1]; + else if (add_pos_dl == pdsch_dmrs_pos1 || add_pos_dl == pdsch_dmrs_pos2) + N_1 = pdsch_N_1_capability_1[numerology][2]; + else + N_1 = pdsch_N_1_capability_1[numerology][3]; - if (ul_time_alignment->apply_ta == 1){ - ul_time_alignment->ta_slot = (nr_slot_rx + ul_tx_timing_adjustment) % slots_per_frame; - if (nr_slot_rx + ul_tx_timing_adjustment > slots_per_frame){ - ul_time_alignment->ta_frame = (frame_rx + 1) % 1024; - } else { - ul_time_alignment->ta_frame = frame_rx; - } - // reset TA flag - ul_time_alignment->apply_ta = 0; - LOG_D(PHY,"Frame %d slot %d -- Starting UL time alignment procedures. TA update will be applied at frame %d slot %d\n", - frame_rx, nr_slot_rx, ul_time_alignment->ta_frame, ul_time_alignment->ta_slot); + /* PUSCH preapration time N_2 for processing capability 1 */ + const int N_2 = pusch_N_2_timing_capability_1[numerology][1]; + + /* d_1_1 depending on the number of PDSCH symbols allocated */ + const int d = 0; // TODO number of overlapping symbols of the scheduling PDCCH and the scheduled PDSCH + int d_1_1 = 0; + if (mapping_type_dl == NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA) + if (nb_symb_sch + start_symbol < 7) + d_1_1 = 7 - (nb_symb_sch + start_symbol); + else + d_1_1 = 0; + else // mapping type B + switch (nb_symb_sch){ + case 7: d_1_1 = 0; break; + case 4: d_1_1 = 3; break; + case 2: d_1_1 = 3 + d; break; + default: break; } + + /* d_2_1 */ + int d_2_1; + if (mapping_type_ul == NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB && start_symbol != 0) + d_2_1 = 0; + else + d_2_1 = 1; + + /* d_2_2 */ + const double d_2_2 = pusch_d_2_2_timing_capability_1[numerology][1]; + + /* N_t_1 time duration in msec of N_1 symbols corresponding to a PDSCH reception time + // N_t_2 time duration in msec of N_2 symbols corresponding to a PUSCH preparation time */ + double N_t_1 = (N_1 + d_1_1) * (ofdm_symbol_size + nb_prefix_samples) * tc_factor; + double N_t_2 = (N_2 + d_2_1) * (ofdm_symbol_size + nb_prefix_samples) * tc_factor; + if (N_t_2 < d_2_2) N_t_2 = d_2_2; + + /* Time alignment procedure */ + // N_t_1 + N_t_2 + N_TA_max must be in msec + const double t_subframe = 1.0; // subframe duration of 1 msec + const int ul_tx_timing_adjustment = 1 + (int)ceil(slots_per_subframe*(N_t_1 + N_t_2 + N_TA_max + 0.5)/t_subframe); + + if (ul_time_alignment->apply_ta == 1){ + ul_time_alignment->ta_slot = (nr_slot_rx + ul_tx_timing_adjustment) % slots_per_frame; + if (nr_slot_rx + ul_tx_timing_adjustment > slots_per_frame){ + ul_time_alignment->ta_frame = (frame_rx + 1) % 1024; + } else { + ul_time_alignment->ta_frame = frame_rx; + } + // reset TA flag + ul_time_alignment->apply_ta = 0; + LOG_D(PHY,"Frame %d slot %d -- Starting UL time alignment procedures. TA update will be applied at frame %d slot %d\n", + frame_rx, nr_slot_rx, ul_time_alignment->ta_frame, ul_time_alignment->ta_slot); } } return dec; @@ -1041,13 +983,15 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, - NR_UE_PDCCH_CONFIG *phy_pdcch_config, + nr_phy_data_t *phy_data, notifiedFIFO_t *txFifo) { int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; fapi_nr_config_request_t *cfg = &ue->nrUE_config; NR_DL_FRAME_PARMS *fp = &ue->frame_parms; + NR_UE_PDCCH_CONFIG *phy_pdcch_config = &phy_data->phy_pdcch_config; + nr_ue_dlsch_init(phy_data->dlsch, NR_MAX_NB_LAYERS>4 ? 2:1, ue->max_ldpc_iterations); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); start_meas(&ue->phy_proc_rx); @@ -1101,7 +1045,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, if(ssb_index == fp->ssb_index) { LOG_D(PHY," ------ Decode MIB: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); - nr_ue_pbch_procedures(gNB_id, ue, proc, estimateSz, dl_ch_estimates, phy_pdcch_config); + nr_ue_pbch_procedures(gNB_id, ue, proc, estimateSz, dl_ch_estimates, phy_data); if (ue->no_timing_correction==0) { LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction); @@ -1202,29 +1146,20 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, stop_meas(&ue->ofdm_demod_stats); } - dci_cnt = dci_cnt + nr_ue_pdcch_procedures(gNB_id, ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, phy_pdcch_config, n_ss); + dci_cnt = dci_cnt + nr_ue_pdcch_procedures(gNB_id, ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, phy_data, n_ss); } + phy_pdcch_config->nb_search_space = 0; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PDCCH, VCD_FUNCTION_OUT); + NR_UE_DLSCH_t *dlsch = &phy_data->dlsch[0]; if (dci_cnt > 0) { LOG_D(PHY,"[UE %d] Frame %d, nr_slot_rx %d: found %d DCIs\n", ue->Mod_id, frame_rx, nr_slot_rx, dci_cnt); - NR_UE_DLSCH_t *dlsch = NULL; - if (ue->dlsch[gNB_id][0]->active == 1){ - dlsch = ue->dlsch[gNB_id][0]; - } else if (ue->dlsch_SI[0]->active == 1){ - dlsch = ue->dlsch_SI[0]; - } else if (ue->dlsch_ra[0]->active == 1){ - dlsch = ue->dlsch_ra[0]; - } - - if (dlsch) { + if (dlsch->active) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PDSCH, VCD_FUNCTION_IN); - uint8_t harq_pid = dlsch->current_harq_pid; - NR_DL_UE_HARQ_t *dlsch0_harq = dlsch->harq_processes[harq_pid]; - uint16_t nb_symb_sch = dlsch0_harq->nb_symbols; - uint16_t start_symb_sch = dlsch0_harq->start_symbol; + uint16_t nb_symb_sch = dlsch[0].dlsch_config.number_symbols; + uint16_t start_symb_sch = dlsch[0].dlsch_config.start_symbol; LOG_D(PHY," ------ --> PDSCH ChannelComp/LLR Frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); //to update from pdsch config @@ -1253,91 +1188,15 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, start_meas(&ue->generic_stat); // do procedures for C-RNTI int ret_pdsch = 0; - if (ue->dlsch[gNB_id][0]->active == 1) { + if (dlsch->active) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_C, VCD_FUNCTION_IN); ret_pdsch = nr_ue_pdsch_procedures(ue, proc, gNB_id, - PDSCH, - ue->dlsch[gNB_id][0], - NULL); + dlsch); - nr_ue_measurement_procedures(2, ue, proc, gNB_id, nr_slot_rx); + nr_ue_measurement_procedures(2, ue, proc, gNB_id, nr_slot_rx, dlsch); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_C, VCD_FUNCTION_OUT); - } - - // do procedures for SI-RNTI - if ((ue->dlsch_SI[gNB_id]) && (ue->dlsch_SI[gNB_id]->active == 1)) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_IN); - nr_ue_pdsch_procedures(ue, - proc, - gNB_id, - SI_PDSCH, - ue->dlsch_SI[gNB_id], - NULL); - - nr_ue_dlsch_procedures(ue, - proc, - gNB_id, - SI_PDSCH, - ue->dlsch_SI[gNB_id], - NULL, - &ue->dlsch_SI_errors[gNB_id]); - - // deactivate dlsch once dlsch proc is done - ue->dlsch_SI[gNB_id]->active = 0; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_OUT); - } - - // do procedures for P-RNTI - if ((ue->dlsch_p[gNB_id]) && (ue->dlsch_p[gNB_id]->active == 1)) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_IN); - nr_ue_pdsch_procedures(ue, - proc, - gNB_id, - P_PDSCH, - ue->dlsch_p[gNB_id], - NULL); - - nr_ue_dlsch_procedures(ue, - proc, - gNB_id, - P_PDSCH, - ue->dlsch_p[gNB_id], - NULL, - &ue->dlsch_p_errors[gNB_id]); - - // deactivate dlsch once dlsch proc is done - ue->dlsch_p[gNB_id]->active = 0; - 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[gNB_id]) && (ue->dlsch_ra[gNB_id]->active == 1) && (ue->UE_mode[gNB_id] != PUSCH)) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_IN); - nr_ue_pdsch_procedures(ue, - proc, - gNB_id, - RA_PDSCH, - ue->dlsch_ra[gNB_id], - NULL); - - nr_ue_dlsch_procedures(ue, - proc, - gNB_id, - RA_PDSCH, - ue->dlsch_ra[gNB_id], - NULL, - &ue->dlsch_ra_errors[gNB_id]); - - // deactivate dlsch once dlsch proc is done - ue->dlsch_ra[gNB_id]->active = 0; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_OUT); - } - // do procedures for C-RNTI - if (ue->dlsch[gNB_id][0]->active == 1) { LOG_D(PHY, "DLSCH data reception at nr_slot_rx: %d\n", nr_slot_rx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); @@ -1346,30 +1205,21 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, NR_UE_DLSCH_t *dlsch1 = NULL; if (NR_MAX_NB_LAYERS>4) - dlsch1 = ue->dlsch[gNB_id][1]; + dlsch1 = &phy_data->dlsch[1]; if (ret_pdsch >= 0) - nr_ue_dlsch_procedures(ue, - proc, - gNB_id, - PDSCH, - ue->dlsch[gNB_id][0], - dlsch1, - &ue->dlsch_errors[gNB_id]); + nr_ue_dlsch_procedures(ue, proc, gNB_id, dlsch, dlsch1); + + stop_meas(&ue->dlsch_procedures_stat); + if (cpumeas(CPUMEAS_GETSTATE)) { + LOG_D(PHY, "[SFN %d] Slot1: Pdsch Proc %5.2f\n",nr_slot_rx,ue->pdsch_procedures_stat.p_time/(cpuf*1000.0)); + LOG_D(PHY, "[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",nr_slot_rx,ue->dlsch_procedures_stat.p_time/(cpuf*1000.0)); + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); - stop_meas(&ue->dlsch_procedures_stat); - if (cpumeas(CPUMEAS_GETSTATE)) { - LOG_D(PHY, "[SFN %d] Slot1: Pdsch Proc %5.2f\n",nr_slot_rx,ue->pdsch_procedures_stat.p_time/(cpuf*1000.0)); - LOG_D(PHY, "[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",nr_slot_rx,ue->dlsch_procedures_stat.p_time/(cpuf*1000.0)); } - // deactivate dlsch once dlsch proc is done - ue->dlsch[gNB_id][0]->active = 0; - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); - - } - // do procedures for CSI-IM if ((ue->csiim_vars[gNB_id]) && (ue->csiim_vars[gNB_id]->active == 1)) { int l_csiim[4] = {-1, -1, -1, -1}; diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 3b36b0d6e5..706e64bfd1 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -106,8 +106,6 @@ int main(int argc, char **argv) int frame_length_complex_samples; //int frame_length_complex_samples_no_prefix; NR_DL_FRAME_PARMS *frame_parms; - uint8_t Kmimo = 0; - uint32_t Nsoft = 0; double sigma; unsigned char qbits = 8; int ret; @@ -403,24 +401,19 @@ int main(int argc, char **argv) //nr_init_frame_parms_ue(&UE->frame_parms); //init_nr_ue_transport(UE, 0); - int num_codeword = NR_MAX_NB_LAYERS > 4? 2:1; - for (i = 0; i < num_codeword; i++) { - UE->dlsch[0][i] = new_nr_ue_dlsch(Kmimo, 8, Nsoft, 5, N_RB_DL); - if (!UE->dlsch[0][i]) { - printf("Can't get ue dlsch structures\n"); - exit(-1); - } - - UE->dlsch[0][i]->rnti = n_rnti; - } + NR_UE_DLSCH_t dlsch_ue[NR_MAX_NB_LAYERS > 4? 2:1] = {0}; + int num_codeword = NR_MAX_NB_LAYERS > 4? 2:1; + nr_ue_dlsch_init(dlsch_ue, num_codeword, 5); + for (int i=0; i < num_codeword; i++) + dlsch_ue[0].rnti = n_rnti; + nr_init_harq_processes(UE->dl_harq_processes[0], 8, nb_rb); unsigned char harq_pid = 0; //dlsch->harq_ids[subframe]; - processingData_L1tx_t msgDataTx; - init_DLSCH_struct(gNB, &msgDataTx); + processingData_L1tx_t msgDataTx; + init_DLSCH_struct(gNB, &msgDataTx); NR_gNB_DLSCH_t *dlsch = msgDataTx.dlsch[0][0]; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->harq_process.pdsch_pdu.pdsch_pdu_rel15; //time_stats_t *rm_stats, *te_stats, *i_stats; - uint8_t is_crnti = 0; unsigned int TBS = 8424; uint8_t nb_re_dmrs = 6; // No data in dmrs symbol uint16_t length_dmrs = 1; @@ -432,7 +425,7 @@ int main(int argc, char **argv) //printf("dlschsim harqid %d nb_rb %d, mscs %d\n",dlsch->harq_ids[subframe], // dlsch->harq_processes[0]->nb_rb,dlsch->harq_processes[0]->mcs,dlsch->harq_processes[0]->Nl); unsigned char mod_order = nr_get_Qm_dl(Imcs, mcs_table); - uint16_t rate = nr_get_code_rate_dl(Imcs, mcs_table); + uint16_t rate = nr_get_code_rate_dl(Imcs, mcs_table); unsigned int available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); TBS = nr_compute_tbs(mod_order,rate, nb_rb, nb_symb_sch, nb_re_dmrs*length_dmrs, 0, 0, Nl); printf("available bits %u TBS %u mod_order %d\n", available_bits, TBS, mod_order); @@ -442,14 +435,14 @@ int main(int argc, char **argv) rel15->qamModOrder[0] = mod_order; rel15->nrOfLayers = Nl; rel15->TBSize[0] = TBS>>3; - rel15->targetCodeRate[0] = rate; - rel15->NrOfCodewords = 1; - rel15->dmrsConfigType = NFAPI_NR_DMRS_TYPE1; + rel15->targetCodeRate[0] = rate; + rel15->NrOfCodewords = 1; + rel15->dmrsConfigType = NFAPI_NR_DMRS_TYPE1; rel15->dlDmrsSymbPos = 4; rel15->mcsIndex[0] = Imcs; - rel15->numDmrsCdmGrpsNoData = 1; - rel15->maintenance_parms_v3.tbSizeLbrmBytes = Tbslbrm; - rel15->maintenance_parms_v3.ldpcBaseGraph = get_BG(TBS, rate); + rel15->numDmrsCdmGrpsNoData = 1; + rel15->maintenance_parms_v3.tbSizeLbrmBytes = Tbslbrm; + rel15->maintenance_parms_v3.ldpcBaseGraph = get_BG(TBS, rate); double modulated_input[16 * 68 * 384]; // [hna] 16 segments, 68*Zc short channel_output_fixed[16 * 68 * 384]; //unsigned char *estimated_output; @@ -457,21 +450,22 @@ int main(int argc, char **argv) unsigned char test_input_bit[16 * 68 * 384]; //estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); unsigned char estimated_output_bit[16 * 68 * 384]; - NR_UE_DLSCH_t *dlsch0_ue = UE->dlsch[0][0]; - NR_DL_UE_HARQ_t *harq_process = dlsch0_ue->harq_processes[harq_pid]; - harq_process->mcs = Imcs; - harq_process->mcs_table = mcs_table; - harq_process->Nl = Nl; - harq_process->nb_rb = nb_rb; - harq_process->Qm = mod_order; - harq_process->rvidx = rvidx; - harq_process->R = rate; - harq_process->TBS = TBS; - harq_process->dmrsConfigType = NFAPI_NR_DMRS_TYPE1; - harq_process->dlDmrsSymbPos = 4; - harq_process->n_dmrs_cdm_groups = 1; - harq_process->tbslbrm = Tbslbrm; - printf("harq process ue mcs = %d Qm = %d, symb %d\n", harq_process->mcs, harq_process->Qm, nb_symb_sch); + NR_UE_DLSCH_t *dlsch0_ue = &dlsch_ue[0]; + NR_DL_UE_HARQ_t *harq_process = &UE->dl_harq_processes[0][harq_pid]; + harq_process->first_rx = 1; + dlsch0_ue->dlsch_config.mcs = Imcs; + dlsch0_ue->dlsch_config.mcs_table = mcs_table; + dlsch0_ue->Nl = Nl; + dlsch0_ue->dlsch_config.number_rbs = nb_rb; + dlsch0_ue->dlsch_config.qamModOrder = mod_order; + dlsch0_ue->dlsch_config.rv = rvidx; + dlsch0_ue->dlsch_config.targetCodeRate = rate; + dlsch0_ue->dlsch_config.TBS = TBS; + dlsch0_ue->dlsch_config.dmrsConfigType = NFAPI_NR_DMRS_TYPE1; + dlsch0_ue->dlsch_config.dlDmrsSymbPos = 4; + dlsch0_ue->dlsch_config.n_dmrs_cdm_groups = 1; + dlsch0_ue->dlsch_config.tbslbrm = Tbslbrm; + printf("harq process ue mcs = %d Qm = %d, symb %d\n", dlsch0_ue->dlsch_config.mcs, dlsch0_ue->dlsch_config.qamModOrder, nb_symb_sch); unsigned char *test_input=dlsch->harq_process.pdu; //unsigned char test_input[TBS / 8] __attribute__ ((aligned(16))); @@ -539,8 +533,8 @@ int main(int argc, char **argv) vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DECODING0, VCD_FUNCTION_IN); ret = nr_dlsch_decoding(UE, &proc, 0, channel_output_fixed, &UE->frame_parms, - dlsch0_ue, dlsch0_ue->harq_processes[0], frame, nb_symb_sch, - slot,harq_pid, is_crnti); + dlsch0_ue, harq_process, frame, nb_symb_sch, + slot,harq_pid); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DECODING0, VCD_FUNCTION_OUT); @@ -551,7 +545,7 @@ int main(int argc, char **argv) errors_bit = 0; for (i = 0; i < TBS; i++) { - estimated_output_bit[i] = (dlsch0_ue->harq_processes[0]->b[i / 8] & (1 << (i & 7))) >> (i & 7); + estimated_output_bit[i] = (harq_process->b[i / 8] & (1 << (i & 7))) >> (i & 7); test_input_bit[i] = (test_input[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments if (estimated_output_bit[i] != test_input_bit[i]) { @@ -620,7 +614,7 @@ int main(int argc, char **argv) int num_cw = NR_MAX_NB_LAYERS > 4? 2:1; for (int i = 0; i < num_cw; i++) - free_nr_ue_dlsch(&UE->dlsch[0][i], N_RB_DL); + free_nr_ue_dl_harq(UE->dl_harq_processes[i], 8, nb_rb); term_nr_ue_signal(UE, 1); free(UE); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 3a0c90842d..68f63d9512 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -379,17 +379,9 @@ int main(int argc, char **argv) int i,aa;//,l; double sigma2, sigma2_dB=10, SNR, snr0=-2.0, snr1=2.0; uint8_t snr1set=0; - uint32_t errors_scrambling[4][100] = {{0}}; - int n_errors[4][100] = {{0}}; - int round_trials[4][100] = {{0}}; - double roundStats[100] = {0}; - double blerStats[4][100] = {{0}}; - double berStats[4][100] = {{0}}; - double snrStats[100] = {0}; float effRate; //float psnr; float eff_tp_check = 0.7; - uint8_t snrRun; uint32_t TBS = 0; int **txdata; double **s_re,**s_im,**r_re,**r_im; @@ -470,8 +462,8 @@ int main(int argc, char **argv) int print_perf = 0; FILE *scg_fd=NULL; - - while ((c = getopt (argc, argv, "f:hA:pf:g:i:n:s:S:t:x:y:z:M:N:F:GR:d:PI:L:Ea:b:e:m:w:T:U:q:X:Y")) != -1) { + + while ((c = getopt(argc, argv, "f:hA:pf:g:i:n:s:S:t:v:x:y:z:M:N:F:GR:d:PI:L:Ea:b:e:m:w:T:U:q:X:Y")) != -1) { switch (c) { case 'f': scg_fd = fopen(optarg,"r"); @@ -577,6 +569,12 @@ int main(int argc, char **argv) break; + case 'v': + num_rounds = atoi(optarg); + + AssertFatal(num_rounds > 0 && num_rounds < 16, "Unsupported number of rounds %d, should be in [1,16]\n", num_rounds); + break; + case 'y': n_tx=atoi(optarg); @@ -723,6 +721,7 @@ int main(int argc, char **argv) printf("-T Enable PTRS, arguments list L_PTRS{0,1,2} K_PTRS{2,4}, e.g. -T 2 0 2 \n"); printf("-U Change DMRS Config, arguments list DMRS TYPE{0=A,1=B} DMRS AddPos{0:2} DMRS ConfType{1:2}, e.g. -U 3 0 2 1 \n"); printf("-P Print DLSCH performances\n"); + printf("-v Maximum number of rounds\n"); printf("-w Write txdata to binary file (one frame)\n"); printf("-d number of dlsch threads, 0: no dlsch parallelization\n"); printf("-X gNB thread pool configuration, n => no threads\n"); @@ -1015,7 +1014,7 @@ int main(int argc, char **argv) nr_dcireq_t dcireq; nr_scheduled_response_t scheduled_response; - NR_UE_PDCCH_CONFIG phy_pdcch_config={0}; + nr_phy_data_t phy_data = {0}; memset((void*)&dcireq,0,sizeof(dcireq)); memset((void*)&scheduled_response,0,sizeof(scheduled_response)); @@ -1030,11 +1029,10 @@ int main(int argc, char **argv) scheduled_response.CC_id = 0; scheduled_response.frame = frame; scheduled_response.slot = slot; - scheduled_response.phy_data = &phy_pdcch_config; + scheduled_response.phy_data = &phy_data; nr_ue_phy_config_request(&UE_mac->phy_config); //NR_COMMON_channels_t *cc = RC.nrmac[0]->common_channels; - snrRun = 0; int n_errs = 0; initNamedTpool(gNBthreads, &gNB->threadPool, true, "gNB-tpool"); @@ -1065,6 +1063,13 @@ int main(int argc, char **argv) clear_pdsch_stats(gNB); + uint32_t errors_scrambling[16] = {0}; + int n_errors[16] = {0}; + int round_trials[16] = {0}; + double roundStats = {0}; + double blerStats[16] = {0}; + double berStats[16] = {0}; + effRate = 0; //n_errors2 = 0; //n_alamouti = 0; @@ -1084,10 +1089,10 @@ int main(int argc, char **argv) dcireq.frame = frame; dcireq.slot = slot; - NR_UE_DLSCH_t *dlsch0 = UE->dlsch[0][0]; + NR_UE_DLSCH_t *dlsch0 = &phy_data.dlsch[0]; int harq_pid = slot; - NR_DL_UE_HARQ_t *UE_harq_process = dlsch0->harq_processes[harq_pid]; + NR_DL_UE_HARQ_t *UE_harq_process = &UE->dl_harq_processes[0][harq_pid]; NR_gNB_DLSCH_t *gNB_dlsch = msgDataTx->dlsch[0][0]; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &gNB_dlsch->harq_process.pdsch_pdu.pdsch_pdu_rel15; @@ -1098,7 +1103,7 @@ int main(int argc, char **argv) UE_harq_process->first_rx = 1; while ((roundack==0)) { - round_trials[round][snrRun]++; + round_trials[round]++; clear_nr_nfapi_information(RC.nrmac[0], 0, frame, slot); UE_info->UE_sched_ctrl.harq_processes[harq_pid].ndi = !(trial&1); @@ -1262,24 +1267,23 @@ int main(int argc, char **argv) phy_procedures_nrUE_RX(UE, &UE_proc, 0, - &phy_pdcch_config, + &phy_data, NULL); //---------------------------------------------------------- //---------------------- count errors ---------------------- //---------------------------------------------------------- - if (UE->dlsch[0][0]->last_iteration_cnt >= - UE->dlsch[0][0]->max_ldpc_iterations+1) - n_errors[round][snrRun]++; + if (dlsch0->last_iteration_cnt >= dlsch0->max_ldpc_iterations+1) + n_errors[round]++; NR_UE_PDSCH **pdsch_vars = UE->pdsch_vars; int16_t *UE_llr = pdsch_vars[0]->llr[0]; - TBS = UE_harq_process->TBS;//rel15->TBSize[0]; + TBS = dlsch0->dlsch_config.TBS;//rel15->TBSize[0]; uint16_t length_dmrs = get_num_dmrs(rel15->dlDmrsSymbPos); uint16_t nb_rb = rel15->rbSize; - uint8_t nb_re_dmrs = rel15->dmrsConfigType == NFAPI_NR_DMRS_TYPE1 ? 6*UE_harq_process->n_dmrs_cdm_groups : 4*UE_harq_process->n_dmrs_cdm_groups; + uint8_t nb_re_dmrs = rel15->dmrsConfigType == NFAPI_NR_DMRS_TYPE1 ? 6*dlsch0->dlsch_config.n_dmrs_cdm_groups : 4*dlsch0->dlsch_config.n_dmrs_cdm_groups; uint8_t mod_order = rel15->qamModOrder[0]; uint8_t nb_symb_sch = rel15->NrOfSymbols; @@ -1293,10 +1297,10 @@ int main(int argc, char **argv) if(((gNB_dlsch->harq_process.f[i] == 0) && (UE_llr[i] <= 0)) || ((gNB_dlsch->harq_process.f[i] == 1) && (UE_llr[i] >= 0))) { - if(errors_scrambling[round][snrRun] == 0) { + if (errors_scrambling[round] == 0) { LOG_D(PHY,"First bit in error in unscrambling = %d\n",i); } - errors_scrambling[round][snrRun]++; + errors_scrambling[round]++; } } @@ -1324,51 +1328,34 @@ int main(int argc, char **argv) if (n_trials == 1) printf("errors_bit = %u (trial %d)\n", errors_bit, trial); } - roundStats[snrRun]+=((float)round); + roundStats += ((float)round); if (UE_harq_process->ack==1) effRate += ((float)TBS)/round; } // noise trials - roundStats[snrRun]/=((float)n_trials); + roundStats /= ((float)n_trials); - blerStats[0][snrRun] = (double)n_errors[0][snrRun]/round_trials[0][snrRun]; - blerStats[1][snrRun] = (double)n_errors[1][snrRun]/round_trials[1][snrRun]; - blerStats[2][snrRun] = (double)n_errors[2][snrRun]/round_trials[2][snrRun]; - blerStats[3][snrRun] = (double)n_errors[3][snrRun]/round_trials[3][snrRun]; - - berStats[0][snrRun] = (double)errors_scrambling[0][snrRun]/available_bits/round_trials[0][snrRun]; - berStats[1][snrRun] = (double)errors_scrambling[1][snrRun]/available_bits/round_trials[1][snrRun]; - berStats[2][snrRun] = (double)errors_scrambling[2][snrRun]/available_bits/round_trials[2][snrRun]; - berStats[3][snrRun] = (double)errors_scrambling[3][snrRun]/available_bits/round_trials[3][snrRun]; + for (int r = 0; r < num_rounds; r++) { + blerStats[r] = (double)n_errors[r] / round_trials[r]; + berStats[r] = (double)errors_scrambling[r] / available_bits / round_trials[r]; + } effRate /= n_trials; printf("*****************************************\n"); - printf("SNR %f: n_errors (%d/%d,%d/%d,%d/%d,%d/%d) (negative CRC), false_positive %d/%d, errors_scrambling (%u/%u,%u/%u,%u/%u,%u/%u\n", - SNR, - n_errors[0][snrRun], round_trials[0][snrRun], - n_errors[1][snrRun], round_trials[1][snrRun], - n_errors[2][snrRun], round_trials[2][snrRun], - n_errors[3][snrRun], round_trials[3][snrRun], - n_false_positive, n_trials, - errors_scrambling[0][snrRun], available_bits*round_trials[0][snrRun], - errors_scrambling[1][snrRun], available_bits*round_trials[1][snrRun], - errors_scrambling[2][snrRun], available_bits*round_trials[2][snrRun], - errors_scrambling[3][snrRun], available_bits*round_trials[3][snrRun]); - printf("\n"); + printf("SNR %f: n_errors (%d/%d", SNR, n_errors[0], round_trials[0]); + for (int r = 1; r < num_rounds; r++) + printf(",%d/%d", n_errors[r], round_trials[r]); + printf(") (negative CRC), false_positive %d/%d, errors_scrambling (%u/%u", n_false_positive, n_trials, errors_scrambling[0], available_bits * round_trials[0]); + for (int r = 1; r < num_rounds; r++) + printf(",%u/%u", errors_scrambling[r], available_bits * round_trials[r]); + printf(")\n\n"); dump_pdsch_stats(stdout,gNB); - printf("SNR %f: Channel BLER (%e,%e,%e,%e), Channel BER (%e,%e,%e,%e) Avg round %.2f, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %u bits/slot\n", - SNR, - blerStats[0][snrRun], - blerStats[1][snrRun], - blerStats[2][snrRun], - blerStats[3][snrRun], - berStats[0][snrRun], - berStats[1][snrRun], - berStats[2][snrRun], - berStats[3][snrRun], - roundStats[snrRun], - effRate, - effRate/TBS*100, - TBS); + printf("SNR %f: Channel BLER (%e", SNR, blerStats[0]); + for (int r = 1; r < num_rounds; r++) + printf(",%e", blerStats[r]); + printf("), Channel BER (%e", berStats[0]); + for (int r = 1; r < num_rounds; r++) + printf(",%e", berStats[r]); + printf(") Avg round %.2f, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %u bits/slot\n", roundStats, effRate, effRate / TBS * 100, TBS); printf("*****************************************\n"); printf("\n"); @@ -1442,24 +1429,9 @@ int main(int argc, char **argv) break; } - snrStats[snrRun] = SNR; - snrRun++; - n_errs = n_errors[0][snrRun]; + n_errs = n_errors[0]; } // NSR - LOG_M("dlsimStats.m","SNR",snrStats,snrRun,1,7); - LOG_MM("dlsimStats.m","BLER",blerStats,snrRun,1,7); - LOG_MM("dlsimStats.m","BER",berStats,snrRun,1,7); - LOG_MM("dlsimStats.m","rounds",roundStats,snrRun,1,7); - /*if (n_trials>1) { - printf("HARQ stats:\nSNR\tRounds\n"); - psnr = snr0; - for (uint8_t i=0; irx_offset=0; uint8_t ssb_index = 0; @@ -776,7 +774,7 @@ int main(int argc, char **argv) 0, ssb_index%8, SISO, - &phy_pdcch_config, + &phy_data, &result); if (ret==0) { diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 54c0d42db1..52b17fa92b 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -313,11 +313,10 @@ int main(int argc, char **argv) cpuf = get_cpu_freq_GHz(); int msg3_flag = 0; int rv_index = 0; - float roundStats[100]; - double effRate[100]; - double effTP[100]; + float roundStats; + double effRate; + double effTP; float eff_tp_check = 100; - uint8_t snrRun; int ldpc_offload_flag = 0; uint8_t max_rounds = 4; int chest_type[2] = {0}; @@ -498,6 +497,7 @@ int main(int argc, char **argv) case 'v': max_rounds = atoi(optarg); + AssertFatal(max_rounds > 0 && max_rounds < 16, "Unsupported number of rounds %d, should be in [1,16]\n", max_rounds); break; case 'w': @@ -1004,7 +1004,6 @@ int main(int argc, char **argv) } //for (int i=0;i<16;i++) printf("%f\n",gaussdouble(0.0,1.0)); - snrRun = 0; int read_errors=0; int slot_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0); @@ -1057,25 +1056,14 @@ int main(int argc, char **argv) } int ret = 1; - uint32_t errors_scrambling[4][100]; - int n_errors[4][100]; - int round_trials[4][100]; - double blerStats[4][100]; - double berStats[4][100]; - double snrStats[100]; - memset(errors_scrambling, 0, sizeof(uint32_t)*4*100); - memset(n_errors, 0, sizeof(int)*4*100); - memset(round_trials, 0, sizeof(int)*4*100); - memset(blerStats, 0, sizeof(double)*4*100); - memset(berStats, 0, sizeof(double)*4*100); - memset(snrStats, 0, sizeof(double) * 100); - for (SNR = snr0; SNR <= snr1; SNR += snr_step) { + varArray_t *table_rx=initVarArray(1000,sizeof(double)); int error_flag = 0; n_false_positive = 0; - effRate[snrRun] = 0; - effTP[snrRun] = 0; + effRate = 0; + effTP = 0; + roundStats = 0; reset_meas(&gNB->phy_proc_rx); reset_meas(&gNB->rx_pusch_stats); reset_meas(&gNB->ulsch_decoding_stats); @@ -1092,254 +1080,240 @@ int main(int argc, char **argv) reset_meas(&UE->ulsch_interleaving_stats); reset_meas(&UE->ulsch_encoding_stats); + uint32_t errors_scrambling[16] = {0}; + int n_errors[16] = {0}; + int round_trials[16] = {0}; + double blerStats[16] = {0}; + double berStats[16] = {0}; + clear_pusch_stats(gNB); for (trial = 0; trial < n_trials; trial++) { - uint8_t round = 0; + uint8_t round = 0; + crc_status = 1; + errors_decoding = 0; + while (round < max_rounds && crc_status) { + round_trials[round]++; + ulsch_ue->harq_processes[harq_pid]->round = round; + rv_index = nr_rv_round_map[round % 4]; - crc_status = 1; - errors_decoding = 0; - memset((void*)roundStats,0,50*sizeof(roundStats[0])); - while (roundharq_processes[harq_pid]->round = round; - gNB->ulsch[0]->harq_processes[harq_pid]->round = round; - rv_index = nr_rv_round_map[round]; + UE_proc.nr_slot_tx = slot; + UE_proc.frame_tx = frame; - UE_proc.nr_slot_tx = slot; - UE_proc.frame_tx = frame; + UL_tti_req->SFN = frame; + UL_tti_req->Slot = slot; + UL_tti_req->n_pdus = 1; + UL_tti_req->pdus_list[0].pdu_type = NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE; + UL_tti_req->pdus_list[0].pdu_size = sizeof(nfapi_nr_pusch_pdu_t); + memset(pusch_pdu, 0, sizeof(nfapi_nr_pusch_pdu_t)); - UL_tti_req->SFN = frame; - UL_tti_req->Slot = slot; - UL_tti_req->n_pdus = 1; - UL_tti_req->pdus_list[0].pdu_type = NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE; - UL_tti_req->pdus_list[0].pdu_size = sizeof(nfapi_nr_pusch_pdu_t); - memset(pusch_pdu,0,sizeof(nfapi_nr_pusch_pdu_t)); - - int abwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,275); - int abwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth,275); - int ibwp_size = ibwps; - int ibwp_start = ibwp_rboffset; - if (msg3_flag == 1) { - if ((ibwp_start < abwp_start) || (ibwp_size > abwp_size)) - pusch_pdu->bwp_start = abwp_start; - else - pusch_pdu->bwp_start = ibwp_start; - pusch_pdu->bwp_size = ibwp_size; - start_rb = (ibwp_start - abwp_start); - printf("msg3: ibwp_size %d, abwp_size %d, ibwp_start %d, abwp_start %d\n", - ibwp_size,abwp_size,ibwp_start,abwp_start); - } - else { - pusch_pdu->bwp_start = abwp_start; - pusch_pdu->bwp_size = abwp_size; - } + int abwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, 275); + int abwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, 275); + int ibwp_size = ibwps; + int ibwp_start = ibwp_rboffset; + if (msg3_flag == 1) { + if ((ibwp_start < abwp_start) || (ibwp_size > abwp_size)) + pusch_pdu->bwp_start = abwp_start; + else + pusch_pdu->bwp_start = ibwp_start; + pusch_pdu->bwp_size = ibwp_size; + start_rb = (ibwp_start - abwp_start); + printf("msg3: ibwp_size %d, abwp_size %d, ibwp_start %d, abwp_start %d\n", ibwp_size, abwp_size, ibwp_start, abwp_start); + } else { + pusch_pdu->bwp_start = abwp_start; + pusch_pdu->bwp_size = abwp_size; + } - pusch_pdu->pusch_data.tb_size = TBS>>3; - pusch_pdu->pdu_bit_map = pdu_bit_map; - pusch_pdu->rnti = n_rnti; - pusch_pdu->mcs_index = Imcs; - pusch_pdu->mcs_table = mcs_table; - pusch_pdu->target_code_rate = code_rate; - pusch_pdu->qam_mod_order = mod_order; - pusch_pdu->transform_precoding = transform_precoding; - pusch_pdu->data_scrambling_id = *scc->physCellId; - pusch_pdu->nrOfLayers = precod_nbr_layers; - pusch_pdu->ul_dmrs_symb_pos = l_prime_mask; - pusch_pdu->dmrs_config_type = dmrs_config_type; - pusch_pdu->ul_dmrs_scrambling_id = *scc->physCellId; - pusch_pdu->scid = 0; - pusch_pdu->dmrs_ports = ((1<num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; - pusch_pdu->resource_alloc = 1; - pusch_pdu->rb_start = start_rb; - pusch_pdu->rb_size = nb_rb; - pusch_pdu->vrb_to_prb_mapping = 0; - pusch_pdu->frequency_hopping = 0; - pusch_pdu->uplink_frequency_shift_7p5khz = 0; - pusch_pdu->start_symbol_index = start_symbol; - pusch_pdu->nr_of_symbols = nb_symb_sch; - pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = tbslbrm; - pusch_pdu->pusch_data.rv_index = rv_index; - pusch_pdu->pusch_data.harq_process_id = 0; - pusch_pdu->pusch_data.new_data_indicator = trial & 0x1; - pusch_pdu->pusch_data.num_cb = 0; - pusch_pdu->pusch_ptrs.ptrs_time_density = ptrs_time_density; - pusch_pdu->pusch_ptrs.ptrs_freq_density = ptrs_freq_density; - pusch_pdu->pusch_ptrs.ptrs_ports_list = (nfapi_nr_ptrs_ports_t *) malloc(2*sizeof(nfapi_nr_ptrs_ports_t)); - pusch_pdu->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0; - pusch_pdu->maintenance_parms_v3.ldpcBaseGraph = get_BG(TBS, code_rate); + pusch_pdu->pusch_data.tb_size = TBS >> 3; + pusch_pdu->pdu_bit_map = pdu_bit_map; + pusch_pdu->rnti = n_rnti; + pusch_pdu->mcs_index = Imcs; + pusch_pdu->mcs_table = mcs_table; + pusch_pdu->target_code_rate = code_rate; + pusch_pdu->qam_mod_order = mod_order; + pusch_pdu->transform_precoding = transform_precoding; + pusch_pdu->data_scrambling_id = *scc->physCellId; + pusch_pdu->nrOfLayers = precod_nbr_layers; + pusch_pdu->ul_dmrs_symb_pos = l_prime_mask; + pusch_pdu->dmrs_config_type = dmrs_config_type; + pusch_pdu->ul_dmrs_scrambling_id = *scc->physCellId; + pusch_pdu->scid = 0; + pusch_pdu->dmrs_ports = ((1 << precod_nbr_layers) - 1); + pusch_pdu->num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; + pusch_pdu->resource_alloc = 1; + pusch_pdu->rb_start = start_rb; + pusch_pdu->rb_size = nb_rb; + pusch_pdu->vrb_to_prb_mapping = 0; + pusch_pdu->frequency_hopping = 0; + pusch_pdu->uplink_frequency_shift_7p5khz = 0; + pusch_pdu->start_symbol_index = start_symbol; + pusch_pdu->nr_of_symbols = nb_symb_sch; + pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = tbslbrm; + pusch_pdu->pusch_data.rv_index = rv_index; + pusch_pdu->pusch_data.harq_process_id = 0; + pusch_pdu->pusch_data.new_data_indicator = round == 0 ? 1 : 0; + pusch_pdu->pusch_data.num_cb = 0; + pusch_pdu->pusch_ptrs.ptrs_time_density = ptrs_time_density; + pusch_pdu->pusch_ptrs.ptrs_freq_density = ptrs_freq_density; + pusch_pdu->pusch_ptrs.ptrs_ports_list = (nfapi_nr_ptrs_ports_t *)malloc(2 * sizeof(nfapi_nr_ptrs_ports_t)); + pusch_pdu->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0; + pusch_pdu->maintenance_parms_v3.ldpcBaseGraph = get_BG(TBS, code_rate); - // if transform precoding is enabled - if (transform_precoding == transformPrecoder_enabled) { + // if transform precoding is enabled + if (transform_precoding == transformPrecoder_enabled) { + pusch_pdu->dfts_ofdm.low_papr_group_number = *scc->physCellId % 30; // U as defined in 38.211 section 6.4.1.1.1.2 + pusch_pdu->dfts_ofdm.low_papr_sequence_number = 0; // V as defined in 38.211 section 6.4.1.1.1.2 + pusch_pdu->num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; + } - pusch_pdu->dfts_ofdm.low_papr_group_number = *scc->physCellId % 30; // U as defined in 38.211 section 6.4.1.1.1.2 - pusch_pdu->dfts_ofdm.low_papr_sequence_number = 0; // V as defined in 38.211 section 6.4.1.1.1.2 - pusch_pdu->num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; - } + // prepare ULSCH/PUSCH reception + pushNotifiedFIFO(&gNB->L1_tx_free, msgL1Tx); // to unblock the process in the beginning + nr_schedule_response(Sched_INFO); - // prepare ULSCH/PUSCH reception - pushNotifiedFIFO(&gNB->L1_tx_free, msgL1Tx); // to unblock the process in the beginning - nr_schedule_response(Sched_INFO); + // --------- setting parameters for UE -------- - // --------- setting parameters for UE -------- + scheduled_response.module_id = 0; + scheduled_response.CC_id = 0; + scheduled_response.frame = frame; + scheduled_response.slot = slot; + scheduled_response.dl_config = NULL; + scheduled_response.ul_config = &ul_config; + scheduled_response.tx_request = &tx_req; - scheduled_response.module_id = 0; - scheduled_response.CC_id = 0; - scheduled_response.frame = frame; - scheduled_response.slot = slot; - scheduled_response.dl_config = NULL; - scheduled_response.ul_config = &ul_config; - scheduled_response.tx_request = &tx_req; - - // Config UL TX PDU - tx_req.slot = slot; - tx_req.sfn = frame; - // tx_req->tx_config // TbD - tx_req.number_of_pdus = 1; - tx_req.tx_request_body[0].pdu_length = TBS/8; - tx_req.tx_request_body[0].pdu_index = 0; - tx_req.tx_request_body[0].pdu = &ulsch_input_buffer[0]; + // Config UL TX PDU + tx_req.slot = slot; + tx_req.sfn = frame; + // tx_req->tx_config // TbD + tx_req.number_of_pdus = 1; + tx_req.tx_request_body[0].pdu_length = TBS / 8; + tx_req.tx_request_body[0].pdu_index = 0; + tx_req.tx_request_body[0].pdu = &ulsch_input_buffer[0]; - ul_config.slot = slot; - ul_config.number_pdus = 1; - ul_config.ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; - ul_config.ul_config_list[0].pusch_config_pdu.rnti = n_rnti; - ul_config.ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map; - ul_config.ul_config_list[0].pusch_config_pdu.qam_mod_order = mod_order; - ul_config.ul_config_list[0].pusch_config_pdu.rb_size = nb_rb; - ul_config.ul_config_list[0].pusch_config_pdu.rb_start = start_rb; - ul_config.ul_config_list[0].pusch_config_pdu.nr_of_symbols = nb_symb_sch; - ul_config.ul_config_list[0].pusch_config_pdu.start_symbol_index = start_symbol; - ul_config.ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = l_prime_mask; - ul_config.ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type; - ul_config.ul_config_list[0].pusch_config_pdu.mcs_index = Imcs; - ul_config.ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table; - ul_config.ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; - ul_config.ul_config_list[0].pusch_config_pdu.nrOfLayers = precod_nbr_layers; - ul_config.ul_config_list[0].pusch_config_pdu.dmrs_ports = ((1<physCellId % 30;// U as defined in 38.211 section 6.4.1.1.1.2 - ul_config.ul_config_list[0].pusch_config_pdu.dfts_ofdm.low_papr_sequence_number = 0;// V as defined in 38.211 section 6.4.1.1.1.2 - //ul_config.ul_config_list[0].pusch_config_pdu.pdu_bit_map |= PUSCH_PDU_BITMAP_DFTS_OFDM; + ul_config.slot = slot; + ul_config.number_pdus = 1; + ul_config.ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; + ul_config.ul_config_list[0].pusch_config_pdu.rnti = n_rnti; + ul_config.ul_config_list[0].pusch_config_pdu.pdu_bit_map = pdu_bit_map; + ul_config.ul_config_list[0].pusch_config_pdu.qam_mod_order = mod_order; + ul_config.ul_config_list[0].pusch_config_pdu.rb_size = nb_rb; + ul_config.ul_config_list[0].pusch_config_pdu.rb_start = start_rb; + ul_config.ul_config_list[0].pusch_config_pdu.nr_of_symbols = nb_symb_sch; + ul_config.ul_config_list[0].pusch_config_pdu.start_symbol_index = start_symbol; + ul_config.ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = l_prime_mask; + ul_config.ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type; + ul_config.ul_config_list[0].pusch_config_pdu.mcs_index = Imcs; + ul_config.ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table; ul_config.ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; + ul_config.ul_config_list[0].pusch_config_pdu.nrOfLayers = precod_nbr_layers; + ul_config.ul_config_list[0].pusch_config_pdu.dmrs_ports = ((1 << precod_nbr_layers) - 1); + ul_config.ul_config_list[0].pusch_config_pdu.absolute_delta_PUSCH = 0; + ul_config.ul_config_list[0].pusch_config_pdu.target_code_rate = code_rate; + ul_config.ul_config_list[0].pusch_config_pdu.tbslbrm = tbslbrm; - } + ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.tb_size = TBS / 8; + ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = trial & 0x1; + ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = rv_index; + ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.harq_process_id = harq_pid; + ul_config.ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_time_density = ptrs_time_density; + ul_config.ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_freq_density = ptrs_freq_density; + ul_config.ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list = (nfapi_nr_ue_ptrs_ports_t *)malloc(2 * sizeof(nfapi_nr_ue_ptrs_ports_t)); + ul_config.ul_config_list[0].pusch_config_pdu.pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0; - //nr_fill_ulsch(gNB,frame,slot,pusch_pdu); // Not needed as its its already filled as apart of "nr_schedule_response(Sched_INFO);" + ul_config.ul_config_list[0].pusch_config_pdu.transform_precoding = transform_precoding; - for (int i=0;i<(TBS/8);i++) ulsch_ue->harq_processes[harq_pid]->a[i]=i&0xff; - if (input_fd == NULL) { + // if transform precoding is enabled + if (transform_precoding == transformPrecoder_enabled) { + ul_config.ul_config_list[0].pusch_config_pdu.dfts_ofdm.low_papr_group_number = *scc->physCellId % 30; // U as defined in 38.211 section 6.4.1.1.1.2 + ul_config.ul_config_list[0].pusch_config_pdu.dfts_ofdm.low_papr_sequence_number = 0; // V as defined in 38.211 section 6.4.1.1.1.2 + // ul_config.ul_config_list[0].pusch_config_pdu.pdu_bit_map |= PUSCH_PDU_BITMAP_DFTS_OFDM; + ul_config.ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; + } - // set FAPI parameters for UE, put them in the scheduled response and call - nr_ue_scheduled_response(&scheduled_response); + // nr_fill_ulsch(gNB,frame,slot,pusch_pdu); // Not needed as its its already filled as apart of "nr_schedule_response(Sched_INFO);" + for (int i = 0; i < (TBS / 8); i++) + ulsch_ue->harq_processes[harq_pid]->a[i] = i & 0xff; + if (input_fd == NULL) { + // set FAPI parameters for UE, put them in the scheduled response and call + nr_ue_scheduled_response(&scheduled_response); - /////////////////////////phy_procedures_nr_ue_TX/////////////////////// - /////////// + /////////////////////////phy_procedures_nr_ue_TX/////////////////////// + /////////// - phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id); + phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id); - /* We need to call common sending function to send signal */ - LOG_D(PHY, "Sending Uplink data \n"); - nr_ue_pusch_common_procedures(UE, - slot, - &UE->frame_parms, - UE->frame_parms.nb_antennas_tx); + /* We need to call common sending function to send signal */ + LOG_D(PHY, "Sending Uplink data \n"); + nr_ue_pusch_common_procedures(UE, slot, &UE->frame_parms, UE->frame_parms.nb_antennas_tx); - - if (n_trials==1) { - LOG_M("txsig0.m","txs0", &UE->common_vars.txdata[0][slot_offset],slot_length,1,1); - LOG_M("txsig0F.m","txs0F", UE->common_vars.txdataF[0],frame_parms->ofdm_symbol_size*14,1,1); - if (precod_nbr_layers > 1) { - LOG_M("txsig1.m","txs1", &UE->common_vars.txdata[1][slot_offset],slot_length,1,1); - LOG_M("txsig1F.m","txs1F", UE->common_vars.txdataF[1],frame_parms->ofdm_symbol_size*14,1,1); - if (precod_nbr_layers==4) { - LOG_M("txsig2.m","txs2", &UE->common_vars.txdata[2][slot_offset],slot_length,1,1); - LOG_M("txsig3.m","txs3", &UE->common_vars.txdata[3][slot_offset],slot_length,1,1); - LOG_M("txsig2F.m","txs2F", UE->common_vars.txdataF[2],frame_parms->ofdm_symbol_size*14,1,1); - LOG_M("txsig3F.m","txs3F", UE->common_vars.txdataF[3],frame_parms->ofdm_symbol_size*14,1,1); + if (n_trials == 1) { + LOG_M("txsig0.m", "txs0", &UE->common_vars.txdata[0][slot_offset], slot_length, 1, 1); + LOG_M("txsig0F.m", "txs0F", UE->common_vars.txdataF[0], frame_parms->ofdm_symbol_size * 14, 1, 1); + if (precod_nbr_layers > 1) { + LOG_M("txsig1.m", "txs1", &UE->common_vars.txdata[1][slot_offset], slot_length, 1, 1); + LOG_M("txsig1F.m", "txs1F", UE->common_vars.txdataF[1], frame_parms->ofdm_symbol_size * 14, 1, 1); + if (precod_nbr_layers == 4) { + LOG_M("txsig2.m", "txs2", &UE->common_vars.txdata[2][slot_offset], slot_length, 1, 1); + LOG_M("txsig3.m", "txs3", &UE->common_vars.txdata[3][slot_offset], slot_length, 1, 1); + LOG_M("txsig2F.m", "txs2F", UE->common_vars.txdataF[2], frame_parms->ofdm_symbol_size * 14, 1, 1); + LOG_M("txsig3F.m", "txs3F", UE->common_vars.txdataF[3], frame_parms->ofdm_symbol_size * 14, 1, 1); + } } } - } - /////////// - //////////////////////////////////////////////////// - tx_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0); - txlev_sum = 0; - for (int aa=0; aaframe_parms.nb_antennas_tx; aa++) { - atxlev[aa] = signal_energy(&UE->common_vars.txdata[aa][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], - frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); + /////////// + //////////////////////////////////////////////////// + tx_offset = frame_parms->get_samples_slot_timestamp(slot, frame_parms, 0); + txlev_sum = 0; + for (int aa = 0; aa < UE->frame_parms.nb_antennas_tx; aa++) { + atxlev[aa] = signal_energy(&UE->common_vars.txdata[aa][tx_offset + 5 * frame_parms->ofdm_symbol_size + 4 * frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], + frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); - txlev_sum += atxlev[aa]; + txlev_sum += atxlev[aa]; - if (n_trials==1) printf("txlev[%d] = %d (%f dB) txlev_sum %d\n",aa,atxlev[aa],10*log10((double)atxlev[aa]),txlev_sum); - } - } - else - n_trials = 1; - - if (input_fd == NULL) { - // Justification of division by precod_nbr_layers: - // When the channel is the identity matrix, the results in terms of SNR should be almost equal for 2x2 and 4x4. - sigma_dB = 10 * log10((double)txlev_sum/precod_nbr_layers * ((double)frame_parms->ofdm_symbol_size/(12*nb_rb))) - SNR;; - sigma = pow(10,sigma_dB/10); - - - if(n_trials==1) printf("sigma %f (%f dB), txlev_sum %f (factor %f)\n",sigma,sigma_dB,10*log10((double)txlev_sum),(double)(double) - frame_parms->ofdm_symbol_size/(12*nb_rb)); - - for (i=0; iframe_parms.nb_antennas_tx; aa++) { - s_re[aa][i] = ((double)(((short *)&UE->common_vars.txdata[aa][slot_offset]))[(i<<1)]); - s_im[aa][i] = ((double)(((short *)&UE->common_vars.txdata[aa][slot_offset]))[(i<<1)+1]); + if (n_trials == 1) + printf("txlev[%d] = %d (%f dB) txlev_sum %d\n", aa, atxlev[aa], 10 * log10((double)atxlev[aa]), txlev_sum); } + } else + n_trials = 1; + + if (input_fd == NULL) { + // Justification of division by precod_nbr_layers: + // When the channel is the identity matrix, the results in terms of SNR should be almost equal for 2x2 and 4x4. + sigma_dB = 10 * log10((double)txlev_sum / precod_nbr_layers * ((double)frame_parms->ofdm_symbol_size / (12 * nb_rb))) - SNR; + ; + sigma = pow(10, sigma_dB / 10); + + if (n_trials == 1) + printf("sigma %f (%f dB), txlev_sum %f (factor %f)\n", sigma, sigma_dB, 10 * log10((double)txlev_sum), (double)(double)frame_parms->ofdm_symbol_size / (12 * nb_rb)); + + for (i = 0; i < slot_length; i++) { + for (int aa = 0; aa < UE->frame_parms.nb_antennas_tx; aa++) { + s_re[aa][i] = ((double)(((short *)&UE->common_vars.txdata[aa][slot_offset]))[(i << 1)]); + s_im[aa][i] = ((double)(((short *)&UE->common_vars.txdata[aa][slot_offset]))[(i << 1) + 1]); + } + } + + if (UE2gNB->max_Doppler == 0) { + multipath_channel(UE2gNB, s_re, s_im, r_re, r_im, slot_length, 0, (n_trials==1)?1:0); + } else { + multipath_tv_channel(UE2gNB, s_re, s_im, r_re, r_im, 2*slot_length, 0); + } + add_noise(rxdata, (const double **) r_re, (const double **) r_im, sigma, slot_length, slot_offset, ts, delay, pdu_bit_map, frame_parms->nb_antennas_rx); + + } /*End input_fd */ + + if (pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { + set_ptrs_symb_idx(&ptrsSymPos, pusch_pdu->nr_of_symbols, pusch_pdu->start_symbol_index, 1 << ptrs_time_density, pusch_pdu->ul_dmrs_symb_pos); + ptrsSymbPerSlot = get_ptrs_symbols_in_slot(ptrsSymPos, pusch_pdu->start_symbol_index, pusch_pdu->nr_of_symbols); + ptrsRePerSymb = ((pusch_pdu->rb_size + ptrs_freq_density - 1) / ptrs_freq_density); + LOG_D(PHY, "[ULSIM] PTRS Symbols in a slot: %2u, RE per Symbol: %3u, RE in a slot %4d\n", ptrsSymbPerSlot, ptrsRePerSymb, ptrsSymbPerSlot * ptrsRePerSymb); } - if (UE2gNB->max_Doppler == 0) { - multipath_channel(UE2gNB, s_re, s_im, r_re, r_im, slot_length, 0, (n_trials==1)?1:0); - } else { - multipath_tv_channel(UE2gNB, s_re, s_im, r_re, r_im, 2*slot_length, 0); - } - add_noise(rxdata, (const double **) r_re, (const double **) r_im, sigma, slot_length, slot_offset, ts, delay, pdu_bit_map, frame_parms->nb_antennas_rx); - - } /*End input_fd */ - - - if(pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { - set_ptrs_symb_idx(&ptrsSymPos, - pusch_pdu->nr_of_symbols, - pusch_pdu->start_symbol_index, - 1<ul_dmrs_symb_pos); - ptrsSymbPerSlot = get_ptrs_symbols_in_slot(ptrsSymPos, pusch_pdu->start_symbol_index, pusch_pdu->nr_of_symbols); - ptrsRePerSymb = ((pusch_pdu->rb_size + ptrs_freq_density - 1)/ptrs_freq_density); - LOG_D(PHY,"[ULSIM] PTRS Symbols in a slot: %2u, RE per Symbol: %3u, RE in a slot %4d\n", ptrsSymbPerSlot,ptrsRePerSymb, ptrsSymbPerSlot*ptrsRePerSymb ); - } - //////////////////////////////////////////////////////////// - - //---------------------------------------------------------- - //------------------- gNB phy procedures ------------------- - //---------------------------------------------------------- - gNB->UL_INFO.rx_ind.number_of_pdus = 0; - gNB->UL_INFO.crc_ind.number_crcs = 0; + //---------------------------------------------------------- + //------------------- gNB phy procedures ------------------- + //---------------------------------------------------------- + gNB->UL_INFO.rx_ind.number_of_pdus = 0; + gNB->UL_INFO.crc_ind.number_crcs = 0; for(uint8_t symbol = 0; symbol < (gNB->frame_parms.Ncp == EXTENDED ? 12 : 14); symbol++) { for (int aa = 0; aa < gNB->frame_parms.nb_antennas_rx; aa++) @@ -1359,209 +1333,252 @@ int main(int argc, char **argv) gNB->frame_parms.Ncp == EXTENDED ? 12 : 14); } - ul_proc_error = phy_procedures_gNB_uespec_RX(gNB, frame, slot); - - if (n_trials==1 && round==0) { - LOG_M("rxsig0.m","rx0",&rxdata[0][slot_offset],slot_length,1,1); - LOG_M("rxsigF0.m","rxsF0",gNB->common_vars.rxdataF[0],14*frame_parms->ofdm_symbol_size,1,1); - if (precod_nbr_layers > 1) { - LOG_M("rxsig1.m","rx1",&rxdata[1][slot_offset],slot_length,1,1); - LOG_M("rxsigF1.m","rxsF1",gNB->common_vars.rxdataF[1],14*frame_parms->ofdm_symbol_size,1,1); - if (precod_nbr_layers==4) { - LOG_M("rxsig2.m","rx2",&rxdata[2][slot_offset],slot_length,1,1); - LOG_M("rxsig3.m","rx3",&rxdata[3][slot_offset],slot_length,1,1); - LOG_M("rxsigF2.m","rxsF2",gNB->common_vars.rxdataF[2],14*frame_parms->ofdm_symbol_size,1,1); - LOG_M("rxsigF3.m","rxsF3",gNB->common_vars.rxdataF[3],14*frame_parms->ofdm_symbol_size,1,1); - } - } - } - - - if (n_trials == 1 && round==0) { - __attribute__((unused)) - int off = ((nb_rb&1) == 1)? 4:0; - - LOG_M("rxsigF0_ext.m","rxsF0_ext", - &gNB->pusch_vars[0]->rxdataF_ext[0][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("chestF0.m","chF0", - &gNB->pusch_vars[0]->ul_ch_estimates[0][start_symbol*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size,1,1); - LOG_M("chestT0.m","chT0", - &gNB->pusch_vars[0]->ul_ch_estimates_time[0][0],frame_parms->ofdm_symbol_size,1,1); - LOG_M("chestF0_ext.m","chF0_ext", - &gNB->pusch_vars[0]->ul_ch_estimates_ext[0][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], - (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("rxsigF0_comp.m","rxsF0_comp", - &gNB->pusch_vars[0]->rxdataF_comp[0][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("chmagF0.m","chmF0", - &gNB->pusch_vars[0]->ul_ch_mag[0][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("chmagbF0.m","chmbF0", - &gNB->pusch_vars[0]->ul_ch_magb[0][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("rxsigF0_llrlayers0.m","rxsF0_llrlayers0", - &gNB->pusch_vars[0]->llr_layers[0][0],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0); - - if (precod_nbr_layers==2) { - LOG_M("rxsigF1_ext.m","rxsF1_ext", - &gNB->pusch_vars[0]->rxdataF_ext[1][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - - LOG_M("chestF3.m","chF3", - &gNB->pusch_vars[0]->ul_ch_estimates[3][start_symbol*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size,1,1); - - LOG_M("chestF3_ext.m","chF3_ext", - &gNB->pusch_vars[0]->ul_ch_estimates_ext[3][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], - (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - - LOG_M("rxsigF2_comp.m","rxsF2_comp", - &gNB->pusch_vars[0]->rxdataF_comp[2][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - - LOG_M("rxsigF0_llrlayers1.m","rxsF0_llrlayers1", - &gNB->pusch_vars[0]->llr_layers[1][0],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0); + ul_proc_error = phy_procedures_gNB_uespec_RX(gNB, frame, slot); + if (n_trials == 1 && round == 0) { + LOG_M("rxsig0.m", "rx0", &rxdata[0][slot_offset], slot_length, 1, 1); + LOG_M("rxsigF0.m", "rxsF0", gNB->common_vars.rxdataF[0], 14 * frame_parms->ofdm_symbol_size, 1, 1); + if (precod_nbr_layers > 1) { + LOG_M("rxsig1.m", "rx1", &rxdata[1][slot_offset], slot_length, 1, 1); + LOG_M("rxsigF1.m", "rxsF1", gNB->common_vars.rxdataF[1], 14 * frame_parms->ofdm_symbol_size, 1, 1); + if (precod_nbr_layers == 4) { + LOG_M("rxsig2.m", "rx2", &rxdata[2][slot_offset], slot_length, 1, 1); + LOG_M("rxsig3.m", "rx3", &rxdata[3][slot_offset], slot_length, 1, 1); + LOG_M("rxsigF2.m", "rxsF2", gNB->common_vars.rxdataF[2], 14 * frame_parms->ofdm_symbol_size, 1, 1); + LOG_M("rxsigF3.m", "rxsF3", gNB->common_vars.rxdataF[3], 14 * frame_parms->ofdm_symbol_size, 1, 1); + } + } } - if (precod_nbr_layers==4) { - LOG_M("rxsigF1_ext.m","rxsF1_ext", - &gNB->pusch_vars[0]->rxdataF_ext[1][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("rxsigF2_ext.m","rxsF2_ext", - &gNB->pusch_vars[0]->rxdataF_ext[2][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("rxsigF3_ext.m","rxsF3_ext", - &gNB->pusch_vars[0]->rxdataF_ext[3][start_symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + if (n_trials == 1 && round == 0) { + __attribute__((unused)) int off = ((nb_rb & 1) == 1) ? 4 : 0; - LOG_M("chestF5.m","chF5", - &gNB->pusch_vars[0]->ul_ch_estimates[5][start_symbol*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size,1,1); - LOG_M("chestF10.m","chF10", - &gNB->pusch_vars[0]->ul_ch_estimates[10][start_symbol*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size,1,1); - LOG_M("chestF15.m","chF15", - &gNB->pusch_vars[0]->ul_ch_estimates[15][start_symbol*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size,1,1); + LOG_M("rxsigF0_ext.m", + "rxsF0_ext", + &gNB->pusch_vars[0]->rxdataF_ext[0][start_symbol * NR_NB_SC_PER_RB * pusch_pdu->rb_size], + nb_symb_sch * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); + LOG_M("chestF0.m", "chF0", &gNB->pusch_vars[0]->ul_ch_estimates[0][start_symbol * frame_parms->ofdm_symbol_size], frame_parms->ofdm_symbol_size, 1, 1); + LOG_M("chestT0.m", "chT0", &gNB->pusch_vars[0]->ul_ch_estimates_time[0][0], frame_parms->ofdm_symbol_size, 1, 1); + LOG_M("chestF0_ext.m", + "chF0_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[0][(start_symbol + 1) * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (nb_symb_sch - 1) * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); + LOG_M("rxsigF0_comp.m", + "rxsF0_comp", + &gNB->pusch_vars[0]->rxdataF_comp[0][start_symbol * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + nb_symb_sch * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); + LOG_M("chmagF0.m", + "chmF0", + &gNB->pusch_vars[0]->ul_ch_mag[0][start_symbol * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + nb_symb_sch * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); + LOG_M("chmagbF0.m", + "chmbF0", + &gNB->pusch_vars[0]->ul_ch_magb[0][start_symbol * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + nb_symb_sch * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); + LOG_M("rxsigF0_llrlayers0.m", "rxsF0_llrlayers0", &gNB->pusch_vars[0]->llr_layers[0][0], (nb_symb_sch - 1) * NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order, 1, 0); + if (precod_nbr_layers == 2) { + LOG_M("rxsigF1_ext.m", + "rxsF1_ext", + &gNB->pusch_vars[0]->rxdataF_ext[1][start_symbol * NR_NB_SC_PER_RB * pusch_pdu->rb_size], + nb_symb_sch * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); - LOG_M("chestF5_ext.m","chF5_ext", - &gNB->pusch_vars[0]->ul_ch_estimates_ext[5][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], - (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("chestF10_ext.m","chF10_ext", - &gNB->pusch_vars[0]->ul_ch_estimates_ext[10][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], - (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("chestF15_ext.m","chF15_ext", - &gNB->pusch_vars[0]->ul_ch_estimates_ext[15][(start_symbol+1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))], - (nb_symb_sch-1)*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); + LOG_M("chestF3.m", "chF3", &gNB->pusch_vars[0]->ul_ch_estimates[3][start_symbol * frame_parms->ofdm_symbol_size], frame_parms->ofdm_symbol_size, 1, 1); + LOG_M("chestF3_ext.m", + "chF3_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[3][(start_symbol + 1) * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (nb_symb_sch - 1) * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); - LOG_M("rxsigF4_comp.m","rxsF4_comp", - &gNB->pusch_vars[0]->rxdataF_comp[4][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("rxsigF8_comp.m","rxsF8_comp", - &gNB->pusch_vars[0]->rxdataF_comp[8][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("rxsigF12_comp.m","rxsF12_comp", - &gNB->pusch_vars[0]->rxdataF_comp[12][start_symbol*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size))],nb_symb_sch*(off+(NR_NB_SC_PER_RB * pusch_pdu->rb_size)),1,1); - LOG_M("rxsigF0_llrlayers1.m","rxsF0_llrlayers1", - &gNB->pusch_vars[0]->llr_layers[1][0],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0); - LOG_M("rxsigF0_llrlayers2.m","rxsF0_llrlayers2", - &gNB->pusch_vars[0]->llr_layers[2][0],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0); - LOG_M("rxsigF0_llrlayers3.m","rxsF0_llrlayers3", - &gNB->pusch_vars[0]->llr_layers[3][0],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0); + LOG_M("rxsigF2_comp.m", + "rxsF2_comp", + &gNB->pusch_vars[0]->rxdataF_comp[2][start_symbol * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + nb_symb_sch * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); + + LOG_M("rxsigF0_llrlayers1.m", "rxsF0_llrlayers1", &gNB->pusch_vars[0]->llr_layers[1][0], (nb_symb_sch - 1) * NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order, 1, 0); + } + + if (precod_nbr_layers == 4) { + LOG_M("rxsigF1_ext.m", + "rxsF1_ext", + &gNB->pusch_vars[0]->rxdataF_ext[1][start_symbol * NR_NB_SC_PER_RB * pusch_pdu->rb_size], + nb_symb_sch * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); + LOG_M("rxsigF2_ext.m", + "rxsF2_ext", + &gNB->pusch_vars[0]->rxdataF_ext[2][start_symbol * NR_NB_SC_PER_RB * pusch_pdu->rb_size], + nb_symb_sch * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); + LOG_M("rxsigF3_ext.m", + "rxsF3_ext", + &gNB->pusch_vars[0]->rxdataF_ext[3][start_symbol * NR_NB_SC_PER_RB * pusch_pdu->rb_size], + nb_symb_sch * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); + + LOG_M("chestF5.m", "chF5", &gNB->pusch_vars[0]->ul_ch_estimates[5][start_symbol * frame_parms->ofdm_symbol_size], frame_parms->ofdm_symbol_size, 1, 1); + LOG_M("chestF10.m", "chF10", &gNB->pusch_vars[0]->ul_ch_estimates[10][start_symbol * frame_parms->ofdm_symbol_size], frame_parms->ofdm_symbol_size, 1, 1); + LOG_M("chestF15.m", "chF15", &gNB->pusch_vars[0]->ul_ch_estimates[15][start_symbol * frame_parms->ofdm_symbol_size], frame_parms->ofdm_symbol_size, 1, 1); + + LOG_M("chestF5_ext.m", + "chF5_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[5][(start_symbol + 1) * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (nb_symb_sch - 1) * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); + LOG_M("chestF10_ext.m", + "chF10_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[10][(start_symbol + 1) * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (nb_symb_sch - 1) * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); + LOG_M("chestF15_ext.m", + "chF15_ext", + &gNB->pusch_vars[0]->ul_ch_estimates_ext[15][(start_symbol + 1) * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + (nb_symb_sch - 1) * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); + + LOG_M("rxsigF4_comp.m", + "rxsF4_comp", + &gNB->pusch_vars[0]->rxdataF_comp[4][start_symbol * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + nb_symb_sch * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); + LOG_M("rxsigF8_comp.m", + "rxsF8_comp", + &gNB->pusch_vars[0]->rxdataF_comp[8][start_symbol * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + nb_symb_sch * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); + LOG_M("rxsigF12_comp.m", + "rxsF12_comp", + &gNB->pusch_vars[0]->rxdataF_comp[12][start_symbol * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size))], + nb_symb_sch * (off + (NR_NB_SC_PER_RB * pusch_pdu->rb_size)), + 1, + 1); + LOG_M("rxsigF0_llrlayers1.m", "rxsF0_llrlayers1", &gNB->pusch_vars[0]->llr_layers[1][0], (nb_symb_sch - 1) * NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order, 1, 0); + LOG_M("rxsigF0_llrlayers2.m", "rxsF0_llrlayers2", &gNB->pusch_vars[0]->llr_layers[2][0], (nb_symb_sch - 1) * NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order, 1, 0); + LOG_M("rxsigF0_llrlayers3.m", "rxsF0_llrlayers3", &gNB->pusch_vars[0]->llr_layers[3][0], (nb_symb_sch - 1) * NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order, 1, 0); + } + + LOG_M("rxsigF0_llr.m", "rxsF0_llr", &gNB->pusch_vars[0]->llr[0], precod_nbr_layers * (nb_symb_sch - 1) * NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order, 1, 0); + } + + if ((gNB->ulsch[0]->last_iteration_cnt >= gNB->ulsch[0]->max_ldpc_iterations + 1) || ul_proc_error == 1) { + error_flag = 1; + n_errors[round]++; + crc_status = 1; + } else + crc_status = 0; + if (n_trials == 1) + printf("end of round %d rv_index %d\n", round, rv_index); + + //---------------------------------------------------------- + //----------------- count and print errors ----------------- + //---------------------------------------------------------- + + if ((pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) && (SNR == snr0) && (trial == 0) && (round == 0)) { + ptrs_symbols = 0; + for (int i = pusch_pdu->start_symbol_index; i < pusch_pdu->start_symbol_index + pusch_pdu->nr_of_symbols; i++) + ptrs_symbols += ((gNB->pusch_vars[UE_id]->ptrs_symbols) >> i) & 1; + + /* 2*5*(50/2), for RB = 50,K = 2 for 5 OFDM PTRS symbols */ + available_bits -= 2 * ptrs_symbols * ((nb_rb + ptrs_freq_density - 1) / ptrs_freq_density); + printf("[ULSIM][PTRS] Available bits are: %5u, removed PTRS bits are: %5d \n", available_bits, (ptrsSymbPerSlot * ptrsRePerSymb * 2)); + } + + for (i = 0; i < available_bits; i++) { + if (((ulsch_ue->harq_processes[harq_pid]->f[i] == 0) && (gNB->pusch_vars[UE_id]->llr[i] <= 0)) + || ((ulsch_ue->harq_processes[harq_pid]->f[i] == 1) && (gNB->pusch_vars[UE_id]->llr[i] >= 0))) { + /*if(errors_scrambling == 0) + printf("\x1B[34m" "[frame %d][trial %d]\t1st bit in error in unscrambling = %d\n" "\x1B[0m", frame, trial, i);*/ + errors_scrambling[round]++; + } + } + round++; + } // round + + if (n_trials == 1 && errors_scrambling[0] > 0) { + printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in unscrambling = %u\n" "\x1B[0m", frame, trial, errors_scrambling[0]); } - LOG_M("rxsigF0_llr.m","rxsF0_llr", - &gNB->pusch_vars[0]->llr[0],precod_nbr_layers*(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0); - } - //////////////////////////////////////////////////////////// - - if ((gNB->ulsch[0]->last_iteration_cnt >= - gNB->ulsch[0]->max_ldpc_iterations+1) || ul_proc_error == 1) { - error_flag = 1; - n_errors[round][snrRun]++; - crc_status = 1; - } else - crc_status = 0; - if(n_trials==1) printf("end of round %d rv_index %d\n",round, rv_index); - - //---------------------------------------------------------- - //----------------- count and print errors ----------------- - //---------------------------------------------------------- - - if ((pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) && (SNR==snr0) && (trial==0) && (round==0)) { - ptrs_symbols = 0; - for (int i = pusch_pdu->start_symbol_index; i < pusch_pdu->start_symbol_index + pusch_pdu->nr_of_symbols; i++) - ptrs_symbols += ((gNB->pusch_vars[UE_id]->ptrs_symbols) >> i) & 1; - - /* 2*5*(50/2), for RB = 50,K = 2 for 5 OFDM PTRS symbols */ - available_bits -= 2 * ptrs_symbols * ((nb_rb + ptrs_freq_density - 1) /ptrs_freq_density); - printf("[ULSIM][PTRS] Available bits are: %5u, removed PTRS bits are: %5d \n",available_bits, (ptrsSymbPerSlot * ptrsRePerSymb * 2) ); - } - - for (i = 0; i < available_bits; i++) { - - if(((ulsch_ue->harq_processes[harq_pid]->f[i] == 0) && (gNB->pusch_vars[UE_id]->llr[i] <= 0)) || - ((ulsch_ue->harq_processes[harq_pid]->f[i] == 1) && (gNB->pusch_vars[UE_id]->llr[i] >= 0))) { - - /*if(errors_scrambling == 0) - printf("\x1B[34m" "[frame %d][trial %d]\t1st bit in error in unscrambling = %d\n" "\x1B[0m", frame, trial, i);*/ - errors_scrambling[round][snrRun]++; - } - } - round++; - - } // round - - if (n_trials == 1 && errors_scrambling[0][snrRun] > 0) { - printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in unscrambling = %u\n" "\x1B[0m", frame, trial, errors_scrambling[0][snrRun]); - } - - for (i = 0; i < TBS; i++) { + for (i = 0; i < TBS; i++) { - estimated_output_bit[i] = (ulsch_gNB->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7); - test_input_bit[i] = (ulsch_ue->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7); + estimated_output_bit[i] = (ulsch_gNB->harq_processes[harq_pid]->b[i / 8] & (1 << (i & 7))) >> (i & 7); + test_input_bit[i] = (ulsch_ue->harq_processes[harq_pid]->b[i / 8] & (1 << (i & 7))) >> (i & 7); - if (estimated_output_bit[i] != test_input_bit[i]) { - /*if(errors_decoding == 0) - printf("\x1B[34m""[frame %d][trial %d]\t1st bit in error in decoding = %d\n" "\x1B[0m", frame, trial, i);*/ - errors_decoding++; + if (estimated_output_bit[i] != test_input_bit[i]) { + /*if(errors_decoding == 0) + printf("\x1B[34m""[frame %d][trial %d]\t1st bit in error in decoding = %d\n" "\x1B[0m", frame, trial, i);*/ + errors_decoding++; + } } - } - if (n_trials == 1) { - for (int r=0;rharq_processes[harq_pid]->C;r++) - for (int i=0;iharq_processes[harq_pid]->K>>3;i++) { - if ((ulsch_ue->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]) != 0) printf("************"); - /*printf("r %d: in[%d] %x, out[%d] %x (%x)\n",r, - i,ulsch_ue->harq_processes[harq_pid]->c[r][i], - i,ulsch_gNB->harq_processes[harq_pid]->c[r][i], - ulsch_ue->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]);*/ - } - } - if (errors_decoding > 0 && error_flag == 0) { - n_false_positive++; - if (n_trials==1) - printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in decoding = %u\n" "\x1B[0m", frame, trial, errors_decoding); - } - roundStats[snrRun] += ((float)round); - if (!crc_status) effRate[snrRun] += ((double)TBS)/(double)round; + if (n_trials == 1) { + for (int r = 0; r < ulsch_ue->harq_processes[harq_pid]->C; r++) + for (int i = 0; i < ulsch_ue->harq_processes[harq_pid]->K >> 3; i++) { + if ((ulsch_ue->harq_processes[harq_pid]->c[r][i] ^ ulsch_gNB->harq_processes[harq_pid]->c[r][i]) != 0) + printf("************"); + /*printf("r %d: in[%d] %x, out[%d] %x (%x)\n",r, + i,ulsch_ue->harq_processes[harq_pid]->c[r][i], + i,ulsch_gNB->harq_processes[harq_pid]->c[r][i], + ulsch_ue->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]);*/ + } + } + if (errors_decoding > 0 && error_flag == 0) { + n_false_positive++; + if (n_trials==1) + printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in decoding = %u\n" "\x1B[0m", frame, trial, errors_decoding); + } + roundStats += ((float)round); + if (!crc_status) + effRate += ((double)TBS) / (double)round; } // trial loop - - roundStats[snrRun]/=((float)n_trials); - effRate[snrRun] /= (double)n_trials; + + roundStats/=((float)n_trials); + effRate /= (double)n_trials; printf("*****************************************\n"); - printf("SNR %f: n_errors (%d/%d,%d/%d,%d/%d,%d/%d) (negative CRC), false_positive %d/%d, errors_scrambling (%u/%u,%u/%u,%u/%u,%u/%u\n", SNR, n_errors[0][snrRun], round_trials[0][snrRun],n_errors[1][snrRun], round_trials[1][snrRun],n_errors[2][snrRun], round_trials[2][snrRun],n_errors[3][snrRun], round_trials[3][snrRun], n_false_positive, n_trials, errors_scrambling[0][snrRun],available_bits*n_trials,errors_scrambling[1][snrRun],available_bits*n_trials,errors_scrambling[2][snrRun],available_bits*n_trials,errors_scrambling[3][snrRun],available_bits*n_trials); + printf("SNR %f: n_errors (%d/%d", SNR, n_errors[0], round_trials[0]); + for (int r = 1; r < max_rounds; r++) + printf(",%d/%d", n_errors[r], round_trials[r]); + printf(") (negative CRC), false_positive %d/%d, errors_scrambling (%u/%u", + n_false_positive, n_trials, errors_scrambling[0], available_bits * round_trials[0]); + for (int r = 1; r < max_rounds; r++) + printf(",%u/%u", errors_scrambling[r], available_bits * round_trials[r]); + printf(")\n"); printf("\n"); - blerStats[0][snrRun] = (double)n_errors[0][snrRun]/round_trials[0][snrRun]; - blerStats[1][snrRun] = (double)n_errors[1][snrRun]/round_trials[1][snrRun]; - blerStats[2][snrRun] = (double)n_errors[2][snrRun]/round_trials[2][snrRun]; - blerStats[3][snrRun] = (double)n_errors[3][snrRun]/round_trials[3][snrRun]; - berStats[0][snrRun] = (double)errors_scrambling[0][snrRun]/available_bits/round_trials[0][snrRun]; - berStats[1][snrRun] = (double)errors_scrambling[1][snrRun]/available_bits/round_trials[1][snrRun]; - berStats[2][snrRun] = (double)errors_scrambling[2][snrRun]/available_bits/round_trials[2][snrRun]; - berStats[3][snrRun] = (double)errors_scrambling[3][snrRun]/available_bits/round_trials[3][snrRun]; - effTP[snrRun] = effRate[snrRun]/(double)TBS*(double)100; - printf("SNR %f: Channel BLER (%e,%e,%e,%e), Channel BER (%e,%e,%e,%e) Avg round %.2f, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %u bits/slot\n", - SNR, - blerStats[0][snrRun], - blerStats[1][snrRun], - blerStats[2][snrRun], - blerStats[3][snrRun], - berStats[0][snrRun], - berStats[1][snrRun], - berStats[2][snrRun], - berStats[3][snrRun], - roundStats[snrRun],effRate[snrRun],effTP[snrRun],TBS); + for (int r = 0; r < max_rounds; r++) { + blerStats[r] = (double)n_errors[r] / round_trials[r]; + berStats[r] = (double)errors_scrambling[r] / available_bits/round_trials[r]; + } + effTP = effRate/(double)TBS * (double)100; + printf("SNR %f: Channel BLER (%e", SNR, blerStats[0]); + for (int r = 1; r < max_rounds; r++) + printf(",%e", blerStats[r]); + printf(" Channel BER (%e", berStats[0]); + for (int r = 1; r < max_rounds; r++) + printf(",%e", berStats[r]); + printf(") Avg round %.2f, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %u bits/slot\n", roundStats,effRate,effTP,TBS); FILE *fd=fopen("nr_ulsim.log","w"); if (fd == NULL) { @@ -1599,19 +1616,16 @@ int main(int argc, char **argv) if(n_trials==1) break; - if ((float)effTP[snrRun] >= eff_tp_check) { + if ((float)effTP >= eff_tp_check) { printf("*************\n"); printf("PUSCH test OK\n"); printf("*************\n"); ret = 0; break; } - - snrStats[snrRun] = SNR; - snrRun++; } // SNR loop - printf("\n"); + printf("\n"); printf( "Num RB:\t%d\n" "Num symbols:\t%d\n" "MCS:\t%d\n" @@ -1629,20 +1643,6 @@ int main(int argc, char **argv) length_dmrs, num_dmrs_cdm_grps_no_data); - char opStatsFile[50]; - sprintf(opStatsFile, "ulsimStats_z%d.m", n_rx); - LOG_M(opStatsFile,"SNR",snrStats,snrRun,1,7); - LOG_MM(opStatsFile,"BLER_round0",blerStats[0],snrRun,1,7); - LOG_MM(opStatsFile,"BLER_round1",blerStats[1],snrRun,1,7); - LOG_MM(opStatsFile,"BLER_round2",blerStats[2],snrRun,1,7); - LOG_MM(opStatsFile,"BLER_round3",blerStats[3],snrRun,1,7); - LOG_MM(opStatsFile,"BER_round0",berStats[0],snrRun,1,7); - LOG_MM(opStatsFile,"BER_round1",berStats[1],snrRun,1,7); - LOG_MM(opStatsFile,"BER_round2",berStats[2],snrRun,1,7); - LOG_MM(opStatsFile,"BER_round3",berStats[3],snrRun,1,7); - LOG_MM(opStatsFile,"EffRate",effRate,snrRun,1,7); - LOG_MM(opStatsFile,"EffTP",effTP,snrRun,1,7); - free(test_input_bit); free(estimated_output_bit); if (gNB->ldpc_offload_flag) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 6f9011e6ed..3af6089487 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -833,6 +833,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t NULL, ra->Msg3_tda_id, ra->msg3_TPC, + 1, // Not toggling NDI in msg3 retransmissions &ra->UL_BWP); fill_dci_pdu_rel15(scc, @@ -1036,7 +1037,7 @@ void fill_msg3_pusch_pdu(nfapi_nr_pusch_pdu_t *pusch_pdu, //Optional Data only included if indicated in pduBitmap pusch_pdu->pusch_data.rv_index = nr_rv_round_map[round%4]; pusch_pdu->pusch_data.harq_process_id = 0; - pusch_pdu->pusch_data.new_data_indicator = 1; + pusch_pdu->pusch_data.new_data_indicator = (round == 0) ? 1 : 0;; pusch_pdu->pusch_data.num_cb = 0; int num_dmrs_symb = 0; for(int i = start_symbol_index; i < start_symbol_index+nr_of_symbols; i++) @@ -1787,8 +1788,16 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra harq->round = 0; harq->ndi ^= 1; - sched_ctrl->rrc_processing_timer = 1; // No need to wait at this point in time, setting it to 1 just to enter in function nr_mac_update_timers - LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %04x with %d ms\n", frameP, slotP, UE->rnti, 1); + if(!UE->CellGroup) + // In the specific scenario where UE correctly received MSG4 (assuming it decoded RRCsetup with CellGroup) and gNB didn't correctly received an ACK, + // the UE would already have CG but the UE-dedicated gNB structure wouldn't (because RA didn't complete on gNB side). + uper_decode(NULL, + &asn_DEF_NR_CellGroupConfig, //might be added prefix later + (void **)&UE->CellGroup, + (uint8_t *)UE->cg_buf, + (UE->enc_rval.encoded+7)/8, 0, 0); + process_CellGroup(UE->CellGroup, sched_ctrl); + configure_UE_BWP(nr_mac, scc, sched_ctrl, NULL, UE); // Reset uplink failure flags/counters/timers at MAC so gNB will resume again scheduling resources for this UE UE->UE_sched_ctrl.pusch_consecutive_dtx_cnt = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index db4649008c..ccdc8aca59 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -885,6 +885,7 @@ void config_uldci(const NR_SIB1_t *sib1, nr_srs_feedback_t *srs_feedback, int time_domain_assignment, uint8_t tpc, + uint8_t ndi, NR_UE_UL_BWP_t *ul_bwp) { int bwp_id = ul_bwp->bwp_id; @@ -895,7 +896,7 @@ void config_uldci(const NR_SIB1_t *sib1, dci_pdu_rel15->time_domain_assignment.val = time_domain_assignment; dci_pdu_rel15->frequency_hopping_flag.val = pusch_pdu->frequency_hopping; dci_pdu_rel15->mcs = pusch_pdu->mcs_index; - dci_pdu_rel15->ndi = pusch_pdu->pusch_data.new_data_indicator; + dci_pdu_rel15->ndi = ndi; dci_pdu_rel15->rv = pusch_pdu->pusch_data.rv_index; dci_pdu_rel15->harq_pid = pusch_pdu->pusch_data.harq_process_id; dci_pdu_rel15->tpc = tpc; @@ -2245,6 +2246,8 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, else { DL_BWP = &UE->current_DL_BWP; UL_BWP = &UE->current_UL_BWP; + sched_ctrl->next_dl_bwp_id = -1; + sched_ctrl->next_ul_bwp_id = -1; CellGroup = UE->CellGroup; } NR_BWP_Downlink_t *dl_bwp = NULL; @@ -2273,6 +2276,14 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, DL_BWP->bwp_id = 0; UL_BWP->bwp_id = 0; UE->Msg3_dcch_dtch = false; + + // Schedule BWP switching to the first active BWP (previous active BWP before RA with Msg3 carrying DCCH or DTCH message) + if (servingCellConfig->firstActiveDownlinkBWP_Id) { + sched_ctrl->next_dl_bwp_id = *servingCellConfig->firstActiveDownlinkBWP_Id; + } + if (servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id) { + sched_ctrl->next_ul_bwp_id = *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id; + } } else { // (re)configuring BWP @@ -2326,7 +2337,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, } else { DL_BWP->bwp_id = 0; - DL_BWP->bwp_id = 0; + UL_BWP->bwp_id = 0; target_ss = NR_SearchSpace__searchSpaceType_PR_common; DL_BWP->pdsch_Config = NULL; UL_BWP->pusch_Config = NULL; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index d310c461dc..6c95048ce7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -66,8 +66,8 @@ int compute_ph_factor(int mu, int delta_tf = 0; if(deltaMCS != NULL && n_layers == 1) { const int n_re = (NR_NB_SC_PER_RB * n_symbols - n_dmrs) * rb; - const int BPRE = tbs_bits/n_re; //TODO change for PUSCH with CSI - const float f = pow(2, (float) BPRE * 1.25); + const float BPRE = (float) tbs_bits/n_re; //TODO change for PUSCH with CSI + const float f = pow(2, BPRE * 1.25); const float beta = 1.0f; //TODO change for PUSCH with CSI delta_tf = (10 * log10((f - 1) * beta)); } @@ -2171,7 +2171,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) AssertFatal(cur_harq->round < nr_mac->ul_bler.harq_round_max, "Indexing nr_rv_round_map[%d] is out of bounds\n", cur_harq->round%4); pusch_pdu->pusch_data.rv_index = nr_rv_round_map[cur_harq->round%4]; pusch_pdu->pusch_data.harq_process_id = harq_id; - pusch_pdu->pusch_data.new_data_indicator = cur_harq->ndi; + pusch_pdu->pusch_data.new_data_indicator = (cur_harq->round == 0) ? 1 : 0; // not NDI but indicator for new transmission pusch_pdu->pusch_data.tb_size = sched_pusch->tb_size; pusch_pdu->pusch_data.num_cb = 0; //CBG not supported @@ -2275,6 +2275,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) &sched_ctrl->srs_feedback, sched_pusch->time_domain_allocation, UE->UE_sched_ctrl.tpc0, + cur_harq->ndi, current_BWP); fill_dci_pdu_rel15(scc, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index a322c4917b..64f9882294 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -192,6 +192,7 @@ void config_uldci(const NR_SIB1_t *sib1, nr_srs_feedback_t *srs_feedback, int time_domain_assignment, uint8_t tpc, + uint8_t ndi, NR_UE_UL_BWP_t *ul_bwp); void nr_schedule_pucch(gNB_MAC_INST *nrmac, diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index e548717459..1559f55a43 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -1131,21 +1131,19 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon = mac->scc != NULL ? mac->scc->tdd_UL_DL_ConfigurationCommon : mac->scc_SIB->tdd_UL_DL_ConfigurationCommon; + LOG_T(NR_MAC, "In %s():%d not calling scheduler. sched mode = %d and mac->ra.ra_state = %d\n", + __FUNCTION__, __LINE__, ul_info->ue_sched_mode, mac->ra.ra_state); switch (ul_info->ue_sched_mode) { case SCHED_PUSCH: ret = nr_ue_scheduler(NULL, ul_info); if (is_nr_UL_slot(tdd_UL_DL_ConfigurationCommon, ul_info->slot_tx, mac->frame_type) && !get_softmodem_params()->phy_test) nr_ue_prach_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx); - LOG_T(NR_MAC, "In %s():%d not calling scheduler. sched mode = %d and mac->ra.ra_state = %d\n", - __FUNCTION__, __LINE__, ul_info->ue_sched_mode, mac->ra.ra_state); break; case SCHED_PUCCH: if (is_nr_UL_slot(tdd_UL_DL_ConfigurationCommon, ul_info->slot_tx, mac->frame_type)) nr_ue_pucch_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx, ul_info->phy_data); - LOG_T(NR_MAC, "In %s():%d not calling scheduler. sched mode = %d and mac->ra.ra_state = %d\n", - __FUNCTION__, __LINE__, ul_info->ue_sched_mode, mac->ra.ra_state); break; } @@ -1241,7 +1239,6 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.ack_nack, (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu, (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu_length)) << FAPI_NR_RX_PDU_TYPE_SIB; - free((dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu); break; case FAPI_NR_RX_PDU_TYPE_DLSCH: ret_mask |= (handle_dlsch(dl_info, ul_time_alignment, i)) << FAPI_NR_RX_PDU_TYPE_DLSCH; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 9b782cc9bb..1c2f38069d 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -716,218 +716,6 @@ uint8_t do_SIB23_NR(rrc_gNB_carrier_data_t *carrier, return((enc_rval.encoded+7)/8); } -void do_RLC_BEARER(uint8_t Mod_id, - int CC_id, - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_BearerToAddModList, - rlc_bearer_config_t *rlc_config) { - struct NR_RLC_BearerConfig *rlc_bearer; - rlc_bearer = CALLOC(1,sizeof(struct NR_RLC_BearerConfig)); - rlc_bearer->logicalChannelIdentity = rlc_config->LogicalChannelIdentity[CC_id]; - rlc_bearer->servedRadioBearer = CALLOC(1,sizeof(struct NR_RLC_BearerConfig__servedRadioBearer)); - rlc_bearer->servedRadioBearer->present = rlc_config->servedRadioBearer_present[CC_id]; - - if(rlc_bearer->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity) { - rlc_bearer->servedRadioBearer->choice.srb_Identity = rlc_config->srb_Identity[CC_id]; - } else if(rlc_bearer->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity) { - rlc_bearer->servedRadioBearer->choice.drb_Identity = rlc_config->drb_Identity[CC_id]; - } - - rlc_bearer->reestablishRLC = CALLOC(1,sizeof(long)); - *(rlc_bearer->reestablishRLC) = rlc_config->reestablishRLC[CC_id]; - rlc_bearer->rlc_Config = CALLOC(1,sizeof(struct NR_RLC_Config)); - rlc_bearer->rlc_Config->present = rlc_config->rlc_Config_present[CC_id]; - - if(rlc_bearer->rlc_Config->present == NR_RLC_Config_PR_am) { - rlc_bearer->rlc_Config->choice.am = CALLOC(1,sizeof(struct NR_RLC_Config__am)); - rlc_bearer->rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = CALLOC(1,sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_bearer->rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength) = rlc_config->ul_AM_sn_FieldLength[CC_id]; - rlc_bearer->rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = rlc_config->t_PollRetransmit[CC_id]; - rlc_bearer->rlc_Config->choice.am->ul_AM_RLC.pollPDU = rlc_config->pollPDU[CC_id]; - rlc_bearer->rlc_Config->choice.am->ul_AM_RLC.pollByte = rlc_config->pollByte[CC_id]; - rlc_bearer->rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = rlc_config->maxRetxThreshold[CC_id]; - rlc_bearer->rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = CALLOC(1,sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_bearer->rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength) = rlc_config->dl_AM_sn_FieldLength[CC_id]; - rlc_bearer->rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = rlc_config->dl_AM_t_Reassembly[CC_id]; - rlc_bearer->rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = rlc_config->t_StatusProhibit[CC_id]; - } else if(rlc_bearer->rlc_Config->present == NR_RLC_Config_PR_um_Bi_Directional) { - rlc_bearer->rlc_Config->choice.um_Bi_Directional = CALLOC(1,sizeof(struct NR_RLC_Config__um_Bi_Directional)); - rlc_bearer->rlc_Config->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength = CALLOC(1,sizeof(NR_SN_FieldLengthUM_t)); - *(rlc_bearer->rlc_Config->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength) = rlc_config->ul_UM_sn_FieldLength[CC_id]; - rlc_bearer->rlc_Config->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength = CALLOC(1,sizeof(NR_SN_FieldLengthUM_t)); - *(rlc_bearer->rlc_Config->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength) = rlc_config->dl_UM_sn_FieldLength[CC_id]; - rlc_bearer->rlc_Config->choice.um_Bi_Directional->dl_UM_RLC.t_Reassembly = rlc_config->dl_UM_t_Reassembly[CC_id]; - } else if(rlc_bearer->rlc_Config->present == NR_RLC_Config_PR_um_Uni_Directional_UL) { - rlc_bearer->rlc_Config->choice.um_Uni_Directional_UL = CALLOC(1,sizeof(struct NR_RLC_Config__um_Uni_Directional_UL)); - rlc_bearer->rlc_Config->choice.um_Uni_Directional_UL->ul_UM_RLC.sn_FieldLength = CALLOC(1,sizeof(NR_SN_FieldLengthUM_t)); - *(rlc_bearer->rlc_Config->choice.um_Uni_Directional_UL->ul_UM_RLC.sn_FieldLength) = rlc_config->ul_UM_sn_FieldLength[CC_id]; - } else if(rlc_bearer->rlc_Config->present == NR_RLC_Config_PR_um_Uni_Directional_DL) { - rlc_bearer->rlc_Config->choice.um_Uni_Directional_DL = CALLOC(1,sizeof(struct NR_RLC_Config__um_Uni_Directional_DL)); - rlc_bearer->rlc_Config->choice.um_Uni_Directional_DL->dl_UM_RLC.sn_FieldLength = CALLOC(1,sizeof(NR_SN_FieldLengthUM_t)); - *(rlc_bearer->rlc_Config->choice.um_Uni_Directional_DL->dl_UM_RLC.sn_FieldLength) = rlc_config->dl_UM_sn_FieldLength[CC_id]; - rlc_bearer->rlc_Config->choice.um_Uni_Directional_DL->dl_UM_RLC.t_Reassembly = rlc_config->dl_UM_t_Reassembly[CC_id]; - } - - rlc_bearer->mac_LogicalChannelConfig = CALLOC(1,sizeof(struct NR_LogicalChannelConfig)); - rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters = CALLOC(1,sizeof(struct NR_LogicalChannelConfig__ul_SpecificParameters)); - rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->priority = rlc_config->priority[CC_id]; - rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = rlc_config->prioritisedBitRate[CC_id]; - rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->bucketSizeDuration = rlc_config->bucketSizeDuration[CC_id]; - rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->allowedServingCells = CALLOC(1,sizeof(struct NR_LogicalChannelConfig__ul_SpecificParameters__allowedServingCells)); - rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->allowedSCS_List = CALLOC(1,sizeof(struct NR_LogicalChannelConfig__ul_SpecificParameters__allowedSCS_List)); - NR_ServCellIndex_t *servingcellindex; - servingcellindex = CALLOC(1,sizeof(NR_ServCellIndex_t)); - *servingcellindex = rlc_config->allowedServingCells[CC_id]; - ASN_SEQUENCE_ADD(&(rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->allowedServingCells->list),&servingcellindex); - NR_SubcarrierSpacing_t *subcarrierspacing; - subcarrierspacing = CALLOC(1,sizeof(NR_SubcarrierSpacing_t)); - *subcarrierspacing = rlc_config->subcarrierspacing[CC_id]; - ASN_SEQUENCE_ADD(&(rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->allowedSCS_List->list),&subcarrierspacing); - rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->maxPUSCH_Duration = CALLOC(1,sizeof(long)); - rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->configuredGrantType1Allowed = CALLOC(1,sizeof(long)); - rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = CALLOC(1,sizeof(long)); - rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->schedulingRequestID = CALLOC(1,sizeof(NR_SchedulingRequestId_t)); - *(rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->maxPUSCH_Duration) = rlc_config->maxPUSCH_Duration[CC_id]; - *(rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->configuredGrantType1Allowed) = rlc_config->configuredGrantType1Allowed[CC_id]; - *(rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->logicalChannelGroup) = rlc_config->logicalChannelGroup[CC_id]; - *(rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->schedulingRequestID) = rlc_config->schedulingRequestID[CC_id]; - rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = rlc_config->logicalChannelSR_Mask[CC_id]; - rlc_bearer->mac_LogicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = rlc_config->logicalChannelSR_DelayTimerApplied[CC_id]; - ASN_SEQUENCE_ADD(&(rlc_BearerToAddModList->list),&rlc_bearer); -} - - -void do_MAC_CELLGROUP(uint8_t Mod_id, - int CC_id, - NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, - mac_cellgroup_t *mac_cellgroup_config) { - mac_CellGroupConfig->drx_Config = CALLOC(1,sizeof(struct NR_SetupRelease_DRX_Config)); - mac_CellGroupConfig->schedulingRequestConfig = CALLOC(1,sizeof(struct NR_SchedulingRequestConfig)); - mac_CellGroupConfig->bsr_Config = CALLOC(1,sizeof(struct NR_BSR_Config)); - mac_CellGroupConfig->tag_Config = CALLOC(1,sizeof(struct NR_TAG_Config)); - mac_CellGroupConfig->phr_Config = CALLOC(1,sizeof(struct NR_SetupRelease_PHR_Config)); - mac_CellGroupConfig->drx_Config->present = mac_cellgroup_config->DRX_Config_PR[CC_id]; - mac_CellGroupConfig->drx_Config->choice.setup = CALLOC(1,sizeof(struct NR_DRX_Config)); - mac_CellGroupConfig->drx_Config->choice.setup->drx_onDurationTimer.present = mac_cellgroup_config->drx_onDurationTimer_PR[CC_id]; - - if(mac_CellGroupConfig->drx_Config->choice.setup->drx_onDurationTimer.present == NR_DRX_Config__drx_onDurationTimer_PR_subMilliSeconds) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_onDurationTimer.choice.subMilliSeconds = mac_cellgroup_config->subMilliSeconds[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_onDurationTimer.present == NR_DRX_Config__drx_onDurationTimer_PR_milliSeconds) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_onDurationTimer.choice.milliSeconds = mac_cellgroup_config->milliSeconds[CC_id]; - } - - mac_CellGroupConfig->drx_Config->choice.setup->drx_InactivityTimer = mac_cellgroup_config->drx_InactivityTimer[CC_id]; - mac_CellGroupConfig->drx_Config->choice.setup->drx_HARQ_RTT_TimerDL = mac_cellgroup_config->drx_HARQ_RTT_TimerDL[CC_id]; - mac_CellGroupConfig->drx_Config->choice.setup->drx_HARQ_RTT_TimerUL = mac_cellgroup_config->drx_HARQ_RTT_TimerUL[CC_id]; - mac_CellGroupConfig->drx_Config->choice.setup->drx_RetransmissionTimerDL = mac_cellgroup_config->drx_RetransmissionTimerDL[CC_id]; - mac_CellGroupConfig->drx_Config->choice.setup->drx_RetransmissionTimerUL = mac_cellgroup_config->drx_RetransmissionTimerUL[CC_id]; - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present = mac_cellgroup_config->drx_LongCycleStartOffset_PR[CC_id]; - - if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms10) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms10 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms20) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms20 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms32) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms32 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms40) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms40 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms60) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms60 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms64) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms64 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms70) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms70 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms80) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms80 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms128) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms128 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms160) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms160 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms256) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms256 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms320) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms320 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms512) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms512 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms640) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms640 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms1024) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms1024 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms1280) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms1280 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms2048) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms2048 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms2560) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms2560 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms5120) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms5120 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } else if(mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.present == NR_DRX_Config__drx_LongCycleStartOffset_PR_ms10240) { - mac_CellGroupConfig->drx_Config->choice.setup->drx_LongCycleStartOffset.choice.ms10240 = mac_cellgroup_config->drx_LongCycleStartOffset[CC_id]; - } - - mac_CellGroupConfig->drx_Config->choice.setup->shortDRX = CALLOC(1,sizeof(struct NR_DRX_Config__shortDRX)); - mac_CellGroupConfig->drx_Config->choice.setup->shortDRX->drx_ShortCycle = mac_cellgroup_config->drx_ShortCycle[CC_id]; - mac_CellGroupConfig->drx_Config->choice.setup->shortDRX->drx_ShortCycleTimer = mac_cellgroup_config->drx_ShortCycleTimer[CC_id]; - mac_CellGroupConfig->drx_Config->choice.setup->drx_SlotOffset = mac_cellgroup_config->drx_SlotOffset[CC_id]; - mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = CALLOC(1,sizeof(struct NR_SchedulingRequestConfig__schedulingRequestToAddModList)); - struct NR_SchedulingRequestToAddMod *schedulingrequestlist; - schedulingrequestlist = CALLOC(1,sizeof(struct NR_SchedulingRequestToAddMod)); - schedulingrequestlist->schedulingRequestId = mac_cellgroup_config->schedulingRequestId[CC_id]; - schedulingrequestlist->sr_ProhibitTimer = CALLOC(1,sizeof(long)); - *(schedulingrequestlist->sr_ProhibitTimer) = mac_cellgroup_config->sr_ProhibitTimer[CC_id]; - schedulingrequestlist->sr_TransMax = mac_cellgroup_config->sr_TransMax[CC_id]; - ASN_SEQUENCE_ADD(&(mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list),&schedulingrequestlist); - mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = mac_cellgroup_config->periodicBSR_Timer[CC_id]; - mac_CellGroupConfig->bsr_Config->retxBSR_Timer = mac_cellgroup_config->retxBSR_Timer[CC_id]; - mac_CellGroupConfig->bsr_Config->logicalChannelSR_DelayTimer = CALLOC(1,sizeof(long)); - *(mac_CellGroupConfig->bsr_Config->logicalChannelSR_DelayTimer) = mac_cellgroup_config->logicalChannelSR_DelayTimer[CC_id]; - mac_CellGroupConfig->tag_Config->tag_ToAddModList = CALLOC(1,sizeof(struct NR_TAG_Config__tag_ToAddModList)); - struct NR_TAG *tag; - tag = CALLOC(1,sizeof(struct NR_TAG)); - tag->tag_Id = mac_cellgroup_config->tag_Id[CC_id]; - tag->timeAlignmentTimer = mac_cellgroup_config->timeAlignmentTimer[CC_id]; - ASN_SEQUENCE_ADD(&(mac_CellGroupConfig->tag_Config->tag_ToAddModList->list),&tag); - mac_CellGroupConfig->phr_Config->present = mac_cellgroup_config->PHR_Config_PR[CC_id]; - mac_CellGroupConfig->phr_Config->choice.setup = CALLOC(1,sizeof(struct NR_PHR_Config)); - mac_CellGroupConfig->phr_Config->choice.setup->phr_PeriodicTimer = mac_cellgroup_config->phr_PeriodicTimer[CC_id]; - mac_CellGroupConfig->phr_Config->choice.setup->phr_ProhibitTimer = mac_cellgroup_config->phr_ProhibitTimer[CC_id]; - mac_CellGroupConfig->phr_Config->choice.setup->phr_Tx_PowerFactorChange = mac_cellgroup_config->phr_Tx_PowerFactorChange[CC_id]; - mac_CellGroupConfig->phr_Config->choice.setup->multiplePHR = mac_cellgroup_config->multiplePHR[CC_id]; - mac_CellGroupConfig->phr_Config->choice.setup->dummy = mac_cellgroup_config->phr_Type2SpCell[CC_id]; - mac_CellGroupConfig->phr_Config->choice.setup->phr_Type2OtherCell = mac_cellgroup_config->phr_Type2OtherCell[CC_id]; - mac_CellGroupConfig->phr_Config->choice.setup->phr_ModeOtherCG = mac_cellgroup_config->phr_ModeOtherCG[CC_id]; - mac_CellGroupConfig->skipUplinkTxDynamic = mac_cellgroup_config->skipUplinkTxDynamic[CC_id]; -} - - -void do_PHYSICALCELLGROUP(uint8_t Mod_id, - int CC_id, - NR_PhysicalCellGroupConfig_t *physicalCellGroupConfig, - physicalcellgroup_t *physicalcellgroup_config) { - physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH = CALLOC(1,sizeof(long)); - physicalCellGroupConfig->harq_ACK_SpatialBundlingPUSCH = CALLOC(1,sizeof(long)); - physicalCellGroupConfig->p_NR_FR1 = CALLOC(1,sizeof(NR_P_Max_t)); - physicalCellGroupConfig->tpc_SRS_RNTI = CALLOC(1,sizeof(NR_RNTI_Value_t)); - physicalCellGroupConfig->tpc_PUCCH_RNTI = CALLOC(1,sizeof(NR_RNTI_Value_t)); - physicalCellGroupConfig->tpc_PUSCH_RNTI = CALLOC(1,sizeof(NR_RNTI_Value_t)); - physicalCellGroupConfig->sp_CSI_RNTI = CALLOC(1,sizeof(NR_RNTI_Value_t)); - *(physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH) = physicalcellgroup_config->harq_ACK_SpatialBundlingPUCCH[CC_id]; - *(physicalCellGroupConfig->harq_ACK_SpatialBundlingPUSCH) = physicalcellgroup_config->harq_ACK_SpatialBundlingPUSCH[CC_id]; - *(physicalCellGroupConfig->p_NR_FR1) = physicalcellgroup_config->p_NR[CC_id]; - physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook = physicalcellgroup_config->pdsch_HARQ_ACK_Codebook[CC_id]; - *(physicalCellGroupConfig->tpc_SRS_RNTI) = physicalcellgroup_config->tpc_SRS_RNTI[CC_id]; - *(physicalCellGroupConfig->tpc_PUCCH_RNTI) = physicalcellgroup_config->tpc_PUCCH_RNTI[CC_id]; - *(physicalCellGroupConfig->tpc_PUSCH_RNTI) = physicalcellgroup_config->tpc_PUSCH_RNTI[CC_id]; - *(physicalCellGroupConfig->sp_CSI_RNTI) = physicalcellgroup_config->sp_CSI_RNTI[CC_id]; - physicalCellGroupConfig->cs_RNTI = CALLOC(1,sizeof(struct NR_SetupRelease_RNTI_Value)); - physicalCellGroupConfig->cs_RNTI->present = physicalcellgroup_config->RNTI_Value_PR[CC_id]; - - if(physicalCellGroupConfig->cs_RNTI->present == NR_SetupRelease_RNTI_Value_PR_setup) { - physicalCellGroupConfig->cs_RNTI->choice.setup = physicalcellgroup_config->RNTI_Value[CC_id]; - } -} - - - void do_SpCellConfig(gNB_RRC_INST *rrc, struct NR_SpCellConfig *spconfig){ //gNB_RrcConfigurationReq *common_configuration; @@ -994,6 +782,7 @@ void fill_initial_SpCellConfig(int uid, // where the startPosition = 2 or 3 and sl160 = 17, 17, 27 ... 157 only give us 30 different allocations. AssertFatal(uid>=0 && uid<30, "gNB cannot allocate the SRS resources\n"); + const int pdsch_AntennaPorts = configuration->pdsch_AntennaPorts.N1 * configuration->pdsch_AntennaPorts.N2 * configuration->pdsch_AntennaPorts.XP; int curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); SpCellConfig->servCellIndex = NULL; SpCellConfig->reconfigurationWithSync = NULL; @@ -1082,38 +871,7 @@ void fill_initial_SpCellConfig(int uid, ASN_SEQUENCE_ADD(&bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list, ss2); - bwp_Dedicated->pdsch_Config=calloc(1,sizeof(*bwp_Dedicated->pdsch_Config)); - bwp_Dedicated->pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup; - bwp_Dedicated->pdsch_Config->choice.setup = calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup)); - bwp_Dedicated->pdsch_Config->choice.setup->dataScramblingIdentityPDSCH = NULL; - bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA)); - bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; - bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); - - bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL; - bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL; - - bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition)); - *bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1; - bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation = NR_PDSCH_Config__resourceAllocation_resourceAllocationType1; - bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling; - bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling)); - bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = - calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize)); - *bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband; - - bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList)); - NR_TCI_State_t *tcic; - - tcic=calloc(1,sizeof(*tcic)); - tcic->tci_StateId=0; - tcic->qcl_Type1.cell=NULL; - tcic->qcl_Type1.bwp_Id=NULL; - tcic->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb; - tcic->qcl_Type1.referenceSignal.choice.ssb = 0; - tcic->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeD; - - ASN_SEQUENCE_ADD(&bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcic); + bwp_Dedicated->pdsch_Config = config_pdsch(bitmap, 0, pdsch_AntennaPorts); SpCellConfig->spCellConfigDedicated->tag_Id=0; SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig=calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig)); @@ -1191,8 +949,6 @@ void fill_initial_SpCellConfig(int uid, } ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0); - int pdsch_AntennaPorts = configuration->pdsch_AntennaPorts.N1 * configuration->pdsch_AntennaPorts.N2 * configuration->pdsch_AntennaPorts.XP; - int bwp_loop_end = n_dl_bwp>0 ? n_dl_bwp : 1; for (int bwp_loop = 0; bwp_loop < bwp_loop_end; bwp_loop++) { @@ -2025,19 +1781,6 @@ int16_t do_RRCReconfiguration( return -1; } - LOG_D(NR_RRC,"[gNB %d] RRCReconfiguration for UE %x Encoded %zd bits (%zd bytes)\n", - ctxt_pP->module_id, - ctxt_pP->rnti, - enc_rval.encoded, - (enc_rval.encoded+7)/8); - - if (enc_rval.encoded == -1) { - LOG_E(NR_RRC,"[gNB %d] ASN1 : RRCReconfiguration encoding failed for UE %x\n", - ctxt_pP->module_id, - ctxt_pP->rnti); - return(-1); - } - return((enc_rval.encoded+7)/8); } @@ -2479,3 +2222,95 @@ do_RRCReestablishmentComplete(uint8_t *buffer, size_t buffer_size, int64_t rrc_T return((enc_rval.encoded+7)/8); } +NR_MeasConfig_t *get_defaultMeasConfig(const gNB_RrcConfigurationReq *conf) +{ + const NR_FrequencyInfoDL_t *freqInfoDL = conf->scc->downlinkConfigCommon->frequencyInfoDL; + const NR_ARFCN_ValueNR_t absFreqSSB = *freqInfoDL->absoluteFrequencySSB; + DevAssert(freqInfoDL->scs_SpecificCarrierList.list.count == 1); + const NR_SubcarrierSpacing_t scs = freqInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + DevAssert(freqInfoDL->frequencyBandList.list.count == 1); + const NR_FreqBandIndicatorNR_t band = *freqInfoDL->frequencyBandList.list.array[0]; + + NR_MeasConfig_t *mc = calloc(1, sizeof(*mc)); + mc->measObjectToAddModList = calloc(1, sizeof(*mc->measObjectToAddModList)); + mc->reportConfigToAddModList = calloc(1, sizeof(*mc->reportConfigToAddModList)); + + // Measurement Objects: Specifies what is to be measured. For NR and inter-RAT E-UTRA measurements, this may include + // cell-specific offsets, blacklisted cells to be ignored and whitelisted cells to consider for measurements. + NR_MeasObjectToAddMod_t *mo1 = calloc(1, sizeof(*mo1)); + mo1->measObjectId = 1; + mo1->measObject.present = NR_MeasObjectToAddMod__measObject_PR_measObjectNR; + NR_MeasObjectNR_t *monr1 = calloc(1, sizeof(*monr1)); + asn1cCallocOne(monr1->ssbFrequency, absFreqSSB); + asn1cCallocOne(monr1->ssbSubcarrierSpacing, scs); + monr1->referenceSignalConfig.ssb_ConfigMobility = calloc(1, sizeof(*monr1->referenceSignalConfig.ssb_ConfigMobility)); + monr1->referenceSignalConfig.ssb_ConfigMobility->deriveSSB_IndexFromCell = true; + monr1->absThreshSS_BlocksConsolidation = calloc(1, sizeof(*monr1->absThreshSS_BlocksConsolidation)); + asn1cCallocOne(monr1->absThreshSS_BlocksConsolidation->thresholdRSRP, 36); + asn1cCallocOne(monr1->nrofSS_BlocksToAverage, 8); + monr1->smtc1 = calloc(1, sizeof(*monr1->smtc1)); + monr1->smtc1->periodicityAndOffset.present = NR_SSB_MTC__periodicityAndOffset_PR_sf20; + monr1->smtc1->periodicityAndOffset.choice.sf20 = 2; + monr1->smtc1->duration = NR_SSB_MTC__duration_sf2; + monr1->quantityConfigIndex = 1; + monr1->ext1 = calloc(1, sizeof(*monr1->ext1)); + asn1cCallocOne(monr1->ext1->freqBandIndicatorNR, band); + mo1->measObject.choice.measObjectNR = monr1; + int ret = ASN_SEQUENCE_ADD(&mc->measObjectToAddModList->list, mo1); + AssertFatal(ret == 0, "ASN_SEQUENCE_ADD() returned %d\n", ret); + + // Reporting Configuration: Specifies how reporting should be done. This could be periodic or event-triggered. + NR_ReportConfigToAddMod_t *rc = calloc(1, sizeof(*rc)); + rc->reportConfigId = 1; + rc->reportConfig.present = NR_ReportConfigToAddMod__reportConfig_PR_reportConfigNR; + + NR_PeriodicalReportConfig_t *prc = calloc(1, sizeof(*prc)); + prc->rsType = NR_NR_RS_Type_ssb; + prc->reportInterval = NR_ReportInterval_ms1024; + prc->reportAmount = NR_PeriodicalReportConfig__reportAmount_infinity; + prc->reportQuantityCell.rsrp = true; + prc->reportQuantityCell.rsrq = true; + prc->reportQuantityCell.sinr = true; + prc->reportQuantityRS_Indexes = calloc(1, sizeof(*prc->reportQuantityRS_Indexes)); + prc->reportQuantityRS_Indexes->rsrp = true; + prc->reportQuantityRS_Indexes->rsrq = true; + prc->reportQuantityRS_Indexes->sinr = true; + asn1cCallocOne(prc->maxNrofRS_IndexesToReport, 4); + prc->maxReportCells = 4; + prc->includeBeamMeasurements = true; + + NR_ReportConfigNR_t *rcnr = calloc(1, sizeof(*rcnr)); + rcnr->reportType.present = NR_ReportConfigNR__reportType_PR_periodical; + rcnr->reportType.choice.periodical = prc; + + + rc->reportConfig.choice.reportConfigNR = rcnr; + ret = ASN_SEQUENCE_ADD(&mc->reportConfigToAddModList->list, rc); + AssertFatal(ret == 0, "ASN_SEQUENCE_ADD() returned %d\n", ret); + //prc->reportQuantityRS_Indexes->rsrp = 1; + + // Measurement ID: Identifies how to report measurements of a specific object. This is a many-to-many mapping: a + // measurement object could have multiple reporting configurations, a reporting configuration could apply to multiple + // objects. A unique ID is used for each object-to-report-config association. When UE sends a MeasurementReport + // message, a single ID and related measurements are included in the message. + mc->measIdToAddModList = calloc(1, sizeof(*mc->measIdToAddModList)); + NR_MeasIdToAddMod_t *measid = calloc(1, sizeof(*measid)); + measid->measId = 1; + measid->measObjectId = 1; + measid->reportConfigId = 1; + ret = ASN_SEQUENCE_ADD(&mc->measIdToAddModList->list, measid); + AssertFatal(ret == 0, "ASN_SEQUENCE_ADD() returned %d\n", ret); + + // Quantity Configuration: Specifies parameters for layer 3 filtering of measurements. Only after filtering, reporting + // criteria are evaluated. The formula used is F_n = (1-a)F_(n-1) + a*M_n, where M is the latest measurement, F is the + // filtered measurement, and ais based on configured filter coefficient. + mc->quantityConfig = calloc(1, sizeof(*mc->quantityConfig)); + mc->quantityConfig->quantityConfigNR_List = calloc(1, sizeof(*mc->quantityConfig->quantityConfigNR_List)); + NR_QuantityConfigNR_t *qcnr3 = calloc(1, sizeof(*qcnr3)); + asn1cCallocOne(qcnr3->quantityConfigCell.ssb_FilterConfig.filterCoefficientRSRP, NR_FilterCoefficient_fc6); + asn1cCallocOne(qcnr3->quantityConfigCell.csi_RS_FilterConfig.filterCoefficientRSRP, NR_FilterCoefficient_fc6); + ret = ASN_SEQUENCE_ADD(&mc->quantityConfig->quantityConfigNR_List->list, qcnr3); + AssertFatal(ret == 0, "ASN_SEQUENCE_ADD() returned %d\n", ret); + + return mc; +} diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index 770399b382..45ec5a72f9 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -69,21 +69,6 @@ uint16_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, gNB_RrcConfigurationReq *co uint8_t do_SIB23_NR(rrc_gNB_carrier_data_t *carrier, gNB_RrcConfigurationReq *configuration); -void do_RLC_BEARER(uint8_t Mod_id, - int CC_id, - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_BearerToAddModList, - rlc_bearer_config_t *rlc_config); -void do_MAC_CELLGROUP(uint8_t Mod_id, - int CC_id, - NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, - mac_cellgroup_t *mac_cellgroup_config); - -void do_PHYSICALCELLGROUP(uint8_t Mod_id, - int CC_id, - NR_PhysicalCellGroupConfig_t *physicalCellGroupConfig, - physicalcellgroup_t *physicalcellgroup_config); - - void do_SpCellConfig(gNB_RRC_INST *rrc, struct NR_SpCellConfig *spconfig); @@ -207,4 +192,6 @@ do_RRCReestablishmentComplete( uint8_t *buffer, size_t buffer_size, int64_t rrc_TransactionIdentifier); +NR_MeasConfig_t *get_defaultMeasConfig(const gNB_RrcConfigurationReq *conf); + #endif /* __RRC_NR_MESSAGES_ASN1_MSG__H__ */ diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index eaf00371b5..af12637ae9 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -941,6 +941,51 @@ struct NR_SetupRelease_PUSCH_Config *config_pusch(NR_PUSCH_Config_t *pusch_Confi return setup_puschconfig; } +struct NR_SetupRelease_PDSCH_Config *config_pdsch(uint64_t ssb_bitmap, int bwp_Id, int dl_antenna_ports) +{ + struct NR_SetupRelease_PDSCH_Config *setup_pdsch_Config = calloc(1,sizeof(*setup_pdsch_Config)); + setup_pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup; + NR_PDSCH_Config_t *pdsch_Config = calloc(1, sizeof(*pdsch_Config)); + setup_pdsch_Config->choice.setup = pdsch_Config; + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1, sizeof(*pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA)); + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->present = NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1, sizeof(*pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); + NR_DMRS_DownlinkConfig_t *dmrs_DownlinkForPDSCH_MappingTypeA = pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup; + if ((get_softmodem_params()->do_ra || get_softmodem_params()->phy_test) && dl_antenna_ports > 1) // for MIMO, we use DMRS Config Type 2 but only with OAI UE + dmrs_DownlinkForPDSCH_MappingTypeA->dmrs_Type = calloc(1, sizeof(*dmrs_DownlinkForPDSCH_MappingTypeA->dmrs_Type)); + else + dmrs_DownlinkForPDSCH_MappingTypeA->dmrs_Type = NULL; + dmrs_DownlinkForPDSCH_MappingTypeA->maxLength = NULL; + dmrs_DownlinkForPDSCH_MappingTypeA->scramblingID0 = NULL; + dmrs_DownlinkForPDSCH_MappingTypeA->scramblingID1 = NULL; + dmrs_DownlinkForPDSCH_MappingTypeA->dmrs_AdditionalPosition = calloc(1, sizeof(*dmrs_DownlinkForPDSCH_MappingTypeA->dmrs_AdditionalPosition)); + // TODO possible improvement is to select based on some input additional position + *dmrs_DownlinkForPDSCH_MappingTypeA->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1; + + pdsch_Config->dataScramblingIdentityPDSCH = NULL; + pdsch_Config->resourceAllocation = NR_PDSCH_Config__resourceAllocation_resourceAllocationType1; + + pdsch_Config->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling; + pdsch_Config->prb_BundlingType.choice.staticBundling = calloc(1, sizeof(*pdsch_Config->prb_BundlingType.choice.staticBundling)); + pdsch_Config->prb_BundlingType.choice.staticBundling->bundleSize = calloc(1, sizeof(*pdsch_Config->prb_BundlingType.choice.staticBundling->bundleSize)); + *pdsch_Config->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband; + + int n_ssb = 0; + for (int i = 0; i < 64; i++) { + if (((ssb_bitmap >> (63 - i)) & 0x01) == 0) + continue; + NR_TCI_State_t *tcid = calloc(1, sizeof(*tcid)); + tcid->tci_StateId = n_ssb++; + tcid->qcl_Type1.cell = NULL; + asn1cCallocOne(tcid->qcl_Type1.bwp_Id, bwp_Id); + tcid->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb; + tcid->qcl_Type1.referenceSignal.choice.ssb = i; + tcid->qcl_Type1.qcl_Type = NR_QCL_Info__qcl_Type_typeC; + ASN_SEQUENCE_ADD(&pdsch_Config->tci_StatesToAddModList->list, tcid); + } + return setup_pdsch_Config; +} + void config_downlinkBWP(NR_BWP_Downlink_t *bwp, const NR_ServingCellConfigCommon_t *scc, const NR_ServingCellConfig_t *servingcellconfigdedicated, @@ -1066,55 +1111,12 @@ void config_downlinkBWP(NR_BWP_Downlink_t *bwp, ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list, ss2); bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToReleaseList = NULL; + bwp->bwp_Dedicated->pdsch_Config = config_pdsch(ssb_bitmap, bwp->bwp_Id, dl_antenna_ports); - struct NR_SetupRelease_PDSCH_Config *pdsch_Config = NULL; - pdsch_Config = calloc(1,sizeof(*pdsch_Config)); - pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup; - pdsch_Config->choice.setup = calloc(1,sizeof(*pdsch_Config->choice.setup)); - pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,sizeof(*pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA)); - pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; - pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); - pdsch_Config->choice.setup->dataScramblingIdentityPDSCH = NULL; - struct NR_SetupRelease_DMRS_DownlinkConfig *dmrs_DownlinkForPDSCH_MappingTypeA = pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA; - - if ((get_softmodem_params()->do_ra || get_softmodem_params()->phy_test) && dl_antenna_ports > 1) // for MIMO, we use DMRS Config Type 2 but only with OAI UE - dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=calloc(1,sizeof(*dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type)); - else - dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL; - dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL; - dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID0=NULL; - dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID1=NULL; - dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition)); - *dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1; - - pdsch_Config->choice.setup->resourceAllocation = NR_PDSCH_Config__resourceAllocation_resourceAllocationType1; - pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling; - pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling)); - pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = calloc(1,sizeof(*pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize)); - *pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband; - - bwp->bwp_Dedicated->pdsch_Config = pdsch_Config; set_dl_mcs_table(bwp->bwp_Common->genericParameters.subcarrierSpacing, force_256qam_off ? NULL : uecap, bwp->bwp_Dedicated, scc); - - int n_ssb = 0; - NR_TCI_State_t *tcid[64]; - for (int i=0;i<64;i++) { - if ((ssb_bitmap>>(63-i))&0x01){ - tcid[i]=calloc(1,sizeof(*tcid[i])); - tcid[i]->tci_StateId=n_ssb; - tcid[i]->qcl_Type1.cell=NULL; - tcid[i]->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid[i]->qcl_Type1.bwp_Id)); - *tcid[i]->qcl_Type1.bwp_Id=bwp->bwp_Id; - tcid[i]->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb; - tcid[i]->qcl_Type1.referenceSignal.choice.ssb = i; - tcid[i]->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC; - ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid[i]); - n_ssb++; - } - } } void config_uplinkBWP(NR_BWP_Uplink_t *ubwp, diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 156db46d3b..f9c0675551 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -41,84 +41,6 @@ TyPe *lOcPtr= calloc(1,sizeof(TyPe)); \ ASN_SEQUENCE_ADD(&VaR,lOcPtr); -typedef struct rlc_bearer_config_s{ - long LogicalChannelIdentity[MAX_NUM_CCs]; - long servedRadioBearer_present[MAX_NUM_CCs]; - long srb_Identity[MAX_NUM_CCs]; - long drb_Identity[MAX_NUM_CCs]; - long reestablishRLC[MAX_NUM_CCs]; - long rlc_Config_present[MAX_NUM_CCs]; - long ul_AM_sn_FieldLength[MAX_NUM_CCs]; - long t_PollRetransmit[MAX_NUM_CCs]; - long pollPDU[MAX_NUM_CCs]; - long pollByte[MAX_NUM_CCs]; - long maxRetxThreshold[MAX_NUM_CCs]; - long dl_AM_sn_FieldLength[MAX_NUM_CCs]; - long dl_AM_t_Reassembly[MAX_NUM_CCs]; - long t_StatusProhibit[MAX_NUM_CCs]; - long ul_UM_sn_FieldLength[MAX_NUM_CCs]; - long dl_UM_sn_FieldLength[MAX_NUM_CCs]; - long dl_UM_t_Reassembly[MAX_NUM_CCs]; - long priority[MAX_NUM_CCs]; - long prioritisedBitRate[MAX_NUM_CCs]; - long bucketSizeDuration[MAX_NUM_CCs]; - long allowedServingCells[MAX_NUM_CCs]; - long subcarrierspacing[MAX_NUM_CCs]; - long maxPUSCH_Duration[MAX_NUM_CCs]; - long configuredGrantType1Allowed[MAX_NUM_CCs]; - long logicalChannelGroup[MAX_NUM_CCs]; - long schedulingRequestID[MAX_NUM_CCs]; /* OPTIONAL */ - int logicalChannelSR_Mask[MAX_NUM_CCs]; - int logicalChannelSR_DelayTimerApplied[MAX_NUM_CCs]; -}rlc_bearer_config_t; - -typedef struct mac_cellgroup_s{ - long DRX_Config_PR[MAX_NUM_CCs]; - long drx_onDurationTimer_PR[MAX_NUM_CCs]; - long subMilliSeconds[MAX_NUM_CCs]; - long milliSeconds[MAX_NUM_CCs]; - long drx_InactivityTimer[MAX_NUM_CCs]; - long drx_HARQ_RTT_TimerDL[MAX_NUM_CCs]; - long drx_HARQ_RTT_TimerUL[MAX_NUM_CCs]; - long drx_RetransmissionTimerDL[MAX_NUM_CCs]; - long drx_RetransmissionTimerUL[MAX_NUM_CCs]; - long drx_LongCycleStartOffset_PR[MAX_NUM_CCs]; - long drx_LongCycleStartOffset[MAX_NUM_CCs]; - long drx_ShortCycle[MAX_NUM_CCs]; - long drx_ShortCycleTimer[MAX_NUM_CCs]; - long drx_SlotOffset[MAX_NUM_CCs]; - long schedulingRequestId[MAX_NUM_CCs]; - long sr_ProhibitTimer[MAX_NUM_CCs]; - long sr_TransMax[MAX_NUM_CCs]; - long periodicBSR_Timer[MAX_NUM_CCs]; - long retxBSR_Timer[MAX_NUM_CCs]; - long logicalChannelSR_DelayTimer[MAX_NUM_CCs]; - long tag_Id[MAX_NUM_CCs]; - long timeAlignmentTimer[MAX_NUM_CCs]; - long PHR_Config_PR[MAX_NUM_CCs]; - long phr_PeriodicTimer[MAX_NUM_CCs]; - long phr_ProhibitTimer[MAX_NUM_CCs]; - long phr_Tx_PowerFactorChange[MAX_NUM_CCs]; - int multiplePHR[MAX_NUM_CCs]; - int phr_Type2SpCell[MAX_NUM_CCs]; - int phr_Type2OtherCell[MAX_NUM_CCs]; - long phr_ModeOtherCG[MAX_NUM_CCs]; - int skipUplinkTxDynamic[MAX_NUM_CCs]; -}mac_cellgroup_t; - -typedef struct physicalcellgroup_s{ - long harq_ACK_SpatialBundlingPUCCH[MAX_NUM_CCs]; - long harq_ACK_SpatialBundlingPUSCH[MAX_NUM_CCs]; - long p_NR[MAX_NUM_CCs]; - long pdsch_HARQ_ACK_Codebook[MAX_NUM_CCs]; - long tpc_SRS_RNTI[MAX_NUM_CCs]; - long tpc_PUCCH_RNTI[MAX_NUM_CCs]; - long tpc_PUSCH_RNTI[MAX_NUM_CCs]; - long sp_CSI_RNTI[MAX_NUM_CCs]; - long RNTI_Value_PR[MAX_NUM_CCs]; - long RNTI_Value[MAX_NUM_CCs]; -}physicalcellgroup_t; - void set_phr_config(NR_MAC_CellGroupConfig_t *mac_CellGroupConfig); uint64_t get_ssb_bitmap(const NR_ServingCellConfigCommon_t *scc); void rrc_coreset_config(NR_ControlResourceSet_t *coreset, @@ -152,6 +74,7 @@ void config_srs(NR_SetupRelease_SRS_Config_t *setup_release_srs_Config, const int res_id, const long maxMIMO_Layers, const int do_srs); +struct NR_SetupRelease_PDSCH_Config *config_pdsch(uint64_t ssb_bitmap, int bwp_Id, int dl_antenna_ports); void set_dl_mcs_table(int scs, NR_UE_NR_Capability_t *cap, NR_BWP_DownlinkDedicated_t *bwp_Dedicated, diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index b5941a5b0c..fdd6fb9544 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -541,7 +541,7 @@ rrc_gNB_generate_defaultRRCReconfiguration( //----------------------------------------------------------------------------- { uint8_t buffer[RRC_BUF_SIZE]; - uint16_t size; + int16_t size; /*NR_SRB_ToAddModList_t **SRB_configList2 = NULL; NR_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList; NR_DRB_ToAddModList_t **DRB_configList = NULL; @@ -651,6 +651,8 @@ rrc_gNB_generate_defaultRRCReconfiguration( } gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; + NR_MeasConfig_t *measconfig = get_defaultMeasConfig(&rrc->configuration); + gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; memset(buffer, 0, sizeof(buffer)); size = do_RRCReconfiguration(ctxt_pP, buffer, sizeof(buffer), @@ -660,13 +662,17 @@ rrc_gNB_generate_defaultRRCReconfiguration( NULL, NULL, NULL, - NULL, + measconfig, dedicatedNAS_MessageList, ue_context_pP, &rrc->carrier, &rrc->configuration, NULL, ue_p->masterCellGroup); + AssertFatal(size > 0, "cannot encode RRCReconfiguration in %s()\n", __func__); + LOG_W(RRC, "do_RRCReconfiguration(): size %d\n", size); + + xer_fprint(stdout,&asn_DEF_NR_CellGroupConfig, ue_p->masterCellGroup); free(ue_context_pP->ue_context.nas_pdu.buffer); @@ -2234,6 +2240,25 @@ static inline uint64_t bitStr_to_uint64(BIT_STRING_t *asn) { return result; } +static void rrc_gNB_process_MeasurementReport(rrc_gNB_ue_context_t *ue_context, const NR_MeasurementReport_t *measurementReport) +{ + if (LOG_DEBUGFLAG(DEBUG_ASN1)) + xer_fprint(stdout, &asn_DEF_NR_MeasurementReport, (void *)measurementReport); + + DevAssert(measurementReport->criticalExtensions.present == NR_MeasurementReport__criticalExtensions_PR_measurementReport + && measurementReport->criticalExtensions.choice.measurementReport != NULL); + + gNB_RRC_UE_t *ue_ctxt = &ue_context->ue_context; + if (ue_ctxt->measResults != NULL) { + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_NR_MeasResults, ue_ctxt->measResults); + ue_ctxt->measResults = NULL; + } + + const NR_MeasId_t id = measurementReport->criticalExtensions.choice.measurementReport->measResults.measId; + AssertFatal(id, "unexpected MeasResult for MeasurementId %ld received\n", id); + asn1cCallocOne(ue_ctxt->measResults, measurementReport->criticalExtensions.choice.measurementReport->measResults); +} + //----------------------------------------------------------------------------- int rrc_gNB_decode_dcch( @@ -2453,6 +2478,14 @@ rrc_gNB_decode_dcch( ue_context_p->ue_context.ue_release_timer = 0; break; + case NR_UL_DCCH_MessageType__c1_PR_measurementReport: + DevAssert(ul_dcch_msg != NULL + && ul_dcch_msg->message.present == NR_UL_DCCH_MessageType_PR_c1 + && ul_dcch_msg->message.choice.c1 + && ul_dcch_msg->message.choice.c1->present == NR_UL_DCCH_MessageType__c1_PR_measurementReport); + rrc_gNB_process_MeasurementReport(ue_context_p, ul_dcch_msg->message.choice.c1->choice.measurementReport); + break; + case NR_UL_DCCH_MessageType__c1_PR_ulInformationTransfer: LOG_I(NR_RRC,"Recived RRC GNB UL Information Transfer \n"); if(!ue_context_p) { @@ -3606,9 +3639,8 @@ unsigned int mask_flip(unsigned int x) { return((((x>>8) + (x<<8))&0xffff)>>6); } -unsigned int get_dl_bw_mask(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { - - +static unsigned int get_dl_bw_mask(const gNB_RRC_INST *rrc, const NR_UE_NR_Capability_t *cap) +{ int common_band = *rrc->carrier.servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; int common_scs = rrc->carrier.servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; for (int i=0;irf_Parameters.supportedBandListNR.list.count;i++) { @@ -3657,9 +3689,8 @@ unsigned int get_dl_bw_mask(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { return(0); } -unsigned int get_ul_bw_mask(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { - - +static unsigned int get_ul_bw_mask(const gNB_RRC_INST *rrc, const NR_UE_NR_Capability_t *cap) +{ int common_band = *rrc->carrier.servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0]; int common_scs = rrc->carrier.servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; for (int i=0;irf_Parameters.supportedBandListNR.list.count;i++) { @@ -3708,7 +3739,8 @@ unsigned int get_ul_bw_mask(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { return(0); } -int get_ul_mimo_layersCB(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { +static int get_ul_mimo_layersCB(const gNB_RRC_INST *rrc, const NR_UE_NR_Capability_t *cap) +{ int common_scs = rrc->carrier.servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; // check featureSet @@ -3725,7 +3757,8 @@ int get_ul_mimo_layersCB(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { return(1); } -int get_ul_mimo_layers(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { +static int get_ul_mimo_layers(const gNB_RRC_INST *rrc, const NR_UE_NR_Capability_t *cap) +{ int common_scs = rrc->carrier.servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; // check featureSet @@ -3741,7 +3774,8 @@ int get_ul_mimo_layers(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { return(1); } -int get_dl_mimo_layers(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { +static int get_dl_mimo_layers(const gNB_RRC_INST *rrc, const NR_UE_NR_Capability_t *cap) +{ int common_scs = rrc->carrier.servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; // check featureSet @@ -3756,36 +3790,15 @@ int get_dl_mimo_layers(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { } return(1); } + void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { MessageDef *msg; rrc_gNB_ue_context_t *ue_context_p = NULL; - FILE *fd=NULL;//fopen("nrRRCstats.log","w"); RB_FOREACH(ue_context_p, rrc_nr_ue_tree_s, &(RC.nrrrc[ctxt_pP->module_id]->rrc_ue_head)) { ctxt_pP->rnti = ue_context_p->ue_id_rnti; gNB_MAC_INST *nrmac=RC.nrmac[ctxt_pP->module_id]; //WHAT A BEAUTIFULL RACE CONDITION !!! - if (fd) { - if (ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.presence == true) { - fprintf(fd,"NR RRC UE rnti %x: S-TMSI %x failure timer %d/8\n", - ue_context_p->ue_id_rnti, - ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.fiveg_tmsi, - ue_context_p->ue_context.ul_failure_timer); - } else { - fprintf(fd,"NR RRC UE rnti %x failure timer %d/8\n", - ue_context_p->ue_id_rnti, - ue_context_p->ue_context.ul_failure_timer); - } - - if (ue_context_p->ue_context.UE_Capability_nr) { - fprintf(fd,"NR RRC UE cap: BW DL %x. BW UL %x, DL MIMO Layers %d UL MIMO Layers (CB) %d UL MIMO Layers (nonCB) %d\n", - get_dl_bw_mask(RC.nrrrc[0],ue_context_p->ue_context.UE_Capability_nr), - get_ul_bw_mask(RC.nrrrc[0],ue_context_p->ue_context.UE_Capability_nr), - get_dl_mimo_layers(RC.nrrrc[0],ue_context_p->ue_context.UE_Capability_nr), - get_ul_mimo_layersCB(RC.nrrrc[0],ue_context_p->ue_context.UE_Capability_nr), - get_ul_mimo_layers(RC.nrrrc[0],ue_context_p->ue_context.UE_Capability_nr)); - } - } if (ue_context_p->ue_context.ul_failure_timer > 0) { ue_context_p->ue_context.ul_failure_timer++; @@ -3856,8 +3869,6 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { } } - if (fd) fclose(fd); - /* send a tick to x2ap */ if (is_x2ap_enabled()){ msg = itti_alloc_new_message(TASK_RRC_ENB, 0, X2AP_SUBFRAME_PROCESS); @@ -3865,6 +3876,66 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { } } +static void print_rrc_meas(FILE *f, const NR_MeasResults_t *measresults) +{ + DevAssert(measresults->measResultServingMOList.list.count >= 1); + if (measresults->measResultServingMOList.list.count > 1) + LOG_W(RRC, "Received %d MeasResultServMO, but handling only 1!\n", measresults->measResultServingMOList.list.count); + + NR_MeasResultServMO_t *measresultservmo = measresults->measResultServingMOList.list.array[0]; + NR_MeasResultNR_t *measresultnr = &measresultservmo->measResultServingCell; + NR_MeasQuantityResults_t *mqr = measresultnr->measResult.cellResults.resultsSSB_Cell; + + fprintf(f, " servingCellId %ld MeasResultNR for phyCellId %ld:\n resultSSB:", measresultservmo->servCellId, *measresultnr->physCellId); + if (mqr != NULL) { + const long rrsrp = *mqr->rsrp - 156; + const float rrsrq = (float) (*mqr->rsrq - 87) / 2.0f; + const float rsinr = (float) (*mqr->sinr - 46) / 2.0f; + fprintf(f, "RSRP %ld dBm RSRQ %.1f dB SINR %.1f dB\n", rrsrp, rrsrq, rsinr); + } else { + fprintf(f, "NOT PROVIDED\n"); + } +} + +static void write_rrc_stats(const gNB_RRC_INST *rrc) +{ + const char *filename = "nrRRC_stats.log"; + FILE *f = fopen(filename, "w"); + if (f == NULL) { + LOG_E(NR_RRC, "cannot open %s for writing\n", filename); + return; + } + + rrc_gNB_ue_context_t *ue_context_p = NULL; + /* cast is necessary to eliminate warning "discards ‘const’ qualifier" */ + RB_FOREACH(ue_context_p, rrc_nr_ue_tree_s, &((gNB_RRC_INST *)rrc)->rrc_ue_head) { + const rnti_t rnti = ue_context_p->ue_id_rnti; + const gNB_RRC_UE_t *ue_ctxt = &ue_context_p->ue_context; + + fprintf(f, "NR RRC UE rnti %04x:", rnti); + + if (ue_ctxt->Initialue_identity_5g_s_TMSI.presence) + fprintf(f, " S-TMSI %x\n", ue_ctxt->Initialue_identity_5g_s_TMSI.fiveg_tmsi); + + fprintf(f, " failure timer %d/8\n", ue_ctxt->ul_failure_timer); + + if (ue_ctxt->UE_Capability_nr) { + fprintf(f, + " UE cap: BW DL %x. BW UL %x, DL MIMO Layers %d UL MIMO Layers (CB) %d UL MIMO Layers (nonCB) %d\n", + get_dl_bw_mask(rrc, ue_ctxt->UE_Capability_nr), + get_ul_bw_mask(rrc, ue_ctxt->UE_Capability_nr), + get_dl_mimo_layers(rrc, ue_ctxt->UE_Capability_nr), + get_ul_mimo_layersCB(rrc, ue_ctxt->UE_Capability_nr), + get_ul_mimo_layers(rrc, ue_ctxt->UE_Capability_nr)); + } + + if (ue_ctxt->measResults) + print_rrc_meas(f, ue_ctxt->measResults); + } + + fclose(f); +} + ///---------------------------------------------------------------------------------------------------------------/// ///---------------------------------------------------------------------------------------------------------------/// void *rrc_gnb_task(void *args_p) { @@ -3883,6 +3954,11 @@ void *rrc_gnb_task(void *args_p) { .eNB_index=0, .brOption=false }; + + /* timer to write stats to file */ + long stats_timer_id = 1; + timer_setup(1, 0, TASK_RRC_GNB, 0, TIMER_PERIODIC, NULL, &stats_timer_id); + itti_mark_task_ready(TASK_RRC_GNB); LOG_I(NR_RRC,"Entering main loop of NR_RRC message task\n"); @@ -3892,10 +3968,6 @@ void *rrc_gnb_task(void *args_p) { msg_name_p = ITTI_MSG_NAME(msg_p); instance = ITTI_MSG_DESTINATION_INSTANCE(msg_p); - /* RRC_SUBFRAME_PROCESS is sent every subframe, do not log it */ - if (ITTI_MSG_ID(msg_p) != RRC_SUBFRAME_PROCESS) - LOG_I(NR_RRC,"Received message %s\n",msg_name_p); - switch (ITTI_MSG_ID(msg_p)) { case TERMINATE_MESSAGE: LOG_W(NR_RRC, " *** Exiting NR_RRC thread\n"); @@ -3906,6 +3978,12 @@ void *rrc_gnb_task(void *args_p) { LOG_I(NR_RRC, "[gNB %ld] Received %s\n", instance, msg_name_p); break; + case TIMER_HAS_EXPIRED: + /* only this one handled for now */ + DevAssert(TIMER_HAS_EXPIRED(msg_p).timer_id == stats_timer_id); + write_rrc_stats(RC.nrrrc[0]); + break; + case RRC_SUBFRAME_PROCESS: nr_rrc_subframe_process(&RRC_SUBFRAME_PROCESS(msg_p).ctxt, RRC_SUBFRAME_PROCESS(msg_p).CC_id); break; diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index c9702fedd2..1fe4cb30e9 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -206,156 +206,10 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)); secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdcch_Config=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config)); - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup = calloc(1, - sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup)); - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dataScramblingIdentityPDSCH = NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1, - sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA)); - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); + secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config = config_pdsch(bitmap, 0, dl_antenna_ports); + secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->sps_Config = NULL; // calloc(1,sizeof(struct NR_SetupRelease_SPS_Config)); - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID0=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID1=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=NULL; - - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition)); - *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1; - - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList)); - - int n_ssb = 0; - NR_TCI_State_t *tcic[64]; - for (int i=0;i<64;i++) { - if ((bitmap>>(63-i))&0x01){ - tcic[i]=calloc(1,sizeof(*tcic[i])); - tcic[i]->tci_StateId=n_ssb; - tcic[i]->qcl_Type1.cell=NULL; - tcic[i]->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcic[i]->qcl_Type1.bwp_Id)); - *tcic[i]->qcl_Type1.bwp_Id=1; - tcic[i]->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb; - tcic[i]->qcl_Type1.referenceSignal.choice.ssb = i; - tcic[i]->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC; - ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcic[i]); - n_ssb++; - } - } - -#if 0 - - NR_TCI_State_t*tci0=calloc(1,sizeof(*tci0)); - tci0->tci_StateId=0; - tci0->qcl_Type1.cell=NULL; - tci0->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci0->qcl_Type1.bwp_Id)); - *tci0->qcl_Type1.bwp_Id=1; - tci0->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs; - tci0->qcl_Type1.referenceSignal.choice.csi_rs = 2; - tci0->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA; - ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci0); - - NR_TCI_State_t*tci1=calloc(1,sizeof(*tci1)); - tci1->tci_StateId=1; - tci1->qcl_Type1.cell=NULL; - tci1->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci1->qcl_Type1.bwp_Id)); - *tci1->qcl_Type1.bwp_Id=1; - tci1->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs; - tci1->qcl_Type1.referenceSignal.choice.csi_rs = 6; - tci1->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA; - ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci1); - - NR_TCI_State_t*tci2=calloc(1,sizeof(*tci2)); - tci2->tci_StateId=2; - tci2->qcl_Type1.cell=NULL; - tci2->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci2->qcl_Type1.bwp_Id)); - *tci2->qcl_Type1.bwp_Id=1; - tci2->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs; - tci2->qcl_Type1.referenceSignal.choice.csi_rs = 10; - tci2->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA; - ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci2); - - NR_TCI_State_t *tci3=calloc(1,sizeof(*tci3)); - tci3->tci_StateId=3; - tci3->qcl_Type1.cell=NULL; - tci3->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci3->qcl_Type1.bwp_Id)); - *tci3->qcl_Type1.bwp_Id=1; - tci3->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs; - tci3->qcl_Type1.referenceSignal.choice.csi_rs = 14; - tci3->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA; - ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci3); - - NR_TCI_State_t*tci4=calloc(1,sizeof(*tci4)); - tci4->tci_StateId=4; - tci4->qcl_Type1.cell=NULL; - tci4->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci4->qcl_Type1.bwp_Id)); - *tci4->qcl_Type1.bwp_Id=1; - tci4->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs; - tci4->qcl_Type1.referenceSignal.choice.csi_rs = 18; - tci4->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA; - ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci4); - - NR_TCI_State_t*tci5=calloc(1,sizeof(*tci5)); - tci5->tci_StateId=5; - tci5->qcl_Type1.cell=NULL; - tci5->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci5->qcl_Type1.bwp_Id)); - *tci5->qcl_Type1.bwp_Id=1; - tci5->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs; - tci5->qcl_Type1.referenceSignal.choice.csi_rs = 22; - tci5->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA; - ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci5); - - NR_TCI_State_t*tci6=calloc(1,sizeof(*tci6)); - tci6->tci_StateId=6; - tci6->qcl_Type1.cell=NULL; - tci6->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci6->qcl_Type1.bwp_Id)); - *tci6->qcl_Type1.bwp_Id=1; - tci6->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs; - tci6->qcl_Type1.referenceSignal.choice.csi_rs = 26; - tci6->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA; - ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci6); - - NR_TCI_State_t*tci7=calloc(1,sizeof(*tci7)); - tci7->tci_StateId=7; - tci7->qcl_Type1.cell=NULL; - tci7->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci7->qcl_Type1.bwp_Id)); - *tci7->qcl_Type1.bwp_Id=1; - tci7->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs; - tci7->qcl_Type1.referenceSignal.choice.csi_rs = 30; - tci7->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA; - ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci7); - -#endif - - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToReleaseList=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->resourceAllocation=NR_PDSCH_Config__resourceAllocation_resourceAllocationType1; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->pdsch_AggregationFactor=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternToAddModList=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternToReleaseList=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternGroup1=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternGroup2=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rbg_Size=NR_PDSCH_Config__rbg_Size_config1; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->mcs_Table=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI)); - *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = NR_PDSCH_Config__maxNrofCodeWordsScheduledByDCI_n1; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling)); - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = - calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize)); - *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToAddModList=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToReleaseList=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToAddModList=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToReleaseList=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->p_ZP_CSI_RS_ResourceSet=NULL; - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->sps_Config = NULL; //calloc(1,sizeof(struct NR_SetupRelease_SPS_Config)); - - secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig = NULL; + secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig = NULL; #if 0 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig)); secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->present = NR_SetupRelease_RadioLinkMonitoringConfig_PR_setup; diff --git a/radio/rfsimulator/simulator.c b/radio/rfsimulator/simulator.c index 498c3d1ea3..48a78448ed 100644 --- a/radio/rfsimulator/simulator.c +++ b/radio/rfsimulator/simulator.c @@ -547,7 +547,8 @@ sin_port: sin_addr: { s_addr: INADDR_ANY } }; - bind(t->listen_sock, (struct sockaddr *)&addr, sizeof(addr)); + int rc = bind(t->listen_sock, (struct sockaddr *)&addr, sizeof(addr)); + AssertFatal(rc == 0, "bind failed: errno %d, %s", errno, strerror(errno)); AssertFatal(listen(t->listen_sock, 5) == 0, ""); struct epoll_event ev= {0}; ev.events = EPOLLIN; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.24PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.24PRB.usrpx300.conf index c74476902b..b640e2de55 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.24PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.24PRB.usrpx300.conf @@ -181,7 +181,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpx300.conf index ac1dba7e42..3337f67ac8 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.25PRB.usrpx300.conf @@ -179,7 +179,6 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; - thread_pool_size = 8; ofdm_offset_divisor = 8; #set this to UINT_MAX for offset 0 } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf index f5918cfb83..538ce4f615 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.106PRB.2x2.usrpn310.conf @@ -235,7 +235,6 @@ L1s = ( num_cc = 1; tr_n_preference = "local_mac"; prach_dtx_threshold = 120; - thread_pool_size = 4; # pucch0_dtx_threshold = 150; } ); diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf index e893e88d1a..8d409bf423 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.band78.sa.fr1.162PRB.2x2.usrpn310.conf @@ -239,7 +239,6 @@ L1s = ( num_cc = 1; tr_n_preference = "local_mac"; prach_dtx_threshold = 120; - thread_pool_size = 8; # pucch0_dtx_threshold = 150; } );