diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index 6e73a0f855..f73c1f2db3 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -472,8 +472,7 @@ typedef struct Type0_PDCCH_CSS_config_s { uint32_t type0_pdcch_ss_mux_pattern; uint16_t frame; int sfn_c; - uint32_t n_c; - uint32_t n_0; + uint32_t 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 563b3f2ca2..917c00ec6b 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -3726,8 +3726,8 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD // type0-pdcch search space float big_o = 0.0f; 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->sfn_c = 0; // only valid for mux=1 + type0_PDCCH_CSS_config->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 @@ -3738,9 +3738,9 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD big_o = table_38213_13_11_c1[index_4lsb]; big_m = table_38213_13_11_c3[index_4lsb]; - uint32_t temp = (uint32_t)(big_o*(1<ssb_index*big_m); - type0_PDCCH_CSS_config->n_c = temp / num_slot_per_frame; - type0_PDCCH_CSS_config->sfn_c = type0_PDCCH_CSS_config->n_c % 2; + uint32_t temp = (uint32_t)(big_o * (1 << scs_pdcch)) + (uint32_t)(type0_PDCCH_CSS_config->ssb_index * big_m); + type0_PDCCH_CSS_config->slot = temp % num_slot_per_frame; + type0_PDCCH_CSS_config->sfn_c = (temp / num_slot_per_frame) % 2; if((index_4lsb == 1 || index_4lsb == 3 || index_4lsb == 5 || index_4lsb == 7) && (type0_PDCCH_CSS_config->ssb_index&1)){ type0_PDCCH_CSS_config->first_symbol_index = type0_PDCCH_CSS_config->num_symbols; @@ -3757,9 +3757,9 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD big_o = table_38213_13_12_c1[index_4lsb]; big_m = table_38213_13_12_c3[index_4lsb]; - uint32_t temp = (uint32_t)(big_o*(1<ssb_index*big_m); - type0_PDCCH_CSS_config->n_c = temp / num_slot_per_frame; - type0_PDCCH_CSS_config->sfn_c = type0_PDCCH_CSS_config->n_c % 2; + uint32_t temp = (uint32_t)(big_o * (1 << scs_pdcch)) + (uint32_t)(type0_PDCCH_CSS_config->ssb_index * big_m); + type0_PDCCH_CSS_config->slot = temp % num_slot_per_frame; + type0_PDCCH_CSS_config->sfn_c = (temp / num_slot_per_frame) % 2; if((index_4lsb == 1 || index_4lsb == 3 || index_4lsb == 5 || index_4lsb == 10) && (type0_PDCCH_CSS_config->ssb_index&1)){ type0_PDCCH_CSS_config->first_symbol_index = 7; @@ -3782,7 +3782,7 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD AssertFatal(index_4lsb == 0, "38.213 Table 13-13 4 LSB out of range\n"); // PDCCH monitoring occasions (SFN and slot number) same as SSB frame-slot // sfn_c = SFN_C_EQ_SFN_SSB; - type0_PDCCH_CSS_config->n_c = ssb_slot; + type0_PDCCH_CSS_config->slot = ssb_slot; switch(type0_PDCCH_CSS_config->ssb_index & 0x3){ // ssb_index(i) mod 4 case 0: type0_PDCCH_CSS_config->first_symbol_index = 0; @@ -3804,7 +3804,7 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD AssertFatal(index_4lsb == 0, "38.213 Table 13-14 4 LSB out of range\n"); // PDCCH monitoring occasions (SFN and slot number) same as SSB frame-slot // sfn_c = SFN_C_EQ_SFN_SSB; - type0_PDCCH_CSS_config->n_c = ssb_slot; + type0_PDCCH_CSS_config->slot = ssb_slot; switch(type0_PDCCH_CSS_config->ssb_index & 0x7){ // ssb_index(i) mod 8 case 0: type0_PDCCH_CSS_config->first_symbol_index = 0; @@ -3820,11 +3820,11 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD break; case 4: type0_PDCCH_CSS_config->first_symbol_index = 12; - type0_PDCCH_CSS_config->n_c = ssb_slot - 1; + type0_PDCCH_CSS_config->slot = ssb_slot - 1; break; case 5: type0_PDCCH_CSS_config->first_symbol_index = 13; - type0_PDCCH_CSS_config->n_c = ssb_slot - 1; + type0_PDCCH_CSS_config->slot = ssb_slot - 1; break; case 6: type0_PDCCH_CSS_config->first_symbol_index = 0; @@ -3848,7 +3848,7 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD AssertFatal(index_4lsb == 0, "38.213 Table 13-15 4 LSB out of range\n"); // PDCCH monitoring occasions (SFN and slot number) same as SSB frame-slot // sfn_c = SFN_C_EQ_SFN_SSB; - type0_PDCCH_CSS_config->n_c = ssb_slot; + type0_PDCCH_CSS_config->slot = ssb_slot; switch(type0_PDCCH_CSS_config->ssb_index & 0x3){ // ssb_index(i) mod 4 case 0: type0_PDCCH_CSS_config->first_symbol_index = 4; @@ -3870,11 +3870,8 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD // SSB periodicity in slots type0_PDCCH_CSS_config->search_space_frame_period = ssb_period * slots_per_frame; } + AssertFatal(type0_PDCCH_CSS_config->slot != UINT_MAX, "type0_PDCCH_CSS_config slot not configured"); - 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; AssertFatal(type0_PDCCH_CSS_config->cset_start_rb >= 0, "Invalid CSET0 start PRB %d SSB offset point A %d RB offset %d\n", type0_PDCCH_CSS_config->cset_start_rb, ssb_offset_point_a, type0_PDCCH_CSS_config->rb_offset); @@ -3950,8 +3947,8 @@ void fill_searchSpaceZero(NR_SearchSpace_t *ss0, int slots_per_frame, NR_Type0_P 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 + (slots_per_frame * type0_PDCCH_CSS_config->sfn_c) : - type0_PDCCH_CSS_config->n_c; + type0_PDCCH_CSS_config->slot + (slots_per_frame * type0_PDCCH_CSS_config->sfn_c) : + type0_PDCCH_CSS_config->slot; ss0->searchSpaceId = 0; *ss0->controlResourceSetId = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 6dd4886911..9f661984d0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -85,7 +85,7 @@ static void schedule_ssb(frame_t frame, dl_config_pdu->ssb_pdu.ssb_pdu_rel15.precoding_and_beamforming.prgs_list[0].dig_bf_interface_list[0].beam_idx = beam_index; dl_req->nPDUs++; - LOG_D(MAC,"Scheduling ssb %d at frame %d and slot %d\n", i_ssb, frame, slot); + LOG_D(NR_MAC,"Scheduling ssb %d at frame %d and slot %d\n", i_ssb, frame, slot); } static void fill_ssb_vrb_map(NR_COMMON_channels_t *cc, @@ -521,6 +521,19 @@ static bool check_sib1_tda(gNB_MAC_INST *gNB_mac, } } +static bool check_frame_sib1(NR_ServingCellConfigCommon_t *scc, NR_Type0_PDCCH_CSS_config_t *type0, int frame) +{ + if (type0->type0_pdcch_ss_mux_pattern == 1) + return frame % 2 == type0->sfn_c; + else { + long ssb_period = *scc->ssb_periodicityServingCell; + int ssb_frame_periodicity = 1; // every how many frames SSB are generated + if (ssb_period > 1) // 0 is every half frame + ssb_frame_periodicity = 1 << (ssb_period -1); + return frame % ssb_frame_periodicity == 0; + } +} + void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, slot_t slotP, @@ -553,13 +566,14 @@ void schedule_nr_sib1(module_id_t module_idP, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = &gNB_mac->type0_PDCCH_CSS_config[i]; - if((frameP % 2 == type0_PDCCH_CSS_config->sfn_c) && - (slotP == type0_PDCCH_CSS_config->n_0) && + if(check_frame_sib1(scc, type0_PDCCH_CSS_config, frameP) && + (slotP == type0_PDCCH_CSS_config->slot) && (type0_PDCCH_CSS_config->num_rbs > 0) && (type0_PDCCH_CSS_config->active == true)) { AssertFatal(is_dl_slot(slotP, &gNB_mac->frame_structure), - "Trying to schedule SIB1 in slot %d which is not DL. Check searchSpaceZero configuration.\n", + "Trying to schedule SIB1 for SSB %d in slot %d which is not DL. Check searchSpaceZero configuration.\n", + type0_PDCCH_CSS_config->ssb_index, slotP); const int n_slots_frame = gNB_mac->frame_structure.numb_slots_frame; int beam_index = get_beam_from_ssbidx(gNB_mac, i);