diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 213263978a..8332c2352f 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -328,7 +328,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) free_and_zero(ch_info); } - if (is_nr_DL_slot(mac->tdd_UL_DL_ConfigurationCommon, slot)) { + if (is_dl_slot(slot, &mac->frame_structure)) { memset(&mac->dl_info, 0, sizeof(mac->dl_info)); mac->dl_info.cc_id = CC_id; mac->dl_info.gNB_index = gNB_id; @@ -342,7 +342,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); - if (is_nr_UL_slot(mac->tdd_UL_DL_ConfigurationCommon, ul_info.slot, mac->frame_type)) { + if (is_ul_slot(ul_info.slot, &mac->frame_structure)) { LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind()\n", ul_info.slot); nr_ue_ul_scheduler(mac, &ul_info); } diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index edc8d2d265..09b18447f8 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, mu); + ue_init_config_request(UE_mac, nr_slots_per_frame[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 788adce9ad..42f7908479 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, mu); + ue_init_config_request(UE_mac, nr_slots_per_frame[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 be6f87d1e8..a638573c9b 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -3553,73 +3553,6 @@ int ul_ant_bits(NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig, long transformPrec } } -static const int tdd_period_to_num[8] = {500, 625, 1000, 1250, 2000, 2500, 5000, 10000}; - -bool is_nr_DL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slot) -{ - if (tdd_UL_DL_ConfigurationCommon == NULL) - return true; - - int period1, period2 = 0; - if (tdd_UL_DL_ConfigurationCommon->pattern1.ext1 && - tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530) - period1 = 3000+*tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530; - else - period1 = tdd_period_to_num[tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity]; - - if (tdd_UL_DL_ConfigurationCommon->pattern2) { - if (tdd_UL_DL_ConfigurationCommon->pattern2->ext1 && - tdd_UL_DL_ConfigurationCommon->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530) - period2 = 3000 + *tdd_UL_DL_ConfigurationCommon->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530; - else - period2 = tdd_period_to_num[tdd_UL_DL_ConfigurationCommon->pattern2->dl_UL_TransmissionPeriodicity]; - } - int period = period1+period2; - int scs = tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing; - int slots = period * (1 << scs) / 1000; - int slots1 = period1 * (1 << scs) / 1000; - int slot_in_period = slot % slots; - if (slot_in_period < slots1) - return slot_in_period <= tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots; - else - return slot_in_period <= slots1 + tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSlots; -} - -bool is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slot, frame_type_t frame_type) -{ - // Note: condition on frame_type - // goal: the UL scheduler assumes mode is TDD therefore this hack is needed to make FDD work - if (frame_type == FDD) - return true; - if (tdd_UL_DL_ConfigurationCommon == NULL) - // before receiving TDD information all slots should be considered to be DL - return false; - - int period1, period2 = 0; - if (tdd_UL_DL_ConfigurationCommon->pattern1.ext1 && - tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530) - period1 = 3000 + *tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530; - else - period1 = tdd_period_to_num[tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity]; - - if (tdd_UL_DL_ConfigurationCommon->pattern2) { - if (tdd_UL_DL_ConfigurationCommon->pattern2->ext1 && - tdd_UL_DL_ConfigurationCommon->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530) - period2 = 3000 + *tdd_UL_DL_ConfigurationCommon->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530; - else - period2 = tdd_period_to_num[tdd_UL_DL_ConfigurationCommon->pattern2->dl_UL_TransmissionPeriodicity]; - } - int period = period1+period2; - int scs = tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing; - int slots = period * (1 << scs) / 1000; - int slots1 = period1 * (1 << scs) / 1000; - int slot_in_period = slot % slots; - if (slot_in_period < slots1) - return slot_in_period >= tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots; - else - return slot_in_period >= slots1+tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSlots; -} - int16_t fill_dmrs_mask(const NR_PDSCH_Config_t *pdsch_Config, int dci_format, int dmrs_TypeA_Position, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index f543b95057..31fe454fd3 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -64,9 +64,6 @@ int16_t fill_dmrs_mask(const NR_PDSCH_Config_t *pdsch_Config, mappingType_t mappingtype, int length); -bool is_nr_DL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slotP); -bool is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slotP, frame_type_t frame_type); - 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_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 732b4738b5..34f1eb6a98 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -106,9 +106,7 @@ void set_tdd_config_nr_ue(fapi_nr_tdd_table_t *tdd_table, } } -static void config_common_ue_sa(NR_UE_MAC_INST_t *mac, - NR_ServingCellConfigCommonSIB_t *scc, - int cc_idP) +static void config_common_ue_sa(NR_UE_MAC_INST_t *mac, NR_ServingCellConfigCommonSIB_t *scc, int cc_idP) { fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; mac->phy_config.Mod_id = mac->ue_id; @@ -166,10 +164,10 @@ static void config_common_ue_sa(NR_UE_MAC_INST_t *mac, } } - mac->frame_type = get_frame_type(mac->nr_band, get_softmodem_params()->numerology); + frame_type_t frame_type = get_frame_type(mac->nr_band, get_softmodem_params()->numerology); // cell config cfg->cell_config.phy_cell_id = mac->physCellId; - cfg->cell_config.frame_duplex_type = mac->frame_type; + cfg->cell_config.frame_duplex_type = frame_type; // SSB config cfg->ssb_config.ss_pbch_power = scc->ss_PBCH_BlockPower; @@ -191,6 +189,13 @@ static void config_common_ue_sa(NR_UE_MAC_INST_t *mac, } } + int period_idx = mac->tdd_UL_DL_ConfigurationCommon ? get_tdd_period_idx(mac->tdd_UL_DL_ConfigurationCommon) : 0; + config_frame_structure(get_softmodem_params()->numerology, + mac->tdd_UL_DL_ConfigurationCommon, + period_idx, + frame_type, + &mac->frame_structure); + // TDD Table Configuration if (cfg->cell_config.frame_duplex_type == TDD){ set_tdd_config_nr_ue(&cfg->tdd_table_1, cfg->ssb_config.scs_common, &mac->tdd_UL_DL_ConfigurationCommon->pattern1); @@ -214,7 +219,7 @@ static void config_common_ue_sa(NR_UE_MAC_INST_t *mac, else { // If absent, the UE applies the SCS as derived from the prach-ConfigurationIndex (for 839) int config_index = rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex; - const int64_t *prach_config_info_p = get_prach_config_info(mac->frequency_range, config_index, mac->frame_type); + const int64_t *prach_config_info_p = get_prach_config_info(mac->frequency_range, config_index, frame_type); int format = prach_config_info_p[0]; cfg->prach_config.prach_sub_c_spacing = format == 3 ? 5 : 4; } @@ -239,7 +244,9 @@ static void config_common_ue_sa(NR_UE_MAC_INST_t *mac, (get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing, frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing ) * i); prach_fd_occasion->prach_zero_corr_conf = rach_ConfigCommon->rach_ConfigGeneric.zeroCorrelationZoneConfig; prach_fd_occasion->num_root_sequences = compute_nr_root_seq(rach_ConfigCommon, - nb_preambles, mac->frame_type, mac->frequency_range); + nb_preambles, + frame_type, + mac->frequency_range); //prach_fd_occasion->num_unused_root_sequences = ??? } cfg->prach_config.ssb_per_rach = rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present-1; @@ -296,24 +303,22 @@ void configure_ntn_ta(module_id_t module_id, ntn_timing_advance_componets_t *ntn ntn_ta->ntn_params_changed = true; } -static void config_common_ue(NR_UE_MAC_INST_t *mac, - NR_ServingCellConfigCommon_t *scc, - int cc_idP) +static void config_common_ue(NR_UE_MAC_INST_t *mac, NR_ServingCellConfigCommon_t *scc, int cc_idP) { fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; mac->phy_config.Mod_id = mac->ue_id; mac->phy_config.CC_id = cc_idP; + frame_type_t frame_type = mac->frame_structure.frame_type; // carrier config LOG_D(MAC, "[UE %d] Entering UE Config Common\n", mac->ue_id); AssertFatal(scc->downlinkConfigCommon, "Not expecting downlinkConfigCommon to be NULL here\n"); - NR_FrequencyInfoDL_t *frequencyInfoDL = scc->downlinkConfigCommon->frequencyInfoDL; if (frequencyInfoDL) { // NeedM for inter-freq handover mac->nr_band = *frequencyInfoDL->frequencyBandList.list.array[0]; - mac->frame_type = get_frame_type(mac->nr_band, get_softmodem_params()->numerology); + frame_type = get_frame_type(mac->nr_band, get_softmodem_params()->numerology); mac->frequency_range = mac->nr_band < 256 ? FR1 : FR2; int bw_index = get_supported_band_index(frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing, @@ -371,7 +376,7 @@ static void config_common_ue(NR_UE_MAC_INST_t *mac, // cell config cfg->cell_config.phy_cell_id = *scc->physCellId; - cfg->cell_config.frame_duplex_type = mac->frame_type; + cfg->cell_config.frame_duplex_type = frame_type; // SSB config cfg->ssb_config.ss_pbch_power = scc->ss_PBCH_BlockPower; @@ -412,6 +417,13 @@ static void config_common_ue(NR_UE_MAC_INST_t *mac, AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", scc->ssb_PositionsInBurst->present); } + int period_idx = mac->tdd_UL_DL_ConfigurationCommon ? get_tdd_period_idx(mac->tdd_UL_DL_ConfigurationCommon) : 0; + config_frame_structure(*scc->ssbSubcarrierSpacing, + mac->tdd_UL_DL_ConfigurationCommon, + period_idx, + frame_type, + &mac->frame_structure); + // TDD Table Configuration if (cfg->cell_config.frame_duplex_type == TDD){ set_tdd_config_nr_ue(&cfg->tdd_table_1, cfg->ssb_config.scs_common, &mac->tdd_UL_DL_ConfigurationCommon->pattern1); @@ -437,7 +449,7 @@ static void config_common_ue(NR_UE_MAC_INST_t *mac, else { // If absent, the UE applies the SCS as derived from the prach-ConfigurationIndex (for 839) int config_index = rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex; - const int64_t *prach_config_info_p = get_prach_config_info(mac->frequency_range, config_index, mac->frame_type); + const int64_t *prach_config_info_p = get_prach_config_info(mac->frequency_range, config_index, frame_type); int format = prach_config_info_p[0]; cfg->prach_config.prach_sub_c_spacing = format == 3 ? 5 : 4; } @@ -461,7 +473,7 @@ static void config_common_ue(NR_UE_MAC_INST_t *mac, prach_fd_occasion->k1 = rach_ConfigCommon->rach_ConfigGeneric.msg1_FrequencyStart; prach_fd_occasion->prach_zero_corr_conf = rach_ConfigCommon->rach_ConfigGeneric.zeroCorrelationZoneConfig; prach_fd_occasion->num_root_sequences = - compute_nr_root_seq(rach_ConfigCommon, nb_preambles, mac->frame_type, mac->frequency_range); + compute_nr_root_seq(rach_ConfigCommon, nb_preambles, frame_type, mac->frequency_range); cfg->prach_config.ssb_per_rach = rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present - 1; // prach_fd_occasion->num_unused_root_sequences = ??? @@ -893,9 +905,8 @@ static void configure_logicalChannelBearer(NR_UE_MAC_INST_t *mac, } } -void ue_init_config_request(NR_UE_MAC_INST_t *mac, int scs) +void ue_init_config_request(NR_UE_MAC_INST_t *mac, int slots_per_frame) { - int slots_per_frame = nr_slots_per_frame[scs]; LOG_I(NR_MAC, "Initializing dl and ul config_request. num_slots = %d\n", slots_per_frame); mac->dl_config_request = calloc(slots_per_frame, sizeof(*mac->dl_config_request)); mac->ul_config_request = calloc(slots_per_frame, sizeof(*mac->ul_config_request)); @@ -2107,17 +2118,17 @@ static void configure_maccellgroup(NR_UE_MAC_INST_t *mac, const NR_MAC_CellGroup } } } + int slots_per_subframe = mac->frame_structure.numb_slots_frame / 10; if (mcg->bsr_Config) { - int subframes_per_slot = nr_slots_per_frame[scs] / 10; uint32_t periodic_sf = nr_get_sf_periodicBSRTimer(mcg->bsr_Config->periodicBSR_Timer); - uint32_t target = periodic_sf < UINT_MAX ? periodic_sf * subframes_per_slot : periodic_sf; + uint32_t target = periodic_sf < UINT_MAX ? periodic_sf * slots_per_subframe : periodic_sf; nr_timer_setup(&si->periodicBSR_Timer, target, 1); // 1 slot update rate nr_timer_start(&si->periodicBSR_Timer); uint32_t retx_sf = nr_get_sf_retxBSRTimer(mcg->bsr_Config->retxBSR_Timer); - nr_timer_setup(&si->retxBSR_Timer, retx_sf * subframes_per_slot, 1); // 1 slot update rate + nr_timer_setup(&si->retxBSR_Timer, retx_sf * slots_per_subframe, 1); // 1 slot update rate if (mcg->bsr_Config->logicalChannelSR_DelayTimer) { uint32_t dt_sf = get_sr_DelayTimer(*mcg->bsr_Config->logicalChannelSR_DelayTimer); - nr_timer_setup(&si->sr_DelayTimer, dt_sf * subframes_per_slot, 1); // 1 slot update rate + nr_timer_setup(&si->sr_DelayTimer, dt_sf * slots_per_subframe, 1); // 1 slot update rate } } if (mcg->tag_Config) { @@ -2151,7 +2162,6 @@ static void configure_maccellgroup(NR_UE_MAC_INST_t *mac, const NR_MAC_CellGroup nr_phr_info_t *phr_info = &si->phr_info; phr_info->is_configured = mcg->phr_Config->choice.setup != NULL; if (phr_info->is_configured) { - int slots_per_subframe = nr_slots_per_frame[scs] / 10; struct NR_PHR_Config *config = mcg->phr_Config->choice.setup; AssertFatal(config->multiplePHR == 0, "mulitplePHR not supported"); phr_info->PathlossChange_db = config->phr_Tx_PowerFactorChange; @@ -2644,9 +2654,7 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id, configure_timeAlignmentTimer(&mac->time_alignment_timer, mac->TAG_list.array[j]->timeAlignmentTimer, mac->current_UL_BWP->scs); } - configure_logicalChannelBearer(mac, - cell_group_config->rlc_BearerToAddModList, - cell_group_config->rlc_BearerToReleaseList); + configure_logicalChannelBearer(mac, cell_group_config->rlc_BearerToAddModList, cell_group_config->rlc_BearerToReleaseList); if (ue_Capability) handle_mac_uecap_info(mac, ue_Capability); @@ -2657,7 +2665,7 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id, build_ssb_to_ro_map(mac); if (!mac->dl_config_request || !mac->ul_config_request) - ue_init_config_request(mac, mac->current_DL_BWP->scs); + ue_init_config_request(mac, mac->frame_structure.numb_slots_frame); ret = pthread_mutex_unlock(&mac->if_mutex); AssertFatal(!ret, "mutex failed %d\n", ret); } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 55120dca96..7910fd2327 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -599,7 +599,7 @@ typedef struct NR_UE_MAC_INST_s { NR_UL_TIME_ALIGNMENT_t ul_time_alignment; NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon; - frame_type_t frame_type; + frame_structure_t frame_structure; /* Random Access */ /// CRNTI diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index dfda03e011..b310bd4590 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -367,7 +367,7 @@ int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *p void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac); -void ue_init_config_request(NR_UE_MAC_INST_t *mac, int scs); +void ue_init_config_request(NR_UE_MAC_INST_t *mac, int slots_per_frame); fapi_nr_dl_config_request_t *get_dl_config_request(NR_UE_MAC_INST_t *mac, int slot); @@ -376,7 +376,6 @@ void remove_ul_config_last_item(fapi_nr_ul_config_request_pdu_t *pdu); fapi_nr_ul_config_request_pdu_t *fapiLockIterator(fapi_nr_ul_config_request_t *ul_config, frame_t frame_tx, int slot_tx); void release_ul_config(fapi_nr_ul_config_request_pdu_t *pdu, bool clearIt); -void clear_ul_config_request(NR_UE_MAC_INST_t *mac, int scs); int16_t compute_nr_SSB_PL(NR_UE_MAC_INST_t *mac, short ssb_rsrp_dBm); // PUSCH scheduler: diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 4e9acbf355..48d12840e5 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -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, get_softmodem_params()->numerology); + ue_init_config_request(mac, nr_slots_per_frame[get_softmodem_params()->numerology]); } int rc = rlc_module_init(0); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 70e3019701..c5727acab8 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -84,7 +84,7 @@ void init_RA(NR_UE_MAC_INST_t *mac, // PRACH shall be as specified for QPSK modulated DFT-s-OFDM of equivalent RB allocation (38.101-1) prach_resources->RA_PCMAX = nr_get_Pcmax(mac->p_Max, mac->nr_band, - mac->frame_type, + mac->frame_structure.frame_type, mac->frequency_range, mac->current_UL_BWP->channel_bandwidth, 2, @@ -617,8 +617,7 @@ void nr_Msg3_transmitted(NR_UE_MAC_INST_t *mac, uint8_t CC_id, frame_t frameP, s RA_config_t *ra = &mac->ra; NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP->rach_ConfigCommon; const double ta_Common_ms = GET_COMPLETE_TIME_ADVANCE_MS(&mac->ntn_ta); - const int mu = mac->current_UL_BWP->scs; - const int slots_per_ms = nr_slots_per_frame[mu] / 10; + const int slots_per_ms = mac->frame_structure.numb_slots_frame / 10; // start contention resolution timer const int RA_contention_resolution_timer_ms = (nr_rach_ConfigCommon->ra_ContentionResolutionTimer + 1) << 3; @@ -914,14 +913,12 @@ int16_t nr_get_RA_window_4Step(const NR_RACH_ConfigCommon_t *rach_ConfigCommon) void nr_get_RA_window(NR_UE_MAC_INST_t *mac) { RA_config_t *ra = &mac->ra; - NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP->rach_ConfigCommon; AssertFatal(&setup->rach_ConfigGeneric != NULL, "In %s: FATAL! rach_ConfigGeneric is NULL...\n", __FUNCTION__); const double ta_Common_ms = GET_COMPLETE_TIME_ADVANCE_MS(&mac->ntn_ta); - const int mu = mac->current_DL_BWP->scs; - const int slots_per_ms = nr_slots_per_frame[mu] / 10; - - const int ra_Offset_slots = ra->RA_offset * nr_slots_per_frame[mu]; + int slots_per_frame = mac->frame_structure.numb_slots_frame; + const int slots_per_ms = slots_per_frame / 10; + const int ra_Offset_slots = ra->RA_offset * slots_per_frame; const int ta_Common_slots = (int)ceil(ta_Common_ms * slots_per_ms); ra->RA_window_cnt = ra_Offset_slots + ta_Common_slots; // taking into account the 2 frames gap introduced by OAI gNB diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_power_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_power_procedures.c index b277352105..7083b4a141 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_power_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_power_procedures.c @@ -347,7 +347,7 @@ int16_t get_pucch_tx_power_ue(NR_UE_MAC_INST_t *mac, // modulated CP-OFDM of equivalent RB allocation. int P_CMAX = nr_get_Pcmax(mac->p_Max, mac->nr_band, - mac->frame_type, + mac->frame_structure.frame_type, mac->frequency_range, current_UL_BWP->channel_bandwidth, 2, @@ -529,7 +529,7 @@ int get_pusch_tx_power_ue(NR_UE_MAC_INST_t *mac, int M_pusch_component = 10 * log10((pow(2, mu)) * num_rb); int P_CMAX = nr_get_Pcmax(mac->p_Max, mac->nr_band, - mac->frame_type, + mac->frame_structure.frame_type, mac->frequency_range, mac->current_UL_BWP->channel_bandwidth, qm, @@ -619,7 +619,7 @@ int get_srs_tx_power_ue(NR_UE_MAC_INST_t *mac, // allocation. int P_CMAX = nr_get_Pcmax(mac->p_Max, mac->nr_band, - mac->frame_type, + mac->frame_structure.frame_type, mac->frequency_range, mac->current_UL_BWP->channel_bandwidth, 2, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index c7ceeeab8e..3533c04a12 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -235,6 +235,7 @@ static void configure_ratematching_csi(fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsc int frame, int slot, int mu, + int slots_per_frame, NR_PDSCH_Config_t *pdsch_config) { // only for C-RNTI, MCS-C-RNTI, CS-RNTI (and only C-RNTI is supported for now) @@ -258,7 +259,7 @@ static void configure_ratematching_csi(fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsc AssertFatal(zp_res->periodicityAndOffset, "periodicityAndOffset cannot be null for periodic ZP resource\n"); int period, offset; csi_period_offset(NULL, zp_res->periodicityAndOffset, &period, &offset); - if((frame * nr_slots_per_frame[mu] + slot - offset) % period != 0) + if((frame * slots_per_frame + slot - offset) % period != 0) continue; AssertFatal(dlsch_pdu->numCsiRsForRateMatching < NFAPI_MAX_NUM_CSI_RATEMATCH, "csiRsForRateMatching out of bounds\n"); fapi_nr_dl_config_csirs_pdu_rel15_t *csi_pdu = &dlsch_pdu->csiRsForRateMatching[dlsch_pdu->numCsiRsForRateMatching]; @@ -705,7 +706,8 @@ static int nr_ue_process_dci_dl_10(NR_UE_MAC_INST_t *mac, } dlsch_pdu->numCsiRsForRateMatching = 0; - configure_ratematching_csi(dlsch_pdu, dl_config, rnti_type, frame, slot, dlsch_pdu->SubcarrierSpacing, pdsch_config); + int slots_frame = mac->frame_structure.numb_slots_frame; + configure_ratematching_csi(dlsch_pdu, dl_config, rnti_type, frame, slot, dlsch_pdu->SubcarrierSpacing, slots_frame, pdsch_config); /* IDENTIFIER_DCI_FORMATS */ @@ -1034,7 +1036,8 @@ static int nr_ue_process_dci_dl_11(NR_UE_MAC_INST_t *mac, nr_rnti_type_t rnti_type = get_rnti_type(mac, dci_ind->rnti); dlsch_pdu->numCsiRsForRateMatching = 0; - configure_ratematching_csi(dlsch_pdu, dl_config, rnti_type, frame, slot, current_DL_BWP->scs, pdsch_Config); + int slots_frame = mac->frame_structure.numb_slots_frame; + configure_ratematching_csi(dlsch_pdu, dl_config, rnti_type, frame, slot, current_DL_BWP->scs, slots_frame, pdsch_Config); /* IDENTIFIER_DCI_FORMATS */ /* CARRIER_IND */ @@ -1468,8 +1471,7 @@ void set_harq_status(NR_UE_MAC_INST_t *mac, current_harq->dai_cumul = 0; current_harq->delta_pucch = delta_pucch; // FIXME k0 != 0 currently not taken into consideration - int scs = mac->current_DL_BWP ? mac->current_DL_BWP->scs : get_softmodem_params()->numerology; - int slots_per_frame = nr_slots_per_frame[scs]; + int slots_per_frame = mac->frame_structure.numb_slots_frame; current_harq->ul_frame = frame; current_harq->ul_slot = slot + data_toul_fb; if (current_harq->ul_slot >= slots_per_frame) { @@ -1532,8 +1534,7 @@ int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, long *pusch_id = NULL; long *id0 = NULL; const int scs = current_UL_BWP->scs; - - int subframe_number = slot / (nr_slots_per_frame[scs]/10); + int subframe_number = slot / (mac->frame_structure.numb_slots_frame / 10); pucch_pdu->rnti = rnti; LOG_D(NR_MAC, "initial_pucch_id %d, pucch_resource %p\n", pucch->initial_pucch_id, pucch->pucch_resource); @@ -2503,7 +2504,7 @@ bool trigger_periodic_scheduling_request(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *p int SR_period; int SR_offset; find_period_offset_SR(sr_Config, &SR_period, &SR_offset); - const int n_slots_frame = nr_slots_per_frame[current_UL_BWP->scs]; + const int n_slots_frame = mac->frame_structure.numb_slots_frame; int sfn_sf = frame * n_slots_frame + slot; if ((sfn_sf - SR_offset) % SR_period == 0) { @@ -2613,7 +2614,7 @@ int nr_get_csi_measurements(NR_UE_MAC_INST_t *mac, frame_t frame, int slot, PUCC if(csirep->reportConfigType.present == NR_CSI_ReportConfig__reportConfigType_PR_periodic) { int period, offset; csi_period_offset(csirep, NULL, &period, &offset); - const int n_slots_frame = nr_slots_per_frame[current_UL_BWP->scs]; + const int n_slots_frame = mac->frame_structure.numb_slots_frame; if (((n_slots_frame*frame + slot - offset)%period) == 0 && pucch_Config) { int csi_res_id = -1; for (int i = 0; i < csirep->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list.count; i++) { @@ -3433,12 +3434,10 @@ static void set_time_alignment(NR_UE_MAC_INST_t *mac, int ta, ta_type_t type, in NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &mac->ul_time_alignment; ul_time_alignment->ta_command = ta; ul_time_alignment->ta_apply = type; - const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(&mac->ntn_ta, mac->current_UL_BWP->scs); - const int n_slots_frame = nr_slots_per_frame[mac->current_UL_BWP->scs]; + const int n_slots_frame = mac->frame_structure.numb_slots_frame; ul_time_alignment->frame = (frame + (slot + ntn_ue_koffset) / n_slots_frame) % MAX_FRAME_NUMBER; ul_time_alignment->slot = (slot + ntn_ue_koffset) % n_slots_frame; - // start or restart the timeAlignmentTimer associated with the indicated TAG nr_timer_start(&mac->time_alignment_timer); } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index aa00daf9c9..37224a6dfd 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -81,9 +81,9 @@ static uint8_t nr_ue_get_sdu(NR_UE_MAC_INST_t *mac, int P_MAX, bool *BSRsent); -void clear_ul_config_request(NR_UE_MAC_INST_t *mac, int scs) +static void clear_ul_config_request(NR_UE_MAC_INST_t *mac) { - int slots = nr_slots_per_frame[scs]; + int slots = mac->frame_structure.numb_slots_frame; for (int i = 0; i < slots ; i++) { fapi_nr_ul_config_request_t *ul_config = mac->ul_config_request + i; verifyMutex(pthread_mutex_lock(&ul_config->mutex_ul_config)); @@ -94,10 +94,8 @@ void clear_ul_config_request(NR_UE_MAC_INST_t *mac, int scs) fapi_nr_ul_config_request_pdu_t *lockGet_ul_config(NR_UE_MAC_INST_t *mac, frame_t frame_tx, int slot_tx, uint8_t pdu_type) { - NR_TDD_UL_DL_ConfigCommon_t *tdd_config = mac->tdd_UL_DL_ConfigurationCommon; - // Check if requested on the right slot - if (!is_nr_UL_slot(tdd_config, slot_tx, mac->frame_type)) { + if (!is_ul_slot(slot_tx, &mac->frame_structure)) { LOG_E(NR_MAC, "Lock of UL config for PDU type %d called for slot %d which is not UL\n", pdu_type, slot_tx); return NULL; } @@ -177,11 +175,10 @@ void handle_time_alignment_timer_expired(NR_UE_MAC_INST_t *mac) // release SRS for all Serving Cells; release_PUCCH_SRS(mac); // clear any configured downlink assignments and uplink grants; - int scs = mac->current_UL_BWP ? mac->current_UL_BWP->scs : get_softmodem_params()->numerology; if (mac->dl_config_request) memset(mac->dl_config_request, 0, sizeof(*mac->dl_config_request)); if (mac->ul_config_request) - clear_ul_config_request(mac, scs); + clear_ul_config_request(mac); // clear any PUSCH resources for semi-persistent CSI reporting // TODO we don't have semi-persistent CSI reporting // maintain N_TA @@ -284,9 +281,8 @@ fapi_nr_ul_config_request_pdu_t *fapiLockIterator(fapi_nr_ul_config_request_t *u fapi_nr_ul_config_request_pdu_t *lockGet_ul_iterator(NR_UE_MAC_INST_t *mac, frame_t frame_tx, int slot_tx) { - NR_TDD_UL_DL_ConfigCommon_t *tdd_config = mac->tdd_UL_DL_ConfigurationCommon; //Check if requested on the right slot - if (!is_nr_UL_slot(tdd_config, slot_tx, mac->frame_type)) { + if (!is_ul_slot(slot_tx, &mac->frame_structure)) { LOG_E(NR_MAC, "UL lock iterator called for slot %d which is not UL\n", slot_tx); return NULL; } @@ -1271,10 +1267,9 @@ void nr_ue_aperiodic_srs_scheduling(NR_UE_MAC_INST_t *mac, long resource_trigger AssertFatal(slot_offset > GET_DURATION_RX_TO_TX(&mac->ntn_ta), "Slot offset between DCI and aperiodic SRS (%d) needs to be higher than DURATION_RX_TO_TX (%ld)\n", slot_offset, GET_DURATION_RX_TO_TX(&mac->ntn_ta)); - int n_slots_frame = nr_slots_per_frame[current_UL_BWP->scs]; + int n_slots_frame = mac->frame_structure.numb_slots_frame; int sched_slot = (slot + slot_offset) % n_slots_frame; - NR_TDD_UL_DL_ConfigCommon_t *tdd_config = mac->tdd_UL_DL_ConfigurationCommon; - if (!is_nr_UL_slot(tdd_config, sched_slot, mac->frame_type)) { + if (!is_ul_slot(sched_slot, &mac->frame_structure)) { LOG_E(NR_MAC, "Slot for scheduling aperiodic SRS %d is not an UL slot\n", sched_slot); return; } @@ -1326,8 +1321,7 @@ static bool nr_ue_periodic_srs_scheduling(NR_UE_MAC_INST_t *mac, frame_t frame, uint16_t period = srs_period[srs_resource->resourceType.choice.periodic->periodicityAndOffset_p.present]; uint16_t offset = get_nr_srs_offset(srs_resource->resourceType.choice.periodic->periodicityAndOffset_p); - - int n_slots_frame = nr_slots_per_frame[current_UL_BWP->scs]; + int n_slots_frame = mac->frame_structure.numb_slots_frame; // Check if UE should transmit the SRS if((frame*n_slots_frame+slot-offset)%period == 0) { @@ -1409,11 +1403,10 @@ void schedule_RA_after_SR_failure(NR_UE_MAC_INST_t *mac) // release SRS for all Serving Cells; release_PUCCH_SRS(mac); // clear any configured downlink assignments and uplink grants; - int scs = mac->current_UL_BWP->scs; if (mac->dl_config_request) memset(mac->dl_config_request, 0, sizeof(*mac->dl_config_request)); if (mac->ul_config_request) - clear_ul_config_request(mac, scs); + clear_ul_config_request(mac); // clear any PUSCH resources for semi-persistent CSI reporting // TODO we don't have semi-persistent CSI reporting } @@ -1620,7 +1613,7 @@ void nr_ue_ul_scheduler(NR_UE_MAC_INST_t *mac, nr_uplink_indication_t *ul_info) int tx_power = pdu->tx_power; int P_CMAX = nr_get_Pcmax(mac->p_Max, mac->nr_band, - mac->frame_type, + mac->frame_structure.frame_type, mac->frequency_range, mac->current_UL_BWP->channel_bandwidth, pdu->qam_mod_order, @@ -1756,6 +1749,7 @@ int nr_ue_pusch_scheduler(const NR_UE_MAC_INST_t *mac, // Get the numerology to calculate the Tx frame and slot int mu = current_UL_BWP->scs; + int slots_per_frame = mac->frame_structure.numb_slots_frame; // k2 as per 3GPP TS 38.214 version 15.9.0 Release 15 ch 6.1.2.1.1 // PUSCH time domain resource allocation is higher layer configured from uschTimeDomainAllocationList in either pusch-ConfigCommon @@ -1786,9 +1780,8 @@ int nr_ue_pusch_scheduler(const NR_UE_MAC_INST_t *mac, GET_DURATION_RX_TO_TX(&mac->ntn_ta), GET_DURATION_RX_TO_TX(&mac->ntn_ta)); - *slot_tx = (current_slot + k2 + delta) % nr_slots_per_frame[mu]; - *frame_tx = (current_frame + (current_slot + k2 + delta) / nr_slots_per_frame[mu]) % MAX_FRAME_NUMBER; - + *slot_tx = (current_slot + k2 + delta) % slots_per_frame; + *frame_tx = (current_frame + (current_slot + k2 + delta) / slots_per_frame) % MAX_FRAME_NUMBER; } else { AssertFatal(k2 > GET_DURATION_RX_TO_TX(&mac->ntn_ta), @@ -1804,13 +1797,11 @@ int nr_ue_pusch_scheduler(const NR_UE_MAC_INST_t *mac, } // Calculate TX slot and frame - *slot_tx = (current_slot + k2) % nr_slots_per_frame[mu]; - *frame_tx = (current_frame + (current_slot + k2) / nr_slots_per_frame[mu]) % MAX_FRAME_NUMBER; - + *slot_tx = (current_slot + k2) % slots_per_frame; + *frame_tx = (current_frame + (current_slot + k2) / slots_per_frame) % MAX_FRAME_NUMBER; } LOG_D(NR_MAC, "[%04d.%02d] UL transmission in [%04d.%02d] (k2 %ld delta %d)\n", current_frame, current_slot, *frame_tx, *slot_tx, k2, delta); - return 0; } @@ -1911,7 +1902,7 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) prach_association_pattern_t *prach_assoc_pattern = &mac->prach_assoc_pattern[bwp_id]; prach_assoc_pattern->nb_of_prach_conf_period_in_max_period = MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD / x; nb_of_frames_per_prach_conf_period = x; - + int slots_per_frame = mac->frame_structure.numb_slots_frame; LOG_D(NR_MAC,"nb_of_prach_conf_period_in_max_period %d\n", prach_assoc_pattern->nb_of_prach_conf_period_in_max_period); // Fill in the PRACH occasions table for every slot in every frame in every PRACH configuration periods in the maximum association pattern period @@ -1923,7 +1914,7 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) prach_conf_period_t *prach_conf_period_list = &prach_assoc_pattern->prach_conf_period_list[period_idx]; prach_conf_period_list->nb_of_prach_occasion = 0; prach_conf_period_list->nb_of_frame = nb_of_frames_per_prach_conf_period; - prach_conf_period_list->nb_of_slot = nr_slots_per_frame[mu]; + prach_conf_period_list->nb_of_slot = slots_per_frame; LOG_D(NR_MAC,"PRACH Conf Period Idx %d\n", period_idx); @@ -1938,7 +1929,7 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) // For every slot in a frame // ------------------------- - for (int slot = 0; slot < nr_slots_per_frame[mu]; slot++) { + for (int slot = 0; slot < slots_per_frame; slot++) { // Is it a valid slot? map_shift = slot >> slot_shift_for_map; // in PRACH configuration index table slots are numbered wrt 60kHz if ((s_map>>map_shift) & 0x01) { @@ -2561,7 +2552,7 @@ void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot) for (int id = 0; id < csi_measconfig->csi_IM_ResourceToAddModList->list.count; id++){ imcsi = csi_measconfig->csi_IM_ResourceToAddModList->list.array[id]; csi_period_offset(NULL,imcsi->periodicityAndOffset,&period,&offset); - if((frame*nr_slots_per_frame[mu]+slot-offset)%period != 0) + if((frame * mac->frame_structure.numb_slots_frame + slot - offset ) %period != 0) continue; fapi_nr_dl_config_csiim_pdu_rel15_t *csiim_config_pdu = &dl_config->dl_config_list[dl_config->number_pdus].csiim_config_pdu.csiim_config_rel15; csiim_config_pdu->bwp_size = bwp_size; @@ -2802,7 +2793,7 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) NR_NZP_CSI_RS_Resource_t *nzpcsi = csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.array[id]; int period, offset; csi_period_offset(NULL, nzpcsi->periodicityAndOffset, &period, &offset); - if((frame * nr_slots_per_frame[mu] + slot-offset) % period != 0) + if((frame * mac->frame_structure.numb_slots_frame + slot-offset) % period != 0) continue; NR_CSI_ResourceConfigId_t csi_res_id = find_CSI_resourceconfig(csi_measconfig, dl_bwp_id, nzpcsi->nzp_CSI_RS_ResourceId); // do not schedule reseption of this CSI-RS if not associated with current BWP @@ -2850,10 +2841,8 @@ static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, sub_fra NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP->rach_ConfigCommon; NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; const int bwp_id = mac->current_UL_BWP->bwp_id; - NR_TDD_UL_DL_ConfigCommon_t *tdd_config = mac->tdd_UL_DL_ConfigurationCommon; - - if (is_nr_UL_slot(tdd_config, slotP, mac->frame_type)) { + if (is_ul_slot(slotP, &mac->frame_structure)) { // WIP Need to get the proper selected ssb_idx // Initial beam selection functionality is not available yet uint8_t selected_gnb_ssb_idx = mac->mib_ssb; @@ -2986,8 +2975,7 @@ static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, sub_fra } else if (ra->ra_type == RA_2_STEP) { NR_MsgA_PUSCH_Resource_r16_t *msgA_PUSCH_Resource = mac->current_UL_BWP->msgA_ConfigCommon_r16->msgA_PUSCH_Config_r16->msgA_PUSCH_ResourceGroupA_r16; - int mu = nr_get_prach_mu(mac->current_UL_BWP->msgA_ConfigCommon_r16, setup); - const int n_slots_frame = nr_slots_per_frame[mu]; + const int n_slots_frame = mac->frame_structure.numb_slots_frame; slot_t msgA_pusch_slot = (slotP + msgA_PUSCH_Resource->msgA_PUSCH_TimeDomainOffset_r16) % n_slots_frame; frame_t msgA_pusch_frame = (frameP + ((slotP + msgA_PUSCH_Resource->msgA_PUSCH_TimeDomainOffset_r16) / n_slots_frame)) % 1024; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler_sl.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler_sl.c index 483241b17b..a27a464878 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler_sl.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler_sl.c @@ -175,15 +175,9 @@ uint8_t sl_determine_if_SSB_slot(uint16_t frame, uint16_t slot, uint16_t slots_p return 0; } -static uint8_t sl_psbch_scheduler(sl_nr_ue_mac_params_t *sl_mac_params, int ue_id, int frame, int slot) +static uint8_t sl_psbch_scheduler(sl_nr_ue_mac_params_t *sl_mac_params, int ue_id, int frame, int slot, int slots_per_frame) { - uint8_t config_type = 0, is_psbch_rx_slot = 0, is_psbch_tx_slot = 0; - - sl_nr_phy_config_request_t *sl_cfg = &sl_mac_params->sl_phy_config.sl_config_req; - uint16_t scs = sl_cfg->sl_bwp_config.sl_scs; - uint16_t slots_per_frame = nr_slots_per_frame[scs]; - if (sl_mac_params->rx_sl_bch.status) { is_psbch_rx_slot = sl_determine_if_SSB_slot(frame, slot, slots_per_frame, &sl_mac_params->rx_sl_bch); @@ -259,16 +253,9 @@ static void sl_adjust_indices_based_on_timing(sl_nr_ue_mac_params_t *sl_mac, } // Adjust indices as new timing is acquired -static void sl_actions_after_new_timing(sl_nr_ue_mac_params_t *sl_mac, - int ue_id, - int frame, int slot) +static void sl_actions_after_new_timing(sl_nr_ue_mac_params_t *sl_mac, int ue_id, int frame, int slot, int slots_per_frame) { - - uint8_t mu = sl_mac->sl_phy_config.sl_config_req.sl_bwp_config.sl_scs; - uint8_t slots_per_frame = nr_slots_per_frame[mu]; - sl_determine_slot_bitmap(sl_mac, ue_id); - sl_mac->N_SL_SLOTS = sl_determine_num_sidelink_slots(sl_mac, ue_id, &sl_mac->N_SSB_16frames); sl_adjust_indices_based_on_timing(sl_mac, ue_id, frame, slot, slots_per_frame); } @@ -385,7 +372,7 @@ void nr_ue_sidelink_scheduler(nr_sidelink_indication_t *sl_ind, NR_UE_MAC_INST_t // Adjust indices as new timing is acquired if (sl_mac->timing_acquired) { - sl_actions_after_new_timing(sl_mac, ue_id, sl_ind->frame_tx, sl_ind->slot_tx); + sl_actions_after_new_timing(sl_mac, ue_id, sl_ind->frame_tx, sl_ind->slot_tx, mac->frame_structure.numb_slots_frame); sl_mac->timing_acquired = false; } @@ -399,7 +386,7 @@ void nr_ue_sidelink_scheduler(nr_sidelink_indication_t *sl_ind, NR_UE_MAC_INST_t uint8_t tti_action = 0; // Check if PSBCH slot and PSBCH should be transmitted or Received - tti_action = sl_psbch_scheduler(sl_mac, ue_id, frame, slot); + tti_action = sl_psbch_scheduler(sl_mac, ue_id, frame, slot, mac->frame_structure.numb_slots_frame); #if 0 // To be expanded later // TBD .. Check for Actions coming out of TX resource pool diff --git a/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_power_procedures.cpp b/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_power_procedures.cpp index 59f932ac57..bcbec989c2 100644 --- a/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_power_procedures.cpp +++ b/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_power_procedures.cpp @@ -92,7 +92,7 @@ TEST(test_pucch_power_state, test_accumulated_delta_pucch) pucch_Config.pucch_PowerControl = &power_config; mac.G_b_f_c = 0; mac.pucch_power_control_initialized = true; - mac.frame_type = TDD; + mac.frame_structure.frame_type = TDD; int scs = 1; int sum_delta_pucch = 3; @@ -106,7 +106,7 @@ TEST(test_pucch_power_state, test_accumulated_delta_pucch) uint16_t start_prb = 0; int P_CMAX = nr_get_Pcmax(23, mac.nr_band, - mac.frame_type, + mac.frame_structure.frame_type, FR1, current_UL_BWP.channel_bandwidth, 2, @@ -201,7 +201,7 @@ TEST(pusch_power_control, pusch_power_control_msg3) pusch_Config.pusch_PowerControl = &pusch_PowerControl; pusch_PowerControl.tpc_Accumulation = (long*)1; mac.pusch_power_control_initialized = true; - mac.frame_type = TDD; + mac.frame_structure.frame_type = TDD; // msg3 cofiguration as in 5g_rfsimulator testcase int num_rb = 8; @@ -218,7 +218,7 @@ TEST(pusch_power_control, pusch_power_control_msg3) int P_CMAX = nr_get_Pcmax(23, mac.nr_band, - mac.frame_type, + mac.frame_structure.frame_type, FR1, current_UL_BWP.channel_bandwidth, Qm, @@ -294,7 +294,7 @@ TEST(pusch_power_control, pusch_power_data) NR_RACH_ConfigCommon_t nr_rach_ConfigCommon = {0}; current_UL_BWP.rach_ConfigCommon = &nr_rach_ConfigCommon; mac.nr_band = 78; - mac.frame_type = TDD; + mac.frame_structure.frame_type = TDD; bool is_rar_tx_retx = false; int num_rb = 5; @@ -319,7 +319,7 @@ TEST(pusch_power_control, pusch_power_data) int P_CMAX = nr_get_Pcmax(23, mac.nr_band, - mac.frame_type, + mac.frame_structure.frame_type, FR1, current_UL_BWP.channel_bandwidth, Qm, @@ -444,11 +444,11 @@ TEST(pusch_power_control, pusch_power_control_state) pusch_Config.pusch_PowerControl = &pusch_PowerControl; long p0_NominalWithGrant = 0; current_UL_BWP.p0_NominalWithGrant = &p0_NominalWithGrant; - mac.frame_type = TDD; + mac.frame_structure.frame_type = TDD; int P_CMAX = nr_get_Pcmax(23, mac.nr_band, - mac.frame_type, + mac.frame_structure.frame_type, FR1, current_UL_BWP.channel_bandwidth, Qm, diff --git a/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_ra_procedures.cpp b/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_ra_procedures.cpp index af8e140824..f5a402c467 100644 --- a/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_ra_procedures.cpp +++ b/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_ra_procedures.cpp @@ -96,7 +96,7 @@ TEST(test_init_ra, four_step_cbra) nr_rach_ConfigCommon.msg1_SubcarrierSpacing = &scs; mac.p_Max = 23; mac.nr_band = 78; - mac.frame_type = TDD; + mac.frame_structure.frame_type = TDD; mac.frequency_range = FR1; init_RA(&mac, &prach_resources, &nr_rach_ConfigCommon, &rach_ConfigGeneric, rach_ConfigDedicated); @@ -121,7 +121,7 @@ TEST(test_init_ra, four_step_cfra) nr_rach_ConfigCommon.msg1_SubcarrierSpacing = &scs; mac.p_Max = 23; mac.nr_band = 78; - mac.frame_type = TDD; + mac.frame_structure.frame_type = TDD; mac.frequency_range = FR1; NR_RACH_ConfigDedicated_t rach_ConfigDedicated = {0}; diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index a8c06604d7..537086a06d 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -794,7 +794,7 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, int slots_per_frame = 20; //30 kHZ subcarrier spacing int slot_ahead = 2; // TODO: Make this dynamic - if (is_nr_UL_slot(mac->tdd_UL_DL_ConfigurationCommon, (slot + slot_ahead) % slots_per_frame, mac->frame_type) + if (is_ul_slot((slot + slot_ahead) % slots_per_frame, &mac->frame_structure) && mac->ra.ra_state != nrRA_SUCCEEDED) { // If we filled dl_info AFTER we got the slot indication, we want to check if we should fill tx_req: nr_uplink_indication_t ul_info = {.slot = (slot + slot_ahead) % slots_per_frame, @@ -1203,7 +1203,7 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info) LOG_T(NR_MAC, "Not calling scheduler mac->ra.ra_state = %d\n", mac->ra.ra_state); - if (is_nr_UL_slot(mac->tdd_UL_DL_ConfigurationCommon, ul_info->slot, mac->frame_type)) + if (is_ul_slot(ul_info->slot, &mac->frame_structure)) nr_ue_ul_scheduler(mac, ul_info); ret = pthread_mutex_unlock(&mac->if_mutex); AssertFatal(!ret, "mutex failed %d\n", ret);