Commit 65bc749e authored by francescomani's avatar francescomani

start the rar reception window in PRACH slots but take into account the...

start the rar reception window in PRACH slots but take into account the additional slots difference wrt when we actually would need to start it (in first DCI occasion)
parent 5df61530
......@@ -331,7 +331,7 @@ typedef struct {
int ra_ssb;
/// Random-access response window timer
NR_timer_t response_window_timer;
bool start_response_window;
int response_window_setup_time;
/// Random-access backoff timer
NR_timer_t RA_backoff_timer;
int RA_backoff_limit;
......
......@@ -302,6 +302,7 @@ void configure_initial_pucch(PUCCH_sched_t *pucch, int res_ind);
void release_PUCCH_SRS(NR_UE_MAC_INST_t *mac);
void nr_ue_reset_sync_state(NR_UE_MAC_INST_t *mac);
void nr_ue_send_synch_request(NR_UE_MAC_INST_t *mac, module_id_t module_id, int cc_id, const fapi_nr_synch_request_t *sync_req);
bool is_ss_monitor_occasion(const int frame, const int slot, const int slots_per_frame, const NR_SearchSpace_t *ss);
/**
* @brief Get UE sync state
......
......@@ -820,7 +820,7 @@ static void setup_ra_response_window(RA_config_t *ra,
ta_Common_slots = (int)ceil(ta_Common_ms * slots_per_frame / 10);
}
nr_timer_setup(&ra->response_window_timer, respwind_value + ta_Common_slots, 1);
ra->response_window_setup_time = respwind_value + ta_Common_slots;
}
// Random Access procedure initialization as per 5.1.1 and initialization of variables specific
......@@ -1067,8 +1067,6 @@ bool init_RA(NR_UE_MAC_INST_t *mac, int frame)
rach_ConfigGeneric,
twostep_generic,
&mac->ntn_ta);
ra->start_response_window = false;
return true;
}
......
......@@ -560,18 +560,13 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
config_dci_pdu(mac, dl_config, TYPE_SI_RNTI_, slot, ss);
}
}
if (mac->state == UE_PERFORMING_RA && mac->ra.ra_state >= nrRA_WAIT_RAR) {
RA_config_t *ra = &mac->ra;
if (mac->state == UE_PERFORMING_RA && ra->ra_state >= nrRA_WAIT_RAR) {
// if RA is ongoing use RA search space
if (is_ss_monitor_occasion(frame, slot, slots_per_frame, pdcch_config->ra_SS)) {
// The RA response window starts at the first symbol of the earliest CORESET
// the UE is configured to receive PDCCH for Type1-PDCCH CSS set
if (mac->ra.start_response_window) {
nr_timer_start(&mac->ra.response_window_timer);
mac->ra.start_response_window = false;
}
nr_rnti_type_t rnti_type = 0;
if (mac->ra.ra_type == RA_4_STEP) {
rnti_type = mac->ra.ra_state == nrRA_WAIT_RAR ? TYPE_RA_RNTI_ : TYPE_TC_RNTI_;
if (ra->ra_type == RA_4_STEP) {
rnti_type = ra->ra_state == nrRA_WAIT_RAR ? TYPE_RA_RNTI_ : TYPE_TC_RNTI_;
} else {
rnti_type = TYPE_MSGB_RNTI_;
}
......
......@@ -2180,13 +2180,31 @@ static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t
T(T_UE_PHY_INITIATE_RA_PROCEDURE, T_INT(frameP), T_INT(pdu->prach_config_pdu.prach_slot),
T_INT(pdu->prach_config_pdu.ra_PreambleIndex), T_INT(pdu->prach_config_pdu.prach_tx_power));
const int n_slots_frame = mac->frame_structure.numb_slots_frame;
if (ra->ra_type == RA_4_STEP) {
ra->ra_state = nrRA_WAIT_RAR;
ra->start_response_window = true;
// we start to monitor DCI for RAR in the first valid occasion after transmitting RACH
// the response window timer should be started at that time
// but for processing reasons it is better to start it here and to add the slot difference
// that also takes into account the rx to tx slot offset
int next_slot = (slotP + 1) % n_slots_frame;
int next_frame = (frameP + (next_slot < slotP)) % MAX_FRAME_NUMBER;
int add_slots = 1;
NR_BWP_PDCCH_t *pdcch_config = &mac->config_BWP_PDCCH[mac->current_DL_BWP->bwp_id];
while (!is_dl_slot(next_slot, &mac->frame_structure)
|| !is_ss_monitor_occasion(next_frame, next_slot, n_slots_frame, pdcch_config->ra_SS)) {
int temp_slot = (next_slot + 1) % n_slots_frame;
next_frame = (next_frame + (temp_slot < next_slot)) % MAX_FRAME_NUMBER;
next_slot = temp_slot;
add_slots++;
}
nr_timer_setup(&ra->response_window_timer,
ra->response_window_setup_time + add_slots + GET_DURATION_RX_TO_TX(&mac->ntn_ta),
1);
nr_timer_start(&ra->response_window_timer);
} else if (ra->ra_type == RA_2_STEP) {
NR_MsgA_PUSCH_Resource_r16_t *msgA_PUSCH_Resource =
mac->current_UL_BWP->msgA_ConfigCommon_r16->msgA_PUSCH_Config_r16->msgA_PUSCH_ResourceGroupA_r16;
const int n_slots_frame = mac->frame_structure.numb_slots_frame;
slot_t msgA_pusch_slot = (slotP + msgA_PUSCH_Resource->msgA_PUSCH_TimeDomainOffset_r16) % n_slots_frame;
frame_t msgA_pusch_frame =
(frameP + ((slotP + msgA_PUSCH_Resource->msgA_PUSCH_TimeDomainOffset_r16) / n_slots_frame)) % 1024;
......
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