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. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 20 | */ |
| 21 | |
| 22 | #include <bts.h> |
| 23 | #include <tbf.h> |
Pau Espin Pedrol | 9d1cdb1 | 2019-09-25 17:47:02 +0200 | [diff] [blame] | 24 | #include <tbf_ul.h> |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 25 | #include <rlc.h> |
| 26 | #include <encoding.h> |
| 27 | #include <gprs_rlcmac.h> |
| 28 | #include <gprs_debug.h> |
| 29 | #include <gprs_bssgp_pcu.h> |
| 30 | #include <decoding.h> |
Jacob Erlbeck | 20f6fd1 | 2015-06-08 11:05:45 +0200 | [diff] [blame] | 31 | #include <pcu_l1_if.h> |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 32 | #include <gprs_ms.h> |
| 33 | #include <llc.h> |
sivasankari | 8adfcd0 | 2017-01-16 15:41:21 +0530 | [diff] [blame] | 34 | #include "pcu_utils.h" |
| 35 | |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 36 | extern "C" { |
| 37 | #include <osmocom/core/msgb.h> |
| 38 | #include <osmocom/core/talloc.h> |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 39 | #include <osmocom/core/bitvec.h> |
| 40 | #include <osmocom/core/logging.h> |
| 41 | #include <osmocom/core/rate_ctr.h> |
| 42 | #include <osmocom/core/utils.h> |
| 43 | #include <osmocom/gprs/gprs_bssgp_bss.h> |
| 44 | #include <osmocom/gprs/protocol/gsm_08_18.h> |
| 45 | #include <osmocom/gsm/tlv.h> |
Max | 136ebcc | 2019-03-05 14:59:03 +0100 | [diff] [blame] | 46 | #include "coding_scheme.h" |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | #include <errno.h> |
| 50 | #include <string.h> |
| 51 | |
| 52 | /* After receiving these frames, we send ack/nack. */ |
| 53 | #define SEND_ACK_AFTER_FRAMES 20 |
| 54 | |
| 55 | extern void *tall_pcu_ctx; |
| 56 | |
Pau Espin Pedrol | bddf1ad | 2019-09-26 14:41:18 +0200 | [diff] [blame] | 57 | gprs_rlcmac_ul_tbf::gprs_rlcmac_ul_tbf(BTS *bts_) : |
| 58 | gprs_rlcmac_tbf(bts_, GPRS_RLCMAC_UL_TBF), |
| 59 | m_rx_counter(0), |
| 60 | m_contention_resolution_done(0), |
| 61 | m_final_ack_sent(0), |
| 62 | m_ul_gprs_ctrs(NULL), |
| 63 | m_ul_egprs_ctrs(NULL) |
| 64 | { |
| 65 | memset(&m_usf, 0, sizeof(m_usf)); |
| 66 | } |
| 67 | |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 68 | /* |
| 69 | * Store received block data in LLC message(s) and forward to SGSN |
| 70 | * if complete. |
| 71 | */ |
| 72 | int gprs_rlcmac_ul_tbf::assemble_forward_llc(const gprs_rlc_data *_data) |
| 73 | { |
| 74 | const uint8_t *data = _data->block; |
| 75 | uint8_t len = _data->len; |
Jacob Erlbeck | f2ba4cb | 2016-01-07 18:59:28 +0100 | [diff] [blame] | 76 | const struct gprs_rlc_data_block_info *rdbi = &_data->block_info; |
Pau Espin Pedrol | 2ae8337 | 2020-05-18 11:35:35 +0200 | [diff] [blame] | 77 | enum CodingScheme cs = _data->cs_last; |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 78 | |
| 79 | Decoding::RlcData frames[16], *frame; |
| 80 | int i, num_frames = 0; |
| 81 | uint32_t dummy_tlli; |
| 82 | |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 83 | LOGPTBFUL(this, LOGL_DEBUG, "Assembling frames: (len=%d)\n", len); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 84 | |
| 85 | num_frames = Decoding::rlc_data_from_ul_data( |
Alexander Couzens | ce936f3 | 2016-05-24 14:45:41 +0200 | [diff] [blame] | 86 | rdbi, cs, data, &(frames[0]), ARRAY_SIZE(frames), |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 87 | &dummy_tlli); |
| 88 | |
| 89 | /* create LLC frames */ |
| 90 | for (i = 0; i < num_frames; i++) { |
| 91 | frame = frames + i; |
| 92 | |
Aravind Sirsikar | 22a9019 | 2016-09-15 17:24:49 +0530 | [diff] [blame] | 93 | if (frame->length) { |
Pau Espin Pedrol | a107f8f | 2020-05-12 22:32:24 +0200 | [diff] [blame] | 94 | bts->do_rate_ctr_add(CTR_RLC_UL_PAYLOAD_BYTES, frame->length); |
Alexander Couzens | 7fdbf89 | 2016-05-21 19:45:23 +0200 | [diff] [blame] | 95 | |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 96 | LOGPTBFUL(this, LOGL_DEBUG, "Frame %d " |
Aravind Sirsikar | 22a9019 | 2016-09-15 17:24:49 +0530 | [diff] [blame] | 97 | "starts at offset %d, " |
| 98 | "length=%d, is_complete=%d\n", |
| 99 | i + 1, frame->offset, frame->length, |
| 100 | frame->is_complete); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 101 | |
Aravind Sirsikar | 22a9019 | 2016-09-15 17:24:49 +0530 | [diff] [blame] | 102 | m_llc.append_frame(data + frame->offset, frame->length); |
| 103 | m_llc.consume(frame->length); |
| 104 | } |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 105 | |
| 106 | if (frame->is_complete) { |
| 107 | /* send frame to SGSN */ |
Max | 0fdaa9d | 2018-01-30 16:03:10 +0100 | [diff] [blame] | 108 | LOGPTBFUL(this, LOGL_DEBUG, "complete UL frame len=%d\n", m_llc.frame_length()); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 109 | snd_ul_ud(); |
Pau Espin Pedrol | a107f8f | 2020-05-12 22:32:24 +0200 | [diff] [blame] | 110 | bts->do_rate_ctr_add(CTR_LLC_UL_BYTES, m_llc.frame_length()); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 111 | m_llc.reset(); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | return 0; |
| 116 | } |
| 117 | |
Max | fd13f6c | 2017-07-07 14:29:36 +0200 | [diff] [blame] | 118 | bool gprs_rlcmac_ul_tbf::ctrl_ack_to_toggle() |
| 119 | { |
Max | 8dce1de | 2018-01-02 14:17:04 +0100 | [diff] [blame] | 120 | if (check_n_clear(GPRS_RLCMAC_FLAG_TO_UL_ACK)) |
Max | fd13f6c | 2017-07-07 14:29:36 +0200 | [diff] [blame] | 121 | return true; /* GPRS_RLCMAC_FLAG_TO_UL_ACK was set, now cleared */ |
Max | fd13f6c | 2017-07-07 14:29:36 +0200 | [diff] [blame] | 122 | |
| 123 | state_flags |= (1 << GPRS_RLCMAC_FLAG_TO_UL_ACK); |
| 124 | return false; /* GPRS_RLCMAC_FLAG_TO_UL_ACK was unset, now set */ |
| 125 | } |
| 126 | |
| 127 | bool gprs_rlcmac_ul_tbf::handle_ctrl_ack() |
| 128 | { |
| 129 | /* check if this control ack belongs to packet uplink ack */ |
Max | 088c7df | 2018-01-23 20:16:23 +0100 | [diff] [blame] | 130 | if (ul_ack_state_is(GPRS_RLCMAC_UL_ACK_WAIT_ACK)) { |
| 131 | TBF_SET_ACK_STATE(this, GPRS_RLCMAC_UL_ACK_NONE); |
Max | fd13f6c | 2017-07-07 14:29:36 +0200 | [diff] [blame] | 132 | return true; |
| 133 | } |
| 134 | |
| 135 | return false; |
| 136 | } |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 137 | |
Jacob Erlbeck | 5a3c84d | 2016-01-22 17:25:38 +0100 | [diff] [blame] | 138 | struct msgb *gprs_rlcmac_ul_tbf::create_ul_ack(uint32_t fn, uint8_t ts) |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 139 | { |
| 140 | int final = (state_is(GPRS_RLCMAC_FINISHED)); |
| 141 | struct msgb *msg; |
Jacob Erlbeck | f2694b7 | 2016-01-26 21:46:26 +0100 | [diff] [blame] | 142 | int rc; |
| 143 | unsigned int rrbp = 0; |
| 144 | uint32_t new_poll_fn = 0; |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 145 | |
| 146 | if (final) { |
Max | cac6b66 | 2018-01-24 11:00:17 +0100 | [diff] [blame] | 147 | if (poll_scheduled() && ul_ack_state_is(GPRS_RLCMAC_UL_ACK_WAIT_ACK)) { |
Max | c21f007 | 2017-12-15 17:36:45 +0100 | [diff] [blame] | 148 | LOGPTBFUL(this, LOGL_DEBUG, |
| 149 | "Polling is already scheduled, so we must wait for the final uplink ack...\n"); |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 150 | return NULL; |
| 151 | } |
Jacob Erlbeck | f2694b7 | 2016-01-26 21:46:26 +0100 | [diff] [blame] | 152 | |
| 153 | rc = check_polling(fn, ts, &new_poll_fn, &rrbp); |
| 154 | if (rc < 0) |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 155 | return NULL; |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | msg = msgb_alloc(23, "rlcmac_ul_ack"); |
| 159 | if (!msg) |
| 160 | return NULL; |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 161 | bitvec *ack_vec = bitvec_alloc(23, tall_pcu_ctx); |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 162 | if (!ack_vec) { |
| 163 | msgb_free(msg); |
| 164 | return NULL; |
| 165 | } |
Max | 7426c5f | 2019-02-18 20:42:42 +0100 | [diff] [blame] | 166 | bitvec_unhex(ack_vec, DUMMY_VEC); |
Alexander Couzens | 3a499f3 | 2019-06-16 15:25:30 +0200 | [diff] [blame] | 167 | Encoding::write_packet_uplink_ack(ack_vec, this, final, rrbp); |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 168 | bitvec_pack(ack_vec, msgb_put(msg, 23)); |
| 169 | bitvec_free(ack_vec); |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 170 | |
| 171 | /* now we must set this flag, so we are allowed to assign downlink |
| 172 | * TBF on PACCH. it is only allowed when TLLI is acknowledged. */ |
| 173 | m_contention_resolution_done = 1; |
| 174 | |
| 175 | if (final) { |
Max | f60cf62 | 2017-07-10 14:40:09 +0200 | [diff] [blame] | 176 | set_polling(new_poll_fn, ts, GPRS_RLCMAC_POLL_UL_ACK); |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 177 | /* waiting for final acknowledge */ |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 178 | m_final_ack_sent = 1; |
| 179 | } else |
Max | 088c7df | 2018-01-23 20:16:23 +0100 | [diff] [blame] | 180 | TBF_SET_ACK_STATE(this, GPRS_RLCMAC_UL_ACK_NONE); |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 181 | |
| 182 | return msg; |
| 183 | } |
| 184 | |
Alexander Couzens | 2fcfc29 | 2016-05-24 14:40:03 +0200 | [diff] [blame] | 185 | /*! \brief receive data from PDCH/L1 */ |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 186 | int gprs_rlcmac_ul_tbf::rcv_data_block_acknowledged( |
Jacob Erlbeck | f2ba4cb | 2016-01-07 18:59:28 +0100 | [diff] [blame] | 187 | const struct gprs_rlc_data_info *rlc, |
Jacob Erlbeck | fc1b3e6 | 2016-01-11 09:58:11 +0100 | [diff] [blame] | 188 | uint8_t *data, struct pcu_l1_meas *meas) |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 189 | { |
Pau Espin Pedrol | c33a024 | 2020-05-15 16:57:48 +0200 | [diff] [blame] | 190 | const struct gprs_rlc_data_block_info *rdbi; |
| 191 | struct gprs_rlc_data *block; |
| 192 | |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 193 | int8_t rssi = meas->have_rssi ? meas->rssi : 0; |
| 194 | |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 195 | const uint16_t ws = m_window.ws(); |
| 196 | |
| 197 | this->state_flags |= (1 << GPRS_RLCMAC_FLAG_UL_DATA); |
| 198 | |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 199 | LOGPTBFUL(this, LOGL_DEBUG, "UL DATA TFI=%d received (V(Q)=%d .. " |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 200 | "V(R)=%d)\n", rlc->tfi, this->m_window.v_q(), |
| 201 | this->m_window.v_r()); |
| 202 | |
| 203 | /* process RSSI */ |
| 204 | gprs_rlcmac_rssi(this, rssi); |
| 205 | |
| 206 | /* store measurement values */ |
| 207 | if (ms()) |
| 208 | ms()->update_l1_meas(meas); |
| 209 | |
| 210 | uint32_t new_tlli = 0; |
| 211 | unsigned int block_idx; |
| 212 | |
| 213 | /* restart T3169 */ |
Pau Espin Pedrol | 28f160e | 2019-09-05 14:48:35 +0200 | [diff] [blame] | 214 | T_START(this, T3169, 3169, "acked (data)", true); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 215 | |
| 216 | /* Increment RX-counter */ |
| 217 | this->m_rx_counter++; |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 218 | update_coding_scheme_counter_ul(rlc->cs); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 219 | /* Loop over num_blocks */ |
| 220 | for (block_idx = 0; block_idx < rlc->num_data_blocks; block_idx++) { |
| 221 | int num_chunks; |
| 222 | uint8_t *rlc_data; |
Pau Espin Pedrol | c33a024 | 2020-05-15 16:57:48 +0200 | [diff] [blame] | 223 | rdbi = &rlc->block_info[block_idx]; |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 224 | bool need_rlc_data = false; |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 225 | |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 226 | LOGPTBFUL(this, LOGL_DEBUG, |
| 227 | "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] | 228 | mcs_name(rlc->cs), |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 229 | rdbi->cv, rdbi->bsn, rdbi->spb, |
| 230 | rdbi->pi, rdbi->e, rdbi->ti, |
| 231 | rlc->data_offs_bits[block_idx]); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 232 | |
| 233 | /* Check whether the block needs to be decoded */ |
| 234 | |
| 235 | if (!m_window.is_in_window(rdbi->bsn)) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 236 | LOGPTBFUL(this, LOGL_DEBUG, "BSN %d out of window %d..%d (it's normal)\n", |
| 237 | rdbi->bsn, |
| 238 | m_window.v_q(), m_window.mod_sns(m_window.v_q() + ws - 1)); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 239 | } else if (m_window.is_received(rdbi->bsn)) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 240 | LOGPTBFUL(this, LOGL_DEBUG, |
| 241 | "BSN %d already received\n", rdbi->bsn); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 242 | } else { |
| 243 | need_rlc_data = true; |
| 244 | } |
| 245 | |
| 246 | if (!is_tlli_valid()) { |
| 247 | if (!rdbi->ti) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 248 | LOGPTBFUL(this, LOGL_NOTICE, "Missing TLLI within UL DATA.\n"); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 249 | continue; |
| 250 | } |
| 251 | need_rlc_data = true; |
| 252 | } |
| 253 | |
| 254 | if (!need_rlc_data) |
| 255 | continue; |
| 256 | |
| 257 | /* Store block and meta info to BSN buffer */ |
| 258 | |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 259 | LOGPTBFUL(this, LOGL_DEBUG, "BSN %d storing in window (%d..%d)\n", |
| 260 | rdbi->bsn, m_window.v_q(), |
| 261 | m_window.mod_sns(m_window.v_q() + ws - 1)); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 262 | block = m_rlc.block(rdbi->bsn); |
Aravind Sirsikar | 550a541 | 2016-06-14 18:59:18 +0530 | [diff] [blame] | 263 | OSMO_ASSERT(rdbi->data_len <= sizeof(block->block)); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 264 | rlc_data = &(block->block[0]); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 265 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 266 | if (rdbi->spb) { |
| 267 | egprs_rlc_ul_reseg_bsn_state assemble_status; |
| 268 | |
| 269 | assemble_status = handle_egprs_ul_spb(rlc, |
| 270 | block, data, block_idx); |
| 271 | |
| 272 | if (assemble_status != EGPRS_RESEG_DEFAULT) |
| 273 | return 0; |
| 274 | } else { |
| 275 | block->block_info = *rdbi; |
| 276 | block->cs_last = rlc->cs; |
| 277 | block->len = |
| 278 | Decoding::rlc_copy_to_aligned_buffer(rlc, |
| 279 | block_idx, data, rlc_data); |
| 280 | } |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 281 | |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 282 | LOGPTBFUL(this, LOGL_DEBUG, |
| 283 | "data_length=%d, data=%s\n", |
| 284 | block->len, osmo_hexdump(rlc_data, block->len)); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 285 | /* Get/Handle TLLI */ |
| 286 | if (rdbi->ti) { |
| 287 | num_chunks = Decoding::rlc_data_from_ul_data( |
| 288 | rdbi, rlc->cs, rlc_data, NULL, 0, &new_tlli); |
| 289 | |
| 290 | if (num_chunks < 0) { |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 291 | bts->do_rate_ctr_inc(CTR_DECODE_ERRORS); |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 292 | LOGPTBFUL(this, LOGL_NOTICE, |
| 293 | "Failed to decode TLLI of %s UL DATA TFI=%d.\n", |
Max | 136ebcc | 2019-03-05 14:59:03 +0100 | [diff] [blame] | 294 | mcs_name(rlc->cs), rlc->tfi); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 295 | m_window.invalidate_bsn(rdbi->bsn); |
| 296 | continue; |
| 297 | } |
| 298 | if (!this->is_tlli_valid()) { |
| 299 | if (!new_tlli) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 300 | LOGPTBFUL(this, LOGL_NOTICE, |
| 301 | "TLLI = 0 within UL DATA.\n"); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 302 | m_window.invalidate_bsn(rdbi->bsn); |
| 303 | continue; |
| 304 | } |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 305 | LOGPTBFUL(this, LOGL_INFO, |
| 306 | "Decoded premier TLLI=0x%08x of UL DATA TFI=%d.\n", |
Vadim Yanitskiy | 3f27fb5 | 2020-04-20 11:26:12 +0700 | [diff] [blame] | 307 | new_tlli, rlc->tfi); |
Pau Espin Pedrol | d21e961 | 2020-06-26 14:20:37 +0200 | [diff] [blame] | 308 | update_ms(new_tlli, GPRS_RLCMAC_UL_TBF); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 309 | } else if (new_tlli && new_tlli != tlli()) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 310 | LOGPTBFUL(this, LOGL_NOTICE, |
| 311 | "TLLI mismatch on UL DATA TFI=%d. (Ignoring due to contention resolution)\n", |
| 312 | rlc->tfi); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 313 | m_window.invalidate_bsn(rdbi->bsn); |
| 314 | continue; |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | m_window.receive_bsn(rdbi->bsn); |
| 319 | } |
| 320 | |
| 321 | /* Raise V(Q) if possible, and retrieve LLC frames from blocks. |
| 322 | * This is looped until there is a gap (non received block) or |
| 323 | * the window is empty.*/ |
| 324 | const uint16_t v_q_beg = m_window.v_q(); |
| 325 | const uint16_t count = m_window.raise_v_q(); |
| 326 | |
| 327 | /* Retrieve LLC frames from blocks that are ready */ |
| 328 | for (uint16_t i = 0; i < count; ++i) { |
Jacob Erlbeck | 93c55d0 | 2015-12-23 16:29:07 +0100 | [diff] [blame] | 329 | uint16_t index = m_window.mod_sns(v_q_beg + i); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 330 | assemble_forward_llc(m_rlc.block(index)); |
| 331 | } |
| 332 | |
Pau Espin Pedrol | c33a024 | 2020-05-15 16:57:48 +0200 | [diff] [blame] | 333 | /* Last frame in buffer: */ |
| 334 | block = m_rlc.block(m_window.mod_sns(m_window.v_r() - 1)); |
| 335 | rdbi = &block->block_info; |
| 336 | |
| 337 | /* Check if we already received all data TBF had to send: */ |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 338 | if (this->state_is(GPRS_RLCMAC_FLOW) /* still in flow state */ |
| 339 | && this->m_window.v_q() == this->m_window.v_r()) { /* if complete */ |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 340 | LOGPTBFUL(this, LOGL_DEBUG, |
| 341 | "No gaps in received block, last block: BSN=%d CV=%d\n", |
| 342 | rdbi->bsn, rdbi->cv); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 343 | if (rdbi->cv == 0) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 344 | LOGPTBFUL(this, LOGL_DEBUG, "Finished with UL TBF\n"); |
Max | 2399b1d | 2018-01-12 15:48:12 +0100 | [diff] [blame] | 345 | TBF_SET_STATE(this, GPRS_RLCMAC_FINISHED); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 346 | /* Reset N3103 counter. */ |
Max | 847ed9f | 2018-02-20 18:16:11 +0100 | [diff] [blame] | 347 | this->n_reset(N3103); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 348 | } |
| 349 | } |
| 350 | |
| 351 | /* If TLLI is included or if we received half of the window, we send |
| 352 | * an ack/nack */ |
Pau Espin Pedrol | c33a024 | 2020-05-15 16:57:48 +0200 | [diff] [blame] | 353 | maybe_schedule_uplink_acknack(rlc, rdbi->cv == 0); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 354 | |
| 355 | return 0; |
| 356 | } |
| 357 | |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 358 | void gprs_rlcmac_ul_tbf::maybe_schedule_uplink_acknack( |
Pau Espin Pedrol | c33a024 | 2020-05-15 16:57:48 +0200 | [diff] [blame] | 359 | const gprs_rlc_data_info *rlc, bool countdown_finished) |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 360 | { |
Pau Espin Pedrol | 09afd6f | 2020-05-15 16:40:18 +0200 | [diff] [blame] | 361 | bool require_ack = false; |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 362 | bool have_ti = rlc->block_info[0].ti || |
| 363 | (rlc->num_data_blocks > 1 && rlc->block_info[1].ti); |
| 364 | |
Pau Espin Pedrol | 09afd6f | 2020-05-15 16:40:18 +0200 | [diff] [blame] | 365 | if (rlc->si) { |
| 366 | require_ack = true; |
| 367 | LOGPTBFUL(this, LOGL_NOTICE, |
| 368 | "Scheduling Ack/Nack, because MS is stalled.\n"); |
| 369 | } |
| 370 | if (have_ti) { |
| 371 | require_ack = true; |
| 372 | LOGPTBFUL(this, LOGL_DEBUG, |
| 373 | "Scheduling Ack/Nack, because TLLI is included.\n"); |
| 374 | } |
Pau Espin Pedrol | c33a024 | 2020-05-15 16:57:48 +0200 | [diff] [blame] | 375 | if (countdown_finished) { |
Pau Espin Pedrol | 09afd6f | 2020-05-15 16:40:18 +0200 | [diff] [blame] | 376 | require_ack = true; |
Pau Espin Pedrol | c33a024 | 2020-05-15 16:57:48 +0200 | [diff] [blame] | 377 | if (state_is(GPRS_RLCMAC_FLOW)) |
| 378 | LOGPTBFUL(this, LOGL_DEBUG, |
| 379 | "Scheduling Ack/Nack, because some data is missing and last block has CV==0.\n"); |
| 380 | else if (state_is(GPRS_RLCMAC_FINISHED)) |
| 381 | LOGPTBFUL(this, LOGL_DEBUG, |
| 382 | "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] | 383 | } |
| 384 | if ((m_rx_counter % SEND_ACK_AFTER_FRAMES) == 0) { |
| 385 | require_ack = true; |
| 386 | LOGPTBFUL(this, LOGL_DEBUG, |
| 387 | "Scheduling Ack/Nack, because %d frames received.\n", |
| 388 | SEND_ACK_AFTER_FRAMES); |
| 389 | } |
| 390 | |
| 391 | if (!require_ack) |
| 392 | return; |
| 393 | |
| 394 | if (ul_ack_state_is(GPRS_RLCMAC_UL_ACK_NONE)) { |
| 395 | /* trigger sending at next RTS */ |
| 396 | TBF_SET_ACK_STATE(this, GPRS_RLCMAC_UL_ACK_SEND_ACK); |
| 397 | } else { |
| 398 | /* already triggered */ |
| 399 | LOGPTBFUL(this, LOGL_DEBUG, |
| 400 | "Sending Ack/Nack already scheduled, no need to re-schedule\n"); |
Jacob Erlbeck | b3100e1 | 2015-12-14 13:36:13 +0100 | [diff] [blame] | 401 | } |
| 402 | } |
| 403 | |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 404 | /* Send Uplink unit-data to SGSN. */ |
| 405 | int gprs_rlcmac_ul_tbf::snd_ul_ud() |
| 406 | { |
| 407 | uint8_t qos_profile[3]; |
| 408 | struct msgb *llc_pdu; |
| 409 | unsigned msg_len = NS_HDR_LEN + BSSGP_HDR_LEN + m_llc.frame_length(); |
| 410 | struct bssgp_bvc_ctx *bctx = gprs_bssgp_pcu_current_bctx(); |
| 411 | |
| 412 | LOGP(DBSSGP, LOGL_INFO, "LLC [PCU -> SGSN] %s len=%d\n", tbf_name(this), m_llc.frame_length()); |
| 413 | if (!bctx) { |
| 414 | LOGP(DBSSGP, LOGL_ERROR, "No bctx\n"); |
| 415 | m_llc.reset_frame_space(); |
| 416 | return -EIO; |
| 417 | } |
Pau Espin Pedrol | 488aa29 | 2019-09-25 17:48:35 +0200 | [diff] [blame] | 418 | |
Daniel Willmann | ca102af | 2014-08-08 12:14:12 +0200 | [diff] [blame] | 419 | llc_pdu = msgb_alloc_headroom(msg_len, msg_len,"llc_pdu"); |
| 420 | uint8_t *buf = msgb_push(llc_pdu, TL16V_GROSS_LEN(sizeof(uint8_t)*m_llc.frame_length())); |
| 421 | tl16v_put(buf, BSSGP_IE_LLC_PDU, sizeof(uint8_t)*m_llc.frame_length(), m_llc.frame); |
| 422 | qos_profile[0] = QOS_PROFILE >> 16; |
| 423 | qos_profile[1] = QOS_PROFILE >> 8; |
| 424 | qos_profile[2] = QOS_PROFILE; |
| 425 | bssgp_tx_ul_ud(bctx, tlli(), qos_profile, llc_pdu); |
| 426 | |
| 427 | m_llc.reset_frame_space(); |
| 428 | return 0; |
| 429 | } |
| 430 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 431 | egprs_rlc_ul_reseg_bsn_state gprs_rlcmac_ul_tbf::handle_egprs_ul_second_seg( |
| 432 | const struct gprs_rlc_data_info *rlc, struct gprs_rlc_data *block, |
| 433 | uint8_t *data, const uint8_t block_idx) |
| 434 | { |
| 435 | const gprs_rlc_data_block_info *rdbi = &rlc->block_info[block_idx]; |
| 436 | union split_block_status *spb_status = &block->spb_status; |
| 437 | uint8_t *rlc_data = &block->block[0]; |
| 438 | |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 439 | bts->do_rate_ctr_inc(CTR_SPB_UL_SECOND_SEGMENT); |
sivasankari | da7250a | 2016-12-16 12:57:18 +0530 | [diff] [blame] | 440 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 441 | if (spb_status->block_status_ul & |
| 442 | EGPRS_RESEG_FIRST_SEG_RXD) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 443 | LOGPTBFUL(this, LOGL_DEBUG, |
| 444 | "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] | 445 | spb_status->block_status_ul = EGPRS_RESEG_DEFAULT; |
| 446 | |
| 447 | block->len += Decoding::rlc_copy_to_aligned_buffer(rlc, |
| 448 | block_idx, data, rlc_data + block->len); |
| 449 | block->block_info.data_len += rdbi->data_len; |
| 450 | } else if (spb_status->block_status_ul == EGPRS_RESEG_DEFAULT) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 451 | LOGPTBFUL(this, LOGL_DEBUG, |
| 452 | "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] | 453 | |
| 454 | block->len = Decoding::rlc_copy_to_aligned_buffer(rlc, |
| 455 | block_idx, data, |
| 456 | rlc_data + rlc->block_info[block_idx].data_len); |
| 457 | |
| 458 | spb_status->block_status_ul = EGPRS_RESEG_SECOND_SEG_RXD; |
| 459 | block->block_info = *rdbi; |
| 460 | } |
| 461 | return spb_status->block_status_ul; |
| 462 | } |
| 463 | |
| 464 | egprs_rlc_ul_reseg_bsn_state gprs_rlcmac_ul_tbf::handle_egprs_ul_first_seg( |
| 465 | const struct gprs_rlc_data_info *rlc, struct gprs_rlc_data *block, |
| 466 | uint8_t *data, const uint8_t block_idx) |
| 467 | { |
| 468 | const gprs_rlc_data_block_info *rdbi = &rlc->block_info[block_idx]; |
| 469 | uint8_t *rlc_data = &block->block[0]; |
| 470 | union split_block_status *spb_status = &block->spb_status; |
| 471 | |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 472 | bts->do_rate_ctr_inc(CTR_SPB_UL_FIRST_SEGMENT); |
sivasankari | da7250a | 2016-12-16 12:57:18 +0530 | [diff] [blame] | 473 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 474 | if (spb_status->block_status_ul & EGPRS_RESEG_SECOND_SEG_RXD) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 475 | LOGPTBFUL(this, LOGL_DEBUG, |
| 476 | "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] | 477 | |
| 478 | block->len += Decoding::rlc_copy_to_aligned_buffer(rlc, |
| 479 | block_idx, data, rlc_data); |
| 480 | |
| 481 | block->block_info.data_len = block->len; |
| 482 | spb_status->block_status_ul = EGPRS_RESEG_DEFAULT; |
| 483 | } else if (spb_status->block_status_ul == EGPRS_RESEG_DEFAULT) { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 484 | LOGPTBFUL(this, LOGL_DEBUG, |
| 485 | "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] | 486 | |
| 487 | spb_status->block_status_ul = EGPRS_RESEG_FIRST_SEG_RXD; |
| 488 | block->len = Decoding::rlc_copy_to_aligned_buffer(rlc, |
| 489 | block_idx, data, rlc_data); |
| 490 | block->block_info = *rdbi; |
| 491 | } |
| 492 | return spb_status->block_status_ul; |
| 493 | } |
| 494 | |
| 495 | egprs_rlc_ul_reseg_bsn_state gprs_rlcmac_ul_tbf::handle_egprs_ul_spb( |
| 496 | const struct gprs_rlc_data_info *rlc, struct gprs_rlc_data *block, |
| 497 | uint8_t *data, const uint8_t block_idx) |
| 498 | { |
| 499 | const gprs_rlc_data_block_info *rdbi = &rlc->block_info[block_idx]; |
| 500 | |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 501 | LOGPTBFUL(this, LOGL_DEBUG, |
| 502 | "Got SPB(%d) cs(%s) data block with BSN (%d), TFI(%d).\n", |
Max | 136ebcc | 2019-03-05 14:59:03 +0100 | [diff] [blame] | 503 | rdbi->spb, mcs_name(rlc->cs), rdbi->bsn, rlc->tfi); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 504 | |
| 505 | egprs_rlc_ul_reseg_bsn_state assemble_status = EGPRS_RESEG_INVALID; |
| 506 | |
| 507 | /* Section 10.4.8b of 44.060*/ |
| 508 | if (rdbi->spb == 2) |
| 509 | assemble_status = handle_egprs_ul_first_seg(rlc, |
| 510 | block, data, block_idx); |
| 511 | else if (rdbi->spb == 3) |
| 512 | assemble_status = handle_egprs_ul_second_seg(rlc, |
| 513 | block, data, block_idx); |
| 514 | else { |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 515 | LOGPTBFUL(this, LOGL_ERROR, |
| 516 | "spb(%d) Not supported SPB for this EGPRS configuration\n", |
| 517 | rdbi->spb); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 518 | } |
| 519 | |
| 520 | /* |
| 521 | * When the block is successfully constructed out of segmented blocks |
| 522 | * upgrade the MCS to the type 2 |
| 523 | */ |
| 524 | if (assemble_status == EGPRS_RESEG_DEFAULT) { |
Pau Espin Pedrol | 2ae8337 | 2020-05-18 11:35:35 +0200 | [diff] [blame] | 525 | switch (rlc->cs) { |
Max | bea2edb | 2019-03-06 17:04:59 +0100 | [diff] [blame] | 526 | case MCS3 : |
| 527 | block->cs_last = MCS6; |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 528 | LOGPTBFUL(this, LOGL_DEBUG, "Upgrading to MCS6\n"); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 529 | break; |
Max | bea2edb | 2019-03-06 17:04:59 +0100 | [diff] [blame] | 530 | case MCS2 : |
| 531 | block->cs_last = MCS5; |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 532 | LOGPTBFUL(this, LOGL_DEBUG, "Upgrading to MCS5\n"); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 533 | break; |
Max | bea2edb | 2019-03-06 17:04:59 +0100 | [diff] [blame] | 534 | case MCS1 : |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 535 | LOGPTBFUL(this, LOGL_DEBUG, "Upgrading to MCS4\n"); |
Max | bea2edb | 2019-03-06 17:04:59 +0100 | [diff] [blame] | 536 | block->cs_last = MCS4; |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 537 | break; |
| 538 | default: |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 539 | LOGPTBFUL(this, LOGL_ERROR, |
| 540 | "cs(%s) Error in Upgrading to higher MCS\n", |
Max | 136ebcc | 2019-03-05 14:59:03 +0100 | [diff] [blame] | 541 | mcs_name(rlc->cs)); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 542 | break; |
| 543 | } |
| 544 | } |
| 545 | return assemble_status; |
| 546 | } |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 547 | |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 548 | 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] | 549 | { |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 550 | switch (cs) { |
| 551 | case CS1: |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 552 | bts->do_rate_ctr_inc(CTR_GPRS_UL_CS1); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 553 | rate_ctr_inc(&m_ul_gprs_ctrs->ctr[TBF_CTR_GPRS_UL_CS1]); |
| 554 | break; |
| 555 | case CS2: |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 556 | bts->do_rate_ctr_inc(CTR_GPRS_UL_CS2); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 557 | rate_ctr_inc(&m_ul_gprs_ctrs->ctr[TBF_CTR_GPRS_UL_CS2]); |
| 558 | break; |
| 559 | case CS3: |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 560 | bts->do_rate_ctr_inc(CTR_GPRS_UL_CS3); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 561 | rate_ctr_inc(&m_ul_gprs_ctrs->ctr[TBF_CTR_GPRS_UL_CS3]); |
| 562 | break; |
| 563 | case CS4: |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 564 | bts->do_rate_ctr_inc(CTR_GPRS_UL_CS4); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 565 | rate_ctr_inc(&m_ul_gprs_ctrs->ctr[TBF_CTR_GPRS_UL_CS4]); |
| 566 | break; |
| 567 | case MCS1: |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 568 | bts->do_rate_ctr_inc(CTR_EGPRS_UL_MCS1); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 569 | rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS1]); |
| 570 | break; |
| 571 | case MCS2: |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 572 | bts->do_rate_ctr_inc(CTR_EGPRS_UL_MCS2); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 573 | rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS2]); |
| 574 | break; |
| 575 | case MCS3: |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 576 | bts->do_rate_ctr_inc(CTR_EGPRS_UL_MCS3); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 577 | rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS3]); |
| 578 | break; |
| 579 | case MCS4: |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 580 | bts->do_rate_ctr_inc(CTR_EGPRS_UL_MCS4); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 581 | rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS4]); |
| 582 | break; |
| 583 | case MCS5: |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 584 | bts->do_rate_ctr_inc(CTR_EGPRS_UL_MCS5); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 585 | rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS5]); |
| 586 | break; |
| 587 | case MCS6: |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 588 | bts->do_rate_ctr_inc(CTR_EGPRS_UL_MCS6); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 589 | rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS6]); |
| 590 | break; |
| 591 | case MCS7: |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 592 | bts->do_rate_ctr_inc(CTR_EGPRS_UL_MCS7); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 593 | rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS7]); |
| 594 | break; |
| 595 | case MCS8: |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 596 | bts->do_rate_ctr_inc(CTR_EGPRS_UL_MCS8); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 597 | rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS8]); |
| 598 | break; |
| 599 | case MCS9: |
Pau Espin Pedrol | 2338e53 | 2020-05-12 20:54:35 +0200 | [diff] [blame] | 600 | bts->do_rate_ctr_inc(CTR_EGPRS_UL_MCS9); |
Max | fb59a93 | 2019-03-13 18:40:19 +0100 | [diff] [blame] | 601 | rate_ctr_inc(&m_ul_egprs_ctrs->ctr[TBF_CTR_EGPRS_UL_MCS9]); |
| 602 | break; |
| 603 | default: |
| 604 | LOGPTBFUL(this, LOGL_ERROR, "attempting to update rate counters for unsupported (M)CS %s\n", |
| 605 | mcs_name(cs)); |
Mrinal Mishra | f86307e | 2016-11-10 18:16:30 +0530 | [diff] [blame] | 606 | } |
| 607 | } |
sivasankari | 8adfcd0 | 2017-01-16 15:41:21 +0530 | [diff] [blame] | 608 | |
Max | 9d7357e | 2017-12-14 15:02:33 +0100 | [diff] [blame] | 609 | void gprs_rlcmac_ul_tbf::set_window_size() |
sivasankari | 8adfcd0 | 2017-01-16 15:41:21 +0530 | [diff] [blame] | 610 | { |
Max | 34513fe | 2018-12-11 16:47:30 +0100 | [diff] [blame] | 611 | const struct gprs_rlcmac_bts *b = bts->bts_data(); |
| 612 | uint16_t ws = egprs_window_size(b, ul_slots()); |
Max | 0524e38 | 2018-01-19 18:22:25 +0100 | [diff] [blame] | 613 | LOGPTBFUL(this, LOGL_INFO, "setting EGPRS UL window size to %u, base(%u) slots(%u) ws_pdch(%u)\n", |
Max | 34513fe | 2018-12-11 16:47:30 +0100 | [diff] [blame] | 614 | ws, b->ws_base, pcu_bitcount(ul_slots()), b->ws_pdch); |
sivasankari | 8adfcd0 | 2017-01-16 15:41:21 +0530 | [diff] [blame] | 615 | m_window.set_ws(ws); |
| 616 | } |