Wei-Yu Chen | 49950b9 | 2021-11-08 19:19:18 +0800 | [diff] [blame^] | 1 | """ |
| 2 | Copyright 2020 The Magma Authors. |
| 3 | |
| 4 | This source code is licensed under the BSD-style license found in the |
| 5 | LICENSE file in the root directory of this source tree. |
| 6 | |
| 7 | Unless required by applicable law or agreed to in writing, software |
| 8 | distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | See the License for the specific language governing permissions and |
| 11 | limitations under the License. |
| 12 | """ |
| 13 | |
| 14 | from exceptions import ConfigurationError |
| 15 | |
| 16 | CELL_RESERVED_MAP = { |
| 17 | True: 'reserved', |
| 18 | False: 'notReserved', |
| 19 | } |
| 20 | |
| 21 | |
| 22 | INVERT_CELL_RESERVED_MAP = { |
| 23 | True: 'notReserved', |
| 24 | False: 'reserved', |
| 25 | } |
| 26 | |
| 27 | |
| 28 | def admin_state(flag): |
| 29 | return 'UP' if flag else 'DOWN' |
| 30 | |
| 31 | |
| 32 | def cell_reserved(value): |
| 33 | return CELL_RESERVED_MAP.get(value) |
| 34 | |
| 35 | |
| 36 | def 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 | |
| 43 | def 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 | |
| 50 | def 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 |