From 9c8274f6bd186f39fd3c7019354612af18ac3b58 Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 12 Sep 2025 15:51:14 +0200 Subject: [PATCH] separate RRC to MAC message to trigger SIB scheduling --- openair1/SIMULATION/NR_PHY/dlsim.c | 2 +- openair2/COMMON/rrc_messages_types.h | 7 +++++- openair2/LAYER2/NR_MAC_UE/config_ue.c | 32 ++++++++++++++------------- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 4 ++-- openair2/RRC/NR_UE/L2_interface_ue.c | 4 +++- openair2/RRC/NR_UE/rrc_UE.c | 10 ++++++--- 6 files changed, 36 insertions(+), 23 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 82984657d3..16ff94dd47 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -955,7 +955,7 @@ int main(int argc, char **argv) //Configure UE NR_BCCH_BCH_Message_t *mib = get_new_MIB_NR(scc); - nr_rrc_mac_config_req_mib(0, 0, mib->message.choice.mib, false, false); + nr_rrc_mac_config_req_mib(0, 0, mib->message.choice.mib, false); nr_rrc_mac_config_req_cg(0, 0, UE_CellGroup, UE_Capability_nr); asn1cFreeStruc(asn_DEF_NR_CellGroupConfig, UE_CellGroup); diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index 255da9f189..233d3f1a80 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -478,7 +478,6 @@ typedef struct { } nr_mac_rrc_config_cg_t; typedef struct { NR_BCCH_BCH_Message_t *bcch; - int get_sib; bool access_barred; } nr_mac_rrc_config_mib_t; typedef struct { @@ -489,6 +488,10 @@ typedef struct { NR_SIB19_r17_t *sib19; bool can_start_ra; } nr_mac_rrc_config_other_sib_t; +typedef struct { + int get_sib; +} nr_mac_rrc_sched_sib_t; + enum payload_type { NR_MAC_RRC_CONFIG_RESET, @@ -496,6 +499,7 @@ enum payload_type { NR_MAC_RRC_CONFIG_MIB, NR_MAC_RRC_CONFIG_SIB1, NR_MAC_RRC_CONFIG_OTHER_SIB, + NR_MAC_RRC_SCHED_SIB, NR_MAC_RRC_RESUME_RB }; @@ -506,6 +510,7 @@ typedef struct { 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_sched_sib_t sched_sib; nr_mac_rrc_config_other_sib_t config_other_sib; nr_mac_rrc_resume_rb_t resume_rb; } payload; diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 192b0a5111..05d2f87eb8 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -1024,7 +1024,21 @@ static bool is_cset0_present(frequency_range_t const fr, uint8_t const kssb) return (fr == FR1) ? (kssb < 24) : (kssb < 12); } -void nr_rrc_mac_config_req_mib(module_id_t module_id, int cc_idP, NR_MIB_t *mib, int sched_sib, bool barred) +void nr_rrc_mac_sched_sib(module_id_t module_id, int sched_sib) +{ + NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + if (sched_sib == 1) { + bool const is_c0 = is_cset0_present(mac->frequency_range, mac->ssb_subcarrier_offset); + mac->get_sib1 = is_c0; + AssertFatal(is_c0, "RRC scheduling SIB1 reception but MIB indicates no SIB1 present in current cell\n"); + } else if (sched_sib > 1) + mac->get_otherSI[sched_sib - 2] = true; + + if (mac->state == UE_NOT_SYNC && mac->get_sib1) + mac->state = UE_RECEIVING_SIB; +} + +void nr_rrc_mac_config_req_mib(module_id_t module_id, int cc_idP, NR_MIB_t *mib, bool barred) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); int ret = pthread_mutex_lock(&mac->if_mutex); @@ -1044,22 +1058,10 @@ void nr_rrc_mac_config_req_mib(module_id_t module_id, int cc_idP, NR_MIB_t *mib, mac->phy_config.CC_id = cc_idP; nr_ue_decode_mib(mac, cc_idP); - - if (sched_sib == 1) { - bool const is_c0 = is_cset0_present(mac->frequency_range, mac->ssb_subcarrier_offset); - mac->get_sib1 = is_c0; - AssertFatal(is_c0, "RRC scheduling SIB1 reception but MIB indicates no SIB1 present in current cell\n"); - } else if (sched_sib > 1) - mac->get_otherSI[sched_sib - 2] = true; - if (get_softmodem_params()->phy_test) mac->state = UE_CONNECTED; - else if (mac->state == UE_NOT_SYNC) { - if (IS_SA_MODE(get_softmodem_params()) && mac->get_sib1) - mac->state = UE_RECEIVING_SIB; - else - mac->state = UE_PERFORMING_RA; - } + else if (mac->state == UE_NOT_SYNC && !IS_SA_MODE(get_softmodem_params())) + mac->state = UE_PERFORMING_RA; 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 aee55e4883..981048f7b0 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -85,8 +85,8 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id, NR_CellGroupConfig_t *cell_group_config, NR_UE_NR_Capability_t *ue_Capability); -void nr_rrc_mac_config_req_mib(module_id_t module_id, int cc_idP, NR_MIB_t *mibP, int sched_sib1, bool barred); - +void nr_rrc_mac_config_req_mib(module_id_t module_id, int cc_idP, NR_MIB_t *mibP, bool barred); +void nr_rrc_mac_sched_sib(module_id_t module_id, int sched_sib); void nr_rrc_mac_config_req_sib1(module_id_t module_id, int cc_idP, NR_SIB1_t *sib1, bool can_start_ra); struct position; /* forward declaration */ diff --git a/openair2/RRC/NR_UE/L2_interface_ue.c b/openair2/RRC/NR_UE/L2_interface_ue.c index bae8915916..668f2981fb 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.c +++ b/openair2/RRC/NR_UE/L2_interface_ue.c @@ -146,7 +146,6 @@ void process_msg_rcc_to_mac(nr_mac_rrc_message_t *msg, int instance_id) nr_rrc_mac_config_req_mib(instance_id, 0, 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; @@ -160,6 +159,9 @@ void process_msg_rcc_to_mac(nr_mac_rrc_message_t *msg, int instance_id) 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_SCHED_SIB: + nr_rrc_mac_sched_sib(instance_id, msg->payload.sched_sib.get_sib); + break; case NR_MAC_RRC_RESUME_RB: nr_rrc_mac_resume_rb(instance_id, msg->payload.resume_rb.is_srb, msg->payload.resume_rb.rb_id); break; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 27e1dc0bb1..90c9c40ade 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1507,17 +1507,21 @@ static void nr_rrc_ue_decode_NR_BCCH_BCH_Message(NR_UE_RRC_INST_t *rrc, && rrc->nrRrcState != RRC_STATE_DETACH_NR) { // to schedule MAC to get SI if required get_sib = check_si_status(SI_info); - if (get_sib) - SI_info->sib_pending = true; } if (bcch_message->message.present == NR_BCCH_BCH_MessageType_PR_mib) { 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); + if (get_sib) { + SI_info->sib_pending = true; + nr_mac_rrc_message_t sib_msg = {0}; + sib_msg.payload_type = NR_MAC_RRC_SCHED_SIB; + sib_msg.payload.sched_sib.get_sib = get_sib; + nr_rrc_send_msg_to_mac(rrc, &sib_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);