fix timing advance from msg2/rar
This commit is contained in:
@@ -547,6 +547,7 @@ typedef struct {
|
||||
int ta_frame;
|
||||
int ta_slot;
|
||||
int ta_command;
|
||||
bool is_rar;
|
||||
} fapi_nr_ta_command_pdu;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -320,7 +320,7 @@ static void configure_dlsch(NR_UE_DLSCH_t *dlsch0,
|
||||
}
|
||||
}
|
||||
|
||||
void configure_ta_command(PHY_VARS_NR_UE *ue, fapi_nr_ta_command_pdu *ta_command_pdu)
|
||||
static void configure_ta_command(PHY_VARS_NR_UE *ue, fapi_nr_ta_command_pdu *ta_command_pdu)
|
||||
{
|
||||
|
||||
/* Time Alignment procedure
|
||||
@@ -365,13 +365,19 @@ void configure_ta_command(PHY_VARS_NR_UE *ue, fapi_nr_ta_command_pdu *ta_command
|
||||
const double t_subframe = 1.0; // subframe duration of 1 msec
|
||||
const int ul_tx_timing_adjustment = 1 + (int)ceil(slots_per_subframe*(N_t_1 + N_t_2 + N_TA_max + 0.5)/t_subframe);
|
||||
|
||||
ue->ta_slot = (ta_command_pdu->ta_slot + ul_tx_timing_adjustment) % slots_per_frame;
|
||||
if (ta_command_pdu->ta_slot + ul_tx_timing_adjustment > slots_per_frame)
|
||||
ue->ta_frame = (ta_command_pdu->ta_frame + 1) % 1024;
|
||||
else
|
||||
if (ta_command_pdu->is_rar) {
|
||||
ue->ta_slot = ta_command_pdu->ta_slot;
|
||||
ue->ta_frame = ta_command_pdu->ta_frame;
|
||||
|
||||
ue->ta_command = ta_command_pdu->ta_command;
|
||||
ue->timing_advance = 0;
|
||||
ue->ta_command = ta_command_pdu->ta_command + 31; // To use TA adjustment algo in ue_ta_procedures()
|
||||
} else {
|
||||
ue->ta_slot = (ta_command_pdu->ta_slot + ul_tx_timing_adjustment) % slots_per_frame;
|
||||
if (ta_command_pdu->ta_slot + ul_tx_timing_adjustment > slots_per_frame)
|
||||
ue->ta_frame = (ta_command_pdu->ta_frame + 1) % 1024;
|
||||
else
|
||||
ue->ta_frame = ta_command_pdu->ta_frame;
|
||||
ue->ta_command = ta_command_pdu->ta_command;
|
||||
}
|
||||
LOG_D(PHY,"TA command received in Frame.Slot %d.%d -- Starting UL time alignment procedures. TA update will be applied at frame %d slot %d\n",
|
||||
ta_command_pdu->ta_frame, ta_command_pdu->ta_slot, ue->ta_frame, ue->ta_slot);
|
||||
}
|
||||
|
||||
@@ -232,15 +232,14 @@ int get_tx_amp_prach(int power_dBm, int power_max_dBm, int N_RB_UL){
|
||||
// - If the current tx frame and slot match the TA configuration
|
||||
// then timing advance is processed and set to be applied in the next UL transmission
|
||||
// - Application of timing adjustment according to TS 38.213 p4.2
|
||||
// todo:
|
||||
// - handle RAR TA application as per ch 4.2 TS 38.213
|
||||
void ue_ta_procedures(PHY_VARS_NR_UE *ue, int slot_tx, int frame_tx)
|
||||
{
|
||||
if (frame_tx == ue->ta_frame && slot_tx == ue->ta_slot) {
|
||||
|
||||
uint16_t ofdm_symbol_size = ue->frame_parms.ofdm_symbol_size;
|
||||
|
||||
// convert time factor "16 * 64 * T_c / (2^mu)" in N_TA calculation in TS38.213 section 4.2 to samples by multiplying with samples per second
|
||||
// convert time factor "16 * 64 * T_c / (2^mu)" in N_TA calculation in TS38.213 section 4.2 to samples by multiplying with
|
||||
// samples per second
|
||||
// 16 * 64 * T_c / (2^mu) * samples_per_second
|
||||
// = 16 * T_s / (2^mu) * samples_per_second
|
||||
// = 16 * 1 / (15 kHz * 2048) / (2^mu) * (15 kHz * 2^mu * ofdm_symbol_size)
|
||||
@@ -250,7 +249,8 @@ void ue_ta_procedures(PHY_VARS_NR_UE *ue, int slot_tx, int frame_tx)
|
||||
|
||||
ue->timing_advance += (ue->ta_command - 31) * bw_scaling;
|
||||
|
||||
LOG_D(PHY, "[UE %d] [%d.%d] Got timing advance command %u from MAC, new value is %d\n",
|
||||
LOG_D(PHY,
|
||||
"[UE %d] [%d.%d] Got timing advance command %u from MAC, new value is %d\n",
|
||||
ue->Mod_id,
|
||||
frame_tx,
|
||||
slot_tx,
|
||||
|
||||
@@ -552,6 +552,8 @@ int main(int argc, char *argv[])
|
||||
gNB = RC.gNB[0];
|
||||
gNB->ofdm_offset_divisor = UINT_MAX;
|
||||
gNB->num_pusch_symbols_per_thread = 1;
|
||||
gNB->RU_list[0] = calloc(1, sizeof(**gNB->RU_list));
|
||||
gNB->RU_list[0]->rfdevice.openair0_cfg = openair0_cfg;
|
||||
|
||||
initFloatingCoresTpool(threadCnt, &gNB->threadPool, false, "gNB-tpool");
|
||||
initNotifiedFIFO(&gNB->respDecode);
|
||||
|
||||
@@ -384,11 +384,16 @@ typedef struct {
|
||||
short ssb_rsrp_dBm;
|
||||
} NR_SSB_meas_t;
|
||||
|
||||
typedef enum ta_type {
|
||||
no_ta = 0,
|
||||
adjustment_ta,
|
||||
rar_ta,
|
||||
} ta_type_t;
|
||||
|
||||
typedef struct NR_UL_TIME_ALIGNMENT {
|
||||
/// TA command and TAGID received from the gNB
|
||||
bool ta_apply;
|
||||
ta_type_t ta_apply;
|
||||
int ta_command;
|
||||
int ta_total;
|
||||
uint32_t tag_id;
|
||||
int frame;
|
||||
int slot;
|
||||
|
||||
@@ -401,7 +401,6 @@ and fills the PRACH PDU per each FD occasion.
|
||||
void nr_ue_pucch_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, int slotP, void *phy_data);
|
||||
void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot);
|
||||
void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot);
|
||||
void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment);
|
||||
|
||||
/* \brief This function schedules the Msg3 transmission
|
||||
@param
|
||||
|
||||
@@ -3722,12 +3722,11 @@ void nr_ue_process_mac_pdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_i
|
||||
const int tag = ((NR_MAC_CE_TA *)pduP)[1].TAGID;
|
||||
|
||||
NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &mac->ul_time_alignment;
|
||||
ul_time_alignment->ta_total += ta - 31;
|
||||
ul_time_alignment->tag_id = tag;
|
||||
ul_time_alignment->ta_command = ta;
|
||||
ul_time_alignment->frame = frameP;
|
||||
ul_time_alignment->slot = slot;
|
||||
ul_time_alignment->ta_apply = true;
|
||||
ul_time_alignment->ta_apply = adjustment_ta;
|
||||
/*
|
||||
#ifdef DEBUG_HEADER_PARSING
|
||||
LOG_D(MAC, "[UE] CE %d : UE Timing Advance : %d\n", i, pduP[1]);
|
||||
@@ -3735,21 +3734,9 @@ void nr_ue_process_mac_pdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_i
|
||||
*/
|
||||
|
||||
if (ta == 31)
|
||||
LOG_D(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d TA total %d\n",
|
||||
frameP,
|
||||
slot,
|
||||
ta,
|
||||
tag,
|
||||
CC_id,
|
||||
ul_time_alignment->ta_total);
|
||||
LOG_D(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d \n", frameP, slot, ta, tag, CC_id);
|
||||
else
|
||||
LOG_I(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d TA total %d\n",
|
||||
frameP,
|
||||
slot,
|
||||
ta,
|
||||
tag,
|
||||
CC_id,
|
||||
ul_time_alignment->ta_total);
|
||||
LOG_I(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d \n", frameP, slot, ta, tag, CC_id);
|
||||
|
||||
break;
|
||||
case DL_SCH_LCID_CON_RES_ID:
|
||||
@@ -4129,9 +4116,9 @@ static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *d
|
||||
// TA command
|
||||
NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &mac->ul_time_alignment;
|
||||
const int ta = rar->TA2 + (rar->TA1 << 5);
|
||||
ul_time_alignment->ta_command = 31 + ta;
|
||||
ul_time_alignment->ta_total = ta;
|
||||
ul_time_alignment->ta_apply = true;
|
||||
ul_time_alignment->ta_command = ta;
|
||||
ul_time_alignment->ta_apply = rar_ta;
|
||||
|
||||
LOG_W(MAC, "received TA command %d\n", 31 + ta);
|
||||
#ifdef DEBUG_RAR
|
||||
// CSI
|
||||
@@ -4221,6 +4208,8 @@ static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *d
|
||||
return;
|
||||
}
|
||||
ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, tda_info.k2);
|
||||
ul_time_alignment->frame = frame_tx;
|
||||
ul_time_alignment->slot = slot_tx;
|
||||
|
||||
if (ret != -1) {
|
||||
uint16_t rnti = mac->crnti;
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
//#define SRS_DEBUG
|
||||
|
||||
static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, sub_frame_t slotP);
|
||||
static void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment);
|
||||
|
||||
fapi_nr_ul_config_request_pdu_t *lockGet_ul_config(NR_UE_MAC_INST_t *mac, frame_t frame_tx, int slot_tx, uint8_t pdu_type)
|
||||
{
|
||||
@@ -1018,7 +1019,7 @@ void nr_ue_dl_scheduler(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info
|
||||
|
||||
ue_dci_configuration(mac, dl_config, rx_frame, rx_slot);
|
||||
|
||||
if (mac->ul_time_alignment.ta_apply)
|
||||
if (mac->ul_time_alignment.ta_apply != no_ta)
|
||||
schedule_ta_command(dl_config, &mac->ul_time_alignment);
|
||||
if (mac->state == UE_CONNECTED) {
|
||||
nr_schedule_csirs_reception(mac, rx_frame, rx_slot);
|
||||
@@ -3354,15 +3355,16 @@ uint8_t nr_ue_get_sdu(NR_UE_MAC_INST_t *mac,
|
||||
return num_sdus > 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment)
|
||||
static void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment)
|
||||
{
|
||||
fapi_nr_ta_command_pdu *ta = &dl_config->dl_config_list[dl_config->number_pdus].ta_command_pdu;
|
||||
ta->ta_frame = ul_time_alignment->frame;
|
||||
ta->ta_slot = ul_time_alignment->slot;
|
||||
ta->is_rar = ul_time_alignment->ta_apply == rar_ta;
|
||||
ta->ta_command = ul_time_alignment->ta_command;
|
||||
dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_CONFIG_TA_COMMAND;
|
||||
dl_config->number_pdus += 1;
|
||||
ul_time_alignment->ta_apply = false;
|
||||
ul_time_alignment->ta_apply = no_ta;
|
||||
}
|
||||
|
||||
uint32_t nr_get_pbr(long prioritizedbitrate)
|
||||
|
||||
Reference in New Issue
Block a user