Commit 954666b3 authored by cig's avatar cig

Contention resolution TS 38.321 ch 5.1.5

parent f3870265
......@@ -3273,6 +3273,17 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) {
}
}
// if contention resolution fails, go back to UE mode PRACH
void nr_ra_failed(uint8_t Mod_id, uint8_t CC_id, uint8_t gNB_index) {
PHY_VARS_NR_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
ue->UE_mode[gNB_index] = PRACH;
for (int i=0; i <RX_NB_TH_MAX; i++ ) {
ue->pdcch_vars[i][gNB_index]->pdcch_config[0].rnti = 0;
}
LOG_E(PHY,"[UE %d] [RAPROC] Random-access procedure fails, going back to PRACH\n", Mod_id);
}
void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc,
......
......@@ -216,5 +216,9 @@ uint16_t nr_ue_process_rar(module_id_t mod_id,
void nr_process_rar(nr_downlink_indication_t *dl_info);
void ue_contention_resolution(module_id_t module_id, uint8_t gNB_index, int cc_id, frame_t tx_frame);
void nr_ra_failed(uint8_t Mod_id, uint8_t CC_id, uint8_t gNB_index);
#endif
/** @}*/
......@@ -728,6 +728,9 @@ NR_UE_L2_STATE_t nr_ue_scheduler(const module_id_t module_id,
*/
}
if (mac->RA_contention_resolution_timer_active == 1) {
ue_contention_resolution(module_id, gNB_index, cc_id, tx_frame);
}
mac->scheduled_response.dl_config = dl_config;
......@@ -735,6 +738,49 @@ NR_UE_L2_STATE_t nr_ue_scheduler(const module_id_t module_id,
return UE_CONNECTION_OK;
}
////////////////////////////////////////////////////////////////////////////
/////////* Random Access Contention Resolution (5.1.35 TS 38.321) */////////
////////////////////////////////////////////////////////////////////////////
// Handling contention resolution timer
// WIP todo:
// - beam failure recovery
// - RA completed
void ue_contention_resolution(module_id_t module_id, uint8_t gNB_index, int cc_id, frame_t tx_frame){
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
NR_RACH_ConfigCommon_t *rach_ConfigCommon;
if (mac->RA_contention_resolution_timer_active == 1) {
if (mac->nr_rach_ConfigCommon) {
rach_ConfigCommon = &mac->nr_rach_ConfigCommon;
} else {
// LOG_E(MAC, "FATAL: radioResourceConfigCommon is NULL!!!\n");
// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER,VCD_FUNCTION_OUT);
// stop_meas(&mac->ue_scheduler);
// AssertFatal(1 == 0, "");
// #if UE_TIMING_TRACE
// stop_meas(&mac->ue_scheduler);
// #endif
}
LOG_I(MAC, "Frame %d: Contention resolution timer %d/%ld\n",
tx_frame,
mac->RA_contention_resolution_cnt,
((1 + rach_ConfigCommon->ra_ContentionResolutionTimer) << 3));
mac->RA_contention_resolution_cnt++;
if (mac->RA_contention_resolution_cnt == ((1 + rach_ConfigCommon->ra_ContentionResolutionTimer) << 3)) {
mac->t_crnti = 0;
mac->RA_active = 0;
mac->RA_contention_resolution_timer_active = 0;
// Signal PHY to quit RA procedure
LOG_E(MAC, "[UE %u] [RAPROC] Contention resolution timer expired, RA failed, discarded TC-RNTI\n", module_id);
nr_ra_failed(module_id, cc_id, gNB_index);
}
}
}
#if 0
uint16_t nr_dci_format_size (PHY_VARS_NR_UE *ue,
uint8_t slot,
......
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