[PATCH] osmo-gsm-tester[master]: bts: Allow setting amount of TRX and timeslot in cfg and fro...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Tue May 8 15:14:41 UTC 2018


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/8061

to look at the new patch set (#2).

bts: Allow setting amount of TRX and timeslot in cfg and from test at runtime

The num_trx attribute for a given BTS states the number of TRX to be
used by that BTS. If more than num_trx are configured in trx_list in the
cfg file, then only up to num_trx are taken into account. If a num_trx
value higher than max_trx is specified throuygh config file or at
runtime by the test, an exception is raised explaining the issue.

The num/max_trx attributes are overlayed along the config levels
(generic -> bsc_bts -> specific bts-type -> specific resource object).
This way we can specify a long list of trx+timeslot config in the
generic config (bsc_bts), and tune for each model and specific BTS which
is the desired default number of TRX, as well as the maximum supported
per type.

Change-Id: I7f46eaf7a16f03268653299c93600c0443f691ac
---
M example/defaults.conf
M src/osmo_gsm_tester/bts.py
M src/osmo_gsm_tester/bts_octphy.py
M src/osmo_gsm_tester/resource.py
4 files changed, 98 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/61/8061/2

diff --git a/example/defaults.conf b/example/defaults.conf
index c110dde..1e84200 100644
--- a/example/defaults.conf
+++ b/example/defaults.conf
@@ -28,6 +28,8 @@
   base_station_id_code: 63
   stream_id: 255
   osmobsc_bts_type: sysmobts
+  num_trx: 1
+  max_trx: 1
   trx_list:
   - nominal_power: 23
     max_power_red: 0
@@ -41,3 +43,18 @@
     - phys_chan_config: TCH/F
     - phys_chan_config: PDCH
     - phys_chan_config: PDCH
+  - nominal_power: 23
+    max_power_red: 0
+    arfcn: 870
+    timeslot_list:
+    - phys_chan_config: TCH/F
+    - phys_chan_config: TCH/F
+    - phys_chan_config: TCH/F
+    - phys_chan_config: TCH/F
+    - phys_chan_config: TCH/F
+    - phys_chan_config: TCH/F
+    - phys_chan_config: TCH/F
+    - phys_chan_config: TCH/F
+
+osmo_bts_octphy:
+  max_trx: 2
diff --git a/src/osmo_gsm_tester/bts.py b/src/osmo_gsm_tester/bts.py
index 731f5a7..f59cff3 100644
--- a/src/osmo_gsm_tester/bts.py
+++ b/src/osmo_gsm_tester/bts.py
@@ -21,7 +21,7 @@
 import pprint
 import tempfile
 from abc import ABCMeta, abstractmethod
-from . import log, config, util, template, process, pcu_osmo
+from . import log, config, util, template, process, schema, pcu_osmo
 
 class Bts(log.Origin, metaclass=ABCMeta):
     suite_run = None
@@ -33,6 +33,9 @@
     cellid = None
     bvci = None
     defaults_cfg_name = None
+    _num_trx = 1
+    _max_trx = None
+    overlay_trx_list = []
 
 ##############
 # PROTECTED
@@ -42,10 +45,65 @@
         self.suite_run = suite_run
         self.conf = conf
         self.defaults_cfg_name = defaults_cfg_name
+        self._init_num_trx()
+
+    def _resolve_bts_cfg(self, cfg_name):
+        res = None
+        val = config.get_defaults('bsc_bts').get(cfg_name)
+        if val is not None:
+            res = val
+        val = config.get_defaults(self.defaults_cfg_name).get(cfg_name)
+        if val is not None:
+            res = val
+        val = self.conf.get(cfg_name)
+        if val is not None:
+            res = val
+        return res
+
+    def _init_num_trx(self):
+        self._num_trx = 1
+        self._max_trx = None
+        val = self._resolve_bts_cfg('num_trx')
+        if val is not None:
+            self._num_trx = int(val)
+        val = self._resolve_bts_cfg('max_trx')
+        if val is not None:
+            self._max_trx = int(val)
+        self._validate_new_num_trx(self._num_trx)
+        self.overlay_trx_list = [Bts._new_default_trx_cfg() for trx in range(self._num_trx)]
+
+    def _validate_new_num_trx(self, num_trx):
+        if self._max_trx is not None and num_trx > self._max_trx:
+            raise log.Error('Amount of TRX requested is too high for maximum allowed: %u > %u' %(num_trx, self._max_trx))
+
+    @staticmethod
+    def _new_default_trx_cfg():
+        return {'timeslot_list':[{} for ts in range(8)]}
+
+    @staticmethod
+    def _trx_list_recreate(trx_list, new_size):
+        curr_len = len(trx_list)
+        if new_size < curr_len:
+            trx_list = trx_list[0:new_size]
+        elif new_size > curr_len:
+            for i in range(new_size - curr_len):
+                trx_list.append(Bts._new_default_trx_cfg())
+        return trx_list
 
     def conf_for_bsc_prepare(self):
         values = config.get_defaults('bsc_bts')
-        config.overlay(values, config.get_defaults(self.defaults_cfg_name))
+        # Make sure the trx_list is adapted to num of trx configured at runtime
+        # to avoid overlay issues.
+        trx_list = values.get('trx_list')
+        if trx_list and len(trx_list) != self.num_trx():
+            values['trx_list'] = Bts._trx_list_recreate(trx_list, self.num_trx())
+
+        bts_defaults = config.get_defaults(self.defaults_cfg_name)
+        trx_list = bts_defaults.get('trx_list')
+        if trx_list and len(trx_list) != self.num_trx():
+            bts_defaults['trx_list'] = Bts._trx_list_recreate(trx_list, self.num_trx())
+
+        config.overlay(values, bts_defaults)
         if self.lac is not None:
             config.overlay(values, { 'location_area_code': self.lac })
         if self.rac is not None:
@@ -58,6 +116,8 @@
 
         sgsn_conf = {} if self.sgsn is None else self.sgsn.conf_for_client()
         config.overlay(values, sgsn_conf)
+
+        config.overlay(values, { 'trx_list': self.overlay_trx_list })
         return values
 
 ########################
@@ -111,4 +171,21 @@
     def set_bvci(self, bvci):
         self.bvci = bvci
 
+    def set_num_trx(self, num_trx):
+        assert num_trx > 0
+        self._validate_new_num_trx(num_trx)
+        if num_trx == self._num_trx:
+            return
+        self._num_trx = num_trx
+        self.overlay_trx_list = Bts._trx_list_recreate(self.overlay_trx_list, num_trx)
+
+    def num_trx(self):
+        return self._num_trx
+
+    def set_trx_phy_channel(self, trx_idx, ts_idx, config):
+        assert trx_idx < self._num_trx
+        assert ts_idx < 8
+        schema.phy_channel_config(config) # validation
+        self.overlay_trx_list[trx_idx]['timeslot_list'][ts_idx]['phys_chan_config'] = config
+
 # vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/osmo_gsm_tester/bts_octphy.py b/src/osmo_gsm_tester/bts_octphy.py
index 1c4b4a0..318c30d 100644
--- a/src/osmo_gsm_tester/bts_octphy.py
+++ b/src/osmo_gsm_tester/bts_octphy.py
@@ -52,9 +52,6 @@
         proc.launch()
         return proc
 
-    def num_trx(self):
-        return len(self.values['osmo_bts_octphy'].get('trx_list', []))
-
     def allocate_phy_instances(self, c):
         '''
         Generate match trx Z <-> phy X inst Y to use in vty config
diff --git a/src/osmo_gsm_tester/resource.py b/src/osmo_gsm_tester/resource.py
index 4b9e1ff..70d6e8a 100644
--- a/src/osmo_gsm_tester/resource.py
+++ b/src/osmo_gsm_tester/resource.py
@@ -60,6 +60,8 @@
         'bts[].power_supply.device': schema.STR,
         'bts[].power_supply.port': schema.STR,
         'bts[].ciphers[]': schema.CIPHER,
+        'bts[].num_trx': schema.UINT,
+        'bts[].max_trx': schema.UINT,
         'bts[].trx_list[].hw_addr': schema.HWADDR,
         'bts[].trx_list[].net_device': schema.STR,
         'bts[].trx_list[].nominal_power': schema.UINT,

-- 
To view, visit https://gerrit.osmocom.org/8061
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I7f46eaf7a16f03268653299c93600c0443f691ac
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list