Holger Hans Peter Freyther | 17c31ce | 2013-08-24 18:31:27 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 by Holger Hans Peter Freyther |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; either version 2 |
| 7 | * of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | */ |
| 18 | |
| 19 | #pragma once |
| 20 | |
Daniel Willmann | afa72f5 | 2014-01-15 17:06:19 +0100 | [diff] [blame] | 21 | #ifdef __cplusplus |
| 22 | |
Holger Hans Peter Freyther | be57081 | 2013-11-07 08:01:49 +0100 | [diff] [blame] | 23 | #include "llc.h" |
Holger Hans Peter Freyther | 6b5660c | 2013-11-23 16:10:48 +0100 | [diff] [blame] | 24 | #include "rlc.h" |
Jacob Erlbeck | 6835cea | 2015-08-21 15:24:02 +0200 | [diff] [blame] | 25 | #include "cxx_linuxlist.h" |
Daniel Willmann | eb10024 | 2014-08-08 11:43:53 +0200 | [diff] [blame] | 26 | #include <gprs_debug.h> |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 27 | #include <gprs_coding_scheme.h> |
| 28 | #include <gsm_timer.h> |
Holger Hans Peter Freyther | 17c31ce | 2013-08-24 18:31:27 +0200 | [diff] [blame] | 29 | #include <stdint.h> |
Max | e66de5b | 2017-01-05 18:26:58 +0100 | [diff] [blame] | 30 | extern "C" { |
| 31 | #include <osmocom/core/utils.h> |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 32 | #include <osmocom/core/linuxlist.h> |
| 33 | #include <osmocom/core/logging.h> |
| 34 | #include <osmocom/core/timer.h> |
Max | e66de5b | 2017-01-05 18:26:58 +0100 | [diff] [blame] | 35 | } |
Holger Hans Peter Freyther | 17c31ce | 2013-08-24 18:31:27 +0200 | [diff] [blame] | 36 | |
Holger Hans Peter Freyther | 1702f10 | 2013-10-20 08:44:02 +0200 | [diff] [blame] | 37 | struct bssgp_bvc_ctx; |
Jacob Erlbeck | fecece0 | 2015-05-08 12:13:08 +0200 | [diff] [blame] | 38 | class GprsMs; |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 39 | struct gprs_rlcmac_bts; |
Holger Hans Peter Freyther | 1702f10 | 2013-10-20 08:44:02 +0200 | [diff] [blame] | 40 | |
Holger Hans Peter Freyther | 9e21d84 | 2013-10-16 17:48:12 +0200 | [diff] [blame] | 41 | /* |
| 42 | * TBF instance |
| 43 | */ |
| 44 | |
Max | b2de1f7 | 2017-12-20 18:05:29 +0100 | [diff] [blame] | 45 | #define T_ASS_AGCH_USEC 200000 /* waiting after IMM.ASS confirm */ |
| 46 | #define T_ASS_PACCH_SEC 2 /* timeout for pacch assigment */ |
| 47 | #define T_REJ_PACCH_USEC 2000 /* timeout for tbf reject for PRR*/ |
Holger Hans Peter Freyther | 9e21d84 | 2013-10-16 17:48:12 +0200 | [diff] [blame] | 48 | |
| 49 | enum gprs_rlcmac_tbf_state { |
| 50 | GPRS_RLCMAC_NULL = 0, /* new created TBF */ |
Neels Hofmeyr | 4ea4526 | 2016-06-08 15:27:40 +0200 | [diff] [blame] | 51 | GPRS_RLCMAC_ASSIGN, /* wait for downlink assignment */ |
Holger Hans Peter Freyther | 9e21d84 | 2013-10-16 17:48:12 +0200 | [diff] [blame] | 52 | GPRS_RLCMAC_FLOW, /* RLC/MAC flow, resource needed */ |
| 53 | GPRS_RLCMAC_FINISHED, /* flow finished, wait for release */ |
| 54 | GPRS_RLCMAC_WAIT_RELEASE,/* wait for release or restart of DL TBF */ |
| 55 | GPRS_RLCMAC_RELEASING, /* releasing, wait to free TBI/USF */ |
| 56 | }; |
| 57 | |
Max | f60cf62 | 2017-07-10 14:40:09 +0200 | [diff] [blame] | 58 | enum gprs_rlcmac_tbf_poll_type { |
| 59 | GPRS_RLCMAC_POLL_UL_ASS, |
| 60 | GPRS_RLCMAC_POLL_DL_ASS, |
| 61 | GPRS_RLCMAC_POLL_UL_ACK, |
| 62 | GPRS_RLCMAC_POLL_DL_ACK, |
| 63 | }; |
| 64 | |
Holger Hans Peter Freyther | 9e21d84 | 2013-10-16 17:48:12 +0200 | [diff] [blame] | 65 | enum gprs_rlcmac_tbf_poll_state { |
| 66 | GPRS_RLCMAC_POLL_NONE = 0, |
| 67 | GPRS_RLCMAC_POLL_SCHED, /* a polling was scheduled */ |
| 68 | }; |
| 69 | |
Max | cac6b66 | 2018-01-24 11:00:17 +0100 | [diff] [blame] | 70 | extern const struct value_string gprs_rlcmac_tbf_poll_state_names[]; |
| 71 | |
Holger Hans Peter Freyther | 9e21d84 | 2013-10-16 17:48:12 +0200 | [diff] [blame] | 72 | enum gprs_rlcmac_tbf_dl_ass_state { |
| 73 | GPRS_RLCMAC_DL_ASS_NONE = 0, |
| 74 | GPRS_RLCMAC_DL_ASS_SEND_ASS, /* send downlink assignment on next RTS */ |
| 75 | GPRS_RLCMAC_DL_ASS_WAIT_ACK, /* wait for PACKET CONTROL ACK */ |
| 76 | }; |
| 77 | |
Max | e66de5b | 2017-01-05 18:26:58 +0100 | [diff] [blame] | 78 | extern const struct value_string gprs_rlcmac_tbf_dl_ass_state_names[]; |
| 79 | |
Holger Hans Peter Freyther | 9e21d84 | 2013-10-16 17:48:12 +0200 | [diff] [blame] | 80 | enum gprs_rlcmac_tbf_ul_ass_state { |
| 81 | GPRS_RLCMAC_UL_ASS_NONE = 0, |
| 82 | GPRS_RLCMAC_UL_ASS_SEND_ASS, /* send uplink assignment on next RTS */ |
aravind sirsikar | ed3413e | 2016-11-11 17:15:10 +0530 | [diff] [blame] | 83 | GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ, /* send assignment reject next RTS */ |
Holger Hans Peter Freyther | 9e21d84 | 2013-10-16 17:48:12 +0200 | [diff] [blame] | 84 | GPRS_RLCMAC_UL_ASS_WAIT_ACK, /* wait for PACKET CONTROL ACK */ |
| 85 | }; |
| 86 | |
Max | e66de5b | 2017-01-05 18:26:58 +0100 | [diff] [blame] | 87 | extern const struct value_string gprs_rlcmac_tbf_ul_ass_state_names[]; |
| 88 | |
Holger Hans Peter Freyther | 9e21d84 | 2013-10-16 17:48:12 +0200 | [diff] [blame] | 89 | enum gprs_rlcmac_tbf_ul_ack_state { |
| 90 | GPRS_RLCMAC_UL_ACK_NONE = 0, |
| 91 | GPRS_RLCMAC_UL_ACK_SEND_ACK, /* send acknowledge on next RTS */ |
| 92 | GPRS_RLCMAC_UL_ACK_WAIT_ACK, /* wait for PACKET CONTROL ACK */ |
| 93 | }; |
| 94 | |
Max | 088c7df | 2018-01-23 20:16:23 +0100 | [diff] [blame] | 95 | extern const struct value_string gprs_rlcmac_tbf_ul_ack_state_names[]; |
| 96 | |
Holger Hans Peter Freyther | 9e21d84 | 2013-10-16 17:48:12 +0200 | [diff] [blame] | 97 | enum gprs_rlcmac_tbf_direction { |
| 98 | GPRS_RLCMAC_DL_TBF, |
| 99 | GPRS_RLCMAC_UL_TBF |
| 100 | }; |
| 101 | |
Max | d0532b5 | 2017-12-13 18:27:32 +0100 | [diff] [blame] | 102 | enum tbf_dl_prio { |
| 103 | DL_PRIO_NONE, |
| 104 | DL_PRIO_SENT_DATA, /* the data has been sent and not (yet) nacked */ |
| 105 | DL_PRIO_LOW_AGE, /* the age has reached the first threshold */ |
| 106 | DL_PRIO_NEW_DATA, /* the data has not been sent yet or nacked */ |
| 107 | DL_PRIO_HIGH_AGE, /* the age has reached the second threshold */ |
| 108 | DL_PRIO_CONTROL, /* a control block needs to be sent */ |
| 109 | }; |
| 110 | |
Max | 847ed9f | 2018-02-20 18:16:11 +0100 | [diff] [blame] | 111 | enum tbf_rlc_counters { |
sivasankari | 5395073 | 2016-12-08 17:15:17 +0530 | [diff] [blame] | 112 | TBF_CTR_RLC_NACKED, |
| 113 | }; |
| 114 | |
| 115 | enum tbf_gprs_counters { |
| 116 | TBF_CTR_GPRS_DL_CS1, |
| 117 | TBF_CTR_GPRS_DL_CS2, |
| 118 | TBF_CTR_GPRS_DL_CS3, |
| 119 | TBF_CTR_GPRS_DL_CS4, |
| 120 | }; |
| 121 | |
| 122 | enum tbf_egprs_counters { |
| 123 | TBF_CTR_EGPRS_DL_MCS1, |
| 124 | TBF_CTR_EGPRS_DL_MCS2, |
| 125 | TBF_CTR_EGPRS_DL_MCS3, |
| 126 | TBF_CTR_EGPRS_DL_MCS4, |
| 127 | TBF_CTR_EGPRS_DL_MCS5, |
| 128 | TBF_CTR_EGPRS_DL_MCS6, |
| 129 | TBF_CTR_EGPRS_DL_MCS7, |
| 130 | TBF_CTR_EGPRS_DL_MCS8, |
| 131 | TBF_CTR_EGPRS_DL_MCS9, |
| 132 | }; |
| 133 | |
sivasankari | da7250a | 2016-12-16 12:57:18 +0530 | [diff] [blame] | 134 | enum tbf_gprs_ul_counters { |
| 135 | TBF_CTR_GPRS_UL_CS1, |
| 136 | TBF_CTR_GPRS_UL_CS2, |
| 137 | TBF_CTR_GPRS_UL_CS3, |
| 138 | TBF_CTR_GPRS_UL_CS4, |
| 139 | }; |
| 140 | |
| 141 | enum tbf_egprs_ul_counters { |
| 142 | TBF_CTR_EGPRS_UL_MCS1, |
| 143 | TBF_CTR_EGPRS_UL_MCS2, |
| 144 | TBF_CTR_EGPRS_UL_MCS3, |
| 145 | TBF_CTR_EGPRS_UL_MCS4, |
| 146 | TBF_CTR_EGPRS_UL_MCS5, |
| 147 | TBF_CTR_EGPRS_UL_MCS6, |
| 148 | TBF_CTR_EGPRS_UL_MCS7, |
| 149 | TBF_CTR_EGPRS_UL_MCS8, |
| 150 | TBF_CTR_EGPRS_UL_MCS9, |
| 151 | }; |
| 152 | |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 153 | #define LOGPTBF(tbf, level, fmt, args...) LOGP(DTBF, level, "%s " fmt, tbf_name(tbf), ## args) |
| 154 | #define LOGPTBFUL(tbf, level, fmt, args...) LOGP(DTBFUL, level, "%s " fmt, tbf_name(tbf), ## args) |
| 155 | #define LOGPTBFDL(tbf, level, fmt, args...) LOGP(DTBFDL, level, "%s " fmt, tbf_name(tbf), ## args) |
Max | c21f007 | 2017-12-15 17:36:45 +0100 | [diff] [blame] | 156 | |
Max | ee5be3a | 2017-12-20 17:31:13 +0100 | [diff] [blame] | 157 | enum tbf_timers { |
Max | b2de1f7 | 2017-12-20 18:05:29 +0100 | [diff] [blame] | 158 | /* internal assign/reject timer */ |
| 159 | T0, |
| 160 | |
Max | ee5be3a | 2017-12-20 17:31:13 +0100 | [diff] [blame] | 161 | /* Wait for reuse of USF and TFI(s) after the MS uplink assignment for this TBF is invalid. */ |
| 162 | T3169, |
| 163 | |
| 164 | /* Wait for reuse of TFI(s) after sending of the last RLC Data Block on this TBF. |
| 165 | Wait for reuse of TFI(s) after sending the PACKET TBF RELEASE for an MBMS radio bearer. */ |
| 166 | T3191, |
| 167 | |
| 168 | /* Wait for reuse of TFI(s) after reception of the final PACKET DOWNLINK ACK/NACK from the |
| 169 | MS for this TBF. */ |
| 170 | T3193, |
| 171 | |
| 172 | /* Wait for reuse of TFI(s) when there is no response from the MS |
| 173 | (radio failure or cell change) for this TBF/MBMS radio bearer. */ |
| 174 | T3195, |
| 175 | T_MAX |
| 176 | }; |
| 177 | |
Max | 847ed9f | 2018-02-20 18:16:11 +0100 | [diff] [blame] | 178 | enum tbf_counters { /* TBF counters from 3GPP TS 44.060 §13.4 */ |
| 179 | /* counters are reset when: */ |
| 180 | N3101, /* received a valid data block from mobile station in a block assigned for this USF */ |
| 181 | N3103, /* transmitting the final PACKET UPLINK ACK/NACK message */ |
| 182 | N3105, /* after sending a RRBP field in the downlink RLC data block, receives a valid RLC/MAC control message */ |
| 183 | N_MAX |
| 184 | }; |
| 185 | |
Holger Hans Peter Freyther | 9e21d84 | 2013-10-16 17:48:12 +0200 | [diff] [blame] | 186 | #define GPRS_RLCMAC_FLAG_CCCH 0 /* assignment on CCCH */ |
| 187 | #define GPRS_RLCMAC_FLAG_PACCH 1 /* assignment on PACCH */ |
| 188 | #define GPRS_RLCMAC_FLAG_UL_DATA 2 /* uplink data received */ |
| 189 | #define GPRS_RLCMAC_FLAG_DL_ACK 3 /* downlink acknowledge received */ |
| 190 | #define GPRS_RLCMAC_FLAG_TO_UL_ACK 4 |
| 191 | #define GPRS_RLCMAC_FLAG_TO_DL_ACK 5 |
| 192 | #define GPRS_RLCMAC_FLAG_TO_UL_ASS 6 |
| 193 | #define GPRS_RLCMAC_FLAG_TO_DL_ASS 7 |
| 194 | #define GPRS_RLCMAC_FLAG_TO_MASK 0xf0 /* timeout bits */ |
| 195 | |
Max | 467f633 | 2017-12-20 18:13:29 +0100 | [diff] [blame] | 196 | #define T_START(tbf, t, sec, usec, r, f) tbf->t_start(t, sec, usec, r, f, __FILE__, __LINE__) |
| 197 | |
Max | 2399b1d | 2018-01-12 15:48:12 +0100 | [diff] [blame] | 198 | #define TBF_SET_STATE(t, st) do { t->set_state(st, __FILE__, __LINE__); } while(0) |
Max | 0e59980 | 2018-01-23 20:09:06 +0100 | [diff] [blame] | 199 | #define TBF_SET_ASS_STATE_DL(t, st) do { t->set_ass_state_dl(st, __FILE__, __LINE__); } while(0) |
| 200 | #define TBF_SET_ASS_STATE_UL(t, st) do { t->set_ass_state_ul(st, __FILE__, __LINE__); } while(0) |
Max | 088c7df | 2018-01-23 20:16:23 +0100 | [diff] [blame] | 201 | #define TBF_SET_ACK_STATE(t, st) do { t->set_ack_state(st, __FILE__, __LINE__); } while(0) |
Max | cac6b66 | 2018-01-24 11:00:17 +0100 | [diff] [blame] | 202 | #define TBF_POLL_SCHED_SET(t) do { t->poll_sched_set(__FILE__, __LINE__); } while(0) |
| 203 | #define TBF_POLL_SCHED_UNSET(t) do { t->poll_sched_unset(__FILE__, __LINE__); } while(0) |
Max | 2399b1d | 2018-01-12 15:48:12 +0100 | [diff] [blame] | 204 | #define TBF_SET_ASS_ON(t, fl, chk) do { t->set_assigned_on(fl, chk, __FILE__, __LINE__); } while(0) |
Max | 5d7f757 | 2018-01-30 16:56:43 +0100 | [diff] [blame] | 205 | #define TBF_ASS_TYPE_SET(t, kind) do { t->ass_type_mod(kind, false, __FILE__, __LINE__); } while(0) |
| 206 | #define TBF_ASS_TYPE_UNSET(t, kind) do { t->ass_type_mod(kind, true, __FILE__, __LINE__); } while(0) |
Max | 2399b1d | 2018-01-12 15:48:12 +0100 | [diff] [blame] | 207 | |
Holger Hans Peter Freyther | 099535a | 2013-10-16 17:42:31 +0200 | [diff] [blame] | 208 | struct gprs_rlcmac_tbf { |
Jacob Erlbeck | b6b3c7e | 2015-08-28 12:07:14 +0200 | [diff] [blame] | 209 | gprs_rlcmac_tbf(BTS *bts_, gprs_rlcmac_tbf_direction dir); |
Holger Hans Peter Freyther | 964ddb6 | 2013-10-16 17:53:23 +0200 | [diff] [blame] | 210 | |
| 211 | static void free_all(struct gprs_rlcmac_trx *trx); |
Holger Hans Peter Freyther | 4f6a4e5d | 2013-10-16 17:58:46 +0200 | [diff] [blame] | 212 | static void free_all(struct gprs_rlcmac_pdch *pdch); |
Holger Hans Peter Freyther | 964ddb6 | 2013-10-16 17:53:23 +0200 | [diff] [blame] | 213 | |
Holger Hans Peter Freyther | 1c344e2 | 2013-10-16 18:33:18 +0200 | [diff] [blame] | 214 | bool state_is(enum gprs_rlcmac_tbf_state rhs) const; |
| 215 | bool state_is_not(enum gprs_rlcmac_tbf_state rhs) const; |
Max | 0e59980 | 2018-01-23 20:09:06 +0100 | [diff] [blame] | 216 | bool dl_ass_state_is(enum gprs_rlcmac_tbf_dl_ass_state rhs) const; |
| 217 | bool ul_ass_state_is(enum gprs_rlcmac_tbf_ul_ass_state rhs) const; |
Max | 088c7df | 2018-01-23 20:16:23 +0100 | [diff] [blame] | 218 | bool ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state rhs) const; |
Max | cac6b66 | 2018-01-24 11:00:17 +0100 | [diff] [blame] | 219 | bool poll_scheduled() const; |
Max | 2399b1d | 2018-01-12 15:48:12 +0100 | [diff] [blame] | 220 | void set_state(enum gprs_rlcmac_tbf_state new_state, const char *file, int line); |
Max | 0e59980 | 2018-01-23 20:09:06 +0100 | [diff] [blame] | 221 | void set_ass_state_dl(enum gprs_rlcmac_tbf_dl_ass_state new_state, const char *file, int line); |
| 222 | void set_ass_state_ul(enum gprs_rlcmac_tbf_ul_ass_state new_state, const char *file, int line); |
Max | 088c7df | 2018-01-23 20:16:23 +0100 | [diff] [blame] | 223 | void set_ack_state(enum gprs_rlcmac_tbf_ul_ack_state new_state, const char *file, int line); |
Max | cac6b66 | 2018-01-24 11:00:17 +0100 | [diff] [blame] | 224 | void poll_sched_set(const char *file, int line); |
| 225 | void poll_sched_unset(const char *file, int line); |
Max | 0e59980 | 2018-01-23 20:09:06 +0100 | [diff] [blame] | 226 | void check_pending_ass(); |
Max | 8dce1de | 2018-01-02 14:17:04 +0100 | [diff] [blame] | 227 | bool check_n_clear(uint8_t state_flag); |
Max | 2399b1d | 2018-01-12 15:48:12 +0100 | [diff] [blame] | 228 | void set_assigned_on(uint8_t state_flag, bool check_ccch, const char *file, int line); |
Max | 5d7f757 | 2018-01-30 16:56:43 +0100 | [diff] [blame] | 229 | void ass_type_mod(uint8_t t, bool unset, const char *file, int line); |
Daniel Willmann | 08e57c8 | 2014-08-15 18:11:57 +0200 | [diff] [blame] | 230 | const char *state_name() const; |
Holger Hans Peter Freyther | 1c344e2 | 2013-10-16 18:33:18 +0200 | [diff] [blame] | 231 | |
Jacob Erlbeck | adcdf15 | 2015-03-03 14:45:55 +0100 | [diff] [blame] | 232 | const char *name() const; |
| 233 | |
Jacob Erlbeck | 5a3c84d | 2016-01-22 17:25:38 +0100 | [diff] [blame] | 234 | struct msgb *create_dl_ass(uint32_t fn, uint8_t ts); |
| 235 | struct msgb *create_ul_ass(uint32_t fn, uint8_t ts); |
aravind sirsikar | ed3413e | 2016-11-11 17:15:10 +0530 | [diff] [blame] | 236 | struct msgb *create_packet_access_reject(); |
Holger Hans Peter Freyther | 2db7e7e | 2013-10-26 20:45:35 +0200 | [diff] [blame] | 237 | |
Jacob Erlbeck | 10ed795 | 2015-06-02 11:37:22 +0200 | [diff] [blame] | 238 | GprsMs *ms() const; |
Jacob Erlbeck | fecece0 | 2015-05-08 12:13:08 +0200 | [diff] [blame] | 239 | void set_ms(GprsMs *ms); |
| 240 | |
Holger Hans Peter Freyther | 8f399de | 2013-12-25 20:22:35 +0100 | [diff] [blame] | 241 | uint8_t tsc() const; |
Holger Hans Peter Freyther | a1da251 | 2013-11-07 07:32:51 +0100 | [diff] [blame] | 242 | |
Holger Hans Peter Freyther | 7380bab | 2013-10-16 18:09:19 +0200 | [diff] [blame] | 243 | int rlcmac_diag(); |
Holger Hans Peter Freyther | 964ddb6 | 2013-10-16 17:53:23 +0200 | [diff] [blame] | 244 | |
Max | 847ed9f | 2018-02-20 18:16:11 +0100 | [diff] [blame] | 245 | bool n_inc(enum tbf_counters n); |
| 246 | void n_reset(enum tbf_counters n); |
| 247 | |
Jacob Erlbeck | e0c734d | 2015-07-03 14:03:33 +0200 | [diff] [blame] | 248 | int update(); |
Holger Hans Peter Freyther | af8094d | 2013-10-26 17:56:15 +0200 | [diff] [blame] | 249 | void handle_timeout(); |
Max | ee5be3a | 2017-12-20 17:31:13 +0100 | [diff] [blame] | 250 | void stop_timers(const char *reason); |
| 251 | bool timers_pending(enum tbf_timers t); |
| 252 | void t_stop(enum tbf_timers t, const char *reason); |
Max | 467f633 | 2017-12-20 18:13:29 +0100 | [diff] [blame] | 253 | void t_start(enum tbf_timers t, uint32_t sec, uint32_t microsec, const char *reason, bool force, |
| 254 | const char *file, unsigned line); |
Jacob Erlbeck | 91ff7d1 | 2015-09-01 11:20:29 +0200 | [diff] [blame] | 255 | int establish_dl_tbf_on_pacch(); |
Holger Hans Peter Freyther | aa9c326 | 2013-10-26 17:49:36 +0200 | [diff] [blame] | 256 | |
Jacob Erlbeck | f2694b7 | 2016-01-26 21:46:26 +0100 | [diff] [blame] | 257 | int check_polling(uint32_t fn, uint8_t ts, |
| 258 | uint32_t *poll_fn, unsigned int *rrbp); |
Max | f60cf62 | 2017-07-10 14:40:09 +0200 | [diff] [blame] | 259 | void set_polling(uint32_t poll_fn, uint8_t ts, enum gprs_rlcmac_tbf_poll_type t); |
Holger Hans Peter Freyther | d9262b3 | 2013-10-26 20:12:59 +0200 | [diff] [blame] | 260 | void poll_timeout(); |
| 261 | |
Holger Hans Peter Freyther | 474685e | 2013-10-27 17:01:14 +0100 | [diff] [blame] | 262 | /** tlli handling */ |
Holger Hans Peter Freyther | 474685e | 2013-10-27 17:01:14 +0100 | [diff] [blame] | 263 | uint32_t tlli() const; |
| 264 | bool is_tlli_valid() const; |
Holger Hans Peter Freyther | 474685e | 2013-10-27 17:01:14 +0100 | [diff] [blame] | 265 | |
Jacob Erlbeck | fecece0 | 2015-05-08 12:13:08 +0200 | [diff] [blame] | 266 | /** MS updating */ |
Jacob Erlbeck | be0cbc1 | 2015-05-18 14:35:11 +0200 | [diff] [blame] | 267 | void update_ms(uint32_t tlli, enum gprs_rlcmac_tbf_direction); |
Jacob Erlbeck | fecece0 | 2015-05-08 12:13:08 +0200 | [diff] [blame] | 268 | |
Holger Hans Peter Freyther | 34f6e5e | 2013-10-27 20:31:47 +0100 | [diff] [blame] | 269 | uint8_t tfi() const; |
Jacob Erlbeck | 6b356a5 | 2016-01-29 16:39:21 +0100 | [diff] [blame] | 270 | bool is_tfi_assigned() const; |
Holger Hans Peter Freyther | 34f6e5e | 2013-10-27 20:31:47 +0100 | [diff] [blame] | 271 | |
Holger Hans Peter Freyther | 5464c9b | 2013-10-27 20:57:35 +0100 | [diff] [blame] | 272 | const char *imsi() const; |
| 273 | void assign_imsi(const char *imsi); |
Jacob Erlbeck | 9200ce6 | 2015-05-22 17:48:04 +0200 | [diff] [blame] | 274 | uint8_t ta() const; |
| 275 | void set_ta(uint8_t); |
Jacob Erlbeck | befc760 | 2015-06-02 12:33:30 +0200 | [diff] [blame] | 276 | uint8_t ms_class() const; |
| 277 | void set_ms_class(uint8_t); |
Jacob Erlbeck | cb72890 | 2016-01-05 15:33:03 +0100 | [diff] [blame] | 278 | GprsCodingScheme current_cs() const; |
Max | 869c0c2 | 2018-01-03 12:00:36 +0100 | [diff] [blame] | 279 | size_t llc_queue_size() const; |
Holger Hans Peter Freyther | 5464c9b | 2013-10-27 20:57:35 +0100 | [diff] [blame] | 280 | |
Holger Hans Peter Freyther | a004799 | 2014-01-16 10:07:20 +0100 | [diff] [blame] | 281 | time_t created_ts() const; |
Jacob Erlbeck | 617c712 | 2015-06-30 09:18:30 +0200 | [diff] [blame] | 282 | uint8_t dl_slots() const; |
| 283 | uint8_t ul_slots() const; |
Daniel Willmann | 80367aa | 2014-01-15 17:40:28 +0100 | [diff] [blame] | 284 | |
Jacob Erlbeck | 646da1b | 2016-01-22 17:41:33 +0100 | [diff] [blame] | 285 | bool is_control_ts(uint8_t ts) const; |
| 286 | |
Jacob Erlbeck | 5643f35 | 2015-11-27 16:17:40 +0100 | [diff] [blame] | 287 | /* EGPRS */ |
| 288 | bool is_egprs_enabled() const; |
Jacob Erlbeck | 5643f35 | 2015-11-27 16:17:40 +0100 | [diff] [blame] | 289 | void disable_egprs(); |
| 290 | |
Holger Hans Peter Freyther | 7a5f3c2 | 2013-11-26 13:08:12 +0100 | [diff] [blame] | 291 | /* attempt to make things a bit more fair */ |
| 292 | void rotate_in_list(); |
| 293 | |
Jacob Erlbeck | 6835cea | 2015-08-21 15:24:02 +0200 | [diff] [blame] | 294 | LListHead<gprs_rlcmac_tbf>& ms_list() {return this->m_ms_list;} |
| 295 | const LListHead<gprs_rlcmac_tbf>& ms_list() const {return this->m_ms_list;} |
| 296 | |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 297 | LListHead<gprs_rlcmac_tbf>& list(); |
| 298 | const LListHead<gprs_rlcmac_tbf>& list() const; |
| 299 | |
Holger Hans Peter Freyther | 099535a | 2013-10-16 17:42:31 +0200 | [diff] [blame] | 300 | uint32_t state_flags; |
| 301 | enum gprs_rlcmac_tbf_direction direction; |
Holger Hans Peter Freyther | 743bafa | 2013-09-29 07:50:50 +0200 | [diff] [blame] | 302 | struct gprs_rlcmac_trx *trx; |
Holger Hans Peter Freyther | 099535a | 2013-10-16 17:42:31 +0200 | [diff] [blame] | 303 | uint8_t first_ts; /* first TS used by TBF */ |
| 304 | uint8_t first_common_ts; /* first TS that the phone can send and |
| 305 | reveive simultaniously */ |
| 306 | uint8_t control_ts; /* timeslot control messages and polling */ |
Holger Hans Peter Freyther | 099535a | 2013-10-16 17:42:31 +0200 | [diff] [blame] | 307 | struct gprs_rlcmac_pdch *pdch[8]; /* list of PDCHs allocated to TBF */ |
Holger Hans Peter Freyther | 28e5378 | 2013-11-06 20:23:56 +0100 | [diff] [blame] | 308 | |
| 309 | gprs_llc m_llc; |
Holger Hans Peter Freyther | 099535a | 2013-10-16 17:42:31 +0200 | [diff] [blame] | 310 | |
Holger Hans Peter Freyther | 099535a | 2013-10-16 17:42:31 +0200 | [diff] [blame] | 311 | uint32_t poll_fn; /* frame number to poll */ |
Jacob Erlbeck | 8eb1714 | 2016-01-22 17:58:17 +0100 | [diff] [blame] | 312 | uint8_t poll_ts; /* TS to poll */ |
Holger Hans Peter Freyther | 099535a | 2013-10-16 17:42:31 +0200 | [diff] [blame] | 313 | |
Holger Hans Peter Freyther | 9241fd0 | 2013-11-13 19:51:55 +0100 | [diff] [blame] | 314 | gprs_rlc m_rlc; |
Max | 847ed9f | 2018-02-20 18:16:11 +0100 | [diff] [blame] | 315 | |
Holger Hans Peter Freyther | 099535a | 2013-10-16 17:42:31 +0200 | [diff] [blame] | 316 | struct osmo_gsm_timer_list gsm_timer; |
| 317 | unsigned int fT; /* fTxxxx number */ |
| 318 | unsigned int num_fT_exp; /* number of consecutive fT expirations */ |
| 319 | |
Jacob Erlbeck | b6b3c7e | 2015-08-28 12:07:14 +0200 | [diff] [blame] | 320 | struct Meas { |
Stefan Sperling | f0f7df1 | 2018-05-25 15:12:30 +0200 | [diff] [blame] | 321 | struct timespec rssi_tv; /* timestamp for rssi calculation */ |
Holger Hans Peter Freyther | 099535a | 2013-10-16 17:42:31 +0200 | [diff] [blame] | 322 | int32_t rssi_sum; /* sum of rssi values */ |
| 323 | int rssi_num; /* number of rssi values added since rssi_tv */ |
Jacob Erlbeck | b6b3c7e | 2015-08-28 12:07:14 +0200 | [diff] [blame] | 324 | |
| 325 | Meas(); |
Holger Hans Peter Freyther | 099535a | 2013-10-16 17:42:31 +0200 | [diff] [blame] | 326 | } meas; |
| 327 | |
Daniel Willmann | 73191a4 | 2014-05-30 17:58:00 +0200 | [diff] [blame] | 328 | /* Remember if the tbf was in wait_release state when we want to |
| 329 | * schedule a new dl assignment */ |
| 330 | uint8_t was_releasing; |
| 331 | |
Daniel Willmann | cf1fae7 | 2014-05-30 17:58:01 +0200 | [diff] [blame] | 332 | /* Can/should we upgrade this tbf to use multiple slots? */ |
| 333 | uint8_t upgrade_to_multislot; |
| 334 | |
Holger Hans Peter Freyther | 9f0c1d2 | 2013-10-19 21:24:34 +0200 | [diff] [blame] | 335 | /* store the BTS this TBF belongs to */ |
| 336 | BTS *bts; |
Holger Hans Peter Freyther | d9262b3 | 2013-10-26 20:12:59 +0200 | [diff] [blame] | 337 | |
Holger Hans Peter Freyther | 474685e | 2013-10-27 17:01:14 +0100 | [diff] [blame] | 338 | /* |
| 339 | * private fields. We can't make it private as it is breaking the |
| 340 | * llist macros. |
| 341 | */ |
Holger Hans Peter Freyther | 34f6e5e | 2013-10-27 20:31:47 +0100 | [diff] [blame] | 342 | uint8_t m_tfi; |
Holger Hans Peter Freyther | a004799 | 2014-01-16 10:07:20 +0100 | [diff] [blame] | 343 | time_t m_created_ts; |
Holger Hans Peter Freyther | 474685e | 2013-10-27 17:01:14 +0100 | [diff] [blame] | 344 | |
sivasankari | 5395073 | 2016-12-08 17:15:17 +0530 | [diff] [blame] | 345 | struct rate_ctr_group *m_ctrs; |
| 346 | |
Holger Hans Peter Freyther | d9262b3 | 2013-10-26 20:12:59 +0200 | [diff] [blame] | 347 | protected: |
| 348 | gprs_rlcmac_bts *bts_data() const; |
Max | 25a3ca4 | 2017-12-13 18:47:52 +0100 | [diff] [blame] | 349 | void enable_egprs(); |
Jacob Erlbeck | e8f5fe5 | 2015-12-14 13:23:15 +0100 | [diff] [blame] | 350 | int set_tlli_from_ul(uint32_t new_tlli); |
Jacob Erlbeck | 28c40b1 | 2015-08-16 18:19:32 +0200 | [diff] [blame] | 351 | void merge_and_clear_ms(GprsMs *old_ms); |
Holger Hans Peter Freyther | 4c06d91 | 2013-11-25 23:05:26 +0100 | [diff] [blame] | 352 | |
Alexander Couzens | d38b92e | 2016-08-21 19:38:30 +0200 | [diff] [blame] | 353 | gprs_llc_queue *llc_queue(); |
| 354 | const gprs_llc_queue *llc_queue() const; |
| 355 | |
Neels Hofmeyr | 4ea4526 | 2016-06-08 15:27:40 +0200 | [diff] [blame] | 356 | static const char *tbf_state_name[6]; |
Jacob Erlbeck | adcdf15 | 2015-03-03 14:45:55 +0100 | [diff] [blame] | 357 | |
Jacob Erlbeck | fecece0 | 2015-05-08 12:13:08 +0200 | [diff] [blame] | 358 | class GprsMs *m_ms; |
Jacob Erlbeck | 9200ce6 | 2015-05-22 17:48:04 +0200 | [diff] [blame] | 359 | |
Jacob Erlbeck | befc760 | 2015-06-02 12:33:30 +0200 | [diff] [blame] | 360 | /* Fields to take the TA/MS class values if no MS is associated */ |
Jacob Erlbeck | 9200ce6 | 2015-05-22 17:48:04 +0200 | [diff] [blame] | 361 | uint8_t m_ta; |
Jacob Erlbeck | befc760 | 2015-06-02 12:33:30 +0200 | [diff] [blame] | 362 | uint8_t m_ms_class; |
Jacob Erlbeck | 6dbe822 | 2015-05-29 10:37:09 +0200 | [diff] [blame] | 363 | |
Jacob Erlbeck | adcdf15 | 2015-03-03 14:45:55 +0100 | [diff] [blame] | 364 | private: |
Max | 5081806 | 2017-12-06 13:35:08 +0100 | [diff] [blame] | 365 | enum gprs_rlcmac_tbf_state state; |
Max | 0e59980 | 2018-01-23 20:09:06 +0100 | [diff] [blame] | 366 | enum gprs_rlcmac_tbf_dl_ass_state dl_ass_state; |
| 367 | enum gprs_rlcmac_tbf_ul_ass_state ul_ass_state; |
Max | 088c7df | 2018-01-23 20:16:23 +0100 | [diff] [blame] | 368 | enum gprs_rlcmac_tbf_ul_ack_state ul_ack_state; |
Max | cac6b66 | 2018-01-24 11:00:17 +0100 | [diff] [blame] | 369 | enum gprs_rlcmac_tbf_poll_state poll_state; |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 370 | LListHead<gprs_rlcmac_tbf> m_list; |
Jacob Erlbeck | 6835cea | 2015-08-21 15:24:02 +0200 | [diff] [blame] | 371 | LListHead<gprs_rlcmac_tbf> m_ms_list; |
Jacob Erlbeck | 5643f35 | 2015-11-27 16:17:40 +0100 | [diff] [blame] | 372 | bool m_egprs_enabled; |
Max | b2de1f7 | 2017-12-20 18:05:29 +0100 | [diff] [blame] | 373 | struct osmo_timer_list T[T_MAX]; |
Max | 847ed9f | 2018-02-20 18:16:11 +0100 | [diff] [blame] | 374 | uint8_t N[N_MAX]; |
Jacob Erlbeck | adcdf15 | 2015-03-03 14:45:55 +0100 | [diff] [blame] | 375 | mutable char m_name_buf[60]; |
Holger Hans Peter Freyther | 099535a | 2013-10-16 17:42:31 +0200 | [diff] [blame] | 376 | }; |
| 377 | |
Holger Hans Peter Freyther | 17c31ce | 2013-08-24 18:31:27 +0200 | [diff] [blame] | 378 | |
Daniel Willmann | 0d12a2f | 2014-07-10 17:44:07 +0200 | [diff] [blame] | 379 | struct gprs_rlcmac_ul_tbf *tbf_alloc_ul(struct gprs_rlcmac_bts *bts, |
Jacob Erlbeck | 86b6f05 | 2015-11-27 15:17:34 +0100 | [diff] [blame] | 380 | int8_t use_trx, uint8_t ms_class, uint8_t egprs_ms_class, |
Jacob Erlbeck | e2e004e | 2015-06-18 17:16:26 +0200 | [diff] [blame] | 381 | uint32_t tlli, uint8_t ta, GprsMs *ms); |
Holger Hans Peter Freyther | 9e21d84 | 2013-10-16 17:48:12 +0200 | [diff] [blame] | 382 | |
Max | e9fe0e3 | 2017-09-28 15:56:05 +0200 | [diff] [blame] | 383 | struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms, int8_t use_trx, uint8_t ms_class, |
| 384 | uint8_t egprs_ms_class, bool single_slot); |
Daniel Willmann | 48aa0b0 | 2014-07-16 18:54:10 +0200 | [diff] [blame] | 385 | |
Max | e9fe0e3 | 2017-09-28 15:56:05 +0200 | [diff] [blame] | 386 | struct gprs_rlcmac_dl_tbf *tbf_alloc_dl_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms, int8_t use_trx, uint8_t ms_class, |
| 387 | uint8_t egprs_ms_class, bool single_slot); |
Holger Hans Peter Freyther | 9e21d84 | 2013-10-16 17:48:12 +0200 | [diff] [blame] | 388 | |
Holger Hans Peter Freyther | 9e21d84 | 2013-10-16 17:48:12 +0200 | [diff] [blame] | 389 | void tbf_free(struct gprs_rlcmac_tbf *tbf); |
| 390 | |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 391 | struct gprs_rlcmac_ul_tbf *handle_tbf_reject(struct gprs_rlcmac_bts *bts, |
| 392 | GprsMs *ms, uint32_t tlli, uint8_t trx_no, uint8_t ts_no); |
| 393 | |
Holger Hans Peter Freyther | 9e21d84 | 2013-10-16 17:48:12 +0200 | [diff] [blame] | 394 | int tbf_assign_control_ts(struct gprs_rlcmac_tbf *tbf); |
| 395 | |
Holger Hans Peter Freyther | 1c344e2 | 2013-10-16 18:33:18 +0200 | [diff] [blame] | 396 | inline bool gprs_rlcmac_tbf::state_is(enum gprs_rlcmac_tbf_state rhs) const |
| 397 | { |
| 398 | return state == rhs; |
| 399 | } |
| 400 | |
Max | 0e59980 | 2018-01-23 20:09:06 +0100 | [diff] [blame] | 401 | inline bool gprs_rlcmac_tbf::dl_ass_state_is(enum gprs_rlcmac_tbf_dl_ass_state rhs) const |
| 402 | { |
| 403 | return dl_ass_state == rhs; |
| 404 | } |
| 405 | |
| 406 | inline bool gprs_rlcmac_tbf::ul_ass_state_is(enum gprs_rlcmac_tbf_ul_ass_state rhs) const |
| 407 | { |
| 408 | return ul_ass_state == rhs; |
| 409 | } |
| 410 | |
Max | 088c7df | 2018-01-23 20:16:23 +0100 | [diff] [blame] | 411 | inline bool gprs_rlcmac_tbf::ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state rhs) const |
| 412 | { |
| 413 | return ul_ack_state == rhs; |
| 414 | } |
| 415 | |
Max | cac6b66 | 2018-01-24 11:00:17 +0100 | [diff] [blame] | 416 | inline bool gprs_rlcmac_tbf::poll_scheduled() const |
| 417 | { |
| 418 | return poll_state == GPRS_RLCMAC_POLL_SCHED; |
| 419 | } |
| 420 | |
Holger Hans Peter Freyther | 1c344e2 | 2013-10-16 18:33:18 +0200 | [diff] [blame] | 421 | inline bool gprs_rlcmac_tbf::state_is_not(enum gprs_rlcmac_tbf_state rhs) const |
| 422 | { |
| 423 | return state != rhs; |
| 424 | } |
| 425 | |
Daniel Willmann | eb10024 | 2014-08-08 11:43:53 +0200 | [diff] [blame] | 426 | const char *tbf_name(gprs_rlcmac_tbf *tbf); |
| 427 | |
Daniel Willmann | 08e57c8 | 2014-08-15 18:11:57 +0200 | [diff] [blame] | 428 | inline const char *gprs_rlcmac_tbf::state_name() const |
| 429 | { |
| 430 | return tbf_state_name[state]; |
| 431 | } |
| 432 | |
Max | 8dce1de | 2018-01-02 14:17:04 +0100 | [diff] [blame] | 433 | /* Set assignment state and corrsponding flags */ |
Max | 2399b1d | 2018-01-12 15:48:12 +0100 | [diff] [blame] | 434 | inline void gprs_rlcmac_tbf::set_assigned_on(uint8_t state_flag, bool check_ccch, const char *file, int line) |
Max | 8dce1de | 2018-01-02 14:17:04 +0100 | [diff] [blame] | 435 | { |
Max | 2399b1d | 2018-01-12 15:48:12 +0100 | [diff] [blame] | 436 | set_state(GPRS_RLCMAC_ASSIGN, file, line); |
Max | 8dce1de | 2018-01-02 14:17:04 +0100 | [diff] [blame] | 437 | if (check_ccch) { |
| 438 | if (!(state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))) |
Max | 5d7f757 | 2018-01-30 16:56:43 +0100 | [diff] [blame] | 439 | ass_type_mod(state_flag, false, file, line); |
Max | 8dce1de | 2018-01-02 14:17:04 +0100 | [diff] [blame] | 440 | } else |
| 441 | state_flags |= (1 << state_flag); |
| 442 | } |
| 443 | |
Max | 5d7f757 | 2018-01-30 16:56:43 +0100 | [diff] [blame] | 444 | inline void gprs_rlcmac_tbf::ass_type_mod(uint8_t t, bool unset, const char *file, int line) |
| 445 | { |
| 446 | const char *ch = "UNKNOWN"; |
| 447 | switch (t) { |
| 448 | case GPRS_RLCMAC_FLAG_CCCH: |
| 449 | if (unset) { |
| 450 | if (!(state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))) |
| 451 | return; |
| 452 | } else { |
| 453 | if (state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH)) |
| 454 | LOGPSRC(DTBF, LOGL_ERROR, file, line, |
| 455 | "%s attempted to set ass. type CCCH which is already set.\n", |
| 456 | tbf_name(this)); |
| 457 | } |
| 458 | ch = "CCCH"; |
| 459 | break; |
| 460 | case GPRS_RLCMAC_FLAG_PACCH: |
| 461 | if (unset) { |
| 462 | if (!(state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH))) |
| 463 | return; |
| 464 | } else { |
| 465 | if (state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH)) |
| 466 | LOGPSRC(DTBF, LOGL_ERROR, file, line, |
| 467 | "%s attempted to set ass. type PACCH which is already set.\n", |
| 468 | tbf_name(this)); |
| 469 | } |
| 470 | ch = "PACCH"; |
| 471 | break; |
| 472 | default: |
| 473 | LOGPSRC(DTBF, LOGL_ERROR, file, line, "%s attempted to %sset unexpected ass. type %d - FIXME!\n", |
| 474 | tbf_name(this), unset ? "un" : "", t); |
| 475 | return; |
| 476 | } |
| 477 | |
| 478 | LOGPSRC(DTBF, LOGL_INFO, file, line, "%s %sset ass. type %s [prev CCCH:%u, PACCH:%u]\n", |
| 479 | tbf_name(this), unset ? "un" : "", ch, |
| 480 | state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH), |
| 481 | state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH)); |
| 482 | |
| 483 | if (unset) { |
| 484 | state_flags &= GPRS_RLCMAC_FLAG_TO_MASK; /* keep to flags */ |
| 485 | state_flags &= ~(1 << t); |
| 486 | } else |
| 487 | state_flags |= (1 << t); |
| 488 | } |
| 489 | |
Max | 2399b1d | 2018-01-12 15:48:12 +0100 | [diff] [blame] | 490 | inline void gprs_rlcmac_tbf::set_state(enum gprs_rlcmac_tbf_state new_state, const char *file, int line) |
Holger Hans Peter Freyther | 1c344e2 | 2013-10-16 18:33:18 +0200 | [diff] [blame] | 491 | { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 492 | LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes state from %s to %s\n", |
Daniel Willmann | eb10024 | 2014-08-08 11:43:53 +0200 | [diff] [blame] | 493 | tbf_name(this), |
| 494 | tbf_state_name[state], tbf_state_name[new_state]); |
Holger Hans Peter Freyther | 1c344e2 | 2013-10-16 18:33:18 +0200 | [diff] [blame] | 495 | state = new_state; |
| 496 | } |
Holger Hans Peter Freyther | bd449f5 | 2013-10-27 16:39:36 +0100 | [diff] [blame] | 497 | |
Max | 0e59980 | 2018-01-23 20:09:06 +0100 | [diff] [blame] | 498 | inline void gprs_rlcmac_tbf::set_ass_state_dl(enum gprs_rlcmac_tbf_dl_ass_state new_state, const char *file, int line) |
| 499 | { |
| 500 | LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes DL ASS state from %s to %s\n", |
| 501 | tbf_name(this), |
| 502 | get_value_string(gprs_rlcmac_tbf_dl_ass_state_names, dl_ass_state), |
| 503 | get_value_string(gprs_rlcmac_tbf_dl_ass_state_names, new_state)); |
| 504 | dl_ass_state = new_state; |
| 505 | } |
| 506 | |
| 507 | inline void gprs_rlcmac_tbf::set_ass_state_ul(enum gprs_rlcmac_tbf_ul_ass_state new_state, const char *file, int line) |
| 508 | { |
| 509 | LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes UL ASS state from %s to %s\n", |
| 510 | tbf_name(this), |
| 511 | get_value_string(gprs_rlcmac_tbf_ul_ass_state_names, ul_ass_state), |
| 512 | get_value_string(gprs_rlcmac_tbf_ul_ass_state_names, new_state)); |
| 513 | ul_ass_state = new_state; |
| 514 | } |
| 515 | |
Max | 088c7df | 2018-01-23 20:16:23 +0100 | [diff] [blame] | 516 | inline void gprs_rlcmac_tbf::set_ack_state(enum gprs_rlcmac_tbf_ul_ack_state new_state, const char *file, int line) |
| 517 | { |
| 518 | LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes UL ACK state from %s to %s\n", |
| 519 | tbf_name(this), |
| 520 | get_value_string(gprs_rlcmac_tbf_ul_ack_state_names, ul_ack_state), |
| 521 | get_value_string(gprs_rlcmac_tbf_ul_ack_state_names, new_state)); |
| 522 | ul_ack_state = new_state; |
| 523 | } |
| 524 | |
Max | cac6b66 | 2018-01-24 11:00:17 +0100 | [diff] [blame] | 525 | inline void gprs_rlcmac_tbf::poll_sched_set(const char *file, int line) |
| 526 | { |
| 527 | LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes poll state from %s to GPRS_RLCMAC_POLL_SCHED\n", |
| 528 | tbf_name(this), get_value_string(gprs_rlcmac_tbf_poll_state_names, poll_state)); |
| 529 | poll_state = GPRS_RLCMAC_POLL_SCHED; |
| 530 | } |
| 531 | |
| 532 | inline void gprs_rlcmac_tbf::poll_sched_unset(const char *file, int line) |
| 533 | { |
| 534 | LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes poll state from %s to GPRS_RLCMAC_POLL_NONE\n", |
| 535 | tbf_name(this), get_value_string(gprs_rlcmac_tbf_poll_state_names, poll_state)); |
| 536 | poll_state = GPRS_RLCMAC_POLL_NONE; |
| 537 | } |
| 538 | |
Max | 0e59980 | 2018-01-23 20:09:06 +0100 | [diff] [blame] | 539 | inline void gprs_rlcmac_tbf::check_pending_ass() |
| 540 | { |
| 541 | if (ul_ass_state != GPRS_RLCMAC_UL_ASS_NONE) |
| 542 | LOGPTBF(this, LOGL_ERROR, "FIXME: Software error: Pending uplink assignment in state %s. " |
| 543 | "This may not happen, because the assignment message never gets transmitted. " |
| 544 | "Please be sure not to free in this state. PLEASE FIX!\n", |
| 545 | get_value_string(gprs_rlcmac_tbf_ul_ass_state_names, ul_ass_state)); |
| 546 | |
| 547 | if (dl_ass_state != GPRS_RLCMAC_DL_ASS_NONE) |
| 548 | LOGPTBF(this, LOGL_ERROR, "FIXME: Software error: Pending downlink assignment in state %s. " |
| 549 | "This may not happen, because the assignment message never gets transmitted. " |
| 550 | "Please be sure not to free in this state. PLEASE FIX!\n", |
| 551 | get_value_string(gprs_rlcmac_tbf_dl_ass_state_names, dl_ass_state)); |
| 552 | } |
| 553 | |
Max | 8dce1de | 2018-01-02 14:17:04 +0100 | [diff] [blame] | 554 | inline bool gprs_rlcmac_tbf::check_n_clear(uint8_t state_flag) |
| 555 | { |
| 556 | if ((state_flags & (1 << state_flag))) { |
| 557 | state_flags &= ~(1 << state_flag); |
| 558 | return true; |
| 559 | } |
| 560 | |
| 561 | return false; |
| 562 | } |
| 563 | |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 564 | inline LListHead<gprs_rlcmac_tbf>& gprs_rlcmac_tbf::list() |
| 565 | { |
| 566 | return this->m_list; |
| 567 | } |
| 568 | |
| 569 | inline const LListHead<gprs_rlcmac_tbf>& gprs_rlcmac_tbf::list() const |
| 570 | { |
| 571 | return this->m_list; |
| 572 | } |
| 573 | |
Jacob Erlbeck | 10ed795 | 2015-06-02 11:37:22 +0200 | [diff] [blame] | 574 | inline GprsMs *gprs_rlcmac_tbf::ms() const |
Jacob Erlbeck | fecece0 | 2015-05-08 12:13:08 +0200 | [diff] [blame] | 575 | { |
| 576 | return m_ms; |
| 577 | } |
| 578 | |
Holger Hans Peter Freyther | 474685e | 2013-10-27 17:01:14 +0100 | [diff] [blame] | 579 | inline bool gprs_rlcmac_tbf::is_tlli_valid() const |
| 580 | { |
Jacob Erlbeck | 767193e | 2015-05-20 12:06:46 +0200 | [diff] [blame] | 581 | return tlli() != 0; |
Holger Hans Peter Freyther | 474685e | 2013-10-27 17:01:14 +0100 | [diff] [blame] | 582 | } |
| 583 | |
Jacob Erlbeck | 6b356a5 | 2016-01-29 16:39:21 +0100 | [diff] [blame] | 584 | inline bool gprs_rlcmac_tbf::is_tfi_assigned() const |
| 585 | { |
| 586 | /* The TBF is established or has been assigned by a IMM.ASS for |
| 587 | * download */ |
Neels Hofmeyr | 4ea4526 | 2016-06-08 15:27:40 +0200 | [diff] [blame] | 588 | return state > GPRS_RLCMAC_ASSIGN || |
| 589 | (direction == GPRS_RLCMAC_DL_TBF && |
| 590 | state == GPRS_RLCMAC_ASSIGN && |
| 591 | (state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))); |
Jacob Erlbeck | 6b356a5 | 2016-01-29 16:39:21 +0100 | [diff] [blame] | 592 | } |
| 593 | |
Holger Hans Peter Freyther | 34f6e5e | 2013-10-27 20:31:47 +0100 | [diff] [blame] | 594 | inline uint8_t gprs_rlcmac_tbf::tfi() const |
| 595 | { |
| 596 | return m_tfi; |
| 597 | } |
| 598 | |
Holger Hans Peter Freyther | a004799 | 2014-01-16 10:07:20 +0100 | [diff] [blame] | 599 | inline time_t gprs_rlcmac_tbf::created_ts() const |
Daniel Willmann | 80367aa | 2014-01-15 17:40:28 +0100 | [diff] [blame] | 600 | { |
Holger Hans Peter Freyther | a004799 | 2014-01-16 10:07:20 +0100 | [diff] [blame] | 601 | return m_created_ts; |
Daniel Willmann | 80367aa | 2014-01-15 17:40:28 +0100 | [diff] [blame] | 602 | } |
| 603 | |
Jacob Erlbeck | 5643f35 | 2015-11-27 16:17:40 +0100 | [diff] [blame] | 604 | inline bool gprs_rlcmac_tbf::is_egprs_enabled() const |
| 605 | { |
| 606 | return m_egprs_enabled; |
| 607 | } |
| 608 | |
| 609 | inline void gprs_rlcmac_tbf::enable_egprs() |
| 610 | { |
| 611 | m_egprs_enabled = true; |
| 612 | } |
| 613 | |
| 614 | inline void gprs_rlcmac_tbf::disable_egprs() |
| 615 | { |
| 616 | m_egprs_enabled = false; |
| 617 | } |
| 618 | |
Daniel Willmann | 078bb71 | 2014-07-10 17:44:06 +0200 | [diff] [blame] | 619 | struct gprs_rlcmac_dl_tbf : public gprs_rlcmac_tbf { |
Jacob Erlbeck | b6b3c7e | 2015-08-28 12:07:14 +0200 | [diff] [blame] | 620 | gprs_rlcmac_dl_tbf(BTS *bts); |
Max | ea98b7d | 2018-01-04 15:13:27 +0100 | [diff] [blame] | 621 | gprs_rlc_dl_window *window(); |
Jacob Erlbeck | d0261b7 | 2015-04-02 13:58:09 +0200 | [diff] [blame] | 622 | void cleanup(); |
Max | 25a3ca4 | 2017-12-13 18:47:52 +0100 | [diff] [blame] | 623 | void enable_egprs(); |
Daniel Willmann | 3016888 | 2014-08-07 12:48:29 +0200 | [diff] [blame] | 624 | /* dispatch Unitdata.DL messages */ |
| 625 | static int handle(struct gprs_rlcmac_bts *bts, |
Jacob Erlbeck | 9399046 | 2015-05-15 15:50:43 +0200 | [diff] [blame] | 626 | const uint32_t tlli, const uint32_t old_tlli, |
| 627 | const char *imsi, const uint8_t ms_class, |
Jacob Erlbeck | 14e00f8 | 2015-11-27 18:10:39 +0100 | [diff] [blame] | 628 | const uint8_t egprs_ms_class, const uint16_t delay_csec, |
| 629 | const uint8_t *data, const uint16_t len); |
Daniel Willmann | 3016888 | 2014-08-07 12:48:29 +0200 | [diff] [blame] | 630 | |
Daniel Willmann | 538ac5b | 2014-07-30 19:12:27 +0200 | [diff] [blame] | 631 | int append_data(const uint8_t ms_class, |
| 632 | const uint16_t pdu_delay_csec, |
| 633 | const uint8_t *data, const uint16_t len); |
| 634 | |
Max | 7df82d4 | 2017-12-15 11:14:30 +0100 | [diff] [blame] | 635 | int rcvd_dl_ack(bool final, uint8_t ssn, uint8_t *rbb); |
| 636 | int rcvd_dl_ack(bool final_ack, unsigned first_bsn, struct bitvec *rbb); |
Daniel Willmann | b8f2601 | 2014-07-30 19:12:28 +0200 | [diff] [blame] | 637 | struct msgb *create_dl_acked_block(uint32_t fn, uint8_t ts); |
Max | a10c398 | 2017-07-07 18:25:41 +0200 | [diff] [blame] | 638 | void trigger_ass(struct gprs_rlcmac_tbf *old_tbf); |
Max | 8dce1de | 2018-01-02 14:17:04 +0100 | [diff] [blame] | 639 | |
Max | aae1bfb | 2017-07-07 13:49:29 +0200 | [diff] [blame] | 640 | bool handle_ack_nack(); |
Jacob Erlbeck | 7c44415 | 2015-03-12 12:08:54 +0100 | [diff] [blame] | 641 | void request_dl_ack(); |
Jacob Erlbeck | eceb910 | 2015-03-20 14:41:50 +0100 | [diff] [blame] | 642 | bool need_control_ts() const; |
| 643 | bool have_data() const; |
Jacob Erlbeck | 005ee7f | 2015-03-20 14:53:54 +0100 | [diff] [blame] | 644 | int frames_since_last_poll(unsigned fn) const; |
Jacob Erlbeck | 3bed5d1 | 2015-03-19 11:22:38 +0100 | [diff] [blame] | 645 | int frames_since_last_drain(unsigned fn) const; |
| 646 | bool keep_open(unsigned fn) const; |
Jacob Erlbeck | 91ff7d1 | 2015-09-01 11:20:29 +0200 | [diff] [blame] | 647 | int release(); |
Jacob Erlbeck | f04a5b3 | 2016-01-21 20:42:40 +0100 | [diff] [blame] | 648 | int abort(); |
Max | a4f570f | 2017-12-15 11:21:57 +0100 | [diff] [blame] | 649 | uint16_t window_size() const; |
Max | 9d7357e | 2017-12-14 15:02:33 +0100 | [diff] [blame] | 650 | void set_window_size(); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 651 | void update_coding_scheme_counter_dl(enum CodingScheme cs); |
Aravind Sirsikar | 8e70bb5 | 2016-09-15 17:51:16 +0530 | [diff] [blame] | 652 | |
Daniel Willmann | cf706b0 | 2014-08-07 17:35:22 +0200 | [diff] [blame] | 653 | /* TODO: add the gettimeofday as parameter */ |
| 654 | struct msgb *llc_dequeue(bssgp_bvc_ctx *bctx); |
| 655 | |
Daniel Willmann | 6a8a1dc | 2014-08-07 15:14:08 +0200 | [diff] [blame] | 656 | /* Please note that all variables here will be reset when changing |
| 657 | * from WAIT RELEASE back to FLOW state (re-use of TBF). |
| 658 | * All states that need reset must be in this struct, so this is why |
| 659 | * variables are in both (dl and ul) structs and not outside union. |
| 660 | */ |
Daniel Willmann | 7e994e3 | 2014-08-07 15:49:21 +0200 | [diff] [blame] | 661 | int32_t m_tx_counter; /* count all transmitted blocks */ |
| 662 | uint8_t m_wait_confirm; /* wait for CCCH IMM.ASS cnf */ |
Jacob Erlbeck | 7c44415 | 2015-03-12 12:08:54 +0100 | [diff] [blame] | 663 | bool m_dl_ack_requested; |
Jacob Erlbeck | 005ee7f | 2015-03-20 14:53:54 +0100 | [diff] [blame] | 664 | int32_t m_last_dl_poll_fn; |
Jacob Erlbeck | 3bed5d1 | 2015-03-19 11:22:38 +0100 | [diff] [blame] | 665 | int32_t m_last_dl_drained_fn; |
Daniel Willmann | 6a8a1dc | 2014-08-07 15:14:08 +0200 | [diff] [blame] | 666 | |
Jacob Erlbeck | b6b3c7e | 2015-08-28 12:07:14 +0200 | [diff] [blame] | 667 | struct BandWidth { |
Stefan Sperling | f0f7df1 | 2018-05-25 15:12:30 +0200 | [diff] [blame] | 668 | struct timespec dl_bw_tv; /* timestamp for dl bw calculation */ |
Daniel Willmann | 418a423 | 2014-08-08 11:21:04 +0200 | [diff] [blame] | 669 | uint32_t dl_bw_octets; /* number of octets since bw_tv */ |
sivasankari | 5395073 | 2016-12-08 17:15:17 +0530 | [diff] [blame] | 670 | uint32_t dl_throughput; /* throughput to be displayed in stats */ |
Daniel Willmann | 418a423 | 2014-08-08 11:21:04 +0200 | [diff] [blame] | 671 | |
Stefan Sperling | f0f7df1 | 2018-05-25 15:12:30 +0200 | [diff] [blame] | 672 | struct timespec dl_loss_tv; /* timestamp for loss calculation */ |
Daniel Willmann | 418a423 | 2014-08-08 11:21:04 +0200 | [diff] [blame] | 673 | uint16_t dl_loss_lost; /* sum of lost packets */ |
| 674 | uint16_t dl_loss_received; /* sum of received packets */ |
Jacob Erlbeck | b6b3c7e | 2015-08-28 12:07:14 +0200 | [diff] [blame] | 675 | |
| 676 | BandWidth(); |
Daniel Willmann | 418a423 | 2014-08-08 11:21:04 +0200 | [diff] [blame] | 677 | } m_bw; |
| 678 | |
sivasankari | 5395073 | 2016-12-08 17:15:17 +0530 | [diff] [blame] | 679 | struct rate_ctr_group *m_dl_gprs_ctrs; |
| 680 | struct rate_ctr_group *m_dl_egprs_ctrs; |
| 681 | |
Daniel Willmann | b8f2601 | 2014-07-30 19:12:28 +0200 | [diff] [blame] | 682 | protected: |
Jacob Erlbeck | 2db0f08 | 2015-09-07 18:49:00 +0200 | [diff] [blame] | 683 | struct ana_result { |
| 684 | unsigned received_packets; |
| 685 | unsigned lost_packets; |
| 686 | unsigned received_bytes; |
| 687 | unsigned lost_bytes; |
| 688 | }; |
| 689 | |
Jacob Erlbeck | d675249 | 2016-02-02 18:12:46 +0100 | [diff] [blame] | 690 | int take_next_bsn(uint32_t fn, int previous_bsn, |
Jacob Erlbeck | 64e7b83 | 2016-02-04 15:16:47 +0100 | [diff] [blame] | 691 | bool *may_combine); |
Jacob Erlbeck | d675249 | 2016-02-02 18:12:46 +0100 | [diff] [blame] | 692 | bool restart_bsn_cycle(); |
| 693 | int create_new_bsn(const uint32_t fn, GprsCodingScheme cs); |
Daniel Willmann | b8f2601 | 2014-07-30 19:12:28 +0200 | [diff] [blame] | 694 | struct msgb *create_dl_acked_block(const uint32_t fn, const uint8_t ts, |
Jacob Erlbeck | be314d9 | 2016-02-02 15:32:10 +0100 | [diff] [blame] | 695 | int index, int index2 = -1); |
Daniel Willmann | 3016888 | 2014-08-07 12:48:29 +0200 | [diff] [blame] | 696 | int update_window(const uint8_t ssn, const uint8_t *rbb); |
Jacob Erlbeck | eb08f86 | 2016-02-05 17:07:12 +0100 | [diff] [blame] | 697 | int update_window(unsigned first_bsn, const struct bitvec *rbb); |
Daniel Willmann | 3016888 | 2014-08-07 12:48:29 +0200 | [diff] [blame] | 698 | int maybe_start_new_window(); |
| 699 | bool dl_window_stalled() const; |
Jacob Erlbeck | 409efa1 | 2015-06-12 14:06:09 +0200 | [diff] [blame] | 700 | void reuse_tbf(); |
Jacob Erlbeck | d0261b7 | 2015-04-02 13:58:09 +0200 | [diff] [blame] | 701 | void start_llc_timer(); |
Jacob Erlbeck | 2db0f08 | 2015-09-07 18:49:00 +0200 | [diff] [blame] | 702 | int analyse_errors(char *show_rbb, uint8_t ssn, ana_result *res); |
Jacob Erlbeck | 409efa1 | 2015-06-12 14:06:09 +0200 | [diff] [blame] | 703 | void schedule_next_frame(); |
Jacob Erlbeck | d0261b7 | 2015-04-02 13:58:09 +0200 | [diff] [blame] | 704 | |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 705 | enum egprs_rlc_dl_reseg_bsn_state egprs_dl_get_data |
| 706 | (int bsn, uint8_t **block_data); |
| 707 | unsigned int get_egprs_dl_spb_status(int bsn); |
| 708 | enum egprs_rlcmac_dl_spb get_egprs_dl_spb(int bsn); |
| 709 | |
Jacob Erlbeck | d0261b7 | 2015-04-02 13:58:09 +0200 | [diff] [blame] | 710 | struct osmo_timer_list m_llc_timer; |
Max | ea98b7d | 2018-01-04 15:13:27 +0100 | [diff] [blame] | 711 | |
| 712 | /* Please note that all variables below will be reset when changing |
| 713 | * from WAIT RELEASE back to FLOW state (re-use of TBF). |
| 714 | * All states that need reset must be in this struct, so this is why |
| 715 | * variables are in both (dl and ul) structs and not outside union. |
| 716 | */ |
| 717 | gprs_rlc_dl_window m_window; |
Daniel Willmann | 078bb71 | 2014-07-10 17:44:06 +0200 | [diff] [blame] | 718 | }; |
| 719 | |
| 720 | struct gprs_rlcmac_ul_tbf : public gprs_rlcmac_tbf { |
Jacob Erlbeck | b6b3c7e | 2015-08-28 12:07:14 +0200 | [diff] [blame] | 721 | gprs_rlcmac_ul_tbf(BTS *bts); |
Max | ea98b7d | 2018-01-04 15:13:27 +0100 | [diff] [blame] | 722 | gprs_rlc_ul_window *window(); |
Jacob Erlbeck | 5a3c84d | 2016-01-22 17:25:38 +0100 | [diff] [blame] | 723 | struct msgb *create_ul_ack(uint32_t fn, uint8_t ts); |
Max | fd13f6c | 2017-07-07 14:29:36 +0200 | [diff] [blame] | 724 | bool ctrl_ack_to_toggle(); |
| 725 | bool handle_ctrl_ack(); |
Max | 25a3ca4 | 2017-12-13 18:47:52 +0100 | [diff] [blame] | 726 | void enable_egprs(); |
Daniel Willmann | 350f64d | 2014-08-07 14:54:11 +0200 | [diff] [blame] | 727 | /* blocks were acked */ |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 728 | int rcv_data_block_acknowledged( |
Jacob Erlbeck | f2ba4cb | 2016-01-07 18:59:28 +0100 | [diff] [blame] | 729 | const struct gprs_rlc_data_info *rlc, |
Jacob Erlbeck | fc1b3e6 | 2016-01-11 09:58:11 +0100 | [diff] [blame] | 730 | uint8_t *data, struct pcu_l1_meas *meas); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 731 | |
Daniel Willmann | 350f64d | 2014-08-07 14:54:11 +0200 | [diff] [blame] | 732 | |
Daniel Willmann | e2732e2 | 2014-08-07 17:32:01 +0200 | [diff] [blame] | 733 | /* TODO: extract LLC class? */ |
| 734 | int assemble_forward_llc(const gprs_rlc_data *data); |
| 735 | int snd_ul_ud(); |
| 736 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 737 | egprs_rlc_ul_reseg_bsn_state handle_egprs_ul_spb( |
| 738 | const struct gprs_rlc_data_info *rlc, |
| 739 | struct gprs_rlc_data *block, |
| 740 | uint8_t *data, const uint8_t block_idx); |
| 741 | |
| 742 | egprs_rlc_ul_reseg_bsn_state handle_egprs_ul_first_seg( |
| 743 | const struct gprs_rlc_data_info *rlc, |
| 744 | struct gprs_rlc_data *block, |
| 745 | uint8_t *data, const uint8_t block_idx); |
| 746 | |
| 747 | egprs_rlc_ul_reseg_bsn_state handle_egprs_ul_second_seg( |
| 748 | const struct gprs_rlc_data_info *rlc, |
| 749 | struct gprs_rlc_data *block, |
| 750 | uint8_t *data, const uint8_t block_idx); |
| 751 | |
Max | a4f570f | 2017-12-15 11:21:57 +0100 | [diff] [blame] | 752 | uint16_t window_size() const; |
Max | 9d7357e | 2017-12-14 15:02:33 +0100 | [diff] [blame] | 753 | void set_window_size(); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 754 | void update_coding_scheme_counter_ul(enum CodingScheme cs); |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 755 | |
Daniel Willmann | 6a8a1dc | 2014-08-07 15:14:08 +0200 | [diff] [blame] | 756 | /* Please note that all variables here will be reset when changing |
| 757 | * from WAIT RELEASE back to FLOW state (re-use of TBF). |
| 758 | * All states that need reset must be in this struct, so this is why |
| 759 | * variables are in both (dl and ul) structs and not outside union. |
| 760 | */ |
Daniel Willmann | 7e994e3 | 2014-08-07 15:49:21 +0200 | [diff] [blame] | 761 | int32_t m_rx_counter; /* count all received blocks */ |
Daniel Willmann | 7e994e3 | 2014-08-07 15:49:21 +0200 | [diff] [blame] | 762 | uint8_t m_usf[8]; /* list USFs per PDCH (timeslot) */ |
| 763 | uint8_t m_contention_resolution_done; /* set after done */ |
| 764 | uint8_t m_final_ack_sent; /* set if we sent final ack */ |
Daniel Willmann | 6a8a1dc | 2014-08-07 15:14:08 +0200 | [diff] [blame] | 765 | |
sivasankari | da7250a | 2016-12-16 12:57:18 +0530 | [diff] [blame] | 766 | struct rate_ctr_group *m_ul_gprs_ctrs; |
| 767 | struct rate_ctr_group *m_ul_egprs_ctrs; |
| 768 | |
Daniel Willmann | 350f64d | 2014-08-07 14:54:11 +0200 | [diff] [blame] | 769 | protected: |
Jacob Erlbeck | f2ba4cb | 2016-01-07 18:59:28 +0100 | [diff] [blame] | 770 | void maybe_schedule_uplink_acknack(const gprs_rlc_data_info *rlc); |
Max | ea98b7d | 2018-01-04 15:13:27 +0100 | [diff] [blame] | 771 | |
| 772 | /* Please note that all variables below will be reset when changing |
| 773 | * from WAIT RELEASE back to FLOW state (re-use of TBF). |
| 774 | * All states that need reset must be in this struct, so this is why |
| 775 | * variables are in both (dl and ul) structs and not outside union. |
| 776 | */ |
| 777 | gprs_rlc_ul_window m_window; |
Daniel Willmann | 078bb71 | 2014-07-10 17:44:06 +0200 | [diff] [blame] | 778 | }; |
| 779 | |
Max | 701afa4 | 2017-12-01 17:13:22 +0100 | [diff] [blame] | 780 | #ifdef __cplusplus |
| 781 | extern "C" { |
| 782 | #endif |
| 783 | void update_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, int8_t ta_delta); |
| 784 | void set_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, uint8_t ta); |
| 785 | #ifdef __cplusplus |
| 786 | } |
| 787 | #endif |
| 788 | |
Jacob Erlbeck | ac89a55 | 2015-06-29 14:18:46 +0200 | [diff] [blame] | 789 | inline enum gprs_rlcmac_tbf_direction reverse(enum gprs_rlcmac_tbf_direction dir) |
| 790 | { |
| 791 | return (enum gprs_rlcmac_tbf_direction) |
| 792 | ((int)GPRS_RLCMAC_UL_TBF - (int)dir + (int)GPRS_RLCMAC_DL_TBF); |
| 793 | } |
Jacob Erlbeck | aa9daa1 | 2015-12-28 18:49:12 +0100 | [diff] [blame] | 794 | |
Max | a4f570f | 2017-12-15 11:21:57 +0100 | [diff] [blame] | 795 | inline uint16_t gprs_rlcmac_ul_tbf::window_size() const |
| 796 | { |
| 797 | return m_window.ws(); |
| 798 | } |
| 799 | |
| 800 | inline uint16_t gprs_rlcmac_dl_tbf::window_size() const |
| 801 | { |
| 802 | return m_window.ws(); |
| 803 | } |
| 804 | |
Max | 25a3ca4 | 2017-12-13 18:47:52 +0100 | [diff] [blame] | 805 | inline void gprs_rlcmac_ul_tbf::enable_egprs() |
| 806 | { |
| 807 | m_window.set_sns(RLC_EGPRS_SNS); |
| 808 | gprs_rlcmac_tbf::enable_egprs(); |
| 809 | } |
| 810 | |
| 811 | inline void gprs_rlcmac_dl_tbf::enable_egprs() |
| 812 | { |
| 813 | m_window.set_sns(RLC_EGPRS_SNS); |
| 814 | gprs_rlcmac_tbf::enable_egprs(); |
| 815 | } |
| 816 | |
Jacob Erlbeck | aa9daa1 | 2015-12-28 18:49:12 +0100 | [diff] [blame] | 817 | inline gprs_rlcmac_ul_tbf *as_ul_tbf(gprs_rlcmac_tbf *tbf) |
| 818 | { |
| 819 | if (tbf && tbf->direction == GPRS_RLCMAC_UL_TBF) |
| 820 | return static_cast<gprs_rlcmac_ul_tbf *>(tbf); |
| 821 | else |
| 822 | return NULL; |
| 823 | } |
| 824 | |
| 825 | inline gprs_rlcmac_dl_tbf *as_dl_tbf(gprs_rlcmac_tbf *tbf) |
| 826 | { |
| 827 | if (tbf && tbf->direction == GPRS_RLCMAC_DL_TBF) |
| 828 | return static_cast<gprs_rlcmac_dl_tbf *>(tbf); |
| 829 | else |
| 830 | return NULL; |
| 831 | } |
| 832 | |
Max | 9d7357e | 2017-12-14 15:02:33 +0100 | [diff] [blame] | 833 | uint16_t egprs_window_size(const struct gprs_rlcmac_bts *bts_data, uint8_t slots); |
| 834 | |
Daniel Willmann | afa72f5 | 2014-01-15 17:06:19 +0100 | [diff] [blame] | 835 | #endif |