blob: aa2214eb491f9be6187e7624f4f357c45fff6a59 [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
Pau Espin Pedrol6691f512023-07-27 21:39:48 +020025/* 3GPP TS 45.002 Annex B.1 */
Max842d7812017-11-01 18:11:24 +010026
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
Pau Espin Pedrol441768a2023-07-27 21:42:01 +020033/* If Multislot Class is not known, use ms_class=1: Rx=1 Tx=1 Sum=2 */
34#define DEFAULT_MSLOT_CLASS 1
Max842d7812017-11-01 18:11:24 +010035
Maxc5407c72018-02-05 16:11:36 +010036#define NO_FREE_TFI 0xffffffff
37
Maxf633b8d2018-01-31 15:28:53 +010038enum { MASK_TT = 0, MASK_TR = 1 };
39
Max842d7812017-11-01 18:11:24 +010040/* multislot class selection routines */
41uint8_t mslot_class_get_ta(uint8_t ms_cl);
42uint8_t mslot_class_get_tb(uint8_t ms_cl);
Max01bd0cc2018-01-23 20:58:49 +010043uint8_t mslot_class_get_ra(uint8_t ms_cl, uint8_t ta);
44uint8_t mslot_class_get_rb(uint8_t ms_cl, uint8_t ta);
Max842d7812017-11-01 18:11:24 +010045uint8_t mslot_class_get_tx(uint8_t ms_cl);
46uint8_t mslot_class_get_rx(uint8_t ms_cl);
47uint8_t mslot_class_get_sum(uint8_t ms_cl);
48uint8_t mslot_class_get_type(uint8_t ms_cl);
Max327e1212017-11-21 13:01:19 +010049uint8_t mslot_class_max();
Maxf633b8d2018-01-31 15:28:53 +010050
Max0cc72122018-01-31 17:00:06 +010051/* multislot allocation helper routines */
Maxf633b8d2018-01-31 15:28:53 +010052void mslot_fill_rx_mask(uint8_t mslot_class, uint8_t num_tx, uint8_t *rx_mask);
Maxadca67b2018-01-31 15:22:36 +010053int8_t find_free_usf(uint8_t usf_map);
Maxc5407c72018-02-05 16:11:36 +010054int8_t find_free_tfi(uint32_t tfi_map);
Max0cc72122018-01-31 17:00:06 +010055void masked_override_with(char *buf, uint8_t mask, char set_char);
Max77988d42018-02-19 18:00:38 +010056void ts_format(char *buf, uint8_t dl_mask, uint8_t ul_mask);
Max731e2bb2018-02-05 16:15:30 +010057uint16_t mslot_wrap_window(uint16_t win);
58bool mslot_test_and_set_bit(uint32_t *bits, size_t elem);
59int16_t mslot_filter_bad(uint8_t mask, uint8_t ul_slots, uint8_t dl_slots, uint16_t rx_valid_win);