Wei-Yu Chen | ad55cb8 | 2022-02-15 20:07:01 +0800 | [diff] [blame] | 1 | # 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 Chen | 49950b9 | 2021-11-08 19:19:18 +0800 | [diff] [blame] | 5 | |
| 6 | from exceptions import ConfigurationError |
| 7 | |
| 8 | CELL_RESERVED_MAP = { |
| 9 | True: 'reserved', |
| 10 | False: 'notReserved', |
| 11 | } |
| 12 | |
| 13 | |
| 14 | INVERT_CELL_RESERVED_MAP = { |
| 15 | True: 'notReserved', |
| 16 | False: 'reserved', |
| 17 | } |
| 18 | |
| 19 | |
| 20 | def admin_state(flag): |
| 21 | return 'UP' if flag else 'DOWN' |
| 22 | |
| 23 | |
| 24 | def cell_reserved(value): |
| 25 | return CELL_RESERVED_MAP.get(value) |
| 26 | |
| 27 | |
| 28 | def 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 | |
| 35 | def 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 | |
| 42 | def 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 |