From 321df962d2e5535dfb53f6150115520735040924 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 8 May 2025 15:05:13 +0200 Subject: [PATCH 1/2] make functions to create harq lists static --- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 110 +++++++++--------- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 4 - 2 files changed, 55 insertions(+), 59 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 7b9ad1ed3b..8d7e1674f9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2208,6 +2208,61 @@ static void set_sched_pucch_list(NR_UE_sched_ctrl_t *sched_ctrl, } } +static void create_dl_harq_list(NR_UE_sched_ctrl_t *sched_ctrl, const NR_UE_ServingCell_Info_t *sc_info) +{ + const int nrofHARQ = get_nrofHARQ_ProcessesForPDSCH(sc_info); + // add all available DL HARQ processes for this UE + AssertFatal(sched_ctrl->available_dl_harq.len == sched_ctrl->feedback_dl_harq.len + && sched_ctrl->available_dl_harq.len == sched_ctrl->retrans_dl_harq.len, + "HARQ lists have different lengths (%d/%d/%d)\n", + sched_ctrl->available_dl_harq.len, + sched_ctrl->feedback_dl_harq.len, + sched_ctrl->retrans_dl_harq.len); + if (sched_ctrl->available_dl_harq.len == 0) { + create_nr_list(&sched_ctrl->available_dl_harq, nrofHARQ); + for (int harq = 0; harq < nrofHARQ; harq++) + add_tail_nr_list(&sched_ctrl->available_dl_harq, harq); + create_nr_list(&sched_ctrl->feedback_dl_harq, nrofHARQ); + create_nr_list(&sched_ctrl->retrans_dl_harq, nrofHARQ); + } else if (sched_ctrl->available_dl_harq.len == nrofHARQ) { + LOG_D(NR_MAC, "nrofHARQ %d already configured\n", nrofHARQ); + } else { + const int old_nrofHARQ = sched_ctrl->available_dl_harq.len; + AssertFatal(nrofHARQ > old_nrofHARQ, + "cannot resize HARQ list to be smaller (nrofHARQ %d, old_nrofHARQ %d)\n", + nrofHARQ, old_nrofHARQ); + resize_nr_list(&sched_ctrl->available_dl_harq, nrofHARQ); + for (int harq = old_nrofHARQ; harq < nrofHARQ; harq++) + add_tail_nr_list(&sched_ctrl->available_dl_harq, harq); + resize_nr_list(&sched_ctrl->feedback_dl_harq, nrofHARQ); + resize_nr_list(&sched_ctrl->retrans_dl_harq, nrofHARQ); + } +} + +static void create_ul_harq_list(NR_UE_sched_ctrl_t *sched_ctrl, const NR_UE_ServingCell_Info_t *sc_info) +{ + int nrofHARQ = get_nrofHARQ_ProcessesForPUSCH(sc_info); + if (sched_ctrl->available_ul_harq.len == 0) { + create_nr_list(&sched_ctrl->available_ul_harq, nrofHARQ); + for (int harq = 0; harq < nrofHARQ; harq++) + add_tail_nr_list(&sched_ctrl->available_ul_harq, harq); + create_nr_list(&sched_ctrl->feedback_ul_harq, nrofHARQ); + create_nr_list(&sched_ctrl->retrans_ul_harq, nrofHARQ); + } else if (sched_ctrl->available_ul_harq.len == nrofHARQ) { + LOG_D(NR_MAC, "nrofHARQ %d already configured\n", nrofHARQ); + } else { + const int old_nrofHARQ = sched_ctrl->available_ul_harq.len; + AssertFatal(nrofHARQ > old_nrofHARQ, + "cannot resize HARQ list to be smaller (nrofHARQ %d, old_nrofHARQ %d)\n", + nrofHARQ, old_nrofHARQ); + resize_nr_list(&sched_ctrl->available_ul_harq, nrofHARQ); + for (int harq = old_nrofHARQ; harq < nrofHARQ; harq++) + add_tail_nr_list(&sched_ctrl->available_ul_harq, harq); + resize_nr_list(&sched_ctrl->feedback_ul_harq, nrofHARQ); + resize_nr_list(&sched_ctrl->retrans_ul_harq, nrofHARQ); + } +} + // main function to configure parameters of current BWP void configure_UE_BWP(gNB_MAC_INST *nr_mac, NR_ServingCellConfigCommon_t *scc, @@ -2615,61 +2670,6 @@ void free_sched_pucch_list(NR_UE_sched_ctrl_t *sched_ctrl) free(sched_ctrl->sched_pucch); } -void create_dl_harq_list(NR_UE_sched_ctrl_t *sched_ctrl, const NR_UE_ServingCell_Info_t *sc_info) -{ - const int nrofHARQ = get_nrofHARQ_ProcessesForPDSCH(sc_info); - // add all available DL HARQ processes for this UE - AssertFatal(sched_ctrl->available_dl_harq.len == sched_ctrl->feedback_dl_harq.len - && sched_ctrl->available_dl_harq.len == sched_ctrl->retrans_dl_harq.len, - "HARQ lists have different lengths (%d/%d/%d)\n", - sched_ctrl->available_dl_harq.len, - sched_ctrl->feedback_dl_harq.len, - sched_ctrl->retrans_dl_harq.len); - if (sched_ctrl->available_dl_harq.len == 0) { - create_nr_list(&sched_ctrl->available_dl_harq, nrofHARQ); - for (int harq = 0; harq < nrofHARQ; harq++) - add_tail_nr_list(&sched_ctrl->available_dl_harq, harq); - create_nr_list(&sched_ctrl->feedback_dl_harq, nrofHARQ); - create_nr_list(&sched_ctrl->retrans_dl_harq, nrofHARQ); - } else if (sched_ctrl->available_dl_harq.len == nrofHARQ) { - LOG_D(NR_MAC, "nrofHARQ %d already configured\n", nrofHARQ); - } else { - const int old_nrofHARQ = sched_ctrl->available_dl_harq.len; - AssertFatal(nrofHARQ > old_nrofHARQ, - "cannot resize HARQ list to be smaller (nrofHARQ %d, old_nrofHARQ %d)\n", - nrofHARQ, old_nrofHARQ); - resize_nr_list(&sched_ctrl->available_dl_harq, nrofHARQ); - for (int harq = old_nrofHARQ; harq < nrofHARQ; harq++) - add_tail_nr_list(&sched_ctrl->available_dl_harq, harq); - resize_nr_list(&sched_ctrl->feedback_dl_harq, nrofHARQ); - resize_nr_list(&sched_ctrl->retrans_dl_harq, nrofHARQ); - } -} - -void create_ul_harq_list(NR_UE_sched_ctrl_t *sched_ctrl, const NR_UE_ServingCell_Info_t *sc_info) -{ - int nrofHARQ = get_nrofHARQ_ProcessesForPUSCH(sc_info); - if (sched_ctrl->available_ul_harq.len == 0) { - create_nr_list(&sched_ctrl->available_ul_harq, nrofHARQ); - for (int harq = 0; harq < nrofHARQ; harq++) - add_tail_nr_list(&sched_ctrl->available_ul_harq, harq); - create_nr_list(&sched_ctrl->feedback_ul_harq, nrofHARQ); - create_nr_list(&sched_ctrl->retrans_ul_harq, nrofHARQ); - } else if (sched_ctrl->available_ul_harq.len == nrofHARQ) { - LOG_D(NR_MAC, "nrofHARQ %d already configured\n", nrofHARQ); - } else { - const int old_nrofHARQ = sched_ctrl->available_ul_harq.len; - AssertFatal(nrofHARQ > old_nrofHARQ, - "cannot resize HARQ list to be smaller (nrofHARQ %d, old_nrofHARQ %d)\n", - nrofHARQ, old_nrofHARQ); - resize_nr_list(&sched_ctrl->available_ul_harq, nrofHARQ); - for (int harq = old_nrofHARQ; harq < nrofHARQ; harq++) - add_tail_nr_list(&sched_ctrl->available_ul_harq, harq); - resize_nr_list(&sched_ctrl->feedback_ul_harq, nrofHARQ); - resize_nr_list(&sched_ctrl->retrans_ul_harq, nrofHARQ); - } -} - void reset_dl_harq_list(NR_UE_sched_ctrl_t *sched_ctrl) { int harq; while ((harq = sched_ctrl->feedback_dl_harq.head) >= 0) { diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 3ac09ce98a..c78c061820 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -348,10 +348,6 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, const uint8_t ul_cqi, const uint16_t rssi); -void create_dl_harq_list(NR_UE_sched_ctrl_t *sched_ctrl, const NR_UE_ServingCell_Info_t *sc_info); - -void create_ul_harq_list(NR_UE_sched_ctrl_t *sched_ctrl, const NR_UE_ServingCell_Info_t *sc_info); - void reset_dl_harq_list(NR_UE_sched_ctrl_t *sched_ctrl); void reset_ul_harq_list(NR_UE_sched_ctrl_t *sched_ctrl); From 2f1dbed8ec479cff3ee18e18d057f3a0a664a649 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 8 May 2025 15:26:24 +0200 Subject: [PATCH 2/2] limit the number of HARQ processes in lists for DCI 10 and 00 (also removed unnecessary call to create lists at UE init) --- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 8d7e1674f9..03ec701880 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2208,9 +2208,12 @@ static void set_sched_pucch_list(NR_UE_sched_ctrl_t *sched_ctrl, } } -static void create_dl_harq_list(NR_UE_sched_ctrl_t *sched_ctrl, const NR_UE_ServingCell_Info_t *sc_info) +static void create_dl_harq_list(NR_UE_sched_ctrl_t *sched_ctrl, const NR_UE_ServingCell_Info_t *sc_info, bool dci_00_10) { - const int nrofHARQ = get_nrofHARQ_ProcessesForPDSCH(sc_info); + int nrofHARQ = get_nrofHARQ_ProcessesForPDSCH(sc_info); + // limit the number of HARQ PIDs to 16 in case of common search space + if (dci_00_10 && nrofHARQ > 16) + nrofHARQ = 16; // add all available DL HARQ processes for this UE AssertFatal(sched_ctrl->available_dl_harq.len == sched_ctrl->feedback_dl_harq.len && sched_ctrl->available_dl_harq.len == sched_ctrl->retrans_dl_harq.len, @@ -2239,9 +2242,12 @@ static void create_dl_harq_list(NR_UE_sched_ctrl_t *sched_ctrl, const NR_UE_Serv } } -static void create_ul_harq_list(NR_UE_sched_ctrl_t *sched_ctrl, const NR_UE_ServingCell_Info_t *sc_info) +static void create_ul_harq_list(NR_UE_sched_ctrl_t *sched_ctrl, const NR_UE_ServingCell_Info_t *sc_info, bool dci_00_10) { int nrofHARQ = get_nrofHARQ_ProcessesForPUSCH(sc_info); + // limit the number of HARQ PIDs to 16 in case of common search space + if (dci_00_10 && nrofHARQ > 16) + nrofHARQ = 16; if (sched_ctrl->available_ul_harq.len == 0) { create_nr_list(&sched_ctrl->available_ul_harq, nrofHARQ); for (int harq = 0; harq < nrofHARQ; harq++) @@ -2452,8 +2458,6 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, sc_info->nrofHARQ_ProcessesForPUSCH_r17 = pusch_servingcellconfig->ext3->nrofHARQ_ProcessesForPUSCH_r17; } } - create_dl_harq_list(sched_ctrl, sc_info); - create_ul_harq_list(sched_ctrl, sc_info); } if (CellGroup && CellGroup->physicalCellGroupConfig) @@ -2516,6 +2520,10 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, DL_BWP->dci_format = NR_DL_DCI_FORMAT_1_0; } + bool format_00_10 = DL_BWP->dci_format == NR_DL_DCI_FORMAT_1_0; // if DL is 10 UL is surely 00 + create_dl_harq_list(sched_ctrl, sc_info, format_00_10); + create_ul_harq_list(sched_ctrl, sc_info, format_00_10); + set_max_fb_time(UL_BWP, DL_BWP); set_sched_pucch_list(sched_ctrl, UL_BWP, scc, &nr_mac->frame_structure); @@ -2577,11 +2585,6 @@ NR_UE_info_t *get_new_nr_ue_inst(uid_allocator_t *uia, rnti_t rnti, NR_CellGroup /* Set default BWPs */ AssertFatal(UE->sc_info.n_ul_bwp <= NR_MAX_NUM_BWP, "uplinkBWP_ToAddModList has %d BWP!\n", UE->sc_info.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, &UE->sc_info); - create_ul_harq_list(sched_ctrl, &UE->sc_info); - // initialize LCID structure seq_arr_init(&sched_ctrl->lc_config, sizeof(nr_lc_config_t)); return UE;