From 5d0ae84ad23b858636e0b5cfa3a76669506fbe5a Mon Sep 17 00:00:00 2001 From: Robert Schmidt <robert.schmidt@openairinterface.org> Date: Fri, 21 Jul 2023 16:34:55 +0200 Subject: [PATCH] Move MIB to MAC The MasterInformationBlock is handled at the DU and sent to the CU in the F1 Setup Response. Hence, move it down to the MAC. Furthermore: - Change type because MIB_PDU_t is 4G type - Simplify schedule_nr_mib() --- doc/SW_archi.md | 2 +- openair1/SIMULATION/NR_PHY/ulsim.c | 1 - openair2/GNB_APP/gnb_config.c | 14 +++++---- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 2 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 2 +- openair2/LAYER2/NR_MAC_gNB/config.c | 12 -------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 26 +++++++++++------ openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 1 - openair2/LAYER2/NR_MAC_gNB/main.c | 1 + openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 2 +- openair2/RRC/NR/L2_nr_interface.c | 8 +---- openair2/RRC/NR/nr_rrc_defs.h | 2 +- openair2/RRC/NR/rrc_gNB.c | 29 ++++++++++--------- 13 files changed, 47 insertions(+), 55 deletions(-) diff --git a/doc/SW_archi.md b/doc/SW_archi.md index 7facfcb5955..4f80c98dcd8 100644 --- a/doc/SW_archi.md +++ b/doc/SW_archi.md @@ -211,7 +211,7 @@ The scheduler also calls "run_pdcp()", as this is not a autonomous thread, it ne After calling run_pdcp, it updates "rlc" time data but it doesn't actually process rlc it sends a iiti message to activate the thread for RRC, the answer will be asynchronous in ???? -Calls schedule_nr_mib() that calls mac_rrc_nr_data_req() to fill MIB, +Calls schedule_nr_mib() that fills MIB, Calls schedule_nr_prach() which schedules the (fixed) PRACH region one frame in advance. diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 626bc652705..bf65be3fa2e 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -652,7 +652,6 @@ 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); - 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); frame_parms->nb_antennas_tx = 1; diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index cf84570cf39..67784ad8e97 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -1960,9 +1960,10 @@ int RC_config_trigger_F1Setup() req->cell[0].info.plmn.mnc_digit_length, req->cell[0].info.nr_cellid); - gNB_RRC_INST *rrc = RC.nrrrc[0]; - DevAssert(rrc); - const NR_ServingCellConfigCommon_t *scc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon; + + gNB_MAC_INST *mac = RC.nrmac[0]; + DevAssert(mac); + const NR_ServingCellConfigCommon_t *scc = mac->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"); @@ -1992,16 +1993,18 @@ int RC_config_trigger_F1Setup() req->cell[0].info.measurement_timing_information = "0"; - DevAssert(rrc->carrier.mib != NULL); + DevAssert(mac->common_channels[0].mib != NULL); int buf_len = 3; // this is what we assume in monolithic req->cell[0].sys_info = calloc(1, sizeof(*req->cell[0].sys_info)); AssertFatal(req->cell[0].sys_info != NULL, "out of memory\n"); f1ap_gnb_du_system_info_t *sys_info = req->cell[0].sys_info; sys_info->mib = calloc(buf_len, sizeof(*sys_info->mib)); DevAssert(sys_info->mib != NULL); - sys_info->mib_length = encode_MIB_NR(rrc->carrier.mib, 0, sys_info->mib, buf_len); + 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, @@ -2026,7 +2029,6 @@ int RC_config_trigger_F1Setup() if (LOG_DEBUGFLAG(DEBUG_ASN1)) xer_fprint(stdout, &asn_DEF_NR_SIB1, (void *)bcch_message->message.choice.c1->choice.systemInformationBlockType1); - gNB_MAC_INST *mac = RC.nrmac[0]; mac->mac_rrc.f1_setup_request(req); mac->f1_config.setup_req = req; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 656195815aa..a0f3fae4132 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -4105,7 +4105,7 @@ uint32_t get_Y(const NR_SearchSpace_t *ss, int slot, rnti_t rnti) { void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config, frame_t frameP, - NR_MIB_t *mib, + const NR_MIB_t *mib, uint8_t num_slot_per_frame, uint8_t ssb_subcarrier_offset, uint16_t ssb_start_symbol, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index ab7a8206126..3689e4a5a26 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -207,7 +207,7 @@ uint32_t nr_compute_tbslbrm(uint16_t table, void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config, frame_t frameP, - NR_MIB_t *mib, + const NR_MIB_t *mib, uint8_t num_slot_per_frame, uint8_t ssb_subcarrier_offset, uint16_t ssb_start_symbol, diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index c7371a3ef4b..b357138da26 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_mib(gNB_MAC_INST *nrmac, NR_BCCH_BCH_Message_t *mib) -{ - DevAssert(nrmac != NULL); - DevAssert(mib != NULL); - NR_SCHED_LOCK(&nrmac->sched_lock); - NR_COMMON_channels_t *cc = &nrmac->common_channels[0]; - - AssertFatal(cc->mib == NULL, "logic bug: updated MIB multiple times\n"); - cc->mib = mib; - 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); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 3c5d56893dd..57e8922bf59 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -105,19 +105,26 @@ static void fill_ssb_vrb_map(NR_COMMON_channels_t *cc, int rbStart, int ssb_subc vrb_map[rbStart + rb] = SL_to_bitmap(symStart % NR_SYMBOLS_PER_SLOT, 4); } +static int encode_mib(NR_BCCH_BCH_Message_t *mib, frame_t frame, uint8_t *buffer, int buf_size) +{ + int encode_size = 3; + AssertFatal(buf_size >= encode_size, "buffer of size %d too small, need 3 bytes\n", buf_size); + int encoded = encode_MIB_NR(mib, frame, buffer, encode_size); + DevAssert(encoded == encode_size); + return encode_size; +} + void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, nfapi_nr_dl_tti_request_t *DL_req) { gNB_MAC_INST *gNB = RC.nrmac[module_idP]; /* already mutex protected: held in gNB_dlsch_ulsch_scheduler() */ - NR_COMMON_channels_t *cc; nfapi_nr_dl_tti_request_body_t *dl_req; - NR_MIB_t *mib = RC.nrrrc[module_idP]->carrier.mib->message.choice.mib; uint8_t num_tdd_period,num_ssb; - int mib_sdu_length; int CC_id; for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - cc = &gNB->common_channels[CC_id]; + NR_COMMON_channels_t *cc= &gNB->common_channels[CC_id]; + const NR_MIB_t *mib = cc->mib->message.choice.mib; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; const int slots_per_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; dl_req = &DL_req->dl_tti_request_body; @@ -125,8 +132,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, // get MIB every 8 frames if(((slotP == 0) && (frameP & 7) == 0) || gNB->first_MIB) { - - mib_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, MIBCH, 0, 1, &cc->MIB_pdu.payload[0]); + int mib_sdu_length = encode_mib(cc->mib, frameP, cc->MIB_pdu, sizeof(cc->MIB_pdu)); // flag to avoid sending an empty MIB in the first frames of execution since gNB doesn't get at the beginning in frame 0 slot 0 gNB->first_MIB = false; @@ -139,6 +145,8 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, mib_sdu_length); } + uint32_t mib_pdu = (*(uint32_t *)cc->MIB_pdu) & ((1 << 24) - 1); + int8_t ssb_period = *scc->ssb_periodicityServingCell; uint8_t ssb_frame_periodicity = 1; // every how many frames SSB are generated @@ -175,7 +183,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, // if start symbol is in current slot, schedule current SSB, fill VRB map and call get_type0_PDCCH_CSS_config_parameters if ((ssb_start_symbol/14) == rel_slot){ const int prb_offset = offset_pointa >> scs; - schedule_ssb(frameP, slotP, scc, dl_req, i_ssb, ssbSubcarrierOffset, offset_pointa, (*(uint32_t*)cc->MIB_pdu.payload) & ((1<<24)-1)); + schedule_ssb(frameP, slotP, scc, dl_req, i_ssb, ssbSubcarrierOffset, offset_pointa, mib_pdu); fill_ssb_vrb_map(cc, prb_offset, ssbSubcarrierOffset, ssb_start_symbol, CC_id); if (get_softmodem_params()->sa == 1) { get_type0_PDCCH_CSS_config_parameters(&gNB->type0_PDCCH_CSS_config[i_ssb], @@ -204,7 +212,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, // if start symbol is in current slot, schedule current SSB, fill VRB map and call get_type0_PDCCH_CSS_config_parameters if ((ssb_start_symbol/14) == rel_slot){ const int prb_offset = offset_pointa >> scs; - schedule_ssb(frameP, slotP, scc, dl_req, i_ssb, ssbSubcarrierOffset, offset_pointa, (*(uint32_t*)cc->MIB_pdu.payload) & ((1<<24)-1)); + schedule_ssb(frameP, slotP, scc, dl_req, i_ssb, ssbSubcarrierOffset, offset_pointa, mib_pdu); fill_ssb_vrb_map(cc, prb_offset, ssbSubcarrierOffset, ssb_start_symbol, CC_id); if (get_softmodem_params()->sa == 1) { get_type0_PDCCH_CSS_config_parameters(&gNB->type0_PDCCH_CSS_config[i_ssb], @@ -234,7 +242,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, // if start symbol is in current slot, schedule current SSB, fill VRB map and call get_type0_PDCCH_CSS_config_parameters if ((ssb_start_symbol/14) == rel_slot){ const int prb_offset = offset_pointa >> (scs-2); // reference 60kHz - schedule_ssb(frameP, slotP, scc, dl_req, i_ssb, ssbSubcarrierOffset, offset_pointa, (*(uint32_t*)cc->MIB_pdu.payload) & ((1<<24)-1)); + schedule_ssb(frameP, slotP, scc, dl_req, i_ssb, ssbSubcarrierOffset, offset_pointa, mib_pdu); fill_ssb_vrb_map(cc, prb_offset, ssbSubcarrierOffset >> (scs - 2), ssb_start_symbol, CC_id); const NR_TDD_UL_DL_Pattern_t *tdd = &scc->tdd_UL_DL_ConfigurationCommon->pattern1; const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index cb907e7af50..82f9f8008fe 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_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); bool nr_mac_prepare_ra_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 1d07f396306..17d546c62ab 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -245,6 +245,7 @@ void mac_top_init_gNB(ngran_node_t node_type, NR_ServingCellConfigCommon_t *scc, RC.nrmac[i]->common_channels[0].pre_ServingCellConfig = scd; RC.nrmac[i]->first_MIB = true; + RC.nrmac[i]->common_channels[0].mib = get_new_MIB_NR(scc); RC.nrmac[i]->cset0_bwp_start = 0; RC.nrmac[i]->cset0_bwp_size = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index ef35bc0a8e6..f73e64b9f89 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -225,7 +225,7 @@ typedef struct { NR_ARFCN_ValueEUTRA_t ul_CarrierFreq; long ul_Bandwidth; /// Outgoing MIB PDU for PHY - MIB_PDU MIB_pdu; + uint8_t MIB_pdu[3]; /// Outgoing BCCH pdu for PHY BCCH_PDU BCCH_pdu; /// Outgoing BCCH DCI allocation diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index 3334842616b..14a1838b581 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -74,13 +74,7 @@ uint16_t mac_rrc_nr_data_req(const module_id_t Mod_idP, // MIBCH if ((Srb_id & RAB_OFFSET) == MIBCH) { - int encode_size = 3; - rrc_gNB_carrier_data_t *carrier = &RC.nrrrc[Mod_idP]->carrier; - int encoded = encode_MIB_NR(carrier->mib, frameP, buffer_pP, encode_size); - DevAssert(encoded == encode_size); - LOG_D(NR_RRC, "MIB PDU buffer_pP[0]=%x , buffer_pP[1]=%x, buffer_pP[2]=%x\n", buffer_pP[0], buffer_pP[1], - buffer_pP[2]); - return encode_size; + DevAssert(false); } if ((Srb_id & RAB_OFFSET) == BCCH) { diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index 055ef88fbe2..836f7560104 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -331,7 +331,6 @@ typedef struct { uint8_t *SIB23; uint8_t sizeof_SIB23; - NR_BCCH_BCH_Message_t *mib; NR_SIB1_t *siblock1_DU; NR_SIB1_t *sib1; NR_SIB2_t *sib2; @@ -376,6 +375,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_rrc_du_container_t; //---NR---(completely change)--------------------- diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 455ded6c02b..6a86e0cb657 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -237,11 +237,6 @@ 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(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, scc); //xer_fprint(stdout, &asn_DEF_NR_BCCH_DL_SCH_Message, sib1); @@ -270,7 +265,6 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration rrc->configuration.pusch_AntennaPorts, rrc->configuration.sib1_tda, rrc->configuration.minRXTXTIME); - nr_mac_config_mib(RC.nrmac[rrc->module_id], rrc->carrier.mib); } if (get_softmodem_params()->phy_test > 0 || get_softmodem_params()->do_ra > 0) { @@ -1931,6 +1925,18 @@ static void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *req) return; } + /* do we need the MIB? for the moment, just check it is valid, then drop it */ + NR_BCCH_BCH_Message_t *mib = NULL; + asn_dec_rval_t dec_rval = + uper_decode_complete(NULL, &asn_DEF_NR_BCCH_BCH_Message, (void **)&mib, sys_info->mib, sys_info->mib_length); + if (dec_rval.code != RC_OK || mib->message.present != NR_BCCH_BCH_MessageType_PR_mib + || mib->message.choice.messageClassExtension == NULL) { + LOG_E(RRC, "Failed to decode NR_BCCH_BCH_MESSAGE (%zu bits) of DU, rejecting DU\n", dec_rval.consumed); + rrc->mac_rrc.f1_setup_failure(&fail); + ASN_STRUCT_FREE(asn_DEF_NR_BCCH_BCH_Message, mib); + return; + } + LOG_I(RRC, "Accepting DU %ld (%s), sending F1 Setup Response\n", req->gNB_DU_id, req->gNB_DU_name); // we accept the DU @@ -1943,14 +1949,9 @@ static void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *req) rrc->du->setup_req = malloc(sizeof(*rrc->du->setup_req)); AssertFatal(rrc->du->setup_req != NULL, "out of memory\n"); *rrc->du->setup_req = *req; - - if (rrc->carrier.mib != NULL) { - LOG_E(NR_RRC, "CU MIB is already initialized: double F1 setup request?\n"); - } else { - asn_dec_rval_t dec_rval = - uper_decode_complete(NULL, &asn_DEF_NR_BCCH_BCH_Message, (void **)&rrc->carrier.mib, sys_info->mib, sys_info->mib_length); - AssertFatal(dec_rval.code == RC_OK, "Failed to decode NR_BCCH_BCH_MESSAGE (%zu bits)\n", dec_rval.consumed); - } + 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"); -- GitLab