From 583d2cc0d4c05eb94b15fd9a06a827b0051fd258 Mon Sep 17 00:00:00 2001
From: luis_pereira87 <lpereira@allbesmart.pt>
Date: Sun, 24 Jan 2021 12:14:48 +0000
Subject: [PATCH] Fix for NR_MAX_PDCCH_AGG_LEVEL

---
 nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h | 2 +-
 openair1/PHY/NR_TRANSPORT/nr_dci.c                         | 4 ++--
 openair1/PHY/NR_UE_TRANSPORT/dci_nr.c                      | 6 +++---
 openair1/PHY/defs_nr_common.h                              | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h
index 774520cde7..c254e1a028 100644
--- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h
+++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h
@@ -626,7 +626,7 @@ typedef struct {
 //table 3-37 
 
 #define DCI_PAYLOAD_BYTE_LEN 8 // 12 ? TS38.212 sec 7.3.1
-#define MAX_DCI_CORESET 16 // 3GPP TS 38.211 v15.8 Section 7.3.2 Table 7.3.2.1-1: Supported PDCCH aggregation levels
+#define MAX_DCI_CORESET 8
 
 typedef struct {
   // The RNTI used for identifying the UE when receiving the PDU Value: 1 -> 65535.
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c
index dfdadba7f0..7395586dd6 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dci.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c
@@ -171,8 +171,8 @@ void nr_generate_dci(PHY_VARS_gNB *gNB,
 
     // Get cce_list indices by reg_idx in ascending order
     int reg_list_index = 0;
-    int reg_list_order[MAX_DCI_CORESET] = {};
-    for (int p = 0; p < MAX_DCI_CORESET; p++) {
+    int reg_list_order[NR_MAX_PDCCH_AGG_LEVEL] = {};
+    for (int p = 0; p < NR_MAX_PDCCH_AGG_LEVEL; p++) {
       for(int p2 = 0; p2 < pdcch_pdu_rel15->dci_pdu.AggregationLevel[d]; p2++) {
         if(gNB->cce_list[d][p2].reg_list[0].reg_idx == p * NR_NB_REG_PER_CCE) {
           reg_list_order[reg_list_index] = p2;
diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c
index 8893fc3e31..fb53f8460d 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c
@@ -138,7 +138,7 @@ void nr_pdcch_demapping_deinterleaving(uint32_t *llr,
   }
 
 
-  int f_bundle_j_list[MAX_DCI_CORESET] = {};
+  int f_bundle_j_list[NR_MAX_PDCCH_AGG_LEVEL] = {};
 
   for (int reg = 0; reg < ((coreset_nbr_rb * coreset_time_dur)); reg++) {
     if ((reg % reg_bundle_size_L) == 0) {
@@ -161,10 +161,10 @@ void nr_pdcch_demapping_deinterleaving(uint32_t *llr,
 
   // Get cce_list indices by reg_idx in ascending order
   int f_bundle_j_list_id = 0;
-  int f_bundle_j_list_ord[MAX_DCI_CORESET] = {};
+  int f_bundle_j_list_ord[NR_MAX_PDCCH_AGG_LEVEL] = {};
   for (int c_id = 0; c_id < number_of_candidates; c_id++ ) {
     f_bundle_j_list_id = CCE[c_id];
-    for (int p = 0; p < MAX_DCI_CORESET; p++) {
+    for (int p = 0; p < NR_MAX_PDCCH_AGG_LEVEL; p++) {
       for (int p2 = CCE[c_id]; p2 < CCE[c_id] + L[c_id]; p2++) {
         if (f_bundle_j_list[p2] == p) {
           f_bundle_j_list_ord[f_bundle_j_list_id] = p;
diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h
index 08b54c5c98..aa3c7bc15e 100644
--- a/openair1/PHY/defs_nr_common.h
+++ b/openair1/PHY/defs_nr_common.h
@@ -94,7 +94,7 @@
 
 #define NR_MAX_NUM_BWP 4
 
-#define NR_MAX_PDCCH_AGG_LEVEL 16
+#define NR_MAX_PDCCH_AGG_LEVEL 16 // 3GPP TS 38.211 V15.8 Section 7.3.2 Table 7.3.2.1-1: Supported PDCCH aggregation levels
 #define NR_MAX_CSET_DURATION 3
 
 #define NR_MAX_NB_RBG 18
-- 
2.26.2