Max | 842d781 | 2017-11-01 18:11:24 +0100 | [diff] [blame] | 1 | /* mslot_class.h |
| 2 | * |
| 3 | * Copyright (C) 2012 Ivan Klyuchnikov |
| 4 | * Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu> |
| 5 | * Copyright (C) 2013 by Holger Hans Peter Freyther |
| 6 | * Copyright (C) 2017 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License |
| 10 | * as published by the Free Software Foundation; either version 2 |
| 11 | * of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
Max | 842d781 | 2017-11-01 18:11:24 +0100 | [diff] [blame] | 17 | */ |
| 18 | |
| 19 | #pragma once |
| 20 | |
| 21 | #include <stdint.h> |
| 22 | #include <stddef.h> |
| 23 | #include <stdbool.h> |
| 24 | |
| 25 | /* 3GPP TS 05.02 Annex B.1 */ |
| 26 | |
Max | 327e121 | 2017-11-21 13:01:19 +0100 | [diff] [blame] | 27 | #define MS_NA 255 /* N/A */ |
Max | 842d781 | 2017-11-01 18:11:24 +0100 | [diff] [blame] | 28 | #define MS_A 254 /* 1 with hopping, 0 without */ |
| 29 | #define MS_B 253 /* 1 with hopping, 0 without (change Rx to Tx)*/ |
| 30 | #define MS_C 252 /* 1 with hopping, 0 without (change Tx to Rx)*/ |
Max | 01bd0cc | 2018-01-23 20:58:49 +0100 | [diff] [blame] | 31 | #define MS_TO 251 /* 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value) */ |
Max | 842d781 | 2017-11-01 18:11:24 +0100 | [diff] [blame] | 32 | |
| 33 | #define DEFAULT_MSLOT_CLASS 12 |
| 34 | |
Max | c5407c7 | 2018-02-05 16:11:36 +0100 | [diff] [blame] | 35 | #define NO_FREE_TFI 0xffffffff |
| 36 | |
Max | f633b8d | 2018-01-31 15:28:53 +0100 | [diff] [blame] | 37 | enum { MASK_TT = 0, MASK_TR = 1 }; |
| 38 | |
Max | 842d781 | 2017-11-01 18:11:24 +0100 | [diff] [blame] | 39 | /* multislot class selection routines */ |
| 40 | uint8_t mslot_class_get_ta(uint8_t ms_cl); |
| 41 | uint8_t mslot_class_get_tb(uint8_t ms_cl); |
Max | 01bd0cc | 2018-01-23 20:58:49 +0100 | [diff] [blame] | 42 | uint8_t mslot_class_get_ra(uint8_t ms_cl, uint8_t ta); |
| 43 | uint8_t mslot_class_get_rb(uint8_t ms_cl, uint8_t ta); |
Max | 842d781 | 2017-11-01 18:11:24 +0100 | [diff] [blame] | 44 | uint8_t mslot_class_get_tx(uint8_t ms_cl); |
| 45 | uint8_t mslot_class_get_rx(uint8_t ms_cl); |
| 46 | uint8_t mslot_class_get_sum(uint8_t ms_cl); |
| 47 | uint8_t mslot_class_get_type(uint8_t ms_cl); |
Max | 327e121 | 2017-11-21 13:01:19 +0100 | [diff] [blame] | 48 | uint8_t mslot_class_max(); |
Max | f633b8d | 2018-01-31 15:28:53 +0100 | [diff] [blame] | 49 | |
Max | 0cc7212 | 2018-01-31 17:00:06 +0100 | [diff] [blame] | 50 | /* multislot allocation helper routines */ |
Max | f633b8d | 2018-01-31 15:28:53 +0100 | [diff] [blame] | 51 | void mslot_fill_rx_mask(uint8_t mslot_class, uint8_t num_tx, uint8_t *rx_mask); |
Max | adca67b | 2018-01-31 15:22:36 +0100 | [diff] [blame] | 52 | int8_t find_free_usf(uint8_t usf_map); |
Max | c5407c7 | 2018-02-05 16:11:36 +0100 | [diff] [blame] | 53 | int8_t find_free_tfi(uint32_t tfi_map); |
Max | 0cc7212 | 2018-01-31 17:00:06 +0100 | [diff] [blame] | 54 | void masked_override_with(char *buf, uint8_t mask, char set_char); |
Max | 77988d4 | 2018-02-19 18:00:38 +0100 | [diff] [blame] | 55 | void ts_format(char *buf, uint8_t dl_mask, uint8_t ul_mask); |
Max | 731e2bb | 2018-02-05 16:15:30 +0100 | [diff] [blame] | 56 | uint16_t mslot_wrap_window(uint16_t win); |
| 57 | bool mslot_test_and_set_bit(uint32_t *bits, size_t elem); |
| 58 | int16_t mslot_filter_bad(uint8_t mask, uint8_t ul_slots, uint8_t dl_slots, uint16_t rx_valid_win); |