blob: 6075f401c1f164b6ed2386492c5bff4b22077633 [file] [log] [blame]
Wei-Yu Chenad55cb82022-02-15 20:07:01 +08001# SPDX-FileCopyrightText: 2020 The Magma Authors.
2# SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
3#
4# SPDX-License-Identifier: BSD-3-Clause
Wei-Yu Chen49950b92021-11-08 19:19:18 +08005
6from exceptions import ConfigurationError
7
8CELL_RESERVED_MAP = {
9 True: 'reserved',
10 False: 'notReserved',
11}
12
13
14INVERT_CELL_RESERVED_MAP = {
15 True: 'notReserved',
16 False: 'reserved',
17}
18
19
20def admin_state(flag):
21 return 'UP' if flag else 'DOWN'
22
23
24def cell_reserved(value):
25 return CELL_RESERVED_MAP.get(value)
26
27
28def invert_cell_reserved(value):
29 """
30 We need to handle Baicells bug which inverts the meaning of 'cell reserved'
31 """
32 return INVERT_CELL_RESERVED_MAP.get(value)
33
34
35def invert_cell_barred(value: bool):
36 """
37 We need to handle Baicells bug which inverts the meaning of 'cell barred'
38 """
39 return not value
40
41
42def bandwidth(bandwidth_mhz):
43 """
44 Map bandwidth in MHz to number of RBs
45 TODO: TR-196 spec says this should be '6' rather than 'n6', but
46 BaiCells eNodeB uses 'n6'. Need to resolve this.
47
48 Args:
49 bandwidth_mhz (int): Bandwidth in MHz
50 Returns:
51 str: Bandwidth in RBS
52 """
53 if bandwidth_mhz == 1.4:
54 bandwidth_rbs = 'n6'
55 elif bandwidth_mhz == 3:
56 bandwidth_rbs = 'n15'
57 elif bandwidth_mhz == 5:
58 bandwidth_rbs = 'n25'
59 elif bandwidth_mhz == 10:
60 bandwidth_rbs = 'n50'
61 elif bandwidth_mhz == 15:
62 bandwidth_rbs = 'n75'
63 elif bandwidth_mhz == 20:
64 bandwidth_rbs = 'n100'
65 else:
66 raise ConfigurationError(
67 'Unknown bandwidth_mhz (%s)' %
68 str(bandwidth_mhz),
69 )
70 return bandwidth_rbs