blob: 7a6d5d46537fbfcd568c303f20685405bdb58a33 [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.
Max842d7812017-11-01 18:11:24 +010017 */
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
Max327e1212017-11-21 13:01:19 +010027#define MS_NA 255 /* N/A */
Max842d7812017-11-01 18:11:24 +010028#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)*/
Max01bd0cc2018-01-23 20:58:49 +010031#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 +010032
33#define DEFAULT_MSLOT_CLASS 12
34
Maxc5407c72018-02-05 16:11:36 +010035#define NO_FREE_TFI 0xffffffff
36
Maxf633b8d2018-01-31 15:28:53 +010037enum { MASK_TT = 0, MASK_TR = 1 };
38
Max842d7812017-11-01 18:11:24 +010039/* multislot class selection routines */
40uint8_t mslot_class_get_ta(uint8_t ms_cl);
41uint8_t mslot_class_get_tb(uint8_t ms_cl);
Max01bd0cc2018-01-23 20:58:49 +010042uint8_t mslot_class_get_ra(uint8_t ms_cl, uint8_t ta);
43uint8_t mslot_class_get_rb(uint8_t ms_cl, uint8_t ta);
Max842d7812017-11-01 18:11:24 +010044uint8_t mslot_class_get_tx(uint8_t ms_cl);
45uint8_t mslot_class_get_rx(uint8_t ms_cl);
46uint8_t mslot_class_get_sum(uint8_t ms_cl);
47uint8_t mslot_class_get_type(uint8_t ms_cl);
Max327e1212017-11-21 13:01:19 +010048uint8_t mslot_class_max();
Maxf633b8d2018-01-31 15:28:53 +010049
Max0cc72122018-01-31 17:00:06 +010050/* multislot allocation helper routines */
Maxf633b8d2018-01-31 15:28:53 +010051void mslot_fill_rx_mask(uint8_t mslot_class, uint8_t num_tx, uint8_t *rx_mask);
Maxadca67b2018-01-31 15:22:36 +010052int8_t find_free_usf(uint8_t usf_map);
Maxc5407c72018-02-05 16:11:36 +010053int8_t find_free_tfi(uint32_t tfi_map);
Max0cc72122018-01-31 17:00:06 +010054void masked_override_with(char *buf, uint8_t mask, char set_char);
Max77988d42018-02-19 18:00:38 +010055void ts_format(char *buf, uint8_t dl_mask, uint8_t ul_mask);
Max731e2bb2018-02-05 16:15:30 +010056uint16_t mslot_wrap_window(uint16_t win);
57bool mslot_test_and_set_bit(uint32_t *bits, size_t elem);
58int16_t mslot_filter_bad(uint8_t mask, uint8_t ul_slots, uint8_t dl_slots, uint16_t rx_valid_win);