From 7b163f16889398385f9af1233e20eef7a1bf2f64 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 4 Oct 2024 21:54:39 +0200 Subject: [PATCH] Harmonize UE context setup resp bearer handling This is preparatory work to handle the UE context setup response from the target DU. There are two cases: - "Initial" UE context setup response (during connection setup): we need to inform the CU-UP via an E1 message of the new bearers (GTP tunnel update) - F1 handover: we need to inform the CU-UP via an E1 message that there are DRBs to reestablish There are two different functions, e1_send_bearer_updates() and cuup_notify_reestablishment(), to do this. Harmonize the code, before implementing the actual handover logic in the next commit. --- openair2/RRC/NR/rrc_gNB.c | 8 +++++++- openair2/RRC/NR/rrc_gNB_radio_bearers.c | 9 +++++++++ openair2/RRC/NR/rrc_gNB_radio_bearers.h | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 268dfb7772..08547d7542 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1851,11 +1851,17 @@ static void rrc_CU_process_ue_context_setup_response(MessageDef *msg_p, instance xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, UE->masterCellGroup); if (resp->drbs_to_be_setup_length > 0) { + int num_drb = get_number_active_drbs(UE); + DevAssert(num_drb == 0 || num_drb == resp->drbs_to_be_setup_length); + /* Note: we would ideally check that SRB2 is acked, but at least LiteOn DU * seems buggy and does not ack, so simply check that locally we activated */ AssertFatal(UE->Srb[1].Active && UE->Srb[2].Active, "SRBs 1 and 2 must be active during DRB Establishment"); store_du_f1u_tunnel(resp->drbs_to_be_setup, resp->drbs_to_be_setup_length, UE); - e1_send_bearer_updates(rrc, UE, resp->drbs_to_be_setup_length, resp->drbs_to_be_setup); + if (num_drb == 0) + e1_send_bearer_updates(rrc, UE, resp->drbs_to_be_setup_length, resp->drbs_to_be_setup); + else + cuup_notify_reestablishment(rrc, UE); } rrc_gNB_generate_dedicatedRRCReconfiguration(rrc, UE); diff --git a/openair2/RRC/NR/rrc_gNB_radio_bearers.c b/openair2/RRC/NR/rrc_gNB_radio_bearers.c index ab2bf13071..aec7865a1c 100644 --- a/openair2/RRC/NR/rrc_gNB_radio_bearers.c +++ b/openair2/RRC/NR/rrc_gNB_radio_bearers.c @@ -181,6 +181,15 @@ uint8_t get_next_available_drb_id(gNB_RRC_UE_t *ue) return DRB_INACTIVE; } +int get_number_active_drbs(gNB_RRC_UE_t *ue) +{ + int n = 0; + for (int i = 0; i < MAX_DRBS_PER_UE; ++i) + if (ue->established_drbs[i].status != DRB_INACTIVE) + n++; + return n; +} + bool drb_is_active(gNB_RRC_UE_t *ue, uint8_t drb_id) { drb_t *drb = get_drb(ue, drb_id); diff --git a/openair2/RRC/NR/rrc_gNB_radio_bearers.h b/openair2/RRC/NR/rrc_gNB_radio_bearers.h index 82502d8669..29fead6bea 100644 --- a/openair2/RRC/NR/rrc_gNB_radio_bearers.h +++ b/openair2/RRC/NR/rrc_gNB_radio_bearers.h @@ -61,6 +61,9 @@ drb_t *generateDRB(gNB_RRC_UE_t *ue, /// @brief return the next available (inactive) DRB ID of UE ue uint8_t get_next_available_drb_id(gNB_RRC_UE_t *ue); +/// @brief returns the number of active DRBs for this UE +int get_number_active_drbs(gNB_RRC_UE_t *ue); + /// @brief check if DRB with ID drb_id of UE ue is active bool drb_is_active(gNB_RRC_UE_t *ue, uint8_t drb_id);