Pau Espin Pedrol | 15c58ac | 2021-03-08 14:57:58 +0100 | [diff] [blame] | 1 | /* 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 | |
| 28 | struct gprs_rlcmac_pdch; |
| 29 | struct gprs_rlcmac_tbf; |
| 30 | struct gprs_rlcmac_ul_tbf; |
| 31 | struct gprs_rlcmac_sba; |
| 32 | |
| 33 | struct 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 | |
| 40 | enum PdchUlcNode { |
| 41 | PDCH_ULC_NODE_TBF_USF, |
| 42 | PDCH_ULC_NODE_TBF_POLL, |
| 43 | PDCH_ULC_NODE_SBA, |
| 44 | }; |
| 45 | extern const struct value_string pdch_ul_node_names[]; |
| 46 | |
| 47 | struct 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 | |
| 65 | struct pdch_ulc *pdch_ulc_alloc(struct gprs_rlcmac_pdch *pdch, void *ctx); |
| 66 | |
| 67 | int pdch_ulc_reserve_tbf_usf(struct pdch_ulc *ulc, uint32_t fn, struct gprs_rlcmac_ul_tbf *ul_tbf); |
| 68 | int pdch_ulc_reserve_tbf_poll(struct pdch_ulc *ulc, uint32_t fn, struct gprs_rlcmac_tbf *tbf); |
| 69 | int pdch_ulc_reserve_sba(struct pdch_ulc *ulc, struct gprs_rlcmac_sba *sba); |
| 70 | |
| 71 | bool pdch_ulc_fn_is_free(struct pdch_ulc *ulc, uint32_t fn); |
| 72 | |
Pau Espin Pedrol | 99360a3 | 2021-03-09 17:18:12 +0100 | [diff] [blame] | 73 | int pdch_ulc_get_next_free_rrbp_fn(struct pdch_ulc *ulc, uint32_t fn, uint32_t *poll_fn, unsigned int *rrbp); |
| 74 | |
Pau Espin Pedrol | 15c58ac | 2021-03-08 14:57:58 +0100 | [diff] [blame] | 75 | struct pdch_ulc_node *pdch_ulc_get_node(struct pdch_ulc *ulc, uint32_t fn); |
| 76 | struct pdch_ulc_node *pdch_ulc_pop_node(struct pdch_ulc *ulc, uint32_t fn); |
| 77 | struct gprs_rlcmac_sba *pdch_ulc_get_sba(struct pdch_ulc *ulc, uint32_t fn); |
Pau Espin Pedrol | fd1fbdb | 2021-03-11 16:59:50 +0100 | [diff] [blame] | 78 | struct gprs_rlcmac_tbf *pdch_ulc_get_tbf_poll(struct pdch_ulc *ulc, uint32_t fn); |
Pau Espin Pedrol | 15c58ac | 2021-03-08 14:57:58 +0100 | [diff] [blame] | 79 | |
Pau Espin Pedrol | ade9c2f | 2021-03-24 14:02:49 +0100 | [diff] [blame] | 80 | void pdch_ulc_release_node(struct pdch_ulc *ulc, struct pdch_ulc_node *item); |
Pau Espin Pedrol | 99360a3 | 2021-03-09 17:18:12 +0100 | [diff] [blame] | 81 | void pdch_ulc_release_tbf(struct pdch_ulc *ulc, const struct gprs_rlcmac_tbf *tbf); |
Pau Espin Pedrol | 15c58ac | 2021-03-08 14:57:58 +0100 | [diff] [blame] | 82 | int pdch_ulc_release_fn(struct pdch_ulc *ulc, uint32_t fn); |
| 83 | |
| 84 | void pdch_ulc_expire_fn(struct pdch_ulc *ulc, uint32_t fn); |