blob: bb5053f5257c30684ad1f616da8d56f1ae3538c9 [file] [log] [blame]
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +02001# osmo_gsm_tester: base classes to share code among eNodeB subclasses.
2#
3# Copyright (C) 2020 by sysmocom - s.f.m.c. GmbH
4#
5# Author: Pau Espin Pedrol <pespin@sysmocom.de>
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20from abc import ABCMeta, abstractmethod
Pau Espin Pedrole1a58bd2020-04-10 20:46:07 +020021from ..core import log, config
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020022
23
24class eNodeB(log.Origin, metaclass=ABCMeta):
25
26##############
27# PROTECTED
28##############
29 def __init__(self, suite_run, conf, name):
30 super().__init__(log.C_RUN, '%s' % name)
31 self._conf = conf
32 self._addr = conf.get('addr', None)
33 if self._addr is None:
34 raise log.Error('addr not set')
35 self.set_name('%s_%s' % (name, self._addr))
Pau Espin Pedrole44e76a2020-03-31 12:35:19 +020036 self._txmode = 0
37 self._num_prb = 0
38 self._epc = None
39
Pau Espin Pedrolc04528c2020-04-01 13:55:51 +020040 def configure(self, config_specifics_li):
Pau Espin Pedrole44e76a2020-03-31 12:35:19 +020041 values = dict(enb=config.get_defaults('enb'))
Pau Espin Pedrolc04528c2020-04-01 13:55:51 +020042 for config_specifics in config_specifics_li:
43 config.overlay(values, dict(enb=config.get_defaults(config_specifics)))
Pau Espin Pedrole44e76a2020-03-31 12:35:19 +020044 config.overlay(values, dict(enb=self.suite_run.config().get('enb', {})))
Pau Espin Pedrolc04528c2020-04-01 13:55:51 +020045 for config_specifics in config_specifics_li:
46 config.overlay(values, dict(enb=self.suite_run.config().get(config_specifics, {})))
Pau Espin Pedrole44e76a2020-03-31 12:35:19 +020047 config.overlay(values, dict(enb=self._conf))
48 self._num_prb = int(values['enb'].get('num_prb', None))
49 assert self._num_prb
50 self._txmode = int(values['enb'].get('transmission_mode', None))
51 assert self._txmode
52 config.overlay(values, dict(enb={ 'num_ports': self.num_ports() }))
53 assert self._epc is not None
54 config.overlay(values, dict(enb={ 'mme_addr': self._epc.addr() }))
55 return values
56
57 def num_ports(self):
58 if self._txmode == 1:
59 return 1
60 return 2
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020061
62########################
63# PUBLIC - INTERNAL API
64########################
65 def cleanup(self):
66 'Nothing to do by default. Subclass can override if required.'
67 pass
68
Pau Espin Pedrole44e76a2020-03-31 12:35:19 +020069 def num_prb(self):
70 return self._num_prb
71
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020072###################
73# PUBLIC (test API included)
74###################
75 @abstractmethod
76 def start(self, epc):
77 'Starts ENB, it will connect to "epc"'
78 pass
79
80 @abstractmethod
81 def ue_add(self, ue):
82 pass
83
84 @abstractmethod
85 def running(self):
86 pass
87
88 @abstractmethod
89 def ue_max_rate(self, downlink=True):
90 pass
91
92 def addr(self):
93 return self._addr
94
Pau Espin Pedrole44e76a2020-03-31 12:35:19 +020095 def ue_max_rate(self, downlink=True):
96 # The max rate for a single UE per PRB configuration in TM1
97 max_phy_rate_tm1_dl = { 6 : 3.5e6,
98 15 : 11e6,
99 25 : 18e6,
100 50 : 36e6,
101 75 : 55e6,
102 100 : 75e6 }
103 max_phy_rate_tm1_ul = { 6 : 0.9e6,
104 15 : 4.7e6,
105 25 : 10e6,
106 50 : 23e6,
107 75 : 34e6,
108 100 : 51e6 }
109 if downlink:
110 max_rate = max_phy_rate_tm1_dl[self.num_prb()]
111 else:
112 max_rate = max_phy_rate_tm1_ul[self.num_prb()]
113 #TODO: calculate for non-standard prb numbers.
114 if self._txmode > 2:
115 max_rate *= 2
116 # We use 3 control symbols for 6, 15 and 25 PRBs which results in lower max rate
117 if self.num_prb() < 50:
118 max_rate *= 0.9
119 return max_rate
120
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200121# vim: expandtab tabstop=4 shiftwidth=4