Commit 98b3f4d4 authored by hsum's avatar hsum

Refactor nr_slot_select function to improve readability and maintainability

parent a0eaf8ad
...@@ -295,63 +295,46 @@ int get_next_downlink_slot(PHY_VARS_gNB *gNB, nfapi_nr_config_request_scf_t *cfg ...@@ -295,63 +295,46 @@ 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)
{
/* for FFD all slot can be considered as an uplink */ /* for FFD all slot can be considered as an uplink */
int mu = cfg->ssb_config.scs_common.value,check_slot=0; int mu = cfg->ssb_config.scs_common.value;
int check_slot = 0;
int nb_max_tdd_periodicity = get_nb_max_tdd_periodicity(mu, cfg->tdd_table.tdd_period.value);
if (cfg->cell_config.frame_duplex_type.value == FDD) { 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_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);
}
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++;
}
} }
if(check_slot == NR_NUMBER_OF_SYMBOLS_PER_SLOT) { for (int symbol_count = 0; symbol_count < NR_NUMBER_OF_SYMBOLS_PER_SLOT; symbol_count++) {
return (NR_DOWNLINK_SLOT); if (cfg->tdd_table.max_tdd_periodicity_list[nr_slot % nb_max_tdd_periodicity]
} else { .max_num_of_symbol_per_slot_list[symbol_count]
return (NR_MIXED_SLOT); .slot_config.value
} == 1) {
} else {
for(int symbol_count=0; symbol_count<NR_NUMBER_OF_SYMBOLS_PER_SLOT; symbol_count++) {
if (cfg->tdd_table.max_tdd_periodicity_list[((1<<mu) * NR_NUMBER_OF_SUBFRAMES_PER_FRAME) + nr_slot].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value==1) {
check_slot++; check_slot++;
} }
} }
if(check_slot == NR_NUMBER_OF_SYMBOLS_PER_SLOT) { if (check_slot == NR_NUMBER_OF_SYMBOLS_PER_SLOT) {
return (NR_UPLINK_SLOT); return (NR_UPLINK_SLOT);
} }
check_slot = 0; check_slot = 0;
for(int symbol_count=0; symbol_count<NR_NUMBER_OF_SYMBOLS_PER_SLOT; symbol_count++) { for (int symbol_count = 0; symbol_count < NR_NUMBER_OF_SYMBOLS_PER_SLOT; symbol_count++) {
if (cfg->tdd_table.max_tdd_periodicity_list[((1<<mu) * NR_NUMBER_OF_SUBFRAMES_PER_FRAME) + nr_slot].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value==0) { if (cfg->tdd_table.max_tdd_periodicity_list[nr_slot % nb_max_tdd_periodicity]
.max_num_of_symbol_per_slot_list[symbol_count]
.slot_config.value
== 0) {
check_slot++; check_slot++;
} }
} }
if(check_slot == NR_NUMBER_OF_SYMBOLS_PER_SLOT) { if (check_slot == NR_NUMBER_OF_SYMBOLS_PER_SLOT) {
return (NR_DOWNLINK_SLOT); return (NR_DOWNLINK_SLOT);
} else { } else {
return (NR_MIXED_SLOT); return (NR_MIXED_SLOT);
} }
}
} }
/******************************************************************* /*******************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment