separating MAC and PHY procedures for TA
This commit is contained in:
@@ -380,6 +380,16 @@ typedef struct {
|
||||
|
||||
} NR_SSB_meas_t;
|
||||
|
||||
typedef struct NR_UL_TIME_ALIGNMENT {
|
||||
/// TA command and TAGID received from the gNB
|
||||
bool ta_apply;
|
||||
int ta_command;
|
||||
int ta_total;
|
||||
uint32_t tag_id;
|
||||
int frame;
|
||||
int slot;
|
||||
} NR_UL_TIME_ALIGNMENT_t;
|
||||
|
||||
/*!\brief Top level UE MAC structure */
|
||||
typedef struct {
|
||||
NR_UE_L2_STATE_t state;
|
||||
@@ -402,11 +412,12 @@ typedef struct {
|
||||
|
||||
NR_UE_DL_BWP_t current_DL_BWP;
|
||||
NR_UE_UL_BWP_t current_UL_BWP;
|
||||
NR_UL_TIME_ALIGNMENT_t ul_time_alignment;
|
||||
|
||||
NR_BWP_Downlink_t *DLbwp[MAX_NUM_BWP_UE];
|
||||
NR_BWP_Uplink_t *ULbwp[MAX_NUM_BWP_UE];
|
||||
NR_ControlResourceSet_t *coreset[MAX_NUM_BWP_UE][FAPI_NR_MAX_CORESET_PER_BWP];
|
||||
NR_SearchSpace_t *SSpace[MAX_NUM_BWP_UE][FAPI_NR_MAX_SS];
|
||||
NR_BWP_Downlink_t *DLbwp[MAX_NUM_BWP_UE];
|
||||
NR_BWP_Uplink_t *ULbwp[MAX_NUM_BWP_UE];
|
||||
NR_ControlResourceSet_t *coreset[MAX_NUM_BWP_UE][FAPI_NR_MAX_CORESET_PER_BWP];
|
||||
NR_SearchSpace_t *SSpace[MAX_NUM_BWP_UE][FAPI_NR_MAX_SS];
|
||||
|
||||
bool phy_config_request_sent;
|
||||
frame_type_t frame_type;
|
||||
|
||||
@@ -235,11 +235,9 @@ uint8_t get_rsrp_diff_index(int best_rsrp,int current_rsrp);
|
||||
@returns void
|
||||
*/
|
||||
void nr_ue_send_sdu(nr_downlink_indication_t *dl_info,
|
||||
NR_UL_TIME_ALIGNMENT_t *ul_time_alignment,
|
||||
int pdu_id);
|
||||
|
||||
void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
|
||||
NR_UL_TIME_ALIGNMENT_t *ul_time_alignment,
|
||||
int pdu_id);
|
||||
|
||||
int nr_write_ce_ulsch_pdu(uint8_t *mac_ce,
|
||||
@@ -333,6 +331,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
|
||||
void nr_ue_pucch_scheduler(module_id_t module_idP, 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
|
||||
@@ -367,7 +366,7 @@ random-access procedure
|
||||
@param selected_rar_buffer the output buffer for storing the selected RAR header and RAR payload
|
||||
@returns timing advance or 0xffff if preamble doesn't match
|
||||
*/
|
||||
int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment, int pdu_id);
|
||||
int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id);
|
||||
|
||||
void nr_ue_contention_resolution(module_id_t module_id, int cc_id, frame_t frame, int slot, NR_PRACH_RESOURCES_t *prach_resources);
|
||||
|
||||
|
||||
@@ -50,16 +50,10 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) {
|
||||
//LOG_I(MAC, "[MAIN] init UE MAC functions \n");
|
||||
|
||||
//init mac here
|
||||
nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(sizeof(NR_UE_MAC_INST_t),NB_NR_UE_MAC_INST);
|
||||
nr_ue_mac_inst->first_sync_frame = -1;
|
||||
nr_ue_mac_inst->sib1_decoded = false;
|
||||
nr_ue_mac_inst->phy_config_request_sent = false;
|
||||
nr_ue_mac_inst->state = UE_NOT_SYNC;
|
||||
memset(&nr_ue_mac_inst->ssb_measurements, 0, sizeof(nr_ue_mac_inst->ssb_measurements));
|
||||
nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(sizeof(NR_UE_MAC_INST_t), NB_NR_UE_MAC_INST);
|
||||
|
||||
for (int j=0;j<NB_NR_UE_MAC_INST;j++) {
|
||||
nr_ue_init_mac(j);
|
||||
}
|
||||
for (int j = 0; j < NB_NR_UE_MAC_INST; j++)
|
||||
nr_ue_init_mac(j);
|
||||
|
||||
if (rrc_inst && rrc_inst->scell_group_config) {
|
||||
|
||||
|
||||
@@ -131,9 +131,8 @@ const initial_pucch_resource_t initial_pucch_resource[16] = {
|
||||
};
|
||||
|
||||
|
||||
void nr_ue_init_mac(module_id_t module_idP) {
|
||||
int i;
|
||||
|
||||
void nr_ue_init_mac(module_id_t module_idP)
|
||||
{
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
|
||||
// default values as deined in 38.331 sec 9.2.2
|
||||
LOG_I(NR_MAC, "[UE%d] Applying default macMainConfig\n", module_idP);
|
||||
@@ -162,7 +161,7 @@ void nr_ue_init_mac(module_id_t module_idP) {
|
||||
// mac->scheduling_info.PathlossChange_db = nr_get_db_dl_PathlossChange(mac->scheduling_info.PathlossChange);
|
||||
// mac->PHR_reporting_active = 0;
|
||||
|
||||
for (i = 0; i < NR_MAX_NUM_LCID; i++) {
|
||||
for (int i = 0; i < NR_MAX_NUM_LCID; i++) {
|
||||
LOG_D(NR_MAC, "[UE%d] Applying default logical channel config for LCGID %d\n",
|
||||
module_idP, i);
|
||||
mac->scheduling_info.Bj[i] = -1;
|
||||
@@ -176,8 +175,16 @@ void nr_ue_init_mac(module_id_t module_idP) {
|
||||
|
||||
mac->scheduling_info.LCID_status[i] = LCID_EMPTY;
|
||||
mac->scheduling_info.LCID_buffer_remain[i] = 0;
|
||||
for (int i=0;i<NR_MAX_HARQ_PROCESSES;i++) mac->first_ul_tx[i]=1;
|
||||
for (int i = 0; i < NR_MAX_HARQ_PROCESSES; i++)
|
||||
mac->first_ul_tx[i] = 1;
|
||||
}
|
||||
|
||||
mac->first_sync_frame = -1;
|
||||
mac->sib1_decoded = false;
|
||||
mac->phy_config_request_sent = false;
|
||||
mac->state = UE_NOT_SYNC;
|
||||
memset(&mac->ssb_measurements, 0, sizeof(mac->ssb_measurements));
|
||||
memset(&mac->ul_time_alignment, 0, sizeof(mac->ul_time_alignment));
|
||||
}
|
||||
|
||||
NR_BWP_DownlinkCommon_t *get_bwp_downlink_common(NR_UE_MAC_INST_t *mac, NR_BWP_Id_t dl_bwp_id) {
|
||||
@@ -2380,8 +2387,8 @@ uint8_t get_rsrp_diff_index(int best_rsrp,int current_rsrp) {
|
||||
|
||||
}
|
||||
|
||||
void nr_ue_send_sdu(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment, int pdu_id){
|
||||
|
||||
void nr_ue_send_sdu(nr_downlink_indication_t *dl_info, int pdu_id)
|
||||
{
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_IN);
|
||||
|
||||
LOG_D(MAC, "In %s [%d.%d] Handling DLSCH PDU...\n", __FUNCTION__, dl_info->frame, dl_info->slot);
|
||||
@@ -2390,10 +2397,10 @@ void nr_ue_send_sdu(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t *u
|
||||
// it parses MAC CEs subheaders, MAC CEs, SDU subheaderds and SDUs
|
||||
switch (dl_info->rx_ind->rx_indication_body[pdu_id].pdu_type){
|
||||
case FAPI_NR_RX_PDU_TYPE_DLSCH:
|
||||
nr_ue_process_mac_pdu(dl_info, ul_time_alignment, pdu_id);
|
||||
nr_ue_process_mac_pdu(dl_info, pdu_id);
|
||||
break;
|
||||
case FAPI_NR_RX_PDU_TYPE_RAR:
|
||||
nr_ue_process_rar(dl_info, ul_time_alignment, pdu_id);
|
||||
nr_ue_process_rar(dl_info, pdu_id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -3107,8 +3114,8 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
|
||||
// R: Reserved bit, set to zero.
|
||||
////////////////////////////////
|
||||
void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
|
||||
NR_UL_TIME_ALIGNMENT_t *ul_time_alignment,
|
||||
int pdu_id){
|
||||
int pdu_id)
|
||||
{
|
||||
|
||||
module_id_t module_idP = dl_info->module_id;
|
||||
frame_t frameP = dl_info->frame;
|
||||
@@ -3228,11 +3235,14 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
|
||||
|
||||
const int ta = ((NR_MAC_CE_TA *)pduP)[1].TA_COMMAND;
|
||||
const int tag = ((NR_MAC_CE_TA *)pduP)[1].TAGID;
|
||||
ul_time_alignment->apply_ta = 1;
|
||||
ul_time_alignment->ta_command = ta; //here
|
||||
|
||||
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;
|
||||
/*
|
||||
#ifdef DEBUG_HEADER_PARSING
|
||||
LOG_D(MAC, "[UE] CE %d : UE Timing Advance : %d\n", i, pduP[1]);
|
||||
@@ -3515,8 +3525,8 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce,
|
||||
// - b buffer
|
||||
// - ulsch power offset
|
||||
// - optimize: mu_pusch, j and table_6_1_2_1_1_2_time_dom_res_alloc_A are already defined in nr_ue_procedures
|
||||
int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment, int pdu_id){
|
||||
|
||||
int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id)
|
||||
{
|
||||
module_id_t mod_id = dl_info->module_id;
|
||||
frame_t frame = dl_info->frame;
|
||||
int slot = dl_info->slot;
|
||||
@@ -3601,12 +3611,12 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
|
||||
#endif
|
||||
|
||||
// TA command
|
||||
ul_time_alignment->apply_ta = 1;
|
||||
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;
|
||||
LOG_W(MAC, "received TA command %d\n", ul_time_alignment->ta_command);
|
||||
|
||||
ul_time_alignment->ta_apply = true;
|
||||
LOG_W(MAC, "received TA command %d\n", 31 + ta);
|
||||
#ifdef DEBUG_RAR
|
||||
// CSI
|
||||
csi_req = (unsigned char) (rar->UL_GRANT_4 & 0x01);
|
||||
@@ -3674,7 +3684,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
|
||||
mod_id,
|
||||
rar_grant.Msg3_t_alloc,
|
||||
rar_grant.Msg3_f_alloc,
|
||||
ul_time_alignment->ta_command,
|
||||
ta_command,
|
||||
rar_grant.mcs,
|
||||
rar_grant.freq_hopping,
|
||||
tpc_command,
|
||||
@@ -3720,10 +3730,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
ra->t_crnti = 0;
|
||||
ul_time_alignment->ta_command = (0xffff);
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -1024,6 +1024,8 @@ void nr_ue_dl_scheduler(nr_downlink_indication_t *dl_info)
|
||||
nr_ue_dcireq(&dcireq); //to be replaced with function pointer later
|
||||
*dl_config = dcireq.dl_config_req;
|
||||
|
||||
if(mac->ul_time_alignment.ta_apply)
|
||||
schedule_ta_command(dl_config, &mac->ul_time_alignment);
|
||||
nr_schedule_csirs_reception(mac, rx_frame, rx_slot);
|
||||
nr_schedule_csi_for_im(mac, rx_frame, rx_slot);
|
||||
dcireq.dl_config_req = *dl_config;
|
||||
@@ -1037,6 +1039,8 @@ void nr_ue_dl_scheduler(nr_downlink_indication_t *dl_info)
|
||||
else if (mac->state == UE_PERFORMING_RA) {
|
||||
// this is for Msg2/Msg4
|
||||
if (mac->ra.ra_state >= WAIT_RAR) {
|
||||
if(mac->ul_time_alignment.ta_apply)
|
||||
schedule_ta_command(dl_config, &mac->ul_time_alignment);
|
||||
fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15;
|
||||
rel15->num_dci_options = mac->ra.ra_state == WAIT_RAR ? 1 : 2;
|
||||
rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0;
|
||||
@@ -3178,5 +3182,15 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
|
||||
#endif
|
||||
|
||||
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)
|
||||
{
|
||||
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->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;
|
||||
}
|
||||
|
||||
@@ -108,10 +108,8 @@ int nr_write_ce_dlsch_pdu(module_id_t module_idP,
|
||||
AssertFatal(timing_advance_cmd < 64, "timing_advance_cmd %d > 63\n", timing_advance_cmd);
|
||||
((NR_MAC_CE_TA *) ce_ptr)->TA_COMMAND = timing_advance_cmd; //(timing_advance_cmd+31)&0x3f;
|
||||
|
||||
if (gNB->tag->tag_Id != 0) {
|
||||
tag_id = gNB->tag->tag_Id;
|
||||
((NR_MAC_CE_TA *) ce_ptr)->TAGID = tag_id;
|
||||
}
|
||||
tag_id = gNB->tag->tag_Id;
|
||||
((NR_MAC_CE_TA *) ce_ptr)->TAGID = tag_id;
|
||||
|
||||
LOG_D(NR_MAC, "NR MAC CE timing advance command = %d (%d) TAG ID = %d\n", timing_advance_cmd, ((NR_MAC_CE_TA *) ce_ptr)->TA_COMMAND, tag_id);
|
||||
mac_ce_size = sizeof(NR_MAC_CE_TA);
|
||||
@@ -1191,7 +1189,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
|
||||
T_INT(frame), T_INT(slot), T_INT(current_harq_pid), T_INT(harq->round), T_BUFFER(harq->transportBlock, TBS));
|
||||
UE->mac_stats.dl.total_rbs_retx += sched_pdsch->rbSize;
|
||||
} else { /* initial transmission */
|
||||
LOG_D(NR_MAC, "[%s] Initial HARQ transmission in %d.%d\n", __FUNCTION__, frame, slot);
|
||||
LOG_D(NR_MAC, "Initial HARQ transmission in %d.%d\n", frame, slot);
|
||||
uint8_t *buf = (uint8_t *) harq->transportBlock;
|
||||
/* first, write all CEs that might be there */
|
||||
int written = nr_write_ce_dlsch_pdu(module_id,
|
||||
|
||||
Reference in New Issue
Block a user