From 49e9b6e7da2ef5b4c4eb038a58ef35cd9245d5f8 Mon Sep 17 00:00:00 2001
From: Kirill Smelkov <kirr@nexedi.com>
Date: Thu, 1 Feb 2024 15:16:03 +0000
Subject: [PATCH] software/ors-amarisoft: enb: lte: Simplify Carrier
 Aggregation code

So far CA was setup only for lte case and it is possible to simplify generation
of all pair of cells to be done without extra loop and state.

Tests will be added later as full tests for generic MultiRU.

Backward compatibility: no change for ORS, which has only one cell, and
rendered enb.cfg and gnb.cfg stay the same.
---
 software/ors-amarisoft/config/enb.jinja2.cfg | 22 +++++++-------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/software/ors-amarisoft/config/enb.jinja2.cfg b/software/ors-amarisoft/config/enb.jinja2.cfg
index 4d5b35c32..10fa91937 100644
--- a/software/ors-amarisoft/config/enb.jinja2.cfg
+++ b/software/ors-amarisoft/config/enb.jinja2.cfg
@@ -184,7 +184,7 @@
   // LTE cells
   cell_list: [
 {%- if do_lte %}
-{%- for i, (cell_ref, cell) in enumerate(cell_dict|dictsort) %}
+{%- for cell_ref, cell in cell_dict|dictsort %}
 {%-   set ru_ref = cell.ru_ref %}
 {%-   set ru = ru_dict[ru_ref]  %}
 
@@ -205,23 +205,15 @@
 {{- handover_config() }}
 
       // Carrier Aggregation
-      {%- set scell_list = [] %}
-      {%- for j, l in enumerate(cell_dict) %}
-      {%-   if j != i %}
-      {%-     do scell_list.append([j, l]) %}
-      {%-   endif %}
-      {%- endfor %}
       scell_list: [
-        {%- for j, l in enumerate(scell_list) %}
-        {%- if j == 0 -%}
+{%-   for cell2_ref, cell2 in cell_dict|dictsort %}
+{%-     if cell2_ref != cell_ref  %}
         {
-        {%- else -%}
-        , {
-        {%- endif %}
-          cell_id: {{ cell_dict[l[1]].cell_id }},
+          cell_id: {{ cell2.cell_id }},  // + {{ cell2_ref }}
           cross_carrier_scheduling: false,
-        }
-        {%- endfor %}
+        },
+{%-     endif %}
+{%-   endfor %}
       ],
 
     // tune LTE parameters for the cell
-- 
2.30.9