From 95442d607586f597c4ef9b11b858e441ca734b41 Mon Sep 17 00:00:00 2001
From: francescomani <email@francescomani.it>
Date: Wed, 29 May 2024 15:26:28 +0200
Subject: [PATCH] adding a control to the maxMIMO_layers input and updating
 RUNMODEM.md

---
 doc/RUNMODEM.md               | 2 ++
 openair2/GNB_APP/gnb_config.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/doc/RUNMODEM.md b/doc/RUNMODEM.md
index a85f0d9b0c8..2544dce8456 100644
--- a/doc/RUNMODEM.md
+++ b/doc/RUNMODEM.md
@@ -280,4 +280,6 @@ The DL logical antenna port configuration can be selected through configuration
 
 Finally the number of TX physical antenna in the RU part of the configuration file, `nb_tx`, should be equal or larger than the total number of PDSCH logical antenna ports.
 
+It is possible to limit the number supported DL MIMO layers via RRC configuration, e.g. to a value lower than the number of logical antenna ports configured, by using the configuration file parameter `maxMIMO_layers`.
+
 [Example of configuration file with parameters for 2-layer MIMO](https://gitlab.eurecom.fr/oai/openairinterface5g/-/blob/develop/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band77.fr1.273PRB.2x2.usrpn300.conf)
diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c
index 7ed249ee751..c1d15d810b7 100644
--- a/openair2/GNB_APP/gnb_config.c
+++ b/openair2/GNB_APP/gnb_config.c
@@ -1313,6 +1313,8 @@ void RCconfig_nr_macrlc(configmodule_interface_t *cfg)
         config.force_256qam_off ? "force off" : "may be on",
         config.use_deltaMCS ? "on" : "off",
         config.maxMIMO_layers);
+  int tot_ant = config.pdsch_AntennaPorts.N1 * config.pdsch_AntennaPorts.N2 * config.pdsch_AntennaPorts.XP;
+  AssertFatal(config.maxMIMO_layers != 0 && config.maxMIMO_layers <= tot_ant, "Invalid maxMIMO_layers %d\n", config.maxMIMO_layers);
 
   NR_ServingCellConfigCommon_t *scc = get_scc_config(cfg, config.minRXTXTIME);
   //xer_fprint(stdout, &asn_DEF_NR_ServingCellConfigCommon, scc);
-- 
GitLab