blob: 7f3aaf8da22f2d09247421a1bf3515b93faa2bf2 [file] [log] [blame]
Wei-Yu Chen49950b92021-11-08 19:19:18 +08001"""
2Copyright 2020 The Magma Authors.
3
4This source code is licensed under the BSD-style license found in the
5LICENSE file in the root directory of this source tree.
6
7Unless required by applicable law or agreed to in writing, software
8distributed under the License is distributed on an "AS IS" BASIS,
9WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10See the License for the specific language governing permissions and
11limitations under the License.
12"""
13
14from exceptions import ConfigurationError
15
16CELL_RESERVED_MAP = {
17 True: 'reserved',
18 False: 'notReserved',
19}
20
21
22INVERT_CELL_RESERVED_MAP = {
23 True: 'notReserved',
24 False: 'reserved',
25}
26
27
28def admin_state(flag):
29 return 'UP' if flag else 'DOWN'
30
31
32def cell_reserved(value):
33 return CELL_RESERVED_MAP.get(value)
34
35
36def invert_cell_reserved(value):
37 """
38 We need to handle Baicells bug which inverts the meaning of 'cell reserved'
39 """
40 return INVERT_CELL_RESERVED_MAP.get(value)
41
42
43def invert_cell_barred(value: bool):
44 """
45 We need to handle Baicells bug which inverts the meaning of 'cell barred'
46 """
47 return not value
48
49
50def bandwidth(bandwidth_mhz):
51 """
52 Map bandwidth in MHz to number of RBs
53 TODO: TR-196 spec says this should be '6' rather than 'n6', but
54 BaiCells eNodeB uses 'n6'. Need to resolve this.
55
56 Args:
57 bandwidth_mhz (int): Bandwidth in MHz
58 Returns:
59 str: Bandwidth in RBS
60 """
61 if bandwidth_mhz == 1.4:
62 bandwidth_rbs = 'n6'
63 elif bandwidth_mhz == 3:
64 bandwidth_rbs = 'n15'
65 elif bandwidth_mhz == 5:
66 bandwidth_rbs = 'n25'
67 elif bandwidth_mhz == 10:
68 bandwidth_rbs = 'n50'
69 elif bandwidth_mhz == 15:
70 bandwidth_rbs = 'n75'
71 elif bandwidth_mhz == 20:
72 bandwidth_rbs = 'n100'
73 else:
74 raise ConfigurationError(
75 'Unknown bandwidth_mhz (%s)' %
76 str(bandwidth_mhz),
77 )
78 return bandwidth_rbs