diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index ca0fac4908..2b882ee485 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -489,7 +489,6 @@ void nr_Msg1_transmitted(module_id_t mod_id); void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, slot_t slotP, uint8_t gNB_id); void nr_get_msg3_payload(module_id_t mod_id, uint8_t *buf, int TBS_max); -void send_msg3_rrc_request(module_id_t mod_id, int rnti); void nr_ue_msg2_scheduler(module_id_t mod_id, uint16_t rach_frame, uint16_t rach_slot, uint16_t *msg2_frame, uint16_t *msg2_slot); diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 09b2312054..be013b6dff 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -53,12 +53,6 @@ void send_srb0_rrc(int ue_id, const uint8_t *sdu, sdu_size_t sdu_len, void *data itti_send_msg_to_task(TASK_RRC_NRUE, ue_id, message_p); } -void send_msg3_rrc_request(module_id_t mod_id, int rnti) -{ - nr_rlc_activate_srb0(mod_id, NULL, send_srb0_rrc); - nr_mac_rrc_msg3_ind(mod_id, rnti); -} - void nr_ue_init_mac(module_id_t module_idP) { LOG_I(NR_MAC, "[UE%d] Applying default macMainConfig\n", module_idP); @@ -129,6 +123,10 @@ NR_UE_MAC_INST_t *nr_l2_init_ue(int nb_inst) int rc = rlc_module_init(0); AssertFatal(rc == 0, "Could not initialize RLC layer\n"); + for (int j = 0; j < nb_inst; j++) { + nr_rlc_activate_srb0(j, NULL, send_srb0_rrc); + } + return (nr_ue_mac_inst); } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 1f76ef2825..aed14ed73c 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -4167,7 +4167,7 @@ static int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) if (!ra->cfra) { ra->t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8); rnti = ra->t_crnti; - send_msg3_rrc_request(mod_id, rnti); + nr_mac_rrc_msg3_ind(mod_id, rnti); } pthread_mutex_lock(&ul_config->mutex_ul_config); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index badf181f39..6e94eb0a61 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -141,7 +141,6 @@ static void nr_rrc_manage_rlc_bearers(const NR_UE_RRC_INST_t *rrc, static void nr_rrc_ue_process_RadioBearerConfig(NR_UE_RRC_INST_t *ue_rrc, rrcPerNB_t *rrcNB, NR_RadioBearerConfig_t *const radioBearerConfig); -static void nr_rrc_ue_generate_RRCSetupRequest(NR_UE_RRC_INST_t *rrc); static void nr_rrc_ue_generate_rrcReestablishmentComplete(NR_RRCReestablishment_t *rrcReestablishment); static void process_lte_nsa_msg(NR_UE_RRC_INST_t *rrc, nsa_msg_t *msg, int msg_len); static void nr_rrc_ue_process_rrcReconfiguration(NR_UE_RRC_INST_t *rrc, @@ -309,7 +308,7 @@ NR_UE_RRC_INST_t* nr_rrc_init_ue(char* uecap_file, int nb_inst) rrc->dl_bwp_id = 0; rrc->ul_bwp_id = 0; rrc->as_security_activated = false; - + rrc->ra_trigger = RA_NOT_RUNNING; rrc->uecap_file = uecap_file; for (int i = 0; i < NB_CNX_UE; i++) { @@ -566,13 +565,15 @@ static int nr_decode_SI(NR_UE_RRC_SI_INFO *SI_info, NR_SystemInformation_t *si) return 0; } -void nr_rrc_ue_generate_ra_msg(NR_UE_RRC_INST_t *rrc, RA_trigger_t trigger, int rnti) +static void nr_rrc_handle_msg3_indication(NR_UE_RRC_INST_t *rrc, int rnti) { - switch (trigger) { + switch (rrc->ra_trigger) { case INITIAL_ACCESS_FROM_RRC_IDLE: // After SIB1 is received, prepare RRCConnectionRequest rrc->rnti = rnti; - nr_rrc_ue_generate_RRCSetupRequest(rrc); + // start timer T300 + NR_UE_Timers_Constants_t *tac = &rrc->timers_and_constants; + tac->T300_active = true; break; case RRC_CONNECTION_REESTABLISHMENT: AssertFatal(1==0, "ra_trigger not implemented yet!\n"); @@ -601,7 +602,7 @@ void nr_rrc_ue_generate_ra_msg(NR_UE_RRC_INST_t *rrc, RA_trigger_t trigger, int } } -static void nr_rrc_ue_generate_RRCSetupRequest(NR_UE_RRC_INST_t *rrc) +static void nr_rrc_ue_prepare_RRCSetupRequest(NR_UE_RRC_INST_t *rrc) { LOG_D(NR_RRC, "Generation of RRCSetupRequest\n"); uint8_t rv[6]; @@ -619,11 +620,6 @@ static void nr_rrc_ue_generate_RRCSetupRequest(NR_UE_RRC_INST_t *rrc) uint8_t buf[1024]; int len = do_RRCSetupRequest(buf, sizeof(buf), rv); - // start timer T300 - NR_UE_Timers_Constants_t *tac = &rrc->timers_and_constants; - tac->T300_active = true; - - /* convention: RNTI for SRB0 is zero, as it changes all the time */ nr_rlc_srb_recv_sdu(rrc->ue_id, 0, buf, len); } @@ -687,9 +683,10 @@ static int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(NR_UE_RRC_INST_t *rrc, xer_fprint(stdout, &asn_DEF_NR_SIB1, (const void *) SI_info->sib1); LOG_A(NR_RRC, "SIB1 decoded\n"); SI_info->sib1_timer = 0; - // FIXME: improve condition for the RA trigger if (rrc->nrRrcState == RRC_STATE_IDLE_NR) { - LOG_D(PHY,"Setting state to RRC_STATE_IDLE_NR\n"); + rrc->ra_trigger = INITIAL_ACCESS_FROM_RRC_IDLE; + // preparing RRC setup request payload in advance + nr_rrc_ue_prepare_RRCSetupRequest(rrc); } // configure default SI nr_rrc_configure_default_SI(SI_info, sib1); @@ -1440,7 +1437,7 @@ void *rrc_nrue(void *notUsed) break; case NR_RRC_MAC_MSG3_IND: - nr_rrc_ue_generate_ra_msg(rrc, INITIAL_ACCESS_FROM_RRC_IDLE, NR_RRC_MAC_MSG3_IND(msg_p).rnti); + nr_rrc_handle_msg3_indication(rrc, NR_RRC_MAC_MSG3_IND(msg_p).rnti); break; case NR_RRC_MAC_RA_IND: diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index efcb9acfe5..73f2d0827f 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -213,9 +213,8 @@ typedef struct NR_UE_RRC_INST_s { OAI_NR_UECapability_t UECap; NR_UE_Timers_Constants_t timers_and_constants; - plmn_t plmnID; - - // NR_MIB_t *mib; + RA_trigger_t ra_trigger; + plmn_t plmnID; NR_BWP_Id_t dl_bwp_id; NR_BWP_Id_t ul_bwp_id;