From 16ead1d001e8801cba21d2f57c6434bd2c0b90b7 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 14 Feb 2024 18:10:15 +0100 Subject: [PATCH] nr_slot_select() and set_tdd_config_nr(): remove useless second frame FAPI says these lists should be for MAX_TDD_PERIODICITY (which is maybe a frame, or a TDD period? but likely not two frames). Reduce to one frame. Also, the nFAPI code assumes one entire frame, so use that (this commit necessary to actually make the PNF work, otherwise, the packing/unpacking of the FAPI message would need to do 2 frames). Closes: #876 --- openair1/PHY/impl_defs_top.h | 1 - openair1/SCHED_NR/phy_frame_config_nr.c | 176 +++++++----------- openair1/SCHED_NR/phy_frame_config_nr.h | 4 - openair1/SIMULATION/NR_PHY/dlschsim.c | 2 +- openair1/SIMULATION/NR_PHY/pbchsim.c | 2 +- openair1/SIMULATION/NR_PHY/prachsim.c | 2 +- openair1/SIMULATION/NR_PHY/pucchsim.c | 2 +- openair1/SIMULATION/NR_PHY/ulschsim.c | 2 +- .../unit_tests/src/frame_config_test.c | 6 +- openair2/LAYER2/NR_MAC_UE/config_ue_sl.c | 2 +- 10 files changed, 77 insertions(+), 122 deletions(-) diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h index 27384532c5..178549e5cc 100644 --- a/openair1/PHY/impl_defs_top.h +++ b/openair1/PHY/impl_defs_top.h @@ -268,7 +268,6 @@ #if 1 #define NB_NUMEROLOGIES_NR (5) -#define TDD_CONFIG_NB_FRAMES (2) #define NR_MAX_SLOTS_PER_FRAME (160) /* number of slots per frame */ /* FFS_NR_TODO it defines ue capability which is the number of slots */ diff --git a/openair1/SCHED_NR/phy_frame_config_nr.c b/openair1/SCHED_NR/phy_frame_config_nr.c index 7c8e6e978d..ad672bccb8 100644 --- a/openair1/SCHED_NR/phy_frame_config_nr.c +++ b/openair1/SCHED_NR/phy_frame_config_nr.c @@ -67,101 +67,84 @@ int set_tdd_config_nr(nfapi_nr_config_request_scf_t *cfg, int nrofUplinkSlots, int nrofUplinkSymbols) { - 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 = TDD_CONFIG_NB_FRAMES*(1<tdd_table.max_tdd_periodicity_list = (nfapi_nr_max_tdd_periodicity_t *) malloc(nb_slots_to_set*sizeof(nfapi_nr_max_tdd_periodicity_t)); + cfg->tdd_table.max_tdd_periodicity_list = calloc(nb_slots_to_set, sizeof(nfapi_nr_max_tdd_periodicity_t)); - for(int memory_alloc =0 ; memory_alloctdd_table.max_tdd_periodicity_list[memory_alloc].max_num_of_symbol_per_slot_list = (nfapi_nr_max_num_of_symbol_per_slot_t *) malloc(NR_NUMBER_OF_SYMBOLS_PER_SLOT*sizeof( - nfapi_nr_max_num_of_symbol_per_slot_t)); - for(int number_of_symbol = 0; number_of_symbol < NR_NUMBER_OF_SYMBOLS_PER_SLOT; number_of_symbol++ ){ - //for each symbol, assign the TLV tag for usage when packing - cfg->tdd_table.max_tdd_periodicity_list[memory_alloc].max_num_of_symbol_per_slot_list[number_of_symbol].slot_config.tl.tag = NFAPI_NR_CONFIG_SLOT_CONFIG_TAG; + 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)); + 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; } } - while(slot_number != nb_slots_to_set) { - if(nrofDownlinkSlots != 0) { - for (int number_of_symbol = 0; number_of_symbol < nrofDownlinkSlots*NR_NUMBER_OF_SYMBOLS_PER_SLOT; number_of_symbol++) { - cfg->tdd_table.max_tdd_periodicity_list[slot_number].max_num_of_symbol_per_slot_list[number_of_symbol%NR_NUMBER_OF_SYMBOLS_PER_SLOT].slot_config.value= 0; + 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((number_of_symbol+1)%NR_NUMBER_OF_SYMBOLS_PER_SLOT == 0) + if ((sym + 1) % NR_NUMBER_OF_SYMBOLS_PER_SLOT == 0) slot_number++; } } if (nrofDownlinkSymbols != 0 || nrofUplinkSymbols != 0) { - for(int number_of_symbol =0; number_of_symbol < nrofDownlinkSymbols; number_of_symbol++) { - cfg->tdd_table.max_tdd_periodicity_list[slot_number].max_num_of_symbol_per_slot_list[number_of_symbol].slot_config.value= 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; } - for(int number_of_symbol = nrofDownlinkSymbols; number_of_symbol < NR_NUMBER_OF_SYMBOLS_PER_SLOT-nrofUplinkSymbols; number_of_symbol++) { - cfg->tdd_table.max_tdd_periodicity_list[slot_number].max_num_of_symbol_per_slot_list[number_of_symbol].slot_config.value= 2; + 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; } - for(int number_of_symbol = NR_NUMBER_OF_SYMBOLS_PER_SLOT-nrofUplinkSymbols; number_of_symbol < NR_NUMBER_OF_SYMBOLS_PER_SLOT; number_of_symbol++) { - cfg->tdd_table.max_tdd_periodicity_list[slot_number].max_num_of_symbol_per_slot_list[number_of_symbol].slot_config.value= 1; + 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; } slot_number++; } - if(nrofUplinkSlots != 0) { - for (int number_of_symbol = 0; number_of_symbol < nrofUplinkSlots*NR_NUMBER_OF_SYMBOLS_PER_SLOT; number_of_symbol++) { - cfg->tdd_table.max_tdd_periodicity_list[slot_number].max_num_of_symbol_per_slot_list[number_of_symbol%NR_NUMBER_OF_SYMBOLS_PER_SLOT].slot_config.value= 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((number_of_symbol+1)%NR_NUMBER_OF_SYMBOLS_PER_SLOT == 0) + if ((sym + 1) % NR_NUMBER_OF_SYMBOLS_PER_SLOT == 0) slot_number++; } } } - /* - while(slot_number != nb_slots_to_set) { - for (int number_of_slot = 0; number_of_slot < nrofDownlinkSlots; number_of_slot++) { - frame_parms->tdd_uplink_nr[slot_number] = NR_TDD_DOWNLINK_SLOT; - printf("slot %d set as downlink\n",slot_number); - slot_number++; - } - - if (nrofDownlinkSymbols != 0 || nrofUplinkSymbols != 0) { - frame_parms->tdd_uplink_nr[slot_number] = (1<tdd_uplink_nr[slot_number] = NR_TDD_UPLINK_SLOT; - printf("slot %d set as uplink\n",slot_number); - slot_number++; - } - - if (p_tdd_ul_dl_configuration->nrofUplinkSymbols != 0) { - LOG_E(PHY,"set_tdd_configuration_nr: uplink symbol for slot is not supported for tdd configuration \n"); - return (-1); - } - } - - if (frame_parms->p_tdd_UL_DL_ConfigurationCommon2 != NULL) { - LOG_E(PHY,"set_tdd_configuration_nr: additionnal tdd configuration 2 is not supported for tdd configuration \n"); - return (-1); - }*/ return (nb_periods_per_frame); } @@ -235,7 +218,7 @@ int set_tdd_configuration_dedicated_nr(NR_DL_FRAME_PARMS *frame_parms) { while(p_current_TDD_UL_DL_SlotConfig != NULL) { int slot_index = p_current_TDD_UL_DL_SlotConfig->slotIndex; - if (slot_index < TDD_CONFIG_NB_FRAMES * frame_parms->slots_per_frame) { + if (slot_index < frame_parms->slots_per_frame) { if (p_current_TDD_UL_DL_SlotConfig->nrofDownlinkSymbols != 0) { if (p_current_TDD_UL_DL_SlotConfig->nrofDownlinkSymbols == NR_TDD_SET_ALL_SYMBOLS) { if (p_current_TDD_UL_DL_SlotConfig->nrofUplinkSymbols == 0) { @@ -306,62 +289,39 @@ int get_next_downlink_slot(PHY_VARS_gNB *gNB, nfapi_nr_config_request_scf_t *cfg } } -int nr_slot_select(nfapi_nr_config_request_scf_t *cfg, int nr_frame, int nr_slot) { +int nr_slot_select(nfapi_nr_config_request_scf_t *cfg, int nr_frame, int nr_slot) +{ + (void) nr_frame; + /* for FFD all slot can be considered as an uplink */ - int mu = cfg->ssb_config.scs_common.value,check_slot=0; + int check_slot = 0; if (cfg->cell_config.frame_duplex_type.value == FDD) { - return (NR_UPLINK_SLOT | NR_DOWNLINK_SLOT ); + return (NR_UPLINK_SLOT | NR_DOWNLINK_SLOT); } - if (nr_frame%2 == 0) { - for(int symbol_count=0; symbol_counttdd_table.max_tdd_periodicity_list[nr_slot].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value==1) { - check_slot++; - } + for (int symbol_count = 0; symbol_count < NR_NUMBER_OF_SYMBOLS_PER_SLOT; symbol_count++) { + if (cfg->tdd_table.max_tdd_periodicity_list[nr_slot].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value == 1) { + check_slot++; } + } - if(check_slot == NR_NUMBER_OF_SYMBOLS_PER_SLOT) { - return (NR_UPLINK_SLOT); + if (check_slot == NR_NUMBER_OF_SYMBOLS_PER_SLOT) { + return (NR_UPLINK_SLOT); + } + + check_slot = 0; + + for (int symbol_count = 0; symbol_count < NR_NUMBER_OF_SYMBOLS_PER_SLOT; symbol_count++) { + if (cfg->tdd_table.max_tdd_periodicity_list[nr_slot].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value == 0) { + check_slot++; } + } - check_slot = 0; - - for(int symbol_count=0; symbol_counttdd_table.max_tdd_periodicity_list[nr_slot].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value==0) { - check_slot++; - } - } - - if(check_slot == NR_NUMBER_OF_SYMBOLS_PER_SLOT) { - return (NR_DOWNLINK_SLOT); - } else { - return (NR_MIXED_SLOT); - } + if (check_slot == NR_NUMBER_OF_SYMBOLS_PER_SLOT) { + return (NR_DOWNLINK_SLOT); } else { - for(int symbol_count=0; symbol_counttdd_table.max_tdd_periodicity_list[((1<tdd_table.max_tdd_periodicity_list[((1<gNB_config.tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list); free(gNB->gNB_config.tdd_table.max_tdd_periodicity_list); diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index b6d92b9b81..b77b4ad786 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -782,7 +782,7 @@ int main(int argc, char **argv) free_channel_desc_scm(gNB2UE); - int nb_slots_to_set = TDD_CONFIG_NB_FRAMES * (1 << mu) * NR_NUMBER_OF_SUBFRAMES_PER_FRAME; + int nb_slots_to_set = (1 << mu) * NR_NUMBER_OF_SUBFRAMES_PER_FRAME; for (int i = 0; i < nb_slots_to_set; ++i) free(gNB->gNB_config.tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list); free(gNB->gNB_config.tdd_table.max_tdd_periodicity_list); diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 5eab1c6974..18c762051a 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -825,7 +825,7 @@ int main(int argc, char **argv){ phy_free_nr_gNB(gNB); // allocated in set_tdd_config_nr() - int nb_slots_to_set = TDD_CONFIG_NB_FRAMES*(1<gNB_config.prach_config.num_prach_fd_occasions_list); for (int i = 0; i < nb_slots_to_set; ++i) free(gNB->gNB_config.tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list); diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index ab73a13626..62aa21f5f7 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -762,7 +762,7 @@ int main(int argc, char **argv) free_channel_desc_scm(UE2gNB); term_freq_channel(); - int nb_slots_to_set = TDD_CONFIG_NB_FRAMES * (1 << mu) * NR_NUMBER_OF_SUBFRAMES_PER_FRAME; + int nb_slots_to_set = (1 << mu) * NR_NUMBER_OF_SUBFRAMES_PER_FRAME; for (int i = 0; i < nb_slots_to_set; ++i) free(gNB->gNB_config.tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list); free(gNB->gNB_config.tdd_table.max_tdd_periodicity_list); diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 8a39852995..5c55e4ad13 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -598,7 +598,7 @@ int main(int argc, char **argv) free_nr_ue_ul_harq(UE->ul_harq_processes, NR_MAX_ULSCH_HARQ_PROCESSES, UE->frame_parms.N_RB_UL, UE->frame_parms.nb_antennas_tx); - int nb_slots_to_set = TDD_CONFIG_NB_FRAMES * (1 << mu) * NR_NUMBER_OF_SUBFRAMES_PER_FRAME; + int nb_slots_to_set = (1 << mu) * NR_NUMBER_OF_SUBFRAMES_PER_FRAME; for (int i = 0; i < nb_slots_to_set; ++i) free(gNB->gNB_config.tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list); free(gNB->gNB_config.tdd_table.max_tdd_periodicity_list); diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c index 093bb2d000..6e0f78d3ab 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/frame_config_test.c @@ -54,9 +54,9 @@ void display_frame_configuration(NR_DL_FRAME_PARMS *frame_parms) { printf("\nTdd configuration tti %d downlink %d uplink %d period %d \n", frame_parms->slots_per_subframe, frame_parms->p_tdd_UL_DL_Configuration->nrofDownlinkSlots, frame_parms->p_tdd_UL_DL_Configuration->nrofUplinkSlots, frame_parms->p_tdd_UL_DL_Configuration->dl_UL_TransmissionPeriodicity); - int k = (TDD_CONFIG_NB_FRAMES * NR_NUMBER_OF_SUBFRAMES_PER_FRAME) - 1; //19; + int k = NR_NUMBER_OF_SUBFRAMES_PER_FRAME - 1; int tti = 0; - for (int j = 0; j < TDD_CONFIG_NB_FRAMES * frame_parms->slots_per_frame; j++) { + for (int j = 0; j < frame_parms->slots_per_frame; j++) { int frame = 0; if (j != 0) { frame = j / frame_parms->slots_per_frame; @@ -81,7 +81,7 @@ void display_frame_configuration(NR_DL_FRAME_PARMS *frame_parms) { } if (j == k) { printf("\n"); - k += (TDD_CONFIG_NB_FRAMES * NR_NUMBER_OF_SUBFRAMES_PER_FRAME); // 20 + k += NR_NUMBER_OF_SUBFRAMES_PER_FRAME; } } printf("\n"); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue_sl.c b/openair2/LAYER2/NR_MAC_UE/config_ue_sl.c index babdd96f10..58db78ea83 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue_sl.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue_sl.c @@ -43,7 +43,7 @@ void sl_ue_mac_free(NR_UE_MAC_INST_t *mac) // @todo: maybe this should be done by phy if (tdd_list) { int mu = sl_config->sl_bwp_config.sl_scs; - int nb_slots_to_set = TDD_CONFIG_NB_FRAMES*(1<