From b4675c106f95cc7c06b5fd16dc8817467d3c7e91 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 9 Jan 2023 11:29:19 +0100 Subject: [PATCH 1/7] PDSCH configuration --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 14 +--- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 23 ++----- openair2/LAYER2/NR_MAC_UE/config_ue.c | 32 ++++++--- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 1 - openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 69 +++++-------------- 5 files changed, 51 insertions(+), 88 deletions(-) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index a68411c4cf..2ffb7519da 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -909,7 +909,6 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, const double N_TA_max = Ta_max * bw_scaling * tc_factor; NR_UE_MAC_INST_t *mac = get_mac_inst(0); - NR_BWP_Id_t dl_bwp = mac->current_DL_BWP.bwp_id; NR_BWP_Id_t ul_bwp = mac->current_UL_BWP.bwp_id; NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; @@ -938,17 +937,8 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, } long mapping_type_ul = pusch_TimeDomainAllocationList ? pusch_TimeDomainAllocationList->list.array[0]->mappingType : NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeA; - NR_PDSCH_Config_t *pdsch_Config = NULL; - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; - if(dl_bwp){ - pdsch_Config = (mac->DLbwp[dl_bwp-1] && mac->DLbwp[dl_bwp-1]->bwp_Dedicated->pdsch_Config->choice.setup) ? mac->DLbwp[dl_bwp-1]->bwp_Dedicated->pdsch_Config->choice.setup : NULL; - if (mac->DLbwp[dl_bwp-1] && mac->DLbwp[dl_bwp-1]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = pdsch_Config->pdsch_TimeDomainAllocationList->choice.setup; - else if (mac->DLbwp[dl_bwp-1] && mac->DLbwp[dl_bwp-1]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = mac->DLbwp[dl_bwp-1]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } - else if (mac->scc_SIB && mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup) - pdsch_TimeDomainAllocationList = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + NR_PDSCH_Config_t *pdsch_Config = mac->current_DL_BWP.pdsch_Config; + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = mac->current_DL_BWP.tdaList; long mapping_type_dl = pdsch_TimeDomainAllocationList ? pdsch_TimeDomainAllocationList->list.array[0]->mappingType : NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; NR_DMRS_DownlinkConfig_t *NR_DMRS_dlconfig = NULL; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 619f64dee9..ff71f8bd57 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -3175,16 +3175,15 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, long rbg_size_config; int num_entries = 0; - NR_UplinkConfig_t *uplinkConfig = NULL; + NR_UplinkConfig_t *uplinkConfig = NULL; if (cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated) { uplinkConfig = cg->spCellConfig->spCellConfigDedicated->uplinkConfig; } const NR_BWP_DownlinkDedicated_t *bwpd = NULL; const NR_BWP_UplinkDedicated_t *ubwpd = NULL; - const NR_BWP_DownlinkCommon_t *bwpc = NULL; const NR_BWP_UplinkCommon_t *ubwpc = NULL; - NR_PDSCH_Config_t *pdsch_Config = NULL; + NR_PDSCH_Config_t *pdsch_Config = DL_BWP ? DL_BWP->pdsch_Config : NULL; NR_PUSCH_Config_t *pusch_Config = NULL; NR_PUCCH_Config_t *pucch_Config = NULL; NR_PDCCH_Config_t *pdcch_Config = NULL; @@ -3192,21 +3191,17 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, if(bwp_id > 0) { AssertFatal(cg!=NULL,"Cellgroup is null and bwp_id!=0"); bwpd = cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; - bwpc = cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Common; ubwpd = uplinkConfig ? uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated : NULL; ubwpc = uplinkConfig ? uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Common : NULL; - pdsch_Config = (bwpd->pdsch_Config) ? bwpd->pdsch_Config->choice.setup : NULL; pdcch_Config = (bwpd->pdcch_Config) ? bwpd->pdcch_Config->choice.setup : NULL; pucch_Config = (ubwpd->pucch_Config) ? ubwpd->pucch_Config->choice.setup : NULL; pusch_Config = (ubwpd->pusch_Config) ? ubwpd->pusch_Config->choice.setup : NULL; srs_config = (ubwpd->srs_Config) ? ubwpd->srs_Config->choice.setup : NULL; } else if (cg) { - bwpc = initialDownlinkBWP; ubwpc = initialUplinkBWP; bwpd = cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated ? cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; ubwpd = uplinkConfig ? uplinkConfig->initialUplinkBWP : NULL; - pdsch_Config = (bwpd && bwpd->pdsch_Config) ? bwpd->pdsch_Config->choice.setup : NULL; pdcch_Config = (bwpd && bwpd->pdcch_Config) ? bwpd->pdcch_Config->choice.setup : NULL; pucch_Config = (ubwpd && ubwpd->pucch_Config) ? ubwpd->pucch_Config->choice.setup : NULL; pusch_Config = (ubwpd && ubwpd->pusch_Config) ? ubwpd->pusch_Config->choice.setup : NULL; @@ -3403,7 +3398,7 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, break; case NR_DL_DCI_FORMAT_1_1: - LOG_D(NR_MAC,"DCI_FORMAT 1_1 : pdsch_Config %p, pucch_Config %p\n",pdsch_Config,pucch_Config); + LOG_D(NR_MAC,"DCI_FORMAT 1_1 : pdsch_Config %p, pucch_Config %p\n", pdsch_Config, pucch_Config); // General note: 0 bits condition is ignored as default nbits is 0. // Format identifier size = 1; @@ -3435,15 +3430,11 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, dci_pdu->frequency_domain_assignment.nbits = ((int)ceil(log2((N_RB * (N_RB + 1)) >> 1)) > numRBG) ? (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)) + 1 : numRBG + 1; size += dci_pdu->frequency_domain_assignment.nbits; LOG_D(NR_MAC,"dci_pdu->frequency_domain_assignment.nbits %d (N_RB %d)\n",dci_pdu->frequency_domain_assignment.nbits,N_RB); - // Time domain assignment (see table 5.1.2.1.1-1 in 38.214 - if (pdsch_Config == NULL || pdsch_Config->pdsch_TimeDomainAllocationList==NULL) { - if (bwpc->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList==NULL) - num_entries = 16; // num of entries in default table - else - num_entries = bwpc->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count; - } + // Time domain assignment (see table 5.1.2.1.1-1 in 38.214) + if (DL_BWP->tdaList) + num_entries = DL_BWP->tdaList->list.count; else - num_entries = pdsch_Config->pdsch_TimeDomainAllocationList->choice.setup->list.count; + num_entries = 16; // num of entries in default table dci_pdu->time_domain_assignment.nbits = (int)ceil(log2(num_entries)); LOG_D(NR_MAC,"pdsch tda.nbits= %d\n",dci_pdu->time_domain_assignment.nbits); size += dci_pdu->time_domain_assignment.nbits; diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index ac48e17b62..fa2fb68718 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -547,16 +547,23 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, NR_UE_UL_BWP_t *UL_BWP = &mac->current_UL_BWP; NR_BWP_t dl_genericParameters = {0}; NR_BWP_t ul_genericParameters = {0}; + NR_BWP_DownlinkCommon_t *bwp_dlcommon = NULL; if(scc) { DL_BWP->bwp_id = 0; UL_BWP->bwp_id = 0; - dl_genericParameters = scc->downlinkConfigCommon.initialDownlinkBWP.genericParameters; + bwp_dlcommon = &scc->downlinkConfigCommon.initialDownlinkBWP; + dl_genericParameters = bwp_dlcommon->genericParameters; if(scc->uplinkConfigCommon) ul_genericParameters = scc->uplinkConfigCommon->initialUplinkBWP.genericParameters; else - ul_genericParameters = scc->downlinkConfigCommon.initialDownlinkBWP.genericParameters; + ul_genericParameters = bwp_dlcommon->genericParameters; + + DL_BWP->pdsch_Config = NULL; + if(bwp_dlcommon->pdsch_ConfigCommon) + DL_BWP->tdaList = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; } + if(cell_group_config) { if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->spCellConfigDedicated) { @@ -566,6 +573,12 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, if (spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id) UL_BWP->bwp_id = *spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id; + if(mac->scc) { + bwp_dlcommon = mac->scc->downlinkConfigCommon->initialDownlinkBWP; + } + if(mac->scc_SIB) { + bwp_dlcommon = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP; + } NR_BWP_Downlink_t *bwp_downlink = NULL; const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = spCellConfigDedicated->downlinkBWP_ToAddModList; if (bwpList && DL_BWP->bwp_id > 0) { @@ -576,15 +589,18 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, } AssertFatal(bwp_downlink != NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n", DL_BWP->bwp_id); dl_genericParameters = bwp_downlink->bwp_Common->genericParameters; + DL_BWP->pdsch_Config = bwp_downlink->bwp_Dedicated->pdsch_Config->choice.setup; } else { - if(mac->scc) { - dl_genericParameters = mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; - } - if(mac->scc_SIB) { - dl_genericParameters = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; - } + dl_genericParameters = bwp_dlcommon->genericParameters; + DL_BWP->pdsch_Config = spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup; } + if(DL_BWP->pdsch_Config && + DL_BWP->pdsch_Config->pdsch_TimeDomainAllocationList) + DL_BWP->tdaList = DL_BWP->pdsch_Config->pdsch_TimeDomainAllocationList->choice.setup; + else + DL_BWP->tdaList = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + NR_BWP_Uplink_t *bwp_uplink = NULL; const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList; if (ubwpList && UL_BWP->bwp_id > 0) { diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index bf6b89f71c..7c04d76e8a 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -262,7 +262,6 @@ void get_bwp_info(NR_UE_MAC_INST_t *mac, NR_BWP_DownlinkCommon_t *get_bwp_downlink_common(NR_UE_MAC_INST_t *mac, NR_BWP_Id_t dl_bwp_id); NR_PUSCH_TimeDomainResourceAllocationList_t *choose_ul_tda_list(const NR_PUSCH_Config_t *pusch_Config,NR_PUSCH_ConfigCommon_t *pusch_ConfigCommon); -NR_PDSCH_TimeDomainResourceAllocationList_t *choose_dl_tda_list(NR_PDSCH_Config_t *pdsch_Config,NR_PDSCH_ConfigCommon_t *pdsch_ConfigCommon); int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 17dde4c9c9..7c51a7dd37 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -237,19 +237,6 @@ NR_BWP_DownlinkCommon_t *get_bwp_downlink_common(NR_UE_MAC_INST_t *mac, NR_BWP_I return bwp_Common; } -NR_PDSCH_TimeDomainResourceAllocationList_t *choose_dl_tda_list(NR_PDSCH_Config_t *pdsch_Config,NR_PDSCH_ConfigCommon_t *pdsch_ConfigCommon) { - - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList=NULL; - - if (pdsch_Config && - pdsch_Config->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = pdsch_Config->pdsch_TimeDomainAllocationList->choice.setup; - else if (pdsch_ConfigCommon->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = pdsch_ConfigCommon->pdsch_TimeDomainAllocationList; - - return(pdsch_TimeDomainAllocationList); -} - NR_PUSCH_TimeDomainResourceAllocationList_t *choose_ul_tda_list(const NR_PUSCH_Config_t *pusch_Config,NR_PUSCH_ConfigCommon_t *pusch_ConfigCommon) { NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList=NULL; @@ -645,7 +632,6 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr uint8_t is_Msg3 = 0; NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id; NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id; int default_abc = 1; @@ -815,8 +801,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti; fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_0 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15; - NR_PDSCH_Config_t *pdsch_config= (dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1]) ? mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup : NULL; - int is_common=0; + NR_PDSCH_Config_t *pdsch_config = current_DL_BWP ? current_DL_BWP->pdsch_Config : NULL; + int is_common = 0; if (dci_ind->ss_type == NR_SearchSpace__searchSpaceType_PR_common) { dlsch_config_pdu_1_0->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs ? mac->type0_PDCCH_CSS_config.num_rbs : current_DL_BWP->initial_BWPSize; dlsch_config_pdu_1_0->BWPStart = dci_ind->cset_start; @@ -839,16 +825,9 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; } if( (ra->RA_window_cnt >= 0 && rnti == ra->ra_rnti) || (rnti == ra->t_crnti) ) { - if (mac->scc == NULL) { // use coreset0 + if (mac->scc == NULL) // use coreset0 is_common=1; - } - if (!get_softmodem_params()->sa) { // NSA mode is not using the Initial BWP - pdsch_config = mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup; - } - } else if (dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1]) { - pdsch_config = mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup; - } else if (mac->scc) - pdsch_config = NULL; + } } /* IDENTIFIER_DCI_FORMATS */ @@ -859,17 +838,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr } - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; - if (dl_bwp_id>0 && - mac->DLbwp[dl_bwp_id-1] && - mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated && - mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config && - mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList->choice.setup; - else if (dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1] && mac->DLbwp[dl_bwp_id-1]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = mac->DLbwp[dl_bwp_id-1]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - else if (mac->scc_SIB && mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup) - pdsch_TimeDomainAllocationList = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = (rnti == SI_RNTI) ? NULL : current_DL_BWP->tdaList; int mappingtype; /* TIME_DOM_RESOURCE_ASSIGNMENT */ @@ -880,14 +849,14 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr LOG_W(MAC, "[%d.%d] Invalid time_domain_assignment. Possibly due to false DCI. Ignoring DCI!\n", frame, slot); return -1; } - if(pdsch_TimeDomainAllocationList && rnti!=SI_RNTI) + if(pdsch_TimeDomainAllocationList) mappingtype = pdsch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->mappingType; struct NR_DMRS_DownlinkConfig *dl_dmrs_config = NULL; - if(dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1] != NULL) + if(pdsch_config) dl_dmrs_config = (mappingtype == typeA) ? - mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup : - mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup; + pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup : + pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup; dlsch_config_pdu_1_0->nscid = 0; if(dl_dmrs_config && dl_dmrs_config->scramblingID0) @@ -1084,16 +1053,15 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr LOG_W(NR_MAC,"[%d.%d] bwp_indicator %d > NR_MAX_NUM_BWP Possibly due to false DCI. Ignoring DCI!\n", frame, slot,dci->bwp_indicator.val); return -1; } - NR_BWP_Id_t dl_bwp_id = mac->current_DL_BWP.bwp_id; - NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id; - NR_PDSCH_Config_t *pdsch_Config=NULL; + NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id; + NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id; + NR_PDSCH_Config_t *pdsch_Config = current_DL_BWP->pdsch_Config; NR_BWP_DownlinkDedicated_t *bwpd=NULL; NR_BWP_DownlinkCommon_t *bwpc=NULL; NR_BWP_UplinkDedicated_t *ubwpd=NULL; NR_BWP_UplinkCommon_t *ubwpc=NULL; get_bwp_info(mac,dl_bwp_id,ul_bwp_id,&bwpd,&bwpc,&ubwpd,&ubwpc); - pdsch_Config = bwpd->pdsch_Config->choice.setup; dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti; @@ -1114,7 +1082,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr } /* TIME_DOM_RESOURCE_ASSIGNMENT */ int mappingtype; - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = choose_dl_tda_list(pdsch_Config,bwpc->pdsch_ConfigCommon->choice.setup); + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = current_DL_BWP->tdaList; if (nr_ue_process_dci_time_dom_resource_assignment(mac,NULL,pdsch_TimeDomainAllocationList, NULL,dlsch_config_pdu_1_1,&mappingtype, dci->time_domain_assignment.val,0,false) < 0) { @@ -2115,11 +2083,10 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, NR_BWP_UplinkCommon_t *ubwpc=NULL; get_bwp_info(mac,dl_bwp_id,ul_bwp_id,&bwpd,&bwpc,&ubwpd,&ubwpc); - if (bwpd && - bwpd->pdsch_Config && - bwpd->pdsch_Config->choice.setup && - bwpd->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI && - bwpd->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI[0] == 2) { + if (current_DL_BWP && + current_DL_BWP->pdsch_Config && + current_DL_BWP->pdsch_Config->maxNrofCodeWordsScheduledByDCI && + current_DL_BWP->pdsch_Config->maxNrofCodeWordsScheduledByDCI[0] == 2) { two_transport_blocks = true; number_of_code_word = 2; } @@ -2212,7 +2179,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, if (mac->cg != NULL && mac->cg->physicalCellGroupConfig != NULL && mac->cg->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH != NULL) { - int N_TB_max_DL = bwpd->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI[0]; + int N_TB_max_DL = current_DL_BWP->pdsch_Config->maxNrofCodeWordsScheduledByDCI[0]; pucch->n_HARQ_ACK = (((V_DAI_m_DL - U_DAI_c)%4) * N_TB_max_DL) + N_m_c_rx + N_SPS_c; LOG_D(MAC, "PUCCH power n(%d) = ( V(%d) - U(%d) )mod4 * N_TB(%d) + N(%d) \n", pucch->n_HARQ_ACK, V_DAI_m_DL, U_DAI_c, N_TB_max_DL, N_m_c_rx); } From 91f8f88781912ab3088175a33c0cbaf10239ece3 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 9 Jan 2023 13:33:50 +0100 Subject: [PATCH 2/7] remove pdcch_config from dci_size function --- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 21 ++++--------------- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 2 +- .../NR_MAC_UE/nr_ue_dci_configuration.c | 6 +++--- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 6 +++--- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index ff71f8bd57..b6b0e77e3e 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -3163,7 +3163,7 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, nr_rnti_type_t rnti_type, - int controlResourceSetId, + NR_ControlResourceSet_t *coreset, int bwp_id, int ss_type, uint16_t cset0_bwp_size, @@ -3180,29 +3180,22 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, uplinkConfig = cg->spCellConfig->spCellConfigDedicated->uplinkConfig; } - const NR_BWP_DownlinkDedicated_t *bwpd = NULL; const NR_BWP_UplinkDedicated_t *ubwpd = NULL; const NR_BWP_UplinkCommon_t *ubwpc = NULL; NR_PDSCH_Config_t *pdsch_Config = DL_BWP ? DL_BWP->pdsch_Config : NULL; NR_PUSCH_Config_t *pusch_Config = NULL; NR_PUCCH_Config_t *pucch_Config = NULL; - NR_PDCCH_Config_t *pdcch_Config = NULL; NR_SRS_Config_t *srs_config = NULL; if(bwp_id > 0) { AssertFatal(cg!=NULL,"Cellgroup is null and bwp_id!=0"); - bwpd = cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; ubwpd = uplinkConfig ? uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated : NULL; ubwpc = uplinkConfig ? uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Common : NULL; - pdcch_Config = (bwpd->pdcch_Config) ? bwpd->pdcch_Config->choice.setup : NULL; pucch_Config = (ubwpd->pucch_Config) ? ubwpd->pucch_Config->choice.setup : NULL; pusch_Config = (ubwpd->pusch_Config) ? ubwpd->pusch_Config->choice.setup : NULL; srs_config = (ubwpd->srs_Config) ? ubwpd->srs_Config->choice.setup : NULL; } else if (cg) { ubwpc = initialUplinkBWP; - bwpd = cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated ? - cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; ubwpd = uplinkConfig ? uplinkConfig->initialUplinkBWP : NULL; - pdcch_Config = (bwpd && bwpd->pdcch_Config) ? bwpd->pdcch_Config->choice.setup : NULL; pucch_Config = (ubwpd && ubwpd->pucch_Config) ? ubwpd->pucch_Config->choice.setup : NULL; pusch_Config = (ubwpd && ubwpd->pusch_Config) ? ubwpd->pusch_Config->choice.setup : NULL; srs_config = (ubwpd && ubwpd->srs_Config) ? ubwpd->srs_Config->choice.setup: NULL; @@ -3499,15 +3492,9 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, size += dci_pdu->antenna_ports.nbits; LOG_D(NR_MAC,"dci_pdu->antenna_ports.nbits %d\n",dci_pdu->antenna_ports.nbits); // Tx Config Indication - for (int i = 0; i < pdcch_Config->controlResourceSetToAddModList->list.count; i++) { - if (pdcch_Config->controlResourceSetToAddModList->list.array[i]->controlResourceSetId == controlResourceSetId) { - long *isTciEnable = pdcch_Config->controlResourceSetToAddModList->list.array[i]->tci_PresentInDCI; - if (isTciEnable != NULL) { - dci_pdu->transmission_configuration_indication.nbits = 3; - size += dci_pdu->transmission_configuration_indication.nbits; - } - break; - } + if (coreset->tci_PresentInDCI != NULL) { + dci_pdu->transmission_configuration_indication.nbits = 3; + size += dci_pdu->transmission_configuration_indication.nbits; } // SRS request if (cg->spCellConfig->spCellConfigDedicated->supplementaryUplink==NULL) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 8aee2cc5a3..3e6100e2d5 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -97,7 +97,7 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, nr_rnti_type_t rnti_type, - int controlResourceSetId, + NR_ControlResourceSet_t *coreset, int bwp_id, int ss_type, uint16_t cset0_bwp_size, 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 2815a42c16..04b7d36e5e 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -176,20 +176,20 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t alt_size = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, current_DL_BWP, current_UL_BWP, mac->cg, &temp_pdu, - NR_UL_DCI_FORMAT_0_0, rnti_type, coreset_id, dl_bwp_id, + NR_UL_DCI_FORMAT_0_0, rnti_type, coreset, dl_bwp_id, ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, 0); if(dci_format == NR_UL_DCI_FORMAT_0_0) alt_size = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, current_DL_BWP, current_UL_BWP, mac->cg, &temp_pdu, - NR_DL_DCI_FORMAT_1_0, rnti_type, coreset_id, dl_bwp_id, + NR_DL_DCI_FORMAT_1_0, rnti_type, coreset, dl_bwp_id, ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, 0); } rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, current_DL_BWP, current_UL_BWP, mac->cg, &mac->def_dci_pdu_rel15[dci_format], - dci_format, NR_RNTI_TC, coreset_id, dl_bwp_id, + dci_format, NR_RNTI_TC, coreset, dl_bwp_id, ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, alt_size); rel15->BWPStart = coreset_id == 0 ? mac->type0_PDCCH_CSS_config.cset_start_rb : current_DL_BWP->BWPStart; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 4814250fd9..6f9d829bce 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1194,14 +1194,14 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, scc->uplinkConfigCommon->initialUplinkBWP, current_DL_BWP, current_UL_BWP, CellGroup, &temp_pdu, NR_UL_DCI_FORMAT_0_0, rnti_type, - controlResourceSetId, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, 0); + coreset, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, 0); if(dci_format == NR_UL_DCI_FORMAT_0_0) alt_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP, scc->uplinkConfigCommon->initialUplinkBWP, current_DL_BWP, current_UL_BWP, CellGroup, &temp_pdu, NR_DL_DCI_FORMAT_1_0, rnti_type, - controlResourceSetId, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, 0); + coreset, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, 0); } else @@ -1210,7 +1210,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, int dci_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP, scc->uplinkConfigCommon->initialUplinkBWP, current_DL_BWP, current_UL_BWP, - CellGroup, dci_pdu_rel15, dci_format, rnti_type, controlResourceSetId, + CellGroup, dci_pdu_rel15, dci_format, rnti_type, coreset, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, alt_size); pdcch_dci_pdu->PayloadSizeBits = dci_size; AssertFatal(dci_size <= 64, "DCI sizes above 64 bits not yet supported"); From 0d9d4f55f762335d4f5ca21b2ed55f81cc7a13c7 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 9 Jan 2023 19:36:59 +0100 Subject: [PATCH 3/7] further improvements in tda lists --- .../nfapi/public_inc/fapi_nr_ue_interface.h | 1 + openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 1 + openair2/LAYER2/NR_MAC_COMMON/nr_mac.h | 12 ++ openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 133 ++++++++++-- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 20 +- openair2/LAYER2/NR_MAC_UE/config_ue.c | 22 +- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 13 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 189 ++++++------------ openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 149 +++----------- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 12 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 12 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 3 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 4 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 +- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 1 + 15 files changed, 263 insertions(+), 311 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 0ddc0986bd..e13fbbb790 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -87,6 +87,7 @@ typedef struct { typedef struct { uint16_t rnti; uint8_t dci_format; + uint8_t CoreSetType; int ss_type; // n_CCE index of first CCE for PDCCH reception int n_CCE; diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 2809a21cd4..76db94b63f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -935,6 +935,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, dci_ind->dci_list[dci_ind->number_of_dcis].N_CCE = L; dci_ind->dci_list[dci_ind->number_of_dcis].dci_format = rel15->dci_format_options[k]; dci_ind->dci_list[dci_ind->number_of_dcis].ss_type = rel15->dci_type_options[k]; + dci_ind->dci_list[dci_ind->number_of_dcis].CoreSetType = rel15->coreset.CoreSetType; int n_rb, rb_offset; get_coreset_rballoc(rel15->coreset.frequency_domain_resource, &n_rb, &rb_offset); dci_ind->dci_list[dci_ind->number_of_dcis].cset_start = rel15->BWPStart + rb_offset; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index fec7e90178..e0b8b40fb9 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -603,5 +603,17 @@ typedef struct NR_UE_UL_BWP { int max_fb_time; } NR_UE_UL_BWP_t; +typedef enum { + typeA = 0, + typeB = 1 +} mappingType_t; + +typedef struct NR_ul_tda_info { + mappingType_t mapping_type; + int startSymbolIndex; + int nrOfSymbols; + long k2; +} NR_ul_tda_info_t; + #endif /*__LAYER2_MAC_H__ */ diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index b6b0e77e3e..c62af96a8e 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -419,6 +419,82 @@ const char table_38211_6_3_1_5_5[22][4][2] = { {{'1', '1'}, {'o', 'o'}, {'j', 'o'}, {'1', 'n'}} // tpmi 21 }; +const uint8_t table_6_1_2_1_1_2[16][4]={ + {0,0,0,14}, // row index 1 + {0,0,0,12}, // row index 2 + {0,0,0,10}, // row index 3 + {1,0,2,10}, // row index 4 + {1,0,4,10}, // row index 5 + {1,0,4,8}, // row index 6 + {1,0,4,6}, // row index 7 + {0,1,0,14}, // row index 8 + {0,1,0,12}, // row index 9 + {0,1,0,10}, // row index 10 + {0,2,0,14}, // row index 11 + {0,2,0,12}, // row index 12 + {0,2,0,10}, // row index 13 + {1,0,8,6}, // row index 14 + {0,3,0,14}, // row index 15 + {0,3,0,10} // row index 16 +}; + +const uint8_t table_6_1_2_1_1_3[16][4]={ + {0,0,0,8}, // row index 1 + {0,0,0,12}, // row index 2 + {0,0,0,10}, // row index 3 + {1,0,2,10}, // row index 4 + {1,0,4,4}, // row index 5 + {1,0,4,8}, // row index 6 + {1,0,4,6}, // row index 7 + {0,1,0,8}, // row index 8 + {0,1,0,12}, // row index 9 + {0,1,0,10}, // row index 10 + {0,2,0,6}, // row index 11 + {0,2,0,12}, // row index 12 + {0,2,0,10}, // row index 13 + {1,0,8,4}, // row index 14 + {0,3,0,8}, // row index 15 + {0,3,0,10} // row index 16 +}; + +NR_ul_tda_info_t get_ul_tda_info(NR_PUSCH_TimeDomainResourceAllocationList_t *tdalist, + int tda_index, + int scs, + int normal_CP) +{ + + NR_ul_tda_info_t tda_info = {0}; + int j = scs == 0 ? 1 : scs; + if(tdalist) { + if(tda_index >= tdalist->list.count) { + LOG_E(MAC, "TDA index from DCI %d exceeds TDA list array size %d\n", tda_index, tdalist->list.count); + return tda_info; + } + NR_PUSCH_TimeDomainResourceAllocation_t *tda = tdalist->list.array[tda_index]; + tda_info.mapping_type = tda->mappingType; + tda_info.k2 = tda->k2 ? *tda->k2 : j; + int S, L; + SLIV2SL(tda->startSymbolAndLength, &S, &L); + tda_info.startSymbolIndex = S; + tda_info.nrOfSymbols = L; + } + else { + if(normal_CP) { + tda_info.mapping_type = table_6_1_2_1_1_2[tda_index][0]; + tda_info.k2 = table_6_1_2_1_1_2[tda_index][1] + j; + tda_info.startSymbolIndex = table_6_1_2_1_1_2[tda_index][2]; + tda_info.nrOfSymbols = table_6_1_2_1_1_2[tda_index][3]; + } + else { + tda_info.mapping_type = table_6_1_2_1_1_3[tda_index][0]; + tda_info.k2 = table_6_1_2_1_1_3[tda_index][1] + j; + tda_info.startSymbolIndex = table_6_1_2_1_1_3[tda_index][2]; + tda_info.nrOfSymbols = table_6_1_2_1_1_3[tda_index][3]; + } + } + return tda_info; +} + void get_info_from_tda_tables(int default_abc, int tda, int dmrs_TypeA_Position, @@ -3130,6 +3206,39 @@ uint8_t compute_precoding_information(NR_PUSCH_Config_t *pusch_Config, return nbits; } +NR_PDSCH_TimeDomainResourceAllocationList_t *get_dl_tdalist(const NR_UE_DL_BWP_t *DL_BWP, + int controlResourceSetId, + int ss_type, + nr_rnti_type_t rnti_type) +{ + + if(!DL_BWP) return NULL; + // see table 5.1.2.1.1-1 in 38.214 + if((rnti_type == NR_RNTI_CS || rnti_type == NR_RNTI_C || rnti_type == NR_RNTI_MCS_C) && + !(ss_type == NR_SearchSpace__searchSpaceType_PR_common && controlResourceSetId == 0) && + (DL_BWP->pdsch_Config && DL_BWP->pdsch_Config->pdsch_TimeDomainAllocationList)) + return DL_BWP->pdsch_Config->pdsch_TimeDomainAllocationList->choice.setup; + else + return DL_BWP->tdaList; + +} + + +NR_PUSCH_TimeDomainResourceAllocationList_t *get_ul_tdalist(const NR_UE_UL_BWP_t *UL_BWP, + int controlResourceSetId, + int ss_type, + nr_rnti_type_t rnti_type) +{ + + if((rnti_type == NR_RNTI_CS || rnti_type == NR_RNTI_C || rnti_type == NR_RNTI_MCS_C) && + !(ss_type == NR_SearchSpace__searchSpaceType_PR_common && controlResourceSetId == 0) && + (UL_BWP->pusch_Config && UL_BWP->pusch_Config->pusch_TimeDomainAllocationList)) + return UL_BWP->pusch_Config->pusch_TimeDomainAllocationList->choice.setup; + else + return UL_BWP->tdaList; +} + + uint16_t get_rb_bwp_dci(nr_dci_format_t format, int ss_type, uint16_t cset0_bwp_size, @@ -3181,23 +3290,18 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, } const NR_BWP_UplinkDedicated_t *ubwpd = NULL; - const NR_BWP_UplinkCommon_t *ubwpc = NULL; NR_PDSCH_Config_t *pdsch_Config = DL_BWP ? DL_BWP->pdsch_Config : NULL; - NR_PUSCH_Config_t *pusch_Config = NULL; + NR_PUSCH_Config_t *pusch_Config = UL_BWP ? UL_BWP->pusch_Config : NULL; NR_PUCCH_Config_t *pucch_Config = NULL; NR_SRS_Config_t *srs_config = NULL; if(bwp_id > 0) { AssertFatal(cg!=NULL,"Cellgroup is null and bwp_id!=0"); ubwpd = uplinkConfig ? uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated : NULL; - ubwpc = uplinkConfig ? uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Common : NULL; pucch_Config = (ubwpd->pucch_Config) ? ubwpd->pucch_Config->choice.setup : NULL; - pusch_Config = (ubwpd->pusch_Config) ? ubwpd->pusch_Config->choice.setup : NULL; srs_config = (ubwpd->srs_Config) ? ubwpd->srs_Config->choice.setup : NULL; } else if (cg) { - ubwpc = initialUplinkBWP; ubwpd = uplinkConfig ? uplinkConfig->initialUplinkBWP : NULL; pucch_Config = (ubwpd && ubwpd->pucch_Config) ? ubwpd->pucch_Config->choice.setup : NULL; - pusch_Config = (ubwpd && ubwpd->pusch_Config) ? ubwpd->pusch_Config->choice.setup : NULL; srs_config = (ubwpd && ubwpd->srs_Config) ? ubwpd->srs_Config->choice.setup: NULL; } @@ -3269,14 +3373,11 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, LOG_D(NR_MAC,"PUSCH Frequency Domain Assignment nbits %d, N_RB %d\n",dci_pdu->frequency_domain_assignment.nbits,N_RB); size += dci_pdu->frequency_domain_assignment.nbits; // Time domain assignment - if (pusch_Config==NULL || pusch_Config->pusch_TimeDomainAllocationList==NULL) { - if (ubwpc->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList==NULL) - num_entries = 16; // num of entries in default table - else - num_entries = ubwpc->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.count; - } + NR_PUSCH_TimeDomainResourceAllocationList_t *tdalistul = get_ul_tdalist(UL_BWP, coreset->controlResourceSetId, ss_type, rnti_type); + if (tdalistul) + num_entries = tdalistul->list.count; else - num_entries = pusch_Config->pusch_TimeDomainAllocationList->choice.setup->list.count; + num_entries = 16; // num of entries in default table dci_pdu->time_domain_assignment.nbits = (int)ceil(log2(num_entries)); LOG_D(NR_MAC,"PUSCH Time Domain Allocation nbits %d, pusch_Config %p\n",dci_pdu->time_domain_assignment.nbits,pusch_Config); size += dci_pdu->time_domain_assignment.nbits; @@ -3423,9 +3524,9 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, dci_pdu->frequency_domain_assignment.nbits = ((int)ceil(log2((N_RB * (N_RB + 1)) >> 1)) > numRBG) ? (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)) + 1 : numRBG + 1; size += dci_pdu->frequency_domain_assignment.nbits; LOG_D(NR_MAC,"dci_pdu->frequency_domain_assignment.nbits %d (N_RB %d)\n",dci_pdu->frequency_domain_assignment.nbits,N_RB); - // Time domain assignment (see table 5.1.2.1.1-1 in 38.214) - if (DL_BWP->tdaList) - num_entries = DL_BWP->tdaList->list.count; + NR_PDSCH_TimeDomainResourceAllocationList_t *tdalist = get_dl_tdalist(DL_BWP, coreset->controlResourceSetId, ss_type, rnti_type); + if (tdalist) + num_entries = tdalist->list.count; else num_entries = 16; // num of entries in default table dci_pdu->time_domain_assignment.nbits = (int)ceil(log2(num_entries)); diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 3e6100e2d5..a41467b3fc 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -51,11 +51,6 @@ typedef enum { pusch_len2 = 2 } pusch_maxLength_t; -typedef enum { - typeA = 0, - typeB = 1 -} mappingType_t; - uint32_t get_Y(const NR_SearchSpace_t *ss, int slot, rnti_t rnti); uint8_t get_BG(uint32_t A, uint16_t R); @@ -89,6 +84,21 @@ uint8_t compute_precoding_information(NR_PUSCH_Config_t *pusch_Config, const uint8_t *nrOfLayers, uint32_t *val); +NR_PDSCH_TimeDomainResourceAllocationList_t *get_dl_tdalist(const NR_UE_DL_BWP_t *DL_BWP, + int controlResourceSetId, + int ss_type, + nr_rnti_type_t rnti_type); + +NR_PUSCH_TimeDomainResourceAllocationList_t *get_ul_tdalist(const NR_UE_UL_BWP_t *UL_BWP, + int controlResourceSetId, + int ss_type, + nr_rnti_type_t rnti_type); + +NR_ul_tda_info_t get_ul_tda_info(NR_PUSCH_TimeDomainResourceAllocationList_t *tdalist, + int tda_index, + int scs, + int normal_CP); + uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, const NR_BWP_UplinkCommon_t *initialUplinkBWP, const NR_UE_DL_BWP_t *DL_BWP, diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index fa2fb68718..108948adb1 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -548,11 +548,13 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, NR_BWP_t dl_genericParameters = {0}; NR_BWP_t ul_genericParameters = {0}; NR_BWP_DownlinkCommon_t *bwp_dlcommon = NULL; + NR_BWP_UplinkCommon_t *bwp_ulcommon = NULL; if(scc) { DL_BWP->bwp_id = 0; UL_BWP->bwp_id = 0; bwp_dlcommon = &scc->downlinkConfigCommon.initialDownlinkBWP; + bwp_ulcommon = &scc->uplinkConfigCommon->initialUplinkBWP; dl_genericParameters = bwp_dlcommon->genericParameters; if(scc->uplinkConfigCommon) ul_genericParameters = scc->uplinkConfigCommon->initialUplinkBWP.genericParameters; @@ -562,6 +564,8 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, DL_BWP->pdsch_Config = NULL; if(bwp_dlcommon->pdsch_ConfigCommon) DL_BWP->tdaList = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + if(bwp_ulcommon->pusch_ConfigCommon) + UL_BWP->tdaList = bwp_ulcommon->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; } if(cell_group_config) { @@ -575,9 +579,11 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, if(mac->scc) { bwp_dlcommon = mac->scc->downlinkConfigCommon->initialDownlinkBWP; + bwp_ulcommon = mac->scc->uplinkConfigCommon->initialUplinkBWP; } if(mac->scc_SIB) { bwp_dlcommon = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP; + bwp_ulcommon = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; } NR_BWP_Downlink_t *bwp_downlink = NULL; const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = spCellConfigDedicated->downlinkBWP_ToAddModList; @@ -595,11 +601,8 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, dl_genericParameters = bwp_dlcommon->genericParameters; DL_BWP->pdsch_Config = spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup; } - if(DL_BWP->pdsch_Config && - DL_BWP->pdsch_Config->pdsch_TimeDomainAllocationList) - DL_BWP->tdaList = DL_BWP->pdsch_Config->pdsch_TimeDomainAllocationList->choice.setup; - else - DL_BWP->tdaList = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + DL_BWP->tdaList = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + UL_BWP->tdaList = bwp_ulcommon->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; NR_BWP_Uplink_t *bwp_uplink = NULL; const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList; @@ -611,14 +614,11 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, } AssertFatal(bwp_uplink != NULL,"Couldn't find ULBWP corresponding to BWP ID %ld\n",UL_BWP->bwp_id); ul_genericParameters = bwp_uplink->bwp_Common->genericParameters; + UL_BWP->pusch_Config = bwp_uplink->bwp_Dedicated->pusch_Config->choice.setup; } else { - if(mac->scc) { - ul_genericParameters = mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; - } - if(mac->scc_SIB) { - ul_genericParameters = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters; - } + UL_BWP->pusch_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pusch_Config->choice.setup; + ul_genericParameters = bwp_ulcommon->genericParameters; } } else diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 7c04d76e8a..deb2ceb217 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -261,15 +261,11 @@ void get_bwp_info(NR_UE_MAC_INST_t *mac, NR_BWP_DownlinkCommon_t *get_bwp_downlink_common(NR_UE_MAC_INST_t *mac, NR_BWP_Id_t dl_bwp_id); -NR_PUSCH_TimeDomainResourceAllocationList_t *choose_ul_tda_list(const NR_PUSCH_Config_t *pusch_Config,NR_PUSCH_ConfigCommon_t *pusch_ConfigCommon); - int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList, NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList, - nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, - fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, - int *mappingtype, - uint8_t time_domain_ind, + fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, + int *mapping_type, + uint8_t time_domain_ind, int default_abc, bool use_default); @@ -474,7 +470,7 @@ int16_t compute_nr_SSB_PL(NR_UE_MAC_INST_t *mac, short ssb_rsrp_dBm); // - in which ULSCH should be scheduled. K2 is configured in RRC configuration. // PUSCH Msg3 scheduler: // - scheduled by RAR UL grant according to 8.3 of TS 38.213 -int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, uint8_t is_Msg3, frame_t current_frame, int current_slot, frame_t *frame_tx, int *slot_tx, uint8_t tda_id); +int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, uint8_t is_Msg3, frame_t current_frame, int current_slot, frame_t *frame_tx, int *slot_tx, long k2); int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti); @@ -487,6 +483,7 @@ int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti); // - 6.4.1.1.1 of TS 38.211 // - 6.3.1.7 of 38.211 int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, + NR_ul_tda_info_t *tda_info, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci, RAR_grant_t *rar_grant, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 7c51a7dd37..d74767f860 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -237,19 +237,6 @@ NR_BWP_DownlinkCommon_t *get_bwp_downlink_common(NR_UE_MAC_INST_t *mac, NR_BWP_I return bwp_Common; } -NR_PUSCH_TimeDomainResourceAllocationList_t *choose_ul_tda_list(const NR_PUSCH_Config_t *pusch_Config,NR_PUSCH_ConfigCommon_t *pusch_ConfigCommon) { - - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList=NULL; - - if (pusch_Config && - pusch_Config->pusch_TimeDomainAllocationList) - pusch_TimeDomainAllocationList = pusch_Config->pusch_TimeDomainAllocationList->choice.setup; - else if (pusch_ConfigCommon->pusch_TimeDomainAllocationList) - pusch_TimeDomainAllocationList = pusch_ConfigCommon->pusch_TimeDomainAllocationList; - - return(pusch_TimeDomainAllocationList); -} - int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti){ RA_config_t *ra = &mac->ra; @@ -469,60 +456,19 @@ int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *p } int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList, NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList, - nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, int *mapping_type, uint8_t time_domain_ind, int default_abc, - bool use_default){ + bool use_default) +{ int dmrs_typeA_pos = (mac->scc != NULL) ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position; // uint8_t k_offset=0; int sliv_S=0; int sliv_L=0; - uint8_t mu_pusch = 1; - - // definition table j Table 6.1.2.1.1-4 - uint8_t j = (mu_pusch==3)?3:(mu_pusch==2)?2:1; - uint8_t table_6_1_2_1_1_2_time_dom_res_alloc_A[16][3]={ // for PUSCH from TS 38.214 subclause 6.1.2.1.1 - {j, 0,14}, // row index 1 - {j, 0,12}, // row index 2 - {j, 0,10}, // row index 3 - {j, 2,10}, // row index 4 - {j, 4,10}, // row index 5 - {j, 4,8}, // row index 6 - {j, 4,6}, // row index 7 - {j+1,0,14}, // row index 8 - {j+1,0,12}, // row index 9 - {j+1,0,10}, // row index 10 - {j+2,0,14}, // row index 11 - {j+2,0,12}, // row index 12 - {j+2,0,10}, // row index 13 - {j, 8,6}, // row index 14 - {j+3,0,14}, // row index 15 - {j+3,0,10} // row index 16 - }; - /*uint8_t table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[16][3]={ // for PUSCH from TS 38.214 subclause 6.1.2.1.1 - {j, 0,8}, // row index 1 - {j, 0,12}, // row index 2 - {j, 0,10}, // row index 3 - {j, 2,10}, // row index 4 - {j, 4,4}, // row index 5 - {j, 4,8}, // row index 6 - {j, 4,6}, // row index 7 - {j+1,0,8}, // row index 8 - {j+1,0,12}, // row index 9 - {j+1,0,10}, // row index 10 - {j+2,0,6}, // row index 11 - {j+2,0,12}, // row index 12 - {j+2,0,10}, // row index 13 - {j, 8,4}, // row index 14 - {j+3,0,8}, // row index 15 - {j+3,0,10} // row index 16 - };*/ /* * TS 38.214 subclause 5.1.2.1 Resource allocation in time domain (downlink) @@ -563,39 +509,6 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, dlsch_config_pdu->number_symbols = sliv_L; dlsch_config_pdu->start_symbol = sliv_S; } - } /* - * TS 38.214 subclause 6.1.2.1 Resource allocation in time domain (uplink) - */ - if(pusch_config_pdu != NULL){ - if (pusch_TimeDomainAllocationList && use_default==false) { - if (time_domain_ind >= pusch_TimeDomainAllocationList->list.count) { - LOG_E(NR_MAC, "time_domain_ind %d >= pusch->TimeDomainAllocationList->list.count %d\n", - time_domain_ind, pusch_TimeDomainAllocationList->list.count); - pusch_config_pdu->start_symbol_index=0; - pusch_config_pdu->nr_of_symbols=0; - return -1; - } - - LOG_D(NR_MAC,"Filling Time-Domain Allocation from pusch_TimeDomainAllocationList\n"); - int startSymbolAndLength = pusch_TimeDomainAllocationList->list.array[time_domain_ind]->startSymbolAndLength; - int S,L; - SLIV2SL(startSymbolAndLength,&S,&L); - pusch_config_pdu->start_symbol_index=S; - pusch_config_pdu->nr_of_symbols=L; - } - else { - LOG_D(NR_MAC,"Filling Time-Domain Allocation from tables\n"); -// k_offset = table_6_1_2_1_1_2_time_dom_res_alloc_A[time_domain_ind-1][0]; - sliv_S = table_6_1_2_1_1_2_time_dom_res_alloc_A[time_domain_ind][1]; - sliv_L = table_6_1_2_1_1_2_time_dom_res_alloc_A[time_domain_ind][2]; - // k_offset = table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][0]; - // sliv_S = table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][1]; - // sliv_L = table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][2]; - pusch_config_pdu->nr_of_symbols = sliv_L; - pusch_config_pdu->start_symbol_index = sliv_S; - } - LOG_D(NR_MAC,"start_symbol = %i\n", pusch_config_pdu->start_symbol_index); - LOG_D(NR_MAC,"number_symbols = %i\n", pusch_config_pdu->nr_of_symbols); } return 0; } @@ -621,6 +534,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr uint16_t rnti = dci_ind->rnti; uint8_t dci_format = dci_ind->dci_format; + int coreset_type = dci_ind->CoreSetType == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG; // 0 for coreset0, 1 otherwise int ret = 0; int pucch_res_set_cnt = 0, valid = 0; frame_t frame_tx = 0; @@ -636,6 +550,10 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr int default_abc = 1; LOG_D(MAC, "In %s: Processing received DCI format %s\n", __FUNCTION__, dci_formats[dci_format]); + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; + int normal_CP = current_UL_BWP->cyclicprefix ? 0 : 1; + NR_ul_tda_info_t tda_info = {0}; switch(dci_format){ case NR_UL_DCI_FORMAT_0_0: { @@ -660,7 +578,12 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // - SUL_IND_0_0 // Schedule PUSCH - ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, dci->time_domain_assignment.val); + pusch_TimeDomainAllocationList = get_ul_tdalist(current_UL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, rnti)); + tda_info = get_ul_tda_info(pusch_TimeDomainAllocationList, dci->time_domain_assignment.val, current_UL_BWP->scs, normal_CP); + if(tda_info.nrOfSymbols == 0) + ret = -1; + else + ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, tda_info.k2); if (ret != -1){ @@ -679,9 +602,10 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr pthread_mutex_unlock(&ul_config->mutex_ul_config); // Config PUSCH PDU - ret = nr_config_pusch_pdu(mac, pusch_config_pdu, dci, NULL, rnti, &dci_format); + ret = nr_config_pusch_pdu(mac, &tda_info, pusch_config_pdu, dci, NULL, rnti, &dci_format); } - + else + LOG_E(MAC,"Cannot schedule PUSCH\n"); break; } @@ -720,7 +644,12 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // - SRS_RESOURCE_IND // Schedule PUSCH - ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, dci->time_domain_assignment.val); + pusch_TimeDomainAllocationList = get_ul_tdalist(current_UL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, rnti)); + tda_info = get_ul_tda_info(pusch_TimeDomainAllocationList, dci->time_domain_assignment.val, current_UL_BWP->scs, normal_CP); + if(tda_info.nrOfSymbols == 0) + ret = -1; + else + ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, tda_info.k2); if (ret != -1){ @@ -741,8 +670,10 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr pthread_mutex_unlock(&ul_config->mutex_ul_config); // Config PUSCH PDU - ret = nr_config_pusch_pdu(mac, pusch_config_pdu, dci, NULL, rnti, &dci_format); - } else AssertFatal(1==0,"Cannot schedule PUSCH\n"); + ret = nr_config_pusch_pdu(mac, &tda_info, pusch_config_pdu, dci, NULL, rnti, &dci_format); + } + else + LOG_E(MAC,"Cannot schedule PUSCH\n"); break; } @@ -837,13 +768,11 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr return -1; } - - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = (rnti == SI_RNTI) ? NULL : current_DL_BWP->tdaList; - int mappingtype; /* TIME_DOM_RESOURCE_ASSIGNMENT */ - if (nr_ue_process_dci_time_dom_resource_assignment(mac,NULL,pdsch_TimeDomainAllocationList, - NULL,dlsch_config_pdu_1_0,&mappingtype, + pdsch_TimeDomainAllocationList = get_dl_tdalist(current_DL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, rnti)); + if (nr_ue_process_dci_time_dom_resource_assignment(mac,pdsch_TimeDomainAllocationList, + dlsch_config_pdu_1_0,&mappingtype, dci->time_domain_assignment.val, default_abc,rnti==SI_RNTI) < 0) { LOG_W(MAC, "[%d.%d] Invalid time_domain_assignment. Possibly due to false DCI. Ignoring DCI!\n", frame, slot); @@ -1082,9 +1011,10 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr } /* TIME_DOM_RESOURCE_ASSIGNMENT */ int mappingtype; - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = current_DL_BWP->tdaList; - if (nr_ue_process_dci_time_dom_resource_assignment(mac,NULL,pdsch_TimeDomainAllocationList, - NULL,dlsch_config_pdu_1_1,&mappingtype, + + pdsch_TimeDomainAllocationList = get_dl_tdalist(current_DL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, rnti)); + if (nr_ue_process_dci_time_dom_resource_assignment(mac,pdsch_TimeDomainAllocationList, + dlsch_config_pdu_1_1,&mappingtype, dci->time_domain_assignment.val,0,false) < 0) { LOG_W(MAC, "[%d.%d] Invalid time_domain_assignment. Possibly due to false DCI. Ignoring DCI!\n", frame, slot); return -1; @@ -1382,25 +1312,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr break; } - - if(rnti == SI_RNTI){ - - // }else if(rnti == mac->ra_rnti){ - - }else if(rnti == P_RNTI){ - - }else{ // c-rnti - - /// check if this is pdcch order - //dci->random_access_preamble_index; - //dci->ss_pbch_index; - //dci->prach_mask_index; - - /// else normal DL-SCH grant - } - return ret; - } int8_t nr_ue_process_csirs_measurements(module_id_t module_id, @@ -1535,19 +1447,22 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, LOG_E(MAC,"PUCCH Unsupported code block group for serving cell config\n"); return; } + + NR_PUSCH_Config_t *pusch_Config = current_UL_BWP ? current_UL_BWP->pusch_Config : NULL; + if (pusch_Config) { + pusch_id = pusch_Config->dataScramblingIdentityPUSCH; + if (pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA != NULL) + id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup->transformPrecodingDisabled->scramblingID0; + else if (pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB != NULL) + id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->transformPrecodingDisabled->scramblingID0; + } + NR_PUCCH_Config_t *pucch_Config; if (bwp_id>0 && mac->ULbwp[bwp_id-1] && mac->ULbwp[bwp_id-1]->bwp_Dedicated && mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config && mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup) { - NR_PUSCH_Config_t *pusch_Config = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup; - pusch_id = pusch_Config->dataScramblingIdentityPUSCH; - if (pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA != NULL) - id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup->transformPrecodingDisabled->scramblingID0; - else if (pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB != NULL) - id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->transformPrecodingDisabled->scramblingID0; - else *id0 = mac->physCellId; pucch_Config = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup; } else if (bwp_id==0 && @@ -1610,8 +1525,8 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, pucch_pdu->n_bit = O_uci+O_SR; pucch_pdu->nr_of_symbols = pucchres->format.choice.format2->nrofSymbols; pucch_pdu->start_symbol_index = pucchres->format.choice.format2->startingSymbolIndex; - pucch_pdu->data_scrambling_id = pusch_id!= NULL ? *pusch_id : mac->physCellId; - pucch_pdu->dmrs_scrambling_id = id0!= NULL ? *id0 : mac->physCellId; + pucch_pdu->data_scrambling_id = pusch_id != NULL ? *pusch_id : mac->physCellId; + pucch_pdu->dmrs_scrambling_id = id0 != NULL ? *id0 : mac->physCellId; pucch_pdu->prb_size = compute_pucch_prb_size(2,pucchres->format.choice.format2->nrofPRBs, O_uci+O_SR,O_CSI,pucch_Config->format2->choice.setup->maxCodeRate, 2,pucchres->format.choice.format2->nrofSymbols,8); @@ -1621,7 +1536,7 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, pucch_pdu->n_bit = O_uci+O_SR; pucch_pdu->nr_of_symbols = pucchres->format.choice.format3->nrofSymbols; pucch_pdu->start_symbol_index = pucchres->format.choice.format3->startingSymbolIndex; - pucch_pdu->data_scrambling_id = pusch_id!= NULL ? *pusch_id : mac->physCellId; + pucch_pdu->data_scrambling_id = pusch_id != NULL ? *pusch_id : mac->physCellId; if (pucch_Config->format3 == NULL) { pucch_pdu->pi_2bpsk = 0; pucch_pdu->add_dmrs_flag = 0; @@ -4041,7 +3956,15 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t #endif // Schedule Msg3 - ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, rar_grant.Msg3_t_alloc); + NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + int normal_CP = current_UL_BWP->cyclicprefix ? 0 : 1; + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = get_ul_tdalist(current_UL_BWP, *ra->ss->controlResourceSetId, ra->ss->searchSpaceType->present, NR_RNTI_RA); + NR_ul_tda_info_t tda_info = get_ul_tda_info(pusch_TimeDomainAllocationList, rar_grant.Msg3_t_alloc, current_UL_BWP->scs, normal_CP); + if(tda_info.nrOfSymbols == 0) { + LOG_E(MAC, "Cannot schedule Msg3. Something wrong in TDA information\n"); + return -1; + } + ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, tda_info.k2); if (ret != -1){ @@ -4069,7 +3992,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t pthread_mutex_unlock(&ul_config->mutex_ul_config); // Config Msg3 PDU - nr_config_pusch_pdu(mac, pusch_config_pdu, NULL, &rar_grant, rnti, NULL); + nr_config_pusch_pdu(mac, &tda_info, pusch_config_pdu, NULL, &rar_grant, rnti, NULL); } } else { diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 813292f462..84075cd337 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -100,49 +100,6 @@ void fill_scheduled_response(nr_scheduled_response_t *scheduled_response, } -/* - * This function returns the slot offset K2 corresponding to a given time domain - * indication value from RRC configuration. - */ -long get_k2(NR_UE_MAC_INST_t *mac, uint8_t time_domain_ind) { - long k2 = -1; - - NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id; - // Get K2 from RRC configuration - NR_PUSCH_Config_t *pusch_config= ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup : NULL; - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; - if (pusch_config && pusch_config->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = pusch_config->pusch_TimeDomainAllocationList->choice.setup; - } - else if (ul_bwp_id > 0 && - mac->ULbwp[ul_bwp_id-1] && - mac->ULbwp[ul_bwp_id-1]->bwp_Common&& - mac->ULbwp[ul_bwp_id-1]->bwp_Common->pusch_ConfigCommon&& - mac->ULbwp[ul_bwp_id-1]->bwp_Common->pusch_ConfigCommon->choice.setup && - mac->ULbwp[ul_bwp_id-1]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { - pusch_TimeDomainAllocationList = mac->ULbwp[ul_bwp_id-1]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } - else if (mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) - pusch_TimeDomainAllocationList=mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - else AssertFatal(1==0,"need to fall back to default PUSCH time-domain allocations\n"); - - if (pusch_TimeDomainAllocationList) { - if (time_domain_ind >= pusch_TimeDomainAllocationList->list.count) { - LOG_E(NR_MAC, "time_domain_ind %d >= pusch->TimeDomainAllocationList->list.count %d\n", - time_domain_ind, pusch_TimeDomainAllocationList->list.count); - return -1; - } - k2 = *pusch_TimeDomainAllocationList->list.array[time_domain_ind]->k2; - } - - AssertFatal(k2 >= DURATION_RX_TO_TX, - "Slot offset K2 (%ld) cannot be less than DURATION_RX_TO_TX (%d). K2 set according to min_rxtxtime in config file.\n", - k2,DURATION_RX_TO_TX); - - LOG_D(NR_MAC, "get_k2(): k2 is %ld\n", k2); - return k2; -} - /* * This function returns the UL config corresponding to a given UL slot * from MAC instance . @@ -182,8 +139,7 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl 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_ServingCellConfigCommon_t *scc = mac->scc; - NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id; - NR_BWP_UplinkDedicated_t *ubwpd=NULL; + NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; NR_SRS_Config_t *srs_config = NULL; if (mac->cg && @@ -191,15 +147,10 @@ void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_con mac->cg->spCellConfig->spCellConfigDedicated && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { - ubwpd = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; srs_config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config->choice.setup; } - NR_PUSCH_Config_t *pusch_Config = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? - mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup : - (ubwpd? - ubwpd->pusch_Config->choice.setup: - NULL); + NR_PUSCH_Config_t *pusch_Config = current_UL_BWP->pusch_Config; long transformPrecoder; if (pusch_Config && pusch_Config->transformPrecoder) @@ -339,19 +290,9 @@ void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_con void ul_ports_config(NR_UE_MAC_INST_t *mac, int *n_front_load_symb, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci) { uint8_t rank = pusch_config_pdu->nrOfLayers; - - NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id; NR_ServingCellConfigCommon_t *scc = mac->scc; - NR_BWP_UplinkDedicated_t *ubwpd=NULL; - if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) - ubwpd = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; - - NR_PUSCH_Config_t *pusch_Config = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup : (ubwpd?ubwpd->pusch_Config->choice.setup:NULL); + NR_PUSCH_Config_t *pusch_Config = mac->current_UL_BWP.pusch_Config; AssertFatal(pusch_Config!=NULL,"pusch_Config shouldn't be null\n"); long transformPrecoder; @@ -536,6 +477,7 @@ void ul_ports_config(NR_UE_MAC_INST_t *mac, int *n_front_load_symb, nfapi_nr_ue_ // - 6.4.1.1.1 of TS 38.211 // - 6.3.1.7 of 38.211 int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, + NR_ul_tda_info_t *tda_info, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci, RAR_grant_t *rar_grant, @@ -545,8 +487,6 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, int f_alloc; int mask; - int StartSymbolIndex; - int NrOfSymbols; uint8_t nb_dmrs_re_per_rb; uint16_t l_prime_mask = 0; @@ -555,7 +495,6 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, int rnti_type = get_rnti_type(mac, rnti); NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id; // Common configuration pusch_config_pdu->dmrs_config_type = pusch_dmrs_type1; @@ -569,30 +508,11 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_dmrs_AdditionalPosition_t add_pos = pusch_dmrs_pos2; int dmrslength = 1; + NR_PUSCH_Config_t *pusch_Config = current_UL_BWP->pusch_Config; if (rar_grant) { // Note: for Msg3 or MsgA PUSCH transmission the N_PRB_oh is always set to 0 - NR_BWP_Uplink_t *ubwp = ul_bwp_id > 0 ? mac->ULbwp[ul_bwp_id - 1] : NULL; - NR_BWP_UplinkDedicated_t *ibwp; - int startSymbolAndLength,mappingtype; - NR_PUSCH_Config_t *pusch_Config=NULL; - if (mac->cg && ubwp && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { - - ibwp = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; - pusch_Config = ibwp->pusch_Config->choice.setup; - startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[rar_grant->Msg3_t_alloc]->startSymbolAndLength; - mappingtype = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[rar_grant->Msg3_t_alloc]->mappingType; - - } - else { - startSymbolAndLength = initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[rar_grant->Msg3_t_alloc]->startSymbolAndLength; - mappingtype = initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[rar_grant->Msg3_t_alloc]->mappingType; - } int ibwp_start = current_UL_BWP->initial_BWPStart; int ibwp_size = current_UL_BWP->initial_BWPSize; int abwp_start = current_UL_BWP->BWPStart; @@ -623,12 +543,11 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, //pusch_config_pdu->rb_start += ibwp_start - abwp_start; // Time domain allocation - SLIV2SL(startSymbolAndLength, &StartSymbolIndex, &NrOfSymbols); - pusch_config_pdu->start_symbol_index = StartSymbolIndex; - pusch_config_pdu->nr_of_symbols = NrOfSymbols; + pusch_config_pdu->start_symbol_index = tda_info->startSymbolIndex; + pusch_config_pdu->nr_of_symbols = tda_info->nrOfSymbols; - l_prime_mask = get_l_prime(NrOfSymbols, mappingtype, add_pos, dmrslength, StartSymbolIndex, mac->scc ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position); - LOG_D(NR_MAC, "MSG3 start_sym:%d NR Symb:%d mappingtype:%d, DMRS_MASK:%x\n", pusch_config_pdu->start_symbol_index, pusch_config_pdu->nr_of_symbols, mappingtype, l_prime_mask); + l_prime_mask = get_l_prime(tda_info->nrOfSymbols, tda_info->mapping_type, add_pos, dmrslength, tda_info->startSymbolIndex, mac->scc ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position); + LOG_D(NR_MAC, "MSG3 start_sym:%d NR Symb:%d mappingtype:%d, DMRS_MASK:%x\n", pusch_config_pdu->start_symbol_index, pusch_config_pdu->nr_of_symbols, tda_info->mapping_type, l_prime_mask); #ifdef DEBUG_MSG3 LOG_D(NR_MAC, "In %s BWP assignment (BWP (start %d, size %d) \n", __FUNCTION__, pusch_config_pdu->bwp_start, pusch_config_pdu->bwp_size); @@ -683,8 +602,6 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->bwp_start = current_UL_BWP->BWPStart; pusch_config_pdu->bwp_size = current_UL_BWP->BWPSize; - const NR_PUSCH_Config_t *pusch_Config = ubwpd? ubwpd->pusch_Config->choice.setup : NULL; - // Basic sanity check for MCS value to check for a false or erroneous DCI if (dci->mcs > 28) { LOG_W(NR_MAC, "MCS value %d out of bounds! Possibly due to false DCI. Ignoring DCI!\n", dci->mcs); @@ -716,10 +633,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, } - NR_PUSCH_ConfigCommon_t *pusch_ConfigCommon = ubwpc->pusch_ConfigCommon->choice.setup; - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = choose_ul_tda_list(pusch_Config,pusch_ConfigCommon); - - int mappingtype = pusch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->mappingType; + int mappingtype = tda_info->mapping_type; NR_DMRS_UplinkConfig_t *NR_DMRS_ulconfig = NULL; if(pusch_Config) { @@ -774,10 +688,9 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, if (nr_ue_process_dci_freq_dom_resource_assignment(pusch_config_pdu, NULL, current_UL_BWP->BWPSize, 0, dci->frequency_domain_assignment.val) < 0){ return -1; } - /* TIME_DOM_RESOURCE_ASSIGNMENT */ - if (nr_ue_process_dci_time_dom_resource_assignment(mac, pusch_TimeDomainAllocationList, NULL, pusch_config_pdu, NULL, NULL, dci->time_domain_assignment.val,0,false) < 0) { - return -1; - } + + pusch_config_pdu->start_symbol_index = tda_info->startSymbolIndex; + pusch_config_pdu->nr_of_symbols = tda_info->nrOfSymbols; /* FREQ_HOPPING_FLAG */ if ((pusch_Config!=NULL) && (pusch_Config->frequencyHopping!=NULL) && (pusch_Config->resourceAllocation != NR_PUSCH_Config__resourceAllocation_resourceAllocationType0)){ @@ -866,17 +779,13 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->tbslbrm = 0; /* PTRS */ - if (ul_bwp_id > 0 && - mac->ULbwp[ul_bwp_id-1] && - mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated && - mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config && - mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup && - mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB && - mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS) { + if (pusch_Config && + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB && + pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS) { if (pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_disabled) { nfapi_nr_ue_ptrs_ports_t ptrs_ports_list; pusch_config_pdu->pusch_ptrs.ptrs_ports_list = &ptrs_ports_list; - valid_ptrs_setup = set_ul_ptrs_values(mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup, + valid_ptrs_setup = set_ul_ptrs_values(pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup, pusch_config_pdu->rb_size, pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table, &pusch_config_pdu->pusch_ptrs.ptrs_freq_density,&pusch_config_pdu->pusch_ptrs.ptrs_time_density, &pusch_config_pdu->pusch_ptrs.ptrs_ports_list->ptrs_re_offset,&pusch_config_pdu->pusch_ptrs.num_ptrs_ports, @@ -1565,24 +1474,22 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, int current_slot, frame_t *frame_tx, int *slot_tx, - uint8_t tda_id){ + long k2){ + + AssertFatal(k2 >= DURATION_RX_TO_TX, + "Slot offset K2 (%ld) cannot be less than DURATION_RX_TO_TX (%d). K2 set according to min_rxtxtime in config file.\n", + k2,DURATION_RX_TO_TX); int delta = 0; NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id; // Get the numerology to calculate the Tx frame and slot int mu = current_UL_BWP->scs; - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? - mac->ULbwp[ul_bwp_id-1]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList: - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; // k2 as per 3GPP TS 38.214 version 15.9.0 Release 15 ch 6.1.2.1.1 // PUSCH time domain resource allocation is higher layer configured from uschTimeDomainAllocationList in either pusch-ConfigCommon - int k2; if (is_Msg3) { - k2 = *pusch_TimeDomainAllocationList->list.array[tda_id]->k2; switch (mu) { case 0: @@ -1599,9 +1506,9 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, break; } - AssertFatal((k2+delta) >= DURATION_RX_TO_TX, - "Slot offset (%d) for Msg3 cannot be less than DURATION_RX_TO_TX (%d)\n", - k2+delta,DURATION_RX_TO_TX); + AssertFatal((k2 + delta) >= DURATION_RX_TO_TX, + "Slot offset (%ld) for Msg3 cannot be less than DURATION_RX_TO_TX (%d)\n", + k2 + delta, DURATION_RX_TO_TX); *slot_tx = (current_slot + k2 + delta) % nr_slots_per_frame[mu]; if (current_slot + k2 + delta > nr_slots_per_frame[mu]){ @@ -1612,10 +1519,8 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, } else { - // Get slot offset K2 which will be used to calculate TX slot - k2 = get_k2(mac, tda_id); if (k2 < 0) { // This can happen when a false DCI is received - LOG_W(PHY,"%d.%d. Received k2 %d, tda_id %d\n",current_frame,current_slot,k2,tda_id); + LOG_W(PHY,"%d.%d. Received k2 %ld\n", current_frame, current_slot, k2); return -1; } @@ -1625,7 +1530,7 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, } - LOG_D(NR_MAC, "In %s: currently at [%d.%d] UL transmission in [%d.%d] (k2 %d delta %d)\n", __FUNCTION__, current_frame, current_slot, *frame_tx, *slot_tx, k2, delta); + LOG_D(NR_MAC, "In %s: currently at [%d.%d] UL transmission in [%d.%d] (k2 %ld delta %d)\n", __FUNCTION__, current_frame, current_slot, *frame_tx, *slot_tx, k2, delta); return 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 1282a0625c..ebc977b1a8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1161,12 +1161,12 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra BWPSize = type0_PDCCH_CSS_config->num_rbs; } + NR_ControlResourceSet_t *coreset = ra->coreset; + const int coresetid = coreset->controlResourceSetId; // Calculate number of symbols int time_domain_assignment = get_dl_tda(nr_mac, scc, slotP); - NR_tda_info_t tda_info = nr_get_pdsch_tda_info(dl_bwp, - time_domain_assignment); - - NR_ControlResourceSet_t *coreset = ra->coreset; + NR_PDSCH_TimeDomainResourceAllocationList_t *tda_list = get_dl_tdalist(dl_bwp, coresetid, ss->searchSpaceType->present, NR_RNTI_RA); + NR_tda_info_t tda_info = nr_get_pdsch_tda_info(tda_list, time_domain_assignment); AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg2\n"); @@ -1208,7 +1208,6 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not exist, create it. This is especially // important if we have multiple RAs, and the DLSCH has to reuse them, so we need to mark them - const int coresetid = coreset->controlResourceSetId; nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][coresetid]; if (!pdcch_pdu_rel15) { nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; @@ -1480,7 +1479,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra } uint8_t time_domain_assignment = get_dl_tda(nr_mac, scc, slotP); - NR_tda_info_t msg4_tda = nr_get_pdsch_tda_info(dl_bwp, time_domain_assignment); + NR_PDSCH_TimeDomainResourceAllocationList_t *tda_list = get_dl_tdalist(dl_bwp, coreset->controlResourceSetId, ss->searchSpaceType->present, NR_RNTI_TC); + NR_tda_info_t msg4_tda = nr_get_pdsch_tda_info(tda_list, time_domain_assignment); NR_pdsch_dmrs_t dmrs_info = get_dl_dmrs_params(scc, dl_bwp, &msg4_tda, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 7cd98a5e28..fbab81c1b9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -411,7 +411,9 @@ bool allocate_dl_retransmission(module_id_t module_id, /* Check first whether the old TDA can be reused * this helps allocate retransmission when TDA changes (e.g. new nrOfSymbols > old nrOfSymbols) */ - NR_tda_info_t temp_tda = nr_get_pdsch_tda_info(dl_bwp, tda); + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = get_dl_tdalist(dl_bwp, coresetid, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); + NR_tda_info_t temp_tda = nr_get_pdsch_tda_info(pdsch_TimeDomainAllocationList, tda); + bool reuse_old_tda = (retInfo->tda_info.startSymbolIndex == temp_tda.startSymbolIndex) && (retInfo->tda_info.nrOfSymbols <= temp_tda.nrOfSymbols); LOG_D(NR_MAC, "[UE %x] %s old TDA, %s number of layers\n", UE->rnti, @@ -729,7 +731,8 @@ void pf_dl(module_id_t module_id, sched_pdsch->time_domain_allocation = get_dl_tda(mac, scc, slot); AssertFatal(sched_pdsch->time_domain_allocation>=0,"Unable to find PDSCH time domain allocation in list\n"); - sched_pdsch->tda_info = nr_get_pdsch_tda_info(dl_bwp, sched_pdsch->time_domain_allocation); + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = get_dl_tdalist(dl_bwp, coresetid, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); + sched_pdsch->tda_info = nr_get_pdsch_tda_info(pdsch_TimeDomainAllocationList, sched_pdsch->time_domain_allocation); NR_tda_info_t *tda_info = &sched_pdsch->tda_info; const uint16_t slbitmap = SL_to_bitmap(tda_info->startSymbolIndex, tda_info->nrOfSymbols); @@ -798,13 +801,12 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t NR_UE_DL_BWP_t *current_BWP = &UE->current_DL_BWP; const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); int startSymbolIndex, nrOfSymbols; - const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = current_BWP->tdaList; + const int coresetid = sched_ctrl->coreset->controlResourceSetId; + const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = get_dl_tdalist(current_BWP, coresetid, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); - const int coresetid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : current_BWP->BWPSize; const uint16_t BWPStart = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_start : current_BWP->BWPStart; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index e2b4542a80..ea05759dad 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -59,7 +59,8 @@ void nr_preprocessor_phytest(module_id_t module_id, const int CC_id = 0; const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); - NR_tda_info_t tda_info = nr_get_pdsch_tda_info(dl_bwp, tda); + NR_PDSCH_TimeDomainResourceAllocationList_t *tdalist = get_dl_tdalist(dl_bwp, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); + NR_tda_info_t tda_info = nr_get_pdsch_tda_info(tdalist, tda); sched_ctrl->sched_pdsch.tda_info = tda_info; sched_ctrl->sched_pdsch.time_domain_allocation = tda; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 6f9d829bce..c34d7f6316 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -563,11 +563,10 @@ bool nr_find_nb_rb(uint16_t Qm, return *tbs >= bytes && *nb_rb <= nb_rb_max; } -NR_tda_info_t nr_get_pdsch_tda_info(const NR_UE_DL_BWP_t *dl_bwp, +NR_tda_info_t nr_get_pdsch_tda_info(const NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList, const int tda) { NR_tda_info_t tda_info = {0}; - NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = dl_bwp->tdaList; AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); tda_info.mapping_type = tdaList->list.array[tda]->mappingType; const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; @@ -1177,7 +1176,6 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, *dci_pdu = 0; uint16_t alt_size = 0; uint16_t N_RB; - const int controlResourceSetId = *ss->controlResourceSetId; if(current_DL_BWP) { N_RB = get_rb_bwp_dci(dci_format, ss->searchSpaceType->present, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 7e9a66ca7f..ae93e07c36 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -307,7 +307,7 @@ long get_K2(NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList, int time_domain_assignment, int mu); -NR_tda_info_t nr_get_pdsch_tda_info(const NR_UE_DL_BWP_t *dl_bwp, +NR_tda_info_t nr_get_pdsch_tda_info(const NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList, const int tda); NR_tda_info_t nr_get_pusch_tda_info(const NR_UE_UL_BWP_t *ul_bwp, diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index eb1de74d20..e274ebab91 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -667,6 +667,7 @@ static void fill_dci_from_dl_config(nr_downlink_indication_t*dl_ind, fapi_nr_dl_ if (rel15_dci->dci_length_options[j] == dl_ind->dci_ind->dci_list[k].payloadSize) { dl_ind->dci_ind->dci_list[k].dci_format = rel15_dci->dci_format_options[j]; dl_ind->dci_ind->dci_list[k].ss_type = rel15_dci->dci_type_options[j]; + dl_ind->dci_ind->dci_list[k].CoreSetType = rel15_dci->coreset.CoreSetType; LOG_D(NR_PHY, "format assigned dl_ind->dci_ind->dci_list[k].dci_format %d\n", dl_ind->dci_ind->dci_list[k].dci_format); } From ffdffeee9ea1125c8e0c7eed61a3a858aa97f98f Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 16 Jan 2023 18:05:15 +0100 Subject: [PATCH 4/7] further improvements in UE BWP configuration --- openair2/LAYER2/NR_MAC_COMMON/nr_mac.h | 5 + openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 119 +++---- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 11 +- openair2/LAYER2/NR_MAC_UE/config_ue.c | 38 ++- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 8 - openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 45 ++- .../NR_MAC_UE/nr_ue_dci_configuration.c | 20 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 300 ++++-------------- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 160 +++------- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 30 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 11 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 2 +- 12 files changed, 220 insertions(+), 529 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index e0b8b40fb9..183697822d 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -577,6 +577,7 @@ typedef struct NR_UE_DL_BWP { NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList; NR_PDSCH_Config_t *pdsch_Config; NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig; + long *pdsch_HARQ_ACK_Codebook; uint8_t mcsTableIdx; nr_dci_format_t dci_format; } NR_UE_DL_BWP_t; @@ -590,13 +591,17 @@ typedef struct NR_UE_UL_BWP { uint16_t BWPStart; uint16_t initial_BWPSize; uint16_t initial_BWPStart; + NR_RACH_ConfigCommon_t *rach_ConfigCommon; NR_PUSCH_ServingCellConfig_t *pusch_servingcellconfig; NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList; + NR_ConfiguredGrantConfig_t *configuredGrantConfig; NR_PUSCH_Config_t *pusch_Config; NR_PUCCH_Config_t *pucch_Config; NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon; + long *harq_ACK_SpatialBundlingPUCCH; NR_CSI_MeasConfig_t *csi_MeasConfig; NR_SRS_Config_t *srs_Config; + long *msg3_DeltaPreamble; uint8_t transform_precoding; uint8_t mcs_table; nr_dci_format_t dci_format; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index c62af96a8e..6612b78b92 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -2777,38 +2777,23 @@ uint16_t get_nr_srs_offset(NR_SRS_PeriodicityAndOffset_t periodicityAndOffset) { // Set the transform precoding status according to 6.1.3 of 3GPP TS 38.214 version 16.3.0 Release 16: // - "UE procedure for applying transform precoding on PUSCH" -uint8_t get_transformPrecoding(const NR_BWP_UplinkCommon_t *initialUplinkBWP, - const NR_PUSCH_Config_t *pusch_config, - const NR_BWP_UplinkDedicated_t *ubwp, - uint8_t *dci_format, - int rnti_type, - uint8_t configuredGrant){ +uint8_t get_transformPrecoding(const NR_UE_UL_BWP_t *current_UL_BWP, + nr_dci_format_t dci_format, + uint8_t configuredGrant) +{ - if (configuredGrant) { - if (ubwp->configuredGrantConfig) { - if (ubwp->configuredGrantConfig->choice.setup->transformPrecoder) { - return *ubwp->configuredGrantConfig->choice.setup->transformPrecoder; - } - } - } + if (configuredGrant && + current_UL_BWP->configuredGrantConfig && + current_UL_BWP->configuredGrantConfig->transformPrecoder) + return *current_UL_BWP->configuredGrantConfig->transformPrecoder; - if (rnti_type != NR_RNTI_RA && rnti_type != NR_RNTI_TC) { - if (*dci_format != NR_UL_DCI_FORMAT_0_0) { - if (pusch_config && pusch_config->transformPrecoder != NULL) { - return *pusch_config->transformPrecoder; - } - } - } - - if (initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL) { - return 1; // Transformprecoding disabled - } else { - LOG_D(PHY, "MAC_COMMON: Transform Precodig enabled through msg3_transformPrecoder\n"); - return 0; // Enabled - } - - LOG_E(MAC, "In %s: could not fetch transform precoder status...\n", __FUNCTION__); - return -1; + if (dci_format == NR_UL_DCI_FORMAT_0_1 && + current_UL_BWP && + current_UL_BWP->pusch_Config && + current_UL_BWP->pusch_Config->transformPrecoder) + return *current_UL_BWP->pusch_Config->transformPrecoder; + else + return current_UL_BWP->rach_ConfigCommon->msg3_transformPrecoder ? 0 : 1; } uint8_t get_pusch_nb_antenna_ports(NR_PUSCH_Config_t *pusch_Config, @@ -3264,9 +3249,7 @@ uint16_t get_rb_bwp_dci(nr_dci_format_t format, return N_RB; } -uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, - const NR_BWP_UplinkCommon_t *initialUplinkBWP, - const NR_UE_DL_BWP_t *DL_BWP, +uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, const NR_UE_UL_BWP_t *UL_BWP, const NR_CellGroupConfig_t *cg, dci_pdu_rel15_t *dci_pdu, @@ -3284,26 +3267,10 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, long rbg_size_config; int num_entries = 0; - NR_UplinkConfig_t *uplinkConfig = NULL; - if (cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated) { - uplinkConfig = cg->spCellConfig->spCellConfigDedicated->uplinkConfig; - } - - const NR_BWP_UplinkDedicated_t *ubwpd = NULL; NR_PDSCH_Config_t *pdsch_Config = DL_BWP ? DL_BWP->pdsch_Config : NULL; NR_PUSCH_Config_t *pusch_Config = UL_BWP ? UL_BWP->pusch_Config : NULL; - NR_PUCCH_Config_t *pucch_Config = NULL; - NR_SRS_Config_t *srs_config = NULL; - if(bwp_id > 0) { - AssertFatal(cg!=NULL,"Cellgroup is null and bwp_id!=0"); - ubwpd = uplinkConfig ? uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated : NULL; - pucch_Config = (ubwpd->pucch_Config) ? ubwpd->pucch_Config->choice.setup : NULL; - srs_config = (ubwpd->srs_Config) ? ubwpd->srs_Config->choice.setup : NULL; - } else if (cg) { - ubwpd = uplinkConfig ? uplinkConfig->initialUplinkBWP : NULL; - pucch_Config = (ubwpd && ubwpd->pucch_Config) ? ubwpd->pucch_Config->choice.setup : NULL; - srs_config = (ubwpd && ubwpd->srs_Config) ? ubwpd->srs_Config->choice.setup: NULL; - } + NR_PUCCH_Config_t *pucch_Config = UL_BWP ? UL_BWP->pucch_Config : NULL; + NR_SRS_Config_t *srs_config = UL_BWP ? UL_BWP->srs_Config : NULL; uint16_t N_RB = cset0_bwp_size; if (DL_BWP) @@ -3315,7 +3282,6 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, UL_BWP->initial_BWPSize, DL_BWP->initial_BWPSize); - int n_ul_bwp = 1,n_dl_bwp = 1; switch(format) { case NR_UL_DCI_FORMAT_0_0: /// fixed: Format identifier 1, Hop flag 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2 Time Domain assgnmt 4 --20 @@ -3345,12 +3311,8 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, size += dci_pdu->ul_sul_indicator.nbits; } // BWP Indicator - n_ul_bwp = 0; - if (cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) - n_ul_bwp = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count; - if (n_ul_bwp < 2) - dci_pdu->bwp_indicator.nbits = n_ul_bwp; + if (UL_BWP->n_ul_bwp < 2) + dci_pdu->bwp_indicator.nbits = UL_BWP->n_ul_bwp; else dci_pdu->bwp_indicator.nbits = 2; size += dci_pdu->bwp_indicator.nbits; @@ -3389,21 +3351,19 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, size += 1; } // 1st DAI - if (cg->physicalCellGroupConfig && cg->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook == NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic) + if (DL_BWP->pdsch_HARQ_ACK_Codebook && *DL_BWP->pdsch_HARQ_ACK_Codebook == NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic) dci_pdu->dai[0].nbits = 2; else dci_pdu->dai[0].nbits = 1; size += dci_pdu->dai[0].nbits; LOG_D(NR_MAC, "DAI1 nbits %d\n", dci_pdu->dai[0].nbits); // 2nd DAI - if (cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig && cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup - && cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) { // TODO not sure about that + if (DL_BWP->pdsch_servingcellconfig && DL_BWP->pdsch_servingcellconfig->codeBlockGroupTransmission != NULL) { // TODO not sure about that dci_pdu->dai[1].nbits = 2; size += dci_pdu->dai[1].nbits; } // SRS resource indicator - NR_PUSCH_ServingCellConfig_t *pusch_servingcellconfig = uplinkConfig && uplinkConfig->pusch_ServingCellConfig ? uplinkConfig->pusch_ServingCellConfig->choice.setup : NULL; - dci_pdu->srs_resource_indicator.nbits = compute_srs_resource_indicator(pusch_servingcellconfig, pusch_Config, srs_config, NULL, NULL); + dci_pdu->srs_resource_indicator.nbits = compute_srs_resource_indicator(UL_BWP->pusch_servingcellconfig, pusch_Config, srs_config, NULL, NULL); size += dci_pdu->srs_resource_indicator.nbits; LOG_D(NR_MAC, "dci_pdu->srs_resource_indicator.nbits %d\n", dci_pdu->srs_resource_indicator.nbits); // Precoding info and number of layers @@ -3411,7 +3371,7 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, size += dci_pdu->precoding_information.nbits; LOG_D(NR_MAC, "dci_pdu->precoding_informaiton.nbits=%d\n", dci_pdu->precoding_information.nbits); // Antenna ports - long transformPrecoder = get_transformPrecoding(initialUplinkBWP, pusch_Config, ubwpd, (uint8_t *)&format, rnti_type, 0); + long transformPrecoder = get_transformPrecoding(UL_BWP, format, 0); NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = NULL; int xa = 0; int xb = 0; @@ -3437,16 +3397,16 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, dci_pdu->srs_request.nbits = 3; size += dci_pdu->srs_request.nbits; // CSI request - if (cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig != NULL) { - if (cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup->reportTriggerSize != NULL) { - dci_pdu->csi_request.nbits = *cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup->reportTriggerSize; + if (UL_BWP->csi_MeasConfig != NULL) { + if (UL_BWP->csi_MeasConfig->reportTriggerSize != NULL) { + dci_pdu->csi_request.nbits = *UL_BWP->csi_MeasConfig->reportTriggerSize; size += dci_pdu->csi_request.nbits; } } // CBGTI - if (cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) { - int num = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock; + if (UL_BWP->pusch_servingcellconfig && + UL_BWP->pusch_servingcellconfig->codeBlockGroupTransmission != NULL) { + int num = UL_BWP->pusch_servingcellconfig->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock; dci_pdu->cbgti.nbits = 2 + (num<<1); size += dci_pdu->cbgti.nbits; } @@ -3503,11 +3463,8 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, } // BWP Indicator - n_dl_bwp = 0; - if (cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) - n_dl_bwp = cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count; - if (n_dl_bwp < 2) - dci_pdu->bwp_indicator.nbits = n_dl_bwp; + if (DL_BWP->n_dl_bwp < 2) + dci_pdu->bwp_indicator.nbits = DL_BWP->n_dl_bwp; else dci_pdu->bwp_indicator.nbits = 2; size += dci_pdu->bwp_indicator.nbits; @@ -3570,8 +3527,7 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, // HARQ PID size += 4; // DAI - if (cg->physicalCellGroupConfig && - cg->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook == NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic) { // FIXME in case of more than one serving cell + if (DL_BWP->pdsch_HARQ_ACK_Codebook && *DL_BWP->pdsch_HARQ_ACK_Codebook == NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic) { // FIXME in case of more than one serving cell dci_pdu->dai[0].nbits = 2; size += dci_pdu->dai[0].nbits; } @@ -3604,16 +3560,15 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, dci_pdu->srs_request.nbits = 3; size += dci_pdu->srs_request.nbits; // CBGTI - if (cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig && - cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup && - cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) { - uint8_t maxCBGperTB = (cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock + 1) * 2; + if (DL_BWP->pdsch_servingcellconfig && + DL_BWP->pdsch_servingcellconfig->codeBlockGroupTransmission != NULL) { + uint8_t maxCBGperTB = (DL_BWP->pdsch_servingcellconfig->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock + 1) * 2; long *maxCWperDCI_rrc = pdsch_Config->maxNrofCodeWordsScheduledByDCI; uint8_t maxCW = (maxCWperDCI_rrc == NULL) ? 1 : *maxCWperDCI_rrc; dci_pdu->cbgti.nbits = maxCBGperTB * maxCW; size += dci_pdu->cbgti.nbits; // CBGFI - if (cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator) { + if (DL_BWP->pdsch_servingcellconfig->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator) { dci_pdu->cbgfi.nbits = 1; size += dci_pdu->cbgfi.nbits; } diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index a41467b3fc..dd957ed39e 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -99,9 +99,7 @@ NR_ul_tda_info_t get_ul_tda_info(NR_PUSCH_TimeDomainResourceAllocationList_t *td int scs, int normal_CP); -uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, - const NR_BWP_UplinkCommon_t *initialUplinkBWP, - const NR_UE_DL_BWP_t *DL_BWP, +uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, const NR_UE_UL_BWP_t *UL_BWP, const NR_CellGroupConfig_t *cg, dci_pdu_rel15_t *dci_pdu, @@ -283,11 +281,8 @@ bool set_ul_ptrs_values(NR_PTRS_UplinkConfig_t *ul_ptrs_config, @param rnti_type rnti type @param configuredGrant indicates whether a configured grant was received or not @returns transformPrecoding value */ -uint8_t get_transformPrecoding(const NR_BWP_UplinkCommon_t *initialUplinkBWP, - const NR_PUSCH_Config_t *pusch_config, - const NR_BWP_UplinkDedicated_t *ubwp, - uint8_t *dci_format, - int rnti_type, +uint8_t get_transformPrecoding(const NR_UE_UL_BWP_t *current_UL_BWP, + nr_dci_format_t dci_format, uint8_t configuredGrant); void nr_mac_gNB_rrc_ul_failure(const module_id_t Mod_instP, diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 108948adb1..950c0c6d5f 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -549,6 +549,8 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, NR_BWP_t ul_genericParameters = {0}; NR_BWP_DownlinkCommon_t *bwp_dlcommon = NULL; NR_BWP_UplinkCommon_t *bwp_ulcommon = NULL; + DL_BWP->n_dl_bwp = 1; + UL_BWP->n_ul_bwp = 1; if(scc) { DL_BWP->bwp_id = 0; @@ -564,14 +566,30 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, DL_BWP->pdsch_Config = NULL; if(bwp_dlcommon->pdsch_ConfigCommon) DL_BWP->tdaList = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - if(bwp_ulcommon->pusch_ConfigCommon) + if(bwp_ulcommon->pusch_ConfigCommon) { UL_BWP->tdaList = bwp_ulcommon->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + UL_BWP->msg3_DeltaPreamble = bwp_ulcommon->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble; + } + if(bwp_ulcommon->pucch_ConfigCommon) + UL_BWP->pucch_ConfigCommon = bwp_ulcommon->pucch_ConfigCommon->choice.setup; + if(bwp_ulcommon->rach_ConfigCommon) + UL_BWP->rach_ConfigCommon = bwp_ulcommon->rach_ConfigCommon->choice.setup; } if(cell_group_config) { + if (cell_group_config->physicalCellGroupConfig) { + DL_BWP->pdsch_HARQ_ACK_Codebook = &cell_group_config->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook; + UL_BWP->harq_ACK_SpatialBundlingPUCCH = cell_group_config->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH; + } if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->spCellConfigDedicated) { + struct NR_ServingCellConfig *spCellConfigDedicated = cell_group_config->spCellConfig->spCellConfigDedicated; + UL_BWP->csi_MeasConfig = spCellConfigDedicated->csi_MeasConfig ? spCellConfigDedicated->csi_MeasConfig->choice.setup : NULL; + UL_BWP->pusch_servingcellconfig = spCellConfigDedicated->uplinkConfig && spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig ? + spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup : NULL; + DL_BWP->pdsch_servingcellconfig = spCellConfigDedicated->pdsch_ServingCellConfig ? spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup : NULL; + if (spCellConfigDedicated->firstActiveDownlinkBWP_Id) DL_BWP->bwp_id = *spCellConfigDedicated->firstActiveDownlinkBWP_Id; if (spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id) @@ -587,6 +605,8 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, } NR_BWP_Downlink_t *bwp_downlink = NULL; const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = spCellConfigDedicated->downlinkBWP_ToAddModList; + if(bwpList) + DL_BWP->n_dl_bwp = bwpList->list.count; if (bwpList && DL_BWP->bwp_id > 0) { for (int i = 0; i < bwpList->list.count; i++) { bwp_downlink = bwpList->list.array[i]; @@ -603,9 +623,12 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, } DL_BWP->tdaList = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; UL_BWP->tdaList = bwp_ulcommon->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + UL_BWP->msg3_DeltaPreamble = bwp_ulcommon->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble; NR_BWP_Uplink_t *bwp_uplink = NULL; const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList; + if (ubwpList) + UL_BWP->n_ul_bwp = ubwpList->list.count; if (ubwpList && UL_BWP->bwp_id > 0) { for (int i = 0; i < ubwpList->list.count; i++) { bwp_uplink = ubwpList->list.array[i]; @@ -615,10 +638,23 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, AssertFatal(bwp_uplink != NULL,"Couldn't find ULBWP corresponding to BWP ID %ld\n",UL_BWP->bwp_id); ul_genericParameters = bwp_uplink->bwp_Common->genericParameters; UL_BWP->pusch_Config = bwp_uplink->bwp_Dedicated->pusch_Config->choice.setup; + UL_BWP->pucch_Config = bwp_uplink->bwp_Dedicated->pucch_Config->choice.setup; + UL_BWP->srs_Config = bwp_uplink->bwp_Dedicated->srs_Config->choice.setup; + UL_BWP->configuredGrantConfig = bwp_uplink->bwp_Dedicated->configuredGrantConfig ? bwp_uplink->bwp_Dedicated->configuredGrantConfig->choice.setup : NULL; + if(bwp_uplink->bwp_Common->pucch_ConfigCommon) + UL_BWP->pucch_ConfigCommon = bwp_uplink->bwp_Common->pucch_ConfigCommon->choice.setup; + if(bwp_uplink->bwp_Common->rach_ConfigCommon) + UL_BWP->rach_ConfigCommon = bwp_uplink->bwp_Common->rach_ConfigCommon->choice.setup; } else { UL_BWP->pusch_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pusch_Config->choice.setup; + UL_BWP->pucch_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; + UL_BWP->srs_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config->choice.setup; + UL_BWP->configuredGrantConfig = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->configuredGrantConfig ? + spCellConfigDedicated->uplinkConfig->initialUplinkBWP->configuredGrantConfig->choice.setup : NULL; ul_genericParameters = bwp_ulcommon->genericParameters; + if(bwp_ulcommon->rach_ConfigCommon) + UL_BWP->rach_ConfigCommon = bwp_ulcommon->rach_ConfigCommon->choice.setup; } } else diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index deb2ceb217..b20da8bf81 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -251,14 +251,6 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot); -void get_bwp_info(NR_UE_MAC_INST_t *mac, - int dl_bwp_id, - int ul_bwp_id, - NR_BWP_DownlinkDedicated_t **bwpd, - NR_BWP_DownlinkCommon_t **bwpc, - NR_BWP_UplinkDedicated_t **ubwpd, - NR_BWP_UplinkCommon_t **ubwpc); - NR_BWP_DownlinkCommon_t *get_bwp_downlink_common(NR_UE_MAC_INST_t *mac, NR_BWP_Id_t dl_bwp_id); int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index e4bbb546d8..da3a4777ed 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -138,7 +138,8 @@ void init_RA(module_id_t mod_id, NR_PRACH_RESOURCES_t *prach_resources, NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon, NR_RACH_ConfigGeneric_t *rach_ConfigGeneric, - NR_RACH_ConfigDedicated_t *rach_ConfigDedicated) { + NR_RACH_ConfigDedicated_t *rach_ConfigDedicated) +{ NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); @@ -280,14 +281,13 @@ void init_RA(module_id_t mod_id, /* TS 38.321 subclause 7.3 - return DELTA_PREAMBLE values in dB */ -int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_format){ +int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_format) +{ NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); - NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = (mac->scc!=NULL) ? - mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup: - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; + NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP.rach_ConfigCommon; NR_SubcarrierSpacing_t scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing; - int prach_sequence_length = (mac->scc!=NULL)?(mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present - 1) : (mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present-1); + int prach_sequence_length = nr_rach_ConfigCommon->prach_RootSequenceIndex.present - 1; uint8_t prachConfigIndex, mu; AssertFatal(CC_id == 0, "Transmission on secondary CCs is not supported yet\n"); @@ -385,13 +385,14 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_forma // - RA_PREAMBLE_POWER_RAMPING_STEP dB // - POWER_OFFSET_2STEP_RA dB // returns receivedTargerPower in dBm -int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t mod_id, uint8_t CC_id){ +int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t mod_id, uint8_t CC_id) +{ NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); int8_t receivedTargerPower; int8_t delta_preamble; - NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = (mac->scc != NULL) ? mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup: mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; + NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP.rach_ConfigCommon; long preambleReceivedTargetPower = nr_rach_ConfigCommon->rach_ConfigGeneric.preambleReceivedTargetPower; delta_preamble = nr_get_DELTA_PREAMBLE(mod_id, CC_id, prach_resources->prach_format); @@ -402,7 +403,8 @@ int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t m return receivedTargerPower; } -void ssb_rach_config(RA_config_t *ra, NR_PRACH_RESOURCES_t *prach_resources, NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon){ +void ssb_rach_config(RA_config_t *ra, NR_PRACH_RESOURCES_t *prach_resources, NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon) +{ // Determine the SSB to RACH mapping ratio // ======================================= @@ -489,14 +491,11 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t unsigned short int *seed = (unsigned short int*)&tmp; RA_config_t *ra = &mac->ra; - NR_RACH_ConfigCommon_t *setup; - if (mac->scc) setup = mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup; - else setup = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; + NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP.rach_ConfigCommon; NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; - NR_BWP_UplinkCommon_t *initialUplinkBWP = (mac->scc) ? mac->scc->uplinkConfigCommon->initialUplinkBWP : &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; - if (initialUplinkBWP->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble){ - deltaPreamble_Msg3 = (*initialUplinkBWP->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble) * 2; // dB + if (mac->current_UL_BWP.msg3_DeltaPreamble){ + deltaPreamble_Msg3 = (*mac->current_UL_BWP.msg3_DeltaPreamble) * 2; // dB LOG_D(MAC, "In %s: deltaPreamble_Msg3 set to %ld\n", __FUNCTION__, deltaPreamble_Msg3); } @@ -661,9 +660,7 @@ void nr_get_prach_resources(module_id_t mod_id, NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); RA_config_t *ra = &mac->ra; - NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = (mac->scc)? - mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup : - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; + NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP.rach_ConfigCommon; LOG_D(MAC, "In %s: getting PRACH resources frame (first_Msg3 %d)\n", __FUNCTION__, ra->first_Msg3); @@ -701,12 +698,8 @@ void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, slot NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); RA_config_t *ra = &mac->ra; - NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = (mac->scc) ? - mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup: - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; - long mu = (mac->scc) ? - mac->scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing : - mac->scc_SIB->downlinkConfigCommon.frequencyInfoDL.scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP.rach_ConfigCommon; + long mu = mac->current_UL_BWP.scs; int subframes_per_slot = nr_slots_per_frame[mu]/10; // start contention resolution timer (cnt in slots) @@ -934,9 +927,7 @@ void nr_get_RA_window(NR_UE_MAC_INST_t *mac){ uint8_t mu, ra_ResponseWindow; RA_config_t *ra = &mac->ra; - NR_RACH_ConfigCommon_t *setup; - if (mac->scc) setup = mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup; - else setup = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; + NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP.rach_ConfigCommon; AssertFatal(&setup->rach_ConfigGeneric != NULL, "In %s: FATAL! rach_ConfigGeneric is NULL...\n", __FUNCTION__); NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; long scs = (mac->scc) ? 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 04b7d36e5e..ff8a2de982 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -93,20 +93,9 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t uint16_t monitoringSymbolsWithinSlot = 0; int sps = 0; - AssertFatal(mac->scc == NULL || mac->scc_SIB == NULL, "both scc and scc_SIB cannot be non-null\n"); - NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; NR_BWP_Id_t dl_bwp_id = current_DL_BWP ? current_DL_BWP->bwp_id : 0; - NR_ServingCellConfigCommon_t *scc = mac->scc; - NR_ServingCellConfigCommonSIB_t *scc_SIB = mac->scc_SIB; - NR_BWP_DownlinkCommon_t *initialDownlinkBWP=NULL; - NR_BWP_UplinkCommon_t *initialUplinkBWP=NULL; - - if (scc!=NULL || scc_SIB != NULL) { - initialDownlinkBWP = scc!=NULL ? scc->downlinkConfigCommon->initialDownlinkBWP : &scc_SIB->downlinkConfigCommon.initialDownlinkBWP; - initialUplinkBWP = scc!=NULL ? scc->uplinkConfigCommon->initialUplinkBWP : &scc_SIB->uplinkConfigCommon->initialUplinkBWP; - } NR_SearchSpace_t *ss; NR_ControlResourceSet_t *coreset; @@ -173,21 +162,18 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t // computing alternative size for padding dci_pdu_rel15_t temp_pdu; if(dci_format == NR_DL_DCI_FORMAT_1_0) - alt_size = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, - current_DL_BWP, current_UL_BWP, + alt_size = nr_dci_size(current_DL_BWP, current_UL_BWP, mac->cg, &temp_pdu, NR_UL_DCI_FORMAT_0_0, rnti_type, coreset, dl_bwp_id, ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, 0); if(dci_format == NR_UL_DCI_FORMAT_0_0) - alt_size = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, - current_DL_BWP, current_UL_BWP, + alt_size = nr_dci_size(current_DL_BWP, current_UL_BWP, mac->cg, &temp_pdu, NR_DL_DCI_FORMAT_1_0, rnti_type, coreset, dl_bwp_id, ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, 0); } - rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, - current_DL_BWP, current_UL_BWP, + rel15->dci_length_options[i] = nr_dci_size(current_DL_BWP, current_UL_BWP, mac->cg, &mac->def_dci_pdu_rel15[dci_format], dci_format, NR_RNTI_TC, coreset, dl_bwp_id, ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, alt_size); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index d74767f860..09ee7c6cb5 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -180,51 +180,6 @@ void nr_ue_init_mac(module_id_t module_idP) { } } -void get_bwp_info(NR_UE_MAC_INST_t *mac, - int dl_bwp_id, - int ul_bwp_id, - NR_BWP_DownlinkDedicated_t **bwpd, - NR_BWP_DownlinkCommon_t **bwpc, - NR_BWP_UplinkDedicated_t **ubwpd, - NR_BWP_UplinkCommon_t **ubwpc) { - - if (dl_bwp_id > 0) { - AssertFatal(mac->DLbwp[dl_bwp_id-1]!=NULL,"mac->DLbwp[%d] is null, shouldn't be\n", (int)dl_bwp_id-1); - *bwpd = mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated; - } else { - if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP) - *bwpd = mac->cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; - } - - *bwpc = get_bwp_downlink_common(mac, dl_bwp_id); - AssertFatal(*bwpc!=NULL,"bwpc shouldn't be null\n"); - - if (ul_bwp_id > 0) { - AssertFatal(mac->ULbwp[ul_bwp_id-1]!=NULL,"mac->ULbwp[%d] is null, shouldn't be\n", - ul_bwp_id-1); - *ubwpd = mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated; - if (mac->ULbwp[ul_bwp_id-1]->bwp_Common) *ubwpc = mac->ULbwp[ul_bwp_id-1]->bwp_Common; - else if (mac->scc) *ubwpc = mac->scc->uplinkConfigCommon->initialUplinkBWP; - else if (mac->scc_SIB) *ubwpc = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; - AssertFatal(*bwpc!=NULL,"bwpc shouldn't be null\n"); - - } - else { - if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) - *ubwpd = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; - if (mac->scc) *ubwpc = mac->scc->uplinkConfigCommon->initialUplinkBWP; - else if (mac->scc_SIB) *ubwpc = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; - AssertFatal(*ubwpc!=NULL,"ubwpc shouldn't be null\n"); - } -} - NR_BWP_DownlinkCommon_t *get_bwp_downlink_common(NR_UE_MAC_INST_t *mac, NR_BWP_Id_t dl_bwp_id) { NR_BWP_DownlinkCommon_t *bwp_Common = NULL; if (dl_bwp_id > 0 && mac->cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) { @@ -546,7 +501,6 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr uint8_t is_Msg3 = 0; NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id; int default_abc = 1; LOG_D(MAC, "In %s: Processing received DCI format %s\n", __FUNCTION__, dci_formats[dci_format]); @@ -554,6 +508,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; int normal_CP = current_UL_BWP->cyclicprefix ? 0 : 1; NR_ul_tda_info_t tda_info = {0}; + NR_PUCCH_Config_t *pucch_Config = current_UL_BWP->pucch_Config; switch(dci_format){ case NR_UL_DCI_FORMAT_0_0: { @@ -755,9 +710,9 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr } else { dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; } - if( (ra->RA_window_cnt >= 0 && rnti == ra->ra_rnti) || (rnti == ra->t_crnti) ) { + if((ra->RA_window_cnt >= 0 && rnti == ra->ra_rnti) || (rnti == ra->t_crnti)) { if (mac->scc == NULL) // use coreset0 - is_common=1; + is_common = 1; } } @@ -869,35 +824,15 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr if (dci->tpc == 3) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 3; // Sanity check for pucch_resource_indicator value received to check for false DCI. valid = 0; - if (ul_bwp_id > 0 && - mac->ULbwp[ul_bwp_id-1] && - mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated && - mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pucch_Config && - mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup&& - mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList) { - pucch_res_set_cnt = mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.count; + if(pucch_Config && + pucch_Config->resourceSetToAddModList) { + pucch_res_set_cnt = pucch_Config->resourceSetToAddModList->list.count; for (int id = 0; id < pucch_res_set_cnt; id++) { - if (dci->pucch_resource_indicator < mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[id]->resourceList.list.count) { + if (dci->pucch_resource_indicator < pucch_Config->resourceSetToAddModList->list.array[id]->resourceList.list.count) { valid = 1; break; } } - } - else if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList){ - pucch_res_set_cnt = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList->list.count; - for (int id = 0; id < pucch_res_set_cnt; id++) { - if (dci->pucch_resource_indicator < mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList->list.array[id]->resourceList.list.count) { - valid = 1; - break; - } - } } else valid=1; if (!valid) { LOG_W(MAC, "[%d.%d] pucch_resource_indicator value %d is out of bounds. Possibly due to false DCI. Ignoring DCI!\n", frame, slot, dci->pucch_resource_indicator); @@ -982,14 +917,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr LOG_W(NR_MAC,"[%d.%d] bwp_indicator %d > NR_MAX_NUM_BWP Possibly due to false DCI. Ignoring DCI!\n", frame, slot,dci->bwp_indicator.val); return -1; } - NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id; - NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id; NR_PDSCH_Config_t *pdsch_Config = current_DL_BWP->pdsch_Config; - NR_BWP_DownlinkDedicated_t *bwpd=NULL; - NR_BWP_DownlinkCommon_t *bwpc=NULL; - NR_BWP_UplinkDedicated_t *ubwpd=NULL; - NR_BWP_UplinkCommon_t *ubwpc=NULL; - get_bwp_info(mac,dl_bwp_id,ul_bwp_id,&bwpd,&bwpc,&ubwpd,&ubwpc); dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti; @@ -1092,9 +1020,9 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // Sanity check for pucch_resource_indicator value received to check for false DCI. valid = 0; - pucch_res_set_cnt = ubwpd->pucch_Config->choice.setup->resourceSetToAddModList->list.count; + pucch_res_set_cnt = pucch_Config->resourceSetToAddModList->list.count; for (int id = 0; id < pucch_res_set_cnt; id++) { - if (dci->pucch_resource_indicator < ubwpd->pucch_Config->choice.setup->resourceSetToAddModList->list.array[id]->resourceList.list.count) { + if (dci->pucch_resource_indicator < pucch_Config->resourceSetToAddModList->list.array[id]->resourceList.list.count) { valid = 1; break; } @@ -1230,8 +1158,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND */ // according to TS 38.213 Table 9.2.3-1 - uint8_t feedback_ti = - ubwpd->pucch_Config->choice.setup->dl_DataToUL_ACK->list.array[dci->pdsch_to_harq_feedback_timing_indicator.val][0]; + uint8_t feedback_ti = pucch_Config->dl_DataToUL_ACK->list.array[dci->pdsch_to_harq_feedback_timing_indicator.val][0]; AssertFatal(feedback_ti>=DURATION_RX_TO_TX,"PDSCH to HARQ feedback time (%d) cannot be less than DURATION_RX_TO_TX (%d). Min feedback time set in config file (min_rxtxtime).\n", feedback_ti,DURATION_RX_TO_TX); @@ -1272,7 +1199,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr nb_rb_oh, 0, Nl); // TBS_LBRM according to section 5.4.2.1 of 38.212 - long *maxMIMO_Layers = mac->cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers; + long *maxMIMO_Layers = current_DL_BWP->pdsch_servingcellconfig->ext1->maxMIMO_Layers; AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); int nl_tbslbrm = *maxMIMO_Layers < 4 ? *maxMIMO_Layers : 4; int bw_tbslbrm = get_dlbw_tbslbrm(current_DL_BWP->initial_BWPSize, mac->cg); @@ -1376,7 +1303,7 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, int O_CRC = 0; //FIXME uint16_t O_uci = O_CSI + O_ACK; NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - NR_BWP_Id_t bwp_id = current_UL_BWP->bwp_id; + NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; NR_PUCCH_FormatConfig_t *pucchfmt; long *pusch_id = NULL; long *id0 = NULL; @@ -1392,10 +1319,10 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, // only for ack/nack if (pucch->initial_pucch_id > -1 && pucch->pucch_resource == NULL) { - - pucch_pdu->format_type = initial_pucch_resource[pucch->initial_pucch_id].format; - pucch_pdu->start_symbol_index = initial_pucch_resource[pucch->initial_pucch_id].startingSymbolIndex; - pucch_pdu->nr_of_symbols = initial_pucch_resource[pucch->initial_pucch_id].nrofSymbols; + int pucch_resourcecommon = *current_UL_BWP->pucch_ConfigCommon->pucch_ResourceCommon; + pucch_pdu->format_type = initial_pucch_resource[pucch_resourcecommon].format; + pucch_pdu->start_symbol_index = initial_pucch_resource[pucch_resourcecommon].startingSymbolIndex; + pucch_pdu->nr_of_symbols = initial_pucch_resource[pucch_resourcecommon].nrofSymbols; pucch_pdu->bwp_size = current_UL_BWP->BWPSize; pucch_pdu->bwp_start = current_UL_BWP->BWPStart; @@ -1403,19 +1330,21 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, pucch_pdu->prb_size = 1; // format 0 or 1 int RB_BWP_offset; if (pucch->initial_pucch_id == 15) - RB_BWP_offset = pucch_pdu->bwp_size>>2; + RB_BWP_offset = pucch_pdu->bwp_size >> 2; else - RB_BWP_offset = initial_pucch_resource[pucch->initial_pucch_id].PRB_offset; + RB_BWP_offset = initial_pucch_resource[pucch_resourcecommon].PRB_offset; - int N_CS = initial_pucch_resource[pucch->initial_pucch_id].nb_CS_indexes; - pucch_pdu->prb_start = RB_BWP_offset + (pucch->initial_pucch_id/N_CS); - if (pucch->initial_pucch_id>>3 == 0) { - pucch_pdu->second_hop_prb = pucch_pdu->bwp_size - 1 - RB_BWP_offset - (pucch->initial_pucch_id/N_CS); - pucch_pdu->initial_cyclic_shift = initial_pucch_resource[pucch->initial_pucch_id].initial_CS_indexes[pucch->initial_pucch_id%N_CS]; + int N_CS = initial_pucch_resource[pucch_resourcecommon].nb_CS_indexes; + + if (pucch->initial_pucch_id >> 3 == 0) { + pucch_pdu->prb_start = RB_BWP_offset + (pucch->initial_pucch_id / N_CS); + pucch_pdu->second_hop_prb = pucch_pdu->bwp_size - 1 - RB_BWP_offset - (pucch->initial_pucch_id / N_CS); + pucch_pdu->initial_cyclic_shift = initial_pucch_resource[pucch_resourcecommon].initial_CS_indexes[pucch->initial_pucch_id % N_CS]; } else { - pucch_pdu->second_hop_prb = pucch_pdu->bwp_size - 1 - RB_BWP_offset - ((pucch->initial_pucch_id - 8)/N_CS); - pucch_pdu->initial_cyclic_shift = initial_pucch_resource[pucch->initial_pucch_id].initial_CS_indexes[(pucch->initial_pucch_id - 8)%N_CS]; + pucch_pdu->prb_start = pucch_pdu->bwp_size - 1 - RB_BWP_offset - ((pucch->initial_pucch_id - 8) / N_CS); + pucch_pdu->second_hop_prb = RB_BWP_offset + ((pucch->initial_pucch_id - 8) / N_CS); + pucch_pdu->initial_cyclic_shift = initial_pucch_resource[pucch_resourcecommon].initial_CS_indexes[(pucch->initial_pucch_id - 8) % N_CS]; } pucch_pdu->freq_hop_flag = 1; pucch_pdu->time_domain_occ_idx = 0; @@ -1431,19 +1360,14 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, NR_PUCCH_Resource_t *pucchres = pucch->pucch_resource; - if (mac->cg && - mac->cg->physicalCellGroupConfig && - (mac->cg->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH != NULL || - mac->cg->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook != 1)) { + if (current_UL_BWP->harq_ACK_SpatialBundlingPUCCH != NULL || + *current_DL_BWP->pdsch_HARQ_ACK_Codebook != 1) { LOG_E(MAC,"PUCCH Unsupported cell group configuration\n"); return; } - else if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup && - mac->cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) { + else if (current_DL_BWP && + current_DL_BWP->pdsch_servingcellconfig && + current_DL_BWP->pdsch_servingcellconfig->codeBlockGroupTransmission != NULL) { LOG_E(MAC,"PUCCH Unsupported code block group for serving cell config\n"); return; } @@ -1457,25 +1381,8 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->transformPrecodingDisabled->scramblingID0; } - NR_PUCCH_Config_t *pucch_Config; - if (bwp_id>0 && - mac->ULbwp[bwp_id-1] && - mac->ULbwp[bwp_id-1]->bwp_Dedicated && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup) { - pucch_Config = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup; - } - else if (bwp_id==0 && - mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { - pucch_Config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; - } - else AssertFatal(1==0,"no pucch_Config\n"); + NR_PUCCH_Config_t *pucch_Config = current_UL_BWP->pucch_Config; + AssertFatal(pucch_Config,"no pucch_Config\n"); pucch_pdu->bwp_size = current_UL_BWP->BWPSize; pucch_pdu->bwp_start = current_UL_BWP->BWPStart; @@ -1595,14 +1502,8 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, } else AssertFatal(1==0,"problem with pucch configuration\n"); - NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon; - if (bwp_id>0 && - mac->ULbwp[bwp_id-1] && - mac->ULbwp[bwp_id-1]->bwp_Common && - mac->ULbwp[bwp_id-1]->bwp_Common->pucch_ConfigCommon) - pucch_ConfigCommon = mac->ULbwp[bwp_id-1]->bwp_Common->pucch_ConfigCommon->choice.setup; - else if (mac->scc) pucch_ConfigCommon = mac->scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup; - else pucch_ConfigCommon = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pucch_ConfigCommon->choice.setup; + NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon = current_UL_BWP->pucch_ConfigCommon; + if (pucch_ConfigCommon->hoppingId != NULL) pucch_pdu->hopping_id = *pucch_ConfigCommon->hoppingId; else @@ -1643,10 +1544,9 @@ int16_t get_pucch_tx_power_ue(NR_UE_MAC_INST_t *mac, int O_ACK, int O_SR, int O_CSI, int O_CRC) { + NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; int PUCCH_POWER_DEFAULT = 0; - int16_t P_O_NOMINAL_PUCCH; - if (mac->scc) P_O_NOMINAL_PUCCH = *mac->scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->p0_nominal; - else P_O_NOMINAL_PUCCH = *mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pucch_ConfigCommon->choice.setup->p0_nominal; + int16_t P_O_NOMINAL_PUCCH = *current_UL_BWP->pucch_ConfigCommon->p0_nominal; struct NR_PUCCH_PowerControl *power_config = pucch_Config->pucch_PowerControl; @@ -1790,7 +1690,7 @@ int get_deltatf(uint16_t nb_of_prbs, int find_pucch_resource_set(NR_UE_MAC_INST_t *mac, int uci_size) { int pucch_resource_set_id = 0; - NR_BWP_Id_t bwp_id = mac->current_DL_BWP.bwp_id; + NR_PUCCH_Config_t *pucch_Config = mac->current_UL_BWP.pucch_Config; //long *pucch_max_pl_bits = NULL; @@ -1803,23 +1703,9 @@ int find_pucch_resource_set(NR_UE_MAC_INST_t *mac, int uci_size) { */ /* look for the first resource set which supports uci_size number of bits for payload */ while (pucch_resource_set_id < MAX_NB_OF_PUCCH_RESOURCE_SETS) { - if ((bwp_id>0 && - mac->ULbwp[bwp_id-1] && - mac->ULbwp[bwp_id-1]->bwp_Dedicated && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[pucch_resource_set_id] != NULL) || - (bwp_id==0 && - mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList->list.array[pucch_resource_set_id] != NULL)) { + if (pucch_Config && + pucch_Config->resourceSetToAddModList && + pucch_Config->resourceSetToAddModList->list.array[pucch_resource_set_id] != NULL) { // PUCCH with format0 can be up to 3 bits (2 ack/nacks + 1 sr is 3 max bits) if (uci_size <= 3) { pucch_resource_set_id = 0; @@ -1859,32 +1745,16 @@ int find_pucch_resource_set(NR_UE_MAC_INST_t *mac, int uci_size) { *********************************************************************/ void select_pucch_resource(NR_UE_MAC_INST_t *mac, - PUCCH_sched_t *pucch) { + PUCCH_sched_t *pucch) +{ NR_PUCCH_ResourceId_t *current_resource_id = NULL; - NR_BWP_Id_t bwp_id = mac->current_UL_BWP.bwp_id; + NR_PUCCH_Config_t *pucch_Config = mac->current_UL_BWP.pucch_Config; int n_list; - if (pucch->is_common == 1 || - (bwp_id == 0 && - mac->cg == NULL) || - (bwp_id == 0 && - mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList->list.array[0] == NULL) || - (mac->ULbwp[bwp_id-1] && - mac->ULbwp[bwp_id-1]->bwp_Dedicated && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[0] == NULL) - ){ + !pucch_Config || + !pucch_Config->resourceSetToAddModList || + pucch_Config->resourceSetToAddModList->list.array[0] == NULL) { /* see TS 38.213 9.2.1 PUCCH Resource Sets */ int delta_PRI = pucch->resource_indicator; @@ -1898,19 +1768,8 @@ void select_pucch_resource(NR_UE_MAC_INST_t *mac, pucch->pucch_resource = NULL; } else { - struct NR_PUCCH_Config__resourceSetToAddModList *resourceSetToAddModList = NULL; - struct NR_PUCCH_Config__resourceToAddModList *resourceToAddModList = NULL; - if (bwp_id > 0 && mac->ULbwp[bwp_id-1]) { - AssertFatal(mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList!=NULL, - "mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList is null\n"); - resourceSetToAddModList = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList; - resourceToAddModList = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceToAddModList; - } - else if (bwp_id == 0 && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList!=NULL) { - resourceSetToAddModList = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList; - resourceToAddModList = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceToAddModList; - } - + struct NR_PUCCH_Config__resourceSetToAddModList *resourceSetToAddModList = pucch_Config->resourceSetToAddModList; + struct NR_PUCCH_Config__resourceToAddModList *resourceToAddModList = pucch_Config->resourceToAddModList; n_list = resourceSetToAddModList->list.count; if (pucch->resource_set_id > n_list) { LOG_E(MAC,"Invalid PUCCH resource set id %d\n",pucch->resource_set_id); @@ -1990,13 +1849,6 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id; - NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id; - NR_BWP_DownlinkDedicated_t *bwpd=NULL; - NR_BWP_DownlinkCommon_t *bwpc=NULL; - NR_BWP_UplinkDedicated_t *ubwpd=NULL; - NR_BWP_UplinkCommon_t *ubwpc=NULL; - get_bwp_info(mac,dl_bwp_id,ul_bwp_id,&bwpd,&bwpc,&ubwpd,&ubwpc); if (current_DL_BWP && current_DL_BWP->pdsch_Config && @@ -2026,8 +1878,8 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, sched_frame = (sched_frame + 1) % 1024; } AssertFatal(sched_slot < slots_per_frame, "sched_slot was calculated incorrect %d\n", sched_slot); - LOG_D(PHY,"HARQ pid %d is active for %d.%d (dl_slot %d, feedback_to_ul %d, is_common %d\n", - dl_harq_pid, sched_frame,sched_slot,current_harq->dl_slot,current_harq->feedback_to_ul,current_harq->is_common); + LOG_D(PHY,"HARQ pid %d is active for %d.%d (dl_slot %d, feedback_to_ul %d\n", + dl_harq_pid, sched_frame,sched_slot,current_harq->dl_slot,current_harq->feedback_to_ul); /* check if current tx slot should transmit downlink acknowlegment */ if (sched_frame == frame && sched_slot == slot) { if (get_softmodem_params()->emulate_l1) { @@ -2091,9 +1943,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, U_DAI_c = number_harq_feedback/number_of_code_word; N_m_c_rx = number_harq_feedback; int N_SPS_c = 0; /* FFS TODO_NR multicells and SPS are not supported at the moment */ - if (mac->cg != NULL && - mac->cg->physicalCellGroupConfig != NULL && - mac->cg->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH != NULL) { + if (current_UL_BWP->harq_ACK_SpatialBundlingPUCCH != NULL) { int N_TB_max_DL = current_DL_BWP->pdsch_Config->maxNrofCodeWordsScheduledByDCI[0]; pucch->n_HARQ_ACK = (((V_DAI_m_DL - U_DAI_c)%4) * N_TB_max_DL) + N_m_c_rx + N_SPS_c; LOG_D(MAC, "PUCCH power n(%d) = ( V(%d) - U(%d) )mod4 * N_TB(%d) + N(%d) \n", pucch->n_HARQ_ACK, V_DAI_m_DL, U_DAI_c, N_TB_max_DL, N_m_c_rx); @@ -2187,28 +2037,10 @@ bool trigger_periodic_scheduling_request(NR_UE_MAC_INST_t *mac, int slot) { NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - NR_BWP_Id_t bwp_id = current_UL_BWP->bwp_id; - NR_PUCCH_Config_t *pucch_Config = NULL; + NR_PUCCH_Config_t *pucch_Config = current_UL_BWP->pucch_Config; const int n_slots_frame = nr_slots_per_frame[current_UL_BWP->scs]; - if (bwp_id>0 && - mac->ULbwp[bwp_id-1] && - mac->ULbwp[bwp_id-1]->bwp_Dedicated && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup) { - pucch_Config = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup; - } - else if (bwp_id==0 && - mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { - pucch_Config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; - } if(!pucch_Config || !pucch_Config->schedulingRequestResourceToAddModList || pucch_Config->schedulingRequestResourceToAddModList->list.count==0) @@ -2301,15 +2133,12 @@ uint8_t nr_get_csi_measurements(NR_UE_MAC_INST_t *mac, NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; NR_BWP_Id_t bwp_id = current_UL_BWP->bwp_id; - NR_PUCCH_Config_t *pucch_Config = NULL; + NR_PUCCH_Config_t *pucch_Config = current_UL_BWP->pucch_Config; int csi_bits = 0; - if(mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig) { + if(current_UL_BWP->csi_MeasConfig) { - NR_CSI_MeasConfig_t *csi_measconfig = mac->cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; + NR_CSI_MeasConfig_t *csi_measconfig = current_UL_BWP->csi_MeasConfig; for (int csi_report_id = 0; csi_report_id < csi_measconfig->csi_ReportConfigToAddModList->list.count; csi_report_id++){ NR_CSI_ReportConfig_t *csirep = csi_measconfig->csi_ReportConfigToAddModList->list.array[csi_report_id]; @@ -2323,21 +2152,6 @@ uint8_t nr_get_csi_measurements(NR_UE_MAC_INST_t *mac, int period, offset; csi_period_offset(csirep, NULL, &period, &offset); - if (bwp_id>0 && - mac->ULbwp[bwp_id-1] && - mac->ULbwp[bwp_id-1]->bwp_Dedicated && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup) { - pucch_Config = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup; - } - else if (bwp_id==0 && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { - pucch_Config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; - } - const int n_slots_frame = nr_slots_per_frame[current_UL_BWP->scs]; if (((n_slots_frame*frame + slot - offset)%period) == 0 && pucch_Config) { LOG_D(NR_MAC, "Preparing CSI report in frame %d slot %d CSI report ID %d\n", frame, slot, csi_report_id); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 84075cd337..6a96ff474b 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -136,31 +136,14 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl return &mac->ul_config_request[index]; } -void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci) { +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) +{ - NR_ServingCellConfigCommon_t *scc = mac->scc; NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - NR_SRS_Config_t *srs_config = NULL; - - if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { - srs_config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config->choice.setup; - } - + NR_SRS_Config_t *srs_config = current_UL_BWP->srs_Config; NR_PUSCH_Config_t *pusch_Config = current_UL_BWP->pusch_Config; - long transformPrecoder; - if (pusch_Config && pusch_Config->transformPrecoder) - transformPrecoder = *pusch_Config->transformPrecoder; - else { - if(scc && scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder) - transformPrecoder = NR_PUSCH_Config__transformPrecoder_enabled; - else - transformPrecoder = NR_PUSCH_Config__transformPrecoder_disabled; - } + long transformPrecoder = get_transformPrecoding(current_UL_BWP, dci_format, 0); pusch_config_pdu->transform_precoding = transformPrecoder; /* PRECOD_NBR_LAYERS */ @@ -287,23 +270,15 @@ void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_con } // todo: this function shall be reviewed completely because of the many comments left by the author -void ul_ports_config(NR_UE_MAC_INST_t *mac, int *n_front_load_symb, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci) { +void ul_ports_config(NR_UE_MAC_INST_t *mac, int *n_front_load_symb, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci, nr_dci_format_t dci_format) +{ uint8_t rank = pusch_config_pdu->nrOfLayers; - NR_ServingCellConfigCommon_t *scc = mac->scc; NR_PUSCH_Config_t *pusch_Config = mac->current_UL_BWP.pusch_Config; AssertFatal(pusch_Config!=NULL,"pusch_Config shouldn't be null\n"); - long transformPrecoder; - if (pusch_Config->transformPrecoder) - transformPrecoder = *pusch_Config->transformPrecoder; - else { - if(scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder) - transformPrecoder = NR_PUSCH_Config__transformPrecoder_enabled; - else - transformPrecoder = NR_PUSCH_Config__transformPrecoder_disabled; - } + long transformPrecoder = get_transformPrecoding(&mac->current_UL_BWP, dci_format, 0); long *max_length = NULL; long *dmrs_type = NULL; LOG_D(NR_MAC,"transformPrecoder %s\n",transformPrecoder==NR_PUSCH_Config__transformPrecoder_disabled?"disabled":"enabled"); @@ -502,9 +477,6 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->nrOfLayers = 1; pusch_config_pdu->Tpmi = 0; pusch_config_pdu->rnti = rnti; - NR_BWP_UplinkCommon_t *initialUplinkBWP; - if (mac->scc) initialUplinkBWP = mac->scc->uplinkConfigCommon->initialUplinkBWP; - else initialUplinkBWP = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; pusch_dmrs_AdditionalPosition_t add_pos = pusch_dmrs_pos2; int dmrslength = 1; @@ -567,10 +539,10 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->scid = 0; // Transform precoding according to 6.1.3 UE procedure for applying transform precoding on PUSCH in 38.214 - pusch_config_pdu->transform_precoding = get_transformPrecoding(initialUplinkBWP, pusch_Config, NULL, NULL, NR_RNTI_TC, 0); // TBR fix rnti and take out + pusch_config_pdu->transform_precoding = get_transformPrecoding(current_UL_BWP, NR_UL_DCI_FORMAT_0_0, 0); // as if it was DCI 0_0 // Resource allocation in frequency domain according to 6.1.2.2 in TS 38.214 - pusch_config_pdu->resource_alloc = (mac->cg) ? pusch_Config->resourceAllocation : 1; + pusch_config_pdu->resource_alloc = 1; //// Completing PUSCH PDU pusch_config_pdu->mcs_table = 0; @@ -588,13 +560,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->tbslbrm = 0; } else if (dci) { - NR_BWP_Id_t dl_bwp_id = mac->current_DL_BWP.bwp_id; NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id; - NR_BWP_DownlinkDedicated_t *bwpd=NULL; - NR_BWP_DownlinkCommon_t *bwpc=NULL; - NR_BWP_UplinkDedicated_t *ubwpd=NULL; - NR_BWP_UplinkCommon_t *ubwpc=NULL; - get_bwp_info(mac,dl_bwp_id,ul_bwp_id,&bwpd,&bwpc,&ubwpd,&ubwpc); int target_ss; bool valid_ptrs_setup = 0; @@ -610,7 +576,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, /* Transform precoding */ if (rnti_type != NR_RNTI_CS || (rnti_type == NR_RNTI_CS && dci->ndi == 1)) { - pusch_config_pdu->transform_precoding = get_transformPrecoding(initialUplinkBWP, pusch_Config, NULL, dci_format, rnti_type, 0); + pusch_config_pdu->transform_precoding = get_transformPrecoding(current_UL_BWP, *dci_format, 0); } /*DCI format-related configuration*/ @@ -620,11 +586,9 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, } else if (*dci_format == NR_UL_DCI_FORMAT_0_1) { - get_bwp_info(mac,dl_bwp_id,ul_bwp_id,&bwpd,&bwpc,&ubwpd,&ubwpc); - target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - ul_layers_config(mac, pusch_config_pdu, dci); - ul_ports_config(mac, &dmrslength, pusch_config_pdu, dci); + ul_layers_config(mac, pusch_config_pdu, dci, *dci_format); + ul_ports_config(mac, &dmrslength, pusch_config_pdu, dci, *dci_format); } else { @@ -750,23 +714,15 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, } // Num PRB Overhead from PUSCH-ServingCellConfig - if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead) - N_PRB_oh = *mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead; + if (current_UL_BWP->pusch_servingcellconfig && + current_UL_BWP->pusch_servingcellconfig->xOverhead) + N_PRB_oh = *current_UL_BWP->pusch_servingcellconfig->xOverhead; + else + N_PRB_oh = 0; - else N_PRB_oh = 0; - - if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->rateMatching) { - long *maxMIMO_Layers = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers; + if (current_UL_BWP->pusch_servingcellconfig && + current_UL_BWP->pusch_servingcellconfig->rateMatching) { + long *maxMIMO_Layers = current_UL_BWP->pusch_servingcellconfig->ext1->maxMIMO_Layers; if (!maxMIMO_Layers) maxMIMO_Layers = pusch_Config ? pusch_Config->maxRank : NULL; AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); @@ -846,21 +802,8 @@ bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slo NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id; - NR_SRS_Config_t *srs_config = NULL; - if (ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1]) { - if (mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated && - mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->srs_Config) { - srs_config = mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->srs_Config->choice.setup; - } - } else if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { - srs_config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config->choice.setup; - } + NR_SRS_Config_t *srs_config = current_UL_BWP->srs_Config; if (!srs_config) { return false; @@ -1554,7 +1497,7 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) { uint8_t format2 = 0xff; int nb_fdm; - uint8_t config_index, mu; + uint8_t config_index; int msg1_FDM; uint8_t prach_conf_period_idx; @@ -1562,20 +1505,16 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) { uint8_t prach_conf_period_frame_idx; int64_t *prach_config_info_p; - NR_RACH_ConfigCommon_t *setup = (mac->scc) ? - mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup: - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; + NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP.rach_ConfigCommon; NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; config_index = rach_ConfigGeneric->prach_ConfigurationIndex; - if (setup->msg1_SubcarrierSpacing) { + int mu; + if (setup->msg1_SubcarrierSpacing) mu = *setup->msg1_SubcarrierSpacing; - } else if(mac->scc) { - mu = mac->scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; - } else { - mu = get_softmodem_params()->numerology; - } + else + mu = mac->current_UL_BWP.scs; msg1_FDM = rach_ConfigGeneric->msg1_FDM; @@ -1810,9 +1749,7 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) { // Map SSBs to PRACH occasions // =========================== // WIP: Assumption: No PRACH occasion is rejected because of a conflict with SSBs or TDD_UL_DL_ConfigurationCommon schedule - NR_RACH_ConfigCommon_t *setup = (mac->scc) ? - mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup: - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; + NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP.rach_ConfigCommon; NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR ssb_perRACH_config = setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present; bool multiple_ssb_per_ro; // true if more than one or exactly one SSB per RACH occasion, false if more than one RO per SSB @@ -2222,27 +2159,7 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, vo // ACKNACK O_ACK = get_downlink_ack(mac, frameP, slotP, &pucch); - NR_BWP_Id_t bwp_id = mac->current_UL_BWP.bwp_id; - NR_PUCCH_Config_t *pucch_Config = NULL; - - if (bwp_id>0 && - mac->ULbwp[bwp_id-1] && - mac->ULbwp[bwp_id-1]->bwp_Dedicated && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup) { - pucch_Config = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup; - } - else if (bwp_id==0 && - mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { - pucch_Config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; - } - + NR_PUCCH_Config_t *pucch_Config = mac->current_UL_BWP.pucch_Config; // if multiplexing of HARQ and CSI is not possible, transmit only HARQ bits if ((O_ACK != 0) && (O_CSI != 0) && @@ -2282,7 +2199,6 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, vo &pucch, pucch_pdu, O_SR, O_ACK, O_CSI); - LOG_D(NR_MAC, "Configuring pucch, is_common = %d\n", pucch.is_common); nr_scheduled_response_t scheduled_response; fill_scheduled_response(&scheduled_response, NULL, ul_config, NULL, module_idP, 0 /*TBR fix*/, frameP, slotP, phy_data); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) @@ -2296,13 +2212,12 @@ void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot) { if (mac->ra.ra_state != RA_SUCCEEDED && get_softmodem_params()->phy_test == 0) return; - NR_CellGroupConfig_t *CellGroup = mac->cg; + NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - if (!CellGroup || !CellGroup->spCellConfig || !CellGroup->spCellConfig->spCellConfigDedicated || - !CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig) + if (!current_UL_BWP->csi_MeasConfig) return; - NR_CSI_MeasConfig_t *csi_measconfig = CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; + NR_CSI_MeasConfig_t *csi_measconfig = current_UL_BWP->csi_MeasConfig; if (csi_measconfig->csi_IM_ResourceToAddModList == NULL) return; @@ -2354,13 +2269,12 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { if (mac->ra.ra_state != RA_SUCCEEDED && get_softmodem_params()->phy_test == 0) return; - NR_CellGroupConfig_t *CellGroup = mac->cg; + NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - if (!CellGroup || !CellGroup->spCellConfig || !CellGroup->spCellConfig->spCellConfigDedicated || - !CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig) + if (!current_UL_BWP->csi_MeasConfig) return; - NR_CSI_MeasConfig_t *csi_measconfig = CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; + NR_CSI_MeasConfig_t *csi_measconfig = current_UL_BWP->csi_MeasConfig; if (csi_measconfig->nzp_CSI_RS_ResourceToAddModList == NULL) return; @@ -2541,9 +2455,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s NR_ServingCellConfigCommon_t *scc = mac->scc; NR_ServingCellConfigCommonSIB_t *scc_SIB = mac->scc_SIB; - NR_RACH_ConfigCommon_t *setup; - if (scc!=NULL) setup = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup; - else setup = scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; + NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP.rach_ConfigCommon; NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; NR_TDD_UL_DL_ConfigCommon_t *tdd_config = scc==NULL ? scc_SIB->tdd_UL_DL_ConfigurationCommon : scc->tdd_UL_DL_ConfigurationCommon; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index c34d7f6316..88c3856931 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1081,7 +1081,8 @@ void prepare_dci(const NR_CellGroupConfig_t *CellGroup, const NR_UE_DL_BWP_t *current_BWP, const NR_ControlResourceSet_t *coreset, dci_pdu_rel15_t *dci_pdu_rel15, - nr_dci_format_t format) { + nr_dci_format_t format) +{ AssertFatal(CellGroup!=NULL,"CellGroup shouldn't be null here\n"); @@ -1188,16 +1189,12 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, // computing alternative size for padding dci_pdu_rel15_t temp_pdu; if(dci_format == NR_DL_DCI_FORMAT_1_0) - alt_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP, - scc->uplinkConfigCommon->initialUplinkBWP, - current_DL_BWP, current_UL_BWP, + alt_size = nr_dci_size(current_DL_BWP, current_UL_BWP, CellGroup, &temp_pdu, NR_UL_DCI_FORMAT_0_0, rnti_type, coreset, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, 0); if(dci_format == NR_UL_DCI_FORMAT_0_0) - alt_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP, - scc->uplinkConfigCommon->initialUplinkBWP, - current_DL_BWP, current_UL_BWP, + alt_size = nr_dci_size(current_DL_BWP, current_UL_BWP, CellGroup, &temp_pdu, NR_DL_DCI_FORMAT_1_0, rnti_type, coreset, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, 0); @@ -1205,9 +1202,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, else N_RB = cset0_bwp_size; - int dci_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP, - scc->uplinkConfigCommon->initialUplinkBWP, - current_DL_BWP, current_UL_BWP, + int dci_size = nr_dci_size(current_DL_BWP, current_UL_BWP, CellGroup, dci_pdu_rel15, dci_format, rnti_type, coreset, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, alt_size); pdcch_dci_pdu->PayloadSizeBits = dci_size; @@ -2092,6 +2087,10 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, int target_ss; + if(CellGroup && + CellGroup->physicalCellGroupConfig) + DL_BWP->pdsch_HARQ_ACK_Codebook = &CellGroup->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook; + if (CellGroup && CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated) { @@ -2100,6 +2099,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, DL_BWP->pdsch_servingcellconfig = servingCellConfig->pdsch_ServingCellConfig ? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; UL_BWP->pusch_servingcellconfig = servingCellConfig->uplinkConfig && servingCellConfig->uplinkConfig->pusch_ServingCellConfig ? servingCellConfig->uplinkConfig->pusch_ServingCellConfig->choice.setup : NULL; + target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; if(UE && UE->Msg3_dcch_dtch) { @@ -2165,6 +2165,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, ubwpd = servingCellConfig->uplinkConfig->initialUplinkBWP; DL_BWP->pdsch_Config = bwpd->pdsch_Config->choice.setup; + UL_BWP->configuredGrantConfig = ubwpd->configuredGrantConfig ? ubwpd->configuredGrantConfig->choice.setup : NULL; UL_BWP->pusch_Config = ubwpd->pusch_Config->choice.setup; UL_BWP->pucch_Config = ubwpd->pucch_Config->choice.setup; UL_BWP->srs_Config = ubwpd->srs_Config->choice.setup; @@ -2178,6 +2179,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, UL_BWP->pusch_Config = NULL; UL_BWP->pucch_Config = NULL; UL_BWP->csi_MeasConfig = NULL; + UL_BWP->configuredGrantConfig = NULL; } if (old_dl_bwp_id != DL_BWP->bwp_id) @@ -2224,10 +2226,14 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, else UL_BWP->transform_precoding = *UL_BWP->pusch_Config->transformPrecoder; - if(UL_BWP->bwp_id>0) + if(UL_BWP->bwp_id > 0) { UL_BWP->pucch_ConfigCommon = ul_bwp->bwp_Common->pucch_ConfigCommon->choice.setup; - else + UL_BWP->rach_ConfigCommon = ul_bwp->bwp_Common->rach_ConfigCommon->choice.setup; + } + else { UL_BWP->pucch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup; + UL_BWP->rach_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup; + } if(UE) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 5caea0c2c7..8d3d377d43 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -1015,14 +1015,13 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, } } -void set_pucch_allocation(const NR_PUCCH_Config_t *pucch_Config, - const NR_ServingCellConfigCommon_t *scc, +void set_pucch_allocation(const NR_UE_UL_BWP_t *ul_bwp, const int r_pucch, const int bwp_size, NR_sched_pucch_t *pucch) { if(r_pucch<0){ - const NR_PUCCH_Resource_t *resource = pucch_Config->resourceToAddModList->list.array[0]; + const NR_PUCCH_Resource_t *resource = ul_bwp->pucch_Config->resourceToAddModList->list.array[0]; DevAssert(resource->format.present == NR_PUCCH_Resource__format_PR_format0); pucch->second_hop_prb = resource->secondHopPRB!= NULL ? *resource->secondHopPRB : 0; pucch->nr_of_symb = resource->format.choice.format0->nrofSymbols; @@ -1030,7 +1029,7 @@ void set_pucch_allocation(const NR_PUCCH_Config_t *pucch_Config, pucch->prb_start = resource->startingPRB; } else{ - int rsetindex = *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon; + int rsetindex = *ul_bwp->pucch_ConfigCommon->pucch_ResourceCommon; set_r_pucch_parms(rsetindex, r_pucch, bwp_size, @@ -1155,7 +1154,7 @@ int nr_acknack_scheduling(gNB_MAC_INST *mac, } else { // unoccupied occasion // checking if in ul_slot the resources potentially to be assigned to this PUCCH are available - set_pucch_allocation(pucch_Config, scc, r_pucch, bwp_size, curr_pucch); + set_pucch_allocation(ul_bwp, r_pucch, bwp_size, curr_pucch); uint16_t *vrb_map_UL = &mac->common_channels[CC_id].vrb_map_UL[pucch_slot * MAX_BWP_SIZE]; bool ret = test_pucch0_vrb_occupation(curr_pucch, vrb_map_UL, @@ -1249,7 +1248,7 @@ void nr_sr_reporting(gNB_MAC_INST *nrmac, frame_t SFN, sub_frame_t slot) uint16_t *vrb_map_UL = &nrmac->common_channels[CC_id].vrb_map_UL[slot * MAX_BWP_SIZE]; const int bwp_start = ul_bwp->BWPStart; const int bwp_size = ul_bwp->BWPSize; - set_pucch_allocation(pucch_Config, scc, -1, bwp_size, curr_pucch); + set_pucch_allocation(ul_bwp, -1, bwp_size, curr_pucch); bool ret = test_pucch0_vrb_occupation(curr_pucch, vrb_map_UL, bwp_start, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index ae93e07c36..8ddebc9118 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -278,7 +278,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, uint16_t cset0_bwp_size); void prepare_dci(const NR_CellGroupConfig_t *CellGroup, - const NR_UE_DL_BWP_t *dl_bwp, + const NR_UE_DL_BWP_t *current_BWP, const NR_ControlResourceSet_t *coreset, dci_pdu_rel15_t *dci_pdu_rel15, nr_dci_format_t format); From 4b6ac06b5eb319200642d84cb38f25b4f7a2a717 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 17 Jan 2023 10:55:55 +0100 Subject: [PATCH 5/7] fixes --- openair1/SIMULATION/NR_PHY/dlsim.c | 3 ++- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 5 +++-- openair2/LAYER2/NR_MAC_UE/config_ue.c | 11 +++++++---- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 5 +++-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 9b6db46aa8..b17e722700 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -253,7 +253,8 @@ void nr_dlsim_preprocessor(module_id_t module_id, sched_pdsch->time_domain_allocation = get_dl_tda(RC.nrmac[module_id], scc, slot); AssertFatal(sched_pdsch->time_domain_allocation>=0,"Unable to find PDSCH time domain allocation in list\n"); - sched_pdsch->tda_info = nr_get_pdsch_tda_info(current_BWP, sched_pdsch->time_domain_allocation); + NR_PDSCH_TimeDomainResourceAllocationList_t *tdalist = get_dl_tdalist(current_BWP, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); + sched_pdsch->tda_info = nr_get_pdsch_tda_info(tdalist, sched_pdsch->time_domain_allocation); sched_pdsch->dmrs_parms = get_dl_dmrs_params(scc, current_BWP, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 6612b78b92..bdc40f0039 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -3315,6 +3315,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, dci_pdu->bwp_indicator.nbits = UL_BWP->n_ul_bwp; else dci_pdu->bwp_indicator.nbits = 2; + LOG_D(NR_MAC,"BWP indicator nbits %d, num UL BWPs %d\n", dci_pdu->bwp_indicator.nbits, UL_BWP->n_ul_bwp); size += dci_pdu->bwp_indicator.nbits; // Freq domain assignment if (pusch_Config) { @@ -3332,7 +3333,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, } else dci_pdu->frequency_domain_assignment.nbits = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); - LOG_D(NR_MAC,"PUSCH Frequency Domain Assignment nbits %d, N_RB %d\n",dci_pdu->frequency_domain_assignment.nbits,N_RB); + LOG_D(NR_MAC,"PUSCH Frequency Domain Assignment nbits %d, N_RB %d\n", dci_pdu->frequency_domain_assignment.nbits, N_RB); size += dci_pdu->frequency_domain_assignment.nbits; // Time domain assignment NR_PUSCH_TimeDomainResourceAllocationList_t *tdalistul = get_ul_tdalist(UL_BWP, coreset->controlResourceSetId, ss_type, rnti_type); @@ -3341,7 +3342,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, else num_entries = 16; // num of entries in default table dci_pdu->time_domain_assignment.nbits = (int)ceil(log2(num_entries)); - LOG_D(NR_MAC,"PUSCH Time Domain Allocation nbits %d, pusch_Config %p\n",dci_pdu->time_domain_assignment.nbits,pusch_Config); + LOG_D(NR_MAC,"PUSCH Time Domain Allocation nbits %d, pusch_Config %p\n", dci_pdu->time_domain_assignment.nbits, pusch_Config); size += dci_pdu->time_domain_assignment.nbits; // Frequency Hopping flag if (pusch_Config && diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 950c0c6d5f..0e01eb6712 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -549,8 +549,8 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, NR_BWP_t ul_genericParameters = {0}; NR_BWP_DownlinkCommon_t *bwp_dlcommon = NULL; NR_BWP_UplinkCommon_t *bwp_ulcommon = NULL; - DL_BWP->n_dl_bwp = 1; - UL_BWP->n_ul_bwp = 1; + DL_BWP->n_dl_bwp = 0; + UL_BWP->n_ul_bwp = 0; if(scc) { DL_BWP->bwp_id = 0; @@ -616,13 +616,14 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, AssertFatal(bwp_downlink != NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n", DL_BWP->bwp_id); dl_genericParameters = bwp_downlink->bwp_Common->genericParameters; DL_BWP->pdsch_Config = bwp_downlink->bwp_Dedicated->pdsch_Config->choice.setup; + DL_BWP->tdaList = bwp_downlink->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; } else { dl_genericParameters = bwp_dlcommon->genericParameters; DL_BWP->pdsch_Config = spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup; + DL_BWP->tdaList = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; } - DL_BWP->tdaList = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - UL_BWP->tdaList = bwp_ulcommon->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + UL_BWP->msg3_DeltaPreamble = bwp_ulcommon->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble; NR_BWP_Uplink_t *bwp_uplink = NULL; @@ -637,6 +638,7 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, } AssertFatal(bwp_uplink != NULL,"Couldn't find ULBWP corresponding to BWP ID %ld\n",UL_BWP->bwp_id); ul_genericParameters = bwp_uplink->bwp_Common->genericParameters; + UL_BWP->tdaList = bwp_uplink->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; UL_BWP->pusch_Config = bwp_uplink->bwp_Dedicated->pusch_Config->choice.setup; UL_BWP->pucch_Config = bwp_uplink->bwp_Dedicated->pucch_Config->choice.setup; UL_BWP->srs_Config = bwp_uplink->bwp_Dedicated->srs_Config->choice.setup; @@ -647,6 +649,7 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, UL_BWP->rach_ConfigCommon = bwp_uplink->bwp_Common->rach_ConfigCommon->choice.setup; } else { + UL_BWP->tdaList = bwp_ulcommon->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; UL_BWP->pusch_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pusch_Config->choice.setup; UL_BWP->pucch_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; UL_BWP->srs_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config->choice.setup; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 88c3856931..d1f1524fa2 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2080,8 +2080,9 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, NR_BWP_Uplink_t *ul_bwp = NULL; NR_BWP_DownlinkDedicated_t *bwpd = NULL; NR_BWP_UplinkDedicated_t *ubwpd = NULL; - DL_BWP->n_dl_bwp = 1; - UL_BWP->n_ul_bwp = 1; + // number of additional BWPs (excluding initial BWP) + DL_BWP->n_dl_bwp = 0; + UL_BWP->n_ul_bwp = 0; int old_dl_bwp_id = DL_BWP->bwp_id; int old_ul_bwp_id = UL_BWP->bwp_id; From a7e7899edd8b6004b99b037f11922e3f3deaa4b7 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 31 Jan 2023 09:51:34 +0100 Subject: [PATCH 6/7] addressing review including clang formatting --- .../nfapi/public_inc/fapi_nr_ue_interface.h | 2 +- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 2 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac.h | 5 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 151 +++++++----------- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 19 +-- openair2/LAYER2/NR_MAC_UE/config_ue.c | 29 ++-- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 12 +- openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 7 +- .../NR_MAC_UE/nr_ue_dci_configuration.c | 27 ++-- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 104 +++++------- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 77 ++++----- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 33 ++-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 5 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 9 +- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 2 +- 15 files changed, 186 insertions(+), 298 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index e13fbbb790..94bf1b02dc 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -87,7 +87,7 @@ typedef struct { typedef struct { uint16_t rnti; uint8_t dci_format; - uint8_t CoreSetType; + uint8_t coreset_type; int ss_type; // n_CCE index of first CCE for PDCCH reception int n_CCE; diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 76db94b63f..d4ffb66b65 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -935,7 +935,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, dci_ind->dci_list[dci_ind->number_of_dcis].N_CCE = L; dci_ind->dci_list[dci_ind->number_of_dcis].dci_format = rel15->dci_format_options[k]; dci_ind->dci_list[dci_ind->number_of_dcis].ss_type = rel15->dci_type_options[k]; - dci_ind->dci_list[dci_ind->number_of_dcis].CoreSetType = rel15->coreset.CoreSetType; + dci_ind->dci_list[dci_ind->number_of_dcis].coreset_type = rel15->coreset.CoreSetType; int n_rb, rb_offset; get_coreset_rballoc(rel15->coreset.frequency_domain_resource, &n_rb, &rb_offset); dci_ind->dci_list[dci_ind->number_of_dcis].cset_start = rel15->BWPStart + rb_offset; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index 183697822d..5782fbf054 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -608,10 +608,7 @@ typedef struct NR_UE_UL_BWP { int max_fb_time; } NR_UE_UL_BWP_t; -typedef enum { - typeA = 0, - typeB = 1 -} mappingType_t; +typedef enum { typeA = 0, typeB = 1 } mappingType_t; typedef struct NR_ul_tda_info { mappingType_t mapping_type; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index bdc40f0039..fdc093a52e 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -419,73 +419,68 @@ const char table_38211_6_3_1_5_5[22][4][2] = { {{'1', '1'}, {'o', 'o'}, {'j', 'o'}, {'1', 'n'}} // tpmi 21 }; -const uint8_t table_6_1_2_1_1_2[16][4]={ - {0,0,0,14}, // row index 1 - {0,0,0,12}, // row index 2 - {0,0,0,10}, // row index 3 - {1,0,2,10}, // row index 4 - {1,0,4,10}, // row index 5 - {1,0,4,8}, // row index 6 - {1,0,4,6}, // row index 7 - {0,1,0,14}, // row index 8 - {0,1,0,12}, // row index 9 - {0,1,0,10}, // row index 10 - {0,2,0,14}, // row index 11 - {0,2,0,12}, // row index 12 - {0,2,0,10}, // row index 13 - {1,0,8,6}, // row index 14 - {0,3,0,14}, // row index 15 - {0,3,0,10} // row index 16 +// Default PUSCH time domain resource allocation tables from 38.214 +const uint8_t table_6_1_2_1_1_2[16][4] = { + {0, 0, 0, 14}, // row index 1 + {0, 0, 0, 12}, // row index 2 + {0, 0, 0, 10}, // row index 3 + {1, 0, 2, 10}, // row index 4 + {1, 0, 4, 10}, // row index 5 + {1, 0, 4, 8}, // row index 6 + {1, 0, 4, 6}, // row index 7 + {0, 1, 0, 14}, // row index 8 + {0, 1, 0, 12}, // row index 9 + {0, 1, 0, 10}, // row index 10 + {0, 2, 0, 14}, // row index 11 + {0, 2, 0, 12}, // row index 12 + {0, 2, 0, 10}, // row index 13 + {1, 0, 8, 6}, // row index 14 + {0, 3, 0, 14}, // row index 15 + {0, 3, 0, 10} // row index 16 }; -const uint8_t table_6_1_2_1_1_3[16][4]={ - {0,0,0,8}, // row index 1 - {0,0,0,12}, // row index 2 - {0,0,0,10}, // row index 3 - {1,0,2,10}, // row index 4 - {1,0,4,4}, // row index 5 - {1,0,4,8}, // row index 6 - {1,0,4,6}, // row index 7 - {0,1,0,8}, // row index 8 - {0,1,0,12}, // row index 9 - {0,1,0,10}, // row index 10 - {0,2,0,6}, // row index 11 - {0,2,0,12}, // row index 12 - {0,2,0,10}, // row index 13 - {1,0,8,4}, // row index 14 - {0,3,0,8}, // row index 15 - {0,3,0,10} // row index 16 +const uint8_t table_6_1_2_1_1_3[16][4] = { + {0, 0, 0, 8}, // row index 1 + {0, 0, 0, 12}, // row index 2 + {0, 0, 0, 10}, // row index 3 + {1, 0, 2, 10}, // row index 4 + {1, 0, 4, 4}, // row index 5 + {1, 0, 4, 8}, // row index 6 + {1, 0, 4, 6}, // row index 7 + {0, 1, 0, 8}, // row index 8 + {0, 1, 0, 12}, // row index 9 + {0, 1, 0, 10}, // row index 10 + {0, 2, 0, 6}, // row index 11 + {0, 2, 0, 12}, // row index 12 + {0, 2, 0, 10}, // row index 13 + {1, 0, 8, 4}, // row index 14 + {0, 3, 0, 8}, // row index 15 + {0, 3, 0, 10} // row index 16 }; -NR_ul_tda_info_t get_ul_tda_info(NR_PUSCH_TimeDomainResourceAllocationList_t *tdalist, - int tda_index, - int scs, - int normal_CP) +NR_ul_tda_info_t get_ul_tda_info(NR_PUSCH_TimeDomainResourceAllocationList_t *tdalist, int tda_index, int scs, bool normal_CP) { - NR_ul_tda_info_t tda_info = {0}; + // Definition of value j in Table 6.1.2.1.1-4 of 38.214 int j = scs == 0 ? 1 : scs; - if(tdalist) { - if(tda_index >= tdalist->list.count) { - LOG_E(MAC, "TDA index from DCI %d exceeds TDA list array size %d\n", tda_index, tdalist->list.count); - return tda_info; - } + if (tdalist) { + AssertFatal(tda_index < tdalist->list.count, "TDA index from DCI %d exceeds TDA list array size %d\n", tda_index, tdalist->list.count); NR_PUSCH_TimeDomainResourceAllocation_t *tda = tdalist->list.array[tda_index]; tda_info.mapping_type = tda->mappingType; + // As described in 38.331, when the field is absent the UE applies the value 1 when PUSCH SCS is 15/30KHz + // 2 when PUSCH SCS is 60KHz and 3 when PUSCH SCS is 120KHz. This equates to the parameter j. tda_info.k2 = tda->k2 ? *tda->k2 : j; int S, L; SLIV2SL(tda->startSymbolAndLength, &S, &L); tda_info.startSymbolIndex = S; tda_info.nrOfSymbols = L; - } - else { - if(normal_CP) { + } else { + if (normal_CP) { tda_info.mapping_type = table_6_1_2_1_1_2[tda_index][0]; tda_info.k2 = table_6_1_2_1_1_2[tda_index][1] + j; tda_info.startSymbolIndex = table_6_1_2_1_1_2[tda_index][2]; tda_info.nrOfSymbols = table_6_1_2_1_1_2[tda_index][3]; - } - else { + } else { tda_info.mapping_type = table_6_1_2_1_1_3[tda_index][0]; tda_info.k2 = table_6_1_2_1_1_3[tda_index][1] + j; tda_info.startSymbolIndex = table_6_1_2_1_1_3[tda_index][2]; @@ -2777,20 +2772,12 @@ uint16_t get_nr_srs_offset(NR_SRS_PeriodicityAndOffset_t periodicityAndOffset) { // Set the transform precoding status according to 6.1.3 of 3GPP TS 38.214 version 16.3.0 Release 16: // - "UE procedure for applying transform precoding on PUSCH" -uint8_t get_transformPrecoding(const NR_UE_UL_BWP_t *current_UL_BWP, - nr_dci_format_t dci_format, - uint8_t configuredGrant) +uint8_t get_transformPrecoding(const NR_UE_UL_BWP_t *current_UL_BWP, nr_dci_format_t dci_format, uint8_t configuredGrant) { - - if (configuredGrant && - current_UL_BWP->configuredGrantConfig && - current_UL_BWP->configuredGrantConfig->transformPrecoder) + if (configuredGrant && current_UL_BWP->configuredGrantConfig && current_UL_BWP->configuredGrantConfig->transformPrecoder) return *current_UL_BWP->configuredGrantConfig->transformPrecoder; - if (dci_format == NR_UL_DCI_FORMAT_0_1 && - current_UL_BWP && - current_UL_BWP->pusch_Config && - current_UL_BWP->pusch_Config->transformPrecoder) + if (dci_format == NR_UL_DCI_FORMAT_0_1 && current_UL_BWP && current_UL_BWP->pusch_Config && current_UL_BWP->pusch_Config->transformPrecoder) return *current_UL_BWP->pusch_Config->transformPrecoder; else return current_UL_BWP->rach_ConfigCommon->msg3_transformPrecoder ? 0 : 1; @@ -3191,39 +3178,27 @@ uint8_t compute_precoding_information(NR_PUSCH_Config_t *pusch_Config, return nbits; } -NR_PDSCH_TimeDomainResourceAllocationList_t *get_dl_tdalist(const NR_UE_DL_BWP_t *DL_BWP, - int controlResourceSetId, - int ss_type, - nr_rnti_type_t rnti_type) +NR_PDSCH_TimeDomainResourceAllocationList_t *get_dl_tdalist(const NR_UE_DL_BWP_t *DL_BWP, int controlResourceSetId, int ss_type, nr_rnti_type_t rnti_type) { - - if(!DL_BWP) return NULL; + if (!DL_BWP) + return NULL; // see table 5.1.2.1.1-1 in 38.214 - if((rnti_type == NR_RNTI_CS || rnti_type == NR_RNTI_C || rnti_type == NR_RNTI_MCS_C) && - !(ss_type == NR_SearchSpace__searchSpaceType_PR_common && controlResourceSetId == 0) && - (DL_BWP->pdsch_Config && DL_BWP->pdsch_Config->pdsch_TimeDomainAllocationList)) + if ((rnti_type == NR_RNTI_CS || rnti_type == NR_RNTI_C || rnti_type == NR_RNTI_MCS_C) && !(ss_type == NR_SearchSpace__searchSpaceType_PR_common && controlResourceSetId == 0) + && (DL_BWP->pdsch_Config && DL_BWP->pdsch_Config->pdsch_TimeDomainAllocationList)) return DL_BWP->pdsch_Config->pdsch_TimeDomainAllocationList->choice.setup; else return DL_BWP->tdaList; - } - -NR_PUSCH_TimeDomainResourceAllocationList_t *get_ul_tdalist(const NR_UE_UL_BWP_t *UL_BWP, - int controlResourceSetId, - int ss_type, - nr_rnti_type_t rnti_type) +NR_PUSCH_TimeDomainResourceAllocationList_t *get_ul_tdalist(const NR_UE_UL_BWP_t *UL_BWP, int controlResourceSetId, int ss_type, nr_rnti_type_t rnti_type) { - - if((rnti_type == NR_RNTI_CS || rnti_type == NR_RNTI_C || rnti_type == NR_RNTI_MCS_C) && - !(ss_type == NR_SearchSpace__searchSpaceType_PR_common && controlResourceSetId == 0) && - (UL_BWP->pusch_Config && UL_BWP->pusch_Config->pusch_TimeDomainAllocationList)) + if ((rnti_type == NR_RNTI_CS || rnti_type == NR_RNTI_C || rnti_type == NR_RNTI_MCS_C) && !(ss_type == NR_SearchSpace__searchSpaceType_PR_common && controlResourceSetId == 0) + && (UL_BWP->pusch_Config && UL_BWP->pusch_Config->pusch_TimeDomainAllocationList)) return UL_BWP->pusch_Config->pusch_TimeDomainAllocationList->choice.setup; else return UL_BWP->tdaList; } - uint16_t get_rb_bwp_dci(nr_dci_format_t format, int ss_type, uint16_t cset0_bwp_size, @@ -3315,7 +3290,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, dci_pdu->bwp_indicator.nbits = UL_BWP->n_ul_bwp; else dci_pdu->bwp_indicator.nbits = 2; - LOG_D(NR_MAC,"BWP indicator nbits %d, num UL BWPs %d\n", dci_pdu->bwp_indicator.nbits, UL_BWP->n_ul_bwp); + LOG_D(NR_MAC, "BWP indicator nbits %d, num UL BWPs %d\n", dci_pdu->bwp_indicator.nbits, UL_BWP->n_ul_bwp); size += dci_pdu->bwp_indicator.nbits; // Freq domain assignment if (pusch_Config) { @@ -3333,7 +3308,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, } else dci_pdu->frequency_domain_assignment.nbits = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); - LOG_D(NR_MAC,"PUSCH Frequency Domain Assignment nbits %d, N_RB %d\n", dci_pdu->frequency_domain_assignment.nbits, N_RB); + LOG_D(NR_MAC, "PUSCH Frequency Domain Assignment nbits %d, N_RB %d\n", dci_pdu->frequency_domain_assignment.nbits, N_RB); size += dci_pdu->frequency_domain_assignment.nbits; // Time domain assignment NR_PUSCH_TimeDomainResourceAllocationList_t *tdalistul = get_ul_tdalist(UL_BWP, coreset->controlResourceSetId, ss_type, rnti_type); @@ -3342,7 +3317,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, else num_entries = 16; // num of entries in default table dci_pdu->time_domain_assignment.nbits = (int)ceil(log2(num_entries)); - LOG_D(NR_MAC,"PUSCH Time Domain Allocation nbits %d, pusch_Config %p\n", dci_pdu->time_domain_assignment.nbits, pusch_Config); + LOG_D(NR_MAC, "PUSCH Time Domain Allocation nbits %d, pusch_Config %p\n", dci_pdu->time_domain_assignment.nbits, pusch_Config); size += dci_pdu->time_domain_assignment.nbits; // Frequency Hopping flag if (pusch_Config && @@ -3359,7 +3334,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, size += dci_pdu->dai[0].nbits; LOG_D(NR_MAC, "DAI1 nbits %d\n", dci_pdu->dai[0].nbits); // 2nd DAI - if (DL_BWP->pdsch_servingcellconfig && DL_BWP->pdsch_servingcellconfig->codeBlockGroupTransmission != NULL) { // TODO not sure about that + if (DL_BWP->pdsch_servingcellconfig && DL_BWP->pdsch_servingcellconfig->codeBlockGroupTransmission != NULL) { dci_pdu->dai[1].nbits = 2; size += dci_pdu->dai[1].nbits; } @@ -3405,8 +3380,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, } } // CBGTI - if (UL_BWP->pusch_servingcellconfig && - UL_BWP->pusch_servingcellconfig->codeBlockGroupTransmission != NULL) { + if (UL_BWP->pusch_servingcellconfig && UL_BWP->pusch_servingcellconfig->codeBlockGroupTransmission != NULL) { int num = UL_BWP->pusch_servingcellconfig->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock; dci_pdu->cbgti.nbits = 2 + (num<<1); size += dci_pdu->cbgti.nbits; @@ -3453,7 +3427,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, break; case NR_DL_DCI_FORMAT_1_1: - LOG_D(NR_MAC,"DCI_FORMAT 1_1 : pdsch_Config %p, pucch_Config %p\n", pdsch_Config, pucch_Config); + LOG_D(NR_MAC, "DCI_FORMAT 1_1 : pdsch_Config %p, pucch_Config %p\n", pdsch_Config, pucch_Config); // General note: 0 bits condition is ignored as default nbits is 0. // Format identifier size = 1; @@ -3561,8 +3535,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, dci_pdu->srs_request.nbits = 3; size += dci_pdu->srs_request.nbits; // CBGTI - if (DL_BWP->pdsch_servingcellconfig && - DL_BWP->pdsch_servingcellconfig->codeBlockGroupTransmission != NULL) { + if (DL_BWP->pdsch_servingcellconfig && DL_BWP->pdsch_servingcellconfig->codeBlockGroupTransmission != NULL) { uint8_t maxCBGperTB = (DL_BWP->pdsch_servingcellconfig->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock + 1) * 2; long *maxCWperDCI_rrc = pdsch_Config->maxNrofCodeWordsScheduledByDCI; uint8_t maxCW = (maxCWperDCI_rrc == NULL) ? 1 : *maxCWperDCI_rrc; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index dd957ed39e..3909dec15b 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -84,20 +84,11 @@ uint8_t compute_precoding_information(NR_PUSCH_Config_t *pusch_Config, const uint8_t *nrOfLayers, uint32_t *val); -NR_PDSCH_TimeDomainResourceAllocationList_t *get_dl_tdalist(const NR_UE_DL_BWP_t *DL_BWP, - int controlResourceSetId, - int ss_type, - nr_rnti_type_t rnti_type); +NR_PDSCH_TimeDomainResourceAllocationList_t *get_dl_tdalist(const NR_UE_DL_BWP_t *DL_BWP, int controlResourceSetId, int ss_type, nr_rnti_type_t rnti_type); -NR_PUSCH_TimeDomainResourceAllocationList_t *get_ul_tdalist(const NR_UE_UL_BWP_t *UL_BWP, - int controlResourceSetId, - int ss_type, - nr_rnti_type_t rnti_type); +NR_PUSCH_TimeDomainResourceAllocationList_t *get_ul_tdalist(const NR_UE_UL_BWP_t *UL_BWP, int controlResourceSetId, int ss_type, nr_rnti_type_t rnti_type); -NR_ul_tda_info_t get_ul_tda_info(NR_PUSCH_TimeDomainResourceAllocationList_t *tdalist, - int tda_index, - int scs, - int normal_CP); +NR_ul_tda_info_t get_ul_tda_info(NR_PUSCH_TimeDomainResourceAllocationList_t *tdalist, int tda_index, int scs, bool normal_CP); uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, const NR_UE_UL_BWP_t *UL_BWP, @@ -281,9 +272,7 @@ bool set_ul_ptrs_values(NR_PTRS_UplinkConfig_t *ul_ptrs_config, @param rnti_type rnti type @param configuredGrant indicates whether a configured grant was received or not @returns transformPrecoding value */ -uint8_t get_transformPrecoding(const NR_UE_UL_BWP_t *current_UL_BWP, - nr_dci_format_t dci_format, - uint8_t configuredGrant); +uint8_t get_transformPrecoding(const NR_UE_UL_BWP_t *current_UL_BWP, nr_dci_format_t dci_format, uint8_t configuredGrant); void nr_mac_gNB_rrc_ul_failure(const module_id_t Mod_instP, const int CC_idP, diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 0e01eb6712..1eee95e823 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -564,15 +564,15 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, ul_genericParameters = bwp_dlcommon->genericParameters; DL_BWP->pdsch_Config = NULL; - if(bwp_dlcommon->pdsch_ConfigCommon) + if (bwp_dlcommon->pdsch_ConfigCommon) DL_BWP->tdaList = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - if(bwp_ulcommon->pusch_ConfigCommon) { + if (bwp_ulcommon->pusch_ConfigCommon) { UL_BWP->tdaList = bwp_ulcommon->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; UL_BWP->msg3_DeltaPreamble = bwp_ulcommon->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble; } - if(bwp_ulcommon->pucch_ConfigCommon) + if (bwp_ulcommon->pucch_ConfigCommon) UL_BWP->pucch_ConfigCommon = bwp_ulcommon->pucch_ConfigCommon->choice.setup; - if(bwp_ulcommon->rach_ConfigCommon) + if (bwp_ulcommon->rach_ConfigCommon) UL_BWP->rach_ConfigCommon = bwp_ulcommon->rach_ConfigCommon->choice.setup; } @@ -583,11 +583,10 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, } if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->spCellConfigDedicated) { - struct NR_ServingCellConfig *spCellConfigDedicated = cell_group_config->spCellConfig->spCellConfigDedicated; UL_BWP->csi_MeasConfig = spCellConfigDedicated->csi_MeasConfig ? spCellConfigDedicated->csi_MeasConfig->choice.setup : NULL; - UL_BWP->pusch_servingcellconfig = spCellConfigDedicated->uplinkConfig && spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig ? - spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup : NULL; + UL_BWP->pusch_servingcellconfig = + spCellConfigDedicated->uplinkConfig && spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig ? spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup : NULL; DL_BWP->pdsch_servingcellconfig = spCellConfigDedicated->pdsch_ServingCellConfig ? spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup : NULL; if (spCellConfigDedicated->firstActiveDownlinkBWP_Id) @@ -595,17 +594,17 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, if (spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id) UL_BWP->bwp_id = *spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id; - if(mac->scc) { + if (mac->scc) { bwp_dlcommon = mac->scc->downlinkConfigCommon->initialDownlinkBWP; bwp_ulcommon = mac->scc->uplinkConfigCommon->initialUplinkBWP; } - if(mac->scc_SIB) { + if (mac->scc_SIB) { bwp_dlcommon = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP; bwp_ulcommon = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; } NR_BWP_Downlink_t *bwp_downlink = NULL; const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = spCellConfigDedicated->downlinkBWP_ToAddModList; - if(bwpList) + if (bwpList) DL_BWP->n_dl_bwp = bwpList->list.count; if (bwpList && DL_BWP->bwp_id > 0) { for (int i = 0; i < bwpList->list.count; i++) { @@ -643,9 +642,9 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, UL_BWP->pucch_Config = bwp_uplink->bwp_Dedicated->pucch_Config->choice.setup; UL_BWP->srs_Config = bwp_uplink->bwp_Dedicated->srs_Config->choice.setup; UL_BWP->configuredGrantConfig = bwp_uplink->bwp_Dedicated->configuredGrantConfig ? bwp_uplink->bwp_Dedicated->configuredGrantConfig->choice.setup : NULL; - if(bwp_uplink->bwp_Common->pucch_ConfigCommon) + if (bwp_uplink->bwp_Common->pucch_ConfigCommon) UL_BWP->pucch_ConfigCommon = bwp_uplink->bwp_Common->pucch_ConfigCommon->choice.setup; - if(bwp_uplink->bwp_Common->rach_ConfigCommon) + if (bwp_uplink->bwp_Common->rach_ConfigCommon) UL_BWP->rach_ConfigCommon = bwp_uplink->bwp_Common->rach_ConfigCommon->choice.setup; } else { @@ -653,10 +652,10 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, UL_BWP->pusch_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pusch_Config->choice.setup; UL_BWP->pucch_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; UL_BWP->srs_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config->choice.setup; - UL_BWP->configuredGrantConfig = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->configuredGrantConfig ? - spCellConfigDedicated->uplinkConfig->initialUplinkBWP->configuredGrantConfig->choice.setup : NULL; + UL_BWP->configuredGrantConfig = + spCellConfigDedicated->uplinkConfig->initialUplinkBWP->configuredGrantConfig ? spCellConfigDedicated->uplinkConfig->initialUplinkBWP->configuredGrantConfig->choice.setup : NULL; ul_genericParameters = bwp_ulcommon->genericParameters; - if(bwp_ulcommon->rach_ConfigCommon) + if (bwp_ulcommon->rach_ConfigCommon) UL_BWP->rach_ConfigCommon = bwp_ulcommon->rach_ConfigCommon->choice.setup; } } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index b20da8bf81..37f0adfa95 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -255,9 +255,9 @@ NR_BWP_DownlinkCommon_t *get_bwp_downlink_common(NR_UE_MAC_INST_t *mac, NR_BWP_I int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList, - fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, + fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, int *mapping_type, - uint8_t time_domain_ind, + uint8_t time_domain_ind, int default_abc, bool use_default); @@ -474,12 +474,6 @@ int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti); // - 6.1.4.2 of TS 38.214 // - 6.4.1.1.1 of TS 38.211 // - 6.3.1.7 of 38.211 -int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, - NR_ul_tda_info_t *tda_info, - nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, - dci_pdu_rel15_t *dci, - RAR_grant_t *rar_grant, - uint16_t rnti, - uint8_t *dci_format); +int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, NR_ul_tda_info_t *tda_info, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci, RAR_grant_t *rar_grant, uint16_t rnti, uint8_t *dci_format); #endif /** @}*/ diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index da3a4777ed..f871796230 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -140,7 +140,6 @@ void init_RA(module_id_t mod_id, NR_RACH_ConfigGeneric_t *rach_ConfigGeneric, NR_RACH_ConfigDedicated_t *rach_ConfigDedicated) { - NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); RA_config_t *ra = &mac->ra; @@ -279,11 +278,9 @@ void init_RA(module_id_t mod_id, } } - /* TS 38.321 subclause 7.3 - return DELTA_PREAMBLE values in dB */ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_format) { - NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP.rach_ConfigCommon; NR_SubcarrierSpacing_t scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing; @@ -387,7 +384,6 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_forma // returns receivedTargerPower in dBm int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t mod_id, uint8_t CC_id) { - NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); int8_t receivedTargerPower; int8_t delta_preamble; @@ -405,7 +401,6 @@ int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t m void ssb_rach_config(RA_config_t *ra, NR_PRACH_RESOURCES_t *prach_resources, NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon) { - // Determine the SSB to RACH mapping ratio // ======================================= @@ -494,7 +489,7 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP.rach_ConfigCommon; NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; - if (mac->current_UL_BWP.msg3_DeltaPreamble){ + if (mac->current_UL_BWP.msg3_DeltaPreamble) { deltaPreamble_Msg3 = (*mac->current_UL_BWP.msg3_DeltaPreamble) * 2; // dB LOG_D(MAC, "In %s: deltaPreamble_Msg3 set to %ld\n", __FUNCTION__, deltaPreamble_Msg3); } 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 ff8a2de982..9d691514ed 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -162,21 +162,24 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t // computing alternative size for padding dci_pdu_rel15_t temp_pdu; if(dci_format == NR_DL_DCI_FORMAT_1_0) - alt_size = nr_dci_size(current_DL_BWP, current_UL_BWP, - mac->cg, &temp_pdu, - NR_UL_DCI_FORMAT_0_0, rnti_type, coreset, dl_bwp_id, - ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, 0); + alt_size = + nr_dci_size(current_DL_BWP, current_UL_BWP, mac->cg, &temp_pdu, NR_UL_DCI_FORMAT_0_0, rnti_type, coreset, dl_bwp_id, ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, 0); if(dci_format == NR_UL_DCI_FORMAT_0_0) - alt_size = nr_dci_size(current_DL_BWP, current_UL_BWP, - mac->cg, &temp_pdu, - NR_DL_DCI_FORMAT_1_0, rnti_type, coreset, dl_bwp_id, - ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, 0); + alt_size = + nr_dci_size(current_DL_BWP, current_UL_BWP, mac->cg, &temp_pdu, NR_DL_DCI_FORMAT_1_0, rnti_type, coreset, dl_bwp_id, ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, 0); } - rel15->dci_length_options[i] = nr_dci_size(current_DL_BWP, current_UL_BWP, - mac->cg, &mac->def_dci_pdu_rel15[dci_format], - dci_format, NR_RNTI_TC, coreset, dl_bwp_id, - ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, alt_size); + rel15->dci_length_options[i] = nr_dci_size(current_DL_BWP, + current_UL_BWP, + mac->cg, + &mac->def_dci_pdu_rel15[dci_format], + dci_format, + NR_RNTI_TC, + coreset, + dl_bwp_id, + ss->searchSpaceType->present, + mac->type0_PDCCH_CSS_config.num_rbs, + alt_size); rel15->BWPStart = coreset_id == 0 ? mac->type0_PDCCH_CSS_config.cset_start_rb : current_DL_BWP->BWPStart; rel15->BWPSize = coreset_id == 0 ? mac->type0_PDCCH_CSS_config.num_rbs : current_DL_BWP->BWPSize; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 09ee7c6cb5..ca924f79bd 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -412,13 +412,12 @@ int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *p int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList, - fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, + fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, int *mapping_type, - uint8_t time_domain_ind, + uint8_t time_domain_ind, int default_abc, bool use_default) { - int dmrs_typeA_pos = (mac->scc != NULL) ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position; // uint8_t k_offset=0; @@ -489,7 +488,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr uint16_t rnti = dci_ind->rnti; uint8_t dci_format = dci_ind->dci_format; - int coreset_type = dci_ind->CoreSetType == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG; // 0 for coreset0, 1 otherwise + int coreset_type = dci_ind->coreset_type == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG; // 0 for coreset0, 1 otherwise int ret = 0; int pucch_res_set_cnt = 0, valid = 0; frame_t frame_tx = 0; @@ -506,7 +505,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr LOG_D(MAC, "In %s: Processing received DCI format %s\n", __FUNCTION__, dci_formats[dci_format]); NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; - int normal_CP = current_UL_BWP->cyclicprefix ? 0 : 1; + bool normal_CP = current_UL_BWP->cyclicprefix ? false : true; NR_ul_tda_info_t tda_info = {0}; NR_PUCCH_Config_t *pucch_Config = current_UL_BWP->pucch_Config; @@ -535,7 +534,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // Schedule PUSCH pusch_TimeDomainAllocationList = get_ul_tdalist(current_UL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, rnti)); tda_info = get_ul_tda_info(pusch_TimeDomainAllocationList, dci->time_domain_assignment.val, current_UL_BWP->scs, normal_CP); - if(tda_info.nrOfSymbols == 0) + if (tda_info.nrOfSymbols == 0) ret = -1; else ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, tda_info.k2); @@ -558,9 +557,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // Config PUSCH PDU ret = nr_config_pusch_pdu(mac, &tda_info, pusch_config_pdu, dci, NULL, rnti, &dci_format); - } - else - LOG_E(MAC,"Cannot schedule PUSCH\n"); + } else + LOG_E(MAC, "Cannot schedule PUSCH\n"); break; } @@ -601,7 +599,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // Schedule PUSCH pusch_TimeDomainAllocationList = get_ul_tdalist(current_UL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, rnti)); tda_info = get_ul_tda_info(pusch_TimeDomainAllocationList, dci->time_domain_assignment.val, current_UL_BWP->scs, normal_CP); - if(tda_info.nrOfSymbols == 0) + if (tda_info.nrOfSymbols == 0) ret = -1; else ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, tda_info.k2); @@ -626,9 +624,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // Config PUSCH PDU ret = nr_config_pusch_pdu(mac, &tda_info, pusch_config_pdu, dci, NULL, rnti, &dci_format); - } - else - LOG_E(MAC,"Cannot schedule PUSCH\n"); + } else + LOG_E(MAC, "Cannot schedule PUSCH\n"); break; } @@ -710,7 +707,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr } else { dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; } - if((ra->RA_window_cnt >= 0 && rnti == ra->ra_rnti) || (rnti == ra->t_crnti)) { + if ((ra->RA_window_cnt >= 0 && rnti == ra->ra_rnti) || (rnti == ra->t_crnti)) { if (mac->scc == NULL) // use coreset0 is_common = 1; } @@ -726,21 +723,16 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr int mappingtype; /* TIME_DOM_RESOURCE_ASSIGNMENT */ pdsch_TimeDomainAllocationList = get_dl_tdalist(current_DL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, rnti)); - if (nr_ue_process_dci_time_dom_resource_assignment(mac,pdsch_TimeDomainAllocationList, - dlsch_config_pdu_1_0,&mappingtype, - dci->time_domain_assignment.val, - default_abc,rnti==SI_RNTI) < 0) { + if (nr_ue_process_dci_time_dom_resource_assignment(mac, pdsch_TimeDomainAllocationList, dlsch_config_pdu_1_0, &mappingtype, dci->time_domain_assignment.val, default_abc, rnti == SI_RNTI) < 0) { LOG_W(MAC, "[%d.%d] Invalid time_domain_assignment. Possibly due to false DCI. Ignoring DCI!\n", frame, slot); return -1; } - if(pdsch_TimeDomainAllocationList) + if (pdsch_TimeDomainAllocationList) mappingtype = pdsch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->mappingType; struct NR_DMRS_DownlinkConfig *dl_dmrs_config = NULL; - if(pdsch_config) - dl_dmrs_config = (mappingtype == typeA) ? - pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup : - pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup; + if (pdsch_config) + dl_dmrs_config = (mappingtype == typeA) ? pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup : pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup; dlsch_config_pdu_1_0->nscid = 0; if(dl_dmrs_config && dl_dmrs_config->scramblingID0) @@ -824,16 +816,16 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr if (dci->tpc == 3) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 3; // Sanity check for pucch_resource_indicator value received to check for false DCI. valid = 0; - if(pucch_Config && - pucch_Config->resourceSetToAddModList) { + if (pucch_Config && pucch_Config->resourceSetToAddModList) { pucch_res_set_cnt = pucch_Config->resourceSetToAddModList->list.count; for (int id = 0; id < pucch_res_set_cnt; id++) { - if (dci->pucch_resource_indicator < pucch_Config->resourceSetToAddModList->list.array[id]->resourceList.list.count) { - valid = 1; - break; - } + if (dci->pucch_resource_indicator < pucch_Config->resourceSetToAddModList->list.array[id]->resourceList.list.count) { + valid = 1; + break; + } } - } else valid=1; + } else + valid = 1; if (!valid) { LOG_W(MAC, "[%d.%d] pucch_resource_indicator value %d is out of bounds. Possibly due to false DCI. Ignoring DCI!\n", frame, slot, dci->pucch_resource_indicator); return -1; @@ -941,9 +933,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr int mappingtype; pdsch_TimeDomainAllocationList = get_dl_tdalist(current_DL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, rnti)); - if (nr_ue_process_dci_time_dom_resource_assignment(mac,pdsch_TimeDomainAllocationList, - dlsch_config_pdu_1_1,&mappingtype, - dci->time_domain_assignment.val,0,false) < 0) { + if (nr_ue_process_dci_time_dom_resource_assignment(mac, pdsch_TimeDomainAllocationList, dlsch_config_pdu_1_1, &mappingtype, dci->time_domain_assignment.val, 0, false) < 0) { LOG_W(MAC, "[%d.%d] Invalid time_domain_assignment. Possibly due to false DCI. Ignoring DCI!\n", frame, slot); return -1; } @@ -1340,11 +1330,10 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, pucch_pdu->prb_start = RB_BWP_offset + (pucch->initial_pucch_id / N_CS); pucch_pdu->second_hop_prb = pucch_pdu->bwp_size - 1 - RB_BWP_offset - (pucch->initial_pucch_id / N_CS); pucch_pdu->initial_cyclic_shift = initial_pucch_resource[pucch_resourcecommon].initial_CS_indexes[pucch->initial_pucch_id % N_CS]; - } - else { + } else { pucch_pdu->prb_start = pucch_pdu->bwp_size - 1 - RB_BWP_offset - ((pucch->initial_pucch_id - 8) / N_CS); pucch_pdu->second_hop_prb = RB_BWP_offset + ((pucch->initial_pucch_id - 8) / N_CS); - pucch_pdu->initial_cyclic_shift = initial_pucch_resource[pucch_resourcecommon].initial_CS_indexes[(pucch->initial_pucch_id - 8) % N_CS]; + pucch_pdu->initial_cyclic_shift = initial_pucch_resource[pucch_resourcecommon].initial_CS_indexes[(pucch->initial_pucch_id - 8) % N_CS]; } pucch_pdu->freq_hop_flag = 1; pucch_pdu->time_domain_occ_idx = 0; @@ -1360,14 +1349,10 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, NR_PUCCH_Resource_t *pucchres = pucch->pucch_resource; - if (current_UL_BWP->harq_ACK_SpatialBundlingPUCCH != NULL || - *current_DL_BWP->pdsch_HARQ_ACK_Codebook != 1) { + if (current_UL_BWP->harq_ACK_SpatialBundlingPUCCH != NULL || *current_DL_BWP->pdsch_HARQ_ACK_Codebook != 1) { LOG_E(MAC,"PUCCH Unsupported cell group configuration\n"); return; - } - else if (current_DL_BWP && - current_DL_BWP->pdsch_servingcellconfig && - current_DL_BWP->pdsch_servingcellconfig->codeBlockGroupTransmission != NULL) { + } else if (current_DL_BWP && current_DL_BWP->pdsch_servingcellconfig && current_DL_BWP->pdsch_servingcellconfig->codeBlockGroupTransmission != NULL) { LOG_E(MAC,"PUCCH Unsupported code block group for serving cell config\n"); return; } @@ -1382,7 +1367,7 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, } NR_PUCCH_Config_t *pucch_Config = current_UL_BWP->pucch_Config; - AssertFatal(pucch_Config,"no pucch_Config\n"); + AssertFatal(pucch_Config, "no pucch_Config\n"); pucch_pdu->bwp_size = current_UL_BWP->BWPSize; pucch_pdu->bwp_start = current_UL_BWP->BWPStart; @@ -1543,7 +1528,6 @@ int16_t get_pucch_tx_power_ue(NR_UE_MAC_INST_t *mac, int subframe_number, int O_ACK, int O_SR, int O_CSI, int O_CRC) { - NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; int PUCCH_POWER_DEFAULT = 0; int16_t P_O_NOMINAL_PUCCH = *current_UL_BWP->pucch_ConfigCommon->p0_nominal; @@ -1703,9 +1687,7 @@ int find_pucch_resource_set(NR_UE_MAC_INST_t *mac, int uci_size) { */ /* look for the first resource set which supports uci_size number of bits for payload */ while (pucch_resource_set_id < MAX_NB_OF_PUCCH_RESOURCE_SETS) { - if (pucch_Config && - pucch_Config->resourceSetToAddModList && - pucch_Config->resourceSetToAddModList->list.array[pucch_resource_set_id] != NULL) { + if (pucch_Config && pucch_Config->resourceSetToAddModList && pucch_Config->resourceSetToAddModList->list.array[pucch_resource_set_id] != NULL) { // PUCCH with format0 can be up to 3 bits (2 ack/nacks + 1 sr is 3 max bits) if (uci_size <= 3) { pucch_resource_set_id = 0; @@ -1744,18 +1726,12 @@ int find_pucch_resource_set(NR_UE_MAC_INST_t *mac, int uci_size) { * *********************************************************************/ -void select_pucch_resource(NR_UE_MAC_INST_t *mac, - PUCCH_sched_t *pucch) +void select_pucch_resource(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *pucch) { - NR_PUCCH_ResourceId_t *current_resource_id = NULL; NR_PUCCH_Config_t *pucch_Config = mac->current_UL_BWP.pucch_Config; int n_list; - if (pucch->is_common == 1 || - !pucch_Config || - !pucch_Config->resourceSetToAddModList || - pucch_Config->resourceSetToAddModList->list.array[0] == NULL) { - + if (pucch->is_common == 1 || !pucch_Config || !pucch_Config->resourceSetToAddModList || pucch_Config->resourceSetToAddModList->list.array[0] == NULL) { /* see TS 38.213 9.2.1 PUCCH Resource Sets */ int delta_PRI = pucch->resource_indicator; int n_CCE_0 = pucch->n_CCE; @@ -1766,8 +1742,7 @@ void select_pucch_resource(NR_UE_MAC_INST_t *mac, int r_PUCCH = ((2 * n_CCE_0)/N_CCE_0) + (2 * delta_PRI); pucch->initial_pucch_id = r_PUCCH; pucch->pucch_resource = NULL; - } - else { + } else { struct NR_PUCCH_Config__resourceSetToAddModList *resourceSetToAddModList = pucch_Config->resourceSetToAddModList; struct NR_PUCCH_Config__resourceToAddModList *resourceToAddModList = pucch_Config->resourceToAddModList; n_list = resourceSetToAddModList->list.count; @@ -1850,10 +1825,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - if (current_DL_BWP && - current_DL_BWP->pdsch_Config && - current_DL_BWP->pdsch_Config->maxNrofCodeWordsScheduledByDCI && - current_DL_BWP->pdsch_Config->maxNrofCodeWordsScheduledByDCI[0] == 2) { + if (current_DL_BWP && current_DL_BWP->pdsch_Config && current_DL_BWP->pdsch_Config->maxNrofCodeWordsScheduledByDCI && current_DL_BWP->pdsch_Config->maxNrofCodeWordsScheduledByDCI[0] == 2) { two_transport_blocks = true; number_of_code_word = 2; } @@ -1878,8 +1850,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, sched_frame = (sched_frame + 1) % 1024; } AssertFatal(sched_slot < slots_per_frame, "sched_slot was calculated incorrect %d\n", sched_slot); - LOG_D(PHY,"HARQ pid %d is active for %d.%d (dl_slot %d, feedback_to_ul %d\n", - dl_harq_pid, sched_frame,sched_slot,current_harq->dl_slot,current_harq->feedback_to_ul); + LOG_D(PHY, "HARQ pid %d is active for %d.%d (dl_slot %d, feedback_to_ul %d\n", dl_harq_pid, sched_frame, sched_slot, current_harq->dl_slot, current_harq->feedback_to_ul); /* check if current tx slot should transmit downlink acknowlegment */ if (sched_frame == frame && sched_slot == slot) { if (get_softmodem_params()->emulate_l1) { @@ -2136,8 +2107,7 @@ uint8_t nr_get_csi_measurements(NR_UE_MAC_INST_t *mac, NR_PUCCH_Config_t *pucch_Config = current_UL_BWP->pucch_Config; int csi_bits = 0; - if(current_UL_BWP->csi_MeasConfig) { - + if (current_UL_BWP->csi_MeasConfig) { NR_CSI_MeasConfig_t *csi_measconfig = current_UL_BWP->csi_MeasConfig; for (int csi_report_id = 0; csi_report_id < csi_measconfig->csi_ReportConfigToAddModList->list.count; csi_report_id++){ @@ -3771,10 +3741,10 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t // Schedule Msg3 NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - int normal_CP = current_UL_BWP->cyclicprefix ? 0 : 1; + bool normal_CP = current_UL_BWP->cyclicprefix ? false : true; NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = get_ul_tdalist(current_UL_BWP, *ra->ss->controlResourceSetId, ra->ss->searchSpaceType->present, NR_RNTI_RA); NR_ul_tda_info_t tda_info = get_ul_tda_info(pusch_TimeDomainAllocationList, rar_grant.Msg3_t_alloc, current_UL_BWP->scs, normal_CP); - if(tda_info.nrOfSymbols == 0) { + if (tda_info.nrOfSymbols == 0) { LOG_E(MAC, "Cannot schedule Msg3. Something wrong in TDA information\n"); return -1; } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 6a96ff474b..fc3b954769 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -136,9 +136,8 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl return &mac->ul_config_request[index]; } -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) +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) { - NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; NR_SRS_Config_t *srs_config = current_UL_BWP->srs_Config; NR_PUSCH_Config_t *pusch_Config = current_UL_BWP->pusch_Config; @@ -272,13 +271,12 @@ void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_con // todo: this function shall be reviewed completely because of the many comments left by the author void ul_ports_config(NR_UE_MAC_INST_t *mac, int *n_front_load_symb, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci, nr_dci_format_t dci_format) { - uint8_t rank = pusch_config_pdu->nrOfLayers; NR_PUSCH_Config_t *pusch_Config = mac->current_UL_BWP.pusch_Config; AssertFatal(pusch_Config!=NULL,"pusch_Config shouldn't be null\n"); - long transformPrecoder = get_transformPrecoding(&mac->current_UL_BWP, dci_format, 0); + long transformPrecoder = get_transformPrecoding(&mac->current_UL_BWP, dci_format, 0); long *max_length = NULL; long *dmrs_type = NULL; LOG_D(NR_MAC,"transformPrecoder %s\n",transformPrecoder==NR_PUSCH_Config__transformPrecoder_disabled?"disabled":"enabled"); @@ -451,13 +449,7 @@ void ul_ports_config(NR_UE_MAC_INST_t *mac, int *n_front_load_symb, nfapi_nr_ue_ // - 6.1.4.2 of TS 38.214 // - 6.4.1.1.1 of TS 38.211 // - 6.3.1.7 of 38.211 -int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, - NR_ul_tda_info_t *tda_info, - nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, - dci_pdu_rel15_t *dci, - RAR_grant_t *rar_grant, - uint16_t rnti, - uint8_t *dci_format) +int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, NR_ul_tda_info_t *tda_info, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci, RAR_grant_t *rar_grant, uint16_t rnti, uint8_t *dci_format) { int f_alloc; @@ -518,10 +510,11 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->start_symbol_index = tda_info->startSymbolIndex; pusch_config_pdu->nr_of_symbols = tda_info->nrOfSymbols; - l_prime_mask = get_l_prime(tda_info->nrOfSymbols, tda_info->mapping_type, add_pos, dmrslength, tda_info->startSymbolIndex, mac->scc ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position); + l_prime_mask = + get_l_prime(tda_info->nrOfSymbols, tda_info->mapping_type, add_pos, dmrslength, tda_info->startSymbolIndex, mac->scc ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position); LOG_D(NR_MAC, "MSG3 start_sym:%d NR Symb:%d mappingtype:%d, DMRS_MASK:%x\n", pusch_config_pdu->start_symbol_index, pusch_config_pdu->nr_of_symbols, tda_info->mapping_type, l_prime_mask); - #ifdef DEBUG_MSG3 +#ifdef DEBUG_MSG3 LOG_D(NR_MAC, "In %s BWP assignment (BWP (start %d, size %d) \n", __FUNCTION__, pusch_config_pdu->bwp_start, pusch_config_pdu->bwp_size); #endif @@ -714,15 +707,13 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, } // Num PRB Overhead from PUSCH-ServingCellConfig - if (current_UL_BWP->pusch_servingcellconfig && - current_UL_BWP->pusch_servingcellconfig->xOverhead) + if (current_UL_BWP->pusch_servingcellconfig && current_UL_BWP->pusch_servingcellconfig->xOverhead) N_PRB_oh = *current_UL_BWP->pusch_servingcellconfig->xOverhead; else N_PRB_oh = 0; - if (current_UL_BWP->pusch_servingcellconfig && - current_UL_BWP->pusch_servingcellconfig->rateMatching) { - long *maxMIMO_Layers = current_UL_BWP->pusch_servingcellconfig->ext1->maxMIMO_Layers; + if (current_UL_BWP->pusch_servingcellconfig && current_UL_BWP->pusch_servingcellconfig->rateMatching) { + long *maxMIMO_Layers = current_UL_BWP->pusch_servingcellconfig->ext1->maxMIMO_Layers; if (!maxMIMO_Layers) maxMIMO_Layers = pusch_Config ? pusch_Config->maxRank : NULL; AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); @@ -730,29 +721,30 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->tbslbrm = nr_compute_tbslbrm(pusch_config_pdu->mcs_table, bw_tbslbrm, *maxMIMO_Layers); - } - else + } else pusch_config_pdu->tbslbrm = 0; /* PTRS */ - if (pusch_Config && - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB && - pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS) { + if (pusch_Config && pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB && pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS) { if (pusch_config_pdu->transform_precoding == NR_PUSCH_Config__transformPrecoder_disabled) { nfapi_nr_ue_ptrs_ports_t ptrs_ports_list; pusch_config_pdu->pusch_ptrs.ptrs_ports_list = &ptrs_ports_list; valid_ptrs_setup = set_ul_ptrs_values(pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS->choice.setup, - pusch_config_pdu->rb_size, pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table, - &pusch_config_pdu->pusch_ptrs.ptrs_freq_density,&pusch_config_pdu->pusch_ptrs.ptrs_time_density, - &pusch_config_pdu->pusch_ptrs.ptrs_ports_list->ptrs_re_offset,&pusch_config_pdu->pusch_ptrs.num_ptrs_ports, - &pusch_config_pdu->pusch_ptrs.ul_ptrs_power, pusch_config_pdu->nr_of_symbols); + pusch_config_pdu->rb_size, + pusch_config_pdu->mcs_index, + pusch_config_pdu->mcs_table, + &pusch_config_pdu->pusch_ptrs.ptrs_freq_density, + &pusch_config_pdu->pusch_ptrs.ptrs_time_density, + &pusch_config_pdu->pusch_ptrs.ptrs_ports_list->ptrs_re_offset, + &pusch_config_pdu->pusch_ptrs.num_ptrs_ports, + &pusch_config_pdu->pusch_ptrs.ul_ptrs_power, + pusch_config_pdu->nr_of_symbols); if(valid_ptrs_setup==true) { pusch_config_pdu->pdu_bit_map |= PUSCH_PDU_BITMAP_PUSCH_PTRS; } LOG_D(NR_MAC, "UL PTRS values: PTRS time den: %d, PTRS freq den: %d\n", pusch_config_pdu->pusch_ptrs.ptrs_time_density, pusch_config_pdu->pusch_ptrs.ptrs_freq_density); } } - } LOG_D(NR_MAC, "In %s: received UL grant (rb_start %d, rb_size %d, start_symbol_index %d, nr_of_symbols %d) for RNTI type %s \n", @@ -1411,17 +1403,14 @@ int nr_get_sf_retxBSRTimer(uint8_t sf_offset) { // PUSCH Msg3 scheduler: // - scheduled by RAR UL grant according to 8.3 of TS 38.213 // Note: Msg3 tx in the uplink symbols of mixed slot -int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, - uint8_t is_Msg3, - frame_t current_frame, - int current_slot, - frame_t *frame_tx, - int *slot_tx, - long k2){ - +int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, uint8_t is_Msg3, frame_t current_frame, int current_slot, frame_t *frame_tx, int *slot_tx, long k2) +{ AssertFatal(k2 >= DURATION_RX_TO_TX, - "Slot offset K2 (%ld) cannot be less than DURATION_RX_TO_TX (%d). K2 set according to min_rxtxtime in config file.\n", - k2,DURATION_RX_TO_TX); + "Slot offset K2 (%ld) cannot be less than DURATION_RX_TO_TX (%d). Please set min_rxtxtime at least to %d in gNB config file or gNBs.[0].min_rxtxtime=%d via command line.\n", + k2, + DURATION_RX_TO_TX, + DURATION_RX_TO_TX, + DURATION_RX_TO_TX); int delta = 0; NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; @@ -1450,8 +1439,11 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, } AssertFatal((k2 + delta) >= DURATION_RX_TO_TX, - "Slot offset (%ld) for Msg3 cannot be less than DURATION_RX_TO_TX (%d)\n", - k2 + delta, DURATION_RX_TO_TX); + "Slot offset (%ld) for Msg3 cannot be less than DURATION_RX_TO_TX (%d). Please set min_rxtxtime at least to %d in gNB config file or gNBs.[0].min_rxtxtime=%d via command line.\n", + k2, + DURATION_RX_TO_TX, + DURATION_RX_TO_TX, + DURATION_RX_TO_TX); *slot_tx = (current_slot + k2 + delta) % nr_slots_per_frame[mu]; if (current_slot + k2 + delta > nr_slots_per_frame[mu]){ @@ -1463,7 +1455,7 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, } else { if (k2 < 0) { // This can happen when a false DCI is received - LOG_W(PHY,"%d.%d. Received k2 %ld\n", current_frame, current_slot, k2); + LOG_W(PHY, "%d.%d. Received k2 %ld\n", current_frame, current_slot, k2); return -1; } @@ -1473,10 +1465,9 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, } - LOG_D(NR_MAC, "In %s: currently at [%d.%d] UL transmission in [%d.%d] (k2 %ld delta %d)\n", __FUNCTION__, current_frame, current_slot, *frame_tx, *slot_tx, k2, delta); + LOG_D(NR_MAC, "[%04d.%02d] UL transmission in [%04d.%02d] (k2 %ld delta %d)\n", current_frame, current_slot, *frame_tx, *slot_tx, k2, delta); return 0; - } // Build the list of all the valid RACH occasions in the maximum association pattern period according to the PRACH config diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index d1f1524fa2..f28e7f6024 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -563,9 +563,8 @@ bool nr_find_nb_rb(uint16_t Qm, return *tbs >= bytes && *nb_rb <= nb_rb_max; } -NR_tda_info_t nr_get_pdsch_tda_info(const NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList, - const int tda) { - +NR_tda_info_t nr_get_pdsch_tda_info(const NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList, const int tda) +{ NR_tda_info_t tda_info = {0}; AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); tda_info.mapping_type = tdaList->list.array[tda]->mappingType; @@ -1077,13 +1076,8 @@ void set_r_pucch_parms(int rsetindex, *start_symbol_index = default_pucch_firstsymb[rsetindex]; } -void prepare_dci(const NR_CellGroupConfig_t *CellGroup, - const NR_UE_DL_BWP_t *current_BWP, - const NR_ControlResourceSet_t *coreset, - dci_pdu_rel15_t *dci_pdu_rel15, - nr_dci_format_t format) +void prepare_dci(const NR_CellGroupConfig_t *CellGroup, const NR_UE_DL_BWP_t *current_BWP, const NR_ControlResourceSet_t *coreset, dci_pdu_rel15_t *dci_pdu_rel15, nr_dci_format_t format) { - AssertFatal(CellGroup!=NULL,"CellGroup shouldn't be null here\n"); const NR_PDSCH_Config_t *pdsch_Config = current_BWP ? current_BWP->pdsch_Config : NULL; @@ -1157,7 +1151,6 @@ void prepare_dci(const NR_CellGroupConfig_t *CellGroup, } } - void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, const NR_CellGroupConfig_t *CellGroup, const NR_UE_DL_BWP_t *current_DL_BWP, @@ -1189,22 +1182,16 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, // computing alternative size for padding dci_pdu_rel15_t temp_pdu; if(dci_format == NR_DL_DCI_FORMAT_1_0) - alt_size = nr_dci_size(current_DL_BWP, current_UL_BWP, - CellGroup, &temp_pdu, NR_UL_DCI_FORMAT_0_0, rnti_type, - coreset, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, 0); + alt_size = nr_dci_size(current_DL_BWP, current_UL_BWP, CellGroup, &temp_pdu, NR_UL_DCI_FORMAT_0_0, rnti_type, coreset, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, 0); if(dci_format == NR_UL_DCI_FORMAT_0_0) - alt_size = nr_dci_size(current_DL_BWP, current_UL_BWP, - CellGroup, &temp_pdu, NR_DL_DCI_FORMAT_1_0, rnti_type, - coreset, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, 0); + alt_size = nr_dci_size(current_DL_BWP, current_UL_BWP, CellGroup, &temp_pdu, NR_DL_DCI_FORMAT_1_0, rnti_type, coreset, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, 0); } else N_RB = cset0_bwp_size; - int dci_size = nr_dci_size(current_DL_BWP, current_UL_BWP, - CellGroup, dci_pdu_rel15, dci_format, rnti_type, coreset, - bwp_id, ss->searchSpaceType->present, cset0_bwp_size, alt_size); + int dci_size = nr_dci_size(current_DL_BWP, current_UL_BWP, CellGroup, dci_pdu_rel15, dci_format, rnti_type, coreset, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, alt_size); pdcch_dci_pdu->PayloadSizeBits = dci_size; AssertFatal(dci_size <= 64, "DCI sizes above 64 bits not yet supported"); if (dci_format == NR_DL_DCI_FORMAT_1_1 || dci_format == NR_UL_DCI_FORMAT_0_1) @@ -2088,8 +2075,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, int target_ss; - if(CellGroup && - CellGroup->physicalCellGroupConfig) + if (CellGroup && CellGroup->physicalCellGroupConfig) DL_BWP->pdsch_HARQ_ACK_Codebook = &CellGroup->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook; if (CellGroup && @@ -2227,11 +2213,10 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, else UL_BWP->transform_precoding = *UL_BWP->pusch_Config->transformPrecoder; - if(UL_BWP->bwp_id > 0) { + if (UL_BWP->bwp_id > 0) { UL_BWP->pucch_ConfigCommon = ul_bwp->bwp_Common->pucch_ConfigCommon->choice.setup; UL_BWP->rach_ConfigCommon = ul_bwp->bwp_Common->rach_ConfigCommon->choice.setup; - } - else { + } else { UL_BWP->pucch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup; UL_BWP->rach_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 8d3d377d43..51b3e29930 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -1015,10 +1015,7 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, } } -void set_pucch_allocation(const NR_UE_UL_BWP_t *ul_bwp, - const int r_pucch, - const int bwp_size, - NR_sched_pucch_t *pucch) +void set_pucch_allocation(const NR_UE_UL_BWP_t *ul_bwp, const int r_pucch, const int bwp_size, NR_sched_pucch_t *pucch) { if(r_pucch<0){ const NR_PUCCH_Resource_t *resource = ul_bwp->pucch_Config->resourceToAddModList->list.array[0]; diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 8ddebc9118..988ad1d6e3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -277,11 +277,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, NR_ControlResourceSet_t *coreset, uint16_t cset0_bwp_size); -void prepare_dci(const NR_CellGroupConfig_t *CellGroup, - const NR_UE_DL_BWP_t *current_BWP, - const NR_ControlResourceSet_t *coreset, - dci_pdu_rel15_t *dci_pdu_rel15, - nr_dci_format_t format); +void prepare_dci(const NR_CellGroupConfig_t *CellGroup, const NR_UE_DL_BWP_t *current_BWP, const NR_ControlResourceSet_t *coreset, dci_pdu_rel15_t *dci_pdu_rel15, nr_dci_format_t format); void set_r_pucch_parms(int rsetindex, int r_pucch, @@ -307,8 +303,7 @@ long get_K2(NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList, int time_domain_assignment, int mu); -NR_tda_info_t nr_get_pdsch_tda_info(const NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList, - const int tda); +NR_tda_info_t nr_get_pdsch_tda_info(const NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList, const int tda); NR_tda_info_t nr_get_pusch_tda_info(const NR_UE_UL_BWP_t *ul_bwp, const int tda); diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index e274ebab91..27adaa39bc 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -667,7 +667,7 @@ static void fill_dci_from_dl_config(nr_downlink_indication_t*dl_ind, fapi_nr_dl_ if (rel15_dci->dci_length_options[j] == dl_ind->dci_ind->dci_list[k].payloadSize) { dl_ind->dci_ind->dci_list[k].dci_format = rel15_dci->dci_format_options[j]; dl_ind->dci_ind->dci_list[k].ss_type = rel15_dci->dci_type_options[j]; - dl_ind->dci_ind->dci_list[k].CoreSetType = rel15_dci->coreset.CoreSetType; + dl_ind->dci_ind->dci_list[k].coreset_type = rel15_dci->coreset.CoreSetType; LOG_D(NR_PHY, "format assigned dl_ind->dci_ind->dci_list[k].dci_format %d\n", dl_ind->dci_ind->dci_list[k].dci_format); } From 605efb5e869afa31660a4737802ecbf34b024196 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 23 Feb 2023 14:33:01 +0100 Subject: [PATCH 7/7] improving handling of TDAs and other fixes --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 2 +- openair1/SIMULATION/NR_PHY/dlsim.c | 6 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac.h | 19 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 172 +++++++++++++----- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 18 +- openair2/LAYER2/NR_MAC_UE/config_ue.c | 17 +- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 10 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 115 +++--------- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 22 ++- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 22 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 9 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 11 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 30 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c | 5 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 25 +-- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 5 - openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 6 - 18 files changed, 235 insertions(+), 261 deletions(-) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 2ffb7519da..1e83033ed0 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -938,7 +938,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, long mapping_type_ul = pusch_TimeDomainAllocationList ? pusch_TimeDomainAllocationList->list.array[0]->mappingType : NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeA; NR_PDSCH_Config_t *pdsch_Config = mac->current_DL_BWP.pdsch_Config; - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = mac->current_DL_BWP.tdaList; + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = mac->current_DL_BWP.tdaList_Common; long mapping_type_dl = pdsch_TimeDomainAllocationList ? pdsch_TimeDomainAllocationList->list.array[0]->mappingType : NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA; NR_DMRS_DownlinkConfig_t *NR_DMRS_dlconfig = NULL; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index b17e722700..3638ef3ef8 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -251,10 +251,10 @@ void nr_dlsim_preprocessor(module_id_t module_id, * configuration */ current_BWP->mcsTableIdx = g_mcsTableIdx; sched_pdsch->time_domain_allocation = get_dl_tda(RC.nrmac[module_id], scc, slot); - AssertFatal(sched_pdsch->time_domain_allocation>=0,"Unable to find PDSCH time domain allocation in list\n"); + AssertFatal(sched_pdsch->time_domain_allocation >= 0,"Unable to find PDSCH time domain allocation in list\n"); - NR_PDSCH_TimeDomainResourceAllocationList_t *tdalist = get_dl_tdalist(current_BWP, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); - sched_pdsch->tda_info = nr_get_pdsch_tda_info(tdalist, sched_pdsch->time_domain_allocation); + sched_pdsch->tda_info = get_dl_tda_info(current_BWP, sched_ctrl->search_space->searchSpaceType->present, sched_pdsch->time_domain_allocation, + NR_MIB__dmrs_TypeA_Position_pos2, 1, NR_RNTI_C, sched_ctrl->coreset->controlResourceSetId, false); sched_pdsch->dmrs_parms = get_dl_dmrs_params(scc, current_BWP, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index 5782fbf054..4af6eb02e6 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -574,7 +574,7 @@ typedef struct NR_UE_DL_BWP { uint16_t BWPStart; uint16_t initial_BWPSize; uint16_t initial_BWPStart; - NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList; + NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList_Common; NR_PDSCH_Config_t *pdsch_Config; NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig; long *pdsch_HARQ_ACK_Codebook; @@ -593,7 +593,7 @@ typedef struct NR_UE_UL_BWP { uint16_t initial_BWPStart; NR_RACH_ConfigCommon_t *rach_ConfigCommon; NR_PUSCH_ServingCellConfig_t *pusch_servingcellconfig; - NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList; + NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList_Common; NR_ConfiguredGrantConfig_t *configuredGrantConfig; NR_PUSCH_Config_t *pusch_Config; NR_PUCCH_Config_t *pucch_Config; @@ -608,14 +608,23 @@ typedef struct NR_UE_UL_BWP { int max_fb_time; } NR_UE_UL_BWP_t; -typedef enum { typeA = 0, typeB = 1 } mappingType_t; +typedef enum { + defaultA = 0, + defaultB = 1, + defaultC = 2 +} default_table_type_t; -typedef struct NR_ul_tda_info { +typedef enum { + typeA = 0, + typeB = 1 +} mappingType_t; + +typedef struct NR_tda_info { mappingType_t mapping_type; int startSymbolIndex; int nrOfSymbols; long k2; -} NR_ul_tda_info_t; +} NR_tda_info_t; #endif /*__LAYER2_MAC_H__ */ diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index fdc093a52e..7ee06c4406 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -458,10 +458,13 @@ const uint8_t table_6_1_2_1_1_3[16][4] = { {0, 3, 0, 10} // row index 16 }; -NR_ul_tda_info_t get_ul_tda_info(NR_PUSCH_TimeDomainResourceAllocationList_t *tdalist, int tda_index, int scs, bool normal_CP) +NR_tda_info_t get_ul_tda_info(const NR_UE_UL_BWP_t *ul_bwp, int controlResourceSetId, int ss_type, nr_rnti_type_t rnti_type, int tda_index) { - NR_ul_tda_info_t tda_info = {0}; + NR_tda_info_t tda_info = {0}; + NR_PUSCH_TimeDomainResourceAllocationList_t *tdalist = get_ul_tdalist(ul_bwp, controlResourceSetId, ss_type, rnti_type); // Definition of value j in Table 6.1.2.1.1-4 of 38.214 + int scs = ul_bwp->scs; + AssertFatal(scs >= 0 && scs < 5, "Subcarrier spacing indicatior %d invalid value\n", scs); int j = scs == 0 ? 1 : scs; if (tdalist) { AssertFatal(tda_index < tdalist->list.count, "TDA index from DCI %d exceeds TDA list array size %d\n", tda_index, tdalist->list.count); @@ -475,6 +478,7 @@ NR_ul_tda_info_t get_ul_tda_info(NR_PUSCH_TimeDomainResourceAllocationList_t *td tda_info.startSymbolIndex = S; tda_info.nrOfSymbols = L; } else { + bool normal_CP = ul_bwp->cyclicprefix ? false : true; if (normal_CP) { tda_info.mapping_type = table_6_1_2_1_1_2[tda_index][0]; tda_info.k2 = table_6_1_2_1_1_2[tda_index][1] + j; @@ -490,79 +494,155 @@ NR_ul_tda_info_t get_ul_tda_info(NR_PUSCH_TimeDomainResourceAllocationList_t *td return tda_info; } -void get_info_from_tda_tables(int default_abc, - int tda, - int dmrs_TypeA_Position, - int normal_CP, - bool *is_mapping_typeA, - int *startSymbolIndex, - int *nrOfSymbols) { +NR_tda_info_t get_info_from_tda_tables(default_table_type_t table_type, + int tda, + int dmrs_TypeA_Position, + int normal_CP) +{ + NR_tda_info_t tda_info = {0}; + bool is_mapping_typeA; int k0 = 0; - switch(default_abc){ - case 1: + switch(table_type){ + case defaultA: if (normal_CP){ if (dmrs_TypeA_Position){ - *is_mapping_typeA = table_5_1_2_1_1_2_time_dom_res_alloc_A_dmrs_typeA_pos3[tda][0]; + is_mapping_typeA = table_5_1_2_1_1_2_time_dom_res_alloc_A_dmrs_typeA_pos3[tda][0]; k0 = table_5_1_2_1_1_2_time_dom_res_alloc_A_dmrs_typeA_pos3[tda][1]; - *startSymbolIndex = table_5_1_2_1_1_2_time_dom_res_alloc_A_dmrs_typeA_pos3[tda][2]; - *nrOfSymbols = table_5_1_2_1_1_2_time_dom_res_alloc_A_dmrs_typeA_pos3[tda][3]; + tda_info.startSymbolIndex = table_5_1_2_1_1_2_time_dom_res_alloc_A_dmrs_typeA_pos3[tda][2]; + tda_info.nrOfSymbols = table_5_1_2_1_1_2_time_dom_res_alloc_A_dmrs_typeA_pos3[tda][3]; } else{ - *is_mapping_typeA = table_5_1_2_1_1_2_time_dom_res_alloc_A_dmrs_typeA_pos2[tda][0]; + is_mapping_typeA = table_5_1_2_1_1_2_time_dom_res_alloc_A_dmrs_typeA_pos2[tda][0]; k0 = table_5_1_2_1_1_2_time_dom_res_alloc_A_dmrs_typeA_pos2[tda][1]; - *startSymbolIndex = table_5_1_2_1_1_2_time_dom_res_alloc_A_dmrs_typeA_pos2[tda][2]; - *nrOfSymbols = table_5_1_2_1_1_2_time_dom_res_alloc_A_dmrs_typeA_pos2[tda][3]; + tda_info.startSymbolIndex = table_5_1_2_1_1_2_time_dom_res_alloc_A_dmrs_typeA_pos2[tda][2]; + tda_info.nrOfSymbols = table_5_1_2_1_1_2_time_dom_res_alloc_A_dmrs_typeA_pos2[tda][3]; } } else{ if (dmrs_TypeA_Position){ - *is_mapping_typeA = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP_dmrs_typeA_pos3[tda][0]; + is_mapping_typeA = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP_dmrs_typeA_pos3[tda][0]; k0 = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP_dmrs_typeA_pos3[tda][1]; - *startSymbolIndex = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP_dmrs_typeA_pos3[tda][2]; - *nrOfSymbols = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP_dmrs_typeA_pos3[tda][3]; + tda_info.startSymbolIndex = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP_dmrs_typeA_pos3[tda][2]; + tda_info.nrOfSymbols = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP_dmrs_typeA_pos3[tda][3]; } else{ - *is_mapping_typeA = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP_dmrs_typeA_pos2[tda][0]; + is_mapping_typeA = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP_dmrs_typeA_pos2[tda][0]; k0 = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP_dmrs_typeA_pos2[tda][1]; - *startSymbolIndex = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP_dmrs_typeA_pos2[tda][2]; - *nrOfSymbols = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP_dmrs_typeA_pos2[tda][3]; + tda_info.startSymbolIndex = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP_dmrs_typeA_pos2[tda][2]; + tda_info.nrOfSymbols = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP_dmrs_typeA_pos2[tda][3]; } } break; - case 2: + case defaultB: if (dmrs_TypeA_Position){ - *is_mapping_typeA = table_5_1_2_1_1_4_time_dom_res_alloc_B_dmrs_typeA_pos3[tda][0]; + is_mapping_typeA = table_5_1_2_1_1_4_time_dom_res_alloc_B_dmrs_typeA_pos3[tda][0]; k0 = table_5_1_2_1_1_4_time_dom_res_alloc_B_dmrs_typeA_pos3[tda][1]; - *startSymbolIndex = table_5_1_2_1_1_4_time_dom_res_alloc_B_dmrs_typeA_pos3[tda][2]; - *nrOfSymbols = table_5_1_2_1_1_4_time_dom_res_alloc_B_dmrs_typeA_pos3[tda][3]; + tda_info.startSymbolIndex = table_5_1_2_1_1_4_time_dom_res_alloc_B_dmrs_typeA_pos3[tda][2]; + tda_info.nrOfSymbols = table_5_1_2_1_1_4_time_dom_res_alloc_B_dmrs_typeA_pos3[tda][3]; } else{ - *is_mapping_typeA = table_5_1_2_1_1_4_time_dom_res_alloc_B_dmrs_typeA_pos2[tda][0]; + is_mapping_typeA = table_5_1_2_1_1_4_time_dom_res_alloc_B_dmrs_typeA_pos2[tda][0]; k0 = table_5_1_2_1_1_4_time_dom_res_alloc_B_dmrs_typeA_pos2[tda][1]; - *startSymbolIndex = table_5_1_2_1_1_4_time_dom_res_alloc_B_dmrs_typeA_pos2[tda][2]; - *nrOfSymbols = table_5_1_2_1_1_4_time_dom_res_alloc_B_dmrs_typeA_pos2[tda][3]; + tda_info.startSymbolIndex = table_5_1_2_1_1_4_time_dom_res_alloc_B_dmrs_typeA_pos2[tda][2]; + tda_info.nrOfSymbols = table_5_1_2_1_1_4_time_dom_res_alloc_B_dmrs_typeA_pos2[tda][3]; } break; - case 3: + case defaultC: if (dmrs_TypeA_Position){ - *is_mapping_typeA = table_5_1_2_1_1_5_time_dom_res_alloc_C_dmrs_typeA_pos3[tda][0]; + is_mapping_typeA = table_5_1_2_1_1_5_time_dom_res_alloc_C_dmrs_typeA_pos3[tda][0]; k0 = table_5_1_2_1_1_5_time_dom_res_alloc_C_dmrs_typeA_pos3[tda][1]; - *startSymbolIndex = table_5_1_2_1_1_5_time_dom_res_alloc_C_dmrs_typeA_pos3[tda][2]; - *nrOfSymbols = table_5_1_2_1_1_5_time_dom_res_alloc_C_dmrs_typeA_pos3[tda][3]; + tda_info.startSymbolIndex = table_5_1_2_1_1_5_time_dom_res_alloc_C_dmrs_typeA_pos3[tda][2]; + tda_info.nrOfSymbols = table_5_1_2_1_1_5_time_dom_res_alloc_C_dmrs_typeA_pos3[tda][3]; } else{ - *is_mapping_typeA = table_5_1_2_1_1_5_time_dom_res_alloc_C_dmrs_typeA_pos2[tda][0]; + is_mapping_typeA = table_5_1_2_1_1_5_time_dom_res_alloc_C_dmrs_typeA_pos2[tda][0]; k0 = table_5_1_2_1_1_5_time_dom_res_alloc_C_dmrs_typeA_pos2[tda][1]; - *startSymbolIndex = table_5_1_2_1_1_5_time_dom_res_alloc_C_dmrs_typeA_pos2[tda][2]; - *nrOfSymbols = table_5_1_2_1_1_5_time_dom_res_alloc_C_dmrs_typeA_pos2[tda][3]; + tda_info.startSymbolIndex = table_5_1_2_1_1_5_time_dom_res_alloc_C_dmrs_typeA_pos2[tda][2]; + tda_info.nrOfSymbols = table_5_1_2_1_1_5_time_dom_res_alloc_C_dmrs_typeA_pos2[tda][3]; } break; default: - AssertFatal(1==0,"Invalid default time domaing allocation type\n"); + AssertFatal(1 == 0, "Invalid default time domaing allocation type\n"); } - AssertFatal(k0==0,"Only k0 = 0 is supported\n"); + AssertFatal(k0 == 0, "Only k0 = 0 is supported\n"); + tda_info.mapping_type = is_mapping_typeA ? typeA : typeB; + return tda_info; } +default_table_type_t get_default_table_type(int mux_pattern) +{ + switch (mux_pattern) { + case 1: + return defaultA; + case 2: + return defaultB; + case 3: + return defaultC; + default : + AssertFatal(1 == 0, "Invalid multiplexing type %d\n", mux_pattern); + } +} + +NR_tda_info_t set_tda_info_from_list(NR_PDSCH_TimeDomainResourceAllocationList_t *tdalist, int tda_index) +{ + NR_tda_info_t tda_info = {0}; + AssertFatal(tda_index < tdalist->list.count, "TDA index from DCI %d exceeds TDA list array size %d\n", tda_index, tdalist->list.count); + NR_PDSCH_TimeDomainResourceAllocation_t *tda = tdalist->list.array[tda_index]; + tda_info.mapping_type = tda->mappingType; + int S, L; + SLIV2SL(tda->startSymbolAndLength, &S, &L); + tda_info.startSymbolIndex = S; + tda_info.nrOfSymbols = L; + return tda_info; +} + +NR_tda_info_t get_dl_tda_info(const NR_UE_DL_BWP_t *dl_BWP, int ss_type, int tda_index, int dmrs_typeA_pos, + int mux_pattern, nr_rnti_type_t rnti_type, int coresetid, bool sib1) +{ + NR_tda_info_t tda_info; + bool normal_CP = dl_BWP->cyclicprefix ? false : true; + // implements Table 5.1.2.1.1-1 of 38.214 + NR_PDSCH_TimeDomainResourceAllocationList_t *tdalist = get_dl_tdalist(dl_BWP, coresetid, ss_type, rnti_type); + switch (rnti_type) { + case NR_RNTI_SI: + if(sib1) { + default_table_type_t table_type = get_default_table_type(mux_pattern); + tda_info = get_info_from_tda_tables(table_type, tda_index, dmrs_typeA_pos, normal_CP); + } + else { + if(tdalist) + tda_info = set_tda_info_from_list(tdalist, tda_index); + else { + default_table_type_t table_type = get_default_table_type(mux_pattern); + tda_info = get_info_from_tda_tables(table_type, tda_index, dmrs_typeA_pos, normal_CP); + } + } + break; + case NR_RNTI_P: + if(tdalist) + tda_info = set_tda_info_from_list(tdalist, tda_index); + else { + default_table_type_t table_type = get_default_table_type(mux_pattern); + tda_info = get_info_from_tda_tables(table_type, tda_index, dmrs_typeA_pos, normal_CP); + } + break; + case NR_RNTI_C: + case NR_RNTI_CS: + case NR_RNTI_MCS_C: + case NR_RNTI_RA: + case NR_RNTI_TC: + if(tdalist) + tda_info = set_tda_info_from_list(tdalist, tda_index); + else + tda_info = get_info_from_tda_tables(defaultA, tda_index, dmrs_typeA_pos, normal_CP); + break; + default : + AssertFatal(1 == 0, "Invalid RNTI type\n"); + } + return tda_info; +} + + const char *prachfmt[]={"0","1","2","3", "A1","A2","A3","B1","B4","C0","C2","A1/B1","A2/B2","A3/B3"}; uint16_t get_NCS(uint8_t index, uint16_t format0, uint8_t restricted_set_config) { @@ -3187,7 +3267,7 @@ NR_PDSCH_TimeDomainResourceAllocationList_t *get_dl_tdalist(const NR_UE_DL_BWP_t && (DL_BWP->pdsch_Config && DL_BWP->pdsch_Config->pdsch_TimeDomainAllocationList)) return DL_BWP->pdsch_Config->pdsch_TimeDomainAllocationList->choice.setup; else - return DL_BWP->tdaList; + return DL_BWP->tdaList_Common; } NR_PUSCH_TimeDomainResourceAllocationList_t *get_ul_tdalist(const NR_UE_UL_BWP_t *UL_BWP, int controlResourceSetId, int ss_type, nr_rnti_type_t rnti_type) @@ -3196,7 +3276,7 @@ NR_PUSCH_TimeDomainResourceAllocationList_t *get_ul_tdalist(const NR_UE_UL_BWP_t && (UL_BWP->pusch_Config && UL_BWP->pusch_Config->pusch_TimeDomainAllocationList)) return UL_BWP->pusch_Config->pusch_TimeDomainAllocationList->choice.setup; else - return UL_BWP->tdaList; + return UL_BWP->tdaList_Common; } uint16_t get_rb_bwp_dci(nr_dci_format_t format, @@ -3312,10 +3392,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, size += dci_pdu->frequency_domain_assignment.nbits; // Time domain assignment NR_PUSCH_TimeDomainResourceAllocationList_t *tdalistul = get_ul_tdalist(UL_BWP, coreset->controlResourceSetId, ss_type, rnti_type); - if (tdalistul) - num_entries = tdalistul->list.count; - else - num_entries = 16; // num of entries in default table + num_entries = tdalistul ? tdalistul->list.count : 16; // 16 in default table dci_pdu->time_domain_assignment.nbits = (int)ceil(log2(num_entries)); LOG_D(NR_MAC, "PUSCH Time Domain Allocation nbits %d, pusch_Config %p\n", dci_pdu->time_domain_assignment.nbits, pusch_Config); size += dci_pdu->time_domain_assignment.nbits; @@ -3457,10 +3534,7 @@ uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, size += dci_pdu->frequency_domain_assignment.nbits; LOG_D(NR_MAC,"dci_pdu->frequency_domain_assignment.nbits %d (N_RB %d)\n",dci_pdu->frequency_domain_assignment.nbits,N_RB); NR_PDSCH_TimeDomainResourceAllocationList_t *tdalist = get_dl_tdalist(DL_BWP, coreset->controlResourceSetId, ss_type, rnti_type); - if (tdalist) - num_entries = tdalist->list.count; - else - num_entries = 16; // num of entries in default table + num_entries = tdalist ? tdalist->list.count : 16; // 16 in default table dci_pdu->time_domain_assignment.nbits = (int)ceil(log2(num_entries)); LOG_D(NR_MAC,"pdsch tda.nbits= %d\n",dci_pdu->time_domain_assignment.nbits); size += dci_pdu->time_domain_assignment.nbits; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 3909dec15b..a6cc264c02 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -88,7 +88,10 @@ NR_PDSCH_TimeDomainResourceAllocationList_t *get_dl_tdalist(const NR_UE_DL_BWP_t NR_PUSCH_TimeDomainResourceAllocationList_t *get_ul_tdalist(const NR_UE_UL_BWP_t *UL_BWP, int controlResourceSetId, int ss_type, nr_rnti_type_t rnti_type); -NR_ul_tda_info_t get_ul_tda_info(NR_PUSCH_TimeDomainResourceAllocationList_t *tdalist, int tda_index, int scs, bool normal_CP); +NR_tda_info_t get_ul_tda_info(const NR_UE_UL_BWP_t *ul_bwp, int controlResourceSetId, int ss_type, nr_rnti_type_t rnti_type, int tda_index); + +NR_tda_info_t get_dl_tda_info(const NR_UE_DL_BWP_t *dl_BWP, int ss_type, int tda_index, int dmrs_typeA_pos, + int mux_pattern, nr_rnti_type_t rnti_type, int coresetid, bool sib1); uint16_t nr_dci_size(const NR_UE_DL_BWP_t *DL_BWP, const NR_UE_UL_BWP_t *UL_BWP, @@ -219,13 +222,12 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD uint16_t get_ssb_start_symbol(const long band, NR_SubcarrierSpacing_t scs, int i_ssb); -void get_info_from_tda_tables(int default_abc, - int tda, - int dmrs_TypeA_Position, - int normal_CP, - bool *is_mapping_typeA, - int *startSymbolIndex, - int *nrOfSymbols); +NR_tda_info_t get_info_from_tda_tables(default_table_type_t table_type, + int tda, + int dmrs_TypeA_Position, + int normal_CP); + +default_table_type_t get_default_table_type(int mux_pattern); void fill_coresetZero(NR_ControlResourceSet_t *coreset0, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config); void fill_searchSpaceZero(NR_SearchSpace_t *ss0, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 1eee95e823..5b5587a7e7 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -565,9 +565,9 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, DL_BWP->pdsch_Config = NULL; if (bwp_dlcommon->pdsch_ConfigCommon) - DL_BWP->tdaList = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + DL_BWP->tdaList_Common = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; if (bwp_ulcommon->pusch_ConfigCommon) { - UL_BWP->tdaList = bwp_ulcommon->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + UL_BWP->tdaList_Common = bwp_ulcommon->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; UL_BWP->msg3_DeltaPreamble = bwp_ulcommon->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble; } if (bwp_ulcommon->pucch_ConfigCommon) @@ -598,10 +598,13 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, bwp_dlcommon = mac->scc->downlinkConfigCommon->initialDownlinkBWP; bwp_ulcommon = mac->scc->uplinkConfigCommon->initialUplinkBWP; } - if (mac->scc_SIB) { + else if (mac->scc_SIB) { bwp_dlcommon = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP; bwp_ulcommon = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; } + else + AssertFatal(false, "Either SCC or SCC SIB should be non-NULL\n"); + NR_BWP_Downlink_t *bwp_downlink = NULL; const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = spCellConfigDedicated->downlinkBWP_ToAddModList; if (bwpList) @@ -615,12 +618,12 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, AssertFatal(bwp_downlink != NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n", DL_BWP->bwp_id); dl_genericParameters = bwp_downlink->bwp_Common->genericParameters; DL_BWP->pdsch_Config = bwp_downlink->bwp_Dedicated->pdsch_Config->choice.setup; - DL_BWP->tdaList = bwp_downlink->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + DL_BWP->tdaList_Common = bwp_downlink->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; } else { dl_genericParameters = bwp_dlcommon->genericParameters; DL_BWP->pdsch_Config = spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup; - DL_BWP->tdaList = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + DL_BWP->tdaList_Common = bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; } UL_BWP->msg3_DeltaPreamble = bwp_ulcommon->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble; @@ -637,7 +640,7 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, } AssertFatal(bwp_uplink != NULL,"Couldn't find ULBWP corresponding to BWP ID %ld\n",UL_BWP->bwp_id); ul_genericParameters = bwp_uplink->bwp_Common->genericParameters; - UL_BWP->tdaList = bwp_uplink->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + UL_BWP->tdaList_Common = bwp_uplink->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; UL_BWP->pusch_Config = bwp_uplink->bwp_Dedicated->pusch_Config->choice.setup; UL_BWP->pucch_Config = bwp_uplink->bwp_Dedicated->pucch_Config->choice.setup; UL_BWP->srs_Config = bwp_uplink->bwp_Dedicated->srs_Config->choice.setup; @@ -648,7 +651,7 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, UL_BWP->rach_ConfigCommon = bwp_uplink->bwp_Common->rach_ConfigCommon->choice.setup; } else { - UL_BWP->tdaList = bwp_ulcommon->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + UL_BWP->tdaList_Common = bwp_ulcommon->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; UL_BWP->pusch_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pusch_Config->choice.setup; UL_BWP->pucch_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; UL_BWP->srs_Config = spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config->choice.setup; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 37f0adfa95..eb773672d4 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -253,14 +253,6 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl NR_BWP_DownlinkCommon_t *get_bwp_downlink_common(NR_UE_MAC_INST_t *mac, NR_BWP_Id_t dl_bwp_id); -int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList, - fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, - int *mapping_type, - uint8_t time_domain_ind, - int default_abc, - bool use_default); - uint8_t nr_ue_get_sdu(module_id_t module_idP, int cc_id, frame_t frameP, @@ -474,6 +466,6 @@ int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti); // - 6.1.4.2 of TS 38.214 // - 6.4.1.1.1 of TS 38.211 // - 6.3.1.7 of 38.211 -int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, NR_ul_tda_info_t *tda_info, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci, RAR_grant_t *rar_grant, uint16_t rnti, uint8_t *dci_format); +int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, NR_tda_info_t *tda_info, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci, RAR_grant_t *rar_grant, uint16_t rnti, uint8_t *dci_format); #endif /** @}*/ diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index ca924f79bd..02ad48a655 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -192,7 +192,8 @@ NR_BWP_DownlinkCommon_t *get_bwp_downlink_common(NR_UE_MAC_INST_t *mac, NR_BWP_I return bwp_Common; } -int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti){ +int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti) +{ RA_config_t *ra = &mac->ra; int rnti_type; @@ -410,63 +411,6 @@ int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *p return 0; } -int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList, - fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, - int *mapping_type, - uint8_t time_domain_ind, - int default_abc, - bool use_default) -{ - int dmrs_typeA_pos = (mac->scc != NULL) ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position; - -// uint8_t k_offset=0; - int sliv_S=0; - int sliv_L=0; - - /* - * TS 38.214 subclause 5.1.2.1 Resource allocation in time domain (downlink) - */ - if(dlsch_config_pdu != NULL){ - if (pdsch_TimeDomainAllocationList && use_default==false) { - - if (time_domain_ind >= pdsch_TimeDomainAllocationList->list.count) { - LOG_E(MAC, "time_domain_ind %d >= pdsch->TimeDomainAllocationList->list.count %d\n", - time_domain_ind, pdsch_TimeDomainAllocationList->list.count); - dlsch_config_pdu->start_symbol = 0; - dlsch_config_pdu->number_symbols = 0; - return -1; - } - - int startSymbolAndLength = pdsch_TimeDomainAllocationList->list.array[time_domain_ind]->startSymbolAndLength; - int S,L; - SLIV2SL(startSymbolAndLength,&S,&L); - dlsch_config_pdu->start_symbol=S; - dlsch_config_pdu->number_symbols=L; - - LOG_D(MAC,"SLIV = %i\n", startSymbolAndLength); - LOG_D(MAC,"start_symbol = %i\n", dlsch_config_pdu->start_symbol); - LOG_D(MAC,"number_symbols = %i\n", dlsch_config_pdu->number_symbols); - - } - else {// Default configuration from tables - - bool is_typeA; - get_info_from_tda_tables(default_abc, - time_domain_ind, - dmrs_typeA_pos, - 1, // normal CP - &is_typeA, - &sliv_S, - &sliv_L); - *mapping_type = is_typeA? typeA : typeB; - dlsch_config_pdu->number_symbols = sliv_L; - dlsch_config_pdu->start_symbol = sliv_S; - } - } - return 0; -} - int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_index, frame_t frame, int slot, fapi_nr_dci_indication_pdu_t *dci) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); @@ -500,13 +444,10 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr uint8_t is_Msg3 = 0; NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - int default_abc = 1; + int mux_pattern = 1; LOG_D(MAC, "In %s: Processing received DCI format %s\n", __FUNCTION__, dci_formats[dci_format]); - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; - bool normal_CP = current_UL_BWP->cyclicprefix ? false : true; - NR_ul_tda_info_t tda_info = {0}; + NR_tda_info_t tda_info = {0}; NR_PUCCH_Config_t *pucch_Config = current_UL_BWP->pucch_Config; switch(dci_format){ @@ -532,8 +473,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // - SUL_IND_0_0 // Schedule PUSCH - pusch_TimeDomainAllocationList = get_ul_tdalist(current_UL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, rnti)); - tda_info = get_ul_tda_info(pusch_TimeDomainAllocationList, dci->time_domain_assignment.val, current_UL_BWP->scs, normal_CP); + tda_info = get_ul_tda_info(current_UL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, rnti), dci->time_domain_assignment.val); if (tda_info.nrOfSymbols == 0) ret = -1; else @@ -597,8 +537,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // - SRS_RESOURCE_IND // Schedule PUSCH - pusch_TimeDomainAllocationList = get_ul_tdalist(current_UL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, rnti)); - tda_info = get_ul_tda_info(pusch_TimeDomainAllocationList, dci->time_domain_assignment.val, current_UL_BWP->scs, normal_CP); + tda_info = get_ul_tda_info(current_UL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, rnti), dci->time_domain_assignment.val); if (tda_info.nrOfSymbols == 0) ret = -1; else @@ -696,7 +635,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr } if(rnti == SI_RNTI) { NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config = mac->type0_PDCCH_CSS_config; - default_abc = type0_PDCCH_CSS_config.type0_pdcch_ss_mux_pattern; + 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; dlsch_config_pdu_1_0->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon; 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' @@ -720,19 +659,18 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr return -1; } - int mappingtype; /* TIME_DOM_RESOURCE_ASSIGNMENT */ - pdsch_TimeDomainAllocationList = get_dl_tdalist(current_DL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, rnti)); - if (nr_ue_process_dci_time_dom_resource_assignment(mac, pdsch_TimeDomainAllocationList, dlsch_config_pdu_1_0, &mappingtype, dci->time_domain_assignment.val, default_abc, rnti == SI_RNTI) < 0) { - LOG_W(MAC, "[%d.%d] Invalid time_domain_assignment. Possibly due to false DCI. Ignoring DCI!\n", frame, slot); - return -1; - } - if (pdsch_TimeDomainAllocationList) - mappingtype = pdsch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->mappingType; + int dmrs_typeA_pos = (mac->scc != NULL) ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position; + // TODO need to differentiate SI_RNTI between SIB1 and other SIB + NR_tda_info_t tda_info = get_dl_tda_info(current_DL_BWP, dci_ind->ss_type, dci->time_domain_assignment.val, + dmrs_typeA_pos, mux_pattern, get_rnti_type(mac, rnti), coreset_type, rnti == SI_RNTI); + + dlsch_config_pdu_1_0->number_symbols = tda_info.nrOfSymbols; + dlsch_config_pdu_1_0->start_symbol = tda_info.startSymbolIndex; struct NR_DMRS_DownlinkConfig *dl_dmrs_config = NULL; if (pdsch_config) - dl_dmrs_config = (mappingtype == typeA) ? pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup : pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup; + dl_dmrs_config = (tda_info.mapping_type == typeA) ? pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup : pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup; dlsch_config_pdu_1_0->nscid = 0; if(dl_dmrs_config && dl_dmrs_config->scramblingID0) @@ -746,7 +684,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr (get_softmodem_params()->nsa) ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position, dlsch_config_pdu_1_0->number_symbols, dlsch_config_pdu_1_0->start_symbol, - mappingtype, + tda_info.mapping_type, 1); dlsch_config_pdu_1_0->dmrsConfigType = (dl_dmrs_config != NULL) ? @@ -930,17 +868,14 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr return -1; } /* TIME_DOM_RESOURCE_ASSIGNMENT */ - int mappingtype; + int dmrs_typeA_pos = (mac->scc != NULL) ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position; + NR_tda_info_t tda_info = get_dl_tda_info(current_DL_BWP, dci_ind->ss_type, dci->time_domain_assignment.val, + dmrs_typeA_pos, mux_pattern, get_rnti_type(mac, rnti), coreset_type, false); - pdsch_TimeDomainAllocationList = get_dl_tdalist(current_DL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, rnti)); - if (nr_ue_process_dci_time_dom_resource_assignment(mac, pdsch_TimeDomainAllocationList, dlsch_config_pdu_1_1, &mappingtype, dci->time_domain_assignment.val, 0, false) < 0) { - LOG_W(MAC, "[%d.%d] Invalid time_domain_assignment. Possibly due to false DCI. Ignoring DCI!\n", frame, slot); - return -1; - } - if(pdsch_TimeDomainAllocationList) - mappingtype = pdsch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->mappingType; + dlsch_config_pdu_1_1->number_symbols = tda_info.nrOfSymbols; + dlsch_config_pdu_1_1->start_symbol = tda_info.startSymbolIndex; - struct NR_DMRS_DownlinkConfig *dl_dmrs_config = (mappingtype == typeA) ? + struct NR_DMRS_DownlinkConfig *dl_dmrs_config = (tda_info.mapping_type == typeA) ? pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup : pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup; @@ -1127,7 +1062,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr mac->scc? mac->scc->dmrs_TypeA_Position:mac->mib->dmrs_TypeA_Position, dlsch_config_pdu_1_1->number_symbols, dlsch_config_pdu_1_1->start_symbol, - mappingtype, + tda_info.mapping_type, dlsch_config_pdu_1_1->n_front_load_symb); /* TCI */ @@ -3741,9 +3676,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t // Schedule Msg3 NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - bool normal_CP = current_UL_BWP->cyclicprefix ? false : true; - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = get_ul_tdalist(current_UL_BWP, *ra->ss->controlResourceSetId, ra->ss->searchSpaceType->present, NR_RNTI_RA); - NR_ul_tda_info_t tda_info = get_ul_tda_info(pusch_TimeDomainAllocationList, rar_grant.Msg3_t_alloc, current_UL_BWP->scs, normal_CP); + NR_tda_info_t tda_info = get_ul_tda_info(current_UL_BWP, *ra->ss->controlResourceSetId, ra->ss->searchSpaceType->present, NR_RNTI_RA, rar_grant.Msg3_t_alloc); if (tda_info.nrOfSymbols == 0) { LOG_E(MAC, "Cannot schedule Msg3. Something wrong in TDA information\n"); return -1; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index fc3b954769..a6acf1fa77 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -449,7 +449,7 @@ void ul_ports_config(NR_UE_MAC_INST_t *mac, int *n_front_load_symb, nfapi_nr_ue_ // - 6.1.4.2 of TS 38.214 // - 6.4.1.1.1 of TS 38.211 // - 6.3.1.7 of 38.211 -int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, NR_ul_tda_info_t *tda_info, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci, RAR_grant_t *rar_grant, uint16_t rnti, uint8_t *dci_format) +int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, NR_tda_info_t *tda_info, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci, RAR_grant_t *rar_grant, uint16_t rnti, uint8_t *dci_format) { int f_alloc; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index ebc977b1a8..41d74d6a6a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -699,7 +699,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_UE_UL_BWP_t *ul_bwp = &ra->UL_BWP; - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = ul_bwp->tdaList; + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = ul_bwp->tdaList_Common; int mu = ul_bwp->scs; uint8_t K2 = *pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->k2; const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); @@ -887,7 +887,7 @@ void nr_get_Msg3alloc(module_id_t module_id, int Msg3maxsymb = 14, Msg3start = 0; ra->Msg3_tda_id = 16; // initialization to a value above limit - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = ul_bwp->tdaList; + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = ul_bwp->tdaList_Common; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; const int n_slots_frame = nr_slots_per_frame[mu]; @@ -1108,8 +1108,8 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t const int ibwp_size = ul_bwp->initial_BWPSize; const int scs = ul_bwp->scs; const int fh = (ul_bwp->pusch_Config && ul_bwp->pusch_Config->frequencyHopping) ? 1 : 0; - const int startSymbolAndLength = ul_bwp->tdaList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; - const int mappingtype = ul_bwp->tdaList->list.array[ra->Msg3_tda_id]->mappingType; + const int startSymbolAndLength = ul_bwp->tdaList_Common->list.array[ra->Msg3_tda_id]->startSymbolAndLength; + const int mappingtype = ul_bwp->tdaList_Common->list.array[ra->Msg3_tda_id]->mappingType; LOG_D(NR_MAC, "Frame %d, Slot %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d) for rnti: %d\n", frameP, @@ -1162,13 +1162,13 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra } NR_ControlResourceSet_t *coreset = ra->coreset; + AssertFatal(coreset != NULL,"Coreset cannot be null for RA-Msg2\n"); const int coresetid = coreset->controlResourceSetId; // Calculate number of symbols int time_domain_assignment = get_dl_tda(nr_mac, scc, slotP); - NR_PDSCH_TimeDomainResourceAllocationList_t *tda_list = get_dl_tdalist(dl_bwp, coresetid, ss->searchSpaceType->present, NR_RNTI_RA); - NR_tda_info_t tda_info = nr_get_pdsch_tda_info(tda_list, time_domain_assignment); - - AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg2\n"); + int mux_pattern = type0_PDCCH_CSS_config ? type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern : 1; + NR_tda_info_t tda_info = get_dl_tda_info(dl_bwp, ss->searchSpaceType->present, time_domain_assignment, + scc->dmrs_TypeA_Position, mux_pattern, NR_RNTI_RA, coresetid, false); uint16_t *vrb_map = cc[CC_id].vrb_map; for (int i = 0; (i < rbSize) && (rbStart <= (BWPSize - rbSize)); i++) { @@ -1479,8 +1479,10 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra } uint8_t time_domain_assignment = get_dl_tda(nr_mac, scc, slotP); - NR_PDSCH_TimeDomainResourceAllocationList_t *tda_list = get_dl_tdalist(dl_bwp, coreset->controlResourceSetId, ss->searchSpaceType->present, NR_RNTI_TC); - NR_tda_info_t msg4_tda = nr_get_pdsch_tda_info(tda_list, time_domain_assignment); + int mux_pattern = type0_PDCCH_CSS_config ? type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern : 1; + NR_tda_info_t msg4_tda = get_dl_tda_info(dl_bwp, ss->searchSpaceType->present, time_domain_assignment, + scc->dmrs_TypeA_Position, mux_pattern, NR_RNTI_TC, coreset->controlResourceSetId, false); + NR_pdsch_dmrs_t dmrs_info = get_dl_dmrs_params(scc, dl_bwp, &msg4_tda, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index dc2467e904..8db40a26c7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -569,23 +569,11 @@ void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) 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); - get_info_from_tda_tables(type0_PDCCH_CSS_config->type0_pdcch_ss_mux_pattern, - time_domain_allocation, - gNB_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position, - 1, &is_typeA, - &startSymbolIndex, &nrOfSymbols); - - AssertFatal((startSymbolIndex+nrOfSymbols)<14,"SIB1 TDA %d would cause overlap with CSI-RS. Please select a different SIB1 TDA.\n",time_domain_allocation); - - NR_tda_info_t tda_info = { - .mapping_type = is_typeA ? typeA : typeB, - .startSymbolIndex = startSymbolIndex, - .nrOfSymbols = nrOfSymbols - }; + AssertFatal((tda_info.startSymbolIndex + tda_info.nrOfSymbols) < 14, "SIB1 TDA %d would cause overlap with CSI-RS. Please select a different SIB1 TDA.\n", time_domain_allocation); NR_pdsch_dmrs_t dmrs_parms = get_dl_dmrs_params(scc, NULL, @@ -603,7 +591,7 @@ void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; int pdu_index = gNB_mac->pdu_index[0]++; - nr_fill_nfapi_dl_sib1_pdu(module_idP, dl_req, pdu_index, type0_PDCCH_CSS_config, TBS, startSymbolIndex, nrOfSymbols); + nr_fill_nfapi_dl_sib1_pdu(module_idP, dl_req, pdu_index, type0_PDCCH_CSS_config, TBS, tda_info.startSymbolIndex, tda_info.nrOfSymbols); const int ntx_req = gNB_mac->TX_req[CC_id].Number_of_PDUs; nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[ntx_req]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index fbab81c1b9..08611fccd5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -411,8 +411,8 @@ bool allocate_dl_retransmission(module_id_t module_id, /* Check first whether the old TDA can be reused * this helps allocate retransmission when TDA changes (e.g. new nrOfSymbols > old nrOfSymbols) */ - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = get_dl_tdalist(dl_bwp, coresetid, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); - NR_tda_info_t temp_tda = nr_get_pdsch_tda_info(pdsch_TimeDomainAllocationList, tda); + NR_tda_info_t temp_tda = get_dl_tda_info(dl_bwp, sched_ctrl->search_space->searchSpaceType->present, tda, + scc->dmrs_TypeA_Position, 1, NR_RNTI_C, coresetid, false); bool reuse_old_tda = (retInfo->tda_info.startSymbolIndex == temp_tda.startSymbolIndex) && (retInfo->tda_info.nrOfSymbols <= temp_tda.nrOfSymbols); LOG_D(NR_MAC, "[UE %x] %s old TDA, %s number of layers\n", @@ -731,8 +731,9 @@ void pf_dl(module_id_t module_id, sched_pdsch->time_domain_allocation = get_dl_tda(mac, scc, slot); AssertFatal(sched_pdsch->time_domain_allocation>=0,"Unable to find PDSCH time domain allocation in list\n"); - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = get_dl_tdalist(dl_bwp, coresetid, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); - sched_pdsch->tda_info = nr_get_pdsch_tda_info(pdsch_TimeDomainAllocationList, sched_pdsch->time_domain_allocation); + sched_pdsch->tda_info = get_dl_tda_info(dl_bwp, sched_ctrl->search_space->searchSpaceType->present, sched_pdsch->time_domain_allocation, + scc->dmrs_TypeA_Position, 1, NR_RNTI_C, coresetid, false); + NR_tda_info_t *tda_info = &sched_pdsch->tda_info; const uint16_t slbitmap = SL_to_bitmap(tda_info->startSymbolIndex, tda_info->nrOfSymbols); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index ea05759dad..863cdffa75 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -59,8 +59,9 @@ void nr_preprocessor_phytest(module_id_t module_id, const int CC_id = 0; const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); - NR_PDSCH_TimeDomainResourceAllocationList_t *tdalist = get_dl_tdalist(dl_bwp, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); - NR_tda_info_t tda_info = nr_get_pdsch_tda_info(tdalist, tda); + NR_tda_info_t tda_info = get_dl_tda_info(dl_bwp, sched_ctrl->search_space->searchSpaceType->present, tda, + scc->dmrs_TypeA_Position, 1, NR_RNTI_C, sched_ctrl->coreset->controlResourceSetId, false); + sched_ctrl->sched_pdsch.tda_info = tda_info; sched_ctrl->sched_pdsch.time_domain_allocation = tda; @@ -206,7 +207,7 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; const int mu = ul_bwp->scs; - const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = ul_bwp->tdaList; + NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = get_ul_tdalist(ul_bwp, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); const int temp_tda = get_ul_tda(nr_mac, scc, frame, slot); if (temp_tda < 0) return false; @@ -214,7 +215,7 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ "time domain assignment %d >= %d\n", temp_tda, tdaList->list.count); - int K2 = get_K2(ul_bwp->tdaList, temp_tda, mu); + int K2 = get_K2(tdaList, temp_tda, mu); const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; const int tda = get_ul_tda(nr_mac, scc, sched_frame, sched_slot); @@ -241,7 +242,7 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ else rbSize = target_ul_bw; - NR_tda_info_t tda_info = nr_get_pusch_tda_info(ul_bwp, tda); + NR_tda_info_t tda_info = get_ul_tda_info(ul_bwp, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C, tda); sched_ctrl->sched_pusch.tda_info = tda_info; uint16_t *vrb_map_UL = diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index f28e7f6024..02bc94804d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -563,28 +563,6 @@ bool nr_find_nb_rb(uint16_t Qm, return *tbs >= bytes && *nb_rb <= nb_rb_max; } -NR_tda_info_t nr_get_pdsch_tda_info(const NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList, const int tda) -{ - NR_tda_info_t tda_info = {0}; - AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); - tda_info.mapping_type = tdaList->list.array[tda]->mappingType; - const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; - SLIV2SL(startSymbolAndLength, &tda_info.startSymbolIndex, &tda_info.nrOfSymbols); - return tda_info; -} - -NR_tda_info_t nr_get_pusch_tda_info(const NR_UE_UL_BWP_t *ul_bwp, - const int tda) { - - NR_tda_info_t tda_info = {0}; - NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = ul_bwp->tdaList; - AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); - tda_info.mapping_type = tdaList->list.array[tda]->mappingType; - const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; - SLIV2SL(startSymbolAndLength, &tda_info.startSymbolIndex, &tda_info.nrOfSymbols); - return tda_info; -} - NR_pusch_dmrs_t get_ul_dmrs_params(const NR_ServingCellConfigCommon_t *scc, const NR_UE_UL_BWP_t *ul_bwp, const NR_tda_info_t *tda_info, @@ -2176,14 +2154,14 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, // TDA lists if (DL_BWP->bwp_id>0) - DL_BWP->tdaList = dl_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + DL_BWP->tdaList_Common = dl_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; else - DL_BWP->tdaList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + DL_BWP->tdaList_Common = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; if(UL_BWP->bwp_id>0) - UL_BWP->tdaList = ul_bwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + UL_BWP->tdaList_Common = ul_bwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; else - UL_BWP->tdaList = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + UL_BWP->tdaList_Common = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; // setting generic parameters NR_BWP_t dl_genericParameters = (DL_BWP->bwp_id > 0 && dl_bwp) ? diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c index ef98c82eab..fe8ffdf51e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c @@ -274,11 +274,12 @@ void nr_schedule_srs(int module_id, frame_t frame, int slot) continue; } - const int num_tda = current_BWP->tdaList->list.count; + NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = get_ul_tdalist(current_BWP, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); + const int num_tda = tdaList->list.count; int max_k2 = 0; // avoid last one in the list (for msg3) for (int i = 0; i < num_tda - 1; i++) { - int k2 = get_K2(current_BWP->tdaList, i, current_BWP->scs); + int k2 = get_K2(tdaList, i, current_BWP->scs); max_k2 = k2 > max_k2 ? k2 : max_k2; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index dd44ce44f7..19dc6109b5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1426,13 +1426,14 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, const int CC_id = 0; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_sched_pusch_t *retInfo = &sched_ctrl->ul_harq_processes[harq_pid].sched_pusch; + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; int rbStart = 0; // wrt BWP start - const uint16_t bwpSize = UE->current_UL_BWP.BWPSize; + const uint16_t bwpSize = ul_bwp->BWPSize; const uint8_t nrOfLayers = retInfo->nrOfLayers; LOG_D(NR_MAC,"retInfo->time_domain_allocation = %d, tda = %d\n", retInfo->time_domain_allocation, tda); LOG_D(NR_MAC,"tbs %d\n",retInfo->tb_size); - NR_tda_info_t tda_info = nr_get_pusch_tda_info(&UE->current_UL_BWP, tda); + NR_tda_info_t tda_info = get_ul_tda_info(ul_bwp, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C, tda); bool reuse_old_tda = (retInfo->tda_info.startSymbolIndex == tda_info.startSymbolIndex) && (retInfo->tda_info.nrOfSymbols <= tda_info.nrOfSymbols); if (reuse_old_tda && nrOfLayers == retInfo->nrOfLayers) { /* Check the resource is enough for retransmission */ @@ -1452,7 +1453,7 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, LOG_D(NR_MAC, "%s(): retransmission keeping TDA %d and TBS %d\n", __func__, tda, retInfo->tb_size); } else { NR_pusch_dmrs_t dmrs_info = get_ul_dmrs_params(scc, - &UE->current_UL_BWP, + ul_bwp, &tda_info, nrOfLayers); /* the retransmission will use a different time domain allocation, check @@ -1668,7 +1669,7 @@ void pf_ul(module_id_t module_id, sched_pusch->nrOfLayers = sched_ctrl->srs_feedback.ul_ri + 1; sched_pusch->time_domain_allocation = get_ul_tda(nrmac, scc, sched_pusch->frame, sched_pusch->slot); - sched_pusch->tda_info = nr_get_pusch_tda_info(current_BWP, sched_pusch->time_domain_allocation); + sched_pusch->tda_info = get_ul_tda_info(current_BWP, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C, sched_pusch->time_domain_allocation); sched_pusch->dmrs_info = get_ul_dmrs_params(scc, current_BWP, &sched_pusch->tda_info, @@ -1768,7 +1769,7 @@ void pf_ul(module_id_t module_id, sched_pusch->nrOfLayers = sched_ctrl->srs_feedback.ul_ri + 1; sched_pusch->time_domain_allocation = get_ul_tda(nrmac, scc, sched_pusch->frame, sched_pusch->slot); - sched_pusch->tda_info = nr_get_pusch_tda_info(current_BWP, sched_pusch->time_domain_allocation); + sched_pusch->tda_info = get_ul_tda_info(current_BWP, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C, sched_pusch->time_domain_allocation); sched_pusch->dmrs_info = get_ul_dmrs_params(scc, current_BWP, &sched_pusch->tda_info, @@ -1870,13 +1871,14 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t NR_UE_UL_BWP_t *current_BWP = &nr_mac->UE_info.list[0]->current_UL_BWP; int mu = current_BWP->scs; const int temp_tda = get_ul_tda(nr_mac, scc, frame, slot); - int K2 = get_K2(current_BWP->tdaList, temp_tda, mu); + NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = get_ul_tdalist(current_BWP, sched_ctrl->coreset->controlResourceSetId, sched_ctrl->search_space->searchSpaceType->present, NR_RNTI_C); + int K2 = get_K2(tdaList, temp_tda, mu); const int sched_frame = (frame + (slot + K2 >= nr_slots_per_frame[mu])) & 1023; const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; const int tda = get_ul_tda(nr_mac, scc, sched_frame, sched_slot); if (tda < 0) return false; - DevAssert(K2 == get_K2(current_BWP->tdaList, tda, mu)); + DevAssert(K2 == get_K2(tdaList, tda, mu)); if (!is_xlsch_in_slot(nr_mac->ulsch_slot_bitmap[sched_slot / 64], sched_slot)) return false; @@ -1885,9 +1887,9 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t sched_ctrl->sched_pusch.frame = sched_frame; UE_iterator(nr_mac->UE_info.list, UE2) { NR_UE_sched_ctrl_t *sched_ctrl = &UE2->UE_sched_ctrl; - AssertFatal(K2 == get_K2(current_BWP->tdaList, tda, mu), + AssertFatal(K2 == get_K2(tdaList, tda, mu), "Different K2, %d(UE%d) != %ld(UE%04x)\n", - K2, 0, get_K2(current_BWP->tdaList, tda, mu), UE2->rnti); + K2, 0, get_K2(tdaList, tda, mu), UE2->rnti); sched_ctrl->sched_pusch.slot = sched_slot; sched_ctrl->sched_pusch.frame = sched_frame; } @@ -1895,13 +1897,12 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t /* Change vrb_map_UL to rballoc_mask: check which symbols per RB (in * vrb_map_UL) overlap with the "default" tda and exclude those RBs. * Calculate largest contiguous RBs */ - uint16_t *vrb_map_UL = - &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; + uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; const uint16_t bwpSize = current_BWP->BWPSize; const uint16_t bwpStart = current_BWP->BWPStart; - const int startSymbolAndLength = current_BWP->tdaList->list.array[tda]->startSymbolAndLength; + const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; int startSymbolIndex, nrOfSymbols; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); const uint16_t symb = SL_to_bitmap(startSymbolIndex, nrOfSymbols); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 988ad1d6e3..d1d70b35ce 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -303,11 +303,6 @@ long get_K2(NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList, int time_domain_assignment, int mu); -NR_tda_info_t nr_get_pdsch_tda_info(const NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList, const int tda); - -NR_tda_info_t nr_get_pusch_tda_info(const NR_UE_UL_BWP_t *ul_bwp, - const int tda); - NR_pusch_dmrs_t get_ul_dmrs_params(const NR_ServingCellConfigCommon_t *scc, const NR_UE_UL_BWP_t *ul_bwp, const NR_tda_info_t *tda_info, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 22c1619ea6..2699c403ca 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -334,12 +334,6 @@ typedef struct NR_sched_pucch { int start_symb; } NR_sched_pucch_t; -typedef struct NR_tda_info { - mappingType_t mapping_type; - int startSymbolIndex; - int nrOfSymbols; -} NR_tda_info_t; - typedef struct NR_pusch_dmrs { uint8_t N_PRB_DMRS; uint8_t num_dmrs_symb;