From 2b2953159159bfa7cb1b00f7496d1b956644d229 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 19 Jul 2023 19:16:29 +0200 Subject: [PATCH] Move ServingCellConfigCommon to MAC Note: the reestablishment is broken, and a later commit fixes it. The ServingCellConfigCommon is an inherently radio-related configuration. As such, it should be handled by the DU, not the CU. Therefore, move it "down" to the MAC. --- openair1/SIMULATION/NR_PHY/dlsim.c | 16 +- openair1/SIMULATION/NR_PHY/ulsim.c | 14 +- openair2/COMMON/rrc_messages_types.h | 1 - openair2/GNB_APP/gnb_config.c | 18 +-- openair2/LAYER2/NR_MAC_gNB/config.c | 7 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 3 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 5 +- openair2/LAYER2/NR_MAC_gNB/main.c | 6 +- openair2/RRC/NR/MESSAGES/asn1_msg.c | 35 ++--- openair2/RRC/NR/MESSAGES/asn1_msg.h | 36 +++-- openair2/RRC/NR/nr_rrc_config.c | 63 ++++---- openair2/RRC/NR/nr_rrc_config.h | 5 +- openair2/RRC/NR/nr_rrc_defs.h | 1 - openair2/RRC/NR/rrc_gNB.c | 142 +++++++++++------- openair2/RRC/NR/rrc_gNB_nsa.c | 9 +- 15 files changed, 201 insertions(+), 160 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index b42edf31e0..b90ccc835c 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -622,11 +622,17 @@ int main(int argc, char **argv) frame_parms->N_RB_DL = N_RB_DL; frame_parms->N_RB_UL = N_RB_DL; + NR_ServingCellConfigCommon_t *scc = calloc(1,sizeof(*scc));; + prepare_scc(scc); + uint64_t ssb_bitmap = 1; // Enable only first SSB with index ssb_indx=0 + fill_scc_sim(scc, &ssb_bitmap, N_RB_DL, N_RB_DL, mu, mu); + fix_scc(scc, ssb_bitmap); + RC.nb_nr_macrlc_inst = 1; RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int)); for (i = 0; i < RC.nb_nr_macrlc_inst; i++) RC.nb_nr_mac_CC[i] = 1; - mac_top_init_gNB(ngran_gNB); + mac_top_init_gNB(ngran_gNB, scc); gNB_mac = RC.nrmac[0]; gNB_mac->dl_bler.harq_round_max = num_rounds; @@ -673,12 +679,6 @@ int main(int argc, char **argv) NR_ServingCellConfigCommon_t *scc = secondaryCellGroup->spCellConfig->reconfigurationWithSync->spCellConfigCommon; */ - NR_ServingCellConfigCommon_t *scc = calloc(1,sizeof(*scc));; - prepare_scc(scc); - uint64_t ssb_bitmap = 1; // Enable only first SSB with index ssb_indx=0 - fill_scc_sim(scc, &ssb_bitmap, N_RB_DL, N_RB_DL, mu, mu); - fix_scc(scc, ssb_bitmap); - NR_ServingCellConfig_t *scd = calloc(1,sizeof(*scd)); prepare_scd(scd); @@ -723,7 +723,7 @@ int main(int argc, char **argv) gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; // common configuration - nr_mac_config_scc(RC.nrmac[0], pdsch_AntennaPorts, n_tx, 0, 6, scc); + nr_mac_config_scc(RC.nrmac[0], pdsch_AntennaPorts, n_tx, 0, 6); // UE dedicated configuration nr_mac_add_test_ue(RC.nrmac[0], secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity, secondaryCellGroup); // reset preprocessor to the one of DLSIM after it has been set during diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index f307884d45..8f2eb42d63 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -613,18 +613,18 @@ int main(int argc, char *argv[]) r_re = malloc(n_rx*sizeof(double*)); r_im = malloc(n_rx*sizeof(double*)); - RC.nb_nr_macrlc_inst = 1; - RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int)); - for (i = 0; i < RC.nb_nr_macrlc_inst; i++) - RC.nb_nr_mac_CC[i] = 1; - mac_top_init_gNB(ngran_gNB); - NR_ServingCellConfigCommon_t *scc = calloc(1,sizeof(*scc));; prepare_scc(scc); uint64_t ssb_bitmap; fill_scc_sim(scc, &ssb_bitmap, N_RB_DL, N_RB_DL, mu, mu); fix_scc(scc,ssb_bitmap); + RC.nb_nr_macrlc_inst = 1; + RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int)); + for (i = 0; i < RC.nb_nr_macrlc_inst; i++) + RC.nb_nr_mac_CC[i] = 1; + mac_top_init_gNB(ngran_gNB, scc); + NR_ServingCellConfig_t *scd = calloc(1,sizeof(NR_ServingCellConfig_t)); prepare_scd(scd); @@ -651,7 +651,7 @@ int main(int argc, char *argv[]) gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; // common configuration - nr_mac_config_scc(RC.nrmac[0], conf.pdsch_AntennaPorts, n_tx, 0, 6, scc); + nr_mac_config_scc(RC.nrmac[0], conf.pdsch_AntennaPorts, n_tx, 0, 6); nr_mac_config_mib(RC.nrmac[0], mib); // UE dedicated configuration nr_mac_add_test_ue(RC.nrmac[0], secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity, secondaryCellGroup); diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index ef44b31e69..1781eb5d18 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -415,7 +415,6 @@ typedef struct NRRrcConfigurationReq_s { uint16_t mnc[PLMN_LIST_MAX_SIZE]; uint8_t mnc_digit_length[PLMN_LIST_MAX_SIZE]; uint8_t num_plmn; - NR_ServingCellConfigCommon_t *scc; NR_ServingCellConfig_t *scd; int sib1_tda; rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts; diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 30e9404c76..e237114459 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -947,6 +947,8 @@ static NR_ServingCellConfig_t *get_scd_config(void) return scd; } +// temporary minRXTXTIME, to be taken out once all radio config is read at DU +static int minRXTXTIME = 6; void RCconfig_nr_macrlc() { int j = 0; uint16_t prbbl[275] = {0}; @@ -983,10 +985,13 @@ void RCconfig_nr_macrlc() { MacRLC_Params[i].chkPptr = &(config_check_MacRLCParams[i]); config_getlist(&MacRLC_ParamList, MacRLC_Params, sizeof(MacRLC_Params) / sizeof(paramdef_t), NULL); + NR_ServingCellConfigCommon_t *scc = get_scc_config(minRXTXTIME); + //xer_fprint(stdout, &asn_DEF_NR_ServingCellConfigCommon, scc); + if (MacRLC_ParamList.numelt > 0) { RC.nb_nr_macrlc_inst = MacRLC_ParamList.numelt; ngran_node_t node_type = get_node_type(); - mac_top_init_gNB(node_type); + mac_top_init_gNB(node_type, scc); RC.nb_nr_mac_CC = (int *)malloc(RC.nb_nr_macrlc_inst * sizeof(int)); for (j = 0; j < RC.nb_nr_macrlc_inst; j++) { @@ -1256,10 +1261,6 @@ void RCconfig_NRRRC(gNB_RRC_INST *rrc) paramdef_t GNBParams[] = GNBPARAMS_DESC; paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST,NULL,0}; - int minRXTXTIME = 6; - NR_ServingCellConfigCommon_t *scc = get_scc_config(minRXTXTIME); - //xer_fprint(stdout, &asn_DEF_NR_ServingCellConfigCommon, scc); - NR_ServingCellConfig_t *scd = get_scd_config(); ////////// Physical parameters @@ -1399,7 +1400,6 @@ void RCconfig_NRRRC(gNB_RRC_INST *rrc) nrrrc_config.do_SRS = *GNBParamList.paramarray[i][GNB_DO_SRS_IDX].iptr; nrrrc_config.force_256qam_off = *GNBParamList.paramarray[i][GNB_FORCE256QAMOFF_IDX].iptr; LOG_I(GNB_APP, "256 QAM: %s\n", nrrrc_config.force_256qam_off ? "force off" : "may be on"); - nrrrc_config.scc = scc; nrrrc_config.scd = scd; nrrrc_config.enable_sdap = *GNBParamList.paramarray[i][GNB_ENABLE_SDAP_IDX].iptr; LOG_I(GNB_APP, "SDAP layer is %s\n", nrrrc_config.enable_sdap ? "enabled" : "disabled"); @@ -1966,8 +1966,7 @@ int RC_config_trigger_F1Setup() gNB_RRC_INST *rrc = RC.nrrrc[0]; DevAssert(rrc); - // wait until RRC cell information is configured - const NR_ServingCellConfigCommon_t *scc = rrc->configuration.scc; + const NR_ServingCellConfigCommon_t *scc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon; DevAssert(scc != NULL); req->cell[0].info.nr_pci = *scc->physCellId; LOG_W(GNB_APP, "no slices transported via F1 Setup Request!\n"); @@ -2074,11 +2073,10 @@ int gNB_app_handle_f1ap_gnb_cu_configuration_update(f1ap_gnb_cu_configuration_up NR_SCHED_LOCK(&mac->sched_lock); for (j = 0; j < gnb_cu_cfg_update->num_cells_to_activate; j++) { for (i = 0; i < RC.nb_nr_inst; i++) { - rrc_gNB_carrier_data_t *carrier = &RC.nrrrc[i]->carrier; f1ap_setup_req_t *setup_req = RC.nrmac[i]->f1_config.setup_req; // identify local index of cell j by nr_cellid, plmn identity and physical cell ID - if (RC.nrrrc[i]->nr_cellid == gnb_cu_cfg_update->cells_to_activate[j].nr_cellid + if (setup_req->cell[0].info.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 && setup_req->cell[0].info.nr_pci == gnb_cu_cfg_update->cells_to_activate[j].nrpci) { // copy system information and decode it diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 853770887e..c7371a3ef4 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -471,13 +471,14 @@ void nr_mac_config_scc(gNB_MAC_INST *nrmac, rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts, int pusch_AntennaPorts, int sib1_tda, - int minRXTXTIMEpdsch, - NR_ServingCellConfigCommon_t *scc) + int minRXTXTIMEpdsch) { + int CC_id = 0; DevAssert(nrmac != NULL); - AssertFatal(nrmac->common_channels[0].ServingCellConfigCommon == NULL, "logic error: multiple configurations of SCC\n"); + AssertFatal(nrmac->common_channels[0].ServingCellConfigCommon != NULL, "logic error: SCC not in MAC\n"); NR_SCHED_LOCK(&nrmac->sched_lock); + NR_ServingCellConfigCommon_t *scc = nrmac->common_channels[CC_id].ServingCellConfigCommon; DevAssert(scc != NULL); AssertFatal(scc->ssb_PositionsInBurst->present > 0 && scc->ssb_PositionsInBurst->present < 4, "SSB Bitmap type %d is not valid\n", diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index f475ed385a..0bbe82ef3a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2887,8 +2887,9 @@ void prepare_initial_ul_rrc_message(gNB_MAC_INST *mac, NR_UE_info_t *UE) /* Note: relying on the RRC is a hack, as we are in the DU; there should be * no RRC, remove in the future */ module_id_t mod_id = 0; + int CC_id = 0; gNB_RRC_INST *rrc = RC.nrrrc[mod_id]; - const NR_ServingCellConfigCommon_t *scc = rrc->carrier.servingcellconfigcommon; + const NR_ServingCellConfigCommon_t *scc = mac->common_channels[CC_id].ServingCellConfigCommon; const NR_ServingCellConfig_t *sccd = rrc->configuration.scd; NR_CellGroupConfig_t *cellGroupConfig = get_initial_cellGroupConfig(UE->uid, scc, sccd, &rrc->configuration); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 15d823aaf2..c12fa69eb0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -38,7 +38,7 @@ void set_cset_offset(uint16_t); -void mac_top_init_gNB(ngran_node_t node_type); +void mac_top_init_gNB(ngran_node_t node_type, NR_ServingCellConfigCommon_t *scc); int nr_mac_enable_ue_rrc_processing_timer(module_id_t Mod_idP, rnti_t rnti, @@ -49,8 +49,7 @@ void nr_mac_config_scc(gNB_MAC_INST *nrmac, rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts, int pusch_AntennaPorts, int sib1_tda, - int minRXTXTIMEpdsch, - NR_ServingCellConfigCommon_t *scc); + int minRXTXTIMEpdsch); void nr_mac_config_mib(gNB_MAC_INST *nrmac, NR_BCCH_BCH_Message_t *mib); void nr_mac_config_sib1(gNB_MAC_INST *nrmac, NR_BCCH_DL_SCH_Message_t *sib1); bool nr_mac_add_test_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup); diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 7fd559fdcd..a7f8de1d8f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -205,11 +205,13 @@ static void mac_rrc_init(gNB_MAC_INST *mac, ngran_node_t node_type) } } -void mac_top_init_gNB(ngran_node_t node_type) +void mac_top_init_gNB(ngran_node_t node_type, NR_ServingCellConfigCommon_t *scc) { module_id_t i; gNB_MAC_INST *nrmac; + AssertFatal(RC.nb_nr_macrlc_inst == 1, "what is the point of calling %s() if you don't need exactly one MAC?\n", __func__); + LOG_I(MAC, "[MAIN] Init function start:nb_nr_macrlc_inst=%d\n",RC.nb_nr_macrlc_inst); if (RC.nb_nr_macrlc_inst > 0) { @@ -239,6 +241,8 @@ void mac_top_init_gNB(ngran_node_t node_type) RC.nrmac[i]->ul_handle = 0; + RC.nrmac[i]->common_channels[0].ServingCellConfigCommon = scc; + RC.nrmac[i]->first_MIB = true; RC.nrmac[i]->cset0_bwp_start = 0; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 2ea998dd65..3768782b06 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -689,9 +689,8 @@ int16_t do_RRCReconfiguration( NR_MeasConfig_t *meas_config, struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *dedicatedNAS_MessageList, rrc_gNB_ue_context_t *const ue_context_pP, - rrc_gNB_carrier_data_t *carrier, const gNB_RrcConfigurationReq *configuration, - NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, + const NR_ServingCellConfigCommon_t *scc, NR_CellGroupConfig_t *cellGroupConfig) //------------------------------------------------------------------------------ { @@ -742,7 +741,17 @@ int16_t do_RRCReconfiguration( } if(cellGroupConfig!=NULL){ - update_cellGroupConfig(cellGroupConfig, ue_context_pP->ue_context.rrc_ue_id, ue_context_pP ? ue_context_pP->ue_context.UE_Capability_nr : NULL, configuration); + /* TODO UECAP: update_cellGroupConfig should not even be here, it is + * updated by DU */ + if (scc != NULL) { + update_cellGroupConfig(cellGroupConfig, + ue_context_pP->ue_context.rrc_ue_id, + ue_context_pP ? ue_context_pP->ue_context.UE_Capability_nr : NULL, + configuration, + scc); + } else { + LOG_W(RRC, "no scc, cannot update cellGroup\n"); + } enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, @@ -1064,7 +1073,7 @@ int do_RRCReestablishment(rrc_gNB_ue_context_t *const ue_context_pP, size_t buffer_size, const uint8_t Transaction_id, uint16_t pci, - NR_ServingCellConfigCommon_t *scc) + NR_ARFCN_ValueNR_t absoluteFrequencySSB) { asn_enc_rval_t enc_rval; NR_DL_DCCH_Message_t dl_dcch_msg = {0}; @@ -1081,15 +1090,14 @@ 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)); - 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); + LOG_I(NR_RRC, "Reestablishment update key pci=%d, earfcn_dl=%lu\n", pci, absoluteFrequencySSB); // 3GPP TS 33.501 Section 6.11 Security handling for RRC connection re-establishment procedure if (ue_context_pP->ue_context.nh_ncc >= 0) { - nr_derive_key_ng_ran_star(pci, nr_arfcn_dl, ue_context_pP->ue_context.nh, ue_context_pP->ue_context.kgnb); + nr_derive_key_ng_ran_star(pci, absoluteFrequencySSB, ue_context_pP->ue_context.nh, ue_context_pP->ue_context.kgnb); rrcReestablishment->criticalExtensions.choice.rrcReestablishment->nextHopChainingCount = ue_context_pP->ue_context.nh_ncc; } else { // first HO - nr_derive_key_ng_ran_star(pci, nr_arfcn_dl, ue_context_pP->ue_context.kgnb, ue_context_pP->ue_context.kgnb); + nr_derive_key_ng_ran_star(pci, absoluteFrequencySSB, ue_context_pP->ue_context.kgnb, ue_context_pP->ue_context.kgnb); // LG: really 1 rrcReestablishment->criticalExtensions.choice.rrcReestablishment->nextHopChainingCount = 0; } @@ -1144,15 +1152,8 @@ int do_RRCReestablishmentComplete(uint8_t *buffer, size_t buffer_size, int64_t r return((enc_rval.encoded+7)/8); } -NR_MeasConfig_t *get_defaultMeasConfig(const gNB_RrcConfigurationReq *conf) +NR_MeasConfig_t *get_defaultMeasConfig(int arfcn, int band, int scs) { - const NR_FrequencyInfoDL_t *freqInfoDL = conf->scc->downlinkConfigCommon->frequencyInfoDL; - const NR_ARFCN_ValueNR_t absFreqSSB = *freqInfoDL->absoluteFrequencySSB; - DevAssert(freqInfoDL->scs_SpecificCarrierList.list.count == 1); - const NR_SubcarrierSpacing_t scs = freqInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; - DevAssert(freqInfoDL->frequencyBandList.list.count == 1); - const NR_FreqBandIndicatorNR_t band = *freqInfoDL->frequencyBandList.list.array[0]; - NR_MeasConfig_t *mc = calloc(1, sizeof(*mc)); mc->measObjectToAddModList = calloc(1, sizeof(*mc->measObjectToAddModList)); mc->reportConfigToAddModList = calloc(1, sizeof(*mc->reportConfigToAddModList)); @@ -1163,7 +1164,7 @@ NR_MeasConfig_t *get_defaultMeasConfig(const gNB_RrcConfigurationReq *conf) mo1->measObjectId = 1; mo1->measObject.present = NR_MeasObjectToAddMod__measObject_PR_measObjectNR; NR_MeasObjectNR_t *monr1 = calloc(1, sizeof(*monr1)); - asn1cCallocOne(monr1->ssbFrequency, absFreqSSB); + asn1cCallocOne(monr1->ssbFrequency, arfcn); asn1cCallocOne(monr1->ssbSubcarrierSpacing, scs); monr1->referenceSignalConfig.ssb_ConfigMobility = calloc(1, sizeof(*monr1->referenceSignalConfig.ssb_ConfigMobility)); monr1->referenceSignalConfig.ssb_ConfigMobility->deriveSSB_IndexFromCell = true; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index 1ae0c905b8..d041c39a7c 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -99,23 +99,21 @@ uint8_t do_NR_SA_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, int do_NR_RRCRelease(uint8_t *buffer, size_t buffer_size, uint8_t Transaction_id); -int16_t do_RRCReconfiguration( - const protocol_ctxt_t *const ctxt_pP, - uint8_t *buffer, - size_t buffer_size, - uint8_t Transaction_id, - NR_SRB_ToAddModList_t *SRB_configList, - NR_DRB_ToAddModList_t *DRB_configList, - NR_DRB_ToReleaseList_t *DRB_releaseList, - NR_SecurityConfig_t *security_config, - NR_SDAP_Config_t *sdap_config, - NR_MeasConfig_t *meas_config, - struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *dedicatedNAS_MessageList, - rrc_gNB_ue_context_t *const ue_context_pP, - rrc_gNB_carrier_data_t *carrier, - const gNB_RrcConfigurationReq *configuration, - NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, - NR_CellGroupConfig_t *cellGroupConfig); +int16_t do_RRCReconfiguration(const protocol_ctxt_t *const ctxt_pP, + uint8_t *buffer, + size_t buffer_size, + uint8_t Transaction_id, + NR_SRB_ToAddModList_t *SRB_configList, + NR_DRB_ToAddModList_t *DRB_configList, + NR_DRB_ToReleaseList_t *DRB_releaseList, + NR_SecurityConfig_t *security_config, + NR_SDAP_Config_t *sdap_config, + NR_MeasConfig_t *meas_config, + struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *dedicatedNAS_MessageList, + rrc_gNB_ue_context_t *const ue_context_pP, + const gNB_RrcConfigurationReq *configuration, + const NR_ServingCellConfigCommon_t *scc, + NR_CellGroupConfig_t *cellGroupConfig); uint8_t do_RRCSetupComplete(uint8_t Mod_id, uint8_t *buffer, @@ -156,11 +154,11 @@ int do_RRCReestablishment(rrc_gNB_ue_context_t *const ue_context_pP, size_t buffer_size, const uint8_t Transaction_id, uint16_t pci, - NR_ServingCellConfigCommon_t *scc); + NR_ARFCN_ValueNR_t absoluteFrequencySSB); int do_RRCReestablishmentComplete(uint8_t *buffer, size_t buffer_size, int64_t rrc_TransactionIdentifier); -NR_MeasConfig_t *get_defaultMeasConfig(const gNB_RrcConfigurationReq *conf); +NR_MeasConfig_t *get_defaultMeasConfig(int absFreqSSB, int band, int scs); uint8_t do_NR_Paging(uint8_t Mod_id, uint8_t *buffer, uint32_t tmsi); #endif /* __RRC_NR_MESSAGES_ASN1_MSG__H__ */ diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index 5418f5dc9f..4d4ea4f860 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -1712,7 +1712,7 @@ int encode_MIB_NR(NR_BCCH_BCH_Message_t *mib, int frame, uint8_t *buf, int buf_s return (enc_rval.encoded + 7) / 8; } -NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const gNB_RrcConfigurationReq *configuration) +NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const gNB_RrcConfigurationReq *configuration, const NR_ServingCellConfigCommon_t *scc) { NR_BCCH_DL_SCH_Message_t *sib1_message = CALLOC(1,sizeof(NR_BCCH_DL_SCH_Message_t)); AssertFatal(sib1_message != NULL, "out of memory\n"); @@ -1812,9 +1812,9 @@ NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const gNB_RrcConfigurationReq *configurati // servingCellConfigCommon asn1cCalloc(sib1->servingCellConfigCommon, ServCellCom); NR_BWP_DownlinkCommon_t *initialDownlinkBWP = &ServCellCom->downlinkConfigCommon.initialDownlinkBWP; - initialDownlinkBWP->genericParameters = configuration->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + initialDownlinkBWP->genericParameters = scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; - const NR_FrequencyInfoDL_t *frequencyInfoDL = configuration->scc->downlinkConfigCommon->frequencyInfoDL; + const NR_FrequencyInfoDL_t *frequencyInfoDL = scc->downlinkConfigCommon->frequencyInfoDL; for (int i = 0; i < frequencyInfoDL->frequencyBandList.list.count; i++) { asn1cSequenceAdd(ServCellCom->downlinkConfigCommon.frequencyInfoDL.frequencyBandList.list, struct NR_NR_MultiBandInfo, @@ -1823,11 +1823,11 @@ NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const gNB_RrcConfigurationReq *configurati frequencyInfoDL->frequencyBandList.list.array[i]; } - const NR_FreqBandIndicatorNR_t band = *configuration->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; + const NR_FreqBandIndicatorNR_t band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; frequency_range_t frequency_range = band < 100 ? FR1 : FR2; - sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.offsetToPointA = get_ssb_offset_to_pointA(*configuration->scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB, - configuration->scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA, - configuration->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing, + sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.offsetToPointA = get_ssb_offset_to_pointA(*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB, + scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA, + scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing, frequency_range); LOG_I(NR_RRC, @@ -1839,7 +1839,7 @@ NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const gNB_RrcConfigurationReq *configurati frequencyInfoDL->scs_SpecificCarrierList.list.array[i]); } - initialDownlinkBWP->pdcch_ConfigCommon = configuration->scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon; + initialDownlinkBWP->pdcch_ConfigCommon = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon; initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList = CALLOC(1, sizeof(struct NR_PDCCH_ConfigCommon__commonSearchSpaceList)); AssertFatal(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList != NULL, "out of memory\n"); @@ -1858,7 +1858,7 @@ NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const gNB_RrcConfigurationReq *configurati asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->pagingSearchSpace, 2); asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace, 1); - initialDownlinkBWP->pdsch_ConfigCommon = configuration->scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon; + initialDownlinkBWP->pdsch_ConfigCommon = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon; ServCellCom->downlinkConfigCommon.bcch_Config.modificationPeriodCoeff = NR_BCCH_Config__modificationPeriodCoeff_n2; ServCellCom->downlinkConfigCommon.pcch_Config.defaultPagingCycle = NR_PagingCycle_rf256; ServCellCom->downlinkConfigCommon.pcch_Config.nAndPagingFrameOffset.present = NR_PCCH_Config__nAndPagingFrameOffset_PR_quarterT; @@ -1874,7 +1874,7 @@ NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const gNB_RrcConfigurationReq *configurati asn1cCalloc(ServCellCom->uplinkConfigCommon, UL); asn_set_empty(&UL->frequencyInfoUL.scs_SpecificCarrierList.list); - const NR_FrequencyInfoUL_t *frequencyInfoUL = configuration->scc->uplinkConfigCommon->frequencyInfoUL; + const NR_FrequencyInfoUL_t *frequencyInfoUL = scc->uplinkConfigCommon->frequencyInfoUL; for (int i = 0; i < frequencyInfoUL->scs_SpecificCarrierList.list.count; i++) { asn1cSeqAdd(&UL->frequencyInfoUL.scs_SpecificCarrierList.list, frequencyInfoUL->scs_SpecificCarrierList.list.array[i]); } @@ -1882,14 +1882,14 @@ NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const gNB_RrcConfigurationReq *configurati asn1cCallocOne(UL->frequencyInfoUL.p_Max, *frequencyInfoUL->p_Max); frame_type_t frame_type = - get_frame_type((int)*configuration->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], - *configuration->scc->ssbSubcarrierSpacing); + get_frame_type((int)*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], + *scc->ssbSubcarrierSpacing); if (frame_type == FDD) { UL->frequencyInfoUL.absoluteFrequencyPointA = malloc(sizeof(*UL->frequencyInfoUL.absoluteFrequencyPointA)); AssertFatal(UL->frequencyInfoUL.absoluteFrequencyPointA != NULL, "out of memory\n"); *UL->frequencyInfoUL.absoluteFrequencyPointA = - *configuration->scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA; + *scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA; UL->frequencyInfoUL.frequencyBandList = calloc(1, sizeof(*UL->frequencyInfoUL.frequencyBandList)); AssertFatal(UL->frequencyInfoUL.frequencyBandList != NULL, "out of memory\n"); for (int i = 0; i < frequencyInfoUL->frequencyBandList->list.count; i++) { @@ -1898,25 +1898,25 @@ NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const gNB_RrcConfigurationReq *configurati } } - UL->initialUplinkBWP.genericParameters = configuration->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; - UL->initialUplinkBWP.rach_ConfigCommon = configuration->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon; - UL->initialUplinkBWP.pusch_ConfigCommon = configuration->scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon; + UL->initialUplinkBWP.genericParameters = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + UL->initialUplinkBWP.rach_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon; + UL->initialUplinkBWP.pusch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon; UL->initialUplinkBWP.pusch_ConfigCommon->choice.setup->groupHoppingEnabledTransformPrecoding = NULL; - UL->initialUplinkBWP.pucch_ConfigCommon = configuration->scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon; + UL->initialUplinkBWP.pucch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon; UL->timeAlignmentTimerCommon = NR_TimeAlignmentTimer_infinity; - ServCellCom->n_TimingAdvanceOffset = configuration->scc->n_TimingAdvanceOffset; + ServCellCom->n_TimingAdvanceOffset = scc->n_TimingAdvanceOffset; ServCellCom->ssb_PositionsInBurst.inOneGroup.buf = calloc(1, sizeof(uint8_t)); uint8_t bitmap8,temp_bitmap=0; - switch (configuration->scc->ssb_PositionsInBurst->present) { + switch (scc->ssb_PositionsInBurst->present) { case NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_shortBitmap: - ServCellCom->ssb_PositionsInBurst.inOneGroup = configuration->scc->ssb_PositionsInBurst->choice.shortBitmap; + ServCellCom->ssb_PositionsInBurst.inOneGroup = scc->ssb_PositionsInBurst->choice.shortBitmap; break; case NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap: - ServCellCom->ssb_PositionsInBurst.inOneGroup = configuration->scc->ssb_PositionsInBurst->choice.mediumBitmap; + ServCellCom->ssb_PositionsInBurst.inOneGroup = scc->ssb_PositionsInBurst->choice.mediumBitmap; break; /* * groupPresence: This field is present when maximum number of SS/PBCH blocks per half frame equals to 64 as defined in @@ -1940,7 +1940,7 @@ NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const gNB_RrcConfigurationReq *configurati AssertFatal(ServCellCom->ssb_PositionsInBurst.groupPresence->buf != NULL, "out of memory\n"); ServCellCom->ssb_PositionsInBurst.groupPresence->buf[0] = 0; for (int i = 0; i < 8; i++) { - bitmap8 = configuration->scc->ssb_PositionsInBurst->choice.longBitmap.buf[i]; + bitmap8 = scc->ssb_PositionsInBurst->choice.longBitmap.buf[i]; if (bitmap8 != 0) { if (temp_bitmap == 0) temp_bitmap = bitmap8; @@ -1958,15 +1958,15 @@ NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const gNB_RrcConfigurationReq *configurati break; } - ServCellCom->ssb_PeriodicityServingCell = *configuration->scc->ssb_periodicityServingCell; - if (configuration->scc->tdd_UL_DL_ConfigurationCommon) { + ServCellCom->ssb_PeriodicityServingCell = *scc->ssb_periodicityServingCell; + if (scc->tdd_UL_DL_ConfigurationCommon) { ServCellCom->tdd_UL_DL_ConfigurationCommon = CALLOC(1,sizeof(struct NR_TDD_UL_DL_ConfigCommon)); AssertFatal(ServCellCom->tdd_UL_DL_ConfigurationCommon != NULL, "out of memory\n"); - ServCellCom->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing = configuration->scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing; - ServCellCom->tdd_UL_DL_ConfigurationCommon->pattern1 = configuration->scc->tdd_UL_DL_ConfigurationCommon->pattern1; - ServCellCom->tdd_UL_DL_ConfigurationCommon->pattern2 = configuration->scc->tdd_UL_DL_ConfigurationCommon->pattern2; + ServCellCom->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing = scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing; + ServCellCom->tdd_UL_DL_ConfigurationCommon->pattern1 = scc->tdd_UL_DL_ConfigurationCommon->pattern1; + ServCellCom->tdd_UL_DL_ConfigurationCommon->pattern2 = scc->tdd_UL_DL_ConfigurationCommon->pattern2; } - ServCellCom->ss_PBCH_BlockPower = configuration->scc->ss_PBCH_BlockPower; + ServCellCom->ss_PBCH_BlockPower = scc->ss_PBCH_BlockPower; // ims-EmergencySupport // TODO: add ims-EmergencySupport @@ -2345,7 +2345,8 @@ NR_CellGroupConfig_t *get_initial_cellGroupConfig(int uid, void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, const int uid, NR_UE_NR_Capability_t *uecap, - const gNB_RrcConfigurationReq *configuration) + const gNB_RrcConfigurationReq *configuration, + const NR_ServingCellConfigCommon_t *scc) { DevAssert(cellGroupConfig != NULL); /* this is wrong: we should not call this function is spCellConfig is not @@ -2355,7 +2356,8 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, /* same as for spCellConfig */ if (configuration == NULL) return; - DevAssert(configuration->scc != NULL); + /* if scc is not allocated, there is a serious problem */ + DevAssert(scc != NULL); /* This is a hack and will be removed once the CellGroupConfig is fully * handled at the DU */ @@ -2365,7 +2367,6 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, } NR_SpCellConfig_t *SpCellConfig = cellGroupConfig->spCellConfig; - NR_ServingCellConfigCommon_t *scc = configuration->scc; int curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); NR_UplinkConfig_t *uplinkConfig = diff --git a/openair2/RRC/NR/nr_rrc_config.h b/openair2/RRC/NR/nr_rrc_config.h index 592d14bf01..dbb97c14a8 100644 --- a/openair2/RRC/NR/nr_rrc_config.h +++ b/openair2/RRC/NR/nr_rrc_config.h @@ -53,7 +53,7 @@ int encode_MIB_NR(NR_BCCH_BCH_Message_t *mib, int frame, uint8_t *buf, int buf_s #define NR_MAX_SIB_LENGTH 2976 // 3GPP TS 38.331 section 5.2.1 -NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const gNB_RrcConfigurationReq *configuration); +NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const gNB_RrcConfigurationReq *configuration, const NR_ServingCellConfigCommon_t *scc); void free_SIB1_NR(NR_BCCH_DL_SCH_Message_t *sib1); int encode_SIB1_NR(NR_BCCH_DL_SCH_Message_t *sib1, uint8_t *buffer, int max_buffer_size); @@ -64,7 +64,8 @@ NR_CellGroupConfig_t *get_initial_cellGroupConfig(int uid, void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, const int uid, NR_UE_NR_Capability_t *uecap, - const gNB_RrcConfigurationReq *configuration); + const gNB_RrcConfigurationReq *configuration, + const NR_ServingCellConfigCommon_t *scc); void free_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig); int encode_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, uint8_t *buffer, int max_buffer_size); NR_CellGroupConfig_t *decode_cellGroupConfig(const uint8_t *buffer, int max_buffer_size); diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index 637c43bd4a..3bb5cdfccd 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -338,7 +338,6 @@ typedef struct { NR_SIB3_t *sib3; NR_BCCH_DL_SCH_Message_t systemInformation; // SIB23 NR_BCCH_DL_SCH_Message_t *siblock1; - NR_ServingCellConfigCommon_t *servingcellconfigcommon; NR_CellGroupConfig_t *secondaryCellGroup[MAX_NR_RRC_UE_CONTEXTS]; } rrc_gNB_carrier_data_t; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 35c4dc4d68..2f8fa42eae 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -210,18 +210,40 @@ void nr_rrc_transfer_protected_rrc_message(const gNB_RRC_INST *rrc, const gNB_RR nr_pdcp_data_req_srb(ue_p->rrc_ue_id, srb_id, rrc_gNB_mui++, size, (unsigned char *const)buffer, rrc_deliver_dl_rrc_message, &data); } +static int get_dl_band(const f1ap_served_cell_info_t *cell_info) +{ + return cell_info->mode == F1AP_MODE_TDD ? cell_info->tdd.freqinfo.band : cell_info->fdd.dl_freqinfo.band; +} + +static int get_ul_band(const f1ap_served_cell_info_t *cell_info) +{ + return cell_info->mode == F1AP_MODE_TDD ? cell_info->tdd.freqinfo.band : cell_info->fdd.ul_freqinfo.band; +} + +static int get_ssb_scs(const f1ap_served_cell_info_t *cell_info) +{ + return cell_info->mode == F1AP_MODE_TDD ? cell_info->tdd.tbw.scs : cell_info->fdd.dl_tbw.scs; +} + +static int get_dl_arfcn(const f1ap_served_cell_info_t *cell_info) +{ + return cell_info->mode == F1AP_MODE_TDD ? cell_info->tdd.freqinfo.arfcn : cell_info->fdd.dl_freqinfo.arfcn; +} + ///---------------------------------------------------------------------------------------------------------------/// ///---------------------------------------------------------------------------------------------------------------/// static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration) { + const NR_ServingCellConfigCommon_t *scc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon; LOG_D(RRC,"%s()\n\n\n\n",__FUNCTION__); - if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) - rrc->carrier.mib = get_new_MIB_NR(rrc->carrier.servingcellconfigcommon); + if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) { + rrc->carrier.mib = get_new_MIB_NR(scc); + } if((get_softmodem_params()->sa) && ( (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)))) { - NR_BCCH_DL_SCH_Message_t *sib1 = get_SIB1_NR(configuration); + NR_BCCH_DL_SCH_Message_t *sib1 = get_SIB1_NR(configuration, scc); //xer_fprint(stdout, &asn_DEF_NR_BCCH_DL_SCH_Message, sib1); rrc->carrier.SIB1 = calloc(NR_MAX_SIB_LENGTH / 8, sizeof(*rrc->carrier.SIB1)); AssertFatal(rrc->carrier.SIB1 != NULL, "out of memory\n"); @@ -242,12 +264,12 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration if (NODE_IS_MONOLITHIC(rrc->node_type) || NODE_IS_DU(rrc->node_type)){ // update SI info + /* 1. move this to MAC */ nr_mac_config_scc(RC.nrmac[rrc->module_id], rrc->configuration.pdsch_AntennaPorts, rrc->configuration.pusch_AntennaPorts, rrc->configuration.sib1_tda, - rrc->configuration.minRXTXTIME, - rrc->carrier.servingcellconfigcommon); + rrc->configuration.minRXTXTIME); nr_mac_config_mib(RC.nrmac[rrc->module_id], rrc->carrier.mib); } @@ -300,7 +322,6 @@ void openair_rrc_gNB_configuration(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *c uid_linear_allocator_init(&rrc->uid_allocator); RB_INIT(&rrc->rrc_ue_head); rrc->configuration = *configuration; - rrc->carrier.servingcellconfigcommon = configuration->scc; /// System Information INIT init_NR_SI(rrc, configuration); return; @@ -491,6 +512,9 @@ static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *co uint8_t xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id); ue_p->xids[xid] = RRC_DEFAULT_RECONF; + const nr_rrc_du_container_t *du = rrc->du; + DevAssert(du != NULL); + struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *dedicatedNAS_MessageList = CALLOC(1, sizeof(*dedicatedNAS_MessageList)); /* Add all NAS PDUs to the list */ @@ -515,7 +539,12 @@ static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *co dedicatedNAS_MessageList = NULL; } - NR_MeasConfig_t *measconfig = get_defaultMeasConfig(&rrc->configuration); + AssertFatal(du->setup_req->num_cells_available == 1, "cannot handle more than one cell, but have %d\n", du->setup_req->num_cells_available); + f1ap_served_cell_info_t *cell_info = &du->setup_req->cell[0].info; + int scs = get_ssb_scs(cell_info); + int band = get_dl_band(cell_info); + int arfcn = get_dl_arfcn(cell_info); + NR_MeasConfig_t *measconfig = get_defaultMeasConfig(arfcn, band, scs); uint8_t buffer[RRC_BUF_SIZE] = {0}; int size = do_RRCReconfiguration(ctxt_pP, @@ -530,7 +559,6 @@ static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *co measconfig, dedicatedNAS_MessageList, ue_context_pP, - &rrc->carrier, &rrc->configuration, NULL, ue_p->masterCellGroup); @@ -572,7 +600,10 @@ static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *co ? NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_RECONFIGURATION_DELAY_MS; - nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, *rrc->carrier.servingcellconfigcommon->ssbSubcarrierSpacing, delay_ms); + const nr_rrc_du_container_t *du = rrc->du; + DevAssert(du != NULL); + int scs = get_ssb_scs(&du->setup_req->cell[0].info); + nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, scs, delay_ms); } } @@ -650,7 +681,6 @@ void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const c NULL, dedicatedNAS_MessageList, ue_context_pP, - &rrc->carrier, &rrc->configuration, NULL, cellGroupConfig); @@ -678,7 +708,10 @@ void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const c ? NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_RECONFIGURATION_DELAY_MS; - nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, *rrc->carrier.servingcellconfigcommon->ssbSubcarrierSpacing, delay_ms); + const nr_rrc_du_container_t *du = rrc->du; + DevAssert(du != NULL); + int scs = get_ssb_scs(&du->setup_req->cell[0].info); + nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, scs, delay_ms); } } @@ -796,7 +829,6 @@ rrc_gNB_modify_dedicatedRRCReconfiguration( NULL, NULL, NULL, - NULL, NULL); LOG_DUMPMSG(NR_RRC, DEBUG_RRC, (char *)buffer, size, "[MSG] RRC Reconfiguration\n"); @@ -829,7 +861,10 @@ rrc_gNB_modify_dedicatedRRCReconfiguration( ? NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_RECONFIGURATION_DELAY_MS; - nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, *rrc->carrier.servingcellconfigcommon->ssbSubcarrierSpacing, delay_ms); + const nr_rrc_du_container_t *du = rrc->du; + DevAssert(du != NULL); + int scs = get_ssb_scs(&du->setup_req->cell[0].info); + nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, scs, delay_ms); } } @@ -880,7 +915,6 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release( NULL, NULL, NULL, - NULL, NULL); LOG_DUMPMSG(NR_RRC,DEBUG_RRC,(char *)buffer,size, "[MSG] RRC Reconfiguration\n"); @@ -910,7 +944,10 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release( ? NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_RECONFIGURATION_DELAY_MS; - nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, *rrc->carrier.servingcellconfigcommon->ssbSubcarrierSpacing, delay_ms); + const nr_rrc_du_container_t *du = rrc->du; + DevAssert(du != NULL); + int scs = get_ssb_scs(&du->setup_req->cell[0].info); + nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, scs, delay_ms); } } @@ -1015,8 +1052,8 @@ static void rrc_gNB_process_RRCReconfigurationComplete(const protocol_ctxt_t *co //----------------------------------------------------------------------------- static void rrc_gNB_generate_RRCReestablishment(rrc_gNB_ue_context_t *ue_context_pP, const uint8_t *masterCellGroup_from_DU, - NR_ServingCellConfigCommon_t *scc, - const rnti_t old_rnti) + const rnti_t old_rnti, + const f1ap_served_cell_info_t *cell_info) //----------------------------------------------------------------------------- { module_id_t module_id = 0; @@ -1024,16 +1061,12 @@ 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, buffer, RRC_BUF_SIZE, xid, cell_info->nr_pci, scc); + uint32_t arfcn = get_dl_arfcn(cell_info); + int size = do_RRCReestablishment(ue_context_pP, buffer, RRC_BUF_SIZE, xid, cell_info->nr_pci, arfcn); LOG_I(NR_RRC, "[RAPROC] UE %04x Logical Channel DL-DCCH, Generating NR_RRCReestablishment (bytes %d)\n", ue_p->rnti, size); @@ -1133,7 +1166,6 @@ static void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *co NULL, // MeasObj_list, NULL, ue_context_pP, - &rrc->carrier, NULL, NULL, cellGroupConfig); @@ -1156,10 +1188,10 @@ static void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *co ? NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_RECONFIGURATION_DELAY_MS; - nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, - ue_p->rnti, - *RC.nrrrc[ctxt_pP->module_id]->carrier.servingcellconfigcommon->ssbSubcarrierSpacing, - delay_ms); + const nr_rrc_du_container_t *du = RC.nrrrc[0]->du; + DevAssert(du != NULL); + int scs = get_ssb_scs(&du->setup_req->cell[0].info); + nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, scs, delay_ms); } } //----------------------------------------------------------------------------- @@ -1197,7 +1229,6 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP ue_context_pP, NULL, NULL, - NULL, masterCellGroup); gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; @@ -1212,10 +1243,10 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP ? NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_RECONFIGURATION_DELAY_MS; - nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, - ue_p->rnti, - *rrc->carrier.servingcellconfigcommon->ssbSubcarrierSpacing, - delay_ms); + const nr_rrc_du_container_t *du = rrc->du; + DevAssert(du != NULL); + int scs = get_ssb_scs(&du->setup_req->cell[0].info); + nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, scs, delay_ms); } return 0; @@ -1351,7 +1382,6 @@ static int nr_rrc_gNB_decode_ccch(module_id_t module_id, const f1ap_initial_ul_r ? "Other Failure" : (cause == NR_ReestablishmentCause_handoverFailure ? "Handover Failure" : "reconfigurationFailure")); - 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) { @@ -1412,8 +1442,8 @@ static int nr_rrc_gNB_decode_ccch(module_id_t module_id, const f1ap_initial_ul_r rrc_gNB_generate_RRCReestablishment(ue_context_p, msg->du2cu_rrc_container, - gnb_rrc_inst->carrier.servingcellconfigcommon, - old_rnti); + old_rnti, + cell_info); } break; case NR_UL_CCCH_MessageType__c1_PR_rrcSystemInfoRequest: @@ -2195,10 +2225,10 @@ unsigned int mask_flip(unsigned int x) { return((((x>>8) + (x<<8))&0xffff)>>6); } -static unsigned int get_dl_bw_mask(const gNB_RRC_INST *rrc, const NR_UE_NR_Capability_t *cap) +static unsigned int get_dl_bw_mask(const f1ap_served_cell_info_t *cell_info, const NR_UE_NR_Capability_t *cap) { - int common_band = *rrc->carrier.servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; - int common_scs = rrc->carrier.servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + int common_band = get_dl_band(cell_info); + int common_scs = get_ssb_scs(cell_info); for (int i=0;irf_Parameters.supportedBandListNR.list.count;i++) { NR_BandNR_t *bandNRinfo = cap->rf_Parameters.supportedBandListNR.list.array[i]; if (bandNRinfo->bandNR == common_band) { @@ -2245,10 +2275,10 @@ static unsigned int get_dl_bw_mask(const gNB_RRC_INST *rrc, const NR_UE_NR_Capab return(0); } -static unsigned int get_ul_bw_mask(const gNB_RRC_INST *rrc, const NR_UE_NR_Capability_t *cap) +static unsigned int get_ul_bw_mask(const f1ap_served_cell_info_t *cell_info, const NR_UE_NR_Capability_t *cap) { - int common_band = *rrc->carrier.servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0]; - int common_scs = rrc->carrier.servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + int common_band = get_ul_band(cell_info); + int common_scs = get_ssb_scs(cell_info); for (int i=0;irf_Parameters.supportedBandListNR.list.count;i++) { NR_BandNR_t *bandNRinfo = cap->rf_Parameters.supportedBandListNR.list.array[i]; if (bandNRinfo->bandNR == common_band) { @@ -2295,9 +2325,9 @@ static unsigned int get_ul_bw_mask(const gNB_RRC_INST *rrc, const NR_UE_NR_Capab return(0); } -static int get_ul_mimo_layersCB(const gNB_RRC_INST *rrc, const NR_UE_NR_Capability_t *cap) +static int get_ul_mimo_layersCB(const f1ap_served_cell_info_t *cell_info, const NR_UE_NR_Capability_t *cap) { - int common_scs = rrc->carrier.servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + int common_scs = get_ssb_scs(cell_info); // check featureSet NR_FeatureSets_t *fs=cap->featureSets; @@ -2313,9 +2343,9 @@ static int get_ul_mimo_layersCB(const gNB_RRC_INST *rrc, const NR_UE_NR_Capabili return(1); } -static int get_ul_mimo_layers(const gNB_RRC_INST *rrc, const NR_UE_NR_Capability_t *cap) +static int get_ul_mimo_layers(const f1ap_served_cell_info_t *cell_info, const NR_UE_NR_Capability_t *cap) { - int common_scs = rrc->carrier.servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + int common_scs = get_ssb_scs(cell_info); // check featureSet NR_FeatureSets_t *fs=cap->featureSets; @@ -2330,9 +2360,9 @@ static int get_ul_mimo_layers(const gNB_RRC_INST *rrc, const NR_UE_NR_Capability return(1); } -static int get_dl_mimo_layers(const gNB_RRC_INST *rrc, const NR_UE_NR_Capability_t *cap) +static int get_dl_mimo_layers(const f1ap_served_cell_info_t *cell_info, const NR_UE_NR_Capability_t *cap) { - int common_scs = rrc->carrier.servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + int common_scs = get_ssb_scs(cell_info); // check featureSet NR_FeatureSets_t *fs=cap->featureSets; @@ -2517,6 +2547,10 @@ static void write_rrc_stats(const gNB_RRC_INST *rrc) { const gNB_RRC_UE_t *ue_ctxt = &ue_context_p->ue_context; f1_ue_data_t ue_data = cu_get_f1_ue_data(ue_ctxt->rrc_ue_id); + /* currently, we support only one DU. If we support multiple, need to + * search for the DU corresponding to this UE here */ + const nr_rrc_du_container_t *du = rrc->du; + DevAssert(du != NULL); fprintf(f, "UE %d CU UE ID %d DU UE ID %d RNTI %04x random identity %016lx", @@ -2539,13 +2573,15 @@ static void write_rrc_stats(const gNB_RRC_INST *rrc) } if (ue_ctxt->UE_Capability_nr) { + AssertFatal(du->setup_req->num_cells_available == 1, "only one cell supported at the moment\n"); + const f1ap_served_cell_info_t *cell_info = &du->setup_req->cell[0].info; fprintf(f, " UE cap: BW DL %x. BW UL %x, DL MIMO Layers %d UL MIMO Layers (CB) %d UL MIMO Layers (nonCB) %d\n", - get_dl_bw_mask(rrc, ue_ctxt->UE_Capability_nr), - get_ul_bw_mask(rrc, ue_ctxt->UE_Capability_nr), - get_dl_mimo_layers(rrc, ue_ctxt->UE_Capability_nr), - get_ul_mimo_layersCB(rrc, ue_ctxt->UE_Capability_nr), - get_ul_mimo_layers(rrc, ue_ctxt->UE_Capability_nr)); + get_dl_bw_mask(cell_info, ue_ctxt->UE_Capability_nr), + get_ul_bw_mask(cell_info, ue_ctxt->UE_Capability_nr), + get_dl_mimo_layers(cell_info, ue_ctxt->UE_Capability_nr), + get_ul_mimo_layersCB(cell_info, ue_ctxt->UE_Capability_nr), + get_ul_mimo_layers(cell_info, ue_ctxt->UE_Capability_nr)); } if (ue_ctxt->measResults) diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index 79adaa3737..8289ec73de 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -119,7 +119,6 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2a { AssertFatal(!get_softmodem_params()->sa, "%s() cannot be called in SA mode, it is intrinsically for NSA\n", __func__); // generate nr-Config-r15 containers for LTE RRC : inside message for X2 EN-DC (CG-Config Message from 38.331) - rrc_gNB_carrier_data_t *carrier=&rrc->carrier; const gNB_RrcConfigurationReq *configuration = &rrc->configuration; MessageDef *msg; msg = itti_alloc_new_message(TASK_RRC_ENB, 0, X2AP_ENDC_SGNB_ADDITION_REQ_ACK); @@ -243,7 +242,11 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2a } NR_ServingCellConfig_t *scc = UE->spCellConfig ? UE->spCellConfig->spCellConfigDedicated : NULL; - UE->secondaryCellGroup = get_default_secondaryCellGroup(carrier->servingcellconfigcommon, + // The MAC has the ServingCellConfigCommon; the below code is incorrect: the + // CU should send a UE Context Setup Request to request the creating of the + // MAC Context + NR_ServingCellConfigCommon_t *sccc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon; + UE->secondaryCellGroup = get_default_secondaryCellGroup(sccc, scc, UE->UE_Capability_nr, 1, @@ -253,7 +256,7 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2a AssertFatal(UE->secondaryCellGroup != NULL, "out of memory\n"); xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, UE->secondaryCellGroup); - fill_default_reconfig(carrier->servingcellconfigcommon, scc, reconfig_ies, UE->secondaryCellGroup, UE->UE_Capability_nr, configuration, ue_context_p->ue_context.rrc_ue_id); + fill_default_reconfig(sccc, scc, reconfig_ies, UE->secondaryCellGroup, UE->UE_Capability_nr, configuration, ue_context_p->ue_context.rrc_ue_id); UE->rnti = UE->secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity; NR_CG_Config_t *CG_Config = calloc(1,sizeof(*CG_Config)); memset((void *)CG_Config,0,sizeof(*CG_Config));