blob: 045fb31725380e420c39ba2ccae8625bf929d279 [file] [log] [blame]
Max842d7812017-11-01 18:11:24 +01001/* 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.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 */
22
23#pragma once
24
25#include <stdint.h>
26#include <stddef.h>
27#include <stdbool.h>
28
29/* 3GPP TS 05.02 Annex B.1 */
30
Max327e1212017-11-21 13:01:19 +010031#define MS_NA 255 /* N/A */
Max842d7812017-11-01 18:11:24 +010032#define MS_A 254 /* 1 with hopping, 0 without */
33#define MS_B 253 /* 1 with hopping, 0 without (change Rx to Tx)*/
34#define MS_C 252 /* 1 with hopping, 0 without (change Tx to Rx)*/
Max01bd0cc2018-01-23 20:58:49 +010035#define MS_TO 251 /* 31 symbol periods (this can be provided by a TA offset, i.e. a minimum TA value) */
Max842d7812017-11-01 18:11:24 +010036
37#define DEFAULT_MSLOT_CLASS 12
38
Maxc5407c72018-02-05 16:11:36 +010039#define NO_FREE_TFI 0xffffffff
40
Maxf633b8d2018-01-31 15:28:53 +010041enum { MASK_TT = 0, MASK_TR = 1 };
42
Max842d7812017-11-01 18:11:24 +010043/* multislot class selection routines */
44uint8_t mslot_class_get_ta(uint8_t ms_cl);
45uint8_t mslot_class_get_tb(uint8_t ms_cl);
Max01bd0cc2018-01-23 20:58:49 +010046uint8_t mslot_class_get_ra(uint8_t ms_cl, uint8_t ta);
47uint8_t mslot_class_get_rb(uint8_t ms_cl, uint8_t ta);
Max842d7812017-11-01 18:11:24 +010048uint8_t mslot_class_get_tx(uint8_t ms_cl);
49uint8_t mslot_class_get_rx(uint8_t ms_cl);
50uint8_t mslot_class_get_sum(uint8_t ms_cl);
51uint8_t mslot_class_get_type(uint8_t ms_cl);
Max327e1212017-11-21 13:01:19 +010052uint8_t mslot_class_max();
Maxf633b8d2018-01-31 15:28:53 +010053
Max0cc72122018-01-31 17:00:06 +010054/* multislot allocation helper routines */
Maxf633b8d2018-01-31 15:28:53 +010055void mslot_fill_rx_mask(uint8_t mslot_class, uint8_t num_tx, uint8_t *rx_mask);
Maxadca67b2018-01-31 15:22:36 +010056int8_t find_free_usf(uint8_t usf_map);
Maxc5407c72018-02-05 16:11:36 +010057int8_t find_free_tfi(uint32_t tfi_map);
Max0cc72122018-01-31 17:00:06 +010058void masked_override_with(char *buf, uint8_t mask, char set_char);
Max77988d42018-02-19 18:00:38 +010059void ts_format(char *buf, uint8_t dl_mask, uint8_t ul_mask);
Max731e2bb2018-02-05 16:15:30 +010060uint16_t mslot_wrap_window(uint16_t win);
61bool mslot_test_and_set_bit(uint32_t *bits, size_t elem);
62int16_t mslot_filter_bad(uint8_t mask, uint8_t ul_slots, uint8_t dl_slots, uint16_t rx_valid_win);