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