diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 032983644d..76373a2113 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -861,6 +861,7 @@ int main(int argc, char **argv) nr_l2_init_ue(NULL); UE_mac = get_mac_inst(0); + ue_init_config_request(UE_mac, mu); UE->if_inst = nr_ue_if_module_init(0); UE->if_inst->scheduled_response = nr_ue_scheduled_response; @@ -888,8 +889,8 @@ int main(int argc, char **argv) //Configure UE NR_BCCH_BCH_Message_t *mib = get_new_MIB_NR(scc); - nr_rrc_mac_config_req_mib(0, 0, 0, mib->message.choice.mib, false); - nr_rrc_mac_config_req_scg(0, 0, 0, secondaryCellGroup); + nr_rrc_mac_config_req_mib(0, 0, mib->message.choice.mib, false); + nr_rrc_mac_config_req_scg(0, 0, secondaryCellGroup); nr_dcireq_t dcireq; nr_scheduled_response_t scheduled_response; diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index ebcad5d0de..8bca8819c2 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -693,23 +693,17 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, } -void init_config_request(NR_UE_MAC_INST_t *mac) +void ue_init_config_request(NR_UE_MAC_INST_t *mac, int scs) { - if(mac->dl_config_request == NULL && mac->ul_config_request == NULL) { - int scs = mac->mib->subCarrierSpacingCommon; - if(mac->frequency_range == FR2) - scs += 2; - int slots_per_frame = nr_slots_per_frame[scs]; - LOG_I(NR_MAC, "Initializing dl and ul config_request. num_slots = %d\n", slots_per_frame); - mac->dl_config_request = calloc(slots_per_frame, sizeof(*mac->dl_config_request)); - mac->ul_config_request = calloc(slots_per_frame, sizeof(*mac->ul_config_request)); - for (int i = 0; i < slots_per_frame; i++) - pthread_mutex_init(&(mac->ul_config_request[i].mutex_ul_config), NULL); - } + int slots_per_frame = nr_slots_per_frame[scs]; + LOG_I(NR_MAC, "Initializing dl and ul config_request. num_slots = %d\n", slots_per_frame); + mac->dl_config_request = calloc(slots_per_frame, sizeof(*mac->dl_config_request)); + mac->ul_config_request = calloc(slots_per_frame, sizeof(*mac->ul_config_request)); + for (int i = 0; i < slots_per_frame; i++) + pthread_mutex_init(&(mac->ul_config_request[i].mutex_ul_config), NULL); } void nr_rrc_mac_config_req_mib(module_id_t module_id, - uint8_t gNB_index, int cc_idP, NR_MIB_t *mib, bool sched_sib1) @@ -718,7 +712,6 @@ void nr_rrc_mac_config_req_mib(module_id_t module_id, AssertFatal(mib, "MIB should not be NULL\n"); // initialize dl and ul config_request upon first reception of MIB mac->mib = mib; // update by every reception - init_config_request(mac); mac->phy_config.Mod_id = module_id; mac->phy_config.CC_id = cc_idP; mac->get_sib1 = sched_sib1; @@ -726,7 +719,6 @@ void nr_rrc_mac_config_req_mib(module_id_t module_id, void nr_rrc_mac_config_req_sib1(module_id_t module_id, int cc_idP, - uint8_t gNB_index, NR_ServingCellConfigCommonSIB_t *scc) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); @@ -745,7 +737,6 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, void nr_rrc_mac_config_req_mcg(module_id_t module_id, int cc_idP, - uint8_t gNB_index, NR_CellGroupConfig_t *cell_group_config) { LOG_I(MAC,"Applying CellGroupConfig from gNodeB\n"); @@ -777,7 +768,7 @@ void nr_rrc_mac_config_req_mcg(module_id_t module_id, mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon; mac->nr_band = *mac->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; if (mac->scc_SIB) { - free(mac->scc_SIB); + ASN_STRUCT_FREE(asn_DEF_NR_ServingCellConfigCommonSIB, mac->scc_SIB); mac->scc_SIB = NULL; } mac->state = UE_NOT_SYNC; @@ -806,7 +797,6 @@ void nr_rrc_mac_config_req_mcg(module_id_t module_id, void nr_rrc_mac_config_req_scg(module_id_t module_id, int cc_idP, - uint8_t gNB_index, NR_CellGroupConfig_t *scell_group_config) { diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 3be9eb934d..3c4d552827 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -93,23 +93,19 @@ int nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id, void nr_rrc_mac_config_req_scg(module_id_t module_id, int cc_idP, - uint8_t gNB_index, NR_CellGroupConfig_t *scell_group_config); void nr_rrc_mac_config_req_mcg(module_id_t module_id, int cc_idP, - uint8_t gNB_index, NR_CellGroupConfig_t *scell_group_config); void nr_rrc_mac_config_req_mib(module_id_t module_id, - uint8_t gNB_index, int cc_idP, NR_MIB_t *mibP, bool sched_sib1); void nr_rrc_mac_config_req_sib1(module_id_t module_id, int cc_idP, - uint8_t gNB_index, NR_ServingCellConfigCommonSIB_t *scc); /**\brief initialization NR UE MAC instance(s), total number of MAC instance based on NB_NR_UE_MAC_INST*/ @@ -425,6 +421,8 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac); +void ue_init_config_request(NR_UE_MAC_INST_t *mac, int scs); + void configure_ss_coreset(NR_UE_MAC_INST_t *mac, NR_ServingCellConfig_t *scd, NR_BWP_Id_t dl_bwp_id); diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 78d1b4b0f1..8899be18e6 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -56,9 +56,17 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { for (int j = 0; j < NB_NR_UE_MAC_INST; j++) nr_ue_init_mac(j); + int scs = get_softmodem_params()->sa ? + get_softmodem_params()->numerology : + rrc_inst ? + *rrc_inst->scell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon->ssbSubcarrierSpacing : + - 1; + if (scs > -1) + ue_init_config_request(nr_ue_mac_inst, scs); + if (rrc_inst && rrc_inst->scell_group_config) { - nr_rrc_mac_config_req_scg(0, 0, 0, rrc_inst->scell_group_config); + nr_rrc_mac_config_req_scg(0, 0, rrc_inst->scell_group_config); AssertFatal(rlc_module_init(0) == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); if (IS_SOFTMODEM_NOS1){ // get default noS1 configuration diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 5aa4438af0..6adaecef41 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -220,9 +220,8 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->rnti = SI_RNTI; // SI-RNTI - 3GPP TS 38.321 Table 7.1-1: RNTI values - if(mac->frequency_range == FR1) - rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon; - else + rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon; + if(mac->frequency_range == FR2) rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon + 2; break; case NR_RNTI_SFI: diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 8b1582a984..9d32171eb0 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -676,9 +676,9 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config = mac->type0_PDCCH_CSS_config; mux_pattern = type0_PDCCH_CSS_config.type0_pdcch_ss_mux_pattern; dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_SI_DLSCH; - if(mac->frequency_range == FR1) - dlsch_config_pdu_1_0->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon; - else + // in MIB SCS is signaled as 15or60 and 30or120 + dlsch_config_pdu_1_0->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon; + if(mac->frequency_range == FR2) dlsch_config_pdu_1_0->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon + 2; if (pdsch_config) pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NULL; // For PDSCH with mapping type A, the UE shall assume dmrs-AdditionalPosition='pos2' } else { diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 32914b37f9..6545fc945a 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -118,12 +118,8 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl int mu = mac->current_UL_BWP.scs; const int n = nr_slots_per_frame[mu]; AssertFatal(fb_time < n, "Cannot schedule to a slot more than 1 frame away, ul_config_request is not big enough\n"); - if (mac->ul_config_request) - return &mac->ul_config_request[slot]; - else { - LOG_E(NR_MAC, "mac->ul_config_request not set\n"); - return NULL; - } + AssertFatal(mac->ul_config_request != NULL, "mac->ul_config_request not initialized, logic bug\n"); + return &mac->ul_config_request[slot]; } /* @@ -132,12 +128,8 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl */ fapi_nr_dl_config_request_t *get_dl_config_request(NR_UE_MAC_INST_t *mac, int slot) { - if (mac->dl_config_request) - return &mac->dl_config_request[slot]; - else { - LOG_E(NR_MAC, "mac->dl_config_request not set\n"); - return NULL; - } + AssertFatal(mac->dl_config_request != NULL, "mac->dl_config_request not initialized, logic bug\n"); + return &mac->dl_config_request[slot]; } void ul_layers_config(NR_UE_MAC_INST_t *mac, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci, nr_dci_format_t dci_format) diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 187976753d..b9876b6773 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -1144,7 +1144,6 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info) uint32_t ret_mask = 0x0; module_id_t module_id = dl_info->module_id; NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); - fapi_nr_dl_config_request_t *dl_config = get_dl_config_request(mac, dl_info->slot); if ((!dl_info->dci_ind && !dl_info->rx_ind)) { // UL indication to schedule DCI reception @@ -1179,6 +1178,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info) if (ret >= 0) { AssertFatal( nr_ue_if_module_inst[module_id] != NULL, "IF module is NULL!\n" ); AssertFatal( nr_ue_if_module_inst[module_id]->scheduled_response != NULL, "scheduled_response is NULL!\n" ); + fapi_nr_dl_config_request_t *dl_config = get_dl_config_request(mac, dl_info->slot); fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, dl_info->module_id, dl_info->cc_id, dl_info->frame, dl_info->slot, dl_info->phy_data); nr_ue_if_module_inst[module_id]->scheduled_response(&scheduled_response); } diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 468440a98c..0bffcfdc26 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -286,8 +286,7 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(const module_id_t module_id, NR_RRCR nr_rrc_ue_process_scg_config(module_id,cellGroupConfig); } if (get_softmodem_params()->nsa) { - nr_rrc_mac_config_req_scg(0, 0, 0, cellGroupConfig); - LOG_D(NR_RRC, "Filled scc now \n"); + nr_rrc_mac_config_req_scg(0, 0, cellGroupConfig); } } else @@ -601,8 +600,8 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message(const module_id_t module_id, const u NR_SIB1_t *sib1 = NR_UE_rrc_inst[module_id].sib1[gNB_index]; // if no sib1 because not acquired yet or expired, get a new one - bool get_sib1 = sib1 ? false : true; - nr_rrc_mac_config_req_mib(module_id, gNB_index, 0, NR_UE_rrc_inst[module_id].mib, get_sib1); + bool get_sib1 = sib1 == NULL; + nr_rrc_mac_config_req_mib(module_id, 0, NR_UE_rrc_inst[module_id].mib, get_sib1); ret = 0; } ASN_STRUCT_FREE(asn_DEF_NR_BCCH_BCH_Message, bcch_message); @@ -1212,7 +1211,7 @@ int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(module_id_t module_id, } // take ServingCellConfigCommon and configure L1/L2 NR_UE_rrc_inst[module_id].servingCellConfigCommonSIB = sib1->servingCellConfigCommon; - nr_rrc_mac_config_req_sib1(module_id, 0, gNB_index, sib1->servingCellConfigCommon); + nr_rrc_mac_config_req_sib1(module_id, 0, sib1->servingCellConfigCommon); nr_rrc_ue_generate_ra_msg(module_id, gNB_index); } else { LOG_E(NR_RRC, "SIB1 not decoded\n"); @@ -1341,23 +1340,23 @@ void nr_rrc_ue_process_masterCellGroup(const protocol_ctxt_t *const ctxt_pP, sizeof(struct NR_MAC_CellGroupConfig)); } - if( cellGroupConfig->sCellToReleaseList != NULL){ + if(cellGroupConfig->sCellToReleaseList != NULL) { //TODO (perform SCell release as specified in 5.3.5.5.8) } - if( cellGroupConfig->spCellConfig != NULL){ + if(cellGroupConfig->spCellConfig != NULL) { if (NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config && - NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig) { + NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig) { memcpy(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig,cellGroupConfig->spCellConfig, sizeof(struct NR_SpCellConfig)); } else { if (NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config) - NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig = cellGroupConfig->spCellConfig; + NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig = cellGroupConfig->spCellConfig; else - NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config = cellGroupConfig; + NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config = cellGroupConfig; } LOG_D(RRC,"Sending CellGroupConfig to MAC\n"); - nr_rrc_mac_config_req_mcg(ctxt_pP->module_id, 0, 0, cellGroupConfig); + nr_rrc_mac_config_req_mcg(ctxt_pP->module_id, 0, cellGroupConfig); //TODO (configure the SpCell as specified in 5.3.5.5.7) }