diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index fda299898d..76252325fc 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -608,7 +608,9 @@ NR_tda_info_t get_dl_tda_info(const NR_UE_DL_BWP_t *dl_BWP, int ss_type, int tda 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; + bool normal_CP = true; + if (dl_BWP && dl_BWP->cyclicprefix) + normal_CP = false; // 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) { @@ -3708,7 +3710,6 @@ int16_t fill_dmrs_mask(const NR_PDSCH_Config_t *pdsch_Config, mappingType_t mappingtype, int length) { - int dmrs_AdditionalPosition = 0; NR_DMRS_DownlinkConfig_t *dmrs_config = NULL; @@ -4729,43 +4730,6 @@ uint16_t compute_pucch_prb_size(uint8_t format, return 0; } -int get_dlbw_tbslbrm(int scc_bwpsize, - const NR_ServingCellConfig_t *servingCellConfig) -{ - int bw = scc_bwpsize; - if (servingCellConfig) { - if(servingCellConfig->downlinkBWP_ToAddModList) { - const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *BWP_list = servingCellConfig->downlinkBWP_ToAddModList; - for (int i=0; ilist.count; i++) { - NR_BWP_t genericParameters = BWP_list->list.array[i]->bwp_Common->genericParameters; - int curr_bw = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - if (curr_bw > bw) - bw = curr_bw; - } - } - } - return bw; -} - -int get_ulbw_tbslbrm(int scc_bwpsize, - const NR_ServingCellConfig_t *servingCellConfig) -{ - int bw = scc_bwpsize; - if (servingCellConfig) { - if (servingCellConfig->uplinkConfig && - servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList) { - const struct NR_UplinkConfig__uplinkBWP_ToAddModList *BWP_list = servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList; - for (int i=0; ilist.count; i++) { - NR_BWP_t genericParameters = BWP_list->list.array[i]->bwp_Common->genericParameters; - int curr_bw = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - if (curr_bw > bw) - bw = curr_bw; - } - } - } - return bw; -} - /* extract UL PTRS values from RRC and validate it based upon 38.214 6.2.3 */ bool set_ul_ptrs_values(NR_PTRS_UplinkConfig_t *ul_ptrs_config, uint16_t rbSize,uint8_t mcsIndex, uint8_t mcsTable, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 5ff8e6ceba..315cc9837b 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -196,12 +196,6 @@ uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); uint16_t get_nr_srs_offset(NR_SRS_PeriodicityAndOffset_t periodicityAndOffset); -int get_dlbw_tbslbrm(int scc_bwpsize, - const NR_ServingCellConfig_t *servingCellConfig); - -int get_ulbw_tbslbrm(int scc_bwpsize, - const NR_ServingCellConfig_t *servingCellConfig); - uint32_t nr_compute_tbslbrm(uint16_t table, uint16_t nb_rb, uint8_t Nl); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index d2fbd8d851..7f49ea096a 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -484,18 +484,70 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, } } +void release_common_ss_cset(NR_BWP_PDCCH_t *pdcch) +{ + if (pdcch->otherSI_SS) { + ASN_STRUCT_FREE(asn_DEF_NR_SearchSpace, + pdcch->otherSI_SS); + pdcch->otherSI_SS = NULL; + } + if (pdcch->ra_SS) { + ASN_STRUCT_FREE(asn_DEF_NR_SearchSpace, + pdcch->ra_SS); + pdcch->otherSI_SS = NULL; + } + if (pdcch->paging_SS) { + ASN_STRUCT_FREE(asn_DEF_NR_SearchSpace, + pdcch->paging_SS); + pdcch->paging_SS = NULL; + } + if (pdcch->commonControlResourceSet) { + ASN_STRUCT_FREE(asn_DEF_NR_ControlResourceSet, + pdcch->commonControlResourceSet); + pdcch->commonControlResourceSet = NULL; + } +} + +void modlist_ss(NR_SearchSpace_t *source, NR_SearchSpace_t *target) +{ + target->searchSpaceId = source->searchSpaceId; + if (source->controlResourceSetId) + updateMACie(target->controlResourceSetId, + source->controlResourceSetId, + NR_ControlResourceSetId_t); + if (source->monitoringSlotPeriodicityAndOffset) + updateMACie(target->monitoringSlotPeriodicityAndOffset, + source->monitoringSlotPeriodicityAndOffset, + struct NR_SearchSpace__monitoringSlotPeriodicityAndOffset); + updateMACie(target->duration, + source->duration, + long); + if (source->monitoringSymbolsWithinSlot) + updateMACie(target->monitoringSymbolsWithinSlot, + source->monitoringSymbolsWithinSlot, + BIT_STRING_t); + if (source->nrofCandidates) + updateMACie(target->nrofCandidates, + source->nrofCandidates, + struct NR_SearchSpace__nrofCandidates); + if (source->searchSpaceType) + updateMACie(target->searchSpaceType, + source->searchSpaceType, + struct NR_SearchSpace__searchSpaceType); +} NR_SearchSpace_t *get_common_search_space(const struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList, - const NR_UE_MAC_INST_t *mac, + const NR_BWP_PDCCH_t *pdcch, const NR_SearchSpaceId_t ss_id) { if (ss_id == 0) - return mac->search_space_zero; + return pdcch->search_space_zero; NR_SearchSpace_t *css = NULL; for (int i = 0; i < commonSearchSpaceList->list.count; i++) { if (commonSearchSpaceList->list.array[i]->searchSpaceId == ss_id) { - css = commonSearchSpaceList->list.array[i]; + css = calloc(1, sizeof(*css)); + modlist_ss(commonSearchSpaceList->list.array[i], css); break; } } @@ -503,67 +555,172 @@ NR_SearchSpace_t *get_common_search_space(const struct NR_PDCCH_ConfigCommon__co return css; } -void configure_ss_coreset(NR_UE_MAC_INST_t *mac, - const NR_PDCCH_ConfigCommon_t *pdcch_ConfigCommon, - const NR_PDCCH_Config_t *pdcch_Config) +void configure_common_ss_coreset(NR_BWP_PDCCH_t *pdcch, + NR_PDCCH_ConfigCommon_t *pdcch_ConfigCommon) { - - // configuration of search spaces if (pdcch_ConfigCommon) { - mac->otherSI_SS = pdcch_ConfigCommon->searchSpaceOtherSystemInformation ? - get_common_search_space(pdcch_ConfigCommon->commonSearchSpaceList, mac, - *pdcch_ConfigCommon->searchSpaceOtherSystemInformation) : - NULL; - mac->ra_SS = pdcch_ConfigCommon->ra_SearchSpace ? - get_common_search_space(pdcch_ConfigCommon->commonSearchSpaceList, mac, - *pdcch_ConfigCommon->ra_SearchSpace) : - NULL; - mac->paging_SS = pdcch_ConfigCommon->pagingSearchSpace ? - get_common_search_space(pdcch_ConfigCommon->commonSearchSpaceList, mac, - *pdcch_ConfigCommon->pagingSearchSpace) : - NULL; - } - if(pdcch_Config && - pdcch_Config->searchSpacesToAddModList) { - int ss_configured = 0; - struct NR_PDCCH_Config__searchSpacesToAddModList *searchSpacesToAddModList = pdcch_Config->searchSpacesToAddModList; - for (int i = 0; i < searchSpacesToAddModList->list.count; i++) { - AssertFatal(ss_configured < FAPI_NR_MAX_SS, "Attempting to configure %d SS but only %d per BWP are allowed", - ss_configured + 1, FAPI_NR_MAX_SS); - mac->BWP_searchspaces[ss_configured] = searchSpacesToAddModList->list.array[i]; - ss_configured++; - } - for (int i = ss_configured; i < FAPI_NR_MAX_SS; i++) - mac->BWP_searchspaces[i] = NULL; - } + ASN_STRUCT_FREE(asn_DEF_NR_SearchSpace, + pdcch->otherSI_SS); + pdcch->otherSI_SS = NULL; + if (pdcch_ConfigCommon->searchSpaceOtherSystemInformation) + pdcch->otherSI_SS = get_common_search_space(pdcch_ConfigCommon->commonSearchSpaceList, + pdcch, + *pdcch_ConfigCommon->searchSpaceOtherSystemInformation); - // configuration of coresets - int cset_configured = 0; - int common_cset_id = -1; - if (pdcch_ConfigCommon && - pdcch_ConfigCommon->commonControlResourceSet) { - mac->BWP_coresets[cset_configured] = pdcch_ConfigCommon->commonControlResourceSet; - common_cset_id = pdcch_ConfigCommon->commonControlResourceSet->controlResourceSetId; - cset_configured++; + ASN_STRUCT_FREE(asn_DEF_NR_SearchSpace, + pdcch->ra_SS); + pdcch->ra_SS = NULL; + if (pdcch_ConfigCommon->ra_SearchSpace) { + if (pdcch->otherSI_SS && + *pdcch_ConfigCommon->ra_SearchSpace == pdcch->otherSI_SS->searchSpaceId) + pdcch->ra_SS = pdcch->otherSI_SS; + else + pdcch->ra_SS = get_common_search_space(pdcch_ConfigCommon->commonSearchSpaceList, + pdcch, + *pdcch_ConfigCommon->ra_SearchSpace); + } + + ASN_STRUCT_FREE(asn_DEF_NR_SearchSpace, + pdcch->paging_SS); + pdcch->paging_SS = NULL; + if (pdcch_ConfigCommon->pagingSearchSpace) { + if (pdcch->otherSI_SS && + *pdcch_ConfigCommon->pagingSearchSpace == pdcch->otherSI_SS->searchSpaceId) + pdcch->paging_SS = pdcch->otherSI_SS; + else if (pdcch->ra_SS && + *pdcch_ConfigCommon->pagingSearchSpace == pdcch->ra_SS->searchSpaceId) + pdcch->paging_SS = pdcch->ra_SS; + if (!pdcch->paging_SS) + pdcch->paging_SS = get_common_search_space(pdcch_ConfigCommon->commonSearchSpaceList, pdcch, + *pdcch_ConfigCommon->pagingSearchSpace); + } + + updateMACie(pdcch->commonControlResourceSet, + pdcch_ConfigCommon->commonControlResourceSet, + NR_ControlResourceSet_t); } - if(pdcch_Config && - pdcch_Config->controlResourceSetToAddModList) { - struct NR_PDCCH_Config__controlResourceSetToAddModList *controlResourceSetToAddModList = pdcch_Config->controlResourceSetToAddModList; - for (int i = 0; i < controlResourceSetToAddModList->list.count; i++) { - AssertFatal(cset_configured < FAPI_NR_MAX_CORESET_PER_BWP, "Attempting to configure %d CORESET but only %d per BWP are allowed", - cset_configured + 1, FAPI_NR_MAX_CORESET_PER_BWP); - // In case network reconfigures control resource set with the same ControlResourceSetId as used for commonControlResourceSet - // configured via PDCCH-ConfigCommon, the configuration from PDCCH-Config always takes precedence - if (controlResourceSetToAddModList->list.array[i]->controlResourceSetId == common_cset_id) - mac->BWP_coresets[0] = controlResourceSetToAddModList->list.array[i]; - else { - mac->BWP_coresets[cset_configured] = controlResourceSetToAddModList->list.array[i]; - cset_configured++; +} + +void modlist_coreset(NR_ControlResourceSet_t *source, NR_ControlResourceSet_t *target) +{ + target->controlResourceSetId = source->controlResourceSetId; + target->frequencyDomainResources.size = source->frequencyDomainResources.size; + target->frequencyDomainResources.buf = calloc(target->frequencyDomainResources.size, + sizeof(*target->frequencyDomainResources.buf)); + for (int i = 0; i < source->frequencyDomainResources.size; i++) + target->frequencyDomainResources.buf[i] = source->frequencyDomainResources.buf[i]; + target->duration = source->duration; + target->precoderGranularity = source->precoderGranularity; + long *shiftIndex = NULL; + if (target->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved) + shiftIndex = target->cce_REG_MappingType.choice.interleaved->shiftIndex; + if (source->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved) { + target->cce_REG_MappingType.present = NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved; + target->cce_REG_MappingType.choice.interleaved->reg_BundleSize = source->cce_REG_MappingType.choice.interleaved->reg_BundleSize; + target->cce_REG_MappingType.choice.interleaved->interleaverSize = source->cce_REG_MappingType.choice.interleaved->interleaverSize; + updateMACie(target->cce_REG_MappingType.choice.interleaved->shiftIndex, + source->cce_REG_MappingType.choice.interleaved->shiftIndex, + long); + } + else { + if (shiftIndex) + free(shiftIndex); + target->cce_REG_MappingType = source->cce_REG_MappingType; + } + updateMACie(target->tci_PresentInDCI, + source->tci_PresentInDCI, + long); + updateMACie(target->pdcch_DMRS_ScramblingID, + source->pdcch_DMRS_ScramblingID, + long); + // TCI States + if (source->tci_StatesPDCCH_ToReleaseList) { + for (int i = 0; i < source->tci_StatesPDCCH_ToReleaseList->list.count; i++) { + long id = *source->tci_StatesPDCCH_ToReleaseList->list.array[i]; + int j; + for (j = 0; j < target->tci_StatesPDCCH_ToAddList->list.count; j++) { + if(id == *target->tci_StatesPDCCH_ToAddList->list.array[j]) + break; + } + if (j < target->tci_StatesPDCCH_ToAddList->list.count) + asn_sequence_del(&target->tci_StatesPDCCH_ToAddList->list, j, 1); + else + LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); + } + } + if (source->tci_StatesPDCCH_ToAddList) { + if (target->tci_StatesPDCCH_ToAddList) + for (int i = 0; source->tci_StatesPDCCH_ToAddList->list.count; i++) + ASN_SEQUENCE_ADD(&target->tci_StatesPDCCH_ToAddList->list, source->tci_StatesPDCCH_ToAddList->list.array[i]); + else + updateMACie(target->tci_StatesPDCCH_ToAddList, + source->tci_StatesPDCCH_ToAddList, + struct NR_ControlResourceSet__tci_StatesPDCCH_ToAddList); + } + // end TCI States +} + +void configure_ss_coreset(NR_BWP_PDCCH_t *pdcch, + NR_PDCCH_Config_t *pdcch_Config) +{ + if(!pdcch_Config) + return; + if(pdcch_Config->controlResourceSetToAddModList) { + for (int i = 0; i < pdcch_Config->controlResourceSetToAddModList->list.count; i++) { + NR_ControlResourceSet_t *source_coreset = pdcch_Config->controlResourceSetToAddModList->list.array[i]; + NR_ControlResourceSet_t *target_coreset = NULL; + for (int j = 0; j < pdcch->list_Coreset.count; j++) { + if (pdcch->list_Coreset.array[j]->controlResourceSetId == source_coreset->controlResourceSetId) { + target_coreset = pdcch->list_Coreset.array[j]; + break; + } + } + if (!target_coreset) { + target_coreset = calloc(1, sizeof(*target_coreset)); + ASN_SEQUENCE_ADD(&pdcch->list_Coreset, target_coreset); + } + modlist_coreset(source_coreset, target_coreset); + } + } + if(pdcch_Config->controlResourceSetToReleaseList) { + for (int i = 0; i < pdcch_Config->controlResourceSetToReleaseList->list.count; i++) { + NR_ControlResourceSetId_t id = *pdcch_Config->controlResourceSetToReleaseList->list.array[i]; + for (int j = 0; j < pdcch->list_Coreset.count; j++) { + if (id == pdcch->list_Coreset.array[j]->controlResourceSetId) { + asn_sequence_del(&pdcch->list_Coreset, j, 1); + break; + } + } + } + } + if(pdcch_Config->searchSpacesToAddModList) { + for (int i = 0; i < pdcch_Config->searchSpacesToAddModList->list.count; i++) { + NR_SearchSpace_t *source_ss = pdcch_Config->searchSpacesToAddModList->list.array[i]; + NR_SearchSpace_t *target_ss = NULL; + for (int j = 0; j < pdcch->list_SS.count; j++) { + if (pdcch->list_SS.array[j]->searchSpaceId == source_ss->searchSpaceId) { + target_ss = pdcch->list_SS.array[j]; + break; + } + } + if (!target_ss) { + target_ss = calloc(1, sizeof(*target_ss)); + ASN_SEQUENCE_ADD(&pdcch->list_SS, target_ss); + } + modlist_ss(source_ss, target_ss); + } + } + if(pdcch_Config->searchSpacesToReleaseList) { + for (int i = 0; i < pdcch_Config->searchSpacesToReleaseList->list.count; i++) { + NR_ControlResourceSetId_t id = *pdcch_Config->searchSpacesToReleaseList->list.array[i]; + for (int j = 0; j < pdcch->list_SS.count; j++) { + if (id == pdcch->list_SS.array[j]->searchSpaceId) { + asn_sequence_del(&pdcch->list_SS, j, 1); + break; + } } } } - for (int i = cset_configured; i < FAPI_NR_MAX_CORESET_PER_BWP; i++) - mac->BWP_coresets[i] = NULL; } static int lcid_cmp(const void *lc1, const void *lc2, void *mac_inst) @@ -584,8 +741,9 @@ void nr_release_mac_config_logicalChannelBearer(module_id_t module_id, long chan { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); if (mac->logicalChannelConfig[channel_identity - 1] != NULL) { + ASN_STRUCT_FREE(asn_DEF_NR_LogicalChannelConfig, + mac->logicalChannelConfig[channel_identity - 1]); mac->logicalChannelConfig[channel_identity - 1] = NULL; - memset(&mac->scheduling_info.lc_sched_info[channel_identity - 1], 0, sizeof(NR_LC_SCHEDULING_INFO)); } else { LOG_E(NR_MAC, "Trying to release a non configured logical channel bearer %li\n", channel_identity); } @@ -664,7 +822,7 @@ void nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id, NR_RLC_BearerConfig_t *rlc_bearer = rlc_toadd_list->list.array[i]; int lc_identity = rlc_bearer->logicalChannelIdentity; mac->lc_ordered_info[i].lcids_ordered = lc_identity; - NR_LogicalChannelConfig_t *mac_lc_config; + NR_LogicalChannelConfig_t *mac_lc_config = NULL; if (mac->logicalChannelConfig[lc_identity - 1] == NULL) { /* setup of new LCID*/ LOG_D(NR_MAC, "Establishing the logical channel %d\n", lc_identity); @@ -672,7 +830,9 @@ void nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id, if (rlc_bearer->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity) { /* SRB */ NR_SRB_Identity_t srb_id = rlc_bearer->servedRadioBearer->choice.srb_Identity; if (rlc_bearer->mac_LogicalChannelConfig != NULL) { - mac_lc_config = rlc_bearer->mac_LogicalChannelConfig; + updateMACie(mac_lc_config, + rlc_bearer->mac_LogicalChannelConfig, + NR_LogicalChannelConfig_t); } else { LOG_I(NR_RRC, "Applying the default logicalChannelConfig for SRB\n"); if (srb_id == 1) @@ -692,7 +852,9 @@ void nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id, /* LC is already established, reconfiguring the LC */ LOG_D(NR_MAC, "Logical channel %d is already established, Reconfiguring now\n", lc_identity); if (rlc_bearer->mac_LogicalChannelConfig != NULL) { - mac_lc_config = rlc_bearer->mac_LogicalChannelConfig; + updateMACie(mac_lc_config, + rlc_bearer->mac_LogicalChannelConfig, + NR_LogicalChannelConfig_t); } else { /* Need M - Maintains current value */ continue; @@ -707,137 +869,6 @@ void nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id, } } -void configure_current_BWP(NR_UE_MAC_INST_t *mac, - NR_ServingCellConfigCommonSIB_t *scc, - const NR_ServingCellConfig_t *spCellConfigDedicated) -{ - NR_UE_DL_BWP_t *DL_BWP = &mac->current_DL_BWP; - NR_UE_UL_BWP_t *UL_BWP = &mac->current_UL_BWP; - NR_BWP_t dl_genericParameters = {0}; - NR_BWP_t ul_genericParameters = {0}; - - if(scc) { - DL_BWP->bwp_id = 0; - UL_BWP->bwp_id = 0; - mac->bwp_dlcommon = &scc->downlinkConfigCommon.initialDownlinkBWP; - mac->bwp_ulcommon = &scc->uplinkConfigCommon->initialUplinkBWP; - dl_genericParameters = mac->bwp_dlcommon->genericParameters; - if(mac->bwp_ulcommon) - ul_genericParameters = mac->bwp_ulcommon->genericParameters; - else - ul_genericParameters = mac->bwp_dlcommon->genericParameters; - - if (mac->bwp_dlcommon->pdsch_ConfigCommon) - DL_BWP->tdaList_Common = mac->bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - if (mac->bwp_ulcommon->pusch_ConfigCommon) { - UL_BWP->tdaList_Common = mac->bwp_ulcommon->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - UL_BWP->msg3_DeltaPreamble = mac->bwp_ulcommon->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble; - } - if (mac->bwp_ulcommon->pucch_ConfigCommon) - UL_BWP->pucch_ConfigCommon = mac->bwp_ulcommon->pucch_ConfigCommon->choice.setup; - if (mac->bwp_ulcommon->rach_ConfigCommon) { - UL_BWP->rach_ConfigCommon = mac->bwp_ulcommon->rach_ConfigCommon->choice.setup; - // Setup the SSB to Rach Occasions mapping according to the config - build_ssb_to_ro_map(mac); - } - if (mac->bwp_dlcommon->pdcch_ConfigCommon) - configure_ss_coreset(mac, mac->bwp_dlcommon->pdcch_ConfigCommon->choice.setup, NULL); - } - - if(spCellConfigDedicated) { - if (spCellConfigDedicated->firstActiveDownlinkBWP_Id) - DL_BWP->bwp_id = *spCellConfigDedicated->firstActiveDownlinkBWP_Id; - if (spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id) - UL_BWP->bwp_id = *spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id; - - 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]; - if(bwp_downlink->bwp_Id == DL_BWP->bwp_id) - break; - } - 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_Common = bwp_downlink->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - configure_ss_coreset(mac, - bwp_downlink->bwp_Common->pdcch_ConfigCommon ? bwp_downlink->bwp_Common->pdcch_ConfigCommon->choice.setup : NULL, - bwp_downlink->bwp_Dedicated->pdcch_Config ? bwp_downlink->bwp_Dedicated->pdcch_Config->choice.setup : NULL); - - } - else { - dl_genericParameters = mac->bwp_dlcommon->genericParameters; - DL_BWP->pdsch_Config = spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup; - DL_BWP->tdaList_Common = mac->bwp_dlcommon->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - configure_ss_coreset(mac, - mac->bwp_dlcommon->pdcch_ConfigCommon ? mac->bwp_dlcommon->pdcch_ConfigCommon->choice.setup : NULL, - spCellConfigDedicated->initialDownlinkBWP->pdcch_Config ? spCellConfigDedicated->initialDownlinkBWP->pdcch_Config->choice.setup : NULL); - } - - UL_BWP->msg3_DeltaPreamble = mac->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]; - if(bwp_uplink->bwp_Id == UL_BWP->bwp_id) - break; - } - 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_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; - 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; - // Setup the SSB to Rach Occasions mapping according to the config - build_ssb_to_ro_map(mac); - } - } - else { - UL_BWP->tdaList_Common = mac->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; - UL_BWP->configuredGrantConfig = - spCellConfigDedicated->uplinkConfig->initialUplinkBWP->configuredGrantConfig ? spCellConfigDedicated->uplinkConfig->initialUplinkBWP->configuredGrantConfig->choice.setup : NULL; - ul_genericParameters = mac->bwp_ulcommon->genericParameters; - if (mac->bwp_ulcommon->pucch_ConfigCommon) - UL_BWP->pucch_ConfigCommon = mac->bwp_ulcommon->pucch_ConfigCommon->choice.setup; - if (mac->bwp_ulcommon->rach_ConfigCommon) - UL_BWP->rach_ConfigCommon = mac->bwp_ulcommon->rach_ConfigCommon->choice.setup; - } - } - - DL_BWP->scs = dl_genericParameters.subcarrierSpacing; - DL_BWP->cyclicprefix = dl_genericParameters.cyclicPrefix; - DL_BWP->BWPSize = NRRIV2BW(dl_genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - DL_BWP->BWPStart = NRRIV2PRBOFFSET(dl_genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - UL_BWP->scs = ul_genericParameters.subcarrierSpacing; - UL_BWP->cyclicprefix = ul_genericParameters.cyclicPrefix; - UL_BWP->BWPSize = NRRIV2BW(ul_genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - UL_BWP->BWPStart = NRRIV2PRBOFFSET(ul_genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - - DL_BWP->initial_BWPSize = NRRIV2BW(mac->bwp_dlcommon->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - UL_BWP->initial_BWPSize = NRRIV2BW(mac->bwp_ulcommon->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - DL_BWP->initial_BWPStart = NRRIV2PRBOFFSET(mac->bwp_dlcommon->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - UL_BWP->initial_BWPStart = NRRIV2PRBOFFSET(mac->bwp_ulcommon->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - - DL_BWP->bw_tbslbrm = get_dlbw_tbslbrm(DL_BWP->initial_BWPSize, spCellConfigDedicated); - UL_BWP->bw_tbslbrm = get_ulbw_tbslbrm(UL_BWP->initial_BWPSize, spCellConfigDedicated); -} - void ue_init_config_request(NR_UE_MAC_INST_t *mac, int scs) { int slots_per_frame = nr_slots_per_frame[scs]; @@ -867,6 +898,843 @@ void nr_rrc_mac_config_req_mib(module_id_t module_id, cc_idP); } +void setup_puschpowercontrol(NR_PUSCH_PowerControl_t *source, NR_PUSCH_PowerControl_t *target) +{ + updateMACie(target->tpc_Accumulation, + source->tpc_Accumulation, + long); + updateMACie(target->msg3_Alpha, + source->msg3_Alpha, + NR_Alpha_t); + if (source->p0_NominalWithoutGrant) + updateMACie(target->p0_NominalWithoutGrant, + source->p0_NominalWithoutGrant, + long); + if (source->p0_AlphaSets) + updateMACie(target->p0_AlphaSets, + source->p0_AlphaSets, + struct NR_PUSCH_PowerControl__p0_AlphaSets); + updateMACie(target->twoPUSCH_PC_AdjustmentStates, + source->twoPUSCH_PC_AdjustmentStates, + long); + updateMACie(target->deltaMCS, + source->deltaMCS, + long); + if (source->pathlossReferenceRSToReleaseList) { + for (int i = 0; i < source->pathlossReferenceRSToReleaseList->list.count; i++) { + long id = *source->pathlossReferenceRSToReleaseList->list.array[i]; + int j; + for (j = 0; j < target->pathlossReferenceRSToAddModList->list.count; j++) { + if(id == target->pathlossReferenceRSToAddModList->list.array[j]->pusch_PathlossReferenceRS_Id) + break; + } + if (j < target->pathlossReferenceRSToAddModList->list.count) + asn_sequence_del(&target->pathlossReferenceRSToAddModList->list, j, 1); + else + LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); + } + } + if (source->pathlossReferenceRSToAddModList) { + if (!target->pathlossReferenceRSToAddModList) + target->pathlossReferenceRSToAddModList = calloc(1, sizeof(*target->pathlossReferenceRSToAddModList)); + for (int i = 0; i < source->pathlossReferenceRSToAddModList->list.count; i++) { + long id = source->pathlossReferenceRSToAddModList->list.array[i]->pusch_PathlossReferenceRS_Id; + int j; + for (j = 0; j < target->pathlossReferenceRSToAddModList->list.count; j++) { + if(id == target->pathlossReferenceRSToAddModList->list.array[j]->pusch_PathlossReferenceRS_Id) + break; + } + if (j == target->pathlossReferenceRSToAddModList->list.count) { + NR_PUSCH_PathlossReferenceRS_t *rs = calloc(1, sizeof(*rs)); + ASN_SEQUENCE_ADD(&target->pathlossReferenceRSToAddModList->list, rs); + } + updateMACie(target->pathlossReferenceRSToAddModList->list.array[j], + source->pathlossReferenceRSToAddModList->list.array[i], + NR_PUSCH_PathlossReferenceRS_t); + } + } + if (source->sri_PUSCH_MappingToReleaseList) { + for (int i = 0; i < source->sri_PUSCH_MappingToReleaseList->list.count; i++) { + long id = *source->sri_PUSCH_MappingToReleaseList->list.array[i]; + int j; + for (j = 0; j < target->sri_PUSCH_MappingToAddModList->list.count; j++) { + if(id == target->sri_PUSCH_MappingToAddModList->list.array[j]->sri_PUSCH_PowerControlId) + break; + } + if (j < target->sri_PUSCH_MappingToAddModList->list.count) + asn_sequence_del(&target->sri_PUSCH_MappingToAddModList->list, j, 1); + else + LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); + } + } + if (source->sri_PUSCH_MappingToAddModList) { + if (!target->sri_PUSCH_MappingToAddModList) + target->sri_PUSCH_MappingToAddModList = calloc(1, sizeof(*target->sri_PUSCH_MappingToAddModList)); + for (int i = 0; i < source->sri_PUSCH_MappingToAddModList->list.count; i++) { + long id = source->sri_PUSCH_MappingToAddModList->list.array[i]->sri_PUSCH_PowerControlId; + int j; + for (j = 0; j < target->sri_PUSCH_MappingToAddModList->list.count; j++) { + if(id == target->sri_PUSCH_MappingToAddModList->list.array[j]->sri_PUSCH_PowerControlId) + break; + } + if (j == target->sri_PUSCH_MappingToAddModList->list.count) { + NR_SRI_PUSCH_PowerControl_t *rs = calloc(1, sizeof(*rs)); + ASN_SEQUENCE_ADD(&target->sri_PUSCH_MappingToAddModList->list, rs); + } + updateMACie(target->sri_PUSCH_MappingToAddModList->list.array[j], + source->sri_PUSCH_MappingToAddModList->list.array[i], + NR_SRI_PUSCH_PowerControl_t); + } + } +} + +void setup_puschconfig(NR_PUSCH_Config_t *source, NR_PUSCH_Config_t *target) +{ + updateMACie(target->dataScramblingIdentityPUSCH, + source->dataScramblingIdentityPUSCH, + long); + updateMACie(target->txConfig, + source->txConfig, + long); + if (source->dmrs_UplinkForPUSCH_MappingTypeA) + handleMACsetupreleaseElement(target->dmrs_UplinkForPUSCH_MappingTypeA, + source->dmrs_UplinkForPUSCH_MappingTypeA, + NR_DMRS_UplinkConfig_t, + asn_DEF_NR_SetupRelease_DMRS_UplinkConfig); + if (source->dmrs_UplinkForPUSCH_MappingTypeB) + handleMACsetupreleaseElement(target->dmrs_UplinkForPUSCH_MappingTypeB, + source->dmrs_UplinkForPUSCH_MappingTypeB, + NR_DMRS_UplinkConfig_t, + asn_DEF_NR_SetupRelease_DMRS_UplinkConfig); + if (source->pusch_PowerControl) { + if (!target->pusch_PowerControl) + target->pusch_PowerControl = calloc(1, sizeof(*target->pusch_PowerControl)); + setup_puschpowercontrol(source->pusch_PowerControl, target->pusch_PowerControl); + } + updateMACie(target->frequencyHopping, + source->frequencyHopping, + long); + if (source->frequencyHoppingOffsetLists) + updateMACie(target->frequencyHoppingOffsetLists, + source->frequencyHoppingOffsetLists, + struct NR_PUSCH_Config__frequencyHoppingOffsetLists); + target->resourceAllocation = source->resourceAllocation; + if(source->pusch_TimeDomainAllocationList) + handleMACsetupreleaseElement(target->pusch_TimeDomainAllocationList, + source->pusch_TimeDomainAllocationList, + NR_PUSCH_TimeDomainResourceAllocationList_t, + asn_DEF_NR_SetupRelease_PUSCH_TimeDomainResourceAllocationList); + updateMACie(target->pusch_AggregationFactor, + source->pusch_AggregationFactor, + long); + updateMACie(target->mcs_Table, + source->mcs_Table, + long); + updateMACie(target->mcs_TableTransformPrecoder, + source->mcs_TableTransformPrecoder, + long); + updateMACie(target->transformPrecoder, + source->transformPrecoder, + long); + updateMACie(target->codebookSubset, + source->codebookSubset, + long); + updateMACie(target->maxRank, + source->maxRank, + long); + updateMACie(target->rbg_Size, + source->rbg_Size, + long); + updateMACie(target->tp_pi2BPSK, + source->tp_pi2BPSK, + long); + if (source->uci_OnPUSCH) { + if (source->uci_OnPUSCH->present == + NR_SetupRelease_UCI_OnPUSCH_PR_release) { + ASN_STRUCT_FREE(asn_DEF_NR_UCI_OnPUSCH, + target->uci_OnPUSCH); + target->uci_OnPUSCH = NULL; + } + if (source->uci_OnPUSCH->present == + NR_SetupRelease_UCI_OnPUSCH_PR_setup) { + if (target->uci_OnPUSCH) { + target->uci_OnPUSCH->choice.setup->scaling = source->uci_OnPUSCH->choice.setup->scaling; + if (source->uci_OnPUSCH->choice.setup->betaOffsets) + updateMACie(target->uci_OnPUSCH->choice.setup->betaOffsets, + source->uci_OnPUSCH->choice.setup->betaOffsets, + struct NR_UCI_OnPUSCH__betaOffsets); + } + } + } +} + +void setup_pdschconfig(NR_PDSCH_Config_t *source, NR_PDSCH_Config_t *target) +{ + updateMACie(target->dataScramblingIdentityPDSCH, + source->dataScramblingIdentityPDSCH, + long); + if (source->dmrs_DownlinkForPDSCH_MappingTypeA) + handleMACsetupreleaseElement(target->dmrs_DownlinkForPDSCH_MappingTypeA, + source->dmrs_DownlinkForPDSCH_MappingTypeA, + NR_DMRS_DownlinkConfig_t, + asn_DEF_NR_SetupRelease_DMRS_DownlinkConfig); + if (source->dmrs_DownlinkForPDSCH_MappingTypeB) + handleMACsetupreleaseElement(target->dmrs_DownlinkForPDSCH_MappingTypeB, + source->dmrs_DownlinkForPDSCH_MappingTypeB, + NR_DMRS_DownlinkConfig_t, + asn_DEF_NR_SetupRelease_DMRS_DownlinkConfig); + // TCI States + if (source->tci_StatesToReleaseList) { + for (int i = 0; i < source->tci_StatesToReleaseList->list.count; i++) { + long id = *source->tci_StatesToReleaseList->list.array[i]; + int j; + for (j = 0; j < target->tci_StatesToAddModList->list.count; j++) { + if(id == target->tci_StatesToAddModList->list.array[j]->tci_StateId) + break; + } + if (j < target->tci_StatesToAddModList->list.count) + asn_sequence_del(&target->tci_StatesToAddModList->list, j, 1); + else + LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); + } + } + if (source->tci_StatesToAddModList) { + if (!target->tci_StatesToAddModList) + target->tci_StatesToAddModList = calloc(1, sizeof(*target->tci_StatesToAddModList)); + for (int i = 0; i < source->tci_StatesToAddModList->list.count; i++) { + long id = source->tci_StatesToAddModList->list.array[i]->tci_StateId; + int j; + for (j = 0; j < target->tci_StatesToAddModList->list.count; j++) { + if(id == target->tci_StatesToAddModList->list.array[j]->tci_StateId) + break; + } + if (j == target->tci_StatesToAddModList->list.count) { + NR_TCI_State_t *tci = calloc(1, sizeof(*tci)); + ASN_SEQUENCE_ADD(&target->tci_StatesToAddModList->list, tci); + } + updateMACie(target->tci_StatesToAddModList->list.array[j], + source->tci_StatesToAddModList->list.array[i], + NR_TCI_State_t); + } + } + // end TCI States + updateMACie(target->vrb_ToPRB_Interleaver, + source->vrb_ToPRB_Interleaver, + long); + target->resourceAllocation = source->resourceAllocation; + if (source->pdsch_TimeDomainAllocationList) + handleMACsetupreleaseElement(target->pdsch_TimeDomainAllocationList, + source->pdsch_TimeDomainAllocationList, + NR_PDSCH_TimeDomainResourceAllocationList_t, + asn_DEF_NR_SetupRelease_PDSCH_TimeDomainResourceAllocationList); + updateMACie(target->pdsch_AggregationFactor, + source->pdsch_AggregationFactor, + long); + // rateMatchPattern + if (source->rateMatchPatternToReleaseList) { + for (int i = 0; i < source->rateMatchPatternToReleaseList->list.count; i++) { + long id = *source->rateMatchPatternToReleaseList->list.array[i]; + int j; + for (j = 0; j < target->rateMatchPatternToAddModList->list.count; j++) { + if(id == target->rateMatchPatternToAddModList->list.array[j]->rateMatchPatternId) + break; + } + if (j < target->rateMatchPatternToAddModList->list.count) + asn_sequence_del(&target->rateMatchPatternToAddModList->list, j, 1); + else + LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); + } + } + if (source->rateMatchPatternToAddModList) { + if (!target->rateMatchPatternToAddModList) + target->rateMatchPatternToAddModList = calloc(1, sizeof(*target->rateMatchPatternToAddModList)); + for (int i = 0; i < source->rateMatchPatternToAddModList->list.count; i++) { + long id = source->rateMatchPatternToAddModList->list.array[i]->rateMatchPatternId; + int j; + for (j = 0; j < target->rateMatchPatternToAddModList->list.count; j++) { + if(id == target->rateMatchPatternToAddModList->list.array[j]->rateMatchPatternId) + break; + } + if (j == target->rateMatchPatternToAddModList->list.count) { + NR_RateMatchPattern_t *rm = calloc(1, sizeof(*rm)); + ASN_SEQUENCE_ADD(&target->rateMatchPatternToAddModList->list, rm); + } + updateMACie(target->rateMatchPatternToAddModList->list.array[j], + source->rateMatchPatternToAddModList->list.array[i], + NR_RateMatchPattern_t); + } + } + // end rateMatchPattern + updateMACie(target->rateMatchPatternGroup1, + source->rateMatchPatternGroup1, + NR_RateMatchPatternGroup_t); + updateMACie(target->rateMatchPatternGroup2, + source->rateMatchPatternGroup2, + NR_RateMatchPatternGroup_t); + target->rbg_Size = source->rbg_Size; + updateMACie(target->mcs_Table, + source->mcs_Table, + long); + updateMACie(target->maxNrofCodeWordsScheduledByDCI, + source->maxNrofCodeWordsScheduledByDCI, + long); + target->prb_BundlingType = source->prb_BundlingType; + AssertFatal(source->zp_CSI_RS_ResourceToAddModList == NULL, + "Not handled\n"); + AssertFatal(source->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList == NULL, + "Not handled\n"); + AssertFatal(source->sp_ZP_CSI_RS_ResourceSetsToAddModList == NULL, + "Not handled\n"); +} + +void setup_sr_resource(NR_SchedulingRequestResourceConfig_t *source, + NR_SchedulingRequestResourceConfig_t *target) +{ + target->schedulingRequestResourceId = source->schedulingRequestResourceId; + target->schedulingRequestID = source->schedulingRequestID; + if (source->periodicityAndOffset) + updateMACie(target->periodicityAndOffset, + source->periodicityAndOffset, + struct NR_SchedulingRequestResourceConfig__periodicityAndOffset); + if (source->resource) + updateMACie(target->resource, + source->resource, + NR_PUCCH_ResourceId_t); +} + +void setup_pucchconfig(NR_PUCCH_Config_t *source, NR_PUCCH_Config_t *target) +{ + // PUCCH-ResourceSet + if (source->resourceSetToAddModList) { + if (!target->resourceSetToAddModList) + target->resourceSetToAddModList = calloc(1, sizeof(*target->resourceSetToAddModList)); + for (int i = 0; i < source->resourceSetToAddModList->list.count; i++) { + long id = source->resourceSetToAddModList->list.array[i]->pucch_ResourceSetId; + int j; + for (j = 0; j < target->resourceSetToAddModList->list.count; j++) { + if(id == target->resourceSetToAddModList->list.array[j]->pucch_ResourceSetId) + break; + } + if (j == target->resourceSetToAddModList->list.count) { + NR_PUCCH_ResourceSet_t *set = calloc(1, sizeof(*set)); + ASN_SEQUENCE_ADD(&target->resourceSetToAddModList->list, set); + } + updateMACie(target->resourceSetToAddModList->list.array[j], + source->resourceSetToAddModList->list.array[i], + NR_PUCCH_ResourceSet_t); + } + } + if (source->resourceSetToReleaseList) { + for (int i = 0; i < source->resourceSetToReleaseList->list.count; i++) { + long id = *source->resourceSetToReleaseList->list.array[i]; + int j; + for (j = 0; j < target->resourceSetToAddModList->list.count; j++) { + if(id == target->resourceSetToAddModList->list.array[j]->pucch_ResourceSetId) + break; + } + if (j < target->resourceSetToAddModList->list.count) + asn_sequence_del(&target->resourceSetToAddModList->list, j, 1); + else + LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); + } + } + // PUCCH-Resource + if (source->resourceToAddModList) { + if (!target->resourceToAddModList) + target->resourceToAddModList = calloc(1, sizeof(*target->resourceToAddModList)); + for (int i = 0; i < source->resourceToAddModList->list.count; i++) { + long id = source->resourceToAddModList->list.array[i]->pucch_ResourceId; + int j; + for (j = 0; j < target->resourceToAddModList->list.count; j++) { + if(id == target->resourceToAddModList->list.array[j]->pucch_ResourceId) + break; + } + if (j == target->resourceToAddModList->list.count) { + NR_PUCCH_Resource_t *res = calloc(1, sizeof(*res)); + ASN_SEQUENCE_ADD(&target->resourceToAddModList->list, res); + } + updateMACie(target->resourceToAddModList->list.array[j], + source->resourceToAddModList->list.array[i], + NR_PUCCH_Resource_t); + } + } + if (source->resourceToReleaseList) { + for (int i = 0; i < source->resourceToReleaseList->list.count; i++) { + long id = *source->resourceToReleaseList->list.array[i]; + int j; + for (j = 0; j < target->resourceToAddModList->list.count; j++) { + if(id == target->resourceToAddModList->list.array[j]->pucch_ResourceId) + break; + } + if (j < target->resourceToAddModList->list.count) + asn_sequence_del(&target->resourceToAddModList->list, j, 1); + else + LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); + } + } + // PUCCH-FormatConfig + if (source->format1) + handleMACsetupreleaseElement(target->format1, + source->format1, + NR_PUCCH_FormatConfig_t, + asn_DEF_NR_SetupRelease_PUCCH_FormatConfig); + if (source->format2) + handleMACsetupreleaseElement(target->format2, + source->format2, + NR_PUCCH_FormatConfig_t, + asn_DEF_NR_SetupRelease_PUCCH_FormatConfig); + if (source->format3) + handleMACsetupreleaseElement(target->format3, + source->format3, + NR_PUCCH_FormatConfig_t, + asn_DEF_NR_SetupRelease_PUCCH_FormatConfig); + if (source->format4) + handleMACsetupreleaseElement(target->format4, + source->format4, + NR_PUCCH_FormatConfig_t, + asn_DEF_NR_SetupRelease_PUCCH_FormatConfig); + // SchedulingRequestResourceConfig + if (source->schedulingRequestResourceToAddModList) { + if (!target->schedulingRequestResourceToAddModList) + target->schedulingRequestResourceToAddModList = calloc(1, sizeof(*target->schedulingRequestResourceToAddModList)); + for (int i = 0; i < source->schedulingRequestResourceToAddModList->list.count; i++) { + long id = source->schedulingRequestResourceToAddModList->list.array[i]->schedulingRequestResourceId; + int j; + for (j = 0; j < target->schedulingRequestResourceToAddModList->list.count; j++) { + if(id == target->schedulingRequestResourceToAddModList->list.array[j]->schedulingRequestResourceId) + break; + } + if (j == target->schedulingRequestResourceToAddModList->list.count) { + NR_SchedulingRequestResourceConfig_t *res = calloc(1, sizeof(*res)); + ASN_SEQUENCE_ADD(&target->schedulingRequestResourceToAddModList->list, res); + } + setup_sr_resource(source->schedulingRequestResourceToAddModList->list.array[i], + target->schedulingRequestResourceToAddModList->list.array[j]); + } + } + if (source->schedulingRequestResourceToReleaseList) { + for (int i = 0; i < source->schedulingRequestResourceToReleaseList->list.count; i++) { + long id = *source->schedulingRequestResourceToReleaseList->list.array[i]; + int j; + for (j = 0; j < target->schedulingRequestResourceToAddModList->list.count; j++) { + if(id == target->schedulingRequestResourceToAddModList->list.array[j]->schedulingRequestResourceId) + break; + } + if (j < target->schedulingRequestResourceToAddModList->list.count) + asn_sequence_del(&target->schedulingRequestResourceToAddModList->list, j, 1); + else + LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); + } + } + + if(source->multi_CSI_PUCCH_ResourceList) + updateMACie(target->multi_CSI_PUCCH_ResourceList, + source->multi_CSI_PUCCH_ResourceList, + struct NR_PUCCH_Config__multi_CSI_PUCCH_ResourceList); + if(source->dl_DataToUL_ACK) + updateMACie(target->dl_DataToUL_ACK, + source->dl_DataToUL_ACK, + struct NR_PUCCH_Config__dl_DataToUL_ACK); + // PUCCH-SpatialRelationInfo + if (source->spatialRelationInfoToAddModList) { + if (!target->spatialRelationInfoToAddModList) + target->spatialRelationInfoToAddModList = calloc(1, sizeof(*target->spatialRelationInfoToAddModList)); + for (int i = 0; i < source->spatialRelationInfoToAddModList->list.count; i++) { + long id = source->spatialRelationInfoToAddModList->list.array[i]->pucch_SpatialRelationInfoId; + int j; + for (j = 0; j < target->spatialRelationInfoToAddModList->list.count; j++) { + if(id == target->spatialRelationInfoToAddModList->list.array[j]->pucch_SpatialRelationInfoId) + break; + } + if (j == target->spatialRelationInfoToAddModList->list.count) { + NR_PUCCH_SpatialRelationInfo_t *res = calloc(1, sizeof(*res)); + ASN_SEQUENCE_ADD(&target->spatialRelationInfoToAddModList->list, res); + } + updateMACie(target->spatialRelationInfoToAddModList->list.array[j], + source->spatialRelationInfoToAddModList->list.array[i], + NR_PUCCH_SpatialRelationInfo_t); + } + } + if (source->spatialRelationInfoToReleaseList) { + for (int i = 0; i < source->spatialRelationInfoToReleaseList->list.count; i++) { + long id = *source->spatialRelationInfoToReleaseList->list.array[i]; + int j; + for (j = 0; j < target->spatialRelationInfoToAddModList->list.count; j++) { + if(id == target->spatialRelationInfoToAddModList->list.array[j]->pucch_SpatialRelationInfoId) + break; + } + if (j < target->spatialRelationInfoToAddModList->list.count) + asn_sequence_del(&target->spatialRelationInfoToAddModList->list, j, 1); + else + LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); + } + } + + if (source->pucch_PowerControl) { + if (!target->pucch_PowerControl) + target->pucch_PowerControl = calloc(1, sizeof(*target->pucch_PowerControl)); + updateMACie(target->pucch_PowerControl->deltaF_PUCCH_f0, + source->pucch_PowerControl->deltaF_PUCCH_f0, + long); + updateMACie(target->pucch_PowerControl->deltaF_PUCCH_f1, + source->pucch_PowerControl->deltaF_PUCCH_f1, + long); + updateMACie(target->pucch_PowerControl->deltaF_PUCCH_f2, + source->pucch_PowerControl->deltaF_PUCCH_f2, + long); + updateMACie(target->pucch_PowerControl->deltaF_PUCCH_f3, + source->pucch_PowerControl->deltaF_PUCCH_f3, + long); + updateMACie(target->pucch_PowerControl->deltaF_PUCCH_f4, + source->pucch_PowerControl->deltaF_PUCCH_f4, + long); + if (source->pucch_PowerControl->p0_Set) + updateMACie(target->pucch_PowerControl->p0_Set, + source->pucch_PowerControl->p0_Set, + struct NR_PUCCH_PowerControl__p0_Set); + if (source->pucch_PowerControl->pathlossReferenceRSs) + updateMACie(target->pucch_PowerControl->pathlossReferenceRSs, + source->pucch_PowerControl->pathlossReferenceRSs, + struct NR_PUCCH_PowerControl__pathlossReferenceRSs); + updateMACie(target->pucch_PowerControl->twoPUCCH_PC_AdjustmentStates, + source->pucch_PowerControl->twoPUCCH_PC_AdjustmentStates, + long); + } +} + +void setup_srsresourceset(NR_SRS_ResourceSet_t *source, NR_SRS_ResourceSet_t *target) +{ + target->srs_ResourceSetId = source->srs_ResourceSetId; + if (source->srs_ResourceIdList) + updateMACie(target->srs_ResourceIdList, + source->srs_ResourceIdList, + struct NR_SRS_ResourceSet__srs_ResourceIdList); + target->resourceType = source->resourceType; + target->usage = source->usage; + updateMACie(target->alpha, + source->alpha, + NR_Alpha_t); + if (source->p0) + updateMACie(target->p0, + source->p0, + long); + if (source->pathlossReferenceRS) + updateMACie(target->pathlossReferenceRS, + source->pathlossReferenceRS, + struct NR_PathlossReferenceRS_Config); + updateMACie(target->srs_PowerControlAdjustmentStates, + source->srs_PowerControlAdjustmentStates, + long); +} + +void setup_srsconfig(NR_SRS_Config_t *source, NR_SRS_Config_t *target) +{ + updateMACie(target->tpc_Accumulation, + source->tpc_Accumulation, + long); + // SRS-Resource + if (source->srs_ResourceToAddModList) { + if (!target->srs_ResourceToAddModList) + target->srs_ResourceToAddModList = calloc(1, sizeof(*target->srs_ResourceToAddModList)); + for (int i = 0; i < source->srs_ResourceToAddModList->list.count; i++) { + long id = source->srs_ResourceToAddModList->list.array[i]->srs_ResourceId; + int j; + for (j = 0; j < target->srs_ResourceToAddModList->list.count; j++) { + if(id == target->srs_ResourceToAddModList->list.array[j]->srs_ResourceId) + break; + } + if (j == target->srs_ResourceToAddModList->list.count) { + NR_SRS_Resource_t *res = calloc(1, sizeof(*res)); + ASN_SEQUENCE_ADD(&target->srs_ResourceToAddModList->list, res); + } + updateMACie(target->srs_ResourceToAddModList->list.array[j], + source->srs_ResourceToAddModList->list.array[i], + NR_SRS_Resource_t); + } + } + if (source->srs_ResourceToReleaseList) { + for (int i = 0; i < source->srs_ResourceToReleaseList->list.count; i++) { + long id = *source->srs_ResourceToReleaseList->list.array[i]; + int j; + for (j = 0; j < target->srs_ResourceToAddModList->list.count; j++) { + if(id == target->srs_ResourceToAddModList->list.array[j]->srs_ResourceId) + break; + } + if (j < target->srs_ResourceToAddModList->list.count) + asn_sequence_del(&target->srs_ResourceToAddModList->list, j, 1); + else + LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); + } + } + // SRS-ResourceSet + if (source->srs_ResourceSetToAddModList) { + if (!target->srs_ResourceSetToAddModList) + target->srs_ResourceSetToAddModList = calloc(1, sizeof(*target->srs_ResourceSetToAddModList)); + for (int i = 0; i < source->srs_ResourceSetToAddModList->list.count; i++) { + long id = source->srs_ResourceSetToAddModList->list.array[i]->srs_ResourceSetId; + int j; + for (j = 0; j < target->srs_ResourceSetToAddModList->list.count; j++) { + if(id == target->srs_ResourceSetToAddModList->list.array[j]->srs_ResourceSetId) + break; + } + if (j == target->srs_ResourceSetToAddModList->list.count) { + NR_SRS_ResourceSet_t *res = calloc(1, sizeof(*res)); + ASN_SEQUENCE_ADD(&target->srs_ResourceSetToAddModList->list, res); + } + setup_srsresourceset(source->srs_ResourceSetToAddModList->list.array[i], + target->srs_ResourceSetToAddModList->list.array[j]); + } + } + if (source->srs_ResourceSetToReleaseList) { + for (int i = 0; i < source->srs_ResourceSetToReleaseList->list.count; i++) { + long id = *source->srs_ResourceSetToReleaseList->list.array[i]; + int j; + for (j = 0; j < target->srs_ResourceSetToAddModList->list.count; j++) { + if(id == target->srs_ResourceSetToAddModList->list.array[j]->srs_ResourceSetId) + break; + } + if (j < target->srs_ResourceSetToAddModList->list.count) + asn_sequence_del(&target->srs_ResourceSetToAddModList->list, j, 1); + else + LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); + } + } +} + +NR_UE_DL_BWP_t *get_dl_bwp_structure(NR_UE_MAC_INST_t *mac, + int bwp_id, + bool setup) +{ + NR_UE_DL_BWP_t *bwp = NULL; + for (int i = 0; i < mac->dl_BWPs.count; i++) { + if (bwp_id == mac->dl_BWPs.array[i]->bwp_id) { + bwp = mac->dl_BWPs.array[i]; + break; + } + } + if (!bwp && setup) { + bwp = calloc(1, sizeof(*bwp)); + ASN_SEQUENCE_ADD(&mac->dl_BWPs, bwp); + } + if (!setup) { + bwp->n_dl_bwp = mac->dl_BWPs.count - 1; + bwp->bw_tbslbrm = 0; + for (int i = 0; i < mac->dl_BWPs.count; i++) { + if (mac->dl_BWPs.array[i]->BWPSize > bwp->bw_tbslbrm) + bwp->bw_tbslbrm = mac->dl_BWPs.array[i]->BWPSize; + } + } + return bwp; +} + +NR_UE_UL_BWP_t *get_ul_bwp_structure(NR_UE_MAC_INST_t *mac, + int bwp_id, + bool setup) +{ + NR_UE_UL_BWP_t *bwp = NULL; + for (int i = 0; i < mac->ul_BWPs.count; i++) { + if (bwp_id == mac->ul_BWPs.array[i]->bwp_id) { + bwp = mac->ul_BWPs.array[i]; + break; + } + } + if (!bwp && setup) { + bwp = calloc(1, sizeof(*bwp)); + ASN_SEQUENCE_ADD(&mac->ul_BWPs, bwp); + } + if (!setup) { + bwp->n_ul_bwp = mac->ul_BWPs.count - 1; + bwp->bw_tbslbrm = 0; + for (int i = 0; i < mac->ul_BWPs.count; i++) { + if (mac->ul_BWPs.array[i]->BWPSize > bwp->bw_tbslbrm) + bwp->bw_tbslbrm = mac->ul_BWPs.array[i]->BWPSize; + } + } + return bwp; +} + +void configure_dedicated_BWP_dl(NR_UE_MAC_INST_t *mac, + int bwp_id, + NR_BWP_DownlinkDedicated_t *dl_dedicated) +{ + if(dl_dedicated) { + NR_UE_DL_BWP_t *bwp = get_dl_bwp_structure(mac, bwp_id, true); + bwp->bwp_id = bwp_id; + NR_BWP_PDCCH_t *pdcch = &mac->config_BWP_PDCCH[bwp_id]; + if(dl_dedicated->pdsch_Config) { + if (dl_dedicated->pdsch_Config->present == + NR_SetupRelease_PDSCH_Config_PR_release) { + ASN_STRUCT_FREE(asn_DEF_NR_PDSCH_Config, + bwp->pdsch_Config); + bwp->pdsch_Config = NULL; + } + if (dl_dedicated->pdsch_Config->present == + NR_SetupRelease_PDSCH_Config_PR_setup) { + if (!bwp->pdsch_Config) + bwp->pdsch_Config = calloc(1, sizeof(*bwp->pdsch_Config)); + setup_pdschconfig(dl_dedicated->pdsch_Config->choice.setup, bwp->pdsch_Config); + } + } + if(dl_dedicated->pdcch_Config) { + if (dl_dedicated->pdcch_Config->present == + NR_SetupRelease_PDCCH_Config_PR_release) { + for (int i = 0; pdcch->list_Coreset.count; i++) + asn_sequence_del(&pdcch->list_Coreset, i, 1); + for (int i = 0; pdcch->list_SS.count; i++) + asn_sequence_del(&pdcch->list_SS, i, 1); + } + if (dl_dedicated->pdcch_Config->present == + NR_SetupRelease_PDCCH_Config_PR_setup) + configure_ss_coreset(pdcch, + dl_dedicated->pdcch_Config->choice.setup); + } + } +} + +void configure_dedicated_BWP_ul(NR_UE_MAC_INST_t *mac, + int bwp_id, + NR_BWP_UplinkDedicated_t *ul_dedicated) +{ + if(ul_dedicated) { + NR_UE_UL_BWP_t *bwp = get_ul_bwp_structure(mac, bwp_id, true); + bwp->bwp_id = bwp_id; + if(ul_dedicated->pucch_Config) { + if (ul_dedicated->pucch_Config->present == + NR_SetupRelease_PUCCH_Config_PR_release) { + ASN_STRUCT_FREE(asn_DEF_NR_PUCCH_Config, + bwp->pucch_Config); + bwp->pucch_Config = NULL; + } + if (ul_dedicated->pucch_Config->present == + NR_SetupRelease_PUCCH_Config_PR_setup) { + if (!bwp->pucch_Config) + bwp->pucch_Config = calloc(1, sizeof(*bwp->pucch_Config)); + setup_pucchconfig(ul_dedicated->pucch_Config->choice.setup, bwp->pucch_Config); + } + } + if(ul_dedicated->pusch_Config) { + if (ul_dedicated->pusch_Config->present == + NR_SetupRelease_PUSCH_Config_PR_release) { + ASN_STRUCT_FREE(asn_DEF_NR_PUSCH_Config, + bwp->pusch_Config); + bwp->pusch_Config = NULL; + } + if (ul_dedicated->pusch_Config->present == + NR_SetupRelease_PUSCH_Config_PR_setup) { + if (!bwp->pusch_Config) + bwp->pusch_Config = calloc(1, sizeof(*bwp->pusch_Config)); + setup_puschconfig(ul_dedicated->pusch_Config->choice.setup, bwp->pusch_Config); + } + } + if(ul_dedicated->srs_Config) { + if (ul_dedicated->srs_Config->present == + NR_SetupRelease_SRS_Config_PR_release) { + ASN_STRUCT_FREE(asn_DEF_NR_SRS_Config, + bwp->srs_Config); + bwp->srs_Config = NULL; + } + if (ul_dedicated->srs_Config->present == + NR_SetupRelease_SRS_Config_PR_setup) { + if (!bwp->srs_Config) + bwp->srs_Config = calloc(1, sizeof(*bwp->srs_Config)); + setup_srsconfig(ul_dedicated->srs_Config->choice.setup, bwp->srs_Config); + } + } + AssertFatal(!ul_dedicated->configuredGrantConfig, "configuredGrantConfig not supported\n"); + } +} + +void configure_common_BWP_dl(NR_UE_MAC_INST_t *mac, + int bwp_id, + NR_BWP_DownlinkCommon_t *dl_common) +{ + if(dl_common) { + NR_UE_DL_BWP_t *bwp = get_dl_bwp_structure(mac, bwp_id, true); + bwp->bwp_id = bwp_id; + NR_BWP_t *dl_genericParameters = &dl_common->genericParameters; + bwp->scs = dl_genericParameters->subcarrierSpacing; + bwp->cyclicprefix = dl_genericParameters->cyclicPrefix; + bwp->BWPSize = NRRIV2BW(dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + bwp->BWPStart = NRRIV2PRBOFFSET(dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + if (bwp_id == 0) { + bwp->initial_BWPSize = bwp->BWPSize; + bwp->initial_BWPStart = bwp->BWPStart; + } + if (dl_common->pdsch_ConfigCommon) { + if (dl_common->pdsch_ConfigCommon->present == + NR_SetupRelease_PDSCH_ConfigCommon_PR_setup) + updateMACie(bwp->tdaList_Common, + dl_common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList, + NR_PDSCH_TimeDomainResourceAllocationList_t); + if (dl_common->pdsch_ConfigCommon->present == + NR_SetupRelease_PDSCH_ConfigCommon_PR_release) { + ASN_STRUCT_FREE(asn_DEF_NR_PDSCH_TimeDomainResourceAllocationList, + bwp->tdaList_Common); + bwp->tdaList_Common = NULL; + } + } + NR_BWP_PDCCH_t *pdcch = &mac->config_BWP_PDCCH[bwp_id]; + if (dl_common->pdcch_ConfigCommon) { + if (dl_common->pdcch_ConfigCommon->present == + NR_SetupRelease_PDCCH_ConfigCommon_PR_setup) + configure_common_ss_coreset(pdcch, + dl_common->pdcch_ConfigCommon->choice.setup); + if (dl_common->pdcch_ConfigCommon->present == + NR_SetupRelease_PDCCH_ConfigCommon_PR_release) + release_common_ss_cset(pdcch); + } + } +} + +void configure_common_BWP_ul(NR_UE_MAC_INST_t *mac, + int bwp_id, + NR_BWP_UplinkCommon_t *ul_common) +{ + if (ul_common) { + NR_UE_UL_BWP_t *bwp = get_ul_bwp_structure(mac, bwp_id, true); + bwp->bwp_id = bwp_id; + NR_BWP_t *ul_genericParameters = &ul_common->genericParameters; + bwp->scs = ul_genericParameters->subcarrierSpacing; + bwp->cyclicprefix = ul_genericParameters->cyclicPrefix; + bwp->BWPSize = NRRIV2BW(ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + bwp->BWPStart = NRRIV2PRBOFFSET(ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + if (bwp_id == 0) { + bwp->initial_BWPSize = bwp->BWPSize; + bwp->initial_BWPStart = bwp->BWPStart; + } + if (ul_common->rach_ConfigCommon) { + handleMACsetuprelease(bwp->rach_ConfigCommon, + ul_common->rach_ConfigCommon, + NR_RACH_ConfigCommon_t, + asn_DEF_NR_RACH_ConfigCommon); + } + if (ul_common->pucch_ConfigCommon) + handleMACsetuprelease(bwp->pucch_ConfigCommon, + ul_common->pucch_ConfigCommon, + NR_PUCCH_ConfigCommon_t, + asn_DEF_NR_PUCCH_ConfigCommon); + if (ul_common->pusch_ConfigCommon) { + if (ul_common->pusch_ConfigCommon->present == + NR_SetupRelease_PUSCH_ConfigCommon_PR_setup) { + updateMACie(bwp->tdaList_Common, + ul_common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList, + NR_PUSCH_TimeDomainResourceAllocationList_t); + updateMACie(bwp->msg3_DeltaPreamble, + ul_common->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble, + long); + } + if (ul_common->pusch_ConfigCommon->present == + NR_SetupRelease_PUSCH_ConfigCommon_PR_release) { + ASN_STRUCT_FREE(asn_DEF_NR_PUSCH_TimeDomainResourceAllocationList, + bwp->tdaList_Common); + bwp->tdaList_Common = NULL; + free(bwp->msg3_DeltaPreamble); + bwp->msg3_DeltaPreamble = NULL; + } + } + } +} + void nr_rrc_mac_config_req_sib1(module_id_t module_id, int cc_idP, NR_SI_SchedulingInfo_t *si_SchedulingInfo, @@ -883,14 +1751,33 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, NR_SI_SchedulingInfo_t); config_common_ue_sa(mac, scc, module_id, cc_idP); - // configure BWP only if it is a SIB1 detection in non connected state (after sync) - // not if it is a periodical update of SIB1 (no change of BWP in that case) - if(mac->state < UE_CONNECTED) - configure_current_BWP(mac, scc, NULL); + configure_common_BWP_dl(mac, + 0, // bwp-id + &scc->downlinkConfigCommon.initialDownlinkBWP); + if (scc->uplinkConfigCommon) + configure_common_BWP_ul(mac, + 0, // bwp-id + &scc->uplinkConfigCommon->initialUplinkBWP); + // set current BWP only if coming from non-connected state + // otherwise it is just a periodically update of the SIB1 content + if(mac->state < UE_CONNECTED) { + mac->current_DL_BWP = get_dl_bwp_structure(mac, 0, false); + AssertFatal(mac->current_DL_BWP, "Couldn't find DL-BWP0\n"); + mac->current_UL_BWP = get_ul_bwp_structure(mac, 0, false); + AssertFatal(mac->current_UL_BWP, "Couldn't find DL-BWP0\n"); + } + + // Setup the SSB to Rach Occasions mapping according to the config + build_ssb_to_ro_map(mac); if (!get_softmodem_params()->emulate_l1) mac->if_module->phy_config_request(&mac->phy_config); mac->phy_config_request_sent = true; + + ASN_STRUCT_FREE(asn_DEF_NR_SI_SchedulingInfo, + si_SchedulingInfo); + ASN_STRUCT_FREE(asn_DEF_NR_ServingCellConfigCommonSIB, + scc); } void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac, @@ -911,8 +1798,14 @@ void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac, if (reconfigurationWithSync->spCellConfigCommon) { NR_ServingCellConfigCommon_t *scc = reconfigurationWithSync->spCellConfigCommon; - mac->bwp_dlcommon = scc->downlinkConfigCommon->initialDownlinkBWP; - mac->bwp_ulcommon = scc->uplinkConfigCommon->initialUplinkBWP; + if (scc->downlinkConfigCommon) + configure_common_BWP_dl(mac, + 0, // bwp-id + scc->downlinkConfigCommon->initialDownlinkBWP); + if (scc->uplinkConfigCommon) + configure_common_BWP_ul(mac, + 0, // bwp-id + scc->uplinkConfigCommon->initialUplinkBWP); if (scc->physCellId) mac->physCellId = *scc->physCellId; mac->dmrs_TypeA_Position = scc->dmrs_TypeA_Position; @@ -1026,9 +1919,10 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, NR_CSI_MeasConfig_t); } else { // modification + NR_CSI_MeasConfig_t *target = sc_info->csi_MeasConfig; NR_CSI_MeasConfig_t *csi_MeasConfig = csi_MeasConfig_sr->choice.setup; if (csi_MeasConfig->reportTriggerSize) - updateMACie(sc_info->csi_MeasConfig->reportTriggerSize, + updateMACie(target->reportTriggerSize, csi_MeasConfig->reportTriggerSize, long); if (csi_MeasConfig->aperiodicTriggerStateList) @@ -1037,21 +1931,21 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, NR_CSI_AperiodicTriggerStateList_t, asn_DEF_NR_CSI_AperiodicTriggerStateList); if (csi_MeasConfig->semiPersistentOnPUSCH_TriggerStateList) - handleMACsetuprelease(sc_info->csi_MeasConfig->semiPersistentOnPUSCH_TriggerStateList->choice.setup, - csi_MeasConfig->semiPersistentOnPUSCH_TriggerStateList, - NR_CSI_SemiPersistentOnPUSCH_TriggerStateList_t, - asn_DEF_NR_CSI_SemiPersistentOnPUSCH_TriggerStateList); + handleMACsetupreleaseElement(target->semiPersistentOnPUSCH_TriggerStateList, + csi_MeasConfig->semiPersistentOnPUSCH_TriggerStateList, + NR_CSI_SemiPersistentOnPUSCH_TriggerStateList_t, + asn_DEF_NR_SetupRelease_CSI_SemiPersistentOnPUSCH_TriggerStateList); // NZP-CSI-RS-Resources if (csi_MeasConfig->nzp_CSI_RS_ResourceToReleaseList) { for (int i = 0; i < csi_MeasConfig->nzp_CSI_RS_ResourceToReleaseList->list.count; i++) { long id = *csi_MeasConfig->nzp_CSI_RS_ResourceToReleaseList->list.array[i]; int j; - for (j = 0; j < sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list.count; j++) { - if(id == sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list.array[j]->nzp_CSI_RS_ResourceId) + for (j = 0; j < target->nzp_CSI_RS_ResourceToAddModList->list.count; j++) { + if(id == target->nzp_CSI_RS_ResourceToAddModList->list.array[j]->nzp_CSI_RS_ResourceId) break; } - if (j < sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list.count) - asn_sequence_del(&sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list, j, 1); + if (j < target->nzp_CSI_RS_ResourceToAddModList->list.count) + asn_sequence_del(&target->nzp_CSI_RS_ResourceToAddModList->list, j, 1); else LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); } @@ -1061,12 +1955,12 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, NR_NZP_CSI_RS_Resource_t *res = csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list.array[i]; long id = res->nzp_CSI_RS_ResourceId; int j; - for (j = 0; j < sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list.count; j++) { - if(id == sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list.array[j]->nzp_CSI_RS_ResourceId) + for (j = 0; j < target->nzp_CSI_RS_ResourceToAddModList->list.count; j++) { + if(id == target->nzp_CSI_RS_ResourceToAddModList->list.array[j]->nzp_CSI_RS_ResourceId) break; } - if (j < sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list.count) { // modify - NR_NZP_CSI_RS_Resource_t *mac_res = sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list.array[j]; + if (j < target->nzp_CSI_RS_ResourceToAddModList->list.count) { // modify + NR_NZP_CSI_RS_Resource_t *mac_res = target->nzp_CSI_RS_ResourceToAddModList->list.array[j]; mac_res->resourceMapping = res->resourceMapping; mac_res->powerControlOffset = res->powerControlOffset; updateMACie(mac_res->powerControlOffsetSS, @@ -1083,7 +1977,7 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, NR_TCI_StateId_t); } else { // add - asn1cSequenceAdd(sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list, + asn1cSequenceAdd(target->nzp_CSI_RS_ResourceToAddModList->list, NR_NZP_CSI_RS_Resource_t, nzp_csi_rs); updateMACie(nzp_csi_rs, res, NR_NZP_CSI_RS_Resource_t); @@ -1095,12 +1989,12 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, for (int i = 0; i < csi_MeasConfig->nzp_CSI_RS_ResourceSetToReleaseList->list.count; i++) { long id = *csi_MeasConfig->nzp_CSI_RS_ResourceSetToReleaseList->list.array[i]; int j; - for (j = 0; j < sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.count; j++) { - if(id == sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.array[j]->nzp_CSI_ResourceSetId) + for (j = 0; j < target->nzp_CSI_RS_ResourceSetToAddModList->list.count; j++) { + if(id == target->nzp_CSI_RS_ResourceSetToAddModList->list.array[j]->nzp_CSI_ResourceSetId) break; } - if (j < sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.count) - asn_sequence_del(&sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list, j, 1); + if (j < target->nzp_CSI_RS_ResourceSetToAddModList->list.count) + asn_sequence_del(&target->nzp_CSI_RS_ResourceSetToAddModList->list, j, 1); else LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); } @@ -1110,16 +2004,16 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, NR_NZP_CSI_RS_ResourceSet_t *res = csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.array[i]; long id = res->nzp_CSI_ResourceSetId; int j; - for (j = 0; j < sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.count; j++) { - if(id == sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.array[j]->nzp_CSI_ResourceSetId) + for (j = 0; j < target->nzp_CSI_RS_ResourceSetToAddModList->list.count; j++) { + if(id == target->nzp_CSI_RS_ResourceSetToAddModList->list.array[j]->nzp_CSI_ResourceSetId) break; } - if (j < sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.count) { // modify - NR_NZP_CSI_RS_ResourceSet_t *mac_res = sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list.array[j]; + if (j < target->nzp_CSI_RS_ResourceSetToAddModList->list.count) { // modify + NR_NZP_CSI_RS_ResourceSet_t *mac_res = target->nzp_CSI_RS_ResourceSetToAddModList->list.array[j]; updateMACie(mac_res, res, NR_NZP_CSI_RS_ResourceSet_t); } else { // add - asn1cSequenceAdd(sc_info->csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list, + asn1cSequenceAdd(target->nzp_CSI_RS_ResourceSetToAddModList->list, NR_NZP_CSI_RS_ResourceSet_t, nzp_csi_rsset); updateMACie(nzp_csi_rsset, res, NR_NZP_CSI_RS_ResourceSet_t); @@ -1131,12 +2025,12 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, for (int i = 0; i < csi_MeasConfig->csi_IM_ResourceToReleaseList->list.count; i++) { long id = *csi_MeasConfig->csi_IM_ResourceToReleaseList->list.array[i]; int j; - for (j = 0; j < sc_info->csi_MeasConfig->csi_IM_ResourceToAddModList->list.count; j++) { - if(id == sc_info->csi_MeasConfig->csi_IM_ResourceToAddModList->list.array[j]->csi_IM_ResourceId) + for (j = 0; j < target->csi_IM_ResourceToAddModList->list.count; j++) { + if(id == target->csi_IM_ResourceToAddModList->list.array[j]->csi_IM_ResourceId) break; } - if (j < sc_info->csi_MeasConfig->csi_IM_ResourceToAddModList->list.count) - asn_sequence_del(&sc_info->csi_MeasConfig->csi_IM_ResourceToAddModList->list, j, 1); + if (j < target->csi_IM_ResourceToAddModList->list.count) + asn_sequence_del(&target->csi_IM_ResourceToAddModList->list, j, 1); else LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); } @@ -1146,12 +2040,12 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, NR_CSI_IM_Resource_t *res = csi_MeasConfig->csi_IM_ResourceToAddModList->list.array[i]; long id = res->csi_IM_ResourceId; int j; - for (j = 0; j < sc_info->csi_MeasConfig->csi_IM_ResourceToAddModList->list.count; j++) { - if(id == sc_info->csi_MeasConfig->csi_IM_ResourceToAddModList->list.array[j]->csi_IM_ResourceId) + for (j = 0; j < target->csi_IM_ResourceToAddModList->list.count; j++) { + if(id == target->csi_IM_ResourceToAddModList->list.array[j]->csi_IM_ResourceId) break; } - if (j < sc_info->csi_MeasConfig->csi_IM_ResourceToAddModList->list.count) { // modify - NR_CSI_IM_Resource_t *mac_res = sc_info->csi_MeasConfig->csi_IM_ResourceToAddModList->list.array[j]; + if (j < target->csi_IM_ResourceToAddModList->list.count) { // modify + NR_CSI_IM_Resource_t *mac_res = target->csi_IM_ResourceToAddModList->list.array[j]; if (res->csi_IM_ResourceElementPattern) updateMACie(mac_res->csi_IM_ResourceElementPattern, res->csi_IM_ResourceElementPattern, @@ -1166,7 +2060,7 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, NR_CSI_ResourcePeriodicityAndOffset_t); } else { // add - asn1cSequenceAdd(sc_info->csi_MeasConfig->csi_IM_ResourceToAddModList->list, + asn1cSequenceAdd(target->csi_IM_ResourceToAddModList->list, NR_CSI_IM_Resource_t, csi_im); updateMACie(csi_im, res, NR_CSI_IM_Resource_t); @@ -1178,12 +2072,12 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, for (int i = 0; i < csi_MeasConfig->csi_IM_ResourceSetToReleaseList->list.count; i++) { long id = *csi_MeasConfig->csi_IM_ResourceSetToReleaseList->list.array[i]; int j; - for (j = 0; j < sc_info->csi_MeasConfig->csi_IM_ResourceSetToAddModList->list.count; j++) { - if(id == sc_info->csi_MeasConfig->csi_IM_ResourceSetToAddModList->list.array[j]->csi_IM_ResourceSetId) + for (j = 0; j < target->csi_IM_ResourceSetToAddModList->list.count; j++) { + if(id == target->csi_IM_ResourceSetToAddModList->list.array[j]->csi_IM_ResourceSetId) break; } - if (j < sc_info->csi_MeasConfig->csi_IM_ResourceSetToAddModList->list.count) - asn_sequence_del(&sc_info->csi_MeasConfig->csi_IM_ResourceSetToAddModList->list, j, 1); + if (j < target->csi_IM_ResourceSetToAddModList->list.count) + asn_sequence_del(&target->csi_IM_ResourceSetToAddModList->list, j, 1); else LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); } @@ -1193,16 +2087,16 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, NR_CSI_IM_ResourceSet_t *res = csi_MeasConfig->csi_IM_ResourceSetToAddModList->list.array[i]; long id = res->csi_IM_ResourceSetId; int j; - for (j = 0; j < sc_info->csi_MeasConfig->csi_IM_ResourceSetToAddModList->list.count; j++) { - if(id == sc_info->csi_MeasConfig->csi_IM_ResourceSetToAddModList->list.array[j]->csi_IM_ResourceSetId) + for (j = 0; j < target->csi_IM_ResourceSetToAddModList->list.count; j++) { + if(id == target->csi_IM_ResourceSetToAddModList->list.array[j]->csi_IM_ResourceSetId) break; } - if (j < sc_info->csi_MeasConfig->csi_IM_ResourceSetToAddModList->list.count) { // modify - NR_CSI_IM_ResourceSet_t *mac_res = sc_info->csi_MeasConfig->csi_IM_ResourceSetToAddModList->list.array[j]; + if (j < target->csi_IM_ResourceSetToAddModList->list.count) { // modify + NR_CSI_IM_ResourceSet_t *mac_res = target->csi_IM_ResourceSetToAddModList->list.array[j]; updateMACie(mac_res, res, NR_CSI_IM_ResourceSet_t); } else { // add - asn1cSequenceAdd(sc_info->csi_MeasConfig->csi_IM_ResourceSetToAddModList->list, + asn1cSequenceAdd(target->csi_IM_ResourceSetToAddModList->list, NR_CSI_IM_ResourceSet_t, csi_im_set); updateMACie(csi_im_set, res, NR_CSI_IM_ResourceSet_t); @@ -1214,12 +2108,12 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, for (int i = 0; i < csi_MeasConfig->csi_SSB_ResourceSetToReleaseList->list.count; i++) { long id = *csi_MeasConfig->csi_SSB_ResourceSetToReleaseList->list.array[i]; int j; - for (j = 0; j < sc_info->csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.count; j++) { - if(id == sc_info->csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[j]->csi_SSB_ResourceSetId) + for (j = 0; j < target->csi_SSB_ResourceSetToAddModList->list.count; j++) { + if(id == target->csi_SSB_ResourceSetToAddModList->list.array[j]->csi_SSB_ResourceSetId) break; } - if (j < sc_info->csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.count) - asn_sequence_del(&sc_info->csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list, j, 1); + if (j < target->csi_SSB_ResourceSetToAddModList->list.count) + asn_sequence_del(&target->csi_SSB_ResourceSetToAddModList->list, j, 1); else LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); } @@ -1229,16 +2123,16 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, NR_CSI_SSB_ResourceSet_t *res = csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[i]; long id = res->csi_SSB_ResourceSetId; int j; - for (j = 0; j < sc_info->csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.count; j++) { - if(id == sc_info->csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[j]->csi_SSB_ResourceSetId) + for (j = 0; j < target->csi_SSB_ResourceSetToAddModList->list.count; j++) { + if(id == target->csi_SSB_ResourceSetToAddModList->list.array[j]->csi_SSB_ResourceSetId) break; } - if (j < sc_info->csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.count) { // modify - NR_CSI_SSB_ResourceSet_t *mac_res = sc_info->csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[j]; + if (j < target->csi_SSB_ResourceSetToAddModList->list.count) { // modify + NR_CSI_SSB_ResourceSet_t *mac_res = target->csi_SSB_ResourceSetToAddModList->list.array[j]; updateMACie(mac_res, res, NR_CSI_SSB_ResourceSet_t); } else { // add - asn1cSequenceAdd(sc_info->csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list, + asn1cSequenceAdd(target->csi_SSB_ResourceSetToAddModList->list, NR_CSI_SSB_ResourceSet_t, csi_ssb_set); updateMACie(csi_ssb_set, res, NR_CSI_SSB_ResourceSet_t); @@ -1250,12 +2144,12 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, for (int i = 0; i < csi_MeasConfig->csi_ResourceConfigToReleaseList->list.count; i++) { long id = *csi_MeasConfig->csi_ResourceConfigToReleaseList->list.array[i]; int j; - for (j = 0; j < sc_info->csi_MeasConfig->csi_ResourceConfigToAddModList->list.count; j++) { - if(id == sc_info->csi_MeasConfig->csi_ResourceConfigToAddModList->list.array[j]->csi_ResourceConfigId) + for (j = 0; j < target->csi_ResourceConfigToAddModList->list.count; j++) { + if(id == target->csi_ResourceConfigToAddModList->list.array[j]->csi_ResourceConfigId) break; } - if (j < sc_info->csi_MeasConfig->csi_ResourceConfigToAddModList->list.count) - asn_sequence_del(&sc_info->csi_MeasConfig->csi_ResourceConfigToAddModList->list, j, 1); + if (j < target->csi_ResourceConfigToAddModList->list.count) + asn_sequence_del(&target->csi_ResourceConfigToAddModList->list, j, 1); else LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); } @@ -1265,16 +2159,16 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, NR_CSI_ResourceConfig_t *res = csi_MeasConfig->csi_ResourceConfigToAddModList->list.array[i]; long id = res->csi_ResourceConfigId; int j; - for (j = 0; j < sc_info->csi_MeasConfig->csi_ResourceConfigToAddModList->list.count; j++) { - if(id == sc_info->csi_MeasConfig->csi_ResourceConfigToAddModList->list.array[j]->csi_ResourceConfigId) + for (j = 0; j < target->csi_ResourceConfigToAddModList->list.count; j++) { + if(id == target->csi_ResourceConfigToAddModList->list.array[j]->csi_ResourceConfigId) break; } - if (j < sc_info->csi_MeasConfig->csi_ResourceConfigToAddModList->list.count) { // modify - NR_CSI_ResourceConfig_t *mac_res = sc_info->csi_MeasConfig->csi_ResourceConfigToAddModList->list.array[j]; + if (j < target->csi_ResourceConfigToAddModList->list.count) { // modify + NR_CSI_ResourceConfig_t *mac_res = target->csi_ResourceConfigToAddModList->list.array[j]; updateMACie(mac_res, res, NR_CSI_ResourceConfig_t); } else { // add - asn1cSequenceAdd(sc_info->csi_MeasConfig->csi_ResourceConfigToAddModList->list, + asn1cSequenceAdd(target->csi_ResourceConfigToAddModList->list, NR_CSI_ResourceConfig_t, csi_config); updateMACie(csi_config, res, NR_CSI_ResourceConfig_t); @@ -1286,12 +2180,12 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, for (int i = 0; i < csi_MeasConfig->csi_ReportConfigToReleaseList->list.count; i++) { long id = *csi_MeasConfig->csi_ReportConfigToReleaseList->list.array[i]; int j; - for (j = 0; j < sc_info->csi_MeasConfig->csi_ReportConfigToAddModList->list.count; j++) { - if(id == sc_info->csi_MeasConfig->csi_ReportConfigToAddModList->list.array[j]->reportConfigId) + for (j = 0; j < target->csi_ReportConfigToAddModList->list.count; j++) { + if(id == target->csi_ReportConfigToAddModList->list.array[j]->reportConfigId) break; } - if (j < sc_info->csi_MeasConfig->csi_ReportConfigToAddModList->list.count) - asn_sequence_del(&sc_info->csi_MeasConfig->csi_ReportConfigToAddModList->list, j, 1); + if (j < target->csi_ReportConfigToAddModList->list.count) + asn_sequence_del(&target->csi_ReportConfigToAddModList->list, j, 1); else LOG_E(NR_MAC, "Element not present in the list, impossible to release\n"); } @@ -1301,16 +2195,16 @@ static void configure_csiconfig(NR_UE_ServingCell_Info_t *sc_info, NR_CSI_ReportConfig_t *res = csi_MeasConfig->csi_ReportConfigToAddModList->list.array[i]; long id = res->reportConfigId; int j; - for (j = 0; j < sc_info->csi_MeasConfig->csi_ReportConfigToAddModList->list.count; j++) { - if(id == sc_info->csi_MeasConfig->csi_ReportConfigToAddModList->list.array[j]->reportConfigId) + for (j = 0; j < target->csi_ReportConfigToAddModList->list.count; j++) { + if(id == target->csi_ReportConfigToAddModList->list.array[j]->reportConfigId) break; } - if (j < sc_info->csi_MeasConfig->csi_ReportConfigToAddModList->list.count) { // modify - NR_CSI_ReportConfig_t *mac_res = sc_info->csi_MeasConfig->csi_ReportConfigToAddModList->list.array[j]; + if (j < target->csi_ReportConfigToAddModList->list.count) { // modify + NR_CSI_ReportConfig_t *mac_res = target->csi_ReportConfigToAddModList->list.array[j]; updateMACie(mac_res, res, NR_CSI_ReportConfig_t); } else { // add - asn1cSequenceAdd(sc_info->csi_MeasConfig->csi_ReportConfigToAddModList->list, + asn1cSequenceAdd(target->csi_ReportConfigToAddModList->list, NR_CSI_ReportConfig_t, csi_rep); updateMACie(csi_rep, res, NR_CSI_ReportConfig_t); @@ -1430,6 +2324,122 @@ static void configure_servingcell_info(NR_UE_ServingCell_Info_t *sc_info, } } +void release_dl_BWP(NR_UE_MAC_INST_t *mac, int bwp_id) +{ + NR_UE_DL_BWP_t *bwp = NULL; + for (int i = 0; i < mac->dl_BWPs.count; i++) { + if (bwp_id == mac->dl_BWPs.array[i]->bwp_id) { + bwp = mac->dl_BWPs.array[i]; + asn_sequence_del(&mac->dl_BWPs, i, 0); + break; + } + } + AssertFatal(bwp, "No DL-BWP %d to release\n", bwp_id); + free(bwp->cyclicprefix); + ASN_STRUCT_FREE(asn_DEF_NR_PDSCH_TimeDomainResourceAllocationList, + bwp->tdaList_Common); + bwp->tdaList_Common = NULL; + ASN_STRUCT_FREE(asn_DEF_NR_PDSCH_Config, + bwp->pdsch_Config); + bwp->pdsch_Config = NULL; + free(bwp); + + NR_BWP_PDCCH_t *pdcch = &mac->config_BWP_PDCCH[bwp_id]; + release_common_ss_cset(pdcch); + for (int i = 0; pdcch->list_Coreset.count; i++) + asn_sequence_del(&pdcch->list_Coreset, i, 1); + for (int i = 0; pdcch->list_SS.count; i++) + asn_sequence_del(&pdcch->list_SS, i, 1); +} + +void release_ul_BWP(NR_UE_MAC_INST_t *mac, int bwp_id) +{ + NR_UE_UL_BWP_t *bwp = NULL; + for (int i = 0; i < mac->ul_BWPs.count; i++) { + if (bwp_id == mac->ul_BWPs.array[i]->bwp_id) { + bwp = mac->ul_BWPs.array[i]; + asn_sequence_del(&mac->ul_BWPs, i, 0); + break; + } + } + AssertFatal(bwp, "No UL-BWP %d to release\n", bwp_id); + free(bwp->cyclicprefix); + ASN_STRUCT_FREE(asn_DEF_NR_RACH_ConfigCommon, + bwp->rach_ConfigCommon); + bwp->rach_ConfigCommon = NULL; + ASN_STRUCT_FREE(asn_DEF_NR_PUSCH_TimeDomainResourceAllocationList, + bwp->tdaList_Common); + bwp->tdaList_Common = NULL; + ASN_STRUCT_FREE(asn_DEF_NR_ConfiguredGrantConfig, + bwp->configuredGrantConfig); + bwp->configuredGrantConfig = NULL; + ASN_STRUCT_FREE(asn_DEF_NR_PUSCH_Config, + bwp->pusch_Config); + bwp->pusch_Config = NULL; + ASN_STRUCT_FREE(asn_DEF_NR_PUCCH_Config, + bwp->pucch_Config); + bwp->pucch_Config = NULL; + ASN_STRUCT_FREE(asn_DEF_NR_PUCCH_ConfigCommon, + bwp->pucch_ConfigCommon); + bwp->pucch_ConfigCommon = NULL; + ASN_STRUCT_FREE(asn_DEF_NR_SRS_Config, + bwp->srs_Config); + bwp->srs_Config = NULL; + free(bwp->msg3_DeltaPreamble); + free(bwp); +} + +void configure_BWPs(NR_UE_MAC_INST_t *mac, NR_ServingCellConfig_t *scd) +{ + configure_dedicated_BWP_dl(mac, + 0, + scd->initialDownlinkBWP); + if (scd->downlinkBWP_ToReleaseList) { + for (int i = 0; i < scd->downlinkBWP_ToReleaseList->list.count; i++) + release_dl_BWP(mac, *scd->downlinkBWP_ToReleaseList->list.array[i]); + } + if (scd->downlinkBWP_ToAddModList) { + for (int i = 0; i < scd->downlinkBWP_ToAddModList->list.count; i++) { + NR_BWP_Downlink_t *bwp = scd->downlinkBWP_ToAddModList->list.array[i]; + configure_common_BWP_dl(mac, + bwp->bwp_Id, + bwp->bwp_Common); + configure_dedicated_BWP_dl(mac, + bwp->bwp_Id, + bwp->bwp_Dedicated); + } + } + if (scd->firstActiveDownlinkBWP_Id) { + mac->current_DL_BWP = get_dl_bwp_structure(mac, *scd->firstActiveDownlinkBWP_Id, false); + AssertFatal(mac->current_DL_BWP, "Couldn't find DL-BWP %ld\n", *scd->firstActiveDownlinkBWP_Id); + } + + if (scd->uplinkConfig) { + configure_dedicated_BWP_ul(mac, + 0, + scd->uplinkConfig->initialUplinkBWP); + if (scd->uplinkConfig->uplinkBWP_ToReleaseList) { + for (int i = 0; i < scd->uplinkConfig->uplinkBWP_ToReleaseList->list.count; i++) + release_ul_BWP(mac, *scd->uplinkConfig->uplinkBWP_ToReleaseList->list.array[i]); + } + if (scd->uplinkConfig->uplinkBWP_ToAddModList) { + for (int i = 0; i < scd->uplinkConfig->uplinkBWP_ToAddModList->list.count; i++) { + NR_BWP_Uplink_t *bwp = scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[i]; + configure_common_BWP_ul(mac, + bwp->bwp_Id, + bwp->bwp_Common); + configure_dedicated_BWP_ul(mac, + bwp->bwp_Id, + bwp->bwp_Dedicated); + } + } + if (scd->uplinkConfig->firstActiveUplinkBWP_Id) { + mac->current_UL_BWP = get_ul_bwp_structure(mac, *scd->uplinkConfig->firstActiveUplinkBWP_Id, false); + AssertFatal(mac->current_UL_BWP, "Couldn't find DL-BWP %ld\n", *scd->uplinkConfig->firstActiveUplinkBWP_Id); + } + } +} + void nr_rrc_mac_config_req_cg(module_id_t module_id, int cc_idP, NR_CellGroupConfig_t *cell_group_config) @@ -1454,10 +2464,16 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id, } if (scd) { configure_servingcell_info(&mac->sc_info, scd); - configure_current_BWP(mac, NULL, scd); + configure_BWPs(mac, scd); } } + // Setup the SSB to Rach Occasions mapping according to the config + build_ssb_to_ro_map(mac); + if (!mac->dl_config_request || !mac->ul_config_request) - ue_init_config_request(mac, mac->current_DL_BWP.scs); + ue_init_config_request(mac, mac->current_DL_BWP->scs); + + ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig, + cell_group_config); } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 60daccc3e4..1fdeb06e09 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -432,6 +432,17 @@ typedef struct nr_lcordered_info_s { NR_LogicalChannelConfig_t *logicalChannelConfig_ordered; } nr_lcordered_info_t; +typedef struct { + NR_SearchSpace_t *otherSI_SS; + NR_SearchSpace_t *ra_SS; + NR_SearchSpace_t *paging_SS; + NR_ControlResourceSet_t *coreset0; + NR_ControlResourceSet_t *commonControlResourceSet; + NR_SearchSpace_t *search_space_zero; + A_SEQUENCE_OF(NR_ControlResourceSet_t) list_Coreset; + A_SEQUENCE_OF(NR_SearchSpace_t) list_SS; +} NR_BWP_PDCCH_t; + /*!\brief Top level UE MAC structure */ typedef struct { NR_UE_L2_STATE_t state; @@ -446,24 +457,16 @@ typedef struct { ssb_list_info_t ssb_list; NR_UE_ServingCell_Info_t sc_info; - NR_UE_DL_BWP_t current_DL_BWP; - NR_UE_UL_BWP_t current_UL_BWP; - NR_BWP_DownlinkCommon_t *bwp_dlcommon; - NR_BWP_UplinkCommon_t *bwp_ulcommon; + A_SEQUENCE_OF(NR_UE_DL_BWP_t) dl_BWPs; + A_SEQUENCE_OF(NR_UE_UL_BWP_t) ul_BWPs; + NR_BWP_PDCCH_t config_BWP_PDCCH[5]; + NR_UE_DL_BWP_t *current_DL_BWP; + NR_UE_UL_BWP_t *current_UL_BWP; bool harq_ACK_SpatialBundlingPUCCH; bool harq_ACK_SpatialBundlingPUSCH; NR_UL_TIME_ALIGNMENT_t ul_time_alignment; - - NR_SearchSpace_t *otherSI_SS; - NR_SearchSpace_t *ra_SS; - NR_SearchSpace_t *paging_SS; - NR_ControlResourceSet_t *BWP_coresets[FAPI_NR_MAX_CORESET_PER_BWP]; - NR_ControlResourceSet_t *coreset0; - NR_SearchSpace_t *BWP_searchspaces[FAPI_NR_MAX_SS]; - NR_SearchSpace_t *search_space_zero; - NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon; bool phy_config_request_sent; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 95f60c7b8a..8348a8b1b0 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -56,6 +56,21 @@ type); \ } \ +#define handleMACsetupreleaseElement(destination, origin, type, asn_DEF) { \ + if (origin->present == 1) { \ + ASN_STRUCT_FREE(asn_DEF, destination); \ + destination = NULL; \ + } \ + if (origin->present == 2) { \ + if (!destination) \ + destination = calloc(1, sizeof(*destination)); \ + destination->present = origin->present; \ + updateMACie(destination->choice.setup, \ + origin->choice.setup, \ + type); \ + } \ +} \ + /**\brief initialize the field in nr_mac instance \param module_id module id */ void nr_ue_init_mac(module_id_t module_idP); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index ebcb0e601b..74a27aabfa 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -77,8 +77,8 @@ void init_RA(module_id_t mod_id, prach_resources->RA_PREAMBLE_BACKOFF = 0; NR_SubcarrierSpacing_t prach_scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing; - int n_prbs = get_N_RA_RB (prach_scs, mac->current_UL_BWP.scs); - int start_prb = rach_ConfigGeneric->msg1_FrequencyStart + mac->current_UL_BWP.BWPStart; + int n_prbs = get_N_RA_RB (prach_scs, mac->current_UL_BWP->scs); + int start_prb = rach_ConfigGeneric->msg1_FrequencyStart + mac->current_UL_BWP->BWPStart; // PRACH shall be as specified for QPSK modulated DFT-s-OFDM of equivalent RB allocation (38.101-1) prach_resources->RA_PCMAX = nr_get_Pcmax(mac, 2, false, prach_scs, cfg->carrier_config.dl_grid_size[prach_scs], true, n_prbs, start_prb); prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER = 1; @@ -172,7 +172,7 @@ void init_RA(module_id_t mod_id, 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_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 = nr_rach_ConfigCommon->prach_RootSequenceIndex.present - 1; uint8_t prachConfigIndex, mu; @@ -278,7 +278,7 @@ int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t m int8_t receivedTargerPower; int8_t delta_preamble; - NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP.rach_ConfigCommon; + 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); @@ -383,11 +383,11 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t } RA_config_t *ra = &mac->ra; - NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP.rach_ConfigCommon; + 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) { - deltaPreamble_Msg3 = (*mac->current_UL_BWP.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); } @@ -552,7 +552,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->current_UL_BWP.rach_ConfigCommon; + 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); @@ -590,8 +590,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->current_UL_BWP.rach_ConfigCommon; - long mu = mac->current_UL_BWP.scs; + 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) @@ -699,7 +699,7 @@ uint8_t nr_ue_get_rach(module_id_t mod_id, if (ra->ra_state > RA_UE_IDLE && ra->ra_state < RA_SUCCEEDED) { if (ra->RA_active == 0) { - NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP.rach_ConfigCommon; + NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP->rach_ConfigCommon; NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; init_RA(mod_id, &ra->prach_resources, setup, rach_ConfigGeneric, ra->rach_ConfigDedicated); @@ -821,12 +821,12 @@ uint8_t nr_ue_get_rach(module_id_t mod_id, void nr_get_RA_window(NR_UE_MAC_INST_t *mac) { RA_config_t *ra = &mac->ra; - NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP.rach_ConfigCommon; + 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; int ra_ResponseWindow = rach_ConfigGeneric->ra_ResponseWindow; - int mu = mac->current_DL_BWP.scs; + int mu = mac->current_DL_BWP->scs; ra->RA_window_cnt = ra->RA_offset * nr_slots_per_frame[mu]; // taking into account the 2 frames gap introduced by OAI gNB 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 ad196b65d4..dfab670950 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -86,13 +86,15 @@ void fill_dci_search_candidates(const NR_SearchSpace_t *ss, rel15->number_of_candidates = i; } -NR_ControlResourceSet_t *ue_get_coreset(const NR_UE_MAC_INST_t *mac, const int coreset_id) +NR_ControlResourceSet_t *ue_get_coreset(const NR_BWP_PDCCH_t *config, const int coreset_id) { + if (config->commonControlResourceSet && + coreset_id == config->commonControlResourceSet->controlResourceSetId) + return config->commonControlResourceSet; NR_ControlResourceSet_t *coreset = NULL; - for (int i = 0; i < FAPI_NR_MAX_CORESET_PER_BWP; i++) { - if (mac->BWP_coresets[i] != NULL && - mac->BWP_coresets[i]->controlResourceSetId == coreset_id) { - coreset = mac->BWP_coresets[i]; + for (int i = 0; i < config->list_Coreset.count; i++) { + if (config->list_Coreset.array[i]->controlResourceSetId == coreset_id) { + coreset = config->list_Coreset.array[i]; break; } } @@ -108,19 +110,20 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, const NR_SearchSpace_t *ss) { - const NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; - const NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + const NR_UE_DL_BWP_t *current_DL_BWP = mac->current_DL_BWP; + const 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_BWP_PDCCH_t *pdcch_config = &mac->config_BWP_PDCCH[dl_bwp_id]; fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; const int coreset_id = *ss->controlResourceSetId; NR_ControlResourceSet_t *coreset; if(coreset_id > 0) { - coreset = ue_get_coreset(mac, coreset_id); + coreset = ue_get_coreset(pdcch_config, coreset_id); rel15->coreset.CoreSetType = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG; } else { - coreset = mac->coreset0; + coreset = pdcch_config->coreset0; rel15->coreset.CoreSetType = NFAPI_NR_CSET_CONFIG_MIB_SIB1; } @@ -460,8 +463,10 @@ bool monitior_dci_for_other_SI(NR_UE_MAC_INST_t *mac, void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, const frame_t frame, const int slot) { - const NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; - int scs = mac->get_sib1 ? get_softmodem_params()->numerology : current_DL_BWP->scs; + const NR_UE_DL_BWP_t *current_DL_BWP = mac->current_DL_BWP; + NR_BWP_Id_t dl_bwp_id = current_DL_BWP ? current_DL_BWP->bwp_id : 0; + NR_BWP_PDCCH_t *pdcch_config = &mac->config_BWP_PDCCH[dl_bwp_id]; + int scs = current_DL_BWP ? current_DL_BWP->scs : get_softmodem_params()->numerology; const int slots_per_frame = nr_slots_per_frame[scs]; if (mac->get_sib1) { int ssb_sc_offset_norm; @@ -483,22 +488,22 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl mac->mib_ssb, 1, // If the UE is not configured with a periodicity, the UE assumes a periodicity of a half frame ssb_offset_point_a); - if(mac->search_space_zero == NULL) - mac->search_space_zero=calloc(1,sizeof(*mac->search_space_zero)); - if(mac->coreset0 == NULL) - mac->coreset0 = calloc(1,sizeof(*mac->coreset0)); - fill_coresetZero(mac->coreset0, &mac->type0_PDCCH_CSS_config); - fill_searchSpaceZero(mac->search_space_zero, slots_per_frame, &mac->type0_PDCCH_CSS_config); - if (is_ss_monitor_occasion(frame, slot, slots_per_frame, mac->search_space_zero)) { + if(pdcch_config->search_space_zero == NULL) + pdcch_config->search_space_zero = calloc(1,sizeof(*pdcch_config->search_space_zero)); + if(pdcch_config->coreset0 == NULL) + pdcch_config->coreset0 = calloc(1,sizeof(*pdcch_config->coreset0)); + fill_coresetZero(pdcch_config->coreset0, &mac->type0_PDCCH_CSS_config); + fill_searchSpaceZero(pdcch_config->search_space_zero, slots_per_frame, &mac->type0_PDCCH_CSS_config); + if (is_ss_monitor_occasion(frame, slot, slots_per_frame, pdcch_config->search_space_zero)) { LOG_D(NR_MAC, "Monitoring DCI for SIB1 in frame %d slot %d\n", frame, slot); - config_dci_pdu(mac, dl_config, NR_RNTI_SI, slot, mac->search_space_zero); + config_dci_pdu(mac, dl_config, NR_RNTI_SI, slot, pdcch_config->search_space_zero); } } if (mac->get_otherSI) { // If searchSpaceOtherSystemInformation is set to zero, // PDCCH monitoring occasions for SI message reception in SI-window // are same as PDCCH monitoring occasions for SIB1 - const NR_SearchSpace_t *ss = mac->otherSI_SS ? mac->otherSI_SS : mac->search_space_zero; + const NR_SearchSpace_t *ss = pdcch_config->otherSI_SS ? pdcch_config->otherSI_SS : pdcch_config->search_space_zero; // TODO configure SI-window if (monitior_dci_for_other_SI(mac, ss, slots_per_frame, frame, slot)) { LOG_D(NR_MAC, "Monitoring DCI for other SIs in frame %d slot %d\n", frame, slot); @@ -508,28 +513,24 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl if (mac->state == UE_PERFORMING_RA && mac->ra.ra_state >= WAIT_RAR) { // if RA is ongoing use RA search space - if (is_ss_monitor_occasion(frame, slot, slots_per_frame, mac->ra_SS)) { + if (is_ss_monitor_occasion(frame, slot, slots_per_frame, pdcch_config->ra_SS)) { int rnti_type = mac->ra.ra_state == WAIT_RAR ? NR_RNTI_RA : NR_RNTI_TC; - config_dci_pdu(mac, dl_config, rnti_type, slot, mac->ra_SS); + config_dci_pdu(mac, dl_config, rnti_type, slot, pdcch_config->ra_SS); } } else if (mac->state == UE_CONNECTED) { - bool found = false; - for (int i = 0; i < FAPI_NR_MAX_SS; i++) { - if (mac->BWP_searchspaces[i] != NULL) { - found = true; - NR_SearchSpace_t *ss = mac->BWP_searchspaces[i]; - if (is_ss_monitor_occasion(frame, slot, slots_per_frame, ss)) - config_dci_pdu(mac, dl_config, NR_RNTI_C, slot, ss); - } + for (int i = 0; i < pdcch_config->list_SS.count; i++) { + NR_SearchSpace_t *ss = pdcch_config->list_SS.array[i]; + if (is_ss_monitor_occasion(frame, slot, slots_per_frame, ss)) + config_dci_pdu(mac, dl_config, NR_RNTI_C, slot, ss); } - if (!found && mac->ra_SS) { + if (pdcch_config->list_SS.count == 0 && pdcch_config->ra_SS) { // If the UE has not been provided a Type3-PDCCH CSS set or a USS set and // the UE has received a C-RNTI and has been provided a Type1-PDCCH CSS set, // the UE monitors PDCCH candidates for DCI format 0_0 and DCI format 1_0 // with CRC scrambled by the C-RNTI in the Type1-PDCCH CSS set - if (is_ss_monitor_occasion(frame, slot, slots_per_frame, mac->ra_SS)) - config_dci_pdu(mac, dl_config, NR_RNTI_C, slot, mac->ra_SS); + if (is_ss_monitor_occasion(frame, slot, slots_per_frame, pdcch_config->ra_SS)) + config_dci_pdu(mac, dl_config, NR_RNTI_C, slot, pdcch_config->ra_SS); } } } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index b2acc35d4f..d15fa97fd3 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -171,8 +171,6 @@ void nr_ue_init_mac(module_id_t module_idP) mac->state = UE_NOT_SYNC; mac->si_window_start = -1; mac->servCellIndex = 0; - memset(&mac->current_DL_BWP, 0, sizeof(mac->current_DL_BWP)); - memset(&mac->current_UL_BWP, 0, sizeof(mac->current_UL_BWP)); } void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac) @@ -426,7 +424,7 @@ static int nr_ue_process_dci_ul_00(module_id_t module_id, // Schedule PUSCH const int coreset_type = dci_ind->coreset_type == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG; // 0 for coreset0, 1 otherwise; - NR_tda_info_t tda_info = get_ul_tda_info(&mac->current_UL_BWP, + NR_tda_info_t tda_info = get_ul_tda_info(mac->current_UL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, dci_ind->rnti), @@ -513,7 +511,7 @@ static int nr_ue_process_dci_ul_01(module_id_t module_id, int slot_tx; const int coreset_type = dci_ind->coreset_type == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG; // 0 for coreset0, 1 otherwise; - NR_tda_info_t tda_info = get_ul_tda_info(&mac->current_UL_BWP, + NR_tda_info_t tda_info = get_ul_tda_info(mac->current_UL_BWP, coreset_type, dci_ind->ss_type, get_rnti_type(mac, dci_ind->rnti), @@ -614,7 +612,7 @@ static int nr_ue_process_dci_dl_10(module_id_t module_id, fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_pdu = &dl_conf_req->dlsch_config_pdu.dlsch_config_rel15; dlsch_pdu->pduBitmap = 0; - NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; + NR_UE_DL_BWP_t *current_DL_BWP = mac->current_DL_BWP; NR_PDSCH_Config_t *pdsch_config = (current_DL_BWP || !mac->get_sib1) ? current_DL_BWP->pdsch_Config : NULL; if (dci_ind->ss_type == NR_SearchSpace__searchSpaceType_PR_common) { dlsch_pdu->BWPSize = @@ -738,7 +736,7 @@ static int nr_ue_process_dci_dl_10(module_id_t module_id, dlsch_pdu->TBS = current_harq->TBS; } - int bw_tbslbrm = current_DL_BWP->initial_BWPSize > 0 ? + int bw_tbslbrm = current_DL_BWP? current_DL_BWP->bw_tbslbrm : dlsch_pdu->BWPSize; dlsch_pdu->tbslbrm = nr_compute_tbslbrm(dlsch_pdu->mcs_table, bw_tbslbrm, 1); @@ -767,7 +765,7 @@ static int nr_ue_process_dci_dl_10(module_id_t module_id, dlsch_pdu->accumulated_delta_PUCCH = tcp[dci->tpc]; // Sanity check for pucch_resource_indicator value received to check for false DCI. bool valid = false; - NR_PUCCH_Config_t *pucch_Config = mac->current_UL_BWP.pucch_Config; + NR_PUCCH_Config_t *pucch_Config = mac->current_UL_BWP? mac->current_UL_BWP->pucch_Config : NULL; if (pucch_Config && pucch_Config->resourceSetToAddModList) { int pucch_res_set_cnt = pucch_Config->resourceSetToAddModList->list.count; @@ -897,7 +895,7 @@ static int nr_ue_process_dci_dl_11(module_id_t module_id, dci->bwp_indicator.val); return -1; } - NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; + NR_UE_DL_BWP_t *current_DL_BWP = mac->current_DL_BWP; NR_PDSCH_Config_t *pdsch_Config = current_DL_BWP->pdsch_Config; fapi_nr_dl_config_request_t *dl_config = get_dl_config_request(mac, slot); fapi_nr_dl_config_request_pdu_t *dl_conf_req = &dl_config->dl_config_list[dl_config->number_pdus]; @@ -1005,7 +1003,7 @@ static int nr_ue_process_dci_dl_11(module_id_t module_id, // Sanity check for pucch_resource_indicator value received to check for false DCI. bool valid = false; - NR_PUCCH_Config_t *pucch_Config = mac->current_UL_BWP.pucch_Config; + NR_PUCCH_Config_t *pucch_Config = mac->current_UL_BWP->pucch_Config; int 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) { @@ -1276,7 +1274,8 @@ void set_harq_status(NR_UE_MAC_INST_t *mac, current_harq->N_CCE = N_CCE; current_harq->delta_pucch = delta_pucch; // FIXME k0 != 0 currently not taken into consideration - int slots_per_frame = nr_slots_per_frame[mac->current_DL_BWP.scs]; + int scs = mac->current_DL_BWP ? mac->current_DL_BWP->scs : get_softmodem_params()->numerology; + int slots_per_frame = nr_slots_per_frame[scs]; current_harq->ul_frame = frame; current_harq->ul_slot = slot + data_toul_fb; if (current_harq->ul_slot >= slots_per_frame) { @@ -1314,7 +1313,7 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *pucch, fapi_nr_ul_config_pucch_pdu *pucch_pdu) { - NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; NR_UE_ServingCell_Info_t *sc_info = &mac->sc_info; NR_PUCCH_FormatConfig_t *pucchfmt; long *pusch_id = NULL; @@ -1556,7 +1555,7 @@ int16_t get_pucch_tx_power_ue(NR_UE_MAC_INST_t *mac, int subframe_number, int O_uci) { - NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + 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; @@ -1680,7 +1679,7 @@ int get_deltatf(uint16_t nb_of_prbs, int find_pucch_resource_set(NR_UE_MAC_INST_t *mac, int size) { int pucch_resource_set_id = 0; - NR_PUCCH_Config_t *pucch_Config = mac->current_UL_BWP.pucch_Config; + NR_PUCCH_Config_t *pucch_Config = mac->current_UL_BWP->pucch_Config; //long *pucch_max_pl_bits = NULL; @@ -2140,7 +2139,7 @@ void merge_resources(PUCCH_sched_t *res, int num_res, NR_PUCCH_Config_t *pucch_C void multiplex_pucch_resource(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *pucch, int num_res) { - NR_PUCCH_Config_t *pucch_Config = mac->current_UL_BWP.pucch_Config; + NR_PUCCH_Config_t *pucch_Config = mac->current_UL_BWP->pucch_Config; order_resources(pucch, num_res); // following pseudocode in Ref. 38.213 section 9.2.5 to multiplex resources int j = 0; @@ -2225,8 +2224,8 @@ bool get_downlink_ack(NR_UE_MAC_INST_t *mac, frame_t frame, int slot, PUCCH_sche int number_harq_feedback = 0; uint32_t dai_max = 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_UE_DL_BWP_t *current_DL_BWP = mac->current_DL_BWP; + NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; bool two_transport_blocks = false; int number_of_code_word = 1; @@ -2400,7 +2399,7 @@ bool get_downlink_ack(NR_UE_MAC_INST_t *mac, frame_t frame, int slot, PUCCH_sche bool trigger_periodic_scheduling_request(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *pucch, frame_t frame, int slot) { - NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; NR_PUCCH_Config_t *pucch_Config = current_UL_BWP->pucch_Config; const int n_slots_frame = nr_slots_per_frame[current_UL_BWP->scs]; @@ -2502,7 +2501,7 @@ int compute_csi_priority(NR_UE_MAC_INST_t *mac, NR_CSI_ReportConfig_t *csirep) int nr_get_csi_measurements(NR_UE_MAC_INST_t *mac, frame_t frame, int slot, PUCCH_sched_t *pucch) { - NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + 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 = current_UL_BWP->pucch_Config; int num_csi = 0; @@ -2877,8 +2876,8 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, int pos = 0; int fsize = 0; int rnti_type = get_rnti_type(mac, rnti); - 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_UE_DL_BWP_t *current_DL_BWP = mac->current_DL_BWP; + NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; int N_RB; if(current_DL_BWP) N_RB = get_rb_bwp_dci(dci_format, @@ -4166,8 +4165,14 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) #endif // Schedule Msg3 - NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - NR_tda_info_t tda_info = get_ul_tda_info(current_UL_BWP, *mac->ra_SS->controlResourceSetId, mac->ra_SS->searchSpaceType->present, NR_RNTI_RA, rar_grant.Msg3_t_alloc); + const NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; + const NR_UE_DL_BWP_t *current_DL_BWP = mac->current_DL_BWP; + const NR_BWP_PDCCH_t *pdcch_config = &mac->config_BWP_PDCCH[current_DL_BWP->bwp_id]; + NR_tda_info_t tda_info = get_ul_tda_info(current_UL_BWP, + *pdcch_config->ra_SS->controlResourceSetId, + pdcch_config->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 9f8ef18495..55f421dd0c 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -116,7 +116,7 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl //Check if requested on the right slot AssertFatal(is_nr_UL_slot(tdd_config, slot, mac->frame_type) != 0, "UL config_request called at wrong slot %d\n", slot); - int mu = mac->current_UL_BWP.scs; + int mu = mac->current_UL_BWP->scs; const int n = nr_slots_per_frame[mu]; AssertFatal(fb_time < n, "Cannot schedule to a slot more than 1 frame away, ul_config_request is not big enough\n"); AssertFatal(mac->ul_config_request != NULL, "mac->ul_config_request not initialized, logic bug\n"); @@ -135,7 +135,7 @@ fapi_nr_dl_config_request_t *get_dl_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_dci_format_t dci_format) { - NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + 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; @@ -240,7 +240,7 @@ void ul_ports_config(NR_UE_MAC_INST_t *mac, int *n_front_load_symb, nfapi_nr_ue_ { uint8_t rank = pusch_config_pdu->nrOfLayers; - NR_PUSCH_Config_t *pusch_Config = mac->current_UL_BWP.pusch_Config; + 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 = pusch_config_pdu->transform_precoding; @@ -428,7 +428,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, int N_PRB_oh = 0; int rnti_type = get_rnti_type(mac, rnti); - NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; NR_UE_ServingCell_Info_t *sc_info = &mac->sc_info; // Common configuration @@ -749,7 +749,7 @@ void configure_srs_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_ul_config_srs_pdu *srs_config_pdu, int period, int offset) { - NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; srs_config_pdu->rnti = mac->crnti; srs_config_pdu->handle = 0; @@ -820,7 +820,7 @@ void configure_srs_pdu(NR_UE_MAC_INST_t *mac, // Aperiodic SRS scheduling void nr_ue_aperiodic_srs_scheduling(NR_UE_MAC_INST_t *mac, long resource_trigger, int frame, int slot) { - NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; NR_SRS_Config_t *srs_config = current_UL_BWP->srs_Config; if (!srs_config) { @@ -885,7 +885,7 @@ bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slo bool srs_scheduled = false; NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); - NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; NR_SRS_Config_t *srs_config = current_UL_BWP->srs_Config; @@ -1437,7 +1437,7 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, uint8_t is_Msg3, frame_t curren DURATION_RX_TO_TX); int delta = 0; - NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; // Get the numerology to calculate the Tx frame and slot int mu = current_UL_BWP->scs; @@ -1521,7 +1521,7 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) { uint8_t nb_of_frames_per_prach_conf_period; uint8_t prach_conf_period_frame_idx; - NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP.rach_ConfigCommon; + 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; @@ -1530,7 +1530,7 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) { if (setup->msg1_SubcarrierSpacing) mu = *setup->msg1_SubcarrierSpacing; else - mu = mac->current_UL_BWP.scs; + mu = mac->current_UL_BWP->scs; msg1_FDM = rach_ConfigGeneric->msg1_FDM; @@ -1697,12 +1697,12 @@ static void build_ssb_list(NR_UE_MAC_INST_t *mac) { } // Map the transmitted SSBs to the ROs and create the association pattern according to the config -static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) { - +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->current_UL_BWP.rach_ConfigCommon; + 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 @@ -2002,7 +2002,7 @@ static int get_nr_prach_info_from_ssb_index(uint8_t ssb_idx, // - exact slot number // - frame offset ssb_info_p = &ssb_list->tx_ssb[ssb_idx]; - LOG_D(NR_MAC,"checking for prach : ssb_info_p->nb_mapped_ro %d\n",ssb_info_p->nb_mapped_ro); + LOG_D(NR_MAC,"checking for prach : ssb_info_p->nb_mapped_ro %d\n", ssb_info_p->nb_mapped_ro); for (uint8_t n_mapped_ro=0; n_mapped_ronb_mapped_ro; n_mapped_ro++) { LOG_D(NR_MAC,"%d.%d: mapped_ro[%d]->frame.slot %d.%d, prach_assoc_pattern.nb_of_frame %d\n", frame,slot,n_mapped_ro,ssb_info_p->mapped_ro[n_mapped_ro]->frame,ssb_info_p->mapped_ro[n_mapped_ro]->slot,prach_assoc_pattern.nb_of_frame); @@ -2016,8 +2016,7 @@ static int get_nr_prach_info_from_ssb_index(uint8_t ssb_idx, } // If there is a matching RO slot in the SSB_to_RO map - if (NULL != prach_occasion_slot_p) - { + if (NULL != prach_occasion_slot_p) { // A random RO mapped to the SSB index should be selected in the slot // First count the number of times the SSB index is found in that RO @@ -2065,8 +2064,8 @@ static int get_nr_prach_info_from_ssb_index(uint8_t ssb_idx, } // Build the SSB to RO mapping upon RRC configuration update -void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac) { - +void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac) +{ // Clear all the lists and maps memset(&prach_assoc_pattern, 0, sizeof(prach_association_pattern_t)); memset(&mac->ssb_list, 0, sizeof(ssb_list_info_t)); @@ -2171,7 +2170,7 @@ void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot) NR_CSI_IM_Resource_t *imcsi; int period, offset; - NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; + NR_UE_DL_BWP_t *current_DL_BWP = mac->current_DL_BWP; int mu = current_DL_BWP->scs; uint16_t bwp_size = current_DL_BWP->BWPSize; uint16_t bwp_start = current_DL_BWP->BWPStart; @@ -2304,7 +2303,7 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) return; fapi_nr_dl_config_request_t *dl_config = get_dl_config_request(mac, slot); - NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; + NR_UE_DL_BWP_t *current_DL_BWP = mac->current_DL_BWP; NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id; int mu = current_DL_BWP->scs; @@ -2466,7 +2465,7 @@ static void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_fr fapi_nr_prach_config_t *prach_config = &cfg->prach_config; nr_scheduled_response_t scheduled_response; - NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP.rach_ConfigCommon; + 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 = mac->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 aa6d92d104..60749f9393 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2018,6 +2018,43 @@ void reset_sched_ctrl(NR_UE_sched_ctrl_t *sched_ctrl) sched_ctrl->srs_feedback.sri = 0; } +int get_dlbw_tbslbrm(int scc_bwpsize, + const NR_ServingCellConfig_t *servingCellConfig) +{ + int bw = scc_bwpsize; + if (servingCellConfig) { + if(servingCellConfig->downlinkBWP_ToAddModList) { + const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *BWP_list = servingCellConfig->downlinkBWP_ToAddModList; + for (int i=0; ilist.count; i++) { + NR_BWP_t genericParameters = BWP_list->list.array[i]->bwp_Common->genericParameters; + int curr_bw = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + if (curr_bw > bw) + bw = curr_bw; + } + } + } + return bw; +} + +int get_ulbw_tbslbrm(int scc_bwpsize, + const NR_ServingCellConfig_t *servingCellConfig) +{ + int bw = scc_bwpsize; + if (servingCellConfig) { + if (servingCellConfig->uplinkConfig && + servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList) { + const struct NR_UplinkConfig__uplinkBWP_ToAddModList *BWP_list = servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList; + for (int i=0; ilist.count; i++) { + NR_BWP_t genericParameters = BWP_list->list.array[i]->bwp_Common->genericParameters; + int curr_bw = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + if (curr_bw > bw) + bw = curr_bw; + } + } + } + return bw; +} + // main function to configure parameters of current BWP void configure_UE_BWP(gNB_MAC_INST *nr_mac, NR_ServingCellConfigCommon_t *scc,