diff --git a/nfapi/open-nFAPI/pnf/src/pnf.c b/nfapi/open-nFAPI/pnf/src/pnf.c index f3e44663f8..3880e53c6c 100644 --- a/nfapi/open-nFAPI/pnf/src/pnf.c +++ b/nfapi/open-nFAPI/pnf/src/pnf.c @@ -669,10 +669,6 @@ void pnf_nr_handle_config_request(pnf_t* pnf, void *pRecvMsg, int recvMsgLen) { nfapi_pnf_phy_config_t* phy = nfapi_pnf_phy_config_find(config, req.header.phy_id); -#if 0 // emulate set_config TLV reception (hard-code) - int tdd_return = set_tdd_config_nr(&req, 1, 7, 6, 2, 4); -#endif - if(phy) { if(phy->state != NFAPI_PNF_PHY_RUNNING) diff --git a/openair1/SCHED_NR/phy_frame_config_nr.c b/openair1/SCHED_NR/phy_frame_config_nr.c index ad672bccb8..bff35ce4ff 100644 --- a/openair1/SCHED_NR/phy_frame_config_nr.c +++ b/openair1/SCHED_NR/phy_frame_config_nr.c @@ -44,108 +44,112 @@ #define NR_TST_PHY_PRINTF(...) #endif -/******************************************************************* -* -* NAME : set_tdd_configuration -* -* PARAMETERS : pointer to frame configuration -* -* OUTPUT: table of uplink symbol for each slot for 2 frames -* -* RETURN : nb_periods_per_frame if tdd has been properly configurated -* -1 tdd configuration can not be done -* -* DESCRIPTION : generate bit map for uplink symbol for each slot for several frames -* see TS 38.213 11.1 Slot configuration -* -*********************************************************************/ - -int set_tdd_config_nr(nfapi_nr_config_request_scf_t *cfg, - int mu, - int nrofDownlinkSlots, - int nrofDownlinkSymbols, - int nrofUplinkSlots, - int nrofUplinkSymbols) +/** @brief This function processes TDD dedicated configuration for NR + * by processing the tdd_slot_bitmap and period_cfg, and + * allocates memory and fills max_num_of_symbol_per_slot_list + * in the nfapi config request (cfg) + * @ref see TS 38.213 11.1 Slot configuration + * @param cfg NR config request structure pointer + * @param fs TDD configuration pointer + * @returns void + */ +void set_tdd_config_nr(nfapi_nr_config_request_scf_t *cfg, frame_structure_t *fs) { + AssertFatal(fs != NULL, "frame_structure must be non-NULL"); + int slot_number = 0; - int nb_periods_per_frame = get_nb_periods_per_frame(cfg->tdd_table.tdd_period.value); - int nb_slots_to_set = (1 << mu) * NR_NUMBER_OF_SUBFRAMES_PER_FRAME; + int nb_slots_to_set = fs->numb_slots_frame; + int slot_index = 0; + tdd_period_config_t *pc = &fs->period_cfg; + tdd_bitmap_t *tdd_slot_bitmap = pc->tdd_slot_bitmap; - int nb_slots_per_period = ((1 << mu) * NR_NUMBER_OF_SUBFRAMES_PER_FRAME) / nb_periods_per_frame; - - if ((nrofDownlinkSymbols + nrofUplinkSymbols) == 0) - AssertFatal(nb_slots_per_period == (nrofDownlinkSlots + nrofUplinkSlots), - "set_tdd_configuration_nr: given period is inconsistent with current tdd configuration, nrofDownlinkSlots %d, " - "nrofUplinkSlots %d, nb_slots_per_period %d \n", - nrofDownlinkSlots, - nrofUplinkSlots, - nb_slots_per_period); - else { - AssertFatal(nrofDownlinkSymbols + nrofUplinkSymbols < 14, - "illegal symbol configuration DL %d, UL %d\n", - nrofDownlinkSymbols, - nrofUplinkSymbols); - AssertFatal(nb_slots_per_period == (nrofDownlinkSlots + nrofUplinkSlots + 1), - "set_tdd_configuration_nr: given period is inconsistent with current tdd configuration, nrofDownlinkSlots %d, " - "nrofUplinkSlots %d, nrofMixed slots 1, nb_slots_per_period %d \n", - nrofDownlinkSlots, - nrofUplinkSlots, - nb_slots_per_period); - } - - cfg->tdd_table.max_tdd_periodicity_list = calloc(nb_slots_to_set, sizeof(nfapi_nr_max_tdd_periodicity_t)); + LOG_I(NR_PHY, + "Set TDD Period Configuration: %d periods per frame, %d slots to be configured (%d DL, %d UL)\n", + fs->numb_period_frame, + nb_slots_to_set, + pc->num_dl_slots, + pc->num_ul_slots); + // Allocate memory formax_num_of_symbol_per_slot_list items + cfg->tdd_table.max_tdd_periodicity_list = calloc_or_fail(nb_slots_to_set, sizeof(nfapi_nr_max_tdd_periodicity_t)); for (int slot = 0; slot < nb_slots_to_set; slot++) { nfapi_nr_max_tdd_periodicity_t *p_list = &cfg->tdd_table.max_tdd_periodicity_list[slot]; p_list->max_num_of_symbol_per_slot_list = - calloc(NR_NUMBER_OF_SYMBOLS_PER_SLOT, sizeof(*p_list->max_num_of_symbol_per_slot_list)); + calloc_or_fail(NR_NUMBER_OF_SYMBOLS_PER_SLOT, sizeof(*p_list->max_num_of_symbol_per_slot_list)); for (int sym = 0; sym < NR_NUMBER_OF_SYMBOLS_PER_SLOT; sym++) { // for each symbol, assign the TLV tag for usage when packing p_list->max_num_of_symbol_per_slot_list[sym].slot_config.tl.tag = NFAPI_NR_CONFIG_SLOT_CONFIG_TAG; } } + // Loop through all periods to be configured while (slot_number != nb_slots_to_set) { - if (nrofDownlinkSlots != 0) { - for (int sym = 0; sym < nrofDownlinkSlots * NR_NUMBER_OF_SYMBOLS_PER_SLOT; sym++) { - cfg->tdd_table.max_tdd_periodicity_list[slot_number] - .max_num_of_symbol_per_slot_list[sym % NR_NUMBER_OF_SYMBOLS_PER_SLOT] - .slot_config.value = 0; - - if ((sym + 1) % NR_NUMBER_OF_SYMBOLS_PER_SLOT == 0) + slot_index = get_slot_idx_in_period(slot_number, fs); + /* Fill max_tdd_periodicity_list */ + nfapi_nr_max_tdd_periodicity_t *list = &cfg->tdd_table.max_tdd_periodicity_list[slot_number]; + // FULL DOWNLINK SLOTS + if (tdd_slot_bitmap[slot_index].slot_type == TDD_NR_DOWNLINK_SLOT) { + for (int sym = 0; sym < NR_NUMBER_OF_SYMBOLS_PER_SLOT; sym++) { + list->max_num_of_symbol_per_slot_list[sym % NR_NUMBER_OF_SYMBOLS_PER_SLOT].slot_config.value = 0; + if ((sym + 1) % NR_NUMBER_OF_SYMBOLS_PER_SLOT == 0) { slot_number++; + list += 1; + } } } - - if (nrofDownlinkSymbols != 0 || nrofUplinkSymbols != 0) { - for (int sym = 0; sym < nrofDownlinkSymbols; sym++) { - cfg->tdd_table.max_tdd_periodicity_list[slot_number].max_num_of_symbol_per_slot_list[sym].slot_config.value = 0; + // FLEXIBLE SLOTS + if (tdd_slot_bitmap[slot_index].slot_type == TDD_NR_MIXED_SLOT) { + int nrofDLSymbolsInSlot = tdd_slot_bitmap[slot_index].num_dl_symbols; + int nrofULSymbolsInSlot = tdd_slot_bitmap[slot_index].num_ul_symbols; + AssertFatal(nrofDLSymbolsInSlot + nrofULSymbolsInSlot < NR_NUMBER_OF_SYMBOLS_PER_SLOT, + "illegal symbol configuration DL %d, UL %d\n", + nrofDLSymbolsInSlot, + nrofULSymbolsInSlot); + // DL Symbols + for (int sym = 0; sym < nrofDLSymbolsInSlot; sym++) { + list->max_num_of_symbol_per_slot_list[sym].slot_config.value = 0; } - - for (int sym = nrofDownlinkSymbols; sym < NR_NUMBER_OF_SYMBOLS_PER_SLOT - nrofUplinkSymbols; sym++) { - cfg->tdd_table.max_tdd_periodicity_list[slot_number].max_num_of_symbol_per_slot_list[sym].slot_config.value = 2; + // Flexible Symbols + for (int sym = nrofDLSymbolsInSlot; sym < NR_NUMBER_OF_SYMBOLS_PER_SLOT - nrofULSymbolsInSlot; sym++) { + list->max_num_of_symbol_per_slot_list[sym].slot_config.value = 2; } - - for (int sym = NR_NUMBER_OF_SYMBOLS_PER_SLOT - nrofUplinkSymbols; sym < NR_NUMBER_OF_SYMBOLS_PER_SLOT; sym++) { - cfg->tdd_table.max_tdd_periodicity_list[slot_number].max_num_of_symbol_per_slot_list[sym].slot_config.value = 1; + // UL Symbols + for (int sym = NR_NUMBER_OF_SYMBOLS_PER_SLOT - nrofULSymbolsInSlot; sym < NR_NUMBER_OF_SYMBOLS_PER_SLOT; sym++) { + list->max_num_of_symbol_per_slot_list[sym].slot_config.value = 1; } - slot_number++; + list += 1; } - - if (nrofUplinkSlots != 0) { - for (int sym = 0; sym < nrofUplinkSlots * NR_NUMBER_OF_SYMBOLS_PER_SLOT; sym++) { - cfg->tdd_table.max_tdd_periodicity_list[slot_number] - .max_num_of_symbol_per_slot_list[sym % NR_NUMBER_OF_SYMBOLS_PER_SLOT] - .slot_config.value = 1; - - if ((sym + 1) % NR_NUMBER_OF_SYMBOLS_PER_SLOT == 0) + // FULL UPLINK SLOTS + if (tdd_slot_bitmap[slot_index].slot_type == TDD_NR_UPLINK_SLOT) { + for (int sym = 0; sym < NR_NUMBER_OF_SYMBOLS_PER_SLOT; sym++) { + list->max_num_of_symbol_per_slot_list[sym % NR_NUMBER_OF_SYMBOLS_PER_SLOT].slot_config.value = 1; + if ((sym + 1) % NR_NUMBER_OF_SYMBOLS_PER_SLOT == 0) { slot_number++; + list += 1; + } } } } - - return (nb_periods_per_frame); + // Dump 1 period on the output + for (int s = 0; s < fs->numb_slots_period; s++) { + if (tdd_slot_bitmap[s].slot_type == TDD_NR_MIXED_SLOT) { + char flexi_slot[NR_NUMBER_OF_SYMBOLS_PER_SLOT + 1]; + memset(flexi_slot, 0, sizeof(flexi_slot)); + for (int symb = 0; symb < NR_NUMBER_OF_SYMBOLS_PER_SLOT; symb++) { + uint8_t val = cfg->tdd_table.max_tdd_periodicity_list[s].max_num_of_symbol_per_slot_list[symb].slot_config.value; + char *symb_type_s[] = {"D", "U", "F"}; + flexi_slot[symb] = *symb_type_s[val]; + } + flexi_slot[NR_NUMBER_OF_SYMBOLS_PER_SLOT] = '\0'; + LOG_I(NR_PHY, "TDD period configuration: slot %d is FLEXIBLE: %s\n", s, flexi_slot); + } else { + LOG_I(NR_PHY, + "TDD period configuration: slot %d is %s\n", + s, + tdd_slot_bitmap[s].slot_type == TDD_NR_DOWNLINK_SLOT ? "DOWNLINK" : "UPLINK"); + } + } } /******************************************************************* @@ -389,3 +393,48 @@ void free_tdd_configuration_dedicated_nr(NR_DL_FRAME_PARMS *frame_parms) { } } +void do_tdd_config_sim(PHY_VARS_gNB *gNB, int mu) +{ + frame_structure_t fs = {.is_tdd = true}; + fs.numb_slots_frame = (1 << mu) * NR_NUMBER_OF_SUBFRAMES_PER_FRAME; + fs.numb_period_frame = get_nb_periods_per_frame(gNB->gNB_config.tdd_table.tdd_period.value); + fs.numb_slots_period = fs.numb_slots_frame / fs.numb_period_frame; + tdd_period_config_t *pc = &fs.period_cfg; + // Set DL/UL slots + switch (mu) + { + case 0: + pc->num_dl_slots = 3; + pc->num_ul_slots = 1; + break; + + case 1: + pc->num_dl_slots = 7; + pc->num_ul_slots = 2; + break; + + case 3: + pc->num_dl_slots = 27; + pc->num_ul_slots = 12; + break; + + default: + break; + } + for (int i = 0; i < pc->num_dl_slots; i++) { + pc->tdd_slot_bitmap[i].slot_type = TDD_NR_DOWNLINK_SLOT; + pc->tdd_slot_bitmap[i].num_dl_symbols = 0; + pc->tdd_slot_bitmap[i].num_ul_symbols = 0; + } + for (int i = pc->num_dl_slots; i < fs.numb_slots_period - pc->num_ul_slots; i++) { + pc->tdd_slot_bitmap[i].slot_type = TDD_NR_MIXED_SLOT; + pc->tdd_slot_bitmap[i].num_dl_symbols = 6; + pc->tdd_slot_bitmap[i].num_ul_symbols = 4; + } + for (int i = pc->num_ul_slots; i < fs.numb_slots_period; i++) { + pc->tdd_slot_bitmap[i].slot_type = TDD_NR_UPLINK_SLOT; + pc->tdd_slot_bitmap[i].num_dl_symbols = 0; + pc->tdd_slot_bitmap[i].num_ul_symbols = 0; + } + set_tdd_config_nr(&gNB->gNB_config, &fs); +} diff --git a/openair1/SCHED_NR/phy_frame_config_nr.h b/openair1/SCHED_NR/phy_frame_config_nr.h index b477b435f1..0caf612f37 100644 --- a/openair1/SCHED_NR/phy_frame_config_nr.h +++ b/openair1/SCHED_NR/phy_frame_config_nr.h @@ -36,18 +36,16 @@ /*************** FUNCTIONS *****************************************/ -/** \brief This function processes tdd dedicated configuration for nr - * @param frame_parms NR DL Frame parameters - * @param dl_UL_TransmissionPeriodicity periodicity - * @param nrofDownlinkSlots number of downlink slots - * @param nrofDownlinkSymbols number of downlink symbols - * @param nrofUplinkSlots number of uplink slots - * @param nrofUplinkSymbols number of uplink symbols - @returns 0 if tdd dedicated configuration has been properly set or -1 on error with message */ - -int set_tdd_config_nr(nfapi_nr_config_request_scf_t *cfg, int mu, - int nrofDownlinkSlots, int nrofDownlinkSymbols, - int nrofUplinkSlots, int nrofUplinkSymbols); +/** @brief This function processes TDD dedicated configuration for NR + * by processing the tdd_slot_bitmap and period_cfg, and + * allocates memory and fills max_num_of_symbol_per_slot_list + * in the nfapi config request (cfg) + * @param cfg NR config request structure pointer + * @param fs frame structure pointer + * @returns nb_periods_per_frame if TDD has been properly configurated + * -1 tdd configuration can not be done + */ +void set_tdd_config_nr(nfapi_nr_config_request_scf_t *cfg, frame_structure_t *fs); /** \brief This function adds a slot configuration to current dedicated configuration for nr * @param frame_parms NR DL Frame parameters @@ -92,5 +90,7 @@ void free_tdd_configuration_dedicated_nr(NR_DL_FRAME_PARMS *frame_parms); int get_next_downlink_slot(PHY_VARS_gNB *gNB, nfapi_nr_config_request_scf_t *cfg, int nr_frame, int nr_slot); +void do_tdd_config_sim(PHY_VARS_gNB *gNB, int mu); + #endif /* PHY_FRAME_CONFIG_NR_H */ diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 4b3a128211..1a5f34990e 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -388,8 +388,9 @@ int main(int argc, char **argv) frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL; crcTableInit(); nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell,SSB_positions); - gNB->gNB_config.tdd_table.tdd_period.value = 6; - set_tdd_config_nr(&gNB->gNB_config, mu, 7, 6, 2, 4); + // TDD configuration + gNB->gNB_config.tdd_table.tdd_period.value = 6; + do_tdd_config_sim(gNB, mu); phy_init_nr_gNB(gNB); //init_eNB_afterRU(); frame_length_complex_samples = frame_parms->samples_per_subframe; diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index b77b4ad786..b8ebf2bb30 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -448,13 +448,10 @@ int main(int argc, char **argv) frame_parms->freq_range = mu<2 ? FR1 : FR2; nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell, SSB_positions); + // TDD configuration gNB->gNB_config.tdd_table.tdd_period.value = 6; - if (mu == 0) - set_tdd_config_nr(&gNB->gNB_config, mu, 3, 6, 1, 4); - else if (mu == 1) - set_tdd_config_nr(&gNB->gNB_config, mu, 7, 6, 2, 4); - else if (mu == 3) - set_tdd_config_nr(&gNB->gNB_config, mu, 27, 6, 12, 4); + do_tdd_config_sim(gNB, mu); + phy_init_nr_gNB(gNB); frame_parms->ssb_start_subcarrier = 12 * gNB->gNB_config.ssb_table.ssb_offset_point_a.value + ssb_subcarrier_offset; initFloatingCoresTpool(ssb_scan_threads, &nrUE_params.Tpool, false, "UE-tpool"); diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index db3631276c..bd0a50982b 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -568,7 +568,10 @@ int main(int argc, char **argv){ memcpy((void*)&ru->config,(void*)&RC.gNB[0]->gNB_config,sizeof(ru->config)); RC.nb_nr_L1_inst=1; - set_tdd_config_nr(&gNB->gNB_config, mu, 7, 6, 2, 4); + // TDD configuration + gNB->gNB_config.tdd_table.tdd_period.value = 6; + do_tdd_config_sim(gNB, mu); + phy_init_nr_gNB(gNB); nr_phy_init_RU(ru); diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index 62aa21f5f7..bc022d5bc1 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -433,8 +433,10 @@ int main(int argc, char **argv) cfg->carrier_config.num_tx_ant.value = n_tx; cfg->carrier_config.num_rx_ant.value = n_rx; nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); + // TDD configuration gNB->gNB_config.tdd_table.tdd_period.value = 6; - set_tdd_config_nr(&gNB->gNB_config, mu, 7, 6, 2, 4); + do_tdd_config_sim(gNB, mu); + phy_init_nr_gNB(gNB); /* RU handles rxdataF, and gNB just has a pointer. Here, we don't have an RU, * so we need to allocate that memory as well. */ diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 19f48c5d3c..fcc986e92c 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -406,8 +406,10 @@ int main(int argc, char **argv) gNB->frame_parms.nb_antennas_rx = n_rx; nr_phy_config_request_sim(gNB, N_RB_UL, N_RB_UL, mu, Nid_cell, SSB_positions); + // TDD configuration gNB->gNB_config.tdd_table.tdd_period.value = 6; - set_tdd_config_nr(&gNB->gNB_config, mu, 7, 6, 2, 4); + do_tdd_config_sim(gNB, mu); + phy_init_nr_gNB(gNB); //configure UE diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index e4001ebe5f..4670a95f6f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -468,12 +468,7 @@ static int config_frame_structure(int mu, fs->numb_slots_period = fs->numb_slots_frame / fs->numb_period_frame; fs->is_tdd = true; config_tdd_patterns(scc->tdd_UL_DL_ConfigurationCommon, fs); - set_tdd_config_nr(cfg, - mu, - scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots, - scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols, - scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots, - scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols); + set_tdd_config_nr(cfg, fs); } else { // FDD fs->is_tdd = false; fs->numb_period_frame = 1; @@ -521,10 +516,10 @@ static void config_common(gNB_MAC_INST *nrmac, } } struct NR_FrequencyInfoUL *frequencyInfoUL = scc->uplinkConfigCommon->frequencyInfoUL; + int scs = frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; frequency_range = *frequencyInfoUL->frequencyBandList->list.array[0] > 256 ? FR2 : FR1; - bw_index = get_supported_band_index(frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing, - frequency_range, - frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth); + bw_index = + get_supported_band_index(scs, frequency_range, frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth); cfg->carrier_config.uplink_bandwidth.value = get_supported_bw_mhz(frequency_range, bw_index); cfg->carrier_config.uplink_bandwidth.tl.tag = NFAPI_NR_CONFIG_UPLINK_BANDWIDTH_TAG; // temporary cfg->num_tlv++; @@ -543,7 +538,7 @@ static void config_common(gNB_MAC_INST *nrmac, cfg->num_tlv++; for (int i = 0; i < 5; i++) { - if (i == frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing) { + if (i == scs) { cfg->carrier_config.ul_grid_size[i].value = frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth; cfg->carrier_config.ul_k0[i].value = frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier; cfg->carrier_config.ul_grid_size[i].tl.tag = NFAPI_NR_CONFIG_UL_GRID_SIZE_TAG; @@ -642,21 +637,15 @@ static void config_common(gNB_MAC_INST *nrmac, prach_fd_occasion->k1.value = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE) + rach_ConfigCommon->rach_ConfigGeneric.msg1_FrequencyStart - + (get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing.value, - frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing) - * i); + + (get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing.value, scs) * i); if (IS_SA_MODE(get_softmodem_params())) { prach_fd_occasion->k1.value = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE) + rach_ConfigCommon->rach_ConfigGeneric.msg1_FrequencyStart - + (get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing.value, - frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing) - * i); + + (get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing.value, scs) * i); } else { prach_fd_occasion->k1.value = rach_ConfigCommon->rach_ConfigGeneric.msg1_FrequencyStart - + (get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing.value, - frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing) - * i); + + (get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing.value, scs) * i); } prach_fd_occasion->k1.tl.tag = NFAPI_NR_CONFIG_K1_TAG; cfg->num_tlv++; @@ -789,14 +778,18 @@ static void config_common(gNB_MAC_INST *nrmac, cfg->tdd_table.tdd_period.value = *scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530; } LOG_D(NR_MAC, "Setting TDD configuration period to %d\n", cfg->tdd_table.tdd_period.value); - int periods_per_frame = set_tdd_config_nr(cfg, - frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing, - scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots, - scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols, - scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots, - scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols); - - AssertFatal(periods_per_frame > 0, "TDD configuration cannot be configured\n"); + NR_TDD_UL_DL_Pattern_t *pattern1 = &scc->tdd_UL_DL_ConfigurationCommon->pattern1; + tdd_period_config_t period_cfg = {.num_dl_slots = pattern1->nrofDownlinkSlots, + .num_ul_slots = pattern1->nrofUplinkSlots, + .tdd_slot_bitmap[0].slot_type = TDD_NR_MIXED_SLOT, + .tdd_slot_bitmap[0].num_dl_symbols = pattern1->nrofDownlinkSymbols, + .tdd_slot_bitmap[0].num_ul_symbols = pattern1->nrofUplinkSymbols}; + frame_structure_t fs = {.period_cfg = period_cfg, .is_tdd = true}; + fs.numb_slots_frame = nr_slots_per_frame[scs]; + fs.numb_period_frame = get_nb_periods_per_frame(cfg->tdd_table.tdd_period.value); + fs.numb_slots_period = ((1 << scs) * NR_NUMBER_OF_SUBFRAMES_PER_FRAME) / fs.numb_period_frame; + set_tdd_config_nr(cfg, &fs); + AssertFatal(fs.numb_period_frame > 0, "TDD configuration cannot be configured\n"); } int nb_tx = config->nb_bfw[0]; // number of tx antennas