diff --git a/common/utils/nr/nr_common.c b/common/utils/nr/nr_common.c index a8f997c8266e2c14c93eb3c0f42e28af4ccabf72..d247697c4702f5f1c0e9455de3d4f027e1f289eb 100644 --- a/common/utils/nr/nr_common.c +++ b/common/utils/nr/nr_common.c @@ -684,11 +684,6 @@ int get_slot_idx_in_period(const int slot, const frame_structure_t *fs) return slot % fs->numb_slots_period; } -int get_first_ul_slot(int nrofDownlinkSlots, int nrofDownlinkSymbols, int nrofUplinkSymbols) -{ - return (nrofDownlinkSlots + (nrofDownlinkSymbols != 0 && nrofUplinkSymbols == 0)); -} - int get_dmrs_port(int nl, uint16_t dmrs_ports) { diff --git a/common/utils/nr/nr_common.h b/common/utils/nr/nr_common.h index 03838b52fd9951cd3f3f6ba65c966b7555b42b82..24fa03517bbdc840496499ba19692dbdf2a263a1 100644 --- a/common/utils/nr/nr_common.h +++ b/common/utils/nr/nr_common.h @@ -233,7 +233,6 @@ void reverse_bits_u8(uint8_t const* in, size_t sz, uint8_t* out); uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t dl_nrarfcn); uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint8_t scs_index, uint32_t bw); -int get_first_ul_slot(int nrofDownlinkSlots, int nrofDownlinkSymbols, int nrofUplinkSymbols); int cce_to_reg_interleaving(const int R, int k, int n_shift, const int C, int L, const int N_regs); int get_SLIV(uint8_t S, uint8_t L); void get_coreset_rballoc(uint8_t *FreqDomainResource,int *n_rb,int *rb_offset); diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 8881ab2bd7efad35f5ffbc79e8561ad8f9ce130d..7a554b36caae5840b1d8343dc38c433e145c7a5e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -374,6 +374,28 @@ static void config_tdd_patterns(NR_TDD_UL_DL_ConfigCommon_t *tdd, frame_structur nb_slots_p2); } +/** + * @brief Get the first UL slot index in period + * @param fs frame structure + * @param mixed indicates whether to include in the count also mixed slot with UL symbols or only full UL slot + * @return slot index + */ +int get_first_ul_slot(const frame_structure_t *fs, bool mixed) +{ + DevAssert(fs); + + if (fs->is_tdd) { + for (int i = 0; i < fs->numb_slots_period; i++) { + bool is_mixed = fs->period_cfg.tdd_slot_bitmap[i].num_ul_symbols && fs->period_cfg.tdd_slot_bitmap[i].slot_type == TDD_NR_MIXED_SLOT; + if ((mixed && is_mixed) || fs->period_cfg.tdd_slot_bitmap[i].slot_type == TDD_NR_UPLINK_SLOT) { + return i; + } + } + } + + return 0; // FDD +} + /** * @brief Get number of DL slots per period (full DL slots + mixed slots with DL symbols) */ @@ -908,7 +930,7 @@ void nr_mac_config_scc(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, c int nr_ulstart_slot = 0; if (tdd) { nr_dl_slots = tdd->nrofDownlinkSlots + (tdd->nrofDownlinkSymbols != 0); - nr_ulstart_slot = get_first_ul_slot(tdd->nrofDownlinkSlots, tdd->nrofDownlinkSymbols, tdd->nrofUplinkSymbols); + nr_ulstart_slot = get_first_ul_slot(&nrmac->frame_structure, true); nr_slots_period /= get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity); } else { // if TDD configuration is not present and the band is not FDD, it means it is a dynamic TDD configuration diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index d86f65e365c231bf9f93a96f69a91c024736c1bc..5e2f2761e88656987bb299a7322dc53d60279dbb 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -39,6 +39,7 @@ void set_cset_offset(uint16_t); void get_K1_K2(int N1, int N2, int *K1, int *K2, int layers); int get_NTN_Koffset(const NR_ServingCellConfigCommon_t *scc); +int get_first_ul_slot(const frame_structure_t *fs, bool mixed); int get_ul_slots_per_period(const frame_structure_t *fs); int get_ul_slots_per_frame(const frame_structure_t *fs); int get_dl_slots_per_period(const frame_structure_t *fs); diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 63e6e1374f1edcba430ae1c25fe3f2037f397326..5bbf1e5e8d9165b1443255ce4e0ed40810d332d2 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -49,6 +49,7 @@ #include "constr_TYPE.h" #include "executables/softmodem-common.h" #include "oai_asn1.h" +#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" #include "openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h" #include "openair3/UTILS/conversions.h" #include "uper_decoder.h" @@ -1187,10 +1188,10 @@ void set_pucch_power_config(NR_PUCCH_Config_t *pucch_Config, int do_csirs) { static void set_SR_periodandoffset(NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig, const NR_ServingCellConfigCommon_t *scc, int scs) { - const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; + const frame_structure_t *fs = &RC.nrmac[0]->frame_structure; int sr_slot = 1; // in FDD SR in slot 1 - if(tdd) - sr_slot = get_first_ul_slot(tdd->nrofDownlinkSlots, tdd->nrofDownlinkSymbols, tdd->nrofUplinkSymbols); + if (fs->is_tdd) + sr_slot = get_first_ul_slot(fs, true); schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); @@ -1650,12 +1651,13 @@ static void set_csi_meas_periodicity(const NR_ServingCellConfigCommon_t *scc, int curr_bwp, bool is_rsrp) { + const frame_structure_t *fs = &RC.nrmac[0]->frame_structure; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; const int n_slots_frame = slotsperframe[*scc->ssbSubcarrierSpacing]; const int n_ul_slots_period = tdd ? (tdd->nrofUplinkSlots + (tdd->nrofUplinkSymbols > 0)) : n_slots_frame; const int n_slots_period = tdd ? n_slots_frame / get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity) : n_slots_frame; const int ideal_period = set_ideal_period(n_slots_period, n_ul_slots_period); - const int first_ul_slot_period = tdd ? get_first_ul_slot(tdd->nrofDownlinkSlots, tdd->nrofDownlinkSymbols, tdd->nrofUplinkSymbols) : 0; + const int first_ul_slot_period = tdd ? get_first_ul_slot(fs, true) : 0; const int num_pucch2 = get_nb_pucch2_per_slot(scc, curr_bwp); const int idx = (uid * 2 / num_pucch2) + is_rsrp; const int offset = first_ul_slot_period + idx % n_ul_slots_period + (idx / n_ul_slots_period) * n_slots_period;