Commit 8f28685c authored by rmagueta's avatar rmagueta

Fix in new RA attempts after fail

parent 8b5d5bbb
...@@ -800,7 +800,7 @@ void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_res ...@@ -800,7 +800,7 @@ void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_res
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
ra->first_Msg3 = 0; ra->first_Msg3 = 1;
ra->generate_nr_prach = RA_FAILED; ra->generate_nr_prach = RA_FAILED;
ra->ra_state = RA_UE_IDLE; ra->ra_state = RA_UE_IDLE;
......
...@@ -2291,7 +2291,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t ...@@ -2291,7 +2291,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
break; break;
} }
if (rarh->E == 0) { if (rarh->E == 0) {
LOG_W(NR_MAC,"[UE %d][RAPROC] Received RAR preamble (%d) doesn't match the intended RAPID (%d)\n", mod_id, rarh->RAPID, preamble_index); LOG_W(NR_MAC,"[UE %d][RAPROC][%d.%d] Received RAR preamble (%d) doesn't match the intended RAPID (%d)\n", mod_id, frame, slot, rarh->RAPID, preamble_index);
break; break;
} else { } else {
rarh += sizeof(NR_MAC_RAR) + 1; rarh += sizeof(NR_MAC_RAR) + 1;
......
...@@ -464,9 +464,19 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, ...@@ -464,9 +464,19 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
UE_scheduling_control->sched_ul_bytes = 0; UE_scheduling_control->sched_ul_bytes = 0;
} }
} }
} else { } else if(sduP) {
if (!sduP) // check that CRC passed
return; bool no_sig = true;
for (int k = 0; k < sdu_lenP; k++) {
if(sduP[k]!=0) {
no_sig = false;
break;
}
}
if(no_sig) {
LOG_W(NR_MAC, "No signal\n");
}
T(T_GNB_MAC_UL_PDU_WITH_DATA, T_INT(gnb_mod_idP), T_INT(CC_idP), T(T_GNB_MAC_UL_PDU_WITH_DATA, T_INT(gnb_mod_idP), T_INT(CC_idP),
T_INT(rntiP), T_INT(frameP), T_INT(slotP), T_INT(-1) /* harq_pid */, T_INT(rntiP), T_INT(frameP), T_INT(slotP), T_INT(-1) /* harq_pid */,
...@@ -480,47 +490,69 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, ...@@ -480,47 +490,69 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
if (ra->state != WAIT_Msg3) if (ra->state != WAIT_Msg3)
continue; continue;
// random access pusch with TC-RNTI if(no_sig) {
if (ra->rnti != current_rnti) { LOG_W(NR_MAC, "Random Access %i failed at state %i\n", i, ra->state);
LOG_W(NR_MAC, ra->state = RA_IDLE;
"expected TC-RNTI %04x to match current RNTI %04x\n", ra->timing_offset = 0;
ra->rnti, ra->RRC_timer = 20;
current_rnti); ra->msg3_round = 0;
continue; } else {
}
const int UE_id = add_new_nr_ue(gnb_mod_idP, ra->rnti, ra->secondaryCellGroup); // random access pusch with TC-RNTI
UE_info->UE_beam_index[UE_id] = ra->beam_id; if (ra->rnti != current_rnti) {
LOG_I(NR_MAC, LOG_W(NR_MAC,
"[gNB %d][RAPROC] PUSCH with TC-RNTI %x received correctly, " "expected TC-RNTI %04x to match current RNTI %04x\n",
"adding UE MAC Context UE_id %d/RNTI %04x\n", ra->rnti,
gnb_mod_idP, current_rnti);
current_rnti, continue;
UE_id, }
ra->rnti); const int UE_id = add_new_nr_ue(gnb_mod_idP, ra->rnti, ra->secondaryCellGroup);
UE_info->UE_beam_index[UE_id] = ra->beam_id;
LOG_I(NR_MAC,"[RAPROC] RA-Msg3 received\n"); LOG_I(NR_MAC,
LOG_D(NR_MAC,"[RAPROC] Received Msg3:\n"); "[gNB %d][RAPROC] PUSCH with TC-RNTI %x received correctly, "
for (int k = 0; k < sdu_lenP; k++) { "adding UE MAC Context UE_id %d/RNTI %04x\n",
LOG_D(NR_MAC,"(%i): 0x%x\n",k,sduP[k]); gnb_mod_idP,
} current_rnti,
UE_id,
ra->rnti);
LOG_I(NR_MAC,"[RAPROC] RA-Msg3 received\n");
LOG_D(NR_MAC,"[RAPROC] Received Msg3:\n");
for (int k = 0; k < sdu_lenP; k++) {
LOG_D(NR_MAC,"(%i): 0x%x\n",k,sduP[k]);
}
// UE Contention Resolution Identity // UE Contention Resolution Identity
// Store the first 48 bits belonging to the uplink CCCH SDU within Msg3 to fill in Msg4 // Store the first 48 bits belonging to the uplink CCCH SDU within Msg3 to fill in Msg4
// First byte corresponds to R/LCID MAC sub-header // First byte corresponds to R/LCID MAC sub-header
memcpy(ra->cont_res_id, &sduP[1], sizeof(uint8_t) * 6); memcpy(ra->cont_res_id, &sduP[1], sizeof(uint8_t) * 6);
// re-initialize ta update variables afrer RA procedure completion // re-initialize ta update variables afrer RA procedure completion
UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP; UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP;
nr_process_mac_pdu(gnb_mod_idP, current_rnti, CC_idP, frameP, sduP, sdu_lenP); nr_process_mac_pdu(gnb_mod_idP, current_rnti, CC_idP, frameP, sduP, sdu_lenP);
free(ra->preambles.preamble_list); free(ra->preambles.preamble_list);
ra->state = Msg4; ra->state = Msg4;
ra->Msg4_frame = ( frameP +2 ) % 1024; ra->Msg4_frame = ( frameP +2 ) % 1024;
ra->Msg4_slot = 1; ra->Msg4_slot = 1;
LOG_I(MAC, "Scheduling RA-Msg4 for TC-RNTI %04x (state %d, frame %d, slot %d)\n", ra->rnti, ra->state, ra->Msg4_frame, ra->Msg4_slot); LOG_I(MAC, "Scheduling RA-Msg4 for TC-RNTI %04x (state %d, frame %d, slot %d)\n", ra->rnti, ra->state, ra->Msg4_frame, ra->Msg4_slot);
return; return;
}
}
} else {
for (int i = 0; i < NR_NB_RA_PROC_MAX; ++i) {
NR_RA_t *ra = &gNB_mac->common_channels[CC_idP].ra[i];
if (ra->state != WAIT_Msg3)
continue;
LOG_W(NR_MAC, "Random Access %i failed at state %i\n", i, ra->state);
ra->state = RA_IDLE;
ra->timing_offset = 0;
ra->RRC_timer = 20;
ra->msg3_round = 0;
} }
} }
} }
......
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