From 1dd8c67fc2c1cae82b2829138efe0e366eeecdb7 Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 7 Dec 2021 14:35:42 +0100 Subject: [PATCH 01/13] block ul prbs in map with prbbl --- openair2/GNB_APP/gnb_config.c | 6 +++--- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 2 +- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 9851d14b91..4a13aec400 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -675,13 +675,13 @@ void RCconfig_nr_macrlc() { config_getlist( &GNBParamList,GNBParams,sizeof(GNBParams)/sizeof(paramdef_t),NULL); char *ulprbbl = *GNBParamList.paramarray[0][GNB_ULPRBBLACKLIST_IDX].strptr; char *pt = strtok(ulprbbl,","); - int prbbl[275]; + uint16_t prbbl[275]; int num_prbbl=0; int prb; - memset(prbbl,0,275*sizeof(int)); + memset(prbbl,0,275*sizeof(uint16_t)); while (pt) { prb=atoi(pt); - prbbl[prb] = 1; + prbbl[prb] = 0x3FFF; // all symbols taken pt = strtok(NULL,","); num_prbbl++; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index ae52f8cc60..9516c9a347 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -323,7 +323,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, const int num_slots = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; const int last_slot = (slot + num_slots - 1) % num_slots; uint16_t *vrb_map_UL = cc[CC_id].vrb_map_UL; - memset(&vrb_map_UL[last_slot * MAX_BWP_SIZE], 0, sizeof(uint16_t) * MAX_BWP_SIZE); + memcpy(&vrb_map_UL[last_slot * MAX_BWP_SIZE], &RC.nrmac[module_idP]->ulprbbl, MAX_BWP_SIZE); clear_nr_nfapi_information(RC.nrmac[module_idP], CC_id, frame, slot); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 45e0a5b52b..32fdce60d3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -697,7 +697,7 @@ typedef struct gNB_MAC_INST_s { /// current PDU index (BCH,DLSCH) uint16_t pdu_index[NFAPI_CC_MAX]; int num_ulprbbl; - int ulprbbl[275]; + uint16_t ulprbbl[275]; /// NFAPI Config Request Structure nfapi_nr_config_request_scf_t config[NFAPI_CC_MAX]; /// NFAPI DL Config Request Structure From 7cb3739cf6918029414f43b095db14e842b143fc Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 7 Dec 2021 14:54:48 +0100 Subject: [PATCH 02/13] bitmap occupation function --- common/utils/nr/nr_common.c | 5 +++++ common/utils/nr/nr_common.h | 1 + 2 files changed, 6 insertions(+) diff --git a/common/utils/nr/nr_common.c b/common/utils/nr/nr_common.c index a704a66c76..42c7ef9c7e 100644 --- a/common/utils/nr/nr_common.c +++ b/common/utils/nr/nr_common.c @@ -472,6 +472,11 @@ int get_subband_size(int NPRB,int size) { } +// from start symbol index and nb or symbols to symbol occupation bitmap in a slot +uint16_t startandlength_to_bitmat(int startSymbolIndex, int nrOfSymbols) { + return (((1< Date: Wed, 8 Dec 2021 09:27:33 +0100 Subject: [PATCH 03/13] symbol level occupation for ULSCH and msg3 --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 15 ++- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 5 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 94 ++++++++++--------- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 2 + 4 files changed, 66 insertions(+), 50 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 25aeea70a6..0d0c8980ce 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -729,6 +729,8 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t 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; + SLIV2SL(startSymbolAndLength, &StartSymbolIndex, &NrOfSymbols); int mappingtype = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->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]; @@ -737,7 +739,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t int BWPSize = nr_mac->type0_PDCCH_CSS_config[ra->beam_id].num_rbs; int rbStart = 0; for (int i = 0; (i < ra->msg3_nb_rb) && (rbStart <= (BWPSize - ra->msg3_nb_rb)); i++) { - if (vrb_map_UL[rbStart + BWPStart + i]) { + if (vrb_map_UL[rbStart + BWPStart + i]&startandlength_to_bitmat(StartSymbolIndex, NrOfSymbols)) { rbStart += i; i = 0; } @@ -842,7 +844,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t // Mark the corresponding RBs as used for (int rb = 0; rb < ra->msg3_nb_rb; rb++) { - vrb_map_UL[rbStart + BWPStart + rb] = 1; + vrb_map_UL[rbStart + BWPStart + rb] |= startandlength_to_bitmat(StartSymbolIndex, NrOfSymbols); } // reset state to wait msg3 @@ -891,6 +893,8 @@ void nr_get_Msg3alloc(module_id_t module_id, ra->Msg3_slot = temp_slot%nr_slots_per_frame[mu]; if (is_xlsch_in_slot(RC.nrmac[module_id]->ulsch_slot_bitmap[ra->Msg3_slot / 64], ra->Msg3_slot)) { ra->Msg3_tda_id = i; + ra->msg3_startsymb = StartSymbolIndex; + ra->msg3_nrsymb = NrOfSymbols; break; } } @@ -938,11 +942,12 @@ void nr_get_Msg3alloc(module_id_t module_id, while (rbSize < msg3_nb_rb) { rbStart += rbSize; /* last iteration rbSize was not enough, skip it */ rbSize = 0; - while (rbStart < bwpSize && vrb_map_UL[rbStart + bwpStart]) + while (rbStart < bwpSize && + (vrb_map_UL[rbStart + bwpStart]&startandlength_to_bitmat(StartSymbolIndex, NrOfSymbols))) rbStart++; AssertFatal(rbStart < bwpSize - msg3_nb_rb, "no space to allocate Msg 3 for RA!\n"); while (rbStart + rbSize < bwpSize - && !vrb_map_UL[rbStart + bwpStart + rbSize] + && !(vrb_map_UL[rbStart + bwpStart + rbSize]&startandlength_to_bitmat(StartSymbolIndex, NrOfSymbols)) && rbSize < msg3_nb_rb) rbSize++; } @@ -1039,7 +1044,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t i + ra->msg3_first_rb, ra->Msg3_frame, ra->Msg3_slot); - vrb_map_UL[i + ra->msg3_first_rb + ra->msg3_bwp_start] = 1; + vrb_map_UL[i + ra->msg3_first_rb + ra->msg3_bwp_start] |= startandlength_to_bitmat(ra->msg3_startsymb, ra->msg3_nrsymb); } LOG_D(NR_MAC, "[gNB %d][RAPROC] Frame %d, Slot %d : CC_id %d RA is active, Msg3 in (%d,%d)\n", module_idP, frameP, slotP, CC_id, ra->Msg3_frame, ra->Msg3_slot); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index c0107c5fc6..d939ed8139 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -473,9 +473,8 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; - const uint16_t symb = ((1 << ps->nrOfSymbols) - 1) << ps->startSymbolIndex; for (int i = rbStart; i < rbStart + rbSize; ++i) { - if ((vrb_map_UL[i+BWPStart] & symb) != 0) { + if ((vrb_map_UL[i+BWPStart] & startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols)) != 0) { LOG_E(MAC, "%s(): %4d.%2d RB %d is already reserved, cannot schedule UE\n", __func__, @@ -544,6 +543,6 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ /* mark the corresponding RBs as used */ for (int rb = rbStart; rb < rbStart + rbSize; rb++) - vrb_map_UL[rb+BWPStart] = 1; + vrb_map_UL[rb+BWPStart] |= startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols); return true; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index d14cf09f99..949f148121 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -938,13 +938,6 @@ bool allocate_ul_retransmission(module_id_t module_id, 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) { - /* Check the resource is enough for retransmission */ - while (rbStart < bwpSize && !rballoc_mask[rbStart]) - rbStart++; - if (rbStart + retInfo->rbSize > bwpSize) { - LOG_W(NR_MAC, "cannot allocate retransmission of UE %d/RNTI %04x: no resources (rbStart %d, retInfo->rbSize %d, bwpSize %d\n", UE_id, UE_info->rnti[UE_id], rbStart, retInfo->rbSize, bwpSize); - return false; - } /* 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; @@ -955,18 +948,30 @@ bool allocate_ul_retransmission(module_id_t module_id, || ps->dci_format != dci_format || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, ubwpd, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); + + /* Check the resource is enough for retransmission */ + while (rbStart < bwpSize && + !(rballoc_mask[rbStart]&startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols))) + rbStart++; + if (rbStart + retInfo->rbSize > bwpSize) { + LOG_W(NR_MAC, "cannot allocate retransmission of UE %d/RNTI %04x: no resources (rbStart %d, retInfo->rbSize %d, bwpSize %d\n", UE_id, UE_info->rnti[UE_id], rbStart, retInfo->rbSize, bwpSize); + return false; + } + LOG_D(NR_MAC, "%s(): retransmission keeping TDA %d and TBS %d\n", __func__, tda, retInfo->tb_size); } else { - /* the retransmission will use a different time domain allocation, check - * that we have enough resources */ - while (rbStart < bwpSize && !rballoc_mask[rbStart]) - rbStart++; - int rbSize = 0; - while (rbStart + rbSize < bwpSize && rballoc_mask[rbStart + rbSize]) - rbSize++; NR_pusch_semi_static_t temp_ps; int dci_format = get_dci_format(sched_ctrl); nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp,ubwpd, dci_format, tda, num_dmrs_cdm_grps_no_data, &temp_ps); + /* the retransmission will use a different time domain allocation, check + * that we have enough resources */ + while (rbStart < bwpSize && + !(rballoc_mask[rbStart]&startandlength_to_bitmat(temp_ps.startSymbolIndex, temp_ps.nrOfSymbols))) + rbStart++; + int rbSize = 0; + while (rbStart + rbSize < bwpSize && + (rballoc_mask[rbStart + rbSize]&startandlength_to_bitmat(temp_ps.startSymbolIndex, temp_ps.nrOfSymbols))) + rbSize++; uint32_t new_tbs; uint16_t new_rbSize; bool success = nr_find_nb_rb(retInfo->Qm, @@ -1022,7 +1027,7 @@ bool allocate_ul_retransmission(module_id_t module_id, /* Mark the corresponding RBs as used */ n_rb_sched -= sched_pusch->rbSize; for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] = 0; + rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] -= startandlength_to_bitmat(sched_ctrl->pusch_semi_static.startSymbolIndex, sched_ctrl->pusch_semi_static.nrOfSymbols); return true; } @@ -1121,14 +1126,6 @@ void pf_ul(module_id_t module_id, if (max_num_ue < 0) return; - LOG_D(NR_MAC,"Looking for min_rb %d RBs, starting at %d\n", min_rb, rbStart); - while (rbStart < bwpSize && !rballoc_mask[rbStart]) rbStart++; - if (rbStart + min_rb >= bwpSize) { - LOG_W(NR_MAC, "cannot allocate continuous UL data for UE %d/RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d\n", - UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); - return; - } - /* 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 @@ -1140,6 +1137,17 @@ void pf_ul(module_id_t module_id, || ps->dci_format != dci_format || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, ubwpd, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); + + LOG_D(NR_MAC,"Looking for min_rb %d RBs, starting at %d\n", min_rb, rbStart); + while (rbStart < bwpSize && + !(rballoc_mask[rbStart]&startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols))) + rbStart++; + if (rbStart + min_rb >= bwpSize) { + LOG_W(NR_MAC, "cannot allocate continuous UL data for UE %d/RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d\n", + UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); + return; + } + NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; sched_pusch->mcs = 9; update_ul_ue_R_Qm(sched_pusch, ps); @@ -1158,7 +1166,7 @@ void pf_ul(module_id_t module_id, /* Mark the corresponding RBs as used */ n_rb_sched -= sched_pusch->rbSize; for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] = 0; + rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] -= startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols); continue; } @@ -1215,19 +1223,6 @@ void pf_ul(module_id_t module_id, NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; - while (rbStart < bwpSize && !rballoc_mask[rbStart]) rbStart++; - sched_pusch->rbStart = rbStart; - uint16_t max_rbSize = 1; - while (rbStart + max_rbSize < bwpSize && rballoc_mask[rbStart + max_rbSize]) - max_rbSize++; - - if (rbStart + min_rb >= bwpSize) { - LOG_W(NR_MAC, "cannot allocate UL data for UE %d/RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d\n", - UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); - return; - } - else LOG_D(NR_MAC,"allocating UL data for UE %d/RNTI %04x (rbStsart %d, min_rb %d, bwpSize %d\n",UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); - /* 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 @@ -1241,6 +1236,23 @@ void pf_ul(module_id_t module_id, nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, ubwpd, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); update_ul_ue_R_Qm(sched_pusch, ps); + while (rbStart < bwpSize && + !(rballoc_mask[rbStart]&startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols))) + rbStart++; + sched_pusch->rbStart = rbStart; + uint16_t max_rbSize = 1; + while (rbStart + max_rbSize < bwpSize && + (rballoc_mask[rbStart + max_rbSize]&&startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols))) + max_rbSize++; + + if (rbStart + min_rb >= bwpSize) { + LOG_W(NR_MAC, "cannot allocate UL data for UE %d/RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d\n", + UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); + return; + } + else LOG_D(NR_MAC,"allocating UL data for UE %d/RNTI %04x (rbStsart %d, min_rb %d, bwpSize %d\n",UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); + + /* Calculate the current scheduling bytes and the necessary RBs */ const int B = cmax(sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes, 0); uint16_t rbSize = 0; @@ -1261,7 +1273,7 @@ void pf_ul(module_id_t module_id, /* Mark the corresponding RBs as used */ n_rb_sched -= sched_pusch->rbSize; for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] = 0; + rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] -= startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols); } } @@ -1330,11 +1342,9 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; int startSymbolIndex, nrOfSymbols; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); - const uint16_t symb = ((1 << nrOfSymbols) - 1) << startSymbolIndex; + const uint16_t symb = startandlength_to_bitmat(startSymbolIndex, nrOfSymbols); int st = 0, e = 0, len = 0; - for (int i = 0; i < bwpSize; i++) - if (RC.nrmac[module_id]->ulprbbl[i] == 1) vrb_map_UL[i]=symb; for (int i = 0; i < bwpSize; i++) { while ((vrb_map_UL[bwpStart + i] & symb) != 0 && i < bwpSize) @@ -1355,7 +1365,7 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t /* Calculate mask: if any RB in vrb_map_UL is blocked (1), the current RB will be 0 */ for (int i = 0; i < bwpSize; i++) - rballoc_mask[i] = i >= st && i <= e; + rballoc_mask[i] = (i >= st && i <= e)*startandlength_to_bitmat(startSymbolIndex, nrOfSymbols); /* proportional fair scheduling algorithm */ pf_ul(module_id, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 32fdce60d3..3944cb34f9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -157,6 +157,8 @@ typedef struct { uint8_t msg3_round; /// Flag to indicate if Msg3 carries a DCCH or DTCH message bool msg3_dcch_dtch; + int msg3_startsymb; + int msg3_nrsymb; /// TBS used for Msg4 int msg4_TBsize; /// MCS used for Msg4 From 366c42e6fa030b7f81c8d91509949bbfbe6377f7 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 15 Dec 2021 09:31:30 +0100 Subject: [PATCH 04/13] fix in prach vrb occupation --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 0d0c8980ce..d1fcdc7c05 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -389,7 +389,7 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP const int16_t N_RA_RB = get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing.value, mu_pusch); uint16_t *vrb_map_UL = &cc->vrb_map_UL[slotP * MAX_BWP_SIZE]; for (int i = 0; i < N_RA_RB * fdm; ++i) - vrb_map_UL[bwp_start + rach_ConfigGeneric->msg1_FrequencyStart + i] = 0xff; // all symbols + vrb_map_UL[bwp_start + rach_ConfigGeneric->msg1_FrequencyStart + i] = 0x3fff; // all symbols } } } From 909f0ad44f38e4dc90b20185df64a9c5f57f8690 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 15 Dec 2021 09:43:08 +0100 Subject: [PATCH 05/13] changing the name of a function --- common/utils/nr/nr_common.c | 2 +- common/utils/nr/nr_common.h | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 10 ++++----- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 4 ++-- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 22 +++++++++---------- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/common/utils/nr/nr_common.c b/common/utils/nr/nr_common.c index 42c7ef9c7e..dbe3d218f3 100644 --- a/common/utils/nr/nr_common.c +++ b/common/utils/nr/nr_common.c @@ -473,7 +473,7 @@ int get_subband_size(int NPRB,int size) { } // from start symbol index and nb or symbols to symbol occupation bitmap in a slot -uint16_t startandlength_to_bitmat(int startSymbolIndex, int nrOfSymbols) { +uint16_t SL_to_bitmap(int startSymbolIndex, int nrOfSymbols) { return (((1<type0_PDCCH_CSS_config[ra->beam_id].num_rbs; int rbStart = 0; for (int i = 0; (i < ra->msg3_nb_rb) && (rbStart <= (BWPSize - ra->msg3_nb_rb)); i++) { - if (vrb_map_UL[rbStart + BWPStart + i]&startandlength_to_bitmat(StartSymbolIndex, NrOfSymbols)) { + if (vrb_map_UL[rbStart + BWPStart + i]&SL_to_bitmap(StartSymbolIndex, NrOfSymbols)) { rbStart += i; i = 0; } @@ -844,7 +844,7 @@ void nr_generate_Msg3_retransmission(module_id_t module_idP, int CC_id, frame_t // Mark the corresponding RBs as used for (int rb = 0; rb < ra->msg3_nb_rb; rb++) { - vrb_map_UL[rbStart + BWPStart + rb] |= startandlength_to_bitmat(StartSymbolIndex, NrOfSymbols); + vrb_map_UL[rbStart + BWPStart + rb] |= SL_to_bitmap(StartSymbolIndex, NrOfSymbols); } // reset state to wait msg3 @@ -943,11 +943,11 @@ void nr_get_Msg3alloc(module_id_t module_id, rbStart += rbSize; /* last iteration rbSize was not enough, skip it */ rbSize = 0; while (rbStart < bwpSize && - (vrb_map_UL[rbStart + bwpStart]&startandlength_to_bitmat(StartSymbolIndex, NrOfSymbols))) + (vrb_map_UL[rbStart + bwpStart]&SL_to_bitmap(StartSymbolIndex, NrOfSymbols))) rbStart++; AssertFatal(rbStart < bwpSize - msg3_nb_rb, "no space to allocate Msg 3 for RA!\n"); while (rbStart + rbSize < bwpSize - && !(vrb_map_UL[rbStart + bwpStart + rbSize]&startandlength_to_bitmat(StartSymbolIndex, NrOfSymbols)) + && !(vrb_map_UL[rbStart + bwpStart + rbSize]&SL_to_bitmap(StartSymbolIndex, NrOfSymbols)) && rbSize < msg3_nb_rb) rbSize++; } @@ -1044,7 +1044,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t i + ra->msg3_first_rb, ra->Msg3_frame, ra->Msg3_slot); - vrb_map_UL[i + ra->msg3_first_rb + ra->msg3_bwp_start] |= startandlength_to_bitmat(ra->msg3_startsymb, ra->msg3_nrsymb); + vrb_map_UL[i + ra->msg3_first_rb + ra->msg3_bwp_start] |= SL_to_bitmap(ra->msg3_startsymb, ra->msg3_nrsymb); } LOG_D(NR_MAC, "[gNB %d][RAPROC] Frame %d, Slot %d : CC_id %d RA is active, Msg3 in (%d,%d)\n", module_idP, frameP, slotP, CC_id, ra->Msg3_frame, ra->Msg3_slot); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index d939ed8139..5afdfcbbf3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -474,7 +474,7 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; for (int i = rbStart; i < rbStart + rbSize; ++i) { - if ((vrb_map_UL[i+BWPStart] & startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols)) != 0) { + if ((vrb_map_UL[i+BWPStart] & SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols)) != 0) { LOG_E(MAC, "%s(): %4d.%2d RB %d is already reserved, cannot schedule UE\n", __func__, @@ -543,6 +543,6 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_ /* mark the corresponding RBs as used */ for (int rb = rbStart; rb < rbStart + rbSize; rb++) - vrb_map_UL[rb+BWPStart] |= startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols); + vrb_map_UL[rb+BWPStart] |= SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); return true; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 949f148121..7892da4128 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -951,7 +951,7 @@ bool allocate_ul_retransmission(module_id_t module_id, /* Check the resource is enough for retransmission */ while (rbStart < bwpSize && - !(rballoc_mask[rbStart]&startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols))) + !(rballoc_mask[rbStart]&SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols))) rbStart++; if (rbStart + retInfo->rbSize > bwpSize) { LOG_W(NR_MAC, "cannot allocate retransmission of UE %d/RNTI %04x: no resources (rbStart %d, retInfo->rbSize %d, bwpSize %d\n", UE_id, UE_info->rnti[UE_id], rbStart, retInfo->rbSize, bwpSize); @@ -966,11 +966,11 @@ bool allocate_ul_retransmission(module_id_t module_id, /* the retransmission will use a different time domain allocation, check * that we have enough resources */ while (rbStart < bwpSize && - !(rballoc_mask[rbStart]&startandlength_to_bitmat(temp_ps.startSymbolIndex, temp_ps.nrOfSymbols))) + !(rballoc_mask[rbStart]&SL_to_bitmap(temp_ps.startSymbolIndex, temp_ps.nrOfSymbols))) rbStart++; int rbSize = 0; while (rbStart + rbSize < bwpSize && - (rballoc_mask[rbStart + rbSize]&startandlength_to_bitmat(temp_ps.startSymbolIndex, temp_ps.nrOfSymbols))) + (rballoc_mask[rbStart + rbSize]&SL_to_bitmap(temp_ps.startSymbolIndex, temp_ps.nrOfSymbols))) rbSize++; uint32_t new_tbs; uint16_t new_rbSize; @@ -1027,7 +1027,7 @@ bool allocate_ul_retransmission(module_id_t module_id, /* Mark the corresponding RBs as used */ n_rb_sched -= sched_pusch->rbSize; for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] -= startandlength_to_bitmat(sched_ctrl->pusch_semi_static.startSymbolIndex, sched_ctrl->pusch_semi_static.nrOfSymbols); + rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] -= SL_to_bitmap(sched_ctrl->pusch_semi_static.startSymbolIndex, sched_ctrl->pusch_semi_static.nrOfSymbols); return true; } @@ -1140,7 +1140,7 @@ void pf_ul(module_id_t module_id, LOG_D(NR_MAC,"Looking for min_rb %d RBs, starting at %d\n", min_rb, rbStart); while (rbStart < bwpSize && - !(rballoc_mask[rbStart]&startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols))) + !(rballoc_mask[rbStart]&SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols))) rbStart++; if (rbStart + min_rb >= bwpSize) { LOG_W(NR_MAC, "cannot allocate continuous UL data for UE %d/RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d\n", @@ -1166,7 +1166,7 @@ void pf_ul(module_id_t module_id, /* Mark the corresponding RBs as used */ n_rb_sched -= sched_pusch->rbSize; for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] -= startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols); + rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] -= SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); continue; } @@ -1237,12 +1237,12 @@ void pf_ul(module_id_t module_id, update_ul_ue_R_Qm(sched_pusch, ps); while (rbStart < bwpSize && - !(rballoc_mask[rbStart]&startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols))) + !(rballoc_mask[rbStart]&SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols))) rbStart++; sched_pusch->rbStart = rbStart; uint16_t max_rbSize = 1; while (rbStart + max_rbSize < bwpSize && - (rballoc_mask[rbStart + max_rbSize]&&startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols))) + (rballoc_mask[rbStart + max_rbSize]&&SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols))) max_rbSize++; if (rbStart + min_rb >= bwpSize) { @@ -1273,7 +1273,7 @@ void pf_ul(module_id_t module_id, /* Mark the corresponding RBs as used */ n_rb_sched -= sched_pusch->rbSize; for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] -= startandlength_to_bitmat(ps->startSymbolIndex, ps->nrOfSymbols); + rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] -= SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); } } @@ -1342,7 +1342,7 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; int startSymbolIndex, nrOfSymbols; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); - const uint16_t symb = startandlength_to_bitmat(startSymbolIndex, nrOfSymbols); + const uint16_t symb = SL_to_bitmap(startSymbolIndex, nrOfSymbols); int st = 0, e = 0, len = 0; @@ -1365,7 +1365,7 @@ bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t /* Calculate mask: if any RB in vrb_map_UL is blocked (1), the current RB will be 0 */ for (int i = 0; i < bwpSize; i++) - rballoc_mask[i] = (i >= st && i <= e)*startandlength_to_bitmat(startSymbolIndex, nrOfSymbols); + rballoc_mask[i] = (i >= st && i <= e)*SL_to_bitmap(startSymbolIndex, nrOfSymbols); /* proportional fair scheduling algorithm */ pf_ul(module_id, From f2f6850b33008686f94c84c29999ad62219242c1 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 15 Dec 2021 18:03:43 +0100 Subject: [PATCH 06/13] first version to check pucch vrb occupation --- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 47 ++++- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 189 +++++++++++++----- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 8 + 3 files changed, 181 insertions(+), 63 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 33cb2b1b1d..bda19f252a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1035,23 +1035,26 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, 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; - int prboffset = r_pucch/default_pucch_csset[rsetindex]; - int prboffsetm8 = (r_pucch-8)/default_pucch_csset[rsetindex]; - pucch_pdu->prb_start = (r_pucch>>3)==0 ? - default_pucch_prboffset[rsetindex] + prboffset: - pucch_pdu->bwp_size-1-default_pucch_prboffset[rsetindex]-prboffsetm8; + int prb_start, second_hop_prb, nr_of_symb, start_symb; + set_r_pucch_parms(rsetindex, + r_pucch, + pucch_pdu->bwp_size, + &prb_start, + &second_hop_prb, + &nr_of_symb, + &start_symb); + + pucch_pdu->prb_start = prb_start; pucch_pdu->rnti = rnti; pucch_pdu->freq_hop_flag = 1; - pucch_pdu->second_hop_prb = (r_pucch>>3)==0? - pucch_pdu->bwp_size-1-default_pucch_prboffset[rsetindex]-prboffset: - default_pucch_prboffset[rsetindex] + prboffsetm8; + pucch_pdu->second_hop_prb = second_hop_prb; pucch_pdu->format_type = default_pucch_fmt[rsetindex]; pucch_pdu->initial_cyclic_shift = r_pucch%default_pucch_csset[rsetindex]; if (rsetindex==3||rsetindex==7||rsetindex==11) pucch_pdu->initial_cyclic_shift*=6; else if (rsetindex==1||rsetindex==2) pucch_pdu->initial_cyclic_shift*=3; else pucch_pdu->initial_cyclic_shift*=4; - pucch_pdu->nr_of_symbols = default_pucch_numbsymb[rsetindex]; - pucch_pdu->start_symbol_index = default_pucch_firstsymb[rsetindex]; + pucch_pdu->nr_of_symbols = nr_of_symb; + pucch_pdu->start_symbol_index = start_symb; if (pucch_pdu->format_type == 1) pucch_pdu->time_domain_occ_idx = 0; // check this!! pucch_pdu->sr_flag = O_sr; pucch_pdu->prb_size=1; @@ -1059,6 +1062,30 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, } +void set_r_pucch_parms(int rsetindex, + int r_pucch, + int bwp_size, + int *prb_start, + int *second_hop_prb, + int *nr_of_symbols, + int *start_symbol_index) { + + int prboffset = r_pucch/default_pucch_csset[rsetindex]; + int prboffsetm8 = (r_pucch-8)/default_pucch_csset[rsetindex]; + + *prb_start = (r_pucch>>3)==0 ? + default_pucch_prboffset[rsetindex] + prboffset: + bwp_size-1-default_pucch_prboffset[rsetindex]-prboffsetm8; + + *second_hop_prb = (r_pucch>>3)==0? + bwp_size-1-default_pucch_prboffset[rsetindex]-prboffset: + default_pucch_prboffset[rsetindex] + prboffsetm8; + + *nr_of_symbols = default_pucch_numbsymb[rsetindex]; + *start_symbol_index = default_pucch_firstsymb[rsetindex]; +} + + void prepare_dci(const NR_CellGroupConfig_t *CellGroup, dci_pdu_rel15_t *dci_pdu_rel15, nr_dci_format_t format, diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index a94559769d..d0c2f16157 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -32,6 +32,7 @@ #include "NR_MAC_COMMON/nr_mac_extern.h" #include "NR_MAC_gNB/mac_proto.h" #include "common/ran_context.h" +#include "common/utils/nr/nr_common.h" #include "nfapi/oai_integration/vendor_ext.h" extern RAN_CONTEXT_t RC; @@ -539,16 +540,16 @@ void nr_csi_meas_reporting(int Mod_idP, switch(pucchres->format.present){ case NR_PUCCH_Resource__format_PR_format2: len = pucchres->format.choice.format2->nrofPRBs; - mask = ((1 << pucchres->format.choice.format2->nrofSymbols) - 1) << pucchres->format.choice.format2->startingSymbolIndex; + mask = SL_to_bitmap(pucchres->format.choice.format2->startingSymbolIndex, pucchres->format.choice.format2->nrofSymbols); curr_pucch->simultaneous_harqcsi = pucch_Config->format2->choice.setup->simultaneousHARQ_ACK_CSI; break; case NR_PUCCH_Resource__format_PR_format3: len = pucchres->format.choice.format3->nrofPRBs; - mask = ((1 << pucchres->format.choice.format3->nrofSymbols) - 1) << pucchres->format.choice.format3->startingSymbolIndex; + mask = SL_to_bitmap(pucchres->format.choice.format3->startingSymbolIndex, pucchres->format.choice.format3->nrofSymbols); curr_pucch->simultaneous_harqcsi = pucch_Config->format3->choice.setup->simultaneousHARQ_ACK_CSI; break; case NR_PUCCH_Resource__format_PR_format4: - mask = ((1 << pucchres->format.choice.format4->nrofSymbols) - 1) << pucchres->format.choice.format4->startingSymbolIndex; + mask = SL_to_bitmap(pucchres->format.choice.format4->startingSymbolIndex, pucchres->format.choice.format4->nrofSymbols); curr_pucch->simultaneous_harqcsi = pucch_Config->format4->choice.setup->simultaneousHARQ_ACK_CSI; break; default: @@ -556,7 +557,12 @@ void nr_csi_meas_reporting(int Mod_idP, } // verify resources are free for (int i = start; i < start + len; ++i) { - vrb_map_UL[i+bwp_start] |= mask; + if((vrb_map_UL[i+bwp_start] & mask) != 0) { + LOG_E(NR_MAC, "%s(): VRB MAP not free. Can't schedule CSI reporting on PUCCH.\n", __func__); + memset(curr_pucch, 0, sizeof(*curr_pucch)); + } + else + vrb_map_UL[i+bwp_start] |= mask; } } } @@ -1170,6 +1176,63 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, } } +bool test_acknack_vrb_occupation(NR_UE_sched_ctrl_t *sched_ctrl, + NR_sched_pucch_t *pucch, + uint16_t *vrb_map_UL, + const NR_ServingCellConfigCommon_t *scc, + NR_PUCCH_Config_t *pucch_Config, + int r_pucch, + int bwp_start, + int bwp_size) { + + // We assume initial cyclic shift is always 0 so different pucch resources can't overlap + + NR_sched_pucch_t *csi_pucch = &sched_ctrl->sched_pucch[1]; + if (csi_pucch && + csi_pucch->csi_bits > 0 && + csi_pucch->frame == pucch->frame && + csi_pucch->ul_slot == pucch->ul_slot && + csi_pucch->simultaneous_harqcsi && + (csi_pucch->csi_bits + csi_pucch->dai_c) < 11) + return true; // available resources for csi_pucch already verified + + int prb_start, second_hop_prb, nr_of_symb, start_symb; + if(r_pucch<0){ + const NR_PUCCH_Resource_t *resource = pucch_Config->resourceToAddModList->list.array[0]; + DevAssert(resource->format.present == NR_PUCCH_Resource__format_PR_format0); + second_hop_prb = resource->secondHopPRB!= NULL ? *resource->secondHopPRB : 0; + nr_of_symb = resource->format.choice.format0->nrofSymbols; + start_symb = resource->format.choice.format0->startingSymbolIndex; + prb_start = resource->startingPRB; + } + else{ + int rsetindex = *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon; + set_r_pucch_parms(rsetindex, + r_pucch, + bwp_size, + &prb_start, + &second_hop_prb, + &nr_of_symb, + &start_symb); + } + + // verifying occupation of PRBs for ACK/NACK on dedicated pucch + bool ret = true; + for (int l=0; lUE_info.UE_sched_ctrl[UE_id]; + + 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 (RC.nrmac[mod_id]->UE_info.CellGroup[UE_id] && + RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig && + RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated && + RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig && + RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && + RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { + pucch_Config = RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->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); + NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[0]; LOG_D(NR_MAC,"pucch_acknak %d.%d Trying to allocate pucch, current DAI %d\n",frame,slot,pucch->dai_c); pucch->r_pucch=r_pucch; @@ -1321,21 +1402,32 @@ int nr_acknack_scheduling(int mod_id, int ind_found = -1; // while we are within the feedback limits while ((n_slots_frame + pucch->ul_slot - slot) % n_slots_frame <= max_fb_time) { - int i = 0; - while (i < 8) { - LOG_D(NR_MAC,"pdsch_to_harq_feedback[%d] = %d (pucch->ul_slot %d - slot %d)\n", - i,pdsch_to_harq_feedback[i],pucch->ul_slot,slot); - int diff = pucch->ul_slot - slot; - if (diff<0) - diff += n_slots_frame; - if (pdsch_to_harq_feedback[i] == diff) { - ind_found = i; - break; + // checking if in ul_slot the resources potentially to be assigned to this PUCCH are available + bool ret = test_acknack_vrb_occupation(sched_ctrl, + pucch, + &RC.nrmac[mod_id]->common_channels[CC_id].vrb_map_UL[pucch->ul_slot * MAX_BWP_SIZE], + scc, + pucch_Config, + r_pucch, + bwp_start, + bwp_size); + if (ret) { + int i = 0; + while (i < 8) { + LOG_D(NR_MAC,"pdsch_to_harq_feedback[%d] = %d (pucch->ul_slot %d - slot %d)\n", + i,pdsch_to_harq_feedback[i],pucch->ul_slot,slot); + int diff = pucch->ul_slot - slot; + if (diff<0) + diff += n_slots_frame; + if (pdsch_to_harq_feedback[i] == diff) { + ind_found = i; + break; + } + ++i; } - ++i; + if (ind_found!=-1) + break; } - if (ind_found!=-1) - break; // advance to the next ul slot const int f = pucch->frame; const int s = pucch->ul_slot; @@ -1396,45 +1488,36 @@ int nr_acknack_scheduling(int mod_id, pucch->dai_c++; pucch->resource_indicator = 0; // each UE has dedicated PUCCH resources pucch->r_pucch=r_pucch; - 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 (RC.nrmac[mod_id]->UE_info.CellGroup[UE_id] && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { - pucch_Config = RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->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); - - /* verify that at that slot and symbol, resources are free. We only do this - * for initialCyclicShift 0 (we assume it always has that one), so other - * initialCyclicShifts can overlap with ICS 0!*/ - if (pucch_Config) { + int prb_start, second_hop_prb, nr_of_symb, start_symb; + if(r_pucch<0){ const NR_PUCCH_Resource_t *resource = pucch_Config->resourceToAddModList->list.array[pucch->resource_indicator]; DevAssert(resource->format.present == NR_PUCCH_Resource__format_PR_format0); - int second_hop_prb = resource->secondHopPRB!= NULL ? *resource->secondHopPRB : 0; - int nr_of_symbols = resource->format.choice.format0->nrofSymbols; - if (resource->format.choice.format0->initialCyclicShift == 0) { - uint16_t *vrb_map_UL = &RC.nrmac[mod_id]->common_channels[CC_id].vrb_map_UL[pucch->ul_slot * MAX_BWP_SIZE]; - for (int l=0; lformat.choice.format0->startingSymbolIndex + l); - int prb; - if (l==1 && second_hop_prb != 0) - prb = second_hop_prb; - else - prb = resource->startingPRB; - if ((vrb_map_UL[bwp_start+prb] & symb) != 0) - LOG_W(MAC, "symbol 0x%x is not free for PUCCH alloc in vrb_map_UL at RB %ld and slot %d.%d\n", symb, resource->startingPRB, pucch->frame, pucch->ul_slot); - vrb_map_UL[bwp_start+prb] |= symb; - } - } + second_hop_prb = resource->secondHopPRB!= NULL ? *resource->secondHopPRB : 0; + nr_of_symb = resource->format.choice.format0->nrofSymbols; + start_symb = resource->format.choice.format0->startingSymbolIndex; + prb_start = resource->startingPRB; + } + else{ + int rsetindex = *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon; + set_r_pucch_parms(rsetindex, + r_pucch, + bwp_size, + &prb_start, + &second_hop_prb, + &nr_of_symb, + &start_symb); + } + + uint16_t *vrb_map_UL = &RC.nrmac[mod_id]->common_channels[CC_id].vrb_map_UL[pucch->ul_slot * MAX_BWP_SIZE]; + for (int l=0; l Date: Thu, 16 Dec 2021 14:44:40 +0100 Subject: [PATCH 07/13] additional parameters in pucch structure to avoid double computation --- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 57 ++++++------------- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 4 ++ 2 files changed, 22 insertions(+), 39 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index d0c2f16157..61efbdb941 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -1196,35 +1196,34 @@ bool test_acknack_vrb_occupation(NR_UE_sched_ctrl_t *sched_ctrl, (csi_pucch->csi_bits + csi_pucch->dai_c) < 11) return true; // available resources for csi_pucch already verified - int prb_start, second_hop_prb, nr_of_symb, start_symb; if(r_pucch<0){ const NR_PUCCH_Resource_t *resource = pucch_Config->resourceToAddModList->list.array[0]; DevAssert(resource->format.present == NR_PUCCH_Resource__format_PR_format0); - second_hop_prb = resource->secondHopPRB!= NULL ? *resource->secondHopPRB : 0; - nr_of_symb = resource->format.choice.format0->nrofSymbols; - start_symb = resource->format.choice.format0->startingSymbolIndex; - prb_start = resource->startingPRB; + pucch->second_hop_prb = resource->secondHopPRB!= NULL ? *resource->secondHopPRB : 0; + pucch->nr_of_symb = resource->format.choice.format0->nrofSymbols; + pucch->start_symb = resource->format.choice.format0->startingSymbolIndex; + pucch->prb_start = resource->startingPRB; } else{ int rsetindex = *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon; set_r_pucch_parms(rsetindex, r_pucch, bwp_size, - &prb_start, - &second_hop_prb, - &nr_of_symb, - &start_symb); + &pucch->prb_start, + &pucch->second_hop_prb, + &pucch->nr_of_symb, + &pucch->start_symb); } // verifying occupation of PRBs for ACK/NACK on dedicated pucch bool ret = true; - for (int l=0; lnr_of_symb; l++) { + uint16_t symb = SL_to_bitmap(pucch->start_symb+l, 1); int prb; - if (l==1 && second_hop_prb != 0) - prb = second_hop_prb; + if (l==1 && pucch->second_hop_prb != 0) + prb = pucch->second_hop_prb; else - prb = prb_start; + prb = pucch->prb_start; if ((vrb_map_UL[bwp_start+prb] & symb) != 0) { ret = false; break; @@ -1489,34 +1488,14 @@ int nr_acknack_scheduling(int mod_id, pucch->resource_indicator = 0; // each UE has dedicated PUCCH resources pucch->r_pucch=r_pucch; - int prb_start, second_hop_prb, nr_of_symb, start_symb; - if(r_pucch<0){ - const NR_PUCCH_Resource_t *resource = pucch_Config->resourceToAddModList->list.array[pucch->resource_indicator]; - DevAssert(resource->format.present == NR_PUCCH_Resource__format_PR_format0); - second_hop_prb = resource->secondHopPRB!= NULL ? *resource->secondHopPRB : 0; - nr_of_symb = resource->format.choice.format0->nrofSymbols; - start_symb = resource->format.choice.format0->startingSymbolIndex; - prb_start = resource->startingPRB; - } - else{ - int rsetindex = *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon; - set_r_pucch_parms(rsetindex, - r_pucch, - bwp_size, - &prb_start, - &second_hop_prb, - &nr_of_symb, - &start_symb); - } - uint16_t *vrb_map_UL = &RC.nrmac[mod_id]->common_channels[CC_id].vrb_map_UL[pucch->ul_slot * MAX_BWP_SIZE]; - for (int l=0; lnr_of_symb; l++) { + uint16_t symb = SL_to_bitmap(pucch->start_symb+l, 1); int prb; - if (l==1 && second_hop_prb != 0) - prb = second_hop_prb; + if (l==1 && pucch->second_hop_prb != 0) + prb = pucch->second_hop_prb; else - prb = prb_start; + prb = pucch->prb_start; vrb_map_UL[bwp_start+prb] |= symb; } return 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 3944cb34f9..83eee7f827 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -313,6 +313,10 @@ typedef struct NR_sched_pucch { uint8_t timing_indicator; uint8_t resource_indicator; int r_pucch; + int prb_start; + int second_hop_prb; + int nr_of_symb; + int start_symb; } NR_sched_pucch_t; /* PUSCH semi-static configuration: as long as the TDA and DCI format remain From bcbafdf094e5140740c45a9c80288018ec88569d Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 17 Feb 2022 10:31:16 +0100 Subject: [PATCH 08/13] fix for ulprbbl memcpy --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 544f62a599..e9490c9fb2 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -319,7 +319,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, const int num_slots = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; const int last_slot = (slot + num_slots - 1) % num_slots; uint16_t *vrb_map_UL = cc[CC_id].vrb_map_UL; - memcpy(&vrb_map_UL[last_slot * MAX_BWP_SIZE], &RC.nrmac[module_idP]->ulprbbl, MAX_BWP_SIZE); + memcpy(&vrb_map_UL[last_slot * MAX_BWP_SIZE], &RC.nrmac[module_idP]->ulprbbl, sizeof(uint16_t) * MAX_BWP_SIZE); clear_nr_nfapi_information(RC.nrmac[module_idP], CC_id, frame, slot); From c3d0d6d82a8d3c3c523a11cc91502a44a1e7deda Mon Sep 17 00:00:00 2001 From: francescomani Date: Tue, 22 Feb 2022 14:39:04 +0100 Subject: [PATCH 09/13] addressing review comments --- openair2/GNB_APP/gnb_config.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 24 ++++++++++--------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 14 +++++------ 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index f4433ba1ca..ccd26a62ea 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -740,7 +740,7 @@ void RCconfig_nr_macrlc() { uint16_t prbbl[275]; int num_prbbl=0; int prb; - memset(prbbl,0,275*sizeof(uint16_t)); + memset(prbbl,0,prbbl); while (pt) { prb=atoi(pt); prbbl[prb] = 0x3FFF; // all symbols taken diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index fcab2ab968..61cfb986dc 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -557,7 +557,7 @@ void nr_csi_meas_reporting(int Mod_idP, // verify resources are free for (int i = start; i < start + len; ++i) { if((vrb_map_UL[i+bwp_start] & mask) != 0) { - LOG_E(NR_MAC, "%s(): VRB MAP not free. Can't schedule CSI reporting on PUCCH.\n", __func__); + LOG_E(NR_MAC, "%4d.%2d VRB MAP in %4d.%2d not free. Can't schedule CSI reporting on PUCCH.\n", frame, slot, frame, sched_slot); memset(curr_pucch, 0, sizeof(*curr_pucch)); } else @@ -1273,17 +1273,18 @@ 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 = &RC.nrmac[mod_id]->UE_info.UE_sched_ctrl[UE_id]; + NR_CellGroupConfig_t *cg = RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]; 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 (RC.nrmac[mod_id]->UE_info.CellGroup[UE_id] && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { - pucch_Config = RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; + } else if (cg && + cg->spCellConfig && + cg->spCellConfig->spCellConfigDedicated && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { + 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: @@ -1336,7 +1337,6 @@ int nr_acknack_scheduling(int mod_id, LOG_D(NR_MAC, "In %s: pucch_acknak 1. DL %d.%d, UL_ACK %d.%d, 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_CellGroupConfig_t *cg = RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]; NR_BWP_UplinkDedicated_t *ubwpd=NULL; if (cg && @@ -1410,11 +1410,13 @@ int nr_acknack_scheduling(int mod_id, // Find the right timing_indicator value. int ind_found = -1; // while we are within the feedback limits + uint16_t *vrb_map_UL; while ((n_slots_frame + pucch->ul_slot - slot) % n_slots_frame <= max_fb_time) { // checking if in ul_slot the resources potentially to be assigned to this PUCCH are available + vrb_map_UL = &RC.nrmac[mod_id]->common_channels[CC_id].vrb_map_UL[pucch->ul_slot * MAX_BWP_SIZE]; bool ret = test_acknack_vrb_occupation(sched_ctrl, pucch, - &RC.nrmac[mod_id]->common_channels[CC_id].vrb_map_UL[pucch->ul_slot * MAX_BWP_SIZE], + vrb_map_UL, scc, pucch_Config, r_pucch, @@ -1499,7 +1501,7 @@ int nr_acknack_scheduling(int mod_id, pucch->resource_indicator = 0; // each UE has dedicated PUCCH resources pucch->r_pucch=r_pucch; - uint16_t *vrb_map_UL = &RC.nrmac[mod_id]->common_channels[CC_id].vrb_map_UL[pucch->ul_slot * MAX_BWP_SIZE]; + vrb_map_UL = &RC.nrmac[mod_id]->common_channels[CC_id].vrb_map_UL[pucch->ul_slot * MAX_BWP_SIZE]; for (int l=0; lnr_of_symb; l++) { uint16_t symb = SL_to_bitmap(pucch->start_symb+l, 1); int prb; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index c57218cc33..5f34c10b3b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1209,13 +1209,6 @@ void pf_ul(module_id_t module_id, if (max_num_ue < 0) return; - sched_ctrl->cce_index = CCEIndex; - fill_pdcch_vrb_map(RC.nrmac[module_id], - CC_id, - &sched_ctrl->sched_pdcch, - CCEIndex, - sched_ctrl->aggregation_level); - /* 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 @@ -1238,6 +1231,13 @@ void pf_ul(module_id_t module_id, return; } + sched_ctrl->cce_index = CCEIndex; + fill_pdcch_vrb_map(RC.nrmac[module_id], + CC_id, + &sched_ctrl->sched_pdcch, + CCEIndex, + sched_ctrl->aggregation_level); + NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; sched_pusch->mcs = 9; update_ul_ue_R_Qm(sched_pusch, ps); From d4ce30c54d7801fb52eec7f3721bc0043eed54fa Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 23 Feb 2022 16:52:13 +0100 Subject: [PATCH 10/13] additional review fixes --- openair2/GNB_APP/gnb_config.c | 2 +- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 4 ++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 2 ++ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 3 +-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 6 +++--- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index ccd26a62ea..ec666f9415 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -740,7 +740,7 @@ void RCconfig_nr_macrlc() { uint16_t prbbl[275]; int num_prbbl=0; int prb; - memset(prbbl,0,prbbl); + memset(prbbl,0,sizeof(prbbl)); while (pt) { prb=atoi(pt); prbbl[prb] = 0x3FFF; // all symbols taken diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index cd34a543c7..3c441b7c6c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -681,7 +681,7 @@ bool allocate_dl_retransmission(module_id_t module_id, /* retransmissions: directly allocate */ *n_rb_sched -= sched_ctrl->sched_pdsch.rbSize; for (int rb = 0; rb < sched_ctrl->sched_pdsch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pdsch.rbStart] -= SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); + rballoc_mask[rb + sched_ctrl->sched_pdsch.rbStart] ^= SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); return true; } @@ -878,7 +878,7 @@ void pf_dl(module_id_t module_id, /* transmissions: directly allocate */ n_rb_sched -= sched_pdsch->rbSize; for (int rb = 0; rb < sched_pdsch->rbSize; rb++) - rballoc_mask[rb + sched_pdsch->rbStart] -= slbitmap; + rballoc_mask[rb + sched_pdsch->rbStart] ^= slbitmap; } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 8480e22a60..5c1ef2128f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1149,6 +1149,8 @@ void set_r_pucch_parms(int rsetindex, int *nr_of_symbols, int *start_symbol_index) { + // procedure described in 38.213 section 9.2.1 + int prboffset = r_pucch/default_pucch_csset[rsetindex]; int prboffsetm8 = (r_pucch-8)/default_pucch_csset[rsetindex]; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 61cfb986dc..5880f59655 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -1282,8 +1282,7 @@ int nr_acknack_scheduling(int mod_id, cg->spCellConfig && cg->spCellConfig->spCellConfigDedicated && cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { + cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { pucch_Config = cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; } NR_BWP_t *genericParameters = 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 5f34c10b3b..e77fa0ef29 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1091,7 +1091,7 @@ bool allocate_ul_retransmission(module_id_t module_id, /* Mark the corresponding RBs as used */ n_rb_sched -= sched_pusch->rbSize; for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] -= SL_to_bitmap(sched_ctrl->pusch_semi_static.startSymbolIndex, sched_ctrl->pusch_semi_static.nrOfSymbols); + rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] ^= SL_to_bitmap(sched_ctrl->pusch_semi_static.startSymbolIndex, sched_ctrl->pusch_semi_static.nrOfSymbols); return true; } @@ -1256,7 +1256,7 @@ void pf_ul(module_id_t module_id, /* Mark the corresponding RBs as used */ n_rb_sched -= sched_pusch->rbSize; for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] -= SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); + rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] ^= SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); continue; } @@ -1389,7 +1389,7 @@ void pf_ul(module_id_t module_id, n_rb_sched -= sched_pusch->rbSize; for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] -= SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); + rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] ^= SL_to_bitmap(ps->startSymbolIndex, ps->nrOfSymbols); } } From 38ad1237148d9b171b7ad26c43cf5b9d96485145 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 3 Mar 2022 17:50:57 +0100 Subject: [PATCH 11/13] fix for VRB map occupation for PRACH --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 8b5e1857a7..486c5d0763 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -389,7 +389,7 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP const int16_t N_RA_RB = get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing.value, mu_pusch); uint16_t *vrb_map_UL = &cc->vrb_map_UL[slotP * MAX_BWP_SIZE]; for (int i = 0; i < N_RA_RB * fdm; ++i) - vrb_map_UL[bwp_start + rach_ConfigGeneric->msg1_FrequencyStart + i] = 0x3fff; // all symbols + vrb_map_UL[bwp_start + rach_ConfigGeneric->msg1_FrequencyStart + i] = SL_to_bitmap(start_symbol, N_t_slot*N_dur); } } } From 73bd9034aa49b8b2846e31c4c65eac278060cd68 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 9 Mar 2022 14:39:38 +0100 Subject: [PATCH 12/13] Use strtok_r() to split strings in gnb_config.c --- openair2/GNB_APP/gnb_config.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 2aaf15ae82..f5ff7ddf9e 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -624,15 +624,18 @@ void RCconfig_NR_L1(void) { config_getlist( &GNBParamList,GNBParams,sizeof(GNBParams)/sizeof(paramdef_t),NULL); char *ulprbbl = *GNBParamList.paramarray[0][GNB_ULPRBBLACKLIST_IDX].strptr; if (ulprbbl) LOG_I(NR_PHY,"PRB blacklist %s\n",ulprbbl); - char *pt = strtok(ulprbbl,","); + char *save = NULL; + char *pt = strtok_r(ulprbbl, ",", &save); int prbbl[275]; int num_prbbl=0; memset(prbbl,0,275*sizeof(int)); while (pt) { - prbbl[atoi(pt)] = 1; + const int rb = atoi(pt); + AssertFatal(rb < 275, "RB %d out of bounds (max 275)\n", rb); + prbbl[rb] = 0x3FFF; // all symbols taken LOG_I(NR_PHY,"Blacklisting prb %d\n",atoi(pt)); - pt = strtok(NULL,","); + pt = strtok_r(NULL, ",", &save); num_prbbl++; } @@ -736,15 +739,16 @@ void RCconfig_nr_macrlc() { config_getlist( &GNBParamList,GNBParams,sizeof(GNBParams)/sizeof(paramdef_t),NULL); char *ulprbbl = *GNBParamList.paramarray[0][GNB_ULPRBBLACKLIST_IDX].strptr; - char *pt = strtok(ulprbbl,","); + char *save = NULL; + char *pt = strtok_r(ulprbbl, ",", &save); uint16_t prbbl[275]; int num_prbbl=0; - int prb; memset(prbbl,0,sizeof(prbbl)); while (pt) { - prb=atoi(pt); + const int prb = atoi(pt); + AssertFatal(prb < 275, "RB %d out of bounds (max 275)\n", prb); prbbl[prb] = 0x3FFF; // all symbols taken - pt = strtok(NULL,","); + pt = strtok_r(NULL, ",", &save); num_prbbl++; } @@ -1458,7 +1462,8 @@ int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) { // NGAP_REGISTER_GNB_REQ (msg_p).enb_interface_name_for_NGU = strdup(enb_interface_name_for_NGU); cidr = *(NETParams[GNB_IPV4_ADDRESS_FOR_NG_AMF_IDX].strptr); - address = strtok(cidr, "/"); + char *save = NULL; + address = strtok_r(cidr, "/", &save); NGAP_REGISTER_GNB_REQ (msg_p).gnb_ip_address.ipv6 = 0; NGAP_REGISTER_GNB_REQ (msg_p).gnb_ip_address.ipv4 = 1; @@ -1730,7 +1735,8 @@ int RCconfig_NR_X2(MessageDef *msg_p, uint32_t i) { } cidr = *(NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr); - address = strtok(cidr, "/"); + char *save = NULL; + address = strtok_r(cidr, "/", &save); X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv6 = 0; X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4 = 1; strcpy(X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4_address, address); From e7508533b651de5cdb21aa62f1950442b49e0f68 Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 9 Mar 2022 14:57:26 +0100 Subject: [PATCH 13/13] review fix --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 7d32eb1007..b4b44c26f0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -1551,7 +1551,6 @@ bool test_acknack_vrb_occupation(NR_UE_sched_ctrl_t *sched_ctrl, } // verifying occupation of PRBs for ACK/NACK on dedicated pucch - bool ret = true; for (int l=0; lnr_of_symb; l++) { uint16_t symb = SL_to_bitmap(pucch->start_symb+l, 1); int prb; @@ -1560,11 +1559,11 @@ bool test_acknack_vrb_occupation(NR_UE_sched_ctrl_t *sched_ctrl, else prb = pucch->prb_start; if ((vrb_map_UL[bwp_start+prb] & symb) != 0) { - ret = false; + return false; break; } } - return ret; + return true; }