diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 4a534df3b6..3c41338326 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -731,12 +731,14 @@ static int UE_dl_preprocessing(PHY_VARS_NR_UE *UE, 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); + notifiedFIFO_elt_t *elt = pollNotifiedFIFO(&get_mac_inst(UE->Mod_id)->input_nf); + if (!elt) { + break; + } + process_msg_rcc_to_mac(NotifiedFifoData(elt), UE->Mod_id); + delNotifiedFIFO_elt(elt); + } while (true); if (UE->if_inst) UE->if_inst->slot_indication(UE->Mod_id, false); @@ -1032,12 +1034,10 @@ void *UE_thread(void *arg) decoded_frame_rx = UE->SL_UE_PHY_PARAMS.sync_params.DFN; 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"); + notifiedFIFO_elt_t *elt = pullNotifiedFIFO(&mac->input_nf); + AssertFatal(elt != NULL, "fifo error while waiting for MIB"); + process_msg_rcc_to_mac(NotifiedFifoData(elt), UE->Mod_id); + delNotifiedFIFO_elt(elt); decoded_frame_rx = mac->mib_frame; } LOG_A(PHY, @@ -1287,6 +1287,8 @@ void init_NR_UE(int nb_inst, char *uecap_file, char *reconfig_file, char *rbconf for (int instance_id = 0; instance_id < nb_inst; instance_id++) { NR_UE_RRC_INST_t* rrc = nr_rrc_init_ue(uecap_file, instance_id, get_nrUE_params()->nb_antennas_tx); NR_UE_MAC_INST_t *mac = nr_l2_init_ue(instance_id); + + nr_rrc_set_mac_queue(instance_id, &mac->input_nf); mac->if_module = nr_ue_if_module_init(instance_id); AssertFatal(mac->if_module, "can not initialize IF module\n"); if (!IS_SA_MODE(get_softmodem_params()) && !get_softmodem_params()->sl_mode) { diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 6a5fcf2394..e2523dda2f 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -500,12 +500,14 @@ 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); + do { + notifiedFIFO_elt_t *elt = pollNotifiedFIFO(&mac->input_nf); + if (!elt) { + break; + } + process_msg_rcc_to_mac(NotifiedFifoData(elt), inst); + delNotifiedFIFO_elt(elt); + } while (true); 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/openair2/COMMON/rrc_messages_def.h b/openair2/COMMON/rrc_messages_def.h index df295e2011..33d6b7b59e 100644 --- a/openair2/COMMON/rrc_messages_def.h +++ b/openair2/COMMON/rrc_messages_def.h @@ -85,14 +85,6 @@ MESSAGE_DEF(NAS_INIT_NOS1_IF, MESSAGE_PRIORITY_MED, nas_nos1_msg_t, nas_init_nos 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_RESUME_RB, MESSAGE_PRIORITY_MED, nr_mac_rrc_resume_rb_t, nr_mac_rrc_resume_rb) -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 1d35619ecc..e1656a3d7f 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -105,12 +105,6 @@ #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_RESUME_RB(mSGpTR) (mSGpTR)->ittiMsg.nr_mac_rrc_resume_rb -#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 @@ -497,4 +491,25 @@ typedef struct { bool can_start_ra; } nr_mac_rrc_config_other_sib_t; +enum payload_type { + NR_MAC_RRC_CONFIG_RESET, + NR_MAC_RRC_CONFIG_CG, + NR_MAC_RRC_CONFIG_MIB, + NR_MAC_RRC_CONFIG_SIB1, + NR_MAC_RRC_CONFIG_OTHER_SIB, + NR_MAC_RRC_RESUME_RB +}; + +typedef struct { + enum payload_type payload_type; + union { + nr_mac_rrc_config_reset_t config_reset; + nr_mac_rrc_config_cg_t config_cg; + nr_mac_rrc_config_mib_t config_mib; + nr_mac_rrc_config_sib1_t config_sib1; + nr_mac_rrc_config_other_sib_t config_other_sib; + nr_mac_rrc_resume_rb_t resume_rb; + } payload; +} nr_mac_rrc_message_t; + #endif /* RRC_MESSAGES_TYPES_H_ */ diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 2d88708bfe..d734870f52 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -654,6 +654,7 @@ typedef struct NR_UE_MAC_INST_s { bool msg3_C_RNTI; pthread_mutex_t if_mutex; ue_mac_stats_t stats; + notifiedFIFO_t input_nf; } NR_UE_MAC_INST_t; static inline int GET_NTN_UE_K_OFFSET(const ntn_timing_advance_componets_t *ntn_ta, int scs) diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 78328461b4..1a43dd2972 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -70,6 +70,7 @@ void nr_ue_init_mac(NR_UE_MAC_INST_t *mac) mac->p_Max_alt = INT_MIN; mac->msg3_C_RNTI = false; mac->ntn_ta.ntn_params_changed = false; + initNotifiedFIFO(&mac->input_nf); reset_mac_inst(mac); // need to inizialize because might not been setup (optional timer) diff --git a/openair2/RRC/NR_UE/L2_interface_ue.c b/openair2/RRC/NR_UE/L2_interface_ue.c index 6271957f4f..b751f31670 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.c +++ b/openair2/RRC/NR_UE/L2_interface_ue.c @@ -121,42 +121,40 @@ void nr_mac_rrc_data_ind_ue(const module_id_t module_id, } } -void process_msg_rcc_to_mac(MessageDef *msg) +void process_msg_rcc_to_mac(nr_mac_rrc_message_t *msg, int instance_id) { - instance_t ue_id = ITTI_MSG_DESTINATION_INSTANCE(msg); - switch (ITTI_MSG_ID(msg)) { + switch (msg->payload_type) { case NR_MAC_RRC_CONFIG_RESET: - nr_rrc_mac_config_req_reset(ue_id, NR_MAC_RRC_CONFIG_RESET(msg).cause); + nr_rrc_mac_config_req_reset(instance_id, msg->payload.config_reset.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); + nr_rrc_mac_config_req_cg(instance_id, 0, msg->payload.config_cg.cellGroupConfig, msg->payload.config_cg.UE_NR_Capability); + asn1cFreeStruc(asn_DEF_NR_CellGroupConfig, msg->payload.config_cg.cellGroupConfig); break; case NR_MAC_RRC_CONFIG_MIB: - nr_rrc_mac_config_req_mib(ue_id, + nr_rrc_mac_config_req_mib(instance_id, 0, - NR_MAC_RRC_CONFIG_MIB(msg).bcch->message.choice.mib, - NR_MAC_RRC_CONFIG_MIB(msg).get_sib, - NR_MAC_RRC_CONFIG_MIB(msg).access_barred); - ASN_STRUCT_FREE(asn_DEF_NR_BCCH_BCH_Message, NR_MAC_RRC_CONFIG_MIB(msg).bcch); + msg->payload.config_mib.bcch->message.choice.mib, + msg->payload.config_mib.get_sib, + msg->payload.config_mib.access_barred); + ASN_STRUCT_FREE(asn_DEF_NR_BCCH_BCH_Message, msg->payload.config_mib.bcch); break; case NR_MAC_RRC_CONFIG_SIB1: { - NR_SIB1_t *sib1 = NR_MAC_RRC_CONFIG_SIB1(msg).sib1; - bool can_start_ra = NR_MAC_RRC_CONFIG_SIB1(msg).can_start_ra; - nr_rrc_mac_config_req_sib1(ue_id, 0, sib1, can_start_ra); - SEQUENCE_free(&asn_DEF_NR_SIB1, NR_MAC_RRC_CONFIG_SIB1(msg).sib1, ASFM_FREE_EVERYTHING); + NR_SIB1_t *sib1 = msg->payload.config_sib1.sib1; + bool can_start_ra = msg->payload.config_sib1.can_start_ra; + nr_rrc_mac_config_req_sib1(instance_id, 0, sib1, can_start_ra); + SEQUENCE_free(&asn_DEF_NR_SIB1, msg->payload.config_sib1.sib1, ASFM_FREE_EVERYTHING); } break; case NR_MAC_RRC_CONFIG_OTHER_SIB: { - bool can_start_ra = NR_MAC_RRC_CONFIG_OTHER_SIB(msg).can_start_ra; - nr_rrc_mac_config_other_sib(ue_id, NR_MAC_RRC_CONFIG_OTHER_SIB(msg).sib19, can_start_ra); + bool can_start_ra = msg->payload.config_other_sib.can_start_ra; + nr_rrc_mac_config_other_sib(instance_id, msg->payload.config_other_sib.sib19, can_start_ra); } break; case NR_MAC_RRC_RESUME_RB: - nr_rrc_mac_resume_rb(ue_id, NR_MAC_RRC_RESUME_RB(msg).is_srb, NR_MAC_RRC_RESUME_RB(msg).rb_id); + nr_rrc_mac_resume_rb(instance_id, msg->payload.resume_rb.is_srb, msg->payload.resume_rb.rb_id); break; default: - LOG_E(NR_MAC, "Unexpected msg from RRC: %d\n", ITTI_MSG_ID(msg)); + LOG_E(NR_MAC, "Unexpected msg from RRC: %d\n", msg->payload_type); } - itti_free(ITTI_MSG_ORIGIN_ID(msg), msg); } void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id) diff --git a/openair2/RRC/NR_UE/L2_interface_ue.h b/openair2/RRC/NR_UE/L2_interface_ue.h index e36f6d83fb..daaed50e65 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.h +++ b/openair2/RRC/NR_UE/L2_interface_ue.h @@ -42,6 +42,6 @@ void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, bool prepare_ 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 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); +void process_msg_rcc_to_mac(nr_mac_rrc_message_t *msg, int instance_id); #endif diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index df95a177d6..52d9ecb50a 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -149,6 +149,21 @@ static void nr_rrc_ue_process_masterCellGroup(NR_UE_RRC_INST_t *rrc, static void nr_rrc_ue_process_measConfig(rrcPerNB_t *rrc, NR_MeasConfig_t *const measConfig, NR_UE_Timers_Constants_t *timers); +/** + * @brief Sends an RRC message to the connected UE MAC instance. + * + * @param rrc UE RRC instance structure + * @param msg RRC message to be sent to MAC + */ +static void nr_rrc_send_msg_to_mac(NR_UE_RRC_INST_t *rrc, nr_mac_rrc_message_t *msg) +{ + AssertFatal(rrc->mac_input_nf != NULL, "MAC input NF is NULL for UE %ld\n", rrc->ue_id); + notifiedFIFO_elt_t *nf_msg = newNotifiedFIFO_elt(sizeof(nr_mac_rrc_message_t), 0, NULL, NULL); + nr_mac_rrc_message_t *rrc_msg = NotifiedFifoData(nf_msg); + memcpy(rrc_msg, msg, sizeof(nr_mac_rrc_message_t)); + pushNotifiedFIFO(rrc->mac_input_nf, nf_msg); +} + NR_UE_RRC_INST_t *get_NR_UE_rrc_inst(int instance) { AssertFatal(instance >= 0 && instance < MAX_NUM_NR_UE_INST, "RRC instance %d out of bounds\n", instance); @@ -286,7 +301,6 @@ static void nr_rrc_process_ntnconfig(NR_UE_RRC_INST_t *rrc, NR_UE_RRC_SI_INFO *S static void nr_decode_SI(NR_UE_RRC_SI_INFO *SI_info, NR_SystemInformation_t *si, NR_UE_RRC_INST_t *rrc, int frame) { - instance_t ue_id = rrc->ue_id; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SI, VCD_FUNCTION_IN); // Dump contents @@ -370,10 +384,12 @@ static void nr_decode_SI(NR_UE_RRC_SI_INFO *SI_info, NR_SystemInformation_t *si, } 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); - NR_MAC_RRC_CONFIG_OTHER_SIB(msg).can_start_ra = rrc->is_NTN_UE; - itti_send_msg_to_task(TASK_MAC_UE, ue_id, msg); + nr_mac_rrc_message_t rrc_msg = {0}; + rrc_msg.payload_type = NR_MAC_RRC_CONFIG_OTHER_SIB; + nr_mac_rrc_config_other_sib_t *sib19_msg = &rrc_msg.payload.config_other_sib; + asn_copy(&asn_DEF_NR_SIB19_r17, (void **)&sib19_msg->sib19, sib19); + sib19_msg->can_start_ra = rrc->is_NTN_UE; + nr_rrc_send_msg_to_mac(rrc, &rrc_msg); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_UE_DECODE_SI, VCD_FUNCTION_OUT); } @@ -507,10 +523,13 @@ 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); - MessageDef *msg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NR_MAC_RRC_CONFIG_SIB1); - NR_MAC_RRC_CONFIG_SIB1(msg).sib1 = sib1; - NR_MAC_RRC_CONFIG_SIB1(msg).can_start_ra = !rrc->is_NTN_UE; - itti_send_msg_to_task(TASK_MAC_UE, rrc->ue_id, msg); + + nr_mac_rrc_message_t rrc_msg = {0}; + rrc_msg.payload_type = NR_MAC_RRC_CONFIG_SIB1; + nr_mac_rrc_config_sib1_t *config_sib1 = &rrc_msg.payload.config_sib1; + config_sib1->sib1 = sib1; + config_sib1->can_start_ra = !rrc->is_NTN_UE; + nr_rrc_send_msg_to_mac(rrc, &rrc_msg); } static void nr_rrc_process_reconfiguration_v1530(NR_UE_RRC_INST_t *rrc, NR_RRCReconfiguration_v1530_IEs_t *rec_1530, int gNB_index) @@ -649,12 +668,12 @@ static void nr_rrc_ue_process_rrcReconfiguration(NR_UE_RRC_INST_t *rrc, int gNB_ nr_rrc_cellgroup_configuration(rrc, cellGroupConfig, gNB_index); AssertFatal(!IS_SA_MODE(get_softmodem_params()), "secondaryCellGroup only used in NSA for now\n"); - 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); + nr_mac_rrc_message_t rrc_msg = {0}; + rrc_msg.payload_type = NR_MAC_RRC_CONFIG_CG; + nr_mac_rrc_config_cg_t *config_cg = &rrc_msg.payload.config_cg; + config_cg->cellGroupConfig = cellGroupConfig; + config_cg->UE_NR_Capability = rrc->UECap.UE_NR_Capability; + nr_rrc_send_msg_to_mac(rrc, &rrc_msg); } if (ie->measConfig) { LOG_I(NR_RRC, "RRCReconfiguration includes Measurement Configuration\n"); @@ -974,12 +993,13 @@ static void nr_rrc_ue_decode_NR_BCCH_BCH_Message(NR_UE_RRC_INST_t *rrc, SI_info->sib_pending = true; } 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; - NR_MAC_RRC_CONFIG_MIB(msg).access_barred = barred; - itti_send_msg_to_task(TASK_MAC_UE, rrc->ue_id, msg); + nr_mac_rrc_message_t rrc_msg = {0}; + rrc_msg.payload_type = NR_MAC_RRC_CONFIG_MIB; + nr_mac_rrc_config_mib_t *config_mib = &rrc_msg.payload.config_mib; + config_mib->bcch = bcch_message; + config_mib->get_sib = get_sib; + config_mib->access_barred = barred; + nr_rrc_send_msg_to_mac(rrc, &rrc_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); @@ -1037,10 +1057,11 @@ static void nr_rrc_handle_msg3_indication(NR_UE_RRC_INST_t *rrc, rnti_t rnti) nr_rlc_reconfigure_entity(rrc->ue_id, lc_id, NULL); // resume SRB1 rrc->Srb[srb_id] = RB_ESTABLISHED; - MessageDef *msg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NR_MAC_RRC_RESUME_RB); - NR_MAC_RRC_RESUME_RB(msg).is_srb = true; - NR_MAC_RRC_RESUME_RB(msg).rb_id = 1; - itti_send_msg_to_task(TASK_MAC_UE, rrc->ue_id, msg); + nr_mac_rrc_message_t rrc_msg = {0}; + rrc_msg.payload_type = NR_MAC_RRC_RESUME_RB; + rrc_msg.payload.resume_rb.is_srb = true; + rrc_msg.payload.resume_rb.rb_id = 1; + nr_rrc_send_msg_to_mac(rrc, &rrc_msg); break; case DURING_HANDOVER: AssertFatal(1==0, "ra_trigger not implemented yet!\n"); @@ -1261,10 +1282,12 @@ static void nr_rrc_ue_process_masterCellGroup(NR_UE_RRC_INST_t *rrc, nr_rrc_cellgroup_configuration(rrc, cellGroupConfig, gNB_index); 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); + nr_mac_rrc_message_t rrc_msg = {0}; + rrc_msg.payload_type = NR_MAC_RRC_CONFIG_CG; + nr_mac_rrc_config_cg_t *mac_msg = &rrc_msg.payload.config_cg; + mac_msg->cellGroupConfig = cellGroupConfig; + mac_msg->UE_NR_Capability = rrc->UECap.UE_NR_Capability; + nr_rrc_send_msg_to_mac(rrc, &rrc_msg); } static void rrc_ue_generate_RRCSetupComplete(const NR_UE_RRC_INST_t *rrc, const uint8_t Transaction_id) @@ -1346,9 +1369,10 @@ static void nr_rrc_rrcsetup_fallback(NR_UE_RRC_INST_t *rrc) // default MAC Cell Group configuration and CCCH configuration // TODO to be completed NR_UE_MAC_reset_cause_t cause = RRC_SETUP_REESTAB_RESUME; - 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); + nr_mac_rrc_message_t rrc_msg = {0}; + rrc_msg.payload_type = NR_MAC_RRC_CONFIG_RESET; + rrc_msg.payload.config_reset.cause = cause; + nr_rrc_send_msg_to_mac(rrc, &rrc_msg); // indicate to upper layers fallback of the RRC connection // TODO @@ -1412,9 +1436,10 @@ static void nr_rrc_process_rrcreject(NR_UE_RRC_INST_t *rrc, const NR_RRCReject_t // reset MAC and release the default MAC Cell Group configuration NR_UE_MAC_reset_cause_t cause = REJECT; - 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); + nr_mac_rrc_message_t rrc_msg = {0}; + rrc_msg.payload_type = NR_MAC_RRC_CONFIG_RESET; + rrc_msg.payload.config_reset.cause = cause; + nr_rrc_send_msg_to_mac(rrc, &rrc_msg); // if waitTime is configured in the RRCReject: start timer T302, with the timer value set to the waitTime NR_RejectWaitTime_t *waitTime = NULL; @@ -2122,18 +2147,20 @@ static int nr_rrc_ue_decode_dcch(NR_UE_RRC_INST_t *rrc, // resume SRB2 and DRBs that are suspended if (rrc->Srb[2] == RB_SUSPENDED) { rrc->Srb[2] = RB_ESTABLISHED; - MessageDef *msg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NR_MAC_RRC_RESUME_RB); - NR_MAC_RRC_RESUME_RB(msg).is_srb = true; - NR_MAC_RRC_RESUME_RB(msg).rb_id = 2; - itti_send_msg_to_task(TASK_MAC_UE, rrc->ue_id, msg); + nr_mac_rrc_message_t rrc_msg = {0}; + rrc_msg.payload_type = NR_MAC_RRC_RESUME_RB; + rrc_msg.payload.resume_rb.is_srb = true; + rrc_msg.payload.resume_rb.rb_id = 2; + nr_rrc_send_msg_to_mac(rrc, &rrc_msg); } for (int i = 1; i <= MAX_DRBS_PER_UE; i++) { if (get_DRB_status(rrc, i) == RB_SUSPENDED) { set_DRB_status(rrc, i, RB_ESTABLISHED); - MessageDef *msg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NR_MAC_RRC_RESUME_RB); - NR_MAC_RRC_RESUME_RB(msg).is_srb = false; - NR_MAC_RRC_RESUME_RB(msg).rb_id = i; - itti_send_msg_to_task(TASK_MAC_UE, rrc->ue_id, msg); + nr_mac_rrc_message_t rrc_msg = {0}; + rrc_msg.payload_type = NR_MAC_RRC_RESUME_RB; + rrc_msg.payload.resume_rb.is_srb = true; + rrc_msg.payload.resume_rb.rb_id = i; + nr_rrc_send_msg_to_mac(rrc, &rrc_msg); } } rrc->reconfig_after_reestab = false; @@ -2336,11 +2363,11 @@ void *rrc_nrue(void *notUsed) case NR_RRC_DCCH_DATA_IND: nr_rrc_ue_decode_dcch(rrc, - NR_RRC_DCCH_DATA_IND(msg_p).dcch_index, - NR_RRC_DCCH_DATA_IND(msg_p).sdu_p, - NR_RRC_DCCH_DATA_IND(msg_p).sdu_size, - NR_RRC_DCCH_DATA_IND(msg_p).gNB_index, - &NR_RRC_DCCH_DATA_IND(msg_p).msg_integrity); + NR_RRC_DCCH_DATA_IND(msg_p).dcch_index, + NR_RRC_DCCH_DATA_IND(msg_p).sdu_p, + NR_RRC_DCCH_DATA_IND(msg_p).sdu_size, + NR_RRC_DCCH_DATA_IND(msg_p).gNB_index, + &NR_RRC_DCCH_DATA_IND(msg_p).msg_integrity); /* this is allocated by itti_malloc in PDCP task (deliver_sdu_srb) then passed to the RRC task and freed after use */ free(NR_RRC_DCCH_DATA_IND(msg_p).sdu_p); @@ -2512,9 +2539,10 @@ 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 - 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); + nr_mac_rrc_message_t rrc_msg = {0}; + rrc_msg.payload_type = NR_MAC_RRC_CONFIG_RESET; + rrc_msg.payload.config_reset.cause = RE_ESTABLISHMENT; + nr_rrc_send_msg_to_mac(rrc, &rrc_msg); } static void nr_rrc_ue_generate_rrcReestablishmentComplete(const NR_UE_RRC_INST_t *rrc, @@ -2887,9 +2915,10 @@ 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; - 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); + nr_mac_rrc_message_t rrc_msg = {0}; + rrc_msg.payload_type = NR_MAC_RRC_CONFIG_RESET; + rrc_msg.payload.config_reset.cause = cause; + nr_rrc_send_msg_to_mac(rrc, &rrc_msg); // enter RRC_IDLE LOG_I(NR_RRC, "RRC moved into IDLE state\n"); @@ -2918,9 +2947,11 @@ 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; - 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); + nr_mac_rrc_message_t rrc_msg = {0}; + rrc_msg.payload_type = NR_MAC_RRC_CONFIG_RESET; + rrc_msg.payload.config_reset.cause = cause; + nr_rrc_send_msg_to_mac(rrc, &rrc_msg); + // TODO handle connEstFailureControl // TODO inform upper layers about the failure to establish the RRC connection } @@ -2936,9 +2967,10 @@ void handle_t430_expiry(NR_UE_RRC_INST_t *rrc) } // Indicate MAC that UL SYNC is LOST NR_UE_MAC_reset_cause_t cause = UL_SYNC_LOST_T430_EXPIRED; - 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); + nr_mac_rrc_message_t rrc_msg = {0}; + rrc_msg.payload_type = NR_MAC_RRC_CONFIG_RESET; + rrc_msg.payload.config_reset.cause = cause; + nr_rrc_send_msg_to_mac(rrc, &rrc_msg); } //This calls the sidelink preconf message after RRC, MAC instances are created. @@ -2954,3 +2986,9 @@ void start_sidelink(int instance) } } + +void nr_rrc_set_mac_queue(instance_t instance, notifiedFIFO_t *mac_input_nf) +{ + NR_UE_RRC_INST_t *rrc = get_NR_UE_rrc_inst(instance); + rrc->mac_input_nf = mac_input_nf; +} diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index c71f7697a2..bc645f7cc1 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -63,6 +63,7 @@ #include "RRC/NR/nr_rrc_common.h" #include "as_message.h" #include "common/utils/nr/nr_common.h" +#include "notified_fifo.h" #define NB_CNX_UE 2//MAX_MANAGED_RG_PER_MOBILE #define MAX_MEAS_OBJ 64 @@ -248,6 +249,7 @@ typedef struct NR_UE_RRC_INST_s { NR_SL_PreconfigurationNR_r16_t *sl_preconfig; // NTN params bool is_NTN_UE; + notifiedFIFO_t *mac_input_nf; } NR_UE_RRC_INST_t; #endif diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index bc7f7001af..ba853f546d 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -106,6 +106,8 @@ void nr_rrc_ue_decode_NR_SBCCH_SL_BCH_Message(NR_UE_RRC_INST_t *rrc, const sdu_size_t pdu_len, const uint16_t rx_slss_id); +void nr_rrc_set_mac_queue(instance_t instance, notifiedFIFO_t *mac_input_nf); + /** @}*/ #endif