blob: f863abd789e6e5c7851aef845641b9761d140ab3 [file] [log] [blame]
Pau Espin Pedrolff7c5812022-12-14 18:49:06 +01001/* alloc_algo.h
2 *
Vadim Yanitskiy5fd00222023-05-18 17:22:26 +07003 * Copyright (C) 2022 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
Pau Espin Pedrolff7c5812022-12-14 18:49:06 +01004 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <stdbool.h>
19#include <stdint.h>
20
Pau Espin Pedrola6a972e2023-04-20 19:23:50 +020021#include "tbf.h"
22
Pau Espin Pedrolff7c5812022-12-14 18:49:06 +010023struct gprs_rlcmac_bts;
Pau Espin Pedrola6a972e2023-04-20 19:23:50 +020024struct GprsMs;
Pau Espin Pedrolff7c5812022-12-14 18:49:06 +010025struct gprs_rlcmac_tbf;
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
Pau Espin Pedrola6a972e2023-04-20 19:23:50 +020031struct alloc_resources_req {
32 /* BTS where to allocate resources */
33 struct gprs_rlcmac_bts *bts;
34 /* MS for which to allocate resources */
Pau Espin Pedrold6c555e2023-04-20 20:10:53 +020035 const struct GprsMs *ms;
Pau Espin Pedrola6a972e2023-04-20 19:23:50 +020036 /* Direction of the TBF for which we are allocating resources */
37 enum gprs_rlcmac_tbf_direction direction;
38 /* Whether to allocate only a single (1) TS */
39 bool single;
40 /* Whether to allocate on a specific TRX (>=0) or not (-1) */
41 int8_t use_trx;
Pau Espin Pedrola6a972e2023-04-20 19:23:50 +020042};
Pau Espin Pedrolff7c5812022-12-14 18:49:06 +010043
Pau Espin Pedrold6c555e2023-04-20 20:10:53 +020044struct alloc_resources_res {
45 struct gprs_rlcmac_trx *trx;
46 struct gprs_rlcmac_pdch *first_common_ts;
47 uint8_t reserved_ul_slots;
48 uint8_t reserved_dl_slots;
49 uint8_t ass_slots_mask;
50 bool upgrade_to_multislot;
51 uint8_t tfi;
52 int usf[8];
53};
Pau Espin Pedrolff7c5812022-12-14 18:49:06 +010054
Pau Espin Pedrold6c555e2023-04-20 20:10:53 +020055int alloc_algorithm_a(const struct alloc_resources_req *req,
56 struct alloc_resources_res *res);
Pau Espin Pedrola6a972e2023-04-20 19:23:50 +020057
Pau Espin Pedrold6c555e2023-04-20 20:10:53 +020058int alloc_algorithm_b(const struct alloc_resources_req *req,
59 struct alloc_resources_res *res);
60
61int alloc_algorithm_dynamic(const struct alloc_resources_req *req,
62 struct alloc_resources_res *res);
Pau Espin Pedrolff7c5812022-12-14 18:49:06 +010063int gprs_alloc_max_dl_slots_per_ms(const struct gprs_rlcmac_bts *bts, uint8_t ms_class);
64
65#ifdef __cplusplus
66}
67#endif