diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 76e9db4fb3..a6d48037a7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -686,7 +686,8 @@ static void other_sib_sched_control(module_id_t module_idP, } AssertFatal(nr_of_candidates > 0, "nr_of_candidates is 0\n"); - NR_ControlResourceSet_t *coreset = get_coreset(gNB_mac, scc, NULL, ss, NR_SearchSpace__searchSpaceType_PR_common); + AssertFatal(ss->controlResourceSetId, "ss->controlResourceSetId is NULL\n"); + NR_ControlResourceSet_t *coreset = get_coreset(gNB_mac, scc, NULL, *ss->controlResourceSetId); if (!gNB_mac->sched_pdcch_otherSI) { gNB_mac->sched_pdcch_otherSI = calloc(1, sizeof(*gNB_mac->sched_pdcch_otherSI)); *gNB_mac->sched_pdcch_otherSI = set_pdcch_structure(gNB_mac, ss, coreset, scc, NULL, type0_PDCCH_CSS_config); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index ed49f3451d..f8c842706c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -369,39 +369,31 @@ NR_pdsch_dmrs_t get_dl_dmrs_params(const NR_ServingCellConfigCommon_t *scc, NR_ControlResourceSet_t *get_coreset(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, - void *bwp, - NR_SearchSpace_t *ss, - NR_SearchSpace__searchSpaceType_PR ss_type) { - - NR_ControlResourceSetId_t coreset_id = *ss->controlResourceSetId; - - if (ss_type == NR_SearchSpace__searchSpaceType_PR_common) { // common search space - NR_ControlResourceSet_t *coreset; - if(coreset_id == 0) { - coreset = nrmac->sched_ctrlCommon->coreset; // this is coreset 0 - } else if (bwp) { - coreset = ((NR_BWP_Downlink_t*)bwp)->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet; - } else if (scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonControlResourceSet) { - coreset = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonControlResourceSet; - } else { - coreset = NULL; - } - - if (coreset) AssertFatal(coreset_id == coreset->controlResourceSetId, - "ID of common ss coreset does not correspond to id set in the " - "search space\n"); - return coreset; - } else { - const int n = ((NR_BWP_DownlinkDedicated_t*)bwp)->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.count; + NR_BWP_DownlinkDedicated_t *bwp_dedicated, + NR_ControlResourceSetId_t coreset_id) +{ + if (coreset_id == 0) { + return nrmac->sched_ctrlCommon->coreset; // this is coreset 0 + } + if (bwp_dedicated) { + const int n = bwp_dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.count; for (int i = 0; i < n; i++) { - NR_ControlResourceSet_t *coreset = - ((NR_BWP_DownlinkDedicated_t*)bwp)->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[i]; - if (coreset_id == coreset->controlResourceSetId) { + NR_ControlResourceSet_t *coreset = bwp_dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[i]; + if (coreset->controlResourceSetId == coreset_id) { return coreset; } } - AssertFatal(0, "Couldn't find coreset with id %ld\n", coreset_id); + AssertFatal(false, "Couldn't find CORESET with id %ld in BWP_DownlinkDedicated\n", coreset_id); } + if (scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonControlResourceSet) { + NR_ControlResourceSet_t *coreset = + scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonControlResourceSet; + if (coreset->controlResourceSetId == coreset_id) { + return coreset; + } + AssertFatal(false, "Couldn't find CORESET with id %ld in commonControlResourceSet\n", coreset_id); + } + AssertFatal(false, "Couldn't find coreset with id %ld\n", coreset_id); } static NR_SearchSpace_t *get_searchspace(NR_ServingCellConfigCommon_t *scc, @@ -2594,7 +2586,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, // setting PDCCH related structures for sched_ctrl sched_ctrl->search_space = get_searchspace(scc, bwpd, target_ss); - sched_ctrl->coreset = get_coreset(nr_mac, scc, bwpd, sched_ctrl->search_space, target_ss); + sched_ctrl->coreset = get_coreset(nr_mac, scc, bwpd, *sched_ctrl->search_space->controlResourceSetId); sched_ctrl->sched_pdcch = set_pdcch_structure(nr_mac, sched_ctrl->search_space, @@ -2635,7 +2627,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, } AssertFatal(sched_ctrl->search_space != NULL, "SearchSpace cannot be null for RA\n"); - sched_ctrl->coreset = get_coreset(nr_mac, scc, dl_bwp, sched_ctrl->search_space, NR_SearchSpace__searchSpaceType_PR_common); + sched_ctrl->coreset = get_coreset(nr_mac, scc, bwpd, *sched_ctrl->search_space->controlResourceSetId); NR_COMMON_channels_t *cc = &nr_mac->common_channels[0]; int ssb_index = cc->ssb_index[UE->UE_beam_index]; sched_ctrl->sched_pdcch = set_pdcch_structure(nr_mac, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index ea07fbeea4..66a9262f22 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -283,9 +283,8 @@ void set_r_pucch_parms(int rsetindex, /* find coreset within the search space */ NR_ControlResourceSet_t *get_coreset(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, - void *bwp, - NR_SearchSpace_t *ss, - NR_SearchSpace__searchSpaceType_PR ss_type); + NR_BWP_DownlinkDedicated_t *bwp_dedicated, + NR_ControlResourceSetId_t coreset_id); long get_K2(NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList, int time_domain_assignment,