From f709ee815be52ed3f1adb504b56899e3a341937e Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 20 Jul 2023 17:49:42 +0200 Subject: [PATCH] Move physCellId to MAC The PCI is given to the CU from the DU in the F1 Setup Request message. It is a part of the DU, so move it "down". --- openair2/GNB_APP/gnb_config.c | 3 +-- openair2/RRC/NR/MESSAGES/asn1_msg.c | 11 +++------- openair2/RRC/NR/MESSAGES/asn1_msg.h | 7 ++----- openair2/RRC/NR/nr_rrc_defs.h | 2 -- openair2/RRC/NR/rrc_gNB.c | 31 ++++++++++++++++------------- 5 files changed, 23 insertions(+), 31 deletions(-) diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index e996f70c48..30e9404c76 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -1317,7 +1317,6 @@ void RCconfig_NRRRC(gNB_RRC_INST *rrc) rrc->nr_cellid = (uint64_t)*(GNBParamList.paramarray[i][GNB_NRCELLID_IDX].u64ptr); - rrc->carrier.physCellId = *scc->physCellId; rrc->um_on_default_drb = *(GNBParamList.paramarray[i][GNB_UMONDEFAULTDRB_IDX].uptr); if (strcmp(*(GNBParamList.paramarray[i][GNB_TRANSPORT_S_PREFERENCE_IDX].strptr), "local_mac") == 0) { @@ -2081,7 +2080,7 @@ int gNB_app_handle_f1ap_gnb_cu_configuration_update(f1ap_gnb_cu_configuration_up if (RC.nrrrc[i]->nr_cellid == gnb_cu_cfg_update->cells_to_activate[j].nr_cellid && check_plmn_identity(&setup_req->cell[0].info.plmn, &gnb_cu_cfg_update->cells_to_activate[j].plmn) > 0 - && gnb_cu_cfg_update->cells_to_activate[j].nrpci == carrier->physCellId) { + && setup_req->cell[0].info.nr_pci == gnb_cu_cfg_update->cells_to_activate[j].nrpci) { // copy system information and decode it AssertFatal(gnb_cu_cfg_update->cells_to_activate[j].num_SI == 0, "gNB-CU Configuration Update: handling of additional SIs not implemend\n"); diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 33ceceff28..2ea998dd65 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1060,14 +1060,11 @@ uint8_t do_RRCReestablishmentRequest(uint8_t Mod_id, uint8_t *buffer, uint16_t c //------------------------------------------------------------------------------ int do_RRCReestablishment(rrc_gNB_ue_context_t *const ue_context_pP, - int CC_id, uint8_t *const buffer, size_t buffer_size, const uint8_t Transaction_id, - NR_SRB_ToAddModList_t *SRB_configList, - const uint8_t *masterCellGroup_from_DU, - NR_ServingCellConfigCommon_t *scc, - rrc_gNB_carrier_data_t *carrier) + uint16_t pci, + NR_ServingCellConfigCommon_t *scc) { asn_enc_rval_t enc_rval; NR_DL_DCCH_Message_t dl_dcch_msg = {0}; @@ -1084,8 +1081,6 @@ int do_RRCReestablishment(rrc_gNB_ue_context_t *const ue_context_pP, rrcReestablishment->criticalExtensions.present = NR_RRCReestablishment__criticalExtensions_PR_rrcReestablishment; rrcReestablishment->criticalExtensions.choice.rrcReestablishment = CALLOC(1, sizeof(NR_RRCReestablishment_IEs_t)); - int module_id = 0; - uint16_t pci = RC.nrrrc[module_id]->carrier.physCellId; uint32_t nr_arfcn_dl = (uint64_t)*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB; LOG_I(NR_RRC, "Reestablishment update key pci=%d, earfcn_dl=%u\n", pci, nr_arfcn_dl); @@ -1107,7 +1102,7 @@ int do_RRCReestablishment(rrc_gNB_ue_context_t *const ue_context_pP, xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&dl_dcch_msg); } - enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_DCCH_Message, NULL, (void *)&dl_dcch_msg, buffer, 100); + enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_DCCH_Message, NULL, (void *)&dl_dcch_msg, buffer, buffer_size); AssertFatal(enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index d2f61acd10..1ae0c905b8 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -152,14 +152,11 @@ uint8_t do_NR_ULInformationTransfer(uint8_t **buffer, uint8_t do_RRCReestablishmentRequest(uint8_t Mod_id, uint8_t *buffer, uint16_t c_rnti); int do_RRCReestablishment(rrc_gNB_ue_context_t *const ue_context_pP, - int CC_id, uint8_t *const buffer, size_t buffer_size, const uint8_t Transaction_id, - NR_SRB_ToAddModList_t *SRB_configList, - const uint8_t *masterCellGroup_from_DU, - NR_ServingCellConfigCommon_t *scc, - rrc_gNB_carrier_data_t *carrier); + uint16_t pci, + NR_ServingCellConfigCommon_t *scc); int do_RRCReestablishmentComplete(uint8_t *buffer, size_t buffer_size, int64_t rrc_TransactionIdentifier); diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index ae9a08ef73..637c43bd4a 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -331,8 +331,6 @@ typedef struct { uint8_t *SIB23; uint8_t sizeof_SIB23; - long physCellId; - NR_BCCH_BCH_Message_t *mib; NR_SIB1_t *siblock1_DU; NR_SIB1_t *sib1; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index a181c3ed46..35c4dc4d68 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1024,19 +1024,16 @@ static void rrc_gNB_generate_RRCReestablishment(rrc_gNB_ue_context_t *ue_context int enable_ciphering = 0; gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; + /* look up corresponding DU. For the moment, there is only one */ + const nr_rrc_du_container_t *du = rrc->du; + AssertFatal(du != NULL, "received CCCH message, but no corresponding DU found\n"); + const f1ap_served_cell_info_t *cell_info = &du->setup_req->cell[0].info; + uint8_t buffer[RRC_BUF_SIZE] = {0}; uint8_t xid = rrc_gNB_get_next_transaction_identifier(module_id); ue_p->xids[xid] = RRC_REESTABLISH; NR_SRB_ToAddModList_t *SRBs = createSRBlist(ue_p, true); - int size = do_RRCReestablishment(ue_context_pP, - 0 /* CC_id */, - buffer, - RRC_BUF_SIZE, - xid, - SRBs, - masterCellGroup_from_DU, - scc, - &rrc->carrier); + int size = do_RRCReestablishment(ue_context_pP, buffer, RRC_BUF_SIZE, xid, cell_info->nr_pci, scc); LOG_I(NR_RRC, "[RAPROC] UE %04x Logical Channel DL-DCCH, Generating NR_RRCReestablishment (bytes %d)\n", ue_p->rnti, size); @@ -1234,6 +1231,10 @@ static int nr_rrc_gNB_decode_ccch(module_id_t module_id, const f1ap_initial_ul_r NR_RRCReestablishmentRequest_IEs_t rrcReestablishmentRequest; rnti_t rnti = msg->crnti; + /* look up corresponding DU. For the moment, there is only one */ + const nr_rrc_du_container_t *du = gnb_rrc_inst->du; + AssertFatal(du != NULL, "received CCCH message, but no corresponding DU found\n"); + LOG_I(NR_RRC, "Decoding CCCH: RNTI %04x, payload_size %d\n", rnti, msg->rrc_container_length); dec_rval = uper_decode(NULL, &asn_DEF_NR_UL_CCCH_Message, (void **)&ul_ccch_msg, msg->rrc_container, msg->rrc_container_length, 0, 0); @@ -1349,12 +1350,16 @@ static int nr_rrc_gNB_decode_ccch(module_id_t module_id, const f1ap_initial_ul_r cause == NR_ReestablishmentCause_otherFailure ? "Other Failure" : (cause == NR_ReestablishmentCause_handoverFailure ? "Handover Failure" : "reconfigurationFailure")); - if (physCellId != gnb_rrc_inst->carrier.physCellId) { + + uint8_t xid = -1; + AssertFatal(du->setup_req->num_cells_available == 1, "cannot handle more than one cell\n"); + const f1ap_served_cell_info_t *cell_info = &du->setup_req->cell[0].info; + if (physCellId != cell_info->nr_pci) { /* UE was moving from previous cell so quickly that RRCReestablishment for previous cell was received in this cell */ LOG_E(NR_RRC, - " NR_RRCReestablishmentRequest ue_Identity.physCellId(%ld) is not equal to current physCellId(%ld), fallback to RRC establishment\n", + " NR_RRCReestablishmentRequest ue_Identity.physCellId(%ld) is not equal to current physCellId(%d), fallback to RRC establishment\n", physCellId, - gnb_rrc_inst->carrier.physCellId); + cell_info->nr_pci); /* 38.401 8.7: "If the UE accessed from a gNB-DU other than the * original one, the gNB-CU should trigger the UE Context Setup * procedure" we did not implement this yet; TBD for Multi-DU */ @@ -1908,8 +1913,6 @@ static void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *req) AssertFatal(rrc->du->setup_req != NULL, "out of memory\n"); *rrc->du->setup_req = *req; - rrc->carrier.physCellId = cell_info->nr_pci; - if (rrc->carrier.mib != NULL) { LOG_E(NR_RRC, "CU MIB is already initialized: double F1 setup request?\n"); } else {