diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 67784ad8e9..51db286e43 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -2003,32 +2003,13 @@ int RC_config_trigger_F1Setup() sys_info->mib_length = encode_MIB_NR(mac->common_channels[0].mib, 0, sys_info->mib, buf_len); DevAssert(sys_info->mib_length == buf_len); - gNB_RRC_INST *rrc = RC.nrrrc[0]; - DevAssert(rrc); - NR_BCCH_DL_SCH_Message_t *bcch_message = NULL; - asn_codec_ctx_t st = {100 * 1000}; - asn_dec_rval_t dec_rval = uper_decode_complete(&st, - &asn_DEF_NR_BCCH_DL_SCH_Message, - (void **)&bcch_message, - (const void *)rrc->carrier.SIB1, - rrc->carrier.sizeof_SIB1); - - if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - LOG_E(RRC, "SIB1 decode error\n"); - // free the memory - SEQUENCE_free(&asn_DEF_NR_BCCH_DL_SCH_Message, bcch_message, 1); - exit(1); - } - - NR_SIB1_t *bcch_SIB1 = bcch_message->message.choice.c1->choice.systemInformationBlockType1; - sys_info->sib1 = calloc(1, rrc->carrier.sizeof_SIB1); + DevAssert(mac->common_channels[0].sib1 != NULL); + NR_SIB1_t *bcch_SIB1 = mac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1; + sys_info->sib1 = calloc(NR_MAX_SIB_LENGTH / 8, sizeof(*sys_info->sib1)); asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_SIB1, NULL, (void *)bcch_SIB1, sys_info->sib1, NR_MAX_SIB_LENGTH / 8); AssertFatal(enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); sys_info->sib1_length = (enc_rval.encoded + 7) / 8; - if (LOG_DEBUGFLAG(DEBUG_ASN1)) - xer_fprint(stdout, &asn_DEF_NR_SIB1, (void *)bcch_message->message.choice.c1->choice.systemInformationBlockType1); - mac->mac_rrc.f1_setup_request(req); mac->f1_config.setup_req = req; diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index b357138da2..988f7b3233 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -560,18 +560,6 @@ void nr_mac_config_scc(gNB_MAC_INST *nrmac, NR_SCHED_UNLOCK(&nrmac->sched_lock); } -void nr_mac_config_sib1(gNB_MAC_INST *nrmac, NR_BCCH_DL_SCH_Message_t *sib1) -{ - DevAssert(nrmac != NULL); - DevAssert(sib1 != NULL); - NR_SCHED_LOCK(&nrmac->sched_lock); - NR_COMMON_channels_t *cc = &nrmac->common_channels[0]; - - AssertFatal(cc->sib1 == NULL, "logic bug: updated SIB1 multiple times\n"); - cc->sib1 = sib1; - NR_SCHED_UNLOCK(&nrmac->sched_lock); -} - bool nr_mac_add_test_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup) { DevAssert(nrmac != NULL); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 57e8922bf5..8d44a20aa1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -569,14 +569,6 @@ void schedule_nr_sib1(module_id_t module_idP, LOG_D(NR_MAC,"(%d.%d) SIB1 transmission: ssb_index %d\n", frameP, slotP, type0_PDCCH_CSS_config->ssb_index); - // Get SIB1 - uint8_t sib1_payload[NR_MAX_SIB_LENGTH/8]; - uint16_t sib1_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, BCCH, SI_RNTI, 1, sib1_payload); - LOG_D(NR_MAC,"sib1_sdu_length = %i\n", sib1_sdu_length); - LOG_D(NR_MAC,"SIB1: \n"); - for (int k=0;ktype0_pdcch_ss_mux_pattern); // assuming normal CP NR_tda_info_t tda_info = get_info_from_tda_tables(table_type, time_domain_allocation, gNB_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position, true); @@ -588,6 +580,8 @@ void schedule_nr_sib1(module_id_t module_idP, &tda_info, 1); + + NR_COMMON_channels_t *cc = &gNB_mac->common_channels[0]; // Configure sched_ctrlCommon for SIB1 uint32_t TBS = schedule_control_sib1(module_idP, CC_id, type0_PDCCH_CSS_config, @@ -595,7 +589,7 @@ void schedule_nr_sib1(module_id_t module_idP, &dmrs_parms, &tda_info, candidate_idx, - sib1_sdu_length); + cc->sib1_bcch_length); nfapi_nr_dl_tti_request_body_t *dl_req = &DL_req->dl_tti_request_body; int pdu_index = gNB_mac->pdu_index[0]++; @@ -605,7 +599,7 @@ void schedule_nr_sib1(module_id_t module_idP, nfapi_nr_pdu_t *tx_req = &TX_req->pdu_list[ntx_req]; // Data to be transmitted - memcpy(tx_req->TLVs[0].value.direct, sib1_payload, TBS); + memcpy(tx_req->TLVs[0].value.direct, cc->sib1_bcch_pdu, TBS); tx_req->PDU_length = TBS; tx_req->PDU_index = pdu_index; @@ -617,9 +611,14 @@ void schedule_nr_sib1(module_id_t module_idP, type0_PDCCH_CSS_config->active = false; - T(T_GNB_MAC_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), - T_INT(0xffff), T_INT(frameP), T_INT(slotP), T_INT(0 /* harq_pid */), - T_BUFFER(sib1_payload, TBS)); + T(T_GNB_MAC_DL_PDU_WITH_DATA, + T_INT(module_idP), + T_INT(CC_id), + T_INT(0xffff), + T_INT(frameP), + T_INT(slotP), + T_INT(0 /* harq_pid */), + T_BUFFER(cc->sib1_bcch_pdu, cc->sib1_bcch_length)); } } } diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 82f9f8008f..3dd5165c88 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -50,7 +50,6 @@ void nr_mac_config_scc(gNB_MAC_INST *nrmac, int pusch_AntennaPorts, int sib1_tda, int minRXTXTIMEpdsch); -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); bool nr_mac_prepare_ra_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup); bool nr_mac_update_cellgroup(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 17d546c62a..1ee92fa5be 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -250,6 +250,14 @@ void mac_top_init_gNB(ngran_node_t node_type, NR_ServingCellConfigCommon_t *scc, RC.nrmac[i]->cset0_bwp_start = 0; RC.nrmac[i]->cset0_bwp_size = 0; + /* Temporary: RRC configuration */ + gNB_RrcConfigurationReq conf = { .mcc = {208}, .mnc = {95}, .mnc_digit_length = {2}, .tac = 1, .cell_identity = 3584}; + NR_BCCH_DL_SCH_Message_t *sib1 = get_SIB1_NR(&conf, scc); + NR_COMMON_channels_t *cc = &RC.nrmac[i]->common_channels[0]; + cc->sib1 = sib1; + cc->sib1_bcch_length = encode_SIB1_NR(sib1, cc->sib1_bcch_pdu, sizeof(cc->sib1_bcch_pdu)); + AssertFatal(cc->sib1_bcch_length > 0, "could not encode SIB1\n"); + pthread_mutex_init(&RC.nrmac[i]->sched_lock, NULL); pthread_mutex_init(&RC.nrmac[i]->UE_info.mutex, NULL); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index f73e64b9f8..1cf4efdcbb 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -71,6 +71,7 @@ #include "NR_BCCH-BCH-Message.h" #include "NR_CellGroupConfig.h" #include "NR_BCCH-DL-SCH-Message.h" +#include "openair2/RRC/NR/nr_rrc_config.h" /* PHY */ #include "time_meas.h" @@ -227,7 +228,8 @@ typedef struct { /// Outgoing MIB PDU for PHY uint8_t MIB_pdu[3]; /// Outgoing BCCH pdu for PHY - BCCH_PDU BCCH_pdu; + uint8_t sib1_bcch_pdu[NR_MAX_SIB_LENGTH / 8]; + int sib1_bcch_length; /// Outgoing BCCH DCI allocation uint32_t BCCH_alloc_pdu; /// Outgoing CCCH pdu for PHY diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index 14a1838b58..a3bc40dc9c 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -60,36 +60,6 @@ void nr_rrc_mac_update_cellgroup(rnti_t rntiMaybeUEid, NR_CellGroupConfig_t *cgc NR_SCHED_UNLOCK(&nrmac->sched_lock); } -uint16_t mac_rrc_nr_data_req(const module_id_t Mod_idP, - const int CC_id, - const frame_t frameP, - const rb_id_t Srb_id, - const rnti_t rnti, - const uint8_t Nb_tb, - uint8_t *const buffer_pP) -{ - - LOG_D(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%ld\n",Mod_idP,Srb_id); - - // MIBCH - if ((Srb_id & RAB_OFFSET) == MIBCH) { - - DevAssert(false); - } - - if ((Srb_id & RAB_OFFSET) == BCCH) { - memcpy(&buffer_pP[0], RC.nrrrc[Mod_idP]->carrier.SIB1, RC.nrrrc[Mod_idP]->carrier.sizeof_SIB1); - return RC.nrrrc[Mod_idP]->carrier.sizeof_SIB1; - } - - // CCCH - if ((Srb_id & RAB_OFFSET) == CCCH) { - AssertFatal(0, "CCCH is managed by rlc of srb 0, not anymore by mac_rrc_nr_data_req\n"); - } - - return 0; -} - int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP, const frame_t frameP, const sub_frame_t sub_frameP, diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index 836f756010..29ad2ccd35 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -325,18 +325,12 @@ typedef struct rrc_gNB_ue_context_s { typedef struct { - uint8_t *SIB1; - uint16_t sizeof_SIB1; - uint8_t *SIB23; uint8_t sizeof_SIB23; - NR_SIB1_t *siblock1_DU; - NR_SIB1_t *sib1; NR_SIB2_t *sib2; NR_SIB3_t *sib3; NR_BCCH_DL_SCH_Message_t systemInformation; // SIB23 - NR_BCCH_DL_SCH_Message_t *siblock1; NR_CellGroupConfig_t *secondaryCellGroup[MAX_NR_RRC_UE_CONTEXTS]; } rrc_gNB_carrier_data_t; @@ -376,6 +370,7 @@ typedef struct cucp_cuup_if_s { typedef struct nr_rrc_du_container_t { f1ap_setup_req_t *setup_req; NR_MIB_t *mib; + NR_SIB1_t *sib1; } nr_rrc_du_container_t; //---NR---(completely change)--------------------- diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 7502662da3..317a4976e8 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -46,14 +46,6 @@ #define NR_MAX_SUPPORTED_DL_LAYERS 2 -uint16_t mac_rrc_nr_data_req(const module_id_t Mod_idP, - const int CC_id, - const frame_t frameP, - const rb_id_t Srb_id, - const rnti_t rnti, - const uint8_t Nb_tb, - uint8_t *const buffer_pP); - void rrc_gNB_process_SgNBAdditionRequest( const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *ue_context_pP diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 6a86e0cb65..456c7c7c01 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -235,18 +235,6 @@ static int get_dl_arfcn(const f1ap_served_cell_info_t *cell_info) static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration) { - const NR_ServingCellConfigCommon_t *scc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon; - - 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, 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"); - rrc->carrier.sizeof_SIB1 = encode_SIB1_NR(sib1, rrc->carrier.SIB1, NR_MAX_SIB_LENGTH / 8); - rrc->carrier.siblock1 = sib1; - nr_mac_config_sib1(RC.nrmac[rrc->module_id], sib1); - } - if (!NODE_IS_DU(rrc->node_type)) { rrc->carrier.SIB23 = (uint8_t *) malloc16(100); AssertFatal(rrc->carrier.SIB23 != NULL, "cannot allocate memory for SIB"); @@ -1937,6 +1925,19 @@ static void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *req) return; } + NR_SIB1_t *sib1 = NULL; + if (sys_info->sib1) { + dec_rval = uper_decode_complete(NULL, &asn_DEF_NR_SIB1, (void **)&sib1, sys_info->sib1, sys_info->sib1_length); + if (dec_rval.code != RC_OK) { + LOG_E(RRC, "Failed to decode NR_SIB1 (%zu bits) of DU, rejecting DU\n", dec_rval.consumed); + rrc->mac_rrc.f1_setup_failure(&fail); + ASN_STRUCT_FREE(asn_DEF_NR_SIB1, sib1); + return; + } + if (LOG_DEBUGFLAG(DEBUG_ASN1)) + xer_fprint(stdout, &asn_DEF_NR_SIB1, sib1); + } + LOG_I(RRC, "Accepting DU %ld (%s), sending F1 Setup Response\n", req->gNB_DU_id, req->gNB_DU_name); // we accept the DU @@ -1952,17 +1953,7 @@ static void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *req) rrc->du->mib = mib->message.choice.mib; mib->message.choice.mib = NULL; ASN_STRUCT_FREE(asn_DEF_NR_BCCH_BCH_MessageType, mib); - - if (rrc->carrier.sib1 != NULL) { - LOG_E(NR_RRC, "CU SIB1 is already initiaized: double F1 setup request?\n"); - } else { - asn_dec_rval_t dec_rval = - uper_decode_complete(NULL, &asn_DEF_NR_SIB1, (void **)&rrc->carrier.sib1, sys_info->sib1, sys_info->sib1_length); - AssertFatal(dec_rval.code == RC_OK, "Failed to decode NR_BCCH_DLSCH_MESSAGE (%zu bits)\n", dec_rval.consumed); - - if (LOG_DEBUGFLAG(DEBUG_ASN1)) - xer_fprint(stdout, &asn_DEF_NR_SIB1, (void *)rrc->carrier.sib1); - } + rrc->du->sib1 = sib1; served_cells_to_activate_t cell = { .plmn = cell_info->plmn, @@ -2894,7 +2885,9 @@ int rrc_gNB_generate_pcch_msg(uint32_t tmsi, uint8_t paging_drx, instance_t inst uint32_t T; /* DRX cycle */ uint32_t length; uint8_t buffer[RRC_BUF_SIZE]; - struct NR_SIB1 *sib1 = RC.nrrrc[instance]->carrier.siblock1->message.choice.c1->choice.systemInformationBlockType1; + const nr_rrc_du_container_t *du = RC.nrrrc[0]->du; + DevAssert(du != NULL); + struct NR_SIB1 *sib1 = du->sib1; /* get default DRX cycle from configuration */ Tc = sib1->servingCellConfigCommon->downlinkConfigCommon.pcch_Config.defaultPagingCycle;