blob: e86dbf52e6de919ca78db8a930a0ff8ba29705bd [file] [log] [blame]
Pau Espin Pedrol15c58ac2021-03-08 14:57:58 +01001/* pdch_ul_controller.h
2 *
3 * Copyright (C) 2021 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
4 * Author: Pau Espin Pedrol <pespin@sysmocom.de>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20#pragma once
21
22#include <stdint.h>
23#include <stdbool.h>
24
25#include <osmocom/core/linuxrbtree.h>
26#include <osmocom/core/utils.h>
27
28struct gprs_rlcmac_pdch;
29struct gprs_rlcmac_tbf;
30struct gprs_rlcmac_ul_tbf;
31struct gprs_rlcmac_sba;
32
33struct pdch_ulc {
34 struct gprs_rlcmac_pdch *pdch; /* back pointer */
35 uint32_t last_fn; /* last FN rx from TDMA clock */
36 struct rb_root tree_root;
37 void *pool_ctx; /* talloc pool of struct pdch_ulc_node */
38};
39
40enum PdchUlcNode {
41 PDCH_ULC_NODE_TBF_USF,
42 PDCH_ULC_NODE_TBF_POLL,
43 PDCH_ULC_NODE_SBA,
44};
45extern const struct value_string pdch_ul_node_names[];
46
47struct pdch_ulc_node {
48 struct rb_node node; /*! entry in pdch_ulc->tree_root */
49 uint32_t fn;
50 enum PdchUlcNode type;
51 union {
52 struct {
53 struct gprs_rlcmac_ul_tbf *ul_tbf;
54 } tbf_usf;
55 struct {
56 struct gprs_rlcmac_tbf *poll_tbf;
57 } tbf_poll;
58 struct {
59 struct gprs_rlcmac_sba *sba;
60 } sba;
61 };
62};
63
64
65struct pdch_ulc *pdch_ulc_alloc(struct gprs_rlcmac_pdch *pdch, void *ctx);
66
67int pdch_ulc_reserve_tbf_usf(struct pdch_ulc *ulc, uint32_t fn, struct gprs_rlcmac_ul_tbf *ul_tbf);
68int pdch_ulc_reserve_tbf_poll(struct pdch_ulc *ulc, uint32_t fn, struct gprs_rlcmac_tbf *tbf);
69int pdch_ulc_reserve_sba(struct pdch_ulc *ulc, struct gprs_rlcmac_sba *sba);
70
71bool pdch_ulc_fn_is_free(struct pdch_ulc *ulc, uint32_t fn);
72
73struct pdch_ulc_node *pdch_ulc_get_node(struct pdch_ulc *ulc, uint32_t fn);
74struct pdch_ulc_node *pdch_ulc_pop_node(struct pdch_ulc *ulc, uint32_t fn);
75struct gprs_rlcmac_sba *pdch_ulc_get_sba(struct pdch_ulc *ulc, uint32_t fn);
76
77int pdch_ulc_release_fn(struct pdch_ulc *ulc, uint32_t fn);
78
79void pdch_ulc_expire_fn(struct pdch_ulc *ulc, uint32_t fn);