diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 3c1f8ac531ac5615339baedfffc851eb3ac57122..e396651133c838024e48b3884216f7b2ea4a4739 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -156,6 +156,9 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) AssertFatal( nb_connected_gNB <= NUMBER_OF_CONNECTED_gNB_MAX, "n_connected_gNB is too large" ); // init phy_vars_ue + for (i=0; i<fp->Lmax; i++) + ue->measurements.ssb_rsrp_dBm[i] = INT_MIN; + for (i=0; i<4; i++) { ue->rx_gain_max[i] = 135; ue->rx_gain_med[i] = 128; diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index 5cfe47cfb27b81a50fc028f250c4c7c6e38bb17b..d935e8c0bca0a98df58b9a6a81f4a15b1ba729f2 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -1557,10 +1557,8 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, } // cw loop corr_dB = dB_fixed64((uint64_t)corr); #ifdef DEBUG_NR_PUCCH_RX - printf("cw_ML %d, metric %d dB\n",cw_ML,corr_dB); + LOG_I(PHY,"slot %d PUCCH2 cw_ML %d, metric %d dB\n",slot,cw_ML,corr_dB); #endif - LOG_D(PHY,"slot %d PUCCH2 cw_ML %d, metric %d dB\n", slot, cw_ML, corr_dB); - decodedPayload[0]=(uint64_t)cw_ML; } else { // polar coded case diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h index ce99f0f9c96a770b4f9d1261475328b1879225bf..52b3af9a96519ee5ccd181e8e1b152c1b0b523d4 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h @@ -98,11 +98,10 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t slot); -void nr_ue_rsrp_measurements(PHY_VARS_NR_UE *ue, - uint8_t gNB_index, - UE_nr_rxtx_proc_t *proc, - uint8_t slot, - uint8_t abstraction_flag); +void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue, + uint8_t gNB_index, + UE_nr_rxtx_proc_t *proc, + uint8_t slot); void nr_ue_rrc_measurements(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c index 7f6f0e8ef9bcc190a28eede7e4193653829f97f9..bf7b93b180bb8fb4478b3353071c0152a5bfb728 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c @@ -33,6 +33,7 @@ #include "executables/softmodem-common.h" #include "executables/nr-softmodem-common.h" #include "PHY/defs_nr_UE.h" +#include "PHY/INIT/phy_init.h" #include "PHY/phy_extern_nr_ue.h" #include "common/utils/LOG/log.h" #include "PHY/sse_intrin.h" @@ -203,69 +204,57 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue, // Measurement units: // - RSRP: W (dBW) // - RX Gain dB -void nr_ue_rsrp_measurements(PHY_VARS_NR_UE *ue, - uint8_t gNB_id, - UE_nr_rxtx_proc_t *proc, - uint8_t slot, - uint8_t abstraction_flag) -{ - int aarx; - int nb_re; - int k_start = 55; +void nr_ue_ssb_rsrp_measurements(PHY_VARS_NR_UE *ue, + int ssb_index, + UE_nr_rxtx_proc_t *proc, + uint8_t slot) { + + int k_start = 56; int k_end = 183; unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier; - uint8_t l_sss = ue->symbol_offset + 2; + int symbol_offset = nr_get_ssb_start_symbol(&ue->frame_parms,ssb_index); - if (ssb_offset>= ue->frame_parms.ofdm_symbol_size){ + if (ue->frame_parms.half_frame_bit) + symbol_offset += (ue->frame_parms.slots_per_frame>>1)*ue->frame_parms.symbols_per_slot; - ssb_offset -= ue->frame_parms.ofdm_symbol_size; - - } + uint8_t l_sss = (symbol_offset + 2) % ue->frame_parms.symbols_per_slot; - ue->measurements.rsrp[gNB_id] = 0; - - if (abstraction_flag == 0) { - - LOG_D(PHY, "In %s: [UE %d] slot %d l_sss %d ssb_offset %d\n", __FUNCTION__, ue->Mod_id, slot, l_sss, ssb_offset); + if (ssb_offset>= ue->frame_parms.ofdm_symbol_size) + ssb_offset -= ue->frame_parms.ofdm_symbol_size; - nb_re = 0; + uint32_t rsrp = 0; - for (aarx = 0; aarx < ue->frame_parms.nb_antennas_rx; aarx++) { + LOG_D(PHY, "In %s: [UE %d] slot %d l_sss %d ssb_offset %d\n", __FUNCTION__, ue->Mod_id, slot, l_sss, ssb_offset); + int nb_re = 0; - int16_t *rxF_sss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aarx][(l_sss*ue->frame_parms.ofdm_symbol_size) + ssb_offset]; + for (int aarx = 0; aarx < ue->frame_parms.nb_antennas_rx; aarx++) { - for(int k = k_start; k < k_end; k++){ + int16_t *rxF_sss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aarx][(l_sss*ue->frame_parms.ofdm_symbol_size) + ssb_offset]; - #ifdef DEBUG_MEAS_UE - LOG_I(PHY, "In %s rxF_sss %d %d\n", __FUNCTION__, rxF_sss[k*2], rxF_sss[k*2 + 1]); - #endif + for(int k = k_start; k < k_end; k++){ - ue->measurements.rsrp[gNB_id] += (((int32_t)rxF_sss[k*2]*rxF_sss[k*2]) + ((int32_t)rxF_sss[k*2 + 1]*rxF_sss[k*2 + 1])); +#ifdef DEBUG_MEAS_UE + LOG_I(PHY, "In %s rxF_sss %d %d\n", __FUNCTION__, rxF_sss[k*2], rxF_sss[k*2 + 1]); +#endif - nb_re++; + rsrp += (((int32_t)rxF_sss[k*2]*rxF_sss[k*2]) + ((int32_t)rxF_sss[k*2 + 1]*rxF_sss[k*2 + 1])); + nb_re++; - } } - - ue->measurements.rsrp[gNB_id] /= nb_re; - - } else { - - ue->measurements.rsrp[gNB_id] = -93; - } - ue->measurements.rsrp_filtered[gNB_id] = ue->measurements.rsrp[gNB_id]; - - ue->measurements.rsrp_dBm[gNB_id] = 10*log10(ue->measurements.rsrp[gNB_id]) + 30 - 10*log10(pow(2,30)) - ((int)openair0_cfg[0].rx_gain[0] - (int)openair0_cfg[0].rx_gain_offset[0]) - dB_fixed(ue->frame_parms.ofdm_symbol_size); + rsrp /= nb_re; + ue->measurements.ssb_rsrp_dBm[ssb_index] = 10*log10(rsrp) + + 30 - 10*log10(pow(2,30)) - + ((int)openair0_cfg[0].rx_gain[0] - (int)openair0_cfg[0].rx_gain_offset[0]) - + dB_fixed(ue->frame_parms.ofdm_symbol_size); - LOG_D(PHY, "In %s: [UE %d] slot %d SS-RSRP: %d dBm/RE (%d)\n", + LOG_D(PHY, "In %s: [UE %d] ssb %d SS-RSRP: %d dBm/RE (%d)\n", __FUNCTION__, ue->Mod_id, - slot, - ue->measurements.rsrp_dBm[gNB_id], - ue->measurements.rsrp[gNB_id]); - + ssb_index, + ue->measurements.ssb_rsrp_dBm[ssb_index], + rsrp); } // This function computes the received noise power @@ -281,7 +270,7 @@ void nr_ue_rrc_measurements(PHY_VARS_NR_UE *ue, uint8_t k_left = 48; uint8_t k_right = 183; uint8_t k_length = 8; - uint8_t l_sss = ue->symbol_offset + 2; + uint8_t l_sss = (ue->symbol_offset + 2) % ue->frame_parms.symbols_per_slot; unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier; double rx_gain = openair0_cfg[0].rx_gain[0]; double rx_gain_offset = openair0_cfg[0].rx_gain_offset[0]; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index ea7bde5377ffc9eb10aed4f776849348c24ab6f5..064d4db1afa467649afc70dba9e0730ea9a3357d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -445,13 +445,6 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, } - LOG_I(PHY, "[UE %d] RRC Measurements => rssi %3.1f dBm (dig %3.1f dB, gain %d), N0 %d dBm, rsrp %3.1f dBm/RE, rsrq %3.1f dB\n",ue->Mod_id, - 10*log10(ue->measurements.rssi)-ue->rx_total_gain_dB, - 10*log10(ue->measurements.rssi), - ue->rx_total_gain_dB, - ue->measurements.n0_power_tot_dBm, - 10*log10(ue->measurements.rsrp[0])-ue->rx_total_gain_dB, - (10*log10(ue->measurements.rsrq[0]))); /* LOG_I(PHY, "[UE %d] Frame %d MIB Information => %s, %s, NidCell %d, N_RB_DL %d, PHICH DURATION %d, PHICH RESOURCE %s, TX_ANT %d\n", ue->Mod_id, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 78e4a8a4e811ad7a1609ac3e2d231a365e7e661e..d7b1c93e1d78eabe56009b2f0016a00b32bfb9ba 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -393,6 +393,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, MIMO_mode_t mimo_mode, NR_UE_PDCCH_CONFIG *phy_pdcch_config, fapiPbch_t *result) { + NR_UE_COMMON *nr_ue_common_vars = &ue->common_vars; int max_h=0; int symbol; @@ -416,7 +417,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, int symbol_offset=1; if (ue->is_synchronized > 0) - symbol_offset=(ue->symbol_offset)%(frame_parms->symbols_per_slot); + symbol_offset=nr_get_ssb_start_symbol(frame_parms, i_ssb)%(frame_parms->symbols_per_slot); else symbol_offset=0; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 9896af13fc22bfb91a1c65377e66054f33ae9e09..951050349e1c313f31ef898af1de2361a4379494 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -132,12 +132,9 @@ typedef struct { // RRC measurements uint32_t rssi; int n_adj_cells; - unsigned int adj_cell_id[6]; - uint32_t rsrq[7]; uint32_t rsrp[7]; - float rsrp_filtered[7]; // after layer 3 filtering - float rsrq_filtered[7]; short rsrp_dBm[7]; + int ssb_rsrp_dBm[64]; // common measurements //! estimated noise power (linear) unsigned int n0_power[NB_ANTENNAS_RX]; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 09c24d676dc3b834854f01d62c4567adf3f9e916..4a76608dc02a5be9c696ea496cd0014a87403ce5 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -39,6 +39,7 @@ #include "PHY/NR_REFSIG/dmrs_nr.h" #include "PHY/phy_extern_nr_ue.h" #include "PHY/MODULATION/modulation_UE.h" +#include "PHY/INIT/phy_init.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/NR_UE_TRANSPORT/srs_modulation_nr.h" @@ -173,7 +174,7 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.ssb_length = frame_parms->Lmax; rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.cell_id = frame_parms->Nid_cell; rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.ssb_start_subcarrier = frame_parms->ssb_start_subcarrier; - rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.rsrp_dBm = ue->measurements.rsrp_dBm[gNB_id]; + rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.rsrp_dBm = ue->measurements.ssb_rsrp_dBm[frame_parms->ssb_index]; break; case FAPI_NR_CSIRS_IND: memcpy(&rx_ind->rx_indication_body[n_pdus - 1].csirs_measurements, @@ -366,11 +367,13 @@ void nr_ue_measurement_procedures(uint16_t l, } static void nr_ue_pbch_procedures(uint8_t gNB_id, - PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc,int estimateSz, struct complex16 dl_ch_estimates[][estimateSz], NR_UE_PDCCH_CONFIG *phy_pdcch_config) -{ - int ret = 0; + PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + int estimateSz, + struct complex16 dl_ch_estimates[][estimateSz], + NR_UE_PDCCH_CONFIG *phy_pdcch_config) { + int ret = 0; DevAssert(ue); int frame_rx = proc->frame_rx; @@ -1319,95 +1322,17 @@ void *UE_thread_slot1_dl_processing(void *arg) { } #endif -int is_ssb_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_FRAME_PARMS *fp) -{ - int mu = fp->numerology_index; - //uint8_t half_frame_index = fp->half_frame_bit; - //uint8_t i_ssb = fp->ssb_index; - uint8_t Lmax = fp->Lmax; - if ((config->ssb_table.ssb_period > 0) && !(frame % (1 << (config->ssb_table.ssb_period - 1)))) { - - if(Lmax <= 8) { - if(slot <=3 && (((config->ssb_table.ssb_mask_list[0].ssb_mask << 2*slot)&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[0].ssb_mask << (2*slot +1))&0x80000000) == 0x80000000)) - return 1; - else return 0; - - } - else if(Lmax == 64) { - if (mu == NR_MU_3){ - - if (slot>=0 && slot <= 7){ - if(((config->ssb_table.ssb_mask_list[0].ssb_mask << 2*slot)&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[0].ssb_mask << (2*slot +1))&0x80000000) == 0x80000000) - return 1; - else return 0; - } - else if (slot>=10 && slot <=17){ - if(((config->ssb_table.ssb_mask_list[0].ssb_mask << 2*(slot-2))&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[0].ssb_mask << (2*(slot-2) +1))&0x80000000) == 0x80000000) - return 1; - else return 0; - } - else if (slot>=20 && slot <=27){ - if(((config->ssb_table.ssb_mask_list[1].ssb_mask << 2*(slot-20))&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[1].ssb_mask << (2*(slot-20) +1))&0x80000000) == 0x80000000) - return 1; - else return 0; - } - else if (slot>=30 && slot <=37){ - if(((config->ssb_table.ssb_mask_list[1].ssb_mask << 2*(slot-22))&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[1].ssb_mask << (2*(slot-22) +1))&0x80000000) == 0x80000000) - return 1; - else return 0; - } - else return 0; - - } - - - else if (mu == NR_MU_4) { - AssertFatal(0==1, "not implemented for mu = %d yet\n", mu); - } - else AssertFatal(0==1, "Invalid numerology index %d for the synchronization block\n", mu); - } - else AssertFatal(0==1, "Invalid Lmax %u for the synchronization block\n", Lmax); - } - else return 0; - -} - -int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_FRAME_PARMS *fp) { - - int ssb_slot_decoded = (fp->ssb_index>>1) + ((fp->ssb_index>>4)<<1); //slot in which the decoded SSB can be found - - if (config->ssb_table.ssb_period == 0) { - // check for pbch in corresponding slot each half frame - if (fp->half_frame_bit) - return(slot == ssb_slot_decoded || slot == ssb_slot_decoded - fp->slots_per_frame/2); - else - return(slot == ssb_slot_decoded || slot == ssb_slot_decoded + fp->slots_per_frame/2); - } - else { - // if the current frame is supposed to contain ssb - if (!(frame%(1<<(config->ssb_table.ssb_period-1)))) - return(slot == ssb_slot_decoded); - else - return 0; - } -} - int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, uint8_t dlsch_parallel, NR_UE_PDCCH_CONFIG *phy_pdcch_config, - notifiedFIFO_t *txFifo - ) -{ + notifiedFIFO_t *txFifo) { + int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; - int slot_pbch; - int slot_ssb; fapi_nr_config_request_t *cfg = &ue->nrUE_config; - uint8_t nb_symb_pdcch = phy_pdcch_config->nb_search_space > 0 ? phy_pdcch_config->pdcch_config[0].coreset.duration : 0; - uint8_t dci_cnt = 0; NR_DL_FRAME_PARMS *fp = &ue->frame_parms; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); @@ -1417,64 +1342,72 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, frame_rx%1024, nr_slot_rx, dB_fixed(signal_energy(ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF[0],2048*14))); - /* - uint8_t next1_thread_id = proc->thread_id== (RX_NB_TH-1) ? 0:(proc->thread_id+1); - uint8_t next2_thread_id = next1_thread_id== (RX_NB_TH-1) ? 0:(next1_thread_id+1); - */ - - int coreset_nb_rb=0; - int coreset_start_rb=0; - - if (phy_pdcch_config->nb_search_space > 0) - get_coreset_rballoc(phy_pdcch_config->pdcch_config[0].coreset.frequency_domain_resource,&coreset_nb_rb,&coreset_start_rb); - - slot_pbch = is_pbch_in_slot(cfg, frame_rx, nr_slot_rx, fp); - slot_ssb = is_ssb_in_slot(cfg, frame_rx, nr_slot_rx, fp); - - // looking for pbch only in slot where it is supposed to be - if (slot_ssb) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_IN); - LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); + // checking if current frame is compatible with SSB periodicity + if (cfg->ssb_table.ssb_period == 0 || + !(frame_rx%(1<<(cfg->ssb_table.ssb_period-1)))){ const int estimateSz = fp->symbols_per_slot * fp->ofdm_symbol_size; - __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[fp->nb_antennas_rx][estimateSz]; - __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][fp->ofdm_symbol_size]; - - for (int i=1; i<4; i++) { - - nr_slot_fep(ue, - proc, - (ue->symbol_offset+i)%(fp->symbols_per_slot), - nr_slot_rx); - - start_meas(&ue->dlsch_channel_estimation_stats); - nr_pbch_channel_estimation(ue, estimateSz, dl_ch_estimates, dl_ch_estimates_time,proc,gNB_id,nr_slot_rx,(ue->symbol_offset+i)%(fp->symbols_per_slot),i-1,(fp->ssb_index)&7,fp->half_frame_bit); - stop_meas(&ue->dlsch_channel_estimation_stats); - } - - nr_ue_rsrp_measurements(ue, gNB_id, proc, nr_slot_rx, 0); - - if ((ue->decode_MIB == 1) && slot_pbch) { - - 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); + // loop over SSB blocks + for(int ssb_index=0; ssb_index<fp->Lmax; ssb_index++) { + uint32_t curr_mask = cfg->ssb_table.ssb_mask_list[ssb_index/32].ssb_mask; + // check if if current SSB is transmitted + if ((curr_mask >> (31-(ssb_index%32))) &0x01) { + int ssb_start_symbol = nr_get_ssb_start_symbol(fp, ssb_index); + int ssb_slot = ssb_start_symbol/fp->symbols_per_slot; + int ssb_slot_2 = (cfg->ssb_table.ssb_period == 0) ? ssb_slot+(fp->slots_per_frame>>1) : -1; + + if (ssb_slot == nr_slot_rx || + ssb_slot_2 == nr_slot_rx) { + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_IN); + LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); + + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[fp->nb_antennas_rx][estimateSz]; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][fp->ofdm_symbol_size]; + + for (int i=1; i<4; i++) { + nr_slot_fep(ue, + proc, + (ssb_start_symbol+i)%(fp->symbols_per_slot), + nr_slot_rx); + + start_meas(&ue->dlsch_channel_estimation_stats); + nr_pbch_channel_estimation(ue, estimateSz, dl_ch_estimates, + dl_ch_estimates_time, proc, gNB_id, + nr_slot_rx, (ssb_start_symbol+i)%(fp->symbols_per_slot), + i-1, ssb_index&7, ssb_slot_2 == nr_slot_rx); + stop_meas(&ue->dlsch_channel_estimation_stats); + } - 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); - nr_adjust_synch_ue(fp, - ue, - gNB_id, - fp->ofdm_symbol_size, - dl_ch_estimates_time, - frame_rx, - nr_slot_rx, - 0, - 16384); + nr_ue_ssb_rsrp_measurements(ue, ssb_index, proc, nr_slot_rx); + + // resetting ssb index for PBCH detection if there is a stronger SSB index + if(ue->measurements.ssb_rsrp_dBm[ssb_index] > ue->measurements.ssb_rsrp_dBm[fp->ssb_index]) + fp->ssb_index = ssb_index; + + 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); + + 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); + nr_adjust_synch_ue(fp, + ue, + gNB_id, + fp->ofdm_symbol_size, + dl_ch_estimates_time, + frame_rx, + nr_slot_rx, + 0, + 16384); + } + } + LOG_D(PHY, "Doing N0 measurements in %s\n", __FUNCTION__); + nr_ue_rrc_measurements(ue, proc, nr_slot_rx); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_OUT); + } } - - LOG_D(PHY, "Doing N0 measurements in %s\n", __FUNCTION__); - nr_ue_rrc_measurements(ue, proc, nr_slot_rx); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_OUT); } } @@ -1499,6 +1432,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, LOG_D(PHY," ------ --> PDCCH ChannelComp/LLR Frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PDCCH, VCD_FUNCTION_IN); + uint8_t nb_symb_pdcch = phy_pdcch_config->nb_search_space > 0 ? phy_pdcch_config->pdcch_config[0].coreset.duration : 0; for (uint16_t l=0; l<nb_symb_pdcch; l++) { start_meas(&ue->ofdm_demod_stats); @@ -1512,7 +1446,13 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, 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]; - dci_cnt = 0; + int coreset_nb_rb=0; + int coreset_start_rb=0; + + if (phy_pdcch_config->nb_search_space > 0) + get_coreset_rballoc(phy_pdcch_config->pdcch_config[0].coreset.frequency_domain_resource,&coreset_nb_rb,&coreset_start_rb); + + uint8_t dci_cnt = 0; for(int n_ss = 0; n_ss<phy_pdcch_config->nb_search_space; n_ss++) { for (uint16_t l=0; l<nb_symb_pdcch; l++) { diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index b1f35f76e5cb9f27a9b17ee5f2d32b93ceb54f60..1e67617ee76fe5c557fdee45dfe999dc4b0c5695 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2617,27 +2617,31 @@ uint8_t get_ssb_rsrp_payload(NR_UE_MAC_INST_t *mac, } else nb_meas = 2; + struct NR_CSI_SSB_ResourceSet__csi_SSB_ResourceList SSB_resource; for (int csi_ssb_idx = 0; csi_ssb_idx < csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.count; csi_ssb_idx++) { if (csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_ssb_idx]->csi_SSB_ResourceSetId == *(csi_resourceconfig->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list.array[0])){ - + SSB_resource = csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_ssb_idx]->csi_SSB_ResourceList; ///only one SSB resource set from spec 38.331 IE CSI-ResourceConfig - nb_ssb = csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[csi_ssb_idx]->csi_SSB_ResourceList.list.count; + nb_ssb = SSB_resource.list.count; break; } } AssertFatal(nb_ssb>0,"No SSB found in the resource set\n"); + AssertFatal(nb_meas==1,"PHY currently reports only the strongest SSB to MAC. Can't report more than 1 RSRP\n"); int ssbri_bits = ceil(log2(nb_ssb)); - //TODO measurement of multiple SSBs at PHY and indication to MAC - if(nb_ssb>1) - LOG_E(MAC, "In current implementation only the SSB of synchronization is measured at PHY. This works only for a single SSB scenario\n"); - int ssb_rsrp[2][nb_meas]; // the array contains index and RSRP of each SSB to be reported (nb_meas highest RSRPs) //TODO replace the following 2 lines with a function to order the nb_meas highest SSB RSRPs - ssb_rsrp[0][0] = mac->mib_ssb; + for (int i=0; i<nb_ssb; i++) { + if(*SSB_resource.list.array[i] == mac->mib_ssb) { + ssb_rsrp[0][0] = i; + break; + } + } + AssertFatal(*SSB_resource.list.array[ssb_rsrp[0][0]] == mac->mib_ssb, "Couldn't find corresponding SSB in csi_SSB_ResourceList\n"); ssb_rsrp[1][0] = mac->ssb_rsrp_dBm; uint8_t ssbi;