Commit 5ac8b6f3 authored by Ahmed Hussein's avatar Ahmed Hussein Committed by Guido Casati

TA implementation complete and tested in rfsimulator

parent 0492f7eb
......@@ -119,7 +119,7 @@ SystemInformationBlockType1_nr_t;
#define NR_TDD_SET_ALL_SYMBOLS (0x3FFF)
#define NR_DOWNLINK_SLOT (0x01)
#define NR_UPLINK_SLOT (0x02)
#define NR_UPLINK_SLOT (0x05)
#define FRAME_DURATION_MICRO_SEC (10000) /* frame duration in microsecond */
......
......@@ -268,10 +268,10 @@ void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id,
// --------------------
nfapi_rx_indication_pdu_t *pdu;
int timing_advance_update;
int sync_pos;
uint16_t mu = gNB->gNB_config.subframe_config.numerology_index_mu.value;
// pthread_mutex_lock(&gNB->UL_INFO_mutex);
// gNB->UL_INFO.rx_ind.sfn_sf = frame<<4| slot_rx;
......@@ -285,19 +285,16 @@ void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id,
// pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG;
// pdu->rx_indication_rel8.length = gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->TBS>>3;
// pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation
pdu->data = gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->b;
// estimate timing advance for MAC
sync_pos = nr_est_timing_advance_pusch(gNB, UE_id);
timing_advance_update = sync_pos; // - gNB->frame_parms.nb_prefix_samples/4; //to check
sync_pos = nr_est_timing_advance_pusch(gNB, UE_id); // estimate timing advance for MAC
timing_advance_update = sync_pos * (1 << mu); // scale by the used scs numerology
// scale the 16 factor in N_TA calculation in 38.213 section 4.2 according to the used FFT size
switch (gNB->frame_parms.N_RB_DL) {
// case 6: /* nothing to do */ break;
// case 15: timing_advance_update /= 2; break;
// case 25: timing_advance_update /= 4; break;
// case 50: timing_advance_update /= 8; break;
// case 75: timing_advance_update /= 12; break;
case 106: timing_advance_update /= 16; break;
case 217: timing_advance_update /= 32; break;
case 245: timing_advance_update /= 32; break;
case 273: timing_advance_update /= 32; break;
default: abort();
}
......@@ -308,7 +305,7 @@ void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id,
if (timing_advance_update < 0) timing_advance_update = 0;
if (timing_advance_update > 63) timing_advance_update = 63;
printf("\x1B[33m" "Estimated timing advance PUSCH is = %d, timing_advance_update is %d \n" "\x1B[0m", sync_pos,timing_advance_update);
LOG_D(PHY, "Estimated timing advance PUSCH is = %d, timing_advance_update is %d \n", sync_pos,timing_advance_update);
pdu->rx_indication_rel8.timing_advance = timing_advance_update;
......
......@@ -295,7 +295,7 @@ int8_t nr_find_ue(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB);
@param timing_advance TA command
@param mu numerology index (0,1,2..)
*/
void nr_process_timing_advance(module_id_t Mod_id,uint8_t CC_id,uint8_t timing_advance, uint8_t mu);
void nr_process_timing_advance(module_id_t Mod_id,uint8_t CC_id,uint8_t timing_advance, uint8_t mu, uint16_t bwp_ul_NB_RB);
void nr_process_timing_advance_rar(PHY_VARS_NR_UE *phy_vars_ue,UE_nr_rxtx_proc_t *proc,uint16_t timing_advance);
unsigned int get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb_rb);
......
......@@ -1545,14 +1545,23 @@ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDUR
#endif
void nr_process_timing_advance(module_id_t Mod_id, uint8_t CC_id, uint8_t timing_advance, uint8_t mu){
void nr_process_timing_advance(module_id_t Mod_id, uint8_t CC_id, uint8_t timing_advance, uint8_t mu, uint16_t bwp_ul_NB_RB){
// 3GPP TS 38.213 p4.2
// scale by the scs numerology
int factor_mu = 1 << mu;
uint16_t bw_scaling;
// scale the 16 factor in N_TA calculation in 38.213 section 4.2 according to the used FFT size
switch (bwp_ul_NB_RB) {
case 106: bw_scaling = 16; break;
case 217: bw_scaling = 32; break;
case 245: bw_scaling = 32; break;
case 273: bw_scaling = 32; break;
default: abort();
}
//PHY_vars_UE_g[Mod_id][CC_id]->timing_advance += (timing_advance - 31) * 1024 / factor_mu ;
PHY_vars_UE_g[Mod_id][CC_id]->timing_advance += (timing_advance - 31) * bw_scaling / factor_mu;
LOG_D(PHY,"[UE %d] Got timing advance %u from MAC, new value is %u\n",Mod_id, timing_advance, PHY_vars_UE_g[Mod_id][CC_id]->timing_advance);
}
......
......@@ -2124,7 +2124,7 @@ void nr_ue_process_mac_pdu(
NR_UE_MAC_INST_t *UE_mac_inst = get_mac_inst(module_idP);
uint8_t scs = UE_mac_inst->mib->subCarrierSpacingCommon;
uint16_t bwp_ul_NB_RB = UE_mac_inst->initial_bwp_ul.N_RB;
// For both DL/UL-SCH
// Except:
// - UL/DL-SCH: fixed-size MAC CE(known by LCID)
......@@ -2293,7 +2293,7 @@ void nr_ue_process_mac_pdu(
LOG_D(MAC, "Received TA_COMMAND %u TAGID %u CC_id %d\n", ta_command, tag_id, CC_id);
//if (nfapi_mode!=3){ // TODO check nfapi_mode
nr_process_timing_advance(module_idP, CC_id, ta_command, scs);
nr_process_timing_advance(module_idP, CC_id, ta_command, scs, bwp_ul_NB_RB);
//}
break;
......
......@@ -177,7 +177,7 @@ nr_rx_sdu(const module_id_t gnb_mod_idP,
*/
//UE_scheduling_control->ta_update = (UE_scheduling_control->ta_update * 3 + timing_advance) / 4;
UE_scheduling_control->ta_update = timing_advance;
printf("UE_scheduling_control->ta_update %u\n", UE_scheduling_control->ta_update);
// printf("UE_scheduling_control->ta_update %u\n", UE_scheduling_control->ta_update);
// UE_scheduling_control->pusch_snr[CC_idP] = ul_cqi;
// UE_scheduling_control->ul_consecutive_errors = 0;
......
......@@ -169,7 +169,7 @@ void handle_nr_ulsch(NR_UL_IND_t *UL_info) {
UL_info->rx_ind.rx_indication_body.number_of_pdus = 0;
}
} else {
printf("UL_info->rx_ind.rx_indication_body.number_of_pdus %d UL_info->crc_ind.crc_indication_body.number_of_crcs %d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, UL_info->crc_ind.crc_indication_body.number_of_crcs);
// printf("UL_info->rx_ind.rx_indication_body.number_of_pdus %d UL_info->crc_ind.crc_indication_body.number_of_crcs %d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, UL_info->crc_ind.crc_indication_body.number_of_crcs);
if (UL_info->rx_ind.rx_indication_body.number_of_pdus>0 && UL_info->crc_ind.crc_indication_body.number_of_crcs>0) {
for (int i=0; i<UL_info->rx_ind.rx_indication_body.number_of_pdus; i++) {
for (int j=0; j<UL_info->crc_ind.crc_indication_body.number_of_crcs; j++) {
......@@ -205,7 +205,7 @@ void handle_nr_ulsch(NR_UL_IND_t *UL_info) {
UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance,
UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi);
}
printf("rx_indication_rel8.timing_advance %d\n", UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance);
//printf("rx_indication_rel8.timing_advance %d\n", UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance);
break;
} //if (UL_info->crc_ind.crc_pdu_list[j].rx_ue_information.rnti ==
......
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