From 9f88fe18a3674d3441a408b49c03f884947c65ad Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Fri, 4 Mar 2022 16:10:45 +0000 Subject: [PATCH] Creation of get_pdsch_TimeDomainAllocationList function to avoid replicated code --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 16 ++++--------- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 24 ++++++++++++------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 4 ++++ 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 4d16e81bd9..208ea50fbc 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -95,18 +95,12 @@ void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t * // get coreset symbol "map" const uint16_t symb_coreset = (1 << coreset->duration) - 1; - /* check that TDA index 0 fits into DL and does not overlap CORESET */ - NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = NULL; - if (bwp) { - tdaList = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } else if (scc) { - tdaList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } else { - NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1; - tdaList = sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } - + NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = get_pdsch_TimeDomainAllocationList(bwp, + scc, + nrmac->common_channels[0].sib1 ? (const NR_SIB1_t *)nrmac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL); AssertFatal(tdaList->list.count >= 1, "need to have at least one TDA for DL slots\n"); + + /* check that TDA index 0 fits into DL and does not overlap CORESET */ const NR_PDSCH_TimeDomainResourceAllocation_t *tdaP_DL = tdaList->list.array[0]; AssertFatal(!tdaP_DL->k0 || *tdaP_DL->k0 == 0, "TimeDomainAllocation at index 1: non-null k0 (%ld) is not supported by the scheduler\n", diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 2565f8f904..f2a73572dc 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -254,6 +254,21 @@ NR_BWP_t *get_ul_bwp_genericParameters(NR_BWP_Uplink_t *active_ubwp, return genericParameters; } +NR_PDSCH_TimeDomainResourceAllocationList_t *get_pdsch_TimeDomainAllocationList(const NR_BWP_Downlink_t *active_bwp, + const NR_ServingCellConfigCommon_t *ServingCellConfigCommon, + const NR_SIB1_t *sib1) { + NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = NULL; + if (active_bwp) { + tdaList = active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + } else if (ServingCellConfigCommon) { + tdaList = ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + } else { + tdaList = sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + } + return tdaList; +} + + NR_ControlResourceSet_t *get_coreset(module_id_t module_idP, NR_ServingCellConfigCommon_t *scc, void *bwp, @@ -587,14 +602,7 @@ void nr_set_pdsch_semi_static(const NR_SIB1_t *sib1, if (ps->time_domain_allocation != tda) { reset_dmrs = true; ps->time_domain_allocation = tda; - NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = NULL; - if(bwp) { - tdaList = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } else if(scc) { - tdaList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } else { - tdaList = sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } + NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = get_pdsch_TimeDomainAllocationList(bwp, scc, sib1); AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); ps->mapping_type = tdaList->list.array[tda]->mappingType; if (pdsch_Config) { diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 6085b9d7ef..dbe1a61404 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -308,6 +308,10 @@ NR_BWP_t *get_ul_bwp_genericParameters(NR_BWP_Uplink_t *active_ubwp, NR_ServingCellConfigCommon_t *ServingCellConfigCommon, NR_SIB1_t *sib1); +NR_PDSCH_TimeDomainResourceAllocationList_t *get_pdsch_TimeDomainAllocationList(const NR_BWP_Downlink_t *active_bwp, + const NR_ServingCellConfigCommon_t *ServingCellConfigCommon, + const NR_SIB1_t *sib1); + /* find coreset within the search space */ NR_ControlResourceSet_t *get_coreset(module_id_t module_idP, NR_ServingCellConfigCommon_t *scc,