From b5583d47de5c63a2759fb2ba4ee3d69a3b97deab Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 6 Jun 2022 11:52:12 +0200 Subject: [PATCH 01/16] temporary workaround for RRC passing CG to MAC (forced encoding of message at MAC) --- openair1/PHY/INIT/nr_init.c | 4 +-- openair2/LAYER2/NR_MAC_gNB/config.c | 18 ++++++++++++- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 10 +++++++- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 2 ++ openair2/RRC/NR/rrc_gNB.c | 25 ++++++++++--------- 5 files changed, 43 insertions(+), 16 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 9a57009578..8ab978614e 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -544,8 +544,8 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, gNB->nr_gold_pdsch_dmrs = (uint32_t ****)malloc16(fp->slots_per_frame*sizeof(uint32_t ***)); uint32_t ****pdsch_dmrs = gNB->nr_gold_pdsch_dmrs; - // ceil(((NB_RB*6(k)*2(QPSK)/32) // 3 RE *2(QPSK) - int pdsch_dmrs_init_length = ((fp->N_RB_DL*12)>>5)+1; + // ceil(((NB_RB*12(k)*2(QPSK)/32) // 3 RE *2(QPSK) + int pdsch_dmrs_init_length = ((fp->N_RB_DL*24)>>5)+1; for (int slot=0; slotslots_per_frame; slot++) { pdsch_dmrs[slot] = (uint32_t ***)malloc16(fp->symbols_per_slot*sizeof(uint32_t **)); AssertFatal(pdsch_dmrs[slot]!=NULL, "NR init: pdsch_dmrs for slot %d - malloc failed\n", slot); diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 0e55b519ab..95ccc9a4d4 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -654,7 +654,23 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, } int target_ss; - UE->CellGroup = CellGroup; + /* copy CellGroup by calling asn1c encode + this is a temporary hack to avoid the gNB having + a pointer to RRC CellGroup structure + (otherwise it would be applied to early) + TODO remove once we have a proper implementation */ + UE->enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, + NULL, + (void *)CellGroup, + UE->cg_buf, + 32768); + + if(UE->enc_rval.encoded == -1) { + LOG_E(NR_MAC, "ASN1 message CellGroupConfig encoding failed (%s, %lu)!\n", + UE->enc_rval.failed_type->name, UE->enc_rval.encoded); + exit(1); + } + LOG_I(NR_MAC,"Modified rnti %04x with CellGroup\n",rnti); process_CellGroup(CellGroup,&UE->UE_sched_ctrl); NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 65d2ce09c5..afc37d8d8a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2903,7 +2903,15 @@ void nr_mac_update_timers(module_id_t module_id, LOG_I(NR_MAC, "(%d.%d) De-activating RRC processing timer for UE %04x\n", frame, slot, UE->rnti); const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - NR_CellGroupConfig_t *cg = UE->CellGroup; + + NR_CellGroupConfig_t *cg = NULL; + uper_decode(NULL, + &asn_DEF_NR_CellGroupConfig, //might be added prefix later + (void **)&cg, + (uint8_t *)UE->cg_buf, + (UE->enc_rval.encoded+7)/8, 0, 0); + UE->CellGroup = cg; + NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; const NR_ServingCellConfig_t *spCellConfigDedicated = cg && cg->spCellConfig ? cg->spCellConfig->spCellConfigDedicated : NULL; diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 974d6dff4a..1d0d9750e6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -710,6 +710,8 @@ typedef struct { NR_UE_sched_ctrl_t UE_sched_ctrl; NR_mac_stats_t mac_stats; NR_CellGroupConfig_t *CellGroup; + char cg_buf[32768]; /* arbitrary size */ + asn_enc_rval_t enc_rval; /// CCE indexing int m; // UE selected beam index diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index f5879a0c49..d8c26114c2 100755 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -734,6 +734,19 @@ rrc_gNB_generate_defaultRRCReconfiguration( NULL, ue_p->masterCellGroup); + rrc_mac_config_req_gNB(rrc->module_id, + rrc->configuration.ssb_SubcarrierOffset, + rrc->configuration.pdsch_AntennaPorts, + rrc->configuration.pusch_AntennaPorts, + rrc->configuration.sib1_tda, + rrc->configuration.minRXTXTIME, + NULL, + NULL, + NULL, + 0, + ue_p->rnti, + ue_p->masterCellGroup); + free(ue_context_pP->ue_context.nas_pdu.buffer); LOG_DUMPMSG(NR_RRC, DEBUG_RRC,(char *)buffer, size, "[MSG] RRC Reconfiguration\n"); @@ -1430,18 +1443,6 @@ rrc_gNB_process_RRCReconfigurationComplete( /* Refresh SRBs/DRBs */ if (!NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)) { - rrc_mac_config_req_gNB(rrc->module_id, - rrc->configuration.ssb_SubcarrierOffset, - rrc->configuration.pdsch_AntennaPorts, - rrc->configuration.pusch_AntennaPorts, - rrc->configuration.sib1_tda, - rrc->configuration.minRXTXTIME, - NULL, - NULL, - NULL, - 0, - ue_context_pP->ue_context.rnti, - ue_context_pP->ue_context.masterCellGroup); LOG_D(NR_RRC,"Configuring RLC DRBs/SRBs for UE %x\n",ue_context_pP->ue_context.rnti); nr_rrc_rlc_config_asn1_req(ctxt_pP, SRB_configList, // NULL, From 4d4f7dd616193153034fe1644ce6c12bfadc8c23 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 7 Jun 2022 12:11:37 +0200 Subject: [PATCH 02/16] initial commit for MAC UE BWP structure (bwp id) --- openair1/PHY/INIT/nr_init_ru.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 8 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 8 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 190 ++++++++++-------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 10 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 6 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 7 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 6 + 8 files changed, 129 insertions(+), 108 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ru.c b/openair1/PHY/INIT/nr_init_ru.c index 0e7c29800a..6aa42b1b10 100644 --- a/openair1/PHY/INIT/nr_init_ru.c +++ b/openair1/PHY/INIT/nr_init_ru.c @@ -60,7 +60,7 @@ int nr_phy_init_RU(RU_t *ru) { for (i=0; inb_tx; i++) { // Allocate 10 subframes of I/Q TX signal data (time) if not - ru->common.txdata[i] = (int32_t*)malloc16_clear( ru->sf_extension + (fp->samples_per_frame*sizeof(int32_t) )); + ru->common.txdata[i] = (int32_t*)malloc16_clear((ru->sf_extension + fp->samples_per_frame)*sizeof(int32_t)); LOG_I(PHY,"[INIT] common.txdata[%d] = %p (%lu bytes,sf_extension %d)\n",i,ru->common.txdata[i], (ru->sf_extension + fp->samples_per_frame)*sizeof(int32_t),ru->sf_extension); ru->common.txdata[i] = &ru->common.txdata[i][ru->sf_extension]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 302685bfaf..76becbfcef 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1305,7 +1305,6 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not exist, create it. This is especially // important if we have multiple RAs, and the DLSCH has to reuse them, so we need to mark them - const int bwpid = bwp ? bwp->bwp_Id : 0; const int coresetid = coreset->controlResourceSetId; nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][coresetid]; if (!pdcch_pdu_rel15) { @@ -1479,7 +1478,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_DL_DCI_FORMAT_1_0, NR_RNTI_RA, BWPSize, - bwpid, + ra->dl_bwp_id, coresetid, nr_mac->cset0_bwp_size); @@ -1488,7 +1487,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // Program UL processing for Msg3 NR_BWP_Uplink_t *ubwp = ra->CellGroup ? - ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->dl_bwp_id-1] : + ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->ul_bwp_id-1] : NULL; nr_get_Msg3alloc(module_idP, CC_id, scc, ubwp, slotP, frameP, ra, nr_mac->tdd_beam_association); nr_add_msg3(module_idP, CC_id, frameP, slotP, ra, (uint8_t *) &tx_req->TLVs[0].value.direct[0]); @@ -1764,7 +1763,6 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not exist, create it. This is especially // important if we have multiple RAs, and the DLSCH has to reuse them, so we need to mark them - const int bwpid = bwp ? bwp->bwp_Id : 0; const int coresetid = coreset->controlResourceSetId; nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][coresetid]; if (!pdcch_pdu_rel15) { @@ -1895,7 +1893,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_DL_DCI_FORMAT_1_0, NR_RNTI_TC, pdsch_pdu_rel15->BWPSize, - bwpid, + ra->dl_bwp_id, coresetid, nr_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 95834e84c5..51dd6d4a8d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -902,6 +902,7 @@ nr_pp_impl_dl nr_init_fr1_dlsch_preprocessor(module_id_t module_id, int CC_id) { void nr_schedule_ue_spec(module_id_t module_id, frame_t frame, sub_frame_t slot) { + gNB_MAC_INST *gNB_mac = RC.nrmac[module_id]; if (!is_xlsch_in_slot(gNB_mac->dlsch_slot_bitmap[slot / 64], slot)) @@ -918,6 +919,7 @@ void nr_schedule_ue_spec(module_id_t module_id, UE_iterator(UE_info->list, UE) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_BWP_t *current_BWP = &UE->current_BWP; if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; @@ -1013,7 +1015,7 @@ void nr_schedule_ue_spec(module_id_t module_id, NR_SearchSpace_t *ss = (bwp||bwpd) ? sched_ctrl->search_space : gNB_mac->sched_ctrlCommon->search_space; - const int bwp_id = bwp ? bwp->bwp_Id : 0; + const int bwp_id = current_BWP->dl_bwp_id; const int coresetid = (bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : gNB_mac->sched_ctrlCommon->coreset->controlResourceSetId; /* look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not exist, create it */ @@ -1166,7 +1168,7 @@ void nr_schedule_ue_spec(module_id_t module_id, AssertFatal(n_dl_bwp <= NR_MAX_NUM_BWP, "downlinkBWP_ToAddModList has %d BWP!\n", n_dl_bwp); // as per table 7.3.1.1.2-1 in 38.212 - dci_payload.bwp_indicator.val = bwp ? (n_dl_bwp < 4 ? bwp->bwp_Id : bwp->bwp_Id - 1) : 0; + dci_payload.bwp_indicator.val = bwp ? (n_dl_bwp < 4 ? bwp_id : bwp_id - 1) : 0; if (bwp) AssertFatal(bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation == NR_PDSCH_Config__resourceAllocation_resourceAllocationType1, "Only frequency resource allocation type 1 is currently supported\n"); @@ -1216,7 +1218,7 @@ void nr_schedule_ue_spec(module_id_t module_id, dci_format, rnti_type, pdsch_pdu->BWPSize, - bwp ? bwp->bwp_Id : 0, + bwp_id, coresetid, gNB_mac->cset0_bwp_size); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index afc37d8d8a..cb767edda3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1025,7 +1025,7 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, void config_uldci(const NR_SIB1_t *sib1, const NR_BWP_Uplink_t *ubwp, - const NR_BWP_UplinkDedicated_t *ubwpd, + const NR_BWP_UplinkDedicated_t *ubwpd, const NR_ServingCellConfigCommon_t *scc, const nfapi_nr_pusch_pdu_t *pusch_pdu, dci_pdu_rel15_t *dci_pdu_rel15, @@ -1566,7 +1566,10 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, uint64_t *dci_pdu = (uint64_t *)pdcch_dci_pdu->Payload; *dci_pdu=0; - 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); + 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); 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) @@ -2332,24 +2335,6 @@ int get_nrofHARQ_ProcessesForPDSCH(e_NR_PDSCH_ServingCellConfig__nrofHARQ_Proces } } -int get_dl_bwp_id(const NR_ServingCellConfig_t *servingCellConfig) -{ - if (servingCellConfig->firstActiveDownlinkBWP_Id) - return *servingCellConfig->firstActiveDownlinkBWP_Id; - else if (servingCellConfig->defaultDownlinkBWP_Id) - return *servingCellConfig->defaultDownlinkBWP_Id; - else - return 1; -} - -int get_ul_bwp_id(const NR_ServingCellConfig_t *servingCellConfig) -{ - if (servingCellConfig->uplinkConfig && servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id) - return *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id; - else - return 1; -} - /* hack data to remove UE in the phy */ int rnti_to_remove[10]; volatile int rnti_to_remove_count; @@ -2393,6 +2378,25 @@ void delete_nr_ue_data(NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr) } } +void configure_UE_BWP(NR_UE_BWP_t *BWP, NR_CellGroupConfig_t *CellGroup) { + + if (CellGroup && + CellGroup->spCellConfig && + CellGroup->spCellConfig->spCellConfigDedicated) { + const NR_ServingCellConfig_t *servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; + + // (re)configuring BWP ID + // TODO BWP switching not via RRC reconfiguration + // via RRC if firstActiveXlinkBWP_Id is NULL, MAC stays on the same BWP as before + if (servingCellConfig->firstActiveDownlinkBWP_Id) { + BWP->dl_bwp_id = *servingCellConfig->firstActiveDownlinkBWP_Id; + BWP->ul_bwp_id = *servingCellConfig->firstActiveDownlinkBWP_Id; + } + if (servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id) + BWP->ul_bwp_id = *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id; + } +} + //------------------------------------------------------------------------------ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup) { @@ -2423,84 +2427,90 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig && CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup) compute_csi_bitlen (CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE); - NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - memset(sched_ctrl, 0, sizeof(*sched_ctrl)); - sched_ctrl->dl_max_mcs = 28; /* do not limit MCS for individual UEs */ - sched_ctrl->set_pmi = false; - sched_ctrl->ta_frame = 0; - sched_ctrl->ta_update = 31; - sched_ctrl->ta_apply = false; - sched_ctrl->ul_rssi = 0; - sched_ctrl->pucch_consecutive_dtx_cnt = 0; - sched_ctrl->pusch_consecutive_dtx_cnt = 0; - sched_ctrl->ul_failure = 0; - sched_ctrl->sched_srs.frame = -1; - sched_ctrl->sched_srs.slot = -1; - sched_ctrl->sched_srs.srs_scheduled = false; - /* set illegal time domain allocation to force recomputation of all fields */ - sched_ctrl->pdsch_semi_static.time_domain_allocation = -1; - sched_ctrl->pusch_semi_static.time_domain_allocation = -1; - const NR_ServingCellConfig_t *servingCellConfig = CellGroup && CellGroup->spCellConfig ? CellGroup->spCellConfig->spCellConfigDedicated : NULL; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + memset(sched_ctrl, 0, sizeof(*sched_ctrl)); + sched_ctrl->dl_max_mcs = 28; /* do not limit MCS for individual UEs */ + sched_ctrl->set_pmi = false; + sched_ctrl->ta_frame = 0; + sched_ctrl->ta_update = 31; + sched_ctrl->ta_apply = false; + sched_ctrl->ul_rssi = 0; + sched_ctrl->pucch_consecutive_dtx_cnt = 0; + sched_ctrl->pusch_consecutive_dtx_cnt = 0; + sched_ctrl->ul_failure = 0; + sched_ctrl->sched_srs.frame = -1; + sched_ctrl->sched_srs.slot = -1; + sched_ctrl->sched_srs.srs_scheduled = false; + + // initialize UE BWP information + NR_UE_BWP_t *BWP = &UE->current_BWP; + memset(BWP, 0, sizeof(*BWP)); + configure_UE_BWP(BWP, CellGroup); + + /* set illegal time domain allocation to force recomputation of all fields */ + sched_ctrl->pdsch_semi_static.time_domain_allocation = -1; + sched_ctrl->pusch_semi_static.time_domain_allocation = -1; + const NR_ServingCellConfig_t *servingCellConfig = CellGroup && CellGroup->spCellConfig ? CellGroup->spCellConfig->spCellConfigDedicated : NULL; /* Set default BWPs */ const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig ? servingCellConfig->downlinkBWP_ToAddModList : NULL; - const int bwp_id = servingCellConfig ? *servingCellConfig->firstActiveDownlinkBWP_Id : 0; - sched_ctrl->active_bwp = bwpList && bwp_id > 0 ? bwpList->list.array[bwp_id - 1] : NULL; - NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? - &sched_ctrl->active_bwp->bwp_Common->genericParameters: - &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; - const int target_ss = sched_ctrl->active_bwp ? NR_SearchSpace__searchSpaceType_PR_ue_Specific : NR_SearchSpace__searchSpaceType_PR_common; - const NR_SIB1_t *sib1 = nr_mac->common_channels[0].sib1 ? nr_mac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - sched_ctrl->search_space = get_searchspace(sib1, - scc, - sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, - target_ss); + sched_ctrl->active_bwp = bwpList && BWP->dl_bwp_id > 0 ? bwpList->list.array[BWP->dl_bwp_id - 1] : NULL; + NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? + &sched_ctrl->active_bwp->bwp_Common->genericParameters: + &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + const int target_ss = sched_ctrl->active_bwp ? NR_SearchSpace__searchSpaceType_PR_ue_Specific : NR_SearchSpace__searchSpaceType_PR_common; + const NR_SIB1_t *sib1 = nr_mac->common_channels[0].sib1 ? nr_mac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; + sched_ctrl->search_space = get_searchspace(sib1, + scc, + sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, + target_ss); sched_ctrl->coreset = get_coreset(nr_mac, scc, sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, - sched_ctrl->search_space, + sched_ctrl->search_space, target_ss); - sched_ctrl->sched_pdcch = set_pdcch_structure(nr_mac, - sched_ctrl->search_space, - sched_ctrl->coreset, - scc, - genericParameters, - NULL); - sched_ctrl->next_dl_bwp_id = -1; - sched_ctrl->next_ul_bwp_id = -1; - const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig ? servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList : NULL; + sched_ctrl->sched_pdcch = set_pdcch_structure(nr_mac, + sched_ctrl->search_space, + sched_ctrl->coreset, + scc, + genericParameters, + NULL); + sched_ctrl->next_dl_bwp_id = -1; + sched_ctrl->next_ul_bwp_id = -1; + const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig ? servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList : NULL; if (ubwpList) AssertFatal(ubwpList->list.count <= NR_MAX_NUM_BWP, - "uplinkBWP_ToAddModList has %d BWP!\n", - ubwpList->list.count); - const int ul_bwp_id = servingCellConfig ? *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id : 0; - sched_ctrl->active_ubwp = ubwpList && ul_bwp_id > 0 ? ubwpList->list.array[ul_bwp_id - 1] : NULL; + "uplinkBWP_ToAddModList has %d BWP!\n", + ubwpList->list.count); - /* get Number of HARQ processes for this UE */ + sched_ctrl->active_ubwp = ubwpList && BWP->ul_bwp_id > 0 ? ubwpList->list.array[BWP->ul_bwp_id - 1] : NULL; + + /* get Number of HARQ processes for this UE */ if (servingCellConfig) AssertFatal(servingCellConfig->pdsch_ServingCellConfig->present == NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup, "no pdsch-ServingCellConfig found for UE %04x\n", UE->rnti); - const NR_PDSCH_ServingCellConfig_t *pdsch = servingCellConfig ? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; - // pdsch == NULL in SA -> will create default (8) number of HARQ processes - create_dl_harq_list(sched_ctrl, pdsch); - // add all available UL HARQ processes for this UE - // nb of ul harq processes not configurable - create_nr_list(&sched_ctrl->available_ul_harq, 16); - for (int harq = 0; harq < 16; harq++) - add_tail_nr_list(&sched_ctrl->available_ul_harq, harq); - create_nr_list(&sched_ctrl->feedback_ul_harq, 16); - create_nr_list(&sched_ctrl->retrans_ul_harq, 16); + const NR_PDSCH_ServingCellConfig_t *pdsch = servingCellConfig ? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; + // pdsch == NULL in SA -> will create default (8) number of HARQ processes + create_dl_harq_list(sched_ctrl, pdsch); + // add all available UL HARQ processes for this UE + // nb of ul harq processes not configurable + create_nr_list(&sched_ctrl->available_ul_harq, 16); + for (int harq = 0; harq < 16; harq++) + add_tail_nr_list(&sched_ctrl->available_ul_harq, harq); + create_nr_list(&sched_ctrl->feedback_ul_harq, 16); + create_nr_list(&sched_ctrl->retrans_ul_harq, 16); pthread_mutex_lock(&UE_info->mutex); int i; - for(i=0; ilist[i] == NULL) { UE_info->list[i] = UE; break; } + } if (i == MAX_MOBILES_PER_GNB) { LOG_E(NR_MAC,"Try to add UE %04x but the list is full\n", rntiP); delete_nr_ue_data(UE, nr_mac->common_channels); @@ -2593,8 +2603,7 @@ uint8_t nr_get_tpc(int target, uint8_t cqi, int incr) { } -void get_pdsch_to_harq_feedback( NR_UE_info_t * UE, - int bwp_id, +void get_pdsch_to_harq_feedback(NR_UE_info_t *UE, NR_SearchSpace__searchSpaceType_PR ss_type, int *max_fb_time, uint8_t *pdsch_to_harq_feedback) { @@ -2602,26 +2611,28 @@ void get_pdsch_to_harq_feedback( NR_UE_info_t * UE, NR_CellGroupConfig_t *CellGroup = UE->CellGroup; NR_BWP_DownlinkDedicated_t *bwpd=NULL; NR_BWP_UplinkDedicated_t *ubwpd=NULL; + int dl_bwp_id = UE->current_BWP.dl_bwp_id; + int ul_bwp_id = UE->current_BWP.ul_bwp_id; if (ss_type == NR_SearchSpace__searchSpaceType_PR_ue_Specific) { AssertFatal(CellGroup!=NULL,"Cellgroup is not defined for UE %04x\n",UE->rnti); AssertFatal(CellGroup->spCellConfig!=NULL,"Cellgroup->spCellConfig is null\n"); AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated!=NULL,"CellGroup->spCellConfig->spCellConfigDedicated is null\n"); } - if (bwp_id>0) { + if (dl_bwp_id>0 && ul_bwp_id>0) { AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList!=NULL, "CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList is null\n"); AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList!=NULL, "CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList is null\n"); - AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count >= bwp_id, + AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count >= dl_bwp_id, "CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count %d < bwp_id %d\n", - CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count,bwp_id); - AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count >= bwp_id, + CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count,dl_bwp_id); + AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count >= ul_bwp_id, "CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count %d < bwp_id %d\n", - CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count,bwp_id); + CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count,ul_bwp_id); - bwpd = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; - ubwpd = CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; + bwpd = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[dl_bwp_id-1]->bwp_Dedicated; + ubwpd = CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ul_bwp_id-1]->bwp_Dedicated; } else if (CellGroup && CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated) { // this is an initialBWP AssertFatal((bwpd=CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)!=NULL, @@ -2915,23 +2926,26 @@ void nr_mac_update_timers(module_id_t module_id, NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; const NR_ServingCellConfig_t *spCellConfigDedicated = cg && cg->spCellConfig ? cg->spCellConfig->spCellConfigDedicated : NULL; + // re-configure BWP information + NR_UE_BWP_t *BWP = &UE->current_BWP; + // If needed, update the Dedicated BWP - const int current_bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; - const int current_ubwp_id = sched_ctrl->active_ubwp ? sched_ctrl->active_ubwp->bwp_Id : 0; if (spCellConfigDedicated && spCellConfigDedicated->downlinkBWP_ToAddModList && spCellConfigDedicated->uplinkConfig && spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) { - if (*spCellConfigDedicated->firstActiveDownlinkBWP_Id != current_bwp_id) { + if (*spCellConfigDedicated->firstActiveDownlinkBWP_Id != BWP->dl_bwp_id) { sched_ctrl->active_bwp = spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[*spCellConfigDedicated->firstActiveDownlinkBWP_Id - 1]; LOG_I(NR_MAC, "Changing to DL-BWP %li\n", sched_ctrl->active_bwp->bwp_Id); } - if (*spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id != current_ubwp_id) { + if (*spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id != BWP->ul_bwp_id) { sched_ctrl->active_ubwp = spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[*spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id - 1]; LOG_I(NR_MAC, "Changing to UL-BWP %li\n", sched_ctrl->active_ubwp->bwp_Id); } } + configure_UE_BWP(BWP, UE->CellGroup); + NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp; NR_BWP_DownlinkDedicated_t *bwpd = cg && cg->spCellConfig && diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index a86767ffbc..9378edfd47 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -938,13 +938,12 @@ void tci_handling(NR_UE_info_t *UE, frame_t frame, slot_t slot) { uint8_t target_ssb_beam_index = curr_ssb_beam_index; uint8_t is_triggering_ssb_beam_switch =0; uint8_t ssb_idx = 0; - int pdsch_bwp_id =0; + int pdsch_bwp_id = 0; int ssb_index[MAX_NUM_SSB] = {0}; int ssb_rsrp[MAX_NUM_SSB] = {0}; uint8_t idx = 0; - + NR_UE_BWP_t *BWP = &UE->current_BWP; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - const int bwp_id = sched_ctrl->active_bwp ? 1 : 0; NR_CellGroupConfig_t *CellGroup = UE->CellGroup; //bwp indicator @@ -960,6 +959,7 @@ void tci_handling(NR_UE_info_t *UE, frame_t frame, slot_t slot) { uint8_t diff_rsrp_idx = 0; uint8_t i, j; + const int bwp_id = BWP->dl_bwp_id; if (n_dl_bwp < 4) pdsch_bwp_id = bwp_id; else @@ -1632,6 +1632,7 @@ int nr_acknack_scheduling(int mod_id, * * each UE has dedicated PUCCH Format 0 resources, and we use index 0! */ NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_CellGroupConfig_t *cg = UE->CellGroup; + NR_UE_BWP_t *BWP = &UE->current_BWP; NR_PUCCH_Config_t *pucch_Config = NULL; if (sched_ctrl->active_ubwp) { @@ -1714,10 +1715,9 @@ int nr_acknack_scheduling(int mod_id, NR_SearchSpace__searchSpaceType_PR ss_type = (is_common==0 && (sched_ctrl->active_bwp || ubwpd)) ? NR_SearchSpace__searchSpaceType_PR_ue_Specific: NR_SearchSpace__searchSpaceType_PR_common; uint8_t pdsch_to_harq_feedback[8]; - const int bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; int max_fb_time = 0; - get_pdsch_to_harq_feedback(UE, bwp_id, ss_type, &max_fb_time, pdsch_to_harq_feedback); + get_pdsch_to_harq_feedback(UE, ss_type, &max_fb_time, pdsch_to_harq_feedback); LOG_D(NR_MAC, "In %s: 1b. DL %4d.%2d, UL_ACK %4d.%2d, DAI_C %d\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->dai_c); /* there is a HARQ. Check whether we can use it for this ACKNACK */ diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index dfc8b24ed8..53ebacdcc6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1526,6 +1526,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) if (sched_ctrl->ul_failure == 1 && get_softmodem_params()->phy_test==0) continue; NR_CellGroupConfig_t *cg = UE->CellGroup; + NR_UE_BWP_t *current_BWP = &UE->current_BWP; NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? @@ -1765,7 +1766,6 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) /* look up the PDCCH PDU for this BWP and CORESET. If it does not exist, * create it */ - const int bwp_id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; NR_SearchSpace_t *ss = (sched_ctrl->active_bwp || ubwpd) ? sched_ctrl->search_space: RC.nrmac[module_id]->sched_ctrlCommon->search_space; NR_ControlResourceSet_t *coreset = (sched_ctrl->active_bwp || ubwpd) ? sched_ctrl->coreset: RC.nrmac[module_id]->sched_ctrlCommon->coreset; const int coresetid = coreset->controlResourceSetId; @@ -1821,7 +1821,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) ps->time_domain_allocation, UE->UE_sched_ctrl.tpc0, n_ubwp, - bwp_id); + current_BWP->ul_bwp_id); fill_dci_pdu_rel15(scc, cg, dci_pdu, @@ -1829,7 +1829,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) ps->dci_format, rnti_types[0], pusch_pdu->bwp_size, - bwp_id, + current_BWP->ul_bwp_id, coresetid, 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 f3dd5208d6..1a73cf51ee 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -225,8 +225,7 @@ int nr_acknack_scheduling( int Mod_idP, int r_pucch, int do_common); -void get_pdsch_to_harq_feedback(NR_UE_info_t *, - int bwp_id, +void get_pdsch_to_harq_feedback(NR_UE_info_t *UE, NR_SearchSpace__searchSpaceType_PR ss_type, int *max_fb_time, uint8_t *pdsch_to_harq_feedback); @@ -406,7 +405,9 @@ NR_UE_info_t * find_nr_UE(NR_UEs_t* UEs, rnti_t rntiP); int find_nr_RA_id(module_id_t mod_idP, int CC_idP, rnti_t rntiP); -NR_UE_info_t*add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup); +void configure_UE_BWP(NR_UE_BWP_t *BWP, NR_CellGroupConfig_t *CellGroup); + +NR_UE_info_t* add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup); void mac_remove_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rnti); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 1d0d9750e6..f1692e7710 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -701,6 +701,11 @@ typedef struct NR_bler_options { uint8_t max_mcs; } NR_bler_options_t; +typedef struct NR_UE_BWP { + NR_BWP_Id_t dl_bwp_id; + NR_BWP_Id_t ul_bwp_id; +} NR_UE_BWP_t; + /*! \brief UE list used by gNB to order UEs/CC for scheduling*/ #define MAX_CSI_REPORTCONFIG 48 typedef struct { @@ -708,6 +713,7 @@ typedef struct { /// scheduling control info nr_csi_report_t csi_report_template[MAX_CSI_REPORTCONFIG]; NR_UE_sched_ctrl_t UE_sched_ctrl; + NR_UE_BWP_t current_BWP; NR_mac_stats_t mac_stats; NR_CellGroupConfig_t *CellGroup; char cg_buf[32768]; /* arbitrary size */ From 6c69393edaf7d8a82af9172169665d3bb25a4909 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 8 Jun 2022 12:22:16 +0200 Subject: [PATCH 03/16] genericParameters in the new structure --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 124 +++++++----------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 19 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 17 ++- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 98 +++++++------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c | 22 +--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 22 +--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 37 ++---- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 17 +-- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 19 ++- openair2/RRC/NR/MESSAGES/asn1_msg.c | 4 +- 10 files changed, 152 insertions(+), 227 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 76becbfcef..c00f89394a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -569,20 +569,8 @@ void nr_initiate_ra_proc(module_id_t module_idP, else ra_rnti = 1 + symbol + (slotP * 14) + (freq_index * 14 * 80) + (ul_carrier_id * 14 * 80 * 8); - // This should be handled differently when we use the initialBWP for RA - ra->dl_bwp_id = 0;//TODO - ra->ul_bwp_id = 0; - NR_BWP_Downlink_t *bwp=NULL; - if (ra->CellGroup && ra->CellGroup->spCellConfig && ra->CellGroup->spCellConfig->spCellConfigDedicated) { - if (ra->CellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) { - ra->dl_bwp_id = *ra->CellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id; - bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->dl_bwp_id - 1]; - } - if (ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig && - ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id) - ra->ul_bwp_id = *ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id; - } + // Configure RA BWP + configure_UE_BWP(&ra->BWP, scc, ra->CellGroup); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1); @@ -615,15 +603,19 @@ void nr_initiate_ra_proc(module_id_t module_idP, NR_SearchSpaceId_t ra_SearchSpace = 0; struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = NULL; - NR_BWP_t *genericParameters = NULL; + NR_BWP_Downlink_t *bwp=NULL; + if (ra->CellGroup && ra->CellGroup->spCellConfig && ra->CellGroup->spCellConfig->spCellConfigDedicated) { + if (ra->CellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id && + ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) { + bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->BWP.dl_bwp_id - 1]; + } + } if(bwp) { commonSearchSpaceList = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; ra_SearchSpace = *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; - genericParameters = &bwp->bwp_Common->genericParameters; } else { commonSearchSpaceList = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; ra_SearchSpace = *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; - genericParameters = &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; } AssertFatal(commonSearchSpaceList->list.count > 0, "common SearchSpace list has 0 elements\n"); @@ -641,7 +633,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra->ra_ss, ra->coreset, scc, - genericParameters, + ra->BWP.dl_genericParameters, &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]); // retrieving ra pdcch monitoring period and offset @@ -741,22 +733,19 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; + NR_UE_BWP_t *ra_BWP = &ra->BWP; NR_BWP_Uplink_t *ubwp = NULL; NR_BWP_UplinkDedicated_t *ubwpd = NULL; NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; - NR_BWP_t *genericParameters = NULL; if(ra->CellGroup) { - ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->ul_bwp_id-1]; + ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra_BWP->ul_bwp_id-1]; ubwpd = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; - genericParameters = &ubwp->bwp_Common->genericParameters; pusch_TimeDomainAllocationList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } else { - genericParameters = &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + } else pusch_TimeDomainAllocationList = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } - int mu = genericParameters->subcarrierSpacing; + int mu = ra_BWP->ul_genericParameters->subcarrierSpacing; uint8_t K2 = *pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->k2; const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; @@ -778,7 +767,6 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t tdd_beam_association[num_tdd_period] = ra->beam_id; } - int scs = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; int fh = 0; int startSymbolAndLength = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; int StartSymbolIndex, NrOfSymbols; @@ -823,7 +811,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t fill_msg3_pusch_pdu(pusch_pdu, scc, ra->msg3_round, startSymbolAndLength, - ra->rnti, scs, + ra->rnti, mu, BWPSize, BWPStart, mappingtype, fh, rbStart, ra->msg3_nb_rb); @@ -845,7 +833,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t ul_dci_request_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); pdcch_pdu_rel15 = &ul_dci_request_pdu->pdcch_pdu.pdcch_pdu_rel15; ul_dci_req->numPdus += 1; - nr_configure_pdcch(pdcch_pdu_rel15, coreset, genericParameters, &ra->sched_pdcch); + nr_configure_pdcch(pdcch_pdu_rel15, coreset, ra_BWP->dl_genericParameters, &ra->sched_pdcch); nr_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu_rel15; } @@ -894,7 +882,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t ra->Msg3_tda_id, ra->msg3_TPC, 0, // not used in format 0_0 - ra->ul_bwp_id); + &ra->BWP); fill_dci_pdu_rel15(scc, ra->CellGroup, @@ -903,7 +891,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t NR_UL_DCI_FORMAT_0_0, NR_RNTI_TC, pusch_pdu->bwp_size, - ra->ul_bwp_id, + ra_BWP->ul_bwp_id, coresetid, nr_mac->cset0_bwp_size); @@ -925,7 +913,6 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t ra->Msg3_slot = sched_slot; } - } void nr_get_Msg3alloc(module_id_t module_id, @@ -940,12 +927,11 @@ void nr_get_Msg3alloc(module_id_t module_id, // msg3 is scheduled in mixed slot in the following TDD period uint16_t msg3_nb_rb = 8; // sdu has 6 or 8 bytes - frame_type_t frame_type = RC.nrmac[module_id]->common_channels->frame_type; - int mu = ubwp ? - ubwp->bwp_Common->genericParameters.subcarrierSpacing : - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; + NR_UE_BWP_t *ra_BWP = &ra->BWP; + + int mu = ra_BWP->ul_genericParameters->subcarrierSpacing; int StartSymbolIndex = 0; int NrOfSymbols = 0; int startSymbolAndLength = 0; @@ -1018,10 +1004,9 @@ void nr_get_Msg3alloc(module_id_t module_id, int bwpSize = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); int bwpStart = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - if (ra->CellGroup) { - NR_BWP_Uplink_t *ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->ul_bwp_id - 1]; - int act_bwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int act_bwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + if (ra_BWP->ul_genericParameters != &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters) { + int act_bwp_start = NRRIV2PRBOFFSET(ra_BWP->ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + int act_bwp_size = NRRIV2BW(ra_BWP->ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); if (!((bwpStart >= act_bwp_start) && ((bwpStart+bwpSize) <= (act_bwp_start+act_bwp_size)))) bwpStart = act_bwp_start; } @@ -1056,7 +1041,6 @@ void fill_msg3_pusch_pdu(nfapi_nr_pusch_pdu_t *pusch_pdu, int mappingtype, int fh, int msg3_first_rb, int msg3_nb_rb) { - int start_symbol_index,nr_of_symbols; SLIV2SL(startSymbolAndLength, &start_symbol_index, &nr_of_symbols); @@ -1128,9 +1112,10 @@ void fill_msg3_pusch_pdu(nfapi_nr_pusch_pdu_t *pusch_pdu, void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t slotP, NR_RA_t *ra, uint8_t *RAR_pdu) { - gNB_MAC_INST *mac = RC.nrmac[module_idP]; - NR_COMMON_channels_t *cc = &mac->common_channels[CC_id]; - NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; + gNB_MAC_INST *mac = RC.nrmac[module_idP]; + NR_COMMON_channels_t *cc = &mac->common_channels[CC_id]; + NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; + NR_UE_BWP_t *ra_BWP = &ra->BWP; if (ra->state == RA_IDLE) { LOG_W(NR_MAC,"RA is not active for RA %X. skipping msg3 scheduling\n", ra->rnti); @@ -1164,17 +1149,16 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t memset(pusch_pdu, 0, sizeof(nfapi_nr_pusch_pdu_t)); int ibwp_size = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int scs = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; + int scs = ra_BWP->ul_genericParameters->subcarrierSpacing; int fh = 0; int startSymbolAndLength = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; int mappingtype = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; if (ra->CellGroup) { - NR_BWP_Uplink_t *ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->ul_bwp_id - 1]; + NR_BWP_Uplink_t *ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra_BWP->ul_bwp_id - 1]; startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; mappingtype = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; - scs = ubwp->bwp_Common->genericParameters.subcarrierSpacing; fh = ubwp->bwp_Dedicated->pusch_Config->choice.setup->frequencyHopping ? 1 : 0; } @@ -1205,6 +1189,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; + NR_UE_BWP_t *ra_BWP = &ra->BWP; if ((ra->Msg2_frame == frameP) && (ra->Msg2_slot == slotP)) { @@ -1217,20 +1202,17 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_BWP_Downlink_t *bwp = NULL; NR_ControlResourceSet_t *coreset = NULL; - NR_BWP_t *genericParameters = NULL; NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList=NULL; if (ra->CellGroup && ra->CellGroup->spCellConfig && ra->CellGroup->spCellConfig->spCellConfigDedicated && ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->dl_bwp_id-1]) { - bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->dl_bwp_id-1]; - genericParameters = &bwp->bwp_Common->genericParameters; + ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra_BWP->dl_bwp_id-1]) { + bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra_BWP->dl_bwp_id-1]; pdsch_TimeDomainAllocationList = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; } else { - genericParameters= &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; pdsch_TimeDomainAllocationList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; } @@ -1238,8 +1220,8 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra long BWPSize = 0; NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = NULL; if(*ss->controlResourceSetId!=0) { - BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - BWPSize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + BWPStart = NRRIV2PRBOFFSET(ra_BWP->dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + BWPSize = NRRIV2BW(ra_BWP->dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); } else { type0_PDCCH_CSS_config = &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]; BWPStart = type0_PDCCH_CSS_config->cset_start_rb; @@ -1314,7 +1296,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2 + sizeof(nfapi_nr_dl_tti_pdcch_pdu)); dl_req->nPDUs += 1; pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - nr_configure_pdcch(pdcch_pdu_rel15, coreset, genericParameters, &ra->sched_pdcch); + nr_configure_pdcch(pdcch_pdu_rel15, coreset, ra_BWP->dl_genericParameters, &ra->sched_pdcch); nr_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu_rel15; } @@ -1362,7 +1344,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->pduIndex = pduindex; pdsch_pdu_rel15->BWPSize = BWPSize; pdsch_pdu_rel15->BWPStart = BWPStart; - pdsch_pdu_rel15->SubcarrierSpacing = genericParameters->subcarrierSpacing; + pdsch_pdu_rel15->SubcarrierSpacing = ra_BWP->dl_genericParameters->subcarrierSpacing; pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; @@ -1421,7 +1403,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 bw_tbslbrm = get_bw_tbslbrm(genericParameters, ra->CellGroup); + int bw_tbslbrm = get_bw_tbslbrm(ra_BWP->dl_genericParameters, ra->CellGroup); pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(mcsTableIdx, bw_tbslbrm, 1); @@ -1478,7 +1460,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_DL_DCI_FORMAT_1_0, NR_RNTI_RA, BWPSize, - ra->dl_bwp_id, + ra_BWP->dl_bwp_id, coresetid, nr_mac->cset0_bwp_size); @@ -1487,7 +1469,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // Program UL processing for Msg3 NR_BWP_Uplink_t *ubwp = ra->CellGroup ? - ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->ul_bwp_id-1] : + ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra_BWP->ul_bwp_id-1] : NULL; nr_get_Msg3alloc(module_idP, CC_id, scc, ubwp, slotP, frameP, ra, nr_mac->tdd_beam_association); nr_add_msg3(module_idP, CC_id, frameP, slotP, ra, (uint8_t *) &tx_req->TLVs[0].value.direct[0]); @@ -1527,6 +1509,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; + NR_UE_BWP_t *ra_BWP = &ra->BWP; if (ra->Msg4_frame == frameP && ra->Msg4_slot == slotP ) { @@ -1544,8 +1527,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra ra->CellGroup->spCellConfig && ra->CellGroup->spCellConfig->spCellConfigDedicated && ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->dl_bwp_id-1]) { - bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->dl_bwp_id-1]; + ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra_BWP->dl_bwp_id-1]) { + bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra_BWP->dl_bwp_id-1]; pdsch_TimeDomainAllocationList = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; } else { @@ -1571,14 +1554,12 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra LOG_I(NR_MAC,"Generate msg4, rnti: %04x\n", ra->rnti); NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_BWP_t *genericParameters = bwp ? & bwp->bwp_Common->genericParameters : &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; - long BWPStart = 0; long BWPSize = 0; NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = NULL; if(*ss->controlResourceSetId!=0) { - BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - BWPSize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + BWPStart = NRRIV2PRBOFFSET(ra_BWP->dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + BWPSize = NRRIV2BW(ra_BWP->dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); } else { type0_PDCCH_CSS_config = &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]; BWPStart = type0_PDCCH_CSS_config->cset_start_rb; @@ -1772,7 +1753,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2 + sizeof(nfapi_nr_dl_tti_pdcch_pdu)); dl_req->nPDUs += 1; pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - nr_configure_pdcch(pdcch_pdu_rel15, coreset, genericParameters, &ra->sched_pdcch); + nr_configure_pdcch(pdcch_pdu_rel15, coreset, ra_BWP->dl_genericParameters, &ra->sched_pdcch); nr_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu_rel15; } @@ -1794,7 +1775,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->pduIndex = pduindex; pdsch_pdu_rel15->BWPSize = BWPSize; pdsch_pdu_rel15->BWPStart = BWPStart; - pdsch_pdu_rel15->SubcarrierSpacing = genericParameters->subcarrierSpacing; + pdsch_pdu_rel15->SubcarrierSpacing = ra_BWP->dl_genericParameters->subcarrierSpacing; pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; int R = nr_get_code_rate_dl(mcsIndex,mcsTableIdx); @@ -1823,7 +1804,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 bw_tbslbrm = get_bw_tbslbrm(genericParameters, ra->CellGroup); + int bw_tbslbrm = get_bw_tbslbrm(ra_BWP->dl_genericParameters, ra->CellGroup); pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(mcsTableIdx, bw_tbslbrm, 1); @@ -1893,7 +1874,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_DL_DCI_FORMAT_1_0, NR_RNTI_TC, pdsch_pdu_rel15->BWPSize, - ra->dl_bwp_id, + ra_BWP->dl_bwp_id, coresetid, nr_mac->cset0_bwp_size); @@ -1985,16 +1966,11 @@ void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_fram // Pause scheduling according to: // 3GPP TS 38.331 Section 12 Table 12.1-1: UE performance requirements for RRC procedures for UEs - const NR_COMMON_channels_t *common_channels = &RC.nrmac[module_id]->common_channels[0]; - const NR_SIB1_t *sib1 = common_channels->sib1 ? common_channels->sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; const NR_ServingCellConfig_t *servingCellConfig = UE->CellGroup ? UE->CellGroup->spCellConfig->spCellConfigDedicated : NULL; - NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, - common_channels->ServingCellConfigCommon, - sib1); uint32_t delay_ms = servingCellConfig && servingCellConfig->downlinkBWP_ToAddModList ? NR_RRC_SETUP_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_SETUP_DELAY_MS; - sched_ctrl->rrc_processing_timer = (delay_ms << genericParameters->subcarrierSpacing); + sched_ctrl->rrc_processing_timer = (delay_ms << ra->BWP.dl_genericParameters->subcarrierSpacing); LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %04x with %d ms\n", frame, slot, UE->rnti, delay_ms); } else { LOG_I(NR_MAC, "(ue rnti 0x%04x) RA Procedure failed at Msg4!\n", ra->rnti); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 51dd6d4a8d..fcb5d0d0ae 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -393,12 +393,9 @@ bool allocate_dl_retransmission(module_id_t module_id, cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, - RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon, - sib1); const int coresetid = (sched_ctrl->active_bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : RC.nrmac[module_id]->sched_ctrlCommon->coreset->controlResourceSetId; - const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : NRRIV2BW(UE->current_BWP.dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); int rbStart = 0; // start wrt BWPstart NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; @@ -672,9 +669,7 @@ void pf_dl(module_id_t module_id, RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, - RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon, - sib1); + NR_BWP_t *genericParameters = iterator->UE->current_BWP.dl_genericParameters; const int coresetid = (sched_ctrl->active_bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : @@ -828,10 +823,7 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); - const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, - RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon, - sib1); + NR_BWP_t *genericParameters = UE->current_BWP.dl_genericParameters; NR_BWP_DownlinkDedicated_t *bwpd = UE->CellGroup && @@ -1008,10 +1000,7 @@ void nr_schedule_ue_spec(module_id_t module_id, sched_ctrl->tpc1); NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp; - const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(bwp, - RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon, - sib1); + NR_BWP_t *genericParameters = current_BWP->dl_genericParameters; NR_SearchSpace_t *ss = (bwp||bwpd) ? sched_ctrl->search_space : gNB_mac->sched_ctrlCommon->search_space; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index aff03a5323..8300dd0ff4 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -194,6 +194,7 @@ void nr_preprocessor_phytest(module_id_t module_id, NR_UE_info_t *UE = RC.nrmac[module_id]->UE_info.list[0]; NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_BWP_t *BWP = &UE->current_BWP; const int CC_id = 0; const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); @@ -203,8 +204,8 @@ void nr_preprocessor_phytest(module_id_t module_id, nr_set_pdsch_semi_static(NULL, scc, UE->CellGroup, sched_ctrl->active_bwp, NULL, tda, target_dl_Nl,sched_ctrl , ps); /* find largest unallocated chunk */ - const int bwpSize = NRRIV2BW(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - const int BWPStart = NRRIV2PRBOFFSET(sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + const int bwpSize = NRRIV2BW(BWP->dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const int BWPStart = NRRIV2PRBOFFSET(BWP->dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); int rbStart = 0; int rbSize = 0; @@ -340,7 +341,6 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - const int mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; NR_UE_info_t *UE = nr_mac->UE_info.list[0]; AssertFatal(nr_mac->UE_info.list[1] == NULL, @@ -351,6 +351,9 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ const int CC_id = 0; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_BWP_t *BWP = &UE->current_BWP; + NR_BWP_t *genericParameters = BWP->ul_genericParameters; + const int mu = genericParameters->subcarrierSpacing; const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; @@ -398,12 +401,8 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ uint16_t rbStart = 0; uint16_t rbSize; - const int bw = NRRIV2BW(sched_ctrl->active_ubwp ? - sched_ctrl->active_ubwp->bwp_Common->genericParameters.locationAndBandwidth : - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - const int BWPStart = NRRIV2PRBOFFSET(sched_ctrl->active_ubwp ? - sched_ctrl->active_ubwp->bwp_Common->genericParameters.locationAndBandwidth : - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + const int bw = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const int BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); if (target_ul_bw>bw) rbSize = bw; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index cb767edda3..c03ae014d7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -245,33 +245,6 @@ void set_dl_dmrs_ports(NR_pdsch_semi_static_t *ps) { } } -NR_BWP_t *get_dl_bwp_genericParameters(NR_BWP_Downlink_t *active_bwp, - NR_ServingCellConfigCommon_t *ServingCellConfigCommon, - const NR_SIB1_t *sib1) { - NR_BWP_t *genericParameters = NULL; - if (active_bwp) { - genericParameters = &active_bwp->bwp_Common->genericParameters; - } else if (ServingCellConfigCommon) { - genericParameters = &ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters; - } else { - genericParameters = &sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.genericParameters; - } - return genericParameters; -} - -NR_BWP_t *get_ul_bwp_genericParameters(NR_BWP_Uplink_t *active_ubwp, - NR_ServingCellConfigCommon_t *ServingCellConfigCommon, - const NR_SIB1_t *sib1) { - NR_BWP_t *genericParameters = NULL; - if (active_ubwp) { - genericParameters = &active_ubwp->bwp_Common->genericParameters; - } else if (ServingCellConfigCommon) { - genericParameters = &ServingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP->genericParameters; - } else { - genericParameters = &sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.genericParameters; - } - return genericParameters; -} NR_PDSCH_TimeDomainResourceAllocationList_t *get_pdsch_TimeDomainAllocationList(const NR_BWP_Downlink_t *active_bwp, const NR_ServingCellConfigCommon_t *ServingCellConfigCommon, @@ -1033,13 +1006,11 @@ void config_uldci(const NR_SIB1_t *sib1, int time_domain_assignment, uint8_t tpc, int n_ubwp, - int bwp_id) { + NR_UE_BWP_t *BWP) { - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters((NR_BWP_Uplink_t *)ubwp, - (NR_ServingCellConfigCommon_t *)scc, - (NR_SIB1_t *)sib1); + int bwp_id = BWP->ul_bwp_id; - const int bw = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const int bw = NRRIV2BW(BWP->ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); dci_pdu_rel15->frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pusch_pdu->rb_size, pusch_pdu->rb_start, bw); @@ -1176,10 +1147,8 @@ int nr_get_pucch_resource(NR_ControlResourceSet_t *coreset, void nr_configure_pucch(const NR_SIB1_t *sib1, nfapi_nr_pucch_pdu_t* pucch_pdu, NR_ServingCellConfigCommon_t *scc, - NR_CellGroupConfig_t *CellGroup, - NR_BWP_Uplink_t *bwp, + NR_UE_info_t* UE, NR_BWP_UplinkDedicated_t *bwpd, - uint16_t rnti, uint8_t pucch_resource, uint16_t O_csi, uint16_t O_ack, @@ -1191,6 +1160,7 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, NR_PUCCH_ResourceSet_t *pucchresset; NR_PUCCH_FormatConfig_t *pucchfmt; NR_PUCCH_ResourceId_t *resource_id = NULL; + NR_BWP_Uplink_t *bwp = UE->UE_sched_ctrl.active_ubwp; long *id0 = NULL; int n_list, n_set; @@ -1252,7 +1222,7 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, else pucch_pdu->hopping_id = *scc->physCellId; - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(bwp,scc, sib1); + NR_BWP_t *genericParameters = UE->current_BWP.ul_genericParameters; pucch_pdu->bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); pucch_pdu->bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); @@ -1316,7 +1286,7 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, if (pucchres->pucch_ResourceId == *resource_id) { res_found = 1; pucch_pdu->prb_start = pucchres->startingPRB; - pucch_pdu->rnti = rnti; + pucch_pdu->rnti = UE->rnti; // FIXME why there is only one frequency hopping flag // what about inter slot frequency hopping? pucch_pdu->freq_hop_flag = pucchres->intraSlotFrequencyHopping!= NULL ? 1 : 0; @@ -1417,7 +1387,7 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, &start_symb); pucch_pdu->prb_start = prb_start; - pucch_pdu->rnti = rnti; + pucch_pdu->rnti = UE->rnti; pucch_pdu->freq_hop_flag = 1; pucch_pdu->second_hop_prb = second_hop_prb; pucch_pdu->format_type = default_pucch_fmt[rsetindex]; @@ -2378,7 +2348,12 @@ void delete_nr_ue_data(NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr) } } -void configure_UE_BWP(NR_UE_BWP_t *BWP, NR_CellGroupConfig_t *CellGroup) { +void configure_UE_BWP(NR_UE_BWP_t *BWP, + NR_ServingCellConfigCommon_t *scc, + NR_CellGroupConfig_t *CellGroup) { + + NR_BWP_Downlink_t *dl_bwp = NULL; + NR_BWP_Uplink_t *ul_bwp = NULL; if (CellGroup && CellGroup->spCellConfig && @@ -2394,7 +2369,37 @@ void configure_UE_BWP(NR_UE_BWP_t *BWP, NR_CellGroupConfig_t *CellGroup) { } if (servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id) BWP->ul_bwp_id = *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id; + + const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig->downlinkBWP_ToAddModList; + if (BWP->dl_bwp_id>0) { + for (int i=0; ilist.count; i++) { + if(dl_bwp->bwp_Id == BWP->dl_bwp_id) { + dl_bwp = bwpList->list.array[i - 1]; + break; + } + } + AssertFatal(dl_bwp!=NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n",BWP->dl_bwp_id); + } + + const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList; + if (BWP->ul_bwp_id>0) { + for (int i=0; ilist.count; i++) { + if(ul_bwp->bwp_Id == BWP->ul_bwp_id) { + ul_bwp = ubwpList->list.array[i - 1]; + break; + } + } + AssertFatal(ul_bwp!=NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n",BWP->ul_bwp_id); + } } + + BWP->dl_genericParameters = (BWP->dl_bwp_id>0 && dl_bwp) ? + &dl_bwp->bwp_Common->genericParameters: + &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + + BWP->ul_genericParameters = (BWP->ul_bwp_id>0 && ul_bwp) ? + &ul_bwp->bwp_Common->genericParameters: + &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; } //------------------------------------------------------------------------------ @@ -2446,7 +2451,7 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf // initialize UE BWP information NR_UE_BWP_t *BWP = &UE->current_BWP; memset(BWP, 0, sizeof(*BWP)); - configure_UE_BWP(BWP, CellGroup); + configure_UE_BWP(BWP, scc, CellGroup); /* set illegal time domain allocation to force recomputation of all fields */ sched_ctrl->pdsch_semi_static.time_domain_allocation = -1; @@ -2457,9 +2462,7 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig ? servingCellConfig->downlinkBWP_ToAddModList : NULL; sched_ctrl->active_bwp = bwpList && BWP->dl_bwp_id > 0 ? bwpList->list.array[BWP->dl_bwp_id - 1] : NULL; - NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? - &sched_ctrl->active_bwp->bwp_Common->genericParameters: - &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + const int target_ss = sched_ctrl->active_bwp ? NR_SearchSpace__searchSpaceType_PR_ue_Specific : NR_SearchSpace__searchSpaceType_PR_common; const NR_SIB1_t *sib1 = nr_mac->common_channels[0].sib1 ? nr_mac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; sched_ctrl->search_space = get_searchspace(sib1, @@ -2475,7 +2478,7 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf sched_ctrl->search_space, sched_ctrl->coreset, scc, - genericParameters, + BWP->dl_genericParameters, NULL); sched_ctrl->next_dl_bwp_id = -1; sched_ctrl->next_ul_bwp_id = -1; @@ -2712,6 +2715,7 @@ void nr_csirs_scheduling(int Mod_idP, continue; } NR_CellGroupConfig_t *CellGroup = UE->CellGroup; + NR_UE_BWP_t *BWP = &UE->current_BWP; if (!CellGroup || !CellGroup->spCellConfig || !CellGroup->spCellConfig->spCellConfigDedicated || !CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig) continue; @@ -2724,9 +2728,7 @@ void nr_csirs_scheduling(int Mod_idP, int period, offset; nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; - NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? - &sched_ctrl->active_bwp->bwp_Common->genericParameters : - &gNB_mac->common_channels[0].ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + NR_BWP_t *genericParameters = BWP->dl_genericParameters; for (int id = 0; id < csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.count; id++){ nzpcsi = csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.array[id]; @@ -2944,7 +2946,7 @@ void nr_mac_update_timers(module_id_t module_id, } } - configure_UE_BWP(BWP, UE->CellGroup); + configure_UE_BWP(BWP, scc, UE->CellGroup); NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp; NR_BWP_DownlinkDedicated_t *bwpd = cg && diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c index c156ebf36d..fe07925e3a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c @@ -36,19 +36,15 @@ extern RAN_CONTEXT_t RC; void nr_configure_srs(nfapi_nr_srs_pdu_t *srs_pdu, int module_id, int CC_id,NR_UE_info_t* UE, NR_SRS_Resource_t *srs_resource) { - gNB_MAC_INST *nrmac = RC.nrmac[module_id]; - NR_ServingCellConfigCommon_t *scc = nrmac->common_channels[CC_id].ServingCellConfigCommon; - NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_BWP_t *current_BWP = &UE->current_BWP; - NR_BWP_t ubwp = sched_ctrl->active_ubwp ? - sched_ctrl->active_ubwp->bwp_Common->genericParameters : - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + NR_BWP_t *ubwp = current_BWP->ul_genericParameters; srs_pdu->rnti = UE->rnti; srs_pdu->handle = 0; - srs_pdu->bwp_size = NRRIV2BW(ubwp.locationAndBandwidth, MAX_BWP_SIZE);; - srs_pdu->bwp_start = NRRIV2PRBOFFSET(ubwp.locationAndBandwidth, MAX_BWP_SIZE);; - srs_pdu->subcarrier_spacing = ubwp.subcarrierSpacing; + srs_pdu->bwp_size = NRRIV2BW(ubwp->locationAndBandwidth, MAX_BWP_SIZE);; + srs_pdu->bwp_start = NRRIV2PRBOFFSET(ubwp->locationAndBandwidth, MAX_BWP_SIZE);; + srs_pdu->subcarrier_spacing = ubwp->subcarrierSpacing; srs_pdu->cyclic_prefix = 0; srs_pdu->num_ant_ports = srs_resource->nrofSRS_Ports; srs_pdu->num_symbols = srs_resource->resourceMapping.nrofSymbols; @@ -114,9 +110,9 @@ void nr_schedule_srs(int module_id, frame_t frame) { UE_iterator(UE_info->list, UE) { const int CC_id = 0; - NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[CC_id].ServingCellConfigCommon; NR_CellGroupConfig_t *cg = UE->CellGroup; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_BWP_t *current_BWP = &UE->current_BWP; sched_ctrl->sched_srs.frame = -1; sched_ctrl->sched_srs.slot = -1; @@ -163,14 +159,10 @@ void nr_schedule_srs(int module_id, frame_t frame) { continue; } - NR_BWP_t ubwp = sched_ctrl->active_ubwp ? - sched_ctrl->active_ubwp->bwp_Common->genericParameters : - scc->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_BWP->ul_genericParameters->subcarrierSpacing]; // Check if UE will transmit the SRS in this frame if ( ((frame - offset/n_slots_frame)*n_slots_frame)%period == 0) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 9378edfd47..a4c10257e8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -93,10 +93,8 @@ static void nr_fill_nfapi_pucch(gNB_MAC_INST *nrmac, nr_configure_pucch(sib1, pucch_pdu, scc, - UE->CellGroup, - UE->UE_sched_ctrl.active_ubwp, + UE, ubwpd, - UE->rnti, pucch->resource_indicator, pucch->csi_bits, pucch->dai_c, @@ -706,6 +704,7 @@ void nr_csi_meas_reporting(int Mod_idP, UE_iterator(RC.nrmac[Mod_idP]->UE_info.list, UE ) { const NR_CellGroupConfig_t *CellGroup = UE->CellGroup; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_BWP_t *BWP = &UE->current_BWP; if ((sched_ctrl->rrc_processing_timer > 0) || (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0)) { continue; } @@ -765,12 +764,7 @@ void nr_csi_meas_reporting(int Mod_idP, curr_pucch->csi_bits += nr_get_csi_bitlen(UE,csi_report_id); - const NR_SIB1_t *sib1 = RC.nrmac[Mod_idP]->common_channels[0].sib1 ? RC.nrmac[Mod_idP]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, - scc, - sib1); - - int bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + int bwp_start = NRRIV2PRBOFFSET(BWP->ul_genericParameters->locationAndBandwidth,MAX_BWP_SIZE); // going through the list of PUCCH resources to find the one indexed by resource_id uint16_t *vrb_map_UL = &RC.nrmac[Mod_idP]->common_channels[0].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; @@ -1631,8 +1625,8 @@ int nr_acknack_scheduling(int mod_id, * later) * * each UE has dedicated PUCCH Format 0 resources, and we use index 0! */ NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_CellGroupConfig_t *cg = UE->CellGroup; NR_UE_BWP_t *BWP = &UE->current_BWP; + NR_CellGroupConfig_t *cg = UE->CellGroup; NR_PUCCH_Config_t *pucch_Config = NULL; if (sched_ctrl->active_ubwp) { @@ -1644,11 +1638,9 @@ int nr_acknack_scheduling(int mod_id, cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { pucch_Config = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; } - NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? - &sched_ctrl->active_ubwp->bwp_Common->genericParameters: - &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; - int bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); - int bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + + int bwp_start = NRRIV2PRBOFFSET(BWP->ul_genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + int bwp_size = NRRIV2BW(BWP->ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[0]; LOG_D(NR_MAC, "In %s: %4d.%2d Trying to allocate pucch, current DAI %d\n", __FUNCTION__, frame, slot, pucch->dai_c); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 53ebacdcc6..deb15d4c09 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -847,12 +847,8 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, - (NR_ServingCellConfigCommon_t *)scc, - sib1); - int rbStart = 0; // wrt BWP start - const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const uint16_t bwpSize = NRRIV2BW(UE->current_BWP.ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_bwp || ubwpd) ? 1 : 2; LOG_D(NR_MAC,"retInfo->time_domain_allocation = %d, tda = %d\n", retInfo->time_domain_allocation, tda); @@ -1042,10 +1038,7 @@ void pf_ul(module_id_t module_id, LOG_D(NR_MAC,"pf_ul: preparing UL scheduling for UE %04x\n",UE->rnti); NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, - scc, - sib1); + NR_UE_BWP_t *BWP = &UE->current_BWP; int rbStart = 0; // wrt BWP start NR_CellGroupConfig_t *cg = UE->CellGroup; @@ -1053,7 +1046,7 @@ void pf_ul(module_id_t module_id, cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const uint16_t bwpSize = NRRIV2BW(BWP->ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; const NR_mac_dir_stats_t *stats = &UE->mac_stats.ul; @@ -1243,17 +1236,15 @@ void pf_ul(module_id_t module_id, } else LOG_D(NR_MAC, "%4d.%2d free CCE for UL DCI UE %04x\n",frame,slot, iterator->UE->rnti); + NR_UE_BWP_t *BWP = &iterator->UE->current_BWP; NR_CellGroupConfig_t *cg = iterator->UE->CellGroup; NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, - scc, - sib1); - int rbStart = sched_ctrl->active_ubwp ? NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE) : 0; - const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + int rbStart = sched_ctrl->active_ubwp ? NRRIV2PRBOFFSET(BWP->ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE) : 0; + const uint16_t bwpSize = NRRIV2BW(BWP->ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; @@ -1346,9 +1337,6 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t AssertFatal(scc!=NULL || scc_sib1!=NULL,"We need one serving cell config common\n"); - const int mu = scc ? scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing : - scc_sib1->uplinkConfigCommon->initialUplinkBWP.genericParameters.subcarrierSpacing; - if (nr_mac->UE_info.list[0] == NULL) // no UEs return false; @@ -1360,6 +1348,9 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t * TDAs yet). If the TDA is negative, it means that there is no UL slot to * schedule now (slot + k2 is not UL slot) */ NR_UE_sched_ctrl_t *sched_ctrl = &nr_mac->UE_info.list[0]->UE_sched_ctrl; + NR_UE_BWP_t *BWP = &nr_mac->UE_info.list[0]->current_BWP; + NR_BWP_t *genericParameters = BWP->ul_genericParameters; + int mu = genericParameters->subcarrierSpacing; const int temp_tda = get_ul_tda(nr_mac, scc, slot); int K2 = get_K2(scc, scc_sib1, sched_ctrl->active_ubwp, temp_tda, mu); const int sched_frame = (frame + (slot + K2 >= nr_slots_per_frame[mu])) & 1023; @@ -1409,10 +1400,6 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, - scc, - sib1); - const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); const uint16_t bwpStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); @@ -1656,9 +1643,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->handle = 0; //not yet used /* FAPI: BWP */ - NR_BWP_t *genericParameters = get_ul_bwp_genericParameters(sched_ctrl->active_ubwp, - scc, - sib1); + NR_BWP_t *genericParameters = current_BWP->ul_genericParameters; pusch_pdu->bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); pusch_pdu->bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); @@ -1821,7 +1806,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) ps->time_domain_allocation, UE->UE_sched_ctrl.tpc0, n_ubwp, - current_BWP->ul_bwp_id); + current_BWP); fill_dci_pdu_rel15(scc, cg, dci_pdu, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 1a73cf51ee..6bcef03611 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -201,7 +201,7 @@ void config_uldci(const NR_SIB1_t *sib1, int time_domain_assignment, uint8_t tpc, int n_ubwp, - int bwp_id); + NR_UE_BWP_t *BWP); void nr_schedule_pucch(gNB_MAC_INST* nrmac, frame_t frameP, @@ -257,10 +257,8 @@ int nr_get_pucch_resource(NR_ControlResourceSet_t *coreset, void nr_configure_pucch(const NR_SIB1_t *sib1, nfapi_nr_pucch_pdu_t* pucch_pdu, NR_ServingCellConfigCommon_t *scc, - NR_CellGroupConfig_t *CellGroup, - NR_BWP_Uplink_t *bwp, + NR_UE_info_t* UE, NR_BWP_UplinkDedicated_t *bwpd, - uint16_t rnti, uint8_t pucch_resource, uint16_t O_csi, uint16_t O_ack, @@ -321,13 +319,6 @@ void set_r_pucch_parms(int rsetindex, int *nr_of_symbols, int *start_symbol_index); -NR_BWP_t *get_dl_bwp_genericParameters(NR_BWP_Downlink_t *active_bwp, - NR_ServingCellConfigCommon_t *ServingCellConfigCommon, - const NR_SIB1_t *sib1); - -NR_BWP_t *get_ul_bwp_genericParameters(NR_BWP_Uplink_t *active_ubwp, - NR_ServingCellConfigCommon_t *ServingCellConfigCommon, - const NR_SIB1_t *sib1); NR_PDSCH_TimeDomainResourceAllocationList_t *get_pdsch_TimeDomainAllocationList(const NR_BWP_Downlink_t *active_bwp, const NR_ServingCellConfigCommon_t *ServingCellConfigCommon, @@ -405,7 +396,9 @@ NR_UE_info_t * find_nr_UE(NR_UEs_t* UEs, rnti_t rntiP); int find_nr_RA_id(module_id_t mod_idP, int CC_idP, rnti_t rntiP); -void configure_UE_BWP(NR_UE_BWP_t *BWP, NR_CellGroupConfig_t *CellGroup); +void configure_UE_BWP(NR_UE_BWP_t *BWP, + NR_ServingCellConfigCommon_t *scc, + NR_CellGroupConfig_t *CellGroup); NR_UE_info_t* add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index f1692e7710..914f9b7052 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -91,6 +91,12 @@ typedef struct { int len; } NR_list_t; +typedef struct NR_UE_BWP { + NR_BWP_Id_t dl_bwp_id; + NR_BWP_Id_t ul_bwp_id; + NR_BWP_t *dl_genericParameters; + NR_BWP_t *ul_genericParameters; +} NR_UE_BWP_t; typedef enum { RA_IDLE = 0, @@ -124,10 +130,6 @@ typedef struct NR_sched_pdcch { typedef struct { /// Flag to indicate this process is active RA_gNB_state_t state; - /// DL BWP id of RA process - int dl_bwp_id; - /// UL BWP id of RA process - int ul_bwp_id; /// CORESET0 configured flag int coreset0_configured; /// Slot where preamble was received @@ -199,6 +201,8 @@ typedef struct { rnti_t crnti; /// CFRA flag bool cfra; + // BWP for RA + NR_UE_BWP_t BWP; } NR_RA_t; /*! \brief gNB common channels */ @@ -701,11 +705,6 @@ typedef struct NR_bler_options { uint8_t max_mcs; } NR_bler_options_t; -typedef struct NR_UE_BWP { - NR_BWP_Id_t dl_bwp_id; - NR_BWP_Id_t ul_bwp_id; -} NR_UE_BWP_t; - /*! \brief UE list used by gNB to order UEs/CC for scheduling*/ #define MAX_CSI_REPORTCONFIG 48 typedef struct { @@ -718,8 +717,6 @@ typedef struct { NR_CellGroupConfig_t *CellGroup; char cg_buf[32768]; /* arbitrary size */ asn_enc_rval_t enc_rval; - /// CCE indexing - int m; // UE selected beam index uint8_t UE_beam_index; bool Msg4_ACKed; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 7e38cac8a0..71b1b12fa0 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -304,8 +304,8 @@ uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { } uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, - gNB_RrcConfigurationReq *configuration - ) { + gNB_RrcConfigurationReq *configuration) { + asn_enc_rval_t enc_rval; NR_BCCH_DL_SCH_Message_t *sib1_message = CALLOC(1,sizeof(NR_BCCH_DL_SCH_Message_t)); From c1c5c68e707181932f3bddd61290be67acc637aa Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 10 Jun 2022 13:55:57 +0200 Subject: [PATCH 04/16] calling get_searchspace/coreset inside BWP function --- openair1/SIMULATION/NR_PHY/dlsim.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 4 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 109 ++++++++++-------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 7 +- 4 files changed, 65 insertions(+), 57 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 99236c9a43..d0b422dc74 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -276,7 +276,7 @@ void nr_dlsim_preprocessor(module_id_t module_id, /* manually set free CCE to 0 */ const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - sched_ctrl->search_space = get_searchspace(NULL, scc, sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, target_ss); + sched_ctrl->search_space = get_searchspace(scc, sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, target_ss); uint8_t nr_of_candidates; find_aggregation_candidates(&sched_ctrl->aggregation_level, &nr_of_candidates, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 7911c6e2ea..0336829e1c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -570,7 +570,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra_rnti = 1 + symbol + (slotP * 14) + (freq_index * 14 * 80) + (ul_carrier_id * 14 * 80 * 8); // Configure RA BWP - configure_UE_BWP(&ra->BWP, scc, ra->CellGroup); + configure_UE_BWP(nr_mac, &ra->BWP, scc, NULL, ra->CellGroup); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1); @@ -601,7 +601,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra->timing_offset = timing_offset; ra->preamble_slot = slotP; - NR_SearchSpaceId_t ra_SearchSpace = 0; + NR_SearchSpaceId_t ra_SearchSpace = 0; struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = NULL; NR_BWP_Downlink_t *bwp=NULL; if (ra->CellGroup && ra->CellGroup->spCellConfig && ra->CellGroup->spCellConfig->spCellConfigDedicated) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 8c74b580e7..45be14c622 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -266,6 +266,7 @@ NR_ControlResourceSet_t *get_coreset(gNB_MAC_INST *nrmac, void *bwp, NR_SearchSpace_t *ss, NR_SearchSpace__searchSpaceType_PR ss_type) { + NR_ControlResourceSetId_t coreset_id = *ss->controlResourceSetId; if (ss_type == NR_SearchSpace__searchSpaceType_PR_common) { // common search space @@ -297,29 +298,22 @@ NR_ControlResourceSet_t *get_coreset(gNB_MAC_INST *nrmac, } } -NR_SearchSpace_t *get_searchspace(const NR_SIB1_t *sib1, - NR_ServingCellConfigCommon_t *scc, +NR_SearchSpace_t *get_searchspace(NR_ServingCellConfigCommon_t *scc, NR_BWP_DownlinkDedicated_t *bwp_Dedicated, NR_SearchSpace__searchSpaceType_PR target_ss) { int n = 0; - if(bwp_Dedicated) { + if(bwp_Dedicated) n = bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count; - } else if(scc) { + else n = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list.count; - } else { - n = sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list.count; - } for (int i=0;ipdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]; - } else if(scc) { + else ss = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list.array[i]; - } else { - ss = sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list.array[i]; - } AssertFatal(ss->controlResourceSetId != NULL, "ss->controlResourceSetId is null\n"); AssertFatal(ss->searchSpaceType != NULL, "ss->searchSpaceType is null\n"); if (ss->searchSpaceType->present == target_ss) { @@ -2324,19 +2318,27 @@ void delete_nr_ue_data(NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr) } } -void configure_UE_BWP(NR_UE_BWP_t *BWP, +void configure_UE_BWP(gNB_MAC_INST *nr_mac, + NR_UE_BWP_t *BWP, NR_ServingCellConfigCommon_t *scc, + NR_UE_sched_ctrl_t *sched_ctrl, NR_CellGroupConfig_t *CellGroup) { NR_BWP_Downlink_t *dl_bwp = NULL; NR_BWP_Uplink_t *ul_bwp = NULL; + NR_BWP_DownlinkDedicated_t *bwpd = NULL; + NR_BWP_UplinkDedicated_t *ubwpd = NULL; + + int target_ss; if (CellGroup && CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated) { - const NR_ServingCellConfig_t *servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; - // (re)configuring BWP ID + const NR_ServingCellConfig_t *servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; + target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; + + // (re)configuring BWP // TODO BWP switching not via RRC reconfiguration // via RRC if firstActiveXlinkBWP_Id is NULL, MAC stays on the same BWP as before if (servingCellConfig->firstActiveDownlinkBWP_Id) { @@ -2349,10 +2351,9 @@ void configure_UE_BWP(NR_UE_BWP_t *BWP, const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig->downlinkBWP_ToAddModList; if (BWP->dl_bwp_id>0) { for (int i=0; ilist.count; i++) { - if(dl_bwp->bwp_Id == BWP->dl_bwp_id) { - dl_bwp = bwpList->list.array[i - 1]; + dl_bwp = bwpList->list.array[i]; + if(dl_bwp->bwp_Id == BWP->dl_bwp_id) break; - } } AssertFatal(dl_bwp!=NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n",BWP->dl_bwp_id); } @@ -2360,15 +2361,30 @@ void configure_UE_BWP(NR_UE_BWP_t *BWP, const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList; if (BWP->ul_bwp_id>0) { for (int i=0; ilist.count; i++) { - if(ul_bwp->bwp_Id == BWP->ul_bwp_id) { - ul_bwp = ubwpList->list.array[i - 1]; + ul_bwp = ubwpList->list.array[i]; + if(ul_bwp->bwp_Id == BWP->ul_bwp_id) break; - } } AssertFatal(ul_bwp!=NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n",BWP->ul_bwp_id); } + + // selection of dedicated BWPs + if(dl_bwp) + bwpd = dl_bwp->bwp_Dedicated; + else + bwpd = servingCellConfig->initialDownlinkBWP; + if(ul_bwp) + ubwpd = ul_bwp->bwp_Dedicated; + else + ubwpd = servingCellConfig->uplinkConfig->initialUplinkBWP; + } + else { + BWP->dl_bwp_id = 0; + BWP->ul_bwp_id = 0; + target_ss = NR_SearchSpace__searchSpaceType_PR_common; } + // acquiring generic parameters BWP->dl_genericParameters = (BWP->dl_bwp_id>0 && dl_bwp) ? &dl_bwp->bwp_Common->genericParameters: &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; @@ -2376,6 +2392,24 @@ void configure_UE_BWP(NR_UE_BWP_t *BWP, BWP->ul_genericParameters = (BWP->ul_bwp_id>0 && ul_bwp) ? &ul_bwp->bwp_Common->genericParameters: &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + + if(sched_ctrl) { + sched_ctrl->search_space = get_searchspace(scc, + bwpd, + target_ss); + sched_ctrl->coreset = get_coreset(nr_mac, + scc, + bwpd, + sched_ctrl->search_space, + target_ss); + + sched_ctrl->sched_pdcch = set_pdcch_structure(nr_mac, + sched_ctrl->search_space, + sched_ctrl->coreset, + scc, + BWP->dl_genericParameters, + nr_mac->type0_PDCCH_CSS_config); + } } //------------------------------------------------------------------------------ @@ -2428,7 +2462,7 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf // initialize UE BWP information NR_UE_BWP_t *BWP = &UE->current_BWP; memset(BWP, 0, sizeof(*BWP)); - configure_UE_BWP(BWP, scc, CellGroup); + configure_UE_BWP(nr_mac, BWP, scc, sched_ctrl, CellGroup); /* set illegal time domain allocation to force recomputation of all fields */ sched_ctrl->pdsch_semi_static.time_domain_allocation = -1; @@ -2440,23 +2474,6 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf sched_ctrl->active_bwp = bwpList && BWP->dl_bwp_id > 0 ? bwpList->list.array[BWP->dl_bwp_id - 1] : NULL; - const int target_ss = sched_ctrl->active_bwp ? NR_SearchSpace__searchSpaceType_PR_ue_Specific : NR_SearchSpace__searchSpaceType_PR_common; - const NR_SIB1_t *sib1 = nr_mac->common_channels[0].sib1 ? nr_mac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - sched_ctrl->search_space = get_searchspace(sib1, - scc, - sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, - target_ss); - sched_ctrl->coreset = get_coreset(nr_mac, - scc, - sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, - sched_ctrl->search_space, - target_ss); - sched_ctrl->sched_pdcch = set_pdcch_structure(nr_mac, - sched_ctrl->search_space, - sched_ctrl->coreset, - scc, - BWP->dl_genericParameters, - NULL); sched_ctrl->next_dl_bwp_id = -1; sched_ctrl->next_ul_bwp_id = -1; const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig ? servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList : NULL; @@ -2944,30 +2961,20 @@ void nr_mac_update_timers(module_id_t module_id, } } - configure_UE_BWP(BWP, scc, UE->CellGroup); + configure_UE_BWP(RC.nrmac[module_id], BWP, scc, sched_ctrl, UE->CellGroup); // Update coreset/searchspace NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp; NR_BWP_DownlinkDedicated_t *bwpd = NULL; - int target_ss = NR_SearchSpace__searchSpaceType_PR_common; if (bwp) { - target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; bwpd = sched_ctrl->active_bwp->bwp_Dedicated; } else if (cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && (cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)) { - target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; bwpd = cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; } - sched_ctrl->search_space = get_searchspace(sib1, scc, (void*)bwpd, target_ss); - sched_ctrl->coreset = get_coreset(RC.nrmac[module_id], scc, (void*)bwpd, sched_ctrl->search_space, target_ss); - sched_ctrl->sched_pdcch = set_pdcch_structure(RC.nrmac[module_id], - sched_ctrl->search_space, - sched_ctrl->coreset, - scc, - BWP->dl_genericParameters, - RC.nrmac[module_id]->type0_PDCCH_CSS_config); + sched_ctrl->maxL = 2; if (cg && cg->spCellConfig && diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 6bcef03611..f880b8e709 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -332,8 +332,7 @@ NR_ControlResourceSet_t *get_coreset(gNB_MAC_INST *nrmac, NR_SearchSpace__searchSpaceType_PR ss_type); /* find a search space within a BWP */ -NR_SearchSpace_t *get_searchspace(const NR_SIB1_t *sib1, - NR_ServingCellConfigCommon_t *scc, +NR_SearchSpace_t *get_searchspace(NR_ServingCellConfigCommon_t *scc, NR_BWP_DownlinkDedicated_t *bwp_Dedicated, NR_SearchSpace__searchSpaceType_PR target_ss); @@ -396,8 +395,10 @@ NR_UE_info_t * find_nr_UE(NR_UEs_t* UEs, rnti_t rntiP); int find_nr_RA_id(module_id_t mod_idP, int CC_idP, rnti_t rntiP); -void configure_UE_BWP(NR_UE_BWP_t *BWP, +void configure_UE_BWP(gNB_MAC_INST *nr_mac, + NR_UE_BWP_t *BWP, NR_ServingCellConfigCommon_t *scc, + NR_UE_sched_ctrl_t *sched_ctrl, NR_CellGroupConfig_t *CellGroup); NR_UE_info_t* add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup); From e592045d8f841579758dbb2e1a35c7e42bdbf585 Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 10 Jun 2022 18:18:57 +0200 Subject: [PATCH 05/16] improvements in using genericParameters and other stuff --- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 24 ++--- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 6 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 84 +++++----------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 54 ++++------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 11 +-- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 95 +++++++++++++------ .../LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c | 10 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 39 +++----- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 30 +++--- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 3 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 10 +- 13 files changed, 175 insertions(+), 195 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index bb80ff2a3c..c906a6dcef 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -4112,22 +4112,22 @@ uint16_t compute_pucch_prb_size(uint8_t format, } } -int get_bw_tbslbrm(NR_BWP_t *genericParameters, +int get_bw_tbslbrm(int scc_bwpsize, NR_CellGroupConfig_t *cg) { - int bw = 0; - if (cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) { - struct NR_ServingCellConfig__downlinkBWP_ToAddModList *BWP_list = cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList; - for (int i=0; ilist.count; i++) { - genericParameters = &BWP_list->list.array[i]->bwp_Common->genericParameters; - int curr_bw = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - if (curr_bw > bw) - bw = curr_bw; + int bw = scc_bwpsize; + if (cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated) { + const NR_ServingCellConfig_t *servingCellConfig = cg->spCellConfig->spCellConfigDedicated; + if(servingCellConfig->downlinkBWP_ToAddModList) { + struct NR_ServingCellConfig__downlinkBWP_ToAddModList *BWP_list = servingCellConfig->downlinkBWP_ToAddModList; + for (int i=0; ilist.count; i++) { + NR_BWP_t genericParameters = BWP_list->list.array[i]->bwp_Common->genericParameters; + int curr_bw = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + if (curr_bw > bw) + bw = curr_bw; + } } } - else - bw = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); return bw; } diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index a658c990bc..a7a2a88e94 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -140,7 +140,7 @@ uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); uint16_t get_nr_srs_offset(NR_SRS_PeriodicityAndOffset_t periodicityAndOffset); -int get_bw_tbslbrm(NR_BWP_t *genericParameters, +int get_bw_tbslbrm(int scc_bwpsize, NR_CellGroupConfig_t *cg); uint32_t nr_compute_tbslbrm(uint16_t table, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 6b8dce9c9a..d06e8b71ec 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -957,7 +957,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr 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; - bw_tbslbrm = get_bw_tbslbrm(&genericParameters, mac->cg); + int BWPSize = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + bw_tbslbrm = get_bw_tbslbrm(BWPSize, mac->cg); } else bw_tbslbrm = dlsch_config_pdu_1_0->BWPSize; @@ -1396,7 +1397,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr 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 bw_tbslbrm = get_bw_tbslbrm(&genericParameters, mac->cg); + int BWPSize = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int bw_tbslbrm = get_bw_tbslbrm(BWPSize, mac->cg); dlsch_config_pdu_1_1->tbslbrm = nr_compute_tbslbrm(dlsch_config_pdu_1_1->mcs_table, bw_tbslbrm, nl_tbslbrm); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 0336829e1c..05fcfb0e04 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -398,7 +398,7 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP void nr_schedule_msg2(uint16_t rach_frame, uint16_t rach_slot, uint16_t *msg2_frame, uint16_t *msg2_slot, - NR_ServingCellConfigCommon_t *scc, + int mu, NR_ServingCellConfigCommon_t *scc, frame_type_t frame_type, uint16_t monitoring_slot_period, uint16_t monitoring_offset,uint8_t beam_index, @@ -407,10 +407,9 @@ void nr_schedule_msg2(uint16_t rach_frame, uint16_t rach_slot, // preferentially we schedule the msg2 in the mixed slot or in the last dl slot // if they are allowed by search space configuration - uint8_t mu = *scc->ssbSubcarrierSpacing; uint8_t response_window = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.ra_ResponseWindow; uint8_t slot_window; - const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; + const int n_slots_frame = nr_slots_per_frame[mu]; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; // number of mixed slot or of last dl slot if there is no mixed slot uint8_t last_dl_slot_period = n_slots_frame-1; @@ -516,7 +515,6 @@ void nr_initiate_ra_proc(module_id_t module_idP, int16_t timing_offset){ uint8_t ul_carrier_id = 0; // 0 for NUL 1 for SUL - NR_SearchSpace_t *ss; uint16_t msg2_frame, msg2_slot,monitoring_slot_period,monitoring_offset; gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; @@ -570,7 +568,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra_rnti = 1 + symbol + (slotP * 14) + (freq_index * 14 * 80) + (ul_carrier_id * 14 * 80 * 8); // Configure RA BWP - configure_UE_BWP(nr_mac, &ra->BWP, scc, NULL, ra->CellGroup); + configure_UE_BWP(nr_mac, &ra->BWP, scc, NULL, ra, ra->CellGroup); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1); @@ -601,41 +599,6 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra->timing_offset = timing_offset; ra->preamble_slot = slotP; - NR_SearchSpaceId_t ra_SearchSpace = 0; - struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = NULL; - NR_BWP_Downlink_t *bwp=NULL; - if (ra->CellGroup && ra->CellGroup->spCellConfig && ra->CellGroup->spCellConfig->spCellConfigDedicated) { - if (ra->CellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) { - bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->BWP.dl_bwp_id - 1]; - } - } - if(bwp) { - commonSearchSpaceList = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - ra_SearchSpace = *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; - } else { - commonSearchSpaceList = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; - ra_SearchSpace = *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; - } - AssertFatal(commonSearchSpaceList->list.count > 0, "common SearchSpace list has 0 elements\n"); - - // Common SearchSpace list - for (int i = 0; i < commonSearchSpaceList->list.count; i++) { - ss = commonSearchSpaceList->list.array[i]; - if (ss->searchSpaceId == ra_SearchSpace) - ra->ra_ss = ss; - } - - AssertFatal(ra->ra_ss!=NULL,"SearchSpace cannot be null for RA\n"); - - ra->coreset = get_coreset(nr_mac, scc, bwp, ra->ra_ss, NR_SearchSpace__searchSpaceType_PR_common); - ra->sched_pdcch = set_pdcch_structure(nr_mac, - ra->ra_ss, - ra->coreset, - scc, - ra->BWP.dl_genericParameters, - &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]); - // retrieving ra pdcch monitoring period and offset find_monitoring_periodicity_offset_common(ra->ra_ss, &monitoring_slot_period, &monitoring_offset); @@ -643,6 +606,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, slotP, &msg2_frame, &msg2_slot, + ra->BWP.dl_scs, scc, frame_type, monitoring_slot_period, @@ -745,7 +709,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t } else pusch_TimeDomainAllocationList = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - int mu = ra_BWP->ul_genericParameters->subcarrierSpacing; + int mu = ra_BWP->ul_scs; uint8_t K2 = *pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->k2; const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; @@ -755,7 +719,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t int16_t *tdd_beam_association = nr_mac->tdd_beam_association; if (*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0] >= 257) { // FR2 - const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; + const int n_slots_frame = nr_slots_per_frame[mu]; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; AssertFatal(tdd,"Dynamic TDD not handled yet\n"); uint8_t tdd_period_slot = n_slots_frame/get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity); @@ -833,7 +797,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t ul_dci_request_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); pdcch_pdu_rel15 = &ul_dci_request_pdu->pdcch_pdu.pdcch_pdu_rel15; ul_dci_req->numPdus += 1; - nr_configure_pdcch(pdcch_pdu_rel15, coreset, ra_BWP->dl_genericParameters, &ra->sched_pdcch); + nr_configure_pdcch(pdcch_pdu_rel15, coreset, false, &ra->sched_pdcch); nr_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu_rel15; } @@ -931,7 +895,7 @@ void nr_get_Msg3alloc(module_id_t module_id, NR_UE_BWP_t *ra_BWP = &ra->BWP; - int mu = ra_BWP->ul_genericParameters->subcarrierSpacing; + int mu = ra_BWP->ul_scs; int StartSymbolIndex = 0; int NrOfSymbols = 0; int startSymbolAndLength = 0; @@ -1004,9 +968,9 @@ void nr_get_Msg3alloc(module_id_t module_id, int bwpSize = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); int bwpStart = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - if (ra_BWP->ul_genericParameters != &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters) { - int act_bwp_start = NRRIV2PRBOFFSET(ra_BWP->ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - int act_bwp_size = NRRIV2BW(ra_BWP->ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + if (bwpSize != ra_BWP->ul_BWPSize || bwpStart != ra_BWP->ul_BWPStart) { + int act_bwp_start = ra_BWP->ul_BWPStart; + int act_bwp_size = ra_BWP->ul_BWPSize; if (!((bwpStart >= act_bwp_start) && ((bwpStart+bwpSize) <= (act_bwp_start+act_bwp_size)))) bwpStart = act_bwp_start; } @@ -1149,7 +1113,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t memset(pusch_pdu, 0, sizeof(nfapi_nr_pusch_pdu_t)); int ibwp_size = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int scs = ra_BWP->ul_genericParameters->subcarrierSpacing; + int scs = ra_BWP->ul_scs; int fh = 0; int startSymbolAndLength = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; int mappingtype = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; @@ -1220,8 +1184,8 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra long BWPSize = 0; NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = NULL; if(*ss->controlResourceSetId!=0) { - BWPStart = NRRIV2PRBOFFSET(ra_BWP->dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - BWPSize = NRRIV2BW(ra_BWP->dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + BWPStart = ra_BWP->dl_BWPStart; + BWPSize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); } else { type0_PDCCH_CSS_config = &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]; BWPStart = type0_PDCCH_CSS_config->cset_start_rb; @@ -1296,7 +1260,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2 + sizeof(nfapi_nr_dl_tti_pdcch_pdu)); dl_req->nPDUs += 1; pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - nr_configure_pdcch(pdcch_pdu_rel15, coreset, ra_BWP->dl_genericParameters, &ra->sched_pdcch); + nr_configure_pdcch(pdcch_pdu_rel15, coreset, false, &ra->sched_pdcch); nr_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu_rel15; } @@ -1344,7 +1308,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->pduIndex = pduindex; pdsch_pdu_rel15->BWPSize = BWPSize; pdsch_pdu_rel15->BWPStart = BWPStart; - pdsch_pdu_rel15->SubcarrierSpacing = ra_BWP->dl_genericParameters->subcarrierSpacing; + pdsch_pdu_rel15->SubcarrierSpacing = ra_BWP->dl_scs; pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; @@ -1404,7 +1368,8 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->TBSize[0] = TBS; } - int bw_tbslbrm = get_bw_tbslbrm(ra_BWP->dl_genericParameters, ra->CellGroup); + int scc_bwpsize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int bw_tbslbrm = get_bw_tbslbrm(scc_bwpsize, ra->CellGroup); pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(mcsTableIdx, bw_tbslbrm, 1); @@ -1559,8 +1524,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra long BWPSize = 0; NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = NULL; if(*ss->controlResourceSetId!=0) { - BWPStart = NRRIV2PRBOFFSET(ra_BWP->dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - BWPSize = NRRIV2BW(ra_BWP->dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + BWPStart = ra_BWP->dl_BWPStart; + BWPSize = ra_BWP->dl_BWPSize; } else { type0_PDCCH_CSS_config = &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]; BWPStart = type0_PDCCH_CSS_config->cset_start_rb; @@ -1755,7 +1720,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2 + sizeof(nfapi_nr_dl_tti_pdcch_pdu)); dl_req->nPDUs += 1; pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; - nr_configure_pdcch(pdcch_pdu_rel15, coreset, ra_BWP->dl_genericParameters, &ra->sched_pdcch); + nr_configure_pdcch(pdcch_pdu_rel15, coreset, false, &ra->sched_pdcch); nr_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu_rel15; } @@ -1777,7 +1742,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->pduIndex = pduindex; pdsch_pdu_rel15->BWPSize = BWPSize; pdsch_pdu_rel15->BWPStart = BWPStart; - pdsch_pdu_rel15->SubcarrierSpacing = ra_BWP->dl_genericParameters->subcarrierSpacing; + pdsch_pdu_rel15->SubcarrierSpacing = ra_BWP->dl_scs; pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; int R = nr_get_code_rate_dl(mcsIndex,mcsTableIdx); @@ -1806,7 +1771,8 @@ 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 bw_tbslbrm = get_bw_tbslbrm(ra_BWP->dl_genericParameters, ra->CellGroup); + int scc_bwpsize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int bw_tbslbrm = get_bw_tbslbrm(scc_bwpsize, ra->CellGroup); pdsch_pdu_rel15->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(mcsTableIdx, bw_tbslbrm, 1); @@ -1972,7 +1938,7 @@ void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_fram uint32_t delay_ms = servingCellConfig && servingCellConfig->downlinkBWP_ToAddModList ? NR_RRC_SETUP_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_SETUP_DELAY_MS; - sched_ctrl->rrc_processing_timer = (delay_ms << ra->BWP.dl_genericParameters->subcarrierSpacing); + sched_ctrl->rrc_processing_timer = (delay_ms << ra->BWP.dl_scs); LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %04x with %d ms\n", frame, slot, UE->rnti, delay_ms); } else { LOG_I(NR_MAC, "(ue rnti 0x%04x) RA Procedure failed at Msg4!\n", ra->rnti); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index e2ceadb889..f3eea60e63 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -452,7 +452,7 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; nr_configure_pdcch(pdcch_pdu_rel15, gNB_mac->sched_ctrlCommon->coreset, - NULL, + true, // sib1 &gNB_mac->sched_ctrlCommon->sched_pdcch); nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index af09571195..8b7da91f63 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -394,8 +394,8 @@ bool allocate_dl_retransmission(module_id_t module_id, const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - const int coresetid = (sched_ctrl->active_bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : RC.nrmac[module_id]->sched_ctrlCommon->coreset->controlResourceSetId; - const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : NRRIV2BW(UE->current_BWP.dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const int coresetid = sched_ctrl->coreset->controlResourceSetId; + const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : UE->current_BWP.dl_BWPSize; int rbStart = 0; // start wrt BWPstart NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; @@ -670,14 +670,12 @@ void pf_dl(module_id_t module_id, RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - NR_BWP_t *genericParameters = iterator->UE->current_BWP.dl_genericParameters; + NR_UE_BWP_t *BWP = &iterator->UE->current_BWP; - const int coresetid = (sched_ctrl->active_bwp||bwpd) ? - sched_ctrl->coreset->controlResourceSetId : - RC.nrmac[module_id]->sched_ctrlCommon->coreset->controlResourceSetId; + const int coresetid = sched_ctrl->coreset->controlResourceSetId; const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : - NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + BWP->dl_BWPSize; int rbStart = 0; // start wrt BWPstart if (sched_ctrl->available_dl_harq.head < 0) { @@ -824,18 +822,12 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); - NR_BWP_t *genericParameters = UE->current_BWP.dl_genericParameters; + NR_UE_BWP_t *BWP = &UE->current_BWP; - NR_BWP_DownlinkDedicated_t *bwpd = - UE->CellGroup && - UE->CellGroup->spCellConfig && - UE->CellGroup->spCellConfig->spCellConfigDedicated ? - UE->CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; + const int coresetid = sched_ctrl->coreset->controlResourceSetId; - const int coresetid = (sched_ctrl->active_bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : RC.nrmac[module_id]->sched_ctrlCommon->coreset->controlResourceSetId; - - const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : NRRIV2BW(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); - const uint16_t BWPStart = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_start : NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : BWP->dl_BWPSize; + const uint16_t BWPStart = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_start : BWP->dl_BWPStart; const uint16_t slbitmap = SL_to_bitmap(startSymbolIndex, nrOfSymbols); uint16_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; @@ -920,12 +912,6 @@ void nr_schedule_ue_spec(module_id_t module_id, UE->mac_stats.dl.current_bytes = 0; NR_CellGroupConfig_t *cg = UE->CellGroup; - NR_BWP_DownlinkDedicated_t *bwpd = - cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated ? - cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; - /* update TA and set ta_apply every 10 frames. * Possible improvement: take the periodicity from input file. * If such UE is not scheduled now, it will be by the preprocessor later. @@ -999,14 +985,13 @@ void nr_schedule_ue_spec(module_id_t module_id, pucch->ul_slot, sched_pdsch->pucch_allocation, sched_ctrl->tpc1); + NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp; - NR_BWP_t *genericParameters = current_BWP->dl_genericParameters; - - NR_SearchSpace_t *ss = (bwp||bwpd) ? sched_ctrl->search_space : gNB_mac->sched_ctrlCommon->search_space; + NR_SearchSpace_t *ss = sched_ctrl->search_space; const int bwp_id = current_BWP->dl_bwp_id; - const int coresetid = (bwp||bwpd) ? sched_ctrl->coreset->controlResourceSetId : gNB_mac->sched_ctrlCommon->coreset->controlResourceSetId; + const int coresetid = sched_ctrl->coreset->controlResourceSetId; /* look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not exist, create it */ nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu = gNB_mac->pdcch_pdu_idx[CC_id][coresetid]; @@ -1020,8 +1005,8 @@ void nr_schedule_ue_spec(module_id_t module_id, dl_req->nPDUs += 1; pdcch_pdu = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; LOG_D(NR_MAC,"Trying to configure DL pdcch for UE %04x, bwp %d, cs %d\n", UE->rnti, bwp_id, coresetid); - NR_ControlResourceSet_t *coreset = (bwp||bwpd)? sched_ctrl->coreset:gNB_mac->sched_ctrlCommon->coreset; - nr_configure_pdcch(pdcch_pdu, coreset, genericParameters, &sched_ctrl->sched_pdcch); + NR_ControlResourceSet_t *coreset = sched_ctrl->coreset; + nr_configure_pdcch(pdcch_pdu, coreset, false, &sched_ctrl->sched_pdcch); gNB_mac->pdcch_pdu_idx[CC_id][coresetid] = pdcch_pdu; } @@ -1043,12 +1028,12 @@ void nr_schedule_ue_spec(module_id_t module_id, pdsch_pdu->BWPSize = gNB_mac->cset0_bwp_size; pdsch_pdu->BWPStart = gNB_mac->cset0_bwp_start; } else { - pdsch_pdu->BWPSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - pdsch_pdu->BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + pdsch_pdu->BWPSize = current_BWP->dl_BWPSize; + pdsch_pdu->BWPStart = current_BWP->dl_BWPStart; } - pdsch_pdu->SubcarrierSpacing = genericParameters->subcarrierSpacing; - pdsch_pdu->CyclicPrefix = genericParameters->cyclicPrefix ? *genericParameters->cyclicPrefix : 0; + pdsch_pdu->SubcarrierSpacing = current_BWP->dl_scs; + pdsch_pdu->CyclicPrefix = current_BWP->dl_cyclicprefix ? *current_BWP->dl_cyclicprefix : 0; // Codeword information pdsch_pdu->NrOfCodewords = 1; //number of information bits per 1024 coded bits expressed in 0.1 bit units @@ -1096,7 +1081,8 @@ void nr_schedule_ue_spec(module_id_t module_id, AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); int nl_tbslbrm = *maxMIMO_Layers < 4 ? *maxMIMO_Layers : 4; // Maximum number of PRBs across all configured DL BWPs - int bw_tbslbrm = get_bw_tbslbrm(genericParameters, cg); + int scc_bwpsize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + int bw_tbslbrm = get_bw_tbslbrm(scc_bwpsize, cg); pdsch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(ps->mcsTableIdx, bw_tbslbrm, nl_tbslbrm); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index fa114df5b7..f61fbd6da2 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -205,8 +205,8 @@ void nr_preprocessor_phytest(module_id_t module_id, nr_set_pdsch_semi_static(NULL, scc, UE->CellGroup, sched_ctrl->active_bwp, NULL, tda, target_dl_Nl,sched_ctrl , ps); /* find largest unallocated chunk */ - const int bwpSize = NRRIV2BW(BWP->dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - const int BWPStart = NRRIV2PRBOFFSET(BWP->dl_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const int bwpSize = BWP->dl_BWPSize; + const int BWPStart = BWP->dl_BWPStart; int rbStart = 0; int rbSize = 0; @@ -353,8 +353,7 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_UE_BWP_t *BWP = &UE->current_BWP; - NR_BWP_t *genericParameters = BWP->ul_genericParameters; - const int mu = genericParameters->subcarrierSpacing; + const int mu = BWP->ul_scs; const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; @@ -402,8 +401,8 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ uint16_t rbStart = 0; uint16_t rbSize; - const int bw = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - const int BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const int bw = BWP->ul_BWPSize; + const int BWPStart = BWP->ul_BWPStart; if (target_ul_bw>bw) rbSize = bw; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 45be14c622..7909f192b2 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -983,10 +983,8 @@ void config_uldci(const NR_SIB1_t *sib1, int bwp_id = BWP->ul_bwp_id; - const int bw = NRRIV2BW(BWP->ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - dci_pdu_rel15->frequency_domain_assignment.val = - PRBalloc_to_locationandbandwidth0(pusch_pdu->rb_size, pusch_pdu->rb_start, bw); + PRBalloc_to_locationandbandwidth0(pusch_pdu->rb_size, pusch_pdu->rb_start, BWP->ul_BWPSize); dci_pdu_rel15->time_domain_assignment.val = time_domain_assignment; dci_pdu_rel15->frequency_hopping_flag.val = pusch_pdu->frequency_hopping; dci_pdu_rel15->mcs = pusch_pdu->mcs_index; @@ -1063,7 +1061,7 @@ int nr_get_default_pucch_res(int pucch_ResourceCommon) { void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, NR_ControlResourceSet_t *coreset, - NR_BWP_t *bwp, + bool is_sib1, NR_sched_pdcch_t *pdcch) { @@ -1087,7 +1085,7 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, pdcch_pdu->ShiftIndex = pdcch->ShiftIndex; if(coreset->controlResourceSetId == 0) { - if(bwp == NULL) + if(is_sib1) pdcch_pdu->CoreSetType = NFAPI_NR_CSET_CONFIG_MIB_SIB1; else pdcch_pdu->CoreSetType = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG_CSET_0; @@ -1193,12 +1191,12 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, else pucch_pdu->hopping_id = *scc->physCellId; - NR_BWP_t *genericParameters = UE->current_BWP.ul_genericParameters; + NR_UE_BWP_t *BWP = &UE->current_BWP; - pucch_pdu->bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - pucch_pdu->bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); - pucch_pdu->subcarrier_spacing = genericParameters->subcarrierSpacing; - pucch_pdu->cyclic_prefix = (genericParameters->cyclicPrefix==NULL) ? 0 : *genericParameters->cyclicPrefix; + pucch_pdu->bwp_size = BWP->ul_BWPSize; + pucch_pdu->bwp_start = BWP->ul_BWPStart; + pucch_pdu->subcarrier_spacing = BWP->ul_scs; + pucch_pdu->cyclic_prefix = (BWP->ul_cyclicprefix==NULL) ? 0 : *BWP->ul_cyclicprefix; if (r_pucch<0 || bwp ){ LOG_D(NR_MAC,"pucch_acknak: Filling dedicated configuration for PUCCH\n"); // we have either a dedicated BWP or Dedicated PUCCH configuration on InitialBWP @@ -2322,6 +2320,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, NR_UE_BWP_t *BWP, NR_ServingCellConfigCommon_t *scc, NR_UE_sched_ctrl_t *sched_ctrl, + NR_RA_t *ra, NR_CellGroupConfig_t *CellGroup) { NR_BWP_Downlink_t *dl_bwp = NULL; @@ -2384,16 +2383,27 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, target_ss = NR_SearchSpace__searchSpaceType_PR_common; } - // acquiring generic parameters - BWP->dl_genericParameters = (BWP->dl_bwp_id>0 && dl_bwp) ? - &dl_bwp->bwp_Common->genericParameters: - &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + // setting generic parameters + NR_BWP_t dl_genericParameters = (BWP->dl_bwp_id>0 && dl_bwp) ? + dl_bwp->bwp_Common->genericParameters: + scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; - BWP->ul_genericParameters = (BWP->ul_bwp_id>0 && ul_bwp) ? - &ul_bwp->bwp_Common->genericParameters: - &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + BWP->dl_scs = dl_genericParameters.subcarrierSpacing; + BWP->dl_cyclicprefix = dl_genericParameters.cyclicPrefix; + BWP->dl_BWPSize = NRRIV2BW(dl_genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + BWP->dl_BWPStart = NRRIV2PRBOFFSET(dl_genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + + NR_BWP_t ul_genericParameters = (BWP->ul_bwp_id>0 && ul_bwp) ? + ul_bwp->bwp_Common->genericParameters: + scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + + BWP->ul_scs = ul_genericParameters.subcarrierSpacing; + BWP->ul_cyclicprefix = ul_genericParameters.cyclicPrefix; + BWP->ul_BWPSize = NRRIV2BW(ul_genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + BWP->ul_BWPStart = NRRIV2PRBOFFSET(ul_genericParameters.locationAndBandwidth, MAX_BWP_SIZE); if(sched_ctrl) { + // setting PDCCH related structures for sched_ctrl sched_ctrl->search_space = get_searchspace(scc, bwpd, target_ss); @@ -2407,9 +2417,37 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, sched_ctrl->search_space, sched_ctrl->coreset, scc, - BWP->dl_genericParameters, + &dl_genericParameters, nr_mac->type0_PDCCH_CSS_config); } + + if(ra) { + // setting PDCCH related structures for RA + struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = NULL; + NR_SearchSpaceId_t ra_SearchSpace = 0; + if(dl_bwp) { + commonSearchSpaceList = dl_bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; + ra_SearchSpace = *dl_bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + } else { + commonSearchSpaceList = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; + ra_SearchSpace = *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + } + AssertFatal(commonSearchSpaceList->list.count > 0, "common SearchSpace list has 0 elements\n"); + for (int i = 0; i < commonSearchSpaceList->list.count; i++) { + NR_SearchSpace_t * ss = commonSearchSpaceList->list.array[i]; + if (ss->searchSpaceId == ra_SearchSpace) + ra->ra_ss = ss; + } + AssertFatal(ra->ra_ss!=NULL,"SearchSpace cannot be null for RA\n"); + + ra->coreset = get_coreset(nr_mac, scc, dl_bwp, ra->ra_ss, NR_SearchSpace__searchSpaceType_PR_common); + ra->sched_pdcch = set_pdcch_structure(nr_mac, + ra->ra_ss, + ra->coreset, + scc, + &dl_genericParameters, + &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]); + } } //------------------------------------------------------------------------------ @@ -2462,7 +2500,7 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf // initialize UE BWP information NR_UE_BWP_t *BWP = &UE->current_BWP; memset(BWP, 0, sizeof(*BWP)); - configure_UE_BWP(nr_mac, BWP, scc, sched_ctrl, CellGroup); + configure_UE_BWP(nr_mac, BWP, scc, sched_ctrl, NULL, CellGroup); /* set illegal time domain allocation to force recomputation of all fields */ sched_ctrl->pdsch_semi_static.time_domain_allocation = -1; @@ -2719,7 +2757,6 @@ void nr_csirs_scheduling(int Mod_idP, int period, offset; nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; - NR_BWP_t *genericParameters = BWP->dl_genericParameters; for (int id = 0; id < csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.count; id++){ nzpcsi = csi_measconfig->nzp_CSI_RS_ResourceToAddModList->list.array[id]; @@ -2738,22 +2775,20 @@ void nr_csirs_scheduling(int Mod_idP, nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csirs_pdu_rel15 = &dl_tti_csirs_pdu->csi_rs_pdu.csi_rs_pdu_rel15; - csirs_pdu_rel15->subcarrier_spacing = genericParameters->subcarrierSpacing; - if (genericParameters->cyclicPrefix) - csirs_pdu_rel15->cyclic_prefix = *genericParameters->cyclicPrefix; + csirs_pdu_rel15->subcarrier_spacing = BWP->dl_scs; + if (BWP->dl_cyclicprefix) + csirs_pdu_rel15->cyclic_prefix = *BWP->dl_cyclicprefix; else csirs_pdu_rel15->cyclic_prefix = 0; // According to last paragraph of TS 38.214 5.2.2.3.1 - uint16_t BWPSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - uint16_t BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - if (resourceMapping.freqBand.startingRB < BWPStart) { - csirs_pdu_rel15->start_rb = BWPStart; + if (resourceMapping.freqBand.startingRB < BWP->dl_BWPStart) { + csirs_pdu_rel15->start_rb = BWP->dl_BWPStart; } else { csirs_pdu_rel15->start_rb = resourceMapping.freqBand.startingRB; } - if (resourceMapping.freqBand.nrofRBs > (BWPStart + BWPSize - csirs_pdu_rel15->start_rb)) { - csirs_pdu_rel15->nr_of_rbs = BWPStart + BWPSize - csirs_pdu_rel15->start_rb; + if (resourceMapping.freqBand.nrofRBs > (BWP->dl_BWPStart + BWP->dl_BWPSize - csirs_pdu_rel15->start_rb)) { + csirs_pdu_rel15->nr_of_rbs = BWP->dl_BWPStart + BWP->dl_BWPSize - csirs_pdu_rel15->start_rb; } else { csirs_pdu_rel15->nr_of_rbs = resourceMapping.freqBand.nrofRBs; } @@ -2961,7 +2996,7 @@ void nr_mac_update_timers(module_id_t module_id, } } - configure_UE_BWP(RC.nrmac[module_id], BWP, scc, sched_ctrl, UE->CellGroup); + configure_UE_BWP(RC.nrmac[module_id], BWP, scc, sched_ctrl, NULL, UE->CellGroup); // Update coreset/searchspace NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c index fe07925e3a..4397686c64 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c @@ -38,13 +38,11 @@ void nr_configure_srs(nfapi_nr_srs_pdu_t *srs_pdu, int module_id, int CC_id,NR_U NR_UE_BWP_t *current_BWP = &UE->current_BWP; - NR_BWP_t *ubwp = current_BWP->ul_genericParameters; - srs_pdu->rnti = UE->rnti; srs_pdu->handle = 0; - srs_pdu->bwp_size = NRRIV2BW(ubwp->locationAndBandwidth, MAX_BWP_SIZE);; - srs_pdu->bwp_start = NRRIV2PRBOFFSET(ubwp->locationAndBandwidth, MAX_BWP_SIZE);; - srs_pdu->subcarrier_spacing = ubwp->subcarrierSpacing; + srs_pdu->bwp_size = current_BWP->ul_BWPSize; + srs_pdu->bwp_start = current_BWP->ul_BWPStart; + srs_pdu->subcarrier_spacing = current_BWP->ul_scs; srs_pdu->cyclic_prefix = 0; srs_pdu->num_ant_ports = srs_resource->nrofSRS_Ports; srs_pdu->num_symbols = srs_resource->resourceMapping.nrofSymbols; @@ -162,7 +160,7 @@ void nr_schedule_srs(int module_id, frame_t frame) { 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[current_BWP->ul_genericParameters->subcarrierSpacing]; + int n_slots_frame = nr_slots_per_frame[current_BWP->ul_scs]; // Check if UE will transmit the SRS in this frame if ( ((frame - offset/n_slots_frame)*n_slots_frame)%period == 0) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 9d31135666..b5472542f9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -695,14 +695,11 @@ void nr_csi_meas_reporting(int Mod_idP, frame_t frame, sub_frame_t slot) { - NR_ServingCellConfigCommon_t *scc = RC.nrmac[Mod_idP]->common_channels->ServingCellConfigCommon; - const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; - - UE_iterator(RC.nrmac[Mod_idP]->UE_info.list, UE ) { const NR_CellGroupConfig_t *CellGroup = UE->CellGroup; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_UE_BWP_t *BWP = &UE->current_BWP; + const int n_slots_frame = nr_slots_per_frame[BWP->ul_scs]; if ((sched_ctrl->rrc_processing_timer > 0) || (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0)) { continue; } @@ -761,7 +758,7 @@ void nr_csi_meas_reporting(int Mod_idP, curr_pucch->resource_indicator = res_index; curr_pucch->csi_bits += nr_get_csi_bitlen(UE,csi_report_id); - int bwp_start = NRRIV2PRBOFFSET(BWP->ul_genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + int bwp_start = BWP->ul_BWPStart; // going through the list of PUCCH resources to find the one indexed by resource_id uint16_t *vrb_map_UL = &RC.nrmac[Mod_idP]->common_channels[0].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; @@ -1313,11 +1310,12 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, NR_ServingCellConfigCommon_t *scc) { /** From Table 6.3.1.1.2-3: RI, LI, CQI, and CRI of codebookType=typeI-SinglePanel */ - const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; uint8_t *payload = uci_pdu->csi_part1.csi_part1_payload; uint16_t bitlen = uci_pdu->csi_part1.csi_part1_bit_len; NR_CSI_ReportConfig__reportQuantity_PR reportQuantity_type = NR_CSI_ReportConfig__reportQuantity_PR_NOTHING; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_BWP_t *BWP = &UE->current_BWP; + const int n_slots_frame = nr_slots_per_frame[BWP->ul_scs]; int cumul_bits = 0; int r_index = -1; for (int csi_report_id = 0; csi_report_id < csi_MeasConfig->csi_ReportConfigToAddModList->list.count; csi_report_id++ ) { @@ -1607,7 +1605,8 @@ int nr_acknack_scheduling(int mod_id, const int CC_id = 0; const int minfbtime = RC.nrmac[mod_id]->minRXTXTIMEpdsch; const NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels[CC_id].ServingCellConfigCommon; - const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; + NR_UE_BWP_t *BWP = &UE->current_BWP; + const int n_slots_frame = nr_slots_per_frame[BWP->ul_scs]; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; AssertFatal(tdd || RC.nrmac[mod_id]->common_channels[CC_id].frame_type == FDD, "Dynamic TDD not handled yet\n"); const int nr_slots_period = tdd ? n_slots_frame / get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity) : n_slots_frame; @@ -1622,7 +1621,6 @@ int nr_acknack_scheduling(int mod_id, * later) * * each UE has dedicated PUCCH Format 0 resources, and we use index 0! */ NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_BWP_t *BWP = &UE->current_BWP; NR_CellGroupConfig_t *cg = UE->CellGroup; NR_PUCCH_Config_t *pucch_Config = NULL; @@ -1636,8 +1634,8 @@ int nr_acknack_scheduling(int mod_id, pucch_Config = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; } - int bwp_start = NRRIV2PRBOFFSET(BWP->ul_genericParameters->locationAndBandwidth,MAX_BWP_SIZE); - int bwp_size = NRRIV2BW(BWP->ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + int bwp_start = BWP->ul_BWPStart; + int bwp_size = BWP->ul_BWPSize; NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[0]; LOG_D(NR_MAC, "In %s: %4d.%2d Trying to allocate pucch, current DAI %d\n", __FUNCTION__, frame, slot, pucch->dai_c); @@ -1692,19 +1690,11 @@ int nr_acknack_scheduling(int mod_id, LOG_D(NR_MAC, "In %s: pucch_acknak 1. DL %4d.%2d, UL_ACK %4d.%2d, DAI_C %d\n", __FUNCTION__, frame, slot, pucch->frame, pucch->ul_slot, pucch->dai_c); - // this is hardcoded for now as ue specific only if we are not on the initialBWP (to be fixed to allow ue_Specific also on initialBWP - NR_BWP_UplinkDedicated_t *ubwpd=NULL; + NR_SearchSpace__searchSpaceType_PR ss_type = NR_SearchSpace__searchSpaceType_PR_common; + if(is_common == 0) + ss_type = sched_ctrl->search_space->searchSpaceType->present; - if (cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) - ubwpd = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; - - NR_SearchSpace__searchSpaceType_PR ss_type = (is_common==0 && (sched_ctrl->active_bwp || ubwpd)) ? NR_SearchSpace__searchSpaceType_PR_ue_Specific: NR_SearchSpace__searchSpaceType_PR_common; uint8_t pdsch_to_harq_feedback[8]; - int max_fb_time = 0; get_pdsch_to_harq_feedback(UE, ss_type, &max_fb_time, pdsch_to_harq_feedback); @@ -1727,7 +1717,6 @@ int nr_acknack_scheduling(int mod_id, // we cannot reach this timing anymore, allocate and try again const int f = pucch->frame; const int s = pucch->ul_slot; - const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; LOG_D(NR_MAC, "In %s: %4d.%2d DAI > 0, cannot reach timing for pucch in %4d.%2d, advancing slot by 1 and trying again\n", __FUNCTION__, frame, slot, f, s); if (!(csi_pucch && csi_pucch->csi_bits > 0 && @@ -1890,11 +1879,11 @@ void nr_sr_reporting(gNB_MAC_INST *nrmac, frame_t SFN, sub_frame_t slot) { if (!is_xlsch_in_slot(nrmac->ulsch_slot_bitmap[slot / 64], slot)) return; - NR_ServingCellConfigCommon_t *scc = nrmac->common_channels->ServingCellConfigCommon; - const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; + UE_iterator(nrmac->UE_info.list, UE) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - + NR_UE_BWP_t *BWP = &UE->current_BWP; + const int n_slots_frame = nr_slots_per_frame[BWP->ul_scs]; if (sched_ctrl->ul_failure==1) continue; NR_PUCCH_Config_t *pucch_Config = NULL; if (sched_ctrl->active_ubwp) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 45c0f1b1e1..5106715b47 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -847,9 +847,9 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; int rbStart = 0; // wrt BWP start - const uint16_t bwpSize = NRRIV2BW(UE->current_BWP.ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const uint16_t bwpSize = UE->current_BWP.ul_BWPSize; const uint8_t nrOfLayers = 1; - const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_bwp || ubwpd) ? 1 : 2; + const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; LOG_D(NR_MAC,"retInfo->time_domain_allocation = %d, tda = %d\n", retInfo->time_domain_allocation, tda); LOG_D(NR_MAC,"num_dmrs_cdm_grps_no_data %d, tbs %d\n",num_dmrs_cdm_grps_no_data, retInfo->tb_size); if (tda == retInfo->time_domain_allocation) { @@ -1045,7 +1045,7 @@ void pf_ul(module_id_t module_id, cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - const uint16_t bwpSize = NRRIV2BW(BWP->ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + const uint16_t bwpSize = BWP->ul_BWPSize; NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; const NR_mac_dir_stats_t *stats = &UE->mac_stats.ul; @@ -1242,8 +1242,8 @@ void pf_ul(module_id_t module_id, cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - int rbStart = sched_ctrl->active_ubwp ? NRRIV2PRBOFFSET(BWP->ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE) : 0; - const uint16_t bwpSize = NRRIV2BW(BWP->ul_genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + int rbStart = sched_ctrl->active_ubwp ? BWP->ul_BWPStart : 0; + const uint16_t bwpSize = BWP->ul_BWPSize; NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; @@ -1348,8 +1348,7 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t * schedule now (slot + k2 is not UL slot) */ NR_UE_sched_ctrl_t *sched_ctrl = &nr_mac->UE_info.list[0]->UE_sched_ctrl; NR_UE_BWP_t *BWP = &nr_mac->UE_info.list[0]->current_BWP; - NR_BWP_t *genericParameters = BWP->ul_genericParameters; - int mu = genericParameters->subcarrierSpacing; + int mu = BWP->ul_scs; const int temp_tda = get_ul_tda(nr_mac, scc, slot); int K2 = get_K2(scc, scc_sib1, sched_ctrl->active_ubwp, temp_tda, mu); const int sched_frame = (frame + (slot + K2 >= nr_slots_per_frame[mu])) & 1023; @@ -1399,8 +1398,8 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; - const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); - const uint16_t bwpStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); + const uint16_t bwpSize = BWP->ul_BWPSize; + const uint16_t bwpStart = BWP->ul_BWPStart; NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = NULL; if (sched_ctrl->active_ubwp) { @@ -1642,11 +1641,10 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->handle = 0; //not yet used /* FAPI: BWP */ - NR_BWP_t *genericParameters = current_BWP->ul_genericParameters; - pusch_pdu->bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - pusch_pdu->bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - pusch_pdu->subcarrier_spacing = genericParameters->subcarrierSpacing; + pusch_pdu->bwp_size = current_BWP->ul_BWPSize; + pusch_pdu->bwp_start = current_BWP->ul_BWPStart; + pusch_pdu->subcarrier_spacing = current_BWP->ul_scs; pusch_pdu->cyclic_prefix = 0; /* FAPI: PUSCH information always included */ @@ -1750,8 +1748,8 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) /* look up the PDCCH PDU for this BWP and CORESET. If it does not exist, * create it */ - NR_SearchSpace_t *ss = (sched_ctrl->active_bwp || ubwpd) ? sched_ctrl->search_space: RC.nrmac[module_id]->sched_ctrlCommon->search_space; - NR_ControlResourceSet_t *coreset = (sched_ctrl->active_bwp || ubwpd) ? sched_ctrl->coreset: RC.nrmac[module_id]->sched_ctrlCommon->coreset; + NR_SearchSpace_t *ss = sched_ctrl->search_space; + NR_ControlResourceSet_t *coreset = sched_ctrl->coreset; const int coresetid = coreset->controlResourceSetId; nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu = pdcch_pdu_coreset[coresetid]; if (!pdcch_pdu) { @@ -1761,7 +1759,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) ul_dci_request_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu)); pdcch_pdu = &ul_dci_request_pdu->pdcch_pdu.pdcch_pdu_rel15; ul_dci_req->numPdus += 1; - nr_configure_pdcch(pdcch_pdu, coreset, genericParameters, &sched_ctrl->sched_pdcch); + nr_configure_pdcch(pdcch_pdu, coreset, false, &sched_ctrl->sched_pdcch); pdcch_pdu_coreset[coresetid] = pdcch_pdu; } diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index f880b8e709..74e6884802 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -271,7 +271,7 @@ void find_search_space(int ss_type, void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, NR_ControlResourceSet_t *coreset, - NR_BWP_t *bwp, + bool is_sib1, NR_sched_pdcch_t *pdcch); NR_sched_pdcch_t set_pdcch_structure(gNB_MAC_INST *gNB_mac, @@ -399,6 +399,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, NR_UE_BWP_t *BWP, NR_ServingCellConfigCommon_t *scc, NR_UE_sched_ctrl_t *sched_ctrl, + NR_RA_t *ra, NR_CellGroupConfig_t *CellGroup); NR_UE_info_t* add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 914f9b7052..cf2e6be635 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -94,8 +94,14 @@ typedef struct { typedef struct NR_UE_BWP { NR_BWP_Id_t dl_bwp_id; NR_BWP_Id_t ul_bwp_id; - NR_BWP_t *dl_genericParameters; - NR_BWP_t *ul_genericParameters; + int dl_scs; + int ul_scs; + long *dl_cyclicprefix; + long *ul_cyclicprefix; + uint16_t dl_BWPSize; + uint16_t dl_BWPStart; + uint16_t ul_BWPSize; + uint16_t ul_BWPStart; } NR_UE_BWP_t; typedef enum { From 1be8caaf696feaad236a8d4bae22aeb39b7dbcea Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 14 Jun 2022 18:15:42 +0200 Subject: [PATCH 06/16] removing dl active_bwp --- openair1/SIMULATION/NR_PHY/dlsim.c | 11 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 82 +++++--------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 1 + .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 57 ++-------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 7 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 105 ++++++------------ .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 33 +++--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 1 + openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 11 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 5 +- 10 files changed, 101 insertions(+), 212 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index d0b422dc74..b5f946b8ab 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -272,25 +272,22 @@ void nr_dlsim_preprocessor(module_id_t module_id, NR_UE_info_t *UE_info = RC.nrmac[module_id]->UE_info.list[0]; AssertFatal(RC.nrmac[module_id]->UE_info.list[1]==NULL, "can have only a single UE\n"); NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl; + NR_UE_BWP_t *BWP = &UE_info->current_BWP; NR_ServingCellConfigCommon_t *scc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon; /* manually set free CCE to 0 */ - const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - sched_ctrl->search_space = get_searchspace(scc, sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, target_ss); + uint8_t nr_of_candidates; find_aggregation_candidates(&sched_ctrl->aggregation_level, &nr_of_candidates, sched_ctrl->search_space,4); - sched_ctrl->coreset = get_coreset(RC.nrmac[module_id], scc, sched_ctrl->active_bwp->bwp_Dedicated, sched_ctrl->search_space, target_ss); sched_ctrl->cce_index = 0; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; - nr_set_pdsch_semi_static(NULL, + nr_set_pdsch_semi_static(BWP, scc, UE_info->CellGroup, - sched_ctrl->active_bwp, - NULL, /* tda = */ 0, g_nrOfLayers, sched_ctrl, @@ -838,6 +835,8 @@ int main(int argc, char **argv) N_RB_DL = gNB->frame_parms.N_RB_DL; NR_UE_info_t *UE_info = RC.nrmac[0]->UE_info.list[0]; + configure_UE_BWP(RC.nrmac[0], &UE_info->current_BWP, scc, &UE_info->UE_sched_ctrl, NULL, UE_info->CellGroup); + // stub to configure frame_parms // nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); // call MAC to configure common parameters diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 05fcfb0e04..1bbbc6ac85 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -850,6 +850,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t fill_dci_pdu_rel15(scc, ra->CellGroup, + ra_BWP, dci_pdu, &uldci_payload, NR_UL_DCI_FORMAT_0_0, @@ -1164,21 +1165,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_SearchSpace_t *ss = ra->ra_ss; - NR_BWP_Downlink_t *bwp = NULL; - NR_ControlResourceSet_t *coreset = NULL; - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList=NULL; - - if (ra->CellGroup && - ra->CellGroup->spCellConfig && - ra->CellGroup->spCellConfig->spCellConfigDedicated && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra_BWP->dl_bwp_id-1]) { - bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra_BWP->dl_bwp_id-1]; - pdsch_TimeDomainAllocationList = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } - else { - pdsch_TimeDomainAllocationList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = ra_BWP->tdaList; long BWPStart = 0; long BWPSize = 0; @@ -1199,7 +1186,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); AssertFatal(startSymbolIndex >= 0, "StartSymbolIndex is negative\n"); - coreset = ra->coreset; + NR_ControlResourceSet_t *coreset = ra->coreset; AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg2\n"); @@ -1278,13 +1265,11 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // information to data and is reset every slot. const int pduindex = nr_mac->pdu_index[CC_id]++; + NR_PDSCH_Config_t *pdsch_Config = ra_BWP->pdsch_Config; uint8_t mcsTableIdx = 0; - if (bwp && - bwp->bwp_Dedicated && - bwp->bwp_Dedicated->pdsch_Config && - bwp->bwp_Dedicated->pdsch_Config->choice.setup && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table) { - if (*bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table == 0) + if (pdsch_Config && + pdsch_Config->mcs_Table) { + if (*pdsch_Config->mcs_Table == 0) mcsTableIdx = 1; else mcsTableIdx = 2; @@ -1292,17 +1277,12 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra else mcsTableIdx = 0; int dmrsConfigType=0; - if (bwp && - bwp->bwp_Dedicated && - bwp->bwp_Dedicated->pdsch_Config && - bwp->bwp_Dedicated->pdsch_Config->choice.setup && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type) + if (pdsch_Config && + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA && + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup && + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type) dmrsConfigType = 1; - NR_PDSCH_Config_t *pdsch_config = bwp && bwp->bwp_Dedicated && bwp->bwp_Dedicated->pdsch_Config ? bwp->bwp_Dedicated->pdsch_Config->choice.setup : NULL; - pdsch_pdu_rel15->pduBitmap = 0; pdsch_pdu_rel15->rnti = ra->RA_rnti; pdsch_pdu_rel15->pduIndex = pduindex; @@ -1328,7 +1308,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->VRBtoPRBMapping = 0; pdsch_pdu_rel15->StartSymbolIndex = startSymbolIndex; pdsch_pdu_rel15->NrOfSymbols = nrOfSymbols; - pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config, + pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(pdsch_Config, nr_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position, nrOfSymbols, startSymbolIndex, @@ -1421,6 +1401,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra fill_dci_pdu_rel15(scc, ra->CellGroup, + ra_BWP, &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci - 1], &dci_payload, NR_DL_DCI_FORMAT_1_0, @@ -1485,23 +1466,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_SearchSpace_t *ss = ra->ra_ss; - NR_BWP_Downlink_t *bwp = NULL; - NR_ControlResourceSet_t *coreset = NULL; - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList=NULL; - - if (ra->CellGroup && - ra->CellGroup->spCellConfig && - ra->CellGroup->spCellConfig->spCellConfigDedicated && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra_BWP->dl_bwp_id-1]) { - bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra_BWP->dl_bwp_id-1]; - pdsch_TimeDomainAllocationList = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } - else { - pdsch_TimeDomainAllocationList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } - - coreset = ra->coreset; + NR_ControlResourceSet_t *coreset = ra->coreset; + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = ra_BWP->tdaList; AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg4\n"); @@ -1635,7 +1601,13 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra uint16_t N_DMRS_SLOT = get_num_dmrs(dlDmrsSymbPos); - long dmrsConfigType = bwp!=NULL ? (bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1) : 0; + NR_PDSCH_Config_t *pdsch_Config = ra_BWP->pdsch_Config; + int dmrsConfigType=0; + if (pdsch_Config && + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA && + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup && + pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type) + dmrsConfigType = 1; nr_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData = 2; if (nrOfSymbols == 2) { @@ -1656,12 +1628,9 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra } uint8_t mcsTableIdx = 0; - if (bwp && - bwp->bwp_Dedicated && - bwp->bwp_Dedicated->pdsch_Config && - bwp->bwp_Dedicated->pdsch_Config->choice.setup && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table) { - if (*bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table == 0) + if (pdsch_Config && + pdsch_Config->mcs_Table) { + if (*pdsch_Config->mcs_Table == 0) mcsTableIdx = 1; else mcsTableIdx = 2; @@ -1837,6 +1806,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra fill_dci_pdu_rel15(scc, ra->CellGroup, + ra_BWP, &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci - 1], &dci_payload, NR_DL_DCI_FORMAT_1_0, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index f3eea60e63..743358f47d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -545,6 +545,7 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, int rnti_type = NR_RNTI_SI; fill_dci_pdu_rel15(scc, + NULL, NULL, &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci - 1], &dci_payload, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 8b7da91f63..829e288eae 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -376,15 +376,10 @@ bool allocate_dl_retransmission(module_id_t module_id, gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; const NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels->ServingCellConfigCommon; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_BWP_t *BWP = &UE->current_BWP; NR_sched_pdsch_t *retInfo = &sched_ctrl->harq_processes[current_harq_pid].sched_pdsch; NR_CellGroupConfig_t *cg = UE->CellGroup; - NR_BWP_DownlinkDedicated_t *bwpd = - cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated ? - cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; - NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && @@ -392,8 +387,6 @@ bool allocate_dl_retransmission(module_id_t module_id, cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - const int coresetid = sched_ctrl->coreset->controlResourceSetId; const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : UE->current_BWP.dl_BWPSize; @@ -427,11 +420,9 @@ bool allocate_dl_retransmission(module_id_t module_id, /* check whether we need to switch the TDA allocation since the last * (re-)transmission */ if (ps->time_domain_allocation != tda) { - nr_set_pdsch_semi_static(sib1, + nr_set_pdsch_semi_static(BWP, scc, cg, - sched_ctrl->active_bwp, - bwpd, tda, ps->nrOfLayers, sched_ctrl, @@ -442,11 +433,9 @@ bool allocate_dl_retransmission(module_id_t module_id, * that we have enough resources */ NR_pdsch_semi_static_t temp_ps = *ps; - nr_set_pdsch_semi_static(sib1, + nr_set_pdsch_semi_static(BWP, scc, cg, - sched_ctrl->active_bwp, - bwpd, tda, ps->nrOfLayers, sched_ctrl, @@ -651,12 +640,6 @@ void pf_dl(module_id_t module_id, NR_CellGroupConfig_t *cg = iterator->UE->CellGroup; - NR_BWP_DownlinkDedicated_t *bwpd = - cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated ? - cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; - NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && @@ -666,9 +649,6 @@ void pf_dl(module_id_t module_id, NR_UE_sched_ctrl_t *sched_ctrl = &iterator->UE->UE_sched_ctrl; const uint16_t rnti = iterator->UE->rnti; - const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? - RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : - NULL; NR_UE_BWP_t *BWP = &iterator->UE->current_BWP; @@ -744,11 +724,9 @@ void pf_dl(module_id_t module_id, NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; if (ps->nrOfLayers != iterator->UE->layers || ps->time_domain_allocation != tda ) { - nr_set_pdsch_semi_static(sib1, + nr_set_pdsch_semi_static(BWP, scc, iterator->UE->CellGroup, - sched_ctrl->active_bwp, - bwpd, tda, iterator->UE->layers, sched_ctrl, @@ -813,17 +791,14 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t /* This is temporary and it assumes all UEs have the same BWP and TDA*/ NR_UE_info_t *UE=UE_info->list[0]; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_BWP_t *BWP = &UE->current_BWP; const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); int startSymbolIndex, nrOfSymbols; - const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_bwp ? - sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList : - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = BWP->tdaList; AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); - NR_UE_BWP_t *BWP = &UE->current_BWP; - const int coresetid = sched_ctrl->coreset->controlResourceSetId; const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : BWP->dl_BWPSize; @@ -986,8 +961,6 @@ void nr_schedule_ue_spec(module_id_t module_id, sched_pdsch->pucch_allocation, sched_ctrl->tpc1); - NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp; - NR_SearchSpace_t *ss = sched_ctrl->search_space; const int bwp_id = current_BWP->dl_bwp_id; @@ -1087,13 +1060,7 @@ void nr_schedule_ue_spec(module_id_t module_id, bw_tbslbrm, nl_tbslbrm); - NR_PDSCH_Config_t *pdsch_Config=NULL; - - if (bwp && - bwp->bwp_Dedicated && - bwp->bwp_Dedicated->pdsch_Config && - bwp->bwp_Dedicated->pdsch_Config->choice.setup) - pdsch_Config = bwp->bwp_Dedicated->pdsch_Config->choice.setup; + NR_PDSCH_Config_t *pdsch_Config = current_BWP->pdsch_Config; /* Check and validate PTRS values */ struct NR_SetupRelease_PTRS_DownlinkConfig *phaseTrackingRS = @@ -1140,14 +1107,11 @@ void nr_schedule_ue_spec(module_id_t module_id, dci_pdu_rel15_t dci_payload; memset(&dci_payload, 0, sizeof(dci_pdu_rel15_t)); // bwp indicator - const int n_dl_bwp = bwp ? cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count : 0; - AssertFatal(n_dl_bwp <= NR_MAX_NUM_BWP, "downlinkBWP_ToAddModList has %d BWP!\n", n_dl_bwp); - // as per table 7.3.1.1.2-1 in 38.212 - dci_payload.bwp_indicator.val = bwp ? (n_dl_bwp < 4 ? bwp_id : bwp_id - 1) : 0; + dci_payload.bwp_indicator.val = current_BWP->n_dl_bwp < 4 ? bwp_id : bwp_id - 1; - if (bwp) AssertFatal(bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation == NR_PDSCH_Config__resourceAllocation_resourceAllocationType1, - "Only frequency resource allocation type 1 is currently supported\n"); + AssertFatal(pdsch_Config->resourceAllocation == NR_PDSCH_Config__resourceAllocation_resourceAllocationType1, + "Only frequency resource allocation type 1 is currently supported\n"); dci_payload.frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pdsch_pdu->rbSize, pdsch_pdu->rbStart, @@ -1189,6 +1153,7 @@ void nr_schedule_ue_spec(module_id_t module_id, const int rnti_type = NR_RNTI_C; fill_dci_pdu_rel15(scc, cg, + current_BWP, dci_pdu, &dci_payload, dci_format, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index f61fbd6da2..94b3f99fa0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -202,7 +202,7 @@ void nr_preprocessor_phytest(module_id_t module_id, NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; ps->nrOfLayers = target_dl_Nl; if (ps->time_domain_allocation != tda || ps->nrOfLayers != target_dl_Nl) - nr_set_pdsch_semi_static(NULL, scc, UE->CellGroup, sched_ctrl->active_bwp, NULL, tda, target_dl_Nl,sched_ctrl , ps); + nr_set_pdsch_semi_static(BWP, scc, UE->CellGroup, tda, target_dl_Nl,sched_ctrl , ps); /* find largest unallocated chunk */ const int bwpSize = BWP->dl_BWPSize; @@ -380,9 +380,8 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ if (!is_xlsch_in_slot(ulsch_slot_bitmap, sched_slot)) return false; - const long f = (sched_ctrl->active_bwp && sched_ctrl->search_space && - sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) ? - sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; + const long f = (sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) ? + sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; const int dci_format = f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0; uint8_t num_dmrs_cdm_grps_no_data = 1; if ((target_ul_Nl==4)||(target_ul_Nl==3)) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 7909f192b2..2fd3c0620a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -245,22 +245,6 @@ void set_dl_dmrs_ports(NR_pdsch_semi_static_t *ps) { } } - -NR_PDSCH_TimeDomainResourceAllocationList_t *get_pdsch_TimeDomainAllocationList(const NR_BWP_Downlink_t *active_bwp, - const NR_ServingCellConfigCommon_t *ServingCellConfigCommon, - const NR_SIB1_t *sib1) { - NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = NULL; - if (active_bwp) { - tdaList = active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } else if (ServingCellConfigCommon) { - tdaList = ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } else { - tdaList = sib1->servingCellConfigCommon->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - } - return tdaList; -} - - NR_ControlResourceSet_t *get_coreset(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, void *bwp, @@ -544,11 +528,9 @@ bool nr_find_nb_rb(uint16_t Qm, return *tbs >= bytes && *nb_rb <= nb_rb_max; } -void nr_set_pdsch_semi_static(const NR_SIB1_t *sib1, +void nr_set_pdsch_semi_static(const NR_UE_BWP_t *BWP, const NR_ServingCellConfigCommon_t *scc, const NR_CellGroupConfig_t *secondaryCellGroup, - const NR_BWP_Downlink_t *bwp, - const NR_BWP_DownlinkDedicated_t *bwpd0, int tda, uint8_t layers, NR_UE_sched_ctrl_t *sched_ctrl, @@ -556,19 +538,11 @@ void nr_set_pdsch_semi_static(const NR_SIB1_t *sib1, { bool reset_dmrs = false; - NR_BWP_DownlinkDedicated_t *bwpd = NULL; - if (bwp && bwp->bwp_Dedicated) { - bwpd = bwp->bwp_Dedicated; - } else { - bwpd = (NR_BWP_DownlinkDedicated_t*)bwpd0; - } - - NR_PDSCH_Config_t *pdsch_Config = NULL; - if (bwpd && bwpd->pdsch_Config) pdsch_Config = bwpd->pdsch_Config->choice.setup; + NR_PDSCH_Config_t *pdsch_Config = BWP->pdsch_Config; LOG_D(NR_MAC,"tda %d, ps->time_domain_allocation %d,layers %d, ps->nrOfLayers %d, pdsch_config %p\n",tda,ps->time_domain_allocation,layers,ps->nrOfLayers,pdsch_Config); reset_dmrs = true; ps->time_domain_allocation = tda; - NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = get_pdsch_TimeDomainAllocationList(bwp, scc, sib1); + NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = BWP->tdaList; AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); ps->mapping_type = tdaList->list.array[tda]->mappingType; if (pdsch_Config) { @@ -582,9 +556,7 @@ void nr_set_pdsch_semi_static(const NR_SIB1_t *sib1, const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &ps->startSymbolIndex, &ps->nrOfSymbols); - const long f = ((bwp || bwpd) && - sched_ctrl->search_space && - sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) ? + const long f = sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific ? sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; int dci_format; @@ -615,10 +587,10 @@ void nr_set_pdsch_semi_static(const NR_SIB1_t *sib1, ps->N_PRB_DMRS = ps->numDmrsCdmGrpsNoData * (ps->dmrsConfigType == NFAPI_NR_DMRS_TYPE1 ? 6 : 4); if (reset_dmrs) { - ps->dl_dmrs_symb_pos = fill_dmrs_mask(bwpd ? bwpd->pdsch_Config->choice.setup : NULL, scc ? scc->dmrs_TypeA_Position : 0, ps->nrOfSymbols, ps->startSymbolIndex, ps->mapping_type, ps->frontloaded_symb); + ps->dl_dmrs_symb_pos = fill_dmrs_mask(pdsch_Config, scc ? scc->dmrs_TypeA_Position : 0, ps->nrOfSymbols, ps->startSymbolIndex, ps->mapping_type, ps->frontloaded_symb); ps->N_DMRS_SLOT = get_num_dmrs(ps->dl_dmrs_symb_pos); } - LOG_D(NR_MAC,"bwpd0 %p, bwpd %p : Filling dmrs info, ps->N_PRB_DMRS %d, ps->dl_dmrs_symb_pos %x, ps->N_DMRS_SLOT %d\n",bwpd0,bwpd,ps->N_PRB_DMRS,ps->dl_dmrs_symb_pos,ps->N_DMRS_SLOT); + LOG_D(NR_MAC,"Filling dmrs info, ps->N_PRB_DMRS %d, ps->dl_dmrs_symb_pos %x, ps->N_DMRS_SLOT %d\n",ps->N_PRB_DMRS,ps->dl_dmrs_symb_pos,ps->N_DMRS_SLOT); } void nr_set_pusch_semi_static(const NR_SIB1_t *sib1, @@ -1400,25 +1372,25 @@ void set_r_pucch_parms(int rsetindex, void prepare_dci(const NR_CellGroupConfig_t *CellGroup, + const NR_UE_BWP_t *BWP, dci_pdu_rel15_t *dci_pdu_rel15, nr_dci_format_t format, int bwp_id) { AssertFatal(CellGroup!=NULL,"CellGroup shouldn't be null here\n"); - const NR_BWP_DownlinkDedicated_t *bwpd = NULL; - const NR_PDSCH_Config_t *pdsch_Config = NULL; const NR_PDCCH_Config_t *pdcch_Config = NULL; + const NR_BWP_DownlinkDedicated_t *bwpd = NULL; if (bwp_id>0) { bwpd=CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; } else { bwpd=CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; } - pdsch_Config = (bwpd->pdsch_Config) ? bwpd->pdsch_Config->choice.setup : NULL; pdcch_Config = (bwpd->pdcch_Config) ? bwpd->pdcch_Config->choice.setup : NULL; + const NR_PDSCH_Config_t *pdsch_Config = BWP ? BWP->pdsch_Config : NULL; switch(format) { case NR_UL_DCI_FORMAT_0_1: @@ -1493,6 +1465,7 @@ 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_BWP_t *BWP, nfapi_nr_dl_dci_pdu_t *pdcch_dci_pdu, dci_pdu_rel15_t *dci_pdu_rel15, int dci_format, @@ -1512,7 +1485,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, 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, dci_pdu_rel15, dci_format, bwp_id); + prepare_dci(CellGroup, BWP, dci_pdu_rel15, dci_format, bwp_id); /// Payload generation switch (dci_format) { @@ -2327,6 +2300,8 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, NR_BWP_Uplink_t *ul_bwp = NULL; NR_BWP_DownlinkDedicated_t *bwpd = NULL; NR_BWP_UplinkDedicated_t *ubwpd = NULL; + BWP->n_dl_bwp = 1; + int old_dl_bwp_id = BWP->dl_bwp_id; int target_ss; @@ -2348,6 +2323,8 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, BWP->ul_bwp_id = *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id; const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig->downlinkBWP_ToAddModList; + if(bwpList) + BWP->n_dl_bwp = bwpList->list.count; if (BWP->dl_bwp_id>0) { for (int i=0; ilist.count; i++) { dl_bwp = bwpList->list.array[i]; @@ -2376,13 +2353,24 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, ubwpd = ul_bwp->bwp_Dedicated; else ubwpd = servingCellConfig->uplinkConfig->initialUplinkBWP; + + BWP->pdsch_Config = bwpd->pdsch_Config->choice.setup; } else { BWP->dl_bwp_id = 0; BWP->ul_bwp_id = 0; target_ss = NR_SearchSpace__searchSpaceType_PR_common; + BWP->pdsch_Config = NULL; } + if (old_dl_bwp_id != BWP->dl_bwp_id) + LOG_I(NR_MAC, "Switching to DL-BWP %li\n", BWP->dl_bwp_id); + + if (BWP->dl_bwp_id>0) + BWP->tdaList = dl_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + else + BWP->tdaList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + // setting generic parameters NR_BWP_t dl_genericParameters = (BWP->dl_bwp_id>0 && dl_bwp) ? dl_bwp->bwp_Common->genericParameters: @@ -2508,10 +2496,6 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf const NR_ServingCellConfig_t *servingCellConfig = CellGroup && CellGroup->spCellConfig ? CellGroup->spCellConfig->spCellConfigDedicated : NULL; /* Set default BWPs */ - const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig ? servingCellConfig->downlinkBWP_ToAddModList : NULL; - - sched_ctrl->active_bwp = bwpList && BWP->dl_bwp_id > 0 ? bwpList->list.array[BWP->dl_bwp_id - 1] : NULL; - sched_ctrl->next_dl_bwp_id = -1; sched_ctrl->next_ul_bwp_id = -1; const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig ? servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList : NULL; @@ -2982,14 +2966,8 @@ void nr_mac_update_timers(module_id_t module_id, } // If needed, update the Dedicated BWP - if (spCellConfigDedicated && - spCellConfigDedicated->downlinkBWP_ToAddModList && - spCellConfigDedicated->uplinkConfig && + if (spCellConfigDedicated->uplinkConfig && spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) { - sched_ctrl->active_bwp = spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[*spCellConfigDedicated->firstActiveDownlinkBWP_Id - 1]; - if (*spCellConfigDedicated->firstActiveDownlinkBWP_Id != BWP->dl_bwp_id) { - LOG_I(NR_MAC, "Changing to DL-BWP %li\n", sched_ctrl->active_bwp->bwp_Id); - } sched_ctrl->active_ubwp = spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[*spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id - 1]; if (*spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id != BWP->ul_bwp_id) { LOG_I(NR_MAC, "Changing to UL-BWP %li\n", sched_ctrl->active_ubwp->bwp_Id); @@ -2999,16 +2977,6 @@ void nr_mac_update_timers(module_id_t module_id, configure_UE_BWP(RC.nrmac[module_id], BWP, scc, sched_ctrl, NULL, UE->CellGroup); // Update coreset/searchspace - NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp; - NR_BWP_DownlinkDedicated_t *bwpd = NULL; - if (bwp) { - bwpd = sched_ctrl->active_bwp->bwp_Dedicated; - } else if (cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - (cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)) { - bwpd = cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; - } sched_ctrl->maxL = 2; if (cg && @@ -3024,11 +2992,9 @@ void nr_mac_update_timers(module_id_t module_id, const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); // Update downlink MCS table - if (bwpd && - bwpd->pdsch_Config && - bwpd->pdsch_Config->choice.setup && - bwpd->pdsch_Config->choice.setup->mcs_Table) { - if (*bwpd->pdsch_Config->choice.setup->mcs_Table == 0) { + if (BWP->pdsch_Config && + BWP->pdsch_Config->mcs_Table) { + if (*BWP->pdsch_Config->mcs_Table == 0) { ps->mcsTableIdx = 1; } else { ps->mcsTableIdx = 2; @@ -3038,11 +3004,9 @@ void nr_mac_update_timers(module_id_t module_id, } LOG_D(NR_MAC,"MCS Table Index: %d\n",ps->mcsTableIdx); - nr_set_pdsch_semi_static(sib1, + nr_set_pdsch_semi_static(BWP, scc, cg, - bwp, - bwpd, tda, layers, sched_ctrl, @@ -3091,13 +3055,14 @@ void schedule_nr_bwp_switch(module_id_t module_id, UE_iterator(UE_info->list, UE) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_BWP_t *BWP = &UE->current_BWP; if (sched_ctrl->rrc_processing_timer == 0 && UE->Msg4_ACKed && - ((sched_ctrl->next_dl_bwp_id >= 0 && sched_ctrl->active_bwp && sched_ctrl->active_bwp->bwp_Id != sched_ctrl->next_dl_bwp_id) || - (sched_ctrl->next_ul_bwp_id >= 0 && sched_ctrl->active_ubwp && sched_ctrl->active_ubwp->bwp_Id != sched_ctrl->next_ul_bwp_id))) { + ((sched_ctrl->next_dl_bwp_id >= 0 && BWP->dl_bwp_id != sched_ctrl->next_dl_bwp_id) || + (sched_ctrl->next_ul_bwp_id >= 0 && BWP->ul_bwp_id != sched_ctrl->next_ul_bwp_id))) { LOG_W(NR_MAC,"%4d.%2d UE %04x Schedule BWP switch from dl_bwp_id %ld to %ld and from ul_bwp_id %ld to %ld\n", - frame, slot, UE->rnti, sched_ctrl->active_bwp->bwp_Id, sched_ctrl->next_dl_bwp_id, sched_ctrl->active_ubwp->bwp_Id, sched_ctrl->next_ul_bwp_id); + frame, slot, UE->rnti, BWP->dl_bwp_id, sched_ctrl->next_dl_bwp_id, BWP->ul_bwp_id, sched_ctrl->next_ul_bwp_id); nr_mac_rrc_bwp_switch_req(module_id, frame, slot, UE->rnti, sched_ctrl->next_dl_bwp_id, sched_ctrl->next_ul_bwp_id); } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index b5472542f9..faf8a01c18 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -833,13 +833,13 @@ static void handle_dl_harq(NR_UE_info_t * UE, } int checkTargetSSBInFirst64TCIStates_pdschConfig(int ssb_index_t, NR_UE_info_t * UE) { - NR_CellGroupConfig_t *CellGroup = UE->CellGroup; - int nb_tci_states = CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list.count; - NR_TCI_State_t *tci =NULL; - int i; - for(i=0; ispCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list.array[i]; + const NR_PDSCH_Config_t *pdsch_Config = UE->current_BWP.pdsch_Config; + int nb_tci_states = pdsch_Config ? pdsch_Config->tci_StatesToAddModList->list.count : 0; + NR_TCI_State_t *tci =NULL; + + for(int i=0; itci_StatesToAddModList->list.array[i]; if(tci != NULL) { if(tci->qcl_Type1.referenceSignal.present == NR_QCL_Info__referenceSignal_PR_ssb) { @@ -859,18 +859,17 @@ int checkTargetSSBInFirst64TCIStates_pdschConfig(int ssb_index_t, NR_UE_info_t * } int checkTargetSSBInTCIStates_pdcchConfig(int ssb_index_t, NR_UE_info_t *UE) { - NR_CellGroupConfig_t *CellGroup = UE->CellGroup ; - int nb_tci_states = CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list.count; + NR_TCI_State_t *tci =NULL; NR_TCI_StateId_t *tci_id = NULL; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_ControlResourceSet_t *coreset = sched_ctrl->coreset; - int i; int flag = 0; int tci_stateID = -1; - - for(i=0; ispCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list.array[i]; + const NR_PDSCH_Config_t *pdsch_Config = UE->current_BWP.pdsch_Config; + int nb_tci_states = pdsch_Config ? pdsch_Config->tci_StatesToAddModList->list.count : 0; + for(int i=0; itci_StatesToAddModList->list.array[i]; if(tci != NULL && tci->qcl_Type1.referenceSignal.present == NR_QCL_Info__referenceSignal_PR_ssb) { if(tci->qcl_Type1.referenceSignal.choice.ssb == ssb_index_t) { @@ -932,14 +931,6 @@ void tci_handling(NR_UE_info_t *UE, frame_t frame, slot_t slot) { uint8_t idx = 0; NR_UE_BWP_t *BWP = &UE->current_BWP; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_CellGroupConfig_t *CellGroup = UE->CellGroup; - - //bwp indicator - int n_dl_bwp=0; - if (CellGroup->spCellConfig && - CellGroup->spCellConfig->spCellConfigDedicated && - CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) - n_dl_bwp = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count; uint8_t nr_ssbri_cri = 0; uint8_t nb_of_csi_ssb_report = UE->csi_report_template[cqi_idx].nb_of_csi_ssb_report; @@ -947,6 +938,8 @@ void tci_handling(NR_UE_info_t *UE, frame_t frame, slot_t slot) { uint8_t diff_rsrp_idx = 0; uint8_t i, j; + //bwp indicator + int n_dl_bwp = BWP->n_dl_bwp; const int bwp_id = BWP->dl_bwp_id; if (n_dl_bwp < 4) pdsch_bwp_id = bwp_id; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 5106715b47..3c4ca86cbd 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1806,6 +1806,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) current_BWP); fill_dci_pdu_rel15(scc, cg, + current_BWP, dci_pdu, &uldci_payload, ps->dci_format, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 74e6884802..1eed647565 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -297,6 +297,7 @@ 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_BWP_t *BWP, nfapi_nr_dl_dci_pdu_t *pdcch_dci_pdu, dci_pdu_rel15_t *dci_pdu_rel15, int dci_formats, @@ -307,6 +308,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, uint16_t cset0_bwp_size); void prepare_dci(const NR_CellGroupConfig_t *CellGroup, + const NR_UE_BWP_t *BWP, dci_pdu_rel15_t *dci_pdu_rel15, nr_dci_format_t format, int bwp_id); @@ -319,11 +321,6 @@ void set_r_pucch_parms(int rsetindex, int *nr_of_symbols, int *start_symbol_index); - -NR_PDSCH_TimeDomainResourceAllocationList_t *get_pdsch_TimeDomainAllocationList(const NR_BWP_Downlink_t *active_bwp, - const NR_ServingCellConfigCommon_t *ServingCellConfigCommon, - const NR_SIB1_t *sib1); - /* find coreset within the search space */ NR_ControlResourceSet_t *get_coreset(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, @@ -342,11 +339,9 @@ long get_K2(NR_ServingCellConfigCommon_t *scc, int time_domain_assignment, int mu); -void nr_set_pdsch_semi_static(const NR_SIB1_t *sib1, +void nr_set_pdsch_semi_static(const NR_UE_BWP_t *BWP, const NR_ServingCellConfigCommon_t *scc, const NR_CellGroupConfig_t *secondaryCellGroup, - const NR_BWP_Downlink_t *bwp, - const NR_BWP_DownlinkDedicated_t *bwpd0, int tda, uint8_t layers, NR_UE_sched_ctrl_t *sched_ctrl, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index cf2e6be635..2d42dbe15e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -94,6 +94,7 @@ typedef struct { typedef struct NR_UE_BWP { NR_BWP_Id_t dl_bwp_id; NR_BWP_Id_t ul_bwp_id; + int n_dl_bwp; int dl_scs; int ul_scs; long *dl_cyclicprefix; @@ -102,6 +103,8 @@ typedef struct NR_UE_BWP { uint16_t dl_BWPStart; uint16_t ul_BWPSize; uint16_t ul_BWPStart; + NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList; + NR_PDSCH_Config_t *pdsch_Config; } NR_UE_BWP_t; typedef enum { @@ -576,8 +579,6 @@ typedef struct NR_UE_ul_harq { /*! \brief scheduling control information set through an API */ #define MAX_CSI_REPORTS 48 typedef struct { - /// the currently active BWP in DL - NR_BWP_Downlink_t *active_bwp; /// the currently active BWP in UL NR_BWP_Uplink_t *active_ubwp; From 40049db9c926da89d3cbae3bb48b7e5c213d90d3 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 15 Jun 2022 18:41:36 +0200 Subject: [PATCH 07/16] separate dl and ul bwp structures --- openair1/SIMULATION/NR_PHY/dlsim.c | 12 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 86 ++++----- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 12 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 41 ++-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 18 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 177 ++++++++++-------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c | 12 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 43 +++-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 32 ++-- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 11 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 35 ++-- 11 files changed, 241 insertions(+), 238 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index b5f946b8ab..bd0fe510c7 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -272,7 +272,7 @@ void nr_dlsim_preprocessor(module_id_t module_id, NR_UE_info_t *UE_info = RC.nrmac[module_id]->UE_info.list[0]; AssertFatal(RC.nrmac[module_id]->UE_info.list[1]==NULL, "can have only a single UE\n"); NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl; - NR_UE_BWP_t *BWP = &UE_info->current_BWP; + NR_UE_DL_BWP_t *BWP = &UE_info->current_DL_BWP; NR_ServingCellConfigCommon_t *scc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon; /* manually set free CCE to 0 */ @@ -299,10 +299,10 @@ void nr_dlsim_preprocessor(module_id_t module_id, sched_pdsch->mcs = g_mcsIndex; /* the following might override the table that is mandated by RRC * configuration */ - ps->mcsTableIdx = g_mcsTableIdx; + BWP->mcsTableIdx = g_mcsTableIdx; - sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); - sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); + sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, BWP->mcsTableIdx); + sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, BWP->mcsTableIdx); sched_pdsch->tb_size = nr_compute_tbs(sched_pdsch->Qm, sched_pdsch->R, sched_pdsch->rbSize, @@ -330,7 +330,7 @@ void nr_dlsim_preprocessor(module_id_t module_id, AssertFatal(sched_pdsch->rbStart >= 0, "invalid rbStart %d\n", sched_pdsch->rbStart); AssertFatal(sched_pdsch->rbSize > 0, "invalid rbSize %d\n", sched_pdsch->rbSize); AssertFatal(sched_pdsch->mcs >= 0, "invalid mcs %d\n", sched_pdsch->mcs); - AssertFatal(ps->mcsTableIdx >= 0 && ps->mcsTableIdx <= 2, "invalid mcsTableIdx %d\n", ps->mcsTableIdx); + AssertFatal(BWP->mcsTableIdx >= 0 && BWP->mcsTableIdx <= 2, "invalid mcsTableIdx %d\n", BWP->mcsTableIdx); } typedef struct { @@ -835,7 +835,7 @@ int main(int argc, char **argv) N_RB_DL = gNB->frame_parms.N_RB_DL; NR_UE_info_t *UE_info = RC.nrmac[0]->UE_info.list[0]; - configure_UE_BWP(RC.nrmac[0], &UE_info->current_BWP, scc, &UE_info->UE_sched_ctrl, NULL, UE_info->CellGroup); + configure_UE_BWP(RC.nrmac[0], scc, &UE_info->UE_sched_ctrl, NULL, UE_info); // stub to configure frame_parms // nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 1bbbc6ac85..d29e60b869 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -568,7 +568,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra_rnti = 1 + symbol + (slotP * 14) + (freq_index * 14 * 80) + (ul_carrier_id * 14 * 80 * 8); // Configure RA BWP - configure_UE_BWP(nr_mac, &ra->BWP, scc, NULL, ra, ra->CellGroup); + configure_UE_BWP(nr_mac, scc, NULL, ra, NULL); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1); @@ -606,7 +606,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, slotP, &msg2_frame, &msg2_slot, - ra->BWP.dl_scs, + ra->DL_BWP.scs, scc, frame_type, monitoring_slot_period, @@ -697,19 +697,19 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - NR_UE_BWP_t *ra_BWP = &ra->BWP; + NR_UE_UL_BWP_t *UL_BWP = &ra->UL_BWP; NR_BWP_Uplink_t *ubwp = NULL; NR_BWP_UplinkDedicated_t *ubwpd = NULL; NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; if(ra->CellGroup) { - ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra_BWP->ul_bwp_id-1]; + ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[UL_BWP->bwp_id-1]; ubwpd = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; pusch_TimeDomainAllocationList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; } else pusch_TimeDomainAllocationList = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - int mu = ra_BWP->ul_scs; + int mu = UL_BWP->scs; uint8_t K2 = *pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->k2; const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; @@ -846,17 +846,17 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t ra->Msg3_tda_id, ra->msg3_TPC, 0, // not used in format 0_0 - &ra->BWP); + &ra->UL_BWP); fill_dci_pdu_rel15(scc, ra->CellGroup, - ra_BWP, + &ra->DL_BWP, dci_pdu, &uldci_payload, NR_UL_DCI_FORMAT_0_0, NR_RNTI_TC, pusch_pdu->bwp_size, - ra_BWP->ul_bwp_id, + UL_BWP->bwp_id, coresetid, nr_mac->cset0_bwp_size); @@ -894,9 +894,9 @@ void nr_get_Msg3alloc(module_id_t module_id, uint16_t msg3_nb_rb = 8; // sdu has 6 or 8 bytes frame_type_t frame_type = RC.nrmac[module_id]->common_channels->frame_type; - NR_UE_BWP_t *ra_BWP = &ra->BWP; + NR_UE_UL_BWP_t *UL_BWP = &ra->UL_BWP; - int mu = ra_BWP->ul_scs; + int mu = UL_BWP->scs; int StartSymbolIndex = 0; int NrOfSymbols = 0; int startSymbolAndLength = 0; @@ -969,9 +969,9 @@ void nr_get_Msg3alloc(module_id_t module_id, int bwpSize = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); int bwpStart = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - if (bwpSize != ra_BWP->ul_BWPSize || bwpStart != ra_BWP->ul_BWPStart) { - int act_bwp_start = ra_BWP->ul_BWPStart; - int act_bwp_size = ra_BWP->ul_BWPSize; + if (bwpSize != UL_BWP->BWPSize || bwpStart != UL_BWP->BWPStart) { + int act_bwp_start = UL_BWP->BWPStart; + int act_bwp_size = UL_BWP->BWPSize; if (!((bwpStart >= act_bwp_start) && ((bwpStart+bwpSize) <= (act_bwp_start+act_bwp_size)))) bwpStart = act_bwp_start; } @@ -1080,7 +1080,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t gNB_MAC_INST *mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &mac->common_channels[CC_id]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - NR_UE_BWP_t *ra_BWP = &ra->BWP; + NR_UE_UL_BWP_t *UL_BWP = &ra->UL_BWP; if (ra->state == RA_IDLE) { LOG_W(NR_MAC,"RA is not active for RA %X. skipping msg3 scheduling\n", ra->rnti); @@ -1114,13 +1114,13 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t memset(pusch_pdu, 0, sizeof(nfapi_nr_pusch_pdu_t)); int ibwp_size = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int scs = ra_BWP->ul_scs; + int scs = UL_BWP->scs; int fh = 0; int startSymbolAndLength = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; int mappingtype = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; if (ra->CellGroup) { - NR_BWP_Uplink_t *ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra_BWP->ul_bwp_id - 1]; + NR_BWP_Uplink_t *ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[UL_BWP->bwp_id - 1]; startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; mappingtype = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; @@ -1154,7 +1154,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; - NR_UE_BWP_t *ra_BWP = &ra->BWP; + NR_UE_DL_BWP_t *DL_BWP = &ra->DL_BWP; if ((ra->Msg2_frame == frameP) && (ra->Msg2_slot == slotP)) { @@ -1165,13 +1165,13 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_SearchSpace_t *ss = ra->ra_ss; - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = ra_BWP->tdaList; + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = DL_BWP->tdaList; long BWPStart = 0; long BWPSize = 0; NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = NULL; if(*ss->controlResourceSetId!=0) { - BWPStart = ra_BWP->dl_BWPStart; + BWPStart = DL_BWP->BWPStart; BWPSize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); } else { type0_PDCCH_CSS_config = &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]; @@ -1265,16 +1265,8 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // information to data and is reset every slot. const int pduindex = nr_mac->pdu_index[CC_id]++; - NR_PDSCH_Config_t *pdsch_Config = ra_BWP->pdsch_Config; - uint8_t mcsTableIdx = 0; - if (pdsch_Config && - pdsch_Config->mcs_Table) { - if (*pdsch_Config->mcs_Table == 0) - mcsTableIdx = 1; - else - mcsTableIdx = 2; - } - else mcsTableIdx = 0; + NR_PDSCH_Config_t *pdsch_Config = DL_BWP->pdsch_Config; + uint8_t mcsTableIdx = DL_BWP->mcsTableIdx; int dmrsConfigType=0; if (pdsch_Config && @@ -1288,7 +1280,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->pduIndex = pduindex; pdsch_pdu_rel15->BWPSize = BWPSize; pdsch_pdu_rel15->BWPStart = BWPStart; - pdsch_pdu_rel15->SubcarrierSpacing = ra_BWP->dl_scs; + pdsch_pdu_rel15->SubcarrierSpacing = DL_BWP->scs; pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; @@ -1401,13 +1393,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, - ra_BWP, + DL_BWP, &pdcch_pdu_rel15->dci_pdu[pdcch_pdu_rel15->numDlDci - 1], &dci_payload, NR_DL_DCI_FORMAT_1_0, NR_RNTI_RA, BWPSize, - ra_BWP->dl_bwp_id, + DL_BWP->bwp_id, coresetid, nr_mac->cset0_bwp_size); @@ -1416,7 +1408,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // Program UL processing for Msg3 NR_BWP_Uplink_t *ubwp = ra->CellGroup ? - ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra_BWP->ul_bwp_id-1] : + ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->UL_BWP.bwp_id-1] : NULL; nr_get_Msg3alloc(module_idP, CC_id, scc, ubwp, slotP, frameP, ra, nr_mac->tdd_beam_association); nr_add_msg3(module_idP, CC_id, frameP, slotP, ra, (uint8_t *) &tx_req->TLVs[0].value.direct[0]); @@ -1456,7 +1448,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; - NR_UE_BWP_t *ra_BWP = &ra->BWP; + NR_UE_DL_BWP_t *DL_BWP = &ra->DL_BWP; if (ra->Msg4_frame == frameP && ra->Msg4_slot == slotP ) { @@ -1467,7 +1459,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_SearchSpace_t *ss = ra->ra_ss; NR_ControlResourceSet_t *coreset = ra->coreset; - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = ra_BWP->tdaList; + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = DL_BWP->tdaList; AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg4\n"); @@ -1490,8 +1482,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra long BWPSize = 0; NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = NULL; if(*ss->controlResourceSetId!=0) { - BWPStart = ra_BWP->dl_BWPStart; - BWPSize = ra_BWP->dl_BWPSize; + BWPStart = DL_BWP->BWPStart; + BWPSize = DL_BWP->BWPSize; } else { type0_PDCCH_CSS_config = &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]; BWPStart = type0_PDCCH_CSS_config->cset_start_rb; @@ -1601,7 +1593,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra uint16_t N_DMRS_SLOT = get_num_dmrs(dlDmrsSymbPos); - NR_PDSCH_Config_t *pdsch_Config = ra_BWP->pdsch_Config; + NR_PDSCH_Config_t *pdsch_Config = DL_BWP->pdsch_Config; int dmrsConfigType=0; if (pdsch_Config && pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA && @@ -1627,15 +1619,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra N_PRB_DMRS = nr_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData * 4; } - uint8_t mcsTableIdx = 0; - if (pdsch_Config && - pdsch_Config->mcs_Table) { - if (*pdsch_Config->mcs_Table == 0) - mcsTableIdx = 1; - else - mcsTableIdx = 2; - } - else mcsTableIdx = 0; + uint8_t mcsTableIdx = DL_BWP->mcsTableIdx; int rbStart = 0; int rbSize = 0; @@ -1711,7 +1695,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->pduIndex = pduindex; pdsch_pdu_rel15->BWPSize = BWPSize; pdsch_pdu_rel15->BWPStart = BWPStart; - pdsch_pdu_rel15->SubcarrierSpacing = ra_BWP->dl_scs; + pdsch_pdu_rel15->SubcarrierSpacing = DL_BWP->scs; pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; int R = nr_get_code_rate_dl(mcsIndex,mcsTableIdx); @@ -1806,13 +1790,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, - ra_BWP, + DL_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, - ra_BWP->dl_bwp_id, + DL_BWP->bwp_id, coresetid, nr_mac->cset0_bwp_size); @@ -1908,7 +1892,7 @@ void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_fram uint32_t delay_ms = servingCellConfig && servingCellConfig->downlinkBWP_ToAddModList ? NR_RRC_SETUP_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_SETUP_DELAY_MS; - sched_ctrl->rrc_processing_timer = (delay_ms << ra->BWP.dl_scs); + sched_ctrl->rrc_processing_timer = (delay_ms << ra->DL_BWP.scs); LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %04x with %d ms\n", frame, slot, UE->rnti, delay_ms); } else { LOG_I(NR_MAC, "(ue rnti 0x%04x) RA Procedure failed at Msg4!\n", ra->rnti); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 743358f47d..a06c3f06ed 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -352,7 +352,6 @@ uint32_t schedule_control_sib1(module_id_t module_id, } gNB_mac->sched_ctrlCommon->pdsch_semi_static.time_domain_allocation = time_domain_allocation; - gNB_mac->sched_ctrlCommon->pdsch_semi_static.mcsTableIdx = 0; gNB_mac->sched_ctrlCommon->sched_pdsch.mcs = 0; // starting from mcs 0 gNB_mac->sched_ctrlCommon->num_total_bytes = num_total_bytes; @@ -389,6 +388,7 @@ uint32_t schedule_control_sib1(module_id_t module_id, uint8_t N_PRB_DMRS = gNB_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData * 6; uint16_t dmrs_length = get_num_dmrs(dlDmrsSymbPos); LOG_D(MAC,"dlDmrsSymbPos %x\n",dlDmrsSymbPos); + int mcsTableIdx = 0; int rbSize = 0; uint32_t TBS = 0; do { @@ -400,8 +400,8 @@ uint32_t schedule_control_sib1(module_id_t module_id, else break; } - TBS = nr_compute_tbs(nr_get_Qm_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, gNB_mac->sched_ctrlCommon->pdsch_semi_static.mcsTableIdx), - nr_get_code_rate_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, gNB_mac->sched_ctrlCommon->pdsch_semi_static.mcsTableIdx), + TBS = nr_compute_tbs(nr_get_Qm_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, mcsTableIdx), + nr_get_code_rate_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, mcsTableIdx), rbSize, nrOfSymbols, N_PRB_DMRS * dmrs_length,0, 0,1) >> 3; } while (TBS < gNB_mac->sched_ctrlCommon->num_total_bytes); @@ -443,7 +443,7 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, gNB_MAC_INST *gNB_mac = RC.nrmac[Mod_idP]; NR_COMMON_channels_t *cc = gNB_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - + int mcsTableIdx = 0; nfapi_nr_dl_tti_request_pdu_t *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; @@ -494,9 +494,9 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, pdsch_pdu_rel15->rbSize = gNB_mac->sched_ctrlCommon->sched_pdsch.rbSize; pdsch_pdu_rel15->VRBtoPRBMapping = 0; pdsch_pdu_rel15->qamModOrder[0] = nr_get_Qm_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, - gNB_mac->sched_ctrlCommon->pdsch_semi_static.mcsTableIdx); + mcsTableIdx); pdsch_pdu_rel15->TBSize[0] = TBS; - pdsch_pdu_rel15->mcsTable[0] = gNB_mac->sched_ctrlCommon->pdsch_semi_static.mcsTableIdx; + pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex; pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols; pdsch_pdu_rel15->dlDmrsSymbPos = dlDmrsSymbPos; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 829e288eae..70f4a98a99 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -376,7 +376,7 @@ bool allocate_dl_retransmission(module_id_t module_id, gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; const NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels->ServingCellConfigCommon; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_BWP_t *BWP = &UE->current_BWP; + NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; NR_sched_pdsch_t *retInfo = &sched_ctrl->harq_processes[current_harq_pid].sched_pdsch; NR_CellGroupConfig_t *cg = UE->CellGroup; @@ -388,7 +388,7 @@ bool allocate_dl_retransmission(module_id_t module_id, cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; const int coresetid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : UE->current_BWP.dl_BWPSize; + const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : BWP->BWPSize; int rbStart = 0; // start wrt BWPstart NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; @@ -567,6 +567,7 @@ void pf_dl(module_id_t module_id, continue; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; @@ -606,12 +607,12 @@ void pf_dl(module_id_t module_id, /* Calculate coeff */ const NR_bler_options_t *bo = &mac->dl_bler; - const int max_mcs_table = ps->mcsTableIdx == 1 ? 27 : 28; + const int max_mcs_table = BWP->mcsTableIdx == 1 ? 27 : 28; const int max_mcs = min(sched_ctrl->dl_max_mcs, max_mcs_table); sched_pdsch->mcs = get_mcs_from_bler(bo, stats, &sched_ctrl->dl_bler_stats, max_mcs, frame); UE->layers = set_dl_nrOfLayers(sched_ctrl); - const uint8_t Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); - const uint16_t R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); + const uint8_t Qm = nr_get_Qm_dl(sched_pdsch->mcs, BWP->mcsTableIdx); + const uint16_t R = nr_get_code_rate_dl(sched_pdsch->mcs, BWP->mcsTableIdx); uint32_t tbs = nr_compute_tbs(Qm, R, 1, /* rbSize */ @@ -650,12 +651,12 @@ void pf_dl(module_id_t module_id, NR_UE_sched_ctrl_t *sched_ctrl = &iterator->UE->UE_sched_ctrl; const uint16_t rnti = iterator->UE->rnti; - NR_UE_BWP_t *BWP = &iterator->UE->current_BWP; + NR_UE_DL_BWP_t *BWP = &iterator->UE->current_DL_BWP; const int coresetid = sched_ctrl->coreset->controlResourceSetId; const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : - BWP->dl_BWPSize; + BWP->BWPSize; int rbStart = 0; // start wrt BWPstart if (sched_ctrl->available_dl_harq.head < 0) { @@ -744,8 +745,8 @@ void pf_dl(module_id_t module_id, while (rbStart + max_rbSize < bwpSize && (rballoc_mask[rbStart + max_rbSize] & slbitmap) == slbitmap) max_rbSize++; - sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); - sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); + sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, BWP->mcsTableIdx); + sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, BWP->mcsTableIdx); sched_pdsch->pucch_allocation = alloc; uint32_t TBS = 0; uint16_t rbSize; @@ -791,7 +792,7 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t /* This is temporary and it assumes all UEs have the same BWP and TDA*/ NR_UE_info_t *UE=UE_info->list[0]; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_BWP_t *BWP = &UE->current_BWP; + NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); int startSymbolIndex, nrOfSymbols; const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = BWP->tdaList; @@ -801,8 +802,8 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t const int coresetid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : BWP->dl_BWPSize; - const uint16_t BWPStart = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_start : BWP->dl_BWPStart; + const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : BWP->BWPSize; + const uint16_t BWPStart = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_start : BWP->BWPStart; const uint16_t slbitmap = SL_to_bitmap(startSymbolIndex, nrOfSymbols); uint16_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; @@ -879,7 +880,7 @@ void nr_schedule_ue_spec(module_id_t module_id, UE_iterator(UE_info->list, UE) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_BWP_t *current_BWP = &UE->current_BWP; + NR_UE_DL_BWP_t *current_BWP = &UE->current_DL_BWP; if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; @@ -963,7 +964,7 @@ void nr_schedule_ue_spec(module_id_t module_id, NR_SearchSpace_t *ss = sched_ctrl->search_space; - const int bwp_id = current_BWP->dl_bwp_id; + const int bwp_id = current_BWP->bwp_id; const int coresetid = sched_ctrl->coreset->controlResourceSetId; /* look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not exist, create it */ @@ -1001,19 +1002,19 @@ void nr_schedule_ue_spec(module_id_t module_id, pdsch_pdu->BWPSize = gNB_mac->cset0_bwp_size; pdsch_pdu->BWPStart = gNB_mac->cset0_bwp_start; } else { - pdsch_pdu->BWPSize = current_BWP->dl_BWPSize; - pdsch_pdu->BWPStart = current_BWP->dl_BWPStart; + pdsch_pdu->BWPSize = current_BWP->BWPSize; + pdsch_pdu->BWPStart = current_BWP->BWPStart; } - pdsch_pdu->SubcarrierSpacing = current_BWP->dl_scs; - pdsch_pdu->CyclicPrefix = current_BWP->dl_cyclicprefix ? *current_BWP->dl_cyclicprefix : 0; + pdsch_pdu->SubcarrierSpacing = current_BWP->scs; + pdsch_pdu->CyclicPrefix = current_BWP->cyclicprefix ? *current_BWP->cyclicprefix : 0; // Codeword information pdsch_pdu->NrOfCodewords = 1; //number of information bits per 1024 coded bits expressed in 0.1 bit units pdsch_pdu->targetCodeRate[0] = R; pdsch_pdu->qamModOrder[0] = Qm; pdsch_pdu->mcsIndex[0] = sched_pdsch->mcs; - pdsch_pdu->mcsTable[0] = ps->mcsTableIdx; + pdsch_pdu->mcsTable[0] = current_BWP->mcsTableIdx; AssertFatal(harq!=NULL,"harq is null\n"); AssertFatal(harq->round<4,"%d",harq->round); pdsch_pdu->rvIndex[0] = nr_rv_round_map[harq->round]; @@ -1056,7 +1057,7 @@ void nr_schedule_ue_spec(module_id_t module_id, // Maximum number of PRBs across all configured DL BWPs int scc_bwpsize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); int bw_tbslbrm = get_bw_tbslbrm(scc_bwpsize, cg); - pdsch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(ps->mcsTableIdx, + pdsch_pdu->maintenance_parms_v3.tbSizeLbrmBytes = nr_compute_tbslbrm(current_BWP->mcsTableIdx, bw_tbslbrm, nl_tbslbrm); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 94b3f99fa0..66b7f2e720 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -195,7 +195,7 @@ void nr_preprocessor_phytest(module_id_t module_id, NR_UE_info_t *UE = RC.nrmac[module_id]->UE_info.list[0]; NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_BWP_t *BWP = &UE->current_BWP; + NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; const int CC_id = 0; const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); @@ -205,8 +205,8 @@ void nr_preprocessor_phytest(module_id_t module_id, nr_set_pdsch_semi_static(BWP, scc, UE->CellGroup, tda, target_dl_Nl,sched_ctrl , ps); /* find largest unallocated chunk */ - const int bwpSize = BWP->dl_BWPSize; - const int BWPStart = BWP->dl_BWPStart; + const int bwpSize = BWP->BWPSize; + const int BWPStart = BWP->BWPStart; int rbStart = 0; int rbSize = 0; @@ -311,8 +311,8 @@ void nr_preprocessor_phytest(module_id_t module_id, sched_pdsch->rbSize = rbSize; sched_pdsch->mcs = target_dl_mcs; - sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); - sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); + sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, BWP->mcsTableIdx); + sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, BWP->mcsTableIdx); sched_pdsch->tb_size = nr_compute_tbs(sched_pdsch->Qm, sched_pdsch->R, sched_pdsch->rbSize, @@ -352,8 +352,8 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ const int CC_id = 0; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_BWP_t *BWP = &UE->current_BWP; - const int mu = BWP->ul_scs; + NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; + const int mu = BWP->scs; const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; @@ -400,8 +400,8 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ uint16_t rbStart = 0; uint16_t rbSize; - const int bw = BWP->ul_BWPSize; - const int BWPStart = BWP->ul_BWPStart; + const int bw = BWP->BWPSize; + const int BWPStart = BWP->BWPStart; if (target_ul_bw>bw) rbSize = bw; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 2fd3c0620a..8fdf0fa9a1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -528,7 +528,7 @@ bool nr_find_nb_rb(uint16_t Qm, return *tbs >= bytes && *nb_rb <= nb_rb_max; } -void nr_set_pdsch_semi_static(const NR_UE_BWP_t *BWP, +void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *BWP, const NR_ServingCellConfigCommon_t *scc, const NR_CellGroupConfig_t *secondaryCellGroup, int tda, @@ -951,12 +951,12 @@ void config_uldci(const NR_SIB1_t *sib1, int time_domain_assignment, uint8_t tpc, int n_ubwp, - NR_UE_BWP_t *BWP) { + NR_UE_UL_BWP_t *UBWP) { - int bwp_id = BWP->ul_bwp_id; + int bwp_id = UBWP->bwp_id; dci_pdu_rel15->frequency_domain_assignment.val = - PRBalloc_to_locationandbandwidth0(pusch_pdu->rb_size, pusch_pdu->rb_start, BWP->ul_BWPSize); + PRBalloc_to_locationandbandwidth0(pusch_pdu->rb_size, pusch_pdu->rb_start, UBWP->BWPSize); dci_pdu_rel15->time_domain_assignment.val = time_domain_assignment; dci_pdu_rel15->frequency_hopping_flag.val = pusch_pdu->frequency_hopping; dci_pdu_rel15->mcs = pusch_pdu->mcs_index; @@ -1163,12 +1163,12 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, else pucch_pdu->hopping_id = *scc->physCellId; - NR_UE_BWP_t *BWP = &UE->current_BWP; + NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; - pucch_pdu->bwp_size = BWP->ul_BWPSize; - pucch_pdu->bwp_start = BWP->ul_BWPStart; - pucch_pdu->subcarrier_spacing = BWP->ul_scs; - pucch_pdu->cyclic_prefix = (BWP->ul_cyclicprefix==NULL) ? 0 : *BWP->ul_cyclicprefix; + pucch_pdu->bwp_size = BWP->BWPSize; + pucch_pdu->bwp_start = BWP->BWPStart; + pucch_pdu->subcarrier_spacing = BWP->scs; + pucch_pdu->cyclic_prefix = (BWP->cyclicprefix==NULL) ? 0 : *BWP->cyclicprefix; if (r_pucch<0 || bwp ){ LOG_D(NR_MAC,"pucch_acknak: Filling dedicated configuration for PUCCH\n"); // we have either a dedicated BWP or Dedicated PUCCH configuration on InitialBWP @@ -1372,7 +1372,7 @@ void set_r_pucch_parms(int rsetindex, void prepare_dci(const NR_CellGroupConfig_t *CellGroup, - const NR_UE_BWP_t *BWP, + const NR_UE_DL_BWP_t *BWP, dci_pdu_rel15_t *dci_pdu_rel15, nr_dci_format_t format, int bwp_id) { @@ -1465,7 +1465,7 @@ 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_BWP_t *BWP, + const NR_UE_DL_BWP_t *BWP, nfapi_nr_dl_dci_pdu_t *pdcch_dci_pdu, dci_pdu_rel15_t *dci_pdu_rel15, int dci_format, @@ -2290,18 +2290,31 @@ void delete_nr_ue_data(NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr) } void configure_UE_BWP(gNB_MAC_INST *nr_mac, - NR_UE_BWP_t *BWP, NR_ServingCellConfigCommon_t *scc, NR_UE_sched_ctrl_t *sched_ctrl, NR_RA_t *ra, - NR_CellGroupConfig_t *CellGroup) { + NR_UE_info_t *UE) { + NR_CellGroupConfig_t *CellGroup; + NR_UE_DL_BWP_t *DL_BWP; + NR_UE_UL_BWP_t *UL_BWP; + + if (ra) { + DL_BWP = &ra->DL_BWP; + UL_BWP = &ra->UL_BWP; + CellGroup = ra->CellGroup; + } + else { + DL_BWP = &UE->current_DL_BWP; + UL_BWP = &UE->current_UL_BWP; + CellGroup = UE->CellGroup; + } NR_BWP_Downlink_t *dl_bwp = NULL; NR_BWP_Uplink_t *ul_bwp = NULL; NR_BWP_DownlinkDedicated_t *bwpd = NULL; NR_BWP_UplinkDedicated_t *ubwpd = NULL; - BWP->n_dl_bwp = 1; - int old_dl_bwp_id = BWP->dl_bwp_id; + DL_BWP->n_dl_bwp = 1; + int old_dl_bwp_id = DL_BWP->bwp_id; int target_ss; @@ -2315,33 +2328,31 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, // (re)configuring BWP // TODO BWP switching not via RRC reconfiguration // via RRC if firstActiveXlinkBWP_Id is NULL, MAC stays on the same BWP as before - if (servingCellConfig->firstActiveDownlinkBWP_Id) { - BWP->dl_bwp_id = *servingCellConfig->firstActiveDownlinkBWP_Id; - BWP->ul_bwp_id = *servingCellConfig->firstActiveDownlinkBWP_Id; - } + if (servingCellConfig->firstActiveDownlinkBWP_Id) + DL_BWP->bwp_id = *servingCellConfig->firstActiveDownlinkBWP_Id; if (servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id) - BWP->ul_bwp_id = *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id; + UL_BWP->bwp_id = *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id; const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig->downlinkBWP_ToAddModList; if(bwpList) - BWP->n_dl_bwp = bwpList->list.count; - if (BWP->dl_bwp_id>0) { + DL_BWP->n_dl_bwp = bwpList->list.count; + if (DL_BWP->bwp_id>0) { for (int i=0; ilist.count; i++) { dl_bwp = bwpList->list.array[i]; - if(dl_bwp->bwp_Id == BWP->dl_bwp_id) + if(dl_bwp->bwp_Id == DL_BWP->bwp_id) break; } - AssertFatal(dl_bwp!=NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n",BWP->dl_bwp_id); + AssertFatal(dl_bwp!=NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n",DL_BWP->bwp_id); } const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList; - if (BWP->ul_bwp_id>0) { + if (UL_BWP->bwp_id>0) { for (int i=0; ilist.count; i++) { ul_bwp = ubwpList->list.array[i]; - if(ul_bwp->bwp_Id == BWP->ul_bwp_id) + if(ul_bwp->bwp_Id == UL_BWP->bwp_id) break; } - AssertFatal(ul_bwp!=NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n",BWP->ul_bwp_id); + AssertFatal(ul_bwp!=NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n",UL_BWP->bwp_id); } // selection of dedicated BWPs @@ -2354,43 +2365,54 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, else ubwpd = servingCellConfig->uplinkConfig->initialUplinkBWP; - BWP->pdsch_Config = bwpd->pdsch_Config->choice.setup; + DL_BWP->pdsch_Config = bwpd->pdsch_Config->choice.setup; } else { - BWP->dl_bwp_id = 0; - BWP->ul_bwp_id = 0; + DL_BWP->bwp_id = 0; + DL_BWP->bwp_id = 0; target_ss = NR_SearchSpace__searchSpaceType_PR_common; - BWP->pdsch_Config = NULL; + DL_BWP->pdsch_Config = NULL; } - if (old_dl_bwp_id != BWP->dl_bwp_id) - LOG_I(NR_MAC, "Switching to DL-BWP %li\n", BWP->dl_bwp_id); + if (old_dl_bwp_id != DL_BWP->bwp_id) + LOG_I(NR_MAC, "Switching to DL-BWP %li\n", DL_BWP->bwp_id); - if (BWP->dl_bwp_id>0) - BWP->tdaList = dl_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + if (DL_BWP->bwp_id>0) + DL_BWP->tdaList = dl_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; else - BWP->tdaList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + DL_BWP->tdaList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; // setting generic parameters - NR_BWP_t dl_genericParameters = (BWP->dl_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; - BWP->dl_scs = dl_genericParameters.subcarrierSpacing; - BWP->dl_cyclicprefix = dl_genericParameters.cyclicPrefix; - BWP->dl_BWPSize = NRRIV2BW(dl_genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - BWP->dl_BWPStart = NRRIV2PRBOFFSET(dl_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); - NR_BWP_t ul_genericParameters = (BWP->ul_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; - BWP->ul_scs = ul_genericParameters.subcarrierSpacing; - BWP->ul_cyclicprefix = ul_genericParameters.cyclicPrefix; - BWP->ul_BWPSize = NRRIV2BW(ul_genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - BWP->ul_BWPStart = NRRIV2PRBOFFSET(ul_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); - if(sched_ctrl) { + // Set downlink MCS table + if (DL_BWP->pdsch_Config && + DL_BWP->pdsch_Config->mcs_Table) { + if (*DL_BWP->pdsch_Config->mcs_Table == 0) + DL_BWP->mcsTableIdx = 1; + else + DL_BWP->mcsTableIdx = 2; + } else + DL_BWP->mcsTableIdx = 0; + LOG_D(NR_MAC,"MCS Table Index: %d\n",DL_BWP->mcsTableIdx); + + if(UE) { // setting PDCCH related structures for sched_ctrl sched_ctrl->search_space = get_searchspace(scc, bwpd, @@ -2486,9 +2508,11 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf sched_ctrl->sched_srs.srs_scheduled = false; // initialize UE BWP information - NR_UE_BWP_t *BWP = &UE->current_BWP; - memset(BWP, 0, sizeof(*BWP)); - configure_UE_BWP(nr_mac, BWP, scc, sched_ctrl, NULL, CellGroup); + NR_UE_DL_BWP_t *DL_BWP = &UE->current_DL_BWP; + memset(DL_BWP, 0, sizeof(*DL_BWP)); + NR_UE_UL_BWP_t *UL_BWP = &UE->current_UL_BWP; + memset(UL_BWP, 0, sizeof(*UL_BWP)); + configure_UE_BWP(nr_mac, scc, sched_ctrl, NULL, UE); /* set illegal time domain allocation to force recomputation of all fields */ sched_ctrl->pdsch_semi_static.time_domain_allocation = -1; @@ -2504,7 +2528,7 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf "uplinkBWP_ToAddModList has %d BWP!\n", ubwpList->list.count); - sched_ctrl->active_ubwp = ubwpList && BWP->ul_bwp_id > 0 ? ubwpList->list.array[BWP->ul_bwp_id - 1] : NULL; + sched_ctrl->active_ubwp = ubwpList && UL_BWP->bwp_id > 0 ? ubwpList->list.array[UL_BWP->bwp_id - 1] : NULL; /* get Number of HARQ processes for this UE */ if (servingCellConfig) @@ -2630,8 +2654,8 @@ void get_pdsch_to_harq_feedback(NR_UE_info_t *UE, NR_CellGroupConfig_t *CellGroup = UE->CellGroup; NR_BWP_DownlinkDedicated_t *bwpd=NULL; NR_BWP_UplinkDedicated_t *ubwpd=NULL; - int dl_bwp_id = UE->current_BWP.dl_bwp_id; - int ul_bwp_id = UE->current_BWP.ul_bwp_id; + int dl_bwp_id = UE->current_DL_BWP.bwp_id; + int ul_bwp_id = UE->current_UL_BWP.bwp_id; if (ss_type == NR_SearchSpace__searchSpaceType_PR_ue_Specific) { AssertFatal(CellGroup!=NULL,"Cellgroup is not defined for UE %04x\n",UE->rnti); @@ -2728,7 +2752,7 @@ void nr_csirs_scheduling(int Mod_idP, continue; } NR_CellGroupConfig_t *CellGroup = UE->CellGroup; - NR_UE_BWP_t *BWP = &UE->current_BWP; + NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; if (!CellGroup || !CellGroup->spCellConfig || !CellGroup->spCellConfig->spCellConfigDedicated || !CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig) continue; @@ -2759,20 +2783,20 @@ void nr_csirs_scheduling(int Mod_idP, nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csirs_pdu_rel15 = &dl_tti_csirs_pdu->csi_rs_pdu.csi_rs_pdu_rel15; - csirs_pdu_rel15->subcarrier_spacing = BWP->dl_scs; - if (BWP->dl_cyclicprefix) - csirs_pdu_rel15->cyclic_prefix = *BWP->dl_cyclicprefix; + csirs_pdu_rel15->subcarrier_spacing = BWP->scs; + if (BWP->cyclicprefix) + csirs_pdu_rel15->cyclic_prefix = *BWP->cyclicprefix; else csirs_pdu_rel15->cyclic_prefix = 0; // According to last paragraph of TS 38.214 5.2.2.3.1 - if (resourceMapping.freqBand.startingRB < BWP->dl_BWPStart) { - csirs_pdu_rel15->start_rb = BWP->dl_BWPStart; + if (resourceMapping.freqBand.startingRB < BWP->BWPStart) { + csirs_pdu_rel15->start_rb = BWP->BWPStart; } else { csirs_pdu_rel15->start_rb = resourceMapping.freqBand.startingRB; } - if (resourceMapping.freqBand.nrofRBs > (BWP->dl_BWPStart + BWP->dl_BWPSize - csirs_pdu_rel15->start_rb)) { - csirs_pdu_rel15->nr_of_rbs = BWP->dl_BWPStart + BWP->dl_BWPSize - csirs_pdu_rel15->start_rb; + if (resourceMapping.freqBand.nrofRBs > (BWP->BWPStart + BWP->BWPSize - csirs_pdu_rel15->start_rb)) { + csirs_pdu_rel15->nr_of_rbs = BWP->BWPStart + BWP->BWPSize - csirs_pdu_rel15->start_rb; } else { csirs_pdu_rel15->nr_of_rbs = resourceMapping.freqBand.nrofRBs; } @@ -2956,8 +2980,7 @@ void nr_mac_update_timers(module_id_t module_id, LOG_I(NR_MAC,"Modified rnti %04x with CellGroup\n", UE->rnti); process_CellGroup(cg,&UE->UE_sched_ctrl); NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - // re-configure BWP information - NR_UE_BWP_t *BWP = &UE->current_BWP; + const NR_PDSCH_ServingCellConfig_t *pdsch = spCellConfigDedicated ? spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup : NULL; if (get_softmodem_params()->sa) { @@ -2969,12 +2992,12 @@ void nr_mac_update_timers(module_id_t module_id, if (spCellConfigDedicated->uplinkConfig && spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) { sched_ctrl->active_ubwp = spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[*spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id - 1]; - if (*spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id != BWP->ul_bwp_id) { + if (*spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id != UE->current_UL_BWP.bwp_id) { LOG_I(NR_MAC, "Changing to UL-BWP %li\n", sched_ctrl->active_ubwp->bwp_Id); } } - configure_UE_BWP(RC.nrmac[module_id], BWP, scc, sched_ctrl, NULL, UE->CellGroup); + configure_UE_BWP(RC.nrmac[module_id], scc, sched_ctrl, NULL, UE); // Update coreset/searchspace @@ -2991,20 +3014,7 @@ void nr_mac_update_timers(module_id_t module_id, const uint8_t layers = set_dl_nrOfLayers(sched_ctrl); const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); - // Update downlink MCS table - if (BWP->pdsch_Config && - BWP->pdsch_Config->mcs_Table) { - if (*BWP->pdsch_Config->mcs_Table == 0) { - ps->mcsTableIdx = 1; - } else { - ps->mcsTableIdx = 2; - } - } else { - ps->mcsTableIdx = 0; - } - LOG_D(NR_MAC,"MCS Table Index: %d\n",ps->mcsTableIdx); - - nr_set_pdsch_semi_static(BWP, + nr_set_pdsch_semi_static(&UE->current_DL_BWP, scc, cg, tda, @@ -3055,14 +3065,15 @@ void schedule_nr_bwp_switch(module_id_t module_id, UE_iterator(UE_info->list, UE) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_BWP_t *BWP = &UE->current_BWP; + NR_UE_DL_BWP_t *DLBWP = &UE->current_DL_BWP; + NR_UE_UL_BWP_t *ULBWP = &UE->current_UL_BWP; if (sched_ctrl->rrc_processing_timer == 0 && UE->Msg4_ACKed && - ((sched_ctrl->next_dl_bwp_id >= 0 && BWP->dl_bwp_id != sched_ctrl->next_dl_bwp_id) || - (sched_ctrl->next_ul_bwp_id >= 0 && BWP->ul_bwp_id != sched_ctrl->next_ul_bwp_id))) { + ((sched_ctrl->next_dl_bwp_id >= 0 && DLBWP->bwp_id != sched_ctrl->next_dl_bwp_id) || + (sched_ctrl->next_ul_bwp_id >= 0 && ULBWP->bwp_id != sched_ctrl->next_ul_bwp_id))) { LOG_W(NR_MAC,"%4d.%2d UE %04x Schedule BWP switch from dl_bwp_id %ld to %ld and from ul_bwp_id %ld to %ld\n", - frame, slot, UE->rnti, BWP->dl_bwp_id, sched_ctrl->next_dl_bwp_id, BWP->ul_bwp_id, sched_ctrl->next_ul_bwp_id); + frame, slot, UE->rnti, DLBWP->bwp_id, sched_ctrl->next_dl_bwp_id, ULBWP->bwp_id, sched_ctrl->next_ul_bwp_id); nr_mac_rrc_bwp_switch_req(module_id, frame, slot, UE->rnti, sched_ctrl->next_dl_bwp_id, sched_ctrl->next_ul_bwp_id); } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c index 4397686c64..15d06886f5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c @@ -36,13 +36,13 @@ extern RAN_CONTEXT_t RC; void nr_configure_srs(nfapi_nr_srs_pdu_t *srs_pdu, int module_id, int CC_id,NR_UE_info_t* UE, NR_SRS_Resource_t *srs_resource) { - NR_UE_BWP_t *current_BWP = &UE->current_BWP; + NR_UE_UL_BWP_t *current_BWP = &UE->current_UL_BWP; srs_pdu->rnti = UE->rnti; srs_pdu->handle = 0; - srs_pdu->bwp_size = current_BWP->ul_BWPSize; - srs_pdu->bwp_start = current_BWP->ul_BWPStart; - srs_pdu->subcarrier_spacing = current_BWP->ul_scs; + srs_pdu->bwp_size = current_BWP->BWPSize; + srs_pdu->bwp_start = current_BWP->BWPStart; + srs_pdu->subcarrier_spacing = current_BWP->scs; srs_pdu->cyclic_prefix = 0; srs_pdu->num_ant_ports = srs_resource->nrofSRS_Ports; srs_pdu->num_symbols = srs_resource->resourceMapping.nrofSymbols; @@ -110,7 +110,7 @@ void nr_schedule_srs(int module_id, frame_t frame) { const int CC_id = 0; NR_CellGroupConfig_t *cg = UE->CellGroup; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_BWP_t *current_BWP = &UE->current_BWP; + NR_UE_UL_BWP_t *current_BWP = &UE->current_UL_BWP; sched_ctrl->sched_srs.frame = -1; sched_ctrl->sched_srs.slot = -1; @@ -160,7 +160,7 @@ void nr_schedule_srs(int module_id, frame_t frame) { 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[current_BWP->ul_scs]; + int n_slots_frame = nr_slots_per_frame[current_BWP->scs]; // Check if UE will transmit the SRS in this frame if ( ((frame - offset/n_slots_frame)*n_slots_frame)%period == 0) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index faf8a01c18..559b3cb988 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -698,8 +698,8 @@ void nr_csi_meas_reporting(int Mod_idP, UE_iterator(RC.nrmac[Mod_idP]->UE_info.list, UE ) { const NR_CellGroupConfig_t *CellGroup = UE->CellGroup; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_BWP_t *BWP = &UE->current_BWP; - const int n_slots_frame = nr_slots_per_frame[BWP->ul_scs]; + NR_UE_UL_BWP_t *UL_BWP = &UE->current_UL_BWP; + const int n_slots_frame = nr_slots_per_frame[UL_BWP->scs]; if ((sched_ctrl->rrc_processing_timer > 0) || (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0)) { continue; } @@ -758,7 +758,7 @@ void nr_csi_meas_reporting(int Mod_idP, curr_pucch->resource_indicator = res_index; curr_pucch->csi_bits += nr_get_csi_bitlen(UE,csi_report_id); - int bwp_start = BWP->ul_BWPStart; + int bwp_start = UL_BWP->BWPStart; // going through the list of PUCCH resources to find the one indexed by resource_id uint16_t *vrb_map_UL = &RC.nrmac[Mod_idP]->common_channels[0].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; @@ -834,7 +834,7 @@ static void handle_dl_harq(NR_UE_info_t * UE, int checkTargetSSBInFirst64TCIStates_pdschConfig(int ssb_index_t, NR_UE_info_t * UE) { - const NR_PDSCH_Config_t *pdsch_Config = UE->current_BWP.pdsch_Config; + const NR_PDSCH_Config_t *pdsch_Config = UE->current_DL_BWP.pdsch_Config; int nb_tci_states = pdsch_Config ? pdsch_Config->tci_StatesToAddModList->list.count : 0; NR_TCI_State_t *tci =NULL; @@ -866,7 +866,7 @@ int checkTargetSSBInTCIStates_pdcchConfig(int ssb_index_t, NR_UE_info_t *UE) { NR_ControlResourceSet_t *coreset = sched_ctrl->coreset; int flag = 0; int tci_stateID = -1; - const NR_PDSCH_Config_t *pdsch_Config = UE->current_BWP.pdsch_Config; + const NR_PDSCH_Config_t *pdsch_Config = UE->current_DL_BWP.pdsch_Config; int nb_tci_states = pdsch_Config ? pdsch_Config->tci_StatesToAddModList->list.count : 0; for(int i=0; itci_StatesToAddModList->list.array[i]; @@ -929,7 +929,7 @@ void tci_handling(NR_UE_info_t *UE, frame_t frame, slot_t slot) { int ssb_index[MAX_NUM_SSB] = {0}; int ssb_rsrp[MAX_NUM_SSB] = {0}; uint8_t idx = 0; - NR_UE_BWP_t *BWP = &UE->current_BWP; + NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; uint8_t nr_ssbri_cri = 0; @@ -940,7 +940,7 @@ void tci_handling(NR_UE_info_t *UE, frame_t frame, slot_t slot) { //bwp indicator int n_dl_bwp = BWP->n_dl_bwp; - const int bwp_id = BWP->dl_bwp_id; + const int bwp_id = BWP->bwp_id; if (n_dl_bwp < 4) pdsch_bwp_id = bwp_id; else @@ -1203,9 +1203,12 @@ void evaluate_cqi_report(uint8_t *payload, nr_csi_report_t *csi_report, int cumul_bits, uint8_t ri, - NR_UE_sched_ctrl_t *sched_ctrl, + NR_UE_info_t *UE, long *cqi_Table){ + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; + //TODO sub-band CQI report not yet implemented int cqi_bitlen = csi_report->csi_meas_bitlen.cqi_bitlen[ri]; @@ -1228,7 +1231,7 @@ void evaluate_cqi_report(uint8_t *payload, // TODO for wideband case and multiple TB const int cqi_idx = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb; - const int mcs_table = sched_ctrl->pdsch_semi_static.mcsTableIdx; + const int mcs_table = BWP->mcsTableIdx; const int cqi_table = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.cqi_table; sched_ctrl->dl_max_mcs = get_mcs_from_cqi(mcs_table, cqi_table, cqi_idx); } @@ -1307,8 +1310,8 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, uint16_t bitlen = uci_pdu->csi_part1.csi_part1_bit_len; NR_CSI_ReportConfig__reportQuantity_PR reportQuantity_type = NR_CSI_ReportConfig__reportQuantity_PR_NOTHING; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_BWP_t *BWP = &UE->current_BWP; - const int n_slots_frame = nr_slots_per_frame[BWP->ul_scs]; + NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; + const int n_slots_frame = nr_slots_per_frame[BWP->scs]; int cumul_bits = 0; int r_index = -1; for (int csi_report_id = 0; csi_report_id < csi_MeasConfig->csi_ReportConfigToAddModList->list.count; csi_report_id++ ) { @@ -1343,7 +1346,7 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, cumul_bits += ri_bitlen; if (r_index != -1) skip_zero_padding(&cumul_bits,csi_report,r_index,bitlen); - evaluate_cqi_report(payload,csi_report,cumul_bits,r_index,sched_ctrl,csirep->cqi_Table); + evaluate_cqi_report(payload,csi_report,cumul_bits,r_index,UE,csirep->cqi_Table); break; case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI: cri_bitlen = csi_report->csi_meas_bitlen.cri_bitlen; @@ -1359,7 +1362,7 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, pmi_bitlen = evaluate_pmi_report(payload,csi_report,cumul_bits,r_index,sched_ctrl); sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.csi_report_id = csi_report_id; cumul_bits += pmi_bitlen; - evaluate_cqi_report(payload,csi_report,cumul_bits,r_index,sched_ctrl,csirep->cqi_Table); + evaluate_cqi_report(payload,csi_report,cumul_bits,r_index,UE,csirep->cqi_Table); break; case NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_LI_PMI_CQI: cri_bitlen = csi_report->csi_meas_bitlen.cri_bitlen; @@ -1377,7 +1380,7 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, pmi_bitlen = evaluate_pmi_report(payload,csi_report,cumul_bits,r_index,sched_ctrl); sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.csi_report_id = csi_report_id; cumul_bits += pmi_bitlen; - evaluate_cqi_report(payload,csi_report,cumul_bits,r_index,sched_ctrl,csirep->cqi_Table); + evaluate_cqi_report(payload,csi_report,cumul_bits,r_index,UE,csirep->cqi_Table); break; default: AssertFatal(1==0, "Invalid or not supported CSI measurement report\n"); @@ -1598,8 +1601,8 @@ int nr_acknack_scheduling(int mod_id, const int CC_id = 0; const int minfbtime = RC.nrmac[mod_id]->minRXTXTIMEpdsch; const NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels[CC_id].ServingCellConfigCommon; - NR_UE_BWP_t *BWP = &UE->current_BWP; - const int n_slots_frame = nr_slots_per_frame[BWP->ul_scs]; + NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; + const int n_slots_frame = nr_slots_per_frame[BWP->scs]; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; AssertFatal(tdd || RC.nrmac[mod_id]->common_channels[CC_id].frame_type == FDD, "Dynamic TDD not handled yet\n"); const int nr_slots_period = tdd ? n_slots_frame / get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity) : n_slots_frame; @@ -1627,8 +1630,8 @@ int nr_acknack_scheduling(int mod_id, pucch_Config = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; } - int bwp_start = BWP->ul_BWPStart; - int bwp_size = BWP->ul_BWPSize; + int bwp_start = BWP->BWPStart; + int bwp_size = BWP->BWPSize; NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[0]; LOG_D(NR_MAC, "In %s: %4d.%2d Trying to allocate pucch, current DAI %d\n", __FUNCTION__, frame, slot, pucch->dai_c); @@ -1875,8 +1878,8 @@ void nr_sr_reporting(gNB_MAC_INST *nrmac, frame_t SFN, sub_frame_t slot) UE_iterator(nrmac->UE_info.list, UE) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_BWP_t *BWP = &UE->current_BWP; - const int n_slots_frame = nr_slots_per_frame[BWP->ul_scs]; + NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; + const int n_slots_frame = nr_slots_per_frame[BWP->scs]; if (sched_ctrl->ul_failure==1) continue; NR_PUCCH_Config_t *pucch_Config = NULL; if (sched_ctrl->active_ubwp) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 3c4ca86cbd..49cbcd7a88 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -847,7 +847,7 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; int rbStart = 0; // wrt BWP start - const uint16_t bwpSize = UE->current_BWP.ul_BWPSize; + const uint16_t bwpSize = UE->current_UL_BWP.BWPSize; const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; LOG_D(NR_MAC,"retInfo->time_domain_allocation = %d, tda = %d\n", retInfo->time_domain_allocation, tda); @@ -1037,7 +1037,7 @@ void pf_ul(module_id_t module_id, LOG_D(NR_MAC,"pf_ul: preparing UL scheduling for UE %04x\n",UE->rnti); NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_BWP_t *BWP = &UE->current_BWP; + NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; int rbStart = 0; // wrt BWP start NR_CellGroupConfig_t *cg = UE->CellGroup; @@ -1045,7 +1045,7 @@ void pf_ul(module_id_t module_id, cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - const uint16_t bwpSize = BWP->ul_BWPSize; + const uint16_t bwpSize = BWP->BWPSize; NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; const NR_mac_dir_stats_t *stats = &UE->mac_stats.ul; @@ -1235,15 +1235,15 @@ void pf_ul(module_id_t module_id, } else LOG_D(NR_MAC, "%4d.%2d free CCE for UL DCI UE %04x\n",frame,slot, iterator->UE->rnti); - NR_UE_BWP_t *BWP = &iterator->UE->current_BWP; + NR_UE_UL_BWP_t *BWP = &iterator->UE->current_UL_BWP; NR_CellGroupConfig_t *cg = iterator->UE->CellGroup; NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - int rbStart = sched_ctrl->active_ubwp ? BWP->ul_BWPStart : 0; - const uint16_t bwpSize = BWP->ul_BWPSize; + int rbStart = sched_ctrl->active_ubwp ? BWP->BWPStart : 0; + const uint16_t bwpSize = BWP->BWPSize; NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; @@ -1347,8 +1347,8 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t * TDAs yet). If the TDA is negative, it means that there is no UL slot to * schedule now (slot + k2 is not UL slot) */ NR_UE_sched_ctrl_t *sched_ctrl = &nr_mac->UE_info.list[0]->UE_sched_ctrl; - NR_UE_BWP_t *BWP = &nr_mac->UE_info.list[0]->current_BWP; - int mu = BWP->ul_scs; + NR_UE_UL_BWP_t *BWP = &nr_mac->UE_info.list[0]->current_UL_BWP; + int mu = BWP->scs; const int temp_tda = get_ul_tda(nr_mac, scc, slot); int K2 = get_K2(scc, scc_sib1, sched_ctrl->active_ubwp, temp_tda, mu); const int sched_frame = (frame + (slot + K2 >= nr_slots_per_frame[mu])) & 1023; @@ -1398,8 +1398,8 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; - const uint16_t bwpSize = BWP->ul_BWPSize; - const uint16_t bwpStart = BWP->ul_BWPStart; + const uint16_t bwpSize = BWP->BWPSize; + const uint16_t bwpStart = BWP->BWPStart; NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = NULL; if (sched_ctrl->active_ubwp) { @@ -1511,7 +1511,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) if (sched_ctrl->ul_failure == 1 && get_softmodem_params()->phy_test==0) continue; NR_CellGroupConfig_t *cg = UE->CellGroup; - NR_UE_BWP_t *current_BWP = &UE->current_BWP; + NR_UE_UL_BWP_t *current_BWP = &UE->current_UL_BWP; NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? @@ -1642,9 +1642,9 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) /* FAPI: BWP */ - pusch_pdu->bwp_size = current_BWP->ul_BWPSize; - pusch_pdu->bwp_start = current_BWP->ul_BWPStart; - pusch_pdu->subcarrier_spacing = current_BWP->ul_scs; + pusch_pdu->bwp_size = current_BWP->BWPSize; + pusch_pdu->bwp_start = current_BWP->BWPStart; + pusch_pdu->subcarrier_spacing = current_BWP->scs; pusch_pdu->cyclic_prefix = 0; /* FAPI: PUSCH information always included */ @@ -1806,13 +1806,13 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) current_BWP); fill_dci_pdu_rel15(scc, cg, - current_BWP, + &UE->current_DL_BWP, dci_pdu, &uldci_payload, ps->dci_format, rnti_types[0], pusch_pdu->bwp_size, - current_BWP->ul_bwp_id, + current_BWP->bwp_id, coresetid, 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 1eed647565..26679a1b7c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -201,7 +201,7 @@ void config_uldci(const NR_SIB1_t *sib1, int time_domain_assignment, uint8_t tpc, int n_ubwp, - NR_UE_BWP_t *BWP); + NR_UE_UL_BWP_t *BWP); void nr_schedule_pucch(gNB_MAC_INST* nrmac, frame_t frameP, @@ -297,7 +297,7 @@ 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_BWP_t *BWP, + const NR_UE_DL_BWP_t *BWP, nfapi_nr_dl_dci_pdu_t *pdcch_dci_pdu, dci_pdu_rel15_t *dci_pdu_rel15, int dci_formats, @@ -308,7 +308,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, uint16_t cset0_bwp_size); void prepare_dci(const NR_CellGroupConfig_t *CellGroup, - const NR_UE_BWP_t *BWP, + const NR_UE_DL_BWP_t *BWP, dci_pdu_rel15_t *dci_pdu_rel15, nr_dci_format_t format, int bwp_id); @@ -339,7 +339,7 @@ long get_K2(NR_ServingCellConfigCommon_t *scc, int time_domain_assignment, int mu); -void nr_set_pdsch_semi_static(const NR_UE_BWP_t *BWP, +void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *BWP, const NR_ServingCellConfigCommon_t *scc, const NR_CellGroupConfig_t *secondaryCellGroup, int tda, @@ -391,11 +391,10 @@ NR_UE_info_t * find_nr_UE(NR_UEs_t* UEs, rnti_t rntiP); int find_nr_RA_id(module_id_t mod_idP, int CC_idP, rnti_t rntiP); void configure_UE_BWP(gNB_MAC_INST *nr_mac, - NR_UE_BWP_t *BWP, NR_ServingCellConfigCommon_t *scc, NR_UE_sched_ctrl_t *sched_ctrl, NR_RA_t *ra, - NR_CellGroupConfig_t *CellGroup); + NR_UE_info_t *UE); NR_UE_info_t* add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 2d42dbe15e..e38c23cf72 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -91,21 +91,25 @@ typedef struct { int len; } NR_list_t; -typedef struct NR_UE_BWP { - NR_BWP_Id_t dl_bwp_id; - NR_BWP_Id_t ul_bwp_id; +typedef struct NR_UE_DL_BWP { + NR_BWP_Id_t bwp_id; int n_dl_bwp; - int dl_scs; - int ul_scs; - long *dl_cyclicprefix; - long *ul_cyclicprefix; - uint16_t dl_BWPSize; - uint16_t dl_BWPStart; - uint16_t ul_BWPSize; - uint16_t ul_BWPStart; + int scs; + long *cyclicprefix; + uint16_t BWPSize; + uint16_t BWPStart; NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList; NR_PDSCH_Config_t *pdsch_Config; -} NR_UE_BWP_t; + uint8_t mcsTableIdx; +} NR_UE_DL_BWP_t; + +typedef struct NR_UE_UL_BWP { + NR_BWP_Id_t bwp_id; + int scs; + long *cyclicprefix; + uint16_t BWPSize; + uint16_t BWPStart; +} NR_UE_UL_BWP_t; typedef enum { RA_IDLE = 0, @@ -211,7 +215,8 @@ typedef struct { /// CFRA flag bool cfra; // BWP for RA - NR_UE_BWP_t BWP; + NR_UE_DL_BWP_t DL_BWP; + NR_UE_UL_BWP_t UL_BWP; } NR_RA_t; /*! \brief gNB common channels */ @@ -422,7 +427,6 @@ typedef struct NR_pdsch_semi_static { int startSymbolIndex; int nrOfSymbols; uint8_t nrOfLayers; - uint8_t mcsTableIdx; uint8_t dmrs_ports_id; uint8_t N_PRB_DMRS; uint8_t N_DMRS_SLOT; @@ -719,7 +723,8 @@ typedef struct { /// scheduling control info nr_csi_report_t csi_report_template[MAX_CSI_REPORTCONFIG]; NR_UE_sched_ctrl_t UE_sched_ctrl; - NR_UE_BWP_t current_BWP; + NR_UE_DL_BWP_t current_DL_BWP; + NR_UE_UL_BWP_t current_UL_BWP; NR_mac_stats_t mac_stats; NR_CellGroupConfig_t *CellGroup; char cg_buf[32768]; /* arbitrary size */ From 66e281094034d6c2a285dded4d2ff93d431485e3 Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 17 Jun 2022 12:18:29 +0200 Subject: [PATCH 08/16] moving few parameters from pusch_semistatic to BWP --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 30 ++--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 21 ++- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 121 ++++++++---------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 103 +++++---------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 9 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 12 +- 6 files changed, 110 insertions(+), 186 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index d29e60b869..ffce9533c5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -701,14 +701,11 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t NR_BWP_Uplink_t *ubwp = NULL; NR_BWP_UplinkDedicated_t *ubwpd = NULL; - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = UL_BWP->tdaList; if(ra->CellGroup) { ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[UL_BWP->bwp_id-1]; ubwpd = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; - pusch_TimeDomainAllocationList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } else - pusch_TimeDomainAllocationList = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - + } int mu = UL_BWP->scs; uint8_t K2 = *pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->k2; const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); @@ -732,10 +729,10 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t } int fh = 0; - int startSymbolAndLength = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; + int startSymbolAndLength = pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; int StartSymbolIndex, NrOfSymbols; SLIV2SL(startSymbolAndLength, &StartSymbolIndex, &NrOfSymbols); - int mappingtype = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; + int mappingtype = pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; uint16_t *vrb_map_UL = &RC.nrmac[module_idP]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; @@ -842,7 +839,6 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t scc, pusch_pdu, &uldci_payload, - NR_UL_DCI_FORMAT_0_0, ra->Msg3_tda_id, ra->msg3_TPC, 0, // not used in format 0_0 @@ -903,9 +899,7 @@ void nr_get_Msg3alloc(module_id_t module_id, int temp_slot = 0; ra->Msg3_tda_id = 16; // initialization to a value above limit - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList= ubwp ? - ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList: - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = UL_BWP->tdaList; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; const int n_slots_frame = nr_slots_per_frame[mu]; @@ -1115,17 +1109,9 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t int ibwp_size = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); int scs = UL_BWP->scs; - int fh = 0; - int startSymbolAndLength = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; - int mappingtype = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; - - if (ra->CellGroup) { - NR_BWP_Uplink_t *ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[UL_BWP->bwp_id - 1]; - - startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; - mappingtype = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; - fh = ubwp->bwp_Dedicated->pusch_Config->choice.setup->frequencyHopping ? 1 : 0; - } + int fh = (UL_BWP->pusch_Config && UL_BWP->pusch_Config->frequencyHopping) ? 1 : 0; + int startSymbolAndLength = UL_BWP->tdaList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; + int mappingtype = UL_BWP->tdaList->list.array[ra->Msg3_tda_id]->mappingType; LOG_D(NR_MAC, "Frame %d, Slot %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d) for rnti: %d\n", frameP, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 66b7f2e720..48eff7794e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -355,8 +355,7 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; const int mu = BWP->scs; - const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = - sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = BWP->tdaList; const int temp_tda = get_ul_tda(nr_mac, scc, slot); if (temp_tda < 0) return false; @@ -364,7 +363,7 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ "time domain assignment %d >= %d\n", temp_tda, tdaList->list.count); - int K2 = get_K2(scc,NULL,sched_ctrl->active_ubwp, temp_tda, mu); + int K2 = get_K2(BWP->tdaList, temp_tda, mu); const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; const int tda = get_ul_tda(nr_mac, scc, sched_slot); @@ -380,22 +379,18 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ if (!is_xlsch_in_slot(ulsch_slot_bitmap, sched_slot)) return false; - const long f = (sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) ? - sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; - const int dci_format = f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0; uint8_t num_dmrs_cdm_grps_no_data = 1; if ((target_ul_Nl==4)||(target_ul_Nl==3)) num_dmrs_cdm_grps_no_data = 2; /* we want to avoid a lengthy deduction of DMRS and other parameters in - * every TTI if we can save it, so check whether dci_format, TDA, or + * every TTI if we can save it, so check whether TDA, or * num_dmrs_cdm_grps_no_data has changed and only then recompute */ NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; if (ps->time_domain_allocation != tda - || ps->dci_format != dci_format || ps->nrOfLayers != target_ul_Nl || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) - nr_set_pusch_semi_static(NULL, scc, sched_ctrl->active_ubwp, NULL,dci_format, tda, num_dmrs_cdm_grps_no_data,target_ul_Nl,ps); + nr_set_pusch_semi_static(BWP, scc, sched_ctrl->active_ubwp, NULL, tda, num_dmrs_cdm_grps_no_data,target_ul_Nl,ps); uint16_t rbStart = 0; uint16_t rbSize; @@ -465,10 +460,10 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ /* Calculate TBS from MCS */ ps->nrOfLayers = target_ul_Nl; - sched_pusch->R = nr_get_code_rate_ul(mcs, ps->mcs_table); - sched_pusch->Qm = nr_get_Qm_ul(mcs, ps->mcs_table); - if (ps->pusch_Config->tp_pi2BPSK - && ((ps->mcs_table == 3 && mcs < 2) || (ps->mcs_table == 4 && mcs < 6))) { + sched_pusch->R = nr_get_code_rate_ul(mcs, BWP->mcs_table); + sched_pusch->Qm = nr_get_Qm_ul(mcs, BWP->mcs_table); + if (BWP->pusch_Config->tp_pi2BPSK + && ((BWP->mcs_table == 3 && mcs < 2) || (BWP->mcs_table == 4 && mcs < 6))) { sched_pusch->R >>= 1; sched_pusch->Qm <<= 1; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 8fdf0fa9a1..a9cb4121d7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -593,66 +593,31 @@ void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *BWP, LOG_D(NR_MAC,"Filling dmrs info, ps->N_PRB_DMRS %d, ps->dl_dmrs_symb_pos %x, ps->N_DMRS_SLOT %d\n",ps->N_PRB_DMRS,ps->dl_dmrs_symb_pos,ps->N_DMRS_SLOT); } -void nr_set_pusch_semi_static(const NR_SIB1_t *sib1, +void nr_set_pusch_semi_static(const NR_UE_UL_BWP_t *BWP, const NR_ServingCellConfigCommon_t *scc, const NR_BWP_Uplink_t *ubwp, const NR_BWP_UplinkDedicated_t *ubwpd, - long dci_format, int tda, uint8_t num_dmrs_cdm_grps_no_data, uint8_t nrOfLayers, NR_pusch_semi_static_t *ps) { - ps->dci_format = dci_format; ps->time_domain_allocation = tda; - NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = NULL; - if(ubwp) { - tdaList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } else if(scc) { - tdaList = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } else { - tdaList = sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } - - const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; + const int startSymbolAndLength = BWP->tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &ps->startSymbolIndex, &ps->nrOfSymbols); - ps->pusch_Config = ubwp && ubwp->bwp_Dedicated && ubwp->bwp_Dedicated->pusch_Config ? - ubwp->bwp_Dedicated->pusch_Config->choice.setup : (ubwpd ? ubwpd->pusch_Config->choice.setup : NULL); - if (ps->pusch_Config == NULL || !ps->pusch_Config->transformPrecoder) - ps->transform_precoding = !scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder; - else - ps->transform_precoding = *ps->pusch_Config->transformPrecoder; - const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - if (ps->transform_precoding) - ps->mcs_table = get_pusch_mcs_table(ps->pusch_Config ? ps->pusch_Config->mcs_Table : NULL, - 0, - ps->dci_format, - NR_RNTI_C, - target_ss, - false); - else { - ps->mcs_table = get_pusch_mcs_table(ps->pusch_Config ? ps->pusch_Config->mcs_TableTransformPrecoder : NULL, - 1, - ps->dci_format, - NR_RNTI_C, - target_ss, - false); - num_dmrs_cdm_grps_no_data = 2; // in case of transform precoding - no Data sent in DMRS symbol - } - ps->nrOfLayers = nrOfLayers; - ps->num_dmrs_cdm_grps_no_data = num_dmrs_cdm_grps_no_data; + ps->num_dmrs_cdm_grps_no_data = BWP->transform_precoding ? num_dmrs_cdm_grps_no_data : 2; /* DMRS calculations */ - ps->mapping_type = tdaList->list.array[tda]->mappingType; - ps->NR_DMRS_UplinkConfig = ps->pusch_Config ? + ps->mapping_type = BWP->tdaList->list.array[tda]->mappingType; + ps->NR_DMRS_UplinkConfig = BWP->pusch_Config ? (ps->mapping_type == NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeA ? - ps->pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup : - ps->pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup) : NULL; + BWP->pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup : + BWP->pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup) : NULL; ps->dmrs_config_type = ps->NR_DMRS_UplinkConfig ? ((ps->NR_DMRS_UplinkConfig->dmrs_Type == NULL ? 0 : 1)) : 0; const pusch_dmrs_AdditionalPosition_t additional_pos = ps->NR_DMRS_UplinkConfig ? (ps->NR_DMRS_UplinkConfig->dmrs_AdditionalPosition == NULL @@ -947,13 +912,13 @@ void config_uldci(const NR_SIB1_t *sib1, const NR_ServingCellConfigCommon_t *scc, const nfapi_nr_pusch_pdu_t *pusch_pdu, dci_pdu_rel15_t *dci_pdu_rel15, - int dci_format, int time_domain_assignment, uint8_t tpc, int n_ubwp, NR_UE_UL_BWP_t *UBWP) { int bwp_id = UBWP->bwp_id; + nr_dci_format_t dci_format = UBWP->dci_format; dci_pdu_rel15->frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pusch_pdu->rb_size, pusch_pdu->rb_start, UBWP->BWPSize); @@ -964,9 +929,9 @@ void config_uldci(const NR_SIB1_t *sib1, dci_pdu_rel15->rv = pusch_pdu->pusch_data.rv_index; dci_pdu_rel15->harq_pid = pusch_pdu->pusch_data.harq_process_id; dci_pdu_rel15->tpc = tpc; - const NR_BWP_UplinkDedicated_t *ubwpd2 = (ubwp) ? ubwp->bwp_Dedicated : ubwpd; + NR_PUSCH_Config_t *pusch_Config = UBWP->pusch_Config; - if (ubwpd2) AssertFatal(ubwpd2->pusch_Config->choice.setup->resourceAllocation == NR_PUSCH_Config__resourceAllocation_resourceAllocationType1, + if (pusch_Config) AssertFatal(pusch_Config->resourceAllocation == NR_PUSCH_Config__resourceAllocation_resourceAllocationType1, "Only frequency resource allocation type 1 is currently supported\n"); switch (dci_format) { case NR_UL_DCI_FORMAT_0_0: @@ -978,11 +943,9 @@ void config_uldci(const NR_SIB1_t *sib1, // bwp indicator as per table 7.3.1.1.2-1 in 38.212 dci_pdu_rel15->bwp_indicator.val = n_ubwp < 4 ? bwp_id : bwp_id - 1; // SRS resource indicator - if (ubwpd2 && - ubwpd2->pusch_Config && - ubwpd2->pusch_Config->choice.setup && - ubwpd2->pusch_Config->choice.setup->txConfig != NULL) { - AssertFatal(*ubwpd2->pusch_Config->choice.setup->txConfig == NR_PUSCH_Config__txConfig_codebook, + if (pusch_Config && + pusch_Config->txConfig != NULL) { + AssertFatal(*pusch_Config->txConfig == NR_PUSCH_Config__txConfig_codebook, "Non Codebook configuration non supported\n"); dci_pdu_rel15->srs_resource_indicator.val = 0; // taking resource 0 for SRS } @@ -1102,6 +1065,7 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, NR_PUCCH_FormatConfig_t *pucchfmt; NR_PUCCH_ResourceId_t *resource_id = NULL; NR_BWP_Uplink_t *bwp = UE->UE_sched_ctrl.active_ubwp; + NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; long *id0 = NULL; int n_list, n_set; @@ -1113,12 +1077,7 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, uint16_t O_uci = O_csi + O_ack; - NR_PUSCH_Config_t *pusch_Config = NULL; - if(bwp && bwp->bwp_Dedicated && bwp->bwp_Dedicated->pusch_Config) { - pusch_Config = bwp->bwp_Dedicated->pusch_Config->choice.setup; - } else if(bwpd && bwpd->pusch_Config) { - pusch_Config = bwpd->pusch_Config->choice.setup; - } + NR_PUSCH_Config_t *pusch_Config = BWP->pusch_Config; long *pusch_id = pusch_Config ? pusch_Config->dataScramblingIdentityPUSCH : NULL; @@ -1163,8 +1122,6 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, else pucch_pdu->hopping_id = *scc->physCellId; - NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; - pucch_pdu->bwp_size = BWP->BWPSize; pucch_pdu->bwp_start = BWP->BWPStart; pucch_pdu->subcarrier_spacing = BWP->scs; @@ -2289,6 +2246,7 @@ void delete_nr_ue_data(NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr) } } +// main function to configure parameters of current BWP void configure_UE_BWP(gNB_MAC_INST *nr_mac, NR_ServingCellConfigCommon_t *scc, NR_UE_sched_ctrl_t *sched_ctrl, @@ -2366,22 +2324,30 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, ubwpd = servingCellConfig->uplinkConfig->initialUplinkBWP; DL_BWP->pdsch_Config = bwpd->pdsch_Config->choice.setup; + UL_BWP->pusch_Config = ubwpd->pusch_Config->choice.setup; } else { DL_BWP->bwp_id = 0; DL_BWP->bwp_id = 0; target_ss = NR_SearchSpace__searchSpaceType_PR_common; DL_BWP->pdsch_Config = NULL; + UL_BWP->pusch_Config = NULL; } if (old_dl_bwp_id != DL_BWP->bwp_id) LOG_I(NR_MAC, "Switching to DL-BWP %li\n", DL_BWP->bwp_id); + // TDA lists if (DL_BWP->bwp_id>0) DL_BWP->tdaList = dl_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; else DL_BWP->tdaList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + if(UL_BWP->bwp_id>0) + UL_BWP->tdaList = ul_bwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + else + 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) ? dl_bwp->bwp_Common->genericParameters: @@ -2410,7 +2376,12 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, DL_BWP->mcsTableIdx = 2; } else DL_BWP->mcsTableIdx = 0; - LOG_D(NR_MAC,"MCS Table Index: %d\n",DL_BWP->mcsTableIdx); + LOG_D(NR_MAC,"DL MCS Table Index: %d\n",DL_BWP->mcsTableIdx); + + if (UL_BWP->pusch_Config == NULL || !UL_BWP->pusch_Config->transformPrecoder) + UL_BWP->transform_precoding = !scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder; + else + UL_BWP->transform_precoding = *UL_BWP->pusch_Config->transformPrecoder; if(UE) { // setting PDCCH related structures for sched_ctrl @@ -2429,6 +2400,14 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, scc, &dl_genericParameters, nr_mac->type0_PDCCH_CSS_config); + + // set UL DCI format + UL_BWP->dci_format = (sched_ctrl->search_space->searchSpaceType && + sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) ? + (sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1 ? + NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0) : + NR_UL_DCI_FORMAT_0_0; + } if(ra) { @@ -2457,7 +2436,23 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, scc, &dl_genericParameters, &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]); + + UL_BWP->dci_format = NR_UL_DCI_FORMAT_0_0; } + + // Set uplink MCS table + long *mcs_Table = NULL; + if (UL_BWP->pusch_Config) + mcs_Table = UL_BWP->transform_precoding ? + UL_BWP->pusch_Config->mcs_Table : + UL_BWP->pusch_Config->mcs_TableTransformPrecoder; + + UL_BWP->mcs_table = get_pusch_mcs_table(mcs_Table, + UL_BWP->transform_precoding ? 0 : 1, + UL_BWP->dci_format, + NR_RNTI_C, + target_ss, + false); } //------------------------------------------------------------------------------ @@ -2951,8 +2946,8 @@ void nr_csirs_scheduling(int Mod_idP, void nr_mac_update_timers(module_id_t module_id, frame_t frame, sub_frame_t slot) { - NR_UEs_t *UE_info = &RC.nrmac[module_id]->UE_info; + NR_UEs_t *UE_info = &RC.nrmac[module_id]->UE_info; UE_iterator(UE_info->list, UE) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if (sched_ctrl->rrc_processing_timer > 0) { @@ -2960,8 +2955,6 @@ void nr_mac_update_timers(module_id_t module_id, if (sched_ctrl->rrc_processing_timer == 0) { LOG_I(NR_MAC, "(%d.%d) De-activating RRC processing timer for UE %04x\n", frame, slot, UE->rnti); - const NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1 ? RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - NR_CellGroupConfig_t *cg = NULL; uper_decode(NULL, &asn_DEF_NR_CellGroupConfig, //might be added prefix later @@ -3034,16 +3027,14 @@ void nr_mac_update_timers(module_id_t module_id, } NR_pusch_semi_static_t *ups = &sched_ctrl->pusch_semi_static; - int dci_format = get_dci_format(sched_ctrl); const uint8_t num_dmrs_cdm_grps_no_data = (ubwp || ubwpd) ? 1 : 2; const uint8_t nrOfLayers = 1; const int utda = get_ul_tda(RC.nrmac[module_id], scc, slot); - nr_set_pusch_semi_static(sib1, + nr_set_pusch_semi_static(&UE->current_UL_BWP, scc, ubwp, ubwpd, - dci_format, utda, num_dmrs_cdm_grps_no_data, nrOfLayers, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 49cbcd7a88..eb23775a24 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -37,15 +37,6 @@ #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" -int get_dci_format(NR_UE_sched_ctrl_t *sched_ctrl) { - - int dci_format = sched_ctrl->search_space && sched_ctrl->search_space->searchSpaceType && - sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific ? - NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0; - - return(dci_format); -} - const int get_ul_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot) { /* there is a mixed slot only when in TDD */ @@ -760,23 +751,14 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, } } -long get_K2(NR_ServingCellConfigCommon_t *scc, - NR_ServingCellConfigCommonSIB_t *scc_sib1, - NR_BWP_Uplink_t *ubwp, +long get_K2(NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList, int time_domain_assignment, int mu) { - NR_PUSCH_TimeDomainResourceAllocation_t *tda_list = NULL; - if(ubwp) { - tda_list = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]; - } else if(scc) { - tda_list = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]; - } else if(scc_sib1) { - tda_list = scc_sib1->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[time_domain_assignment]; - } + NR_PUSCH_TimeDomainResourceAllocation_t *tda = tdaList->list.array[time_domain_assignment]; - if (tda_list->k2) - return *tda_list->k2; + if (tda->k2) + return *tda->k2; else if (mu < 2) return 1; else if (mu == 2) @@ -857,17 +839,13 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, * (re-)transmission */ NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; - int dci_format = get_dci_format(sched_ctrl); - if (ps->time_domain_allocation != tda - || ps->dci_format != dci_format || ps->nrOfLayers != nrOfLayers || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) { - nr_set_pusch_semi_static(sib1, + nr_set_pusch_semi_static(&UE->current_UL_BWP, scc, sched_ctrl->active_ubwp, ubwpd, - dci_format, tda, num_dmrs_cdm_grps_no_data, nrOfLayers, @@ -885,12 +863,10 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, LOG_D(NR_MAC, "%s(): retransmission keeping TDA %d and TBS %d\n", __func__, tda, retInfo->tb_size); } else { NR_pusch_semi_static_t temp_ps; - int dci_format = get_dci_format(sched_ctrl); - nr_set_pusch_semi_static(sib1, + nr_set_pusch_semi_static(&UE->current_UL_BWP, scc, sched_ctrl->active_ubwp, ubwpd, - dci_format, tda, num_dmrs_cdm_grps_no_data, nrOfLayers, @@ -988,13 +964,13 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, return true; } -void update_ul_ue_R_Qm(NR_sched_pusch_t *sched_pusch, const NR_pusch_semi_static_t *ps) -{ - const int mcs = sched_pusch->mcs; - sched_pusch->R = nr_get_code_rate_ul(mcs, ps->mcs_table); - sched_pusch->Qm = nr_get_Qm_ul(mcs, ps->mcs_table); +void update_ul_ue_R_Qm(NR_sched_pusch_t *sched_pusch, const NR_PUSCH_Config_t *pusch_Config, const int mcs_table) { - if (ps->pusch_Config && ps->pusch_Config->tp_pi2BPSK && ((ps->mcs_table == 3 && mcs < 2) || (ps->mcs_table == 4 && mcs < 6))) { + const int mcs = sched_pusch->mcs; + sched_pusch->R = nr_get_code_rate_ul(mcs, mcs_table); + sched_pusch->Qm = nr_get_Qm_ul(mcs, mcs_table); + + if (pusch_Config && pusch_Config->tp_pi2BPSK && ((mcs_table == 3 && mcs < 2) || (mcs_table == 4 && mcs < 6))) { sched_pusch->R >>= 1; sched_pusch->Qm <<= 1; } @@ -1127,21 +1103,18 @@ void pf_ul(module_id_t module_id, /* Save PUSCH field */ /* we want to avoid a lengthy deduction of DMRS and other parameters in - * every TTI if we can save it, so check whether dci_format, TDA, or + * every TTI if we can save it, so check whether TDA, or * num_dmrs_cdm_grps_no_data has changed and only then recompute */ const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; - int dci_format = get_dci_format(sched_ctrl); const int tda = get_ul_tda(nrmac, scc, sched_pusch->slot); if (ps->time_domain_allocation != tda - || ps->dci_format != dci_format || ps->nrOfLayers != nrOfLayers || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) { - nr_set_pusch_semi_static(sib1, + nr_set_pusch_semi_static(BWP, scc, sched_ctrl->active_ubwp, ubwpd, - dci_format, tda, num_dmrs_cdm_grps_no_data, nrOfLayers, @@ -1168,7 +1141,7 @@ void pf_ul(module_id_t module_id, NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; sched_pusch->mcs = min(nrmac->min_grant_mcs, sched_pusch->mcs); - update_ul_ue_R_Qm(sched_pusch, ps); + update_ul_ue_R_Qm(sched_pusch, BWP->pusch_Config, BWP->mcs_table); sched_pusch->rbStart = rbStart; sched_pusch->rbSize = min_rb; sched_pusch->tb_size = nr_compute_tbs(sched_pusch->Qm, @@ -1191,7 +1164,7 @@ void pf_ul(module_id_t module_id, /* Create UE_sched for UEs eligibale for new data transmission*/ /* Calculate coefficient*/ - const uint32_t tbs = ul_pf_tbs[ps->mcs_table][sched_pusch->mcs]; + const uint32_t tbs = ul_pf_tbs[BWP->mcs_table][sched_pusch->mcs]; float coeff_ue = (float) tbs / UE->ul_thr_ue; LOG_D(NR_MAC,"rnti %04x b %d, ul_thr_ue %f, tbs %d, coeff_ue %f\n", UE->rnti, b, UE->ul_thr_ue, tbs, coeff_ue); @@ -1249,27 +1222,24 @@ void pf_ul(module_id_t module_id, /* Save PUSCH field */ /* we want to avoid a lengthy deduction of DMRS and other parameters in - * every TTI if we can save it, so check whether dci_format, TDA, or + * every TTI if we can save it, so check whether TDA, or * num_dmrs_cdm_grps_no_data has changed and only then recompute */ const uint8_t nrOfLayers = 1; const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; - int dci_format = get_dci_format(sched_ctrl); const int tda = get_ul_tda(nrmac, scc, sched_pusch->slot); if (ps->time_domain_allocation != tda - || ps->dci_format != dci_format || ps->nrOfLayers != nrOfLayers || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) { - nr_set_pusch_semi_static(sib1, + nr_set_pusch_semi_static(BWP, scc, sched_ctrl->active_ubwp, ubwpd, - dci_format, tda, num_dmrs_cdm_grps_no_data, nrOfLayers, ps); } - update_ul_ue_R_Qm(sched_pusch, ps); + update_ul_ue_R_Qm(sched_pusch, BWP->pusch_Config, BWP->mcs_table); const uint16_t slbitmap = SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); while (rbStart < bwpSize && (rballoc_mask[rbStart] & slbitmap) != slbitmap) @@ -1350,13 +1320,13 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t NR_UE_UL_BWP_t *BWP = &nr_mac->UE_info.list[0]->current_UL_BWP; int mu = BWP->scs; const int temp_tda = get_ul_tda(nr_mac, scc, slot); - int K2 = get_K2(scc, scc_sib1, sched_ctrl->active_ubwp, temp_tda, mu); + int K2 = get_K2(BWP->tdaList, temp_tda, mu); const int sched_frame = (frame + (slot + K2 >= nr_slots_per_frame[mu])) & 1023; const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; const int tda = get_ul_tda(nr_mac, scc, sched_slot); if (tda < 0) return false; - DevAssert(K2 == get_K2(scc, scc_sib1, sched_ctrl->active_ubwp, tda, mu)); + DevAssert(K2 == get_K2(BWP->tdaList, tda, mu)); if (!is_xlsch_in_slot(nr_mac->ulsch_slot_bitmap[sched_slot / 64], sched_slot)) return false; @@ -1385,9 +1355,9 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t sched_ctrl->sched_pusch.frame = sched_frame; UE_iterator(nr_mac->UE_info.list, UE2) { NR_UE_sched_ctrl_t *sched_ctrl = &UE2->UE_sched_ctrl; - AssertFatal(K2 == get_K2(scc,scc_sib1,sched_ctrl->active_ubwp, tda, mu), + AssertFatal(K2 == get_K2(BWP->tdaList, tda, mu), "Different K2, %d(UE%d) != %ld(UE%04x)\n", - K2, 0, get_K2(scc,scc_sib1,sched_ctrl->active_ubwp, tda, mu), UE2->rnti); + K2, 0, get_K2(BWP->tdaList, tda, mu), UE2->rnti); sched_ctrl->sched_pusch.slot = sched_slot; sched_ctrl->sched_pusch.frame = sched_frame; } @@ -1401,17 +1371,7 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t const uint16_t bwpSize = BWP->BWPSize; const uint16_t bwpStart = BWP->BWPStart; - NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList = NULL; - if (sched_ctrl->active_ubwp) { - tdaList = sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } else if (scc) { - tdaList = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } else { - NR_SIB1_t *sib1 = RC.nrmac[module_id]->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1; - tdaList = sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - } - - const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; + const int startSymbolAndLength = BWP->tdaList->list.array[tda]->startSymbolAndLength; int startSymbolIndex, nrOfSymbols; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); const uint16_t symb = SL_to_bitmap(startSymbolIndex, nrOfSymbols); @@ -1651,10 +1611,10 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->target_code_rate = sched_pusch->R; pusch_pdu->qam_mod_order = sched_pusch->Qm; pusch_pdu->mcs_index = sched_pusch->mcs; - pusch_pdu->mcs_table = ps->mcs_table; - pusch_pdu->transform_precoding = ps->transform_precoding; - if (ps->pusch_Config && ps->pusch_Config->dataScramblingIdentityPUSCH) - pusch_pdu->data_scrambling_id = *ps->pusch_Config->dataScramblingIdentityPUSCH; + pusch_pdu->mcs_table = current_BWP->mcs_table; + pusch_pdu->transform_precoding = current_BWP->transform_precoding; + if (current_BWP->pusch_Config && current_BWP->pusch_Config->dataScramblingIdentityPUSCH) + pusch_pdu->data_scrambling_id = *current_BWP->pusch_Config->dataScramblingIdentityPUSCH; else pusch_pdu->data_scrambling_id = *scc->physCellId; pusch_pdu->nrOfLayers = ps->nrOfLayers; @@ -1690,7 +1650,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) pusch_pdu->rb_start = sched_pusch->rbStart; pusch_pdu->rb_size = sched_pusch->rbSize; pusch_pdu->vrb_to_prb_mapping = 0; - if (ps->pusch_Config==NULL || ps->pusch_Config->frequencyHopping==NULL) + if (current_BWP->pusch_Config==NULL || current_BWP->pusch_Config->frequencyHopping==NULL) pusch_pdu->frequency_hopping = 0; else pusch_pdu->frequency_hopping = 1; @@ -1724,7 +1684,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) else AssertFatal(1==0,"SequenceGroupHopping or sequenceHopping are NOT Supported\n"); - LOG_D(NR_MAC,"TRANSFORM PRECODING IS ENABLED. CDM groups: %d, U: %d MCS table: %d\n", pusch_pdu->num_dmrs_cdm_grps_no_data, pusch_pdu->dfts_ofdm.low_papr_group_number, ps->mcs_table); + LOG_D(NR_MAC,"TRANSFORM PRECODING IS ENABLED. CDM groups: %d, U: %d MCS table: %d\n", pusch_pdu->num_dmrs_cdm_grps_no_data, pusch_pdu->dfts_ofdm.low_papr_group_number, current_BWP->mcs_table); } /*-----------------------------------------------------------------------------*/ @@ -1799,7 +1759,6 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) scc, pusch_pdu, &uldci_payload, - ps->dci_format, ps->time_domain_allocation, UE->UE_sched_ctrl.tpc0, n_ubwp, @@ -1809,7 +1768,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) &UE->current_DL_BWP, dci_pdu, &uldci_payload, - ps->dci_format, + current_BWP->dci_format, rnti_types[0], pusch_pdu->bwp_size, current_BWP->bwp_id, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 26679a1b7c..bc145b6dd9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -197,7 +197,6 @@ void config_uldci(const NR_SIB1_t *sib1, const NR_ServingCellConfigCommon_t *scc, const nfapi_nr_pusch_pdu_t *pusch_pdu, dci_pdu_rel15_t *dci_pdu_rel15, - int dci_format, int time_domain_assignment, uint8_t tpc, int n_ubwp, @@ -333,9 +332,7 @@ NR_SearchSpace_t *get_searchspace(NR_ServingCellConfigCommon_t *scc, NR_BWP_DownlinkDedicated_t *bwp_Dedicated, NR_SearchSpace__searchSpaceType_PR target_ss); -long get_K2(NR_ServingCellConfigCommon_t *scc, - NR_ServingCellConfigCommonSIB_t *scc_sib1, - NR_BWP_Uplink_t *ubwp, +long get_K2(NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList, int time_domain_assignment, int mu); @@ -347,11 +344,10 @@ void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *BWP, NR_UE_sched_ctrl_t *sched_ctrl, NR_pdsch_semi_static_t *ps); -void nr_set_pusch_semi_static(const NR_SIB1_t *sib1, +void nr_set_pusch_semi_static(const NR_UE_UL_BWP_t *BWP, const NR_ServingCellConfigCommon_t *scc, const NR_BWP_Uplink_t *ubwp, const NR_BWP_UplinkDedicated_t *ubwpd, - long dci_format, int tda, uint8_t num_dmrs_cdm_grps_no_data, uint8_t nrOfLayers, @@ -499,7 +495,6 @@ uint8_t get_mcs_from_cqi(int mcs_table, int cqi_table, int cqi_idx); uint8_t set_dl_nrOfLayers(NR_UE_sched_ctrl_t *sched_ctrl); -int get_dci_format(NR_UE_sched_ctrl_t *sched_ctrl); const int get_dl_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot); const int get_ul_tda(const gNB_MAC_INST *nrmac, const NR_ServingCellConfigCommon_t *scc, int slot); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index e38c23cf72..ca239ee51e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -109,6 +109,11 @@ typedef struct NR_UE_UL_BWP { long *cyclicprefix; uint16_t BWPSize; uint16_t BWPStart; + NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList; + NR_PUSCH_Config_t *pusch_Config; + uint8_t transform_precoding; + uint8_t mcs_table; + nr_dci_format_t dci_format; } NR_UE_UL_BWP_t; typedef enum { @@ -364,18 +369,11 @@ typedef struct NR_sched_pucch { * recalculate all S/L, MCS table, or DMRS-related parameters over and over * again. Hence, we store them in this struct for easy reference. */ typedef struct NR_pusch_semi_static_t { - int dci_format; int time_domain_allocation; uint8_t nrOfLayers; uint8_t num_dmrs_cdm_grps_no_data; - int startSymbolIndex; int nrOfSymbols; - - NR_PUSCH_Config_t *pusch_Config; - uint8_t transform_precoding; - uint8_t mcs_table; - long mapping_type; NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig; uint16_t dmrs_config_type; From 3cd49db442c07cdbeef2b3e5f29a75c66ddbc50d Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 17 Jun 2022 16:34:01 +0200 Subject: [PATCH 09/16] removing ul active_bwp --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 17 +-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 22 +--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 11 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 121 ++++++------------ .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 56 ++------ .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 59 +-------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 14 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 8 +- 8 files changed, 68 insertions(+), 240 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index ffce9533c5..6e2af05a13 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -699,13 +699,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_UE_UL_BWP_t *UL_BWP = &ra->UL_BWP; - NR_BWP_Uplink_t *ubwp = NULL; - NR_BWP_UplinkDedicated_t *ubwpd = NULL; NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = UL_BWP->tdaList; - if(ra->CellGroup) { - ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[UL_BWP->bwp_id-1]; - ubwpd = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; - } int mu = UL_BWP->scs; uint8_t K2 = *pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->k2; const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); @@ -834,14 +828,11 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t const NR_SIB1_t *sib1 = cc->sib1 ? cc->sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; config_uldci(sib1, - ubwp, - ubwpd, scc, pusch_pdu, &uldci_payload, ra->Msg3_tda_id, ra->msg3_TPC, - 0, // not used in format 0_0 &ra->UL_BWP); fill_dci_pdu_rel15(scc, @@ -879,7 +870,6 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t void nr_get_Msg3alloc(module_id_t module_id, int CC_id, NR_ServingCellConfigCommon_t *scc, - NR_BWP_Uplink_t *ubwp, sub_frame_t current_slot, frame_t current_frame, NR_RA_t *ra, @@ -1393,10 +1383,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra nfapi_nr_pdu_t *tx_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs]; // Program UL processing for Msg3 - NR_BWP_Uplink_t *ubwp = ra->CellGroup ? - ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->UL_BWP.bwp_id-1] : - NULL; - nr_get_Msg3alloc(module_idP, CC_id, scc, ubwp, slotP, frameP, ra, nr_mac->tdd_beam_association); + nr_get_Msg3alloc(module_idP, CC_id, scc, slotP, frameP, ra, nr_mac->tdd_beam_association); nr_add_msg3(module_idP, CC_id, frameP, slotP, ra, (uint8_t *) &tx_req->TLVs[0].value.direct[0]); if(ra->cfra) { @@ -1520,7 +1507,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra } const int delta_PRI=0; - int r_pucch = nr_get_pucch_resource(coreset, sched_ctrl->active_ubwp, NULL, CCEIndex); + int r_pucch = nr_get_pucch_resource(coreset, ra->UL_BWP.pucch_Config, CCEIndex); LOG_D(NR_MAC,"[RAPROC] Msg4 r_pucch %d (CCEIndex %d, nb_of_candidates %d, delta_PRI %d)\n", r_pucch, CCEIndex, nr_of_candidates, delta_PRI); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 70f4a98a99..079bc3da40 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -377,16 +377,10 @@ bool allocate_dl_retransmission(module_id_t module_id, const NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels->ServingCellConfigCommon; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; + NR_UE_UL_BWP_t *UBWP = &UE->current_UL_BWP; NR_sched_pdsch_t *retInfo = &sched_ctrl->harq_processes[current_harq_pid].sched_pdsch; NR_CellGroupConfig_t *cg = UE->CellGroup; - NR_BWP_UplinkDedicated_t *ubwpd = - cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - const int coresetid = sched_ctrl->coreset->controlResourceSetId; const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : BWP->BWPSize; @@ -506,7 +500,7 @@ bool allocate_dl_retransmission(module_id_t module_id, /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH * allocation after CCE alloc fail would be more complex) */ - int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, ubwpd, CCEIndex); + int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, UBWP->pucch_Config, CCEIndex); const int alloc = nr_acknack_scheduling(module_id, UE, frame, slot, r_pucch, 0); if (alloc<0) { LOG_D(MAC, @@ -639,19 +633,11 @@ void pf_dl(module_id_t module_id, /* Loop UE_sched to find max coeff and allocate transmission */ while (remainUEs> 0 && n_rb_sched >= min_rbSize && iterator->UE != NULL) { - NR_CellGroupConfig_t *cg = iterator->UE->CellGroup; - - NR_BWP_UplinkDedicated_t *ubwpd = - cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - NR_UE_sched_ctrl_t *sched_ctrl = &iterator->UE->UE_sched_ctrl; const uint16_t rnti = iterator->UE->rnti; NR_UE_DL_BWP_t *BWP = &iterator->UE->current_DL_BWP; + NR_UE_UL_BWP_t *UBWP = &iterator->UE->current_UL_BWP; const int coresetid = sched_ctrl->coreset->controlResourceSetId; const uint16_t bwpSize = coresetid == 0 ? @@ -697,7 +683,7 @@ void pf_dl(module_id_t module_id, /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH * allocation after CCE alloc fail would be more complex) */ - int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, ubwpd, CCEIndex); + int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, UBWP->pucch_Config, CCEIndex); const int alloc = nr_acknack_scheduling(module_id, iterator->UE, frame, slot, r_pucch, 0); if (alloc<0) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 48eff7794e..64c7447ed9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -280,7 +280,7 @@ void nr_preprocessor_phytest(module_id_t module_id, __func__, UE->rnti); - int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, NULL, CCEIndex); + int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, UE->current_UL_BWP.pucch_Config, CCEIndex); const int alloc = nr_acknack_scheduling(module_id, UE, frame, slot, r_pucch, 0); if (alloc < 0) { LOG_D(MAC, @@ -379,18 +379,13 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ if (!is_xlsch_in_slot(ulsch_slot_bitmap, sched_slot)) return false; - uint8_t num_dmrs_cdm_grps_no_data = 1; - if ((target_ul_Nl==4)||(target_ul_Nl==3)) - num_dmrs_cdm_grps_no_data = 2; - /* we want to avoid a lengthy deduction of DMRS and other parameters in * every TTI if we can save it, so check whether TDA, or * num_dmrs_cdm_grps_no_data has changed and only then recompute */ NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; if (ps->time_domain_allocation != tda - || ps->nrOfLayers != target_ul_Nl - || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) - nr_set_pusch_semi_static(BWP, scc, sched_ctrl->active_ubwp, NULL, tda, num_dmrs_cdm_grps_no_data,target_ul_Nl,ps); + || ps->nrOfLayers != target_ul_Nl) + nr_set_pusch_semi_static(BWP, scc, tda, target_ul_Nl,ps); uint16_t rbStart = 0; uint16_t rbSize; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index a9cb4121d7..ab17aebc6e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -595,10 +595,7 @@ void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *BWP, void nr_set_pusch_semi_static(const NR_UE_UL_BWP_t *BWP, const NR_ServingCellConfigCommon_t *scc, - const NR_BWP_Uplink_t *ubwp, - const NR_BWP_UplinkDedicated_t *ubwpd, int tda, - uint8_t num_dmrs_cdm_grps_no_data, uint8_t nrOfLayers, NR_pusch_semi_static_t *ps) { @@ -610,7 +607,11 @@ void nr_set_pusch_semi_static(const NR_UE_UL_BWP_t *BWP, &ps->nrOfSymbols); ps->nrOfLayers = nrOfLayers; - ps->num_dmrs_cdm_grps_no_data = BWP->transform_precoding ? num_dmrs_cdm_grps_no_data : 2; + // TODO setting of cdm groups with no data to be redone for MIMO + if (BWP->transform_precoding || nrOfLayers<3) + ps->num_dmrs_cdm_grps_no_data = (BWP->dci_format == NR_UL_DCI_FORMAT_0_1) ? 1 : (ps->nrOfSymbols == 2 ? 1 : 2); + else + ps->num_dmrs_cdm_grps_no_data = 2; /* DMRS calculations */ ps->mapping_type = BWP->tdaList->list.array[tda]->mappingType; @@ -639,8 +640,8 @@ void nr_set_pusch_semi_static(const NR_UE_UL_BWP_t *BWP, num_dmrs_symb += (ps->ul_dmrs_symb_pos >> i) & 1; ps->num_dmrs_symb = num_dmrs_symb; ps->N_PRB_DMRS = ps->dmrs_config_type == 0 - ? num_dmrs_cdm_grps_no_data * 6 - : num_dmrs_cdm_grps_no_data * 4; + ? ps->num_dmrs_cdm_grps_no_data * 6 + : ps->num_dmrs_cdm_grps_no_data * 4; } #define BLER_UPDATE_FRAME 10 @@ -907,14 +908,11 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, } void config_uldci(const NR_SIB1_t *sib1, - const NR_BWP_Uplink_t *ubwp, - const NR_BWP_UplinkDedicated_t *ubwpd, const NR_ServingCellConfigCommon_t *scc, const nfapi_nr_pusch_pdu_t *pusch_pdu, dci_pdu_rel15_t *dci_pdu_rel15, int time_domain_assignment, uint8_t tpc, - int n_ubwp, NR_UE_UL_BWP_t *UBWP) { int bwp_id = UBWP->bwp_id; @@ -941,7 +939,7 @@ void config_uldci(const NR_SIB1_t *sib1, LOG_D(NR_MAC,"Configuring DCI Format 0_1\n"); dci_pdu_rel15->dai[0].val = 0; //TODO // bwp indicator as per table 7.3.1.1.2-1 in 38.212 - dci_pdu_rel15->bwp_indicator.val = n_ubwp < 4 ? bwp_id : bwp_id - 1; + dci_pdu_rel15->bwp_indicator.val = UBWP->n_ul_bwp < 4 ? bwp_id : bwp_id - 1; // SRS resource indicator if (pusch_Config && pusch_Config->txConfig != NULL) { @@ -1033,11 +1031,10 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, } int nr_get_pucch_resource(NR_ControlResourceSet_t *coreset, - NR_BWP_Uplink_t *bwp, - NR_BWP_UplinkDedicated_t *bwpd, + NR_PUCCH_Config_t *pucch_Config, int CCEIndex) { int r_pucch = -1; - if(bwp == NULL && bwpd == NULL) { + if(pucch_Config == NULL) { int n_rb,rb_offset; get_coreset_rballoc(coreset->frequencyDomainResources.buf,&n_rb,&rb_offset); const uint16_t N_cce = n_rb * coreset->duration / NR_NB_REG_PER_CCE; @@ -1048,23 +1045,19 @@ int nr_get_pucch_resource(NR_ControlResourceSet_t *coreset, } // This function configures pucch pdu fapi structure -void nr_configure_pucch(const NR_SIB1_t *sib1, - nfapi_nr_pucch_pdu_t* pucch_pdu, +void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, NR_ServingCellConfigCommon_t *scc, NR_UE_info_t* UE, - NR_BWP_UplinkDedicated_t *bwpd, uint8_t pucch_resource, uint16_t O_csi, uint16_t O_ack, uint8_t O_sr, int r_pucch) { - NR_PUCCH_Config_t *pucch_Config; NR_PUCCH_Resource_t *pucchres; NR_PUCCH_ResourceSet_t *pucchresset; NR_PUCCH_FormatConfig_t *pucchfmt; NR_PUCCH_ResourceId_t *resource_id = NULL; - NR_BWP_Uplink_t *bwp = UE->UE_sched_ctrl.active_ubwp; NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; long *id0 = NULL; @@ -1087,14 +1080,7 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->transformPrecodingDisabled->scramblingID0; else id0 = scc->physCellId; - NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon = NULL; - if(bwp) { - pucch_ConfigCommon = bwp->bwp_Common->pucch_ConfigCommon->choice.setup; - } else if(scc) { - pucch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup; - } else { - pucch_ConfigCommon = sib1->servingCellConfigCommon->uplinkConfigCommon->initialUplinkBWP.pucch_ConfigCommon->choice.setup; - } + NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon = BWP->pucch_ConfigCommon; // hop flags and hopping id are valid for any BWP switch (pucch_ConfigCommon->pucch_GroupHopping){ @@ -1126,12 +1112,10 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, pucch_pdu->bwp_start = BWP->BWPStart; pucch_pdu->subcarrier_spacing = BWP->scs; pucch_pdu->cyclic_prefix = (BWP->cyclicprefix==NULL) ? 0 : *BWP->cyclicprefix; - if (r_pucch<0 || bwp ){ + + NR_PUCCH_Config_t *pucch_Config = BWP->pucch_Config; + if (r_pucch<0 || pucch_Config){ LOG_D(NR_MAC,"pucch_acknak: Filling dedicated configuration for PUCCH\n"); - // we have either a dedicated BWP or Dedicated PUCCH configuration on InitialBWP - AssertFatal(bwp!=NULL || bwpd!=NULL,"We need one dedicated configuration for a BWP (neither additional or initial BWP has a dedicated configuration)\n"); - pucch_Config = bwp && bwp->bwp_Dedicated && bwp->bwp_Dedicated->pucch_Config ? - bwp->bwp_Dedicated->pucch_Config->choice.setup : bwpd->pucch_Config->choice.setup; AssertFatal(pucch_Config->resourceSetToAddModList!=NULL, "PUCCH resourceSetToAddModList is null\n"); @@ -1273,8 +1257,8 @@ void nr_configure_pucch(const NR_SIB1_t *sib1, LOG_D(NR_MAC,"Configure pucch: pucch_pdu->format_type %d pucch_pdu->bit_len_harq %d, pucch->pdu->bit_len_csi %d\n",pucch_pdu->format_type,pucch_pdu->bit_len_harq,pucch_pdu->bit_len_csi_part1); } else { // this is the default PUCCH configuration, PUCCH format 0 or 1 - LOG_D(NR_MAC,"pucch_acknak: Filling default PUCCH configuration from Tables (r_pucch %d, bwp %p)\n",r_pucch,bwp); - int rsetindex = *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon; + LOG_D(NR_MAC,"pucch_acknak: Filling default PUCCH configuration from Tables (r_pucch %d, pucch_Config %p)\n",r_pucch,pucch_Config); + int rsetindex = *pucch_ConfigCommon->pucch_ResourceCommon; int prb_start, second_hop_prb, nr_of_symb, start_symb; set_r_pucch_parms(rsetindex, r_pucch, @@ -2271,8 +2255,11 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, NR_BWP_Uplink_t *ul_bwp = NULL; NR_BWP_DownlinkDedicated_t *bwpd = NULL; NR_BWP_UplinkDedicated_t *ubwpd = NULL; + NR_CSI_MeasConfig_t *csi_MeasConfig = NULL; DL_BWP->n_dl_bwp = 1; + UL_BWP->n_ul_bwp = 1; int old_dl_bwp_id = DL_BWP->bwp_id; + int old_ul_bwp_id = UL_BWP->bwp_id; int target_ss; @@ -2281,6 +2268,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, CellGroup->spCellConfig->spCellConfigDedicated) { const NR_ServingCellConfig_t *servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; + csi_MeasConfig = servingCellConfig->csi_MeasConfig ? servingCellConfig->csi_MeasConfig->choice.setup : NULL; target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; // (re)configuring BWP @@ -2304,6 +2292,8 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, } const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList; + if(ubwpList) + UL_BWP->n_ul_bwp = ubwpList->list.count; if (UL_BWP->bwp_id>0) { for (int i=0; ilist.count; i++) { ul_bwp = ubwpList->list.array[i]; @@ -2325,6 +2315,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, DL_BWP->pdsch_Config = bwpd->pdsch_Config->choice.setup; UL_BWP->pusch_Config = ubwpd->pusch_Config->choice.setup; + UL_BWP->pucch_Config = ubwpd->pucch_Config->choice.setup; } else { DL_BWP->bwp_id = 0; @@ -2332,10 +2323,13 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, target_ss = NR_SearchSpace__searchSpaceType_PR_common; DL_BWP->pdsch_Config = NULL; UL_BWP->pusch_Config = NULL; + UL_BWP->pucch_Config = NULL; } if (old_dl_bwp_id != DL_BWP->bwp_id) LOG_I(NR_MAC, "Switching to DL-BWP %li\n", DL_BWP->bwp_id); + if (old_ul_bwp_id != UL_BWP->bwp_id) + LOG_I(NR_MAC, "Switching to UL-BWP %li\n", UL_BWP->bwp_id); // TDA lists if (DL_BWP->bwp_id>0) @@ -2383,6 +2377,12 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, else UL_BWP->transform_precoding = *UL_BWP->pusch_Config->transformPrecoder; + if(UL_BWP->bwp_id>0) + UL_BWP->pucch_ConfigCommon = ul_bwp->bwp_Common->pucch_ConfigCommon->choice.setup; + else + UL_BWP->pucch_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup; + + if(UE) { // setting PDCCH related structures for sched_ctrl sched_ctrl->search_space = get_searchspace(scc, @@ -2408,6 +2408,9 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0) : NR_UL_DCI_FORMAT_0_0; + if (csi_MeasConfig) + compute_csi_bitlen (csi_MeasConfig, UE); + } if(ra) { @@ -2480,13 +2483,6 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf else UE->Msg4_ACKed = false; - if (CellGroup && - CellGroup->spCellConfig && - CellGroup->spCellConfig->spCellConfigDedicated && - CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig && - CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup) - compute_csi_bitlen (CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE); - NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; memset(sched_ctrl, 0, sizeof(*sched_ctrl)); sched_ctrl->dl_max_mcs = 28; /* do not limit MCS for individual UEs */ @@ -2523,8 +2519,6 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf "uplinkBWP_ToAddModList has %d BWP!\n", ubwpList->list.count); - sched_ctrl->active_ubwp = ubwpList && UL_BWP->bwp_id > 0 ? ubwpList->list.array[UL_BWP->bwp_id - 1] : NULL; - /* get Number of HARQ processes for this UE */ if (servingCellConfig) AssertFatal(servingCellConfig->pdsch_ServingCellConfig->present == NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup, @@ -2648,7 +2642,6 @@ void get_pdsch_to_harq_feedback(NR_UE_info_t *UE, NR_CellGroupConfig_t *CellGroup = UE->CellGroup; NR_BWP_DownlinkDedicated_t *bwpd=NULL; - NR_BWP_UplinkDedicated_t *ubwpd=NULL; int dl_bwp_id = UE->current_DL_BWP.bwp_id; int ul_bwp_id = UE->current_UL_BWP.bwp_id; @@ -2670,13 +2663,10 @@ void get_pdsch_to_harq_feedback(NR_UE_info_t *UE, CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count,ul_bwp_id); bwpd = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[dl_bwp_id-1]->bwp_Dedicated; - ubwpd = CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ul_bwp_id-1]->bwp_Dedicated; } else if (CellGroup && CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated) { // this is an initialBWP AssertFatal((bwpd=CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)!=NULL, "CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP is null\n"); - AssertFatal((ubwpd=CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP)!=NULL, - "CellGroup->spCellConfig->spCellConfigDedicated->uplnikConfig->initialUplinkBWP is null\n"); } NR_SearchSpace_t *ss=NULL; @@ -2714,10 +2704,11 @@ void get_pdsch_to_harq_feedback(NR_UE_info_t *UE, } } else { - AssertFatal(ubwpd!=NULL,"ubwpd shouldn't be null here\n"); - if(ubwpd->pucch_Config->choice.setup->dl_DataToUL_ACK != NULL) { + NR_PUCCH_Config_t *pucch_Config = UE->current_UL_BWP.pucch_Config; + AssertFatal(pucch_Config!=NULL,"pucch_Config shouldn't be null here\n"); + if(pucch_Config->dl_DataToUL_ACK != NULL) { for (int i=0; i<8; i++) { - pdsch_to_harq_feedback[i] = *ubwpd->pucch_Config->choice.setup->dl_DataToUL_ACK->list.array[i]; + pdsch_to_harq_feedback[i] = *pucch_Config->dl_DataToUL_ACK->list.array[i]; if(pdsch_to_harq_feedback[i]>*max_fb_time) *max_fb_time = pdsch_to_harq_feedback[i]; } @@ -2981,28 +2972,10 @@ void nr_mac_update_timers(module_id_t module_id, create_dl_harq_list(sched_ctrl, pdsch); } - // If needed, update the Dedicated BWP - if (spCellConfigDedicated->uplinkConfig && - spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) { - sched_ctrl->active_ubwp = spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[*spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id - 1]; - if (*spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id != UE->current_UL_BWP.bwp_id) { - LOG_I(NR_MAC, "Changing to UL-BWP %li\n", sched_ctrl->active_ubwp->bwp_Id); - } - } - configure_UE_BWP(RC.nrmac[module_id], scc, sched_ctrl, NULL, UE); // Update coreset/searchspace - sched_ctrl->maxL = 2; - if (cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig && - cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup) { - compute_csi_bitlen (cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE); - } - NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; const uint8_t layers = set_dl_nrOfLayers(sched_ctrl); const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); @@ -3015,28 +2988,14 @@ void nr_mac_update_timers(module_id_t module_id, sched_ctrl, ps); - NR_BWP_Uplink_t *ubwp = sched_ctrl->active_ubwp; - NR_BWP_UplinkDedicated_t *ubwpd = NULL; - if (ubwp) { - ubwpd = sched_ctrl->active_ubwp->bwp_Dedicated; - } else if (cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - (cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)) { - ubwpd = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; - } NR_pusch_semi_static_t *ups = &sched_ctrl->pusch_semi_static; - const uint8_t num_dmrs_cdm_grps_no_data = (ubwp || ubwpd) ? 1 : 2; const uint8_t nrOfLayers = 1; const int utda = get_ul_tda(RC.nrmac[module_id], scc, slot); nr_set_pusch_semi_static(&UE->current_UL_BWP, scc, - ubwp, - ubwpd, utda, - num_dmrs_cdm_grps_no_data, nrOfLayers, ups); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 559b3cb988..2065dff90a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -80,21 +80,13 @@ static void nr_fill_nfapi_pucch(gNB_MAC_INST *nrmac, pucch->resource_indicator); NR_COMMON_channels_t * common_ch=nrmac->common_channels; NR_ServingCellConfigCommon_t *scc = common_ch->ServingCellConfigCommon; - NR_CellGroupConfig_t *cg=UE->CellGroup; - NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; + LOG_D(NR_MAC,"%4d.%2d Calling nr_configure_pucch (pucch_Config %p,r_pucch %d) pucch to be scheduled in %4d.%2d\n", + frame,slot,UE->current_UL_BWP.pucch_Config,pucch->r_pucch,pucch->frame,pucch->ul_slot); - LOG_D(NR_MAC,"%4d.%2d Calling nr_configure_pucch (ubwpd %p,r_pucch %d) pucch to be scheduled in %4d.%2d\n", - frame,slot,ubwpd,pucch->r_pucch,pucch->frame,pucch->ul_slot); - - const NR_SIB1_t *sib1 = common_ch->sib1 ? common_ch->sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - nr_configure_pucch(sib1, - pucch_pdu, + nr_configure_pucch(pucch_pdu, scc, UE, - ubwpd, pucch->resource_indicator, pucch->csi_bits, pucch->dai_c, @@ -708,17 +700,7 @@ void nr_csi_meas_reporting(int Mod_idP, const NR_CSI_MeasConfig_t *csi_measconfig = CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; AssertFatal(csi_measconfig->csi_ReportConfigToAddModList->list.count > 0, "NO CSI report configuration available"); - NR_PUCCH_Config_t *pucch_Config = NULL; - if (sched_ctrl->active_ubwp) { - pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; - } else if (CellGroup && - CellGroup->spCellConfig && - CellGroup->spCellConfig->spCellConfigDedicated && - CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig && - CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { - pucch_Config = CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; - } + NR_PUCCH_Config_t *pucch_Config = UL_BWP->pucch_Config; for (int csi_report_id = 0; csi_report_id < csi_measconfig->csi_ReportConfigToAddModList->list.count; csi_report_id++){ NR_CSI_ReportConfig_t *csirep = csi_measconfig->csi_ReportConfigToAddModList->list.array[csi_report_id]; @@ -1617,18 +1599,7 @@ int nr_acknack_scheduling(int mod_id, * later) * * each UE has dedicated PUCCH Format 0 resources, and we use index 0! */ NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_CellGroupConfig_t *cg = UE->CellGroup; - - NR_PUCCH_Config_t *pucch_Config = NULL; - if (sched_ctrl->active_ubwp) { - pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; - } else if (cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { - pucch_Config = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; - } + NR_PUCCH_Config_t *pucch_Config = BWP->pucch_Config; int bwp_start = BWP->BWPStart; int bwp_size = BWP->BWPSize; @@ -1881,21 +1852,10 @@ void nr_sr_reporting(gNB_MAC_INST *nrmac, frame_t SFN, sub_frame_t slot) NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; const int n_slots_frame = nr_slots_per_frame[BWP->scs]; if (sched_ctrl->ul_failure==1) continue; - NR_PUCCH_Config_t *pucch_Config = NULL; - if (sched_ctrl->active_ubwp) { - pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; - } else if (UE->CellGroup && - UE->CellGroup->spCellConfig && - UE->CellGroup->spCellConfig->spCellConfigDedicated && - UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig && - UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { - pucch_Config = UE->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; - } + NR_PUCCH_Config_t *pucch_Config = BWP->pucch_Config; - else continue; - if (!pucch_Config->schedulingRequestResourceToAddModList) - continue; + if (!pucch_Config || !pucch_Config->schedulingRequestResourceToAddModList) + continue; AssertFatal(pucch_Config->schedulingRequestResourceToAddModList->list.count>0,"NO SR configuration available"); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index eb23775a24..c3c7529b4e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -822,32 +822,22 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, const int CC_id = 0; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_sched_pusch_t *retInfo = &sched_ctrl->ul_harq_processes[harq_pid].sched_pusch; - NR_CellGroupConfig_t *cg = UE->CellGroup; - - NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; int rbStart = 0; // wrt BWP start const uint16_t bwpSize = UE->current_UL_BWP.BWPSize; const uint8_t nrOfLayers = 1; - const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; LOG_D(NR_MAC,"retInfo->time_domain_allocation = %d, tda = %d\n", retInfo->time_domain_allocation, tda); - LOG_D(NR_MAC,"num_dmrs_cdm_grps_no_data %d, tbs %d\n",num_dmrs_cdm_grps_no_data, retInfo->tb_size); + LOG_D(NR_MAC,"tbs %d\n",retInfo->tb_size); if (tda == retInfo->time_domain_allocation) { /* check whether we need to switch the TDA allocation since tha last * (re-)transmission */ NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; if (ps->time_domain_allocation != tda - || ps->nrOfLayers != nrOfLayers - || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) { + || ps->nrOfLayers != nrOfLayers) { nr_set_pusch_semi_static(&UE->current_UL_BWP, scc, - sched_ctrl->active_ubwp, - ubwpd, tda, - num_dmrs_cdm_grps_no_data, nrOfLayers, ps); } @@ -865,10 +855,7 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, NR_pusch_semi_static_t temp_ps; nr_set_pusch_semi_static(&UE->current_UL_BWP, scc, - sched_ctrl->active_ubwp, - ubwpd, tda, - num_dmrs_cdm_grps_no_data, nrOfLayers, &temp_ps); /* the retransmission will use a different time domain allocation, check @@ -1016,10 +1003,6 @@ void pf_ul(module_id_t module_id, NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; int rbStart = 0; // wrt BWP start - NR_CellGroupConfig_t *cg = UE->CellGroup; - NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; const uint16_t bwpSize = BWP->BWPSize; NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; @@ -1106,17 +1089,12 @@ void pf_ul(module_id_t module_id, * every TTI if we can save it, so check whether TDA, or * num_dmrs_cdm_grps_no_data has changed and only then recompute */ const uint8_t nrOfLayers = 1; - const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; const int tda = get_ul_tda(nrmac, scc, sched_pusch->slot); if (ps->time_domain_allocation != tda - || ps->nrOfLayers != nrOfLayers - || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) { + || ps->nrOfLayers != nrOfLayers) { nr_set_pusch_semi_static(BWP, scc, - sched_ctrl->active_ubwp, - ubwpd, tda, - num_dmrs_cdm_grps_no_data, nrOfLayers, ps); } @@ -1209,13 +1187,7 @@ void pf_ul(module_id_t module_id, else LOG_D(NR_MAC, "%4d.%2d free CCE for UL DCI UE %04x\n",frame,slot, iterator->UE->rnti); NR_UE_UL_BWP_t *BWP = &iterator->UE->current_UL_BWP; - NR_CellGroupConfig_t *cg = iterator->UE->CellGroup; - NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated - && cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - - int rbStart = sched_ctrl->active_ubwp ? BWP->BWPStart : 0; const uint16_t bwpSize = BWP->BWPSize; NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; @@ -1225,22 +1197,18 @@ void pf_ul(module_id_t module_id, * every TTI if we can save it, so check whether TDA, or * num_dmrs_cdm_grps_no_data has changed and only then recompute */ const uint8_t nrOfLayers = 1; - const uint8_t num_dmrs_cdm_grps_no_data = (sched_ctrl->active_ubwp || ubwpd) ? 1 : 2; const int tda = get_ul_tda(nrmac, scc, sched_pusch->slot); if (ps->time_domain_allocation != tda - || ps->nrOfLayers != nrOfLayers - || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) { + || ps->nrOfLayers != nrOfLayers) { nr_set_pusch_semi_static(BWP, scc, - sched_ctrl->active_ubwp, - ubwpd, tda, - num_dmrs_cdm_grps_no_data, nrOfLayers, ps); } update_ul_ue_R_Qm(sched_pusch, BWP->pusch_Config, BWP->mcs_table); + int rbStart = 0; const uint16_t slbitmap = SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); while (rbStart < bwpSize && (rballoc_mask[rbStart] & slbitmap) != slbitmap) rbStart++; @@ -1340,7 +1308,7 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t is_xlsch_in_slot(nr_mac->ulsch_slot_bitmap[sched_slot / 64], sched_slot); // FIXME: Avoid mixed slots for initialUplinkBWP - if (sched_ctrl->active_ubwp==NULL && is_mixed_slot) + if (BWP->bwp_id==0 && is_mixed_slot) return false; // Avoid slots with the SRS @@ -1473,10 +1441,6 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) NR_CellGroupConfig_t *cg = UE->CellGroup; NR_UE_UL_BWP_t *current_BWP = &UE->current_UL_BWP; - NR_BWP_UplinkDedicated_t *ubwpd = cg && cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig ? - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP : NULL; - UE->mac_stats.ul.current_bytes = 0; /* dynamic PUSCH values (RB alloc, MCS, hence R, Qm, TBS) that change in @@ -1744,24 +1708,13 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) dci_pdu_rel15_t uldci_payload; memset(&uldci_payload, 0, sizeof(uldci_payload)); - int n_ubwp=1; - if (cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) { - n_ubwp = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count; - } config_uldci(sib1, - sched_ctrl->active_ubwp, - ubwpd, scc, pusch_pdu, &uldci_payload, ps->time_domain_allocation, UE->UE_sched_ctrl.tpc0, - n_ubwp, current_BWP); fill_dci_pdu_rel15(scc, cg, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index bc145b6dd9..3a20147f2b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -134,7 +134,6 @@ int nr_allocate_CCEs(int module_idP, int CC_idP, frame_t frameP, sub_frame_t slo void nr_get_Msg3alloc(module_id_t module_id, int CC_id, NR_ServingCellConfigCommon_t *scc, - NR_BWP_Uplink_t *ubwp, sub_frame_t current_subframe, frame_t current_frame, NR_RA_t *ra, @@ -192,14 +191,11 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, void config_uldci(const NR_SIB1_t *sib1, - const NR_BWP_Uplink_t *ubwp, - const NR_BWP_UplinkDedicated_t *ubwpd, const NR_ServingCellConfigCommon_t *scc, const nfapi_nr_pusch_pdu_t *pusch_pdu, dci_pdu_rel15_t *dci_pdu_rel15, int time_domain_assignment, uint8_t tpc, - int n_ubwp, NR_UE_UL_BWP_t *BWP); void nr_schedule_pucch(gNB_MAC_INST* nrmac, @@ -249,15 +245,12 @@ int nr_is_dci_opportunity(nfapi_nr_search_space_t search_space, */ int nr_get_pucch_resource(NR_ControlResourceSet_t *coreset, - NR_BWP_Uplink_t *bwp, - NR_BWP_UplinkDedicated_t *bwpd, + NR_PUCCH_Config_t *pucch_Config, int CCEIndex); -void nr_configure_pucch(const NR_SIB1_t *sib1, - nfapi_nr_pucch_pdu_t* pucch_pdu, +void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, NR_ServingCellConfigCommon_t *scc, NR_UE_info_t* UE, - NR_BWP_UplinkDedicated_t *bwpd, uint8_t pucch_resource, uint16_t O_csi, uint16_t O_ack, @@ -346,10 +339,7 @@ void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *BWP, void nr_set_pusch_semi_static(const NR_UE_UL_BWP_t *BWP, const NR_ServingCellConfigCommon_t *scc, - const NR_BWP_Uplink_t *ubwp, - const NR_BWP_UplinkDedicated_t *ubwpd, int tda, - uint8_t num_dmrs_cdm_grps_no_data, uint8_t nrOfLayers, NR_pusch_semi_static_t *ps); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index ca239ee51e..a8ebde347e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -105,12 +105,15 @@ typedef struct NR_UE_DL_BWP { 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; NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList; NR_PUSCH_Config_t *pusch_Config; + NR_PUCCH_Config_t *pucch_Config; + NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon; uint8_t transform_precoding; uint8_t mcs_table; nr_dci_format_t dci_format; @@ -581,9 +584,6 @@ typedef struct NR_UE_ul_harq { /*! \brief scheduling control information set through an API */ #define MAX_CSI_REPORTS 48 typedef struct { - /// the currently active BWP in UL - NR_BWP_Uplink_t *active_ubwp; - /// the next active BWP ID in DL NR_BWP_Id_t next_dl_bwp_id; /// the next active BWP ID in UL @@ -598,8 +598,6 @@ typedef struct { /// corresponding to the sched_pusch/sched_pdsch structures below int cce_index; uint8_t aggregation_level; - /// maximum aggregation level for UE, can be used to select level - int maxL; /// PUCCH scheduling information. Array of two: HARQ+SR in the first field, /// CSI in second. This order is important for nr_acknack_scheduling()! NR_sched_pucch_t sched_pucch[2]; From 633370ffc378b4eb4a2ee8d78b2ebf6e77083a89 Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 17 Jun 2022 18:50:06 +0200 Subject: [PATCH 10/16] further MAC cleanup with BWPs --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 6 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 11 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 146 ++++-------------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 10 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 2 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 10 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 2 + 8 files changed, 52 insertions(+), 137 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 6e2af05a13..28cc105561 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -844,7 +844,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t NR_RNTI_TC, pusch_pdu->bwp_size, UL_BWP->bwp_id, - coresetid, + coreset, nr_mac->cset0_bwp_size); // Mark the corresponding RBs as used @@ -1376,7 +1376,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_RNTI_RA, BWPSize, DL_BWP->bwp_id, - coresetid, + coreset, nr_mac->cset0_bwp_size); // DL TX request @@ -1770,7 +1770,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_RNTI_TC, pdsch_pdu_rel15->BWPSize, DL_BWP->bwp_id, - coresetid, + coreset, nr_mac->cset0_bwp_size); // Add padding header and zero rest out if there is space left diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index a06c3f06ed..1cda0f4898 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -553,7 +553,7 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, rnti_type, pdsch_pdu_rel15->BWPSize, 0, - 0, + gNB_mac->sched_ctrlCommon->coreset, gNB_mac->cset0_bwp_size); LOG_D(MAC,"BWPSize: %i\n", pdcch_pdu_rel15->BWPSize); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 079bc3da40..cb26b1da9a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -948,8 +948,6 @@ void nr_schedule_ue_spec(module_id_t module_id, sched_pdsch->pucch_allocation, sched_ctrl->tpc1); - NR_SearchSpace_t *ss = sched_ctrl->search_space; - const int bwp_id = current_BWP->bwp_id; const int coresetid = sched_ctrl->coreset->controlResourceSetId; @@ -1037,7 +1035,7 @@ void nr_schedule_ue_spec(module_id_t module_id, csi_report->codebook_mode); } // TBS_LBRM according to section 5.4.2.1 of 38.212 - long *maxMIMO_Layers = cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers; + long *maxMIMO_Layers = current_BWP->pdsch_servingcellconfig->ext1->maxMIMO_Layers; AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n"); int nl_tbslbrm = *maxMIMO_Layers < 4 ? *maxMIMO_Layers : 4; // Maximum number of PRBs across all configured DL BWPs @@ -1134,20 +1132,17 @@ void nr_schedule_ue_spec(module_id_t module_id, dci_payload.tpc, pucch->timing_indicator); - int dci_format = ss && ss->searchSpaceType && ss->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific ? - NR_DL_DCI_FORMAT_1_1 : NR_DL_DCI_FORMAT_1_0; - const int rnti_type = NR_RNTI_C; fill_dci_pdu_rel15(scc, cg, current_BWP, dci_pdu, &dci_payload, - dci_format, + current_BWP->dci_format, rnti_type, pdsch_pdu->BWPSize, bwp_id, - coresetid, + sched_ctrl->coreset, gNB_mac->cset0_bwp_size); LOG_D(NR_MAC, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index ab17aebc6e..492abdc200 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -556,17 +556,7 @@ void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *BWP, const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &ps->startSymbolIndex, &ps->nrOfSymbols); - const long f = sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific ? - sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0; - - int dci_format; - if (sched_ctrl->search_space) { - dci_format = f ? NR_DL_DCI_FORMAT_1_1 : NR_DL_DCI_FORMAT_1_0; - } - else { - dci_format = NR_DL_DCI_FORMAT_1_0; - } - if (dci_format == NR_DL_DCI_FORMAT_1_0) { + if (BWP->dci_format == NR_DL_DCI_FORMAT_1_0) { if (ps->nrOfSymbols == 2) ps->numDmrsCdmGrpsNoData = 1; else @@ -1314,23 +1304,12 @@ void set_r_pucch_parms(int rsetindex, void prepare_dci(const NR_CellGroupConfig_t *CellGroup, const NR_UE_DL_BWP_t *BWP, + const NR_ControlResourceSet_t *coreset, dci_pdu_rel15_t *dci_pdu_rel15, - nr_dci_format_t format, - int bwp_id) { + nr_dci_format_t format) { AssertFatal(CellGroup!=NULL,"CellGroup shouldn't be null here\n"); - const NR_PDCCH_Config_t *pdcch_Config = NULL; - - const NR_BWP_DownlinkDedicated_t *bwpd = NULL; - if (bwp_id>0) { - bwpd=CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]->bwp_Dedicated; - } - else { - bwpd=CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; - } - pdcch_Config = (bwpd->pdcch_Config) ? bwpd->pdcch_Config->choice.setup : NULL; - const NR_PDSCH_Config_t *pdsch_Config = BWP ? BWP->pdsch_Config : NULL; switch(format) { @@ -1369,7 +1348,7 @@ void prepare_dci(const NR_CellGroupConfig_t *CellGroup, if (pdsch_Config->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList != NULL) AssertFatal(1==0,"Aperiodic ZP CSI-RS currently not supported\n"); // transmission configuration indication - if (pdcch_Config->controlResourceSetToAddModList->list.array[0]->tci_PresentInDCI != NULL) + if (coreset->tci_PresentInDCI != NULL) AssertFatal(1==0,"TCI in DCI currently not supported\n"); //srs resource set if (CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->carrierSwitching!=NULL) { @@ -1393,9 +1372,8 @@ void prepare_dci(const NR_CellGroupConfig_t *CellGroup, else dci_pdu_rel15->srs_request.val = 0; // CBGTI and CBGFI - if (CellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig && - CellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup && - CellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) + if (BWP->pdsch_servingcellconfig && + BWP->pdsch_servingcellconfig->codeBlockGroupTransmission != NULL) AssertFatal(1==0,"CBG transmission currently not supported\n"); break; default : @@ -1413,12 +1391,13 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, int rnti_type, int N_RB, int bwp_id, - NR_ControlResourceSetId_t coreset_id, + NR_ControlResourceSet_t *coreset, 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; int dci_size = nr_dci_size(scc->downlinkConfigCommon->initialDownlinkBWP, scc->uplinkConfigCommon->initialUplinkBWP, CellGroup, dci_pdu_rel15, dci_format, @@ -1426,7 +1405,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, 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, BWP, dci_pdu_rel15, dci_format, bwp_id); + prepare_dci(CellGroup, BWP, coreset, dci_pdu_rel15, dci_format); /// Payload generation switch (dci_format) { @@ -2268,6 +2247,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, CellGroup->spCellConfig->spCellConfigDedicated) { const NR_ServingCellConfig_t *servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; + DL_BWP->pdsch_servingcellconfig = servingCellConfig->pdsch_ServingCellConfig? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; csi_MeasConfig = servingCellConfig->csi_MeasConfig ? servingCellConfig->csi_MeasConfig->choice.setup : NULL; target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; @@ -2401,6 +2381,12 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, &dl_genericParameters, nr_mac->type0_PDCCH_CSS_config); + // set DL DCI format + DL_BWP->dci_format = (sched_ctrl->search_space->searchSpaceType && + sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) ? + (sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1 ? + NR_DL_DCI_FORMAT_1_1 : NR_DL_DCI_FORMAT_1_0) : + NR_DL_DCI_FORMAT_1_0; // set UL DCI format UL_BWP->dci_format = (sched_ctrl->search_space->searchSpaceType && sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) ? @@ -2441,6 +2427,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]); UL_BWP->dci_format = NR_UL_DCI_FORMAT_0_0; + DL_BWP->dci_format = NR_DL_DCI_FORMAT_1_0; } // Set uplink MCS table @@ -2508,25 +2495,17 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf /* set illegal time domain allocation to force recomputation of all fields */ sched_ctrl->pdsch_semi_static.time_domain_allocation = -1; sched_ctrl->pusch_semi_static.time_domain_allocation = -1; - const NR_ServingCellConfig_t *servingCellConfig = CellGroup && CellGroup->spCellConfig ? CellGroup->spCellConfig->spCellConfigDedicated : NULL; /* Set default BWPs */ sched_ctrl->next_dl_bwp_id = -1; sched_ctrl->next_ul_bwp_id = -1; - const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig ? servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList : NULL; - if (ubwpList) - AssertFatal(ubwpList->list.count <= NR_MAX_NUM_BWP, - "uplinkBWP_ToAddModList has %d BWP!\n", - ubwpList->list.count); + AssertFatal(UL_BWP->n_ul_bwp <= NR_MAX_NUM_BWP, + "uplinkBWP_ToAddModList has %d BWP!\n", + UL_BWP->n_ul_bwp); /* get Number of HARQ processes for this UE */ - if (servingCellConfig) - AssertFatal(servingCellConfig->pdsch_ServingCellConfig->present == NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup, - "no pdsch-ServingCellConfig found for UE %04x\n", - UE->rnti); - const NR_PDSCH_ServingCellConfig_t *pdsch = servingCellConfig ? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; - // pdsch == NULL in SA -> will create default (8) number of HARQ processes - create_dl_harq_list(sched_ctrl, pdsch); + // pdsch_servingcellconfig == NULL in SA -> will create default (8) number of HARQ processes + create_dl_harq_list(sched_ctrl, DL_BWP->pdsch_servingcellconfig); // add all available UL HARQ processes for this UE // nb of ul harq processes not configurable create_nr_list(&sched_ctrl->available_ul_harq, 16); @@ -2635,43 +2614,12 @@ uint8_t nr_get_tpc(int target, uint8_t cqi, int incr) { } -void get_pdsch_to_harq_feedback(NR_UE_info_t *UE, - NR_SearchSpace__searchSpaceType_PR ss_type, +void get_pdsch_to_harq_feedback(NR_PUCCH_Config_t *pucch_Config, + nr_dci_format_t dci_format, int *max_fb_time, uint8_t *pdsch_to_harq_feedback) { - NR_CellGroupConfig_t *CellGroup = UE->CellGroup; - NR_BWP_DownlinkDedicated_t *bwpd=NULL; - int dl_bwp_id = UE->current_DL_BWP.bwp_id; - int ul_bwp_id = UE->current_UL_BWP.bwp_id; - - if (ss_type == NR_SearchSpace__searchSpaceType_PR_ue_Specific) { - AssertFatal(CellGroup!=NULL,"Cellgroup is not defined for UE %04x\n",UE->rnti); - AssertFatal(CellGroup->spCellConfig!=NULL,"Cellgroup->spCellConfig is null\n"); - AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated!=NULL,"CellGroup->spCellConfig->spCellConfigDedicated is null\n"); - } - if (dl_bwp_id>0 && ul_bwp_id>0) { - AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList!=NULL, - "CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList is null\n"); - AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList!=NULL, - "CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList is null\n"); - AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count >= dl_bwp_id, - "CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count %d < bwp_id %d\n", - CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count,dl_bwp_id); - AssertFatal(CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count >= ul_bwp_id, - "CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count %d < bwp_id %d\n", - CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count,ul_bwp_id); - - bwpd = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[dl_bwp_id-1]->bwp_Dedicated; - } - else if (CellGroup && CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated) { // this is an initialBWP - AssertFatal((bwpd=CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP)!=NULL, - "CellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP is null\n"); - } - NR_SearchSpace_t *ss=NULL; - - // common search type uses DCI format 1_0 - if (ss_type == NR_SearchSpace__searchSpaceType_PR_common) { + if (dci_format == NR_DL_DCI_FORMAT_1_0) { for (int i=0; i<8; i++) { pdsch_to_harq_feedback[i] = i+1; if(pdsch_to_harq_feedback[i]>*max_fb_time) @@ -2679,43 +2627,16 @@ void get_pdsch_to_harq_feedback(NR_UE_info_t *UE, } } else { - - // searching for a ue specific search space - int found=0; - AssertFatal(bwpd->pdcch_Config!=NULL,"bwpd->pdcch_Config is null\n"); - AssertFatal(bwpd->pdcch_Config->choice.setup->searchSpacesToAddModList!=NULL, - "bwpd->pdcch_Config->choice.setup->searchSpacesToAddModList is null\n"); - for (int i=0;ipdcch_Config->choice.setup->searchSpacesToAddModList->list.count;i++) { - ss=bwpd->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i]; - AssertFatal(ss->controlResourceSetId != NULL,"ss->controlResourceSetId is null\n"); - AssertFatal(ss->searchSpaceType != NULL,"ss->searchSpaceType is null\n"); - if (ss->searchSpaceType->present == ss_type) { - found=1; - break; - } - } - AssertFatal(found==1,"Couldn't find a ue specific searchspace\n"); - - if (ss->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_0_And_1_0) { + AssertFatal(pucch_Config!=NULL,"pucch_Config shouldn't be null here\n"); + if(pucch_Config->dl_DataToUL_ACK != NULL) { for (int i=0; i<8; i++) { - pdsch_to_harq_feedback[i] = i+1; + pdsch_to_harq_feedback[i] = *pucch_Config->dl_DataToUL_ACK->list.array[i]; if(pdsch_to_harq_feedback[i]>*max_fb_time) *max_fb_time = pdsch_to_harq_feedback[i]; } } - else { - NR_PUCCH_Config_t *pucch_Config = UE->current_UL_BWP.pucch_Config; - AssertFatal(pucch_Config!=NULL,"pucch_Config shouldn't be null here\n"); - if(pucch_Config->dl_DataToUL_ACK != NULL) { - for (int i=0; i<8; i++) { - pdsch_to_harq_feedback[i] = *pucch_Config->dl_DataToUL_ACK->list.array[i]; - if(pdsch_to_harq_feedback[i]>*max_fb_time) - *max_fb_time = pdsch_to_harq_feedback[i]; - } - } - else - AssertFatal(0==1,"There is no allocated dl_DataToUL_ACK for pdsch to harq feedback\n"); - } + else + AssertFatal(0==1,"There is no allocated dl_DataToUL_ACK for pdsch to harq feedback\n"); } } @@ -2959,21 +2880,18 @@ void nr_mac_update_timers(module_id_t module_id, } NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; - const NR_ServingCellConfig_t *spCellConfigDedicated = cg && cg->spCellConfig ? cg->spCellConfig->spCellConfigDedicated : NULL; LOG_I(NR_MAC,"Modified rnti %04x with CellGroup\n", UE->rnti); process_CellGroup(cg,&UE->UE_sched_ctrl); NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + configure_UE_BWP(RC.nrmac[module_id], scc, sched_ctrl, NULL, UE); - const NR_PDSCH_ServingCellConfig_t *pdsch = spCellConfigDedicated ? spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup : NULL; if (get_softmodem_params()->sa) { // add all available DL HARQ processes for this UE in SA - create_dl_harq_list(sched_ctrl, pdsch); + create_dl_harq_list(sched_ctrl, UE->current_DL_BWP.pdsch_servingcellconfig); } - configure_UE_BWP(RC.nrmac[module_id], scc, sched_ctrl, NULL, UE); - // Update coreset/searchspace NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 2065dff90a..d4c7a7779d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -1583,7 +1583,7 @@ int nr_acknack_scheduling(int mod_id, const int CC_id = 0; const int minfbtime = RC.nrmac[mod_id]->minRXTXTIMEpdsch; const NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels[CC_id].ServingCellConfigCommon; - NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; + const NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; const int n_slots_frame = nr_slots_per_frame[BWP->scs]; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; AssertFatal(tdd || RC.nrmac[mod_id]->common_channels[CC_id].frame_type == FDD, "Dynamic TDD not handled yet\n"); @@ -1657,13 +1657,13 @@ int nr_acknack_scheduling(int mod_id, LOG_D(NR_MAC, "In %s: pucch_acknak 1. DL %4d.%2d, UL_ACK %4d.%2d, DAI_C %d\n", __FUNCTION__, frame, slot, pucch->frame, pucch->ul_slot, pucch->dai_c); - NR_SearchSpace__searchSpaceType_PR ss_type = NR_SearchSpace__searchSpaceType_PR_common; + nr_dci_format_t dci_format = NR_DL_DCI_FORMAT_1_0; if(is_common == 0) - ss_type = sched_ctrl->search_space->searchSpaceType->present; + dci_format = UE->current_DL_BWP.dci_format; uint8_t pdsch_to_harq_feedback[8]; int max_fb_time = 0; - get_pdsch_to_harq_feedback(UE, ss_type, &max_fb_time, pdsch_to_harq_feedback); + get_pdsch_to_harq_feedback(pucch_Config, dci_format, &max_fb_time, pdsch_to_harq_feedback); LOG_D(NR_MAC, "In %s: 1b. DL %4d.%2d, UL_ACK %4d.%2d, DAI_C %d\n", __FUNCTION__, frame,slot,pucch->frame,pucch->ul_slot,pucch->dai_c); /* there is a HARQ. Check whether we can use it for this ACKNACK */ @@ -1859,7 +1859,7 @@ void nr_sr_reporting(gNB_MAC_INST *nrmac, frame_t SFN, sub_frame_t slot) AssertFatal(pucch_Config->schedulingRequestResourceToAddModList->list.count>0,"NO SR configuration available"); - for (int SR_resource_id =0; SR_resource_id < pucch_Config->schedulingRequestResourceToAddModList->list.count;SR_resource_id++) { + for (int SR_resource_id = 0; SR_resource_id < pucch_Config->schedulingRequestResourceToAddModList->list.count;SR_resource_id++) { NR_SchedulingRequestResourceConfig_t *SchedulingRequestResourceConfig = pucch_Config->schedulingRequestResourceToAddModList->list.array[SR_resource_id]; int SR_period; int SR_offset; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index c3c7529b4e..30aac48b26 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1725,7 +1725,7 @@ void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) rnti_types[0], pusch_pdu->bwp_size, current_BWP->bwp_id, - coresetid, + coreset, nr_mac->cset0_bwp_size); memset(sched_pusch, 0, sizeof(*sched_pusch)); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 3a20147f2b..5884d6532f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -220,8 +220,8 @@ int nr_acknack_scheduling( int Mod_idP, int r_pucch, int do_common); -void get_pdsch_to_harq_feedback(NR_UE_info_t *UE, - NR_SearchSpace__searchSpaceType_PR ss_type, +void get_pdsch_to_harq_feedback(NR_PUCCH_Config_t *pucch_Config, + nr_dci_format_t dci_format, int *max_fb_time, uint8_t *pdsch_to_harq_feedback); @@ -296,14 +296,14 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, int rnti_types, int N_RB, int bwp_id, - NR_ControlResourceSetId_t coreset_id, + NR_ControlResourceSet_t *coreset, uint16_t cset0_bwp_size); void prepare_dci(const NR_CellGroupConfig_t *CellGroup, const NR_UE_DL_BWP_t *BWP, + const NR_ControlResourceSet_t *coreset, dci_pdu_rel15_t *dci_pdu_rel15, - nr_dci_format_t format, - int bwp_id); + nr_dci_format_t format); void set_r_pucch_parms(int rsetindex, int r_pucch, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index a8ebde347e..7c805e8a90 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -100,7 +100,9 @@ typedef struct NR_UE_DL_BWP { uint16_t 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 { From 4e69a10cbc131814b96a3b34c411d904936e2eb5 Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 20 Jun 2022 11:41:19 +0200 Subject: [PATCH 11/16] change BWP when Msg3_dcch_dtch --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 18 +++++---------- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 22 +++++++++++++------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 57b7d58ad0..89495139da 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1834,19 +1834,11 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra harq->round = 0; harq->ndi ^= 1; - // Pause scheduling according to: - // 3GPP TS 38.331 Section 12 Table 12.1-1: UE performance requirements for RRC procedures for UEs - const NR_COMMON_channels_t *common_channels = &RC.nrmac[module_idP]->common_channels[0]; - const NR_SIB1_t *sib1 = common_channels->sib1 ? common_channels->sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; - const NR_ServingCellConfig_t *servingCellConfig = UE->CellGroup ? UE->CellGroup->spCellConfig->spCellConfigDedicated : NULL; - NR_BWP_t *genericParameters = get_dl_bwp_genericParameters(sched_ctrl->active_bwp, - common_channels->ServingCellConfigCommon, - sib1); - uint32_t delay_ms = servingCellConfig && servingCellConfig->downlinkBWP_ToAddModList ? - NR_RRC_SETUP_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_SETUP_DELAY_MS; - - sched_ctrl->rrc_processing_timer = (delay_ms << genericParameters->subcarrierSpacing); - LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %04x with %d ms\n", frameP, slotP, UE->rnti, delay_ms); + configure_UE_BWP(nr_mac, + scc, + sched_ctrl, + NULL, + UE); // Reset uplink failure flags/counters/timers at MAC so gNB will resume again scheduling resources for this UE UE->UE_sched_ctrl.pusch_consecutive_dtx_cnt = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index bed24dcc36..c363eac31a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2218,13 +2218,21 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, csi_MeasConfig = servingCellConfig->csi_MeasConfig ? servingCellConfig->csi_MeasConfig->choice.setup : NULL; target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - // (re)configuring BWP - // TODO BWP switching not via RRC reconfiguration - // via RRC if firstActiveXlinkBWP_Id is NULL, MAC stays on the same BWP as before - if (servingCellConfig->firstActiveDownlinkBWP_Id) - DL_BWP->bwp_id = *servingCellConfig->firstActiveDownlinkBWP_Id; - if (servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id) - UL_BWP->bwp_id = *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id; + if(UE && UE->Msg3_dcch_dtch) { + // switching to initial BWP + DL_BWP->bwp_id = 0; + UL_BWP->bwp_id = 0; + UE->Msg3_dcch_dtch = false; + } + else { + // (re)configuring BWP + // TODO BWP switching not via RRC reconfiguration + // via RRC if firstActiveXlinkBWP_Id is NULL, MAC stays on the same BWP as before + if (servingCellConfig->firstActiveDownlinkBWP_Id) + DL_BWP->bwp_id = *servingCellConfig->firstActiveDownlinkBWP_Id; + if (servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id) + UL_BWP->bwp_id = *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id; + } const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig->downlinkBWP_ToAddModList; if(bwpList) From 83a9414258d833a7352cb9d7f0b87f636f189a5d Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 20 Jun 2022 18:03:40 +0200 Subject: [PATCH 12/16] srs and csi in BWP structures --- openair1/SIMULATION/NR_PHY/dlsim.c | 1 - .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 4 ---- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 2 +- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 19 +++++++++---------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c | 12 ++---------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 17 +++++------------ openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 1 - openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 2 ++ 8 files changed, 19 insertions(+), 39 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 90fbd36004..8d89ff0888 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -304,7 +304,6 @@ void nr_dlsim_preprocessor(module_id_t module_id, nr_set_pdsch_semi_static(BWP, scc, - UE_info->CellGroup, /* tda = */ 0, g_nrOfLayers, sched_ctrl, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 5c1203a12c..c42fba7ab0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -379,7 +379,6 @@ bool allocate_dl_retransmission(module_id_t module_id, NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; NR_UE_UL_BWP_t *UBWP = &UE->current_UL_BWP; NR_sched_pdsch_t *retInfo = &sched_ctrl->harq_processes[current_harq_pid].sched_pdsch; - NR_CellGroupConfig_t *cg = UE->CellGroup; const int coresetid = sched_ctrl->coreset->controlResourceSetId; const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : BWP->BWPSize; @@ -416,7 +415,6 @@ bool allocate_dl_retransmission(module_id_t module_id, if (ps->time_domain_allocation != tda) { nr_set_pdsch_semi_static(BWP, scc, - cg, tda, ps->nrOfLayers, sched_ctrl, @@ -429,7 +427,6 @@ bool allocate_dl_retransmission(module_id_t module_id, nr_set_pdsch_semi_static(BWP, scc, - cg, tda, ps->nrOfLayers, sched_ctrl, @@ -710,7 +707,6 @@ void pf_dl(module_id_t module_id, if (ps->nrOfLayers != iterator->UE->layers || ps->time_domain_allocation != tda ) { nr_set_pdsch_semi_static(BWP, scc, - iterator->UE->CellGroup, tda, iterator->UE->layers, sched_ctrl, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index ea681dc1bf..5926b61f4c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -202,7 +202,7 @@ void nr_preprocessor_phytest(module_id_t module_id, NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; ps->nrOfLayers = target_dl_Nl; if (ps->time_domain_allocation != tda || ps->nrOfLayers != target_dl_Nl) - nr_set_pdsch_semi_static(BWP, scc, UE->CellGroup, tda, target_dl_Nl,sched_ctrl , ps); + nr_set_pdsch_semi_static(BWP, scc, tda, target_dl_Nl,sched_ctrl , ps); /* find largest unallocated chunk */ const int bwpSize = BWP->BWPSize; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index c363eac31a..c90955f0aa 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -510,7 +510,6 @@ bool nr_find_nb_rb(uint16_t Qm, void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *BWP, const NR_ServingCellConfigCommon_t *scc, - const NR_CellGroupConfig_t *secondaryCellGroup, int tda, uint8_t layers, NR_UE_sched_ctrl_t *sched_ctrl, @@ -2201,7 +2200,6 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, NR_BWP_Uplink_t *ul_bwp = NULL; NR_BWP_DownlinkDedicated_t *bwpd = NULL; NR_BWP_UplinkDedicated_t *ubwpd = NULL; - NR_CSI_MeasConfig_t *csi_MeasConfig = NULL; DL_BWP->n_dl_bwp = 1; UL_BWP->n_ul_bwp = 1; int old_dl_bwp_id = DL_BWP->bwp_id; @@ -2215,7 +2213,6 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, const NR_ServingCellConfig_t *servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; DL_BWP->pdsch_servingcellconfig = servingCellConfig->pdsch_ServingCellConfig? servingCellConfig->pdsch_ServingCellConfig->choice.setup : NULL; - csi_MeasConfig = servingCellConfig->csi_MeasConfig ? servingCellConfig->csi_MeasConfig->choice.setup : NULL; target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; if(UE && UE->Msg3_dcch_dtch) { @@ -2271,6 +2268,8 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, DL_BWP->pdsch_Config = bwpd->pdsch_Config->choice.setup; UL_BWP->pusch_Config = ubwpd->pusch_Config->choice.setup; UL_BWP->pucch_Config = ubwpd->pucch_Config->choice.setup; + UL_BWP->srs_Config = ubwpd->srs_Config->choice.setup; + UL_BWP->csi_MeasConfig = servingCellConfig->csi_MeasConfig ? servingCellConfig->csi_MeasConfig->choice.setup : NULL; } else { DL_BWP->bwp_id = 0; @@ -2279,6 +2278,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, DL_BWP->pdsch_Config = NULL; UL_BWP->pusch_Config = NULL; UL_BWP->pucch_Config = NULL; + UL_BWP->csi_MeasConfig = NULL; } if (old_dl_bwp_id != DL_BWP->bwp_id) @@ -2369,8 +2369,8 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0) : NR_UL_DCI_FORMAT_0_0; - if (csi_MeasConfig) - compute_csi_bitlen (csi_MeasConfig, UE); + if (UL_BWP->csi_MeasConfig) + compute_csi_bitlen (UL_BWP->csi_MeasConfig, UE); } @@ -2671,13 +2671,13 @@ void nr_csirs_scheduling(int Mod_idP, if (sched_ctrl->rrc_processing_timer > 0) { continue; } - NR_CellGroupConfig_t *CellGroup = UE->CellGroup; + NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; + NR_UE_UL_BWP_t *UBWP = &UE->current_UL_BWP; - if (!CellGroup || !CellGroup->spCellConfig || !CellGroup->spCellConfig->spCellConfigDedicated || - !CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig) continue; + if (!UBWP->csi_MeasConfig) continue; - NR_CSI_MeasConfig_t *csi_measconfig = CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; + NR_CSI_MeasConfig_t *csi_measconfig = UBWP->csi_MeasConfig; if (csi_measconfig->nzp_CSI_RS_ResourceToAddModList != NULL) { @@ -2913,7 +2913,6 @@ void nr_mac_update_timers(module_id_t module_id, nr_set_pdsch_semi_static(&UE->current_DL_BWP, scc, - cg, tda, layers, sched_ctrl, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c index 15d06886f5..0344b7e622 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_srs.c @@ -108,7 +108,6 @@ void nr_schedule_srs(int module_id, frame_t frame) { UE_iterator(UE_info->list, UE) { const int CC_id = 0; - NR_CellGroupConfig_t *cg = UE->CellGroup; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_UE_UL_BWP_t *current_BWP = &UE->current_UL_BWP; @@ -120,16 +119,9 @@ void nr_schedule_srs(int module_id, frame_t frame) { continue; } - NR_SRS_Config_t *srs_config = NULL; - if (cg && - cg->spCellConfig && - cg->spCellConfig->spCellConfigDedicated && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { - srs_config = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config->choice.setup; - } else { + NR_SRS_Config_t *srs_config = current_BWP->srs_Config; + if (!srs_config) continue; - } for(int rs = 0; rs < srs_config->srs_ResourceSetToAddModList->list.count; rs++) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index d4c7a7779d..a8f8ab3f10 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -688,16 +688,14 @@ void nr_csi_meas_reporting(int Mod_idP, sub_frame_t slot) { UE_iterator(RC.nrmac[Mod_idP]->UE_info.list, UE ) { - const NR_CellGroupConfig_t *CellGroup = UE->CellGroup; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_UE_UL_BWP_t *UL_BWP = &UE->current_UL_BWP; const int n_slots_frame = nr_slots_per_frame[UL_BWP->scs]; if ((sched_ctrl->rrc_processing_timer > 0) || (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0)) { continue; } - if (!CellGroup || !CellGroup->spCellConfig || !CellGroup->spCellConfig->spCellConfigDedicated || - !CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig) continue; - const NR_CSI_MeasConfig_t *csi_measconfig = CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; + const NR_CSI_MeasConfig_t *csi_measconfig = UL_BWP->csi_MeasConfig; + if (!csi_measconfig) continue; AssertFatal(csi_measconfig->csi_ReportConfigToAddModList->list.count > 0, "NO CSI report configuration available"); NR_PUCCH_Config_t *pucch_Config = UL_BWP->pucch_Config; @@ -1472,15 +1470,10 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, LOG_E(NR_MAC, "%s(): unknown RNTI %04x in PUCCH UCI\n", __func__, uci_234->rnti); return; } - AssertFatal(UE->CellGroup,"Cellgroup is null for UE %04x\n", uci_234->rnti); - AssertFatal(UE->CellGroup->spCellConfig, - "Cellgroup->spCellConfig is null for UE %04x\n", uci_234->rnti); - AssertFatal(UE->CellGroup->spCellConfig->spCellConfigDedicated, - "Cellgroup->spCellConfig->spCellConfigDedicated is null for UE %04x\n", uci_234->rnti); - if ( UE->CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig==NULL) - return; - NR_CSI_MeasConfig_t *csi_MeasConfig = UE->CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; + NR_CSI_MeasConfig_t *csi_MeasConfig = UE->current_UL_BWP.csi_MeasConfig; + if (csi_MeasConfig==NULL) + return; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; // tpc (power control) diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 196951c47d..a178f5aabd 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -331,7 +331,6 @@ long get_K2(NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList, void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *BWP, const NR_ServingCellConfigCommon_t *scc, - const NR_CellGroupConfig_t *secondaryCellGroup, int tda, uint8_t layers, NR_UE_sched_ctrl_t *sched_ctrl, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 12b4f75927..a14d8369b5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -116,6 +116,8 @@ typedef struct NR_UE_UL_BWP { 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; From a24be049293bafafd1d037939d9e99ca6f0e8208 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 21 Jun 2022 09:52:12 +0200 Subject: [PATCH 13/16] initializing nrofcandidates in dlsim --- openair1/SIMULATION/NR_PHY/dlsim.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 8d89ff0888..b9fed90eab 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -276,9 +276,7 @@ void nr_dlsim_preprocessor(module_id_t module_id, NR_UE_DL_BWP_t *BWP = &UE_info->current_DL_BWP; NR_ServingCellConfigCommon_t *scc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon; - /* manually set free CCE to 0 */ - - uint8_t nr_of_candidates; + uint8_t nr_of_candidates = 0; if (g_mcsIndex < 4) { find_aggregation_candidates(&sched_ctrl->aggregation_level, &nr_of_candidates, From fdd79391e9290250a63032dc9668b4beec20cc14 Mon Sep 17 00:00:00 2001 From: luis_pereira87 Date: Mon, 1 Aug 2022 17:28:15 +0100 Subject: [PATCH 14/16] Call function nr_mac_update_timers when there is a Msg3 carrying a DCCH message --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 89495139da..fa3b79d478 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1834,11 +1834,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra harq->round = 0; harq->ndi ^= 1; - configure_UE_BWP(nr_mac, - scc, - sched_ctrl, - NULL, - UE); + sched_ctrl->rrc_processing_timer = 1; // No need to wait at this point in time, setting it to 1 just to enter in function nr_mac_update_timers + LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %04x with %d ms\n", frameP, slotP, UE->rnti, 1); // Reset uplink failure flags/counters/timers at MAC so gNB will resume again scheduling resources for this UE UE->UE_sched_ctrl.pusch_consecutive_dtx_cnt = 0; From d908779c388fafa787618e4d8fb9cfccbf0bb82e Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 4 Aug 2022 11:34:25 +0200 Subject: [PATCH 15/16] lowercase bwp --- openair1/SIMULATION/NR_PHY/dlsim.c | 12 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 66 +++++----- .../LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 42 +++--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 34 ++--- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 120 ++++++++---------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 39 +++--- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 38 +++--- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 10 +- 8 files changed, 176 insertions(+), 185 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index e2449d21da..0fe5315d4e 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -280,7 +280,7 @@ void nr_dlsim_preprocessor(module_id_t module_id, NR_UE_info_t *UE_info = RC.nrmac[module_id]->UE_info.list[0]; AssertFatal(RC.nrmac[module_id]->UE_info.list[1]==NULL, "can have only a single UE\n"); NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl; - NR_UE_DL_BWP_t *BWP = &UE_info->current_DL_BWP; + NR_UE_DL_BWP_t *current_BWP = &UE_info->current_DL_BWP; NR_ServingCellConfigCommon_t *scc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon; uint8_t nr_of_candidates = 0; @@ -307,7 +307,7 @@ void nr_dlsim_preprocessor(module_id_t module_id, NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; - nr_set_pdsch_semi_static(BWP, + nr_set_pdsch_semi_static(current_BWP, scc, /* tda = */ 0, g_nrOfLayers, @@ -320,10 +320,10 @@ void nr_dlsim_preprocessor(module_id_t module_id, sched_pdsch->mcs = g_mcsIndex; /* the following might override the table that is mandated by RRC * configuration */ - BWP->mcsTableIdx = g_mcsTableIdx; + current_BWP->mcsTableIdx = g_mcsTableIdx; - sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, BWP->mcsTableIdx); - sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, BWP->mcsTableIdx); + sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, current_BWP->mcsTableIdx); + sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, current_BWP->mcsTableIdx); sched_pdsch->tb_size = nr_compute_tbs(sched_pdsch->Qm, sched_pdsch->R, sched_pdsch->rbSize, @@ -351,7 +351,7 @@ void nr_dlsim_preprocessor(module_id_t module_id, AssertFatal(sched_pdsch->rbStart >= 0, "invalid rbStart %d\n", sched_pdsch->rbStart); AssertFatal(sched_pdsch->rbSize > 0, "invalid rbSize %d\n", sched_pdsch->rbSize); AssertFatal(sched_pdsch->mcs >= 0, "invalid mcs %d\n", sched_pdsch->mcs); - AssertFatal(BWP->mcsTableIdx >= 0 && BWP->mcsTableIdx <= 2, "invalid mcsTableIdx %d\n", BWP->mcsTableIdx); + AssertFatal(current_BWP->mcsTableIdx >= 0 && current_BWP->mcsTableIdx <= 2, "invalid mcsTableIdx %d\n", current_BWP->mcsTableIdx); } typedef struct { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index cafa2c02d9..745fc1ae2b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -694,10 +694,10 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - NR_UE_UL_BWP_t *UL_BWP = &ra->UL_BWP; + NR_UE_UL_BWP_t *ul_bwp = &ra->UL_BWP; - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = UL_BWP->tdaList; - int mu = UL_BWP->scs; + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = ul_bwp->tdaList; + int mu = ul_bwp->scs; uint8_t K2 = *pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->k2; const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; @@ -841,7 +841,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t NR_UL_DCI_FORMAT_0_0, NR_RNTI_TC, pusch_pdu->bwp_size, - UL_BWP->bwp_id, + ul_bwp->bwp_id, coreset, nr_mac->cset0_bwp_size); @@ -878,16 +878,16 @@ void nr_get_Msg3alloc(module_id_t module_id, uint16_t msg3_nb_rb = 8; // sdu has 6 or 8 bytes frame_type_t frame_type = RC.nrmac[module_id]->common_channels->frame_type; - NR_UE_UL_BWP_t *UL_BWP = &ra->UL_BWP; + NR_UE_UL_BWP_t *ul_bwp = &ra->UL_BWP; - int mu = UL_BWP->scs; + int mu = ul_bwp->scs; int StartSymbolIndex = 0; int NrOfSymbols = 0; int startSymbolAndLength = 0; int temp_slot = 0; ra->Msg3_tda_id = 16; // initialization to a value above limit - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = UL_BWP->tdaList; + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = ul_bwp->tdaList; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; const int n_slots_frame = nr_slots_per_frame[mu]; @@ -951,9 +951,9 @@ void nr_get_Msg3alloc(module_id_t module_id, int bwpSize = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); int bwpStart = NRRIV2PRBOFFSET(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - if (bwpSize != UL_BWP->BWPSize || bwpStart != UL_BWP->BWPStart) { - int act_bwp_start = UL_BWP->BWPStart; - int act_bwp_size = UL_BWP->BWPSize; + if (bwpSize != ul_bwp->BWPSize || bwpStart != ul_bwp->BWPStart) { + int act_bwp_start = ul_bwp->BWPStart; + int act_bwp_size = ul_bwp->BWPSize; if (!((bwpStart >= act_bwp_start) && ((bwpStart+bwpSize) <= (act_bwp_start+act_bwp_size)))) bwpStart = act_bwp_start; } @@ -1065,7 +1065,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t gNB_MAC_INST *mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &mac->common_channels[CC_id]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - NR_UE_UL_BWP_t *UL_BWP = &ra->UL_BWP; + NR_UE_UL_BWP_t *ul_bwp = &ra->UL_BWP; if (ra->state == RA_IDLE) { LOG_W(NR_MAC,"RA is not active for RA %X. skipping msg3 scheduling\n", ra->rnti); @@ -1098,11 +1098,11 @@ 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)); - int ibwp_size = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - int scs = UL_BWP->scs; - int fh = (UL_BWP->pusch_Config && UL_BWP->pusch_Config->frequencyHopping) ? 1 : 0; - int startSymbolAndLength = UL_BWP->tdaList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; - int mappingtype = UL_BWP->tdaList->list.array[ra->Msg3_tda_id]->mappingType; + const int ibwp_size = NRRIV2BW(scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + const int scs = ul_bwp->scs; + const int fh = (ul_bwp->pusch_Config && ul_bwp->pusch_Config->frequencyHopping) ? 1 : 0; + const int startSymbolAndLength = ul_bwp->tdaList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; + const int mappingtype = ul_bwp->tdaList->list.array[ra->Msg3_tda_id]->mappingType; LOG_D(NR_MAC, "Frame %d, Slot %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d) for rnti: %d\n", frameP, @@ -1131,7 +1131,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; - NR_UE_DL_BWP_t *DL_BWP = &ra->DL_BWP; + NR_UE_DL_BWP_t *dl_bwp = &ra->DL_BWP; if ((ra->Msg2_frame == frameP) && (ra->Msg2_slot == slotP)) { @@ -1142,13 +1142,13 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_SearchSpace_t *ss = ra->ra_ss; - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = DL_BWP->tdaList; + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = dl_bwp->tdaList; long BWPStart = 0; long BWPSize = 0; NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = NULL; if(*ss->controlResourceSetId!=0) { - BWPStart = DL_BWP->BWPStart; + BWPStart = dl_bwp->BWPStart; BWPSize = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); } else { type0_PDCCH_CSS_config = &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]; @@ -1242,8 +1242,8 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // information to data and is reset every slot. const int pduindex = nr_mac->pdu_index[CC_id]++; - NR_PDSCH_Config_t *pdsch_Config = DL_BWP->pdsch_Config; - uint8_t mcsTableIdx = DL_BWP->mcsTableIdx; + NR_PDSCH_Config_t *pdsch_Config = dl_bwp->pdsch_Config; + uint8_t mcsTableIdx = dl_bwp->mcsTableIdx; int dmrsConfigType=0; if (pdsch_Config && @@ -1257,7 +1257,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->pduIndex = pduindex; pdsch_pdu_rel15->BWPSize = BWPSize; pdsch_pdu_rel15->BWPStart = BWPStart; - pdsch_pdu_rel15->SubcarrierSpacing = DL_BWP->scs; + pdsch_pdu_rel15->SubcarrierSpacing = dl_bwp->scs; pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; pdsch_pdu_rel15->mcsTable[0] = mcsTableIdx; @@ -1370,13 +1370,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, + dl_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, + dl_bwp->bwp_id, coreset, nr_mac->cset0_bwp_size); @@ -1422,7 +1422,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; - NR_UE_DL_BWP_t *DL_BWP = &ra->DL_BWP; + NR_UE_DL_BWP_t *dl_bwp = &ra->DL_BWP; if (ra->Msg4_frame == frameP && ra->Msg4_slot == slotP ) { @@ -1433,7 +1433,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_SearchSpace_t *ss = ra->ra_ss; NR_ControlResourceSet_t *coreset = ra->coreset; - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = DL_BWP->tdaList; + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = dl_bwp->tdaList; AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg4\n"); @@ -1456,8 +1456,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra long BWPSize = 0; NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config = NULL; if(*ss->controlResourceSetId!=0) { - BWPStart = DL_BWP->BWPStart; - BWPSize = DL_BWP->BWPSize; + BWPStart = dl_bwp->BWPStart; + BWPSize = dl_bwp->BWPSize; } else { type0_PDCCH_CSS_config = &nr_mac->type0_PDCCH_CSS_config[ra->beam_id]; BWPStart = type0_PDCCH_CSS_config->cset_start_rb; @@ -1567,7 +1567,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra uint16_t N_DMRS_SLOT = get_num_dmrs(dlDmrsSymbPos); - NR_PDSCH_Config_t *pdsch_Config = DL_BWP->pdsch_Config; + NR_PDSCH_Config_t *pdsch_Config = dl_bwp->pdsch_Config; int dmrsConfigType=0; if (pdsch_Config && pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA && @@ -1593,7 +1593,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra N_PRB_DMRS = nr_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData * 4; } - uint8_t mcsTableIdx = DL_BWP->mcsTableIdx; + uint8_t mcsTableIdx = dl_bwp->mcsTableIdx; int rbStart = 0; int rbSize = 0; @@ -1669,7 +1669,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->pduIndex = pduindex; pdsch_pdu_rel15->BWPSize = BWPSize; pdsch_pdu_rel15->BWPStart = BWPStart; - pdsch_pdu_rel15->SubcarrierSpacing = DL_BWP->scs; + pdsch_pdu_rel15->SubcarrierSpacing = dl_bwp->scs; pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; int R = nr_get_code_rate_dl(mcsIndex,mcsTableIdx); @@ -1764,13 +1764,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, + dl_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, + dl_bwp->bwp_id, coreset, nr_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 3e80fd104b..6aee81fa67 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -388,8 +388,8 @@ bool allocate_dl_retransmission(module_id_t module_id, gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; const NR_ServingCellConfigCommon_t *scc = nr_mac->common_channels->ServingCellConfigCommon; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; - NR_UE_UL_BWP_t *UBWP = &UE->current_UL_BWP; + NR_UE_DL_BWP_t *dl_bwp = &UE->current_DL_BWP; + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; NR_sched_pdsch_t *retInfo = &sched_ctrl->harq_processes[current_harq_pid].sched_pdsch; NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; @@ -404,7 +404,7 @@ bool allocate_dl_retransmission(module_id_t module_id, } const int coresetid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : BWP->BWPSize; + const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : dl_bwp->BWPSize; int rbStart = 0; // start wrt BWPstart int rbSize = 0; @@ -435,7 +435,7 @@ bool allocate_dl_retransmission(module_id_t module_id, /* check whether we need to switch the TDA allocation since the last * (re-)transmission */ if (ps->time_domain_allocation != tda) { - nr_set_pdsch_semi_static(BWP, + nr_set_pdsch_semi_static(dl_bwp, scc, tda, ps->nrOfLayers, @@ -447,7 +447,7 @@ bool allocate_dl_retransmission(module_id_t module_id, * that we have enough resources */ NR_pdsch_semi_static_t temp_ps = *ps; - nr_set_pdsch_semi_static(BWP, + nr_set_pdsch_semi_static(dl_bwp, scc, tda, ps->nrOfLayers, @@ -519,7 +519,7 @@ bool allocate_dl_retransmission(module_id_t module_id, /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH * allocation after CCE alloc fail would be more complex) */ - int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, UBWP->pucch_Config, CCEIndex); + int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, ul_bwp->pucch_Config, CCEIndex); const int alloc = nr_acknack_scheduling(module_id, UE, frame, slot, r_pucch, 0); if (alloc<0) { LOG_D(MAC, @@ -579,7 +579,7 @@ void pf_dl(module_id_t module_id, continue; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; + NR_UE_DL_BWP_t *current_BWP = &UE->current_DL_BWP; if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; @@ -619,15 +619,15 @@ void pf_dl(module_id_t module_id, /* Calculate coeff */ const NR_bler_options_t *bo = &mac->dl_bler; - const int max_mcs_table = BWP->mcsTableIdx == 1 ? 27 : 28; + const int max_mcs_table = current_BWP->mcsTableIdx == 1 ? 27 : 28; const int max_mcs = min(sched_ctrl->dl_max_mcs, max_mcs_table); if (bo->harq_round_max == 1) sched_pdsch->mcs = max_mcs; else sched_pdsch->mcs = get_mcs_from_bler(bo, stats, &sched_ctrl->dl_bler_stats, max_mcs, frame); UE->layers = set_dl_nrOfLayers(sched_ctrl); - const uint8_t Qm = nr_get_Qm_dl(sched_pdsch->mcs, BWP->mcsTableIdx); - const uint16_t R = nr_get_code_rate_dl(sched_pdsch->mcs, BWP->mcsTableIdx); + const uint8_t Qm = nr_get_Qm_dl(sched_pdsch->mcs, current_BWP->mcsTableIdx); + const uint16_t R = nr_get_code_rate_dl(sched_pdsch->mcs, current_BWP->mcsTableIdx); uint32_t tbs = nr_compute_tbs(Qm, R, 1, /* rbSize */ @@ -657,13 +657,13 @@ void pf_dl(module_id_t module_id, NR_UE_sched_ctrl_t *sched_ctrl = &iterator->UE->UE_sched_ctrl; const uint16_t rnti = iterator->UE->rnti; - NR_UE_DL_BWP_t *BWP = &iterator->UE->current_DL_BWP; - NR_UE_UL_BWP_t *UBWP = &iterator->UE->current_UL_BWP; + NR_UE_DL_BWP_t *dl_bwp = &iterator->UE->current_DL_BWP; + NR_UE_UL_BWP_t *ul_bwp = &iterator->UE->current_UL_BWP; const int coresetid = sched_ctrl->coreset->controlResourceSetId; const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : - BWP->BWPSize; + dl_bwp->BWPSize; int rbStart = 0; // start wrt BWPstart if (sched_ctrl->available_dl_harq.head < 0) { @@ -703,7 +703,7 @@ void pf_dl(module_id_t module_id, /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH * allocation after CCE alloc fail would be more complex) */ - int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, UBWP->pucch_Config, CCEIndex); + int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, ul_bwp->pucch_Config, CCEIndex); const int alloc = nr_acknack_scheduling(module_id, iterator->UE, frame, slot, r_pucch, 0); if (alloc<0) { @@ -730,7 +730,7 @@ void pf_dl(module_id_t module_id, NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; if (ps->nrOfLayers != iterator->UE->layers || ps->time_domain_allocation != tda ) { - nr_set_pdsch_semi_static(BWP, + nr_set_pdsch_semi_static(dl_bwp, scc, tda, iterator->UE->layers, @@ -749,8 +749,8 @@ void pf_dl(module_id_t module_id, while (rbStart + max_rbSize < bwpSize && (rballoc_mask[rbStart + max_rbSize] & slbitmap) == slbitmap) max_rbSize++; - sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, BWP->mcsTableIdx); - sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, BWP->mcsTableIdx); + sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, dl_bwp->mcsTableIdx); + sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, dl_bwp->mcsTableIdx); sched_pdsch->pucch_allocation = alloc; uint32_t TBS = 0; uint16_t rbSize; @@ -796,18 +796,18 @@ void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t /* This is temporary and it assumes all UEs have the same BWP and TDA*/ NR_UE_info_t *UE=UE_info->list[0]; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; + NR_UE_DL_BWP_t *current_BWP = &UE->current_DL_BWP; const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); int startSymbolIndex, nrOfSymbols; - const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = BWP->tdaList; + const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = current_BWP->tdaList; AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); const int coresetid = sched_ctrl->coreset->controlResourceSetId; - const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : BWP->BWPSize; - const uint16_t BWPStart = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_start : BWP->BWPStart; + const uint16_t bwpSize = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_size : current_BWP->BWPSize; + const uint16_t BWPStart = coresetid == 0 ? RC.nrmac[module_id]->cset0_bwp_start : current_BWP->BWPStart; const uint16_t slbitmap = SL_to_bitmap(startSymbolIndex, nrOfSymbols); uint16_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 5926b61f4c..e474315de7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -195,18 +195,18 @@ void nr_preprocessor_phytest(module_id_t module_id, NR_UE_info_t *UE = RC.nrmac[module_id]->UE_info.list[0]; NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; + NR_UE_DL_BWP_t *dl_bwp = &UE->current_DL_BWP; const int CC_id = 0; const int tda = get_dl_tda(RC.nrmac[module_id], scc, slot); NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; ps->nrOfLayers = target_dl_Nl; if (ps->time_domain_allocation != tda || ps->nrOfLayers != target_dl_Nl) - nr_set_pdsch_semi_static(BWP, scc, tda, target_dl_Nl,sched_ctrl , ps); + nr_set_pdsch_semi_static(dl_bwp, scc, tda, target_dl_Nl,sched_ctrl , ps); /* find largest unallocated chunk */ - const int bwpSize = BWP->BWPSize; - const int BWPStart = BWP->BWPStart; + const int bwpSize = dl_bwp->BWPSize; + const int BWPStart = dl_bwp->BWPStart; int rbStart = 0; int rbSize = 0; @@ -309,8 +309,8 @@ void nr_preprocessor_phytest(module_id_t module_id, sched_pdsch->rbSize = rbSize; sched_pdsch->mcs = target_dl_mcs; - sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, BWP->mcsTableIdx); - sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, BWP->mcsTableIdx); + sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, dl_bwp->mcsTableIdx); + sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, dl_bwp->mcsTableIdx); sched_ctrl->dl_bler_stats.mcs = target_dl_mcs; /* for logging output */ sched_pdsch->tb_size = nr_compute_tbs(sched_pdsch->Qm, sched_pdsch->R, @@ -351,10 +351,10 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ const int CC_id = 0; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; - const int mu = BWP->scs; + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; + const int mu = ul_bwp->scs; - const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = BWP->tdaList; + const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = ul_bwp->tdaList; const int temp_tda = get_ul_tda(nr_mac, scc, slot); if (temp_tda < 0) return false; @@ -362,7 +362,7 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ "time domain assignment %d >= %d\n", temp_tda, tdaList->list.count); - int K2 = get_K2(BWP->tdaList, temp_tda, mu); + int K2 = get_K2(ul_bwp->tdaList, temp_tda, mu); const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; const int tda = get_ul_tda(nr_mac, scc, sched_slot); @@ -384,13 +384,13 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; if (ps->time_domain_allocation != tda || ps->nrOfLayers != target_ul_Nl) - nr_set_pusch_semi_static(BWP, scc, tda, target_ul_Nl,ps); + nr_set_pusch_semi_static(ul_bwp, scc, tda, target_ul_Nl,ps); uint16_t rbStart = 0; uint16_t rbSize; - const int bw = BWP->BWPSize; - const int BWPStart = BWP->BWPStart; + const int bw = ul_bwp->BWPSize; + const int BWPStart = ul_bwp->BWPStart; if (target_ul_bw>bw) rbSize = bw; @@ -453,10 +453,10 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ /* Calculate TBS from MCS */ ps->nrOfLayers = target_ul_Nl; - sched_pusch->R = nr_get_code_rate_ul(mcs, BWP->mcs_table); - sched_pusch->Qm = nr_get_Qm_ul(mcs, BWP->mcs_table); - if (BWP->pusch_Config->tp_pi2BPSK - && ((BWP->mcs_table == 3 && mcs < 2) || (BWP->mcs_table == 4 && mcs < 6))) { + sched_pusch->R = nr_get_code_rate_ul(mcs, ul_bwp->mcs_table); + sched_pusch->Qm = nr_get_Qm_ul(mcs, ul_bwp->mcs_table); + if (ul_bwp->pusch_Config->tp_pi2BPSK + && ((ul_bwp->mcs_table == 3 && mcs < 2) || (ul_bwp->mcs_table == 4 && mcs < 6))) { sched_pusch->R >>= 1; sched_pusch->Qm <<= 1; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 1dafff4635..497546184f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -508,7 +508,7 @@ bool nr_find_nb_rb(uint16_t Qm, return *tbs >= bytes && *nb_rb <= nb_rb_max; } -void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *BWP, +void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *dl_bwp, const NR_ServingCellConfigCommon_t *scc, int tda, uint8_t layers, @@ -517,11 +517,11 @@ void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *BWP, { bool reset_dmrs = false; - NR_PDSCH_Config_t *pdsch_Config = BWP->pdsch_Config; + NR_PDSCH_Config_t *pdsch_Config = dl_bwp->pdsch_Config; LOG_D(NR_MAC,"tda %d, ps->time_domain_allocation %d,layers %d, ps->nrOfLayers %d, pdsch_config %p\n",tda,ps->time_domain_allocation,layers,ps->nrOfLayers,pdsch_Config); reset_dmrs = true; ps->time_domain_allocation = tda; - NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = BWP->tdaList; + NR_PDSCH_TimeDomainResourceAllocationList_t *tdaList = dl_bwp->tdaList; AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); ps->mapping_type = tdaList->list.array[tda]->mappingType; if (pdsch_Config) { @@ -535,7 +535,7 @@ void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *BWP, const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &ps->startSymbolIndex, &ps->nrOfSymbols); - if (BWP->dci_format == NR_DL_DCI_FORMAT_1_0) { + if (dl_bwp->dci_format == NR_DL_DCI_FORMAT_1_0) { if (ps->nrOfSymbols == 2) ps->numDmrsCdmGrpsNoData = 1; else @@ -562,7 +562,7 @@ void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *BWP, LOG_D(NR_MAC,"Filling dmrs info, ps->N_PRB_DMRS %d, ps->dl_dmrs_symb_pos %x, ps->N_DMRS_SLOT %d\n",ps->N_PRB_DMRS,ps->dl_dmrs_symb_pos,ps->N_DMRS_SLOT); } -void nr_set_pusch_semi_static(const NR_UE_UL_BWP_t *BWP, +void nr_set_pusch_semi_static(const NR_UE_UL_BWP_t *ul_bwp, const NR_ServingCellConfigCommon_t *scc, int tda, uint8_t nrOfLayers, @@ -570,24 +570,24 @@ void nr_set_pusch_semi_static(const NR_UE_UL_BWP_t *BWP, ps->time_domain_allocation = tda; - const int startSymbolAndLength = BWP->tdaList->list.array[tda]->startSymbolAndLength; + const int startSymbolAndLength = ul_bwp->tdaList->list.array[tda]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &ps->startSymbolIndex, &ps->nrOfSymbols); ps->nrOfLayers = nrOfLayers; // TODO setting of cdm groups with no data to be redone for MIMO - if (BWP->transform_precoding || nrOfLayers<3) - ps->num_dmrs_cdm_grps_no_data = (BWP->dci_format == NR_UL_DCI_FORMAT_0_1) ? 1 : (ps->nrOfSymbols == 2 ? 1 : 2); + if (ul_bwp->transform_precoding || nrOfLayers<3) + ps->num_dmrs_cdm_grps_no_data = (ul_bwp->dci_format == NR_UL_DCI_FORMAT_0_1) ? 1 : (ps->nrOfSymbols == 2 ? 1 : 2); else ps->num_dmrs_cdm_grps_no_data = 2; /* DMRS calculations */ - ps->mapping_type = BWP->tdaList->list.array[tda]->mappingType; - ps->NR_DMRS_UplinkConfig = BWP->pusch_Config ? + ps->mapping_type = ul_bwp->tdaList->list.array[tda]->mappingType; + ps->NR_DMRS_UplinkConfig = ul_bwp->pusch_Config ? (ps->mapping_type == NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeA ? - BWP->pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup : - BWP->pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup) : NULL; + ul_bwp->pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup : + ul_bwp->pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup) : NULL; ps->dmrs_config_type = ps->NR_DMRS_UplinkConfig ? ((ps->NR_DMRS_UplinkConfig->dmrs_Type == NULL ? 0 : 1)) : 0; const pusch_dmrs_AdditionalPosition_t additional_pos = ps->NR_DMRS_UplinkConfig ? (ps->NR_DMRS_UplinkConfig->dmrs_AdditionalPosition == NULL @@ -882,13 +882,13 @@ void config_uldci(const NR_SIB1_t *sib1, dci_pdu_rel15_t *dci_pdu_rel15, int time_domain_assignment, uint8_t tpc, - NR_UE_UL_BWP_t *UBWP) { + NR_UE_UL_BWP_t *ul_bwp) { - int bwp_id = UBWP->bwp_id; - nr_dci_format_t dci_format = UBWP->dci_format; + int bwp_id = ul_bwp->bwp_id; + nr_dci_format_t dci_format = ul_bwp->dci_format; dci_pdu_rel15->frequency_domain_assignment.val = - PRBalloc_to_locationandbandwidth0(pusch_pdu->rb_size, pusch_pdu->rb_start, UBWP->BWPSize); + PRBalloc_to_locationandbandwidth0(pusch_pdu->rb_size, pusch_pdu->rb_start, ul_bwp->BWPSize); dci_pdu_rel15->time_domain_assignment.val = time_domain_assignment; dci_pdu_rel15->frequency_hopping_flag.val = pusch_pdu->frequency_hopping; dci_pdu_rel15->mcs = pusch_pdu->mcs_index; @@ -896,7 +896,7 @@ void config_uldci(const NR_SIB1_t *sib1, dci_pdu_rel15->rv = pusch_pdu->pusch_data.rv_index; dci_pdu_rel15->harq_pid = pusch_pdu->pusch_data.harq_process_id; dci_pdu_rel15->tpc = tpc; - NR_PUSCH_Config_t *pusch_Config = UBWP->pusch_Config; + NR_PUSCH_Config_t *pusch_Config = ul_bwp->pusch_Config; if (pusch_Config) AssertFatal(pusch_Config->resourceAllocation == NR_PUSCH_Config__resourceAllocation_resourceAllocationType1, "Only frequency resource allocation type 1 is currently supported\n"); @@ -908,7 +908,7 @@ void config_uldci(const NR_SIB1_t *sib1, LOG_D(NR_MAC,"Configuring DCI Format 0_1\n"); dci_pdu_rel15->dai[0].val = 0; //TODO // bwp indicator as per table 7.3.1.1.2-1 in 38.212 - dci_pdu_rel15->bwp_indicator.val = UBWP->n_ul_bwp < 4 ? bwp_id : bwp_id - 1; + dci_pdu_rel15->bwp_indicator.val = ul_bwp->n_ul_bwp < 4 ? bwp_id : bwp_id - 1; // SRS resource indicator if (pusch_Config && pusch_Config->txConfig != NULL) { @@ -1027,7 +1027,7 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, NR_PUCCH_ResourceSet_t *pucchresset; NR_PUCCH_FormatConfig_t *pucchfmt; NR_PUCCH_ResourceId_t *resource_id = NULL; - NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; + NR_UE_UL_BWP_t *current_BWP = &UE->current_UL_BWP; long *id0 = NULL; int n_list, n_set; @@ -1039,7 +1039,7 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, uint16_t O_uci = O_csi + O_ack; - NR_PUSCH_Config_t *pusch_Config = BWP->pusch_Config; + NR_PUSCH_Config_t *pusch_Config = current_BWP->pusch_Config; long *pusch_id = pusch_Config ? pusch_Config->dataScramblingIdentityPUSCH : NULL; @@ -1049,7 +1049,7 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->transformPrecodingDisabled->scramblingID0; else id0 = scc->physCellId; - NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon = BWP->pucch_ConfigCommon; + NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon = current_BWP->pucch_ConfigCommon; // hop flags and hopping id are valid for any BWP switch (pucch_ConfigCommon->pucch_GroupHopping){ @@ -1077,12 +1077,12 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, else pucch_pdu->hopping_id = *scc->physCellId; - pucch_pdu->bwp_size = BWP->BWPSize; - pucch_pdu->bwp_start = BWP->BWPStart; - pucch_pdu->subcarrier_spacing = BWP->scs; - pucch_pdu->cyclic_prefix = (BWP->cyclicprefix==NULL) ? 0 : *BWP->cyclicprefix; + pucch_pdu->bwp_size = current_BWP->BWPSize; + pucch_pdu->bwp_start = current_BWP->BWPStart; + pucch_pdu->subcarrier_spacing = current_BWP->scs; + pucch_pdu->cyclic_prefix = (current_BWP->cyclicprefix==NULL) ? 0 : *current_BWP->cyclicprefix; - NR_PUCCH_Config_t *pucch_Config = BWP->pucch_Config; + NR_PUCCH_Config_t *pucch_Config = current_BWP->pucch_Config; if (r_pucch<0 || pucch_Config){ LOG_D(NR_MAC,"pucch_acknak: Filling dedicated configuration for PUCCH\n"); @@ -1281,14 +1281,14 @@ void set_r_pucch_parms(int rsetindex, } void prepare_dci(const NR_CellGroupConfig_t *CellGroup, - const NR_UE_DL_BWP_t *BWP, + const NR_UE_DL_BWP_t *current_BWP, const NR_ControlResourceSet_t *coreset, dci_pdu_rel15_t *dci_pdu_rel15, nr_dci_format_t format) { AssertFatal(CellGroup!=NULL,"CellGroup shouldn't be null here\n"); - const NR_PDSCH_Config_t *pdsch_Config = BWP ? BWP->pdsch_Config : NULL; + const NR_PDSCH_Config_t *pdsch_Config = current_BWP ? current_BWP->pdsch_Config : NULL; switch(format) { case NR_UL_DCI_FORMAT_0_1: @@ -1350,8 +1350,8 @@ void prepare_dci(const NR_CellGroupConfig_t *CellGroup, else dci_pdu_rel15->srs_request.val = 0; // CBGTI and CBGFI - if (BWP->pdsch_servingcellconfig && - BWP->pdsch_servingcellconfig->codeBlockGroupTransmission != NULL) + if (current_BWP->pdsch_servingcellconfig && + current_BWP->pdsch_servingcellconfig->codeBlockGroupTransmission != NULL) AssertFatal(1==0,"CBG transmission currently not supported\n"); break; default : @@ -1362,7 +1362,7 @@ 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 *BWP, + const NR_UE_DL_BWP_t *current_BWP, nfapi_nr_dl_dci_pdu_t *pdcch_dci_pdu, dci_pdu_rel15_t *dci_pdu_rel15, int dci_format, @@ -1383,7 +1383,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, 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, BWP, coreset, dci_pdu_rel15, dci_format); + prepare_dci(CellGroup, current_BWP, coreset, dci_pdu_rel15, dci_format); /// Payload generation switch (dci_format) { @@ -2251,7 +2251,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, if(ul_bwp->bwp_Id == UL_BWP->bwp_id) break; } - AssertFatal(ul_bwp!=NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n",UL_BWP->bwp_id); + AssertFatal(ul_bwp!=NULL,"Couldn't find ULBWP corresponding to BWP ID %ld\n",UL_BWP->bwp_id); } // selection of dedicated BWPs @@ -2447,23 +2447,15 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; memset(sched_ctrl, 0, sizeof(*sched_ctrl)); sched_ctrl->dl_max_mcs = 28; /* do not limit MCS for individual UEs */ - sched_ctrl->set_pmi = false; - sched_ctrl->ta_frame = 0; sched_ctrl->ta_update = 31; - sched_ctrl->ta_apply = false; - sched_ctrl->ul_rssi = 0; - sched_ctrl->pucch_consecutive_dtx_cnt = 0; - sched_ctrl->pusch_consecutive_dtx_cnt = 0; - sched_ctrl->ul_failure = 0; sched_ctrl->sched_srs.frame = -1; sched_ctrl->sched_srs.slot = -1; - sched_ctrl->sched_srs.srs_scheduled = false; // initialize UE BWP information - NR_UE_DL_BWP_t *DL_BWP = &UE->current_DL_BWP; - memset(DL_BWP, 0, sizeof(*DL_BWP)); - NR_UE_UL_BWP_t *UL_BWP = &UE->current_UL_BWP; - memset(UL_BWP, 0, sizeof(*UL_BWP)); + NR_UE_DL_BWP_t *dl_bwp = &UE->current_DL_BWP; + memset(dl_bwp, 0, sizeof(*dl_bwp)); + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; + memset(ul_bwp, 0, sizeof(*ul_bwp)); configure_UE_BWP(nr_mac, scc, sched_ctrl, NULL, UE); /* set illegal time domain allocation to force recomputation of all fields */ @@ -2473,13 +2465,13 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf /* Set default BWPs */ sched_ctrl->next_dl_bwp_id = -1; sched_ctrl->next_ul_bwp_id = -1; - AssertFatal(UL_BWP->n_ul_bwp <= NR_MAX_NUM_BWP, + AssertFatal(ul_bwp->n_ul_bwp <= NR_MAX_NUM_BWP, "uplinkBWP_ToAddModList has %d BWP!\n", - UL_BWP->n_ul_bwp); + ul_bwp->n_ul_bwp); /* get Number of HARQ processes for this UE */ // pdsch_servingcellconfig == NULL in SA -> will create default (8) number of HARQ processes - create_dl_harq_list(sched_ctrl, DL_BWP->pdsch_servingcellconfig); + create_dl_harq_list(sched_ctrl, dl_bwp->pdsch_servingcellconfig); // add all available UL HARQ processes for this UE // nb of ul harq processes not configurable create_nr_list(&sched_ctrl->available_ul_harq, 16); @@ -2671,12 +2663,12 @@ void nr_csirs_scheduling(int Mod_idP, continue; } - NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; - NR_UE_UL_BWP_t *UBWP = &UE->current_UL_BWP; + NR_UE_DL_BWP_t *dl_bwp = &UE->current_DL_BWP; + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; - if (!UBWP->csi_MeasConfig) continue; + if (!ul_bwp->csi_MeasConfig) continue; - NR_CSI_MeasConfig_t *csi_measconfig = UBWP->csi_MeasConfig; + NR_CSI_MeasConfig_t *csi_measconfig = ul_bwp->csi_MeasConfig; if (csi_measconfig->nzp_CSI_RS_ResourceToAddModList != NULL) { @@ -2702,20 +2694,20 @@ void nr_csirs_scheduling(int Mod_idP, nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *csirs_pdu_rel15 = &dl_tti_csirs_pdu->csi_rs_pdu.csi_rs_pdu_rel15; - csirs_pdu_rel15->subcarrier_spacing = BWP->scs; - if (BWP->cyclicprefix) - csirs_pdu_rel15->cyclic_prefix = *BWP->cyclicprefix; + csirs_pdu_rel15->subcarrier_spacing = dl_bwp->scs; + if (dl_bwp->cyclicprefix) + csirs_pdu_rel15->cyclic_prefix = *dl_bwp->cyclicprefix; else csirs_pdu_rel15->cyclic_prefix = 0; // According to last paragraph of TS 38.214 5.2.2.3.1 - if (resourceMapping.freqBand.startingRB < BWP->BWPStart) { - csirs_pdu_rel15->start_rb = BWP->BWPStart; + if (resourceMapping.freqBand.startingRB < dl_bwp->BWPStart) { + csirs_pdu_rel15->start_rb = dl_bwp->BWPStart; } else { csirs_pdu_rel15->start_rb = resourceMapping.freqBand.startingRB; } - if (resourceMapping.freqBand.nrofRBs > (BWP->BWPStart + BWP->BWPSize - csirs_pdu_rel15->start_rb)) { - csirs_pdu_rel15->nr_of_rbs = BWP->BWPStart + BWP->BWPSize - csirs_pdu_rel15->start_rb; + if (resourceMapping.freqBand.nrofRBs > (dl_bwp->BWPStart + dl_bwp->BWPSize - csirs_pdu_rel15->start_rb)) { + csirs_pdu_rel15->nr_of_rbs = dl_bwp->BWPStart + dl_bwp->BWPSize - csirs_pdu_rel15->start_rb; } else { csirs_pdu_rel15->nr_of_rbs = resourceMapping.freqBand.nrofRBs; } @@ -2942,23 +2934,23 @@ void schedule_nr_bwp_switch(module_id_t module_id, UE_iterator(UE_info->list, UE) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_DL_BWP_t *DLBWP = &UE->current_DL_BWP; - NR_UE_UL_BWP_t *ULBWP = &UE->current_UL_BWP; + NR_UE_DL_BWP_t *dl_bwp = &UE->current_DL_BWP; + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; if (sched_ctrl->rrc_processing_timer == 0 && UE->Msg4_ACKed && sched_ctrl->next_dl_bwp_id >= 0) { int schedule_bwp_switching = false; - if (DLBWP->bwp_id == 0) { + if (dl_bwp->bwp_id == 0) { // Switching from Initial BWP to Dedicated BWP if (sched_ctrl->next_dl_bwp_id > 0 && sched_ctrl->next_ul_bwp_id > 0) { schedule_bwp_switching = true; LOG_W(NR_MAC,"%4d.%2d UE %04x Schedule BWP switch from Initial DL BWP to %ld and from Initial UL BWP to %ld\n", frame, slot, UE->rnti, sched_ctrl->next_dl_bwp_id, sched_ctrl->next_ul_bwp_id); } - } else if (DLBWP->bwp_id != sched_ctrl->next_dl_bwp_id && ULBWP->bwp_id != sched_ctrl->next_ul_bwp_id) { + } else if (dl_bwp->bwp_id != sched_ctrl->next_dl_bwp_id && ul_bwp->bwp_id != sched_ctrl->next_ul_bwp_id) { // Switching between Dedicated BWPs schedule_bwp_switching = true; LOG_W(NR_MAC,"%4d.%2d UE %04x Schedule BWP switch from dl_bwp_id %ld to %ld and from ul_bwp_id %ld to %ld\n", - frame, slot, UE->rnti, DLBWP->bwp_id, sched_ctrl->next_dl_bwp_id, ULBWP->bwp_id, sched_ctrl->next_ul_bwp_id); + frame, slot, UE->rnti, dl_bwp->bwp_id, sched_ctrl->next_dl_bwp_id, ul_bwp->bwp_id, sched_ctrl->next_ul_bwp_id); } if (schedule_bwp_switching) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 7b1c2fe01d..9987feb558 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -165,16 +165,16 @@ void nr_csi_meas_reporting(int Mod_idP, UE_iterator(RC.nrmac[Mod_idP]->UE_info.list, UE ) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_UL_BWP_t *UL_BWP = &UE->current_UL_BWP; - const int n_slots_frame = nr_slots_per_frame[UL_BWP->scs]; + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; + const int n_slots_frame = nr_slots_per_frame[ul_bwp->scs]; if ((sched_ctrl->rrc_processing_timer > 0) || (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0)) { continue; } - const NR_CSI_MeasConfig_t *csi_measconfig = UL_BWP->csi_MeasConfig; + const NR_CSI_MeasConfig_t *csi_measconfig = ul_bwp->csi_MeasConfig; if (!csi_measconfig) continue; AssertFatal(csi_measconfig->csi_ReportConfigToAddModList->list.count > 0, "NO CSI report configuration available"); - NR_PUCCH_Config_t *pucch_Config = UL_BWP->pucch_Config; + NR_PUCCH_Config_t *pucch_Config = ul_bwp->pucch_Config; for (int csi_report_id = 0; csi_report_id < csi_measconfig->csi_ReportConfigToAddModList->list.count; csi_report_id++){ NR_CSI_ReportConfig_t *csirep = csi_measconfig->csi_ReportConfigToAddModList->list.array[csi_report_id]; @@ -214,7 +214,7 @@ void nr_csi_meas_reporting(int Mod_idP, curr_pucch->resource_indicator = res_index; curr_pucch->csi_bits += nr_get_csi_bitlen(UE->csi_report_template, csi_report_id); - int bwp_start = UL_BWP->BWPStart; + int bwp_start = ul_bwp->BWPStart; // going through the list of PUCCH resources to find the one indexed by resource_id uint16_t *vrb_map_UL = &RC.nrmac[Mod_idP]->common_channels[0].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; @@ -378,7 +378,7 @@ void tci_handling(NR_UE_info_t *UE, frame_t frame, slot_t slot) { int ssb_index[MAX_NUM_SSB] = {0}; int ssb_rsrp[MAX_NUM_SSB] = {0}; uint8_t idx = 0; - NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; + NR_UE_DL_BWP_t *dl_bwp = &UE->current_DL_BWP; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; uint8_t nr_ssbri_cri = 0; @@ -388,8 +388,8 @@ void tci_handling(NR_UE_info_t *UE, frame_t frame, slot_t slot) { uint8_t i, j; //bwp indicator - int n_dl_bwp = BWP->n_dl_bwp; - const int bwp_id = BWP->bwp_id; + int n_dl_bwp = dl_bwp->n_dl_bwp; + const int bwp_id = dl_bwp->bwp_id; if (n_dl_bwp < 4) pdsch_bwp_id = bwp_id; else @@ -655,7 +655,6 @@ void evaluate_cqi_report(uint8_t *payload, long *cqi_Table){ NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_DL_BWP_t *BWP = &UE->current_DL_BWP; //TODO sub-band CQI report not yet implemented int cqi_bitlen = csi_report->csi_meas_bitlen.cqi_bitlen[ri]; @@ -679,7 +678,7 @@ void evaluate_cqi_report(uint8_t *payload, // TODO for wideband case and multiple TB const int cqi_idx = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb; - const int mcs_table = BWP->mcsTableIdx; + const int mcs_table = UE->current_DL_BWP.mcsTableIdx; const int cqi_table = sched_ctrl->CSI_report.cri_ri_li_pmi_cqi_report.cqi_table; sched_ctrl->dl_max_mcs = get_mcs_from_cqi(mcs_table, cqi_table, cqi_idx); } @@ -758,8 +757,8 @@ void extract_pucch_csi_report(NR_CSI_MeasConfig_t *csi_MeasConfig, uint16_t bitlen = uci_pdu->csi_part1.csi_part1_bit_len; NR_CSI_ReportConfig__reportQuantity_PR reportQuantity_type = NR_CSI_ReportConfig__reportQuantity_PR_NOTHING; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; - const int n_slots_frame = nr_slots_per_frame[BWP->scs]; + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; + const int n_slots_frame = nr_slots_per_frame[ul_bwp->scs]; int cumul_bits = 0; int r_index = -1; for (int csi_report_id = 0; csi_report_id < csi_MeasConfig->csi_ReportConfigToAddModList->list.count; csi_report_id++ ) { @@ -1043,8 +1042,8 @@ int nr_acknack_scheduling(int mod_id, const int CC_id = 0; const int minfbtime = RC.nrmac[mod_id]->minRXTXTIMEpdsch; const NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels[CC_id].ServingCellConfigCommon; - const NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; - const int n_slots_frame = nr_slots_per_frame[BWP->scs]; + const NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; + const int n_slots_frame = nr_slots_per_frame[ul_bwp->scs]; const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; AssertFatal(tdd || RC.nrmac[mod_id]->common_channels[CC_id].frame_type == FDD, "Dynamic TDD not handled yet\n"); const int nr_slots_period = tdd ? n_slots_frame / get_nb_periods_per_frame(tdd->dl_UL_TransmissionPeriodicity) : n_slots_frame; @@ -1059,10 +1058,10 @@ int nr_acknack_scheduling(int mod_id, * later) * * each UE has dedicated PUCCH Format 0 resources, and we use index 0! */ NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_PUCCH_Config_t *pucch_Config = BWP->pucch_Config; + NR_PUCCH_Config_t *pucch_Config = ul_bwp->pucch_Config; - int bwp_start = BWP->BWPStart; - int bwp_size = BWP->BWPSize; + int bwp_start = ul_bwp->BWPStart; + int bwp_size = ul_bwp->BWPSize; NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[0]; LOG_D(NR_MAC, "In %s: %4d.%2d Trying to allocate pucch, current DAI %d\n", __FUNCTION__, frame, slot, pucch->dai_c); @@ -1308,10 +1307,10 @@ void nr_sr_reporting(gNB_MAC_INST *nrmac, frame_t SFN, sub_frame_t slot) UE_iterator(nrmac->UE_info.list, UE) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; - const int n_slots_frame = nr_slots_per_frame[BWP->scs]; + NR_UE_UL_BWP_t *ul_bwp = &UE->current_UL_BWP; + const int n_slots_frame = nr_slots_per_frame[ul_bwp->scs]; if (sched_ctrl->ul_failure==1 || sched_ctrl->rrc_processing_timer>0) continue; - NR_PUCCH_Config_t *pucch_Config = BWP->pucch_Config; + NR_PUCCH_Config_t *pucch_Config = ul_bwp->pucch_Config; if (!pucch_Config || !pucch_Config->schedulingRequestResourceToAddModList) continue; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 81d2e1e201..27af724c20 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1052,11 +1052,11 @@ void pf_ul(module_id_t module_id, LOG_D(NR_MAC,"pf_ul: preparing UL scheduling for UE %04x\n",UE->rnti); NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - NR_UE_UL_BWP_t *BWP = &UE->current_UL_BWP; + NR_UE_UL_BWP_t *current_BWP = &UE->current_UL_BWP; int rbStart = 0; // wrt BWP start - const uint16_t bwpSize = BWP->BWPSize; + const uint16_t bwpSize = current_BWP->BWPSize; NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; const NR_mac_dir_stats_t *stats = &UE->mac_stats.ul; @@ -1149,7 +1149,7 @@ void pf_ul(module_id_t module_id, const int tda = get_ul_tda(nrmac, scc, sched_pusch->slot); if (ps->time_domain_allocation != tda || ps->nrOfLayers != nrOfLayers) { - nr_set_pusch_semi_static(BWP, + nr_set_pusch_semi_static(current_BWP, scc, tda, nrOfLayers, @@ -1176,7 +1176,7 @@ void pf_ul(module_id_t module_id, NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; sched_pusch->mcs = min(nrmac->min_grant_mcs, sched_pusch->mcs); - update_ul_ue_R_Qm(sched_pusch, BWP->pusch_Config, BWP->mcs_table); + update_ul_ue_R_Qm(sched_pusch, current_BWP->pusch_Config, current_BWP->mcs_table); sched_pusch->rbStart = rbStart; sched_pusch->rbSize = min_rb; sched_pusch->tb_size = nr_compute_tbs(sched_pusch->Qm, @@ -1199,7 +1199,7 @@ void pf_ul(module_id_t module_id, /* Create UE_sched for UEs eligibale for new data transmission*/ /* Calculate coefficient*/ - const uint32_t tbs = ul_pf_tbs[BWP->mcs_table][sched_pusch->mcs]; + const uint32_t tbs = ul_pf_tbs[current_BWP->mcs_table][sched_pusch->mcs]; float coeff_ue = (float) tbs / UE->ul_thr_ue; LOG_D(NR_MAC,"rnti %04x b %d, ul_thr_ue %f, tbs %d, coeff_ue %f\n", UE->rnti, b, UE->ul_thr_ue, tbs, coeff_ue); @@ -1242,9 +1242,9 @@ void pf_ul(module_id_t module_id, } else LOG_D(NR_MAC, "%4d.%2d free CCE for UL DCI UE %04x\n",frame,slot, iterator->UE->rnti); - NR_UE_UL_BWP_t *BWP = &iterator->UE->current_UL_BWP; + NR_UE_UL_BWP_t *current_BWP = &iterator->UE->current_UL_BWP; - const uint16_t bwpSize = BWP->BWPSize; + const uint16_t bwpSize = current_BWP->BWPSize; NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; @@ -1256,13 +1256,13 @@ void pf_ul(module_id_t module_id, const int tda = get_ul_tda(nrmac, scc, sched_pusch->slot); if (ps->time_domain_allocation != tda || ps->nrOfLayers != nrOfLayers) { - nr_set_pusch_semi_static(BWP, + nr_set_pusch_semi_static(current_BWP, scc, tda, nrOfLayers, ps); } - update_ul_ue_R_Qm(sched_pusch, BWP->pusch_Config, BWP->mcs_table); + update_ul_ue_R_Qm(sched_pusch, current_BWP->pusch_Config, current_BWP->mcs_table); int rbStart = 0; const uint16_t slbitmap = SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); @@ -1341,16 +1341,16 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t * TDAs yet). If the TDA is negative, it means that there is no UL slot to * schedule now (slot + k2 is not UL slot) */ NR_UE_sched_ctrl_t *sched_ctrl = &nr_mac->UE_info.list[0]->UE_sched_ctrl; - NR_UE_UL_BWP_t *BWP = &nr_mac->UE_info.list[0]->current_UL_BWP; - int mu = BWP->scs; + NR_UE_UL_BWP_t *current_BWP = &nr_mac->UE_info.list[0]->current_UL_BWP; + int mu = current_BWP->scs; const int temp_tda = get_ul_tda(nr_mac, scc, slot); - int K2 = get_K2(BWP->tdaList, temp_tda, mu); + int K2 = get_K2(current_BWP->tdaList, temp_tda, mu); const int sched_frame = (frame + (slot + K2 >= nr_slots_per_frame[mu])) & 1023; const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; const int tda = get_ul_tda(nr_mac, scc, sched_slot); if (tda < 0) return false; - DevAssert(K2 == get_K2(BWP->tdaList, tda, mu)); + DevAssert(K2 == get_K2(current_BWP->tdaList, tda, mu)); if (!is_xlsch_in_slot(nr_mac->ulsch_slot_bitmap[sched_slot / 64], sched_slot)) return false; @@ -1364,7 +1364,7 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t is_xlsch_in_slot(nr_mac->ulsch_slot_bitmap[sched_slot / 64], sched_slot); // FIXME: Avoid mixed slots for initialUplinkBWP - if (BWP->bwp_id==0 && is_mixed_slot) + if (current_BWP->bwp_id==0 && is_mixed_slot) return false; // Avoid slots with the SRS @@ -1379,9 +1379,9 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t sched_ctrl->sched_pusch.frame = sched_frame; UE_iterator(nr_mac->UE_info.list, UE2) { NR_UE_sched_ctrl_t *sched_ctrl = &UE2->UE_sched_ctrl; - AssertFatal(K2 == get_K2(BWP->tdaList, tda, mu), + AssertFatal(K2 == get_K2(current_BWP->tdaList, tda, mu), "Different K2, %d(UE%d) != %ld(UE%04x)\n", - K2, 0, get_K2(BWP->tdaList, tda, mu), UE2->rnti); + K2, 0, get_K2(current_BWP->tdaList, tda, mu), UE2->rnti); sched_ctrl->sched_pusch.slot = sched_slot; sched_ctrl->sched_pusch.frame = sched_frame; } @@ -1392,10 +1392,10 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; - const uint16_t bwpSize = BWP->BWPSize; - const uint16_t bwpStart = BWP->BWPStart; + const uint16_t bwpSize = current_BWP->BWPSize; + const uint16_t bwpStart = current_BWP->BWPStart; - const int startSymbolAndLength = BWP->tdaList->list.array[tda]->startSymbolAndLength; + const int startSymbolAndLength = current_BWP->tdaList->list.array[tda]->startSymbolAndLength; int startSymbolIndex, nrOfSymbols; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); const uint16_t symb = SL_to_bitmap(startSymbolIndex, nrOfSymbols); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index b6149e9090..fe5affbf38 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -192,7 +192,7 @@ void config_uldci(const NR_SIB1_t *sib1, dci_pdu_rel15_t *dci_pdu_rel15, int time_domain_assignment, uint8_t tpc, - NR_UE_UL_BWP_t *BWP); + NR_UE_UL_BWP_t *ul_bwp); void nr_schedule_pucch(gNB_MAC_INST *nrmac, frame_t frameP, @@ -285,7 +285,7 @@ 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 *BWP, + const NR_UE_DL_BWP_t *dl_bwp, nfapi_nr_dl_dci_pdu_t *pdcch_dci_pdu, dci_pdu_rel15_t *dci_pdu_rel15, int dci_formats, @@ -296,7 +296,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, uint16_t cset0_bwp_size); void prepare_dci(const NR_CellGroupConfig_t *CellGroup, - const NR_UE_DL_BWP_t *BWP, + const NR_UE_DL_BWP_t *dl_bwp, const NR_ControlResourceSet_t *coreset, dci_pdu_rel15_t *dci_pdu_rel15, nr_dci_format_t format); @@ -325,14 +325,14 @@ long get_K2(NR_PUSCH_TimeDomainResourceAllocationList_t *tdaList, int time_domain_assignment, int mu); -void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *BWP, +void nr_set_pdsch_semi_static(const NR_UE_DL_BWP_t *dl_bwp, const NR_ServingCellConfigCommon_t *scc, int tda, uint8_t layers, NR_UE_sched_ctrl_t *sched_ctrl, NR_pdsch_semi_static_t *ps); -void nr_set_pusch_semi_static(const NR_UE_UL_BWP_t *BWP, +void nr_set_pusch_semi_static(const NR_UE_UL_BWP_t *ul_bwp, const NR_ServingCellConfigCommon_t *scc, int tda, uint8_t nrOfLayers, From 9333f53dc8a475c97951f3cf16fc43aae2a9ea15 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 4 Aug 2022 17:46:18 +0200 Subject: [PATCH 16/16] adding an assertion in configure_UE_BWP --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 497546184f..a737e66c40 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2181,6 +2181,8 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, NR_RA_t *ra, NR_UE_info_t *UE) { + AssertFatal((ra != NULL && UE == NULL) || (ra == NULL && UE != NULL), "RA and UE structures are mutually exlusive in BWP configuration\n"); + NR_CellGroupConfig_t *CellGroup; NR_UE_DL_BWP_t *DL_BWP; NR_UE_UL_BWP_t *UL_BWP;