Commit 832b8df6 authored by luis_pereira87's avatar luis_pereira87

Handling Msg3 when transferred through DCCH

parent 614c29ad
......@@ -1405,6 +1405,12 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg4\n");
// If UE is known by the network, to use C-RNTI instead of TC-RNTI
rnti_t tc_rnti = ra->rnti;
if(ra->crnti != 0) {
ra->rnti = ra->crnti;
}
int UE_id = find_nr_UE_id(module_idP, ra->rnti);
NR_UE_info_t *UE_info = &nr_mac->UE_info;
NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
......@@ -1438,6 +1444,11 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
harq->is_waiting = true;
ra->harq_pid = current_harq_pid;
// Remove UE associated to TC-RNTI
if(harq->round==0 && ra->rnti!=tc_rnti) {
mac_remove_nr_ue(module_idP, tc_rnti);
}
// get CCEindex, needed also for PUCCH and then later for PDCCH
uint8_t aggregation_level;
uint8_t nr_of_candidates;
......@@ -1769,7 +1780,6 @@ void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_fram
LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) RA Procedure failed at Msg4!\n", UE_id, ra->rnti);
nr_mac_remove_ra_rnti(module_id, ra->rnti);
nr_clear_ra_proc(module_id, CC_id, frame, ra);
mac_remove_nr_ue(module_id, ra->rnti);
}
}
else {
......@@ -1787,6 +1797,7 @@ void nr_clear_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP, NR_RA_t
ra->timing_offset = 0;
ra->RRC_timer = 20;
ra->msg3_round = 0;
ra->crnti = 0;
if(ra->cfra == false) {
ra->rnti = 0;
}
......
......@@ -325,6 +325,16 @@ int nr_process_mac_pdu(module_id_t module_idP,
break;
case UL_SCH_LCID_C_RNTI:
for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) {
NR_RA_t *ra = &RC.nrmac[module_idP]->common_channels[CC_id].ra[i];
if (ra->state >= WAIT_Msg3 && ra->rnti == UE_info->rnti[UE_id]) {
ra->crnti = ((pduP[1]&0xFF)<<8)|(pduP[2]&0xFF);
LOG_D(NR_MAC, "Received UL_SCH_LCID_C_RNTI with CRNTI: 0x%04x\n", ra->crnti);
break;
}
}
//38.321 section 6.1.3.2
//fixed length
mac_ce_len = 2;
......@@ -392,10 +402,25 @@ int nr_process_mac_pdu(module_id_t module_idP,
mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pduP)->L;
mac_subheader_len = 2;
}
if (UE_info->CellGroup[UE_id]) {
LOG_D(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-DCCH %d (gNB %d, %d bytes), rnti: %d \n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len, UE_info->rnti[UE_id]);
rnti_t crnti = UE_info->rnti[UE_id];
int UE_idx = UE_id;
for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) {
NR_RA_t *ra = &RC.nrmac[module_idP]->common_channels[CC_id].ra[i];
if (ra->state >= WAIT_Msg3 && ra->rnti == UE_info->rnti[UE_id]) {
char *next_subpduP = pduP + mac_subheader_len + mac_sdu_len;
if ((pduP[mac_subheader_len+mac_sdu_len] & 0x3F) == UL_SCH_LCID_C_RNTI) {
crnti = ((next_subpduP[1]&0xFF)<<8)|(next_subpduP[2]&0xFF);
UE_idx = find_nr_UE_id(module_idP, crnti);
break;
}
}
}
if (UE_info->CellGroup[UE_idx]) {
LOG_D(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-DCCH %d (gNB %d, %d bytes), rnti: 0x%04x \n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len, crnti);
mac_rlc_data_ind(module_idP,
UE_info->rnti[UE_id],
crnti,
module_idP,
frameP,
ENB_FLAG_YES,
......
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