diff --git a/executables/nr-ue.c b/executables/nr-ue.c index a0ec760061..6da78819f5 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -624,6 +624,14 @@ static int UE_dl_preprocessing(PHY_VARS_NR_UE *UE, if (UE->sl_mode == 2) fp = &UE->SL_UE_PHY_PARAMS.sl_frame_params; + // process what RRC thread sent to MAC + MessageDef *msg = NULL; + do { + itti_poll_msg(TASK_MAC_UE, &msg); + if (msg) + process_msg_rcc_to_mac(msg); + } while (msg); + if (IS_SOFTMODEM_NOS1 || IS_SA_MODE(get_softmodem_params())) { /* send tick to RLC and PDCP every ms */ if (proc->nr_slot_rx % fp->slots_per_subframe == 0) { @@ -868,10 +876,18 @@ void *UE_thread(void *arg) syncRunning = false; if (UE->is_synchronized) { UE->synch_request.received_synch_request = 0; - if (UE->sl_mode == 2) + if (UE->sl_mode == SL_MODE2_SUPPORTED) decoded_frame_rx = UE->SL_UE_PHY_PARAMS.sync_params.DFN; - else + else { + // We must wait the RRC layer decoded the MIB and sent us the frame number + MessageDef *msg = NULL; + itti_receive_msg(TASK_MAC_UE, &msg); + if (msg) + process_msg_rcc_to_mac(msg); + else + LOG_E(PHY, "It seems we arbort while trying to sync\n"); decoded_frame_rx = mac->mib_frame; + } LOG_A(PHY, "UE synchronized! decoded_frame_rx=%d UE->init_sync_frame=%d trashed_frames=%d\n", decoded_frame_rx, diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index eba55bc46c..d5896bbffd 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -52,6 +52,7 @@ #include "PHY_INTERFACE/phy_interface_vars.h" #include "NR_IF_Module.h" #include "openair1/SIMULATION/TOOLS/sim.h" +#include "openair2/RRC/NR_UE/L2_interface_ue.h" #ifdef SMBV #include "PHY/TOOLS/smbv.h" @@ -488,6 +489,12 @@ int main(int argc, char **argv) get_softmodem_params()->numerology, nr_band); } else { + MessageDef *msg = NULL; + do { + itti_poll_msg(TASK_MAC_UE, &msg); + if (msg) + process_msg_rcc_to_mac(msg); + } while (msg); fapi_nr_config_request_t *nrUE_config = &UE[CC_id]->nrUE_config; nr_init_frame_parms_ue(&UE[CC_id]->frame_parms, nrUE_config, mac->nr_band); } diff --git a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c index 2d64de91e0..ba5c2bf025 100644 --- a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c +++ b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c @@ -3,7 +3,7 @@ #include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h" #include "openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h" #include "openair1/PHY/defs_nr_UE.h" - +#include "position_interface.h" int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) { return (0); } int oai_nfapi_tx_data_req(nfapi_nr_tx_data_request_t *tx_data_req) { return (0); } @@ -19,7 +19,7 @@ int pack_nr_srs_beamforming_report(void *pMessageBuf, void *pPackedBuf, uint32_t int unpack_nr_srs_beamforming_report(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen) { return 0; } int pack_nr_srs_normalized_channel_iq_matrix(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen) { return 0; } int unpack_nr_srs_normalized_channel_iq_matrix(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen) { return 0; } - +void get_position_coordinates(int Mod_id, position_t *position) {} int32_t get_uldl_offset(int nr_bandP) { return (0); } void configure_nr_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port) {} diff --git a/openair2/COMMON/as_message.h b/openair2/COMMON/as_message.h index e4061f5c3d..cdf6792151 100644 --- a/openair2/COMMON/as_message.h +++ b/openair2/COMMON/as_message.h @@ -43,7 +43,6 @@ Description Defines the messages supported by the Access Stratum sublayer #include "commonDef.h" #include "networkDef.h" - /****************************************************************************/ /********************* G L O B A L C O N S T A N T S *******************/ /****************************************************************************/ diff --git a/openair2/COMMON/rrc_messages_def.h b/openair2/COMMON/rrc_messages_def.h index fb94aeb29e..cb4805ff5e 100644 --- a/openair2/COMMON/rrc_messages_def.h +++ b/openair2/COMMON/rrc_messages_def.h @@ -82,6 +82,13 @@ MESSAGE_DEF(NAS_DOWNLINK_DATA_IND, MESSAGE_PRIORITY_MED, dl_info_transfer_ind_t, MESSAGE_DEF(RRC_SUBFRAME_PROCESS, MESSAGE_PRIORITY_MED, RrcSubframeProcess, rrc_subframe_process) MESSAGE_DEF(NRRRC_FRAME_PROCESS, MESSAGE_PRIORITY_MED, NRRrcFrameProcess, nr_rrc_frame_process) +// UE: RRC -> MAC messages +MESSAGE_DEF(NR_MAC_RRC_CONFIG_RESET, MESSAGE_PRIORITY_MED, nr_mac_rrc_config_reset_t, nr_mac_rrc_config_reset) +MESSAGE_DEF(NR_MAC_RRC_CONFIG_CG, MESSAGE_PRIORITY_MED, nr_mac_rrc_config_cg_t, nr_mac_rrc_config_cg) +MESSAGE_DEF(NR_MAC_RRC_CONFIG_MIB, MESSAGE_PRIORITY_MED, nr_mac_rrc_config_mib_t, nr_mac_rrc_config_mib) +MESSAGE_DEF(NR_MAC_RRC_CONFIG_SIB1, MESSAGE_PRIORITY_MED, nr_mac_rrc_config_sib1_t, nr_mac_rrc_config_sib1) +MESSAGE_DEF(NR_MAC_RRC_CONFIG_OTHER_SIB, MESSAGE_PRIORITY_MED, nr_mac_rrc_config_other_sib_t, nr_mac_rrc_config_other_sib) + // eNB: RLC -> RRC messages MESSAGE_DEF(RLC_SDU_INDICATION, MESSAGE_PRIORITY_MED, RlcSduIndication, rlc_sdu_indication) MESSAGE_DEF(NAS_PDU_SESSION_REQ, MESSAGE_PRIORITY_MED, nas_pdu_session_req_t, nas_pdu_session_req) diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index 0e57120ee4..7eba8f3467 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -96,12 +96,16 @@ #define NAS_OAI_TUN_NSA(mSGpTR) (mSGpTR)->ittiMsg.nas_oai_tun_nsa #define NAS_PDU_SESSION_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_pdu_session_req +#define NR_MAC_RRC_CONFIG_RESET(mSGpTR) (mSGpTR)->ittiMsg.nr_mac_rrc_config_reset +#define NR_MAC_RRC_CONFIG_CG(mSGpTR) (mSGpTR)->ittiMsg.nr_mac_rrc_config_cg +#define NR_MAC_RRC_CONFIG_MIB(mSGpTR) (mSGpTR)->ittiMsg.nr_mac_rrc_config_mib +#define NR_MAC_RRC_CONFIG_SIB1(mSGpTR) (mSGpTR)->ittiMsg.nr_mac_rrc_config_sib1 +#define NR_MAC_RRC_CONFIG_OTHER_SIB(mSGpTR) (mSGpTR)->ittiMsg.nr_mac_rrc_config_other_sib #define NR_RRC_RLC_MAXRTX(mSGpTR) (mSGpTR)->ittiMsg.nr_rlc_maxrtx_indication -//-------------------------------------------------------------------------------------------// typedef struct RrcStateInd_s { - Rrc_State_t state; + Rrc_State_t state; Rrc_Sub_State_t sub_state; } RrcStateInd; @@ -459,4 +463,23 @@ typedef struct { int ue_id; } RlcMaxRtxIndication; +#include "openair2/RRC/NR_UE/rrc_defs.h" +typedef struct { + NR_ReestablishmentCause_t cause; +} nr_mac_rrc_config_reset_t; +typedef struct { + NR_CellGroupConfig_t *cellGroupConfig; + NR_UE_NR_Capability_t *UE_NR_Capability; +} nr_mac_rrc_config_cg_t; +typedef struct { + NR_BCCH_BCH_Message_t *bcch; + int get_sib; +} nr_mac_rrc_config_mib_t; +typedef struct { + NR_SIB1_t *sib1; +} nr_mac_rrc_config_sib1_t; +typedef struct { + NR_SIB19_r17_t *sib19; +} nr_mac_rrc_config_other_sib_t; + #endif /* RRC_MESSAGES_TYPES_H_ */ diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index a4161dbd61..ee81d2a95d 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -1704,17 +1704,19 @@ static void configure_si_schedulingInfo(NR_UE_MAC_INST_t *mac, } } -void nr_rrc_mac_config_req_sib1(module_id_t module_id, - int cc_idP, - NR_SI_SchedulingInfo_t *si_SchedulingInfo, - NR_SI_SchedulingInfo_v1700_t *si_SchedulingInfo_v1700, - NR_ServingCellConfigCommonSIB_t *scc) +void nr_rrc_mac_config_req_sib1(module_id_t module_id, int cc_idP, NR_SIB1_t *sib1) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); int ret = pthread_mutex_lock(&mac->if_mutex); AssertFatal(!ret, "mutex failed %d\n", ret); + NR_SI_SchedulingInfo_t *si_SchedulingInfo = sib1->si_SchedulingInfo; + NR_SI_SchedulingInfo_v1700_t *si_SchedulingInfo_v1700 = NULL; + if (sib1->nonCriticalExtension && sib1->nonCriticalExtension->nonCriticalExtension + && sib1->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension) { + si_SchedulingInfo_v1700 = sib1->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->si_SchedulingInfo_v1700; + } + NR_ServingCellConfigCommonSIB_t *scc = sib1->servingCellConfigCommon; AssertFatal(scc, "SIB1 SCC should not be NULL\n"); - UPDATE_IE(mac->tdd_UL_DL_ConfigurationCommon, scc->tdd_UL_DL_ConfigurationCommon, NR_TDD_UL_DL_ConfigCommon_t); configure_si_schedulingInfo(mac, si_SchedulingInfo, si_SchedulingInfo_v1700); mac->n_ta_offset = get_ta_offset(scc->n_TimingAdvanceOffset); @@ -1749,7 +1751,7 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, } // computes delay between ue and sat based on SIB19 ephemeris data -static double calculate_ue_sat_ta(const position_t *position_params, struct NR_PositionVelocity_r17 *sat_pos) +static double calculate_ue_sat_ta(const position_t *position_params, NR_PositionVelocity_r17_t *sat_pos) { // get UE position coordinates double posx = position_params->positionX; @@ -1768,39 +1770,45 @@ static double calculate_ue_sat_ta(const position_t *position_params, struct NR_P return ta_ms; } -void nr_rrc_mac_config_req_sib19_r17(module_id_t module_id, const position_t *pos, NR_SIB19_r17_t *sib19_r17) +void nr_rrc_mac_config_other_sib(module_id_t module_id, NR_SIB19_r17_t *sib19) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); int ret = pthread_mutex_lock(&mac->if_mutex); AssertFatal(!ret, "mutex failed %d\n", ret); - // update ntn_Config_r17 with received values - struct NR_NTN_Config_r17 *ntn_Config_r17 = mac->sc_info.ntn_Config_r17; - UPDATE_IE(ntn_Config_r17, sib19_r17->ntn_Config_r17, NR_NTN_Config_r17_t); + if (sib19) { + // update ntn_Config_r17 with received values + NR_NTN_Config_r17_t *ntn_Config_r17 = mac->sc_info.ntn_Config_r17; + UPDATE_IE(ntn_Config_r17, sib19->ntn_Config_r17, NR_NTN_Config_r17_t); - // populate ntn_ta structure from mac - // if ephemerisInfo_r17 present in SIB19 - struct NR_EphemerisInfo_r17 *ephemeris_info = ntn_Config_r17->ephemerisInfo_r17; - if (ephemeris_info) { - struct NR_PositionVelocity_r17 *position_velocity = ephemeris_info->choice.positionVelocity_r17; - if (position_velocity - && (position_velocity->positionX_r17 != 0 || position_velocity->positionY_r17 != 0 - || position_velocity->positionZ_r17 != 0)) { - mac->ntn_ta.N_UE_TA_adj = calculate_ue_sat_ta(pos, position_velocity); + position_t position_params = {0}; + get_position_coordinates(module_id, &position_params); + + // populate ntn_ta structure from mac + // if ephemerisInfo_r17 present in SIB19 + NR_EphemerisInfo_r17_t *ephemeris_info = ntn_Config_r17->ephemerisInfo_r17; + if (ephemeris_info) { + NR_PositionVelocity_r17_t *position_velocity = ephemeris_info->choice.positionVelocity_r17; + if (position_velocity + && (position_velocity->positionX_r17 != 0 + || position_velocity->positionY_r17 != 0 + || position_velocity->positionZ_r17 != 0)) { + mac->ntn_ta.N_UE_TA_adj = calculate_ue_sat_ta(&position_params, position_velocity); + } } + // if cellSpecificKoffset_r17 is present + if (ntn_Config_r17->cellSpecificKoffset_r17) { + mac->ntn_ta.cell_specific_k_offset = *ntn_Config_r17->cellSpecificKoffset_r17; + } + // Check if ta_Info_r17 is present and convert directly ta_Common_r17 (is in units of 4.072e-3 µs) + if (ntn_Config_r17->ta_Info_r17) { + mac->ntn_ta.N_common_ta_adj = ntn_Config_r17->ta_Info_r17->ta_Common_r17 * 4.072e-6; + // ta_CommonDrift_r17 (is in units of 0.2e-3 µs/s) + if (ntn_Config_r17->ta_Info_r17->ta_CommonDrift_r17) + mac->ntn_ta.ntn_ta_commondrift = *ntn_Config_r17->ta_Info_r17->ta_CommonDrift_r17 * 0.2e-3; + } + mac->ntn_ta.ntn_params_changed = true; } - // if cellSpecificKoffset_r17 is present - if (ntn_Config_r17->cellSpecificKoffset_r17) { - mac->ntn_ta.cell_specific_k_offset = *ntn_Config_r17->cellSpecificKoffset_r17; - } - // Check if ta_Info_r17 is present and convert directly ta_Common_r17 (is in units of 4.072e-3 µs) - if (ntn_Config_r17->ta_Info_r17) { - mac->ntn_ta.N_common_ta_adj = ntn_Config_r17->ta_Info_r17->ta_Common_r17 * 4.072e-6; - // ta_CommonDrift_r17 (is in units of 0.2e-3 µs/s) - if (ntn_Config_r17->ta_Info_r17->ta_CommonDrift_r17) - mac->ntn_ta.ntn_ta_commondrift = *ntn_Config_r17->ta_Info_r17->ta_CommonDrift_r17 * 0.2e-3; - } - mac->ntn_ta.ntn_params_changed = true; ret = pthread_mutex_unlock(&mac->if_mutex); AssertFatal(!ret, "mutex failed %d\n", ret); } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 6558370479..dfda03e011 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -85,14 +85,10 @@ void nr_rrc_mac_config_req_mib(module_id_t module_id, NR_MIB_t *mibP, int sched_sib1); -void nr_rrc_mac_config_req_sib1(module_id_t module_id, - int cc_idP, - NR_SI_SchedulingInfo_t *si_SchedulingInfo, - NR_SI_SchedulingInfo_v1700_t *si_SchedulingInfo_v1700, - NR_ServingCellConfigCommonSIB_t *scc); +void nr_rrc_mac_config_req_sib1(module_id_t module_id, int cc_idP, NR_SIB1_t *sib1); struct position; /* forward declaration */ -void nr_rrc_mac_config_req_sib19_r17(module_id_t module_id, const struct position *pos, NR_SIB19_r17_t *sib19_r17); +void nr_rrc_mac_config_other_sib(module_id_t module_id, NR_SIB19_r17_t *sib19_r17); void nr_rrc_mac_config_req_reset(module_id_t module_id, NR_UE_MAC_reset_cause_t cause); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 272d2b93bd..762cad5106 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -597,6 +597,14 @@ static int nr_ue_process_dci_ul_01(NR_UE_MAC_INST_t *mac, dci_ind->rnti, dci_ind->ss_type, NR_UL_DCI_FORMAT_0_1); + LOG_D(NR_MAC_DCI, + "add ul dci harq %d for %d.%d %d.%d round %d\n", + pdu->pusch_config_pdu.pusch_data.harq_process_id, + frame, + slot, + frame_tx, + slot_tx, + 0); if (ret != 0) remove_ul_config_last_item(pdu); release_ul_config(pdu, false); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index e015369b5b..f6005a6191 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -2629,7 +2629,15 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot, n dci_pdu_rel15_t uldci_payload; memset(&uldci_payload, 0, sizeof(uldci_payload)); - + if (current_BWP->dci_format == NR_UL_DCI_FORMAT_0_1) + LOG_D(NR_MAC_DCI, + "add ul dci harq %d for %d.%d %d.%d round %d\n", + harq_id, + frame, + slot, + sched_pusch->frame, + sched_pusch->slot, + sched_ctrl->ul_harq_processes[harq_id].round); config_uldci(&UE->sc_info, pusch_pdu, &uldci_payload, diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 9cf81fbbe3..0f88066cc1 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -1206,11 +1206,10 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info) return 0; } -static uint32_t nr_ue_dl_processing(nr_downlink_indication_t *dl_info) +static uint32_t nr_ue_dl_processing(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info) { uint32_t ret_mask = 0x0; - DevAssert(dl_info != NULL); - NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id); + DevAssert(mac != NULL && dl_info != NULL); // DL indication after reception of DCI or DL PDU if (dl_info->dci_ind && dl_info->dci_ind->number_of_dcis) { @@ -1322,7 +1321,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info) nr_ue_dl_scheduler(mac, dl_info); else // DL indication to process data channels - ret2 = nr_ue_dl_processing(dl_info); + ret2 = nr_ue_dl_processing(mac, dl_info); ret = pthread_mutex_unlock(&mac->if_mutex); AssertFatal(!ret, "mutex failed %d\n", ret); return ret2; diff --git a/openair2/RRC/NR_UE/L2_interface_ue.c b/openair2/RRC/NR_UE/L2_interface_ue.c index b2b4914c22..cc97b448b5 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.c +++ b/openair2/RRC/NR_UE/L2_interface_ue.c @@ -121,6 +121,34 @@ void nr_mac_rrc_data_ind_ue(const module_id_t module_id, } } +void process_msg_rcc_to_mac(MessageDef *msg) +{ + instance_t ue_id = ITTI_MSG_DESTINATION_INSTANCE(msg); + switch (ITTI_MSG_ID(msg)) { + case NR_MAC_RRC_CONFIG_RESET: + nr_rrc_mac_config_req_reset(ue_id, NR_MAC_RRC_CONFIG_RESET(msg).cause); + break; + case NR_MAC_RRC_CONFIG_CG: + nr_rrc_mac_config_req_cg(ue_id, 0, NR_MAC_RRC_CONFIG_CG(msg).cellGroupConfig, NR_MAC_RRC_CONFIG_CG(msg).UE_NR_Capability); + asn1cFreeStruc(asn_DEF_NR_CellGroupConfig, NR_MAC_RRC_CONFIG_CG(msg).cellGroupConfig); + break; + case NR_MAC_RRC_CONFIG_MIB: + nr_rrc_mac_config_req_mib(ue_id, 0, NR_MAC_RRC_CONFIG_MIB(msg).bcch->message.choice.mib, NR_MAC_RRC_CONFIG_MIB(msg).get_sib); + ASN_STRUCT_FREE(asn_DEF_NR_BCCH_BCH_Message, NR_MAC_RRC_CONFIG_MIB(msg).bcch); + break; + case NR_MAC_RRC_CONFIG_SIB1: { + NR_SIB1_t *sib1 = NR_MAC_RRC_CONFIG_SIB1(msg).sib1; + nr_rrc_mac_config_req_sib1(ue_id, 0, sib1); + SEQUENCE_free(&asn_DEF_NR_SIB1, NR_MAC_RRC_CONFIG_SIB1(msg).sib1, ASFM_FREE_EVERYTHING); + } break; + case NR_MAC_RRC_CONFIG_OTHER_SIB: + nr_rrc_mac_config_other_sib(ue_id, NR_MAC_RRC_CONFIG_OTHER_SIB(msg).sib19); + break; + default: + LOG_E(NR_MAC, "Unexpected msg from RRC: %d\n", ITTI_MSG_ID(msg)); + } +} + void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id) { MessageDef *message_p = itti_alloc_new_message(TASK_MAC_UE, 0, NR_RRC_MAC_INAC_IND); diff --git a/openair2/RRC/NR_UE/L2_interface_ue.h b/openair2/RRC/NR_UE/L2_interface_ue.h index 708633b413..05888cbc0e 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.h +++ b/openair2/RRC/NR_UE/L2_interface_ue.h @@ -41,5 +41,6 @@ void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, 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, int frame, bool success); void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, Rrc_Msg_Type_t msg_type); +void process_msg_rcc_to_mac(MessageDef *msg); #endif diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index b59067430d..88b781723b 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -62,7 +62,6 @@ #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" -#include "executables/position_interface.h" #ifndef CELLULAR #include "RRC/NR/MESSAGES/asn1_msg.h" @@ -166,7 +165,7 @@ static void set_DRB_status(NR_UE_RRC_INST_t *rrc, NR_DRB_Identity_t drb_id, NR_R rrc->status_DRBs[drb_id - 1] = status; } -static void nr_decode_SI(NR_UE_RRC_SI_INFO *SI_info, NR_SystemInformation_t *si, instance_t ue_id, position_t *position) +static void nr_decode_SI(NR_UE_RRC_SI_INFO *SI_info, NR_SystemInformation_t *si, instance_t ue_id) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SI, VCD_FUNCTION_IN); @@ -181,81 +180,81 @@ static void nr_decode_SI(NR_UE_RRC_SI_INFO *SI_info, NR_SystemInformation_t *si, return; } + NR_SIB19_r17_t *sib19 = NULL; for (int i = 0; i < si->criticalExtensions.choice.systemInformation->sib_TypeAndInfo.list.count; i++) { SystemInformation_IEs__sib_TypeAndInfo__Member *typeandinfo; typeandinfo = si->criticalExtensions.choice.systemInformation->sib_TypeAndInfo.list.array[i]; LOG_I(NR_RRC, "Found SIB%d\n", typeandinfo->present + 1); switch(typeandinfo->present) { case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib2: - SI_info->sib2_validity = true; + SI_info->sib2_validity = SIB_VALID; nr_timer_start(&SI_info->sib2_timer); break; case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib3: - SI_info->sib3_validity = true; + SI_info->sib3_validity = SIB_VALID; nr_timer_start(&SI_info->sib3_timer); break; case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib4: - SI_info->sib4_validity = true; + SI_info->sib4_validity = SIB_VALID; nr_timer_start(&SI_info->sib4_timer); break; case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib5: - SI_info->sib5_validity = true; + SI_info->sib5_validity = SIB_VALID; nr_timer_start(&SI_info->sib5_timer); break; case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib6: - SI_info->sib6_validity = true; + SI_info->sib6_validity = SIB_VALID; nr_timer_start(&SI_info->sib6_timer); break; case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib7: - SI_info->sib7_validity = true; + SI_info->sib7_validity = SIB_VALID; nr_timer_start(&SI_info->sib7_timer); break; case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib8: - SI_info->sib8_validity = true; + SI_info->sib8_validity = SIB_VALID; nr_timer_start(&SI_info->sib8_timer); break; case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib9: - SI_info->sib9_validity = true; + SI_info->sib9_validity = SIB_VALID; nr_timer_start(&SI_info->sib9_timer); break; case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib10_v1610: - SI_info->sib10_validity = true; + SI_info->sib10_validity = SIB_VALID; nr_timer_start(&SI_info->sib10_timer); break; case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib11_v1610: - SI_info->sib11_validity = true; + SI_info->sib11_validity = SIB_VALID; nr_timer_start(&SI_info->sib11_timer); break; case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib12_v1610: - SI_info->sib12_validity = true; + SI_info->sib12_validity = SIB_VALID; nr_timer_start(&SI_info->sib12_timer); break; case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib13_v1610: - SI_info->sib13_validity = true; + SI_info->sib13_validity = SIB_VALID; nr_timer_start(&SI_info->sib13_timer); break; case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib14_v1610: - SI_info->sib14_validity = true; + SI_info->sib14_validity = SIB_VALID; nr_timer_start(&SI_info->sib14_timer); break; case NR_SystemInformation_IEs__sib_TypeAndInfo__Member_PR_sib19_v1700: - SI_info->SInfo_r17.sib19_validity = true; + SI_info->SInfo_r17.sib19_validity = SIB_VALID; if (g_log->log_component[NR_RRC].level >= OAILOG_DEBUG) xer_fprint(stdout, &asn_DEF_NR_SIB19_r17, (const void *)typeandinfo->choice.sib19_v1700); - - // allocate memory for position coordinates - if (!position) - position = CALLOC(1, sizeof(*position)); - // populate position with position from config file - get_position_coordinates(ue_id, position); - - nr_rrc_mac_config_req_sib19_r17(ue_id, position, typeandinfo->choice.sib19_v1700); + sib19 = typeandinfo->choice.sib19_v1700; nr_timer_start(&SI_info->SInfo_r17.sib19_timer); break; default: break; } } + + if (sib19) { + MessageDef *msg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NR_MAC_RRC_CONFIG_OTHER_SIB); + asn_copy(&asn_DEF_NR_SIB19_r17, (void **)&NR_MAC_RRC_CONFIG_OTHER_SIB(msg).sib19, sib19); + itti_send_msg_to_task(TASK_MAC_UE, ue_id, msg); + } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SI, VCD_FUNCTION_OUT); } @@ -315,7 +314,7 @@ static void nr_rrc_process_sib1(NR_UE_RRC_INST_t *rrc, NR_UE_RRC_SI_INFO *SI_inf xer_fprint(stdout, &asn_DEF_NR_SIB1, (const void *) sib1); LOG_A(NR_RRC, "SIB1 decoded\n"); nr_timer_start(&SI_info->sib1_timer); - SI_info->sib1_validity = true; + SI_info->sib1_validity = SIB_VALID; if (rrc->nrRrcState == RRC_STATE_IDLE_NR) { rrc->ra_trigger = RRC_CONNECTION_SETUP; // preparing RRC setup request payload in advance @@ -335,8 +334,9 @@ static void nr_rrc_process_sib1(NR_UE_RRC_INST_t *rrc, NR_UE_RRC_SI_INFO *SI_inf nr_rrc_set_sib1_timers_and_constants(&rrc->timers_and_constants, sib1); // RRC storage of SIB1 timers and constants (eg needed in re-establishment) UPDATE_IE(rrc->timers_and_constants.sib1_TimersAndConstants, sib1->ue_TimersAndConstants, NR_UE_TimersAndConstants_t); - - nr_rrc_mac_config_req_sib1(rrc->ue_id, 0, sib1->si_SchedulingInfo, si_SchedInfo_v1700, sib1->servingCellConfigCommon); + MessageDef *msg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NR_MAC_RRC_CONFIG_SIB1); + NR_MAC_RRC_CONFIG_SIB1(msg).sib1 = sib1; + itti_send_msg_to_task(TASK_MAC_UE, rrc->ue_id, msg); } static void nr_rrc_process_reconfiguration_v1530(NR_UE_RRC_INST_t *rrc, NR_RRCReconfiguration_v1530_IEs_t *rec_1530, int gNB_index) @@ -378,6 +378,7 @@ static void nr_rrc_process_reconfiguration_v1530(NR_UE_RRC_INST_t *rrc, NR_RRCRe LOG_E(NR_RRC, "dedicatedSIB1-Delivery decode error\n"); SEQUENCE_free(&asn_DEF_NR_SIB1, sib1, 1); } else { + // mac layer will free sib1 nr_rrc_process_sib1(rrc, SI_info, sib1); } } @@ -395,7 +396,7 @@ static void nr_rrc_process_reconfiguration_v1530(NR_UE_RRC_INST_t *rrc, NR_RRCRe SEQUENCE_free(&asn_DEF_NR_SystemInformation, si, 1); } else { LOG_I(NR_RRC, "[UE %ld] Decoding dedicatedSystemInformationDelivery\n", rrc->ue_id); - nr_decode_SI(SI_info, si, rrc->ue_id, rrc->position_coordinates); + nr_decode_SI(SI_info, si, rrc->ue_id); } } if (rec_1530->otherConfig) { @@ -474,8 +475,12 @@ static void nr_rrc_ue_process_rrcReconfiguration(NR_UE_RRC_INST_t *rrc, int gNB_ nr_rrc_cellgroup_configuration(rrc, cellGroupConfig); AssertFatal(!IS_SA_MODE(get_softmodem_params()), "secondaryCellGroup only used in NSA for now\n"); - nr_rrc_mac_config_req_cg(rrc->ue_id, 0, cellGroupConfig, rrc->UECap.UE_NR_Capability); - asn1cFreeStruc(asn_DEF_NR_CellGroupConfig, cellGroupConfig); + MessageDef *msg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NR_MAC_RRC_CONFIG_CG); + // cellGroupConfig will be managed by MAC + NR_MAC_RRC_CONFIG_CG(msg).cellGroupConfig = cellGroupConfig; + // UE_NR_Capability remain a race condition between this rrc thread and mac thread + NR_MAC_RRC_CONFIG_CG(msg).UE_NR_Capability = rrc->UECap.UE_NR_Capability; + itti_send_msg_to_task(TASK_MAC_UE, rrc->ue_id, msg); } if (ie->measConfig) { LOG_I(NR_RRC, "RRCReconfiguration includes Measurement Configuration\n"); @@ -621,56 +626,82 @@ bool check_si_validity(NR_UE_RRC_SI_INFO *SI_info, int si_type) { switch (si_type) { case NR_SIB_TypeInfo__type_sibType2: - if (!SI_info->sib2_validity) + if (SI_info->sib2_validity == SIB_NOT_VALID) { + SI_info->sib2_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo__type_sibType3: - if (!SI_info->sib3_validity) + if (SI_info->sib3_validity == SIB_NOT_VALID) { + SI_info->sib3_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo__type_sibType4: - if (!SI_info->sib4_validity) + if (SI_info->sib4_validity == SIB_NOT_VALID) { + SI_info->sib4_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo__type_sibType5: - if (!SI_info->sib5_validity) + if (SI_info->sib5_validity == SIB_NOT_VALID) { + SI_info->sib5_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo__type_sibType6: - if (!SI_info->sib6_validity) + if (SI_info->sib6_validity == SIB_NOT_VALID) { + SI_info->sib6_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo__type_sibType7: - if (!SI_info->sib7_validity) + if (SI_info->sib7_validity == SIB_NOT_VALID) { + SI_info->sib7_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo__type_sibType8: - if (!SI_info->sib8_validity) + if (SI_info->sib8_validity == SIB_NOT_VALID) { + SI_info->sib8_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo__type_sibType9: - if (!SI_info->sib9_validity) + if (SI_info->sib9_validity == SIB_NOT_VALID) { + SI_info->sib9_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo__type_sibType10_v1610: - if (!SI_info->sib10_validity) + if (SI_info->sib10_validity == SIB_NOT_VALID) { + SI_info->sib10_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo__type_sibType11_v1610: - if (!SI_info->sib11_validity) + if (SI_info->sib11_validity == SIB_NOT_VALID) { + SI_info->sib11_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo__type_sibType12_v1610: - if (!SI_info->sib12_validity) + if (SI_info->sib12_validity == SIB_NOT_VALID) { + SI_info->sib12_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo__type_sibType13_v1610: - if (!SI_info->sib13_validity) + if (SI_info->sib13_validity == SIB_NOT_VALID) { + SI_info->sib13_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo__type_sibType14_v1610: - if (!SI_info->sib14_validity) + if (SI_info->sib14_validity == SIB_NOT_VALID) { + SI_info->sib14_validity = SIB_REQUESTED; return false; + } break; default : AssertFatal(false, "Invalid SIB type %d\n", si_type); @@ -682,32 +713,46 @@ bool check_si_validity_r17(NR_UE_RRC_SI_INFO_r17 *SI_info, int si_type) { switch (si_type) { case NR_SIB_TypeInfo_v1700__sibType_r17__type1_r17_sibType15: - if (!SI_info->sib15_validity) + if (SI_info->sib15_validity == SIB_NOT_VALID) { + SI_info->sib15_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo_v1700__sibType_r17__type1_r17_sibType16: - if (!SI_info->sib16_validity) + if (SI_info->sib16_validity == SIB_NOT_VALID) { + SI_info->sib16_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo_v1700__sibType_r17__type1_r17_sibType17: - if (!SI_info->sib17_validity) + if (SI_info->sib17_validity == SIB_NOT_VALID) { + SI_info->sib17_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo_v1700__sibType_r17__type1_r17_sibType18: - if (!SI_info->sib18_validity) + if (SI_info->sib18_validity == SIB_NOT_VALID) { + SI_info->sib18_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo_v1700__sibType_r17__type1_r17_sibType19: - if (!SI_info->sib19_validity) + if (SI_info->sib19_validity == SIB_NOT_VALID) { + SI_info->sib19_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo_v1700__sibType_r17__type1_r17_sibType20: - if (!SI_info->sib20_validity) + if (SI_info->sib20_validity == SIB_NOT_VALID) { + SI_info->sib20_validity = SIB_REQUESTED; return false; + } break; case NR_SIB_TypeInfo_v1700__sibType_r17__type1_r17_sibType21: - if (!SI_info->sib21_validity) + if (SI_info->sib21_validity == SIB_NOT_VALID) { + SI_info->sib21_validity = SIB_REQUESTED; return false; + } break; default : AssertFatal(false, "Invalid SIB r17 type %d\n", si_type); @@ -718,8 +763,10 @@ bool check_si_validity_r17(NR_UE_RRC_SI_INFO_r17 *SI_info, int si_type) int check_si_status(NR_UE_RRC_SI_INFO *SI_info) { // schedule reception of SIB1 if RRC doesn't have it - if (!SI_info->sib1_validity) + if (SI_info->sib1_validity == SIB_NOT_VALID) { + SI_info->sib1_validity = SIB_REQUESTED; return 1; + } else { if (SI_info->default_otherSI_map) { // Check if RRC has configured default SI @@ -807,11 +854,16 @@ static void nr_rrc_ue_decode_NR_BCCH_BCH_Message(NR_UE_RRC_INST_t *rrc, // to schedule MAC to get SI if required get_sib = check_si_status(SI_info); } - if (bcch_message->message.present == NR_BCCH_BCH_MessageType_PR_mib) - nr_rrc_mac_config_req_mib(rrc->ue_id, 0, bcch_message->message.choice.mib, get_sib); - else + if (bcch_message->message.present == NR_BCCH_BCH_MessageType_PR_mib) { + MessageDef *msg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NR_MAC_RRC_CONFIG_MIB); + // mac will manage the pointer + NR_MAC_RRC_CONFIG_MIB(msg).bcch = bcch_message; + NR_MAC_RRC_CONFIG_MIB(msg).get_sib = get_sib; + itti_send_msg_to_task(TASK_MAC_UE, rrc->ue_id, msg); + } else { LOG_E(NR_RRC, "RRC-received BCCH message is not a MIB\n"); - ASN_STRUCT_FREE(asn_DEF_NR_BCCH_BCH_Message, bcch_message); + ASN_STRUCT_FREE(asn_DEF_NR_BCCH_BCH_Message, bcch_message); + } return; } @@ -900,11 +952,13 @@ static int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(NR_UE_RRC_INST_t *rrc, switch (bcch_message->message.choice.c1->present) { case NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1: nr_rrc_process_sib1(rrc, SI_info, bcch_message->message.choice.c1->choice.systemInformationBlockType1); + // mac layer will free after usage the sib1 + bcch_message->message.choice.c1->choice.systemInformationBlockType1 = NULL; break; case NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformation: LOG_I(NR_RRC, "[UE %ld] Decoding SI\n", rrc->ue_id); NR_SystemInformation_t *si = bcch_message->message.choice.c1->choice.systemInformation; - nr_decode_SI(SI_info, si, rrc->ue_id, rrc->position_coordinates); + nr_decode_SI(SI_info, si, rrc->ue_id); break; case NR_BCCH_DL_SCH_MessageType__c1_PR_NOTHING: default: @@ -1036,9 +1090,11 @@ static void nr_rrc_ue_process_masterCellGroup(NR_UE_RRC_INST_t *rrc, nr_rrc_cellgroup_configuration(rrc, cellGroupConfig); - LOG_D(RRC,"Sending CellGroupConfig to MAC\n"); - nr_rrc_mac_config_req_cg(rrc->ue_id, 0, cellGroupConfig, rrc->UECap.UE_NR_Capability); - asn1cFreeStruc(asn_DEF_NR_CellGroupConfig, cellGroupConfig); + LOG_D(RRC, "Sending CellGroupConfig to MAC the pointer will be managed by mac\n"); + MessageDef *msg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NR_MAC_RRC_CONFIG_CG); + NR_MAC_RRC_CONFIG_CG(msg).cellGroupConfig = cellGroupConfig; + NR_MAC_RRC_CONFIG_CG(msg).UE_NR_Capability = rrc->UECap.UE_NR_Capability; + itti_send_msg_to_task(TASK_MAC_UE, rrc->ue_id, msg); } static void rrc_ue_generate_RRCSetupComplete(const NR_UE_RRC_INST_t *rrc, const uint8_t Transaction_id) @@ -2126,7 +2182,9 @@ static void nr_rrc_initiate_rrcReestablishment(NR_UE_RRC_INST_t *rrc, NR_Reestab // reset MAC // release spCellConfig, if configured // perform cell selection in accordance with the cell selection process - nr_rrc_mac_config_req_reset(rrc->ue_id, RE_ESTABLISHMENT); + MessageDef *msg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NR_MAC_RRC_CONFIG_RESET); + NR_MAC_RRC_CONFIG_RESET(msg).cause = RE_ESTABLISHMENT; + itti_send_msg_to_task(TASK_MAC_UE, rrc->ue_id, msg); } static void nr_rrc_ue_generate_rrcReestablishmentComplete(const NR_UE_RRC_INST_t *rrc, @@ -2465,27 +2523,27 @@ void nr_rrc_going_to_IDLE(NR_UE_RRC_INST_t *rrc, rrcPerNB_t *nb = &rrc->perNB[i]; NR_UE_RRC_SI_INFO *SI_info = &nb->SInfo; init_SI_timers(SI_info); - SI_info->sib1_validity = false; - SI_info->sib2_validity = false; - SI_info->sib3_validity = false; - SI_info->sib4_validity = false; - SI_info->sib5_validity = false; - SI_info->sib6_validity = false; - SI_info->sib7_validity = false; - SI_info->sib8_validity = false; - SI_info->sib9_validity = false; - SI_info->sib10_validity = false; - SI_info->sib11_validity = false; - SI_info->sib12_validity = false; - SI_info->sib13_validity = false; - SI_info->sib14_validity = false; - SI_info->SInfo_r17.sib15_validity = false; - SI_info->SInfo_r17.sib16_validity = false; - SI_info->SInfo_r17.sib17_validity = false; - SI_info->SInfo_r17.sib18_validity = false; - SI_info->SInfo_r17.sib19_validity = false; - SI_info->SInfo_r17.sib20_validity = false; - SI_info->SInfo_r17.sib21_validity = false; + SI_info->sib1_validity = SIB_NOT_VALID; + SI_info->sib2_validity = SIB_NOT_VALID; + SI_info->sib3_validity = SIB_NOT_VALID; + SI_info->sib4_validity = SIB_NOT_VALID; + SI_info->sib5_validity = SIB_NOT_VALID; + SI_info->sib6_validity = SIB_NOT_VALID; + SI_info->sib7_validity = SIB_NOT_VALID; + SI_info->sib8_validity = SIB_NOT_VALID; + SI_info->sib9_validity = SIB_NOT_VALID; + SI_info->sib10_validity = SIB_NOT_VALID; + SI_info->sib11_validity = SIB_NOT_VALID; + SI_info->sib12_validity = SIB_NOT_VALID; + SI_info->sib13_validity = SIB_NOT_VALID; + SI_info->sib14_validity = SIB_NOT_VALID; + SI_info->SInfo_r17.sib15_validity = SIB_NOT_VALID; + SI_info->SInfo_r17.sib16_validity = SIB_NOT_VALID; + SI_info->SInfo_r17.sib17_validity = SIB_NOT_VALID; + SI_info->SInfo_r17.sib18_validity = SIB_NOT_VALID; + SI_info->SInfo_r17.sib19_validity = SIB_NOT_VALID; + SI_info->SInfo_r17.sib20_validity = SIB_NOT_VALID; + SI_info->SInfo_r17.sib21_validity = SIB_NOT_VALID; } if (rrc->nrRrcState == RRC_STATE_DETACH_NR) { @@ -2495,7 +2553,9 @@ void nr_rrc_going_to_IDLE(NR_UE_RRC_INST_t *rrc, // reset MAC NR_UE_MAC_reset_cause_t cause = (rrc->nrRrcState == RRC_STATE_DETACH_NR) ? DETACH : GO_TO_IDLE; - nr_rrc_mac_config_req_reset(rrc->ue_id, cause); + MessageDef *msg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NR_MAC_RRC_CONFIG_RESET); + NR_MAC_RRC_CONFIG_RESET(msg).cause = cause; + itti_send_msg_to_task(TASK_MAC_UE, rrc->ue_id, msg); // enter RRC_IDLE LOG_I(NR_RRC, "RRC moved into IDLE state\n"); @@ -2517,7 +2577,9 @@ void handle_t300_expiry(NR_UE_RRC_INST_t *rrc) // reset MAC, release the MAC configuration NR_UE_MAC_reset_cause_t cause = T300_EXPIRY; - nr_rrc_mac_config_req_reset(rrc->ue_id, cause); + MessageDef *msg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NR_MAC_RRC_CONFIG_RESET); + NR_MAC_RRC_CONFIG_RESET(msg).cause = cause; + itti_send_msg_to_task(TASK_MAC_UE, rrc->ue_id, msg); // TODO handle connEstFailureControl // TODO inform upper layers about the failure to establish the RRC connection } diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index 6d22e4ad6c..fb320853e2 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -104,53 +104,59 @@ typedef enum RA_trigger_e { BEAM_FAILURE_RECOVERY, } RA_trigger_t; +typedef enum { + SIB_NOT_VALID, + SIB_VALID, + SIB_REQUESTED, +} SIB_validity_t; + typedef struct UE_RRC_SI_INFO_NR_r17_s { uint32_t default_otherSI_map_r17; - bool sib15_validity; + SIB_validity_t sib15_validity; NR_timer_t sib15_timer; - bool sib16_validity; + SIB_validity_t sib16_validity; NR_timer_t sib16_timer; - bool sib17_validity; + SIB_validity_t sib17_validity; NR_timer_t sib17_timer; - bool sib18_validity; + SIB_validity_t sib18_validity; NR_timer_t sib18_timer; - bool sib19_validity; + SIB_validity_t sib19_validity; NR_timer_t sib19_timer; - bool sib20_validity; + SIB_validity_t sib20_validity; NR_timer_t sib20_timer; - bool sib21_validity; + SIB_validity_t sib21_validity; NR_timer_t sib21_timer; } NR_UE_RRC_SI_INFO_r17; typedef struct UE_RRC_SI_INFO_NR_s { uint32_t default_otherSI_map; - bool sib1_validity; + SIB_validity_t sib1_validity; NR_timer_t sib1_timer; - bool sib2_validity; + SIB_validity_t sib2_validity; NR_timer_t sib2_timer; - bool sib3_validity; + SIB_validity_t sib3_validity; NR_timer_t sib3_timer; - bool sib4_validity; + SIB_validity_t sib4_validity; NR_timer_t sib4_timer; - bool sib5_validity; + SIB_validity_t sib5_validity; NR_timer_t sib5_timer; - bool sib6_validity; + SIB_validity_t sib6_validity; NR_timer_t sib6_timer; - bool sib7_validity; + SIB_validity_t sib7_validity; NR_timer_t sib7_timer; - bool sib8_validity; + SIB_validity_t sib8_validity; NR_timer_t sib8_timer; - bool sib9_validity; + SIB_validity_t sib9_validity; NR_timer_t sib9_timer; - bool sib10_validity; + SIB_validity_t sib10_validity; NR_timer_t sib10_timer; - bool sib11_validity; + SIB_validity_t sib11_validity; NR_timer_t sib11_timer; - bool sib12_validity; + SIB_validity_t sib12_validity; NR_timer_t sib12_timer; - bool sib13_validity; + SIB_validity_t sib13_validity; NR_timer_t sib13_timer; - bool sib14_validity; + SIB_validity_t sib14_validity; NR_timer_t sib14_timer; NR_UE_RRC_SI_INFO_r17 SInfo_r17; } NR_UE_RRC_SI_INFO; @@ -196,8 +202,6 @@ typedef struct rrcPerNB { NR_RSRP_Range_t s_measure; } rrcPerNB_t; -/* forward declaration */ -struct position; typedef struct NR_UE_RRC_INST_s { instance_t ue_id; rrcPerNB_t perNB[NB_CNX_UE]; @@ -237,9 +241,6 @@ typedef struct NR_UE_RRC_INST_s { bool reconfig_after_reestab; //Sidelink params NR_SL_PreconfigurationNR_r16_t *sl_preconfig; - - struct position *position_coordinates; - } NR_UE_RRC_INST_t; #endif diff --git a/openair2/RRC/NR_UE/rrc_timers_and_constants.c b/openair2/RRC/NR_UE/rrc_timers_and_constants.c index 6629055b3a..39e73fa5a4 100644 --- a/openair2/RRC/NR_UE/rrc_timers_and_constants.c +++ b/openair2/RRC/NR_UE/rrc_timers_and_constants.c @@ -43,83 +43,33 @@ void init_SI_timers(NR_UE_RRC_SI_INFO *SInfo) nr_timer_setup(&SInfo->SInfo_r17.sib19_timer, 10800000, 10); } +static SIB_validity_t check_sib_timer_validity(SIB_validity_t sib_validity, NR_timer_t *sib_timer) +{ + if (sib_validity == SIB_VALID) { + bool sib_expired = nr_timer_tick(sib_timer); + if (sib_expired) + return SIB_NOT_VALID; + } + return sib_validity; +} + void nr_rrc_SI_timers(NR_UE_RRC_SI_INFO *SInfo) { - if (SInfo->sib1_validity) { - bool sib1_expired = nr_timer_tick(&SInfo->sib1_timer); - if (sib1_expired) - SInfo->sib1_validity = false; - } - if (SInfo->sib2_validity) { - bool sib2_expired = nr_timer_tick(&SInfo->sib2_timer); - if (sib2_expired) - SInfo->sib2_validity = false; - } - if (SInfo->sib3_validity) { - bool sib3_expired = nr_timer_tick(&SInfo->sib3_timer); - if (sib3_expired) - SInfo->sib3_validity = false; - } - if (SInfo->sib4_validity) { - bool sib4_expired = nr_timer_tick(&SInfo->sib4_timer); - if (sib4_expired) - SInfo->sib4_validity = false; - } - if (SInfo->sib5_validity) { - bool sib5_expired = nr_timer_tick(&SInfo->sib5_timer); - if (sib5_expired) - SInfo->sib5_validity = false; - } - if (SInfo->sib6_validity) { - bool sib6_expired = nr_timer_tick(&SInfo->sib6_timer); - if (sib6_expired) - SInfo->sib6_validity = false; - } - if (SInfo->sib7_validity) { - bool sib7_expired = nr_timer_tick(&SInfo->sib7_timer); - if (sib7_expired) - SInfo->sib7_validity = false; - } - if (SInfo->sib8_validity) { - bool sib8_expired = nr_timer_tick(&SInfo->sib8_timer); - if (sib8_expired) - SInfo->sib8_validity = false; - } - if (SInfo->sib9_validity) { - bool sib9_expired = nr_timer_tick(&SInfo->sib9_timer); - if (sib9_expired) - SInfo->sib9_validity = false; - } - if (SInfo->sib10_validity) { - bool sib10_expired = nr_timer_tick(&SInfo->sib10_timer); - if (sib10_expired) - SInfo->sib10_validity = false; - } - if (SInfo->sib11_validity) { - bool sib11_expired = nr_timer_tick(&SInfo->sib11_timer); - if (sib11_expired) - SInfo->sib11_validity = false; - } - if (SInfo->sib12_validity) { - bool sib12_expired = nr_timer_tick(&SInfo->sib12_timer); - if (sib12_expired) - SInfo->sib12_validity = false; - } - if (SInfo->sib13_validity) { - bool sib13_expired = nr_timer_tick(&SInfo->sib13_timer); - if (sib13_expired) - SInfo->sib13_validity = false; - } - if (SInfo->sib14_validity) { - bool sib14_expired = nr_timer_tick(&SInfo->sib14_timer); - if (sib14_expired) - SInfo->sib14_validity = false; - } - if (SInfo->SInfo_r17.sib19_validity) { - bool sib19_expired = nr_timer_tick(&SInfo->SInfo_r17.sib19_timer); - if (sib19_expired) - SInfo->SInfo_r17.sib19_validity = false; - } + SInfo->sib1_validity = check_sib_timer_validity(SInfo->sib1_validity, &SInfo->sib1_timer); + SInfo->sib2_validity = check_sib_timer_validity(SInfo->sib2_validity, &SInfo->sib2_timer); + SInfo->sib3_validity = check_sib_timer_validity(SInfo->sib3_validity, &SInfo->sib3_timer); + SInfo->sib4_validity = check_sib_timer_validity(SInfo->sib4_validity, &SInfo->sib4_timer); + SInfo->sib5_validity = check_sib_timer_validity(SInfo->sib5_validity, &SInfo->sib5_timer); + SInfo->sib6_validity = check_sib_timer_validity(SInfo->sib6_validity, &SInfo->sib6_timer); + SInfo->sib7_validity = check_sib_timer_validity(SInfo->sib7_validity, &SInfo->sib7_timer); + SInfo->sib8_validity = check_sib_timer_validity(SInfo->sib8_validity, &SInfo->sib8_timer); + SInfo->sib9_validity = check_sib_timer_validity(SInfo->sib9_validity, &SInfo->sib9_timer); + SInfo->sib10_validity = check_sib_timer_validity(SInfo->sib10_validity, &SInfo->sib10_timer); + SInfo->sib11_validity = check_sib_timer_validity(SInfo->sib11_validity, &SInfo->sib11_timer); + SInfo->sib12_validity = check_sib_timer_validity(SInfo->sib12_validity, &SInfo->sib12_timer); + SInfo->sib13_validity = check_sib_timer_validity(SInfo->sib13_validity, &SInfo->sib13_timer); + SInfo->sib14_validity = check_sib_timer_validity(SInfo->sib14_validity, &SInfo->sib14_timer); + SInfo->SInfo_r17.sib19_validity = check_sib_timer_validity(SInfo->SInfo_r17.sib19_validity, &SInfo->SInfo_r17.sib19_timer); } void nr_rrc_handle_timers(NR_UE_RRC_INST_t *rrc)