diff --git a/CMakeLists.txt b/CMakeLists.txt index ab6e988939..b4ea5a77eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1366,6 +1366,7 @@ target_link_libraries(NR_L2_UE PRIVATE nr_nas) add_library(MAC_NR_COMMON ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common.c + ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common_tdd.c ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c ) target_link_libraries(MAC_NR_COMMON PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) @@ -1891,6 +1892,7 @@ add_executable(nr-uesoftmodem ${OPENAIR_DIR}/radio/COMMON/common_lib.c ${OPENAIR_DIR}/radio/COMMON/record_player.c ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common.c + ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common_tdd.c ${OPENAIR1_DIR}/PHY/TOOLS/phy_scope_interface.c ) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index ab3a044ac6..edc8d2d265 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -647,7 +647,11 @@ printf("%d\n", slot); frame_structure_t frame_structure = {0}; frame_type_t frame_type = TDD; - config_frame_structure(mu, scc, get_tdd_period_idx(scc->tdd_UL_DL_ConfigurationCommon), frame_type, &frame_structure); + config_frame_structure(mu, + scc->tdd_UL_DL_ConfigurationCommon, + get_tdd_period_idx(scc->tdd_UL_DL_ConfigurationCommon), + frame_type, + &frame_structure); AssertFatal(is_dl_slot(slot, &frame_structure), "The slot selected is not DL. Can't run DLSIM\n"); // TODO do a UECAP for phy-sim diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 4f07bbc7aa..788adce9ad 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -628,7 +628,11 @@ int main(int argc, char *argv[]) frame_structure_t frame_structure = {0}; frame_type_t frame_type = TDD; - config_frame_structure(mu, scc, get_tdd_period_idx(scc->tdd_UL_DL_ConfigurationCommon), frame_type, &frame_structure); + config_frame_structure(mu, + scc->tdd_UL_DL_ConfigurationCommon, + get_tdd_period_idx(scc->tdd_UL_DL_ConfigurationCommon), + frame_type, + &frame_structure); AssertFatal(is_ul_slot(slot, &frame_structure), "The slot selected is not UL. Can't run ULSIM\n"); // TODO do a UECAP for phy-sim diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 6c15ec2943..be6f87d1e8 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -76,8 +76,6 @@ static const uint16_t symbol_ssb_E[64] = {8, 12, 16, 20, 32, 36, 40, 44, 288, 292, 296, 300, 312, 316, 320, 324, 344, 348, 352, 356, 368, 372, 376, 380, 400, 404, 408, 412, 424, 428, 432, 436, 456, 460, 464, 468, 480, 484, 488, 492}; -const uint8_t nr_slots_per_frame[5] = {10, 20, 40, 80, 160}; - // Table 6.3.3.1-5 (38.211) NCS for preamble formats with delta_f_RA = 1.25 KHz static const uint16_t NCS_unrestricted_delta_f_RA_125[16] = {0, 13, 15, 18, 22, 26, 32, 38, 46, 59, 76, 93, 119, 167, 279, 419}; static const uint16_t NCS_restricted_TypeA_delta_f_RA_125[15] = diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 64f8853e3d..f543b95057 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -65,9 +65,18 @@ int16_t fill_dmrs_mask(const NR_PDSCH_Config_t *pdsch_Config, 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); +int get_tdd_period_idx(NR_TDD_UL_DL_ConfigCommon_t *tdd); +void config_frame_structure(int mu, + NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, + uint8_t tdd_period, + uint8_t frame_type, + frame_structure_t *fs); + uint8_t compute_srs_resource_indicator(long *maxMIMO_Layers, NR_PUSCH_Config_t *pusch_Config, NR_SRS_Config_t *srs_config, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common_tdd.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common_tdd.c new file mode 100644 index 0000000000..3790a4893f --- /dev/null +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common_tdd.c @@ -0,0 +1,247 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + + +#include "nr_mac_common.h" +#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}; +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}; + +/** + * @brief Retrieves the periodicity in milliseconds for the given TDD pattern + * depending on the presence of the extension + * @param pattern Pointer to the NR_TDD_UL_DL_Pattern_t pattern structure + * @return Periodicity value in milliseconds. + */ +static float get_tdd_periodicity(NR_TDD_UL_DL_Pattern_t *pattern) +{ + if (!pattern->ext1) { + LOG_D(NR_MAC, "Setting TDD configuration period to dl_UL_TransmissionPeriodicity %ld\n", pattern->dl_UL_TransmissionPeriodicity); + return tdd_ms_period_pattern[pattern->dl_UL_TransmissionPeriodicity]; + } else { + DevAssert(pattern->ext1->dl_UL_TransmissionPeriodicity_v1530 != NULL); + LOG_D(NR_MAC, + "Setting TDD configuration period to dl_UL_TransmissionPeriodicity_v1530 %ld\n", + *pattern->ext1->dl_UL_TransmissionPeriodicity_v1530); + return tdd_ms_period_ext[*pattern->ext1->dl_UL_TransmissionPeriodicity_v1530]; + } +} + +/** + * @brief Determines the TDD period index based on pattern periodicities + * @note Not applicabile to pattern extension + * @param tdd Pointer to the NR_TDD_UL_DL_ConfigCommon_t containing patterns + * @return Index of the TDD period in tdd_ms_period_pattern + */ +int get_tdd_period_idx(NR_TDD_UL_DL_ConfigCommon_t *tdd) +{ + int tdd_period_idx = 0; + float pattern1_ms = get_tdd_periodicity(&tdd->pattern1); + float pattern2_ms = tdd->pattern2 ? get_tdd_periodicity(tdd->pattern2) : 0.0; + bool found_match = false; + // Find matching TDD period in the predefined list of periodicities + for (int i = 0; i < NFAPI_MAX_NUM_PERIODS; i++) { + if ((pattern1_ms + pattern2_ms) == tdd_ms_period_pattern[i]) { + tdd_period_idx = i; + LOG_I(NR_MAC, + "TDD period index = %d, based on the sum of dl_UL_TransmissionPeriodicity " + "from Pattern1 (%f ms) and Pattern2 (%f ms): Total = %f ms\n", + tdd_period_idx, + pattern1_ms, + pattern2_ms, + pattern1_ms + pattern2_ms); + found_match = true; + break; + } + } + // Assert if no match was found + AssertFatal(found_match, "The sum of pattern1_ms and pattern2_ms does not match any value in tdd_ms_period_pattern"); + return tdd_period_idx; +} + +/** + * @brief Configures the TDD period, including bitmap, in the frame structure + * + * This function sets the TDD period configuration for DL, UL, and mixed slots in + * the specified frame structure instance, according to the given pattern, and + * updates the bitmap. + * + * @param pattern NR_TDD_UL_DL_Pattern_t configuration containing TDD slots and symbols configuration + * @param fs frame_structure_t pointer + * @param curr_total_slot current position in the slot bitmap to start from + * + * @return Number of slots in the configured TDD period + */ +static uint8_t set_tdd_bmap_period(NR_TDD_UL_DL_Pattern_t *pattern, tdd_period_config_t *pc, int8_t curr_total_slot) +{ + int8_t n_dl_slot = pattern->nrofDownlinkSlots; + int8_t n_ul_slot = pattern->nrofUplinkSlots; + int8_t n_dl_symbols = pattern->nrofDownlinkSymbols; + int8_t n_ul_symbols = pattern->nrofUplinkSymbols; + + // Total slots in the period: if DL/UL symbols are present, is mixed slot + const bool has_mixed_slot = (n_ul_symbols + n_dl_symbols) > 0; + int8_t total_slot = has_mixed_slot ? n_dl_slot + n_ul_slot + 1 : n_dl_slot + n_ul_slot; + + /** Update TDD period configuration: + * mixed slots with DL symbols are counted as DL slots + * mixed slots with UL symbols are counted as UL slots */ + pc->num_dl_slots += (n_dl_slot + (n_dl_symbols > 0)); + pc->num_ul_slots += (n_ul_slot + (n_ul_symbols > 0)); + + // Populate the slot bitmap for each slot in the TDD period + for (int i = 0; i < total_slot; i++) { + tdd_bitmap_t *bitmap = &pc->tdd_slot_bitmap[i + curr_total_slot]; + if (i < n_dl_slot) + bitmap->slot_type = TDD_NR_DOWNLINK_SLOT; + else if ((i == n_dl_slot) && has_mixed_slot) { + bitmap->slot_type = TDD_NR_MIXED_SLOT; + bitmap->num_dl_symbols = n_dl_symbols; + bitmap->num_ul_symbols = n_ul_symbols; + } else if (n_ul_slot) + bitmap->slot_type = TDD_NR_UPLINK_SLOT; + } + + LOG_I(NR_MAC, + "Set TDD configuration period to: %d DL slots, %d UL slots, %d slots per period (NR_TDD_UL_DL_Pattern is %d DL slots, %d " + "UL slots, %d DL symbols, %d UL symbols)\n", + pc->num_dl_slots, + pc->num_ul_slots, + total_slot, + n_dl_slot, + n_ul_slot, + n_dl_symbols, + n_ul_symbols); + + return total_slot; +} + +/** + * @brief Configures TDD patterns (1 or 2) in the frame structure + * + * This function sets up the TDD configuration in the frame structure by applying + * DL and UL patterns as defined in NR_TDD_UL_DL_ConfigCommon. + * It handles both TDD pattern1 and pattern2. + * + * @param tdd NR_TDD_UL_DL_ConfigCommon_t pointer containing pattern1 and pattern2 + * @param fs Pointer to the frame structure to update with the configured TDD patterns. + * + * @return void + */ +static void config_tdd_patterns(NR_TDD_UL_DL_ConfigCommon_t *tdd, frame_structure_t *fs) +{ + int num_of_patterns = 1; + uint8_t nb_slots_p2 = 0; + // Reset num dl/ul slots + tdd_period_config_t *pc = &fs->period_cfg; + pc->num_dl_slots = 0; + pc->num_ul_slots = 0; + // Pattern1 + uint8_t nb_slots_p1 = set_tdd_bmap_period(&tdd->pattern1, pc, 0); + // Pattern2 + if (tdd->pattern2) { + num_of_patterns++; + nb_slots_p2 = set_tdd_bmap_period(tdd->pattern2, pc, nb_slots_p1); + } + LOG_I(NR_MAC, + "Configured %d TDD patterns (total slots: pattern1 = %d, pattern2 = %d)\n", + num_of_patterns, + nb_slots_p1, + nb_slots_p2); +} + +/** + * @brief Configures the frame structure and the NFAPI config request + * depending on the duplex mode. If TDD, does the TDD patterns + * and TDD periods configuration. + * + * @param mu numerology + * @param scc pointer to scc + * @param tdd_period TDD period + * @param frame_type type of frame structure (FDD or TDD) + * @param fs pointer to the frame structure to update + */ +void config_frame_structure(int mu, + NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, + uint8_t tdd_period, + uint8_t frame_type, + frame_structure_t *fs) +{ + fs->numb_slots_frame = nr_slots_per_frame[mu]; + fs->frame_type = frame_type; + if (frame_type == TDD) { + fs->numb_period_frame = get_nb_periods_per_frame(tdd_period); + fs->numb_slots_period = fs->numb_slots_frame / fs->numb_period_frame; + config_tdd_patterns(tdd_UL_DL_ConfigurationCommon, fs); + } else { // FDD + fs->numb_period_frame = 1; + fs->numb_slots_period = nr_slots_per_frame[mu]; + } + AssertFatal(fs->numb_period_frame > 0, "Frame configuration cannot be configured!\n"); +} + +/** + * @brief Returns true for: + * (1) FDD + * (2) Mixed slot with UL symbols + * (3) Full UL slot + */ +bool is_ul_slot(const slot_t slot, const frame_structure_t *fs) +{ + if (fs->frame_type == FDD) + return true; + const tdd_period_config_t *pc = &fs->period_cfg; + slot_t s = get_slot_idx_in_period(slot, fs); + return ((is_mixed_slot(s, fs) && pc->tdd_slot_bitmap[s].num_ul_symbols) + || (pc->tdd_slot_bitmap[s].slot_type == TDD_NR_UPLINK_SLOT)); +} + +/** + * @brief Returns true for: + * (1) FDD + * (2) Mixed slot with DL symbols + * (3) Full DL slot + */ +bool is_dl_slot(const slot_t slot, const frame_structure_t *fs) +{ + if (fs->frame_type == FDD) + return true; + const tdd_period_config_t *pc = &fs->period_cfg; + slot_t s = get_slot_idx_in_period(slot, fs); + return ((is_mixed_slot(s, fs) && pc->tdd_slot_bitmap[s].num_dl_symbols) + || (pc->tdd_slot_bitmap[s].slot_type == TDD_NR_DOWNLINK_SLOT)); +} + +/** + * @brief Returns true for: + * (1) Mixed slot with DL and/or UL symbols + */ +bool is_mixed_slot(const slot_t slot, const frame_structure_t *fs) +{ + if (fs->frame_type == FDD) + return false; + slot_t s = get_slot_idx_in_period(slot, fs); + const tdd_period_config_t *pc = &fs->period_cfg; + return pc->tdd_slot_bitmap[s].slot_type == TDD_NR_MIXED_SLOT; +} diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 0a511defaf..4b3b48a48a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -279,97 +279,6 @@ nfapi_nr_pm_list_t init_DL_MIMO_codebook(gNB_MAC_INST *gNB, nr_pdsch_AntennaPort return mat; } -/** - * @brief Configures the TDD period, including bitmap, in the frame structure - * - * This function sets the TDD period configuration for DL, UL, and mixed slots in - * the specified frame structure instance, according to the given pattern, and - * updates the bitmap. - * - * @param pattern NR_TDD_UL_DL_Pattern_t configuration containing TDD slots and symbols configuration - * @param fs frame_structure_t pointer - * @param curr_total_slot current position in the slot bitmap to start from - * - * @return Number of slots in the configured TDD period - */ -static uint8_t set_tdd_bmap_period(NR_TDD_UL_DL_Pattern_t *pattern, tdd_period_config_t *pc, int8_t curr_total_slot) -{ - int8_t n_dl_slot = pattern->nrofDownlinkSlots; - int8_t n_ul_slot = pattern->nrofUplinkSlots; - int8_t n_dl_symbols = pattern->nrofDownlinkSymbols; - int8_t n_ul_symbols = pattern->nrofUplinkSymbols; - - // Total slots in the period: if DL/UL symbols are present, is mixed slot - const bool has_mixed_slot = (n_ul_symbols + n_dl_symbols) > 0; - int8_t total_slot = has_mixed_slot ? n_dl_slot + n_ul_slot + 1 : n_dl_slot + n_ul_slot; - - /** Update TDD period configuration: - * mixed slots with DL symbols are counted as DL slots - * mixed slots with UL symbols are counted as UL slots */ - pc->num_dl_slots += (n_dl_slot + (n_dl_symbols > 0)); - pc->num_ul_slots += (n_ul_slot + (n_ul_symbols > 0)); - - // Populate the slot bitmap for each slot in the TDD period - for (int i = 0; i < total_slot; i++) { - tdd_bitmap_t *bitmap = &pc->tdd_slot_bitmap[i + curr_total_slot]; - if (i < n_dl_slot) - bitmap->slot_type = TDD_NR_DOWNLINK_SLOT; - else if ((i == n_dl_slot) && has_mixed_slot) { - bitmap->slot_type = TDD_NR_MIXED_SLOT; - bitmap->num_dl_symbols = n_dl_symbols; - bitmap->num_ul_symbols = n_ul_symbols; - } else if (n_ul_slot) - bitmap->slot_type = TDD_NR_UPLINK_SLOT; - } - - LOG_I(NR_MAC, - "Set TDD configuration period to: %d DL slots, %d UL slots, %d slots per period (NR_TDD_UL_DL_Pattern is %d DL slots, %d " - "UL slots, %d DL symbols, %d UL symbols)\n", - pc->num_dl_slots, - pc->num_ul_slots, - total_slot, - n_dl_slot, - n_ul_slot, - n_dl_symbols, - n_ul_symbols); - - return total_slot; -} - -/** - * @brief Configures TDD patterns (1 or 2) in the frame structure - * - * This function sets up the TDD configuration in the frame structure by applying - * DL and UL patterns as defined in NR_TDD_UL_DL_ConfigCommon. - * It handles both TDD pattern1 and pattern2. - * - * @param tdd NR_TDD_UL_DL_ConfigCommon_t pointer containing pattern1 and pattern2 - * @param fs Pointer to the frame structure to update with the configured TDD patterns. - * - * @return void - */ -static void config_tdd_patterns(NR_TDD_UL_DL_ConfigCommon_t *tdd, frame_structure_t *fs) -{ - int num_of_patterns = 1; - uint8_t nb_slots_p2 = 0; - // Reset num dl/ul slots - tdd_period_config_t *pc = &fs->period_cfg; - pc->num_dl_slots = 0; - pc->num_ul_slots = 0; - // Pattern1 - uint8_t nb_slots_p1 = set_tdd_bmap_period(&tdd->pattern1, pc, 0); - // Pattern2 - if (tdd->pattern2) { - num_of_patterns++; - nb_slots_p2 = set_tdd_bmap_period(tdd->pattern2, pc, nb_slots_p1); - } - LOG_I(NR_MAC, - "Configured %d TDD patterns (total slots: pattern1 = %d, pattern2 = %d)\n", - num_of_patterns, - nb_slots_p1, - nb_slots_p2); -} - /** * @brief Get the first UL slot index in period * @param fs frame structure @@ -493,37 +402,6 @@ int get_ul_slot_offset(const frame_structure_t *fs, int idx, bool count_mixed) return ul_slot_idxs[ul_slot_idx_in_period] + period_idx * fs->numb_slots_period; } -/** - * @brief Configures the frame structure and the NFAPI config request - * depending on the duplex mode. If TDD, does the TDD patterns - * and TDD periods configuration. - * - * @param mu numerology - * @param scc pointer to scc - * @param tdd_period TDD period - * @param frame_type type of frame structure (FDD or TDD) - * @param fs pointer to the frame structure to update - */ -void config_frame_structure(int mu, - NR_ServingCellConfigCommon_t *scc, - uint8_t tdd_period, - uint8_t frame_type, - frame_structure_t *fs) -{ - fs->numb_slots_frame = nr_slots_per_frame[mu]; - if (frame_type == TDD) { - fs->numb_period_frame = get_nb_periods_per_frame(tdd_period); - fs->numb_slots_period = fs->numb_slots_frame / fs->numb_period_frame; - fs->frame_type = TDD; - config_tdd_patterns(scc->tdd_UL_DL_ConfigurationCommon, fs); - } else { // FDD - fs->frame_type = FDD; - fs->numb_period_frame = 1; - fs->numb_slots_period = fs->numb_slots_frame; - } - AssertFatal(fs->numb_period_frame > 0, "Frame configuration cannot be configured!\n"); -} - static void config_common(gNB_MAC_INST *nrmac, const nr_mac_config_t *config, NR_ServingCellConfigCommon_t *scc) @@ -820,7 +698,11 @@ static void config_common(gNB_MAC_INST *nrmac, LOG_D(NR_MAC, "Setting TDD configuration period to %d\n", cfg->tdd_table.tdd_period.value); } frame_structure_t *fs = &nrmac->frame_structure; - config_frame_structure(mu, scc, cfg->tdd_table.tdd_period.value, cfg->cell_config.frame_duplex_type.value, fs); + config_frame_structure(mu, + scc->tdd_UL_DL_ConfigurationCommon, + cfg->tdd_table.tdd_period.value, + cfg->cell_config.frame_duplex_type.value, + fs); if (cfg->cell_config.frame_duplex_type.value == TDD) set_tdd_config_nr(cfg, fs); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 73e09f6e13..49f88373df 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -118,51 +118,6 @@ static void clear_beam_information(NR_beam_info_t *beam_info, int frame, int slo } } -/** - * @brief Returns true for: - * (1) FDD - * (2) Mixed slot with UL symbols - * (3) Full UL slot - */ -bool is_ul_slot(const slot_t slot, const frame_structure_t *fs) -{ - if (fs->frame_type == FDD) - return true; - const tdd_period_config_t *pc = &fs->period_cfg; - slot_t s = get_slot_idx_in_period(slot, fs); - return ((is_mixed_slot(s, fs) && pc->tdd_slot_bitmap[s].num_ul_symbols) - || (pc->tdd_slot_bitmap[s].slot_type == TDD_NR_UPLINK_SLOT)); -} - -/** - * @brief Returns true for: - * (1) FDD - * (2) Mixed slot with DL symbols - * (3) Full DL slot - */ -bool is_dl_slot(const slot_t slot, const frame_structure_t *fs) -{ - if (fs->frame_type == FDD) - return true; - const tdd_period_config_t *pc = &fs->period_cfg; - slot_t s = get_slot_idx_in_period(slot, fs); - return ((is_mixed_slot(s, fs) && pc->tdd_slot_bitmap[s].num_dl_symbols) - || (pc->tdd_slot_bitmap[s].slot_type == TDD_NR_DOWNLINK_SLOT)); -} - -/** - * @brief Returns true for: - * (1) Mixed slot with DL and/or UL symbols - */ -bool is_mixed_slot(const slot_t slot, const frame_structure_t *fs) -{ - if (fs->frame_type == FDD) - return false; - slot_t s = get_slot_idx_in_period(slot, fs); - const tdd_period_config_t *pc = &fs->period_cfg; - return pc->tdd_slot_bitmap[s].slot_type == TDD_NR_MIXED_SLOT; -} - /* the structure nfapi_nr_ul_tti_request_t is very big, let's copy only what is necessary */ static void copy_ul_tti_req(nfapi_nr_ul_tti_request_t *to, nfapi_nr_ul_tti_request_t *from) { diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 5fdc39bcd5..977be3eda3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -39,11 +39,6 @@ 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); -void config_frame_structure(int mu, - NR_ServingCellConfigCommon_t *scc, - uint8_t tdd_period, - uint8_t frame_type, - frame_structure_t *fs); 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); @@ -353,10 +348,6 @@ int nr_write_ce_dlsch_pdu(module_id_t module_idP, int binomial(int n, int k); -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); - /* \brief Function to indicate a received SDU on ULSCH. @param Mod_id Instance ID of gNB @param CC_id Component carrier index diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 4fe0a2d764..889782eb3c 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -983,60 +983,6 @@ void nr_rrc_config_dl_tda(struct NR_PDSCH_TimeDomainResourceAllocationList *pdsc } } -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}; - -/** - * @brief Retrieves the periodicity in milliseconds for the given TDD pattern - * depending on the presence of the extension - * @param pattern Pointer to the NR_TDD_UL_DL_Pattern_t pattern structure - * @return Periodicity value in milliseconds. - */ -static float get_tdd_periodicity(NR_TDD_UL_DL_Pattern_t *pattern) { - if (!pattern->ext1) { - LOG_D(NR_MAC, "Setting TDD configuration period to dl_UL_TransmissionPeriodicity %ld\n", pattern->dl_UL_TransmissionPeriodicity); - return tdd_ms_period_pattern[pattern->dl_UL_TransmissionPeriodicity]; - } else { - DevAssert(pattern->ext1->dl_UL_TransmissionPeriodicity_v1530 != NULL); - LOG_D(NR_MAC, - "Setting TDD configuration period to dl_UL_TransmissionPeriodicity_v1530 %ld\n", - *pattern->ext1->dl_UL_TransmissionPeriodicity_v1530); - return tdd_ms_period_ext[*pattern->ext1->dl_UL_TransmissionPeriodicity_v1530]; - } -} - -/** - * @brief Determines the TDD period index based on pattern periodicities - * @note Not applicabile to pattern extension - * @param tdd Pointer to the NR_TDD_UL_DL_ConfigCommon_t containing patterns - * @return Index of the TDD period in tdd_ms_period_pattern - */ -int get_tdd_period_idx(NR_TDD_UL_DL_ConfigCommon_t *tdd) -{ - int tdd_period_idx = 0; - float pattern1_ms = get_tdd_periodicity(&tdd->pattern1); - float pattern2_ms = tdd->pattern2 ? get_tdd_periodicity(tdd->pattern2) : 0.0; - bool found_match = false; - // Find matching TDD period in the predefined list of periodicities - for (int i = 0; i < NFAPI_MAX_NUM_PERIODS; i++) { - if ((pattern1_ms + pattern2_ms) == tdd_ms_period_pattern[i]) { - tdd_period_idx = i; - LOG_I(NR_MAC, - "TDD period index = %d, based on the sum of dl_UL_TransmissionPeriodicity " - "from Pattern1 (%f ms) and Pattern2 (%f ms): Total = %f ms\n", - tdd_period_idx, - pattern1_ms, - pattern2_ms, - pattern1_ms + pattern2_ms); - found_match = true; - break; - } - } - // Assert if no match was found - AssertFatal(found_match, "The sum of pattern1_ms and pattern2_ms does not match any value in tdd_ms_period_pattern"); - return tdd_period_idx; -} - static struct NR_PUSCH_TimeDomainResourceAllocation *set_TimeDomainResourceAllocation(const int k2, uint8_t index, int ul_symb) { struct NR_PUSCH_TimeDomainResourceAllocation *puschTdrAlloc = calloc_or_fail(1, sizeof(*puschTdrAlloc)); diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 3076b09f62..b9f030e897 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -112,6 +112,5 @@ NR_CellGroupConfig_t *get_default_secondaryCellGroup(const NR_ServingCellConfigC int uid); NR_ReconfigurationWithSync_t *get_reconfiguration_with_sync(rnti_t rnti, uid_t uid, const NR_ServingCellConfigCommon_t *scc); -int get_tdd_period_idx(NR_TDD_UL_DL_ConfigCommon_t *tdd); #endif