Commit d0733ea7 authored by luis_pereira87's avatar luis_pereira87

Handle Msg3 carrying a DCCH or DTCH message

parent 46efcb90
......@@ -521,6 +521,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
RC.nrmac[Mod_idP]->sib1_tda = sib1_tda;
for (int n=0;n<NR_NB_RA_PROC_MAX;n++ ) {
cc->ra[n].cfra = false;
cc->ra[n].msg3_dcch_dtch = false;
cc->ra[n].rnti = 0;
cc->ra[n].preambles.num_preambles = MAX_NUM_NR_PRACH_PREAMBLES;
cc->ra[n].preambles.preamble_list = (uint8_t *) malloc(MAX_NUM_NR_PRACH_PREAMBLES*sizeof(uint8_t));
......@@ -603,6 +604,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
for (int i = 0; i < MAX_NUM_NR_PRACH_PREAMBLES; i++)
ra->preambles.preamble_list[i] = i;
}
ra->msg3_dcch_dtch = false;
LOG_I(NR_MAC,"Added new RA process for UE RNTI %04x with initial CellGroup\n", rnti);
} else { // CellGroup has been updated
const int UE_id = find_nr_UE_id(Mod_idP,rnti);
......
......@@ -1407,7 +1407,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
// 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) {
if(ra->msg3_dcch_dtch) {
ra->rnti = ra->crnti;
}
......@@ -1484,6 +1484,11 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
uint8_t *buf = (uint8_t *) harq->tb;
// Bytes to be transmitted
if (harq->round == 0) {
if (ra->msg3_dcch_dtch) {
// If the UE used MSG3 to transfer a DCCH or DTCH message, then contention resolution is successful if the UE receives a PDCCH transmission which has its CRC bits scrambled by the C-RNTI
// Just send padding LCID
ra->mac_pdu_length = 0;
} else {
uint16_t mac_pdu_length = nr_write_ce_dlsch_pdu(module_idP, nr_mac->sched_ctrlCommon, buf, 255, ra->cont_res_id);
LOG_D(NR_MAC,"Encoded contention resolution mac_pdu_length %d\n",mac_pdu_length);
uint16_t mac_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, CCCH, ra->rnti, 1, &buf[mac_pdu_length+2]);
......@@ -1494,6 +1499,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
ra->mac_pdu_length = mac_pdu_length + mac_sdu_length + sizeof(NR_MAC_SUBHEADER_SHORT);
LOG_D(NR_MAC,"Encoded RRCSetup Piggyback (%d + %d bytes), mac_pdu_length %d\n", mac_sdu_length, (int)sizeof(NR_MAC_SUBHEADER_SHORT), ra->mac_pdu_length);
}
}
// Calculate number of symbols
int startSymbolIndex, nrOfSymbols;
......@@ -1752,9 +1758,23 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
LOG_D(NR_MAC,"precoderGranularity: %i\n", pdcch_pdu_rel15->precoderGranularity);
LOG_D(NR_MAC,"numDlDci: %i\n", pdcch_pdu_rel15->numDlDci);
if(ra->msg3_dcch_dtch) {
LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) CBRA procedure succeeded!\n", UE_id, ra->rnti);
nr_clear_ra_proc(module_idP, CC_id, frameP, ra);
UE_info->active[UE_id] = true;
UE_info->Msg4_ACKed[UE_id] = true;
remove_front_nr_list(&sched_ctrl->feedback_dl_harq);
harq->feedback_slot = -1;
harq->is_waiting = false;
add_tail_nr_list(&sched_ctrl->available_dl_harq, current_harq_pid);
harq->round = 0;
harq->ndi ^= 1;
} else {
ra->state = WAIT_Msg4_ACK;
LOG_D(NR_MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state);
}
}
}
void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t slot, NR_RA_t *ra) {
......@@ -1773,16 +1793,16 @@ void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_fram
if (harq->round == 0) {
if (stats->dlsch_errors == 0) {
LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) Received Ack of RA-Msg4. CBRA procedure succeeded!\n", UE_id, ra->rnti);
nr_clear_ra_proc(module_id, CC_id, frame, ra);
UE_info->active[UE_id] = true;
UE_info->Msg4_ACKed[UE_id] = true;
if(sched_ctrl->retrans_dl_harq.head>=0)
remove_nr_list(&sched_ctrl->retrans_dl_harq, current_harq_pid);
}
else {
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);
if(sched_ctrl->retrans_dl_harq.head >= 0) {
remove_nr_list(&sched_ctrl->retrans_dl_harq, current_harq_pid);
}
}
else {
......@@ -1800,6 +1820,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->msg3_dcch_dtch = false;
ra->crnti = 0;
if(ra->cfra == false) {
ra->rnti = 0;
......
......@@ -2053,7 +2053,7 @@ void mac_remove_nr_ue(module_id_t mod_id, rnti_t rnti)
destroy_nr_list(&sched_ctrl->available_ul_harq);
destroy_nr_list(&sched_ctrl->feedback_ul_harq);
destroy_nr_list(&sched_ctrl->retrans_ul_harq);
LOG_I(NR_MAC, "[gNB %d] Remove NR UE_id %d : rnti %x\n",
LOG_I(NR_MAC, "[gNB %d] Remove NR UE_id %d: rnti 0x%04x\n",
mod_id,
UE_id,
rnti);
......
......@@ -303,7 +303,8 @@ int nr_process_mac_pdu(module_id_t module_idP,
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);
ra->msg3_dcch_dtch = true;
LOG_I(NR_MAC, "Received UL_SCH_LCID_C_RNTI with C-RNTI 0x%04x\n", ra->crnti);
break;
}
}
......@@ -777,13 +778,13 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP;
LOG_D(NR_MAC,
"reset RA state information for RA-RNTI %04x/index %d\n",
"reset RA state information for RA-RNTI 0x%04x/index %d\n",
ra->rnti,
i);
LOG_I(NR_MAC,
"[gNB %d][RAPROC] PUSCH with TC_RNTI %x received correctly, "
"adding UE MAC Context UE_id %d/RNTI %04x\n",
"[gNB %d][RAPROC] PUSCH with TC_RNTI 0x%04x received correctly, "
"adding UE MAC Context UE_id %d/RNTI 0x%04x\n",
gnb_mod_idP,
current_rnti,
UE_id,
......@@ -821,7 +822,8 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
ra->state = Msg4;
ra->Msg4_frame = (frameP + 2) % 1024;
ra->Msg4_slot = 1;
LOG_I(NR_MAC, "Scheduling RA-Msg4 for TC_RNTI 0x%04x (state %d, frame %d, slot %d)\n", ra->rnti, ra->state, ra->Msg4_frame, ra->Msg4_slot);
LOG_I(NR_MAC, "Scheduling RA-Msg4 for TC_RNTI 0x%04x (state %d, frame %d, slot %d)\n",
(ra->msg3_dcch_dtch?ra->crnti:ra->rnti), ra->state, ra->Msg4_frame, ra->Msg4_slot);
}
else {
nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti);
......
......@@ -155,6 +155,8 @@ typedef struct {
uint8_t msg3_cqireq;
/// Round of Msg3 HARQ
uint8_t msg3_round;
/// Flag to indicate if Msg3 carries a DCCH or DTCH message
bool msg3_dcch_dtch;
/// TBS used for Msg4
int msg4_TBsize;
/// MCS used for Msg4
......
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