Commit 39920eb3 authored by francescomani's avatar francescomani

L2 indication to prepare MSG3 payload in advance

This is required to comply with the standard to flush MSG3 buffer in some occasions and to keep preparing MSG3 payload in advance
parent 4b191b7d
...@@ -78,6 +78,7 @@ typedef struct NRRrcMacRaInd_s { ...@@ -78,6 +78,7 @@ typedef struct NRRrcMacRaInd_s {
typedef struct NRRrcMacMsg3Ind_s { typedef struct NRRrcMacMsg3Ind_s {
uint16_t rnti; uint16_t rnti;
int gnb_id; int gnb_id;
bool prepare_payload;
} NRRrcMacMsg3Ind; } NRRrcMacMsg3Ind;
typedef struct NRRrcMacInacInd_s { typedef struct NRRrcMacInacInd_s {
......
...@@ -1003,6 +1003,10 @@ bool init_RA(NR_UE_MAC_INST_t *mac, int frame) ...@@ -1003,6 +1003,10 @@ bool init_RA(NR_UE_MAC_INST_t *mac, int frame)
} }
} }
// need to ask RRC to send the MSG3 data to transmit if needed (CBRA originating from upper layers)
if (!mac->msg3_C_RNTI && ra->cfra == false)
nr_mac_rrc_msg3_ind(mac->ue_id, 0, true);
NR_RACH_ConfigGenericTwoStepRA_r16_t *twostep_generic = twostep_conf ? &twostep_conf->rach_ConfigGenericTwoStepRA_r16 : NULL; NR_RACH_ConfigGenericTwoStepRA_r16_t *twostep_generic = twostep_conf ? &twostep_conf->rach_ConfigGenericTwoStepRA_r16 : NULL;
if (ra->ra_type == RA_2_STEP && twostep_generic && twostep_generic->msgA_PreamblePowerRampingStep_r16) if (ra->ra_type == RA_2_STEP && twostep_generic && twostep_generic->msgA_PreamblePowerRampingStep_r16)
prach_resources->preamble_power_ramping_step = *twostep_generic->msgA_PreamblePowerRampingStep_r16 << 1; prach_resources->preamble_power_ramping_step = *twostep_generic->msgA_PreamblePowerRampingStep_r16 << 1;
...@@ -1215,6 +1219,7 @@ void nr_ra_contention_resolution_failed(NR_UE_MAC_INST_t *mac) ...@@ -1215,6 +1219,7 @@ void nr_ra_contention_resolution_failed(NR_UE_MAC_INST_t *mac)
ra->t_crnti = 0; ra->t_crnti = 0;
// flush MSG3 buffer // flush MSG3 buffer
free_and_zero(ra->Msg3_buffer); free_and_zero(ra->Msg3_buffer);
nr_mac_rrc_msg3_ind(mac->ue_id, 0, true);
NR_PRACH_RESOURCES_t *prach_resources = &ra->prach_resources; NR_PRACH_RESOURCES_t *prach_resources = &ra->prach_resources;
prach_resources->preamble_tx_counter++; prach_resources->preamble_tx_counter++;
if (prach_resources->preamble_tx_counter == ra->preambleTransMax + 1) { if (prach_resources->preamble_tx_counter == ra->preambleTransMax + 1) {
......
...@@ -3863,7 +3863,7 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, ...@@ -3863,7 +3863,7 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce,
return mac_ce - pdu; return mac_ce - pdu;
} }
static void handle_rar_reception(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dlinfo, NR_MAC_RAR *rar, frame_t frame, int slot) static void handle_rar_reception(NR_UE_MAC_INST_t *mac, NR_MAC_RAR *rar, frame_t frame, int slot)
{ {
RAR_grant_t rar_grant; RAR_grant_t rar_grant;
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
...@@ -3953,7 +3953,7 @@ static void handle_rar_reception(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t ...@@ -3953,7 +3953,7 @@ static void handle_rar_reception(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t
ra->t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8); ra->t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8);
rnti = ra->t_crnti; rnti = ra->t_crnti;
if (!mac->msg3_C_RNTI) if (!mac->msg3_C_RNTI)
nr_mac_rrc_msg3_ind(mac->ue_id, rnti, dlinfo->gNB_index); nr_mac_rrc_msg3_ind(mac->ue_id, rnti, false);
} }
fapi_nr_ul_config_request_pdu_t *pdu = lockGet_ul_config(mac, frame_tx, slot_tx, FAPI_NR_UL_CONFIG_TYPE_PUSCH); fapi_nr_ul_config_request_pdu_t *pdu = lockGet_ul_config(mac, frame_tx, slot_tx, FAPI_NR_UL_CONFIG_TYPE_PUSCH);
if (!pdu) if (!pdu)
...@@ -4057,7 +4057,7 @@ static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *d ...@@ -4057,7 +4057,7 @@ static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *d
nr_timer_stop(&ra->response_window_timer); nr_timer_stop(&ra->response_window_timer);
LOG_A(NR_MAC, "[UE %d][RAPROC][%d.%d] Found RAR with the intended RAPID %d\n", mac->ue_id, frame, slot, rarh->RAPID); LOG_A(NR_MAC, "[UE %d][RAPROC][%d.%d] Found RAR with the intended RAPID %d\n", mac->ue_id, frame, slot, rarh->RAPID);
rar = (NR_MAC_RAR *) (dlsch_buffer + n_subheaders + (n_subPDUs - 1) * sizeof(NR_MAC_RAR)); rar = (NR_MAC_RAR *) (dlsch_buffer + n_subheaders + (n_subPDUs - 1) * sizeof(NR_MAC_RAR));
handle_rar_reception(mac, dl_info, rar, frame, slot); handle_rar_reception(mac, rar, frame, slot);
if (ra->cfra) if (ra->cfra)
nr_ra_succeeded(mac, dl_info->gNB_index, frame, slot); nr_ra_succeeded(mac, dl_info->gNB_index, frame, slot);
if (get_softmodem_params()->emulate_l1) { if (get_softmodem_params()->emulate_l1) {
......
...@@ -32,6 +32,9 @@ softmodem_params_t *get_softmodem_params(void) ...@@ -32,6 +32,9 @@ softmodem_params_t *get_softmodem_params(void)
void nr_mac_rrc_ra_ind(const module_id_t mod_id, bool success) void nr_mac_rrc_ra_ind(const module_id_t mod_id, bool success)
{ {
} }
void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, bool prepare_payload)
{
}
tbs_size_t mac_rlc_data_req(const module_id_t module_idP, tbs_size_t mac_rlc_data_req(const module_id_t module_idP,
const rnti_t rntiP, const rnti_t rntiP,
const eNB_index_t eNB_index, const eNB_index_t eNB_index,
......
...@@ -159,11 +159,11 @@ void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id) ...@@ -159,11 +159,11 @@ void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id)
itti_send_msg_to_task(TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE(mod_id), message_p); itti_send_msg_to_task(TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE(mod_id), message_p);
} }
void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, int gnb_id) void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, bool prepare_payload)
{ {
MessageDef *message_p = itti_alloc_new_message(TASK_MAC_UE, 0, NR_RRC_MAC_MSG3_IND); MessageDef *message_p = itti_alloc_new_message(TASK_MAC_UE, 0, NR_RRC_MAC_MSG3_IND);
NR_RRC_MAC_MSG3_IND (message_p).rnti = rnti; NR_RRC_MAC_MSG3_IND (message_p).rnti = rnti;
NR_RRC_MAC_MSG3_IND (message_p).gnb_id = gnb_id; NR_RRC_MAC_MSG3_IND (message_p).prepare_payload = prepare_payload;
itti_send_msg_to_task(TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE(mod_id), message_p); itti_send_msg_to_task(TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE(mod_id), message_p);
} }
......
...@@ -37,7 +37,7 @@ void nr_mac_rrc_data_ind_ue(const module_id_t module_id, ...@@ -37,7 +37,7 @@ void nr_mac_rrc_data_ind_ue(const module_id_t module_id,
const uint8_t* pduP, const uint8_t* pduP,
const sdu_size_t pdu_len); const sdu_size_t pdu_len);
void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id); void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id);
void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, int gnb_id); void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, bool prepare_payload);
void nr_ue_rrc_timer_trigger(int instance, int frame, int gnb_id); void nr_ue_rrc_timer_trigger(int instance, int frame, int gnb_id);
void nr_mac_rrc_ra_ind(const module_id_t mod_id, bool success); void nr_mac_rrc_ra_ind(const module_id_t mod_id, bool success);
void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, Rrc_Msg_Type_t msg_type); void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, Rrc_Msg_Type_t msg_type);
......
...@@ -335,8 +335,6 @@ static void nr_rrc_process_sib1(NR_UE_RRC_INST_t *rrc, NR_UE_RRC_SI_INFO *SI_inf ...@@ -335,8 +335,6 @@ static void nr_rrc_process_sib1(NR_UE_RRC_INST_t *rrc, NR_UE_RRC_SI_INFO *SI_inf
SI_info->sib1_validity = SIB_VALID; SI_info->sib1_validity = SIB_VALID;
if (rrc->nrRrcState == RRC_STATE_IDLE_NR) { if (rrc->nrRrcState == RRC_STATE_IDLE_NR) {
rrc->ra_trigger = RRC_CONNECTION_SETUP; rrc->ra_trigger = RRC_CONNECTION_SETUP;
// preparing RRC setup request payload in advance
nr_rrc_ue_prepare_RRCSetupRequest(rrc);
} }
NR_SIB1_v1700_IEs_t *sib1_v1700 = NULL; NR_SIB1_v1700_IEs_t *sib1_v1700 = NULL;
...@@ -856,15 +854,6 @@ static void nr_rrc_ue_decode_NR_BCCH_BCH_Message(NR_UE_RRC_INST_t *rrc, ...@@ -856,15 +854,6 @@ static void nr_rrc_ue_decode_NR_BCCH_BCH_Message(NR_UE_RRC_INST_t *rrc,
nr_timer_stop(&timers->T311); nr_timer_stop(&timers->T311);
rrc->ra_trigger = RRC_CONNECTION_REESTABLISHMENT; rrc->ra_trigger = RRC_CONNECTION_REESTABLISHMENT;
// preparing MSG3 for re-establishment in advance
uint8_t buffer[1024];
int buf_size = do_RRCReestablishmentRequest(buffer,
rrc->reestablishment_cause,
rrc->phyCellID,
rrc->rnti); // old rnti
nr_rlc_srb_recv_sdu(rrc->ue_id, 0, buffer, buf_size);
// apply the default MAC Cell Group configuration // apply the default MAC Cell Group configuration
// (done at MAC by calling nr_ue_mac_default_configs) // (done at MAC by calling nr_ue_mac_default_configs)
...@@ -892,6 +881,31 @@ static void nr_rrc_ue_decode_NR_BCCH_BCH_Message(NR_UE_RRC_INST_t *rrc, ...@@ -892,6 +881,31 @@ static void nr_rrc_ue_decode_NR_BCCH_BCH_Message(NR_UE_RRC_INST_t *rrc,
return; return;
} }
static void nr_rrc_ue_prepare_RRCReestablishmentRequest(NR_UE_RRC_INST_t *rrc)
{
uint8_t buffer[1024];
int buf_size = do_RRCReestablishmentRequest(buffer, rrc->reestablishment_cause, rrc->phyCellID, rrc->rnti); // old rnti
nr_rlc_srb_recv_sdu(rrc->ue_id, 0, buffer, buf_size);
}
static void nr_rrc_prepare_msg3_payload(NR_UE_RRC_INST_t *rrc)
{
if (!IS_SA_MODE(get_softmodem_params()))
return;
switch (rrc->ra_trigger) {
case RRC_CONNECTION_SETUP:
// preparing RRC setup request payload in advance
nr_rrc_ue_prepare_RRCSetupRequest(rrc);
break;
case RRC_CONNECTION_REESTABLISHMENT:
// preparing MSG3 for re-establishment in advance
nr_rrc_ue_prepare_RRCReestablishmentRequest(rrc);
break;
default:
AssertFatal(false, "RA trigger not implemented\n");
}
}
static void nr_rrc_handle_msg3_indication(NR_UE_RRC_INST_t *rrc, rnti_t rnti) static void nr_rrc_handle_msg3_indication(NR_UE_RRC_INST_t *rrc, rnti_t rnti)
{ {
NR_UE_Timers_Constants_t *tac = &rrc->timers_and_constants; NR_UE_Timers_Constants_t *tac = &rrc->timers_and_constants;
...@@ -2045,7 +2059,10 @@ void *rrc_nrue(void *notUsed) ...@@ -2045,7 +2059,10 @@ void *rrc_nrue(void *notUsed)
break; break;
case NR_RRC_MAC_MSG3_IND: case NR_RRC_MAC_MSG3_IND:
nr_rrc_handle_msg3_indication(rrc, NR_RRC_MAC_MSG3_IND(msg_p).rnti); if (NR_RRC_MAC_MSG3_IND(msg_p).prepare_payload)
nr_rrc_prepare_msg3_payload(rrc);
else
nr_rrc_handle_msg3_indication(rrc, NR_RRC_MAC_MSG3_IND(msg_p).rnti);
break; break;
case NR_RRC_MAC_RA_IND: case NR_RRC_MAC_RA_IND:
......
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