Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 1 | /* Copied from tbf.cpp |
| 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 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version 2 |
| 10 | * of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <bts.h> |
Oliver Smith | d3c7591 | 2021-07-09 16:37:16 +0200 | [diff] [blame] | 19 | #include <bts_pch_timer.h> |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 20 | #include <tbf.h> |
Pau Espin Pedrol | 9d1cdb1 | 2019-09-25 17:47:02 +0200 | [diff] [blame] | 21 | #include <tbf_ul.h> |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 22 | #include <rlc.h> |
| 23 | #include <encoding.h> |
| 24 | #include <gprs_rlcmac.h> |
| 25 | #include <gprs_debug.h> |
| 26 | #include <gprs_bssgp_pcu.h> |
| 27 | #include <decoding.h> |
Jacob Erlbeck | 20f6fd1 | 2015-06-08 11:05:45 +0200 | [diff] [blame] | 28 | #include <pcu_l1_if.h> |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 29 | #include <gprs_ms.h> |
| 30 | #include <llc.h> |
sivasankari | 8adfcd0 | 2017-01-16 15:41:21 +0530 | [diff] [blame] | 31 | #include "pcu_utils.h" |
| 32 | |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 33 | extern "C" { |
| 34 | #include <osmocom/core/msgb.h> |
| 35 | #include <osmocom/core/talloc.h> |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 36 | #include <osmocom/core/bitvec.h> |
| 37 | #include <osmocom/core/logging.h> |
| 38 | #include <osmocom/core/rate_ctr.h> |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 39 | #include <osmocom/core/stats.h> |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 40 | #include <osmocom/core/utils.h> |
| 41 | #include <osmocom/gprs/gprs_bssgp_bss.h> |
| 42 | #include <osmocom/gprs/protocol/gsm_08_18.h> |
| 43 | #include <osmocom/gsm/tlv.h> |
Max | 136ebcc | 2019-03-05 14:59:03 +0100 | [diff] [blame] | 44 | #include "coding_scheme.h" |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | #include <errno.h> |
| 48 | #include <string.h> |
| 49 | |
| 50 | /* After receiving these frames, we send ack/nack. */ |
| 51 | #define SEND_ACK_AFTER_FRAMES 20 |
| 52 | |
| 53 | extern void *tall_pcu_ctx; |
| 54 | |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 55 | static const struct rate_ctr_desc tbf_ul_gprs_ctr_description[] = { |
| 56 | { "gprs:uplink:cs1", "CS1 " }, |
| 57 | { "gprs:uplink:cs2", "CS2 " }, |
| 58 | { "gprs:uplink:cs3", "CS3 " }, |
| 59 | { "gprs:uplink:cs4", "CS4 " }, |
| 60 | }; |
| 61 | |
| 62 | static const struct rate_ctr_desc tbf_ul_egprs_ctr_description[] = { |
| 63 | { "egprs:uplink:mcs1", "MCS1 " }, |
| 64 | { "egprs:uplink:mcs2", "MCS2 " }, |
| 65 | { "egprs:uplink:mcs3", "MCS3 " }, |
| 66 | { "egprs:uplink:mcs4", "MCS4 " }, |
| 67 | { "egprs:uplink:mcs5", "MCS5 " }, |
| 68 | { "egprs:uplink:mcs6", "MCS6 " }, |
| 69 | { "egprs:uplink:mcs7", "MCS7 " }, |
| 70 | { "egprs:uplink:mcs8", "MCS8 " }, |
| 71 | { "egprs:uplink:mcs9", "MCS9 " }, |
| 72 | }; |
| 73 | |
| 74 | static const struct rate_ctr_group_desc tbf_ul_gprs_ctrg_desc = { |
| 75 | "tbf:gprs", |
| 76 | "Data Blocks", |
| 77 | OSMO_STATS_CLASS_SUBSCRIBER, |
| 78 | ARRAY_SIZE(tbf_ul_gprs_ctr_description), |
| 79 | tbf_ul_gprs_ctr_description, |
| 80 | }; |
| 81 | |
| 82 | static const struct rate_ctr_group_desc tbf_ul_egprs_ctrg_desc = { |
| 83 | "tbf:egprs", |
| 84 | "Data Blocks", |
| 85 | OSMO_STATS_CLASS_SUBSCRIBER, |
| 86 | ARRAY_SIZE(tbf_ul_egprs_ctr_description), |
| 87 | tbf_ul_egprs_ctr_description, |
| 88 | }; |
| 89 | |
Pau Espin Pedrol | 131deb0 | 2021-07-26 18:24:14 +0200 | [diff] [blame] | 90 | gprs_rlcmac_ul_tbf::~gprs_rlcmac_ul_tbf() |
| 91 | { |
Pau Espin Pedrol | ea8dbdd | 2021-07-29 18:39:16 +0200 | [diff] [blame] | 92 | osmo_fsm_inst_free(ul_ack_fsm.fi); |
| 93 | ul_ack_fsm.fi = NULL; |
| 94 | |
Pau Espin Pedrol | 131deb0 | 2021-07-26 18:24:14 +0200 | [diff] [blame] | 95 | rate_ctr_group_free(m_ul_egprs_ctrs); |
| 96 | rate_ctr_group_free(m_ul_gprs_ctrs); |
| 97 | /* ~gprs_rlcmac_tbf() is called automatically upon return */ |
| 98 | } |
| 99 | |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 100 | static int ul_tbf_dtor(struct gprs_rlcmac_ul_tbf *tbf) |
| 101 | { |
| 102 | tbf->~gprs_rlcmac_ul_tbf(); |
| 103 | return 0; |
| 104 | } |
| 105 | |
Pau Espin Pedrol | 54742f2 | 2021-04-26 16:48:34 +0200 | [diff] [blame] | 106 | /* Generic function to alloc a UL TBF, later configured to be assigned either over CCCH or PACCH */ |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 107 | struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms, int8_t use_trx, bool single_slot) |
| 108 | { |
| 109 | struct gprs_rlcmac_ul_tbf *tbf; |
| 110 | int rc; |
| 111 | |
| 112 | OSMO_ASSERT(ms != NULL); |
| 113 | |
Pau Espin Pedrol | 36177c6 | 2021-02-25 17:57:37 +0100 | [diff] [blame] | 114 | LOGPMS(ms, DTBF, LOGL_DEBUG, "********** UL-TBF starts here **********\n"); |
| 115 | LOGPMS(ms, DTBF, LOGL_INFO, "Allocating UL TBF\n"); |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 116 | |
| 117 | tbf = talloc(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf); |
| 118 | if (!tbf) |
| 119 | return NULL; |
| 120 | talloc_set_destructor(tbf, ul_tbf_dtor); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 121 | new (tbf) gprs_rlcmac_ul_tbf(bts, ms); |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 122 | |
| 123 | rc = tbf->setup(use_trx, single_slot); |
| 124 | |
| 125 | /* if no resource */ |
| 126 | if (rc < 0) { |
| 127 | talloc_free(tbf); |
| 128 | return NULL; |
| 129 | } |
| 130 | |
| 131 | if (tbf->is_egprs_enabled()) |
| 132 | tbf->set_window_size(); |
| 133 | |
| 134 | tbf->m_ul_egprs_ctrs = rate_ctr_group_alloc(tbf, |
| 135 | &tbf_ul_egprs_ctrg_desc, tbf->m_ctrs->idx); |
| 136 | tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(tbf, |
| 137 | &tbf_ul_gprs_ctrg_desc, tbf->m_ctrs->idx); |
| 138 | if (!tbf->m_ul_egprs_ctrs || !tbf->m_ul_gprs_ctrs) { |
| 139 | LOGPTBF(tbf, LOGL_ERROR, "Couldn't allocate TBF UL counters\n"); |
| 140 | talloc_free(tbf); |
| 141 | return NULL; |
| 142 | } |
| 143 | |
Pau Espin Pedrol | 1a1557a | 2021-05-13 18:39:36 +0200 | [diff] [blame] | 144 | llist_add_tail(tbf_trx_list(tbf), &tbf->trx->ul_tbfs); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 145 | bts_do_rate_ctr_inc(tbf->bts, CTR_TBF_UL_ALLOCATED); |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 146 | |
| 147 | return tbf; |
| 148 | } |
| 149 | |
Pau Espin Pedrol | cc77eed | 2021-11-02 18:46:40 +0100 | [diff] [blame] | 150 | /* Alloc a UL TBF to be assigned over PACCH. Called when an MS requests to |
| 151 | * create a new UL TBF during the end of life of a previous UL TBF (or an SBA). |
| 152 | * In summary, this TBF is allocated as a consequence of receiving a "Pkt |
| 153 | * Resource Req" or "Pkt Ctrl Ack" from the MS. |
| 154 | * See TS 44.060 9.3.2.4.2 "Non-extended uplink TBF mode". |
| 155 | */ |
Pau Espin Pedrol | 5922396 | 2021-10-18 12:24:38 +0200 | [diff] [blame] | 156 | gprs_rlcmac_ul_tbf *tbf_alloc_ul_pacch(struct gprs_rlcmac_bts *bts, GprsMs *ms, int8_t use_trx) |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 157 | { |
| 158 | struct gprs_rlcmac_ul_tbf *tbf; |
| 159 | |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 160 | tbf = tbf_alloc_ul_tbf(bts, ms, use_trx, false); |
| 161 | if (!tbf) { |
Pau Espin Pedrol | 36177c6 | 2021-02-25 17:57:37 +0100 | [diff] [blame] | 162 | LOGPMS(ms, DTBF, LOGL_NOTICE, "No PDCH resource\n"); |
Pau Espin Pedrol | 54742f2 | 2021-04-26 16:48:34 +0200 | [diff] [blame] | 163 | /* Caller will most probably send a Imm Ass Reject after return */ |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 164 | return NULL; |
| 165 | } |
Pau Espin Pedrol | cc77eed | 2021-11-02 18:46:40 +0100 | [diff] [blame] | 166 | /* Contention resolution is considered to be done since TLLI is known in MS: */ |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 167 | tbf->m_contention_resolution_done = 1; |
Pau Espin Pedrol | 33e8007 | 2021-07-22 19:20:50 +0200 | [diff] [blame] | 168 | osmo_fsm_inst_dispatch(tbf->state_fsm.fi, TBF_EV_ASSIGN_ADD_PACCH, NULL); |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 169 | |
| 170 | return tbf; |
| 171 | } |
| 172 | |
Pau Espin Pedrol | 858f038 | 2021-11-02 14:13:47 +0100 | [diff] [blame] | 173 | /* Alloc a UL TBF to be assigned over CCCH. Used by request of a "One phase |
| 174 | * packet access", where MS requested only 1 PDCH TS (TS 44.018 Table 9.1.8.1). */ |
Pau Espin Pedrol | 20271c4 | 2021-05-10 17:21:03 +0200 | [diff] [blame] | 175 | struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_ccch(struct gprs_rlcmac_bts *bts, struct GprsMs *ms) |
| 176 | { |
| 177 | struct gprs_rlcmac_ul_tbf *tbf; |
| 178 | |
| 179 | tbf = tbf_alloc_ul_tbf(bts, ms, -1, true); |
| 180 | if (!tbf) { |
| 181 | LOGP(DTBF, LOGL_NOTICE, "No PDCH resource for Uplink TBF\n"); |
| 182 | /* Caller will most probably send a Imm Ass Reject after return */ |
| 183 | return NULL; |
| 184 | } |
Pau Espin Pedrol | 33e8007 | 2021-07-22 19:20:50 +0200 | [diff] [blame] | 185 | osmo_fsm_inst_dispatch(tbf->state_fsm.fi, TBF_EV_ASSIGN_ADD_CCCH, NULL); |
Pau Espin Pedrol | 4b6f0bf | 2021-05-10 18:54:52 +0200 | [diff] [blame] | 186 | tbf->contention_resolution_start(); |
Pau Espin Pedrol | 20271c4 | 2021-05-10 17:21:03 +0200 | [diff] [blame] | 187 | OSMO_ASSERT(tbf->ms()); |
| 188 | |
| 189 | return tbf; |
| 190 | } |
| 191 | |
Pau Espin Pedrol | 54742f2 | 2021-04-26 16:48:34 +0200 | [diff] [blame] | 192 | /* Create a temporary dummy TBF to Tx a ImmAssReject if allocating a new one during |
| 193 | * packet resource Request failed. This is similar as tbf_alloc_ul() but without |
| 194 | * calling tbf->setup() (in charge of TFI/USF allocation), and reusing resources |
| 195 | * from Packet Resource Request we received. See TS 44.060 sec 7.1.3.2.1 */ |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 196 | struct gprs_rlcmac_ul_tbf *handle_tbf_reject(struct gprs_rlcmac_bts *bts, |
Pau Espin Pedrol | 54742f2 | 2021-04-26 16:48:34 +0200 | [diff] [blame] | 197 | GprsMs *ms, uint8_t trx_no, uint8_t ts) |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 198 | { |
| 199 | struct gprs_rlcmac_ul_tbf *ul_tbf = NULL; |
| 200 | struct gprs_rlcmac_trx *trx = &bts->trx[trx_no]; |
Pau Espin Pedrol | 54742f2 | 2021-04-26 16:48:34 +0200 | [diff] [blame] | 201 | OSMO_ASSERT(ms); |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 202 | |
| 203 | ul_tbf = talloc(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf); |
| 204 | if (!ul_tbf) |
| 205 | return ul_tbf; |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 206 | talloc_set_destructor(ul_tbf, ul_tbf_dtor); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 207 | new (ul_tbf) gprs_rlcmac_ul_tbf(bts, ms); |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 208 | |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 209 | ul_tbf->trx = trx; |
Pau Espin Pedrol | 0632968 | 2021-11-08 12:42:06 +0100 | [diff] [blame] | 210 | /* The only one TS is the common, control TS */ |
| 211 | ul_tbf->first_ts = ts; |
| 212 | ul_tbf->first_common_ts = ts; |
| 213 | tbf_assign_control_ts(ul_tbf); |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 214 | ul_tbf->m_ctrs = rate_ctr_group_alloc(ul_tbf, &tbf_ctrg_desc, next_tbf_ctr_group_id++); |
| 215 | ul_tbf->m_ul_egprs_ctrs = rate_ctr_group_alloc(ul_tbf, |
| 216 | &tbf_ul_egprs_ctrg_desc, |
| 217 | ul_tbf->m_ctrs->idx); |
| 218 | ul_tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(ul_tbf, |
| 219 | &tbf_ul_gprs_ctrg_desc, |
| 220 | ul_tbf->m_ctrs->idx); |
| 221 | if (!ul_tbf->m_ctrs || !ul_tbf->m_ul_egprs_ctrs || !ul_tbf->m_ul_gprs_ctrs) { |
| 222 | LOGPTBF(ul_tbf, LOGL_ERROR, "Cound not allocate TBF UL rate counters\n"); |
| 223 | talloc_free(ul_tbf); |
| 224 | return NULL; |
| 225 | } |
Pau Espin Pedrol | dbd3b78 | 2021-11-08 13:21:39 +0100 | [diff] [blame] | 226 | tbf_update_state_fsm_name(ul_tbf); |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 227 | |
Pau Espin Pedrol | 54742f2 | 2021-04-26 16:48:34 +0200 | [diff] [blame] | 228 | ms_attach_tbf(ms, ul_tbf); |
Pau Espin Pedrol | 1a1557a | 2021-05-13 18:39:36 +0200 | [diff] [blame] | 229 | llist_add(tbf_trx_list((struct gprs_rlcmac_tbf *)ul_tbf), &trx->ul_tbfs); |
Pau Espin Pedrol | 54742f2 | 2021-04-26 16:48:34 +0200 | [diff] [blame] | 230 | bts_do_rate_ctr_inc(ul_tbf->bts, CTR_TBF_UL_ALLOCATED); |
Pau Espin Pedrol | 33e8007 | 2021-07-22 19:20:50 +0200 | [diff] [blame] | 231 | osmo_fsm_inst_dispatch(ul_tbf->state_fsm.fi, TBF_EV_ASSIGN_ADD_PACCH, NULL); |
Pau Espin Pedrol | 6ad11a6 | 2021-07-27 12:27:08 +0200 | [diff] [blame] | 232 | osmo_fsm_inst_dispatch(ul_tbf->ul_ass_fsm.fi, TBF_UL_ASS_EV_SCHED_ASS_REJ, NULL); |
Pau Espin Pedrol | 54742f2 | 2021-04-26 16:48:34 +0200 | [diff] [blame] | 233 | |
Pau Espin Pedrol | 442198c | 2020-10-23 22:30:04 +0200 | [diff] [blame] | 234 | return ul_tbf; |
| 235 | } |
| 236 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 237 | gprs_rlcmac_ul_tbf::gprs_rlcmac_ul_tbf(struct gprs_rlcmac_bts *bts_, GprsMs *ms) : |
Pau Espin Pedrol | e9f77d3 | 2020-10-23 18:41:40 +0200 | [diff] [blame] | 238 | gprs_rlcmac_tbf(bts_, ms, GPRS_RLCMAC_UL_TBF), |
Pau Espin Pedrol | bddf1ad | 2019-09-26 14:41:18 +0200 | [diff] [blame] | 239 | m_rx_counter(0), |
| 240 | m_contention_resolution_done(0), |
Pau Espin Pedrol | bddf1ad | 2019-09-26 14:41:18 +0200 | [diff] [blame] | 241 | m_ul_gprs_ctrs(NULL), |
| 242 | m_ul_egprs_ctrs(NULL) |
| 243 | { |
Pau Espin Pedrol | 7bd92a3 | 2021-03-24 13:14:09 +0100 | [diff] [blame] | 244 | memset(&m_usf, USF_INVALID, sizeof(m_usf)); |
Pau Espin Pedrol | ea8dbdd | 2021-07-29 18:39:16 +0200 | [diff] [blame] | 245 | |
| 246 | memset(&ul_ack_fsm, 0, sizeof(ul_ack_fsm)); |
| 247 | ul_ack_fsm.tbf = this; |
| 248 | ul_ack_fsm.fi = osmo_fsm_inst_alloc(&tbf_ul_ack_fsm, this, &ul_ack_fsm, LOGL_INFO, NULL); |
| 249 | |
Pau Espin Pedrol | bddf1ad | 2019-09-26 14:41:18 +0200 | [diff] [blame] | 250 | } |
| 251 | |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 252 | /* |
| 253 | * Store received block data in LLC message(s) and forward to SGSN |
| 254 | * if complete. |
| 255 | */ |
| 256 | int gprs_rlcmac_ul_tbf::assemble_forward_llc(const gprs_rlc_data *_data) |
| 257 | { |
| 258 | const uint8_t *data = _data->block; |
| 259 | uint8_t len = _data->len; |
Jacob Erlbeck | f2ba4cb | 2016-01-07 18:59:28 +0100 | [diff] [blame] | 260 | const struct gprs_rlc_data_block_info *rdbi = &_data->block_info; |
Pau Espin Pedrol | 2ae8337 | 2020-05-18 11:35:35 +0200 | [diff] [blame] | 261 | enum CodingScheme cs = _data->cs_last; |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 262 | |
| 263 | Decoding::RlcData frames[16], *frame; |
| 264 | int i, num_frames = 0; |
| 265 | uint32_t dummy_tlli; |
| 266 | |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 267 | LOGPTBFUL(this, LOGL_DEBUG, "Assembling frames: (len=%d)\n", len); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 268 | |
| 269 | num_frames = Decoding::rlc_data_from_ul_data( |
Alexander Couzens | ce936f3 | 2016-05-24 14:45:41 +0200 | [diff] [blame] | 270 | rdbi, cs, data, &(frames[0]), ARRAY_SIZE(frames), |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 271 | &dummy_tlli); |
| 272 | |
| 273 | /* create LLC frames */ |
| 274 | for (i = 0; i < num_frames; i++) { |
| 275 | frame = frames + i; |
| 276 | |
Aravind Sirsikar | 22a9019 | 2016-09-15 17:24:49 +0530 | [diff] [blame] | 277 | if (frame->length) { |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 278 | bts_do_rate_ctr_add(bts, CTR_RLC_UL_PAYLOAD_BYTES, frame->length); |
Alexander Couzens | 7fdbf89 | 2016-05-21 19:45:23 +0200 | [diff] [blame] | 279 | |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 280 | LOGPTBFUL(this, LOGL_DEBUG, "Frame %d " |
Aravind Sirsikar | 22a9019 | 2016-09-15 17:24:49 +0530 | [diff] [blame] | 281 | "starts at offset %d, " |
| 282 | "length=%d, is_complete=%d\n", |
| 283 | i + 1, frame->offset, frame->length, |
| 284 | frame->is_complete); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 285 | |
Pau Espin Pedrol | 4f8384b | 2022-03-31 19:36:12 +0200 | [diff] [blame] | 286 | llc_append_frame(&m_llc, data + frame->offset, frame->length); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 287 | llc_consume(&m_llc, frame->length); |
Aravind Sirsikar | 22a9019 | 2016-09-15 17:24:49 +0530 | [diff] [blame] | 288 | } |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 289 | |
| 290 | if (frame->is_complete) { |
| 291 | /* send frame to SGSN */ |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 292 | LOGPTBFUL(this, LOGL_DEBUG, "complete UL frame len=%d\n", llc_frame_length(&m_llc)); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 293 | snd_ul_ud(); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 294 | bts_do_rate_ctr_add(bts, CTR_LLC_UL_BYTES, llc_frame_length(&m_llc)); |
Pau Espin Pedrol | 4f8384b | 2022-03-31 19:36:12 +0200 | [diff] [blame] | 295 | llc_reset(&m_llc); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 296 | } |
| 297 | } |
| 298 | |
| 299 | return 0; |
| 300 | } |
| 301 | |
Pau Espin Pedrol | 4b6f0bf | 2021-05-10 18:54:52 +0200 | [diff] [blame] | 302 | void gprs_rlcmac_ul_tbf::contention_resolution_start() |
| 303 | { |
| 304 | /* 3GPP TS 44.018 sec 11.1.2 Timers on the network side: "This timer is |
| 305 | * started when a temporary block flow is allocated with an IMMEDIATE |
| 306 | * ASSIGNMENT or an IMMEDIATE PACKET ASSIGNMENT or an EC IMMEDIATE |
| 307 | * ASSIGNMENT TYPE 1 message during a packet access procedure. It is |
| 308 | * stopped when the mobile station has correctly seized the temporary |
| 309 | * block flow." |
| 310 | * In our code base, it means we want to do contention resolution |
| 311 | * timeout only for one-phase packet access, since two-phase is handled |
| 312 | * through SBA structs, which are freed by the PDCH UL Controller if the |
| 313 | * single allocated block is lost. */ |
| 314 | T_START(this, T3141, 3141, "Contention resolution (UL-TBF, CCCH)", true); |
| 315 | } |
| 316 | void gprs_rlcmac_ul_tbf::contention_resolution_success() |
| 317 | { |
| 318 | if (m_contention_resolution_done) |
| 319 | return; |
| 320 | |
| 321 | /* 3GPP TS 44.060 sec 7a.2.1 Contention Resolution */ |
| 322 | /* 3GPP TS 44.018 3.5.2.1.4 Packet access completion: The one phase |
| 323 | packet access procedure is completed at a successful contention |
| 324 | resolution. The mobile station has entered the packet transfer mode. |
| 325 | Timer T3141 is stopped on the network side */ |
| 326 | t_stop(T3141, "Contention resolution success (UL-TBF, CCCH)"); |
| 327 | |
| 328 | /* now we must set this flag, so we are allowed to assign downlink |
| 329 | * TBF on PACCH. it is only allowed when TLLI is acknowledged. */ |
| 330 | m_contention_resolution_done = 1; |
Pau Espin Pedrol | ba56831 | 2021-11-02 18:47:44 +0100 | [diff] [blame] | 331 | |
| 332 | bts_do_rate_ctr_inc(bts, CTR_IMMEDIATE_ASSIGN_UL_TBF_CONTENTION_RESOLUTION_SUCCESS); |
Pau Espin Pedrol | 4b6f0bf | 2021-05-10 18:54:52 +0200 | [diff] [blame] | 333 | } |
| 334 | |
Alexander Couzens | 2fcfc29 | 2016-05-24 14:40:03 +0200 | [diff] [blame] | 335 | /*! \brief receive data from PDCH/L1 */ |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 336 | int gprs_rlcmac_ul_tbf::rcv_data_block_acknowledged( |
Jacob Erlbeck | f2ba4cb | 2016-01-07 18:59:28 +0100 | [diff] [blame] | 337 | const struct gprs_rlc_data_info *rlc, |
Jacob Erlbeck | fc1b3e6 | 2016-01-11 09:58:11 +0100 | [diff] [blame] | 338 | uint8_t *data, struct pcu_l1_meas *meas) |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 339 | { |
Pau Espin Pedrol | c33a024 | 2020-05-15 16:57:48 +0200 | [diff] [blame] | 340 | const struct gprs_rlc_data_block_info *rdbi; |
| 341 | struct gprs_rlc_data *block; |
| 342 | |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 343 | int8_t rssi = meas->have_rssi ? meas->rssi : 0; |
| 344 | |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 345 | const uint16_t ws = m_window.ws(); |
| 346 | |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 347 | LOGPTBFUL(this, LOGL_DEBUG, "UL DATA TFI=%d received (V(Q)=%d .. " |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 348 | "V(R)=%d)\n", rlc->tfi, this->m_window.v_q(), |
| 349 | this->m_window.v_r()); |
| 350 | |
| 351 | /* process RSSI */ |
| 352 | gprs_rlcmac_rssi(this, rssi); |
| 353 | |
| 354 | /* store measurement values */ |
Pau Espin Pedrol | f53815f | 2021-05-11 14:23:51 +0200 | [diff] [blame] | 355 | ms_update_l1_meas(ms(), meas); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 356 | |
Vadim Yanitskiy | cb98894 | 2020-11-08 13:27:35 +0700 | [diff] [blame] | 357 | uint32_t new_tlli = GSM_RESERVED_TMSI; |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 358 | unsigned int block_idx; |
| 359 | |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 360 | /* Increment RX-counter */ |
| 361 | this->m_rx_counter++; |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 362 | update_coding_scheme_counter_ul(rlc->cs); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 363 | /* Loop over num_blocks */ |
| 364 | for (block_idx = 0; block_idx < rlc->num_data_blocks; block_idx++) { |
| 365 | int num_chunks; |
| 366 | uint8_t *rlc_data; |
Pau Espin Pedrol | c33a024 | 2020-05-15 16:57:48 +0200 | [diff] [blame] | 367 | rdbi = &rlc->block_info[block_idx]; |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 368 | |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 369 | LOGPTBFUL(this, LOGL_DEBUG, |
| 370 | "Got %s RLC data block: CV=%d, BSN=%d, SPB=%d, PI=%d, E=%d, TI=%d, bitoffs=%d\n", |
Max | 136ebcc | 2019-03-05 14:59:03 +0100 | [diff] [blame] | 371 | mcs_name(rlc->cs), |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 372 | rdbi->cv, rdbi->bsn, rdbi->spb, |
| 373 | rdbi->pi, rdbi->e, rdbi->ti, |
| 374 | rlc->data_offs_bits[block_idx]); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 375 | |
| 376 | /* Check whether the block needs to be decoded */ |
| 377 | |
| 378 | if (!m_window.is_in_window(rdbi->bsn)) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 379 | LOGPTBFUL(this, LOGL_DEBUG, "BSN %d out of window %d..%d (it's normal)\n", |
| 380 | rdbi->bsn, |
| 381 | m_window.v_q(), m_window.mod_sns(m_window.v_q() + ws - 1)); |
Pau Espin Pedrol | 5891631 | 2021-05-11 14:40:41 +0200 | [diff] [blame] | 382 | continue; |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 383 | } else if (m_window.is_received(rdbi->bsn)) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 384 | LOGPTBFUL(this, LOGL_DEBUG, |
| 385 | "BSN %d already received\n", rdbi->bsn); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 386 | continue; |
Pau Espin Pedrol | 5891631 | 2021-05-11 14:40:41 +0200 | [diff] [blame] | 387 | } |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 388 | |
| 389 | /* Store block and meta info to BSN buffer */ |
| 390 | |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 391 | LOGPTBFUL(this, LOGL_DEBUG, "BSN %d storing in window (%d..%d)\n", |
| 392 | rdbi->bsn, m_window.v_q(), |
| 393 | m_window.mod_sns(m_window.v_q() + ws - 1)); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 394 | block = m_rlc.block(rdbi->bsn); |
Aravind Sirsikar | 550a541 | 2016-06-14 18:59:18 +0530 | [diff] [blame] | 395 | OSMO_ASSERT(rdbi->data_len <= sizeof(block->block)); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 396 | rlc_data = &(block->block[0]); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 397 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 398 | if (rdbi->spb) { |
| 399 | egprs_rlc_ul_reseg_bsn_state assemble_status; |
| 400 | |
| 401 | assemble_status = handle_egprs_ul_spb(rlc, |
| 402 | block, data, block_idx); |
| 403 | |
| 404 | if (assemble_status != EGPRS_RESEG_DEFAULT) |
| 405 | return 0; |
| 406 | } else { |
| 407 | block->block_info = *rdbi; |
| 408 | block->cs_last = rlc->cs; |
| 409 | block->len = |
| 410 | Decoding::rlc_copy_to_aligned_buffer(rlc, |
| 411 | block_idx, data, rlc_data); |
| 412 | } |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 413 | |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 414 | LOGPTBFUL(this, LOGL_DEBUG, |
| 415 | "data_length=%d, data=%s\n", |
| 416 | block->len, osmo_hexdump(rlc_data, block->len)); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 417 | /* Get/Handle TLLI */ |
| 418 | if (rdbi->ti) { |
| 419 | num_chunks = Decoding::rlc_data_from_ul_data( |
| 420 | rdbi, rlc->cs, rlc_data, NULL, 0, &new_tlli); |
| 421 | |
| 422 | if (num_chunks < 0) { |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 423 | bts_do_rate_ctr_inc(bts, CTR_DECODE_ERRORS); |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 424 | LOGPTBFUL(this, LOGL_NOTICE, |
| 425 | "Failed to decode TLLI of %s UL DATA TFI=%d.\n", |
Max | 136ebcc | 2019-03-05 14:59:03 +0100 | [diff] [blame] | 426 | mcs_name(rlc->cs), rlc->tfi); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 427 | m_window.invalidate_bsn(rdbi->bsn); |
| 428 | continue; |
| 429 | } |
| 430 | if (!this->is_tlli_valid()) { |
Vadim Yanitskiy | cb98894 | 2020-11-08 13:27:35 +0700 | [diff] [blame] | 431 | if (new_tlli == GSM_RESERVED_TMSI) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 432 | LOGPTBFUL(this, LOGL_NOTICE, |
Vadim Yanitskiy | cb98894 | 2020-11-08 13:27:35 +0700 | [diff] [blame] | 433 | "TLLI is 0x%08x within UL DATA?!?\n", |
| 434 | new_tlli); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 435 | m_window.invalidate_bsn(rdbi->bsn); |
| 436 | continue; |
| 437 | } |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 438 | LOGPTBFUL(this, LOGL_INFO, |
| 439 | "Decoded premier TLLI=0x%08x of UL DATA TFI=%d.\n", |
Vadim Yanitskiy | 3f27fb5 | 2020-04-20 11:26:12 +0700 | [diff] [blame] | 440 | new_tlli, rlc->tfi); |
Pau Espin Pedrol | d21e961 | 2020-06-26 14:20:37 +0200 | [diff] [blame] | 441 | update_ms(new_tlli, GPRS_RLCMAC_UL_TBF); |
Pau Espin Pedrol | 13961c9 | 2021-11-08 17:38:47 +0100 | [diff] [blame] | 442 | bts_pch_timer_stop(bts, ms()); |
Vadim Yanitskiy | cb98894 | 2020-11-08 13:27:35 +0700 | [diff] [blame] | 443 | } else if (new_tlli != GSM_RESERVED_TMSI && new_tlli != tlli()) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 444 | LOGPTBFUL(this, LOGL_NOTICE, |
Pau Espin Pedrol | 305763d | 2020-11-06 20:03:24 +0100 | [diff] [blame] | 445 | "Decoded TLLI=%08x mismatch on UL DATA TFI=%d. (Ignoring due to contention resolution)\n", |
| 446 | new_tlli, rlc->tfi); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 447 | m_window.invalidate_bsn(rdbi->bsn); |
| 448 | continue; |
| 449 | } |
Pau Espin Pedrol | 5891631 | 2021-05-11 14:40:41 +0200 | [diff] [blame] | 450 | } else if (!is_tlli_valid()) { |
| 451 | LOGPTBFUL(this, LOGL_NOTICE, "Missing TLLI within UL DATA.\n"); |
| 452 | m_window.invalidate_bsn(rdbi->bsn); |
| 453 | continue; |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | m_window.receive_bsn(rdbi->bsn); |
| 457 | } |
| 458 | |
| 459 | /* Raise V(Q) if possible, and retrieve LLC frames from blocks. |
| 460 | * This is looped until there is a gap (non received block) or |
| 461 | * the window is empty.*/ |
| 462 | const uint16_t v_q_beg = m_window.v_q(); |
| 463 | const uint16_t count = m_window.raise_v_q(); |
| 464 | |
| 465 | /* Retrieve LLC frames from blocks that are ready */ |
| 466 | for (uint16_t i = 0; i < count; ++i) { |
Jacob Erlbeck | 93c55d0 | 2015-12-23 16:29:07 +0100 | [diff] [blame] | 467 | uint16_t index = m_window.mod_sns(v_q_beg + i); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 468 | assemble_forward_llc(m_rlc.block(index)); |
| 469 | } |
| 470 | |
Pau Espin Pedrol | c33a024 | 2020-05-15 16:57:48 +0200 | [diff] [blame] | 471 | /* Last frame in buffer: */ |
| 472 | block = m_rlc.block(m_window.mod_sns(m_window.v_r() - 1)); |
| 473 | rdbi = &block->block_info; |
| 474 | |
| 475 | /* Check if we already received all data TBF had to send: */ |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 476 | if (this->state_is(TBF_ST_FLOW) /* still in flow state */ |
Pau Espin Pedrol | 9b63cd0 | 2021-05-11 14:54:40 +0200 | [diff] [blame] | 477 | && this->m_window.v_q() == this->m_window.v_r() /* if complete */ |
| 478 | && block->len) { /* if there was ever a last block received */ |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 479 | LOGPTBFUL(this, LOGL_DEBUG, |
| 480 | "No gaps in received block, last block: BSN=%d CV=%d\n", |
| 481 | rdbi->bsn, rdbi->cv); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 482 | if (rdbi->cv == 0) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 483 | LOGPTBFUL(this, LOGL_DEBUG, "Finished with UL TBF\n"); |
Pau Espin Pedrol | c32c4a3 | 2021-07-23 18:27:57 +0200 | [diff] [blame] | 484 | osmo_fsm_inst_dispatch(this->state_fsm.fi, TBF_EV_LAST_UL_DATA_RECVD, NULL); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 485 | /* Reset N3103 counter. */ |
Max | 847ed9f | 2018-02-20 18:16:11 +0100 | [diff] [blame] | 486 | this->n_reset(N3103); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 487 | } |
| 488 | } |
| 489 | |
| 490 | /* If TLLI is included or if we received half of the window, we send |
| 491 | * an ack/nack */ |
Pau Espin Pedrol | 9b63cd0 | 2021-05-11 14:54:40 +0200 | [diff] [blame] | 492 | maybe_schedule_uplink_acknack(rlc, block->len && rdbi->cv == 0); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 493 | |
| 494 | return 0; |
| 495 | } |
| 496 | |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 497 | void gprs_rlcmac_ul_tbf::maybe_schedule_uplink_acknack( |
Pau Espin Pedrol | c33a024 | 2020-05-15 16:57:48 +0200 | [diff] [blame] | 498 | const gprs_rlc_data_info *rlc, bool countdown_finished) |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 499 | { |
Pau Espin Pedrol | 09afd6f | 2020-05-15 16:40:18 +0200 | [diff] [blame] | 500 | bool require_ack = false; |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 501 | bool have_ti = rlc->block_info[0].ti || |
| 502 | (rlc->num_data_blocks > 1 && rlc->block_info[1].ti); |
| 503 | |
Pau Espin Pedrol | 09afd6f | 2020-05-15 16:40:18 +0200 | [diff] [blame] | 504 | if (rlc->si) { |
| 505 | require_ack = true; |
| 506 | LOGPTBFUL(this, LOGL_NOTICE, |
| 507 | "Scheduling Ack/Nack, because MS is stalled.\n"); |
| 508 | } |
| 509 | if (have_ti) { |
| 510 | require_ack = true; |
| 511 | LOGPTBFUL(this, LOGL_DEBUG, |
| 512 | "Scheduling Ack/Nack, because TLLI is included.\n"); |
| 513 | } |
Pau Espin Pedrol | c33a024 | 2020-05-15 16:57:48 +0200 | [diff] [blame] | 514 | if (countdown_finished) { |
Pau Espin Pedrol | 09afd6f | 2020-05-15 16:40:18 +0200 | [diff] [blame] | 515 | require_ack = true; |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 516 | if (state_is(TBF_ST_FLOW)) |
Pau Espin Pedrol | c33a024 | 2020-05-15 16:57:48 +0200 | [diff] [blame] | 517 | LOGPTBFUL(this, LOGL_DEBUG, |
| 518 | "Scheduling Ack/Nack, because some data is missing and last block has CV==0.\n"); |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 519 | else if (state_is(TBF_ST_FINISHED)) |
Pau Espin Pedrol | c33a024 | 2020-05-15 16:57:48 +0200 | [diff] [blame] | 520 | LOGPTBFUL(this, LOGL_DEBUG, |
| 521 | "Scheduling final Ack/Nack, because all data was received and last block has CV==0.\n"); |
Pau Espin Pedrol | 09afd6f | 2020-05-15 16:40:18 +0200 | [diff] [blame] | 522 | } |
| 523 | if ((m_rx_counter % SEND_ACK_AFTER_FRAMES) == 0) { |
| 524 | require_ack = true; |
| 525 | LOGPTBFUL(this, LOGL_DEBUG, |
| 526 | "Scheduling Ack/Nack, because %d frames received.\n", |
| 527 | SEND_ACK_AFTER_FRAMES); |
| 528 | } |
| 529 | |
| 530 | if (!require_ack) |
| 531 | return; |
| 532 | |
Pau Espin Pedrol | ea8dbdd | 2021-07-29 18:39:16 +0200 | [diff] [blame] | 533 | osmo_fsm_inst_dispatch(this->ul_ack_fsm.fi, TBF_UL_ACK_EV_SCHED_ACK, NULL); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 534 | } |
| 535 | |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 536 | /* Send Uplink unit-data to SGSN. */ |
| 537 | int gprs_rlcmac_ul_tbf::snd_ul_ud() |
| 538 | { |
| 539 | uint8_t qos_profile[3]; |
| 540 | struct msgb *llc_pdu; |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 541 | unsigned msg_len = NS_HDR_LEN + BSSGP_HDR_LEN + llc_frame_length(&m_llc); |
Pau Espin Pedrol | db5e339 | 2021-01-21 18:02:40 +0100 | [diff] [blame] | 542 | struct bssgp_bvc_ctx *bctx = bts->pcu->bssgp.bctx; |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 543 | |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 544 | LOGP(DBSSGP, LOGL_INFO, "LLC [PCU -> SGSN] %s len=%d\n", tbf_name(this), llc_frame_length(&m_llc)); |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 545 | if (!bctx) { |
| 546 | LOGP(DBSSGP, LOGL_ERROR, "No bctx\n"); |
Pau Espin Pedrol | 4f8384b | 2022-03-31 19:36:12 +0200 | [diff] [blame] | 547 | llc_reset_frame_space(&m_llc); |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 548 | return -EIO; |
| 549 | } |
Pau Espin Pedrol | 488aa29 | 2019-09-25 17:48:35 +0200 | [diff] [blame] | 550 | |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 551 | llc_pdu = msgb_alloc_headroom(msg_len, msg_len,"llc_pdu"); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 552 | uint8_t *buf = msgb_push(llc_pdu, TL16V_GROSS_LEN(sizeof(uint8_t)*llc_frame_length(&m_llc))); |
| 553 | tl16v_put(buf, BSSGP_IE_LLC_PDU, sizeof(uint8_t)*llc_frame_length(&m_llc), m_llc.frame); |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 554 | qos_profile[0] = QOS_PROFILE >> 16; |
| 555 | qos_profile[1] = QOS_PROFILE >> 8; |
| 556 | qos_profile[2] = QOS_PROFILE; |
| 557 | bssgp_tx_ul_ud(bctx, tlli(), qos_profile, llc_pdu); |
| 558 | |
Pau Espin Pedrol | 4f8384b | 2022-03-31 19:36:12 +0200 | [diff] [blame] | 559 | llc_reset_frame_space(&m_llc); |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 560 | return 0; |
| 561 | } |
| 562 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 563 | egprs_rlc_ul_reseg_bsn_state gprs_rlcmac_ul_tbf::handle_egprs_ul_second_seg( |
| 564 | const struct gprs_rlc_data_info *rlc, struct gprs_rlc_data *block, |
| 565 | uint8_t *data, const uint8_t block_idx) |
| 566 | { |
| 567 | const gprs_rlc_data_block_info *rdbi = &rlc->block_info[block_idx]; |
| 568 | union split_block_status *spb_status = &block->spb_status; |
| 569 | uint8_t *rlc_data = &block->block[0]; |
| 570 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 571 | bts_do_rate_ctr_inc(bts, CTR_SPB_UL_SECOND_SEGMENT); |
sivasankari | da7250a | 2016-12-16 12:57:18 +0530 | [diff] [blame] | 572 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 573 | if (spb_status->block_status_ul & |
| 574 | EGPRS_RESEG_FIRST_SEG_RXD) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 575 | LOGPTBFUL(this, LOGL_DEBUG, |
| 576 | "Second seg is received first seg is already present set the status to complete\n"); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 577 | spb_status->block_status_ul = EGPRS_RESEG_DEFAULT; |
| 578 | |
| 579 | block->len += Decoding::rlc_copy_to_aligned_buffer(rlc, |
| 580 | block_idx, data, rlc_data + block->len); |
| 581 | block->block_info.data_len += rdbi->data_len; |
| 582 | } else if (spb_status->block_status_ul == EGPRS_RESEG_DEFAULT) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 583 | LOGPTBFUL(this, LOGL_DEBUG, |
| 584 | "Second seg is received first seg is not received set the status to second seg received\n"); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 585 | |
| 586 | block->len = Decoding::rlc_copy_to_aligned_buffer(rlc, |
| 587 | block_idx, data, |
| 588 | rlc_data + rlc->block_info[block_idx].data_len); |
| 589 | |
| 590 | spb_status->block_status_ul = EGPRS_RESEG_SECOND_SEG_RXD; |
| 591 | block->block_info = *rdbi; |
| 592 | } |
| 593 | return spb_status->block_status_ul; |
| 594 | } |
| 595 | |
| 596 | egprs_rlc_ul_reseg_bsn_state gprs_rlcmac_ul_tbf::handle_egprs_ul_first_seg( |
| 597 | const struct gprs_rlc_data_info *rlc, struct gprs_rlc_data *block, |
| 598 | uint8_t *data, const uint8_t block_idx) |
| 599 | { |
| 600 | const gprs_rlc_data_block_info *rdbi = &rlc->block_info[block_idx]; |
| 601 | uint8_t *rlc_data = &block->block[0]; |
| 602 | union split_block_status *spb_status = &block->spb_status; |
| 603 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 604 | bts_do_rate_ctr_inc(bts, CTR_SPB_UL_FIRST_SEGMENT); |
sivasankari | da7250a | 2016-12-16 12:57:18 +0530 | [diff] [blame] | 605 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 606 | if (spb_status->block_status_ul & EGPRS_RESEG_SECOND_SEG_RXD) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 607 | LOGPTBFUL(this, LOGL_DEBUG, |
| 608 | "First seg is received second seg is already present set the status to complete\n"); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 609 | |
| 610 | block->len += Decoding::rlc_copy_to_aligned_buffer(rlc, |
| 611 | block_idx, data, rlc_data); |
| 612 | |
| 613 | block->block_info.data_len = block->len; |
| 614 | spb_status->block_status_ul = EGPRS_RESEG_DEFAULT; |
| 615 | } else if (spb_status->block_status_ul == EGPRS_RESEG_DEFAULT) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 616 | LOGPTBFUL(this, LOGL_DEBUG, |
| 617 | "First seg is received second seg is not received set the status to first seg received\n"); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 618 | |
| 619 | spb_status->block_status_ul = EGPRS_RESEG_FIRST_SEG_RXD; |
| 620 | block->len = Decoding::rlc_copy_to_aligned_buffer(rlc, |
| 621 | block_idx, data, rlc_data); |
| 622 | block->block_info = *rdbi; |
| 623 | } |
| 624 | return spb_status->block_status_ul; |
| 625 | } |
| 626 | |
| 627 | egprs_rlc_ul_reseg_bsn_state gprs_rlcmac_ul_tbf::handle_egprs_ul_spb( |
| 628 | const struct gprs_rlc_data_info *rlc, struct gprs_rlc_data *block, |
| 629 | uint8_t *data, const uint8_t block_idx) |
| 630 | { |
| 631 | const gprs_rlc_data_block_info *rdbi = &rlc->block_info[block_idx]; |
| 632 | |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 633 | LOGPTBFUL(this, LOGL_DEBUG, |
| 634 | "Got SPB(%d) cs(%s) data block with BSN (%d), TFI(%d).\n", |
Max | 136ebcc | 2019-03-05 14:59:03 +0100 | [diff] [blame] | 635 | rdbi->spb, mcs_name(rlc->cs), rdbi->bsn, rlc->tfi); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 636 | |
| 637 | egprs_rlc_ul_reseg_bsn_state assemble_status = EGPRS_RESEG_INVALID; |
| 638 | |
| 639 | /* Section 10.4.8b of 44.060*/ |
| 640 | if (rdbi->spb == 2) |
| 641 | assemble_status = handle_egprs_ul_first_seg(rlc, |
| 642 | block, data, block_idx); |
| 643 | else if (rdbi->spb == 3) |
| 644 | assemble_status = handle_egprs_ul_second_seg(rlc, |
| 645 | block, data, block_idx); |
| 646 | else { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 647 | LOGPTBFUL(this, LOGL_ERROR, |
| 648 | "spb(%d) Not supported SPB for this EGPRS configuration\n", |
| 649 | rdbi->spb); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | /* |
| 653 | * When the block is successfully constructed out of segmented blocks |
| 654 | * upgrade the MCS to the type 2 |
| 655 | */ |
| 656 | if (assemble_status == EGPRS_RESEG_DEFAULT) { |
Pau Espin Pedrol | 2ae8337 | 2020-05-18 11:35:35 +0200 | [diff] [blame] | 657 | switch (rlc->cs) { |
Max | bea2edb | 2019-03-06 17:04:59 +0100 | [diff] [blame] | 658 | case MCS3 : |
| 659 | block->cs_last = MCS6; |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 660 | LOGPTBFUL(this, LOGL_DEBUG, "Upgrading to MCS6\n"); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 661 | break; |
Max | bea2edb | 2019-03-06 17:04:59 +0100 | [diff] [blame] | 662 | case MCS2 : |
| 663 | block->cs_last = MCS5; |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 664 | LOGPTBFUL(this, LOGL_DEBUG, "Upgrading to MCS5\n"); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 665 | break; |
Max | bea2edb | 2019-03-06 17:04:59 +0100 | [diff] [blame] | 666 | case MCS1 : |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 667 | LOGPTBFUL(this, LOGL_DEBUG, "Upgrading to MCS4\n"); |
Max | bea2edb | 2019-03-06 17:04:59 +0100 | [diff] [blame] | 668 | block->cs_last = MCS4; |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 669 | break; |
| 670 | default: |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 671 | LOGPTBFUL(this, LOGL_ERROR, |
| 672 | "cs(%s) Error in Upgrading to higher MCS\n", |
Max | 136ebcc | 2019-03-05 14:59:03 +0100 | [diff] [blame] | 673 | mcs_name(rlc->cs)); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 674 | break; |
| 675 | } |
| 676 | } |
| 677 | return assemble_status; |
| 678 | } |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 679 | |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 680 | void gprs_rlcmac_ul_tbf::update_coding_scheme_counter_ul(enum CodingScheme cs) |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 681 | { |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 682 | switch (cs) { |
| 683 | case CS1: |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 684 | bts_do_rate_ctr_inc(bts, CTR_GPRS_UL_CS1); |
Pau Espin Pedrol | 9c1db17 | 2021-06-04 17:05:51 +0200 | [diff] [blame] | 685 | rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_gprs_ctrs, TBF_CTR_GPRS_UL_CS1)); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 686 | break; |
| 687 | case CS2: |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 688 | bts_do_rate_ctr_inc(bts, CTR_GPRS_UL_CS2); |
Pau Espin Pedrol | 9c1db17 | 2021-06-04 17:05:51 +0200 | [diff] [blame] | 689 | rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_gprs_ctrs, TBF_CTR_GPRS_UL_CS2)); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 690 | break; |
| 691 | case CS3: |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 692 | bts_do_rate_ctr_inc(bts, CTR_GPRS_UL_CS3); |
Pau Espin Pedrol | 9c1db17 | 2021-06-04 17:05:51 +0200 | [diff] [blame] | 693 | rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_gprs_ctrs, TBF_CTR_GPRS_UL_CS3)); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 694 | break; |
| 695 | case CS4: |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 696 | bts_do_rate_ctr_inc(bts, CTR_GPRS_UL_CS4); |
Pau Espin Pedrol | 9c1db17 | 2021-06-04 17:05:51 +0200 | [diff] [blame] | 697 | rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_gprs_ctrs, TBF_CTR_GPRS_UL_CS4)); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 698 | break; |
| 699 | case MCS1: |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 700 | bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS1); |
Pau Espin Pedrol | 9c1db17 | 2021-06-04 17:05:51 +0200 | [diff] [blame] | 701 | rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS1)); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 702 | break; |
| 703 | case MCS2: |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 704 | bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS2); |
Pau Espin Pedrol | 9c1db17 | 2021-06-04 17:05:51 +0200 | [diff] [blame] | 705 | rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS2)); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 706 | break; |
| 707 | case MCS3: |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 708 | bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS3); |
Pau Espin Pedrol | 9c1db17 | 2021-06-04 17:05:51 +0200 | [diff] [blame] | 709 | rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS3)); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 710 | break; |
| 711 | case MCS4: |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 712 | bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS4); |
Pau Espin Pedrol | 9c1db17 | 2021-06-04 17:05:51 +0200 | [diff] [blame] | 713 | rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS4)); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 714 | break; |
| 715 | case MCS5: |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 716 | bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS5); |
Pau Espin Pedrol | 9c1db17 | 2021-06-04 17:05:51 +0200 | [diff] [blame] | 717 | rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS5)); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 718 | break; |
| 719 | case MCS6: |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 720 | bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS6); |
Pau Espin Pedrol | 9c1db17 | 2021-06-04 17:05:51 +0200 | [diff] [blame] | 721 | rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS6)); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 722 | break; |
| 723 | case MCS7: |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 724 | bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS7); |
Pau Espin Pedrol | 9c1db17 | 2021-06-04 17:05:51 +0200 | [diff] [blame] | 725 | rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS7)); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 726 | break; |
| 727 | case MCS8: |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 728 | bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS8); |
Pau Espin Pedrol | 9c1db17 | 2021-06-04 17:05:51 +0200 | [diff] [blame] | 729 | rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS8)); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 730 | break; |
| 731 | case MCS9: |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 732 | bts_do_rate_ctr_inc(bts, CTR_EGPRS_UL_MCS9); |
Pau Espin Pedrol | 9c1db17 | 2021-06-04 17:05:51 +0200 | [diff] [blame] | 733 | rate_ctr_inc(rate_ctr_group_get_ctr(m_ul_egprs_ctrs, TBF_CTR_EGPRS_UL_MCS9)); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 734 | break; |
| 735 | default: |
| 736 | LOGPTBFUL(this, LOGL_ERROR, "attempting to update rate counters for unsupported (M)CS %s\n", |
| 737 | mcs_name(cs)); |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 738 | } |
| 739 | } |
sivasankari | 8adfcd0 | 2017-01-16 15:41:21 +0530 | [diff] [blame] | 740 | |
Max | 9d7357e | 2017-12-14 15:02:33 +0100 | [diff] [blame] | 741 | void gprs_rlcmac_ul_tbf::set_window_size() |
sivasankari | 8adfcd0 | 2017-01-16 15:41:21 +0530 | [diff] [blame] | 742 | { |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 743 | const struct gprs_rlcmac_bts *b = bts; |
Max | 34513fe | 2018-12-11 16:47:30 +0100 | [diff] [blame] | 744 | uint16_t ws = egprs_window_size(b, ul_slots()); |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 745 | LOGPTBFUL(this, LOGL_INFO, "setting EGPRS UL window size to %u, base(%u) slots(%u) ws_pdch(%u)\n", |
Pau Espin Pedrol | 519d071 | 2021-01-14 14:30:03 +0100 | [diff] [blame] | 746 | ws, bts->pcu->vty.ws_base, pcu_bitcount(ul_slots()), bts->pcu->vty.ws_pdch); |
sivasankari | 8adfcd0 | 2017-01-16 15:41:21 +0530 | [diff] [blame] | 747 | m_window.set_ws(ws); |
| 748 | } |
Pau Espin Pedrol | 9767e44 | 2020-10-23 21:11:41 +0200 | [diff] [blame] | 749 | |
Pau Espin Pedrol | b3f2397 | 2020-10-23 21:00:23 +0200 | [diff] [blame] | 750 | gprs_rlc_window *gprs_rlcmac_ul_tbf::window() |
Pau Espin Pedrol | 9767e44 | 2020-10-23 21:11:41 +0200 | [diff] [blame] | 751 | { |
| 752 | return &m_window; |
| 753 | } |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 754 | |
Pau Espin Pedrol | 0b998b1 | 2021-03-24 14:45:43 +0100 | [diff] [blame] | 755 | void gprs_rlcmac_ul_tbf::usf_timeout() |
| 756 | { |
Pau Espin Pedrol | cfb61d9 | 2021-07-26 17:17:02 +0200 | [diff] [blame] | 757 | if (n_inc(N3101)) |
Pau Espin Pedrol | 55f600b | 2021-07-26 15:54:39 +0200 | [diff] [blame] | 758 | osmo_fsm_inst_dispatch(this->state_fsm.fi, TBF_EV_MAX_N3101, NULL); |
Pau Espin Pedrol | 0b998b1 | 2021-03-24 14:45:43 +0100 | [diff] [blame] | 759 | } |
| 760 | |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 761 | struct gprs_rlcmac_ul_tbf *as_ul_tbf(struct gprs_rlcmac_tbf *tbf) |
| 762 | { |
| 763 | if (tbf && tbf->direction == GPRS_RLCMAC_UL_TBF) |
| 764 | return static_cast<gprs_rlcmac_ul_tbf *>(tbf); |
| 765 | else |
| 766 | return NULL; |
| 767 | } |
Pau Espin Pedrol | 0b998b1 | 2021-03-24 14:45:43 +0100 | [diff] [blame] | 768 | |
| 769 | void tbf_usf_timeout(struct gprs_rlcmac_ul_tbf *tbf) |
| 770 | { |
| 771 | tbf->usf_timeout(); |
| 772 | } |
Pau Espin Pedrol | 49a2f40 | 2021-07-27 17:33:07 +0200 | [diff] [blame] | 773 | |
| 774 | |
| 775 | bool ul_tbf_contention_resolution_done(const struct gprs_rlcmac_ul_tbf *tbf) |
| 776 | { |
| 777 | return tbf->m_contention_resolution_done; |
| 778 | } |
Pau Espin Pedrol | ea8dbdd | 2021-07-29 18:39:16 +0200 | [diff] [blame] | 779 | |
| 780 | struct osmo_fsm_inst *tbf_ul_ack_fi(const struct gprs_rlcmac_ul_tbf *tbf) |
| 781 | { |
| 782 | return tbf->ul_ack_fsm.fi; |
| 783 | } |
| 784 | |
| 785 | void ul_tbf_contention_resolution_success(struct gprs_rlcmac_ul_tbf *tbf) |
| 786 | { |
| 787 | return tbf->contention_resolution_success(); |
| 788 | } |