From 7a9ad3dbf7426122c68822c50fbae03e20ba9f05 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 9 Dec 2020 11:30:31 +0100 Subject: [PATCH] Keep track of used PUCCH resources --- openair2/LAYER2/NR_MAC_gNB/config.c | 8 ++++++++ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 3 +++ openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 4 ++++ openair2/NR_PHY_INTERFACE/NR_IF_Module.c | 3 +++ 4 files changed, 18 insertions(+) diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index bd6a8f3384..094b751549 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -350,6 +350,14 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, AssertFatal(RC.nrmac[Mod_idP]->common_channels[0].vrb_map_UL, "could not allocate memory for RC.nrmac[]->common_channels[0].vrb_map_UL\n"); + for (int i = 0; i < MAX_NUM_BWP; ++i) { + RC.nrmac[Mod_idP]->pucch_index_used[i] = + calloc(n, sizeof(*RC.nrmac[Mod_idP]->pucch_index_used)); + AssertFatal(RC.nrmac[Mod_idP]->pucch_index_used[i], + "could not allocate memory for RC.nrmac[]->pucch_index_used[%d]\n", + i); + } + LOG_I(MAC,"Configuring common parameters from NR ServingCellConfig\n"); config_common(Mod_idP, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 247d0e2a94..09da2c7391 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -455,12 +455,15 @@ bool nr_acknack_scheduling(int mod_id, curr_pucch->frame = frame; curr_pucch->dai_c++; + int *pucch_index_used = RC.nrmac[mod_id]->pucch_index_used[sched_ctrl->active_ubwp->bwp_Id]; if (curr_pucch->dai_c == 1) { /* FIXME for first allocation: find free resource, here assume first PUCCH * resource and first_ul_slot_tdd */ const int pucch_res = 0; curr_pucch->resource_indicator = pucch_res; curr_pucch->ul_slot = first_ul_slot_tdd; + DevAssert(pucch_index_used[first_ul_slot_tdd] == 0); + pucch_index_used[first_ul_slot_tdd] += 1; /* verify that at that slot and symbol, resources are free. * Note: this does not handle potential mux of PUCCH in the same symbol! */ diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 445f0e19de..894769ca71 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -552,6 +552,10 @@ typedef struct gNB_MAC_INST_s { time_stats_t schedule_pch; /// CCE lists int cce_list[MAX_NUM_BWP][MAX_NUM_CORESET][MAX_NUM_CCE]; + /// PUCCH: keep track of the resources has already been used by saving the + /// highest index not yet been used in a given slot. Dynamically allocated + /// so we can have it for every slot as a function of the numerology + int *pucch_index_used[MAX_NUM_BWP]; /// DL preprocessor for differentiated scheduling nr_pp_impl_dl pre_processor_dl; diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index 7f98dd6a3e..b5cda6ecd6 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -104,6 +104,9 @@ void handle_nr_uci(NR_UL_IND_t *UL_info) } UL_info->uci_ind.num_ucis = 0; + // mark corresponding PUCCH resources as free + // NOTE: we just assume it is BWP ID 1, to be revised for multiple BWPs + RC.nrmac[mod_id]->pucch_index_used[1][slot] = 0; }