RRC (refactor): extract target context application into dedicated function

Refactor handover target context application logic into a reusable
function nr_rrc_apply_target_context() that updates both F1AP
associations (secondary UE and DU association) and RNTI from the
target handover context.

And apply to rrc_CU_process_ue_context_modification_response()
This commit is contained in:
Guido Casati
2025-12-29 13:31:22 +01:00
parent a2625163e6
commit b0d8c1f3b6
3 changed files with 31 additions and 9 deletions
+1 -9
View File
@@ -2579,17 +2579,9 @@ static void rrc_CU_process_ue_context_modification_response(MessageDef *msg_p, i
// nothing is to be done, we wait for confirmation to release the UE in the
// CU/DU)
if (UE->ho_context && UE->ho_context->target && UE->ho_context->source) {
nr_ho_target_cu_t *target_ctx = UE->ho_context->target;
f1_ue_data_t ue_data = cu_get_f1_ue_data(UE->rrc_ue_id);
ue_data.secondary_ue = target_ctx->du_ue_id;
ue_data.du_assoc_id = target_ctx->du->assoc_id;
bool success = cu_update_f1_ue_data(UE->rrc_ue_id, &ue_data);
DevAssert(success);
LOG_I(NR_RRC, "UE %d handover: update RNTI from %04x to %04x\n", UE->rrc_ue_id, UE->rnti, target_ctx->new_rnti);
nr_ho_source_cu_t *source_ctx = UE->ho_context->source;
DevAssert(source_ctx->old_rnti == UE->rnti);
UE->rnti = target_ctx->new_rnti;
UE->nr_cellid = target_ctx->du->setup_req->cell[0].info.nr_cellid;
nr_rrc_apply_target_context(UE);
}
}
+28
View File
@@ -63,6 +63,34 @@ static void free_ho_ctx(nr_handover_context_t *ho_ctx)
free(ho_ctx);
}
/** @brief Apply target handover context: update F1AP associations and RNTI */
void nr_rrc_apply_target_context(gNB_RRC_UE_t *UE)
{
DevAssert(UE->ho_context);
DevAssert(UE->ho_context->target);
nr_ho_target_cu_t *target_ctx = UE->ho_context->target;
f1_ue_data_t ue_data = cu_get_f1_ue_data(UE->rrc_ue_id);
LOG_I(NR_RRC,
"UE %d: update CU F1AP Context DU UE ID %u => %u and RNTI %04x => %04x\n",
UE->rrc_ue_id,
ue_data.secondary_ue,
target_ctx->du_ue_id,
UE->rnti,
target_ctx->new_rnti);
/* update F1 data: secondary UE association and DU association */
ue_data.secondary_ue = target_ctx->du_ue_id;
ue_data.du_assoc_id = target_ctx->du->assoc_id;
bool success = cu_update_f1_ue_data(UE->rrc_ue_id, &ue_data);
DevAssert(success);
/* update UE RNTI */
UE->rnti = target_ctx->new_rnti;
/* update UE NR cell ID */
UE->nr_cellid = target_ctx->du->setup_req->cell[0].info.nr_cellid;
}
/** @brief Fill DRB to Be Setup List in F1 UE Context Setup Request (optional list)
* @return 0 if list is empty, list size otherwise */
static int fill_drb_to_be_setup(const gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue, f1ap_drb_to_setup_t drbs[MAX_DRBS_PER_UE])
+2
View File
@@ -110,4 +110,6 @@ void nr_rrc_trigger_n2_ho_target(gNB_RRC_INST *rrc, gNB_RRC_UE_t *ue);
byte_array_t *get_meas_timing_config(const NR_MeasurementTimingConfiguration_t *mtc, const NR_MeasConfig_t *measConfig);
void nr_rrc_apply_target_context(gNB_RRC_UE_t *UE);
#endif /* RRC_GNB_MOBILITY_H_ */