diff --git a/executables/nr-ue.c b/executables/nr-ue.c index aa7e9f26ea..40a3d16753 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -305,10 +305,10 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) nr_ue_dl_indication(&mac->dl_info); process_queued_nr_nfapi_msgs(mac, sfn_slot); } - if (mac->scc == NULL && mac->scc_SIB == NULL) { - LOG_D(MAC, "[NSA] mac->scc == NULL and [SA] mac->scc_SIB == NULL!\n"); - continue; - } + + bool only_dl = false; + if (mac->scc == NULL && mac->scc_SIB == NULL) + only_dl = true; int CC_id = 0; uint8_t gNB_id = 0; @@ -332,7 +332,8 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) free_and_zero(ch_info); } - if (is_nr_DL_slot(get_softmodem_params()->nsa ? + if (only_dl || + is_nr_DL_slot(get_softmodem_params()->nsa ? mac->scc->tdd_UL_DL_ConfigurationCommon : mac->scc_SIB->tdd_UL_DL_ConfigurationCommon, ul_info.slot_rx)) { @@ -349,7 +350,8 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); - if (is_nr_UL_slot(get_softmodem_params()->nsa ? + if (!only_dl && + is_nr_UL_slot(get_softmodem_params()->nsa ? mac->scc->tdd_UL_DL_ConfigurationCommon : mac->scc_SIB->tdd_UL_DL_ConfigurationCommon, ul_info.slot_tx, mac->frame_type)) { @@ -510,8 +512,9 @@ static void RU_write(nr_rxtx_thread_data_t *rxtxD) { radio_tx_burst_flag_t flags = TX_BURST_INVALID; NR_UE_MAC_INST_t *mac = get_mac_inst(0); - - if (openair0_cfg[0].duplex_mode == duplex_mode_TDD && !get_softmodem_params()->continuous_tx) { + if (mac->phy_config_request_sent && + openair0_cfg[0].duplex_mode == duplex_mode_TDD && + !get_softmodem_params()->continuous_tx) { uint8_t tdd_period = mac->phy_config.config_req.tdd_table.tdd_period_in_slots; int nrofUplinkSlots, nrofUplinkSymbols; @@ -594,8 +597,8 @@ void processSlotTX(void *arg) { RU_write(rxtxD); } -nr_phy_data_t UE_dl_preprocessing(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { - +nr_phy_data_t UE_dl_preprocessing(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) +{ nr_phy_data_t phy_data = {0}; if (IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa) { @@ -619,7 +622,7 @@ nr_phy_data_t UE_dl_preprocessing(PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { } } - if (proc->rx_slot_type == NR_DOWNLINK_SLOT || proc->rx_slot_type == NR_MIXED_SLOT){ + if (proc->rx_slot_type == NR_DOWNLINK_SLOT || proc->rx_slot_type == NR_MIXED_SLOT) { if(UE->if_inst != NULL && UE->if_inst->dl_indication != NULL) { nr_downlink_indication_t dl_indication; @@ -749,7 +752,8 @@ static inline int get_readBlockSize(uint16_t slot, NR_DL_FRAME_PARMS *fp) { return rem_samples + next_slot_first_symbol; } -void *UE_thread(void *arg) { +void *UE_thread(void *arg) +{ //this thread should be over the processing thread to keep in real time PHY_VARS_NR_UE *UE = (PHY_VARS_NR_UE *) arg; // int tx_enabled = 0; @@ -793,21 +797,14 @@ void *UE_thread(void *arg) { if (res) { syncRunning=false; - syncData_t *tmp=(syncData_t *)NotifiedFifoData(res); if (UE->is_synchronized) { - LOG_I(PHY,"UE synchronized decoded_frame_rx=%d UE->init_sync_frame=%d trashed_frames=%d\n", - decoded_frame_rx, - UE->init_sync_frame, - trashed_frames); - - decoded_frame_rx=(((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | tmp->proc.decoded_frame_rx); + decoded_frame_rx = mac->mib_frame; + LOG_I(PHY,"UE synchronized decoded_frame_rx=%d UE->init_sync_frame=%d trashed_frames=%d\n", + decoded_frame_rx, + UE->init_sync_frame, + trashed_frames); // shift the frame index with all the frames we trashed meanwhile we perform the synch search - decoded_frame_rx=(decoded_frame_rx + UE->init_sync_frame + trashed_frames) % MAX_FRAME_NUMBER; - // wait for RRC to configure PHY parameters from SIB - if (get_softmodem_params()->sa) { - notifiedFIFO_elt_t *phy_config_res = pullNotifiedFIFO(&UE->phy_config_ind); - delNotifiedFIFO_elt(phy_config_res); - } + decoded_frame_rx = (decoded_frame_rx + UE->init_sync_frame + trashed_frames) % MAX_FRAME_NUMBER; } delNotifiedFIFO_elt(res); start_rx_stream=0; @@ -856,7 +853,7 @@ void *UE_thread(void *arg) { // and we shifted above to the first slot of next frame decoded_frame_rx++; // we do ++ first in the regular processing, so it will be begin of frame; - absolute_slot=decoded_frame_rx*nb_slot_frame -1; + absolute_slot = decoded_frame_rx * nb_slot_frame - 1; continue; } @@ -869,11 +866,16 @@ void *UE_thread(void *arg) { // update thread index for received subframe curMsg.proc.nr_slot_rx = slot_nr; curMsg.proc.nr_slot_tx = (absolute_slot + DURATION_RX_TO_TX) % nb_slot_frame; - curMsg.proc.frame_rx = (absolute_slot/nb_slot_frame) % MAX_FRAME_NUMBER; - curMsg.proc.frame_tx = ((absolute_slot+DURATION_RX_TO_TX)/nb_slot_frame) % MAX_FRAME_NUMBER; - curMsg.proc.rx_slot_type = nr_ue_slot_select(cfg, curMsg.proc.frame_rx, curMsg.proc.nr_slot_rx); - curMsg.proc.tx_slot_type = nr_ue_slot_select(cfg, curMsg.proc.frame_tx, curMsg.proc.nr_slot_tx); - curMsg.proc.decoded_frame_rx=-1; + curMsg.proc.frame_rx = (absolute_slot / nb_slot_frame) % MAX_FRAME_NUMBER; + curMsg.proc.frame_tx = ((absolute_slot + DURATION_RX_TO_TX) / nb_slot_frame) % MAX_FRAME_NUMBER; + if (mac->phy_config_request_sent) { + curMsg.proc.rx_slot_type = nr_ue_slot_select(cfg, curMsg.proc.frame_rx, curMsg.proc.nr_slot_rx); + curMsg.proc.tx_slot_type = nr_ue_slot_select(cfg, curMsg.proc.frame_tx, curMsg.proc.nr_slot_tx); + } + else { + curMsg.proc.rx_slot_type = NR_DOWNLINK_SLOT; + curMsg.proc.tx_slot_type = NR_DOWNLINK_SLOT; + } int firstSymSamp = get_firstSymSamp(slot_nr, &UE->frame_parms); for (int i=0; iframe_parms.nb_antennas_rx; i++) @@ -882,11 +884,11 @@ void *UE_thread(void *arg) { int readBlockSize, writeBlockSize; - readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms); - writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX) % nb_slot_frame, &UE->frame_parms); - if (UE->apply_timing_offset && (slot_nr == nb_slot_frame-1)) { + readBlockSize = get_readBlockSize(slot_nr, &UE->frame_parms); + writeBlockSize = UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX) % nb_slot_frame, &UE->frame_parms); + if (UE->apply_timing_offset && (slot_nr == nb_slot_frame - 1)) { const int sampShift = -(UE->rx_offset>>1); - readBlockSize -= sampShift; + readBlockSize -= sampShift; writeBlockSize -= sampShift; UE->apply_timing_offset = false; } @@ -898,11 +900,11 @@ void *UE_thread(void *arg) { readBlockSize, UE->frame_parms.nb_antennas_rx),""); - if( slot_nr==(nb_slot_frame-1)) { + if(slot_nr == (nb_slot_frame - 1)) { // read in first symbol of next frame and adjust for timing drift - int first_symbols=UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0; // first symbol of every frames + int first_symbols = UE->frame_parms.ofdm_symbol_size + UE->frame_parms.nb_prefix_samples0; // first symbol of every frames - if ( first_symbols > 0 ) { + if (first_symbols > 0) { openair0_timestamp ignore_timestamp; AssertFatal(first_symbols == UE->rfdevice.trx_read_func(&UE->rfdevice, @@ -915,7 +917,7 @@ void *UE_thread(void *arg) { } // use previous timing_advance value to compute writeTimestamp - writeTimestamp = timestamp+ + writeTimestamp = timestamp + UE->frame_parms.get_samples_slot_timestamp(slot_nr,&UE->frame_parms,DURATION_RX_TO_TX) - firstSymSamp - openair0_cfg[0].tx_sample_advance - UE->N_TA_offset - timing_advance; @@ -947,15 +949,6 @@ void *UE_thread(void *arg) { curMsgRx->phy_data = UE_dl_preprocessing(UE, &curMsg.proc); pushTpool(&(get_nrUE_params()->Tpool), newElt); - if (curMsg.proc.decoded_frame_rx != -1) - decoded_frame_rx=(((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | curMsg.proc.decoded_frame_rx); - else - decoded_frame_rx=-1; - - if (decoded_frame_rx>0 && decoded_frame_rx != curMsg.proc.frame_rx) - LOG_E(PHY,"Decoded frame index (%d) is not compatible with current context (%d), UE should go back to synch mode\n", - decoded_frame_rx, curMsg.proc.frame_rx); - // Wait for TX slot processing to finish notifiedFIFO_elt_t *res; res = pullTpool(&txFifo, &(get_nrUE_params()->Tpool)); diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index c569ea38b1..29afb86a6f 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -515,6 +515,7 @@ int main( int argc, char **argv ) { if (get_softmodem_params()->sa) { // set frame config to initial values from command line and assume that the SSB is centered on the grid uint16_t nr_band = get_softmodem_params()->band; mac->nr_band = nr_band; + mac->ssb_start_subcarrier = UE[CC_id]->frame_parms.ssb_start_subcarrier; nr_init_frame_parms_ue_sa(&UE[CC_id]->frame_parms, downlink_frequency[CC_id][0], uplink_frequency_offset[CC_id][0], diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 44f7507390..a800d3b8d7 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -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_phy_data_t *phy_data, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) +int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_initial_symbol, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; int ret =-1; @@ -163,7 +163,6 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini frame_parms, temp_ptr->i_ssb, SISO, - phy_data, &result, rxdataF); @@ -213,9 +212,6 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, NR_DL_FRAME_PARMS *fp = &ue->frame_parms; int ret=-1; int rx_power=0; //aarx, - - 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); @@ -317,7 +313,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_data, rxdataF); // start pbch detection at first symbol after pss + ret = nr_pbch_detection(proc, ue, 1, rxdataF); // start pbch detection at first symbol after pss } if (ret == 0) { @@ -464,103 +460,6 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, #endif } - - if (ue->target_Nid_cell != -1) { - return ret; - } - - // 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; - proc->gNB_id = 0; //FIXME - - // Hold the channel estimates in frequency domain. - 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_ss < phy_pdcch_config->nb_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, - true, - rxdataF, - link_type_dl); - - nr_pdcch_channel_estimation(ue, - proc, - l, - &phy_pdcch_config->pdcch_config[n_ss].coreset, - fp->first_carrier_offset, - phy_pdcch_config->pdcch_config[n_ss].BWPStart, - pdcch_est_size, - pdcch_dl_ch_estimates, - rxdataF); - - } - int dci_cnt = nr_ue_pdcch_procedures(ue, proc, pdcch_est_size, pdcch_dl_ch_estimates, &phy_data, n_ss, rxdataF); - if (dci_cnt>0){ - 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, - frame_id * fp->samples_per_frame + phy_pdcch_config->sfn * fp->samples_per_frame + ue->rx_offset, - true, - rxdataF, - link_type_dl); - } - - uint8_t nb_re_dmrs; - if (dlsch[0].dlsch_config.dmrsConfigType == NFAPI_NR_DMRS_TYPE1) { - nb_re_dmrs = 6*dlsch[0].dlsch_config.n_dmrs_cdm_groups; - } - else { - nb_re_dmrs = 4*dlsch[0].dlsch_config.n_dmrs_cdm_groups; - } - uint16_t dmrs_len = get_num_dmrs(dlsch[0].dlsch_config.dlDmrsSymbPos); - - const uint32_t rx_llr_size = 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); - int16_t* llr[2]; - int16_t* layer_llr[NR_MAX_NB_LAYERS]; - llr[0] = (int16_t *)malloc16_clear(rx_llr_size*sizeof(int16_t)); - - int ret = nr_ue_pdsch_procedures(ue, - proc, - phy_data.dlsch, - llr, - rxdataF); - if (ret >= 0) - dec = nr_ue_dlsch_procedures(ue, - proc, - phy_data.dlsch, - llr); - - // deactivate dlsch once dlsch proc is done - dlsch[0].active = 0; - free(llr[0]); - for (int i=0; iframe_parms.samples_per_slot_wCP]) { @@ -515,7 +514,7 @@ int nr_rx_pbch(PHY_VARS_NR_UE *ue, uint16_t number_pdus = 1; if(decoderState) { - nr_fill_dl_indication(&dl_indication, NULL, &rx_ind, proc, ue, phy_data); + nr_fill_dl_indication(&dl_indication, NULL, &rx_ind, proc, ue, NULL); nr_fill_rx_indication(&rx_ind, FAPI_NR_RX_PDU_TYPE_SSB, ue, NULL, NULL, number_pdus, proc, NULL, NULL); if (ue->if_inst && ue->if_inst->dl_indication) ue->if_inst->dl_indication(&dl_indication); @@ -569,12 +568,6 @@ int nr_rx_pbch(PHY_VARS_NR_UE *ue, if (frame_parms->half_frame_bit) ue->symbol_offset += (frame_parms->slots_per_frame>>1)*frame_parms->symbols_per_slot; - uint8_t frame_number_4lsb = 0; - - for (int i=0; i<4; i++) - frame_number_4lsb |= ((result->xtra_byte>>i)&1)<<(3-i); - - proc->decoded_frame_rx = frame_number_4lsb; #ifdef DEBUG_PBCH printf("xtra_byte %x payload %x\n", xtra_byte, payload); @@ -585,7 +578,7 @@ int nr_rx_pbch(PHY_VARS_NR_UE *ue, #endif - nr_fill_dl_indication(&dl_indication, NULL, &rx_ind, proc, ue, phy_data); + nr_fill_dl_indication(&dl_indication, NULL, &rx_ind, proc, ue, NULL); nr_fill_rx_indication(&rx_ind, FAPI_NR_RX_PDU_TYPE_SSB, ue, NULL, NULL, number_pdus, proc, (void *)result, NULL); 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 0112d5809e..18469fa733 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -291,14 +291,12 @@ int nr_rx_pbch(PHY_VARS_NR_UE *ue, NR_DL_FRAME_PARMS *frame_parms, uint8_t i_ssb, MIMO_mode_t mimo_mode, - nr_phy_data_t *phy_data, fapiPbch_t* result, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); 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, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]); diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 0cd9cef722..97ff191d65 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -665,8 +665,6 @@ typedef struct { int frame_tx; /// frame to act upon for reception int frame_rx; - int frame_number_4lsb; - int decoded_frame_rx; } UE_nr_rxtx_proc_t; typedef struct nr_phy_data_tx_s { diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 2dbbfab2cc..21b344d901 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -361,7 +361,6 @@ static int nr_ue_pbch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int estimateSz, struct complex16 dl_ch_estimates[][estimateSz], - nr_phy_data_t *phy_data, c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { int ret = 0; @@ -382,7 +381,6 @@ static int nr_ue_pbch_procedures(PHY_VARS_NR_UE *ue, &ue->frame_parms, (ue->frame_parms.ssb_index)&7, SISO, - phy_data, &result, rxdataF); @@ -904,7 +902,7 @@ void pbch_pdcch_processing(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); - const int pbchSuccess = nr_ue_pbch_procedures(ue, proc, estimateSz, dl_ch_estimates, phy_data, rxdataF); + const int pbchSuccess = nr_ue_pbch_procedures(ue, proc, estimateSz, dl_ch_estimates, rxdataF); if (ue->no_timing_correction==0 && pbchSuccess == 0) { LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction); diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index f4f04b0538..4a45360ac0 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -782,7 +782,6 @@ int main(int argc, char **argv) } else { UE_nr_rxtx_proc_t proc={0}; - nr_phy_data_t phy_data={0}; UE->rx_offset=0; uint8_t ssb_index = 0; @@ -814,7 +813,6 @@ int main(int argc, char **argv) frame_parms, ssb_index%8, SISO, - &phy_data, &result, rxdataF); diff --git a/openair2/COMMON/mac_messages_types.h b/openair2/COMMON/mac_messages_types.h index 5703a886c0..db65e245d3 100644 --- a/openair2/COMMON/mac_messages_types.h +++ b/openair2/COMMON/mac_messages_types.h @@ -109,6 +109,7 @@ typedef struct NRRrcMacBcchDataInd_s { uint32_t sdu_size; uint8_t sdu[BCCH_SDU_SIZE]; uint8_t gnb_index; + bool is_bch; uint8_t rsrq; uint8_t rsrp; } NRRrcMacBcchDataInd; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index c15a5cd194..cfc32354e6 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -492,7 +492,6 @@ typedef struct Type0_PDCCH_CSS_config_s { int sfn_c; uint32_t n_c; uint32_t n_0; - uint32_t number_of_search_space_per_slot; uint32_t first_symbol_index; uint32_t search_space_duration; uint32_t search_space_frame_period; // in slots diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index e9fa641a07..8ed2b0d0ba 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -4106,8 +4106,8 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD int nr_band, uint32_t ssb_index, uint32_t ssb_period, - uint32_t ssb_offset_point_a) { - + uint32_t ssb_offset_point_a) +{ NR_SubcarrierSpacing_t scs_pdcch; channel_bandwidth_t min_channel_bw; @@ -4303,7 +4303,6 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD float big_m = 0.0f; type0_PDCCH_CSS_config->sfn_c = -1; // only valid for mux=1 type0_PDCCH_CSS_config->n_c = UINT_MAX; - type0_PDCCH_CSS_config->number_of_search_space_per_slot = UINT_MAX; type0_PDCCH_CSS_config->first_symbol_index = UINT_MAX; type0_PDCCH_CSS_config->search_space_duration = 0; // element of search space // 38.213 table 10.1-1 @@ -4311,7 +4310,6 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD /// MUX PATTERN 1 if(type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern == 1 && frequency_range == FR1){ big_o = table_38213_13_11_c1[index_4lsb]; - type0_PDCCH_CSS_config->number_of_search_space_per_slot = table_38213_13_11_c2[index_4lsb]; big_m = table_38213_13_11_c3[index_4lsb]; uint32_t temp = (uint32_t)(big_o*(1<ssb_index*big_m); @@ -4331,7 +4329,6 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD if(type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern == 1 && frequency_range == FR2){ big_o = table_38213_13_12_c1[index_4lsb]; - type0_PDCCH_CSS_config->number_of_search_space_per_slot = table_38213_13_12_c2[index_4lsb]; big_m = table_38213_13_12_c3[index_4lsb]; uint32_t temp = (uint32_t)(big_o*(1<ssb_index*big_m); @@ -4448,25 +4445,11 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD type0_PDCCH_CSS_config->search_space_frame_period = ssb_period*nr_slots_per_frame[scs_ssb]; } - AssertFatal(type0_PDCCH_CSS_config->number_of_search_space_per_slot!=UINT_MAX,""); - -// uint32_t coreset_duration = num_symbols * number_of_search_space_per_slot; -// mac->type0_pdcch_dci_config.number_of_candidates[0] = table_38213_10_1_1_c2[0]; -// mac->type0_pdcch_dci_config.number_of_candidates[1] = table_38213_10_1_1_c2[1]; -// mac->type0_pdcch_dci_config.number_of_candidates[2] = table_38213_10_1_1_c2[2]; // CCE aggregation level = 4 -// mac->type0_pdcch_dci_config.number_of_candidates[3] = table_38213_10_1_1_c2[3]; // CCE aggregation level = 8 -// mac->type0_pdcch_dci_config.number_of_candidates[4] = table_38213_10_1_1_c2[4]; // CCE aggregation level = 16 -// mac->type0_pdcch_dci_config.duration = search_space_duration; -// mac->type0_pdcch_dci_config.coreset.duration = coreset_duration; // coreset -// AssertFatal(first_symbol_index!=UINT_MAX,""); -// mac->type0_pdcch_dci_config.monitoring_symbols_within_slot = (0x3fff << first_symbol_index) & (0x3fff >> (14-coreset_duration-first_symbol_index)) & 0x3fff; - AssertFatal(type0_PDCCH_CSS_config->sfn_c >= 0, ""); AssertFatal(type0_PDCCH_CSS_config->n_c != UINT_MAX, ""); type0_PDCCH_CSS_config->n_0 = ((uint32_t)(big_o*(1<ssb_index*big_m))%num_slot_per_frame; type0_PDCCH_CSS_config->cset_start_rb = ssb_offset_point_a - type0_PDCCH_CSS_config->rb_offset; - } void fill_coresetZero(NR_ControlResourceSet_t *coreset0, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config) { @@ -4522,7 +4505,10 @@ void fill_coresetZero(NR_ControlResourceSet_t *coreset0, NR_Type0_PDCCH_CSS_conf } -void fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config) { +void fill_searchSpaceZero(NR_SearchSpace_t *ss0, + int slots_per_frame, + NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config) +{ if(ss0 == NULL) ss0=calloc(1,sizeof(*ss0)); if(ss0->controlResourceSetId == NULL) ss0->controlResourceSetId=calloc(1,sizeof(*ss0->controlResourceSetId)); @@ -4537,8 +4523,9 @@ void fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *ty AssertFatal(type0_PDCCH_CSS_config!=NULL,"No type0 CSS configuration\n"); const uint32_t periodicity = type0_PDCCH_CSS_config->search_space_frame_period; - const uint32_t offset = type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern == 1 - ? type0_PDCCH_CSS_config->n_0 : type0_PDCCH_CSS_config->n_c; + const uint32_t offset = type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern == 1 ? + type0_PDCCH_CSS_config->n_0 + (slots_per_frame * type0_PDCCH_CSS_config->sfn_c) : + type0_PDCCH_CSS_config->n_c; ss0->searchSpaceId = 0; *ss0->controlResourceSetId = 0; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index ccb630f63d..e2e97e0964 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -228,7 +228,9 @@ NR_tda_info_t get_info_from_tda_tables(default_table_type_t table_type, default_table_type_t get_default_table_type(int mux_pattern); void fill_coresetZero(NR_ControlResourceSet_t *coreset0, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config); -void fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config); +void fill_searchSpaceZero(NR_SearchSpace_t *ss0, + int slots_per_frame, + NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config); uint8_t get_pusch_nb_antenna_ports(NR_PUSCH_Config_t *pusch_Config, NR_SRS_Config_t *srs_config, diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index b5c3e87a65..a04606b7e2 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -713,6 +713,8 @@ void nr_rrc_mac_config_req_mib(module_id_t module_id, mac->get_sib1 = true; else if (sched_sib == 2) mac->get_otherSI = true; + nr_ue_decode_mib(module_id, + cc_idP); } void nr_rrc_mac_config_req_sib1(module_id_t module_id, diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 5051d92143..596354223f 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -477,6 +477,8 @@ typedef struct { RA_config_t ra; /// SSB index from MIB decoding uint8_t mib_ssb; + uint32_t mib_additional_bits; + int mib_frame; nr_csi_report_t csi_report_template[MAX_CSI_REPORTCONFIG]; @@ -510,6 +512,7 @@ typedef struct { frequency_range_t frequency_range; uint16_t nr_band; uint8_t ssb_subcarrier_offset; + int ssb_start_subcarrier; NR_SSB_meas_t ssb_measurements; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 09d85cb7a2..383880bcb2 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -47,27 +47,7 @@ void nr_ue_init_mac(module_id_t module_idP); \param mac mac instance */ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac); -/**\brief decode mib pdu in NR_UE, from if_module ul_ind with P7 tx_ind message - \param module_id module id - \param cc_id component carrier id - \param gNB_index gNB index - \param phy_data PHY structure to be filled in by the callee in the FAPI call (L1 caller -> indication to L2 -> FAPI call to L1 callee) - \param extra_bits extra bits for frame calculation - \param l_ssb_equal_64 check if ssb number of candicate is equal 64, 1=equal; 0=non equal. Reference 38.212 7.1.1 - \param pduP pointer to pdu - \param pdu_length length of pdu - \param cell_id cell id */ -int8_t nr_ue_decode_mib( - module_id_t module_id, - int cc_id, - uint8_t gNB_index, - void *phy_data, - uint8_t extra_bits, - uint32_t ssb_length, - uint32_t ssb_index, - void *pduP, - uint16_t ssb_start_subcarrier, - uint16_t cell_id ); +int8_t nr_ue_decode_mib(module_id_t module_id, int cc_id); /**\brief decode SIB1 and other SIs pdus in NR_UE, from if_module dl_ind \param module_id module id @@ -341,16 +321,6 @@ void nr_ue_msg3_scheduler(NR_UE_MAC_INST_t *mac, sub_frame_t current_slot, uint8_t Msg3_tda_id); -void nr_ue_sib1_scheduler(module_id_t module_idP, - int cc_id, - uint16_t ssb_start_symbol, - uint16_t frame, - uint8_t ssb_subcarrier_offset, - uint32_t ssb_index, - uint16_t ssb_start_subcarrier, - frequency_range_t frequency_range, - void *phy_data); - /* \brief Function called by PHY to process the received RAR and check that the preamble matches what was sent by the gNB. It provides the timing advance and t-CRNTI. @param Mod_id Index of UE instance @param CC_id Index to a component carrier diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index b69097ae8e..efcbd7e2ff 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -425,7 +425,39 @@ bool monitior_dci_for_other_SI(NR_UE_MAC_INST_t *mac, void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, const frame_t frame, const int slot) { const NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; - const int slots_per_frame = nr_slots_per_frame[current_DL_BWP->scs]; + int scs = mac->get_sib1 ? get_softmodem_params()->numerology : current_DL_BWP->scs; + const int slots_per_frame = nr_slots_per_frame[scs]; + if (mac->get_sib1) { + int ssb_sc_offset_norm; + if (mac->ssb_subcarrier_offset < 24 && mac->frequency_range == FR1) + ssb_sc_offset_norm = mac->ssb_subcarrier_offset >> scs; + else + ssb_sc_offset_norm = mac->ssb_subcarrier_offset; + uint16_t ssb_offset_point_a = (mac->ssb_start_subcarrier - ssb_sc_offset_norm) / 12; + int ssb_start_symbol = get_ssb_start_symbol(mac->nr_band, scs, mac->mib_ssb); + get_type0_PDCCH_CSS_config_parameters(&mac->type0_PDCCH_CSS_config, + mac->mib_frame, + mac->mib, + slots_per_frame, + ssb_sc_offset_norm, + ssb_start_symbol, + scs, + mac->frequency_range, + mac->nr_band, + mac->mib_ssb, + 1, // If the UE is not configured with a periodicity, the UE assumes a periodicity of a half frame + ssb_offset_point_a); + if(mac->search_space_zero == NULL) + mac->search_space_zero=calloc(1,sizeof(*mac->search_space_zero)); + if(mac->coreset0 == NULL) + mac->coreset0 = calloc(1,sizeof(*mac->coreset0)); + fill_coresetZero(mac->coreset0, &mac->type0_PDCCH_CSS_config); + fill_searchSpaceZero(mac->search_space_zero, slots_per_frame, &mac->type0_PDCCH_CSS_config); + if (is_ss_monitor_occasion(frame, slot, slots_per_frame, mac->search_space_zero)) { + LOG_D(NR_MAC, "Monitoring DCI for SIB1 in frame %d slot %d\n", frame, slot); + config_dci_pdu(mac, dl_config, NR_RNTI_SI, slot, mac->search_space_zero); + } + } if (mac->get_otherSI) { // If searchSpaceOtherSystemInformation is set to zero, // PDCCH monitoring occasions for SI message reception in SI-window diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 5d949f74f2..0bc0546fe4 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -246,51 +246,36 @@ int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti) int8_t nr_ue_decode_mib(module_id_t module_id, - int cc_id, - uint8_t gNB_index, - void *phy_data, - uint8_t extra_bits, // 8bits 38.212 c7.1.1 - uint32_t ssb_length, - uint32_t ssb_index, - void *pduP, - uint16_t ssb_start_subcarrier, - uint16_t cell_id) + int cc_id) { LOG_D(MAC,"[L2][MAC] decode mib\n"); NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); - mac->physCellId = cell_id; - - nr_mac_rrc_data_ind_ue(module_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_BCH, (uint8_t *) pduP, 3); // fixed 3 bytes MIB PDU - - AssertFatal(mac->mib != NULL, "nr_ue_decode_mib() mac->mib == NULL\n"); uint16_t frame = (mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused); uint16_t frame_number_4lsb = 0; - for (int i=0; i<4; i++) - frame_number_4lsb |= ((extra_bits>>i)&1)<<(3-i); + int extra_bits = mac->mib_additional_bits; + for (int i = 0; i < 4; i++) + frame_number_4lsb |= ((extra_bits >> i) & 1) << (3 - i); - uint8_t ssb_subcarrier_offset_msb = ( extra_bits >> 5 ) & 0x1; // extra bits[5] + uint8_t ssb_subcarrier_offset_msb = (extra_bits >> 5) & 0x1; // extra bits[5] uint8_t ssb_subcarrier_offset = (uint8_t)mac->mib->ssb_SubcarrierOffset; frame = frame << 4; - frame = frame | frame_number_4lsb; - if(ssb_length == 64){ - mac->frequency_range = FR2; - for (int i=0; i<3; i++) - ssb_index += (((extra_bits>>(7-i))&0x01)<<(3+i)); - }else{ - mac->frequency_range = FR1; - if(ssb_subcarrier_offset_msb){ + mac->mib_frame = frame | frame_number_4lsb; + if (mac->frequency_range == FR2) { + for (int i = 0; i < 3; i++) + mac->mib_ssb += (((extra_bits >> (7 - i)) & 0x01) << (3 + i)); + } else{ + if(ssb_subcarrier_offset_msb) ssb_subcarrier_offset = ssb_subcarrier_offset | 0x10; - } } #ifdef DEBUG_MIB - uint8_t half_frame_bit = ( extra_bits >> 4 ) & 0x1; // extra bits[4] + uint8_t half_frame_bit = (extra_bits >> 4) & 0x1; // extra bits[4] LOG_I(MAC,"system frame number(6 MSB bits): %d\n", mac->mib->systemFrameNumber.buf[0]); - LOG_I(MAC,"system frame number(with LSB): %d\n", (int)frame); + LOG_I(MAC,"system frame number(with LSB): %d\n", (int) mac->mib_frame); LOG_I(MAC,"subcarrier spacing (0=15or60, 1=30or120): %d\n", (int)mac->mib->subCarrierSpacingCommon); LOG_I(MAC,"ssb carrier offset(with MSB): %d\n", (int)ssb_subcarrier_offset); LOG_I(MAC,"dmrs type A position (0=pos2,1=pos3): %d\n", (int)mac->mib->dmrs_TypeA_Position); @@ -299,49 +284,13 @@ int8_t nr_ue_decode_mib(module_id_t module_id, LOG_I(MAC,"cell barred (0=barred,1=notBarred): %d\n", (int)mac->mib->cellBarred); LOG_I(MAC,"intra frequency reselection (0=allowed,1=notAllowed): %d\n", (int)mac->mib->intraFreqReselection); LOG_I(MAC,"half frame bit(extra bits): %d\n", (int)half_frame_bit); - LOG_I(MAC,"ssb index(extra bits): %d\n", (int)ssb_index); + LOG_I(MAC,"ssb index(extra bits): %d\n", (int)mac->mib_ssb); #endif - //storing ssb index in the mac structure - mac->mib_ssb = ssb_index; mac->ssb_subcarrier_offset = ssb_subcarrier_offset; - uint8_t scs_ssb; - uint32_t band; - uint16_t ssb_start_symbol; - - if (get_softmodem_params()->sa == 1) { - - scs_ssb = get_softmodem_params()->numerology; - band = mac->nr_band; - ssb_start_symbol = get_ssb_start_symbol(band,scs_ssb,ssb_index); - int ssb_sc_offset_norm; - if (ssb_subcarrier_offset<24 && mac->frequency_range == FR1) - ssb_sc_offset_norm = ssb_subcarrier_offset>>scs_ssb; - else - ssb_sc_offset_norm = ssb_subcarrier_offset; - - if (mac->get_sib1) { - nr_ue_sib1_scheduler(module_id, - cc_id, - ssb_start_symbol, - frame, - ssb_sc_offset_norm, - ssb_index, - ssb_start_subcarrier, - mac->frequency_range, - phy_data); - mac->first_sync_frame = frame; - } - } - else { - NR_ServingCellConfigCommon_t *scc = mac->scc; - scs_ssb = *scc->ssbSubcarrierSpacing; - band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; - ssb_start_symbol = get_ssb_start_symbol(band,scs_ssb,ssb_index); - if (mac->first_sync_frame == -1) - mac->first_sync_frame = frame; - } + if (mac->first_sync_frame == -1) + mac->first_sync_frame = frame; if(get_softmodem_params()->phy_test) mac->state = UE_CONNECTED; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 33201d8921..defaf6c37d 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -2648,72 +2648,6 @@ static void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_fr } // if is_nr_UL_slot } -// This function schedules the reception of SIB1 after initial sync and before going to real time state -void nr_ue_sib1_scheduler(module_id_t module_idP, - int cc_id, - uint16_t ssb_start_symbol, - uint16_t frame, - uint8_t ssb_subcarrier_offset, - uint32_t ssb_index, - uint16_t ssb_start_subcarrier, - frequency_range_t frequency_range, - void *phy_data) { - - NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); - nr_scheduled_response_t scheduled_response; - - uint8_t scs_ssb = get_softmodem_params()->numerology; - uint16_t ssb_offset_point_a = (ssb_start_subcarrier - ssb_subcarrier_offset)/12; - - get_type0_PDCCH_CSS_config_parameters(&mac->type0_PDCCH_CSS_config, - frame, - mac->mib, - nr_slots_per_frame[scs_ssb], - ssb_subcarrier_offset, - ssb_start_symbol, - scs_ssb, - frequency_range, - mac->nr_band, - ssb_index, - 1, // If the UE is not configured with a periodicity, the UE assumes a periodicity of a half frame - ssb_offset_point_a); - - int frame_s,slot_s; - if(mac->type0_PDCCH_CSS_config.type0_pdcch_ss_mux_pattern == 1){ - // same frame as ssb - if ((mac->type0_PDCCH_CSS_config.frame & 0x1) == mac->type0_PDCCH_CSS_config.sfn_c) - frame_s = 0; - else - frame_s = 1; - slot_s = mac->type0_PDCCH_CSS_config.n_0; - } - else{ - frame_s = 0; // same frame as ssb - slot_s = mac->type0_PDCCH_CSS_config.n_c; - } - - if(mac->search_space_zero == NULL) - mac->search_space_zero=calloc(1,sizeof(*mac->search_space_zero)); - if(mac->coreset0 == NULL) - mac->coreset0 = calloc(1,sizeof(*mac->coreset0)); - fill_coresetZero(mac->coreset0, &mac->type0_PDCCH_CSS_config); - fill_searchSpaceZero(mac->search_space_zero, &mac->type0_PDCCH_CSS_config); - - fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request[0]; // Take the first dl_config_request for SIB1 - config_dci_pdu(mac, dl_config, NR_RNTI_SI, slot_s, mac->search_space_zero); - - LOG_D(MAC,"Calling fill_scheduled_response, type0_pdcch, num_pdus %d\n", dl_config->number_pdus); - fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, module_idP, cc_id, frame_s, slot_s, phy_data); - - if (dl_config->number_pdus) { - if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) - mac->if_module->scheduled_response(&scheduled_response); - } - else - AssertFatal(1==0,"Unable to find aggregation level for type0 CSS\n"); -} - - #define MAX_LCID 8 // NR_MAX_NUM_LCID shall be used but the mac_rlc_data_req function can fetch data for max 8 LCID typedef struct { uint8_t bsr_len; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 49d23185dc..5d36b7d51b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -290,8 +290,10 @@ static uint32_t schedule_control_sib1(module_id_t module_id, gNB_mac->sched_ctrlCommon = calloc(1,sizeof(*gNB_mac->sched_ctrlCommon)); gNB_mac->sched_ctrlCommon->search_space = calloc(1,sizeof(*gNB_mac->sched_ctrlCommon->search_space)); gNB_mac->sched_ctrlCommon->coreset = calloc(1,sizeof(*gNB_mac->sched_ctrlCommon->coreset)); - fill_searchSpaceZero(gNB_mac->sched_ctrlCommon->search_space,type0_PDCCH_CSS_config); - fill_coresetZero(gNB_mac->sched_ctrlCommon->coreset,type0_PDCCH_CSS_config); + fill_searchSpaceZero(gNB_mac->sched_ctrlCommon->search_space, + nr_slots_per_frame[*scc->ssbSubcarrierSpacing], + type0_PDCCH_CSS_config); + fill_coresetZero(gNB_mac->sched_ctrlCommon->coreset, type0_PDCCH_CSS_config); gNB_mac->cset0_bwp_start = type0_PDCCH_CSS_config->cset_start_rb; gNB_mac->cset0_bwp_size = type0_PDCCH_CSS_config->num_rbs; gNB_mac->sched_ctrlCommon->sched_pdcch = set_pdcch_structure(NULL, diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 45c4a5d5c5..8f269a5cd0 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -327,35 +327,37 @@ static void fill_mib_in_rx_ind(nfapi_nr_dl_tti_request_pdu_t *pdu_list, fapi_nr_ static bool is_my_dci(NR_UE_MAC_INST_t *mac, nfapi_nr_dl_dci_pdu_t *received_pdu) { - /* For multiple UEs, we need to be able to filter the rx'd messages by - the RNTI. The filtering is different between NSA mode and SA mode. - NSA mode has a two step CFRA procedure and SA has a 4 step procedure. - We only need to check if the rx'd RNTI doesnt match the CRNTI if the RAR - has been processed already, in NSA mode. - In SA, depending on the RA state, we can have a SIB (0xffff), RAR (0x10b), - Msg3 (TC_RNTI) or an actual DCI message (CRNTI). When we get Msg3, the - MAC instance of the UE still has a CRNTI = 0. We should only check if the - CRNTI doesnt match the received RNTI in SA mode if Msg3 has been processed - already. Only once the RA procedure succeeds is the CRNTI value updated - to the TC_RNTI. */ - if (get_softmodem_params()->nsa) - { - if (received_pdu->RNTI != mac->crnti && - (received_pdu->RNTI != mac->ra.ra_rnti || mac->ra.RA_RAPID_found)) - return false; - } - if (get_softmodem_params()->sa) - { - if (received_pdu->RNTI != mac->crnti && mac->ra.ra_state == RA_SUCCEEDED) - return false; - if (received_pdu->RNTI != mac->ra.t_crnti && mac->ra.ra_state == WAIT_CONTENTION_RESOLUTION) - return false; - if (received_pdu->RNTI != 0x10b && mac->ra.ra_state == WAIT_RAR) - return false; - if (received_pdu->RNTI != 0xFFFF && mac->ra.ra_state <= GENERATE_PREAMBLE) - return false; - } - return true; + /* For multiple UEs, we need to be able to filter the rx'd messages by + the RNTI. The filtering is different between NSA mode and SA mode. + NSA mode has a two step CFRA procedure and SA has a 4 step procedure. + We only need to check if the rx'd RNTI doesnt match the CRNTI if the RAR + has been processed already, in NSA mode. + In SA, depending on the RA state, we can have a SIB (0xffff), RAR (0x10b), + Msg3 (TC_RNTI) or an actual DCI message (CRNTI). When we get Msg3, the + MAC instance of the UE still has a CRNTI = 0. We should only check if the + CRNTI doesnt match the received RNTI in SA mode if Msg3 has been processed + already. Only once the RA procedure succeeds is the CRNTI value updated + to the TC_RNTI. */ + if (get_softmodem_params()->nsa) { + if (received_pdu->RNTI != mac->crnti && + (received_pdu->RNTI != mac->ra.ra_rnti || mac->ra.RA_RAPID_found)) + return false; + } + if (get_softmodem_params()->sa) { + if (mac->state == UE_NOT_SYNC) + return false; + if (received_pdu->RNTI == 0xFFFF && mac->scc_SIB) + return false; + if (received_pdu->RNTI != mac->crnti && mac->ra.ra_state == RA_SUCCEEDED) + return false; + if (received_pdu->RNTI != mac->ra.t_crnti && mac->ra.ra_state == WAIT_CONTENTION_RESOLUTION) + return false; + if (received_pdu->RNTI != 0x10b && mac->ra.ra_state == WAIT_RAR) + return false; + if (received_pdu->RNTI != 0xFFFF && mac->ra.ra_state <= GENERATE_PREAMBLE) + return false; + } + return true; } static void copy_dl_tti_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_nr_dl_tti_request_t *dl_tti_request) @@ -1037,19 +1039,18 @@ int handle_bcch_bch(module_id_t module_id, int cc_id, unsigned int gNB_index, void *phy_data, uint8_t *pduP, unsigned int additional_bits, uint32_t ssb_index, uint32_t ssb_length, - uint16_t ssb_start_subcarrier, uint16_t cell_id){ - - return nr_ue_decode_mib(module_id, - cc_id, - gNB_index, - phy_data, - additional_bits, - ssb_length, // Lssb = 64 is not support - ssb_index, - pduP, - ssb_start_subcarrier, - cell_id); - + uint16_t ssb_start_subcarrier, uint16_t cell_id) +{ + NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + mac->mib_ssb = ssb_index; + mac->physCellId = cell_id; + mac->mib_additional_bits = additional_bits; + if(ssb_length == 64) + mac->frequency_range = FR2; + else + mac->frequency_range = FR1; + nr_mac_rrc_data_ind_ue(module_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_BCH, (uint8_t *) pduP, 3); // fixed 3 bytes MIB PDU + return 0; } // L2 Abstraction Layer @@ -1149,11 +1150,9 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info) uint32_t ret_mask = 0x0; module_id_t module_id = dl_info->module_id; NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); - if ((!dl_info->dci_ind && !dl_info->rx_ind)) { // UL indication to schedule DCI reception - if (mac->phy_config_request_sent) - nr_ue_dl_scheduler(dl_info); + nr_ue_dl_scheduler(dl_info); } else { // UL indication after reception of DCI or DL PDU if (dl_info && dl_info->dci_ind && dl_info->dci_ind->number_of_dcis) { diff --git a/openair2/RRC/NR_UE/L2_interface_ue.c b/openair2/RRC/NR_UE/L2_interface_ue.c index 06fb26536e..d0fb36c475 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.c +++ b/openair2/RRC/NR_UE/L2_interface_ue.c @@ -61,11 +61,8 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, { sdu_size_t sdu_size = 0; - switch(channel){ + switch(channel) { case NR_BCCH_BCH: - AssertFatal(nr_rrc_ue_decode_NR_BCCH_BCH_Message(module_id, gNB_index, (uint8_t*)pduP, pdu_len) == 0, "UE decode BCCH-BCH error!\n"); - break; - case NR_BCCH_DL_SCH: if (pdu_len>0) { LOG_T(NR_RRC, "[UE %d] Received SDU for NR-BCCH-DL-SCH on SRB %u from gNB %d\n", module_id, channel & RAB_OFFSET, @@ -88,6 +85,7 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, NR_RRC_MAC_BCCH_DATA_IND (message_p).slot = slot; NR_RRC_MAC_BCCH_DATA_IND (message_p).sdu_size = sdu_size; NR_RRC_MAC_BCCH_DATA_IND (message_p).gnb_index = gNB_index; + NR_RRC_MAC_BCCH_DATA_IND (message_p).is_bch = (channel == NR_BCCH_BCH); itti_send_msg_to_task(TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE(module_id), message_p); } break; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 7c52c02bfa..892c48a734 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -547,6 +547,8 @@ bool check_si_validity(NR_UE_RRC_SI_INFO *SI_info, int si_type) int check_si_status(NR_UE_RRC_SI_INFO *SI_info) { + if (!get_softmodem_params()->sa) + return 0; // schedule reception of SIB1 if RRC doesn't have it if (!SI_info->sib1) return 1; @@ -2046,15 +2048,22 @@ void *rrc_nrue_task(void *args_p) break; case NR_RRC_MAC_BCCH_DATA_IND: - LOG_D(NR_RRC, "[UE %d] Received %s: frameP %d, gNB %d\n", ue_mod_id, ITTI_MSG_NAME (msg_p), - NR_RRC_MAC_BCCH_DATA_IND (msg_p).frame, NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index); - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, GNB_FLAG_NO, NOT_A_RNTI, NR_RRC_MAC_BCCH_DATA_IND (msg_p).frame, 0,NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index); - nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message (ctxt.module_id, - NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index, - NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu, - NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu_size, - NR_RRC_MAC_BCCH_DATA_IND (msg_p).rsrq, - NR_RRC_MAC_BCCH_DATA_IND (msg_p).rsrp); + LOG_D(NR_RRC, "[UE %d] Received %s: gNB %d\n", ue_mod_id, ITTI_MSG_NAME (msg_p), + NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index); + NRRrcMacBcchDataInd *bcch = &NR_RRC_MAC_BCCH_DATA_IND (msg_p); + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, GNB_FLAG_NO, NOT_A_RNTI, bcch->frame, 0, bcch->gnb_index); + if (bcch->is_bch) + nr_rrc_ue_decode_NR_BCCH_BCH_Message(ue_mod_id, + bcch->gnb_index, + bcch->sdu, + bcch->sdu_size); + else + nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(ctxt.module_id, + bcch->gnb_index, + bcch->sdu, + bcch->sdu_size, + bcch->rsrq, + bcch->rsrp); break; case NR_RRC_MAC_CCCH_DATA_IND: @@ -2144,7 +2153,7 @@ void *rrc_nrue_task(void *args_p) break; } LOG_D(NR_RRC, "[UE %d] RRC Status %d\n", ue_mod_id, nr_rrc_get_state(ue_mod_id)); - result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); + result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), msg_p); AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); msg_p = NULL; }