diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 74414a00b2..97463a406f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1535,13 +1535,11 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra return; } - 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; const int delta_PRI=0; - int r_pucch = ((CCEIndex<<1)/N_cce)+(delta_PRI<<1); + int r_pucch = nr_get_pucch_resource(coreset, sched_ctrl->active_ubwp, NULL, 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); - LOG_D(NR_MAC,"[RAPROC] Msg4 r_pucch %d (CCEIndex %d, N_cce %d, nb_of_candidates %d,delta_PRI %d)\n",r_pucch,CCEIndex,N_cce,nr_of_candidates,delta_PRI); int alloc = nr_acknack_scheduling(module_idP, UE_id, frameP, slotP, r_pucch, 1); AssertFatal(alloc>=0,"Couldn't find a pucch allocation for ack nack (msg4)\n"); NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[alloc]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 17277576ac..f3c366ceeb 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -557,6 +557,13 @@ bool allocate_dl_retransmission(module_id_t module_id, cg->spCellConfig->spCellConfigDedicated ? cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; + 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 = NULL; if(sched_ctrl->active_bwp) { genericParameters = &sched_ctrl->active_bwp->bwp_Common->genericParameters; @@ -662,12 +669,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 n_rb,rb_offset; - get_coreset_rballoc(sched_ctrl->coreset->frequencyDomainResources.buf,&n_rb,&rb_offset); - const uint16_t N_cce = n_rb * sched_ctrl->coreset->duration / NR_NB_REG_PER_CCE; - const int delta_PRI=0; - int r_pucch = ((sched_ctrl->cce_index<<1)/N_cce)+(delta_PRI<<1); - + int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, ubwpd, CCEIndex); const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, r_pucch, 0); if (alloc<0) { LOG_D(MAC, @@ -792,6 +794,13 @@ void pf_dl(module_id_t module_id, cg->spCellConfig->spCellConfigDedicated ? cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL; + 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 = &UE_info->UE_sched_ctrl[UE_id]; const uint16_t rnti = UE_info->rnti[UE_id]; @@ -845,12 +854,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 n_rb,rb_offset; - get_coreset_rballoc(sched_ctrl->coreset->frequencyDomainResources.buf,&n_rb,&rb_offset); - const uint16_t N_cce = n_rb * sched_ctrl->coreset->duration / NR_NB_REG_PER_CCE; - const int delta_PRI=0; - int r_pucch = ((sched_ctrl->cce_index<<1)/N_cce)+(delta_PRI<<1); - + int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, ubwpd, CCEIndex); const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, r_pucch, 0); if (alloc<0) { LOG_D(NR_MAC, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index ce97a483e8..21248c9b9e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -361,12 +361,7 @@ void nr_preprocessor_phytest(module_id_t module_id, __func__, UE_id); - int n_rb,rb_offset; - get_coreset_rballoc(sched_ctrl->coreset->frequencyDomainResources.buf,&n_rb,&rb_offset); - const uint16_t N_cce = n_rb * sched_ctrl->coreset->duration / NR_NB_REG_PER_CCE; - const int delta_PRI=0; - int r_pucch = ((sched_ctrl->cce_index<<1)/N_cce)+(delta_PRI<<1); - + int r_pucch = nr_get_pucch_resource(sched_ctrl->coreset, sched_ctrl->active_ubwp, NULL, CCEIndex); const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, r_pucch, 0); if (alloc < 0) { LOG_D(MAC, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index e8171ead15..111fc1197a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -930,6 +930,20 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, pdcch_pdu->precoderGranularity = coreset->precoderGranularity; } +int nr_get_pucch_resource(NR_ControlResourceSet_t *coreset, + NR_BWP_Uplink_t *bwp, + NR_BWP_UplinkDedicated_t *bwpd, + int CCEIndex) { + int r_pucch = -1; + if(bwp == NULL && bwpd == 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; + const int delta_PRI=0; + r_pucch = ((CCEIndex<<1)/N_cce)+(delta_PRI<<1); + } + return r_pucch; +} // This function configures pucch pdu fapi structure void nr_configure_pucch(module_id_t module_id, @@ -1026,7 +1040,7 @@ void nr_configure_pucch(module_id_t module_id, 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; - if (bwp || bwpd) { + 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 AssertFatal(bwp!=NULL || bwpd!=NULL,"We need one dedicated configuration for a BWP (neither additional or initial BWP has a dedicated configuration)\n"); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index b7a463f24f..6c6e4a7242 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -236,6 +236,11 @@ int nr_is_dci_opportunity(nfapi_nr_search_space_t search_space, nfapi_nr_config_request_scf_t cfg); */ +int nr_get_pucch_resource(NR_ControlResourceSet_t *coreset, + NR_BWP_Uplink_t *bwp, + NR_BWP_UplinkDedicated_t *bwpd, + int CCEIndex); + void nr_configure_pucch(module_id_t module_id, nfapi_nr_pucch_pdu_t* pucch_pdu, NR_ServingCellConfigCommon_t *scc,