From 27c68b2b60a4074accabe831c24cfac92d214e85 Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Mon, 6 Dec 2021 16:40:45 +0000 Subject: [PATCH 1/5] Fix Msg4 segmentation fault when UE_id is invalid --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 25aeea70a6..9b489f06e6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1412,6 +1412,12 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra } int UE_id = find_nr_UE_id(module_idP, ra->rnti); + if (UE_id < 0) { + mac_remove_nr_ue(module_idP, tc_rnti); + nr_clear_ra_proc(module_idP, CC_id, frameP, ra); + return; + } + NR_UE_info_t *UE_info = &nr_mac->UE_info; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; From c9007ee7beaff22ccde56854ac040d3265532e72 Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Mon, 6 Dec 2021 21:11:52 +0000 Subject: [PATCH 2/5] Schedule PUCCH even when ul_failure, otherwise COTS UE cannot use Msg3 to transfer DCCH messages --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 1 - 1 file changed, 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index a94559769d..33ba162ffb 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -141,7 +141,6 @@ void nr_schedule_pucch(int Mod_idP, for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; const int n = sizeof(sched_ctrl->sched_pucch) / sizeof(*sched_ctrl->sched_pucch); for (int i = 0; i < n; i++) { NR_sched_pucch_t *curr_pucch = &UE_info->UE_sched_ctrl[UE_id].sched_pucch[i]; From 1c4549aa1e2c5ad7550ac48c4a4d11d27c1d3267 Mon Sep 17 00:00:00 2001 From: Luis Pereira Date: Tue, 7 Dec 2021 09:08:36 +0000 Subject: [PATCH 3/5] Revert "Schedule PUCCH even when ul_failure, otherwise COTS UE cannot use Msg3 to transfer DCCH messages" This reverts commit c9007ee7beaff22ccde56854ac040d3265532e72 --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 33ba162ffb..a94559769d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -141,6 +141,7 @@ void nr_schedule_pucch(int Mod_idP, for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; const int n = sizeof(sched_ctrl->sched_pucch) / sizeof(*sched_ctrl->sched_pucch); for (int i = 0; i < n; i++) { NR_sched_pucch_t *curr_pucch = &UE_info->UE_sched_ctrl[UE_id].sched_pucch[i]; From e0944aa24b9b41686c311f2f844b8101bc21e92b Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Tue, 7 Dec 2021 11:40:24 +0000 Subject: [PATCH 4/5] Fix Msg4 segmentation fault when UE_id is invalid and reset ul_failure when UE reconnects using C-RNTI --- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 13 +++++++++---- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 6 ------ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 14 ++++++++++++++ openair2/RRC/NR/L2_nr_interface.c | 14 ++++++++++++++ 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index ced29f066f..8182e1c930 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -192,8 +192,13 @@ uint8_t get_transformPrecoding(const NR_BWP_UplinkCommon_t *initialUplinkBWP, uint8_t configuredGrant); void nr_mac_gNB_rrc_ul_failure(const module_id_t Mod_instP, - const int CC_idP, - const frame_t frameP, - const sub_frame_t subframeP, - const rnti_t rntiP) ; + const int CC_idP, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rntiP); + +void nr_mac_gNB_rrc_ul_failure_reset(const module_id_t Mod_instP, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rntiP); #endif diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 9b489f06e6..25aeea70a6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1412,12 +1412,6 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra } int UE_id = find_nr_UE_id(module_idP, ra->rnti); - if (UE_id < 0) { - mac_remove_nr_ue(module_idP, tc_rnti); - nr_clear_ra_proc(module_idP, CC_id, frameP, ra); - return; - } - NR_UE_info_t *UE_info = &nr_mac->UE_info; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index d14cf09f99..0af77a6b3c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -822,6 +822,20 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, ra->state = Msg4; ra->Msg4_frame = (frameP + 2) % 1024; ra->Msg4_slot = 1; + + if (ra->msg3_dcch_dtch) { + // Check if the C-RNTI still exists in the network + int UE_id_C = find_nr_UE_id(gnb_mod_idP, ra->crnti); + if (UE_id_C < 0) { + mac_remove_nr_ue(gnb_mod_idP, ra->rnti); + nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); + return; + } else { + UE_info->UE_sched_ctrl[UE_id_C].pusch_consecutive_dtx_cnt = 0; + UE_info->UE_sched_ctrl[UE_id_C].ul_failure = 0; + nr_mac_gNB_rrc_ul_failure_reset(gnb_mod_idP, frameP, slotP, ra->crnti); + } + } LOG_I(NR_MAC, "Scheduling RA-Msg4 for TC_RNTI 0x%04x (state %d, frame %d, slot %d)\n", (ra->msg3_dcch_dtch?ra->crnti:ra->rnti), ra->state, ra->Msg4_frame, ra->Msg4_slot); } diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index 9cef23a6c5..d781cb7e9b 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -383,3 +383,17 @@ void nr_mac_gNB_rrc_ul_failure(const module_id_t Mod_instP, LOG_D(RRC,"Frame %d, Subframe %d: UL failure: UE %x unknown \n",frameP,subframeP,rntiP); } } + +void nr_mac_gNB_rrc_ul_failure_reset(const module_id_t Mod_instP, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rntiP) { + struct rrc_gNB_ue_context_s *ue_context_p = NULL; + ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[Mod_instP], rntiP); + if (ue_context_p != NULL) { + LOG_W(RRC,"Frame %d, Subframe %d: UE %x UL failure reset, deactivating timer\n",frameP,subframeP,rntiP); + ue_context_p->ue_context.ul_failure_timer=0; + } else { + LOG_W(RRC,"Frame %d, Subframe %d: UL failure reset: UE %x unknown \n",frameP,subframeP,rntiP); + } +} From 158c309cbcbc711794641138d09a3bd1b9684abc Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Wed, 8 Dec 2021 12:21:20 +0000 Subject: [PATCH 5/5] Add some comments on the code and update documentation --- doc/FEATURE_SET.md | 6 ++++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/FEATURE_SET.md b/doc/FEATURE_SET.md index 9443fbd56e..2fc7115193 100644 --- a/doc/FEATURE_SET.md +++ b/doc/FEATURE_SET.md @@ -307,8 +307,10 @@ The following features are valid for the gNB and the 5G-NR UE. - MAC <-> PHY data interface using FAPI P7 interface for BCH PDU, DCI PDU, PDSCH PDU - Scheduler procedures for SIB1 - Scheduler procedures for RA - - Contention free RA procedure - - Contention based RA procedure + - Contention Free RA procedure + - Contention Based RA procedure + - Msg3 can transfer uplink CCCH, DTCH or DCCH messages + - CBRA can be performed using MAC CE or C-RNTI - Scheduler procedures for CSI-RS - MAC downlink scheduler - phy-test scheduler (fixed allocation and usable also without UE) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 0af77a6b3c..313dd6236e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -824,13 +824,17 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, ra->Msg4_slot = 1; if (ra->msg3_dcch_dtch) { - // Check if the C-RNTI still exists in the network + // Check if the UE identified by C-RNTI still exists at the gNB int UE_id_C = find_nr_UE_id(gnb_mod_idP, ra->crnti); if (UE_id_C < 0) { + // The UE identified by C-RNTI no longer exists at the gNB + // Let's abort the current RA, so the UE will trigger a new RA later but using RRCSetupRequest instead. A better solution may be implemented mac_remove_nr_ue(gnb_mod_idP, ra->rnti); nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); return; } else { + // The UE identified by C-RNTI still exists at the gNB + // Reset uplink failure flags/counters/timers at MAC and at RRC so gNB will resume again scheduling resources for this UE UE_info->UE_sched_ctrl[UE_id_C].pusch_consecutive_dtx_cnt = 0; UE_info->UE_sched_ctrl[UE_id_C].ul_failure = 0; nr_mac_gNB_rrc_ul_failure_reset(gnb_mod_idP, frameP, slotP, ra->crnti);