From 75c2f9e5f84987ab6fb0f07580bc35bdbe73e4df Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 31 Jul 2023 17:43:01 +0200 Subject: [PATCH] improving handling of tdd_UL_DL_ConfigurationCommon absence when checking DL or UL slot --- executables/nr-ue.c | 7 +-- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 59 ++++++++++--------- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 4 +- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 16 +++-- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 47ec046612..696a6d4a0e 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -328,9 +328,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) free_and_zero(ch_info); } - bool default_dl = mac->tdd_UL_DL_ConfigurationCommon ? false : true; - if (default_dl || - is_nr_DL_slot(mac->tdd_UL_DL_ConfigurationCommon, + if (is_nr_DL_slot(mac->tdd_UL_DL_ConfigurationCommon, ul_info.slot_rx)) { memset(&mac->dl_info, 0, sizeof(mac->dl_info)); mac->dl_info.cc_id = CC_id; @@ -345,8 +343,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); - if (!default_dl && - is_nr_UL_slot(mac->tdd_UL_DL_ConfigurationCommon, + if (is_nr_UL_slot(mac->tdd_UL_DL_ConfigurationCommon, ul_info.slot_tx, mac->frame_type)) { LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind()\n", ul_info.slot_tx); nr_ue_ul_scheduler(&ul_info); diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 8ed2b0d0ba..e7b6259284 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -3635,12 +3635,12 @@ int ul_ant_bits(NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig, long transformPrec int tdd_period_to_num[8] = {500,625,1000,1250,2000,2500,5000,10000}; -int is_nr_DL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon,slot_t slot) { - - int period,period1,period2=0; - - if (tdd_UL_DL_ConfigurationCommon==NULL) return(1); +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; @@ -3650,49 +3650,54 @@ int is_nr_DL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon,slo 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; + 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]; } - period = period1+period2; - int scs=tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing; - int slots=period*(1<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 ? 1 : 0); - else return(slot_in_period <= slots1+tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSlots ? 1 : 0); + 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; } -int is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slot, frame_type_t frame_type) { - - int period,period1,period2=0; - +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 (tdd_UL_DL_ConfigurationCommon == NULL || frame_type == FDD) { - return(1); - } + 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; + 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; + 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]; } - period = period1+period2; - int scs=tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing; - int slots=period*(1<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 ? 1 : 0); - else return(slot_in_period >= slots1+tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSlots ? 1 : 0); + 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, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index e2e97e0964..07daa61725 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -67,9 +67,9 @@ int16_t fill_dmrs_mask(const NR_PDSCH_Config_t *pdsch_Config, mappingType_t mappingtype, int length); -int is_nr_DL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon,slot_t slotP); +bool is_nr_DL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slotP); -int is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slotP, frame_type_t frame_type); +bool is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, slot_t slotP, frame_type_t frame_type); uint8_t compute_srs_resource_indicator(NR_PUSCH_ServingCellConfig_t *pusch_servingcellconfig, NR_PUSCH_Config_t *pusch_Config, diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index fab054ba48..942ec698c3 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -742,19 +742,17 @@ 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 (mac->tdd_UL_DL_ConfigurationCommon) { - if (is_nr_UL_slot(mac->tdd_UL_DL_ConfigurationCommon, - (slot + slot_ahead) % slots_per_frame, - mac->frame_type) - && mac->ra.ra_state != RA_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 = { + if (is_nr_UL_slot(mac->tdd_UL_DL_ConfigurationCommon, + (slot + slot_ahead) % slots_per_frame, + mac->frame_type) + && mac->ra.ra_state != RA_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 = { .frame_rx = frame, .slot_rx = slot, .slot_tx = (slot + slot_ahead) % slots_per_frame, .frame_tx = (ul_info.slot_rx + slot_ahead >= slots_per_frame) ? ul_info.frame_rx + 1 : ul_info.frame_rx}; - nr_ue_ul_scheduler(&ul_info); - } + nr_ue_ul_scheduler(&ul_info); } }