Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 1 | /* |
| 2 | * TbfTest.cpp |
| 3 | * |
| 4 | * Copyright (C) 2013 by Holger Hans Peter Freyther |
| 5 | * |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU Affero General Public License as published by |
| 10 | * the Free Software Foundation; either version 3 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Affero General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include "bts.h" |
| 24 | #include "tbf.h" |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 25 | #include "tbf_dl.h" |
Pau Espin Pedrol | 9d1cdb1 | 2019-09-25 17:47:02 +0200 | [diff] [blame] | 26 | #include "tbf_ul.h" |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 27 | #include "gprs_ms.h" |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 28 | #include "gprs_debug.h" |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 29 | #include "gprs_ms_storage.h" |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 30 | #include "pcu_utils.h" |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 31 | #include "gprs_bssgp_pcu.h" |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 32 | #include "pcu_l1_if.h" |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 33 | #include "decoding.h" |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 34 | #include <gprs_rlcmac.h> |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 35 | |
| 36 | extern "C" { |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 37 | #include "pcu_vty.h" |
Pau Espin Pedrol | 2ae8337 | 2020-05-18 11:35:35 +0200 | [diff] [blame] | 38 | #include "coding_scheme.h" |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 39 | |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 40 | #include <osmocom/core/application.h> |
| 41 | #include <osmocom/core/msgb.h> |
| 42 | #include <osmocom/core/talloc.h> |
| 43 | #include <osmocom/core/utils.h> |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 44 | #include <osmocom/vty/vty.h> |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 45 | #include <osmocom/gprs/protocol/gsm_04_60.h> |
bhargava | 959d1de | 2016-08-17 15:17:21 +0530 | [diff] [blame] | 46 | #include <osmocom/gsm/l1sap.h> |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 47 | #include <osmocom/core/fsm.h> |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 48 | } |
| 49 | |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 50 | #include <errno.h> |
| 51 | |
Philipp | d935d88 | 2016-11-07 13:07:36 +0100 | [diff] [blame] | 52 | #define DUMMY_FN 2654167 |
| 53 | |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 54 | void *tall_pcu_ctx; |
| 55 | int16_t spoof_mnc = 0, spoof_mcc = 0; |
Neels Hofmeyr | bdc55fa | 2018-02-21 00:39:07 +0100 | [diff] [blame] | 56 | bool spoof_mnc_3_digits = false; |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 57 | |
Vadim Yanitskiy | 87b6e7d | 2019-11-08 04:44:04 +0700 | [diff] [blame] | 58 | /* Measurements shared by all unit tests */ |
| 59 | static struct pcu_l1_meas meas; |
| 60 | |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 61 | int gprs_gp_send_test_cb(void *ctx, struct msgb *msg) |
| 62 | { |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | static gprs_pcu *prepare_pcu(void) |
| 67 | { |
| 68 | struct gprs_pcu *pcu = gprs_pcu_alloc(tall_pcu_ctx); |
| 69 | bssgp_set_bssgp_callback(gprs_gp_send_test_cb, NULL); |
Pau Espin Pedrol | 9184e85 | 2022-05-09 16:13:52 +0200 | [diff] [blame] | 70 | osmo_tdef_set(pcu->T_defs, -2030, 0, OSMO_TDEF_S); |
| 71 | osmo_tdef_set(pcu->T_defs, -2031, 0, OSMO_TDEF_S); |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 72 | return pcu; |
| 73 | } |
| 74 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 75 | static int bts_handle_rach(struct gprs_rlcmac_bts *bts, uint16_t ra, uint32_t Fn, int16_t qta) |
Vadim Yanitskiy | a0a0b7f | 2020-05-21 19:55:46 +0700 | [diff] [blame] | 76 | { |
| 77 | struct rach_ind_params rip = { |
| 78 | .burst_type = GSM_L1_BURST_TYPE_ACCESS_0, |
| 79 | .is_11bit = false, |
| 80 | .ra = ra, |
| 81 | .trx_nr = 0, |
| 82 | .ts_nr = 0, |
| 83 | .rfn = Fn, |
| 84 | .qta = qta, |
| 85 | }; |
| 86 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 87 | return bts_rcv_rach(bts, &rip); |
Vadim Yanitskiy | a0a0b7f | 2020-05-21 19:55:46 +0700 | [diff] [blame] | 88 | } |
| 89 | |
Jacob Erlbeck | 08fe76a | 2015-02-23 15:10:20 +0100 | [diff] [blame] | 90 | static void check_tbf(gprs_rlcmac_tbf *tbf) |
| 91 | { |
| 92 | OSMO_ASSERT(tbf); |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 93 | if (tbf->state_is(TBF_ST_WAIT_RELEASE)) |
Pau Espin Pedrol | f197f15 | 2022-11-17 20:18:46 +0100 | [diff] [blame] | 94 | OSMO_ASSERT(tbf->timers_pending(T3191) || osmo_timer_pending(&tbf->state_fi->timer)); |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 95 | if (tbf->state_is(TBF_ST_RELEASING)) |
Max | ee5be3a | 2017-12-20 17:31:13 +0100 | [diff] [blame] | 96 | OSMO_ASSERT(tbf->timers_pending(T_MAX)); |
Jacob Erlbeck | 08fe76a | 2015-02-23 15:10:20 +0100 | [diff] [blame] | 97 | } |
| 98 | |
Jacob Erlbeck | ac89a55 | 2015-06-29 14:18:46 +0200 | [diff] [blame] | 99 | static void test_tbf_base() |
| 100 | { |
| 101 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 102 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | ac89a55 | 2015-06-29 14:18:46 +0200 | [diff] [blame] | 103 | |
| 104 | OSMO_ASSERT(GPRS_RLCMAC_DL_TBF == reverse(GPRS_RLCMAC_UL_TBF)); |
| 105 | OSMO_ASSERT(GPRS_RLCMAC_UL_TBF == reverse(GPRS_RLCMAC_DL_TBF)); |
| 106 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 107 | fprintf(stderr, "=== end %s ===\n", __func__); |
Jacob Erlbeck | ac89a55 | 2015-06-29 14:18:46 +0200 | [diff] [blame] | 108 | } |
| 109 | |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 110 | static void test_tbf_tlli_update() |
| 111 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 112 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 113 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Jacob Erlbeck | 9399046 | 2015-05-15 15:50:43 +0200 | [diff] [blame] | 114 | GprsMs *ms, *ms_new; |
| 115 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 116 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | 53efa3e | 2016-01-11 16:12:01 +0100 | [diff] [blame] | 117 | |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 118 | the_pcu->alloc_algorithm = alloc_algorithm_a; |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 119 | bts->trx[0].pdch[2].enable(); |
| 120 | bts->trx[0].pdch[3].enable(); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 121 | |
| 122 | /* |
| 123 | * Make a uplink and downlink allocation |
| 124 | */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 125 | ms = bts_alloc_ms(bts, 0, 0); |
Pau Espin Pedrol | 8757384 | 2022-10-26 20:23:45 +0200 | [diff] [blame] | 126 | gprs_rlcmac_tbf *dl_tbf = dl_tbf_alloc(bts, |
Pau Espin Pedrol | 322456e | 2020-05-08 18:15:59 +0200 | [diff] [blame] | 127 | ms, 0, false); |
Jacob Erlbeck | c6d4cee | 2015-06-29 13:03:46 +0200 | [diff] [blame] | 128 | OSMO_ASSERT(dl_tbf != NULL); |
Pau Espin Pedrol | 8abe13c | 2022-10-21 18:49:48 +0200 | [diff] [blame] | 129 | ms_confirm_tlli(ms, 0x2342); |
Jacob Erlbeck | 9200ce6 | 2015-05-22 17:48:04 +0200 | [diff] [blame] | 130 | dl_tbf->set_ta(4); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 131 | OSMO_ASSERT(ms_dl_tbf(ms) == dl_tbf); |
Pau Espin Pedrol | 322456e | 2020-05-08 18:15:59 +0200 | [diff] [blame] | 132 | OSMO_ASSERT(dl_tbf->ms() == ms); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 133 | |
Pau Espin Pedrol | bda7bb7 | 2022-10-31 14:33:09 +0100 | [diff] [blame] | 134 | gprs_rlcmac_tbf *ul_tbf = ul_tbf_alloc(bts, |
Pau Espin Pedrol | 322456e | 2020-05-08 18:15:59 +0200 | [diff] [blame] | 135 | ms, 0, false); |
Jacob Erlbeck | c6d4cee | 2015-06-29 13:03:46 +0200 | [diff] [blame] | 136 | OSMO_ASSERT(ul_tbf != NULL); |
Pau Espin Pedrol | 8abe13c | 2022-10-21 18:49:48 +0200 | [diff] [blame] | 137 | ms_update_announced_tlli(ms, 0x2342); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 138 | OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); |
Pau Espin Pedrol | 322456e | 2020-05-08 18:15:59 +0200 | [diff] [blame] | 139 | OSMO_ASSERT(ul_tbf->ms() == ms); |
| 140 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 141 | OSMO_ASSERT(bts_ms_by_tlli(bts, 0x2342, GSM_RESERVED_TMSI) == ms); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 142 | |
| 143 | /* |
| 144 | * Now check.. that DL changes and that the timing advance |
| 145 | * has changed. |
| 146 | */ |
Pau Espin Pedrol | 8abe13c | 2022-10-21 18:49:48 +0200 | [diff] [blame] | 147 | ms_confirm_tlli(dl_tbf->ms(), 0x4232); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 148 | |
Jacob Erlbeck | 9399046 | 2015-05-15 15:50:43 +0200 | [diff] [blame] | 149 | /* It is still there, since the new TLLI has not been used for UL yet */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 150 | ms_new = bts_ms_by_tlli(bts, 0x2342, GSM_RESERVED_TMSI); |
Jacob Erlbeck | 9399046 | 2015-05-15 15:50:43 +0200 | [diff] [blame] | 151 | OSMO_ASSERT(ms == ms_new); |
| 152 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 153 | ms_new = bts_ms_by_tlli(bts, 0x4232, GSM_RESERVED_TMSI); |
Jacob Erlbeck | 9399046 | 2015-05-15 15:50:43 +0200 | [diff] [blame] | 154 | OSMO_ASSERT(ms == ms_new); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 155 | OSMO_ASSERT(ms_dl_tbf(ms) == dl_tbf); |
| 156 | OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); |
Jacob Erlbeck | 9399046 | 2015-05-15 15:50:43 +0200 | [diff] [blame] | 157 | |
| 158 | /* Now use the new TLLI for UL */ |
Pau Espin Pedrol | 8abe13c | 2022-10-21 18:49:48 +0200 | [diff] [blame] | 159 | ms_update_announced_tlli(ms, 0x4232); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 160 | ms_new = bts_ms_by_tlli(bts, 0x2342, GSM_RESERVED_TMSI); |
Jacob Erlbeck | 9399046 | 2015-05-15 15:50:43 +0200 | [diff] [blame] | 161 | OSMO_ASSERT(ms_new == NULL); |
Holger Hans Peter Freyther | bc1626e | 2013-10-30 19:50:49 +0100 | [diff] [blame] | 162 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 163 | ms_new = bts_ms_by_tlli(bts, 0x4232, GSM_RESERVED_TMSI); |
Jacob Erlbeck | 9200ce6 | 2015-05-22 17:48:04 +0200 | [diff] [blame] | 164 | OSMO_ASSERT(ms_new != NULL); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 165 | OSMO_ASSERT(ms_ta(ms_new) == 4); |
Jacob Erlbeck | 9200ce6 | 2015-05-22 17:48:04 +0200 | [diff] [blame] | 166 | |
| 167 | OSMO_ASSERT(ul_tbf->ta() == 4); |
| 168 | OSMO_ASSERT(dl_tbf->ta() == 4); |
| 169 | |
| 170 | ul_tbf->set_ta(6); |
| 171 | |
| 172 | OSMO_ASSERT(ul_tbf->ta() == 6); |
| 173 | OSMO_ASSERT(dl_tbf->ta() == 6); |
Jacob Erlbeck | 53efa3e | 2016-01-11 16:12:01 +0100 | [diff] [blame] | 174 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 175 | fprintf(stderr, "=== end %s ===\n", __func__); |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 176 | TALLOC_FREE(the_pcu); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 177 | } |
| 178 | |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 179 | static uint8_t llc_data[200]; |
| 180 | |
Max | a296118 | 2018-01-25 19:47:28 +0100 | [diff] [blame] | 181 | /* override, requires '-Wl,--wrap=pcu_sock_send' */ |
| 182 | int __real_pcu_sock_send(struct msgb *msg); |
Pau Espin Pedrol | e91c4c7 | 2021-01-18 17:54:30 +0100 | [diff] [blame] | 183 | extern "C" int __wrap_pcu_sock_send(struct msgb *msg) |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 184 | { |
| 185 | return 0; |
| 186 | } |
| 187 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 188 | static void setup_bts(struct gprs_rlcmac_bts *bts, uint8_t ts_no, uint8_t cs = 1) |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 189 | { |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 190 | gprs_rlcmac_trx *trx; |
| 191 | |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 192 | the_pcu->alloc_algorithm = alloc_algorithm_a; |
Jacob Erlbeck | a700dd9 | 2015-06-02 16:00:41 +0200 | [diff] [blame] | 193 | bts->initial_cs_dl = cs; |
| 194 | bts->initial_cs_ul = cs; |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 195 | trx = &bts->trx[0]; |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 196 | trx->pdch[ts_no].enable(); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 197 | bts_set_current_frame_number(bts, DUMMY_FN); |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 198 | } |
| 199 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 200 | static gprs_rlcmac_dl_tbf *create_dl_tbf(struct gprs_rlcmac_bts *bts, uint8_t ms_class, |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 201 | uint8_t egprs_ms_class, uint8_t *trx_no_) |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 202 | { |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 203 | int tfi; |
| 204 | uint8_t trx_no; |
Pau Espin Pedrol | 322456e | 2020-05-08 18:15:59 +0200 | [diff] [blame] | 205 | GprsMs *ms; |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 206 | gprs_rlcmac_dl_tbf *dl_tbf; |
| 207 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 208 | ms = bts_alloc_ms(bts, ms_class, egprs_ms_class); |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 209 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 210 | tfi = bts_tfi_find_free(bts, GPRS_RLCMAC_DL_TBF, &trx_no, -1); |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 211 | OSMO_ASSERT(tfi >= 0); |
Pau Espin Pedrol | 8757384 | 2022-10-26 20:23:45 +0200 | [diff] [blame] | 212 | dl_tbf = dl_tbf_alloc(bts, ms, trx_no, true); |
Pau Espin Pedrol | 983bb7e | 2020-10-26 14:52:06 +0100 | [diff] [blame] | 213 | OSMO_ASSERT(dl_tbf); |
Max | 9bbe160 | 2016-07-18 12:50:18 +0200 | [diff] [blame] | 214 | dl_tbf->set_ta(0); |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 215 | check_tbf(dl_tbf); |
| 216 | |
| 217 | /* "Establish" the DL TBF */ |
Pau Espin Pedrol | 49a2f40 | 2021-07-27 17:33:07 +0200 | [diff] [blame] | 218 | osmo_fsm_inst_dispatch(dl_tbf->dl_ass_fsm.fi, TBF_DL_ASS_EV_SCHED_ASS, NULL); |
Pau Espin Pedrol | f197f15 | 2022-11-17 20:18:46 +0100 | [diff] [blame] | 219 | osmo_fsm_inst_dispatch(dl_tbf->state_fi, TBF_EV_ASSIGN_ADD_CCCH, NULL); |
| 220 | osmo_fsm_inst_dispatch(dl_tbf->state_fi, TBF_EV_ASSIGN_ACK_PACCH, NULL); |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 221 | check_tbf(dl_tbf); |
| 222 | |
| 223 | *trx_no_ = trx_no; |
| 224 | |
| 225 | return dl_tbf; |
| 226 | } |
| 227 | |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 228 | static unsigned fn_add_blocks(unsigned fn, unsigned blocks) |
| 229 | { |
| 230 | unsigned bn = fn2bn(fn) + blocks; |
| 231 | fn = fn - (fn % 52); |
| 232 | fn += bn * 4 + bn / 3; |
Max | 9dabfa2 | 2017-05-16 16:10:45 +0200 | [diff] [blame] | 233 | return fn % GSM_MAX_FN; |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 234 | } |
| 235 | |
Jacob Erlbeck | cef20ae | 2015-08-24 12:00:33 +0200 | [diff] [blame] | 236 | static void request_dl_rlc_block(struct gprs_rlcmac_bts *bts, |
Max | 878bd1f | 2016-07-20 13:05:05 +0200 | [diff] [blame] | 237 | uint8_t trx_no, uint8_t ts_no, |
Jacob Erlbeck | ee31090 | 2015-08-24 11:55:17 +0200 | [diff] [blame] | 238 | uint32_t *fn, uint8_t *block_nr = NULL) |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 239 | { |
Jacob Erlbeck | ee31090 | 2015-08-24 11:55:17 +0200 | [diff] [blame] | 240 | uint8_t bn = fn2bn(*fn); |
Max | 878bd1f | 2016-07-20 13:05:05 +0200 | [diff] [blame] | 241 | gprs_rlcmac_rcv_rts_block(bts, trx_no, ts_no, *fn, bn); |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 242 | *fn = fn_add_blocks(*fn, 1); |
Jacob Erlbeck | ee31090 | 2015-08-24 11:55:17 +0200 | [diff] [blame] | 243 | bn += 1; |
| 244 | if (block_nr) |
| 245 | *block_nr = bn; |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 246 | } |
| 247 | |
Jacob Erlbeck | cef20ae | 2015-08-24 12:00:33 +0200 | [diff] [blame] | 248 | static void request_dl_rlc_block(struct gprs_rlcmac_tbf *tbf, |
Jacob Erlbeck | ee31090 | 2015-08-24 11:55:17 +0200 | [diff] [blame] | 249 | uint32_t *fn, uint8_t *block_nr = NULL) |
Jacob Erlbeck | 64921d2 | 2015-08-24 11:34:47 +0200 | [diff] [blame] | 250 | { |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 251 | request_dl_rlc_block(tbf->bts, tbf->trx->trx_no, |
Max | 878bd1f | 2016-07-20 13:05:05 +0200 | [diff] [blame] | 252 | tbf->control_ts, fn, block_nr); |
Jacob Erlbeck | 64921d2 | 2015-08-24 11:34:47 +0200 | [diff] [blame] | 253 | } |
| 254 | |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 255 | enum test_tbf_final_ack_mode { |
| 256 | TEST_MODE_STANDARD, |
| 257 | TEST_MODE_REVERSE_FREE |
| 258 | }; |
| 259 | |
Pau Espin Pedrol | afe189e | 2021-07-28 21:48:26 +0200 | [diff] [blame] | 260 | /* Receive an ACK */ |
| 261 | static void _rcv_ack(bool fin, gprs_rlcmac_dl_tbf *tbf, uint8_t *rbb) |
| 262 | { |
| 263 | gprs_rlc_dl_window *w = static_cast<gprs_rlc_dl_window *>(tbf->window()); |
| 264 | uint8_t bits_data[RLC_GPRS_WS/8]; |
| 265 | bitvec bits; |
| 266 | Ack_Nack_Description_t ack_nack; |
| 267 | int bsn_begin, bsn_end; |
| 268 | uint8_t ssn = w->v_s(); |
| 269 | |
| 270 | bits.data = bits_data; |
| 271 | bits.data_len = sizeof(bits_data); |
| 272 | bits.cur_bit = 0; |
| 273 | ack_nack.FINAL_ACK_INDICATION = fin; |
| 274 | ack_nack.STARTING_SEQUENCE_NUMBER = ssn; |
| 275 | memcpy(ack_nack.RECEIVED_BLOCK_BITMAP, rbb, RLC_GPRS_WS/8); |
| 276 | |
| 277 | Decoding::decode_gprs_acknack_bits( |
| 278 | &ack_nack, &bits, |
| 279 | &bsn_begin, &bsn_end, w); |
| 280 | |
| 281 | tbf->rcvd_dl_ack(fin, bsn_begin, &bits); |
| 282 | if (!fin) |
| 283 | OSMO_ASSERT(w->window_empty()); |
| 284 | } |
| 285 | |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 286 | static void test_tbf_final_ack(enum test_tbf_final_ack_mode test_mode) |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 287 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 288 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 289 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 290 | uint8_t ts_no = 4; |
| 291 | unsigned i; |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 292 | uint8_t ms_class = 45; |
| 293 | uint32_t fn; |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 294 | uint8_t block_nr; |
Jacob Erlbeck | a3e4509 | 2015-03-25 09:11:24 +0100 | [diff] [blame] | 295 | uint8_t trx_no; |
Jacob Erlbeck | d3eac28 | 2015-05-22 15:47:55 +0200 | [diff] [blame] | 296 | GprsMs *ms; |
Jacob Erlbeck | 1c68aba | 2015-05-22 15:40:08 +0200 | [diff] [blame] | 297 | uint32_t tlli = 0xffeeddcc; |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 298 | |
| 299 | uint8_t rbb[64/8]; |
| 300 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 301 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | 53efa3e | 2016-01-11 16:12:01 +0100 | [diff] [blame] | 302 | |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 303 | gprs_rlcmac_dl_tbf *dl_tbf; |
| 304 | gprs_rlcmac_tbf *new_tbf; |
| 305 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 306 | setup_bts(bts, ts_no); |
| 307 | dl_tbf = create_dl_tbf(bts, ms_class, 0, &trx_no); |
Pau Espin Pedrol | 8abe13c | 2022-10-21 18:49:48 +0200 | [diff] [blame] | 308 | ms_confirm_tlli(dl_tbf->ms(), tlli); |
Jacob Erlbeck | d3eac28 | 2015-05-22 15:47:55 +0200 | [diff] [blame] | 309 | ms = dl_tbf->ms(); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 310 | |
| 311 | for (i = 0; i < sizeof(llc_data); i++) |
| 312 | llc_data[i] = i%256; |
| 313 | |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 314 | /* Schedule two LLC frames */ |
Pau Espin Pedrol | 14beef6 | 2022-10-26 19:44:07 +0200 | [diff] [blame] | 315 | ms_append_llc_dl_data(dl_tbf->ms(), 1000, llc_data, sizeof(llc_data)); |
| 316 | ms_append_llc_dl_data(dl_tbf->ms(), 1000, llc_data, sizeof(llc_data)); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 317 | |
| 318 | |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 319 | /* Send only a few RLC/MAC blocks */ |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 320 | fn = 0; |
Jacob Erlbeck | ee31090 | 2015-08-24 11:55:17 +0200 | [diff] [blame] | 321 | do { |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 322 | /* Request to send one block */ |
Jacob Erlbeck | cef20ae | 2015-08-24 12:00:33 +0200 | [diff] [blame] | 323 | request_dl_rlc_block(dl_tbf, &fn, &block_nr); |
Jacob Erlbeck | ee31090 | 2015-08-24 11:55:17 +0200 | [diff] [blame] | 324 | } while (block_nr < 3); |
Jacob Erlbeck | 64921d2 | 2015-08-24 11:34:47 +0200 | [diff] [blame] | 325 | |
Jacob Erlbeck | 2493c66 | 2015-03-25 10:05:34 +0100 | [diff] [blame] | 326 | OSMO_ASSERT(dl_tbf->have_data()); |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 327 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_FLOW)); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 328 | |
| 329 | /* Queue a final ACK */ |
| 330 | memset(rbb, 0, sizeof(rbb)); |
| 331 | /* Receive a final ACK */ |
Pau Espin Pedrol | afe189e | 2021-07-28 21:48:26 +0200 | [diff] [blame] | 332 | _rcv_ack(true, dl_tbf, rbb); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 333 | |
| 334 | /* Clean up and ensure tbfs are in the correct state */ |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 335 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_WAIT_RELEASE)); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 336 | new_tbf = ms_dl_tbf(ms); |
Jacob Erlbeck | 08fe76a | 2015-02-23 15:10:20 +0100 | [diff] [blame] | 337 | check_tbf(new_tbf); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 338 | OSMO_ASSERT(new_tbf != dl_tbf); |
| 339 | OSMO_ASSERT(new_tbf->tfi() == 1); |
Jacob Erlbeck | 08fe76a | 2015-02-23 15:10:20 +0100 | [diff] [blame] | 340 | check_tbf(dl_tbf); |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 341 | if (test_mode == TEST_MODE_REVERSE_FREE) { |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 342 | ms_ref(ms); |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 343 | tbf_free(new_tbf); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 344 | OSMO_ASSERT(ms_dl_tbf(ms) == NULL); |
Jacob Erlbeck | 08fe76a | 2015-02-23 15:10:20 +0100 | [diff] [blame] | 345 | check_tbf(dl_tbf); |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 346 | tbf_free(dl_tbf); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 347 | ms_unref(ms); |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 348 | } else { |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 349 | ms_ref(ms); |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 350 | tbf_free(dl_tbf); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 351 | OSMO_ASSERT(ms_dl_tbf(ms) == new_tbf); |
Jacob Erlbeck | 08fe76a | 2015-02-23 15:10:20 +0100 | [diff] [blame] | 352 | check_tbf(new_tbf); |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 353 | tbf_free(new_tbf); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 354 | OSMO_ASSERT(ms_dl_tbf(ms) == NULL); |
| 355 | ms_unref(ms); |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 356 | } |
Jacob Erlbeck | 53efa3e | 2016-01-11 16:12:01 +0100 | [diff] [blame] | 357 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 358 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 359 | fprintf(stderr, "=== end %s ===\n", __func__); |
Daniel Willmann | 510d7d3 | 2014-08-15 18:19:41 +0200 | [diff] [blame] | 360 | } |
| 361 | |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 362 | static void test_tbf_delayed_release() |
| 363 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 364 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 365 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 366 | uint8_t ts_no = 4; |
| 367 | unsigned i; |
| 368 | uint8_t ms_class = 45; |
| 369 | uint32_t fn = 0; |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 370 | uint8_t trx_no; |
Jacob Erlbeck | 1c68aba | 2015-05-22 15:40:08 +0200 | [diff] [blame] | 371 | uint32_t tlli = 0xffeeddcc; |
Pau Espin Pedrol | 2b5c629 | 2019-09-09 13:41:00 +0200 | [diff] [blame] | 372 | unsigned long dl_tbf_idle_msec; |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 373 | |
| 374 | uint8_t rbb[64/8]; |
| 375 | |
| 376 | gprs_rlcmac_dl_tbf *dl_tbf; |
| 377 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 378 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 379 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 380 | setup_bts(bts, ts_no); |
Pau Espin Pedrol | 924aaad | 2021-01-14 12:01:42 +0100 | [diff] [blame] | 381 | OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2031, 200, OSMO_TDEF_MS) == 0); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 382 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 383 | dl_tbf = create_dl_tbf(bts, ms_class, 0, &trx_no); |
Pau Espin Pedrol | 8abe13c | 2022-10-21 18:49:48 +0200 | [diff] [blame] | 384 | ms_confirm_tlli(dl_tbf->ms(), tlli); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 385 | |
| 386 | for (i = 0; i < sizeof(llc_data); i++) |
| 387 | llc_data[i] = i%256; |
| 388 | |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 389 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_FLOW)); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 390 | |
| 391 | /* Schedule two LLC frames */ |
Pau Espin Pedrol | 14beef6 | 2022-10-26 19:44:07 +0200 | [diff] [blame] | 392 | ms_append_llc_dl_data(dl_tbf->ms(), 1000, llc_data, sizeof(llc_data)); |
| 393 | ms_append_llc_dl_data(dl_tbf->ms(), 1000, llc_data, sizeof(llc_data)); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 394 | |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 395 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_FLOW)); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 396 | |
| 397 | /* Drain the queue */ |
| 398 | while (dl_tbf->have_data()) |
| 399 | /* Request to send one RLC/MAC block */ |
Jacob Erlbeck | cef20ae | 2015-08-24 12:00:33 +0200 | [diff] [blame] | 400 | request_dl_rlc_block(dl_tbf, &fn); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 401 | |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 402 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_FLOW)); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 403 | |
| 404 | /* ACK all blocks */ |
| 405 | memset(rbb, 0xff, sizeof(rbb)); |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 406 | |
Pau Espin Pedrol | afe189e | 2021-07-28 21:48:26 +0200 | [diff] [blame] | 407 | _rcv_ack(false, dl_tbf, rbb); /* Receive an ACK */ |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 408 | |
| 409 | /* Force sending of a single block containing an LLC dummy command */ |
Jacob Erlbeck | cef20ae | 2015-08-24 12:00:33 +0200 | [diff] [blame] | 410 | request_dl_rlc_block(dl_tbf, &fn); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 411 | |
Pau Espin Pedrol | afe189e | 2021-07-28 21:48:26 +0200 | [diff] [blame] | 412 | _rcv_ack(false, dl_tbf, rbb); /* Receive an ACK */ |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 413 | |
| 414 | /* Timeout (make sure fn % 52 remains valid) */ |
Pau Espin Pedrol | 924aaad | 2021-01-14 12:01:42 +0100 | [diff] [blame] | 415 | dl_tbf_idle_msec = osmo_tdef_get(the_pcu->T_defs, -2031, OSMO_TDEF_MS, -1); |
Pau Espin Pedrol | 2b5c629 | 2019-09-09 13:41:00 +0200 | [diff] [blame] | 416 | fn += 52 * ((msecs_to_frames(dl_tbf_idle_msec + 100) + 51)/ 52); |
Jacob Erlbeck | cef20ae | 2015-08-24 12:00:33 +0200 | [diff] [blame] | 417 | request_dl_rlc_block(dl_tbf, &fn); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 418 | |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 419 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_FINISHED)); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 420 | |
Pau Espin Pedrol | afe189e | 2021-07-28 21:48:26 +0200 | [diff] [blame] | 421 | _rcv_ack(true, dl_tbf, rbb); /* Receive a final ACK */ |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 422 | |
| 423 | /* Clean up and ensure tbfs are in the correct state */ |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 424 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_WAIT_RELEASE)); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 425 | check_tbf(dl_tbf); |
| 426 | tbf_free(dl_tbf); |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 427 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 428 | fprintf(stderr, "=== end %s ===\n", __func__); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 429 | } |
| 430 | |
Jacob Erlbeck | b0e5eaf | 2015-05-21 11:07:16 +0200 | [diff] [blame] | 431 | static void test_tbf_imsi() |
| 432 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 433 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 434 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Jacob Erlbeck | b0e5eaf | 2015-05-21 11:07:16 +0200 | [diff] [blame] | 435 | uint8_t ts_no = 4; |
| 436 | uint8_t ms_class = 45; |
| 437 | uint8_t trx_no; |
| 438 | GprsMs *ms1, *ms2; |
| 439 | |
| 440 | gprs_rlcmac_dl_tbf *dl_tbf[2]; |
| 441 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 442 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | b0e5eaf | 2015-05-21 11:07:16 +0200 | [diff] [blame] | 443 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 444 | setup_bts(bts, ts_no); |
Jacob Erlbeck | b0e5eaf | 2015-05-21 11:07:16 +0200 | [diff] [blame] | 445 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 446 | dl_tbf[0] = create_dl_tbf(bts, ms_class, 0, &trx_no); |
| 447 | dl_tbf[1] = create_dl_tbf(bts, ms_class, 0, &trx_no); |
Jacob Erlbeck | b0e5eaf | 2015-05-21 11:07:16 +0200 | [diff] [blame] | 448 | |
Pau Espin Pedrol | 8abe13c | 2022-10-21 18:49:48 +0200 | [diff] [blame] | 449 | ms_confirm_tlli(dl_tbf[0]->ms(), 0xf1000001); |
| 450 | ms_confirm_tlli(dl_tbf[1]->ms(), 0xf1000002); |
Jacob Erlbeck | b0e5eaf | 2015-05-21 11:07:16 +0200 | [diff] [blame] | 451 | |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 452 | ms_set_imsi(dl_tbf[0]->ms(), "001001000000001"); |
Pau Espin Pedrol | 7f360e7 | 2022-10-21 14:30:36 +0200 | [diff] [blame] | 453 | ms1 = bts_ms_store(bts)->get_ms(GSM_RESERVED_TMSI, GSM_RESERVED_TMSI, "001001000000001"); |
Jacob Erlbeck | 7b9f825 | 2015-05-21 11:07:53 +0200 | [diff] [blame] | 454 | OSMO_ASSERT(ms1 != NULL); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 455 | ms2 = bts_ms_store(bts)->get_ms(0xf1000001); |
Jacob Erlbeck | b0e5eaf | 2015-05-21 11:07:16 +0200 | [diff] [blame] | 456 | OSMO_ASSERT(ms2 != NULL); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 457 | OSMO_ASSERT(strcmp(ms_imsi(ms2), "001001000000001") == 0); |
Jacob Erlbeck | 7b9f825 | 2015-05-21 11:07:53 +0200 | [diff] [blame] | 458 | OSMO_ASSERT(ms1 == ms2); |
Jacob Erlbeck | b0e5eaf | 2015-05-21 11:07:16 +0200 | [diff] [blame] | 459 | |
| 460 | /* change the IMSI on TBF 0 */ |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 461 | ms_set_imsi(dl_tbf[0]->ms(), "001001000000002"); |
Pau Espin Pedrol | 7f360e7 | 2022-10-21 14:30:36 +0200 | [diff] [blame] | 462 | ms1 = bts_ms_store(bts)->get_ms(GSM_RESERVED_TMSI, GSM_RESERVED_TMSI, "001001000000001"); |
Jacob Erlbeck | b0e5eaf | 2015-05-21 11:07:16 +0200 | [diff] [blame] | 463 | OSMO_ASSERT(ms1 == NULL); |
Pau Espin Pedrol | 7f360e7 | 2022-10-21 14:30:36 +0200 | [diff] [blame] | 464 | ms1 = bts_ms_store(bts)->get_ms(GSM_RESERVED_TMSI, GSM_RESERVED_TMSI, "001001000000002"); |
Jacob Erlbeck | 7b9f825 | 2015-05-21 11:07:53 +0200 | [diff] [blame] | 465 | OSMO_ASSERT(ms1 != NULL); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 466 | OSMO_ASSERT(strcmp(ms_imsi(ms2), "001001000000002") == 0); |
Jacob Erlbeck | 7b9f825 | 2015-05-21 11:07:53 +0200 | [diff] [blame] | 467 | OSMO_ASSERT(ms1 == ms2); |
Jacob Erlbeck | b0e5eaf | 2015-05-21 11:07:16 +0200 | [diff] [blame] | 468 | |
Pau Espin Pedrol | 528820d | 2020-10-26 12:40:11 +0100 | [diff] [blame] | 469 | /* use the same IMSI on TBF 1 */ |
Jacob Erlbeck | 28c40b1 | 2015-08-16 18:19:32 +0200 | [diff] [blame] | 470 | { |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 471 | ms_ref(ms2); |
| 472 | ms_set_imsi(dl_tbf[1]->ms(), "001001000000002"); |
Pau Espin Pedrol | 7f360e7 | 2022-10-21 14:30:36 +0200 | [diff] [blame] | 473 | ms1 = bts_ms_store(bts)->get_ms(GSM_RESERVED_TMSI, GSM_RESERVED_TMSI, "001001000000002"); |
Jacob Erlbeck | 28c40b1 | 2015-08-16 18:19:32 +0200 | [diff] [blame] | 474 | OSMO_ASSERT(ms1 != NULL); |
| 475 | OSMO_ASSERT(ms1 != ms2); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 476 | OSMO_ASSERT(strcmp(ms_imsi(ms1), "001001000000002") == 0); |
| 477 | OSMO_ASSERT(strcmp(ms_imsi(ms2), "") == 0); |
| 478 | ms_unref(ms2); |
Jacob Erlbeck | 28c40b1 | 2015-08-16 18:19:32 +0200 | [diff] [blame] | 479 | } |
| 480 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 481 | ms2 = bts_ms_store(bts)->get_ms(0xf1000001); |
Jacob Erlbeck | 28c40b1 | 2015-08-16 18:19:32 +0200 | [diff] [blame] | 482 | OSMO_ASSERT(ms2 == NULL); |
Jacob Erlbeck | b0e5eaf | 2015-05-21 11:07:16 +0200 | [diff] [blame] | 483 | |
| 484 | tbf_free(dl_tbf[1]); |
Pau Espin Pedrol | 7f360e7 | 2022-10-21 14:30:36 +0200 | [diff] [blame] | 485 | ms1 = bts_ms_store(bts)->get_ms(GSM_RESERVED_TMSI, GSM_RESERVED_TMSI, "001001000000002"); |
Jacob Erlbeck | b0e5eaf | 2015-05-21 11:07:16 +0200 | [diff] [blame] | 486 | OSMO_ASSERT(ms1 == NULL); |
| 487 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 488 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 489 | fprintf(stderr, "=== end %s ===\n", __func__); |
Jacob Erlbeck | b0e5eaf | 2015-05-21 11:07:16 +0200 | [diff] [blame] | 490 | } |
| 491 | |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 492 | static void test_tbf_exhaustion() |
| 493 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 494 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 495 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 496 | unsigned i; |
| 497 | uint8_t ts_no = 4; |
| 498 | uint8_t ms_class = 45; |
| 499 | int rc = 0; |
| 500 | |
| 501 | uint8_t buf[256] = {0}; |
| 502 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 503 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 504 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 505 | bts->pcu->nsi = gprs_ns2_instantiate(tall_pcu_ctx, gprs_ns_prim_cb, NULL); |
| 506 | if (!bts->pcu->nsi) { |
Alexander Couzens | 5c3783b | 2019-05-25 05:41:18 +0200 | [diff] [blame] | 507 | LOGP(DBSSGP, LOGL_ERROR, "Failed to create NS instance\n"); |
| 508 | abort(); |
| 509 | } |
| 510 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 511 | setup_bts(bts, ts_no); |
Alexander Couzens | 290d903 | 2020-09-16 21:52:02 +0200 | [diff] [blame] | 512 | gprs_bssgp_init(bts, 1234, 1234, 1, 1, false, 0, 0, 0); |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 513 | |
| 514 | for (i = 0; i < 1024; i++) { |
| 515 | uint32_t tlli = 0xc0000000 + i; |
| 516 | char imsi[16] = {0}; |
| 517 | unsigned delay_csec = 1000; |
| 518 | |
Jacob Erlbeck | 9a2845d | 2015-05-21 12:06:58 +0200 | [diff] [blame] | 519 | snprintf(imsi, sizeof(imsi), "001001%09d", i); |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 520 | |
Pau Espin Pedrol | 8a35e64 | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 521 | rc = dl_tbf_handle(bts, tlli, 0, imsi, ms_class, 0, |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 522 | delay_csec, buf, sizeof(buf)); |
| 523 | |
| 524 | if (rc < 0) |
| 525 | break; |
| 526 | } |
| 527 | |
| 528 | OSMO_ASSERT(rc == -EBUSY); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 529 | fprintf(stderr, "=== end %s ===\n", __func__); |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 530 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 531 | TALLOC_FREE(the_pcu); |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 532 | } |
| 533 | |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 534 | static void test_tbf_dl_llc_loss() |
| 535 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 536 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 537 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 538 | uint8_t ts_no = 4; |
| 539 | uint8_t ms_class = 45; |
| 540 | int rc = 0; |
| 541 | uint32_t tlli = 0xc0123456; |
| 542 | const char *imsi = "001001000123456"; |
| 543 | unsigned delay_csec = 1000; |
| 544 | GprsMs *ms; |
| 545 | |
| 546 | uint8_t buf[19]; |
| 547 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 548 | bts->pcu->nsi = gprs_ns2_instantiate(tall_pcu_ctx, gprs_ns_prim_cb, NULL); |
| 549 | if (!bts->pcu->nsi) { |
Alexander Couzens | 5c3783b | 2019-05-25 05:41:18 +0200 | [diff] [blame] | 550 | LOGP(DBSSGP, LOGL_ERROR, "Failed to create NS instance\n"); |
| 551 | abort(); |
| 552 | } |
| 553 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 554 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 555 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 556 | setup_bts(bts, ts_no); |
Pau Espin Pedrol | 63700ea | 2019-09-09 13:19:06 +0200 | [diff] [blame] | 557 | /* keep the MS object 10 seconds */ |
Pau Espin Pedrol | 924aaad | 2021-01-14 12:01:42 +0100 | [diff] [blame] | 558 | OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2030, 10, OSMO_TDEF_S) == 0); |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 559 | |
Alexander Couzens | 290d903 | 2020-09-16 21:52:02 +0200 | [diff] [blame] | 560 | gprs_bssgp_init(bts, 2234, 2234, 1, 1, false, 0, 0, 0); |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 561 | |
| 562 | /* Handle LLC frame 1 */ |
| 563 | memset(buf, 1, sizeof(buf)); |
Pau Espin Pedrol | 8a35e64 | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 564 | rc = dl_tbf_handle(bts, tlli, 0, imsi, ms_class, 0, |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 565 | delay_csec, buf, sizeof(buf)); |
| 566 | OSMO_ASSERT(rc >= 0); |
| 567 | |
Pau Espin Pedrol | 7f360e7 | 2022-10-21 14:30:36 +0200 | [diff] [blame] | 568 | ms = bts_ms_store(bts)->get_ms(GSM_RESERVED_TMSI, GSM_RESERVED_TMSI, imsi); |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 569 | OSMO_ASSERT(ms != NULL); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 570 | OSMO_ASSERT(ms_dl_tbf(ms) != NULL); |
| 571 | ms_dl_tbf(ms)->set_ta(0); |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 572 | |
| 573 | /* Handle LLC frame 2 */ |
| 574 | memset(buf, 2, sizeof(buf)); |
Pau Espin Pedrol | 8a35e64 | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 575 | rc = dl_tbf_handle(bts, tlli, 0, imsi, ms_class, 0, |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 576 | delay_csec, buf, sizeof(buf)); |
| 577 | OSMO_ASSERT(rc >= 0); |
| 578 | |
| 579 | /* TBF establishment fails (timeout) */ |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 580 | tbf_free(ms_dl_tbf(ms)); |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 581 | |
| 582 | /* Handle LLC frame 3 */ |
| 583 | memset(buf, 3, sizeof(buf)); |
Pau Espin Pedrol | 8a35e64 | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 584 | rc = dl_tbf_handle(bts, tlli, 0, imsi, ms_class, 0, |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 585 | delay_csec, buf, sizeof(buf)); |
| 586 | OSMO_ASSERT(rc >= 0); |
| 587 | |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 588 | OSMO_ASSERT(ms_dl_tbf(ms) != NULL); |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 589 | |
Pau Espin Pedrol | 65bba93 | 2021-07-26 12:06:20 +0200 | [diff] [blame] | 590 | /* Here PCU would answer with data_cnf and trigger |
Pau Espin Pedrol | 3225290 | 2021-07-29 16:44:11 +0200 | [diff] [blame] | 591 | * bts_rcv_imm_ass_cnf(), which would trigger TBF_EV_ASSIGN_PCUIF_CNF. |
| 592 | * That in turn would set up timer X2002. Finally, X2002 timeout |
| 593 | * moves it to FLOW state. We set X2002 timeout to 0 here to get |
| 594 | * immediate trigger through osmo_select_main() */ |
| 595 | OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2002, 0, OSMO_TDEF_MS) == 0); |
Pau Espin Pedrol | f197f15 | 2022-11-17 20:18:46 +0100 | [diff] [blame] | 596 | osmo_fsm_inst_dispatch(ms_dl_tbf(ms)->state_fi, TBF_EV_ASSIGN_PCUIF_CNF, NULL); |
Pau Espin Pedrol | 3225290 | 2021-07-29 16:44:11 +0200 | [diff] [blame] | 597 | osmo_select_main(0); |
Pau Espin Pedrol | 65bba93 | 2021-07-26 12:06:20 +0200 | [diff] [blame] | 598 | OSMO_ASSERT(ms_dl_tbf(ms)->state_is(TBF_ST_FLOW)); |
| 599 | |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 600 | /* Get first BSN */ |
| 601 | struct msgb *msg; |
| 602 | int fn = 0; |
| 603 | uint8_t expected_data = 1; |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 604 | static uint8_t exp[][GSM_MACBLOCK_LEN] = { |
| 605 | { 0x07, 0x00, 0x00, 0x4d, 0x01, 0x01, 0x01, |
| 606 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, |
| 607 | { 0x07, 0x00, 0x02, 0x4d, 0x02, 0x02, 0x02, |
| 608 | 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }, |
| 609 | { 0x07, 0x01, 0x04, 0x4d, 0x03, 0x03, 0x03, |
| 610 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }, |
| 611 | }; |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 612 | |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 613 | while (ms_dl_tbf(ms)->have_data()) { |
| 614 | msg = ms_dl_tbf(ms)->create_dl_acked_block(fn += 4, 7); |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 615 | fprintf(stderr, "MSG = %s\n", msgb_hexdump(msg)); |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 616 | if (!msgb_eq_data_print(msg, exp[expected_data - 1], GSM_MACBLOCK_LEN)) |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 617 | fprintf(stderr, "%s failed at %u\n", __func__, expected_data); |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 618 | |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 619 | expected_data += 1; |
| 620 | } |
Jacob Erlbeck | 409efa1 | 2015-06-12 14:06:09 +0200 | [diff] [blame] | 621 | OSMO_ASSERT(expected_data-1 == 3); |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 622 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 623 | fprintf(stderr, "=== end %s ===\n", __func__); |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 624 | |
Pau Espin Pedrol | 52e2c08 | 2022-05-09 17:12:53 +0200 | [diff] [blame] | 625 | /* Restore MS release timeout to 0 to make sure it is freed immediately: */ |
| 626 | ms_set_timeout(ms, 0); |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 627 | TALLOC_FREE(the_pcu); |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 628 | } |
| 629 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 630 | static gprs_rlcmac_ul_tbf *establish_ul_tbf_single_phase(struct gprs_rlcmac_bts *bts, |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 631 | uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta) |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 632 | { |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 633 | GprsMs *ms; |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 634 | int tfi = 0; |
| 635 | gprs_rlcmac_ul_tbf *ul_tbf; |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 636 | uint8_t trx_no = 0; |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 637 | struct gprs_rlcmac_pdch *pdch; |
| 638 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 639 | tfi = bts_tfi_find_free(bts, GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 640 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 641 | bts_handle_rach(bts, 0x03, *fn, qta); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 642 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 643 | ul_tbf = bts_ul_tbf_by_tfi(bts, tfi, trx_no, ts_no); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 644 | OSMO_ASSERT(ul_tbf != NULL); |
| 645 | |
Jacob Erlbeck | 9200ce6 | 2015-05-22 17:48:04 +0200 | [diff] [blame] | 646 | OSMO_ASSERT(ul_tbf->ta() == qta / 4); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 647 | |
| 648 | uint8_t data_msg[23] = { |
| 649 | 0x00, /* GPRS_RLCMAC_DATA_BLOCK << 6 */ |
| 650 | uint8_t(1 | (tfi << 2)), |
| 651 | uint8_t(1), /* BSN:7, E:1 */ |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 652 | uint8_t(tlli >> 24), uint8_t(tlli >> 16), |
| 653 | uint8_t(tlli >> 8), uint8_t(tlli), /* TLLI */ |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 654 | }; |
| 655 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 656 | pdch = &bts->trx[trx_no].pdch[ts_no]; |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 657 | pdch->rcv_block(&data_msg[0], sizeof(data_msg), *fn, &meas); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 658 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 659 | ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 660 | OSMO_ASSERT(ms != NULL); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 661 | |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 662 | return ul_tbf; |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 663 | } |
| 664 | |
Pau Espin Pedrol | 99360a3 | 2021-03-09 17:18:12 +0100 | [diff] [blame] | 665 | static void send_ul_mac_block_buf(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_pdch *pdch, |
| 666 | unsigned fn, uint8_t *buf, int num_bytes) |
| 667 | { |
Pau Espin Pedrol | fecab50 | 2021-03-17 15:26:37 +0100 | [diff] [blame] | 668 | bts_set_current_block_frame_number(bts, fn); |
Pau Espin Pedrol | 99360a3 | 2021-03-09 17:18:12 +0100 | [diff] [blame] | 669 | pdch->rcv_block(buf, num_bytes, fn, &meas); |
| 670 | pdch_ulc_expire_fn(pdch->ulc, fn); |
| 671 | } |
| 672 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 673 | static void send_ul_mac_block(struct gprs_rlcmac_bts *bts, unsigned trx_no, unsigned ts_no, |
Jacob Erlbeck | 56f99d1 | 2015-08-20 15:55:56 +0200 | [diff] [blame] | 674 | RlcMacUplink_t *ulreq, unsigned fn) |
| 675 | { |
| 676 | bitvec *rlc_block; |
| 677 | uint8_t buf[64]; |
| 678 | int num_bytes; |
| 679 | struct gprs_rlcmac_pdch *pdch; |
Jacob Erlbeck | 56f99d1 | 2015-08-20 15:55:56 +0200 | [diff] [blame] | 680 | |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 681 | rlc_block = bitvec_alloc(23, tall_pcu_ctx); |
Jacob Erlbeck | 56f99d1 | 2015-08-20 15:55:56 +0200 | [diff] [blame] | 682 | |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 683 | OSMO_ASSERT(encode_gsm_rlcmac_uplink(rlc_block, ulreq) == 0); |
Jacob Erlbeck | 56f99d1 | 2015-08-20 15:55:56 +0200 | [diff] [blame] | 684 | num_bytes = bitvec_pack(rlc_block, &buf[0]); |
| 685 | OSMO_ASSERT(size_t(num_bytes) < sizeof(buf)); |
| 686 | bitvec_free(rlc_block); |
| 687 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 688 | pdch = &bts->trx[trx_no].pdch[ts_no]; |
Pau Espin Pedrol | 99360a3 | 2021-03-09 17:18:12 +0100 | [diff] [blame] | 689 | send_ul_mac_block_buf(bts, pdch, fn, &buf[0], num_bytes); |
Jacob Erlbeck | 56f99d1 | 2015-08-20 15:55:56 +0200 | [diff] [blame] | 690 | } |
| 691 | |
Pau Espin Pedrol | 58046e4 | 2021-03-29 19:01:13 +0200 | [diff] [blame] | 692 | |
| 693 | static uint32_t get_poll_fn(struct gprs_rlcmac_tbf *tbf, uint8_t poll_ts) |
| 694 | { |
| 695 | struct gprs_rlcmac_pdch *pdch = &tbf->trx->pdch[poll_ts]; |
| 696 | struct pdch_ulc *ulc = pdch->ulc; |
| 697 | struct rb_node *node; |
| 698 | struct pdch_ulc_node *item; |
| 699 | |
| 700 | for (node = rb_first(&ulc->tree_root); node; node = rb_next(node)) { |
| 701 | item = container_of(node, struct pdch_ulc_node, node); |
| 702 | if (item->type == PDCH_ULC_NODE_TBF_POLL && item->tbf_poll.poll_tbf == tbf) |
| 703 | return item->fn; |
| 704 | } |
| 705 | OSMO_ASSERT(0); |
| 706 | } |
| 707 | |
Jacob Erlbeck | af45473 | 2015-08-21 15:03:23 +0200 | [diff] [blame] | 708 | static void send_control_ack(gprs_rlcmac_tbf *tbf) |
| 709 | { |
| 710 | RlcMacUplink_t ulreq = {0}; |
| 711 | |
Jacob Erlbeck | af45473 | 2015-08-21 15:03:23 +0200 | [diff] [blame] | 712 | ulreq.u.MESSAGE_TYPE = MT_PACKET_CONTROL_ACK; |
| 713 | Packet_Control_Acknowledgement_t *ctrl_ack = |
| 714 | &ulreq.u.Packet_Control_Acknowledgement; |
| 715 | |
| 716 | ctrl_ack->PayloadType = GPRS_RLCMAC_CONTROL_BLOCK; |
| 717 | ctrl_ack->TLLI = tbf->tlli(); |
Pau Espin Pedrol | 16e1678 | 2021-03-29 19:10:19 +0200 | [diff] [blame] | 718 | send_ul_mac_block(tbf->bts, tbf->trx->trx_no, tbf->control_ts, |
| 719 | &ulreq, get_poll_fn(tbf, tbf->control_ts)); |
Jacob Erlbeck | af45473 | 2015-08-21 15:03:23 +0200 | [diff] [blame] | 720 | } |
| 721 | |
Pau Espin Pedrol | 99360a3 | 2021-03-09 17:18:12 +0100 | [diff] [blame] | 722 | static void send_empty_block(gprs_rlcmac_tbf *tbf, unsigned ts_no, unsigned fn) |
| 723 | { |
| 724 | struct gprs_rlcmac_pdch *pdch; |
| 725 | pdch = &tbf->bts->trx[tbf->trx->trx_no].pdch[ts_no]; |
| 726 | send_ul_mac_block_buf(tbf->bts, pdch, fn, NULL, 0); |
| 727 | } |
| 728 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 729 | static gprs_rlcmac_ul_tbf *puan_urbb_len_issue(struct gprs_rlcmac_bts *bts, |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 730 | uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta, |
| 731 | uint8_t ms_class, uint8_t egprs_ms_class) |
| 732 | { |
| 733 | GprsMs *ms; |
| 734 | uint32_t rach_fn = *fn - 51; |
| 735 | uint32_t sba_fn = *fn + 52; |
| 736 | uint8_t trx_no = 0; |
Neels Hofmeyr | d34646a | 2017-02-08 17:07:40 +0100 | [diff] [blame] | 737 | int tfi = 0; |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 738 | gprs_rlcmac_ul_tbf *ul_tbf; |
| 739 | struct gprs_rlcmac_pdch *pdch; |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 740 | RlcMacUplink_t ulreq = {0}; |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 741 | struct gprs_rlc_ul_header_egprs_3 *egprs3 = NULL; |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 742 | |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 743 | /* needed to set last_rts_fn in the PDCH object */ |
| 744 | request_dl_rlc_block(bts, trx_no, ts_no, fn); |
| 745 | |
| 746 | /* |
| 747 | * simulate RACH, this sends an Immediate |
| 748 | * Assignment Uplink on the AGCH |
| 749 | */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 750 | bts_handle_rach(bts, 0x73, rach_fn, qta); |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 751 | |
| 752 | /* get next free TFI */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 753 | tfi = bts_tfi_find_free(bts, GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 754 | |
| 755 | /* fake a resource request */ |
| 756 | ulreq.u.MESSAGE_TYPE = MT_PACKET_RESOURCE_REQUEST; |
| 757 | ulreq.u.Packet_Resource_Request.PayloadType = GPRS_RLCMAC_CONTROL_BLOCK; |
| 758 | ulreq.u.Packet_Resource_Request.ID.UnionType = 1; /* != 0 */ |
| 759 | ulreq.u.Packet_Resource_Request.ID.u.TLLI = tlli; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 760 | ulreq.u.Packet_Resource_Request.Exist_MS_Radio_Access_capability2 = 1; |
| 761 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 762 | Count_MS_RA_capability_value = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 763 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 764 | MS_RA_capability_value[0].u.Content. |
| 765 | Exist_Multislot_capability = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 766 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 767 | MS_RA_capability_value[0].u.Content.Multislot_capability. |
| 768 | Exist_GPRS_multislot_class = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 769 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 770 | MS_RA_capability_value[0].u.Content.Multislot_capability. |
| 771 | GPRS_multislot_class = ms_class; |
| 772 | if (egprs_ms_class) { |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 773 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 774 | MS_RA_capability_value[0].u.Content. |
| 775 | Multislot_capability.Exist_EGPRS_multislot_class = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 776 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 777 | MS_RA_capability_value[0].u.Content. |
| 778 | Multislot_capability.EGPRS_multislot_class = ms_class; |
| 779 | } |
| 780 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 781 | send_ul_mac_block(bts, trx_no, ts_no, &ulreq, sba_fn); |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 782 | |
| 783 | /* check the TBF */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 784 | ul_tbf = bts_ul_tbf_by_tfi(bts, tfi, trx_no, ts_no); |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 785 | OSMO_ASSERT(ul_tbf); |
| 786 | OSMO_ASSERT(ul_tbf->ta() == qta / 4); |
| 787 | |
| 788 | /* send packet uplink assignment */ |
| 789 | *fn = sba_fn; |
| 790 | request_dl_rlc_block(ul_tbf, fn); |
| 791 | |
| 792 | /* send real acknowledgement */ |
| 793 | send_control_ack(ul_tbf); |
| 794 | |
| 795 | check_tbf(ul_tbf); |
| 796 | /* send fake data */ |
| 797 | uint8_t data_msg[42] = { |
| 798 | 0xf << 2, /* GPRS_RLCMAC_DATA_BLOCK << 6, CV = 15 */ |
Neels Hofmeyr | d34646a | 2017-02-08 17:07:40 +0100 | [diff] [blame] | 799 | (uint8_t)(tfi << 1), |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 800 | 1, /* BSN:7, E:1 */ |
| 801 | }; |
| 802 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 803 | pdch = &bts->trx[trx_no].pdch[ts_no]; |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 804 | pdch->rcv_block(&data_msg[0], 23, *fn, &meas); |
| 805 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 806 | ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 807 | OSMO_ASSERT(ms != NULL); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 808 | OSMO_ASSERT(ms_ta(ms) == qta/4); |
| 809 | OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 810 | |
| 811 | /* |
| 812 | * TS 44.060, B.8.1 |
| 813 | * first seg received first, later second seg |
| 814 | */ |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 815 | egprs3 = (struct gprs_rlc_ul_header_egprs_3 *) data_msg; |
| 816 | egprs3->si = 0; |
| 817 | egprs3->r = 1; |
| 818 | egprs3->cv = 7; |
| 819 | egprs3->tfi_hi = tfi & 0x03; |
| 820 | egprs3->tfi_lo = (tfi & 0x1c) >> 2; |
| 821 | egprs3->bsn1_hi = 1; |
| 822 | egprs3->bsn1_lo = 0; |
| 823 | egprs3->cps_hi = 1; |
| 824 | data_msg[3] = 0xff; |
| 825 | egprs3->pi = 0; |
| 826 | egprs3->cps_lo = 1; |
| 827 | egprs3->rsb = 0; |
| 828 | egprs3->spb = 0; |
| 829 | egprs3->pi = 0; |
| 830 | |
| 831 | pdch->rcv_block(data_msg, 42, *fn, &meas); |
| 832 | |
Pau Espin Pedrol | ea8dbdd | 2021-07-29 18:39:16 +0200 | [diff] [blame] | 833 | osmo_fsm_inst_dispatch(ul_tbf->ul_ack_fsm.fi, TBF_UL_ACK_EV_SCHED_ACK, NULL); |
| 834 | struct msgb *msg1 = tbf_ul_ack_create_rlcmac_msg(ul_tbf, *fn, ts_no); |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 835 | |
Pau Espin Pedrol | c432e06 | 2021-05-11 13:17:31 +0200 | [diff] [blame] | 836 | static uint8_t exp1[] = { 0x40, 0x24, 0x01, 0x0b, 0x3e, 0x24, 0x46, 0x68, 0x9c, 0x70, 0x87, 0xb0, |
| 837 | 0x06, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 838 | }; |
| 839 | |
| 840 | if (!msgb_eq_data_print(msg1, exp1, GSM_MACBLOCK_LEN)) { |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 841 | fprintf(stderr, "%s test failed on 1st segment!\n", __func__); |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 842 | return NULL; |
| 843 | } |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 844 | |
| 845 | egprs3->si = 0; |
| 846 | egprs3->r = 1; |
| 847 | egprs3->cv = 7; |
| 848 | egprs3->tfi_hi = tfi & 0x03; |
| 849 | egprs3->tfi_lo = (tfi & 0x1c) >> 2; |
| 850 | egprs3->bsn1_hi = 4; |
| 851 | egprs3->bsn1_lo = 0; |
| 852 | egprs3->cps_hi = 1; |
| 853 | data_msg[3] = 0xff; |
| 854 | egprs3->pi = 0; |
| 855 | egprs3->cps_lo = 1; |
| 856 | egprs3->rsb = 0; |
| 857 | egprs3->spb = 0; |
| 858 | |
| 859 | pdch->rcv_block(data_msg, 42, *fn, &meas); |
| 860 | |
Pau Espin Pedrol | ea8dbdd | 2021-07-29 18:39:16 +0200 | [diff] [blame] | 861 | osmo_fsm_inst_dispatch(ul_tbf->ul_ack_fsm.fi, TBF_UL_ACK_EV_SCHED_ACK, NULL); |
| 862 | msg1 = tbf_ul_ack_create_rlcmac_msg(ul_tbf, *fn, ts_no); |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 863 | |
Pau Espin Pedrol | c432e06 | 2021-05-11 13:17:31 +0200 | [diff] [blame] | 864 | static uint8_t exp2[] = { 0x40, 0x24, 0x01, 0x0b, 0x3e, 0x24, 0x46, 0x68, 0x9c, 0x70, 0x88, 0xb0, |
| 865 | 0x06, 0x8b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 866 | }; |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 867 | |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 868 | if (!msgb_eq_data_print(msg1, exp2, GSM_MACBLOCK_LEN)) { |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 869 | fprintf(stderr, "%s test failed on 2nd segment!\n", __func__); |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 870 | return NULL; |
| 871 | } |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 872 | return ul_tbf; |
| 873 | } |
| 874 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 875 | static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_spb(struct gprs_rlcmac_bts *bts, |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 876 | uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta, |
| 877 | uint8_t ms_class, uint8_t egprs_ms_class) |
| 878 | { |
| 879 | GprsMs *ms; |
| 880 | uint32_t rach_fn = *fn - 51; |
| 881 | uint32_t sba_fn = *fn + 52; |
| 882 | uint8_t trx_no = 0; |
| 883 | int tfi = 0, i = 0; |
| 884 | gprs_rlcmac_ul_tbf *ul_tbf; |
| 885 | struct gprs_rlcmac_pdch *pdch; |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 886 | RlcMacUplink_t ulreq = {0}; |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 887 | struct gprs_rlc_ul_header_egprs_3 *egprs3 = NULL; |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 888 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 889 | /* needed to set last_rts_fn in the PDCH object */ |
| 890 | request_dl_rlc_block(bts, trx_no, ts_no, fn); |
| 891 | |
| 892 | /* |
| 893 | * simulate RACH, this sends an Immediate |
| 894 | * Assignment Uplink on the AGCH |
| 895 | */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 896 | bts_handle_rach(bts, 0x73, rach_fn, qta); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 897 | |
| 898 | /* get next free TFI */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 899 | tfi = bts_tfi_find_free(bts, GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 900 | |
| 901 | /* fake a resource request */ |
| 902 | ulreq.u.MESSAGE_TYPE = MT_PACKET_RESOURCE_REQUEST; |
| 903 | ulreq.u.Packet_Resource_Request.PayloadType = GPRS_RLCMAC_CONTROL_BLOCK; |
| 904 | ulreq.u.Packet_Resource_Request.ID.UnionType = 1; /* != 0 */ |
| 905 | ulreq.u.Packet_Resource_Request.ID.u.TLLI = tlli; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 906 | ulreq.u.Packet_Resource_Request.Exist_MS_Radio_Access_capability2 = 1; |
| 907 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 908 | Count_MS_RA_capability_value = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 909 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 910 | MS_RA_capability_value[0].u.Content. |
| 911 | Exist_Multislot_capability = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 912 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 913 | MS_RA_capability_value[0].u.Content.Multislot_capability. |
| 914 | Exist_GPRS_multislot_class = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 915 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 916 | MS_RA_capability_value[0].u.Content.Multislot_capability. |
| 917 | GPRS_multislot_class = ms_class; |
| 918 | if (egprs_ms_class) { |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 919 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 920 | MS_RA_capability_value[0].u.Content. |
| 921 | Multislot_capability.Exist_EGPRS_multislot_class = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 922 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 923 | MS_RA_capability_value[0].u.Content. |
| 924 | Multislot_capability.EGPRS_multislot_class = ms_class; |
| 925 | } |
| 926 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 927 | send_ul_mac_block(bts, trx_no, ts_no, &ulreq, sba_fn); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 928 | |
| 929 | /* check the TBF */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 930 | ul_tbf = bts_ul_tbf_by_tfi(bts, tfi, trx_no, ts_no); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 931 | OSMO_ASSERT(ul_tbf != NULL); |
| 932 | OSMO_ASSERT(ul_tbf->ta() == qta / 4); |
| 933 | |
| 934 | /* send packet uplink assignment */ |
| 935 | *fn = sba_fn; |
| 936 | request_dl_rlc_block(ul_tbf, fn); |
| 937 | |
| 938 | /* send real acknowledgement */ |
| 939 | send_control_ack(ul_tbf); |
| 940 | |
| 941 | check_tbf(ul_tbf); |
| 942 | |
| 943 | /* send fake data */ |
| 944 | uint8_t data_msg[42] = { |
| 945 | 0x00 | 0xf << 2, /* GPRS_RLCMAC_DATA_BLOCK << 6, CV = 15 */ |
| 946 | uint8_t(0 | (tfi << 1)), |
| 947 | uint8_t(1), /* BSN:7, E:1 */ |
| 948 | }; |
| 949 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 950 | pdch = &bts->trx[trx_no].pdch[ts_no]; |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 951 | pdch->rcv_block(&data_msg[0], 23, *fn, &meas); |
| 952 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 953 | ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 954 | OSMO_ASSERT(ms != NULL); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 955 | OSMO_ASSERT(ms_ta(ms) == qta/4); |
| 956 | OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 957 | |
| 958 | /* |
| 959 | * TS 44.060, B.8.1 |
| 960 | * first seg received first, later second seg |
| 961 | */ |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 962 | egprs3 = (struct gprs_rlc_ul_header_egprs_3 *) data_msg; |
| 963 | egprs3->si = 1; |
| 964 | egprs3->r = 1; |
| 965 | egprs3->cv = 7; |
| 966 | egprs3->tfi_hi = tfi & 0x03; |
| 967 | egprs3->tfi_lo = (tfi & 0x1c) >> 2; |
| 968 | egprs3->bsn1_hi = 1; |
| 969 | egprs3->bsn1_lo = 0; |
| 970 | egprs3->cps_hi = 1; |
| 971 | data_msg[3] = 0xff; |
| 972 | egprs3->pi = 0; |
| 973 | egprs3->cps_lo = 1; |
| 974 | egprs3->rsb = 0; |
| 975 | egprs3->spb = 2; |
| 976 | egprs3->pi = 0; |
| 977 | |
| 978 | pdch->rcv_block(data_msg, 42, *fn, &meas); |
| 979 | |
| 980 | struct gprs_rlc_data *block = ul_tbf->m_rlc.block(1); |
| 981 | |
| 982 | /* check the status of the block */ |
| 983 | OSMO_ASSERT(block->spb_status.block_status_ul == |
| 984 | EGPRS_RESEG_FIRST_SEG_RXD); |
| 985 | |
| 986 | egprs3->si = 1; |
| 987 | egprs3->r = 1; |
| 988 | egprs3->cv = 7; |
| 989 | egprs3->tfi_hi = tfi & 0x03; |
| 990 | egprs3->tfi_lo = (tfi & 0x1c) >> 2; |
| 991 | egprs3->bsn1_hi = 1; |
| 992 | egprs3->bsn1_lo = 0; |
| 993 | egprs3->cps_hi = 1; |
| 994 | data_msg[3] = 0xff; |
| 995 | egprs3->pi = 0; |
| 996 | egprs3->cps_lo = 1; |
| 997 | egprs3->rsb = 0; |
| 998 | egprs3->spb = 3; |
| 999 | |
| 1000 | pdch->rcv_block(data_msg, 42, *fn, &meas); |
| 1001 | |
| 1002 | /* check the status of the block */ |
| 1003 | OSMO_ASSERT(block->spb_status.block_status_ul == |
| 1004 | EGPRS_RESEG_DEFAULT); |
| 1005 | OSMO_ASSERT(block->cs_last == |
Max | bea2edb | 2019-03-06 17:04:59 +0100 | [diff] [blame] | 1006 | MCS6); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 1007 | /* Assembled MCS is MCS6. so the size is 74 */ |
| 1008 | OSMO_ASSERT(block->len == 74); |
| 1009 | |
| 1010 | /* |
| 1011 | * TS 44.060, B.8.1 |
| 1012 | * second seg first, later first seg |
| 1013 | */ |
| 1014 | memset(data_msg, 0, sizeof(data_msg)); |
| 1015 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 1016 | egprs3 = (struct gprs_rlc_ul_header_egprs_3 *) data_msg; |
| 1017 | egprs3->si = 1; |
| 1018 | egprs3->r = 1; |
| 1019 | egprs3->cv = 7; |
| 1020 | egprs3->tfi_hi = tfi & 0x03; |
| 1021 | egprs3->tfi_lo = (tfi & 0x1c) >> 2; |
| 1022 | egprs3->bsn1_hi = 2; |
| 1023 | egprs3->bsn1_lo = 0; |
| 1024 | egprs3->cps_hi = 1; |
| 1025 | data_msg[3] = 0xff; |
| 1026 | egprs3->pi = 0; |
| 1027 | egprs3->cps_lo = 1; |
| 1028 | egprs3->rsb = 0; |
| 1029 | egprs3->spb = 3; |
| 1030 | egprs3->pi = 0; |
| 1031 | |
| 1032 | pdch->rcv_block(data_msg, 42, *fn, &meas); |
| 1033 | |
| 1034 | block = ul_tbf->m_rlc.block(2); |
| 1035 | /* check the status of the block */ |
| 1036 | OSMO_ASSERT(block->spb_status.block_status_ul == |
| 1037 | EGPRS_RESEG_SECOND_SEG_RXD); |
| 1038 | |
| 1039 | egprs3->si = 1; |
| 1040 | egprs3->r = 1; |
| 1041 | egprs3->cv = 7; |
| 1042 | egprs3->tfi_hi = tfi & 0x03; |
| 1043 | egprs3->tfi_lo = (tfi & 0x1c) >> 2; |
| 1044 | egprs3->bsn1_hi = 2; |
| 1045 | egprs3->bsn1_lo = 0; |
| 1046 | egprs3->cps_hi = 1; |
| 1047 | data_msg[3] = 0xff; |
| 1048 | egprs3->pi = 0; |
| 1049 | egprs3->cps_lo = 1; |
| 1050 | egprs3->rsb = 0; |
| 1051 | egprs3->spb = 2; |
| 1052 | egprs3->pi = 0; |
| 1053 | |
| 1054 | pdch->rcv_block(data_msg, 42, *fn, &meas); |
| 1055 | |
| 1056 | /* check the status of the block */ |
| 1057 | OSMO_ASSERT(block->spb_status.block_status_ul == |
| 1058 | EGPRS_RESEG_DEFAULT); |
| 1059 | OSMO_ASSERT(block->cs_last == |
Max | bea2edb | 2019-03-06 17:04:59 +0100 | [diff] [blame] | 1060 | MCS6); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 1061 | /* Assembled MCS is MCS6. so the size is 74 */ |
| 1062 | OSMO_ASSERT(block->len == 74); |
| 1063 | |
| 1064 | /* |
| 1065 | * TS 44.060, B.8.1 |
| 1066 | * Error scenario with spb as 1 |
| 1067 | */ |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 1068 | egprs3 = (struct gprs_rlc_ul_header_egprs_3 *) data_msg; |
| 1069 | egprs3->si = 1; |
| 1070 | egprs3->r = 1; |
| 1071 | egprs3->cv = 7; |
| 1072 | egprs3->tfi_hi = tfi & 0x03; |
| 1073 | egprs3->tfi_lo = (tfi & 0x1c) >> 2; |
| 1074 | egprs3->bsn1_hi = 3; |
| 1075 | egprs3->bsn1_lo = 0; |
| 1076 | egprs3->cps_hi = 1; |
| 1077 | data_msg[3] = 0xff; |
| 1078 | egprs3->pi = 0; |
| 1079 | egprs3->cps_lo = 1; |
| 1080 | egprs3->rsb = 0; |
| 1081 | egprs3->spb = 1; |
| 1082 | egprs3->pi = 0; |
| 1083 | |
| 1084 | pdch->rcv_block(data_msg, 42, *fn, &meas); |
| 1085 | |
| 1086 | block = ul_tbf->m_rlc.block(3); |
| 1087 | /* check the status of the block */ |
| 1088 | OSMO_ASSERT(block->spb_status.block_status_ul == |
| 1089 | EGPRS_RESEG_DEFAULT); |
| 1090 | /* |
| 1091 | * TS 44.060, B.8.1 |
| 1092 | * comparison of rlc_data for multiple scenarios |
| 1093 | * Receive First, the second(BSN 3) |
| 1094 | * Receive First, First then Second(BSN 4) |
| 1095 | * Receive Second then First(BSN 5) |
| 1096 | * after above 3 scenarios are triggered, |
| 1097 | * rlc_data of all 3 BSN are compared |
| 1098 | */ |
| 1099 | |
| 1100 | /* Initialize the data_msg */ |
| 1101 | for (i = 0; i < 42; i++) |
| 1102 | data_msg[i] = i; |
| 1103 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 1104 | egprs3 = (struct gprs_rlc_ul_header_egprs_3 *) data_msg; |
| 1105 | egprs3->si = 1; |
| 1106 | egprs3->r = 1; |
| 1107 | egprs3->cv = 7; |
| 1108 | egprs3->tfi_hi = tfi & 0x03; |
| 1109 | egprs3->tfi_lo = (tfi & 0x1c) >> 2; |
| 1110 | egprs3->bsn1_hi = 3; |
| 1111 | egprs3->bsn1_lo = 0; |
| 1112 | egprs3->cps_hi = 1; |
| 1113 | data_msg[3] = 0xff; |
| 1114 | egprs3->pi = 0; |
| 1115 | egprs3->cps_lo = 1; |
| 1116 | egprs3->rsb = 0; |
| 1117 | egprs3->spb = 2; |
| 1118 | egprs3->pi = 0; |
| 1119 | |
| 1120 | pdch->rcv_block(data_msg, 42, *fn, &meas); |
| 1121 | |
| 1122 | block = ul_tbf->m_rlc.block(3); |
| 1123 | /* check the status of the block */ |
| 1124 | OSMO_ASSERT(block->spb_status.block_status_ul == |
| 1125 | EGPRS_RESEG_FIRST_SEG_RXD); |
| 1126 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 1127 | egprs3 = (struct gprs_rlc_ul_header_egprs_3 *) data_msg; |
| 1128 | egprs3->si = 1; |
| 1129 | egprs3->r = 1; |
| 1130 | egprs3->cv = 7; |
| 1131 | egprs3->tfi_hi = tfi & 0x03; |
| 1132 | egprs3->tfi_lo = (tfi & 0x1c) >> 2; |
| 1133 | egprs3->bsn1_hi = 3; |
| 1134 | egprs3->bsn1_lo = 0; |
| 1135 | egprs3->cps_hi = 1; |
| 1136 | data_msg[3] = 0xff; |
| 1137 | egprs3->pi = 0; |
| 1138 | egprs3->cps_lo = 1; |
| 1139 | egprs3->rsb = 0; |
| 1140 | egprs3->spb = 3; |
| 1141 | egprs3->pi = 0; |
| 1142 | |
| 1143 | pdch->rcv_block(data_msg, 42, *fn, &meas); |
| 1144 | |
| 1145 | block = ul_tbf->m_rlc.block(3); |
| 1146 | /* check the status of the block */ |
| 1147 | OSMO_ASSERT(block->spb_status.block_status_ul == |
| 1148 | EGPRS_RESEG_DEFAULT); |
| 1149 | /* Assembled MCS is MCS6. so the size is 74 */ |
| 1150 | OSMO_ASSERT(block->len == 74); |
| 1151 | OSMO_ASSERT(block->cs_last == |
Max | bea2edb | 2019-03-06 17:04:59 +0100 | [diff] [blame] | 1152 | MCS6); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 1153 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 1154 | egprs3 = (struct gprs_rlc_ul_header_egprs_3 *) data_msg; |
| 1155 | egprs3->si = 1; |
| 1156 | egprs3->r = 1; |
| 1157 | egprs3->cv = 7; |
| 1158 | egprs3->tfi_hi = tfi & 0x03; |
| 1159 | egprs3->tfi_lo = (tfi & 0x1c) >> 2; |
| 1160 | egprs3->bsn1_hi = 4; |
| 1161 | egprs3->bsn1_lo = 0; |
| 1162 | egprs3->cps_hi = 1; |
| 1163 | data_msg[3] = 0xff; |
| 1164 | egprs3->pi = 0; |
| 1165 | egprs3->cps_lo = 1; |
| 1166 | egprs3->rsb = 0; |
| 1167 | egprs3->spb = 2; |
| 1168 | egprs3->pi = 0; |
| 1169 | |
| 1170 | pdch->rcv_block(data_msg, 42, *fn, &meas); |
| 1171 | |
| 1172 | block = ul_tbf->m_rlc.block(4); |
| 1173 | /* check the status of the block */ |
| 1174 | OSMO_ASSERT(block->spb_status.block_status_ul == |
| 1175 | EGPRS_RESEG_FIRST_SEG_RXD); |
| 1176 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 1177 | egprs3 = (struct gprs_rlc_ul_header_egprs_3 *) data_msg; |
| 1178 | egprs3->si = 1; |
| 1179 | egprs3->r = 1; |
| 1180 | egprs3->cv = 7; |
| 1181 | egprs3->tfi_hi = tfi & 0x03; |
| 1182 | egprs3->tfi_lo = (tfi & 0x1c) >> 2; |
| 1183 | egprs3->bsn1_hi = 4; |
| 1184 | egprs3->bsn1_lo = 0; |
| 1185 | egprs3->cps_hi = 1; |
| 1186 | data_msg[3] = 0xff; |
| 1187 | egprs3->pi = 0; |
| 1188 | egprs3->cps_lo = 1; |
| 1189 | egprs3->rsb = 0; |
| 1190 | egprs3->spb = 2; |
| 1191 | egprs3->pi = 0; |
| 1192 | |
| 1193 | pdch->rcv_block(data_msg, 42, *fn, &meas); |
| 1194 | |
| 1195 | block = ul_tbf->m_rlc.block(4); |
| 1196 | /* check the status of the block */ |
| 1197 | OSMO_ASSERT(block->spb_status.block_status_ul == |
| 1198 | EGPRS_RESEG_FIRST_SEG_RXD); |
| 1199 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 1200 | egprs3 = (struct gprs_rlc_ul_header_egprs_3 *) data_msg; |
| 1201 | egprs3->si = 1; |
| 1202 | egprs3->r = 1; |
| 1203 | egprs3->cv = 7; |
| 1204 | egprs3->tfi_hi = tfi & 0x03; |
| 1205 | egprs3->tfi_lo = (tfi & 0x1c) >> 2; |
| 1206 | egprs3->bsn1_hi = 4; |
| 1207 | egprs3->bsn1_lo = 0; |
| 1208 | egprs3->cps_hi = 1; |
| 1209 | data_msg[3] = 0xff; |
| 1210 | egprs3->pi = 0; |
| 1211 | egprs3->cps_lo = 1; |
| 1212 | egprs3->rsb = 0; |
| 1213 | egprs3->spb = 3; |
| 1214 | egprs3->pi = 0; |
| 1215 | |
| 1216 | pdch->rcv_block(data_msg, 42, *fn, &meas); |
| 1217 | |
| 1218 | block = ul_tbf->m_rlc.block(4); |
| 1219 | /* check the status of the block */ |
| 1220 | OSMO_ASSERT(block->spb_status.block_status_ul == |
| 1221 | EGPRS_RESEG_DEFAULT); |
| 1222 | OSMO_ASSERT(block->cs_last == |
Max | bea2edb | 2019-03-06 17:04:59 +0100 | [diff] [blame] | 1223 | MCS6); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 1224 | /* Assembled MCS is MCS6. so the size is 74 */ |
| 1225 | OSMO_ASSERT(block->len == 74); |
| 1226 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 1227 | egprs3 = (struct gprs_rlc_ul_header_egprs_3 *) data_msg; |
| 1228 | egprs3->si = 1; |
| 1229 | egprs3->r = 1; |
| 1230 | egprs3->cv = 7; |
| 1231 | egprs3->tfi_hi = tfi & 0x03; |
| 1232 | egprs3->tfi_lo = (tfi & 0x1c) >> 2; |
| 1233 | egprs3->bsn1_hi = 5; |
| 1234 | egprs3->bsn1_lo = 0; |
| 1235 | egprs3->cps_hi = 1; |
| 1236 | data_msg[3] = 0xff; |
| 1237 | egprs3->pi = 0; |
| 1238 | egprs3->cps_lo = 1; |
| 1239 | egprs3->rsb = 0; |
| 1240 | egprs3->spb = 3; |
| 1241 | egprs3->pi = 0; |
| 1242 | |
| 1243 | pdch->rcv_block(data_msg, 42, *fn, &meas); |
| 1244 | |
| 1245 | block = ul_tbf->m_rlc.block(5); |
| 1246 | /* check the status of the block */ |
| 1247 | OSMO_ASSERT(block->spb_status.block_status_ul == |
| 1248 | EGPRS_RESEG_SECOND_SEG_RXD); |
| 1249 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 1250 | egprs3 = (struct gprs_rlc_ul_header_egprs_3 *) data_msg; |
| 1251 | egprs3->si = 1; |
| 1252 | egprs3->r = 1; |
| 1253 | egprs3->cv = 7; |
| 1254 | egprs3->tfi_hi = tfi & 0x03; |
| 1255 | egprs3->tfi_lo = (tfi & 0x1c) >> 2; |
| 1256 | egprs3->bsn1_hi = 5; |
| 1257 | egprs3->bsn1_lo = 0; |
| 1258 | egprs3->cps_hi = 1; |
| 1259 | data_msg[3] = 0xff; |
| 1260 | egprs3->pi = 0; |
| 1261 | egprs3->cps_lo = 1; |
| 1262 | egprs3->rsb = 0; |
| 1263 | egprs3->spb = 2; |
| 1264 | egprs3->pi = 0; |
| 1265 | |
| 1266 | pdch->rcv_block(data_msg, 42, *fn, &meas); |
| 1267 | |
| 1268 | block = ul_tbf->m_rlc.block(5); |
| 1269 | |
| 1270 | /* check the status of the block */ |
| 1271 | OSMO_ASSERT(block->spb_status.block_status_ul == |
| 1272 | EGPRS_RESEG_DEFAULT); |
| 1273 | OSMO_ASSERT(block->cs_last == |
Max | bea2edb | 2019-03-06 17:04:59 +0100 | [diff] [blame] | 1274 | MCS6); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 1275 | /* Assembled MCS is MCS6. so the size is 74 */ |
| 1276 | OSMO_ASSERT(block->len == 74); |
| 1277 | |
| 1278 | OSMO_ASSERT(ul_tbf->m_rlc.block(5)->len == |
| 1279 | ul_tbf->m_rlc.block(4)->len); |
| 1280 | OSMO_ASSERT(ul_tbf->m_rlc.block(5)->len == |
| 1281 | ul_tbf->m_rlc.block(3)->len); |
| 1282 | |
| 1283 | /* Compare the spb status of each BSNs(3,4,5). should be same */ |
| 1284 | OSMO_ASSERT( |
| 1285 | ul_tbf->m_rlc.block(5)->spb_status.block_status_ul == |
| 1286 | ul_tbf->m_rlc.block(4)->spb_status.block_status_ul); |
| 1287 | OSMO_ASSERT( |
| 1288 | ul_tbf->m_rlc.block(5)->spb_status.block_status_ul == |
| 1289 | ul_tbf->m_rlc.block(3)->spb_status.block_status_ul); |
| 1290 | |
| 1291 | /* Compare the Assembled MCS of each BSNs(3,4,5). should be same */ |
| 1292 | OSMO_ASSERT(ul_tbf->m_rlc.block(5)->cs_last == |
| 1293 | ul_tbf->m_rlc.block(4)->cs_last); |
| 1294 | OSMO_ASSERT(ul_tbf->m_rlc.block(5)->cs_last == |
| 1295 | ul_tbf->m_rlc.block(3)->cs_last); |
| 1296 | |
| 1297 | /* Compare the data of each BSNs(3,4,5). should be same */ |
| 1298 | OSMO_ASSERT( |
| 1299 | !memcmp(ul_tbf->m_rlc.block(5)->block, |
| 1300 | ul_tbf->m_rlc.block(4)->block, ul_tbf->m_rlc.block(5)->len |
| 1301 | )); |
| 1302 | OSMO_ASSERT( |
| 1303 | !memcmp(ul_tbf->m_rlc.block(5)->block, |
| 1304 | ul_tbf->m_rlc.block(3)->block, ul_tbf->m_rlc.block(5)->len |
| 1305 | )); |
| 1306 | |
| 1307 | return ul_tbf; |
| 1308 | } |
| 1309 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1310 | static gprs_rlcmac_ul_tbf *establish_ul_tbf(struct gprs_rlcmac_bts *bts, |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1311 | uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta, |
| 1312 | uint8_t ms_class, uint8_t egprs_ms_class) |
| 1313 | { |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1314 | uint32_t rach_fn = *fn - 51; |
| 1315 | uint32_t sba_fn = *fn + 52; |
| 1316 | uint8_t trx_no = 0; |
Neels Hofmeyr | d34646a | 2017-02-08 17:07:40 +0100 | [diff] [blame] | 1317 | int tfi = 0; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1318 | gprs_rlcmac_ul_tbf *ul_tbf; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1319 | RlcMacUplink_t ulreq = {0}; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1320 | |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1321 | /* needed to set last_rts_fn in the PDCH object */ |
| 1322 | request_dl_rlc_block(bts, trx_no, ts_no, fn); |
| 1323 | |
| 1324 | /* |
| 1325 | * simulate RACH, this sends an Immediate |
| 1326 | * Assignment Uplink on the AGCH |
| 1327 | */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1328 | bts_handle_rach(bts, 0x73, rach_fn, qta); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1329 | |
| 1330 | /* get next free TFI */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1331 | tfi = bts_tfi_find_free(bts, GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1332 | |
| 1333 | /* fake a resource request */ |
| 1334 | ulreq.u.MESSAGE_TYPE = MT_PACKET_RESOURCE_REQUEST; |
| 1335 | ulreq.u.Packet_Resource_Request.PayloadType = GPRS_RLCMAC_CONTROL_BLOCK; |
| 1336 | ulreq.u.Packet_Resource_Request.ID.UnionType = 1; /* != 0 */ |
| 1337 | ulreq.u.Packet_Resource_Request.ID.u.TLLI = tlli; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 1338 | ulreq.u.Packet_Resource_Request.Exist_MS_Radio_Access_capability2 = 1; |
| 1339 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1340 | Count_MS_RA_capability_value = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 1341 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1342 | MS_RA_capability_value[0].u.Content. |
| 1343 | Exist_Multislot_capability = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 1344 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1345 | MS_RA_capability_value[0].u.Content.Multislot_capability. |
| 1346 | Exist_GPRS_multislot_class = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 1347 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1348 | MS_RA_capability_value[0].u.Content.Multislot_capability. |
| 1349 | GPRS_multislot_class = ms_class; |
| 1350 | if (egprs_ms_class) { |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 1351 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1352 | MS_RA_capability_value[0].u.Content. |
| 1353 | Multislot_capability.Exist_EGPRS_multislot_class = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 1354 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1355 | MS_RA_capability_value[0].u.Content. |
| 1356 | Multislot_capability.EGPRS_multislot_class = ms_class; |
| 1357 | } |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1358 | send_ul_mac_block(bts, trx_no, ts_no, &ulreq, sba_fn); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1359 | |
| 1360 | /* check the TBF */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1361 | ul_tbf = bts_ul_tbf_by_tfi(bts, tfi, trx_no, ts_no); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1362 | /* send packet uplink assignment */ |
| 1363 | *fn = sba_fn; |
| 1364 | request_dl_rlc_block(ul_tbf, fn); |
| 1365 | |
| 1366 | /* send real acknowledgement */ |
| 1367 | send_control_ack(ul_tbf); |
| 1368 | |
| 1369 | check_tbf(ul_tbf); |
| 1370 | |
| 1371 | return ul_tbf; |
| 1372 | } |
| 1373 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1374 | static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_puan_URBB_no_length(struct gprs_rlcmac_bts *bts, |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1375 | uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta, |
| 1376 | uint8_t ms_class, uint8_t egprs_ms_class, gprs_rlcmac_ul_tbf *ul_tbf) |
| 1377 | { |
| 1378 | OSMO_ASSERT(ul_tbf); |
| 1379 | OSMO_ASSERT(ul_tbf->ta() == qta / 4); |
| 1380 | GprsMs *ms; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1381 | uint8_t trx_no = 0; |
Neels Hofmeyr | d34646a | 2017-02-08 17:07:40 +0100 | [diff] [blame] | 1382 | int tfi = 0; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1383 | struct gprs_rlcmac_pdch *pdch; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1384 | |
| 1385 | /* send fake data with cv=0*/ |
| 1386 | struct gprs_rlc_ul_header_egprs_3 *hdr3 = NULL; |
| 1387 | uint8_t data[49] = {0}; |
| 1388 | |
| 1389 | hdr3 = (struct gprs_rlc_ul_header_egprs_3 *)data; |
| 1390 | |
| 1391 | /*header_construction */ |
| 1392 | memset(data, 0x2b, sizeof(data)); |
| 1393 | /* Message with CRBB */ |
| 1394 | for (int i = 0 ; i < 80; i++) { |
| 1395 | hdr3->r = 0; |
| 1396 | hdr3->si = 0; |
| 1397 | hdr3->cv = 10; |
| 1398 | hdr3->tfi_hi = (tfi >> 3) & 0x3; |
| 1399 | hdr3->tfi_lo = tfi & 0x7; |
| 1400 | hdr3->bsn1_hi = ((i * 2)&0x1f); |
| 1401 | hdr3->bsn1_lo = ((i * 2)/32); |
| 1402 | hdr3->cps_hi = 0; |
| 1403 | hdr3->cps_lo = 0; |
| 1404 | hdr3->spb = 0; |
| 1405 | hdr3->rsb = 0; |
| 1406 | hdr3->pi = 0; |
| 1407 | hdr3->spare = 0; |
| 1408 | hdr3->dummy = 1; |
| 1409 | data[4] = 0x0; |
| 1410 | data[5] = 0x0; |
| 1411 | data[6] = 0x2b; |
| 1412 | data[7] = 0x2b; |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1413 | pdch = &bts->trx[trx_no].pdch[ts_no]; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1414 | pdch->rcv_block(&data[0], sizeof(data), *fn, &meas); |
| 1415 | } |
Pau Espin Pedrol | ea8dbdd | 2021-07-29 18:39:16 +0200 | [diff] [blame] | 1416 | osmo_fsm_inst_dispatch(ul_tbf->ul_ack_fsm.fi, TBF_UL_ACK_EV_SCHED_ACK, NULL); |
| 1417 | tbf_ul_ack_create_rlcmac_msg(ul_tbf, *fn, ts_no); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1418 | memset(data, 0x2b, sizeof(data)); |
| 1419 | hdr3 = (struct gprs_rlc_ul_header_egprs_3 *)data; |
| 1420 | hdr3->r = 0; |
| 1421 | hdr3->si = 0; |
| 1422 | hdr3->cv = 0; |
| 1423 | hdr3->tfi_hi = (tfi >> 3) & 0x3; |
| 1424 | hdr3->tfi_lo = tfi & 0x7; |
| 1425 | hdr3->bsn1_hi = 0; |
| 1426 | hdr3->bsn1_lo = 2; |
| 1427 | hdr3->cps_hi = 0; |
| 1428 | hdr3->cps_lo = 0; |
| 1429 | hdr3->spb = 0; |
| 1430 | hdr3->rsb = 0; |
| 1431 | hdr3->pi = 0; |
| 1432 | hdr3->spare = 0; |
| 1433 | hdr3->dummy = 1; |
| 1434 | data[4] = 0x0; |
| 1435 | data[5] = 0x2b; |
| 1436 | data[6] = 0x2b; |
| 1437 | data[7] = 0x2b; |
| 1438 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1439 | pdch = &bts->trx[trx_no].pdch[ts_no]; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1440 | pdch->rcv_block(&data[0], sizeof(data), *fn, &meas); |
| 1441 | |
| 1442 | request_dl_rlc_block(ul_tbf, fn); |
| 1443 | |
| 1444 | check_tbf(ul_tbf); |
Pau Espin Pedrol | ea8dbdd | 2021-07-29 18:39:16 +0200 | [diff] [blame] | 1445 | OSMO_ASSERT(tbf_ul_ack_fi(ul_tbf)->state == TBF_UL_ACK_ST_NONE); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1446 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1447 | ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1448 | OSMO_ASSERT(ms != NULL); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 1449 | OSMO_ASSERT(ms_ta(ms) == qta/4); |
| 1450 | OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1451 | |
| 1452 | return ul_tbf; |
| 1453 | } |
| 1454 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1455 | static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_puan_URBB_with_length(struct gprs_rlcmac_bts *bts, |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1456 | uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta, |
| 1457 | uint8_t ms_class, uint8_t egprs_ms_class, gprs_rlcmac_ul_tbf *ul_tbf) |
| 1458 | { |
| 1459 | OSMO_ASSERT(ul_tbf); |
| 1460 | OSMO_ASSERT(ul_tbf->ta() == qta / 4); |
| 1461 | GprsMs *ms; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1462 | uint8_t trx_no = 0; |
Neels Hofmeyr | d34646a | 2017-02-08 17:07:40 +0100 | [diff] [blame] | 1463 | int tfi = 0; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1464 | struct gprs_rlcmac_pdch *pdch; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1465 | |
| 1466 | check_tbf(ul_tbf); |
| 1467 | /* send fake data with cv=0*/ |
| 1468 | struct gprs_rlc_ul_header_egprs_3 *hdr3 = NULL; |
| 1469 | uint8_t data[49] = {0}; |
| 1470 | |
| 1471 | hdr3 = (struct gprs_rlc_ul_header_egprs_3 *)data; |
| 1472 | |
| 1473 | /*header_construction */ |
| 1474 | memset(data, 0x2b, sizeof(data)); |
| 1475 | |
| 1476 | /* Message with URBB & URBB length */ |
| 1477 | for (int i = 0 ; i < 20; i++) { |
| 1478 | hdr3->r = 0; |
| 1479 | hdr3->si = 0; |
| 1480 | hdr3->cv = 10; |
| 1481 | hdr3->tfi_hi = (tfi >> 3) & 0x3; |
| 1482 | hdr3->tfi_lo = tfi & 0x7; |
| 1483 | hdr3->bsn1_hi = ((i * 2)&0x1f); |
| 1484 | hdr3->bsn1_lo = ((i * 2)/32); |
| 1485 | hdr3->cps_hi = 0; |
| 1486 | hdr3->cps_lo = 0; |
| 1487 | hdr3->spb = 0; |
| 1488 | hdr3->rsb = 0; |
| 1489 | hdr3->pi = 0; |
| 1490 | hdr3->spare = 0; |
| 1491 | hdr3->dummy = 1; |
| 1492 | data[4] = 0x0; |
| 1493 | data[5] = 0x0; |
| 1494 | data[6] = 0x2b; |
| 1495 | data[7] = 0x2b; |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1496 | pdch = &bts->trx[trx_no].pdch[ts_no]; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1497 | pdch->rcv_block(&data[0], sizeof(data), *fn, &meas); |
| 1498 | } |
Pau Espin Pedrol | ea8dbdd | 2021-07-29 18:39:16 +0200 | [diff] [blame] | 1499 | osmo_fsm_inst_dispatch(ul_tbf->ul_ack_fsm.fi, TBF_UL_ACK_EV_SCHED_ACK, NULL); |
| 1500 | tbf_ul_ack_create_rlcmac_msg(ul_tbf, *fn, ts_no); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1501 | memset(data, 0x2b, sizeof(data)); |
| 1502 | hdr3 = (struct gprs_rlc_ul_header_egprs_3 *)data; |
| 1503 | hdr3->r = 0; |
| 1504 | hdr3->si = 0; |
| 1505 | hdr3->cv = 0; |
| 1506 | hdr3->tfi_hi = (tfi >> 3) & 0x3; |
| 1507 | hdr3->tfi_lo = tfi & 0x7; |
| 1508 | hdr3->bsn1_hi = 0; |
| 1509 | hdr3->bsn1_lo = 2; |
| 1510 | hdr3->cps_hi = 0; |
| 1511 | hdr3->cps_lo = 0; |
| 1512 | hdr3->spb = 0; |
| 1513 | hdr3->rsb = 0; |
| 1514 | hdr3->pi = 0; |
| 1515 | hdr3->spare = 0; |
| 1516 | hdr3->dummy = 1; |
| 1517 | data[4] = 0x0; |
| 1518 | data[5] = 0x2b; |
| 1519 | data[6] = 0x2b; |
| 1520 | data[7] = 0x2b; |
| 1521 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1522 | pdch = &bts->trx[trx_no].pdch[ts_no]; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1523 | pdch->rcv_block(&data[0], sizeof(data), *fn, &meas); |
Pau Espin Pedrol | ea8dbdd | 2021-07-29 18:39:16 +0200 | [diff] [blame] | 1524 | osmo_fsm_inst_dispatch(ul_tbf->ul_ack_fsm.fi, TBF_UL_ACK_EV_SCHED_ACK, NULL); |
| 1525 | tbf_ul_ack_create_rlcmac_msg(ul_tbf, *fn, ts_no); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1526 | |
| 1527 | request_dl_rlc_block(ul_tbf, fn); |
| 1528 | |
| 1529 | check_tbf(ul_tbf); |
Pau Espin Pedrol | ea8dbdd | 2021-07-29 18:39:16 +0200 | [diff] [blame] | 1530 | OSMO_ASSERT(tbf_ul_ack_fi(ul_tbf)->state == TBF_UL_ACK_ST_NONE); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1531 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1532 | ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1533 | OSMO_ASSERT(ms != NULL); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 1534 | OSMO_ASSERT(ms_ta(ms) == qta/4); |
| 1535 | OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1536 | |
| 1537 | return ul_tbf; |
| 1538 | } |
| 1539 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1540 | static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_puan_CRBB(struct gprs_rlcmac_bts *bts, |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1541 | uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta, |
| 1542 | uint8_t ms_class, uint8_t egprs_ms_class) |
| 1543 | { |
| 1544 | GprsMs *ms; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1545 | uint8_t trx_no = 0; |
Neels Hofmeyr | d34646a | 2017-02-08 17:07:40 +0100 | [diff] [blame] | 1546 | int tfi = 0; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1547 | gprs_rlcmac_ul_tbf *ul_tbf; |
| 1548 | struct gprs_rlcmac_pdch *pdch; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1549 | |
| 1550 | /* check the TBF */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1551 | ul_tbf = bts_ul_tbf_by_tfi(bts, tfi, trx_no, ts_no); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1552 | OSMO_ASSERT(ul_tbf); |
| 1553 | OSMO_ASSERT(ul_tbf->ta() == qta / 4); |
| 1554 | |
| 1555 | /* send fake data with cv=0*/ |
| 1556 | struct gprs_rlc_ul_header_egprs_3 *hdr3 = NULL; |
| 1557 | uint8_t data[49] = {0}; |
| 1558 | |
| 1559 | hdr3 = (struct gprs_rlc_ul_header_egprs_3 *)data; |
| 1560 | |
| 1561 | /*header_construction */ |
| 1562 | memset(data, 0x2b, sizeof(data)); |
| 1563 | |
| 1564 | /* Message with CRBB */ |
| 1565 | for (int i = 80 ; i < 160; i++) { |
| 1566 | hdr3->r = 0; |
| 1567 | hdr3->si = 0; |
| 1568 | hdr3->cv = 10; |
| 1569 | hdr3->tfi_hi = (tfi >> 3) & 0x3; |
| 1570 | hdr3->tfi_lo = tfi & 0x7; |
| 1571 | hdr3->bsn1_hi = ((i)&0x1f); |
| 1572 | hdr3->bsn1_lo = ((i)/32); |
| 1573 | hdr3->cps_hi = 0; |
| 1574 | hdr3->cps_lo = 0; |
| 1575 | hdr3->spb = 0; |
| 1576 | hdr3->rsb = 0; |
| 1577 | hdr3->pi = 0; |
| 1578 | hdr3->spare = 0; |
| 1579 | hdr3->dummy = 1; |
| 1580 | data[4] = 0x0; |
| 1581 | data[5] = 0x0; |
| 1582 | data[6] = 0x2b; |
| 1583 | data[7] = 0x2b; |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1584 | pdch = &bts->trx[trx_no].pdch[ts_no]; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1585 | pdch->rcv_block(&data[0], sizeof(data), *fn, &meas); |
| 1586 | } |
Pau Espin Pedrol | ea8dbdd | 2021-07-29 18:39:16 +0200 | [diff] [blame] | 1587 | osmo_fsm_inst_dispatch(ul_tbf->ul_ack_fsm.fi, TBF_UL_ACK_EV_SCHED_ACK, NULL); |
| 1588 | tbf_ul_ack_create_rlcmac_msg(ul_tbf, *fn, ts_no); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1589 | memset(data, 0x2b, sizeof(data)); |
| 1590 | hdr3 = (struct gprs_rlc_ul_header_egprs_3 *)data; |
| 1591 | hdr3->r = 0; |
| 1592 | hdr3->si = 0; |
| 1593 | hdr3->cv = 0; |
| 1594 | hdr3->tfi_hi = (tfi >> 3) & 0x3; |
| 1595 | hdr3->tfi_lo = tfi & 0x7; |
| 1596 | hdr3->bsn1_hi = 0; |
| 1597 | hdr3->bsn1_lo = 2; |
| 1598 | hdr3->cps_hi = 0; |
| 1599 | hdr3->cps_lo = 0; |
| 1600 | hdr3->spb = 0; |
| 1601 | hdr3->rsb = 0; |
| 1602 | hdr3->pi = 0; |
| 1603 | hdr3->spare = 0; |
| 1604 | hdr3->dummy = 1; |
| 1605 | data[4] = 0x0; |
| 1606 | data[5] = 0x2b; |
| 1607 | data[6] = 0x2b; |
| 1608 | data[7] = 0x2b; |
| 1609 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1610 | pdch = &bts->trx[trx_no].pdch[ts_no]; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1611 | pdch->rcv_block(&data[0], sizeof(data), *fn, &meas); |
| 1612 | |
| 1613 | request_dl_rlc_block(ul_tbf, fn); |
| 1614 | |
| 1615 | check_tbf(ul_tbf); |
Pau Espin Pedrol | ea8dbdd | 2021-07-29 18:39:16 +0200 | [diff] [blame] | 1616 | OSMO_ASSERT(tbf_ul_ack_fi(ul_tbf)->state == TBF_UL_ACK_ST_NONE); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1617 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1618 | ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1619 | OSMO_ASSERT(ms != NULL); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 1620 | OSMO_ASSERT(ms_ta(ms) == qta/4); |
| 1621 | OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1622 | |
| 1623 | return ul_tbf; |
| 1624 | } |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1625 | static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase(struct gprs_rlcmac_bts *bts, |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1626 | uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta, |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 1627 | uint8_t ms_class, uint8_t egprs_ms_class) |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1628 | { |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1629 | GprsMs *ms; |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1630 | uint32_t rach_fn = *fn - 51; |
| 1631 | uint32_t sba_fn = *fn + 52; |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1632 | uint8_t trx_no = 0; |
| 1633 | int tfi = 0; |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1634 | gprs_rlcmac_ul_tbf *ul_tbf; |
| 1635 | struct gprs_rlcmac_pdch *pdch; |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1636 | RlcMacUplink_t ulreq = {0}; |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1637 | |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1638 | /* needed to set last_rts_fn in the PDCH object */ |
Max | 878bd1f | 2016-07-20 13:05:05 +0200 | [diff] [blame] | 1639 | request_dl_rlc_block(bts, trx_no, ts_no, fn); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1640 | |
bhargava | 959d1de | 2016-08-17 15:17:21 +0530 | [diff] [blame] | 1641 | /* simulate RACH, sends an Immediate Assignment Uplink on the AGCH */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1642 | bts_handle_rach(bts, 0x73, rach_fn, qta); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1643 | |
| 1644 | /* get next free TFI */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1645 | tfi = bts_tfi_find_free(bts, GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1646 | |
| 1647 | /* fake a resource request */ |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1648 | ulreq.u.MESSAGE_TYPE = MT_PACKET_RESOURCE_REQUEST; |
| 1649 | ulreq.u.Packet_Resource_Request.PayloadType = GPRS_RLCMAC_CONTROL_BLOCK; |
| 1650 | ulreq.u.Packet_Resource_Request.ID.UnionType = 1; /* != 0 */ |
| 1651 | ulreq.u.Packet_Resource_Request.ID.u.TLLI = tlli; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 1652 | ulreq.u.Packet_Resource_Request.Exist_MS_Radio_Access_capability2 = 1; |
| 1653 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1654 | Count_MS_RA_capability_value = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 1655 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1656 | MS_RA_capability_value[0].u.Content.Exist_Multislot_capability = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 1657 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1658 | MS_RA_capability_value[0].u.Content.Multislot_capability. |
| 1659 | Exist_GPRS_multislot_class = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 1660 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1661 | MS_RA_capability_value[0].u.Content.Multislot_capability. |
| 1662 | GPRS_multislot_class = ms_class; |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 1663 | if (egprs_ms_class) { |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 1664 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 1665 | MS_RA_capability_value[0].u.Content.Multislot_capability. |
| 1666 | Exist_EGPRS_multislot_class = 1; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 1667 | ulreq.u.Packet_Resource_Request.MS_Radio_Access_capability2. |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 1668 | MS_RA_capability_value[0].u.Content.Multislot_capability. |
| 1669 | EGPRS_multislot_class = ms_class; |
| 1670 | } |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1671 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1672 | send_ul_mac_block(bts, trx_no, ts_no, &ulreq, sba_fn); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1673 | |
| 1674 | /* check the TBF */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1675 | ul_tbf = bts_ul_tbf_by_tfi(bts, tfi, trx_no, ts_no); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1676 | OSMO_ASSERT(ul_tbf != NULL); |
Jacob Erlbeck | 9200ce6 | 2015-05-22 17:48:04 +0200 | [diff] [blame] | 1677 | OSMO_ASSERT(ul_tbf->ta() == qta / 4); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1678 | |
| 1679 | /* send packet uplink assignment */ |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1680 | *fn = sba_fn; |
Jacob Erlbeck | cef20ae | 2015-08-24 12:00:33 +0200 | [diff] [blame] | 1681 | request_dl_rlc_block(ul_tbf, fn); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1682 | |
Jacob Erlbeck | af45473 | 2015-08-21 15:03:23 +0200 | [diff] [blame] | 1683 | /* send real acknowledgement */ |
| 1684 | send_control_ack(ul_tbf); |
| 1685 | |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1686 | check_tbf(ul_tbf); |
| 1687 | |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1688 | /* send fake data */ |
| 1689 | uint8_t data_msg[23] = { |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1690 | 0x00 | 0xf << 2, /* GPRS_RLCMAC_DATA_BLOCK << 6, CV = 15 */ |
| 1691 | uint8_t(0 | (tfi << 1)), |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1692 | uint8_t(1), /* BSN:7, E:1 */ |
| 1693 | }; |
| 1694 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1695 | pdch = &bts->trx[trx_no].pdch[ts_no]; |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1696 | pdch->rcv_block(&data_msg[0], sizeof(data_msg), *fn, &meas); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1697 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1698 | ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1699 | OSMO_ASSERT(ms != NULL); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 1700 | OSMO_ASSERT(ms_ta(ms) == qta/4); |
| 1701 | OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1702 | |
| 1703 | return ul_tbf; |
| 1704 | } |
| 1705 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1706 | static void send_dl_data(struct gprs_rlcmac_bts *bts, uint32_t tlli, const char *imsi, |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1707 | const uint8_t *data, unsigned data_size) |
| 1708 | { |
| 1709 | GprsMs *ms, *ms2; |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1710 | |
Pau Espin Pedrol | 7f360e7 | 2022-10-21 14:30:36 +0200 | [diff] [blame] | 1711 | ms = bts_ms_store(bts)->get_ms(tlli, GSM_RESERVED_TMSI, imsi); |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1712 | |
Pau Espin Pedrol | 8a35e64 | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 1713 | dl_tbf_handle(bts, tlli, 0, imsi, 0, 0, |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1714 | 1000, data, data_size); |
| 1715 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1716 | ms = bts_ms_by_imsi(bts, imsi); |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1717 | OSMO_ASSERT(ms != NULL); |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1718 | |
Pau Espin Pedrol | 5deac14 | 2021-11-12 18:01:50 +0100 | [diff] [blame] | 1719 | if (imsi[0] != '\0') { |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1720 | ms2 = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1721 | OSMO_ASSERT(ms == ms2); |
| 1722 | } |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1723 | } |
| 1724 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1725 | static void transmit_dl_data(struct gprs_rlcmac_bts *bts, uint32_t tlli, uint32_t *fn, |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 1726 | uint8_t slots = 0xff) |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 1727 | { |
| 1728 | gprs_rlcmac_dl_tbf *dl_tbf; |
| 1729 | GprsMs *ms; |
| 1730 | unsigned ts_no; |
| 1731 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1732 | ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 1733 | OSMO_ASSERT(ms); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 1734 | dl_tbf = ms_dl_tbf(ms); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 1735 | OSMO_ASSERT(dl_tbf); |
| 1736 | |
| 1737 | while (dl_tbf->have_data()) { |
| 1738 | uint8_t bn = fn2bn(*fn); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 1739 | for (ts_no = 0 ; ts_no < 8; ts_no += 1) { |
| 1740 | if (!(slots & (1 << ts_no))) |
| 1741 | continue; |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1742 | gprs_rlcmac_rcv_rts_block(bts, |
Max | 878bd1f | 2016-07-20 13:05:05 +0200 | [diff] [blame] | 1743 | dl_tbf->trx->trx_no, ts_no, |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 1744 | *fn, bn); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 1745 | } |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 1746 | *fn = fn_add_blocks(*fn, 1); |
| 1747 | } |
| 1748 | } |
| 1749 | |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 1750 | static inline void print_ta_tlli(const gprs_rlcmac_ul_tbf *ul_tbf, bool print_ms) |
| 1751 | { |
| 1752 | fprintf(stderr, "Got '%s', TA=%d\n", ul_tbf->name(), ul_tbf->ta()); |
| 1753 | if (print_ms) |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 1754 | fprintf(stderr, "Got MS: TLLI = 0x%08x, TA = %d\n", ms_tlli(ul_tbf->ms()), ms_ta(ul_tbf->ms())); |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 1755 | } |
| 1756 | |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1757 | static void test_tbf_single_phase() |
| 1758 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 1759 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 1760 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1761 | int ts_no = 7; |
Philipp | d935d88 | 2016-11-07 13:07:36 +0100 | [diff] [blame] | 1762 | uint32_t fn = DUMMY_FN; /* 17,25,9 */ |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1763 | uint32_t tlli = 0xf1223344; |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1764 | const char *imsi = "0011223344"; |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1765 | uint16_t qta = 31; |
| 1766 | gprs_rlcmac_ul_tbf *ul_tbf; |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1767 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 1768 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1769 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1770 | setup_bts(bts, ts_no); |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1771 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1772 | ul_tbf = establish_ul_tbf_single_phase(bts, ts_no, tlli, &fn, qta); |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1773 | |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 1774 | print_ta_tlli(ul_tbf, true); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1775 | send_dl_data(bts, tlli, imsi, (const uint8_t *)"TEST", 4); |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1776 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 1777 | fprintf(stderr, "=== end %s ===\n", __func__); |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 1778 | TALLOC_FREE(the_pcu); |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1779 | } |
| 1780 | |
Pau Espin Pedrol | 22b26d8 | 2022-10-26 15:44:14 +0200 | [diff] [blame] | 1781 | static void test_tbf_single_phase2() |
| 1782 | { |
| 1783 | the_pcu = prepare_pcu(); |
| 1784 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
| 1785 | int ts_no = 7; |
| 1786 | uint32_t fn = DUMMY_FN; /* 17,25,9 */ |
| 1787 | uint32_t tlli = 0xf1223344; |
| 1788 | const char *imsi = "0011223344"; |
| 1789 | uint16_t qta = 31; |
| 1790 | gprs_rlcmac_ul_tbf *ul_tbf; |
| 1791 | |
| 1792 | fprintf(stderr, "=== start %s ===\n", __func__); |
| 1793 | |
| 1794 | setup_bts(bts, ts_no); |
| 1795 | |
| 1796 | ul_tbf = establish_ul_tbf_single_phase(bts, ts_no, tlli, &fn, qta); |
| 1797 | |
| 1798 | print_ta_tlli(ul_tbf, true); |
| 1799 | /* PCU sends CTRL ACK/NCK with FINAL_ACK=1, hence TBF is not in state FINISHED */ |
| 1800 | request_dl_rlc_block(bts, ul_tbf->trx->trx_no, ts_no, &fn); |
| 1801 | OSMO_ASSERT(ul_tbf->state_is(TBF_ST_FINISHED)); |
| 1802 | /* Now data is sent but no DL TBF is created because MS is not reachable for DL Assignment */ |
| 1803 | send_dl_data(bts, tlli, imsi, (const uint8_t *)"TEST", 4); |
| 1804 | |
| 1805 | /* After MS CTRL ACKs the FINAL_ACK=1 then it releases the TBF and goes |
| 1806 | * to packet-idle mode. Hence PCU will trigger ImmAss(PktDlAss) on PCH. */ |
| 1807 | send_control_ack(ul_tbf); |
| 1808 | |
| 1809 | fprintf(stderr, "=== end %s ===\n", __func__); |
| 1810 | TALLOC_FREE(the_pcu); |
| 1811 | } |
| 1812 | |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1813 | static void test_tbf_egprs_two_phase_puan(void) |
| 1814 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 1815 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 1816 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1817 | int ts_no = 7; |
| 1818 | uint32_t fn = 2654218; |
| 1819 | uint16_t qta = 31; |
| 1820 | uint32_t tlli = 0xf1223344; |
| 1821 | const char *imsi = "0011223344"; |
| 1822 | uint8_t ms_class = 1; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1823 | uint8_t egprs_ms_class = 1; |
| 1824 | gprs_rlcmac_ul_tbf *ul_tbf; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1825 | uint8_t test_data[256]; |
| 1826 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 1827 | fprintf(stderr, "=== start %s ===\n", __func__); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1828 | |
| 1829 | memset(test_data, 1, sizeof(test_data)); |
| 1830 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1831 | setup_bts(bts, ts_no, 4); |
| 1832 | bts->initial_mcs_dl = 9; |
Pau Espin Pedrol | 519d071 | 2021-01-14 14:30:03 +0100 | [diff] [blame] | 1833 | the_pcu->vty.ws_base = 128; |
| 1834 | the_pcu->vty.ws_pdch = 64; |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1835 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1836 | ul_tbf = establish_ul_tbf(bts, ts_no, tlli, &fn, qta, ms_class, egprs_ms_class); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1837 | /* Function to generate URBB with no length */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1838 | ul_tbf = establish_ul_tbf_two_phase_puan_URBB_no_length(bts, ts_no, tlli, &fn, |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1839 | qta, ms_class, egprs_ms_class, ul_tbf); |
| 1840 | |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 1841 | print_ta_tlli(ul_tbf, true); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1842 | send_dl_data(bts, tlli, imsi, test_data, sizeof(test_data)); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1843 | |
Pau Espin Pedrol | b3f2397 | 2020-10-23 21:00:23 +0200 | [diff] [blame] | 1844 | static_cast<gprs_rlc_ul_window *>(ul_tbf->window())->reset_state(); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1845 | /* Function to generate URBB with length */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1846 | ul_tbf = establish_ul_tbf_two_phase_puan_URBB_with_length(bts, ts_no, tlli, &fn, |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1847 | qta, ms_class, egprs_ms_class, ul_tbf); |
| 1848 | |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 1849 | print_ta_tlli(ul_tbf, true); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1850 | send_dl_data(bts, tlli, imsi, test_data, sizeof(test_data)); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1851 | |
Pau Espin Pedrol | b3f2397 | 2020-10-23 21:00:23 +0200 | [diff] [blame] | 1852 | static_cast<gprs_rlc_ul_window *>(ul_tbf->window())->reset_state(); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1853 | /* Function to generate CRBB */ |
Pau Espin Pedrol | 519d071 | 2021-01-14 14:30:03 +0100 | [diff] [blame] | 1854 | the_pcu->vty.ws_base = 128; |
| 1855 | the_pcu->vty.ws_pdch = 64; |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1856 | ul_tbf = establish_ul_tbf_two_phase_puan_CRBB(bts, ts_no, tlli, &fn, |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1857 | qta, ms_class, egprs_ms_class); |
| 1858 | |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 1859 | print_ta_tlli(ul_tbf, true); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1860 | send_dl_data(bts, tlli, imsi, test_data, sizeof(test_data)); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1861 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 1862 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 1863 | fprintf(stderr, "=== end %s ===\n", __func__); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 1864 | } |
aravind sirsikar | c0c3afd | 2016-11-09 16:27:00 +0530 | [diff] [blame] | 1865 | /* |
| 1866 | * Trigger rach for single block |
| 1867 | */ |
| 1868 | static void test_immediate_assign_rej_single_block() |
| 1869 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 1870 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 1871 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
aravind sirsikar | c0c3afd | 2016-11-09 16:27:00 +0530 | [diff] [blame] | 1872 | uint32_t fn = 2654218; |
| 1873 | uint16_t qta = 31; |
| 1874 | int ts_no = 7; |
| 1875 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 1876 | fprintf(stderr, "=== start %s ===\n", __func__); |
aravind sirsikar | c0c3afd | 2016-11-09 16:27:00 +0530 | [diff] [blame] | 1877 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1878 | setup_bts(bts, ts_no, 4); |
aravind sirsikar | c0c3afd | 2016-11-09 16:27:00 +0530 | [diff] [blame] | 1879 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1880 | bts->trx[0].pdch[ts_no].disable(); |
aravind sirsikar | c0c3afd | 2016-11-09 16:27:00 +0530 | [diff] [blame] | 1881 | |
| 1882 | uint32_t rach_fn = fn - 51; |
| 1883 | |
| 1884 | int rc = 0; |
| 1885 | |
| 1886 | /* |
| 1887 | * simulate RACH, sends an Immediate Assignment |
| 1888 | * Uplink reject on the AGCH |
| 1889 | */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1890 | rc = bts_handle_rach(bts, 0x70, rach_fn, qta); |
aravind sirsikar | c0c3afd | 2016-11-09 16:27:00 +0530 | [diff] [blame] | 1891 | |
Pau Espin Pedrol | 15c58ac | 2021-03-08 14:57:58 +0100 | [diff] [blame] | 1892 | OSMO_ASSERT(rc == -EBUSY); |
aravind sirsikar | c0c3afd | 2016-11-09 16:27:00 +0530 | [diff] [blame] | 1893 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 1894 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 1895 | fprintf(stderr, "=== end %s ===\n", __func__); |
aravind sirsikar | c0c3afd | 2016-11-09 16:27:00 +0530 | [diff] [blame] | 1896 | } |
| 1897 | |
| 1898 | /* |
| 1899 | * Trigger rach till resources(USF) exhaust |
| 1900 | */ |
| 1901 | static void test_immediate_assign_rej_multi_block() |
| 1902 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 1903 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 1904 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
aravind sirsikar | c0c3afd | 2016-11-09 16:27:00 +0530 | [diff] [blame] | 1905 | uint32_t fn = 2654218; |
| 1906 | uint16_t qta = 31; |
| 1907 | int ts_no = 7; |
| 1908 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 1909 | fprintf(stderr, "=== start %s ===\n", __func__); |
aravind sirsikar | c0c3afd | 2016-11-09 16:27:00 +0530 | [diff] [blame] | 1910 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1911 | setup_bts(bts, ts_no, 4); |
aravind sirsikar | c0c3afd | 2016-11-09 16:27:00 +0530 | [diff] [blame] | 1912 | |
| 1913 | uint32_t rach_fn = fn - 51; |
| 1914 | |
| 1915 | int rc = 0; |
| 1916 | |
| 1917 | /* |
| 1918 | * simulate RACH, sends an Immediate Assignment Uplink |
| 1919 | * reject on the AGCH |
| 1920 | */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1921 | rc = bts_handle_rach(bts, 0x78, rach_fn, qta); |
| 1922 | rc = bts_handle_rach(bts, 0x79, rach_fn, qta); |
| 1923 | rc = bts_handle_rach(bts, 0x7a, rach_fn, qta); |
| 1924 | rc = bts_handle_rach(bts, 0x7b, rach_fn, qta); |
| 1925 | rc = bts_handle_rach(bts, 0x7c, rach_fn, qta); |
| 1926 | rc = bts_handle_rach(bts, 0x7d, rach_fn, qta); |
| 1927 | rc = bts_handle_rach(bts, 0x7e, rach_fn, qta); |
| 1928 | rc = bts_handle_rach(bts, 0x7f, rach_fn, qta); |
aravind sirsikar | c0c3afd | 2016-11-09 16:27:00 +0530 | [diff] [blame] | 1929 | |
| 1930 | OSMO_ASSERT(rc == -EBUSY); |
| 1931 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 1932 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 1933 | fprintf(stderr, "=== end %s ===\n", __func__); |
aravind sirsikar | c0c3afd | 2016-11-09 16:27:00 +0530 | [diff] [blame] | 1934 | } |
| 1935 | |
| 1936 | static void test_immediate_assign_rej() |
| 1937 | { |
| 1938 | test_immediate_assign_rej_multi_block(); |
| 1939 | test_immediate_assign_rej_single_block(); |
| 1940 | } |
| 1941 | |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1942 | static void test_tbf_two_phase() |
| 1943 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 1944 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 1945 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1946 | int ts_no = 7; |
| 1947 | uint32_t fn = 2654218; |
| 1948 | uint16_t qta = 31; |
| 1949 | uint32_t tlli = 0xf1223344; |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1950 | const char *imsi = "0011223344"; |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1951 | uint8_t ms_class = 1; |
| 1952 | gprs_rlcmac_ul_tbf *ul_tbf; |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1953 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 1954 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1955 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1956 | setup_bts(bts, ts_no, 4); |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1957 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1958 | ul_tbf = establish_ul_tbf_two_phase(bts, ts_no, tlli, &fn, qta, |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 1959 | ms_class, 0); |
Jacob Erlbeck | 4a6fe53 | 2015-08-19 14:00:43 +0200 | [diff] [blame] | 1960 | |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 1961 | print_ta_tlli(ul_tbf, true); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1962 | send_dl_data(bts, tlli, imsi, (const uint8_t *)"TEST", 4); |
Jacob Erlbeck | 076f5c7 | 2015-08-21 18:00:54 +0200 | [diff] [blame] | 1963 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 1964 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 1965 | fprintf(stderr, "=== end %s ===\n", __func__); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 1966 | } |
| 1967 | |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 1968 | static inline void print_ms(GprsMs *ms, bool old) |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 1969 | { |
| 1970 | fprintf(stderr, "%s MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 1971 | old ? "Old" : "New", ms_tlli(ms), ms_ta(ms), ms_imsi(ms), llc_queue_size(ms_llc_queue(ms))); |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 1972 | } |
| 1973 | |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 1974 | static void test_tbf_ra_update_rach() |
| 1975 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 1976 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 1977 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 1978 | int ts_no = 7; |
| 1979 | uint32_t fn = 2654218; |
| 1980 | uint16_t qta = 31; |
| 1981 | uint32_t tlli1 = 0xf1223344; |
| 1982 | uint32_t tlli2 = 0xf5667788; |
| 1983 | const char *imsi = "0011223344"; |
| 1984 | uint8_t ms_class = 1; |
| 1985 | gprs_rlcmac_ul_tbf *ul_tbf; |
Pau Espin Pedrol | 99360a3 | 2021-03-09 17:18:12 +0100 | [diff] [blame] | 1986 | gprs_rlcmac_dl_tbf *dl_tbf; |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 1987 | GprsMs *ms, *ms1, *ms2; |
| 1988 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 1989 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 1990 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1991 | setup_bts(bts, ts_no, 4); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 1992 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1993 | ul_tbf = establish_ul_tbf_two_phase(bts, ts_no, tlli1, &fn, qta, |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 1994 | ms_class, 0); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 1995 | |
| 1996 | ms1 = ul_tbf->ms(); |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 1997 | print_ta_tlli(ul_tbf, false); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 1998 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 1999 | send_dl_data(bts, tlli1, imsi, (const uint8_t *)"RAU_ACCEPT", 10); |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2000 | print_ms(ms1, true); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2001 | |
Jacob Erlbeck | af45473 | 2015-08-21 15:03:23 +0200 | [diff] [blame] | 2002 | /* Send Packet Downlink Assignment to MS */ |
| 2003 | request_dl_rlc_block(ul_tbf, &fn); |
| 2004 | |
| 2005 | /* Ack it */ |
| 2006 | send_control_ack(ul_tbf); |
| 2007 | |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2008 | /* Make sure the RAU Accept gets sent to the MS */ |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2009 | OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms1)) == 1); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2010 | transmit_dl_data(bts, tlli1, &fn); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2011 | OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms1)) == 0); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2012 | |
Pau Espin Pedrol | 99360a3 | 2021-03-09 17:18:12 +0100 | [diff] [blame] | 2013 | dl_tbf = ms_dl_tbf(ms1); |
| 2014 | OSMO_ASSERT(dl_tbf); |
Pau Espin Pedrol | 16e1678 | 2021-03-29 19:10:19 +0200 | [diff] [blame] | 2015 | fn = get_poll_fn(dl_tbf, dl_tbf->control_ts); |
| 2016 | send_empty_block(dl_tbf, dl_tbf->control_ts, fn); |
Pau Espin Pedrol | 99360a3 | 2021-03-09 17:18:12 +0100 | [diff] [blame] | 2017 | fn = fn_add_blocks(fn, 1); |
| 2018 | |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2019 | /* Now establish a new TBF for the RA UPDATE COMPLETE (new TLLI) */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2020 | ul_tbf = establish_ul_tbf_two_phase(bts, ts_no, tlli2, &fn, qta, |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2021 | ms_class, 0); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2022 | |
| 2023 | ms2 = ul_tbf->ms(); |
| 2024 | |
| 2025 | /* The PCU cannot know yet, that both TBF belong to the same MS */ |
| 2026 | OSMO_ASSERT(ms1 != ms2); |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2027 | print_ms(ms1, true); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2028 | |
| 2029 | /* Send some downlink data along with the new TLLI and the IMSI so that |
| 2030 | * the PCU can see, that both MS objects belong to same MS */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2031 | send_dl_data(bts, tlli2, imsi, (const uint8_t *)"DATA", 4); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2032 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2033 | ms = bts_ms_by_imsi(bts, imsi); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2034 | OSMO_ASSERT(ms == ms2); |
| 2035 | |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2036 | print_ms(ms2, false); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2037 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2038 | ms = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2039 | OSMO_ASSERT(ms == NULL); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2040 | ms = bts_ms_by_tlli(bts, tlli2, GSM_RESERVED_TMSI); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2041 | OSMO_ASSERT(ms == ms2); |
| 2042 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 2043 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2044 | fprintf(stderr, "=== end %s ===\n", __func__); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2045 | } |
| 2046 | |
| 2047 | static void test_tbf_dl_flow_and_rach_two_phase() |
| 2048 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 2049 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 2050 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2051 | int ts_no = 7; |
| 2052 | uint32_t fn = 2654218; |
| 2053 | uint16_t qta = 31; |
| 2054 | uint32_t tlli1 = 0xf1223344; |
| 2055 | const char *imsi = "0011223344"; |
| 2056 | uint8_t ms_class = 1; |
| 2057 | gprs_rlcmac_ul_tbf *ul_tbf; |
| 2058 | gprs_rlcmac_dl_tbf *dl_tbf; |
| 2059 | GprsMs *ms, *ms1, *ms2; |
| 2060 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2061 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2062 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2063 | setup_bts(bts, ts_no, 1); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2064 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2065 | ul_tbf = establish_ul_tbf_two_phase(bts, ts_no, tlli1, &fn, qta, |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2066 | ms_class, 0); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2067 | |
| 2068 | ms1 = ul_tbf->ms(); |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2069 | print_ta_tlli(ul_tbf, false); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2070 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2071 | send_dl_data(bts, tlli1, imsi, (const uint8_t *)"DATA 1 *************", 20); |
| 2072 | send_dl_data(bts, tlli1, imsi, (const uint8_t *)"DATA 2 *************", 20); |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2073 | print_ms(ms1, true); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2074 | |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2075 | OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms1)) == 2); |
| 2076 | dl_tbf = ms_dl_tbf(ms1); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2077 | OSMO_ASSERT(dl_tbf != NULL); |
| 2078 | |
| 2079 | /* Get rid of old UL TBF */ |
| 2080 | tbf_free(ul_tbf); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2081 | ms = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2082 | OSMO_ASSERT(ms1 == ms); |
| 2083 | |
| 2084 | /* Now establish a new UL TBF, this will consume one LLC packet */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2085 | ul_tbf = establish_ul_tbf_two_phase(bts, ts_no, tlli1, &fn, qta, |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2086 | ms_class, 0); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2087 | |
| 2088 | ms2 = ul_tbf->ms(); |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2089 | print_ms(ms2, false); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2090 | |
| 2091 | /* This should be the same MS object */ |
| 2092 | OSMO_ASSERT(ms2 == ms1); |
| 2093 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2094 | ms = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2095 | OSMO_ASSERT(ms2 == ms); |
| 2096 | |
Jacob Erlbeck | c8cbfc2 | 2015-09-01 11:38:40 +0200 | [diff] [blame] | 2097 | /* A DL TBF should still exist */ |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2098 | OSMO_ASSERT(ms_dl_tbf(ms)); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2099 | |
| 2100 | /* No queued packets should be lost */ |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2101 | OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms)) == 2); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2102 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 2103 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2104 | fprintf(stderr, "=== end %s ===\n", __func__); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2105 | } |
| 2106 | |
| 2107 | |
| 2108 | static void test_tbf_dl_flow_and_rach_single_phase() |
| 2109 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 2110 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 2111 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2112 | int ts_no = 7; |
| 2113 | uint32_t fn = 2654218; |
| 2114 | uint16_t qta = 31; |
| 2115 | uint32_t tlli1 = 0xf1223344; |
| 2116 | const char *imsi = "0011223344"; |
| 2117 | uint8_t ms_class = 1; |
| 2118 | gprs_rlcmac_ul_tbf *ul_tbf; |
| 2119 | gprs_rlcmac_dl_tbf *dl_tbf; |
| 2120 | GprsMs *ms, *ms1, *ms2; |
| 2121 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2122 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2123 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2124 | setup_bts(bts, ts_no, 1); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2125 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2126 | ul_tbf = establish_ul_tbf_two_phase(bts, ts_no, tlli1, &fn, qta, |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2127 | ms_class, 0); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2128 | |
| 2129 | ms1 = ul_tbf->ms(); |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2130 | print_ta_tlli(ul_tbf, false); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2131 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2132 | send_dl_data(bts, tlli1, imsi, (const uint8_t *)"DATA 1 *************", 20); |
| 2133 | send_dl_data(bts, tlli1, imsi, (const uint8_t *)"DATA 2 *************", 20); |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2134 | print_ms(ms1, true); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2135 | |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2136 | OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms1)) == 2); |
| 2137 | dl_tbf = ms_dl_tbf(ms1); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2138 | OSMO_ASSERT(dl_tbf != NULL); |
| 2139 | |
| 2140 | /* Get rid of old UL TBF */ |
| 2141 | tbf_free(ul_tbf); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2142 | ms = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2143 | OSMO_ASSERT(ms1 == ms); |
| 2144 | |
| 2145 | /* Now establish a new UL TBF */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2146 | ul_tbf = establish_ul_tbf_single_phase(bts, ts_no, tlli1, &fn, qta); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2147 | |
| 2148 | ms2 = ul_tbf->ms(); |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2149 | print_ms(ms2, false); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2150 | |
| 2151 | /* There should be a different MS object */ |
| 2152 | OSMO_ASSERT(ms2 != ms1); |
| 2153 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2154 | ms = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2155 | OSMO_ASSERT(ms2 == ms); |
| 2156 | OSMO_ASSERT(ms1 != ms); |
| 2157 | |
Jacob Erlbeck | 5f93f85 | 2016-01-21 20:48:39 +0100 | [diff] [blame] | 2158 | /* DL TBF should be removed */ |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2159 | OSMO_ASSERT(!ms_dl_tbf(ms)); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2160 | |
| 2161 | /* No queued packets should be lost */ |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2162 | OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms)) == 2); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2163 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 2164 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2165 | fprintf(stderr, "=== end %s ===\n", __func__); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 2166 | } |
| 2167 | |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2168 | static void test_tbf_dl_reuse() |
| 2169 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 2170 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 2171 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2172 | int ts_no = 7; |
| 2173 | uint32_t fn = 2654218; |
| 2174 | uint16_t qta = 31; |
| 2175 | uint32_t tlli1 = 0xf1223344; |
| 2176 | const char *imsi = "0011223344"; |
| 2177 | uint8_t ms_class = 1; |
| 2178 | gprs_rlcmac_ul_tbf *ul_tbf; |
| 2179 | gprs_rlcmac_dl_tbf *dl_tbf1, *dl_tbf2; |
| 2180 | GprsMs *ms1, *ms2; |
| 2181 | unsigned i; |
| 2182 | RlcMacUplink_t ulreq = {0}; |
| 2183 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2184 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2185 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2186 | setup_bts(bts, ts_no, 1); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2187 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2188 | ul_tbf = establish_ul_tbf_two_phase(bts, ts_no, tlli1, &fn, qta, |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2189 | ms_class, 0); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2190 | |
| 2191 | ms1 = ul_tbf->ms(); |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2192 | print_ta_tlli(ul_tbf, false); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2193 | |
| 2194 | /* Send some LLC frames */ |
| 2195 | for (i = 0; i < 40; i++) { |
| 2196 | char buf[32]; |
| 2197 | int rc; |
| 2198 | |
| 2199 | rc = snprintf(buf, sizeof(buf), "LLC PACKET %02i", i); |
| 2200 | OSMO_ASSERT(rc > 0); |
| 2201 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2202 | send_dl_data(bts, tlli1, imsi, (const uint8_t *)buf, rc); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2203 | } |
| 2204 | |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2205 | print_ms(ms1, true); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2206 | |
| 2207 | /* Send Packet Downlink Assignment to MS */ |
| 2208 | request_dl_rlc_block(ul_tbf, &fn); |
| 2209 | |
| 2210 | /* Ack it */ |
| 2211 | send_control_ack(ul_tbf); |
| 2212 | |
| 2213 | /* Transmit all data */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2214 | transmit_dl_data(bts, tlli1, &fn); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2215 | OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms1)) == 0); |
| 2216 | OSMO_ASSERT(ms_dl_tbf(ms1)); |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 2217 | OSMO_ASSERT(ms_dl_tbf(ms1)->state_is(TBF_ST_FINISHED)); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2218 | |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2219 | dl_tbf1 = ms_dl_tbf(ms1); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2220 | |
| 2221 | /* Send some LLC frames */ |
| 2222 | for (i = 0; i < 10; i++) { |
| 2223 | char buf[32]; |
| 2224 | int rc; |
| 2225 | |
| 2226 | rc = snprintf(buf, sizeof(buf), "LLC PACKET %02i (TBF 2)", i); |
| 2227 | OSMO_ASSERT(rc > 0); |
| 2228 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2229 | send_dl_data(bts, tlli1, imsi, (const uint8_t *)buf, rc); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2230 | } |
| 2231 | |
Pau Espin Pedrol | 422636d | 2021-09-28 15:59:35 +0200 | [diff] [blame] | 2232 | /* Drop first DL_ACK poll queued */ |
| 2233 | send_empty_block(dl_tbf1, dl_tbf1->control_ts, get_poll_fn(dl_tbf1, dl_tbf1->control_ts)); |
| 2234 | |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2235 | /* Fake Final DL Ack/Nack */ |
| 2236 | ulreq.u.MESSAGE_TYPE = MT_PACKET_DOWNLINK_ACK_NACK; |
| 2237 | Packet_Downlink_Ack_Nack_t *ack = &ulreq.u.Packet_Downlink_Ack_Nack; |
| 2238 | |
| 2239 | ack->PayloadType = GPRS_RLCMAC_CONTROL_BLOCK; |
| 2240 | ack->DOWNLINK_TFI = dl_tbf1->tfi(); |
| 2241 | ack->Ack_Nack_Description.FINAL_ACK_INDICATION = 1; |
| 2242 | |
Pau Espin Pedrol | 16e1678 | 2021-03-29 19:10:19 +0200 | [diff] [blame] | 2243 | send_ul_mac_block(bts, 0, dl_tbf1->control_ts, &ulreq, get_poll_fn(dl_tbf1, dl_tbf1->control_ts)); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2244 | |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 2245 | OSMO_ASSERT(dl_tbf1->state_is(TBF_ST_WAIT_RELEASE)); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2246 | |
| 2247 | request_dl_rlc_block(dl_tbf1, &fn); |
| 2248 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2249 | ms2 = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2250 | OSMO_ASSERT(ms2 == ms1); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2251 | OSMO_ASSERT(ms_dl_tbf(ms2)); |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 2252 | OSMO_ASSERT(ms_dl_tbf(ms2)->state_is(TBF_ST_ASSIGN)); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2253 | |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2254 | dl_tbf2 = ms_dl_tbf(ms2); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2255 | |
| 2256 | OSMO_ASSERT(dl_tbf1 != dl_tbf2); |
| 2257 | |
| 2258 | send_control_ack(dl_tbf1); |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 2259 | OSMO_ASSERT(dl_tbf2->state_is(TBF_ST_FLOW)); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2260 | |
| 2261 | /* Transmit all data */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2262 | transmit_dl_data(bts, tlli1, &fn); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2263 | OSMO_ASSERT(llc_queue_size(ms_llc_queue(ms2)) == 0); |
| 2264 | OSMO_ASSERT(ms_dl_tbf(ms2)); |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 2265 | OSMO_ASSERT(ms_dl_tbf(ms2)->state_is(TBF_ST_FINISHED)); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2266 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 2267 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2268 | fprintf(stderr, "=== end %s ===\n", __func__); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 2269 | } |
| 2270 | |
Jacob Erlbeck | 9b3d7e0 | 2016-01-19 10:44:42 +0100 | [diff] [blame] | 2271 | static void test_tbf_gprs_egprs() |
| 2272 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 2273 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 2274 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Jacob Erlbeck | 9b3d7e0 | 2016-01-19 10:44:42 +0100 | [diff] [blame] | 2275 | uint8_t ts_no = 4; |
| 2276 | uint8_t ms_class = 45; |
| 2277 | int rc = 0; |
| 2278 | uint32_t tlli = 0xc0006789; |
| 2279 | const char *imsi = "001001123456789"; |
| 2280 | unsigned delay_csec = 1000; |
| 2281 | |
| 2282 | uint8_t buf[256] = {0}; |
| 2283 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2284 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | 9b3d7e0 | 2016-01-19 10:44:42 +0100 | [diff] [blame] | 2285 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2286 | bts->pcu->nsi = gprs_ns2_instantiate(tall_pcu_ctx, gprs_ns_prim_cb, NULL); |
| 2287 | if (!bts->pcu->nsi) { |
Alexander Couzens | 5c3783b | 2019-05-25 05:41:18 +0200 | [diff] [blame] | 2288 | LOGP(DBSSGP, LOGL_ERROR, "Failed to create NS instance\n"); |
| 2289 | abort(); |
| 2290 | } |
| 2291 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2292 | setup_bts(bts, ts_no); |
Jacob Erlbeck | 9b3d7e0 | 2016-01-19 10:44:42 +0100 | [diff] [blame] | 2293 | |
| 2294 | /* EGPRS-only */ |
Jacob Erlbeck | 9b3d7e0 | 2016-01-19 10:44:42 +0100 | [diff] [blame] | 2295 | |
Alexander Couzens | 290d903 | 2020-09-16 21:52:02 +0200 | [diff] [blame] | 2296 | gprs_bssgp_init(bts, 3234, 3234, 1, 1, false, 0, 0, 0); |
Jacob Erlbeck | 9b3d7e0 | 2016-01-19 10:44:42 +0100 | [diff] [blame] | 2297 | |
| 2298 | /* Does not support EGPRS */ |
Pau Espin Pedrol | 8a35e64 | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 2299 | rc = dl_tbf_handle(bts, tlli, 0, imsi, ms_class, 0, |
Jacob Erlbeck | 9b3d7e0 | 2016-01-19 10:44:42 +0100 | [diff] [blame] | 2300 | delay_csec, buf, sizeof(buf)); |
| 2301 | |
Pau Espin Pedrol | 569f0d2 | 2020-10-27 14:45:20 +0100 | [diff] [blame] | 2302 | OSMO_ASSERT(rc == 0); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2303 | fprintf(stderr, "=== end %s ===\n", __func__); |
Jacob Erlbeck | 9b3d7e0 | 2016-01-19 10:44:42 +0100 | [diff] [blame] | 2304 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 2305 | TALLOC_FREE(the_pcu); |
Jacob Erlbeck | 9b3d7e0 | 2016-01-19 10:44:42 +0100 | [diff] [blame] | 2306 | } |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 2307 | |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2308 | static inline void ws_check(gprs_rlcmac_dl_tbf *dl_tbf, const char *test, uint8_t exp_slots, uint16_t exp_ws, |
Pau Espin Pedrol | bf5e3cb | 2022-05-09 16:31:22 +0200 | [diff] [blame] | 2309 | bool free) |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2310 | { |
| 2311 | if (!dl_tbf) { |
| 2312 | fprintf(stderr, "%s(): FAILED (NULL TBF)\n", test); |
| 2313 | return; |
| 2314 | } |
| 2315 | |
| 2316 | fprintf(stderr, "DL TBF slots: 0x%02x, N: %d, WS: %d", |
| 2317 | dl_tbf->dl_slots(), |
| 2318 | pcu_bitcount(dl_tbf->dl_slots()), |
| 2319 | dl_tbf->window_size()); |
| 2320 | |
| 2321 | if (pcu_bitcount(dl_tbf->dl_slots()) != exp_slots || dl_tbf->window_size() != exp_ws) |
| 2322 | fprintf(stderr, "%s(): DL TBF FAILED: dl_slots = %u (exp. %u), WS = %u (exp. %u)", |
| 2323 | test, pcu_bitcount(dl_tbf->dl_slots()), 4, dl_tbf->window_size(), 128 + 4 * 64); |
| 2324 | |
| 2325 | fprintf(stderr, "\n"); |
| 2326 | |
| 2327 | if (free) |
| 2328 | tbf_free(dl_tbf); |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2329 | } |
| 2330 | |
Jacob Erlbeck | 36df774 | 2016-01-19 15:53:30 +0100 | [diff] [blame] | 2331 | static void test_tbf_ws() |
| 2332 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 2333 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 2334 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Pau Espin Pedrol | 322456e | 2020-05-08 18:15:59 +0200 | [diff] [blame] | 2335 | GprsMs *ms; |
Jacob Erlbeck | 36df774 | 2016-01-19 15:53:30 +0100 | [diff] [blame] | 2336 | uint8_t ts_no = 4; |
| 2337 | uint8_t ms_class = 12; |
| 2338 | gprs_rlcmac_dl_tbf *dl_tbf; |
| 2339 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2340 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | 36df774 | 2016-01-19 15:53:30 +0100 | [diff] [blame] | 2341 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2342 | bts->pcu->nsi = gprs_ns2_instantiate(tall_pcu_ctx, gprs_ns_prim_cb, NULL); |
| 2343 | if (!bts->pcu->nsi) { |
Alexander Couzens | 5c3783b | 2019-05-25 05:41:18 +0200 | [diff] [blame] | 2344 | LOGP(DBSSGP, LOGL_ERROR, "Failed to create NS instance\n"); |
| 2345 | abort(); |
| 2346 | } |
| 2347 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2348 | setup_bts(bts, ts_no); |
Jacob Erlbeck | 36df774 | 2016-01-19 15:53:30 +0100 | [diff] [blame] | 2349 | |
Pau Espin Pedrol | 519d071 | 2021-01-14 14:30:03 +0100 | [diff] [blame] | 2350 | the_pcu->vty.ws_base = 128; |
| 2351 | the_pcu->vty.ws_pdch = 64; |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 2352 | the_pcu->alloc_algorithm = alloc_algorithm_b; |
Jacob Erlbeck | 36df774 | 2016-01-19 15:53:30 +0100 | [diff] [blame] | 2353 | bts->trx[0].pdch[2].enable(); |
| 2354 | bts->trx[0].pdch[3].enable(); |
Pau Espin Pedrol | 4f67a9b | 2021-06-30 16:03:06 +0200 | [diff] [blame] | 2355 | /* bts->trx[0].pdch[4].enable(); Already enabled during setup_bts() */ |
Jacob Erlbeck | 36df774 | 2016-01-19 15:53:30 +0100 | [diff] [blame] | 2356 | bts->trx[0].pdch[5].enable(); |
| 2357 | |
Alexander Couzens | 290d903 | 2020-09-16 21:52:02 +0200 | [diff] [blame] | 2358 | gprs_bssgp_init(bts, 4234, 4234, 1, 1, false, 0, 0, 0); |
Jacob Erlbeck | 36df774 | 2016-01-19 15:53:30 +0100 | [diff] [blame] | 2359 | |
| 2360 | /* Does no support EGPRS */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2361 | ms = bts_alloc_ms(bts, ms_class, 0); |
Pau Espin Pedrol | 8757384 | 2022-10-26 20:23:45 +0200 | [diff] [blame] | 2362 | dl_tbf = dl_tbf_alloc(bts, ms, 0, false); |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2363 | |
Pau Espin Pedrol | bf5e3cb | 2022-05-09 16:31:22 +0200 | [diff] [blame] | 2364 | ws_check(dl_tbf, __func__, 4, 64, true); |
Jacob Erlbeck | 36df774 | 2016-01-19 15:53:30 +0100 | [diff] [blame] | 2365 | |
| 2366 | /* EGPRS-only */ |
Jacob Erlbeck | 36df774 | 2016-01-19 15:53:30 +0100 | [diff] [blame] | 2367 | |
| 2368 | /* Does support EGPRS */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2369 | ms = bts_alloc_ms(bts, ms_class, ms_class); |
Pau Espin Pedrol | 8757384 | 2022-10-26 20:23:45 +0200 | [diff] [blame] | 2370 | dl_tbf = dl_tbf_alloc(bts, ms, 0, false); |
Jacob Erlbeck | 36df774 | 2016-01-19 15:53:30 +0100 | [diff] [blame] | 2371 | |
Pau Espin Pedrol | bf5e3cb | 2022-05-09 16:31:22 +0200 | [diff] [blame] | 2372 | ws_check(dl_tbf, __func__, 4, 128 + 4 * 64, true); |
| 2373 | fprintf(stderr, "=== end %s ===\n", __func__); |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 2374 | TALLOC_FREE(the_pcu); |
Jacob Erlbeck | 36df774 | 2016-01-19 15:53:30 +0100 | [diff] [blame] | 2375 | } |
| 2376 | |
Aravind Sirsikar | 3c2eaeb | 2016-08-30 15:39:04 +0530 | [diff] [blame] | 2377 | static void test_tbf_update_ws(void) |
| 2378 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 2379 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 2380 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Pau Espin Pedrol | 322456e | 2020-05-08 18:15:59 +0200 | [diff] [blame] | 2381 | GprsMs *ms; |
Aravind Sirsikar | 3c2eaeb | 2016-08-30 15:39:04 +0530 | [diff] [blame] | 2382 | uint8_t ts_no = 4; |
| 2383 | uint8_t ms_class = 11; |
| 2384 | gprs_rlcmac_dl_tbf *dl_tbf; |
| 2385 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2386 | fprintf(stderr, "=== start %s ===\n", __func__); |
Aravind Sirsikar | 3c2eaeb | 2016-08-30 15:39:04 +0530 | [diff] [blame] | 2387 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2388 | bts->pcu->nsi = gprs_ns2_instantiate(tall_pcu_ctx, gprs_ns_prim_cb, NULL); |
| 2389 | if (!bts->pcu->nsi) { |
Alexander Couzens | 5c3783b | 2019-05-25 05:41:18 +0200 | [diff] [blame] | 2390 | LOGP(DBSSGP, LOGL_ERROR, "Failed to create NS instance\n"); |
| 2391 | abort(); |
| 2392 | } |
| 2393 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2394 | setup_bts(bts, ts_no); |
Aravind Sirsikar | 3c2eaeb | 2016-08-30 15:39:04 +0530 | [diff] [blame] | 2395 | |
Pau Espin Pedrol | 519d071 | 2021-01-14 14:30:03 +0100 | [diff] [blame] | 2396 | the_pcu->vty.ws_base = 128; |
| 2397 | the_pcu->vty.ws_pdch = 64; |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 2398 | the_pcu->alloc_algorithm = alloc_algorithm_b; |
Aravind Sirsikar | 3c2eaeb | 2016-08-30 15:39:04 +0530 | [diff] [blame] | 2399 | bts->trx[0].pdch[2].enable(); |
| 2400 | bts->trx[0].pdch[3].enable(); |
Pau Espin Pedrol | 4f67a9b | 2021-06-30 16:03:06 +0200 | [diff] [blame] | 2401 | /* bts->trx[0].pdch[4].enable(); Already enabled during setup_bts()) */ |
Aravind Sirsikar | 3c2eaeb | 2016-08-30 15:39:04 +0530 | [diff] [blame] | 2402 | bts->trx[0].pdch[5].enable(); |
| 2403 | |
Alexander Couzens | 290d903 | 2020-09-16 21:52:02 +0200 | [diff] [blame] | 2404 | gprs_bssgp_init(bts, 5234, 5234, 1, 1, false, 0, 0, 0); |
Aravind Sirsikar | 3c2eaeb | 2016-08-30 15:39:04 +0530 | [diff] [blame] | 2405 | |
| 2406 | /* EGPRS-only */ |
Aravind Sirsikar | 3c2eaeb | 2016-08-30 15:39:04 +0530 | [diff] [blame] | 2407 | |
| 2408 | /* Does support EGPRS */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2409 | ms = bts_alloc_ms(bts, ms_class, ms_class); |
Pau Espin Pedrol | 8757384 | 2022-10-26 20:23:45 +0200 | [diff] [blame] | 2410 | dl_tbf = dl_tbf_alloc(bts, ms, 0, true); |
Aravind Sirsikar | 3c2eaeb | 2016-08-30 15:39:04 +0530 | [diff] [blame] | 2411 | |
Pau Espin Pedrol | bf5e3cb | 2022-05-09 16:31:22 +0200 | [diff] [blame] | 2412 | ws_check(dl_tbf, __func__, 1, 128 + 1 * 64, false); |
Aravind Sirsikar | 3c2eaeb | 2016-08-30 15:39:04 +0530 | [diff] [blame] | 2413 | |
| 2414 | dl_tbf->update(); |
| 2415 | |
Aravind Sirsikar | 0ee31cf | 2016-09-15 17:54:46 +0530 | [diff] [blame] | 2416 | /* window size should be 384 */ |
Pau Espin Pedrol | bf5e3cb | 2022-05-09 16:31:22 +0200 | [diff] [blame] | 2417 | ws_check(dl_tbf, __func__, 4, 128 + 4 * 64, true); |
| 2418 | fprintf(stderr, "=== end %s ===\n", __func__); |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 2419 | TALLOC_FREE(the_pcu); |
Aravind Sirsikar | 3c2eaeb | 2016-08-30 15:39:04 +0530 | [diff] [blame] | 2420 | } |
| 2421 | |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 2422 | static void test_tbf_puan_urbb_len(void) |
| 2423 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 2424 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 2425 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 2426 | int ts_no = 7; |
| 2427 | uint32_t fn = 2654218; |
| 2428 | uint16_t qta = 31; |
| 2429 | uint32_t tlli = 0xf1223344; |
| 2430 | const char *imsi = "0011223344"; |
| 2431 | uint8_t ms_class = 1; |
| 2432 | uint8_t egprs_ms_class = 1; |
| 2433 | gprs_rlcmac_ul_tbf *ul_tbf; |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 2434 | uint8_t test_data[256]; |
| 2435 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2436 | fprintf(stderr, "=== start %s ===\n", __func__); |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 2437 | |
| 2438 | memset(test_data, 1, sizeof(test_data)); |
| 2439 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2440 | setup_bts(bts, ts_no, 4); |
| 2441 | bts->initial_mcs_dl = 9; |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 2442 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2443 | ul_tbf = puan_urbb_len_issue(bts, ts_no, tlli, &fn, qta, |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 2444 | ms_class, egprs_ms_class); |
| 2445 | |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2446 | print_ta_tlli(ul_tbf, true); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2447 | send_dl_data(bts, tlli, imsi, test_data, sizeof(test_data)); |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 2448 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 2449 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2450 | fprintf(stderr, "=== end %s ===\n", __func__); |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 2451 | } |
| 2452 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2453 | static gprs_rlcmac_ul_tbf *tbf_li_decoding(struct gprs_rlcmac_bts *bts, |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2454 | uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta, |
| 2455 | uint8_t ms_class, uint8_t egprs_ms_class) |
| 2456 | { |
| 2457 | GprsMs *ms; |
| 2458 | uint32_t rach_fn = *fn - 51; |
| 2459 | uint32_t sba_fn = *fn + 52; |
| 2460 | uint8_t trx_no = 0; |
Neels Hofmeyr | d34646a | 2017-02-08 17:07:40 +0100 | [diff] [blame] | 2461 | int tfi = 0; |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2462 | gprs_rlcmac_ul_tbf *ul_tbf; |
| 2463 | struct gprs_rlcmac_pdch *pdch; |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2464 | RlcMacUplink_t ulreq = {0}; |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2465 | struct gprs_rlc_ul_header_egprs_3 *egprs3 = NULL; |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2466 | Packet_Resource_Request_t *presreq = NULL; |
| 2467 | MS_Radio_Access_capability_t *pmsradiocap = NULL; |
| 2468 | Multislot_capability_t *pmultislotcap = NULL; |
| 2469 | |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2470 | /* needed to set last_rts_fn in the PDCH object */ |
| 2471 | request_dl_rlc_block(bts, trx_no, ts_no, fn); |
| 2472 | |
| 2473 | /* |
| 2474 | * simulate RACH, this sends an Immediate |
| 2475 | * Assignment Uplink on the AGCH |
| 2476 | */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2477 | bts_handle_rach(bts, 0x73, rach_fn, qta); |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2478 | |
| 2479 | /* get next free TFI */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2480 | tfi = bts_tfi_find_free(bts, GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2481 | |
| 2482 | /* fake a resource request */ |
| 2483 | ulreq.u.MESSAGE_TYPE = MT_PACKET_RESOURCE_REQUEST; |
| 2484 | presreq = &ulreq.u.Packet_Resource_Request; |
| 2485 | presreq->PayloadType = GPRS_RLCMAC_CONTROL_BLOCK; |
| 2486 | presreq->ID.UnionType = 1; /* != 0 */ |
| 2487 | presreq->ID.u.TLLI = tlli; |
Pau Espin Pedrol | e50ce6e | 2020-03-23 18:49:16 +0100 | [diff] [blame] | 2488 | presreq->Exist_MS_Radio_Access_capability2 = 1; |
| 2489 | pmsradiocap = &presreq->MS_Radio_Access_capability2; |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2490 | pmsradiocap->Count_MS_RA_capability_value = 1; |
| 2491 | pmsradiocap->MS_RA_capability_value[0].u.Content. |
| 2492 | Exist_Multislot_capability = 1; |
| 2493 | pmultislotcap = &pmsradiocap->MS_RA_capability_value[0]. |
| 2494 | u.Content.Multislot_capability; |
| 2495 | |
| 2496 | pmultislotcap->Exist_GPRS_multislot_class = 1; |
| 2497 | pmultislotcap->GPRS_multislot_class = ms_class; |
| 2498 | if (egprs_ms_class) { |
| 2499 | pmultislotcap->Exist_EGPRS_multislot_class = 1; |
| 2500 | pmultislotcap->EGPRS_multislot_class = ms_class; |
| 2501 | } |
| 2502 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2503 | send_ul_mac_block(bts, trx_no, ts_no, &ulreq, sba_fn); |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2504 | |
| 2505 | /* check the TBF */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2506 | ul_tbf = bts_ul_tbf_by_tfi(bts, tfi, trx_no, ts_no); |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2507 | OSMO_ASSERT(ul_tbf); |
| 2508 | OSMO_ASSERT(ul_tbf->ta() == qta / 4); |
| 2509 | |
| 2510 | /* send packet uplink assignment */ |
| 2511 | *fn = sba_fn; |
| 2512 | request_dl_rlc_block(ul_tbf, fn); |
| 2513 | |
| 2514 | /* send real acknowledgement */ |
| 2515 | send_control_ack(ul_tbf); |
| 2516 | |
| 2517 | check_tbf(ul_tbf); |
| 2518 | |
| 2519 | uint8_t data_msg[49] = {0}; |
| 2520 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2521 | pdch = &bts->trx[trx_no].pdch[ts_no]; |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2522 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2523 | ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2524 | OSMO_ASSERT(ms != NULL); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2525 | OSMO_ASSERT(ms_ta(ms) == qta/4); |
| 2526 | OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2527 | |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2528 | egprs3 = (struct gprs_rlc_ul_header_egprs_3 *) data_msg; |
| 2529 | egprs3->si = 0; |
| 2530 | egprs3->r = 1; |
| 2531 | egprs3->cv = 7; |
| 2532 | egprs3->tfi_hi = tfi & 0x03; |
| 2533 | egprs3->tfi_lo = (tfi & 0x1c) >> 2; |
| 2534 | egprs3->bsn1_hi = 0; |
| 2535 | egprs3->bsn1_lo = 0; |
| 2536 | egprs3->cps_hi = 1; |
| 2537 | data_msg[3] = 0xff; |
| 2538 | egprs3->pi = 0; |
| 2539 | egprs3->cps_lo = 1; |
| 2540 | egprs3->rsb = 0; |
| 2541 | egprs3->spb = 0; |
| 2542 | egprs3->pi = 0; |
| 2543 | pdch->rcv_block(data_msg, 49, *fn, &meas); |
| 2544 | |
| 2545 | egprs3->bsn1_hi = 1; |
| 2546 | egprs3->bsn1_lo = 0; |
| 2547 | data_msg[3] = 0x7f; |
| 2548 | egprs3->cps_lo = 1; |
| 2549 | egprs3->rsb = 0; |
| 2550 | egprs3->spb = 0; |
| 2551 | egprs3->pi = 0; |
| 2552 | data_msg[4] = 0x2; |
| 2553 | data_msg[5] = 0x0; |
| 2554 | pdch->rcv_block(data_msg, 49, *fn, &meas); |
| 2555 | |
Pau Espin Pedrol | 1463383 | 2022-03-31 19:08:07 +0200 | [diff] [blame] | 2556 | OSMO_ASSERT(ul_tbf->m_llc.index == 43); |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2557 | |
| 2558 | return ul_tbf; |
| 2559 | } |
| 2560 | |
| 2561 | static void test_tbf_li_decoding(void) |
| 2562 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 2563 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 2564 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2565 | int ts_no = 7; |
| 2566 | uint32_t fn = 2654218; |
| 2567 | uint16_t qta = 31; |
| 2568 | uint32_t tlli = 0xf1223344; |
| 2569 | const char *imsi = "0011223344"; |
| 2570 | uint8_t ms_class = 1; |
| 2571 | uint8_t egprs_ms_class = 1; |
| 2572 | gprs_rlcmac_ul_tbf *ul_tbf; |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2573 | uint8_t test_data[256]; |
| 2574 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2575 | fprintf(stderr, "=== start %s ===\n", __func__); |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2576 | |
| 2577 | memset(test_data, 1, sizeof(test_data)); |
| 2578 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2579 | setup_bts(bts, ts_no, 4); |
| 2580 | bts->initial_mcs_dl = 9; |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2581 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2582 | ul_tbf = tbf_li_decoding(bts, ts_no, tlli, &fn, qta, |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2583 | ms_class, egprs_ms_class); |
| 2584 | |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2585 | print_ta_tlli(ul_tbf, true); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2586 | send_dl_data(bts, tlli, imsi, test_data, sizeof(test_data)); |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2587 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 2588 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2589 | fprintf(stderr, "=== end %s ===\n", __func__); |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 2590 | } |
| 2591 | |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 2592 | /* |
| 2593 | * Test that a bit within the uncompressed bitmap whose BSN is not within |
| 2594 | * the transmit window shall be ignored. See section 9.1.8.2.4 of 44.060 |
| 2595 | * version 7.27.0 Release 7. |
| 2596 | */ |
| 2597 | static void test_tbf_epdan_out_of_rx_window(void) |
| 2598 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 2599 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 2600 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 2601 | uint8_t ms_class = 11; |
| 2602 | uint8_t egprs_ms_class = 11; |
| 2603 | uint8_t trx_no; |
| 2604 | uint32_t tlli = 0xffeeddcc; |
| 2605 | gprs_rlcmac_dl_tbf *dl_tbf; |
| 2606 | int ts_no = 4; |
| 2607 | bitvec *block; |
| 2608 | uint8_t bits_data[RLC_EGPRS_MAX_WS/8]; |
| 2609 | bitvec bits; |
| 2610 | int bsn_begin, bsn_end; |
| 2611 | EGPRS_PD_AckNack_t *ack_nack; |
| 2612 | RlcMacUplink_t ul_control_block; |
| 2613 | gprs_rlc_v_b *prlcmvb; |
| 2614 | gprs_rlc_dl_window *prlcdlwindow; |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 2615 | int rc; |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 2616 | |
aravind sirsikar | cc4214a | 2016-12-09 16:12:42 +0530 | [diff] [blame] | 2617 | memset(&ul_control_block, 0, sizeof(RlcMacUplink_t)); |
| 2618 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2619 | fprintf(stderr, "=== start %s ===\n", __func__); |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 2620 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2621 | setup_bts(bts, ts_no); |
Pau Espin Pedrol | 924aaad | 2021-01-14 12:01:42 +0100 | [diff] [blame] | 2622 | OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2031, 200, OSMO_TDEF_MS) == 0); |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 2623 | /* ARQ II */ |
Pau Espin Pedrol | 97296b2 | 2021-01-14 13:08:02 +0100 | [diff] [blame] | 2624 | the_pcu->vty.dl_arq_type = EGPRS_ARQ2; |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 2625 | |
| 2626 | /* |
| 2627 | * Simulate a message captured during over-the-air testing, |
| 2628 | * where the following values were observed: |
| 2629 | * v_a = 1176, vs = 1288, max sns = 2048, window size = 480. |
| 2630 | */ |
| 2631 | uint8_t data_msg[23] = {0x40, 0x20, 0x0b, 0xff, 0xd1, |
| 2632 | 0x61, 0x00, 0x3e, 0x0e, 0x51, 0x9f, |
| 2633 | 0xff, 0xff, 0xfb, 0x80, 0x00, 0x00, |
| 2634 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 2635 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2636 | dl_tbf = create_dl_tbf(bts, ms_class, egprs_ms_class, &trx_no); |
Pau Espin Pedrol | 8abe13c | 2022-10-21 18:49:48 +0200 | [diff] [blame] | 2637 | ms_confirm_tlli(dl_tbf->ms(), tlli); |
Pau Espin Pedrol | b3f2397 | 2020-10-23 21:00:23 +0200 | [diff] [blame] | 2638 | prlcdlwindow = static_cast<gprs_rlc_dl_window *>(dl_tbf->window()); |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 2639 | prlcmvb = &prlcdlwindow->m_v_b; |
| 2640 | prlcdlwindow->m_v_s = 1288; |
| 2641 | prlcdlwindow->m_v_a = 1176; |
| 2642 | prlcdlwindow->set_sns(2048); |
| 2643 | prlcdlwindow->set_ws(480); |
| 2644 | prlcmvb->mark_unacked(1176); |
| 2645 | prlcmvb->mark_unacked(1177); |
| 2646 | prlcmvb->mark_unacked(1286); |
| 2647 | prlcmvb->mark_unacked(1287); |
| 2648 | |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 2649 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_FLOW)); |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 2650 | |
Alexander Couzens | ccde5c9 | 2017-02-04 03:10:08 +0100 | [diff] [blame] | 2651 | block = bitvec_alloc(23, tall_pcu_ctx); |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 2652 | |
| 2653 | bitvec_unpack(block, data_msg); |
| 2654 | |
| 2655 | bits.data = bits_data; |
| 2656 | bits.data_len = sizeof(bits_data); |
| 2657 | bits.cur_bit = 0; |
| 2658 | |
Pau Espin Pedrol | 5e300ce | 2020-02-03 17:18:03 +0100 | [diff] [blame] | 2659 | rc = decode_gsm_rlcmac_uplink(block, &ul_control_block); |
| 2660 | OSMO_ASSERT(rc == 0); |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 2661 | |
| 2662 | ack_nack = &ul_control_block.u.Egprs_Packet_Downlink_Ack_Nack; |
| 2663 | |
| 2664 | OSMO_ASSERT(prlcmvb->is_unacked(1176)); |
| 2665 | OSMO_ASSERT(prlcmvb->is_unacked(1177)); |
| 2666 | OSMO_ASSERT(prlcmvb->is_unacked(1286)); |
| 2667 | OSMO_ASSERT(prlcmvb->is_unacked(1287)); |
| 2668 | |
| 2669 | Decoding::decode_egprs_acknack_bits( |
| 2670 | &ack_nack->EGPRS_AckNack.Desc, &bits, |
Pau Espin Pedrol | b3f2397 | 2020-10-23 21:00:23 +0200 | [diff] [blame] | 2671 | &bsn_begin, &bsn_end, prlcdlwindow); |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 2672 | |
| 2673 | dl_tbf->rcvd_dl_ack( |
| 2674 | ack_nack->EGPRS_AckNack.Desc.FINAL_ACK_INDICATION, |
| 2675 | bsn_begin, &bits); |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 2676 | |
aravind sirsikar | fb41afa | 2016-11-02 15:48:00 +0530 | [diff] [blame] | 2677 | OSMO_ASSERT(prlcmvb->is_invalid(1176)); |
| 2678 | OSMO_ASSERT(prlcmvb->is_invalid(1177)); |
| 2679 | OSMO_ASSERT(prlcmvb->is_acked(1286)); |
| 2680 | OSMO_ASSERT(prlcmvb->is_acked(1287)); |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 2681 | |
| 2682 | bitvec_free(block); |
| 2683 | tbf_free(dl_tbf); |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 2684 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2685 | fprintf(stderr, "=== end %s ===\n", __func__); |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 2686 | } |
| 2687 | |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 2688 | static void test_tbf_egprs_two_phase_spb(void) |
| 2689 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 2690 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 2691 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 2692 | int ts_no = 7; |
| 2693 | uint32_t fn = 2654218; |
| 2694 | uint16_t qta = 31; |
| 2695 | uint32_t tlli = 0xf1223344; |
| 2696 | const char *imsi = "0011223344"; |
| 2697 | uint8_t ms_class = 1; |
| 2698 | uint8_t egprs_ms_class = 1; |
| 2699 | gprs_rlcmac_ul_tbf *ul_tbf; |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 2700 | uint8_t test_data[256]; |
| 2701 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2702 | fprintf(stderr, "=== start %s ===\n", __func__); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 2703 | |
| 2704 | memset(test_data, 1, sizeof(test_data)); |
| 2705 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2706 | setup_bts(bts, ts_no, 4); |
| 2707 | bts->initial_mcs_dl = 9; |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 2708 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2709 | ul_tbf = establish_ul_tbf_two_phase_spb(bts, ts_no, tlli, &fn, qta, |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 2710 | ms_class, egprs_ms_class); |
| 2711 | |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2712 | print_ta_tlli(ul_tbf, true); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2713 | send_dl_data(bts, tlli, imsi, test_data, sizeof(test_data)); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 2714 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 2715 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2716 | fprintf(stderr, "=== end %s ===\n", __func__); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 2717 | } |
| 2718 | |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2719 | static void test_tbf_egprs_two_phase() |
| 2720 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 2721 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 2722 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2723 | int ts_no = 7; |
| 2724 | uint32_t fn = 2654218; |
| 2725 | uint16_t qta = 31; |
| 2726 | uint32_t tlli = 0xf1223344; |
| 2727 | const char *imsi = "0011223344"; |
| 2728 | uint8_t ms_class = 1; |
| 2729 | uint8_t egprs_ms_class = 1; |
| 2730 | gprs_rlcmac_ul_tbf *ul_tbf; |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2731 | uint8_t test_data[256]; |
| 2732 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2733 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2734 | |
| 2735 | memset(test_data, 1, sizeof(test_data)); |
| 2736 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2737 | setup_bts(bts, ts_no, 4); |
| 2738 | bts->initial_mcs_dl = 9; |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2739 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2740 | ul_tbf = establish_ul_tbf_two_phase(bts, ts_no, tlli, &fn, qta, |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2741 | ms_class, egprs_ms_class); |
| 2742 | |
Max | 4c112dc | 2018-02-01 16:49:23 +0100 | [diff] [blame] | 2743 | print_ta_tlli(ul_tbf, true); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2744 | send_dl_data(bts, tlli, imsi, test_data, sizeof(test_data)); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2745 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 2746 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2747 | fprintf(stderr, "=== end %s ===\n", __func__); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2748 | } |
| 2749 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2750 | static void establish_and_use_egprs_dl_tbf(struct gprs_rlcmac_bts *bts, int mcs) |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2751 | { |
| 2752 | unsigned i; |
| 2753 | uint8_t ms_class = 11; |
| 2754 | uint8_t egprs_ms_class = 11; |
| 2755 | uint32_t fn = 0; |
| 2756 | uint8_t trx_no; |
| 2757 | uint32_t tlli = 0xffeeddcc; |
| 2758 | uint8_t test_data[512]; |
| 2759 | |
| 2760 | uint8_t rbb[64/8]; |
| 2761 | |
| 2762 | gprs_rlcmac_dl_tbf *dl_tbf; |
| 2763 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2764 | fprintf(stderr, "Testing MCS-%d\n", mcs); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2765 | |
| 2766 | memset(test_data, 1, sizeof(test_data)); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2767 | bts->initial_mcs_dl = mcs; |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2768 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2769 | dl_tbf = create_dl_tbf(bts, ms_class, egprs_ms_class, &trx_no); |
Pau Espin Pedrol | 8abe13c | 2022-10-21 18:49:48 +0200 | [diff] [blame] | 2770 | ms_confirm_tlli(dl_tbf->ms(), tlli); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2771 | |
| 2772 | for (i = 0; i < sizeof(llc_data); i++) |
| 2773 | llc_data[i] = i%256; |
| 2774 | |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 2775 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_FLOW)); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2776 | |
| 2777 | /* Schedule a small LLC frame */ |
Pau Espin Pedrol | 14beef6 | 2022-10-26 19:44:07 +0200 | [diff] [blame] | 2778 | ms_append_llc_dl_data(dl_tbf->ms(), 1000, test_data, 10); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2779 | |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 2780 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_FLOW)); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2781 | |
| 2782 | /* Drain the queue */ |
Pau Espin Pedrol | 99360a3 | 2021-03-09 17:18:12 +0100 | [diff] [blame] | 2783 | while (dl_tbf->have_data()) { |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2784 | /* Request to send one RLC/MAC block */ |
| 2785 | request_dl_rlc_block(dl_tbf, &fn); |
Pau Espin Pedrol | 99360a3 | 2021-03-09 17:18:12 +0100 | [diff] [blame] | 2786 | } |
Pau Espin Pedrol | 16e1678 | 2021-03-29 19:10:19 +0200 | [diff] [blame] | 2787 | send_empty_block(dl_tbf, dl_tbf->control_ts, fn); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2788 | |
| 2789 | /* Schedule a large LLC frame */ |
Pau Espin Pedrol | 14beef6 | 2022-10-26 19:44:07 +0200 | [diff] [blame] | 2790 | ms_append_llc_dl_data(dl_tbf->ms(), 1000, test_data, sizeof(test_data)); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2791 | |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 2792 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_FLOW)); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2793 | |
| 2794 | /* Drain the queue */ |
Pau Espin Pedrol | 99360a3 | 2021-03-09 17:18:12 +0100 | [diff] [blame] | 2795 | while (dl_tbf->have_data()) { |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2796 | /* Request to send one RLC/MAC block */ |
| 2797 | request_dl_rlc_block(dl_tbf, &fn); |
Pau Espin Pedrol | 99360a3 | 2021-03-09 17:18:12 +0100 | [diff] [blame] | 2798 | } |
Pau Espin Pedrol | 16e1678 | 2021-03-29 19:10:19 +0200 | [diff] [blame] | 2799 | send_empty_block(dl_tbf, dl_tbf->control_ts, fn); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2800 | |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 2801 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_FLOW)); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2802 | |
Pau Espin Pedrol | afe189e | 2021-07-28 21:48:26 +0200 | [diff] [blame] | 2803 | _rcv_ack(true, dl_tbf, rbb); /* Receive a final ACK */ |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2804 | |
| 2805 | /* Clean up and ensure tbfs are in the correct state */ |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 2806 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_WAIT_RELEASE)); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 2807 | check_tbf(dl_tbf); |
| 2808 | tbf_free(dl_tbf); |
| 2809 | } |
| 2810 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2811 | static gprs_rlcmac_dl_tbf *tbf_init(struct gprs_rlcmac_bts *bts, |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 2812 | int mcs) |
| 2813 | { |
| 2814 | unsigned i; |
| 2815 | uint8_t ms_class = 11; |
| 2816 | uint8_t egprs_ms_class = 11; |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 2817 | uint8_t trx_no; |
| 2818 | uint32_t tlli = 0xffeeddcc; |
| 2819 | uint8_t test_data[512]; |
| 2820 | |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 2821 | gprs_rlcmac_dl_tbf *dl_tbf; |
| 2822 | |
| 2823 | memset(test_data, 1, sizeof(test_data)); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2824 | bts->initial_mcs_dl = mcs; |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 2825 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2826 | dl_tbf = create_dl_tbf(bts, ms_class, egprs_ms_class, &trx_no); |
Pau Espin Pedrol | 8abe13c | 2022-10-21 18:49:48 +0200 | [diff] [blame] | 2827 | ms_confirm_tlli(dl_tbf->ms(), tlli); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 2828 | |
| 2829 | for (i = 0; i < sizeof(test_data); i++) |
| 2830 | test_data[i] = i%256; |
| 2831 | |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 2832 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_FLOW)); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 2833 | |
| 2834 | /* Schedule a LLC frame |
| 2835 | * passing only 100 bytes, since it is enough to construct |
| 2836 | * 2 RLC data blocks. Which are enough to test Header Type 1 |
| 2837 | * cases |
| 2838 | */ |
Pau Espin Pedrol | 14beef6 | 2022-10-26 19:44:07 +0200 | [diff] [blame] | 2839 | ms_append_llc_dl_data(dl_tbf->ms(), 1000, test_data, 100); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 2840 | |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 2841 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_FLOW)); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 2842 | |
| 2843 | return dl_tbf; |
| 2844 | |
| 2845 | } |
| 2846 | |
| 2847 | static void tbf_cleanup(gprs_rlcmac_dl_tbf *dl_tbf) |
| 2848 | { |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 2849 | uint8_t rbb[64/8]; |
| 2850 | |
Pau Espin Pedrol | afe189e | 2021-07-28 21:48:26 +0200 | [diff] [blame] | 2851 | _rcv_ack(true, dl_tbf, rbb); /* Receive a final ACK */ |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 2852 | |
| 2853 | /* Clean up and ensure tbfs are in the correct state */ |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 2854 | OSMO_ASSERT(dl_tbf->state_is(TBF_ST_WAIT_RELEASE)); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 2855 | check_tbf(dl_tbf); |
| 2856 | tbf_free(dl_tbf); |
| 2857 | |
| 2858 | } |
| 2859 | |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 2860 | #define NACK(tbf, x) do { \ |
Pau Espin Pedrol | b3f2397 | 2020-10-23 21:00:23 +0200 | [diff] [blame] | 2861 | gprs_rlc_dl_window *w = static_cast<gprs_rlc_dl_window *>(tbf->window()); \ |
| 2862 | w->m_v_b.mark_nacked(x); \ |
| 2863 | OSMO_ASSERT(w->m_v_b.is_nacked(x)); \ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 2864 | } while(0) |
| 2865 | |
| 2866 | #define CHECK_UNACKED(tbf, cs, bsn) do { \ |
Pau Espin Pedrol | b3f2397 | 2020-10-23 21:00:23 +0200 | [diff] [blame] | 2867 | gprs_rlc_dl_window *w = static_cast<gprs_rlc_dl_window *>(tbf->window()); \ |
| 2868 | OSMO_ASSERT(w->m_v_b.is_unacked(bsn)); \ |
Max | 898dddb | 2019-03-12 15:50:57 +0100 | [diff] [blame] | 2869 | OSMO_ASSERT(mcs_chan_code(tbf->m_rlc.block(bsn)->cs_current_trans) == cs - 1); \ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 2870 | } while(0) |
| 2871 | |
| 2872 | #define CHECK_NACKED(tbf, cs, bsn) do { \ |
Pau Espin Pedrol | b3f2397 | 2020-10-23 21:00:23 +0200 | [diff] [blame] | 2873 | gprs_rlc_dl_window *w = static_cast<gprs_rlc_dl_window *>(tbf->window()); \ |
| 2874 | OSMO_ASSERT(w->m_v_b.is_nacked(bsn)); \ |
Max | 898dddb | 2019-03-12 15:50:57 +0100 | [diff] [blame] | 2875 | OSMO_ASSERT(mcs_chan_code(tbf->m_rlc.block(bsn)->cs_current_trans) == cs - 1); \ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 2876 | } while(0) |
| 2877 | |
| 2878 | #define MAKE_ACKED(m, tbf, fn, cs, check_unacked) do { \ |
| 2879 | m = tbf->create_dl_acked_block(fn, tbf->control_ts); \ |
| 2880 | OSMO_ASSERT(m); \ |
| 2881 | if (check_unacked) \ |
| 2882 | CHECK_UNACKED(tbf, cs, 0); \ |
| 2883 | else \ |
| 2884 | CHECK_NACKED(tbf, cs, 0); \ |
| 2885 | } while(0) |
| 2886 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2887 | static void egprs_spb_to_normal_validation(struct gprs_rlcmac_bts *bts, |
Neels Hofmeyr | d34646a | 2017-02-08 17:07:40 +0100 | [diff] [blame] | 2888 | unsigned int mcs, unsigned int demanded_mcs) |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2889 | { |
| 2890 | uint32_t fn = 0; |
| 2891 | gprs_rlcmac_dl_tbf *dl_tbf; |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2892 | uint16_t bsn1, bsn2, bsn3; |
| 2893 | struct msgb *msg; |
| 2894 | struct gprs_rlc_dl_header_egprs_3 *egprs3; |
| 2895 | struct gprs_rlc_dl_header_egprs_2 *egprs2; |
| 2896 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2897 | fprintf(stderr, "Testing retx for MCS %u to reseg_mcs %u\n", mcs, demanded_mcs); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2898 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2899 | dl_tbf = tbf_init(bts, mcs); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2900 | |
| 2901 | /* |
| 2902 | * Table 10.4.8a.3.1 of 44.060. |
| 2903 | * (MCS7, MCS9) to (MCS2, MCS3) is not handled since it is same as |
| 2904 | * (MCS5, MCS6) to (MCS2, MCS3) transition |
| 2905 | */ |
| 2906 | if (!(mcs == 6 && demanded_mcs == 3)) |
| 2907 | return; |
| 2908 | |
| 2909 | fn = fn_add_blocks(fn, 1); |
| 2910 | /* Send first RLC data block BSN 0 */ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 2911 | MAKE_ACKED(msg, dl_tbf, fn, mcs, true); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2912 | |
| 2913 | egprs2 = (struct gprs_rlc_dl_header_egprs_2 *) msg->data; |
Max | b4d368b | 2017-12-01 17:54:39 +0100 | [diff] [blame] | 2914 | bsn1 = (egprs2->bsn1_hi << 9) | (egprs2->bsn1_mid << 1) | (egprs2->bsn1_lo); |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 2915 | |
| 2916 | NACK(dl_tbf, 0); |
| 2917 | |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2918 | OSMO_ASSERT(bsn1 == 0); |
| 2919 | |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2920 | ms_set_current_cs_dl(dl_tbf->ms(), static_cast < enum CodingScheme > (CS4 + demanded_mcs)); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2921 | |
| 2922 | fn = fn_add_blocks(fn, 1); |
| 2923 | |
| 2924 | /* Send first segment with demanded_mcs */ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 2925 | MAKE_ACKED(msg, dl_tbf, fn, demanded_mcs, false); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2926 | OSMO_ASSERT(dl_tbf->m_rlc.block(0)->spb_status.block_status_dl |
| 2927 | == EGPRS_RESEG_FIRST_SEG_SENT); |
| 2928 | |
| 2929 | egprs3 = (struct gprs_rlc_dl_header_egprs_3 *) msg->data; |
| 2930 | OSMO_ASSERT(egprs3->spb == 2); |
| 2931 | |
| 2932 | /* Table 10.4.8a.3.1 of 44.060 */ |
| 2933 | OSMO_ASSERT(egprs3->cps == 3); |
| 2934 | |
| 2935 | /* Send second segment with demanded_mcs */ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 2936 | MAKE_ACKED(msg, dl_tbf, fn, demanded_mcs, true); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2937 | OSMO_ASSERT(dl_tbf->m_rlc.block(0)->spb_status.block_status_dl |
| 2938 | == EGPRS_RESEG_SECOND_SEG_SENT); |
| 2939 | |
| 2940 | egprs3 = (struct gprs_rlc_dl_header_egprs_3 *) msg->data; |
| 2941 | /* Table 10.4.8a.3.1 of 44.060 */ |
| 2942 | OSMO_ASSERT(egprs3->spb == 3); |
Max | b4d368b | 2017-12-01 17:54:39 +0100 | [diff] [blame] | 2943 | bsn2 = (egprs3->bsn1_hi << 9) | (egprs3->bsn1_mid << 1) | (egprs3->bsn1_lo); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2944 | OSMO_ASSERT(bsn2 == bsn1); |
| 2945 | |
| 2946 | /* Table 10.4.8a.3.1 of 44.060 */ |
| 2947 | OSMO_ASSERT(egprs3->cps == 3); |
| 2948 | |
| 2949 | /* Handle (MCS3, MCS3) -> MCS6 case */ |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2950 | ms_set_current_cs_dl(dl_tbf->ms(), static_cast < enum CodingScheme > (CS4 + mcs)); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2951 | |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 2952 | NACK(dl_tbf, 0); |
| 2953 | |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2954 | msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); |
| 2955 | egprs2 = (struct gprs_rlc_dl_header_egprs_2 *) msg->data; |
| 2956 | |
| 2957 | /* Table 10.4.8a.3.1 of 44.060 */ |
| 2958 | OSMO_ASSERT(egprs2->cps == 0); |
Max | b4d368b | 2017-12-01 17:54:39 +0100 | [diff] [blame] | 2959 | bsn3 = (egprs2->bsn1_hi << 9) | (egprs2->bsn1_mid << 1) | (egprs2->bsn1_lo); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2960 | OSMO_ASSERT(bsn3 == bsn2); |
| 2961 | |
| 2962 | tbf_cleanup(dl_tbf); |
| 2963 | } |
Neels Hofmeyr | d34646a | 2017-02-08 17:07:40 +0100 | [diff] [blame] | 2964 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2965 | static void establish_and_use_egprs_dl_tbf_for_spb(struct gprs_rlcmac_bts *bts, |
Neels Hofmeyr | d34646a | 2017-02-08 17:07:40 +0100 | [diff] [blame] | 2966 | unsigned int mcs, unsigned int demanded_mcs) |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2967 | { |
| 2968 | uint32_t fn = 0; |
| 2969 | gprs_rlcmac_dl_tbf *dl_tbf; |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2970 | struct msgb *msg; |
| 2971 | struct gprs_rlc_dl_header_egprs_3 *egprs3; |
| 2972 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 2973 | fprintf(stderr, "Testing retx for MCS %u to reseg_mcs %u\n", mcs, demanded_mcs); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2974 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 2975 | dl_tbf = tbf_init(bts, mcs); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2976 | |
| 2977 | /* |
| 2978 | * Table 10.4.8a.3.1 of 44.060. |
| 2979 | * (MCS7, MCS9) to (MCS2, MCS3) is not handled since it is same as |
| 2980 | * (MCS5, MCS6) to (MCS2, MCS3) transition |
| 2981 | */ |
| 2982 | /* TODO: Need to support of MCS8 -> MCS6 ->MCS3 transistion |
| 2983 | * Refer commit be881c028fc4da00c4046ecd9296727975c206a3 |
| 2984 | * dated 2016-02-07 23:45:40 (UTC) |
| 2985 | */ |
| 2986 | if (!(((mcs == 5) && (demanded_mcs == 2)) || |
| 2987 | ((mcs == 6) && (demanded_mcs == 3)) || |
| 2988 | ((mcs == 4) && (demanded_mcs == 1)))) |
| 2989 | return; |
| 2990 | |
| 2991 | fn = fn_add_blocks(fn, 1); |
| 2992 | /* Send first RLC data block BSN 0 */ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 2993 | MAKE_ACKED(msg, dl_tbf, fn, mcs, true); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2994 | |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 2995 | NACK(dl_tbf, 0); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2996 | |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 2997 | ms_set_current_cs_dl(dl_tbf->ms(), static_cast < enum CodingScheme > (CS4 + demanded_mcs)); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 2998 | |
| 2999 | fn = fn_add_blocks(fn, 1); |
| 3000 | |
| 3001 | /* Send first segment with demanded_mcs */ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3002 | MAKE_ACKED(msg, dl_tbf, fn, demanded_mcs, false); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 3003 | OSMO_ASSERT(dl_tbf->m_rlc.block(0)->spb_status.block_status_dl |
| 3004 | == EGPRS_RESEG_FIRST_SEG_SENT); |
| 3005 | |
| 3006 | egprs3 = (struct gprs_rlc_dl_header_egprs_3 *) msg->data; |
| 3007 | OSMO_ASSERT(egprs3->spb == 2); |
| 3008 | |
| 3009 | /* Table 10.4.8a.3.1 of 44.060 */ |
| 3010 | switch (demanded_mcs) { |
| 3011 | case 3: |
| 3012 | OSMO_ASSERT(egprs3->cps == 3); |
| 3013 | break; |
| 3014 | case 2: |
| 3015 | OSMO_ASSERT(egprs3->cps == 9); |
| 3016 | break; |
| 3017 | case 1: |
| 3018 | OSMO_ASSERT(egprs3->cps == 11); |
| 3019 | break; |
| 3020 | default: |
| 3021 | OSMO_ASSERT(false); |
| 3022 | break; |
| 3023 | } |
| 3024 | |
| 3025 | /* Send second segment with demanded_mcs */ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3026 | MAKE_ACKED(msg, dl_tbf, fn, demanded_mcs, true); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 3027 | OSMO_ASSERT(dl_tbf->m_rlc.block(0)->spb_status.block_status_dl |
| 3028 | == EGPRS_RESEG_SECOND_SEG_SENT); |
| 3029 | |
| 3030 | egprs3 = (struct gprs_rlc_dl_header_egprs_3 *) msg->data; |
| 3031 | /* Table 10.4.8a.3.1 of 44.060 */ |
| 3032 | OSMO_ASSERT(egprs3->spb == 3); |
| 3033 | |
| 3034 | /* Table 10.4.8a.3.1 of 44.060 */ |
| 3035 | switch (demanded_mcs) { |
| 3036 | case 3: |
| 3037 | OSMO_ASSERT(egprs3->cps == 3); |
| 3038 | break; |
| 3039 | case 2: |
| 3040 | OSMO_ASSERT(egprs3->cps == 9); |
| 3041 | break; |
| 3042 | case 1: |
| 3043 | OSMO_ASSERT(egprs3->cps == 11); |
| 3044 | break; |
| 3045 | default: |
| 3046 | OSMO_ASSERT(false); |
| 3047 | break; |
| 3048 | } |
| 3049 | tbf_cleanup(dl_tbf); |
| 3050 | } |
| 3051 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 3052 | static void establish_and_use_egprs_dl_tbf_for_retx(struct gprs_rlcmac_bts *bts, |
Neels Hofmeyr | d34646a | 2017-02-08 17:07:40 +0100 | [diff] [blame] | 3053 | unsigned int mcs, unsigned int demanded_mcs) |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3054 | { |
| 3055 | uint32_t fn = 0; |
| 3056 | gprs_rlcmac_dl_tbf *dl_tbf; |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3057 | struct msgb *msg; |
| 3058 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 3059 | fprintf(stderr, "Testing retx for MCS %u - %u\n", mcs, demanded_mcs); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3060 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 3061 | dl_tbf = tbf_init(bts, mcs); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3062 | |
| 3063 | /* For MCS reduction cases like MCS9->MCS6, MCS7->MCS5 |
| 3064 | * The MCS transition are referred from table Table 8.1.1.2 |
| 3065 | * of TS 44.060 |
| 3066 | */ |
| 3067 | /* TODO: Need to support of MCS8 -> MCS6 transistion |
| 3068 | * Refer commit be881c028fc4da00c4046ecd9296727975c206a3 |
| 3069 | * dated 2016-02-07 23:45:40 (UTC) |
| 3070 | */ |
| 3071 | if (((mcs == 9) && (demanded_mcs < 9)) || |
| 3072 | ((mcs == 7) && (demanded_mcs < 7))) { |
| 3073 | fn = fn_add_blocks(fn, 1); |
| 3074 | /* Send 2 RLC data block */ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3075 | MAKE_ACKED(msg, dl_tbf, fn, mcs, true); |
| 3076 | CHECK_UNACKED(dl_tbf, mcs, 1); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3077 | |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3078 | NACK(dl_tbf, 0); |
| 3079 | NACK(dl_tbf, 1); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3080 | |
| 3081 | /* Set the demanded MCS to demanded_mcs */ |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 3082 | ms_set_current_cs_dl(dl_tbf->ms(), static_cast < enum CodingScheme > (CS4 + demanded_mcs)); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3083 | |
| 3084 | fn = fn_add_blocks(fn, 1); |
| 3085 | /* Retransmit the first RLC data block with demanded_mcs */ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3086 | MAKE_ACKED(msg, dl_tbf, fn, demanded_mcs, true); |
| 3087 | CHECK_NACKED(dl_tbf, mcs, 1); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3088 | |
| 3089 | fn = fn_add_blocks(fn, 1); |
| 3090 | /* Retransmit the second RLC data block with demanded_mcs */ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3091 | MAKE_ACKED(msg, dl_tbf, fn, demanded_mcs, true); |
| 3092 | CHECK_UNACKED(dl_tbf, demanded_mcs, 1); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3093 | } else if (((mcs == 5) && (demanded_mcs > 6)) || |
| 3094 | ((mcs == 6) && (demanded_mcs > 8))) { |
| 3095 | fn = fn_add_blocks(fn, 1); |
| 3096 | /* Send first RLC data block BSN 0 */ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3097 | MAKE_ACKED(msg, dl_tbf, fn, mcs, true); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3098 | |
| 3099 | fn = fn_add_blocks(fn, 1); |
| 3100 | /* Send second RLC data block BSN 1 */ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3101 | MAKE_ACKED(msg, dl_tbf, fn, mcs, true); |
| 3102 | CHECK_UNACKED(dl_tbf, mcs, 1); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3103 | |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3104 | NACK(dl_tbf, 0); |
| 3105 | NACK(dl_tbf, 1); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3106 | |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 3107 | ms_set_current_cs_dl(dl_tbf->ms(), static_cast < enum CodingScheme > (CS4 + demanded_mcs)); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3108 | |
| 3109 | fn = fn_add_blocks(fn, 1); |
| 3110 | /* Send first, second RLC data blocks with demanded_mcs */ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3111 | MAKE_ACKED(msg, dl_tbf, fn, demanded_mcs, true); |
| 3112 | CHECK_UNACKED(dl_tbf, demanded_mcs, 1); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3113 | } else if (mcs > 6) { |
| 3114 | /* No Mcs change cases are handled here for mcs > MCS6*/ |
| 3115 | fn = fn_add_blocks(fn, 1); |
| 3116 | /* Send first,second RLC data blocks */ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3117 | MAKE_ACKED(msg, dl_tbf, fn, mcs, true); |
| 3118 | CHECK_UNACKED(dl_tbf, mcs, 1); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3119 | |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3120 | NACK(dl_tbf, 0); |
| 3121 | NACK(dl_tbf, 1); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3122 | |
| 3123 | fn = fn_add_blocks(fn, 1); |
| 3124 | /* Send first,second RLC data blocks with demanded_mcs*/ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3125 | MAKE_ACKED(msg, dl_tbf, fn, mcs, true); |
| 3126 | CHECK_UNACKED(dl_tbf, mcs, 1); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3127 | } else { |
| 3128 | |
| 3129 | /* No MCS change cases are handled here for mcs <= MCS6*/ |
| 3130 | fn = fn_add_blocks(fn, 1); |
| 3131 | /* Send first RLC data block */ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3132 | MAKE_ACKED(msg, dl_tbf, fn, mcs, true); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3133 | |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3134 | NACK(dl_tbf, 0); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3135 | |
| 3136 | fn = fn_add_blocks(fn, 1); |
| 3137 | /* Send first RLC data block with demanded_mcs */ |
Max | 7d32f55 | 2017-12-15 11:25:14 +0100 | [diff] [blame] | 3138 | MAKE_ACKED(msg, dl_tbf, fn, mcs, true); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3139 | } |
Pau Espin Pedrol | 99360a3 | 2021-03-09 17:18:12 +0100 | [diff] [blame] | 3140 | /* Clean up pending items in UL controller: */ |
Pau Espin Pedrol | 16e1678 | 2021-03-29 19:10:19 +0200 | [diff] [blame] | 3141 | send_empty_block(dl_tbf, dl_tbf->control_ts, fn+50); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3142 | tbf_cleanup(dl_tbf); |
| 3143 | } |
| 3144 | |
| 3145 | static void test_tbf_egprs_retx_dl(void) |
| 3146 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 3147 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 3148 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3149 | uint8_t ts_no = 4; |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3150 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 3151 | fprintf(stderr, "=== start %s ===\n", __func__); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3152 | |
Pau Espin Pedrol | ad79b85 | 2021-01-14 13:20:55 +0100 | [diff] [blame] | 3153 | the_pcu->vty.cs_downgrade_threshold = 0; |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 3154 | setup_bts(bts, ts_no); |
Pau Espin Pedrol | 924aaad | 2021-01-14 12:01:42 +0100 | [diff] [blame] | 3155 | OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2031, 200, OSMO_TDEF_MS) == 0); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 3156 | /* ARQ II */ |
Pau Espin Pedrol | 97296b2 | 2021-01-14 13:08:02 +0100 | [diff] [blame] | 3157 | the_pcu->vty.dl_arq_type = EGPRS_ARQ2; |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 3158 | |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3159 | |
| 3160 | /* First parameter is current MCS, second one is demanded_mcs */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 3161 | establish_and_use_egprs_dl_tbf_for_retx(bts, 6, 6); |
| 3162 | establish_and_use_egprs_dl_tbf_for_retx(bts, 1, 9); |
| 3163 | establish_and_use_egprs_dl_tbf_for_retx(bts, 2, 8); |
| 3164 | establish_and_use_egprs_dl_tbf_for_retx(bts, 5, 7); |
| 3165 | establish_and_use_egprs_dl_tbf_for_retx(bts, 6, 9); |
| 3166 | establish_and_use_egprs_dl_tbf_for_retx(bts, 7, 5); |
| 3167 | establish_and_use_egprs_dl_tbf_for_retx(bts, 9, 6); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3168 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 3169 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 3170 | fprintf(stderr, "=== end %s ===\n", __func__); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3171 | } |
| 3172 | |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 3173 | static void test_tbf_egprs_spb_dl(void) |
| 3174 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 3175 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 3176 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 3177 | uint8_t ts_no = 4; |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 3178 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 3179 | fprintf(stderr, "=== start %s ===\n", __func__); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 3180 | |
Pau Espin Pedrol | ad79b85 | 2021-01-14 13:20:55 +0100 | [diff] [blame] | 3181 | the_pcu->vty.cs_downgrade_threshold = 0; |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 3182 | setup_bts(bts, ts_no); |
Pau Espin Pedrol | 924aaad | 2021-01-14 12:01:42 +0100 | [diff] [blame] | 3183 | OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2031, 200, OSMO_TDEF_MS) == 0); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 3184 | |
| 3185 | /* ARQ I resegmentation support */ |
Pau Espin Pedrol | 97296b2 | 2021-01-14 13:08:02 +0100 | [diff] [blame] | 3186 | the_pcu->vty.dl_arq_type = EGPRS_ARQ1; |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 3187 | |
| 3188 | /* |
| 3189 | * First parameter is current MCS, second one is demanded_mcs |
| 3190 | * currently only MCS5->MCS2, MCS6->3, MCS4->MCS1 is tested in UT |
| 3191 | * rest scenarios has been integration tested |
| 3192 | */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 3193 | establish_and_use_egprs_dl_tbf_for_spb(bts, 6, 3); |
| 3194 | establish_and_use_egprs_dl_tbf_for_spb(bts, 5, 2); |
| 3195 | establish_and_use_egprs_dl_tbf_for_spb(bts, 4, 1); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 3196 | /* check MCS6->(MCS3+MCS3)->MCS6 case */ |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 3197 | egprs_spb_to_normal_validation(bts, 6, 3); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 3198 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 3199 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 3200 | fprintf(stderr, "=== end %s ===\n", __func__); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 3201 | } |
| 3202 | |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 3203 | static void test_tbf_egprs_dl() |
| 3204 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 3205 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 3206 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 3207 | uint8_t ts_no = 4; |
| 3208 | int i; |
| 3209 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 3210 | fprintf(stderr, "=== start %s ===\n", __func__); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 3211 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 3212 | setup_bts(bts, ts_no); |
Pau Espin Pedrol | 924aaad | 2021-01-14 12:01:42 +0100 | [diff] [blame] | 3213 | OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2031, 200, OSMO_TDEF_MS) == 0); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 3214 | /* ARQ II */ |
Pau Espin Pedrol | 97296b2 | 2021-01-14 13:08:02 +0100 | [diff] [blame] | 3215 | the_pcu->vty.dl_arq_type = EGPRS_ARQ2; |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 3216 | |
| 3217 | for (i = 1; i <= 9; i++) |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 3218 | establish_and_use_egprs_dl_tbf(bts, i); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 3219 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 3220 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 3221 | fprintf(stderr, "=== end %s ===\n", __func__); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 3222 | } |
| 3223 | |
| 3224 | |
| 3225 | |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3226 | static void test_packet_access_rej_prr_no_other_tbfs() |
| 3227 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 3228 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 3229 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3230 | uint32_t fn = 2654218; |
| 3231 | int ts_no = 7; |
| 3232 | uint8_t trx_no = 0; |
| 3233 | uint32_t tlli = 0xffeeddcc; |
Pau Espin Pedrol | 54742f2 | 2021-04-26 16:48:34 +0200 | [diff] [blame] | 3234 | struct gprs_rlcmac_ul_tbf *ul_tbf; |
| 3235 | struct GprsMs *ms; |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3236 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 3237 | fprintf(stderr, "=== start %s ===\n", __func__); |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3238 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 3239 | setup_bts(bts, ts_no, 4); |
Pau Espin Pedrol | 9d67e72 | 2021-07-28 19:25:38 +0200 | [diff] [blame] | 3240 | OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2000, 0, OSMO_TDEF_MS) == 0); |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3241 | |
| 3242 | int rc = 0; |
| 3243 | |
Pau Espin Pedrol | 54742f2 | 2021-04-26 16:48:34 +0200 | [diff] [blame] | 3244 | ms = bts_alloc_ms(bts, 0, 0); |
| 3245 | ms_set_tlli(ms, tlli); |
| 3246 | ul_tbf = handle_tbf_reject(bts, ms, trx_no, ts_no); |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3247 | |
| 3248 | OSMO_ASSERT(ul_tbf != 0); |
| 3249 | |
| 3250 | /* trigger packet access reject */ |
| 3251 | uint8_t bn = fn2bn(fn); |
| 3252 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 3253 | rc = gprs_rlcmac_rcv_rts_block(bts, |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3254 | trx_no, ts_no, fn, bn); |
| 3255 | |
| 3256 | OSMO_ASSERT(rc == 0); |
Pau Espin Pedrol | 9d67e72 | 2021-07-28 19:25:38 +0200 | [diff] [blame] | 3257 | osmo_select_main(0); |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3258 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 3259 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 3260 | fprintf(stderr, "=== end %s ===\n", __func__); |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3261 | } |
| 3262 | |
| 3263 | static void test_packet_access_rej_prr() |
| 3264 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 3265 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 3266 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3267 | uint32_t fn = 2654218; |
| 3268 | uint16_t qta = 31; |
| 3269 | int ts_no = 7; |
| 3270 | uint8_t trx_no = 0; |
| 3271 | RlcMacUplink_t ulreq = {0}; |
| 3272 | Packet_Resource_Request_t *presreq = NULL; |
| 3273 | uint8_t ms_class = 11; |
| 3274 | uint8_t egprs_ms_class = 11; |
| 3275 | uint32_t rach_fn = fn - 51; |
| 3276 | uint32_t sba_fn = fn + 52; |
| 3277 | uint32_t tlli = 0xffeeddcc; |
| 3278 | MS_Radio_Access_capability_t *pmsradiocap = NULL; |
| 3279 | Multislot_capability_t *pmultislotcap = NULL; |
| 3280 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 3281 | fprintf(stderr, "=== start %s ===\n", __func__); |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3282 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 3283 | setup_bts(bts, ts_no, 4); |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3284 | |
| 3285 | int rc = 0; |
| 3286 | |
| 3287 | /* |
| 3288 | * Trigger rach till resources(USF) exhaust |
| 3289 | */ |
Pau Espin Pedrol | 4347997 | 2021-04-22 19:18:13 +0200 | [diff] [blame] | 3290 | int i; |
| 3291 | for (i = 0; i < 8; i++) { |
| 3292 | rc = bts_handle_rach(bts, 0x70 + i, rach_fn, qta); |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3293 | } |
| 3294 | |
Pau Espin Pedrol | 4347997 | 2021-04-22 19:18:13 +0200 | [diff] [blame] | 3295 | sba_fn = 52; |
| 3296 | for (i = 0; i < 8; i++) { |
| 3297 | /* fake a resource request */ |
| 3298 | ulreq.u.MESSAGE_TYPE = MT_PACKET_RESOURCE_REQUEST; |
| 3299 | presreq = &ulreq.u.Packet_Resource_Request; |
| 3300 | presreq->PayloadType = GPRS_RLCMAC_CONTROL_BLOCK; |
| 3301 | presreq->ID.UnionType = 1; /* != 0 */ |
| 3302 | presreq->ID.u.TLLI = tlli + i; |
| 3303 | presreq->Exist_MS_Radio_Access_capability2 = 1; |
| 3304 | pmsradiocap = &presreq->MS_Radio_Access_capability2; |
| 3305 | pmsradiocap->Count_MS_RA_capability_value = 1; |
| 3306 | pmsradiocap->MS_RA_capability_value[0].u.Content. |
| 3307 | Exist_Multislot_capability = 1; |
| 3308 | pmultislotcap = &pmsradiocap->MS_RA_capability_value[0]. |
| 3309 | u.Content.Multislot_capability; |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3310 | |
Pau Espin Pedrol | 4347997 | 2021-04-22 19:18:13 +0200 | [diff] [blame] | 3311 | pmultislotcap->Exist_GPRS_multislot_class = 1; |
| 3312 | pmultislotcap->GPRS_multislot_class = ms_class; |
| 3313 | if (egprs_ms_class) { |
| 3314 | pmultislotcap->Exist_EGPRS_multislot_class = 1; |
| 3315 | pmultislotcap->EGPRS_multislot_class = egprs_ms_class; |
| 3316 | } |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3317 | |
Pau Espin Pedrol | 4347997 | 2021-04-22 19:18:13 +0200 | [diff] [blame] | 3318 | send_ul_mac_block(bts, trx_no, ts_no, &ulreq, sba_fn); |
| 3319 | sba_fn = fn_next_block(sba_fn); |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3320 | |
Pau Espin Pedrol | 4347997 | 2021-04-22 19:18:13 +0200 | [diff] [blame] | 3321 | /* trigger packet access reject */ |
| 3322 | uint8_t bn = fn2bn(fn); |
| 3323 | |
| 3324 | rc = gprs_rlcmac_rcv_rts_block(bts, |
| 3325 | trx_no, ts_no, fn, bn); |
| 3326 | OSMO_ASSERT(rc == 0); |
| 3327 | } |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3328 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 3329 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 3330 | fprintf(stderr, "=== end %s ===\n", __func__); |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3331 | } |
| 3332 | |
aravind sirsikar | ed3413e | 2016-11-11 17:15:10 +0530 | [diff] [blame] | 3333 | void test_packet_access_rej_epdan() |
| 3334 | { |
Pau Espin Pedrol | 945be91 | 2021-07-26 14:47:46 +0200 | [diff] [blame] | 3335 | the_pcu = prepare_pcu(); |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 3336 | struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); |
aravind sirsikar | ed3413e | 2016-11-11 17:15:10 +0530 | [diff] [blame] | 3337 | uint32_t tlli = 0xffeeddcc; |
Pau Espin Pedrol | 2ab840a | 2021-04-26 17:49:05 +0200 | [diff] [blame] | 3338 | static uint8_t exp[] = { 0x40, 0x84, 0x7f, 0xf7, 0x6e, 0xe6, 0x7e, 0xab, |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 3339 | 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, |
| 3340 | 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b |
| 3341 | }; |
aravind sirsikar | ed3413e | 2016-11-11 17:15:10 +0530 | [diff] [blame] | 3342 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 3343 | fprintf(stderr, "=== start %s ===\n", __func__); |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 3344 | setup_bts(bts, 4); |
| 3345 | static gprs_rlcmac_dl_tbf *dl_tbf = tbf_init(bts, 1); |
aravind sirsikar | ed3413e | 2016-11-11 17:15:10 +0530 | [diff] [blame] | 3346 | |
Pau Espin Pedrol | 8abe13c | 2022-10-21 18:49:48 +0200 | [diff] [blame] | 3347 | ms_confirm_tlli(dl_tbf->ms(), tlli); |
aravind sirsikar | ed3413e | 2016-11-11 17:15:10 +0530 | [diff] [blame] | 3348 | |
Pau Espin Pedrol | 6ad11a6 | 2021-07-27 12:27:08 +0200 | [diff] [blame] | 3349 | osmo_fsm_inst_dispatch(dl_tbf->ul_ass_fsm.fi, TBF_UL_ASS_EV_SCHED_ASS_REJ, NULL); |
| 3350 | struct msgb *msg = tbf_ul_ass_create_rlcmac_msg((const struct gprs_rlcmac_tbf*)dl_tbf, 0, 0); |
aravind sirsikar | ed3413e | 2016-11-11 17:15:10 +0530 | [diff] [blame] | 3351 | |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 3352 | fprintf(stderr, "packet reject: %s\n", |
aravind sirsikar | ed3413e | 2016-11-11 17:15:10 +0530 | [diff] [blame] | 3353 | osmo_hexdump(msg->data, 23)); |
| 3354 | |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 3355 | if (!msgb_eq_data_print(msg, exp, GSM_MACBLOCK_LEN)) |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 3356 | fprintf(stderr, "%s test failed!\n", __func__); |
Max | d3a0d91 | 2019-03-05 16:15:01 +0100 | [diff] [blame] | 3357 | |
Pau Espin Pedrol | 47f15fb | 2021-01-14 14:28:26 +0100 | [diff] [blame] | 3358 | TALLOC_FREE(the_pcu); |
Pau Espin Pedrol | 474dc77 | 2019-09-09 14:09:48 +0200 | [diff] [blame] | 3359 | fprintf(stderr, "=== end %s ===\n", __func__); |
aravind sirsikar | ed3413e | 2016-11-11 17:15:10 +0530 | [diff] [blame] | 3360 | } |
| 3361 | |
| 3362 | |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 3363 | int main(int argc, char **argv) |
| 3364 | { |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 3365 | struct vty_app_info pcu_vty_info = {0}; |
| 3366 | |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 3367 | tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile TbfTest context"); |
| 3368 | if (!tall_pcu_ctx) |
| 3369 | abort(); |
| 3370 | |
Neels Hofmeyr | 78ce591 | 2017-02-08 17:07:31 +0100 | [diff] [blame] | 3371 | msgb_talloc_ctx_init(tall_pcu_ctx, 0); |
Neels Hofmeyr | 42f2d61 | 2018-04-01 16:54:40 +0200 | [diff] [blame] | 3372 | osmo_init_logging2(tall_pcu_ctx, &gprs_log_info); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 3373 | log_set_use_color(osmo_stderr_target, 0); |
Pau Espin Pedrol | 00f52cc | 2021-02-19 14:01:52 +0100 | [diff] [blame] | 3374 | log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE); |
Pau Espin Pedrol | b18d2a5 | 2021-02-19 14:00:48 +0100 | [diff] [blame] | 3375 | log_set_print_category(osmo_stderr_target, 0); |
| 3376 | log_set_print_category_hex(osmo_stderr_target, 0); |
Max | fdd79e9 | 2018-01-24 11:04:59 +0100 | [diff] [blame] | 3377 | log_parse_category_mask(osmo_stderr_target, "DRLCMAC,1:DRLCMACDATA,3:DRLCMACDL,3:DRLCMACUL,3:" |
Harald Welte | 398f60e | 2020-12-10 13:39:21 +0100 | [diff] [blame] | 3378 | "DRLCMACSCHED,1:DRLCMACMEAS,3:DNS,3:DLBSSGP,3:DPCU,5:" |
Max | 86e35e4 | 2019-03-07 12:20:42 +0100 | [diff] [blame] | 3379 | "DL1IF,6:DTBF,1:DTBFUL,1:DTBFDL,1:DLGLOBAL,2:"); |
Pau Espin Pedrol | dc2aaac | 2021-05-14 12:50:46 +0200 | [diff] [blame] | 3380 | osmo_fsm_log_addr(false); |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 3381 | vty_init(&pcu_vty_info); |
Pau Espin Pedrol | cd2ac56 | 2019-08-05 14:30:44 +0200 | [diff] [blame] | 3382 | pcu_vty_init(); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 3383 | |
Vadim Yanitskiy | 87b6e7d | 2019-11-08 04:44:04 +0700 | [diff] [blame] | 3384 | /* Initialize shared UL measurements */ |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 3385 | pcu_l1_meas_set_link_qual(&meas, 12); |
| 3386 | pcu_l1_meas_set_rssi(&meas, 31); |
Vadim Yanitskiy | 87b6e7d | 2019-11-08 04:44:04 +0700 | [diff] [blame] | 3387 | |
Jacob Erlbeck | ac89a55 | 2015-06-29 14:18:46 +0200 | [diff] [blame] | 3388 | test_tbf_base(); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 3389 | test_tbf_tlli_update(); |
Jacob Erlbeck | 5e9f40d | 2015-02-23 14:26:59 +0100 | [diff] [blame] | 3390 | test_tbf_final_ack(TEST_MODE_STANDARD); |
| 3391 | test_tbf_final_ack(TEST_MODE_REVERSE_FREE); |
Jacob Erlbeck | 2cbe80b | 2015-03-25 10:48:52 +0100 | [diff] [blame] | 3392 | test_tbf_delayed_release(); |
Jacob Erlbeck | b0e5eaf | 2015-05-21 11:07:16 +0200 | [diff] [blame] | 3393 | test_tbf_imsi(); |
Jacob Erlbeck | d58b711 | 2015-04-09 19:17:21 +0200 | [diff] [blame] | 3394 | test_tbf_exhaustion(); |
Jacob Erlbeck | 4116864 | 2015-06-12 13:41:00 +0200 | [diff] [blame] | 3395 | test_tbf_dl_llc_loss(); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 3396 | test_tbf_single_phase(); |
Pau Espin Pedrol | 22b26d8 | 2022-10-26 15:44:14 +0200 | [diff] [blame] | 3397 | test_tbf_single_phase2(); |
Jacob Erlbeck | ddfc0d5 | 2015-05-27 13:03:15 +0200 | [diff] [blame] | 3398 | test_tbf_two_phase(); |
Jacob Erlbeck | b139598 | 2015-08-21 18:15:38 +0200 | [diff] [blame] | 3399 | test_tbf_ra_update_rach(); |
| 3400 | test_tbf_dl_flow_and_rach_two_phase(); |
| 3401 | test_tbf_dl_flow_and_rach_single_phase(); |
Jacob Erlbeck | 23c4b3f | 2015-08-21 15:04:39 +0200 | [diff] [blame] | 3402 | test_tbf_dl_reuse(); |
Jacob Erlbeck | 9b3d7e0 | 2016-01-19 10:44:42 +0100 | [diff] [blame] | 3403 | test_tbf_gprs_egprs(); |
Jacob Erlbeck | 36df774 | 2016-01-19 15:53:30 +0100 | [diff] [blame] | 3404 | test_tbf_ws(); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 3405 | test_tbf_egprs_two_phase(); |
Aravind Sirsikar | 505a86d | 2016-07-26 18:26:21 +0530 | [diff] [blame] | 3406 | test_tbf_egprs_two_phase_spb(); |
Jacob Erlbeck | 2d2efb1 | 2016-02-04 11:09:19 +0100 | [diff] [blame] | 3407 | test_tbf_egprs_dl(); |
Aravind Sirsikar | 1a67912 | 2016-07-12 15:50:29 +0530 | [diff] [blame] | 3408 | test_tbf_egprs_retx_dl(); |
Aravind Sirsikar | 50b0970 | 2016-08-22 17:21:10 +0530 | [diff] [blame] | 3409 | test_tbf_egprs_spb_dl(); |
Aravind Sirsikar | 02352b4 | 2016-08-25 16:37:30 +0530 | [diff] [blame] | 3410 | test_tbf_puan_urbb_len(); |
Aravind Sirsikar | 3c2eaeb | 2016-08-30 15:39:04 +0530 | [diff] [blame] | 3411 | test_tbf_update_ws(); |
Aravind Sirsikar | 3463bd4 | 2016-09-15 17:19:54 +0530 | [diff] [blame] | 3412 | test_tbf_li_decoding(); |
aravind sirsikar | f276138 | 2016-10-25 12:45:24 +0530 | [diff] [blame] | 3413 | test_tbf_epdan_out_of_rx_window(); |
aravind sirsikar | c0c3afd | 2016-11-09 16:27:00 +0530 | [diff] [blame] | 3414 | test_immediate_assign_rej(); |
sivasankari | 1d8744c | 2017-01-24 15:53:35 +0530 | [diff] [blame] | 3415 | test_tbf_egprs_two_phase_puan(); |
aravind sirsikar | ed3413e | 2016-11-11 17:15:10 +0530 | [diff] [blame] | 3416 | test_packet_access_rej_epdan(); |
aravind sirsikar | e9a138e | 2017-01-24 12:36:08 +0530 | [diff] [blame] | 3417 | test_packet_access_rej_prr(); |
| 3418 | test_packet_access_rej_prr_no_other_tbfs(); |
Jacob Erlbeck | 67c3850 | 2015-05-11 10:32:40 +0200 | [diff] [blame] | 3419 | |
| 3420 | if (getenv("TALLOC_REPORT_FULL")) |
| 3421 | talloc_report_full(tall_pcu_ctx, stderr); |
Holger Hans Peter Freyther | b809866 | 2013-10-30 14:50:17 +0100 | [diff] [blame] | 3422 | return EXIT_SUCCESS; |
| 3423 | } |
| 3424 | |
| 3425 | /* |
| 3426 | * stubs that should not be reached |
| 3427 | */ |
| 3428 | extern "C" { |
| 3429 | void l1if_pdch_req() { abort(); } |
| 3430 | void l1if_connect_pdch() { abort(); } |
| 3431 | void l1if_close_pdch() { abort(); } |
| 3432 | void l1if_open_pdch() { abort(); } |
| 3433 | } |