Commit a42dd041 authored by hsum's avatar hsum Committed by dong881

Enable Dynamic Adjustment of TDD Table Based on Configuration

- Enhanced `pack_nr_config_request` and `unpack_nr_config_request` functions in `nfapi_p5.c`:
  - Removed static assertion for TDD period value.
  - Introduced dynamic calculation of the TDD table size based on `dl_UL_TransmissionPeriodicity` and subcarrier spacing.
  - Added detailed logging for the TDD table content.
- Refactored `nr_slot_select` function in `phy_frame_config_nr.c` to streamline the selection logic for different slot types, removing outdated code handling alternating frames.

Now, the TDD table can be dynamically adjusted based on the `dl_UL_TransmissionPeriodicity` settings in the configuration file. Each transmission will pack and send a complete TDD table.
parent a2d6af56
......@@ -388,6 +388,13 @@ int get_nb_periods_per_frame(uint8_t tdd_period)
return nb_periods_per_frame;
}
int get_nb_max_tdd_periodicity(uint8_t mu, uint8_t tdd_period){
int nr_slots_frame[] = {10, 20, 40, 80, 160};
int slots = nr_slots_frame[mu];
int nb_periods_per_frame = get_nb_periods_per_frame(tdd_period);
return slots / nb_periods_per_frame;
}
void get_delta_arfcn(int i, uint32_t nrarfcn, uint64_t N_OFFs)
{
uint32_t delta_arfcn = nrarfcn - N_OFFs;
......
......@@ -769,12 +769,13 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) {
radio_tx_gpio_flag_t flags_gpio = 0;
if (cfg->cell_config.frame_duplex_type.value == TDD && !get_softmodem_params()->continuous_tx) {
int slot_type = nr_slot_select(cfg,frame,slot%fp->slots_per_frame);
int max_tdd_periodicity_num = get_nb_max_tdd_periodicity(cfg->ssb_config.scs_common.value,cfg->tdd_table.tdd_period.value);
int slot_type = nr_slot_select(cfg,frame,slot);
if(slot_type == NR_MIXED_SLOT) {
int txsymb = 0;
for(int symbol_count = 0; symbol_count<NR_NUMBER_OF_SYMBOLS_PER_SLOT; symbol_count++) {
if (cfg->tdd_table.max_tdd_periodicity_list[slot].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value == 0)
if (cfg->tdd_table.max_tdd_periodicity_list[slot%max_tdd_periodicity_num].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value == 0)
txsymb++;
}
......@@ -931,7 +932,7 @@ static void fill_split7_2_config(split7_config_t *split7, const nfapi_nr_config_
split7->n_tdd_period = slots_per_frame / nb_periods_per_frame;
for (int slot = 0; slot < split7->n_tdd_period; ++slot) {
for (int sym = 0; sym < 14; ++sym) {
split7->slot_dirs[slot].sym_dir[sym] = tdd_table->max_tdd_periodicity_list[slot].max_num_of_symbol_per_slot_list[sym].slot_config.value;
split7->slot_dirs[slot%10].sym_dir[sym] = tdd_table->max_tdd_periodicity_list[slot%10].max_num_of_symbol_per_slot_list[sym].slot_config.value;
}
}
}
......
......@@ -38,6 +38,7 @@
#include "nfapi_nr_interface_scf.h"
#include "nfapi/oai_integration/vendor_ext.h"
#include <debug.h>
#include "common/utils/nr/nr_common.h"
// Pack routines
......@@ -1935,8 +1936,9 @@ static uint8_t pack_nr_config_request(void *msg, uint8_t **ppWritePackedMsg, uin
end,
&pack_uint8_tlv_value);
numTLVs++;
// END TDD Table
for (int i = 0; i < 2*(1<<mu)*10; i++) {
int nb_max_tdd_periodicity = get_nb_max_tdd_periodicity(mu,pNfapiMsg->tdd_table.tdd_period.value);
for (int i = 0; i < nb_max_tdd_periodicity; i++) {
for (int k = 0; k < 14; k++) {
pack_nr_tlv(NFAPI_NR_CONFIG_SLOT_CONFIG_TAG,
&(pNfapiMsg->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list[k].slot_config),
......@@ -1946,6 +1948,7 @@ static uint8_t pack_nr_config_request(void *msg, uint8_t **ppWritePackedMsg, uin
numTLVs++;
}
}
// END TDD Table
}
// START Measurement Config
// SCF222.10.02 Table 3-27 : Contains only one TLV and is currently unused
......@@ -3190,8 +3193,8 @@ static uint8_t unpack_nr_config_request(uint8_t **ppReadPackedMsg, uint8_t *end,
pNfapiMsg->tdd_table.max_tdd_periodicity_list =
(nfapi_nr_max_tdd_periodicity_t *)malloc(1 * sizeof(nfapi_nr_max_tdd_periodicity_t));
// Initialize first, and upon receiving the SCS, reallocate memory to the correct size.
pNfapiMsg->tdd_table.max_tdd_periodicity_list[0].max_num_of_symbol_per_slot_list =
(nfapi_nr_max_num_of_symbol_per_slot_t *)malloc(14 * sizeof(nfapi_nr_max_num_of_symbol_per_slot_t));
pNfapiMsg->tdd_table.max_tdd_periodicity_list[0].max_num_of_symbol_per_slot_list =
(nfapi_nr_max_num_of_symbol_per_slot_t *)malloc(14 * sizeof(nfapi_nr_max_num_of_symbol_per_slot_t));
pNfapiMsg->prach_config.num_prach_fd_occasions_list =
(nfapi_nr_num_prach_fd_occasions_t *)calloc(10, sizeof(nfapi_nr_num_prach_fd_occasions_t));
// unpack TLVs
......@@ -3379,6 +3382,21 @@ static uint8_t unpack_nr_config_request(uint8_t **ppReadPackedMsg, uint8_t *end,
end);
config_beam_idx++;
break;
case NFAPI_NR_CONFIG_TDD_PERIOD_TAG:
printf("*** have tag %x, idx %ld\n", generic_tl.tag, idx);
assert(idx <= sizeof(unpack_fns) / sizeof(unpack_fns[0]));
result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end);
uint8_t mu = pNfapiMsg->ssb_config.scs_common.value;
uint8_t period = pNfapiMsg->tdd_table.tdd_period.value;
// Memory allocations
int nb_max_tdd_periodicity = get_nb_max_tdd_periodicity(mu,pNfapiMsg->tdd_table.tdd_period.value);
pNfapiMsg->tdd_table.max_tdd_periodicity_list =
(nfapi_nr_max_tdd_periodicity_t *)malloc(nb_max_tdd_periodicity * sizeof(nfapi_nr_max_tdd_periodicity_t));
for (int i = 0; i < nb_max_tdd_periodicity; i++) {
pNfapiMsg->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list =
(nfapi_nr_max_num_of_symbol_per_slot_t *)malloc(14 * sizeof(nfapi_nr_max_num_of_symbol_per_slot_t));
}
break;
case NFAPI_NR_CONFIG_SLOT_CONFIG_TAG:
pNfapiMsg->tdd_table.max_tdd_periodicity_list[tdd_periodicity_idx]
.max_num_of_symbol_per_slot_list[symbol_per_slot_idx]
......@@ -3396,19 +3414,6 @@ static uint8_t unpack_nr_config_request(uint8_t **ppReadPackedMsg, uint8_t *end,
tdd_periodicity_idx++;
}
break;
case NFAPI_NR_CONFIG_SCS_COMMON_TAG:
printf("*** have tag %x, idx %ld\n", generic_tl.tag, idx);
assert(idx <= sizeof(unpack_fns) / sizeof(unpack_fns[0]));
result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end);
uint8_t mu = pNfapiMsg->ssb_config.scs_common.value;
// Memory allocations
pNfapiMsg->tdd_table.max_tdd_periodicity_list =
(nfapi_nr_max_tdd_periodicity_t *)malloc(2*(1<<mu)*10 * sizeof(nfapi_nr_max_tdd_periodicity_t));
for (int i = 0; i < 2*(1<<mu)*10; i++) {
pNfapiMsg->tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list =
(nfapi_nr_max_num_of_symbol_per_slot_t *)malloc(14 * sizeof(nfapi_nr_max_num_of_symbol_per_slot_t));
}
break;
default:
/* unpack based on unpack_fns table above, this is a normal case */
printf("*** have tag %x, idx %ld\n", generic_tl.tag, idx);
......@@ -3484,7 +3489,6 @@ static uint8_t unpack_nr_config_request(uint8_t **ppReadPackedMsg, uint8_t *end,
}
struct sockaddr_in vnf_p7_sockaddr;
memcpy(&vnf_p7_sockaddr.sin_addr.s_addr, &(pNfapiMsg->nfapi_config.p7_vnf_address_ipv4), 4);
printf("[PNF] vnf p7 %s:%d\n", inet_ntoa(vnf_p7_sockaddr.sin_addr), pNfapiMsg->nfapi_config.p7_vnf_port.value);
return 1;
}
......
......@@ -297,60 +297,36 @@ 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) {
/* 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) {
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++;
}
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%nb_max_tdd_periodicity].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;
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++;
}
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%nb_max_tdd_periodicity].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_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++;
}
}
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[((1<<mu) * NR_NUMBER_OF_SUBFRAMES_PER_FRAME) + 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);
}
return (NR_MIXED_SLOT);
}
}
......
......@@ -567,9 +567,10 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) {
(pucch->slot == slot_rx) ) {
nfapi_nr_pucch_pdu_t *pucch_pdu = &pucch->pucch_pdu;
LOG_D(PHY,"%d.%d pucch %d : start_symbol %d, nb_symbols %d, prb_size %d\n",frame_rx,slot_rx,i,pucch_pdu->start_symbol_index,pucch_pdu->nr_of_symbols,pucch_pdu->prb_size);
int max_tdd_periodicity_num = get_nb_max_tdd_periodicity(gNB->gNB_config.ssb_config.scs_common.value,gNB->gNB_config.tdd_table.tdd_period.value);
for (int symbol=pucch_pdu->start_symbol_index ; symbol<(pucch_pdu->start_symbol_index+pucch_pdu->nr_of_symbols);symbol++) {
if(gNB->frame_parms.frame_type == FDD ||
(gNB->frame_parms.frame_type == TDD && gNB->gNB_config.tdd_table.max_tdd_periodicity_list[slot_rx].max_num_of_symbol_per_slot_list[symbol].slot_config.value==1)) {
(gNB->frame_parms.frame_type == TDD && gNB->gNB_config.tdd_table.max_tdd_periodicity_list[slot_rx%max_tdd_periodicity_num].max_num_of_symbol_per_slot_list[symbol].slot_config.value==1)) {
for (rb=0; rb<pucch_pdu->prb_size; rb++) {
rb2 = rb + pucch_pdu->bwp_start +
((symbol < pucch_pdu->start_symbol_index+(pucch_pdu->nr_of_symbols>>1)) || (pucch_pdu->freq_hop_flag == 0) ?
......@@ -589,10 +590,12 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) {
if ((ulsch->active == true) && (ulsch->frame == frame_rx) && (ulsch->slot == slot_rx) && (ulsch->handled == 0)) {
uint8_t symbol_start = ulsch_harq->ulsch_pdu.start_symbol_index;
uint8_t symbol_end = symbol_start + ulsch_harq->ulsch_pdu.nr_of_symbols;
int max_tdd_periodicity_num = get_nb_max_tdd_periodicity(gNB->gNB_config.ssb_config.scs_common.value,gNB->gNB_config.tdd_table.tdd_period.value);
for (int symbol = symbol_start; symbol < symbol_end; symbol++) {
if (gNB->frame_parms.frame_type == FDD
|| (gNB->frame_parms.frame_type == TDD
&& gNB->gNB_config.tdd_table.max_tdd_periodicity_list[slot_rx]
&& gNB->gNB_config.tdd_table.max_tdd_periodicity_list[slot_rx%max_tdd_periodicity_num]
.max_num_of_symbol_per_slot_list[symbol]
.slot_config.value
== 1)) {
......@@ -720,11 +723,11 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx)
LOG_D(PHY,"phy_procedures_gNB_uespec_RX frame %d, slot %d\n",frame_rx,slot_rx);
fill_ul_rb_mask(gNB, frame_rx, slot_rx);
int max_tdd_periodicity_num = get_nb_max_tdd_periodicity(gNB->gNB_config.ssb_config.scs_common.value,gNB->gNB_config.tdd_table.tdd_period.value);
int first_symb=0,num_symb=0;
if (gNB->frame_parms.frame_type == TDD)
for(int symbol_count=0; symbol_count<NR_NUMBER_OF_SYMBOLS_PER_SLOT; symbol_count++) {
if (gNB->gNB_config.tdd_table.max_tdd_periodicity_list[slot_rx].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value==1) {
if (gNB->gNB_config.tdd_table.max_tdd_periodicity_list[slot_rx%max_tdd_periodicity_num].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value==1) {
if (num_symb==0) first_symb=symbol_count;
num_symb++;
}
......
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