From f5a1d356dbd5ee87bdc4d4bce22041897e92a851 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 26 Mar 2021 11:27:44 +0100 Subject: [PATCH] Refactor after merge With the merge of fix_NR_DLUL_PF, gNB_dlsch_ulsch_scheduler() has no nb_periods_per_frame variable. There are two changes here: 1) calculate this locally for initializing tdd_beam_association 2) do not pass it into schedule_nr_mib(). Further, use the following: nb_periods_per_frame = slots_per_frame / slots_per_period slots_per_frame / nb_periods_per_frame = = slots_per_frame / (slots_per_frame / slots_per_period) = slots_per_period --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 7 ++++++- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 14 +++++++------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 6 +----- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 8d1e899fcb..60f51ee030 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -331,6 +331,11 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; if (slot==0 && (*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]>=257)) { + const NR_TDD_UL_DL_Pattern_t *tdd = &scc->tdd_UL_DL_ConfigurationCommon->pattern1; + const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; + const int nr_mix_slots = tdd->nrofDownlinkSymbols != 0 || tdd->nrofUplinkSymbols != 0; + const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + nr_mix_slots; + const int nb_periods_per_frame = n / nr_slots_period; // re-initialization of tdd_beam_association at beginning of frame (only for FR2) for (int i=0; itdd_beam_association[i] = -1; @@ -374,7 +379,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, // This schedules MIB - schedule_nr_mib(module_idP, frame, slot, nr_slots_per_frame[*scc->ssbSubcarrierSpacing],nb_periods_per_frame); + schedule_nr_mib(module_idP, frame, slot); // This schedules SIB1 if ( get_softmodem_params()->sa == 1 ) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 3c90bf709b..8eb3fa32d5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -58,12 +58,8 @@ uint8_t SSB_Slot[64]={0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7, 20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27, 30,30,31,31,32,32,33,33,34,34,35,35,36,36,37,37}; -void schedule_nr_mib(module_id_t module_idP, - frame_t frameP, - sub_frame_t slotP, - uint8_t slots_per_frame, - int nb_periods_per_frame){ - +void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) +{ gNB_MAC_INST *gNB = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc; @@ -78,6 +74,7 @@ void schedule_nr_mib(module_id_t module_idP, for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { cc = &gNB->common_channels[CC_id]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; + const int slots_per_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; const long band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; const uint32_t ssb_offset0 = *scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA; int ratio; @@ -244,6 +241,9 @@ void schedule_nr_mib(module_id_t module_idP, AssertFatal(0,"SSB bitmap size value %d undefined (allowed values 1,2,3)\n", scc->ssb_PositionsInBurst->present); } + const NR_TDD_UL_DL_Pattern_t *tdd = &scc->tdd_UL_DL_ConfigurationCommon->pattern1; + const int nr_mix_slots = tdd->nrofDownlinkSymbols != 0 || tdd->nrofUplinkSymbols != 0; + const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + nr_mix_slots; // For FR2 beam ssb association at the beginning of every SSB period if((scc->ssb_PositionsInBurst->present==3) && (abs_slot%slot_per_period == 0)){ uint8_t i_ssb,num_tdd_period; @@ -251,7 +251,7 @@ void schedule_nr_mib(module_id_t module_idP, for (int i=0; i<64; i++){ i_ssb=((longBitmap->buf[i/8])>>(7-(i%8)))&1; if(i_ssb==1){ - num_tdd_period = SSB_Slot[i]/(slots_per_frame/nb_periods_per_frame); + num_tdd_period = SSB_Slot[i]/nr_slots_period; gNB->tdd_beam_association[num_tdd_period]=num_ssb; num_ssb++; } diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index dd4ec15539..2af49b8217 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -86,11 +86,7 @@ void schedule_control_sib1(module_id_t module_id, void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP); -void schedule_nr_mib(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - uint8_t slots_per_frame, - int nb_periods_per_frame); +void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP); /* \brief main UL scheduler function. Calls a preprocessor to decide on * resource allocation, then "post-processes" resource allocation (nFAPI