From 1e6db77be7c8d88281eeb68a34cb8fc7541961e9 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 22 Dec 2022 12:34:31 +0100 Subject: [PATCH 1/4] first commit --- .../nr_dl_channel_estimation.c | 3 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 4 +- openair2/LAYER2/NR_MAC_UE/config_ue.c | 388 ++++++++---------- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 26 +- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 2 - openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 8 +- .../NR_MAC_UE/nr_ue_dci_configuration.c | 38 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 145 ++----- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 85 ++-- 9 files changed, 285 insertions(+), 414 deletions(-) diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index 0a0d92743d..2b858e9a91 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -1017,7 +1017,7 @@ void nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, if(nb_rb_coreset==0) return; #ifdef DEBUG_PDCCH - printf(PHY, "pdcch_channel_estimation: first_carrier_offset %d, BWPStart %d, coreset_start_rb %d, coreset_nb_rb %d\n", + printf("pdcch_channel_estimation: first_carrier_offset %d, BWPStart %d, coreset_start_rb %d, coreset_nb_rb %d\n", first_carrier_offset, BWPStart, coreset_start_rb, nb_rb_coreset); #endif @@ -1044,7 +1044,6 @@ void nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, int dmrs_ref = 0; if (coreset->CoreSetType == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG) dmrs_ref = BWPStart; - // generate pilot int pilot[(nb_rb_coreset + dmrs_ref) * 3] __attribute__((aligned(16))); nr_pdcch_dmrs_rx(ue,Ns,ue->nr_gold_pdcch[gNB_id][Ns][symbol], &pilot[0],2000,(nb_rb_coreset+dmrs_ref)); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 5d624bfd63..01e4cbefd9 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -911,8 +911,8 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, const double N_TA_max = Ta_max * bw_scaling * tc_factor; NR_UE_MAC_INST_t *mac = get_mac_inst(0); - NR_BWP_Id_t dl_bwp = mac->DL_BWP_Id; - NR_BWP_Id_t ul_bwp = mac->UL_BWP_Id; + NR_BWP_Id_t dl_bwp = mac->current_DL_BWP.bwp_id; + NR_BWP_Id_t ul_bwp = mac->current_UL_BWP.bwp_id; NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; if(ul_bwp){ diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index a9160e84ba..d465cbf2e7 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -427,53 +427,6 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, } -/** \brief This function performs some configuration routines according to clause 12 "Bandwidth part operation" 3GPP TS 38.213 version 16.3.0 Release 16 - @param NR_UE_MAC_INST_t mac: pointer to local MAC instance - @returns void - */ - -void config_bwp_ue(NR_UE_MAC_INST_t *mac, uint32_t *bwp_ind, uint8_t *dci_format) -{ - - NR_ServingCellConfig_t *scd = mac->cg->spCellConfig->spCellConfigDedicated; - - int n_ubwp = 0; - if (scd && scd->uplinkConfig && - scd->uplinkConfig->uplinkBWP_ToAddModList) - n_ubwp = scd->uplinkConfig->uplinkBWP_ToAddModList->list.count; - - if (bwp_ind && dci_format){ - switch(*dci_format){ - case NR_UL_DCI_FORMAT_0_1: - mac->UL_BWP_Id = n_ubwp < 4 ? *bwp_ind : *bwp_ind + 1; - break; - case NR_DL_DCI_FORMAT_1_1: - mac->DL_BWP_Id = n_ubwp < 4 ? *bwp_ind : *bwp_ind + 1; - break; - default: - LOG_E(MAC, "In %s: failed to configure BWP Id from DCI with format %d \n", __FUNCTION__, *dci_format); - } - // configure ss coreset after switching BWP - configure_ss_coreset(mac, scd, mac->DL_BWP_Id); - } else { - - if (scd->firstActiveDownlinkBWP_Id) - mac->DL_BWP_Id = *scd->firstActiveDownlinkBWP_Id; - else if (scd->defaultDownlinkBWP_Id) - mac->DL_BWP_Id = *scd->defaultDownlinkBWP_Id; - else - mac->DL_BWP_Id = 0; - - if (scd->uplinkConfig && scd->uplinkConfig->firstActiveUplinkBWP_Id) - mac->UL_BWP_Id = *scd->uplinkConfig->firstActiveUplinkBWP_Id; - else - mac->UL_BWP_Id = 0; - - } - - LOG_D(MAC, "In %s setting DL_BWP_Id %ld UL_BWP_Id %ld \n", __FUNCTION__, mac->DL_BWP_Id, mac->UL_BWP_Id); -} - /** \brief This function is relavant for the UE procedures for control. It loads the search spaces, the BWPs and the CORESETs into the MAC instance and \brief performs assert checks on the relevant RRC configuration. @param NR_UE_MAC_INST_t mac: pointer to local MAC instance @@ -483,8 +436,7 @@ void config_control_ue(NR_UE_MAC_INST_t *mac){ int bwp_id; NR_ServingCellConfig_t *scd = mac->cg->spCellConfig->spCellConfigDedicated; - config_bwp_ue(mac, NULL, NULL); - NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; + NR_BWP_Id_t dl_bwp_id = mac->current_DL_BWP.bwp_id; // configure DLbwp if (scd->downlinkBWP_ToAddModList) { @@ -586,184 +538,188 @@ int nr_rrc_mac_config_req_ue_logicalChannelBearer( return 0; } -int nr_rrc_mac_config_req_ue( - module_id_t module_id, - int cc_idP, - uint8_t gNB_index, - NR_MIB_t *mibP, - NR_ServingCellConfigCommonSIB_t *sccP, - // NR_MAC_CellGroupConfig_t *mac_cell_group_configP, - // NR_PhysicalCellGroupConfig_t *phy_cell_group_configP, - NR_CellGroupConfig_t *cell_group_config, - NR_CellGroupConfig_t *scell_group_config){ - NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); - RA_config_t *ra = &mac->ra; - fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; +void configure_current_BWP(NR_UE_MAC_INST_t *mac, + NR_ServingCellConfigCommonSIB_t *scc, + NR_CellGroupConfig_t *cell_group_config) +{ + NR_DL_BWP_t *DL_BWP = &mac->current_DL_BWP; + NR_UL_BWP_t *UL_BWP = &mac->current_UL_BWP; - // TODO do something FAPI-like P5 L1/L2 config interface in config_si, config_mib, etc. + if(scc) { + DL_BWP->bwp_id = 0; + UL_BWP->bwp_id = 0; + DL_BWP->genericParameters = scc->downlinkConfigCommon.initialDownlinkBWP.genericParameters; + if(scc->uplinkConfigCommon) + UL_BWP->genericParameters = scc->uplinkConfigCommon->initialUplinkBWP.genericParameters; + else + UL_BWP->genericParameters = scc->downlinkConfigCommon.initialDownlinkBWP.genericParameters; + } + if(cell_group_config) { + if (cell_group_config->spCellConfig && + cell_group_config->spCellConfig->spCellConfigDedicated) { + struct NR_ServingCellConfig *spCellConfigDedicated = cell_group_config->spCellConfig->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; - if(mibP != NULL){ - mac->mib = mibP; // update by every reception - mac->phy_config.Mod_id = module_id; - mac->phy_config.CC_id = cc_idP; - } - AssertFatal(scell_group_config == NULL || cell_group_config == NULL, - "both scell_group_config and cell_group_config cannot be non-NULL\n"); - - if (sccP != NULL) { - - mac->scc_SIB=sccP; - LOG_D(NR_MAC, "In %s: Keeping ServingCellConfigCommonSIB\n", __FUNCTION__); - config_common_ue_sa(mac,module_id,cc_idP); - - int num_slots_ul = nr_slots_per_frame[mac->mib->subCarrierSpacingCommon]; - if(cfg->cell_config.frame_duplex_type == TDD){ - num_slots_ul = mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; - if (mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols > 0) { - num_slots_ul++; + NR_BWP_Downlink_t *bwp_downlink = NULL; + const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = spCellConfigDedicated->downlinkBWP_ToAddModList; + 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_BWP->genericParameters = bwp_downlink->bwp_Common->genericParameters; + } + else { + if(mac->scc) { + DL_BWP->genericParameters = mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + } + if(mac->scc_SIB) { + DL_BWP->genericParameters = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; } } - LOG_I(NR_MAC, "Initializing ul_config_request. num_slots_ul = %d\n", num_slots_ul); - mac->ul_config_request = (fapi_nr_ul_config_request_t *)calloc(num_slots_ul, sizeof(fapi_nr_ul_config_request_t)); - for (int i=0; iul_config_request[i].mutex_ul_config), NULL); - // Setup the SSB to Rach Occasions mapping according to the config - build_ssb_to_ro_map(mac);//->scc, mac->phy_config.config_req.cell_config.frame_duplex_type); - if (!get_softmodem_params()->emulate_l1) - mac->if_module->phy_config_request(&mac->phy_config); - } - if(scell_group_config != NULL ){ - mac->cg = scell_group_config; - mac->servCellIndex = *scell_group_config->spCellConfig->servCellIndex; - mac->DL_BWP_Id=mac->cg->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id ? *mac->cg->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id : 0; - mac->UL_BWP_Id=mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id ? *mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id : 0; - - config_control_ue(mac); - if (scell_group_config->spCellConfig->reconfigurationWithSync) { - if (scell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) { - ra->rach_ConfigDedicated = scell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink; + NR_BWP_Uplink_t *bwp_uplink = NULL; + const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList; + if (ubwpList && UL_BWP->bwp_id > 0) { + 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; } - mac->scc = scell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon; - mac->physCellId = *mac->scc->physCellId; + AssertFatal(bwp_uplink != NULL,"Couldn't find ULBWP corresponding to BWP ID %ld\n",UL_BWP->bwp_id); + UL_BWP->genericParameters = bwp_uplink->bwp_Common->genericParameters; + } + else { + if(mac->scc) { + UL_BWP->genericParameters = mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + } + if(mac->scc_SIB) { + UL_BWP->genericParameters = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters; + } + } + } + else + AssertFatal(1==0,"We shouldn't end here in configuring BWP\n"); + } + + DL_BWP->scs = DL_BWP->genericParameters.subcarrierSpacing; + DL_BWP->cyclicprefix = DL_BWP->genericParameters.cyclicPrefix; + DL_BWP->BWPSize = NRRIV2BW(DL_BWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + DL_BWP->BWPStart = NRRIV2PRBOFFSET(DL_BWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + UL_BWP->scs = UL_BWP->genericParameters.subcarrierSpacing; + UL_BWP->cyclicprefix = UL_BWP->genericParameters.cyclicPrefix; + UL_BWP->BWPSize = NRRIV2BW(UL_BWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + UL_BWP->BWPStart = NRRIV2PRBOFFSET(UL_BWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); +} + + +int nr_rrc_mac_config_req_ue(module_id_t module_id, + int cc_idP, + uint8_t gNB_index, + NR_MIB_t *mibP, + NR_ServingCellConfigCommonSIB_t *sccP, + NR_CellGroupConfig_t *cell_group_config, + NR_CellGroupConfig_t *scell_group_config) +{ + + NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + RA_config_t *ra = &mac->ra; + fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; + + // TODO do something FAPI-like P5 L1/L2 config interface in config_si, config_mib, etc. + + if(mibP != NULL){ + mac->mib = mibP; // update by every reception + mac->phy_config.Mod_id = module_id; + mac->phy_config.CC_id = cc_idP; + } + AssertFatal(scell_group_config == NULL || cell_group_config == NULL, + "both scell_group_config and cell_group_config cannot be non-NULL\n"); + + if (sccP != NULL) { + + mac->scc_SIB = sccP; + LOG_D(NR_MAC, "In %s: Keeping ServingCellConfigCommonSIB\n", __FUNCTION__); + config_common_ue_sa(mac, module_id, cc_idP); + configure_current_BWP(mac, sccP, NULL); + + int num_slots_ul = nr_slots_per_frame[mac->mib->subCarrierSpacingCommon]; + if(cfg->cell_config.frame_duplex_type == TDD){ + num_slots_ul = mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; + if (mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols > 0) { + num_slots_ul++; + } + } + LOG_I(NR_MAC, "Initializing ul_config_request. num_slots_ul = %d\n", num_slots_ul); + mac->ul_config_request = (fapi_nr_ul_config_request_t *)calloc(num_slots_ul, sizeof(fapi_nr_ul_config_request_t)); + for (int i=0; iul_config_request[i].mutex_ul_config), NULL); + // Setup the SSB to Rach Occasionsif (cell_group_config->spCellConfig) { mapping according to the config + build_ssb_to_ro_map(mac);//->scc, mac->phy_config.config_req.cell_config.frame_duplex_type); + if (!get_softmodem_params()->emulate_l1) + mac->if_module->phy_config_request(&mac->phy_config); + } + if(scell_group_config != NULL ){ + mac->cg = scell_group_config; + mac->servCellIndex = *scell_group_config->spCellConfig->servCellIndex; + if (scell_group_config->spCellConfig->reconfigurationWithSync) { + if (scell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) { + ra->rach_ConfigDedicated = scell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink; + } + mac->scc = scell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon; + mac->physCellId = *mac->scc->physCellId; + config_common_ue(mac,module_id,cc_idP); + mac->crnti = scell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity; + LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti); + } + configure_current_BWP(mac, NULL, scell_group_config); + config_control_ue(mac); + // Setup the SSB to Rach Occasions mapping according to the config + build_ssb_to_ro_map(mac); + } + else if (cell_group_config != NULL ){ + LOG_I(MAC,"Applying CellGroupConfig from gNodeB\n"); + mac->cg = cell_group_config; + if (cell_group_config->spCellConfig) + mac->servCellIndex = cell_group_config->spCellConfig->servCellIndex ? *cell_group_config->spCellConfig->servCellIndex : 0; + else + mac->servCellIndex = 0; + + mac->scheduling_info.periodicBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; + mac->scheduling_info.retxBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING; + mac->BSR_reporting_active = NR_BSR_TRIGGER_NONE; + LOG_D(MAC, "[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n", + module_id, + mac->scheduling_info.periodicBSR_SF, + mac->scheduling_info.retxBSR_SF); + + configure_current_BWP(mac, NULL, cell_group_config); + config_control_ue(mac); + + if (get_softmodem_params()->nsa) { + if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->reconfigurationWithSync) { + if (cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) { + ra->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink; + } + mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon; + int num_slots = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; + if (mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols > 0) { + num_slots++; + } + mac->ul_config_request = calloc(num_slots, sizeof(*mac->ul_config_request)); config_common_ue(mac,module_id,cc_idP); - mac->crnti = scell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity; + mac->crnti = cell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity; LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti); } // Setup the SSB to Rach Occasions mapping according to the config build_ssb_to_ro_map(mac); } - else if (cell_group_config != NULL ){ - LOG_I(MAC,"Applying CellGroupConfig from gNodeB\n"); - mac->cg = cell_group_config; - if (cell_group_config->spCellConfig) { - mac->servCellIndex = cell_group_config->spCellConfig->servCellIndex ? *cell_group_config->spCellConfig->servCellIndex : 0; - mac->DL_BWP_Id=mac->cg->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id ? *mac->cg->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id : 0; - mac->UL_BWP_Id=mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id ? *mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id : 0; - } - else { - mac->servCellIndex = 0; - mac->DL_BWP_Id = 0; - mac->UL_BWP_Id = 0; - } - - mac->scheduling_info.periodicBSR_SF = - MAC_UE_BSR_TIMER_NOT_RUNNING; - mac->scheduling_info.retxBSR_SF = - MAC_UE_BSR_TIMER_NOT_RUNNING; - mac->BSR_reporting_active = NR_BSR_TRIGGER_NONE; - LOG_D(MAC, "[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n", - module_id, - mac->scheduling_info.periodicBSR_SF, - mac->scheduling_info.retxBSR_SF); - - config_control_ue(mac); - if (get_softmodem_params()->nsa) { - if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->reconfigurationWithSync) { - if (cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) { - ra->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink; - } - mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon; - int num_slots = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; - if (mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols > 0) { - num_slots++; - } - mac->ul_config_request = calloc(num_slots, sizeof(*mac->ul_config_request)); - config_common_ue(mac,module_id,cc_idP); - mac->crnti = cell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity; - LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti); - } - - // Setup the SSB to Rach Occasions mapping according to the config - build_ssb_to_ro_map(mac); - } - - /* - if(mac_cell_group_configP != NULL){ - if(mac_cell_group_configP->drx_Config != NULL ){ - switch(mac_cell_group_configP->drx_Config->present){ - case NR_SetupRelease_DRX_Config_PR_NOTHING: - break; - case NR_SetupRelease_DRX_Config_PR_release: - mac->drx_Config = NULL; - break; - case NR_SetupRelease_DRX_Config_PR_setup: - mac->drx_Config = mac_cell_group_configP->drx_Config->choice.setup; - break; - default: - break; - } - } - - if(mac_cell_group_configP->schedulingRequestConfig != NULL ){ - mac->schedulingRequestConfig = mac_cell_group_configP->schedulingRequestConfig; - } - - if(mac_cell_group_configP->bsr_Config != NULL ){ - mac->bsr_Config = mac_cell_group_configP->bsr_Config; - } - - if(mac_cell_group_configP->tag_Config != NULL ){ - mac->tag_Config = mac_cell_group_configP->tag_Config; - } - - if(mac_cell_group_configP->phr_Config != NULL ){ - switch(mac_cell_group_configP->phr_Config->present){ - case NR_SetupRelease_PHR_Config_PR_NOTHING: - break; - case NR_SetupRelease_PHR_Config_PR_release: - mac->phr_Config = NULL; - break; - case NR_SetupRelease_PHR_Config_PR_setup: - mac->phr_Config = mac_cell_group_configP->phr_Config->choice.setup; - break; - default: - break; - } - } - } - - - if(phy_cell_group_configP != NULL ){ - if(phy_cell_group_configP->cs_RNTI != NULL ){ - switch(phy_cell_group_configP->cs_RNTI->present){ - case NR_SetupRelease_RNTI_Value_PR_NOTHING: - break; - case NR_SetupRelease_RNTI_Value_PR_release: - mac->cs_RNTI = NULL; - break; - case NR_SetupRelease_RNTI_Value_PR_setup: - mac->cs_RNTI = &phy_cell_group_configP->cs_RNTI->choice.setup; - break; - default: - break; - } - } - } - */ - } - - return 0; - + } + return 0; } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 18c34d29e0..4eb3fdfe50 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -372,6 +372,23 @@ typedef struct { } NR_PHY_meas_t; +typedef struct NR_DL_BWP { + NR_BWP_Id_t bwp_id; + NR_BWP_t genericParameters; + int scs; + long *cyclicprefix; + uint16_t BWPSize; + uint16_t BWPStart; +} NR_DL_BWP_t; + +typedef struct NR_UL_BWP { + NR_BWP_Id_t bwp_id; + NR_BWP_t genericParameters; + int scs; + long *cyclicprefix; + uint16_t BWPSize; + uint16_t BWPStart; +} NR_UL_BWP_t; /*!\brief Top level UE MAC structure */ typedef struct { @@ -393,6 +410,9 @@ typedef struct { NR_RNTI_Value_t *cs_RNTI; NR_MIB_t *mib; + NR_DL_BWP_t current_DL_BWP; + NR_UL_BWP_t current_UL_BWP; + NR_BWP_Downlink_t *DLbwp[MAX_NUM_BWP_UE]; NR_BWP_Uplink_t *ULbwp[MAX_NUM_BWP_UE]; NR_ControlResourceSet_t *coreset[MAX_NUM_BWP_UE][FAPI_NR_MAX_CORESET_PER_BWP]; @@ -400,12 +420,6 @@ typedef struct { frame_type_t frame_type; - /*BWP*/ - // dedicated active DL BWP - NR_BWP_Id_t DL_BWP_Id; - // dedicated active UL BWP - NR_BWP_Id_t UL_BWP_Id; - /// Type0-PDCCH seach space fapi_nr_dl_config_dci_dl_pdu_rel15_t type0_pdcch_dci_config; uint32_t type0_pdcch_ss_mux_pattern; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index b8b533705a..ac2881435f 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -451,8 +451,6 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac); -void config_bwp_ue(NR_UE_MAC_INST_t *mac, uint32_t *bwp_ind, uint8_t *dci_format); - void configure_ss_coreset(NR_UE_MAC_INST_t *mac, NR_ServingCellConfig_t *scd, NR_BWP_Id_t dl_bwp_id); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 8b71713eb6..d63c08dc8e 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -177,11 +177,11 @@ void init_RA(module_id_t mod_id, } } if (ss_id < 0) { - if (mac->DL_BWP_Id>0) { - ra_ss = mac->DLbwp[mac->DL_BWP_Id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + if (mac->current_DL_BWP.bwp_id>0) { + ra_ss = mac->DLbwp[mac->current_DL_BWP.bwp_id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; if (ra_ss) { - commonSearchSpaceList = mac->DLbwp[mac->DL_BWP_Id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - ss_id = *mac->DLbwp[mac->DL_BWP_Id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + commonSearchSpaceList = mac->DLbwp[mac->current_DL_BWP.bwp_id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; + ss_id = *mac->DLbwp[mac->current_DL_BWP.bwp_id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; } } } 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 9b618cdbfb..b25b530176 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -94,10 +94,10 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t AssertFatal(mac->scc == NULL || mac->scc_SIB == NULL, "both scc and scc_SIB cannot be non-null\n"); - NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; + NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; + NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id; NR_ServingCellConfigCommon_t *scc = mac->scc; NR_ServingCellConfigCommonSIB_t *scc_SIB = mac->scc_SIB; - NR_BWP_DownlinkCommon_t *bwp_Common=NULL; NR_BWP_DownlinkCommon_t *initialDownlinkBWP=NULL; NR_BWP_UplinkCommon_t *initialUplinkBWP=NULL; @@ -105,7 +105,6 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t initialDownlinkBWP = scc!=NULL ? scc->downlinkConfigCommon->initialDownlinkBWP : &scc_SIB->downlinkConfigCommon.initialDownlinkBWP; initialUplinkBWP = scc!=NULL ? scc->uplinkConfigCommon->initialUplinkBWP : &scc_SIB->uplinkConfigCommon->initialUplinkBWP; } - bwp_Common = dl_bwp_id>0 ? mac->DLbwp[dl_bwp_id-1]->bwp_Common : NULL; NR_SearchSpace_t *ss; NR_ControlResourceSet_t *coreset; @@ -167,28 +166,20 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t switch(rnti_type) { case NR_RNTI_C: // we use DL BWP dedicated - sps = bwp_Common ? - (bwp_Common->genericParameters.cyclicPrefix ? 12 : 14) : - initialDownlinkBWP->genericParameters.cyclicPrefix ? 12 : 14; + sps = current_DL_BWP->cyclicprefix ? 12 : 14; // for SPS=14 8 MSBs in positions 13 down to 6 monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); rel15->rnti = mac->crnti; - if (!bwp_Common) { - rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - rel15->BWPStart = NRRIV2PRBOFFSET(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - } - else { - rel15->BWPSize = NRRIV2BW(bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - rel15->SubcarrierSpacing = bwp_Common->genericParameters.subcarrierSpacing; - } + rel15->BWPSize = current_DL_BWP->BWPSize; + rel15->BWPStart = current_DL_BWP->BWPStart; + rel15->SubcarrierSpacing = current_DL_BWP->scs; for (int i = 0; i < rel15->num_dci_options; i++) { rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_C, rel15->BWPSize, dl_bwp_id, coreset_id, mac->type0_PDCCH_CSS_config.num_rbs); } break; case NR_RNTI_RA: // we use the initial DL BWP - sps = initialDownlinkBWP->genericParameters.cyclicPrefix == NULL ? 14 : 12; + sps = current_DL_BWP->cyclicprefix == NULL ? 14 : 12; monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); rel15->rnti = mac->ra.ra_rnti; if (get_softmodem_params()->sa) { @@ -196,9 +187,9 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; } else { // NSA mode is not using the Initial BWP rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + rel15->BWPStart = current_DL_BWP->BWPStart; } - rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing; + rel15->SubcarrierSpacing = current_DL_BWP->scs; rel15->dci_length_options[0] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[0]], rel15->dci_format_options[0], NR_RNTI_RA, rel15->BWPSize, dl_bwp_id, coreset_id, mac->type0_PDCCH_CSS_config.num_rbs); break; case NR_RNTI_P: @@ -207,12 +198,12 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t break; case NR_RNTI_TC: // we use the initial DL BWP - sps = initialDownlinkBWP->genericParameters.cyclicPrefix == NULL ? 14 : 12; + sps = current_DL_BWP->cyclicprefix == NULL ? 14 : 12; monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); rel15->rnti = mac->ra.t_crnti; rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs; rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; - rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing; + rel15->SubcarrierSpacing = current_DL_BWP->scs; for (int i = 0; i < rel15->num_dci_options; i++) { rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_TC, rel15->BWPSize, dl_bwp_id, coreset_id, mac->type0_PDCCH_CSS_config.num_rbs); } @@ -220,9 +211,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t case NR_RNTI_SP_CSI: break; case NR_RNTI_SI: - // we use DL BWP dedicated - if (bwp_Common) sps = bwp_Common->genericParameters.cyclicPrefix == NULL ? 14 : 12; - else sps=14; // note: normally this would be found with SSS detection + sps=14; // for SPS=14 8 MSBs in positions 13 down to 6 monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); @@ -280,7 +269,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl RA_config_t *ra = &mac->ra; int ss_id; - uint8_t bwp_id = (mac->cg) ? mac->DL_BWP_Id : 0; + uint8_t bwp_id = mac->current_DL_BWP.bwp_id; //NR_ServingCellConfig_t *scd = mac->scg->spCellConfig->spCellConfigDedicated; NR_BWP_DownlinkDedicated_t *bwpd = (bwp_id>0) ? mac->DLbwp[bwp_id-1]->bwp_Dedicated : mac->cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; NR_BWP_DownlinkCommon_t *bwp_Common = (bwp_id>0) ? mac->DLbwp[bwp_id-1]->bwp_Common : &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP; @@ -431,7 +420,6 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl } // for ss_id } else { - AssertFatal(1==0,"Handle DCI searching when CellGroup without dedicated BWP\n"); } } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index cef268d517..e2ba12380e 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -310,10 +310,10 @@ int8_t nr_ue_decode_mib(module_id_t module_id, NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); mac->physCellId = cell_id; - nr_mac_rrc_data_ind_ue( module_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_BCH, (uint8_t *) pduP, 3 ); // fixed 3 bytes MIB PDU + nr_mac_rrc_data_ind_ue(module_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_BCH, (uint8_t *) pduP, 3); // fixed 3 bytes MIB PDU AssertFatal(mac->mib != NULL, "nr_ue_decode_mib() mac->mib == NULL\n"); - //if(mac->mib != NULL){ + uint16_t frame = (mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused); uint16_t frame_number_4lsb = 0; @@ -649,17 +649,13 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr RA_config_t *ra = &mac->ra; fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; uint8_t is_Msg3 = 0; - NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; - NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; + NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id; + NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id; int default_abc = 1; - uint16_t n_RB_DLBWP; - if (dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1]) n_RB_DLBWP = NRRIV2BW(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - else if (mac->scc) n_RB_DLBWP = NRRIV2BW(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); - else if (mac->scc_SIB) n_RB_DLBWP = NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth,MAX_BWP_SIZE); - else n_RB_DLBWP = mac->type0_PDCCH_CSS_config.num_rbs; - - LOG_D(MAC, "In %s: Processing received DCI format %s (DL BWP %d)\n", __FUNCTION__, dci_formats[dci_format], n_RB_DLBWP); + LOG_D(MAC, "In %s: Processing received DCI format %s\n", __FUNCTION__, dci_formats[dci_format]); switch(dci_format){ case NR_UL_DCI_FORMAT_0_0: { @@ -1066,8 +1062,6 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dlsch_config_pdu_1_0->accumulated_delta_PUCCH, dci->pucch_resource_indicator, 1+dci->pdsch_to_harq_feedback_timing_indicator.val); - - // dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP = n_RB_DLBWP; LOG_D(MAC,"(nr_ue_procedures.c) pdu_type=%d\n\n",dl_config->dl_config_list[dl_config->number_pdus].pdu_type); @@ -1111,9 +1105,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr LOG_W(NR_MAC,"[%d.%d] bwp_indicator %d > NR_MAX_NUM_BWP Possibly due to false DCI. Ignoring DCI!\n", frame, slot,dci->bwp_indicator.val); return -1; } - config_bwp_ue(mac, &dci->bwp_indicator.val, &dci_format); - NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; - NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_BWP_Id_t dl_bwp_id = mac->current_DL_BWP.bwp_id; + NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id; NR_PDSCH_Config_t *pdsch_Config=NULL; NR_BWP_DownlinkDedicated_t *bwpd=NULL; NR_BWP_DownlinkCommon_t *bwpc=NULL; @@ -1127,16 +1120,16 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_1 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15; - dlsch_config_pdu_1_1->BWPSize = NRRIV2BW(bwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - dlsch_config_pdu_1_1->BWPStart = NRRIV2PRBOFFSET(bwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - dlsch_config_pdu_1_1->SubcarrierSpacing = bwpc->genericParameters.subcarrierSpacing; + dlsch_config_pdu_1_1->BWPSize = current_DL_BWP->BWPSize; + dlsch_config_pdu_1_1->BWPStart = current_DL_BWP->BWPStart; + dlsch_config_pdu_1_1->SubcarrierSpacing = current_DL_BWP->scs; /* IDENTIFIER_DCI_FORMATS */ /* CARRIER_IND */ /* BANDWIDTH_PART_IND */ // dlsch_config_pdu_1_1->bandwidth_part_ind = dci->bandwidth_part_ind; /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */ - if (nr_ue_process_dci_freq_dom_resource_assignment(NULL,dlsch_config_pdu_1_1,0,n_RB_DLBWP,dci->frequency_domain_assignment.val) < 0) { + if (nr_ue_process_dci_freq_dom_resource_assignment(NULL, dlsch_config_pdu_1_1, 0, current_DL_BWP->BWPSize, dci->frequency_domain_assignment.val) < 0) { LOG_W(MAC, "[%d.%d] Invalid frequency_domain_assignment. Possibly due to false DCI. Ignoring DCI!\n", frame, slot); return -1; } @@ -1357,8 +1350,6 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr /* DMRS_SEQ_INI */ //FIXME!!! - // dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP = n_RB_DLBWP; - /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND */ // according to TS 38.213 Table 9.2.3-1 uint8_t feedback_ti = @@ -1406,9 +1397,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr long *maxMIMO_Layers = mac->cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers; AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); int nl_tbslbrm = *maxMIMO_Layers < 4 ? *maxMIMO_Layers : 4; - NR_BWP_t genericParameters = mac->scc ? mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters : - mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; - int BWPSize = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int BWPSize = current_DL_BWP->BWPSize; int bw_tbslbrm = get_dlbw_tbslbrm(BWPSize, mac->cg); dlsch_config_pdu_1_1->tbslbrm = nr_compute_tbslbrm(dlsch_config_pdu_1_1->mcs_table, bw_tbslbrm, @@ -1527,23 +1516,12 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, int O_CRC = 0; //FIXME uint16_t O_uci = O_CSI + O_ACK; - NR_BWP_Id_t bwp_id = mac->UL_BWP_Id; + NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_BWP_Id_t bwp_id = current_UL_BWP->bwp_id; NR_PUCCH_FormatConfig_t *pucchfmt; long *pusch_id = NULL; long *id0 = NULL; - int scs; - NR_BWP_UplinkCommon_t *initialUplinkBWP; - if (mac->scc) initialUplinkBWP = mac->scc->uplinkConfigCommon->initialUplinkBWP; - else initialUplinkBWP = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; - if (mac->cg && bwp_id > 1 && mac->ULbwp[bwp_id - 1] && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { - scs = mac->ULbwp[bwp_id - 1]->bwp_Common->genericParameters.subcarrierSpacing; - } - else - scs = initialUplinkBWP->genericParameters.subcarrierSpacing; + const int scs = current_UL_BWP->scs; int subframe_number = slot / (nr_slots_per_frame[scs]/10); nb_pucch_format_4_in_subframes[subframe_number] = 0; @@ -1560,10 +1538,8 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, pucch_pdu->start_symbol_index = initial_pucch_resource[pucch->initial_pucch_id].startingSymbolIndex; pucch_pdu->nr_of_symbols = initial_pucch_resource[pucch->initial_pucch_id].nrofSymbols; - pucch_pdu->bwp_size = NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, - MAX_BWP_SIZE); - pucch_pdu->bwp_start = NRRIV2PRBOFFSET(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, - MAX_BWP_SIZE); + pucch_pdu->bwp_size = current_UL_BWP->BWPSize; + pucch_pdu->bwp_start = current_UL_BWP->BWPStart; pucch_pdu->prb_size = 1; // format 0 or 1 int RB_BWP_offset; @@ -1626,8 +1602,6 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->transformPrecodingDisabled->scramblingID0; else *id0 = mac->physCellId; pucch_Config = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup; - pucch_pdu->bwp_size = NRRIV2BW(mac->ULbwp[bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); - pucch_pdu->bwp_start = NRRIV2PRBOFFSET(mac->ULbwp[bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); } else if (bwp_id==0 && mac->cg && @@ -1638,12 +1612,11 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { pucch_Config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; - pucch_pdu->bwp_size = NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth,MAX_BWP_SIZE); - pucch_pdu->bwp_start = NRRIV2PRBOFFSET(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth,MAX_BWP_SIZE); } else AssertFatal(1==0,"no pucch_Config\n"); - + pucch_pdu->bwp_size = current_UL_BWP->BWPSize; + pucch_pdu->bwp_start = current_UL_BWP->BWPStart; pucch_pdu->prb_start = pucchres->startingPRB; pucch_pdu->freq_hop_flag = pucchres->intraSlotFrequencyHopping!= NULL ? 1 : 0; pucch_pdu->second_hop_prb = pucchres->secondHopPRB!= NULL ? *pucchres->secondHopPRB : 0; @@ -1955,7 +1928,7 @@ int get_deltatf(uint16_t nb_of_prbs, int find_pucch_resource_set(NR_UE_MAC_INST_t *mac, int uci_size) { int pucch_resource_set_id = 0; - NR_BWP_Id_t bwp_id = mac->DL_BWP_Id; + NR_BWP_Id_t bwp_id = mac->current_DL_BWP.bwp_id; //long *pucch_max_pl_bits = NULL; @@ -2027,7 +2000,7 @@ void select_pucch_resource(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *pucch) { NR_PUCCH_ResourceId_t *current_resource_id = NULL; - NR_BWP_Id_t bwp_id = mac->UL_BWP_Id; + NR_BWP_Id_t bwp_id = mac->current_UL_BWP.bwp_id; int n_list; if (pucch->is_common == 1 || @@ -2151,10 +2124,12 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, int V_DAI_m_DL = 0; NR_UE_HARQ_STATUS_t *current_harq; int sched_frame,sched_slot; - int slots_per_frame,scs; + int slots_per_frame; - NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; - NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; + NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id; + NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id; NR_BWP_DownlinkDedicated_t *bwpd=NULL; NR_BWP_DownlinkCommon_t *bwpc=NULL; NR_BWP_UplinkDedicated_t *ubwpd=NULL; @@ -2170,7 +2145,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, number_of_code_word = 2; } - scs = ubwpc->genericParameters.subcarrierSpacing; + int scs = current_UL_BWP->scs; slots_per_frame = nr_slots_per_frame[scs]; @@ -2350,24 +2325,11 @@ bool trigger_periodic_scheduling_request(NR_UE_MAC_INST_t *mac, frame_t frame, int slot) { - NR_BWP_Id_t bwp_id = mac->UL_BWP_Id; + NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_BWP_Id_t bwp_id = current_UL_BWP->bwp_id; NR_PUCCH_Config_t *pucch_Config = NULL; - int scs; - NR_BWP_UplinkCommon_t *initialUplinkBWP; - if (mac->scc) initialUplinkBWP = mac->scc->uplinkConfigCommon->initialUplinkBWP; - else initialUplinkBWP = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; - if (mac->cg && bwp_id && mac->ULbwp[bwp_id - 1] && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { - scs = mac->ULbwp[bwp_id - 1]->bwp_Common->genericParameters.subcarrierSpacing; - } - else - scs = initialUplinkBWP->genericParameters.subcarrierSpacing; - - const int n_slots_frame = nr_slots_per_frame[scs]; + const int n_slots_frame = nr_slots_per_frame[current_UL_BWP->scs]; if (bwp_id>0 && mac->ULbwp[bwp_id-1] && @@ -2476,7 +2438,8 @@ uint8_t nr_get_csi_measurements(NR_UE_MAC_INST_t *mac, int slot, PUCCH_sched_t *pucch) { - NR_BWP_Id_t bwp_id = mac->UL_BWP_Id; + NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_BWP_Id_t bwp_id = current_UL_BWP->bwp_id; NR_PUCCH_Config_t *pucch_Config = NULL; int csi_bits = 0; @@ -2499,19 +2462,6 @@ uint8_t nr_get_csi_measurements(NR_UE_MAC_INST_t *mac, int period, offset; csi_period_offset(csirep, NULL, &period, &offset); - int scs; - NR_BWP_Uplink_t *ubwp = mac->ULbwp[bwp_id-1]; - NR_BWP_UplinkCommon_t *initialUplinkBWP; - if (mac->scc) initialUplinkBWP = mac->scc->uplinkConfigCommon->initialUplinkBWP; - else initialUplinkBWP = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; - - if (ubwp && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) - scs = ubwp->bwp_Common->genericParameters.subcarrierSpacing; - else - scs = initialUplinkBWP->genericParameters.subcarrierSpacing; - if (bwp_id>0 && mac->ULbwp[bwp_id-1] && mac->ULbwp[bwp_id-1]->bwp_Dedicated && @@ -2527,7 +2477,7 @@ uint8_t nr_get_csi_measurements(NR_UE_MAC_INST_t *mac, pucch_Config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; } - const int n_slots_frame = nr_slots_per_frame[scs]; + const int n_slots_frame = nr_slots_per_frame[current_UL_BWP->scs]; if (((n_slots_frame*frame + slot - offset)%period) == 0 && pucch_Config) { LOG_D(NR_MAC, "Preparing CSI report in frame %d slot %d CSI report ID %d\n", frame, slot, csi_report_id); NR_PUCCH_CSI_Resource_t *pucchcsires = csirep->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list.array[0]; @@ -2859,7 +2809,7 @@ void nr_ue_send_sdu(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t *u int get_n_rb(NR_UE_MAC_INST_t *mac, int rnti_type){ int N_RB = 0, start_RB; - NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; + NR_BWP_Id_t dl_bwp_id = mac->current_DL_BWP.bwp_id; switch(rnti_type) { case NR_RNTI_RA: case NR_RNTI_TC: @@ -2896,17 +2846,10 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, int fsize = 0; int rnti_type = get_rnti_type(mac, rnti); - NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id ; - NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id ; - - int N_RB_UL = 0; - if(ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1]) { - N_RB_UL = NRRIV2BW(mac->ULbwp[ul_bwp_id - 1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - } else if(mac->scc) { - N_RB_UL = NRRIV2BW(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - } else if(mac->scc_SIB) { - N_RB_UL = NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - } + NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; + NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id; + int N_RB_UL = current_UL_BWP->BWPSize; LOG_D(MAC,"nr_extract_dci_info : dci_pdu %lx, size %d\n",*dci_pdu,dci_size); switch(dci_format) { @@ -2968,10 +2911,7 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, LOG_D(MAC,"Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,N_RB,dci_size-pos,*dci_pdu); #endif - // check BWP id - if (dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1]) N_RB=NRRIV2BW(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - else N_RB=NRRIV2BW(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - + N_RB = current_DL_BWP->BWPSize; // Freq domain assignment (275rb >> fsize = 16) fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); pos+=fsize; @@ -3234,9 +3174,6 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, break; case NR_UL_DCI_FORMAT_0_0: - if (mac->ULbwp[ul_bwp_id-1]) N_RB_UL=NRRIV2BW(mac->ULbwp[ul_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - else N_RB_UL=NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - switch(rnti_type) { case NR_RNTI_C: diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 902bb2aec8..cebd802bbc 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -107,7 +107,7 @@ void fill_scheduled_response(nr_scheduled_response_t *scheduled_response, long get_k2(NR_UE_MAC_INST_t *mac, uint8_t time_domain_ind) { long k2 = -1; - NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id; // Get K2 from RRC configuration NR_PUSCH_Config_t *pusch_config= ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup : NULL; NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; @@ -149,7 +149,7 @@ long get_k2(NR_UE_MAC_INST_t *mac, uint8_t time_domain_ind) { */ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int slot) { - NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_TDD_UL_DL_ConfigCommon_t *tdd_config = mac->scc==NULL ? mac->scc_SIB->tdd_UL_DL_ConfigurationCommon : mac->scc->tdd_UL_DL_ConfigurationCommon; //Check if request to access ul_config is for a UL slot @@ -161,9 +161,7 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl // Calculate the index of the UL slot in mac->ul_config_request list. This is // based on the TDD pattern (slot configuration period) and number of UL+mixed // slots in the period. TS 38.213 Sec 11.1 - int mu = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? - mac->ULbwp[ul_bwp_id-1]->bwp_Common->genericParameters.subcarrierSpacing : - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.subcarrierSpacing; + int mu = mac->current_UL_BWP.scs; const int n = nr_slots_per_frame[mu]; const int num_slots_per_tdd = tdd_config ? (n >> (7 - tdd_config->pattern1.dl_UL_TransmissionPeriodicity)) : n; const int num_slots_ul = tdd_config ? (tdd_config->pattern1.nrofUplinkSlots + (tdd_config->pattern1.nrofUplinkSymbols != 0)) : n; @@ -184,7 +182,7 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci) { NR_ServingCellConfigCommon_t *scc = mac->scc; - NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id; NR_BWP_UplinkDedicated_t *ubwpd=NULL; NR_SRS_Config_t *srs_config = NULL; @@ -342,7 +340,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_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id; NR_ServingCellConfigCommon_t *scc = mac->scc; NR_BWP_UplinkDedicated_t *ubwpd=NULL; @@ -555,7 +553,8 @@ 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_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id; // Common configuration pusch_config_pdu->dmrs_config_type = pusch_dmrs_type1; @@ -675,8 +674,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->tbslbrm = 0; } else if (dci) { - NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; - NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_BWP_Id_t dl_bwp_id = mac->current_DL_BWP.bwp_id; + NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id; NR_BWP_DownlinkDedicated_t *bwpd=NULL; NR_BWP_DownlinkCommon_t *bwpc=NULL; NR_BWP_UplinkDedicated_t *ubwpd=NULL; @@ -686,9 +685,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, int target_ss; bool valid_ptrs_setup = 0; - uint16_t n_RB_ULBWP = NRRIV2BW(ubwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - pusch_config_pdu->bwp_start = NRRIV2PRBOFFSET(ubwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - pusch_config_pdu->bwp_size = n_RB_ULBWP; + pusch_config_pdu->bwp_start = current_UL_BWP->BWPStart; + pusch_config_pdu->bwp_size = current_UL_BWP->BWPSize; const NR_PUSCH_Config_t *pusch_Config = ubwpd? ubwpd->pusch_Config->choice.setup : NULL; @@ -710,8 +708,6 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, } else if (*dci_format == NR_UL_DCI_FORMAT_0_1) { - config_bwp_ue(mac, &dci->bwp_indicator.val, dci_format); - get_bwp_info(mac,dl_bwp_id,ul_bwp_id,&bwpd,&bwpc,&ubwpd,&ubwpc); target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; @@ -780,7 +776,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, /* IDENTIFIER_DCI_FORMATS */ /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */ - if (nr_ue_process_dci_freq_dom_resource_assignment(pusch_config_pdu, NULL, n_RB_ULBWP, 0, dci->frequency_domain_assignment.val) < 0){ + if (nr_ue_process_dci_freq_dom_resource_assignment(pusch_config_pdu, NULL, current_UL_BWP->BWPSize, 0, dci->frequency_domain_assignment.val) < 0){ return -1; } /* TIME_DOM_RESOURCE_ASSIGNMENT */ @@ -953,7 +949,8 @@ 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); - const NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id; NR_SRS_Config_t *srs_config = NULL; if (ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1]) { @@ -997,14 +994,10 @@ bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slo continue; } - NR_BWP_t ubwp = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? - mac->ULbwp[ul_bwp_id-1]->bwp_Common->genericParameters : - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters; - uint16_t period = srs_period[srs_resource->resourceType.choice.periodic->periodicityAndOffset_p.present]; uint16_t offset = get_nr_srs_offset(srs_resource->resourceType.choice.periodic->periodicityAndOffset_p); - int n_slots_frame = nr_slots_per_frame[ubwp.subcarrierSpacing]; + int n_slots_frame = nr_slots_per_frame[current_UL_BWP->scs]; // Check if UE should transmit the SRS if((frame*n_slots_frame+slot-offset)%period == 0) { @@ -1014,9 +1007,9 @@ bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slo srs_config_pdu->rnti = mac->crnti; srs_config_pdu->handle = 0; - srs_config_pdu->bwp_size = NRRIV2BW(ubwp.locationAndBandwidth, MAX_BWP_SIZE);; - srs_config_pdu->bwp_start = NRRIV2PRBOFFSET(ubwp.locationAndBandwidth, MAX_BWP_SIZE);; - srs_config_pdu->subcarrier_spacing = ubwp.subcarrierSpacing; + srs_config_pdu->bwp_size = current_UL_BWP->BWPSize; + srs_config_pdu->bwp_start = current_UL_BWP->BWPStart; + srs_config_pdu->subcarrier_spacing = current_UL_BWP->scs; srs_config_pdu->cyclic_prefix = 0; srs_config_pdu->num_ant_ports = srs_resource->nrofSRS_Ports; srs_config_pdu->num_symbols = srs_resource->resourceMapping.nrofSymbols; @@ -1588,12 +1581,11 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, uint8_t tda_id){ int delta = 0; - NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id; + NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id; // Get the numerology to calculate the Tx frame and slot - int mu = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? - mac->ULbwp[ul_bwp_id-1]->bwp_Common->genericParameters.subcarrierSpacing : - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.subcarrierSpacing; + int mu = current_UL_BWP->scs; NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? mac->ULbwp[ul_bwp_id-1]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList: @@ -2338,7 +2330,7 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, vo // ACKNACK O_ACK = get_downlink_ack(mac, frameP, slotP, &pucch); - NR_BWP_Id_t bwp_id = mac->UL_BWP_Id; + NR_BWP_Id_t bwp_id = mac->current_UL_BWP.bwp_id; NR_PUCCH_Config_t *pucch_Config = NULL; if (bwp_id>0 && @@ -2426,18 +2418,11 @@ void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot) { fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; NR_CSI_IM_Resource_t *imcsi; int period, offset; - NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; - NR_BWP_t *genericParameters = NULL; - if(dl_bwp_id > 0 && mac->DLbwp[dl_bwp_id-1]) { - genericParameters = &mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters; - } else { - genericParameters = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; - } - - int mu = genericParameters->subcarrierSpacing; - uint16_t bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - uint16_t bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + NR_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; for (int id = 0; id < csi_measconfig->csi_IM_ResourceToAddModList->list.count; id++){ imcsi = csi_measconfig->csi_IM_ResourceToAddModList->list.array[id]; @@ -2491,18 +2476,12 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; NR_NZP_CSI_RS_Resource_t *nzpcsi; int period, offset; - NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id; + NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; + NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id; - NR_BWP_t *genericParameters = NULL; - if(dl_bwp_id > 0 && mac->DLbwp[dl_bwp_id-1]) { - genericParameters = &mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters; - } else { - genericParameters = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; - } - - int mu = genericParameters->subcarrierSpacing; - uint16_t bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - uint16_t bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + int mu = current_DL_BWP->scs; + uint16_t bwp_size = current_DL_BWP->BWPSize; + uint16_t bwp_start = current_DL_BWP->BWPStart; // looking for the correct CSI-RS resource in current BWP NR_NZP_CSI_RS_ResourceSetId_t *nzp = NULL; @@ -2530,7 +2509,7 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu = &dl_config->dl_config_list[dl_config->number_pdus].csirs_config_pdu.csirs_config_rel15; NR_CSI_RS_ResourceMapping_t resourceMapping = nzpcsi->resourceMapping; csirs_config_pdu->subcarrier_spacing = mu; - csirs_config_pdu->cyclic_prefix = genericParameters->cyclicPrefix ? *genericParameters->cyclicPrefix : 0; + csirs_config_pdu->cyclic_prefix = current_DL_BWP->cyclicprefix ? *current_DL_BWP->cyclicprefix : 0; // According to last paragraph of TS 38.214 5.2.2.3.1 if (resourceMapping.freqBand.startingRB < bwp_start) { From e55e880b71210155089a05e439c240d748a10e8e Mon Sep 17 00:00:00 2001 From: francescomani Date: Sat, 24 Dec 2022 14:13:35 +0100 Subject: [PATCH 2/4] cleaning up of dci functions --- .../nfapi/public_inc/fapi_nr_ue_interface.h | 2 + openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 9 +- openair1/SIMULATION/NR_PHY/dlsim.c | 17 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 65 ++++-- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 18 +- openair2/LAYER2/NR_MAC_UE/config_ue.c | 9 + openair2/LAYER2/NR_MAC_UE/mac_defs.h | 4 + openair2/LAYER2/NR_MAC_UE/mac_proto.h | 8 + .../NR_MAC_UE/nr_ue_dci_configuration.c | 203 +++++++++++------- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 107 +++------ openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 28 +-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 30 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 3 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 5 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 124 ----------- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 69 +++++- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 8 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 13 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 4 + 19 files changed, 340 insertions(+), 386 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 21710940d6..ebfb2becb0 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -86,6 +86,7 @@ typedef struct { typedef struct { uint16_t rnti; uint8_t dci_format; + int ss_type; // n_CCE index of first CCE for PDCCH reception int n_CCE; // N_CCE is L, or number of CCEs for DCI @@ -413,6 +414,7 @@ typedef struct { uint8_t num_dci_options; // Num DCIs the UE actually needs to decode (1 or 2) uint8_t dci_length_options[2]; uint8_t dci_format_options[2]; + uint8_t dci_type_options[2]; } fapi_nr_dl_config_dci_dl_pdu_rel15_t; typedef struct { diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 423140fc7a..658b440c21 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -931,10 +931,11 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, else { dci_ind->SFN = proc->frame_rx; dci_ind->slot = proc->nr_slot_rx; - dci_ind->dci_list[dci_ind->number_of_dcis].rnti = n_rnti; - dci_ind->dci_list[dci_ind->number_of_dcis].n_CCE = CCEind; - dci_ind->dci_list[dci_ind->number_of_dcis].N_CCE = L; - dci_ind->dci_list[dci_ind->number_of_dcis].dci_format = rel15->dci_format_options[k]; + dci_ind->dci_list[dci_ind->number_of_dcis].rnti = n_rnti; + dci_ind->dci_list[dci_ind->number_of_dcis].n_CCE = CCEind; + dci_ind->dci_list[dci_ind->number_of_dcis].N_CCE = L; + dci_ind->dci_list[dci_ind->number_of_dcis].dci_format = rel15->dci_format_options[k]; + dci_ind->dci_list[dci_ind->number_of_dcis].ss_type = rel15->dci_type_options[k]; dci_ind->dci_list[dci_ind->number_of_dcis].payloadSize = dci_length; memcpy((void*)dci_ind->dci_list[dci_ind->number_of_dcis].payloadBits,(void*)dci_estimation,8); dci_ind->number_of_dcis++; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 671e613679..43ecec10d2 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -434,8 +434,6 @@ int main(int argc, char **argv) int loglvl=OAILOG_WARNING; //float target_error_rate = 0.01; - int css_flag=0; - cpuf = get_cpu_freq_GHz(); int8_t enable_ptrs = 0; int8_t modify_dmrs = 0; @@ -463,7 +461,7 @@ int main(int argc, char **argv) FILE *scg_fd=NULL; - while ((c = getopt(argc, argv, "f:hA:pf:g:i:n:s:S:t:v:x:y:z:M:N:F:GR:d:PI:L:Ea:b:e:m:w:T:U:q:X:Y")) != -1) { + while ((c = getopt(argc, argv, "f:hA:pf:g:i:n:s:S:t:v:x:y:z:M:N:F:GR:d:PI:L:a:b:e:m:w:T:U:q:X:Y")) != -1) { switch (c) { case 'f': scg_fd = fopen(optarg,"r"); @@ -622,12 +620,6 @@ int main(int argc, char **argv) loglvl = atoi(optarg); break; - - case 'E': - css_flag=1; - break; - - case 'a': g_rbStart = atoi(optarg); break; @@ -709,7 +701,6 @@ int main(int argc, char **argv) //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); printf("-f raw file containing RRC configuration (generated by gNB)\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); - printf("-E used CSS scheduler\n"); printf("-o CORESET offset\n"); printf("-a Start PRB for PDSCH\n"); printf("-b Number of PRB for PDSCH\n"); @@ -1122,11 +1113,7 @@ int main(int argc, char **argv) UE_info->UE_sched_ctrl.harq_processes[harq_pid].ndi = !(trial&1); UE_info->UE_sched_ctrl.harq_processes[harq_pid].round = round; - if (css_flag == 0) { - nr_schedule_ue_spec(0, frame, slot); - } else { - nr_schedule_css_dlsch_phytest(0,frame,slot); - } + nr_schedule_ue_spec(0, frame, slot); Sched_INFO.module_id = 0; Sched_INFO.CC_id = 0; Sched_INFO.frame = frame; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index fb20092ed5..713679c4e3 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -3130,16 +3130,42 @@ uint8_t compute_precoding_information(NR_PUSCH_Config_t *pusch_Config, return nbits; } +uint16_t get_rb_bwp_dci(nr_dci_format_t format, + int ss_type, + uint16_t cset0_bwp_size, + uint16_t ul_bwp_size, + uint16_t dl_bwp_size, + uint16_t initial_ul_bwp_size, + uint16_t initial_dl_bwp_size) +{ + uint16_t N_RB; + if (format == NR_UL_DCI_FORMAT_0_0 || format == NR_UL_DCI_FORMAT_0_1) { + if(format == NR_UL_DCI_FORMAT_0_0 && ss_type == NR_SearchSpace__searchSpaceType_PR_common) + N_RB = initial_ul_bwp_size; + else + N_RB = ul_bwp_size; + } + else { + if(format == NR_DL_DCI_FORMAT_1_0 && ss_type == NR_SearchSpace__searchSpaceType_PR_common) { + N_RB = cset0_bwp_size ? cset0_bwp_size : initial_dl_bwp_size; + } + else + N_RB = dl_bwp_size; + } + return N_RB; +} + uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, const NR_BWP_UplinkCommon_t *initialUplinkBWP, const NR_CellGroupConfig_t *cg, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, nr_rnti_type_t rnti_type, - uint16_t N_RB, + int controlResourceSetId, int bwp_id, - NR_ControlResourceSetId_t coreset_id, - uint16_t cset0_bwp_size) { + uint16_t N_RB, + uint16_t alt_size) +{ uint16_t size = 0; uint16_t numRBG = 0; @@ -3184,20 +3210,18 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, srs_config = (ubwpd && ubwpd->srs_Config) ? ubwpd->srs_Config->choice.setup: NULL; } - int n_ul_bwp=1,n_dl_bwp=1; + int n_ul_bwp = 1,n_dl_bwp = 1; switch(format) { - /*Only sizes for 0_0 and 1_0 are correct at the moment*/ case NR_UL_DCI_FORMAT_0_0: /// fixed: Format identifier 1, Hop flag 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2 Time Domain assgnmt 4 --20 size += 20; dci_pdu->frequency_domain_assignment.nbits = (uint8_t)ceil(log2((N_RB * (N_RB + 1)) >>1)); // Freq domain assignment -- hopping scenario to be updated size += dci_pdu->frequency_domain_assignment.nbits; - int dci_10_size = nr_dci_size(initialDownlinkBWP,initialUplinkBWP,cg,dci_pdu,NR_DL_DCI_FORMAT_1_0, rnti_type, N_RB, bwp_id, coreset_id, cset0_bwp_size); - if(dci_10_size >= size) - size += dci_10_size - size; // Padding to match 1_0 size + if(alt_size >= size) + size += alt_size - size; // Padding to match 1_0 size else { - dci_pdu->frequency_domain_assignment.nbits -= (size - dci_10_size); - size = dci_10_size; + dci_pdu->frequency_domain_assignment.nbits -= (size - alt_size); + size = alt_size; } // UL/SUL indicator assumed to be 0 break; @@ -3237,11 +3261,12 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, if (pusch_Config->resourceAllocation == 0) dci_pdu->frequency_domain_assignment.nbits = numRBG; else if (pusch_Config->resourceAllocation == 1) - dci_pdu->frequency_domain_assignment.nbits = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); + dci_pdu->frequency_domain_assignment.nbits = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); else - dci_pdu->frequency_domain_assignment.nbits = ((int)ceil( log2( (N_RB*(N_RB+1))>>1 ) )>numRBG) ? (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) )+1 : numRBG+1; + dci_pdu->frequency_domain_assignment.nbits = ((int)ceil(log2((N_RB * (N_RB + 1)) >> 1)) > numRBG) ? (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)) + 1 : numRBG + 1; } - else dci_pdu->frequency_domain_assignment.nbits = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); + else + dci_pdu->frequency_domain_assignment.nbits = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); LOG_D(NR_MAC,"PUSCH Frequency Domain Assignment nbits %d, N_RB %d\n",dci_pdu->frequency_domain_assignment.nbits,N_RB); size += dci_pdu->frequency_domain_assignment.nbits; // Time domain assignment @@ -3357,14 +3382,10 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, // 3GPP TS 38.212 Section 7.3.1.0: DCI size alignment // Size of DCI format 1_0 is given by the size of CORESET 0 if CORESET 0 is configured for the cell and the size // of initial DL bandwidth part if CORESET 0 is not configured for the cell - if(cset0_bwp_size>0) { - N_RB = cset0_bwp_size; - } - size = 28; - size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment + size += (uint8_t)ceil(log2((N_RB * (N_RB + 1)) >> 1)); // Freq domain assignment - dci_pdu->frequency_domain_assignment.nbits = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); + dci_pdu->frequency_domain_assignment.nbits = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); dci_pdu->time_domain_assignment.nbits = 4; dci_pdu->vrb_to_prb_mapping.nbits = 1; break; @@ -3399,9 +3420,9 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, if (pdsch_Config && pdsch_Config->resourceAllocation == 0) dci_pdu->frequency_domain_assignment.nbits = numRBG; else if (pdsch_Config == NULL || pdsch_Config->resourceAllocation == 1) - dci_pdu->frequency_domain_assignment.nbits = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); + dci_pdu->frequency_domain_assignment.nbits = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); else - dci_pdu->frequency_domain_assignment.nbits = ((int)ceil( log2( (N_RB*(N_RB+1))>>1 ) )>numRBG) ? (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) )+1 : numRBG+1; + dci_pdu->frequency_domain_assignment.nbits = ((int)ceil(log2((N_RB * (N_RB + 1)) >> 1)) > numRBG) ? (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)) + 1 : numRBG + 1; size += dci_pdu->frequency_domain_assignment.nbits; LOG_D(NR_MAC,"dci_pdu->frequency_domain_assignment.nbits %d (N_RB %d)\n",dci_pdu->frequency_domain_assignment.nbits,N_RB); // Time domain assignment (see table 5.1.2.1.1-1 in 38.214 @@ -3478,7 +3499,7 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, LOG_D(NR_MAC,"dci_pdu->antenna_ports.nbits %d\n",dci_pdu->antenna_ports.nbits); // Tx Config Indication for (int i = 0; i < pdcch_Config->controlResourceSetToAddModList->list.count; i++) { - if (pdcch_Config->controlResourceSetToAddModList->list.array[i]->controlResourceSetId == coreset_id) { + if (pdcch_Config->controlResourceSetToAddModList->list.array[i]->controlResourceSetId == controlResourceSetId) { long *isTciEnable = pdcch_Config->controlResourceSetToAddModList->list.array[i]->tci_PresentInDCI; if (isTciEnable != NULL) { dci_pdu->transmission_configuration_indication.nbits = 3; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 7f88216cbd..06251fefb7 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -75,16 +75,24 @@ uint8_t compute_precoding_information(NR_PUSCH_Config_t *pusch_Config, const uint8_t *nrOfLayers, uint32_t *val); -uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDLBWP, - const NR_BWP_UplinkCommon_t *initialULBWP, +uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, + const NR_BWP_UplinkCommon_t *initialUplinkBWP, const NR_CellGroupConfig_t *cg, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, nr_rnti_type_t rnti_type, - uint16_t N_RB, + int controlResourceSetId, int bwp_id, - NR_ControlResourceSetId_t coreset_id, - uint16_t cset0_bwp_size); + uint16_t N_RB, + uint16_t alt_size); + +uint16_t get_rb_bwp_dci(nr_dci_format_t format, + int ss_type, + uint16_t cset0_bwp_size, + uint16_t ul_bwp_size, + uint16_t dl_bwp_size, + uint16_t initial_ul_bwp_size, + uint16_t initial_dl_bwp_size); void find_aggregation_candidates(uint8_t *aggregation_level, uint8_t *nr_of_candidates, diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index d465cbf2e7..4b4c92e406 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -615,6 +615,15 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, UL_BWP->cyclicprefix = UL_BWP->genericParameters.cyclicPrefix; UL_BWP->BWPSize = NRRIV2BW(UL_BWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); UL_BWP->BWPStart = NRRIV2PRBOFFSET(UL_BWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + + DL_BWP->initial_BWPSize = mac->scc ? NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE) : + NRRIV2BW(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + UL_BWP->initial_BWPSize = mac->scc ? NRRIV2BW(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE) : + NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + DL_BWP->initial_BWPStart = mac->scc ? NRRIV2PRBOFFSET(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE) : + NRRIV2PRBOFFSET(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + UL_BWP->initial_BWPStart = mac->scc ? NRRIV2PRBOFFSET(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE) : + NRRIV2PRBOFFSET(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 4eb3fdfe50..b3a3915993 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -377,6 +377,8 @@ typedef struct NR_DL_BWP { NR_BWP_t genericParameters; int scs; long *cyclicprefix; + uint16_t initial_BWPSize; + uint16_t initial_BWPStart; uint16_t BWPSize; uint16_t BWPStart; } NR_DL_BWP_t; @@ -386,6 +388,8 @@ typedef struct NR_UL_BWP { NR_BWP_t genericParameters; int scs; long *cyclicprefix; + uint16_t initial_BWPSize; + uint16_t initial_BWPStart; uint16_t BWPSize; uint16_t BWPStart; } NR_UL_BWP_t; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index ac2881435f..bf6b89f71c 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -455,6 +455,14 @@ void configure_ss_coreset(NR_UE_MAC_INST_t *mac, NR_ServingCellConfig_t *scd, NR_BWP_Id_t dl_bwp_id); +static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, + uint8_t dci_format, + uint8_t dci_size, + uint16_t rnti, + int ss_type, + uint64_t *dci_pdu, + dci_pdu_rel15_t *dci_pdu_rel15); + fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int slot); void fill_ul_config(fapi_nr_ul_config_request_t *ul_config, frame_t frame_tx, int slot_tx, uint8_t pdu_type); 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 b25b530176..0670c1cff0 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -87,7 +87,8 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss, } } -void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id){ +void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id) +{ uint16_t monitoringSymbolsWithinSlot = 0; int sps = 0; @@ -95,6 +96,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t AssertFatal(mac->scc == NULL || mac->scc_SIB == NULL, "both scc and scc_SIB cannot be non-null\n"); NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; + NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id; NR_ServingCellConfigCommon_t *scc = mac->scc; NR_ServingCellConfigCommonSIB_t *scc_SIB = mac->scc_SIB; @@ -122,7 +124,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t uint8_t coreset_id = *ss->controlResourceSetId; - if(coreset_id>0) { + if(coreset_id > 0) { coreset = mac->coreset[dl_bwp_id][coreset_id - 1]; rel15->coreset.CoreSetType = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG; } else { @@ -161,86 +163,131 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->coreset.pdcch_dmrs_scrambling_id = mac->physCellId; rel15->coreset.scrambling_rnti = 0; } - // loop over RNTI type and configure resource allocation for DCI - switch(rnti_type) { - case NR_RNTI_C: - // we use DL BWP dedicated - sps = current_DL_BWP->cyclicprefix ? 12 : 14; - // for SPS=14 8 MSBs in positions 13 down to 6 - monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); - rel15->rnti = mac->crnti; - rel15->BWPSize = current_DL_BWP->BWPSize; - rel15->BWPStart = current_DL_BWP->BWPStart; - rel15->SubcarrierSpacing = current_DL_BWP->scs; - for (int i = 0; i < rel15->num_dci_options; i++) { - rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_C, rel15->BWPSize, dl_bwp_id, coreset_id, mac->type0_PDCCH_CSS_config.num_rbs); - } - break; - case NR_RNTI_RA: - // we use the initial DL BWP - sps = current_DL_BWP->cyclicprefix == NULL ? 14 : 12; - monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); - rel15->rnti = mac->ra.ra_rnti; - if (get_softmodem_params()->sa) { - rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs; - rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; - } else { // NSA mode is not using the Initial BWP - rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - rel15->BWPStart = current_DL_BWP->BWPStart; - } - rel15->SubcarrierSpacing = current_DL_BWP->scs; - rel15->dci_length_options[0] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[0]], rel15->dci_format_options[0], NR_RNTI_RA, rel15->BWPSize, dl_bwp_id, coreset_id, mac->type0_PDCCH_CSS_config.num_rbs); - break; - case NR_RNTI_P: - break; - case NR_RNTI_CS: - break; - case NR_RNTI_TC: - // we use the initial DL BWP - sps = current_DL_BWP->cyclicprefix == NULL ? 14 : 12; - monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); - rel15->rnti = mac->ra.t_crnti; - rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs; - rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; - rel15->SubcarrierSpacing = current_DL_BWP->scs; - for (int i = 0; i < rel15->num_dci_options; i++) { - rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_TC, rel15->BWPSize, dl_bwp_id, coreset_id, mac->type0_PDCCH_CSS_config.num_rbs); + int N_RB; + for (int i = 0; i < rel15->num_dci_options; i++) { + rel15->dci_type_options[i] = ss->searchSpaceType->present; + const int dci_format = rel15->dci_format_options[i]; + uint16_t alt_size = 0; + if(current_DL_BWP) { + N_RB = get_rb_bwp_dci(dci_format, + ss->searchSpaceType->present, + mac->type0_PDCCH_CSS_config.num_rbs, + current_UL_BWP->BWPSize, + current_DL_BWP->BWPSize, + current_UL_BWP->initial_BWPSize, + current_DL_BWP->initial_BWPSize); + + // computing alternative size for padding + uint16_t alt_rb; + dci_pdu_rel15_t temp_pdu; + if(dci_format == NR_DL_DCI_FORMAT_1_0) { + alt_rb = get_rb_bwp_dci(NR_UL_DCI_FORMAT_0_0, + ss->searchSpaceType->present, + mac->type0_PDCCH_CSS_config.num_rbs, + current_UL_BWP->BWPSize, + current_DL_BWP->BWPSize, + current_UL_BWP->initial_BWPSize, + current_DL_BWP->initial_BWPSize); + + alt_size = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &temp_pdu, + NR_UL_DCI_FORMAT_0_0, rnti_type, coreset_id, dl_bwp_id, alt_rb, 0); } - break; - case NR_RNTI_SP_CSI: - break; - case NR_RNTI_SI: - sps=14; + if(dci_format == NR_UL_DCI_FORMAT_0_0) { + alt_rb = get_rb_bwp_dci(NR_DL_DCI_FORMAT_1_0, + ss->searchSpaceType->present, + mac->type0_PDCCH_CSS_config.num_rbs, + current_UL_BWP->BWPSize, + current_DL_BWP->BWPSize, + current_UL_BWP->initial_BWPSize, + current_DL_BWP->initial_BWPSize); - // for SPS=14 8 MSBs in positions 13 down to 6 - monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); - - rel15->rnti = SI_RNTI; // SI-RNTI - 3GPP TS 38.321 Table 7.1-1: RNTI values - rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs; - rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; - - if(mac->frequency_range == FR1) - rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon; - else - rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon + 2; - - for (int i = 0; i < rel15->num_dci_options; i++) { - rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_SI, rel15->BWPSize, 0, coreset_id, mac->type0_PDCCH_CSS_config.num_rbs); + alt_size = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &temp_pdu, + NR_DL_DCI_FORMAT_1_0, rnti_type, coreset_id, dl_bwp_id, alt_rb, 0); } - break; - case NR_RNTI_SFI: - break; - case NR_RNTI_INT: - break; - case NR_RNTI_TPC_PUSCH: - break; - case NR_RNTI_TPC_PUCCH: - break; - case NR_RNTI_TPC_SRS: - break; - default: - break; + } + else + N_RB = mac->type0_PDCCH_CSS_config.num_rbs; + switch(rnti_type) { + case NR_RNTI_C: + // we use DL BWP dedicated + sps = current_DL_BWP->cyclicprefix ? 12 : 14; + // for SPS=14 8 MSBs in positions 13 down to 6 + monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); + rel15->rnti = mac->crnti; + rel15->BWPSize = current_DL_BWP->BWPSize; + rel15->BWPStart = current_DL_BWP->BWPStart; + rel15->SubcarrierSpacing = current_DL_BWP->scs; + rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, + &mac->def_dci_pdu_rel15[dci_format], + dci_format, NR_RNTI_C, coreset_id, dl_bwp_id, N_RB, alt_size); + break; + case NR_RNTI_RA: + // we use the initial DL BWP + sps = current_DL_BWP->cyclicprefix == NULL ? 14 : 12; + monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); + rel15->rnti = mac->ra.ra_rnti; + if (get_softmodem_params()->sa) { + rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs; + rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; + } else { // NSA mode is not using the Initial BWP + rel15->BWPSize = current_DL_BWP->initial_BWPSize; + rel15->BWPStart = current_DL_BWP->BWPStart; + } + rel15->SubcarrierSpacing = current_DL_BWP->scs; + rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, + &mac->def_dci_pdu_rel15[dci_format], + dci_format, NR_RNTI_RA, coreset_id, dl_bwp_id, N_RB, alt_size); + break; + case NR_RNTI_P: + break; + case NR_RNTI_CS: + break; + case NR_RNTI_TC: + // we use the initial DL BWP + sps = current_DL_BWP->cyclicprefix == NULL ? 14 : 12; + monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); + rel15->rnti = mac->ra.t_crnti; + rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs; + rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; + rel15->SubcarrierSpacing = current_DL_BWP->scs; + rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, + mac->cg, &mac->def_dci_pdu_rel15[dci_format], + dci_format, NR_RNTI_TC, coreset_id, dl_bwp_id, N_RB, alt_size); + break; + case NR_RNTI_SP_CSI: + break; + case NR_RNTI_SI: + sps=14; + // for SPS=14 8 MSBs in positions 13 down to 6 + monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); + + rel15->rnti = SI_RNTI; // SI-RNTI - 3GPP TS 38.321 Table 7.1-1: RNTI values + rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs; + rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; + + if(mac->frequency_range == FR1) + rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon; + else + rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon + 2; + + rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, + &mac->def_dci_pdu_rel15[dci_format], + dci_format, NR_RNTI_SI, coreset_id, 0, mac->type0_PDCCH_CSS_config.num_rbs, alt_size); + break; + case NR_RNTI_SFI: + break; + case NR_RNTI_INT: + break; + case NR_RNTI_TPC_PUSCH: + break; + case NR_RNTI_TPC_PUCCH: + break; + case NR_RNTI_TPC_SRS: + break; + default: + break; + } } for (int i = 0; i < sps; i++) { if ((monitoringSymbolsWithinSlot >> (sps - 1 - i)) & 1) { diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index e2ba12380e..3b3c483ec0 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -130,13 +130,6 @@ const initial_pucch_resource_t initial_pucch_resource[16] = { }; -static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, - uint8_t dci_format, - uint8_t dci_length, - uint16_t rnti, - uint64_t *dci_pdu, - dci_pdu_rel15_t *nr_pdci_info_extracted); - void nr_ue_init_mac(module_id_t module_idP) { int i; @@ -170,7 +163,7 @@ void nr_ue_init_mac(module_id_t module_idP) { for (i = 0; i < NR_MAX_NUM_LCID; i++) { LOG_D(NR_MAC, "[UE%d] Applying default logical channel config for LCGID %d\n", - module_idP, i); + module_idP, i); mac->scheduling_info.Bj[i] = -1; mac->scheduling_info.bucket_size[i] = -1; @@ -626,7 +619,7 @@ int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_in LOG_D(MAC,"Received dci indication (rnti %x,dci format %d,n_CCE %d,payloadSize %d,payload %llx)\n", dci->rnti,dci->dci_format,dci->n_CCE,dci->payloadSize,*(unsigned long long*)dci->payloadBits); - int8_t ret = nr_extract_dci_info(mac, dci->dci_format, dci->payloadSize, dci->rnti, (uint64_t *)dci->payloadBits, def_dci_pdu_rel15); + int8_t ret = nr_extract_dci_info(mac, dci->dci_format, dci->payloadSize, dci->rnti, dci->ss_type, (uint64_t *)dci->payloadBits, def_dci_pdu_rel15); if ((ret&1) == 1) return -1; else if (ret == 2) { dci->dci_format = NR_UL_DCI_FORMAT_0_0; @@ -960,12 +953,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr nb_rb_oh, 0, 1); int bw_tbslbrm; - if (mac->scc || mac->scc_SIB || mac->cg) { - NR_BWP_t genericParameters = mac->scc ? mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters : - mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; - int BWPSize = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - bw_tbslbrm = get_dlbw_tbslbrm(BWPSize, mac->cg); - } + if (current_DL_BWP->initial_BWPSize > 0) + bw_tbslbrm = get_dlbw_tbslbrm(current_DL_BWP->initial_BWPSize, mac->cg); else bw_tbslbrm = dlsch_config_pdu_1_0->BWPSize; dlsch_config_pdu_1_0->tbslbrm = nr_compute_tbslbrm(dlsch_config_pdu_1_0->mcs_table, @@ -1397,8 +1386,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr long *maxMIMO_Layers = mac->cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers; AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); int nl_tbslbrm = *maxMIMO_Layers < 4 ? *maxMIMO_Layers : 4; - int BWPSize = current_DL_BWP->BWPSize; - int bw_tbslbrm = get_dlbw_tbslbrm(BWPSize, mac->cg); + int bw_tbslbrm = get_dlbw_tbslbrm(current_DL_BWP->initial_BWPSize, mac->cg); dlsch_config_pdu_1_1->tbslbrm = nr_compute_tbslbrm(dlsch_config_pdu_1_1->mcs_table, bw_tbslbrm, nl_tbslbrm); @@ -2805,65 +2793,39 @@ void nr_ue_send_sdu(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t *u } -// N_RB configuration according to 7.3.1.0 (DCI size alignment) of TS 38.212 -int get_n_rb(NR_UE_MAC_INST_t *mac, int rnti_type){ - - int N_RB = 0, start_RB; - NR_BWP_Id_t dl_bwp_id = mac->current_DL_BWP.bwp_id; - switch(rnti_type) { - case NR_RNTI_RA: - case NR_RNTI_TC: - case NR_RNTI_P: { - if (mac->DLbwp[dl_bwp_id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->controlResourceSetZero) { - uint8_t coreset_id = 0; // assuming controlResourceSetId is 0 for controlResourceSetZero - NR_ControlResourceSet_t *coreset = mac->coreset[dl_bwp_id][coreset_id]; - get_coreset_rballoc(coreset->frequencyDomainResources.buf,&N_RB,&start_RB); - } else { - N_RB = NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - } - break; - } - case NR_RNTI_SI: - N_RB = mac->type0_PDCCH_CSS_config.num_rbs; - break; - case NR_RNTI_C: - N_RB = NRRIV2BW(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - break; - } - return N_RB; - -} - static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, - uint8_t dci_format, - uint8_t dci_size, - uint16_t rnti, - uint64_t *dci_pdu, - dci_pdu_rel15_t *dci_pdu_rel15) { + uint8_t dci_format, + uint8_t dci_size, + uint16_t rnti, + int ss_type, + uint64_t *dci_pdu, + dci_pdu_rel15_t *dci_pdu_rel15) +{ - int N_RB = 0; int pos = 0; int fsize = 0; - int rnti_type = get_rnti_type(mac, rnti); NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id; - int N_RB_UL = current_UL_BWP->BWPSize; - + int N_RB; + if(current_DL_BWP) + N_RB = get_rb_bwp_dci(dci_format, + ss_type, + mac->type0_PDCCH_CSS_config.num_rbs, + current_UL_BWP->BWPSize, + current_DL_BWP->BWPSize, + current_UL_BWP->initial_BWPSize, + current_DL_BWP->initial_BWPSize); + else + N_RB = mac->type0_PDCCH_CSS_config.num_rbs; LOG_D(MAC,"nr_extract_dci_info : dci_pdu %lx, size %d\n",*dci_pdu,dci_size); switch(dci_format) { case NR_DL_DCI_FORMAT_1_0: switch(rnti_type) { case NR_RNTI_RA: - if(mac->scc_SIB) { - N_RB = mac->type0_PDCCH_CSS_config.num_rbs; - } else { - N_RB = get_n_rb(mac, rnti_type); - } // Freq domain assignment - fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); + fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); pos=fsize; dci_pdu_rel15->frequency_domain_assignment.val = *dci_pdu>>(dci_size-pos)&((1<format_indicator == 0) { dci_pdu_rel15 = &mac->def_dci_pdu_rel15[NR_UL_DCI_FORMAT_0_0]; - return 2+nr_extract_dci_info(mac, NR_UL_DCI_FORMAT_0_0, dci_size, rnti, dci_pdu, dci_pdu_rel15); + return 2+nr_extract_dci_info(mac, NR_UL_DCI_FORMAT_0_0, dci_size, rnti, ss_type, dci_pdu, dci_pdu_rel15); } #ifdef DEBUG_EXTRACT_DCI LOG_D(MAC,"Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,N_RB,dci_size-pos,*dci_pdu); #endif - N_RB = current_DL_BWP->BWPSize; - // Freq domain assignment (275rb >> fsize = 16) - fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); + // Freq domain assignment (275rb >> fsize = 16) + fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); pos+=fsize; dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<type0_PDCCH_CSS_config.num_rbs; // Freq domain assignment 0-16 bit - fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); + fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); pos+=fsize; dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<0 && mac->DLbwp[dl_bwp_id-1]) N_RB=NRRIV2BW(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - else N_RB=mac->type0_PDCCH_CSS_config.num_rbs; - - // indicating a DL DCI format 1bit pos++; dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1; @@ -3103,14 +3058,14 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, //switch to DCI_0_0 if (dci_pdu_rel15->format_indicator == 0) { dci_pdu_rel15 = &mac->def_dci_pdu_rel15[NR_UL_DCI_FORMAT_0_0]; - return 2+nr_extract_dci_info(mac, NR_UL_DCI_FORMAT_0_0, dci_size, rnti, dci_pdu, dci_pdu_rel15); + return 2+nr_extract_dci_info(mac, NR_UL_DCI_FORMAT_0_0, dci_size, rnti, ss_type, dci_pdu, dci_pdu_rel15); } if (dci_pdu_rel15->format_indicator == 0) return 1; // discard dci, format indicator not corresponding to dci_format // Freq domain assignment 0-16 bit - fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); + fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); pos+=fsize; dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<bwp_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<bwp_indicator.nbits)-1); // Freq domain assignment max 16 bit - fsize = (int)ceil( log2( (N_RB_UL*(N_RB_UL+1))>>1 ) ); + fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); pos+=fsize; dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1< 0 ? mac->ULbwp[ul_bwp_id - 1] : NULL; NR_BWP_UplinkDedicated_t *ibwp; - int scs,abwp_start,abwp_size,startSymbolAndLength,mappingtype; + int startSymbolAndLength,mappingtype; NR_PUSCH_Config_t *pusch_Config=NULL; if (mac->cg && ubwp && mac->cg->spCellConfig && @@ -587,22 +587,16 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[rar_grant->Msg3_t_alloc]->startSymbolAndLength; mappingtype = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[rar_grant->Msg3_t_alloc]->mappingType; - // active BWP start - abwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - abwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - scs = ubwp->bwp_Common->genericParameters.subcarrierSpacing; } else { startSymbolAndLength = initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[rar_grant->Msg3_t_alloc]->startSymbolAndLength; mappingtype = initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[rar_grant->Msg3_t_alloc]->mappingType; - - // active BWP start - abwp_start = NRRIV2PRBOFFSET(initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - abwp_size = NRRIV2BW(initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - scs = initialUplinkBWP->genericParameters.subcarrierSpacing; } - int ibwp_start = NRRIV2PRBOFFSET(initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int ibwp_size = NRRIV2BW(initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int ibwp_start = current_UL_BWP->initial_BWPStart; + int ibwp_size = current_UL_BWP->initial_BWPSize; + int abwp_start = current_UL_BWP->BWPStart; + int abwp_size = current_UL_BWP->BWPSize; + int scs = current_UL_BWP->scs; // BWP start selection according to 8.3 of TS 38.213 if ((ibwp_start < abwp_start) || (ibwp_size > abwp_size)) { @@ -862,15 +856,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, if (!maxMIMO_Layers) maxMIMO_Layers = pusch_Config ? pusch_Config->maxRank : NULL; AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); - int bw_tbslbrm; - if (mac->scc || mac->scc_SIB || mac->cg) { - NR_BWP_t genericParameters = initialUplinkBWP->genericParameters; - int BWPSize = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - bw_tbslbrm = get_ulbw_tbslbrm(BWPSize, mac->cg); - } - else { - bw_tbslbrm = pusch_config_pdu->bwp_size; - } + int bw_tbslbrm = get_ulbw_tbslbrm(current_UL_BWP->initial_BWPSize, mac->cg); pusch_config_pdu->tbslbrm = nr_compute_tbslbrm(pusch_config_pdu->mcs_table, bw_tbslbrm, *maxMIMO_Layers); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 35850a1a2d..0d9bb25291 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -731,8 +731,8 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t uint16_t *vrb_map_UL = &RC.nrmac[module_idP]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; - const int BWPSize = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - const int BWPStart = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + const int BWPSize = ul_bwp->initial_BWPSize; + const int BWPStart = ul_bwp->initial_BWPStart; int rbStart = 0; for (int i = 0; (i < ra->msg3_nb_rb) && (rbStart <= (BWPSize - ra->msg3_nb_rb)); i++) { @@ -830,17 +830,18 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t ra->Msg3_tda_id, ra->msg3_TPC, 1, // Not toggling NDI in msg3 retransmissions - &ra->UL_BWP); + ul_bwp); fill_dci_pdu_rel15(scc, ra->CellGroup, &ra->DL_BWP, + ul_bwp, dci_pdu, &uldci_payload, NR_UL_DCI_FORMAT_0_0, NR_RNTI_TC, - pusch_pdu->bwp_size, ul_bwp->bwp_id, + ss, coreset, nr_mac->cset0_bwp_size); @@ -953,9 +954,8 @@ void nr_get_Msg3alloc(module_id_t module_id, uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[ra->Msg3_slot * MAX_BWP_SIZE]; - int bwpSize = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int bwpStart = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - + int bwpSize = ul_bwp->initial_BWPSize; + int bwpStart = ul_bwp->initial_BWPStart; if (bwpSize != ul_bwp->BWPSize || bwpStart != ul_bwp->BWPStart) { int act_bwp_start = ul_bwp->BWPStart; int act_bwp_size = ul_bwp->BWPSize; @@ -1104,7 +1104,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t nfapi_nr_pusch_pdu_t *pusch_pdu = &future_ul_tti_req->pdus_list[future_ul_tti_req->n_pdus].pusch_pdu; memset(pusch_pdu, 0, sizeof(nfapi_nr_pusch_pdu_t)); - const int ibwp_size = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + const int ibwp_size = ul_bwp->initial_BWPSize; const int scs = ul_bwp->scs; const int fh = (ul_bwp->pusch_Config && ul_bwp->pusch_Config->frequencyHopping) ? 1 : 0; const int startSymbolAndLength = ul_bwp->tdaList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; @@ -1153,7 +1153,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = NULL; if(*ss->controlResourceSetId!=0) { BWPStart = dl_bwp->BWPStart; - BWPSize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + BWPSize = dl_bwp->initial_BWPSize; } else { type0_PDCCH_CSS_config = &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]; BWPStart = type0_PDCCH_CSS_config->cset_start_rb; @@ -1290,8 +1290,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->TBSize[0] = TBS; } - int scc_bwpsize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int bw_tbslbrm = get_dlbw_tbslbrm(scc_bwpsize, ra->CellGroup); + int bw_tbslbrm = get_dlbw_tbslbrm(dl_bwp->initial_BWPSize, ra->CellGroup); pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(mcsTableIdx, bw_tbslbrm, 1); @@ -1345,12 +1344,13 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra fill_dci_pdu_rel15(scc, ra->CellGroup, dl_bwp, + &ra->UL_BWP, &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci - 1], &dci_payload, NR_DL_DCI_FORMAT_1_0, NR_RNTI_RA, - BWPSize, dl_bwp->bwp_id, + ss, coreset, nr_mac->cset0_bwp_size); @@ -1676,8 +1676,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra int x_Overhead = 0; nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu, x_Overhead, pdsch_pdu_rel15->numDmrsCdmGrpsNoData, tb_scaling); - int scc_bwpsize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int bw_tbslbrm = get_dlbw_tbslbrm(scc_bwpsize, ra->CellGroup); + int bw_tbslbrm = get_dlbw_tbslbrm(dl_bwp->initial_BWPSize, ra->CellGroup); pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(mcsTableIdx, bw_tbslbrm, 1); @@ -1744,12 +1743,13 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra fill_dci_pdu_rel15(scc, ra->CellGroup, dl_bwp, + &ra->UL_BWP, &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci - 1], &dci_payload, NR_DL_DCI_FORMAT_1_0, NR_RNTI_TC, - pdsch_pdu_rel15->BWPSize, dl_bwp->bwp_id, + ss, coreset, nr_mac->cset0_bwp_size); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 0438070da3..dc2467e904 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -494,14 +494,15 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, int rnti_type = NR_RNTI_SI; fill_dci_pdu_rel15(scc, + NULL, NULL, NULL, &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci - 1], &dci_payload, dci_format, rnti_type, - pdsch_pdu_rel15->BWPSize, 0, + gNB_mac->sched_ctrlCommon->search_space, gNB_mac->sched_ctrlCommon->coreset, gNB_mac->cset0_bwp_size); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index c400a8ac13..d5b2b79036 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -1012,7 +1012,7 @@ void nr_schedule_ue_spec(module_id_t module_id, long maxMIMO_Layers = current_BWP->pdsch_servingcellconfig ? *current_BWP->pdsch_servingcellconfig->ext1->maxMIMO_Layers : 1; const int nl_tbslbrm = min(maxMIMO_Layers, 4); // Maximum number of PRBs across all configured DL BWPs - int scc_bwpsize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int scc_bwpsize = current_BWP->initial_BWPSize; int bw_tbslbrm = get_dlbw_tbslbrm(scc_bwpsize, cg); pdsch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(current_BWP->mcsTableIdx, bw_tbslbrm, @@ -1110,12 +1110,13 @@ void nr_schedule_ue_spec(module_id_t module_id, fill_dci_pdu_rel15(scc, cg, current_BWP, + &UE->current_UL_BWP, dci_pdu, &dci_payload, current_BWP->dci_format, rnti_type, - pdsch_pdu->BWPSize, bwp_id, + sched_ctrl->search_space, sched_ctrl->coreset, gNB_mac->cset0_bwp_size); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index da84ccd18f..2ce7877eb7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -55,130 +55,6 @@ extern RAN_CONTEXT_t RC; //#define ENABLE_MAC_PAYLOAD_DEBUG 1 -/*Scheduling of DLSCH with associated DCI in common search space - * current version has only a DCI for type 1 PDCCH for C_RNTI*/ -void nr_schedule_css_dlsch_phytest(module_id_t module_idP, - frame_t frameP, - sub_frame_t slotP) { - uint8_t CC_id; - gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; - NR_COMMON_channels_t *cc = &nr_mac->common_channels[0]; - nfapi_nr_dl_tti_request_body_t *dl_req; - nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu; - nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu; - nfapi_nr_pdu_t *TX_req; - - uint16_t rnti = 0x1234; - // int time_domain_assignment,k0; - - NR_ServingCellConfigCommon_t *scc=cc->ServingCellConfigCommon; - - int dlBWP_carrier_bandwidth = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - - - /* - int scs = scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing; - - int slots_per_frame = 10*(1<downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0] >= 257 ? nr_FR2 : nr_FR1; - */ - - for (CC_id=0; CC_iddownlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE)); - - - dl_req = &nr_mac->DL_req[CC_id].dl_tti_request_body; - dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; - memset((void*)dl_tti_pdcch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); - dl_tti_pdcch_pdu->PDUType = NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE; - dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); - - dl_tti_pdsch_pdu = &nr_mac->DL_req[CC_id].dl_tti_request_body.dl_tti_pdu_list[nr_mac->DL_req[CC_id].dl_tti_request_body.nPDUs+1]; - memset((void *)dl_tti_pdsch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t)); - dl_tti_pdsch_pdu->PDUType = NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE; - dl_tti_pdsch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdsch_pdu)); - - - // nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15; - - pdsch_pdu_rel15->pduBitmap = 0; - pdsch_pdu_rel15->rnti = rnti; - pdsch_pdu_rel15->pduIndex = 0; - - // BWP - pdsch_pdu_rel15->BWPSize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - pdsch_pdu_rel15->BWPStart = NRRIV2PRBOFFSET(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - pdsch_pdu_rel15->SubcarrierSpacing = scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing; - pdsch_pdu_rel15->CyclicPrefix = 0; - pdsch_pdu_rel15->NrOfCodewords = 1; - int mcsIndex = 9; - pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcsIndex,0); - pdsch_pdu_rel15->qamModOrder[0] = 2; - pdsch_pdu_rel15->mcsIndex[0] = mcsIndex; - pdsch_pdu_rel15->mcsTable[0] = 0; - pdsch_pdu_rel15->rvIndex[0] = 0; - pdsch_pdu_rel15->dataScramblingId = *scc->physCellId; - pdsch_pdu_rel15->nrOfLayers = 1; - pdsch_pdu_rel15->transmissionScheme = 0; - pdsch_pdu_rel15->refPoint = 0; // Point A - - pdsch_pdu_rel15->dmrsConfigType = 0; // Type 1 by default for InitialBWP - pdsch_pdu_rel15->dlDmrsScramblingId = *scc->physCellId; - pdsch_pdu_rel15->SCID = 0; - pdsch_pdu_rel15->numDmrsCdmGrpsNoData = 1; - pdsch_pdu_rel15->dmrsPorts = 1; - pdsch_pdu_rel15->resourceAlloc = 1; - pdsch_pdu_rel15->rbStart = 0; - pdsch_pdu_rel15->rbSize = 6; - pdsch_pdu_rel15->VRBtoPRBMapping = 1; // non-interleaved, check if this is ok for initialBWP - // choose shortest PDSCH - int startSymbolAndLength=0; - int StartSymbolIndex=-1,NrOfSymbols=14; - int StartSymbolIndex_tmp,NrOfSymbols_tmp; - int mappingtype_tmp, mappingtype=0; - - for (int i=0; - idownlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count; - i++) { - startSymbolAndLength = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength; - SLIV2SL(startSymbolAndLength,&StartSymbolIndex_tmp,&NrOfSymbols_tmp); - mappingtype_tmp = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->mappingType; - if (NrOfSymbols_tmp < NrOfSymbols) { - NrOfSymbols = NrOfSymbols_tmp; - StartSymbolIndex = StartSymbolIndex_tmp; - mappingtype = mappingtype_tmp; - } - } - AssertFatal(StartSymbolIndex>=0,"StartSymbolIndex is negative\n"); - pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex; - pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols; - pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(NULL, - scc->dmrs_TypeA_Position, - NrOfSymbols, - StartSymbolIndex, - mappingtype, - 1); - - nr_mac->DL_req[CC_id].dl_tti_request_body.nPDUs+=2; - - TX_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs]; - TX_req->PDU_length = 6; - TX_req->PDU_index = nr_mac->pdu_index[CC_id]++; - TX_req->num_TLV = 1; - TX_req->TLVs[0].length = 8; - // why do we copy from RAR_pdu here? Shouldn't we fill some more or less - // meaningful data, e.g., padding + random data? - //memcpy((void *)&TX_req->TLVs[0].value.direct[0], (void *)&cc[CC_id].RAR_pdu[0].payload[0], TX_req->TLVs[0].length); - nr_mac->TX_req[CC_id].Number_of_PDUs++; - nr_mac->TX_req[CC_id].SFN=frameP; - nr_mac->TX_req[CC_id].Slot=slotP; - } -} - uint32_t target_dl_mcs = 9; uint32_t target_dl_Nl = 1; uint32_t target_dl_bw = 50; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 403ae15df7..5e8e0f3709 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1384,28 +1384,71 @@ void prepare_dci(const NR_CellGroupConfig_t *CellGroup, void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, const NR_CellGroupConfig_t *CellGroup, - const NR_UE_DL_BWP_t *current_BWP, + const NR_UE_DL_BWP_t *current_DL_BWP, + const NR_UE_UL_BWP_t *current_UL_BWP, nfapi_nr_dl_dci_pdu_t *pdcch_dci_pdu, dci_pdu_rel15_t *dci_pdu_rel15, int dci_format, int rnti_type, - int N_RB, int bwp_id, + NR_SearchSpace_t *ss, NR_ControlResourceSet_t *coreset, - uint16_t cset0_bwp_size) { - uint8_t fsize = 0, pos = 0; + uint16_t cset0_bwp_size) +{ + uint8_t fsize = 0, pos = 0; uint64_t *dci_pdu = (uint64_t *)pdcch_dci_pdu->Payload; - *dci_pdu=0; - NR_ControlResourceSetId_t coreset_id = coreset->controlResourceSetId; + *dci_pdu = 0; + uint16_t alt_size = 0; + uint16_t N_RB; + const int controlResourceSetId = *ss->controlResourceSetId; + if(current_DL_BWP) { + N_RB = get_rb_bwp_dci(dci_format, + ss->searchSpaceType->present, + cset0_bwp_size, + current_UL_BWP->BWPSize, + current_DL_BWP->BWPSize, + current_UL_BWP->initial_BWPSize, + current_DL_BWP->initial_BWPSize); + + // computing alternative size for padding + uint16_t alt_rb; + dci_pdu_rel15_t temp_pdu; + if(dci_format == NR_DL_DCI_FORMAT_1_0) { + alt_rb = get_rb_bwp_dci(NR_UL_DCI_FORMAT_0_0, + ss->searchSpaceType->present, + cset0_bwp_size, + current_UL_BWP->BWPSize, + current_DL_BWP->BWPSize, + current_UL_BWP->initial_BWPSize, + current_DL_BWP->initial_BWPSize); + alt_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP, + scc->uplinkConfigCommon->initialUplinkBWP, + CellGroup, &temp_pdu, NR_UL_DCI_FORMAT_0_0, rnti_type, controlResourceSetId, bwp_id, alt_rb, 0); + + } + if(dci_format == NR_UL_DCI_FORMAT_0_0) { + alt_rb = get_rb_bwp_dci(NR_DL_DCI_FORMAT_1_0, + ss->searchSpaceType->present, + cset0_bwp_size, + current_UL_BWP->BWPSize, + current_DL_BWP->BWPSize, + current_UL_BWP->initial_BWPSize, + current_DL_BWP->initial_BWPSize); + alt_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP, + scc->uplinkConfigCommon->initialUplinkBWP, + CellGroup, &temp_pdu, NR_DL_DCI_FORMAT_1_0, rnti_type, controlResourceSetId, bwp_id, alt_rb, 0); + } + } + else + N_RB = cset0_bwp_size; int dci_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP, scc->uplinkConfigCommon->initialUplinkBWP, - CellGroup, dci_pdu_rel15, dci_format, - rnti_type, N_RB, bwp_id, coreset_id, cset0_bwp_size); + CellGroup, dci_pdu_rel15, dci_format, rnti_type, controlResourceSetId, bwp_id, N_RB, alt_size); pdcch_dci_pdu->PayloadSizeBits = dci_size; AssertFatal(dci_size <= 64, "DCI sizes above 64 bits not yet supported"); if (dci_format == NR_DL_DCI_FORMAT_1_1 || dci_format == NR_UL_DCI_FORMAT_0_1) - prepare_dci(CellGroup, current_BWP, coreset, dci_pdu_rel15, dci_format); + prepare_dci(CellGroup, current_DL_BWP, coreset, dci_pdu_rel15, dci_format); /// Payload generation switch (dci_format) { @@ -2389,7 +2432,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, UL_BWP->tdaList = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; // setting generic parameters - NR_BWP_t dl_genericParameters = (DL_BWP->bwp_id>0 && dl_bwp) ? + NR_BWP_t dl_genericParameters = (DL_BWP->bwp_id > 0 && dl_bwp) ? dl_bwp->bwp_Common->genericParameters: scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; @@ -2397,8 +2440,10 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, 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); + DL_BWP->initial_BWPSize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + DL_BWP->initial_BWPStart = NRRIV2PRBOFFSET(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - NR_BWP_t ul_genericParameters = (UL_BWP->bwp_id>0 && ul_bwp) ? + NR_BWP_t ul_genericParameters = (UL_BWP->bwp_id > 0 && ul_bwp) ? ul_bwp->bwp_Common->genericParameters: scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; @@ -2406,6 +2451,8 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, 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); + UL_BWP->initial_BWPSize = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + UL_BWP->initial_BWPStart = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); // Set downlink MCS table if (DL_BWP->pdsch_Config && diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 0d25e160fa..e1c47559b8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -263,7 +263,7 @@ int nr_process_mac_pdu(instance_t module_idP, // in sched_ctrl we set normalized PH wrt MCS and PRBs long *deltaMCS = ul_bwp->pusch_Config ? ul_bwp->pusch_Config->pusch_PowerControl->deltaMCS : NULL; sched_ctrl->ph = PH + - compute_ph_factor(sched_pusch->mu, + compute_ph_factor(ul_bwp->scs, sched_pusch->tb_size<<3, sched_pusch->rbSize, sched_pusch->nrOfLayers, @@ -1757,7 +1757,6 @@ void pf_ul(module_id_t module_id, /* Calculate the current scheduling bytes */ const int B = cmax(sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes, 0); /* adjust rbSize and MCS according to PHR and BPRE */ - sched_pusch->mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; if(sched_ctrl->pcmax!=0 || sched_ctrl->ph!=0) // verify if the PHR related parameter have been initialized nr_ue_max_mcs_min_rb(current_BWP->scs, sched_ctrl->ph, sched_pusch, current_BWP, min_rb, B, &max_rbSize, &sched_pusch->mcs); @@ -2162,7 +2161,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) if (!maxMIMO_Layers) maxMIMO_Layers = current_BWP->pusch_Config->maxRank; AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); - const int scc_bwpsize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + const int scc_bwpsize = current_BWP->initial_BWPSize; int bw_tbslbrm = get_ulbw_tbslbrm(scc_bwpsize, cg); pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(current_BWP->mcs_table, bw_tbslbrm, @@ -2260,12 +2259,13 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) fill_dci_pdu_rel15(scc, cg, &UE->current_DL_BWP, + current_BWP, dci_pdu, &uldci_payload, current_BWP->dci_format, rnti_types[0], - pusch_pdu->bwp_size, current_BWP->bwp_id, + ss, coreset, nr_mac->cset0_bwp_size); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index fc569c4eee..93180a7937 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -171,10 +171,6 @@ void nr_preprocessor_phytest(module_id_t module_id, * fixed set of resources */ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_t slot); -void nr_schedule_css_dlsch_phytest(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP); - void handle_nr_uci_pucch_0_1(module_id_t mod_id, frame_t frame, sub_frame_t slot, @@ -289,13 +285,14 @@ void fill_pdcch_vrb_map(gNB_MAC_INST *mac, void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, const NR_CellGroupConfig_t *CellGroup, - const NR_UE_DL_BWP_t *dl_bwp, + const NR_UE_DL_BWP_t *current_DL_BWP, + const NR_UE_UL_BWP_t *current_UL_BWP, nfapi_nr_dl_dci_pdu_t *pdcch_dci_pdu, dci_pdu_rel15_t *dci_pdu_rel15, - int dci_formats, - int rnti_types, - int N_RB, + int dci_format, + int rnti_type, int bwp_id, + NR_SearchSpace_t *ss, NR_ControlResourceSet_t *coreset, uint16_t cset0_bwp_size); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 27cf3fb1a2..7697d74808 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -99,6 +99,8 @@ typedef struct NR_UE_DL_BWP { long *cyclicprefix; uint16_t BWPSize; uint16_t BWPStart; + uint16_t initial_BWPSize; + uint16_t initial_BWPStart; NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList; NR_PDSCH_Config_t *pdsch_Config; NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig; @@ -113,6 +115,8 @@ typedef struct NR_UE_UL_BWP { long *cyclicprefix; uint16_t BWPSize; uint16_t BWPStart; + uint16_t initial_BWPSize; + uint16_t initial_BWPStart; NR_PUSCH_ServingCellConfig_t *pusch_servingcellconfig; NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList; NR_PUSCH_Config_t *pusch_Config; From 5300c57f3d888e795dafc283eefbc686351bed24 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 27 Dec 2022 18:07:39 +0100 Subject: [PATCH 3/4] common BWP structure and further improvements --- common/utils/nr/nr_common.h | 4 +- .../nfapi/public_inc/fapi_nr_ue_interface.h | 2 + openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 3 + openair1/PHY/defs_nr_common.h | 7 -- openair1/PHY/impl_defs_nr.h | 5 -- openair1/PHY/impl_defs_top.h | 3 +- openair1/SCHED_NR_UE/harq_nr.h | 9 -- openair2/LAYER2/NR_MAC_COMMON/nr_mac.h | 44 ++++++++- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 32 ++++--- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 10 ++- openair2/LAYER2/NR_MAC_UE/config_ue.c | 40 +++++---- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 31 ++----- openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 2 +- .../NR_MAC_UE/nr_ue_dci_configuration.c | 89 ++++++------------- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 81 ++++++++--------- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 13 +-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 2 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 35 +++----- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 38 -------- 19 files changed, 189 insertions(+), 261 deletions(-) diff --git a/common/utils/nr/nr_common.h b/common/utils/nr/nr_common.h index 8cd210dec8..db0802a205 100644 --- a/common/utils/nr/nr_common.h +++ b/common/utils/nr/nr_common.h @@ -37,7 +37,9 @@ #include "assertions.h" #include "PHY/defs_common.h" -#define MAX_BWP_SIZE 275 +#define MAX_BWP_SIZE 275 +#define NR_MAX_NUM_BWP 4 +#define NR_MAX_HARQ_PROCESSES 16 typedef struct nr_bandentry_s { int16_t band; diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index ebfb2becb0..0ddc0986bd 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -22,6 +22,7 @@ #include "platform_types.h" #include "fapi_nr_ue_constants.h" #include "PHY/impl_defs_nr.h" +#include "common/utils/nr/nr_common.h" #define NFAPI_UE_MAX_NUM_CB 8 #define NFAPI_MAX_NUM_UL_PDU 255 @@ -91,6 +92,7 @@ typedef struct { int n_CCE; // N_CCE is L, or number of CCEs for DCI int N_CCE; + int cset_start; uint8_t payloadSize; uint8_t payloadBits[16] __attribute__((aligned(16))); // will be cast as uint64 } fapi_nr_dci_indication_pdu_t; diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 658b440c21..5293d13f90 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -936,6 +936,9 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, dci_ind->dci_list[dci_ind->number_of_dcis].N_CCE = L; dci_ind->dci_list[dci_ind->number_of_dcis].dci_format = rel15->dci_format_options[k]; dci_ind->dci_list[dci_ind->number_of_dcis].ss_type = rel15->dci_type_options[k]; + int n_rb, rb_offset; + get_coreset_rballoc(rel15->coreset.frequency_domain_resource, &n_rb, &rb_offset); + dci_ind->dci_list[dci_ind->number_of_dcis].cset_start = rel15->BWPStart + rb_offset; dci_ind->dci_list[dci_ind->number_of_dcis].payloadSize = dci_length; memcpy((void*)dci_ind->dci_list[dci_ind->number_of_dcis].payloadBits,(void*)dci_estimation,8); dci_ind->number_of_dcis++; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index fe0397970b..a73ce9b4c4 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -80,8 +80,6 @@ #define NR_MAX_DCI_SIZE 1728 //16(L)*2(QPSK)*9(12 RE per REG - 3(DMRS))*6(REG per CCE) #define NR_MAX_DCI_SIZE_DWORD 54 // ceil(NR_MAX_DCI_SIZE/32) -#define NR_MAX_NUM_BWP 4 - #define NR_MAX_PDCCH_AGG_LEVEL 16 // 3GPP TS 38.211 V15.8 Section 7.3.2 Table 7.3.2.1-1: Supported PDCCH aggregation levels #define NR_MAX_CSET_DURATION 3 @@ -158,11 +156,6 @@ typedef enum { MOD_QAM256 }nr_mod_t; -typedef enum { - RA_2STEP = 0, - RA_4STEP -} nr_ra_type_e; - typedef struct { /// Size of first RBG uint8_t start_size; diff --git a/openair1/PHY/impl_defs_nr.h b/openair1/PHY/impl_defs_nr.h index 6db54684e6..8dcb383892 100644 --- a/openair1/PHY/impl_defs_nr.h +++ b/openair1/PHY/impl_defs_nr.h @@ -364,11 +364,6 @@ typedef enum { pusch_dmrs_type2 = 1 } pusch_dmrs_type_t; -typedef enum { - pusch_len1 = 1, - pusch_len2 = 2 -} pusch_maxLength_t; - typedef enum { txConfig_codebook = 1, txConfig_nonCodebook = 2 diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h index e082db54fb..6afbd1bf2b 100644 --- a/openair1/PHY/impl_defs_top.h +++ b/openair1/PHY/impl_defs_top.h @@ -107,6 +107,7 @@ * @} */ +#include #include #include "defs_eNB.h" #include "types.h" @@ -277,8 +278,6 @@ #define DURATION_RX_TO_TX (6) /* For LTE, this duration is fixed to 4 and it is linked to LTE standard for both modes FDD/TDD */ #endif - -#define NR_MAX_HARQ_PROCESSES (16) #define NR_MAX_ULSCH_HARQ_PROCESSES (NR_MAX_HARQ_PROCESSES) /* cf 38.214 6.1 UE procedure for receiving the physical uplink shared channel */ #define NR_MAX_DLSCH_HARQ_PROCESSES (NR_MAX_HARQ_PROCESSES) /* cf 38.214 5.1 UE procedure for receiving the physical downlink shared channel */ #endif diff --git a/openair1/SCHED_NR_UE/harq_nr.h b/openair1/SCHED_NR_UE/harq_nr.h index f640d0f7be..9ecdb4a8c9 100644 --- a/openair1/SCHED_NR_UE/harq_nr.h +++ b/openair1/SCHED_NR_UE/harq_nr.h @@ -35,15 +35,6 @@ /************** DEFINE ********************************************/ -#if 0 - -/* these define are in file PHY/impl_defs_top.h" because of compilation problems due to multiple header files inclusions */ -#define NR_MAX_HARQ_PROCESSES (16) -#define NR_MAX_ULSCH_HARQ_PROCESSES (NR_MAX_HARQ_PROCESSES) /* TS 38.214 6.1 UE procedure for receiving the physical uplink shared channel */ -#define NR_MAX_DLSCH_HARQ_PROCESSES (NR_MAX_HARQ_PROCESSES) /* TS 38.214 5.1 UE procedure for receiving the physical downlink shared channel */ - -#endif - #define NR_DEFAULT_DLSCH_HARQ_PROCESSES (8) /* TS 38.214 5.1 */ #define DL_ACKNACK_NO_SET (2) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index 1f98723deb..fec7e90178 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -37,10 +37,8 @@ #include #include #include - -#include "NR_SubcarrierSpacing.h" -#include "NR_CSI-ReportConfig.h" -#include "openair1/SCHED_NR_UE/harq_nr.h" +#include "common/utils/nr/nr_common.h" +#include "NR_CellGroupConfig.h" #define NR_SHORT_BSR_TABLE_SIZE 32 #define NR_LONG_BSR_TABLE_SIZE 256 @@ -567,5 +565,43 @@ typedef struct nr_srs_feedback { uint8_t tpmi; } nr_srs_feedback_t; +typedef struct NR_UE_DL_BWP { + NR_BWP_Id_t bwp_id; + int n_dl_bwp; + int scs; + long *cyclicprefix; + uint16_t BWPSize; + uint16_t BWPStart; + uint16_t initial_BWPSize; + uint16_t initial_BWPStart; + NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList; + NR_PDSCH_Config_t *pdsch_Config; + NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig; + uint8_t mcsTableIdx; + nr_dci_format_t dci_format; +} NR_UE_DL_BWP_t; + +typedef struct NR_UE_UL_BWP { + NR_BWP_Id_t bwp_id; + int n_ul_bwp; + int scs; + long *cyclicprefix; + uint16_t BWPSize; + uint16_t BWPStart; + uint16_t initial_BWPSize; + uint16_t initial_BWPStart; + NR_PUSCH_ServingCellConfig_t *pusch_servingcellconfig; + NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList; + NR_PUSCH_Config_t *pusch_Config; + NR_PUCCH_Config_t *pucch_Config; + NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon; + NR_CSI_MeasConfig_t *csi_MeasConfig; + NR_SRS_Config_t *srs_Config; + uint8_t transform_precoding; + uint8_t mcs_table; + nr_dci_format_t dci_format; + int max_fb_time; +} NR_UE_UL_BWP_t; + #endif /*__LAYER2_MAC_H__ */ diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 713679c4e3..8ddb01a053 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -3157,13 +3157,16 @@ uint16_t get_rb_bwp_dci(nr_dci_format_t format, uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, const NR_BWP_UplinkCommon_t *initialUplinkBWP, + const NR_UE_DL_BWP_t *DL_BWP, + const NR_UE_UL_BWP_t *UL_BWP, const NR_CellGroupConfig_t *cg, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, nr_rnti_type_t rnti_type, int controlResourceSetId, int bwp_id, - uint16_t N_RB, + int ss_type, + uint16_t cset0_bwp_size, uint16_t alt_size) { @@ -3210,6 +3213,16 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, srs_config = (ubwpd && ubwpd->srs_Config) ? ubwpd->srs_Config->choice.setup: NULL; } + uint16_t N_RB = cset0_bwp_size; + if (DL_BWP) + N_RB = get_rb_bwp_dci(format, + ss_type, + cset0_bwp_size, + UL_BWP->BWPSize, + DL_BWP->BWPSize, + UL_BWP->initial_BWPSize, + DL_BWP->initial_BWPSize); + int n_ul_bwp = 1,n_dl_bwp = 1; switch(format) { case NR_UL_DCI_FORMAT_0_0: @@ -3219,7 +3232,7 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, size += dci_pdu->frequency_domain_assignment.nbits; if(alt_size >= size) size += alt_size - size; // Padding to match 1_0 size - else { + else if (ss_type == NR_SearchSpace__searchSpaceType_PR_common) { dci_pdu->frequency_domain_assignment.nbits -= (size - alt_size); size = alt_size; } @@ -3255,9 +3268,7 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, rbg_size_config = 1; else rbg_size_config = 0; - numRBG = getNRBG(NRRIV2BW(ubwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE), - NRRIV2PRBOFFSET(ubwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE), - rbg_size_config); + numRBG = getNRBG(UL_BWP->BWPSize, UL_BWP->BWPStart, rbg_size_config); if (pusch_Config->resourceAllocation == 0) dci_pdu->frequency_domain_assignment.nbits = numRBG; else if (pusch_Config->resourceAllocation == 1) @@ -3383,9 +3394,10 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, // Size of DCI format 1_0 is given by the size of CORESET 0 if CORESET 0 is configured for the cell and the size // of initial DL bandwidth part if CORESET 0 is not configured for the cell size = 28; - size += (uint8_t)ceil(log2((N_RB * (N_RB + 1)) >> 1)); // Freq domain assignment - - dci_pdu->frequency_domain_assignment.nbits = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); + dci_pdu->frequency_domain_assignment.nbits = (uint8_t)ceil(log2((N_RB * (N_RB + 1)) >> 1)); // Freq domain assignment + size += dci_pdu->frequency_domain_assignment.nbits; + if(ss_type == NR_SearchSpace__searchSpaceType_PR_ue_Specific && alt_size >= size) + size += alt_size - size; // Padding to match 0_0 size dci_pdu->time_domain_assignment.nbits = 4; dci_pdu->vrb_to_prb_mapping.nbits = 1; break; @@ -3414,9 +3426,7 @@ uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, if (pdsch_Config) rbg_size_config = pdsch_Config->rbg_Size; else rbg_size_config = 0; - numRBG = getNRBG(NRRIV2BW(bwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE), - NRRIV2PRBOFFSET(bwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE), - rbg_size_config); + numRBG = getNRBG(DL_BWP->BWPSize, DL_BWP->BWPStart, rbg_size_config); if (pdsch_Config && pdsch_Config->resourceAllocation == 0) dci_pdu->frequency_domain_assignment.nbits = numRBG; else if (pdsch_Config == NULL || pdsch_Config->resourceAllocation == 1) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 06251fefb7..9b98ed82f5 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -43,6 +43,11 @@ typedef enum { pusch_dmrs_pos3 = 3, } pusch_dmrs_AdditionalPosition_t; +typedef enum { + pusch_len1 = 1, + pusch_len2 = 2 +} pusch_maxLength_t; + typedef enum { typeA = 0, typeB = 1 @@ -77,13 +82,16 @@ uint8_t compute_precoding_information(NR_PUSCH_Config_t *pusch_Config, uint16_t nr_dci_size(const NR_BWP_DownlinkCommon_t *initialDownlinkBWP, const NR_BWP_UplinkCommon_t *initialUplinkBWP, + const NR_UE_DL_BWP_t *DL_BWP, + const NR_UE_UL_BWP_t *UL_BWP, const NR_CellGroupConfig_t *cg, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, nr_rnti_type_t rnti_type, int controlResourceSetId, int bwp_id, - uint16_t N_RB, + int ss_type, + uint16_t cset0_bwp_size, uint16_t alt_size); uint16_t get_rb_bwp_dci(nr_dci_format_t format, diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 4b4c92e406..ac48e17b62 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -543,17 +543,19 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, NR_ServingCellConfigCommonSIB_t *scc, NR_CellGroupConfig_t *cell_group_config) { - NR_DL_BWP_t *DL_BWP = &mac->current_DL_BWP; - NR_UL_BWP_t *UL_BWP = &mac->current_UL_BWP; + 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; - DL_BWP->genericParameters = scc->downlinkConfigCommon.initialDownlinkBWP.genericParameters; + dl_genericParameters = scc->downlinkConfigCommon.initialDownlinkBWP.genericParameters; if(scc->uplinkConfigCommon) - UL_BWP->genericParameters = scc->uplinkConfigCommon->initialUplinkBWP.genericParameters; + ul_genericParameters = scc->uplinkConfigCommon->initialUplinkBWP.genericParameters; else - UL_BWP->genericParameters = scc->downlinkConfigCommon.initialDownlinkBWP.genericParameters; + ul_genericParameters = scc->downlinkConfigCommon.initialDownlinkBWP.genericParameters; } if(cell_group_config) { if (cell_group_config->spCellConfig && @@ -573,14 +575,14 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, break; } AssertFatal(bwp_downlink != NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n", DL_BWP->bwp_id); - DL_BWP->genericParameters = bwp_downlink->bwp_Common->genericParameters; + dl_genericParameters = bwp_downlink->bwp_Common->genericParameters; } else { if(mac->scc) { - DL_BWP->genericParameters = mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + dl_genericParameters = mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; } if(mac->scc_SIB) { - DL_BWP->genericParameters = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; + dl_genericParameters = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters; } } NR_BWP_Uplink_t *bwp_uplink = NULL; @@ -592,14 +594,14 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, break; } AssertFatal(bwp_uplink != NULL,"Couldn't find ULBWP corresponding to BWP ID %ld\n",UL_BWP->bwp_id); - UL_BWP->genericParameters = bwp_uplink->bwp_Common->genericParameters; + ul_genericParameters = bwp_uplink->bwp_Common->genericParameters; } else { if(mac->scc) { - UL_BWP->genericParameters = mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + ul_genericParameters = mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; } if(mac->scc_SIB) { - UL_BWP->genericParameters = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters; + ul_genericParameters = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters; } } } @@ -607,14 +609,14 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, AssertFatal(1==0,"We shouldn't end here in configuring BWP\n"); } - DL_BWP->scs = DL_BWP->genericParameters.subcarrierSpacing; - DL_BWP->cyclicprefix = DL_BWP->genericParameters.cyclicPrefix; - DL_BWP->BWPSize = NRRIV2BW(DL_BWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - DL_BWP->BWPStart = NRRIV2PRBOFFSET(DL_BWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - UL_BWP->scs = UL_BWP->genericParameters.subcarrierSpacing; - UL_BWP->cyclicprefix = UL_BWP->genericParameters.cyclicPrefix; - UL_BWP->BWPSize = NRRIV2BW(UL_BWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - UL_BWP->BWPStart = NRRIV2PRBOFFSET(UL_BWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + 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 = mac->scc ? NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE) : NRRIV2BW(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index b3a3915993..66397b20a3 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -164,6 +164,11 @@ typedef enum { UE_PHY_HO_PRACH } NR_UE_L2_STATE_t; +typedef enum { + RA_2STEP = 0, + RA_4STEP +} nr_ra_type_e; + // LTE structure, might need to be adapted for NR typedef struct { /// buffer status for each lcgid @@ -372,28 +377,6 @@ typedef struct { } NR_PHY_meas_t; -typedef struct NR_DL_BWP { - NR_BWP_Id_t bwp_id; - NR_BWP_t genericParameters; - int scs; - long *cyclicprefix; - uint16_t initial_BWPSize; - uint16_t initial_BWPStart; - uint16_t BWPSize; - uint16_t BWPStart; -} NR_DL_BWP_t; - -typedef struct NR_UL_BWP { - NR_BWP_Id_t bwp_id; - NR_BWP_t genericParameters; - int scs; - long *cyclicprefix; - uint16_t initial_BWPSize; - uint16_t initial_BWPStart; - uint16_t BWPSize; - uint16_t BWPStart; -} NR_UL_BWP_t; - /*!\brief Top level UE MAC structure */ typedef struct { @@ -414,8 +397,8 @@ typedef struct { NR_RNTI_Value_t *cs_RNTI; NR_MIB_t *mib; - NR_DL_BWP_t current_DL_BWP; - NR_UL_BWP_t current_UL_BWP; + NR_UE_DL_BWP_t current_DL_BWP; + NR_UE_UL_BWP_t current_UL_BWP; NR_BWP_Downlink_t *DLbwp[MAX_NUM_BWP_UE]; NR_BWP_Uplink_t *ULbwp[MAX_NUM_BWP_UE]; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index d63c08dc8e..e4bbb546d8 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -815,7 +815,7 @@ uint8_t nr_ue_get_rach(module_id_t mod_id, } else if (get_softmodem_params()->nsa) { - uint8_t mac_sdus[MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER*1056]; + uint8_t mac_sdus[34*1056]; uint16_t sdu_lengths[NB_RB_MAX] = {0}; int TBS_bytes = 848; int mac_ce_len = 0; 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 0670c1cff0..2815a42c16 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -95,9 +95,9 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t AssertFatal(mac->scc == NULL || mac->scc_SIB == NULL, "both scc and scc_SIB cannot be non-null\n"); - NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; - NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; - NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id; + NR_UE_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; + NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; + NR_BWP_Id_t dl_bwp_id = current_DL_BWP ? current_DL_BWP->bwp_id : 0; NR_ServingCellConfigCommon_t *scc = mac->scc; NR_ServingCellConfigCommonSIB_t *scc_SIB = mac->scc_SIB; NR_BWP_DownlinkCommon_t *initialDownlinkBWP=NULL; @@ -164,50 +164,37 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->coreset.scrambling_rnti = 0; } // loop over RNTI type and configure resource allocation for DCI - int N_RB; for (int i = 0; i < rel15->num_dci_options; i++) { rel15->dci_type_options[i] = ss->searchSpaceType->present; const int dci_format = rel15->dci_format_options[i]; uint16_t alt_size = 0; if(current_DL_BWP) { - N_RB = get_rb_bwp_dci(dci_format, - ss->searchSpaceType->present, - mac->type0_PDCCH_CSS_config.num_rbs, - current_UL_BWP->BWPSize, - current_DL_BWP->BWPSize, - current_UL_BWP->initial_BWPSize, - current_DL_BWP->initial_BWPSize); // computing alternative size for padding - uint16_t alt_rb; dci_pdu_rel15_t temp_pdu; - if(dci_format == NR_DL_DCI_FORMAT_1_0) { - alt_rb = get_rb_bwp_dci(NR_UL_DCI_FORMAT_0_0, - ss->searchSpaceType->present, - mac->type0_PDCCH_CSS_config.num_rbs, - current_UL_BWP->BWPSize, - current_DL_BWP->BWPSize, - current_UL_BWP->initial_BWPSize, - current_DL_BWP->initial_BWPSize); - - alt_size = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &temp_pdu, - NR_UL_DCI_FORMAT_0_0, rnti_type, coreset_id, dl_bwp_id, alt_rb, 0); - } - if(dci_format == NR_UL_DCI_FORMAT_0_0) { - alt_rb = get_rb_bwp_dci(NR_DL_DCI_FORMAT_1_0, - ss->searchSpaceType->present, - mac->type0_PDCCH_CSS_config.num_rbs, - current_UL_BWP->BWPSize, - current_DL_BWP->BWPSize, - current_UL_BWP->initial_BWPSize, - current_DL_BWP->initial_BWPSize); - - alt_size = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &temp_pdu, - NR_DL_DCI_FORMAT_1_0, rnti_type, coreset_id, dl_bwp_id, alt_rb, 0); - } + if(dci_format == NR_DL_DCI_FORMAT_1_0) + alt_size = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, + current_DL_BWP, current_UL_BWP, + mac->cg, &temp_pdu, + NR_UL_DCI_FORMAT_0_0, rnti_type, coreset_id, dl_bwp_id, + ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, 0); + if(dci_format == NR_UL_DCI_FORMAT_0_0) + alt_size = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, + current_DL_BWP, current_UL_BWP, + mac->cg, &temp_pdu, + NR_DL_DCI_FORMAT_1_0, rnti_type, coreset_id, dl_bwp_id, + ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, 0); } - else - N_RB = mac->type0_PDCCH_CSS_config.num_rbs; + + rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, + current_DL_BWP, current_UL_BWP, + mac->cg, &mac->def_dci_pdu_rel15[dci_format], + dci_format, NR_RNTI_TC, coreset_id, dl_bwp_id, + ss->searchSpaceType->present, mac->type0_PDCCH_CSS_config.num_rbs, alt_size); + + rel15->BWPStart = coreset_id == 0 ? mac->type0_PDCCH_CSS_config.cset_start_rb : current_DL_BWP->BWPStart; + rel15->BWPSize = coreset_id == 0 ? mac->type0_PDCCH_CSS_config.num_rbs : current_DL_BWP->BWPSize; + switch(rnti_type) { case NR_RNTI_C: // we use DL BWP dedicated @@ -215,29 +202,14 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t // for SPS=14 8 MSBs in positions 13 down to 6 monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); rel15->rnti = mac->crnti; - rel15->BWPSize = current_DL_BWP->BWPSize; - rel15->BWPStart = current_DL_BWP->BWPStart; rel15->SubcarrierSpacing = current_DL_BWP->scs; - rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, - &mac->def_dci_pdu_rel15[dci_format], - dci_format, NR_RNTI_C, coreset_id, dl_bwp_id, N_RB, alt_size); break; case NR_RNTI_RA: // we use the initial DL BWP sps = current_DL_BWP->cyclicprefix == NULL ? 14 : 12; monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); rel15->rnti = mac->ra.ra_rnti; - if (get_softmodem_params()->sa) { - rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs; - rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; - } else { // NSA mode is not using the Initial BWP - rel15->BWPSize = current_DL_BWP->initial_BWPSize; - rel15->BWPStart = current_DL_BWP->BWPStart; - } rel15->SubcarrierSpacing = current_DL_BWP->scs; - rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, - &mac->def_dci_pdu_rel15[dci_format], - dci_format, NR_RNTI_RA, coreset_id, dl_bwp_id, N_RB, alt_size); break; case NR_RNTI_P: break; @@ -248,12 +220,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t sps = current_DL_BWP->cyclicprefix == NULL ? 14 : 12; monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); rel15->rnti = mac->ra.t_crnti; - rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs; - rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; rel15->SubcarrierSpacing = current_DL_BWP->scs; - rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, - mac->cg, &mac->def_dci_pdu_rel15[dci_format], - dci_format, NR_RNTI_TC, coreset_id, dl_bwp_id, N_RB, alt_size); break; case NR_RNTI_SP_CSI: break; @@ -263,17 +230,11 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); rel15->rnti = SI_RNTI; // SI-RNTI - 3GPP TS 38.321 Table 7.1-1: RNTI values - rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs; - rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; if(mac->frequency_range == FR1) rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon; else rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon + 2; - - rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, - &mac->def_dci_pdu_rel15[dci_format], - dci_format, NR_RNTI_SI, coreset_id, 0, mac->type0_PDCCH_CSS_config.num_rbs, alt_size); break; case NR_RNTI_SFI: break; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 3b3c483ec0..831963b454 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -50,6 +50,7 @@ /* PHY */ #include "executables/softmodem-common.h" +#include "openair1/PHY/defs_nr_UE.h" /* utils */ #include "assertions.h" @@ -642,8 +643,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr RA_config_t *ra = &mac->ra; fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; uint8_t is_Msg3 = 0; - NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; - NR_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; NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id; NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id; int default_abc = 1; @@ -816,15 +817,22 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr NR_PDSCH_Config_t *pdsch_config= (dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1]) ? mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup : NULL; int is_common=0; + if (dci_ind->ss_type == NR_SearchSpace__searchSpaceType_PR_common) { + dlsch_config_pdu_1_0->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs ? mac->type0_PDCCH_CSS_config.num_rbs : current_DL_BWP->initial_BWPSize; + dlsch_config_pdu_1_0->BWPStart = dci_ind->cset_start; + } + else { + dlsch_config_pdu_1_0->BWPSize = current_DL_BWP->BWPSize; + dlsch_config_pdu_1_0->BWPStart = current_DL_BWP->BWPStart; + } if(rnti == SI_RNTI) { NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config = mac->type0_PDCCH_CSS_config; default_abc = type0_PDCCH_CSS_config.type0_pdcch_ss_mux_pattern; dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_SI_DLSCH; - dlsch_config_pdu_1_0->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs; - dlsch_config_pdu_1_0->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; dlsch_config_pdu_1_0->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon; if (pdsch_config) pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NULL; // For PDSCH with mapping type A, the UE shall assume dmrs-AdditionalPosition='pos2' } else { + dlsch_config_pdu_1_0->SubcarrierSpacing = current_DL_BWP->scs; if (ra->RA_window_cnt >= 0 && rnti == ra->ra_rnti){ dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_RA_DLSCH; } else { @@ -832,34 +840,15 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr } if( (ra->RA_window_cnt >= 0 && rnti == ra->ra_rnti) || (rnti == ra->t_crnti) ) { if (mac->scc == NULL) { // use coreset0 - dlsch_config_pdu_1_0->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs; - dlsch_config_pdu_1_0->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb; is_common=1; } - else { - dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - } if (!get_softmodem_params()->sa) { // NSA mode is not using the Initial BWP - dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); pdsch_config = mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup; } } else if (dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1]) { - dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - dlsch_config_pdu_1_0->SubcarrierSpacing = mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.subcarrierSpacing; pdsch_config = mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup; - } else if (mac->scc) { - dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - dlsch_config_pdu_1_0->SubcarrierSpacing = mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing; + } else if (mac->scc) pdsch_config = NULL; - } else if (mac->scc_SIB) { - dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - dlsch_config_pdu_1_0->SubcarrierSpacing = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.subcarrierSpacing; - pdsch_config = NULL; - } } /* IDENTIFIER_DCI_FORMATS */ @@ -1504,7 +1493,7 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, int O_CRC = 0; //FIXME uint16_t O_uci = O_CSI + O_ACK; - NR_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_FormatConfig_t *pucchfmt; long *pusch_id = NULL; @@ -1564,7 +1553,7 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, mac->cg->physicalCellGroupConfig && (mac->cg->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH != NULL || mac->cg->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook != 1)) { - LOG_E(MAC,"PUCCH Unsupported cell group configuration : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); + LOG_E(MAC,"PUCCH Unsupported cell group configuration\n"); return; } else if (mac->cg && @@ -1573,7 +1562,7 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, mac->cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig && mac->cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup && mac->cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) { - LOG_E(MAC,"PUCCH Unsupported code block group for serving cell config : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); + LOG_E(MAC,"PUCCH Unsupported code block group for serving cell config\n"); return; } NR_PUCCH_Config_t *pucch_Config; @@ -1611,7 +1600,7 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, pucch_pdu->prb_size = 1; // format 0 or 1 if ((O_SR+O_CSI+O_SR) > (sizeof(uint64_t)*8)) { - LOG_E(MAC,"PUCCH number of UCI bits exceeds payload size : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); + LOG_E(MAC,"PUCCH number of UCI bits exceeds payload size\n"); return; } pucch_pdu->payload = (pucch->csi_part1_payload << (O_ACK + O_SR)) | (pucch->sr_payload << O_ACK) | pucch->ack_payload; @@ -1783,7 +1772,7 @@ int16_t get_pucch_tx_power_ue(NR_UE_MAC_INST_t *mac, int16_t G_b_f_c = 0; if (pucch_Config->spatialRelationInfoToAddModList != NULL) { /* FFS TODO NR */ - LOG_D(MAC,"PUCCH Spatial relation infos are not yet implemented : at line %d in function %s of file %s \n", LINE_FILE , __func__, __FILE__); + LOG_D(MAC,"PUCCH Spatial relation infos are not yet implemented\n"); return (PUCCH_POWER_DEFAULT); } @@ -1793,7 +1782,7 @@ int16_t get_pucch_tx_power_ue(NR_UE_MAC_INST_t *mac, } else { G_b_f_c = pucch->delta_pucch; - LOG_D(MAC,"PUCCH Transmit power control command not yet implemented for NR : at line %d in function %s of file %s \n", LINE_FILE , __func__, __FILE__); + LOG_E(MAC,"PUCCH Transmit power control command not yet implemented for NR\n"); return (PUCCH_POWER_DEFAULT); } @@ -1854,13 +1843,13 @@ int16_t get_pucch_tx_power_ue(NR_UE_MAC_INST_t *mac, break; default: { - LOG_E(MAC,"PUCCH unknown pucch format : at line %d in function %s of file %s \n", LINE_FILE , __func__, __FILE__); + LOG_E(MAC,"PUCCH unknown pucch format %d\n", format_type); return (0); } } if (*power_config->twoPUCCH_PC_AdjustmentStates > 1) { - LOG_E(MAC,"PUCCH power control adjustment states with 2 states not yet implemented : at line %d in function %s of file %s \n", LINE_FILE , __func__, __FILE__); + LOG_E(MAC,"PUCCH power control adjustment states with 2 states not yet implemented\n"); return (PUCCH_POWER_DEFAULT); } @@ -1869,8 +1858,8 @@ int16_t get_pucch_tx_power_ue(NR_UE_MAC_INST_t *mac, int16_t pucch_power = P_O_PUCCH + M_pucch_component + pathloss + delta_F_PUCCH + DELTA_TF + G_b_f_c; - NR_TST_PHY_PRINTF("PUCCH ( Tx power : %d dBm ) ( 10Log(...) : %d ) ( from Path Loss : %d ) ( delta_F_PUCCH : %d ) ( DELTA_TF : %d ) ( G_b_f_c : %d ) \n", - pucch_power, M_pucch_component, pathloss, delta_F_PUCCH, DELTA_TF, G_b_f_c); + LOG_D(MAC, "PUCCH ( Tx power : %d dBm ) ( 10Log(...) : %d ) ( from Path Loss : %d ) ( delta_F_PUCCH : %d ) ( DELTA_TF : %d ) ( G_b_f_c : %d ) \n", + pucch_power, M_pucch_component, pathloss, delta_F_PUCCH, DELTA_TF, G_b_f_c); return (pucch_power); } @@ -2017,7 +2006,7 @@ void select_pucch_resource(NR_UE_MAC_INST_t *mac, int n_CCE_0 = pucch->n_CCE; int N_CCE_0 = pucch->N_CCE; if (N_CCE_0 == 0) { - AssertFatal(1==0,"PUCCH No compatible pucch format found : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); + AssertFatal(1==0,"PUCCH No compatible pucch format found\n"); } int r_PUCCH = ((2 * n_CCE_0)/N_CCE_0) + (2 * delta_PRI); pucch->initial_pucch_id = r_PUCCH; @@ -2114,8 +2103,8 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, int sched_frame,sched_slot; int slots_per_frame; - NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; - NR_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; NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id; NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id; NR_BWP_DownlinkDedicated_t *bwpd=NULL; @@ -2164,7 +2153,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, } if (current_harq->dai > NR_DL_MAX_DAI) { - LOG_E(MAC,"PUCCH Downlink DAI has an invalid value : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); + LOG_E(MAC,"PUCCH Downlink DAI has an invalid value of %d\n", current_harq->dai); } else { @@ -2175,7 +2164,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, dai_current = current_harq->dai+1; // DCI DAI to counter DAI conversion if (dai_current == 0) { - LOG_E(MAC,"PUCCH Downlink dai is invalid : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); + LOG_E(MAC,"PUCCH Downlink dai is invalid\n"); return(0); } else if (dai_current > dai_max) { dai_max = dai_current; @@ -2209,7 +2198,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, return(0); } else if (number_harq_feedback > (sizeof(uint32_t)*8)) { - LOG_E(MAC,"PUCCH number of ack bits exceeds payload size : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); + LOG_E(MAC,"PUCCH number of ack bits exceeds payload size\n"); return(0); } @@ -2223,7 +2212,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, mac->cg->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH != NULL) { int N_TB_max_DL = bwpd->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI[0]; pucch->n_HARQ_ACK = (((V_DAI_m_DL - U_DAI_c)%4) * N_TB_max_DL) + N_m_c_rx + N_SPS_c; - NR_TST_PHY_PRINTF("PUCCH power n(%d) = ( V(%d) - U(%d) )mod4 * N_TB(%d) + N(%d) \n", pucch->n_HARQ_ACK, V_DAI_m_DL, U_DAI_c, N_TB_max_DL, N_m_c_rx); + LOG_D(MAC, "PUCCH power n(%d) = ( V(%d) - U(%d) )mod4 * N_TB(%d) + N(%d) \n", pucch->n_HARQ_ACK, V_DAI_m_DL, U_DAI_c, N_TB_max_DL, N_m_c_rx); } /* @@ -2295,7 +2284,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac, } if (number_harq_feedback != O_ACK) { - LOG_E(MAC,"PUCCH Error for number of bits for acknowledgment : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); + LOG_E(MAC,"PUCCH Error for number of bits for acknowledgment\n"); return (0); } @@ -2313,7 +2302,7 @@ bool trigger_periodic_scheduling_request(NR_UE_MAC_INST_t *mac, frame_t frame, int slot) { - NR_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 = NULL; @@ -2426,7 +2415,7 @@ uint8_t nr_get_csi_measurements(NR_UE_MAC_INST_t *mac, int slot, PUCCH_sched_t *pucch) { - NR_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 = NULL; int csi_bits = 0; @@ -2805,8 +2794,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_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP; - NR_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, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index cc2064bc83..12b45174a0 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -540,7 +540,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, dci_pdu_rel15_t *dci, RAR_grant_t *rar_grant, uint16_t rnti, - uint8_t *dci_format){ + uint8_t *dci_format) +{ int f_alloc; int mask; @@ -553,7 +554,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_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 ul_bwp_id = current_UL_BWP->bwp_id; // Common configuration @@ -935,7 +936,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_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 ul_bwp_id = current_UL_BWP->bwp_id; NR_SRS_Config_t *srs_config = NULL; @@ -1567,7 +1568,7 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, uint8_t tda_id){ int delta = 0; - NR_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 ul_bwp_id = current_UL_BWP->bwp_id; // Get the numerology to calculate the Tx frame and slot @@ -2405,7 +2406,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_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; @@ -2462,7 +2463,7 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; NR_NZP_CSI_RS_Resource_t *nzpcsi; int period, offset; - NR_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; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 0d9bb25291..b8fcfcdd1e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1151,7 +1151,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra long BWPStart = 0; long BWPSize = 0; NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = NULL; - if(*ss->controlResourceSetId!=0) { + if(*ss->controlResourceSetId != 0) { BWPStart = dl_bwp->BWPStart; BWPSize = dl_bwp->initial_BWPSize; } else { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 5e8e0f3709..65f54bb250 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1412,39 +1412,30 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, current_DL_BWP->initial_BWPSize); // computing alternative size for padding - uint16_t alt_rb; dci_pdu_rel15_t temp_pdu; - if(dci_format == NR_DL_DCI_FORMAT_1_0) { - alt_rb = get_rb_bwp_dci(NR_UL_DCI_FORMAT_0_0, - ss->searchSpaceType->present, - cset0_bwp_size, - current_UL_BWP->BWPSize, - current_DL_BWP->BWPSize, - current_UL_BWP->initial_BWPSize, - current_DL_BWP->initial_BWPSize); + if(dci_format == NR_DL_DCI_FORMAT_1_0) alt_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP, scc->uplinkConfigCommon->initialUplinkBWP, - CellGroup, &temp_pdu, NR_UL_DCI_FORMAT_0_0, rnti_type, controlResourceSetId, bwp_id, alt_rb, 0); + current_DL_BWP, current_UL_BWP, + CellGroup, &temp_pdu, NR_UL_DCI_FORMAT_0_0, rnti_type, + controlResourceSetId, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, 0); - } - if(dci_format == NR_UL_DCI_FORMAT_0_0) { - alt_rb = get_rb_bwp_dci(NR_DL_DCI_FORMAT_1_0, - ss->searchSpaceType->present, - cset0_bwp_size, - current_UL_BWP->BWPSize, - current_DL_BWP->BWPSize, - current_UL_BWP->initial_BWPSize, - current_DL_BWP->initial_BWPSize); + if(dci_format == NR_UL_DCI_FORMAT_0_0) alt_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP, scc->uplinkConfigCommon->initialUplinkBWP, - CellGroup, &temp_pdu, NR_DL_DCI_FORMAT_1_0, rnti_type, controlResourceSetId, bwp_id, alt_rb, 0); - } + current_DL_BWP, current_UL_BWP, + CellGroup, &temp_pdu, NR_DL_DCI_FORMAT_1_0, rnti_type, + controlResourceSetId, bwp_id, ss->searchSpaceType->present, cset0_bwp_size, 0); + } else N_RB = cset0_bwp_size; + int dci_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP, scc->uplinkConfigCommon->initialUplinkBWP, - CellGroup, dci_pdu_rel15, dci_format, rnti_type, controlResourceSetId, bwp_id, N_RB, alt_size); + current_DL_BWP, current_UL_BWP, + CellGroup, dci_pdu_rel15, dci_format, rnti_type, controlResourceSetId, + bwp_id, ss->searchSpaceType->present, cset0_bwp_size, alt_size); pdcch_dci_pdu->PayloadSizeBits = dci_size; AssertFatal(dci_size <= 64, "DCI sizes above 64 bits not yet supported"); if (dci_format == NR_DL_DCI_FORMAT_1_1 || dci_format == NR_UL_DCI_FORMAT_0_1) diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 7697d74808..25be7f7c17 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -92,44 +92,6 @@ typedef struct { int len; } NR_list_t; -typedef struct NR_UE_DL_BWP { - NR_BWP_Id_t bwp_id; - int n_dl_bwp; - int scs; - long *cyclicprefix; - uint16_t BWPSize; - uint16_t BWPStart; - uint16_t initial_BWPSize; - uint16_t initial_BWPStart; - NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList; - NR_PDSCH_Config_t *pdsch_Config; - NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig; - uint8_t mcsTableIdx; - nr_dci_format_t dci_format; -} NR_UE_DL_BWP_t; - -typedef struct NR_UE_UL_BWP { - NR_BWP_Id_t bwp_id; - int n_ul_bwp; - int scs; - long *cyclicprefix; - uint16_t BWPSize; - uint16_t BWPStart; - uint16_t initial_BWPSize; - uint16_t initial_BWPStart; - NR_PUSCH_ServingCellConfig_t *pusch_servingcellconfig; - NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList; - NR_PUSCH_Config_t *pusch_Config; - NR_PUCCH_Config_t *pucch_Config; - NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon; - NR_CSI_MeasConfig_t *csi_MeasConfig; - NR_SRS_Config_t *srs_Config; - uint8_t transform_precoding; - uint8_t mcs_table; - nr_dci_format_t dci_format; - int max_fb_time; -} NR_UE_UL_BWP_t; - typedef enum { RA_IDLE = 0, Msg2 = 1, From 01030bbc4ed9ae1d24b005669ac804dae7ffec75 Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 30 Dec 2022 10:32:58 +0100 Subject: [PATCH 4/4] L2 simulator fix --- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 49305421af..eb1de74d20 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -638,41 +638,35 @@ static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, n static void fill_dci_from_dl_config(nr_downlink_indication_t*dl_ind, fapi_nr_dl_config_request_t *dl_config) { + if (!dl_ind->dci_ind) - { return; - } AssertFatal(dl_config->number_pdus < sizeof(dl_config->dl_config_list) / sizeof(dl_config->dl_config_list[0]), "Too many dl_config pdus %d", dl_config->number_pdus); - for (int i = 0; i < dl_config->number_pdus; i++) - { + for (int i = 0; i < dl_config->number_pdus; i++) { LOG_D(PHY, "In %s: filling DCI with a total of %d total DL PDUs (dl_config %p) \n", __FUNCTION__, dl_config->number_pdus, dl_config); fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15_dci = &dl_config->dl_config_list[i].dci_config_pdu.dci_config_rel15; int num_dci_options = rel15_dci->num_dci_options; if (num_dci_options <= 0) - { LOG_D(NR_MAC, "num_dci_opts = %d for pdu[%d] in dl_config_list\n", rel15_dci->num_dci_options, i); - } AssertFatal(num_dci_options <= sizeof(rel15_dci->dci_length_options) / sizeof(rel15_dci->dci_length_options[0]), "num_dci_options %d > dci_length_options array\n", num_dci_options); AssertFatal(num_dci_options <= sizeof(rel15_dci->dci_format_options) / sizeof(rel15_dci->dci_format_options[0]), "num_dci_options %d > dci_format_options array\n", num_dci_options); - for (int j = 0; j < num_dci_options; j++) - { + for (int j = 0; j < num_dci_options; j++) { int num_dcis = dl_ind->dci_ind->number_of_dcis; AssertFatal(num_dcis <= sizeof(dl_ind->dci_ind->dci_list) / sizeof(dl_ind->dci_ind->dci_list[0]), "dl_config->number_pdus %d > dci_ind->dci_list array\n", num_dcis); - for (int k = 0; k < num_dcis; k++) - { + for (int k = 0; k < num_dcis; k++) { LOG_T(NR_PHY, "Received len %d, length options[%d] %d, format assigned %d, format options[%d] %d\n", dl_ind->dci_ind->dci_list[k].payloadSize, j, rel15_dci->dci_length_options[j], dl_ind->dci_ind->dci_list[k].dci_format, j, rel15_dci->dci_format_options[j]); - if (rel15_dci->dci_length_options[j] == dl_ind->dci_ind->dci_list[k].payloadSize) - { + if (rel15_dci->dci_length_options[j] == dl_ind->dci_ind->dci_list[k].payloadSize) { dl_ind->dci_ind->dci_list[k].dci_format = rel15_dci->dci_format_options[j]; + dl_ind->dci_ind->dci_list[k].ss_type = rel15_dci->dci_type_options[j]; LOG_D(NR_PHY, "format assigned dl_ind->dci_ind->dci_list[k].dci_format %d\n", dl_ind->dci_ind->dci_list[k].dci_format); }