From bd7d007ea83c89f963c2b9a5643151fc138b8fce Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 12 Feb 2025 14:44:40 +0100 Subject: [PATCH] remove global slots_per_frame, use function instead --- openair1/SIMULATION/NR_PHY/dlsim.c | 2 +- openair1/SIMULATION/NR_PHY/ulsim.c | 2 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 13 ++++++------- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 2 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common_tdd.c | 11 ++++++++--- openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h | 2 -- openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 4 ++-- openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c | 2 +- openair2/LAYER2/NR_MAC_gNB/config.c | 2 +- 9 files changed, 21 insertions(+), 19 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 09b18447f8..646158b80d 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -862,7 +862,7 @@ printf("%d\n", slot); nr_l2_init_ue(1); UE_mac = get_mac_inst(0); - ue_init_config_request(UE_mac, nr_slots_per_frame[mu]); + ue_init_config_request(UE_mac, get_slots_per_frame_from_scs(mu)); UE->if_inst = nr_ue_if_module_init(0); UE->if_inst->scheduled_response = nr_ue_scheduled_response; diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 42f7908479..946274a7bd 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -741,7 +741,7 @@ int main(int argc, char *argv[]) nr_l2_init_ue(1); NR_UE_MAC_INST_t* UE_mac = get_mac_inst(0); - ue_init_config_request(UE_mac, nr_slots_per_frame[mu]); + ue_init_config_request(UE_mac, get_slots_per_frame_from_scs(mu)); UE->if_inst = nr_ue_if_module_init(0); UE->if_inst->scheduled_response = nr_ue_scheduled_response; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index a638573c9b..ccee11d37e 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -4129,6 +4129,7 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD // 38.213 table 10.1-1 /// MUX PATTERN 1 + int slots_per_frame = get_slots_per_frame_from_scs(scs_ssb); if(type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern == 1 && frequency_range == FR1){ big_o = table_38213_13_11_c1[index_4lsb]; big_m = table_38213_13_11_c3[index_4lsb]; @@ -4145,7 +4146,7 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD // 38.213 chapter 13: over two consecutive slots type0_PDCCH_CSS_config->search_space_duration = 2; // two frames - type0_PDCCH_CSS_config->search_space_frame_period = nr_slots_per_frame[scs_ssb]<<1; + type0_PDCCH_CSS_config->search_space_frame_period = slots_per_frame << 1; } if(type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern == 1 && frequency_range == FR2){ @@ -4166,7 +4167,7 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD // 38.213 chapter 13: over two consecutive slots type0_PDCCH_CSS_config->search_space_duration = 2; // two frames - type0_PDCCH_CSS_config->search_space_frame_period = nr_slots_per_frame[scs_ssb]<<1; + type0_PDCCH_CSS_config->search_space_frame_period = slots_per_frame << 1; } /// MUX PATTERN 2 @@ -4233,7 +4234,7 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD // 38.213 chapter 13: over one slot type0_PDCCH_CSS_config->search_space_duration = 1; // SSB periodicity in slots - type0_PDCCH_CSS_config->search_space_frame_period = ssb_period*nr_slots_per_frame[scs_ssb]; + type0_PDCCH_CSS_config->search_space_frame_period = ssb_period * slots_per_frame; } /// MUX PATTERN 3 @@ -4263,7 +4264,7 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD // 38.213 chapter 13: over one slot type0_PDCCH_CSS_config->search_space_duration = 1; // SSB periodicity in slots - type0_PDCCH_CSS_config->search_space_frame_period = ssb_period*nr_slots_per_frame[scs_ssb]; + type0_PDCCH_CSS_config->search_space_frame_period = ssb_period * slots_per_frame; } AssertFatal(type0_PDCCH_CSS_config->sfn_c >= 0, ""); @@ -4323,9 +4324,7 @@ void fill_coresetZero(NR_ControlResourceSet_t *coreset0, NR_Type0_PDCCH_CSS_conf coreset0->pdcch_DMRS_ScramblingID = NULL; } -void fill_searchSpaceZero(NR_SearchSpace_t *ss0, - int slots_per_frame, - 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) { AssertFatal(ss0, "SearchSpace0 should have been allocated outside of this function\n"); if(ss0->controlResourceSetId == NULL) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 31fe454fd3..cb0d5a9611 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -63,7 +63,7 @@ int16_t fill_dmrs_mask(const NR_PDSCH_Config_t *pdsch_Config, int startSymbol, mappingType_t mappingtype, int length); - +int get_slots_per_frame_from_scs(int scs); bool is_ul_slot(const slot_t slot, const frame_structure_t *fs); bool is_dl_slot(const slot_t slot, const frame_structure_t *fs); bool is_mixed_slot(const slot_t slot, const frame_structure_t *fs); diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common_tdd.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common_tdd.c index 3790a4893f..8720cbce8b 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common_tdd.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common_tdd.c @@ -24,7 +24,12 @@ #include "common/utils/nr/nr_common.h" #include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h" -const uint8_t nr_slots_per_frame[5] = {10, 20, 40, 80, 160}; +int get_slots_per_frame_from_scs(int scs) +{ + const int nr_slots_per_frame[5] = {10, 20, 40, 80, 160}; + return nr_slots_per_frame[scs]; +} + const float tdd_ms_period_pattern[] = {0.5, 0.625, 1.0, 1.25, 2.0, 2.5, 5.0, 10.0}; const float tdd_ms_period_ext[] = {3.0, 4.0}; @@ -188,7 +193,7 @@ void config_frame_structure(int mu, uint8_t frame_type, frame_structure_t *fs) { - fs->numb_slots_frame = nr_slots_per_frame[mu]; + fs->numb_slots_frame = get_slots_per_frame_from_scs(mu); fs->frame_type = frame_type; if (frame_type == TDD) { fs->numb_period_frame = get_nb_periods_per_frame(tdd_period); @@ -196,7 +201,7 @@ void config_frame_structure(int mu, config_tdd_patterns(tdd_UL_DL_ConfigurationCommon, fs); } else { // FDD fs->numb_period_frame = 1; - fs->numb_slots_period = nr_slots_per_frame[mu]; + fs->numb_slots_period = fs->numb_slots_frame; } AssertFatal(fs->numb_period_frame > 0, "Frame configuration cannot be configured!\n"); } diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h index e06ece8d00..f2f070bf23 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_extern.h @@ -37,8 +37,6 @@ /*#include "PHY/defs_common.h"*/ -extern const uint8_t nr_slots_per_frame[5]; - /* Scheduler */ extern RAN_CONTEXT_t RC; extern uint8_t nfapi_mode; diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 48d12840e5..9147249c1e 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -94,7 +94,7 @@ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac) // sf80 default for retxBSR_Timer sf10 for periodicBSR_Timer int mu = mac->current_UL_BWP ? mac->current_UL_BWP->scs : get_softmodem_params()->numerology; - int subframes_per_slot = nr_slots_per_frame[mu] / 10; + int subframes_per_slot = get_slots_per_frame_from_scs(mu) / 10; nr_timer_setup(&mac->scheduling_info.retxBSR_Timer, 80 * subframes_per_slot, 1); // 1 slot update rate nr_timer_setup(&mac->scheduling_info.periodicBSR_Timer, 10 * subframes_per_slot, 1); // 1 slot update rate @@ -139,7 +139,7 @@ NR_UE_MAC_INST_t *nr_l2_init_ue(int nb_inst) nr_ue_init_mac(mac); nr_ue_mac_default_configs(mac); if (IS_SA_MODE(get_softmodem_params())) - ue_init_config_request(mac, nr_slots_per_frame[get_softmodem_params()->numerology]); + ue_init_config_request(mac, get_slots_per_frame_from_scs(get_softmodem_params()->numerology)); } int rc = rlc_module_init(0); 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 debd5226be..f6e3129ce9 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -515,7 +515,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl NR_BWP_Id_t dl_bwp_id = current_DL_BWP ? current_DL_BWP->bwp_id : 0; NR_BWP_PDCCH_t *pdcch_config = &mac->config_BWP_PDCCH[dl_bwp_id]; int scs = current_DL_BWP ? current_DL_BWP->scs : get_softmodem_params()->numerology; - const int slots_per_frame = nr_slots_per_frame[scs]; + const int slots_per_frame = get_slots_per_frame_from_scs(scs); if (mac->get_sib1) { int ssb_sc_offset_norm; if (mac->ssb_subcarrier_offset < 24 && mac->frequency_range == FR1) diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 4b3b48a48a..862bf563df 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -769,7 +769,7 @@ void nr_mac_config_scc(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, c scc->ssb_PositionsInBurst->present); const int NTN_gNB_Koffset = get_NTN_Koffset(scc); - const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; + const int n = get_slots_per_frame_from_scs(*scc->ssbSubcarrierSpacing); const int size = n << (int)ceil(log2((NTN_gNB_Koffset + 13) / n + 1)); // 13 is upper limit for max_fb_time nrmac->vrb_map_UL_size = size;