Harald Welte | a0895f9 | 2018-03-08 11:51:23 +0100 | [diff] [blame] | 1 | module PCU_Tests { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2 | |
| 3 | /* "RAW" PCU tests: Talk directly to the PCU socket of OsmoPCU on the one hand side (emulating |
| 4 | the BTS/BSC side PCU socket server) and the Gb interface on the other hand side. No NS/BSSGP |
| 5 | Emulation is used; rather, we simply use the NS_CodecPort to implement both standard and non- |
| 6 | standard procedures on the NS and BSSGP level. The goal of these tests is to test exactly |
| 7 | those NS and BSSGP implementations on the BSS (PCU) side. */ |
| 8 | |
| 9 | /* (C) 2018-2019 Harald Welte <laforge@gnumonks.org> |
Vadim Yanitskiy | 4f56d32 | 2020-05-22 20:15:48 +0700 | [diff] [blame] | 10 | * (C) 2019-2020 Vadim Yanitskiy <axilirator@gmail.com> |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 11 | * All rights reserved. |
| 12 | * |
| 13 | * Released under the terms of GNU General Public License, Version 2 or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 17 | */ |
| 18 | |
| 19 | friend module PCU_Tests_NS; |
| 20 | |
| 21 | import from General_Types all; |
| 22 | import from Osmocom_Types all; |
| 23 | import from GSM_Types all; |
| 24 | import from GSM_RR_Types all; |
| 25 | |
| 26 | import from Osmocom_VTY_Functions all; |
| 27 | import from TELNETasp_PortType all; |
| 28 | |
| 29 | import from MobileL3_GMM_SM_Types all; |
| 30 | import from RLCMAC_CSN1_Types all; |
Pau Espin Pedrol | e8d7d16 | 2020-04-29 19:07:36 +0200 | [diff] [blame] | 31 | import from RLCMAC_CSN1_Templates all; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 32 | import from RLCMAC_Types all; |
Pau Espin Pedrol | e8d7d16 | 2020-04-29 19:07:36 +0200 | [diff] [blame] | 33 | import from RLCMAC_Templates all; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 34 | |
| 35 | import from MobileL3_CommonIE_Types all; |
| 36 | import from L3_Templates all; |
| 37 | |
| 38 | import from NS_Types all; |
| 39 | import from BSSGP_Types all; |
| 40 | import from Osmocom_Gb_Types all; |
| 41 | |
| 42 | import from BSSGP_Emulation all; /* BssgpConfig */ |
| 43 | import from NS_Emulation all; /* NSConfiguration */ |
| 44 | |
| 45 | import from UD_Types all; |
| 46 | import from PCUIF_Types all; |
| 47 | import from PCUIF_CodecPort all; |
| 48 | import from PCUIF_Components all; |
| 49 | import from IPL4asp_Types all; |
| 50 | import from Native_Functions all; |
| 51 | import from SGSN_Components all; |
Pau Espin Pedrol | aedc511 | 2020-05-16 17:30:42 +0200 | [diff] [blame] | 52 | import from GPRS_Components all; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 53 | |
Daniel Willmann | 535aea6 | 2020-09-21 13:27:08 +0200 | [diff] [blame] | 54 | import from StatsD_Types all; |
| 55 | import from StatsD_CodecPort all; |
| 56 | import from StatsD_CodecPort_CtrlFunct all; |
| 57 | import from StatsD_Checker all; |
| 58 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 59 | modulepar { |
| 60 | charstring mp_pcu_sock_path := PCU_SOCK_DEFAULT; |
| 61 | |
| 62 | float X2002 := 0.2; /* Timer -2002, IMM ASSIGN confirm delay */ |
Daniel Willmann | 535aea6 | 2020-09-21 13:27:08 +0200 | [diff] [blame] | 63 | |
| 64 | charstring mp_pcu_statsd_ip := "127.0.0.1"; |
| 65 | integer mp_pcu_statsd_port := 8125; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | |
| 69 | /* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 70 | friend template (value) PCUIF_info_ind ts_PCUIF_INFO_default(template (value) PCUIF_Flags flags := c_PCUIF_Flags_default) |
| 71 | := { |
Vadim Yanitskiy | c155930 | 2020-07-19 16:39:12 +0700 | [diff] [blame] | 72 | version := PCUIF_Types.mp_pcuif_version, |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 73 | flags := flags, |
Pau Espin Pedrol | 2aead38 | 2020-10-29 20:46:47 +0100 | [diff] [blame] | 74 | trx := f_PCUIF_ver_INFO_Trxs(GPRS_Components.mp_base_arfcn), |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 75 | bsic := 7, |
| 76 | mcc := 262, |
| 77 | mnc := 42, |
| 78 | mnc_3_digits := 0, |
| 79 | lac := 13135, |
| 80 | rac := 0, |
| 81 | nsei := mp_nsconfig.nsei, |
| 82 | nse_timer := { 3, 3, 3, 3, 30, 3, 10 }, |
| 83 | cell_timer := { 3, 3, 3, 3, 3, 10, 3, 10, 3, 10, 3 }, |
| 84 | cell_id := 20960, |
| 85 | repeat_time := 5 * 50, |
| 86 | repeat_count := 3, |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 87 | bvci := mp_gb_cfg.bvc[0].bvci, |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 88 | t3142 := 20, |
| 89 | t3169 := 5, |
| 90 | t3191 := 5, |
| 91 | t3193_10ms := 160, |
| 92 | t3195 := 5, |
| 93 | t3101 := 10, |
| 94 | t3103 := 4, |
| 95 | t3105 := 8, |
| 96 | cv_countdown := 15, |
| 97 | dl_tbf_ext := 250 * 10, /* ms */ |
| 98 | ul_tbf_ext := 250 * 10, /* ms */ |
| 99 | initial_cs := 2, |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 100 | initial_mcs := 1, |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 101 | nsvci := { mp_nsconfig.nsvc[0].nsvci, 0 }, |
| 102 | local_port := { mp_nsconfig.nsvc[0].provider.ip.remote_udp_port, 0 }, |
| 103 | remote_port := { mp_nsconfig.nsvc[0].provider.ip.local_udp_port, 0 }, |
Alexander Couzens | 1e5dc48 | 2020-07-28 15:38:46 +0200 | [diff] [blame] | 104 | remote_addr := f_PCUIF_ver_INFO_RemoteAddr( |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 105 | f_PCUIF_AF2addr_type(mp_nsconfig.nsvc[0].provider.ip.address_family), mp_nsconfig.nsvc[0].provider.ip.local_ip) |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | type record lqual_range { |
| 109 | /* component reference to the IPA_Client component used for RSL */ |
| 110 | uint8_t low, |
| 111 | uint8_t high |
| 112 | } |
| 113 | |
Daniel Willmann | 535aea6 | 2020-09-21 13:27:08 +0200 | [diff] [blame] | 114 | type component RAW_PCU_Test_CT extends bssgp_CT, MS_BTS_IFACE_CT, StatsD_ConnHdlr { |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 115 | /* PCU interface abstraction component */ |
| 116 | var RAW_PCUIF_CT vc_PCUIF; |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 117 | |
Daniel Willmann | 535aea6 | 2020-09-21 13:27:08 +0200 | [diff] [blame] | 118 | /* StatsD */ |
| 119 | var StatsD_Checker_CT vc_STATSD; |
| 120 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 121 | /* Connection to the PCUIF component */ |
| 122 | port RAW_PCU_MSG_PT PCUIF; |
| 123 | /* VTY connection to the PCU */ |
| 124 | port TELNETasp_PT PCUVTY; |
| 125 | |
| 126 | /* Uplink CS/MCS thresholds, default from pcu_main.c: */ |
| 127 | var lqual_range g_cs_lqual_ranges[4] := {{low := 0, high := 6}, |
| 128 | {low := 5, high := 8}, |
| 129 | {low := 7, high := 13}, |
| 130 | {low := 12,high := 35}}; |
| 131 | var lqual_range g_mcs_lqual_ranges[9] := {{low := 0, high := 6}, |
| 132 | {low := 5, high := 8}, |
| 133 | {low := 7, high := 13}, |
| 134 | {low := 12,high := 15}, |
| 135 | {low := 14, high := 17}, |
| 136 | {low := 16, high := 18}, |
| 137 | {low := 17,high := 20}, |
| 138 | {low := 19, high := 24}, |
| 139 | {low := 23,high := 35}}; |
| 140 | var uint8_t g_cs_initial_dl := 1; |
| 141 | var uint8_t g_cs_initial_ul := 1; |
| 142 | var uint8_t g_mcs_initial_dl := 1; |
| 143 | var uint8_t g_mcs_initial_ul := 1; |
| 144 | var uint8_t g_cs_max_dl := 4; |
| 145 | var uint8_t g_cs_max_ul := 4; |
| 146 | var uint8_t g_mcs_max_dl := 9; |
| 147 | var uint8_t g_mcs_max_ul := 9; |
| 148 | |
Pau Espin Pedrol | 0c0bf87 | 2020-05-14 15:50:49 +0200 | [diff] [blame] | 149 | var boolean g_force_two_phase_access := false; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 150 | |
| 151 | /* Guard timeout */ |
| 152 | timer g_T_guard := 60.0; |
| 153 | }; |
| 154 | |
| 155 | private altstep as_Tguard_RAW() runs on RAW_PCU_Test_CT { |
| 156 | [] g_T_guard.timeout { |
| 157 | setverdict(fail, "Timeout of T_guard"); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 158 | f_shutdown(__BFILE__, __LINE__); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 159 | } |
| 160 | } |
| 161 | |
| 162 | private function f_pcuvty_set_allowed_cs_mcs() runs on RAW_PCU_Test_CT { |
| 163 | f_vty_config2(PCUVTY, {"pcu"}, "cs " & int2str(g_cs_initial_dl) & " " & int2str(g_cs_initial_ul)); |
| 164 | f_vty_config2(PCUVTY, {"pcu"}, "cs max " & int2str(g_cs_max_dl) & " " & int2str(g_cs_max_ul)); |
| 165 | |
| 166 | f_vty_config2(PCUVTY, {"pcu"}, "mcs " & int2str(g_mcs_initial_dl) & " " & int2str(g_mcs_initial_ul)); |
| 167 | f_vty_config2(PCUVTY, {"pcu"}, "mcs max " & int2str(g_mcs_max_dl) & " " & int2str(g_mcs_max_ul)); |
| 168 | } |
| 169 | |
| 170 | private function f_pcuvty_set_link_quality_ranges() runs on RAW_PCU_Test_CT { |
| 171 | var charstring cmd; |
| 172 | |
| 173 | cmd := "cs link-quality-ranges" & |
| 174 | " cs1 " & int2str(g_cs_lqual_ranges[0].high) & |
| 175 | " cs2 " & int2str(g_cs_lqual_ranges[1].low) & " " & int2str(g_cs_lqual_ranges[1].high) & |
| 176 | " cs3 " & int2str(g_cs_lqual_ranges[2].low) & " " & int2str(g_cs_lqual_ranges[2].high) & |
| 177 | " cs4 " & int2str(g_cs_lqual_ranges[3].low); |
| 178 | f_vty_config2(PCUVTY, {"pcu"}, cmd); |
| 179 | |
| 180 | cmd := "mcs link-quality-ranges" & |
| 181 | " mcs1 " & int2str(g_mcs_lqual_ranges[0].high) & |
| 182 | " mcs2 " & int2str(g_mcs_lqual_ranges[1].low) & " " & int2str(g_mcs_lqual_ranges[1].high) & |
| 183 | " mcs3 " & int2str(g_mcs_lqual_ranges[2].low) & " " & int2str(g_mcs_lqual_ranges[2].high) & |
| 184 | " mcs4 " & int2str(g_mcs_lqual_ranges[3].low) & " " & int2str(g_mcs_lqual_ranges[3].high) & |
| 185 | " mcs5 " & int2str(g_mcs_lqual_ranges[4].low) & " " & int2str(g_mcs_lqual_ranges[4].high) & |
| 186 | " mcs6 " & int2str(g_mcs_lqual_ranges[5].low) & " " & int2str(g_mcs_lqual_ranges[5].high) & |
| 187 | " mcs7 " & int2str(g_mcs_lqual_ranges[6].low) & " " & int2str(g_mcs_lqual_ranges[6].high) & |
| 188 | " mcs8 " & int2str(g_mcs_lqual_ranges[7].low) & " " & int2str(g_mcs_lqual_ranges[7].high) & |
| 189 | " mcs9 " & int2str(g_mcs_lqual_ranges[8].low); |
| 190 | f_vty_config2(PCUVTY, {"pcu"}, cmd); |
| 191 | } |
| 192 | |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 193 | private function f_init_vty(charstring id, boolean egprs_only) runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 194 | map(self:PCUVTY, system:PCUVTY); |
| 195 | f_vty_set_prompts(PCUVTY); |
| 196 | f_vty_transceive(PCUVTY, "enable"); |
| 197 | |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 198 | /* This will be removed soon, not needed. EGPRS support is controlled through pcu_ind flags */ |
| 199 | if (egprs_only) { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 200 | f_vty_config2(PCUVTY, {"pcu"}, "egprs only"); |
| 201 | } else { |
| 202 | f_vty_config2(PCUVTY, {"pcu"}, "no egprs"); |
| 203 | } |
Pau Espin Pedrol | 0c0bf87 | 2020-05-14 15:50:49 +0200 | [diff] [blame] | 204 | |
| 205 | if (g_force_two_phase_access) { |
| 206 | f_vty_config2(PCUVTY, {"pcu"}, "two-phase-access"); |
| 207 | } else { |
| 208 | f_vty_config2(PCUVTY, {"pcu"}, "no two-phase-access"); |
| 209 | } |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 210 | } |
| 211 | |
Pau Espin Pedrol | 2456dad | 2020-04-30 20:22:38 +0200 | [diff] [blame] | 212 | function f_init_raw(charstring id, template (value) PCUIF_info_ind info_ind := ts_PCUIF_INFO_default) |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 213 | runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 214 | /* Start the guard timer */ |
| 215 | g_T_guard.start; |
| 216 | activate(as_Tguard_RAW()); |
| 217 | |
| 218 | /* Init PCU interface component */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 219 | vc_PCUIF := RAW_PCUIF_CT.create("PCUIF"); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 220 | connect(vc_PCUIF:MTC, self:PCUIF); |
| 221 | map(vc_PCUIF:PCU, system:PCU); |
| 222 | |
| 223 | /* Create one BTS component (we may want more some day) */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 224 | vc_BTS := RAW_PCU_BTS_CT.create("BTS"); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 225 | connect(vc_BTS:PCUIF, vc_PCUIF:BTS); |
| 226 | connect(vc_BTS:TC, self:BTS); |
| 227 | |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 228 | f_init_vty(id, f_pcuif_ind_flags_egprs_enabled(valueof(info_ind.flags))); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 229 | |
Daniel Willmann | 535aea6 | 2020-09-21 13:27:08 +0200 | [diff] [blame] | 230 | f_init_statsd(id, vc_STATSD, mp_pcu_statsd_ip, mp_pcu_statsd_port); |
| 231 | /* This is normally done in the ConnHdlr component, but here |
| 232 | * the Test_CT doubles as ConnHdlr */ |
| 233 | connect(self:STATSD_PROC, vc_STATSD:STATSD_PROC); |
| 234 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 235 | vc_PCUIF.start(f_PCUIF_CT_handler(mp_pcu_sock_path)); |
| 236 | vc_BTS.start(f_BTS_CT_handler(0, valueof(info_ind))); |
| 237 | |
| 238 | /* Wait until the BTS is ready (SI13 negotiated) */ |
| 239 | BTS.receive(tr_RAW_PCU_EV(BTS_EV_SI13_NEGO)); |
| 240 | } |
| 241 | |
Vadim Yanitskiy | 8a02b92 | 2020-10-31 21:57:10 +0700 | [diff] [blame] | 242 | /* Register TLLI of each allocated GprsMS instance */ |
| 243 | private function f_multi_ms_bssgp_register() |
| 244 | runs on RAW_PCU_Test_CT { |
| 245 | for (var integer i := 0; i < lengthof(g_ms); i := i + 1) { |
| 246 | f_bssgp_client_llgmm_assign(TLLI_UNUSED, g_ms[i].tlli); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | /* Allocate [and activate] an Uplink TBF for each allocated GprsMS instance */ |
| 251 | private function f_multi_ms_establish_tbf(boolean do_activate := false) |
| 252 | runs on RAW_PCU_Test_CT { |
| 253 | for (var integer i := 0; i < lengthof(g_ms); i := i + 1) { |
| 254 | /* Establish an Uplink TBF */ |
| 255 | f_ms_establish_ul_tbf(g_ms[i]); |
| 256 | |
| 257 | /* Send a random block, so this TBF becomes "active" */ |
| 258 | if (do_activate) { |
| 259 | /* FIXME: use the new APU by Pau to get correct TRX/TS here */ |
| 260 | var template TsTrxBtsNum nr := ts_TsTrxBtsNum(7, i mod 8); |
| 261 | var octetstring dummy := f_rnd_octstring(12); |
| 262 | var RlcmacDlBlock dl_block; |
| 263 | var uint32_t poll_fn; |
| 264 | |
| 265 | f_ms_tx_ul_data_block(g_ms[i], dummy, with_tlli := true, nr := nr); |
| 266 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, poll_fn, nr := nr); |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | |
Pau Espin Pedrol | 8155bf4 | 2020-10-29 17:34:26 +0100 | [diff] [blame] | 271 | private function f_ms_establish_ul_tbf_2phase_access(inout GprsMS ms, |
| 272 | template (omit) RlcmacUlCtrlMsg pkt_res_req := omit) |
| 273 | runs on RAW_PCU_Test_CT return PollFnCtx { |
| 274 | var PollFnCtx pollctx; |
| 275 | |
| 276 | /* Single block (two phase) packet access */ |
| 277 | var uint16_t ra := bit2int(chan_req_sb); |
| 278 | if (g_force_two_phase_access) { |
| 279 | /* If 2phase access is enforced by the network, then let's |
| 280 | * request a One phase packet access, we'll receive a single block |
| 281 | * anyway |
| 282 | */ |
| 283 | ra := bit2int(chan_req_def); |
| 284 | } |
| 285 | |
| 286 | /* Establish an Uplink TBF */ |
| 287 | f_ms_use_ra(ms, ra, ra_is_11bit := 0); |
| 288 | f_ms_establish_ul_tbf(ms); |
| 289 | |
| 290 | /* Make sure we've got an Uplink TBF assignment */ |
| 291 | if (not match(ms.ul_tbf.ass.ccch, tr_PacketUlSglAssign)) { |
| 292 | setverdict(fail, "Wrong Packet Uplink Assignment received: ", ms.ul_tbf.ass.ccch, " vs exp: ", tr_PacketUlSglAssign); |
| 293 | f_shutdown(__BFILE__, __LINE__); |
| 294 | } |
| 295 | |
| 296 | /* Send PACKET RESOURCE REQUEST |
| 297 | * (see 3GPP TS 04.60 "7.1.3.1 Initiation of the Packet resource request procedure") |
| 298 | */ |
| 299 | if (istemplatekind(pkt_res_req, "omit")) { |
| 300 | pkt_res_req := ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, omit); |
| 301 | } |
| 302 | |
| 303 | f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(pkt_res_req), 0, nr := f_ms_tx_TsTrxBtsNum(ms)); |
| 304 | /* Store 1st UlTBF context before receiving next one, will will |
| 305 | * overwrite the TS allocation on MS with info from new UL TBF: |
| 306 | */ |
| 307 | pollctx.tstrxbts := f_ms_tx_TsTrxBtsNum(ms); |
| 308 | f_ms_rx_pkt_ass_pacch(ms, pollctx.fn, tr_RLCMAC_UL_PACKET_ASS, nr := f_ms_tx_TsTrxBtsNum(ms)); |
| 309 | return pollctx; |
| 310 | } |
| 311 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 312 | testcase TC_pcuif_suspend() runs on RAW_PCU_Test_CT { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 313 | var octetstring ra_id := enc_RoutingAreaIdentification(mp_gb_cfg.bvc[0].cell_id.ra_id); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 314 | var GprsTlli tlli := 'FFFFFFFF'O; |
| 315 | timer T; |
| 316 | |
| 317 | /* Initialize NS/BSSGP side */ |
| 318 | f_init_bssgp(); |
| 319 | |
| 320 | /* Initialize the PCU interface abstraction */ |
| 321 | f_init_raw(testcasename()); |
| 322 | |
| 323 | /* Establish BSSGP connection to the PCU */ |
| 324 | f_bssgp_establish(); |
| 325 | |
| 326 | BTS.send(ts_PCUIF_SUSP_REQ(0, tlli, ra_id, 0)); |
| 327 | |
| 328 | T.start(2.0); |
| 329 | alt { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 330 | [] BSSGP_SIG[0].receive(tr_BSSGP_SUSPEND(tlli, mp_gb_cfg.bvc[0].cell_id.ra_id)) { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 331 | setverdict(pass); |
| 332 | } |
| 333 | [] T.timeout { |
| 334 | setverdict(fail, "Timeout waiting for BSSGP SUSPEND"); |
| 335 | } |
| 336 | } |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 337 | |
| 338 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | /* Test of correct Timing Advance at the time of TBF establishment |
| 342 | * (derived from timing offset of the Access Burst). */ |
| 343 | testcase TC_ta_rach_imm_ass() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 344 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 345 | |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 346 | /* Initialize GPRS MS side */ |
| 347 | f_init_gprs_ms(); |
| 348 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 349 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 350 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 351 | |
| 352 | /* We cannot send too many TBF requests in a short time because |
| 353 | * at some point the PCU will fail to allocate a new TBF. */ |
| 354 | for (var TimingAdvance ta := 0; ta < 64; ta := ta + 16) { |
| 355 | /* Establish an Uplink TBF (send RACH.ind with current TA) */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 356 | ms.ta := ta; |
Vadim Yanitskiy | 84d1dd5 | 2020-05-28 21:09:22 +0700 | [diff] [blame] | 357 | f_ms_establish_ul_tbf(ms); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 358 | |
| 359 | /* Make sure Timing Advance IE matches out expectations */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 360 | if (ms.ul_tbf.rr_imm_ass.payload.imm_ass.timing_advance != ta) { |
Vadim Yanitskiy | 8685b38 | 2020-05-06 16:53:26 +0700 | [diff] [blame] | 361 | setverdict(fail, "Timing Advance mismatch: ", |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 362 | ms.ul_tbf.rr_imm_ass.payload.imm_ass.timing_advance, |
Vadim Yanitskiy | 8685b38 | 2020-05-06 16:53:26 +0700 | [diff] [blame] | 363 | " vs expected ", ta); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 364 | break; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 365 | } |
| 366 | } |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 367 | |
| 368 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | /* Verify Timing Advance value(s) indicated during the packet Downlink assignment |
| 372 | * procedure as per 3GPP TS 44.018, section 3.5.3. There seems to be a bug in the |
| 373 | * IUT that causes it to send an unreasonable Timing Advance value > 0 despite |
| 374 | * no active TBF exists at the moment of establishment (idle mode). */ |
| 375 | testcase TC_ta_idle_dl_tbf_ass() runs on RAW_PCU_Test_CT { |
Vadim Yanitskiy | 84d1dd5 | 2020-05-28 21:09:22 +0700 | [diff] [blame] | 376 | var OCT4 tlli := f_rnd_octstring(4); |
| 377 | var GsmRrMessage rr_imm_ass; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 378 | |
| 379 | /* Initialize NS/BSSGP side */ |
| 380 | f_init_bssgp(); |
| 381 | |
| 382 | /* Initialize the PCU interface abstraction */ |
| 383 | f_init_raw(testcasename()); |
| 384 | |
| 385 | /* Establish BSSGP connection to the PCU */ |
| 386 | f_bssgp_establish(); |
Vadim Yanitskiy | 84d1dd5 | 2020-05-28 21:09:22 +0700 | [diff] [blame] | 387 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 388 | |
| 389 | /* SGSN sends some DL data, PCU will initiate Packet Downlink |
| 390 | * Assignment on CCCH (PCH). We don't care about the payload. */ |
Vadim Yanitskiy | 84d1dd5 | 2020-05-28 21:09:22 +0700 | [diff] [blame] | 391 | BSSGP[0].send(ts_BSSGP_DL_UD(tlli, f_rnd_octstring(10))); |
| 392 | rr_imm_ass := f_pcuif_rx_imm_ass(PCU_IF_SAPI_PCH, tr_IMM_TBF_ASS(dl := true)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 393 | |
| 394 | /* Make sure that Timing Advance is 0 (the actual value is not known yet). |
| 395 | * As per 3GPP S 44.018, section 3.5.3.1.2, the network *shall* initiate |
| 396 | * the procedures defined in 3GPP TS 44.060 or use the polling mechanism. */ |
Vadim Yanitskiy | 84d1dd5 | 2020-05-28 21:09:22 +0700 | [diff] [blame] | 397 | if (rr_imm_ass.payload.imm_ass.timing_advance != 0) { |
| 398 | setverdict(fail, "Timing Advance value doesn't match"); |
| 399 | } |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 400 | |
| 401 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | /* Verify that the PCU generates valid PTCCH/D messages |
| 405 | * while neither Uplink nor Downlink TBF is established. */ |
| 406 | testcase TC_ta_ptcch_idle() runs on RAW_PCU_Test_CT { |
| 407 | var PTCCHDownlinkMsg ptcch_msg; |
| 408 | var PCUIF_Message pcu_msg; |
| 409 | timer T; |
| 410 | |
| 411 | /* Initialize the PCU interface abstraction */ |
| 412 | f_init_raw(testcasename()); |
| 413 | |
| 414 | /* Sent an RTS.req for PTCCH/D */ |
| 415 | BTS.send(ts_PCUIF_RTS_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 416 | sapi := PCU_IF_SAPI_PTCCH, fn := 0, |
| 417 | arfcn := 871, block_nr := 0)); |
| 418 | T.start(5.0); |
| 419 | alt { |
| 420 | [] BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 421 | sapi := PCU_IF_SAPI_PTCCH)) -> value pcu_msg { |
| 422 | log("Rx DATA.req message: ", pcu_msg); |
| 423 | setverdict(pass); |
| 424 | } |
| 425 | [] BTS.receive(PCUIF_Message:?) { repeat; } |
| 426 | [] T.timeout { |
| 427 | setverdict(fail, "Timeout waiting for a PTCCH/D block"); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 428 | f_shutdown(__BFILE__, __LINE__); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 429 | } |
| 430 | } |
| 431 | |
| 432 | ptcch_msg := dec_PTCCHDownlinkMsg(pcu_msg.u.data_req.data); |
| 433 | log("Decoded PTCCH/D message: ", ptcch_msg); |
| 434 | |
| 435 | /* Make sure the message is encoded correctly |
| 436 | * TODO: do we expect all TA values to be equal '1111111'B? */ |
| 437 | if (not match(ptcch_msg, tr_PTCCHDownlinkMsg)) { |
| 438 | setverdict(fail, "Malformed PTCCH/D message"); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 439 | } |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 440 | |
| 441 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | /* Test of correct Timing Advance during an active Uplink TBF. |
| 445 | * |
| 446 | * Unlike the circuit-switched domain, Uplink transmissions on PDCH time-slots |
| 447 | * are not continuous and there can be long time gaps between them. This happens |
| 448 | * due to a bursty nature of packet data. The actual Timing Advance of a MS may |
| 449 | * significantly change between such rare Uplink transmissions, so GPRS introduces |
| 450 | * additional mechanisms to control Timing Advance, and thus reduce interference |
| 451 | * between neighboring TDMA time-slots. |
| 452 | * |
| 453 | * At the moment of Uplink TBF establishment, initial Timing Advance is measured |
| 454 | * from ToA (Timing of Arrival) of an Access Burst. This is covered by another |
| 455 | * test case - TC_ta_rach_imm_ass. In response to that Access Burst the network |
| 456 | * sends Immediate Assignment on AGCH, which _may_ contain Timing Advance Index |
| 457 | * among with the initial Timing Advance value. And here PTCCH comes to play. |
| 458 | * |
| 459 | * PTCCH is a unidirectional channel on which the network can instruct a sub-set |
| 460 | * of 16 MS (whether TBFs are active or not) to adjust their Timing Advance |
| 461 | * continuously. To ensure continuous measurements of the signal propagation |
| 462 | * delay, the MSs shall transmit Access Bursts on Uplink (PTCCH/U) on sub-slots |
| 463 | * defined by an assigned Timing Advance Index (see 3GPP TS 45.002). |
| 464 | * |
| 465 | * The purpose of this test case is to verify the assignment of Timing Advance |
| 466 | * Index, and the process of Timing Advance notification on PTCCH/D. The MTC |
| 467 | * first establishes several Uplink TBFs, but does not transmit any Uplink |
| 468 | * blocks on them. During 4 TDMA multi-frame periods the MTC is sending RACH |
| 469 | * indications to the PCU, checking the correctness of two received PTCCH/D |
| 470 | * messages (period of PTCCH/D is two multi-frames). |
| 471 | */ |
| 472 | |
| 473 | /* List of ToA values for Access Bursts to be sent on PTCCH/U, |
| 474 | * each ToA (Timing of Arrival) value is in units of 1/4 of |
| 475 | * a symbol (i.e. 1 symbol is 4 QTA units). */ |
| 476 | type record length(16) of int16_t PTCCH_TAI_ToA_MAP; |
| 477 | const PTCCH_TAI_ToA_MAP ptcch_toa_map_def := { |
| 478 | 0, 0, 0, 0, |
| 479 | 0, 0, 0, 0, |
| 480 | 0, 0, 0, 0, |
| 481 | 0, 0, 0, 0 |
| 482 | }; |
| 483 | |
| 484 | private altstep as_ta_ptcch(uint8_t bts_nr := 0, uint8_t trx_nr := 0, uint8_t ts_nr := 7, |
| 485 | in PTCCH_TAI_ToA_MAP toa_map := ptcch_toa_map_def) |
| 486 | runs on RAW_PCU_Test_CT { |
| 487 | var RAW_PCU_Event event; |
| 488 | var integer ss; |
| 489 | |
| 490 | /* Send Access Bursts on PTCCH/U for every TA Index */ |
| 491 | [] BTS.receive(tr_RAW_PCU_EV(TDMA_EV_PTCCH_UL_BURST)) -> value event { |
| 492 | ss := f_tdma_ptcch_fn2ss(event.data.tdma_fn); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 493 | if (ss < 0) { /* Shall not happen */ |
| 494 | f_shutdown(__BFILE__, __LINE__); |
| 495 | } |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 496 | |
| 497 | log("Sending an Access Burst on PTCCH/U", |
| 498 | ", sub-slot=", ss, " (TAI)", |
| 499 | ", fn=", event.data.tdma_fn, |
| 500 | ", ToA=", toa_map[ss], " (QTA)"); |
| 501 | /* TODO: do we care about RA and burst format? */ |
| 502 | BTS.send(ts_PCUIF_RACH_IND(bts_nr, trx_nr, ts_nr, |
| 503 | ra := oct2int('3A'O), |
| 504 | is_11bit := 0, |
| 505 | burst_type := BURST_TYPE_0, |
| 506 | fn := event.data.tdma_fn, |
| 507 | arfcn := 871, |
| 508 | qta := toa_map[ss], |
| 509 | sapi := PCU_IF_SAPI_PTCCH)); |
| 510 | repeat; |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | private function f_TC_ta_ptcch_ul_multi_tbf(in PTCCH_TAI_ToA_MAP ptcch_toa_map, |
| 515 | template PTCCHDownlinkMsg t_ta_msg) |
| 516 | runs on RAW_PCU_Test_CT { |
| 517 | var PTCCHDownlinkMsg ta_msg; |
| 518 | var PCUIF_Message pcu_msg; |
| 519 | timer T; |
| 520 | |
| 521 | /* First, send an RTS.req for the upcoming PTCCH/D block */ |
| 522 | BTS.send(ts_PCUIF_RTS_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 523 | sapi := PCU_IF_SAPI_PTCCH, fn := 0, |
| 524 | arfcn := 871, block_nr := 0)); |
| 525 | T.start(2.0); |
| 526 | alt { |
| 527 | /* Keep sending of Access Bursts during two multi-frames (period of PTCCH/D) |
| 528 | * with increasing ToA (Timing of Arrival) values: 0, 7, 14, 28, 35... */ |
| 529 | [] as_ta_ptcch(bts_nr := 0, trx_nr := 0, ts_nr := 7, toa_map := ptcch_toa_map); |
| 530 | /* In the end of 2nd multi-frame we should receive a PTCCH/D block */ |
| 531 | [] BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 532 | sapi := PCU_IF_SAPI_PTCCH)) -> value pcu_msg { |
| 533 | ta_msg := dec_PTCCHDownlinkMsg(pcu_msg.u.data_req.data); |
| 534 | log("Rx PTCCH/D message: ", ta_msg); |
| 535 | |
| 536 | /* Make sure Timing Advance values match our expectations */ |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 537 | if (not match(ta_msg, t_ta_msg)) { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 538 | setverdict(fail, "PTCCH/D message does not match: ", t_ta_msg); |
| 539 | } |
| 540 | } |
| 541 | [] BTS.receive { repeat; } |
| 542 | [] T.timeout { |
| 543 | setverdict(fail, "Timeout waiting for a PTCCH/D block"); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 544 | } |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | testcase TC_ta_ptcch_ul_multi_tbf() runs on RAW_PCU_Test_CT { |
| 549 | var template PacketUlAssign t_ul_tbf_ass; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 550 | var GprsMS ms; |
| 551 | |
| 552 | /* Initialize GPRS MS side */ |
| 553 | f_init_gprs_ms(); |
| 554 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 555 | |
| 556 | /* Initialize the PCU interface abstraction */ |
| 557 | f_init_raw(testcasename()); |
| 558 | |
| 559 | /* Enable forwarding of PTCCH/U TDMA events to us */ |
| 560 | BTS.send(ts_RAW_PCU_CMD(TDMA_CMD_ENABLE_PTCCH_UL_FWD)); |
| 561 | |
| 562 | /* Establish 7 Uplink TBFs (USF flag is 3 bits long, '111'B is reserved) */ |
| 563 | for (var integer i := 0; i < 7; i := i + 1) { |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 564 | /* Establish an Uplink TBF */ |
| 565 | f_ms_establish_ul_tbf(ms); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 566 | |
| 567 | /* We expect incremental TFI/USF assignment (dynamic allocation) */ |
| 568 | t_ul_tbf_ass := tr_PacketUlDynAssign(tfi := i, usf := i); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 569 | if (not match(ms.ul_tbf.ass.ccch, t_ul_tbf_ass)) { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 570 | setverdict(fail, "Failed to match Packet Uplink Assignment for #", i); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 571 | break; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 572 | } |
| 573 | |
| 574 | /* We also expect Timing Advance Index to be a part of the assignment */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 575 | if (ms.ul_tbf.ass.ccch.dynamic.ta_index != i) { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 576 | setverdict(fail, "Failed to match Timing Advance Index for #", i); |
| 577 | /* Keep going, the current OsmoPCU does not assign TA Index */ |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | /* Prepare a list of ToA values for Access Bursts to be sent on PTCCH/U */ |
| 582 | var PTCCH_TAI_ToA_MAP toa_map := ptcch_toa_map_def; |
| 583 | for (var integer i := 0; i < 7; i := i + 1) { |
| 584 | /* ToA in units of 1/4 of a symbol */ |
| 585 | toa_map[i] := (i + 1) * 7 * 4; |
| 586 | } |
| 587 | |
| 588 | /* Now we have all 7 TBFs established in one-phase access mode, |
| 589 | * however we will not be sending any data on them. Instead, we |
| 590 | * will be sending RACH.ind on PTCCH/U during 4 multi-frame |
| 591 | * periods (TAI 0..8), and then will check two PTCCH/D blocks. |
| 592 | * |
| 593 | * Why not 4 TBFs at once? Because Uplink is delayed by 3 TDMA |
| 594 | * time-slots, so at the moment of scheduling a PTCCH/D block |
| 595 | * the PCU has odd number of PTCCH/U Access Bursts received. */ |
| 596 | f_TC_ta_ptcch_ul_multi_tbf(toa_map, tr_PTCCHDownlinkMsg( |
| 597 | tai0_ta := 7, tai1_ta := 14, tai2_ta := 21, |
| 598 | /* Other values are not known (yet) */ |
| 599 | tai3_ta := ?)); |
| 600 | f_TC_ta_ptcch_ul_multi_tbf(toa_map, tr_PTCCHDownlinkMsg( |
| 601 | tai0_ta := 7, tai1_ta := 14, tai2_ta := 21, |
| 602 | tai3_ta := 28, tai4_ta := 35, tai5_ta := 42, |
| 603 | /* Other values are out of our interest */ |
| 604 | tai6_ta := ?)); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 605 | |
| 606 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | /* Default link quality adaptation (Coding Scheme) ranges (inclusive). |
| 610 | * OsmoPCU (VTY): cs link-quality-ranges cs1 6 cs2 5 8 cs3 7 13 cs4 12 |
| 611 | * |
| 612 | * NOTE: the ranges are intentionally overlapping because OsmoPCU |
| 613 | * does not change CS/MCS on the range borders (5-6, 7-8, 12-13). */ |
| 614 | private template integer CS1_lqual_dB_range := (-infinity .. 6); |
| 615 | private template integer CS2_lqual_dB_range := (5 .. 8); |
| 616 | private template integer CS3_lqual_dB_range := (7 .. 13); |
| 617 | private template integer CS4_lqual_dB_range := (12 .. infinity); |
| 618 | |
| 619 | testcase TC_cs_lqual_ul_tbf() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 620 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 621 | var GprsMS ms; |
| 622 | var uint32_t unused_fn, sched_fn; |
| 623 | var uint4_t cv; |
| 624 | |
| 625 | /* Initialize GPRS MS side */ |
| 626 | f_init_gprs_ms(); |
| 627 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 628 | |
| 629 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 630 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 631 | |
| 632 | f_pcuvty_set_allowed_cs_mcs(); |
| 633 | f_pcuvty_set_link_quality_ranges(); |
| 634 | |
| 635 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 636 | f_ms_establish_ul_tbf(ms); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 637 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 638 | |
| 639 | /* The actual / old link quality values. We need to keep track of the old |
| 640 | * (basically previous) link quality value, because OsmoPCU actually |
| 641 | * changes the coding scheme if not only the actual, but also the old |
| 642 | * value leaves the current link quality range (window). */ |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 643 | var integer lqual_old; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 644 | ms.lqual_cb := 0; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 645 | |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 646 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 647 | contention resoultion) and make sure it is ACKED fine. */ |
| 648 | /* 16 bytes fills the llc block (because TLLI takes 4 bytes) */ |
| 649 | /* Set CV = 15 to signal there's still more than BS_CV_MAX blocks to be sent */ |
| 650 | f_ms_tx_ul_data_block(ms, f_rnd_octstring(16), cv := 15, with_tlli := true) |
| 651 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 652 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 653 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 654 | |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 655 | /* 16 UL blocks (0 .. 15 dB, step = 1 cB) */ |
| 656 | for (var integer i := 150; i >= 0; i := i - 1) { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 657 | /* Update the old / actual link quality */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 658 | lqual_old := ms.lqual_cb; |
| 659 | ms.lqual_cb := 150 - i; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 660 | |
| 661 | /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 662 | log("Sending DATA.ind with link quality (dB): ", ms.lqual_cb); |
| 663 | if (i > g_bs_cv_max) { |
| 664 | cv := 15; |
| 665 | } else { |
| 666 | cv := i; |
| 667 | } |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 668 | |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 669 | f_ms_tx_ul_data_block(ms, f_rnd_octstring(10), cv := cv) |
| 670 | |
| 671 | /* we will receive UL ACK/NACK from time to time. In that case, check CdCofing increases */ |
| 672 | f_rx_rlcmac_dl_block(dl_block, unused_fn); |
| 673 | if (match(dl_block, tr_RLCMAC_DUMMY_CTRL())) { |
| 674 | continue; |
| 675 | } |
| 676 | if (not match(dl_block, tr_RLCMAC_UL_ACK_NACK_GPRS(ul_tfi := ?)) and |
| 677 | not match(dl_block, tr_RLCMAC_UL_ACK_NACK_EGPRS(ul_tfi := ?))) { |
| 678 | setverdict(fail, "Failed to match Packet Uplink ACK / NACK:", dl_block); |
| 679 | f_shutdown(__BFILE__, __LINE__); |
| 680 | } |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 681 | |
| 682 | log("Rx Packet Uplink ACK / NACK with Channel Coding Command: ", |
| 683 | dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd); |
| 684 | |
| 685 | /* Match the received Channel Coding Command. Since we are increasing |
| 686 | * the link quality value on each iteration and not decreasing, there |
| 687 | * is no need to check the both old and current link quality values. */ |
| 688 | var template ChCodingCommand ch_coding; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 689 | select (lqual_old / 10) { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 690 | case (CS1_lqual_dB_range) { ch_coding := CH_CODING_CS1; } |
| 691 | case (CS2_lqual_dB_range) { ch_coding := CH_CODING_CS2; } |
| 692 | case (CS3_lqual_dB_range) { ch_coding := CH_CODING_CS3; } |
| 693 | case (CS4_lqual_dB_range) { ch_coding := CH_CODING_CS4; } |
| 694 | } |
| 695 | |
| 696 | if (not match(dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd, ch_coding)) { |
| 697 | setverdict(fail, "Channel Coding does not match our expectations: ", ch_coding); |
Pau Espin Pedrol | 1617e31 | 2020-05-22 14:41:14 +0200 | [diff] [blame] | 698 | f_shutdown(__BFILE__, __LINE__); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 699 | } |
| 700 | } |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 701 | |
| 702 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | /* Test the max UL CS set by VTY works fine */ |
| 706 | testcase TC_cs_initial_ul() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 707 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 708 | var ChCodingCommand last_ch_coding; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 709 | var uint32_t unused_fn, sched_fn; |
| 710 | var GprsMS ms; |
| 711 | |
| 712 | /* Initialize GPRS MS side */ |
| 713 | f_init_gprs_ms(); |
| 714 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 715 | |
| 716 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 717 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 718 | |
| 719 | /* Set initial UL CS to 3 */ |
| 720 | g_cs_initial_ul := 3; |
| 721 | f_pcuvty_set_allowed_cs_mcs(); |
| 722 | f_pcuvty_set_link_quality_ranges(); |
| 723 | |
| 724 | /* Take lqual (dB->cB) so that we stay in that CS */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 725 | ms.lqual_cb := g_cs_lqual_ranges[2].low * 10; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 726 | |
| 727 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 728 | f_ms_establish_ul_tbf(ms); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 729 | |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 730 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 731 | contention resoultion) and make sure it is ACKED fine. */ |
| 732 | /* 16 bytes fills the llc block (because TLLI takes 4 bytes) */ |
| 733 | /* Set CV = 15 to signal there's still more than BS_CV_MAX blocks to be sent */ |
| 734 | f_ms_tx_ul_data_block(ms, f_rnd_octstring(16), cv := 15, with_tlli := true) |
| 735 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 736 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 737 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 738 | |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 739 | /* Send UL blocks, until we receive UL ACK/NACK and check we are in same initial CS: */ |
| 740 | while (true) { |
| 741 | f_ms_tx_ul_data_block(ms, f_rnd_octstring(10), cv := 15); |
| 742 | f_rx_rlcmac_dl_block(dl_block, unused_fn); |
| 743 | if (match(dl_block, tr_RLCMAC_DUMMY_CTRL())) { |
| 744 | continue; |
| 745 | } |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 746 | |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 747 | if (not match(dl_block, tr_RLCMAC_UL_ACK_NACK_GPRS(ul_tfi := ?)) and |
| 748 | not match(dl_block, tr_RLCMAC_UL_ACK_NACK_EGPRS(ul_tfi := ?))) { |
| 749 | setverdict(fail, "Failed to match Packet Uplink ACK / NACK:", dl_block); |
| 750 | f_shutdown(__BFILE__, __LINE__); |
| 751 | break; |
| 752 | } |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 753 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 754 | last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 755 | break; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 756 | } |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 757 | if (last_ch_coding != CH_CODING_CS3) { |
| 758 | setverdict(fail, "Channel Coding does not match our expectations (CS-3): ", last_ch_coding); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 759 | f_shutdown(__BFILE__, __LINE__); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 760 | } |
| 761 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 762 | /* Remaining UL blocks are used to make sure regardless of initial |
| 763 | /* lqual, we can go lower at any time */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 764 | /* 0 dB, make sure we downgrade CS */ |
| 765 | ms.lqual_cb := 0; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 766 | /* 5 UL blocks, check we are in same initial CS: */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 767 | f_ms_tx_ul_data_block_multi(ms, 5); |
| 768 | /* Enqueue RTS.req, expect DATA.req with UL ACK from the PCU */ |
| 769 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, unused_fn); |
| 770 | last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 771 | |
| 772 | if (last_ch_coding != CH_CODING_CS1) { |
| 773 | setverdict(fail, "Channel Coding does not match our expectations (CS-1): ", last_ch_coding); |
Pau Espin Pedrol | 1617e31 | 2020-05-22 14:41:14 +0200 | [diff] [blame] | 774 | f_shutdown(__BFILE__, __LINE__); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 775 | } |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 776 | |
| 777 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 778 | } |
| 779 | |
| 780 | /* Test the max UL CS set by VTY works fine */ |
| 781 | testcase TC_cs_max_ul() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 782 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 783 | var ChCodingCommand last_ch_coding; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 784 | var uint32_t unused_fn, sched_fn; |
| 785 | var GprsMS ms; |
| 786 | |
| 787 | /* Initialize GPRS MS side */ |
| 788 | f_init_gprs_ms(); |
| 789 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 790 | |
| 791 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 792 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 793 | |
| 794 | /* Set maximum allowed UL CS to 3 */ |
| 795 | g_cs_max_ul := 3; |
| 796 | f_pcuvty_set_allowed_cs_mcs(); |
| 797 | f_pcuvty_set_link_quality_ranges(); |
| 798 | |
| 799 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 800 | f_ms_establish_ul_tbf(ms); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 801 | |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 802 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 803 | contention resoultion) and make sure it is ACKED fine. */ |
| 804 | /* 16 bytes fills the llc block (because TLLI takes 4 bytes) */ |
| 805 | /* Set CV = 15 to signal there's still more than BS_CV_MAX blocks to be sent */ |
| 806 | f_ms_tx_ul_data_block(ms, f_rnd_octstring(16), cv := 15, with_tlli := true) |
| 807 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 808 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 809 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 810 | |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 811 | ms.lqual_cb := 40*10; /* 40 dB */ |
| 812 | f_ms_tx_ul_data_block_multi(ms, 16); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 813 | |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 814 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, unused_fn); |
| 815 | last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 816 | |
| 817 | if (last_ch_coding != CH_CODING_CS3) { |
| 818 | setverdict(fail, "Channel Coding does not match our expectations (CS-3): ", last_ch_coding); |
Pau Espin Pedrol | 1617e31 | 2020-05-22 14:41:14 +0200 | [diff] [blame] | 819 | f_shutdown(__BFILE__, __LINE__); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 820 | } |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 821 | |
| 822 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 823 | } |
| 824 | |
Pau Espin Pedrol | 7512259 | 2020-11-03 15:22:59 +0100 | [diff] [blame] | 825 | /* Test the initial DL CS set by VTY works fine */ |
| 826 | testcase TC_cs_initial_dl() runs on RAW_PCU_Test_CT { |
| 827 | var octetstring data := f_rnd_octstring(10); |
| 828 | var CodingScheme exp_dl_cs_mcs; |
| 829 | var RlcmacDlBlock dl_block; |
| 830 | var uint32_t poll_fn; |
| 831 | var GprsMS ms; |
| 832 | |
| 833 | /* Initialize NS/BSSGP side */ |
| 834 | f_init_bssgp(); |
| 835 | /* Initialize GPRS MS side */ |
| 836 | f_init_gprs_ms(); |
| 837 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 838 | |
| 839 | /* Initialize the PCU interface abstraction */ |
| 840 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
| 841 | |
| 842 | /* Set initial allowed DL CS to 3 */ |
| 843 | g_cs_initial_dl := 3; |
| 844 | exp_dl_cs_mcs := CS_3; |
| 845 | /* Set maximum allowed UL CS to 4 */ |
| 846 | g_cs_max_dl := 4; |
| 847 | f_pcuvty_set_allowed_cs_mcs(); |
| 848 | f_pcuvty_set_link_quality_ranges(); |
| 849 | |
| 850 | /* Establish BSSGP connection to the PCU */ |
| 851 | f_bssgp_establish(); |
| 852 | f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli); |
| 853 | |
| 854 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
| 855 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 856 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
| 857 | |
| 858 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 859 | f_sleep(X2002); |
| 860 | f_rx_rlcmac_dl_block_exp_data(dl_block, poll_fn, data, 0, exp_dl_cs_mcs); |
| 861 | |
| 862 | /* ACK the DL block */ |
| 863 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B); |
| 864 | f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc), |
| 865 | f_dl_block_ack_fn(dl_block, poll_fn)); |
| 866 | |
| 867 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 868 | } |
| 869 | |
Pau Espin Pedrol | 5d07ae6 | 2020-11-05 17:59:30 +0100 | [diff] [blame] | 870 | /* Verify scheduling of multiple Downlink data blocks, enough to reach CS4 */ |
| 871 | function f_dl_data_exp_cs(template CodingScheme exp_cs := ?) runs on RAW_PCU_Test_CT { |
| 872 | var octetstring data := f_rnd_octstring(1000); |
| 873 | var RlcmacDlBlock prev_dl_block, dl_block; |
| 874 | var uint32_t ack_fn; |
| 875 | var uint32_t fn; |
| 876 | var GprsMS ms; |
| 877 | var integer tx_data_remain := 5; |
| 878 | var integer bsn := 0; |
| 879 | |
| 880 | /* Establish BSSGP connection to the PCU */ |
| 881 | f_bssgp_establish(); |
| 882 | |
| 883 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 884 | f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli); |
| 885 | |
| 886 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
| 887 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 888 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
| 889 | |
| 890 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS */ |
| 891 | f_sleep(X2002); |
| 892 | |
| 893 | for (var integer i := 0; i < 250; i := i + 1) { |
| 894 | bsn := i mod 128; |
| 895 | f_rx_rlcmac_dl_block(dl_block, fn); |
| 896 | |
| 897 | if (match(dl_block, tr_RLCMAC_DUMMY_CTRL)) { |
| 898 | /* No more data to receive, done */ |
| 899 | break; |
| 900 | } |
| 901 | |
| 902 | f_rlcmac_dl_block_exp_data(dl_block, ?, bsn, cs_gprs_any); |
| 903 | |
| 904 | /* Keep Ack/Nack description updated */ |
| 905 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block); |
| 906 | |
| 907 | /* TDMA frame number on which we are supposed to send the ACK */ |
| 908 | if (dl_block.data.mac_hdr.mac_hdr.rrbp_valid) { |
| 909 | ack_fn := f_dl_block_ack_fn(dl_block, fn); |
| 910 | f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc), ack_fn); |
| 911 | if (tx_data_remain != 0) { |
| 912 | /* Submit more data from time to time to keep the TBF ongoing */ |
| 913 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 914 | tx_data_remain := tx_data_remain - 1; |
| 915 | } |
| 916 | } |
| 917 | prev_dl_block := dl_block; |
| 918 | } |
| 919 | |
| 920 | bsn := (bsn + 127) mod 128; /* previous bsn: bsn -1 */ |
| 921 | f_rlcmac_dl_block_exp_data(prev_dl_block, ?, bsn, exp_cs); |
| 922 | |
| 923 | |
| 924 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 925 | } |
| 926 | |
| 927 | /* Verify DL CS above "cs max" set by VTY is never used */ |
| 928 | testcase TC_cs_max_dl() runs on RAW_PCU_Test_CT { |
| 929 | /* Initialize NS/BSSGP side */ |
| 930 | f_init_bssgp(); |
| 931 | /* Initialize GPRS MS side */ |
| 932 | f_init_gprs_ms(); |
| 933 | |
| 934 | /* Initialize the PCU interface abstraction */ |
| 935 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
| 936 | |
| 937 | /* Set maximum allowed DL CS to 3 */ |
| 938 | g_cs_initial_dl := 1; |
| 939 | g_cs_max_dl := 3; |
| 940 | f_pcuvty_set_allowed_cs_mcs(); |
| 941 | f_pcuvty_set_link_quality_ranges(); |
| 942 | |
| 943 | f_dl_data_exp_cs(f_rlcmac_block_int2cs_mcs(g_cs_max_dl, false)); |
| 944 | } |
| 945 | |
| 946 | /* Check DL CS4 is used in good link conditions if allowed by config */ |
| 947 | testcase TC_dl_cs1_to_cs4() runs on RAW_PCU_Test_CT { |
| 948 | /* Initialize NS/BSSGP side */ |
| 949 | f_init_bssgp(); |
| 950 | /* Initialize GPRS MS side */ |
| 951 | f_init_gprs_ms(); |
| 952 | |
| 953 | /* Initialize the PCU interface abstraction */ |
| 954 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
| 955 | |
| 956 | /* Set initial DL CS to 1 & maximum allowed DL CS to 4 */ |
| 957 | g_cs_initial_dl := 1; |
| 958 | g_cs_max_dl := 4; |
| 959 | f_pcuvty_set_allowed_cs_mcs(); |
| 960 | f_pcuvty_set_link_quality_ranges(); |
| 961 | |
| 962 | f_dl_data_exp_cs(f_rlcmac_block_int2cs_mcs(g_cs_max_dl, false)); |
| 963 | } |
| 964 | |
Pau Espin Pedrol | 2354d6a | 2020-11-05 18:36:59 +0100 | [diff] [blame] | 965 | /* Test the initial UL MCS set by VTY works fine */ |
| 966 | testcase TC_mcs_initial_ul() runs on RAW_PCU_Test_CT { |
| 967 | var RlcmacDlBlock dl_block; |
| 968 | var PollFnCtx pollctx; |
| 969 | var EgprsChCodingCommand last_ch_coding; |
| 970 | var uint32_t unused_fn, sched_fn; |
| 971 | var GprsMS ms; |
| 972 | var CodingScheme exp_ul_mcs; |
| 973 | var MultislotCap_GPRS mscap_gprs := { |
| 974 | gprsmultislotclass := '00011'B, |
| 975 | gprsextendeddynalloccap := '0'B |
| 976 | }; |
| 977 | var MultislotCap_EGPRS mscap_egprs := { |
| 978 | egprsmultislotclass := '00011'B, |
| 979 | egprsextendeddynalloccap := '0'B |
| 980 | }; |
| 981 | var MSRadioAccessCapabilityV ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, mscap_egprs)) }; |
| 982 | |
| 983 | /* Initialize GPRS MS side */ |
| 984 | f_init_gprs_ms(); |
| 985 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 986 | |
| 987 | /* Initialize the PCU interface abstraction */ |
| 988 | f_init_raw(testcasename()); |
| 989 | |
| 990 | /* Set initial UL MCS to 3 */ |
| 991 | g_mcs_initial_ul := 3; |
| 992 | exp_ul_mcs := f_rlcmac_block_int2cs_mcs(g_mcs_initial_ul, true); |
| 993 | f_pcuvty_set_allowed_cs_mcs(); |
| 994 | f_pcuvty_set_link_quality_ranges(); |
| 995 | |
| 996 | /* Take lqual (dB->cB) so that we stay in that MCS */ |
| 997 | ms.lqual_cb := g_mcs_lqual_ranges[2].low * 10; |
| 998 | |
| 999 | /* Send PACKET RESOURCE REQUEST to upgrade to EGPRS */ |
| 1000 | pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap)); |
| 1001 | |
| 1002 | if (not match(ms.ul_tbf.tx_cs_mcs, exp_ul_mcs)) { |
| 1003 | setverdict(fail, "Wrong CS_MCS ", ms.ul_tbf.tx_cs_mcs, " received vs exp ", exp_ul_mcs); |
| 1004 | f_shutdown(__BFILE__, __LINE__); |
| 1005 | } |
| 1006 | |
| 1007 | /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 1008 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts); |
| 1009 | |
| 1010 | /* Send UL blocks, until we receive UL ACK/NACK and check we are in same initial CS: */ |
| 1011 | while (true) { |
| 1012 | f_ms_tx_ul_data_block(ms, f_rnd_octstring(10), cv := 15); |
| 1013 | f_rx_rlcmac_dl_block(dl_block, unused_fn); |
| 1014 | if (match(dl_block, tr_RLCMAC_DUMMY_CTRL())) { |
| 1015 | continue; |
| 1016 | } |
| 1017 | |
| 1018 | if (not match(dl_block, tr_RLCMAC_UL_ACK_NACK_EGPRS(ul_tfi := ?))) { |
| 1019 | setverdict(fail, "Failed to match Packet Uplink ACK / NACK:", dl_block); |
| 1020 | f_shutdown(__BFILE__, __LINE__); |
| 1021 | break; |
| 1022 | } |
| 1023 | |
| 1024 | last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.egprs.ch_coding_cmd; |
| 1025 | break; |
| 1026 | } |
| 1027 | if (f_rlcmac_block_EgprsChCodingCommand2cs_mcs(last_ch_coding) != exp_ul_mcs) { |
| 1028 | setverdict(fail, "Channel Coding does not match our expectations ", exp_ul_mcs, ": ", last_ch_coding); |
| 1029 | f_shutdown(__BFILE__, __LINE__); |
| 1030 | } |
| 1031 | |
| 1032 | /* Remaining UL blocks are used to make sure regardless of initial |
| 1033 | * lqual, we can go lower at any time |
| 1034 | * 0 dB, make sure we downgrade MCS */ |
| 1035 | ms.lqual_cb := 0; |
| 1036 | /* 5 UL blocks, check we are in same initial MCS: */ |
| 1037 | f_ms_tx_ul_data_block_multi(ms, 5); |
| 1038 | /* Enqueue RTS.req, expect DATA.req with UL ACK from the PCU */ |
| 1039 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, unused_fn); |
| 1040 | last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.egprs.ch_coding_cmd; |
| 1041 | |
| 1042 | if (last_ch_coding != CH_CODING_MCS1) { |
| 1043 | setverdict(fail, "Channel Coding does not match our expectations (MCS-1): ", last_ch_coding); |
| 1044 | f_shutdown(__BFILE__, __LINE__); |
| 1045 | } |
| 1046 | |
| 1047 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 1048 | } |
| 1049 | |
Pau Espin Pedrol | db15fa7 | 2020-11-11 12:58:34 +0100 | [diff] [blame] | 1050 | /* Test the maximum UL MCS set by VTY works fine */ |
| 1051 | testcase TC_mcs_max_ul() runs on RAW_PCU_Test_CT { |
| 1052 | var RlcmacDlBlock dl_block; |
| 1053 | var EgprsChCodingCommand last_ch_coding; |
| 1054 | var PollFnCtx pollctx; |
| 1055 | var uint32_t unused_fn, sched_fn; |
| 1056 | var GprsMS ms; |
| 1057 | var MultislotCap_GPRS mscap_gprs := { |
| 1058 | gprsmultislotclass := '00011'B, |
| 1059 | gprsextendeddynalloccap := '0'B |
| 1060 | }; |
| 1061 | var MultislotCap_EGPRS mscap_egprs := { |
| 1062 | egprsmultislotclass := '00011'B, |
| 1063 | egprsextendeddynalloccap := '0'B |
| 1064 | }; |
| 1065 | var MSRadioAccessCapabilityV ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, mscap_egprs)) }; |
| 1066 | |
| 1067 | |
| 1068 | /* Initialize GPRS MS side */ |
| 1069 | f_init_gprs_ms(); |
| 1070 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 1071 | |
| 1072 | /* Initialize the PCU interface abstraction */ |
| 1073 | f_init_raw(testcasename()); |
| 1074 | |
| 1075 | /* Set maximum allowed UL MCS to 5 */ |
| 1076 | g_mcs_max_ul := 5; |
| 1077 | f_pcuvty_set_allowed_cs_mcs(); |
| 1078 | f_pcuvty_set_link_quality_ranges(); |
| 1079 | |
| 1080 | /* Send PACKET RESOURCE REQUEST to upgrade to EGPRS */ |
| 1081 | pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap)); |
| 1082 | /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 1083 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts); |
| 1084 | |
| 1085 | ms.lqual_cb := 40*10; /* 40 dB */ |
| 1086 | f_ms_tx_ul_data_block_multi(ms, 16); |
| 1087 | |
| 1088 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, unused_fn); |
| 1089 | last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.egprs.ch_coding_cmd; |
| 1090 | |
| 1091 | if (last_ch_coding != CH_CODING_MCS5) { |
| 1092 | setverdict(fail, "Channel Coding does not match our expectations (MCS-5): ", last_ch_coding); |
| 1093 | f_shutdown(__BFILE__, __LINE__); |
| 1094 | } |
| 1095 | |
| 1096 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 1097 | } |
| 1098 | |
Pau Espin Pedrol | e4fa45b | 2020-11-11 13:28:31 +0100 | [diff] [blame] | 1099 | /* Test the initial DL CS set by VTY works fine */ |
| 1100 | testcase TC_mcs_initial_dl() runs on RAW_PCU_Test_CT { |
| 1101 | var octetstring data := f_rnd_octstring(10); |
| 1102 | var CodingScheme exp_dl_cs_mcs; |
| 1103 | var RlcmacDlBlock dl_block; |
| 1104 | var uint32_t poll_fn; |
| 1105 | var GprsMS ms; |
| 1106 | var MultislotCap_GPRS_BSSGP mscap_gprs := { |
| 1107 | gprsmultislotclass := '00011'B, |
| 1108 | gprsextendeddynalloccap := '0'B |
| 1109 | }; |
| 1110 | var MultislotCap_EGPRS_BSSGP mscap_egprs := { |
| 1111 | egprsmultislotclass := '00011'B, |
| 1112 | egprsextendeddynalloccap := '0'B |
| 1113 | }; |
| 1114 | var MSRadioAccessCapabilityV_BSSGP ms_racap := { valueof(ts_RaCapRec_BSSGP('0001'B /* E-GSM */, mscap_gprs, mscap_egprs)) }; |
| 1115 | |
| 1116 | /* Initialize NS/BSSGP side */ |
| 1117 | f_init_bssgp(); |
| 1118 | /* Initialize GPRS MS side */ |
| 1119 | f_init_gprs_ms(); |
| 1120 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 1121 | |
| 1122 | /* Initialize the PCU interface abstraction */ |
| 1123 | f_init_raw(testcasename()); |
| 1124 | |
| 1125 | /* Set initial allowed DL MCS to 3 */ |
| 1126 | g_mcs_initial_dl := 3; |
| 1127 | exp_dl_cs_mcs := MCS_3; |
| 1128 | /* Set maximum allowed DL MCS to 4 */ |
| 1129 | g_mcs_max_dl := 4; |
| 1130 | f_pcuvty_set_allowed_cs_mcs(); |
| 1131 | f_pcuvty_set_link_quality_ranges(); |
| 1132 | |
| 1133 | /* Establish BSSGP connection to the PCU */ |
| 1134 | f_bssgp_establish(); |
| 1135 | f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli); |
| 1136 | |
| 1137 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
| 1138 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, ms_racap)); |
| 1139 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
| 1140 | |
| 1141 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 1142 | f_sleep(X2002); |
| 1143 | f_rx_rlcmac_dl_block_exp_data(dl_block, poll_fn, data, 0, exp_dl_cs_mcs); |
| 1144 | |
| 1145 | /* ACK the DL block */ |
Pau Espin Pedrol | e8db673 | 2020-11-12 21:06:41 +0100 | [diff] [blame] | 1146 | f_dltbf_ack_block(ms.dl_tbf, dl_block, '1'B); |
| 1147 | f_ms_tx_ul_block(ms, f_dltbf_ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf, ischosen(dl_block.data_egprs)), |
Pau Espin Pedrol | e4fa45b | 2020-11-11 13:28:31 +0100 | [diff] [blame] | 1148 | f_dl_block_ack_fn(dl_block, poll_fn)); |
| 1149 | |
| 1150 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 1151 | } |
| 1152 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1153 | /* Verify PCU drops TBF after some time of inactivity. */ |
| 1154 | testcase TC_t3169() runs on RAW_PCU_Test_CT { |
| 1155 | var PCUIF_info_ind info_ind; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1156 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1157 | var uint32_t unused_fn; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1158 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1159 | |
| 1160 | /* Initialize NS/BSSGP side */ |
| 1161 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1162 | /* Initialize GPRS MS side */ |
| 1163 | f_init_gprs_ms(); |
| 1164 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1165 | |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1166 | info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1167 | /* Set timer to 1 sec (default 5) to speedup test: */ |
| 1168 | info_ind.t3169 := 1; |
| 1169 | |
| 1170 | /* Initialize the PCU interface abstraction */ |
| 1171 | f_init_raw(testcasename(), info_ind); |
| 1172 | |
| 1173 | /* Establish BSSGP connection to the PCU */ |
| 1174 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1175 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1176 | |
| 1177 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1178 | f_ms_establish_ul_tbf(ms); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1179 | |
Pau Espin Pedrol | 4aac3d0 | 2020-05-13 15:13:49 +0200 | [diff] [blame] | 1180 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 1181 | contention resoultion) and make sure it is ACKED fine */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1182 | f_ms_tx_ul_data_block(ms, f_rnd_octstring(10), cv := 1, with_tlli := true) |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1183 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, unused_fn); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1184 | /* UL block should NOT be received in SGSN, since we didn't get CV=0 */ |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1185 | |
| 1186 | /* Wait until T3169 fires (plus 1 extra sec to make sure) */ |
| 1187 | f_sleep(int2float(info_ind.t3169) + 1.0); |
| 1188 | |
| 1189 | /* Send an UL block once again, the TBF should be gone by now so no ACK */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1190 | f_ms_tx_ul_data_block(ms, f_rnd_octstring(10), cv := 0) |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1191 | f_rx_rlcmac_dl_block_exp_dummy(dl_block); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 1192 | |
| 1193 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1194 | } |
| 1195 | |
| 1196 | /* Verify that a Downlink TBF can be assigned using PACCH shortly after the |
| 1197 | * release of prev DL TBF due to MS staying in PDCH for a while (T3192, in PCU |
| 1198 | * T3193) after DL TBF release */ |
| 1199 | testcase TC_t3193() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1200 | var RlcmacDlBlock dl_block; |
| 1201 | var octetstring data := f_rnd_octstring(10); |
| 1202 | var boolean ok; |
| 1203 | var uint32_t sched_fn; |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1204 | var uint32_t dl_fn; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1205 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1206 | var AckNackDescription ack_nack_desc := valueof(t_AckNackDescription_init); |
| 1207 | |
| 1208 | /* Initialize NS/BSSGP side */ |
| 1209 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1210 | /* Initialize GPRS MS side */ |
| 1211 | f_init_gprs_ms(); |
| 1212 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1213 | |
| 1214 | /* Initialize the PCU interface abstraction */ |
| 1215 | f_init_raw(testcasename()); |
| 1216 | |
| 1217 | /* Establish BSSGP connection to the PCU */ |
| 1218 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1219 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1220 | |
| 1221 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1222 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 1223 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
Vadim Yanitskiy | 2e213ae | 2020-05-06 22:26:17 +0700 | [diff] [blame] | 1224 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1225 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 1226 | f_sleep(X2002); |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1227 | f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1228 | |
| 1229 | /* ACK the DL block */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1230 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B); |
| 1231 | f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc), |
| 1232 | f_dl_block_ack_fn(dl_block, dl_fn)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1233 | |
| 1234 | /* Now that final DL block is ACKED and TBF is released, T3193 in PCU |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1235 | (T3192 in MS) was started and until it fires the MS will be available |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1236 | on PDCH in case new data arrives from SGSN. Let's verify it: */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1237 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
Vadim Yanitskiy | 7431e9e | 2020-07-21 01:59:17 +0700 | [diff] [blame] | 1238 | f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_DL_PACKET_ASS); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1239 | |
| 1240 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1241 | |
| 1242 | /* Now that we confirmed the new assignment in the dl-tbf, lets receive the data and ack it */ |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1243 | f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1244 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B); |
| 1245 | f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc), |
| 1246 | f_dl_block_ack_fn(dl_block, dl_fn)); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 1247 | |
| 1248 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1249 | } |
| 1250 | |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1251 | /* Verify PCU handles correctly Countdown Procedure based on BS_CV_MAX */ |
| 1252 | testcase TC_countdown_procedure() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1253 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1254 | var uint32_t sched_fn; |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1255 | var octetstring total_payload; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1256 | var GprsMS ms; |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1257 | |
| 1258 | /* Initialize NS/BSSGP side */ |
| 1259 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1260 | /* Initialize GPRS MS side */ |
| 1261 | f_init_gprs_ms(); |
| 1262 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1263 | |
| 1264 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1265 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1266 | |
| 1267 | /* Establish BSSGP connection to the PCU */ |
| 1268 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1269 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1270 | |
| 1271 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1272 | f_ms_establish_ul_tbf(ms); |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1273 | |
| 1274 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 1275 | contention resoultion) and make sure it is ACKED fine. */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1276 | total_payload := f_rnd_octstring(f_ultbf_payload_fill_length(ms.ul_tbf, true)); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1277 | /* Set CV = 15 to signal there's still more than BS_CV_MAX blocks to be sent */ |
| 1278 | f_ms_tx_ul_data_block(ms, total_payload, cv := 15, with_tlli := true) |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1279 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1280 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1281 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1282 | |
| 1283 | /* Send enough blocks to test whole procedure: Until Nth block |
| 1284 | (N=BS_CV_MAX), CV=15 is sent, and then the decreasing countdown value is sent. |
| 1285 | */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1286 | total_payload := total_payload & f_ms_tx_ul_data_block_multi(ms, 20); |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1287 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1288 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1289 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1290 | |
| 1291 | /* receive one message on BSSGP with all aggregated data in payload: */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1292 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, total_payload)); |
Vadim Yanitskiy | 8e6df0c | 2020-10-18 00:13:15 +0700 | [diff] [blame] | 1293 | |
| 1294 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1295 | } |
| 1296 | |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1297 | /* Verify PCU handles correctly CS1..4 with all possible LLC payload sizes fitting alone in one RLC block */ |
| 1298 | testcase TC_ul_all_sizes() runs on RAW_PCU_Test_CT { |
| 1299 | var RlcmacDlBlock dl_block; |
| 1300 | var uint32_t dl_fn, sched_fn; |
| 1301 | var octetstring payload; |
| 1302 | var template (value) RlcmacUlBlock ul_data; |
Vadim Yanitskiy | ceb1f98 | 2020-10-17 15:58:19 +0700 | [diff] [blame] | 1303 | var template (value) LlcBlockHdr blk_hdr; |
| 1304 | var template (value) LlcBlocks blocks; |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1305 | var integer blk_len; |
| 1306 | var CodingScheme tx_cs; |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1307 | var GprsMS ms; |
| 1308 | |
| 1309 | /* Initialize NS/BSSGP side */ |
| 1310 | f_init_bssgp(); |
| 1311 | /* Initialize GPRS MS side */ |
| 1312 | f_init_gprs_ms(); |
| 1313 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 1314 | |
| 1315 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1316 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1317 | |
| 1318 | /* Establish BSSGP connection to the PCU */ |
| 1319 | f_bssgp_establish(); |
| 1320 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 1321 | |
| 1322 | /* Establish an Uplink TBF */ |
| 1323 | f_ms_establish_ul_tbf(ms); |
| 1324 | |
| 1325 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 1326 | contention resoultion) and make sure it is ACKED fine. */ |
| 1327 | payload := f_rnd_octstring(16); /* 16 bytes fills the llc block (because TLLI takes 4 bytes) */ |
Vadim Yanitskiy | ceb1f98 | 2020-10-17 15:58:19 +0700 | [diff] [blame] | 1328 | blk_hdr := t_RLCMAC_LLCBLOCK_HDR(length_ind := lengthof(payload), |
| 1329 | more := false, e := true); |
| 1330 | blocks := { t_RLCMAC_LLCBLOCK(payload, blk_hdr) }; |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1331 | /* Set CV = 15 to signal there's still more than BS_CV_MAX blocks to be sent */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1332 | ul_data := t_RLCMAC_UL_DATA_TLLI(cs := ms.ul_tbf.tx_cs_mcs, |
| 1333 | tfi := ms.ul_tbf.tfi, |
Vadim Yanitskiy | ceb1f98 | 2020-10-17 15:58:19 +0700 | [diff] [blame] | 1334 | cv := 15, |
| 1335 | bsn := ms.ul_tbf.bsn, |
| 1336 | blocks := blocks, |
| 1337 | tlli := ms.tlli); |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1338 | f_ultbf_inc_bsn(ms.ul_tbf); |
| 1339 | f_ms_tx_ul_block(ms, ul_data); |
| 1340 | |
| 1341 | /* ACK and check it was received fine */ |
| 1342 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1343 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 1344 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
| 1345 | /* receive one message on BSSGP with all aggregated data in payload: */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1346 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, payload)); |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1347 | |
| 1348 | /* Test sending LLC PDUS of incrementing size */ |
| 1349 | var integer max_size := 49; |
| 1350 | for (var integer i := 1; i <= max_size; i := i + 1) { |
| 1351 | var integer cv; |
| 1352 | /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */ |
| 1353 | log("Sending DATA.ind with LLC payload size ", i); |
| 1354 | if (i < max_size - g_bs_cv_max) { |
| 1355 | cv := 15; |
| 1356 | } else { |
| 1357 | cv := max_size - i; |
| 1358 | } |
| 1359 | |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1360 | blk_len := 3 + 1 + i; /* 3 Header bytes + LI byte + payload length */ |
| 1361 | tx_cs := f_rlcmac_block_len_required_cs_mcs(blk_len, false); |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1362 | payload := f_rnd_octstring(i); |
Vadim Yanitskiy | ceb1f98 | 2020-10-17 15:58:19 +0700 | [diff] [blame] | 1363 | blk_hdr := t_RLCMAC_LLCBLOCK_HDR(length_ind := lengthof(payload), |
| 1364 | more := false, e := true); |
| 1365 | blocks := { t_RLCMAC_LLCBLOCK(payload, blk_hdr) }; |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1366 | /* Set CV = 15 to signal there's still more than BS_CV_MAX blocks to be sent */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1367 | ul_data := t_RLCMAC_UL_DATA(cs := tx_cs, |
| 1368 | tfi := ms.ul_tbf.tfi, |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1369 | cv := cv, |
| 1370 | bsn := ms.ul_tbf.bsn, |
Vadim Yanitskiy | ceb1f98 | 2020-10-17 15:58:19 +0700 | [diff] [blame] | 1371 | blocks := blocks); |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1372 | f_ultbf_inc_bsn(ms.ul_tbf); |
| 1373 | f_ms_tx_ul_block(ms, ul_data); |
| 1374 | |
| 1375 | /* receive one message on BSSGP with all aggregated data in payload: */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1376 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, payload)); |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1377 | |
| 1378 | /* we will receive UL ACK/NACK from time to time, handle it. */ |
| 1379 | f_rx_rlcmac_dl_block(dl_block, dl_fn); |
| 1380 | if (match(dl_block, tr_RLCMAC_DUMMY_CTRL())) { |
| 1381 | continue; |
| 1382 | } |
| 1383 | if (not match(dl_block, tr_RLCMAC_UL_ACK_NACK_GPRS(ul_tfi := ?)) and |
| 1384 | not match(dl_block, tr_RLCMAC_UL_ACK_NACK_EGPRS(ul_tfi := ?))) { |
| 1385 | setverdict(fail, "Failed to match Packet Uplink ACK / NACK:", dl_block); |
| 1386 | f_shutdown(__BFILE__, __LINE__); |
| 1387 | } |
| 1388 | |
| 1389 | log("Rx Packet Uplink ACK / NACK"); |
| 1390 | sched_fn := f_rrbp_ack_fn(dl_fn, dl_block.ctrl.mac_hdr.rrbp); |
| 1391 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 1392 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
| 1393 | } |
Vadim Yanitskiy | 8e6df0c | 2020-10-18 00:13:15 +0700 | [diff] [blame] | 1394 | |
| 1395 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1396 | } |
| 1397 | |
Pau Espin Pedrol | 5e6844d | 2020-07-01 17:24:02 +0200 | [diff] [blame] | 1398 | function f_TC_ul_data_toolong_fills_padding_cs(inout GprsMS ms, CodingScheme cs, integer cv) runs on RAW_PCU_Test_CT { |
| 1399 | var octetstring payload; |
| 1400 | var template (value) RlcmacUlBlock ul_data; |
Vadim Yanitskiy | ceb1f98 | 2020-10-17 15:58:19 +0700 | [diff] [blame] | 1401 | var template (value) LlcBlockHdr blk_hdr; |
| 1402 | var template (value) LlcBlocks blocks; |
Pau Espin Pedrol | 5e6844d | 2020-07-01 17:24:02 +0200 | [diff] [blame] | 1403 | var integer block_len, max_valid_data_len; |
| 1404 | timer T; |
| 1405 | |
| 1406 | block_len := f_rlcmac_cs_mcs2block_len(cs); |
| 1407 | /* We need to send with TLLI since we are in One-Phase Access Contenion |
| 1408 | * resoultion), so that's -4 bytes of data, -3 for headers, -1 for LI |
| 1409 | * indicator, -1 for spare bits octet at the end */ |
| 1410 | max_valid_data_len := block_len - 4 - 3 - 1 - 1; |
| 1411 | payload := f_rnd_octstring(max_valid_data_len + 1); /* +1 to write LLC data on last padding octet */ |
Vadim Yanitskiy | ceb1f98 | 2020-10-17 15:58:19 +0700 | [diff] [blame] | 1412 | blk_hdr := t_RLCMAC_LLCBLOCK_HDR(length_ind := lengthof(payload), |
| 1413 | more := false, e := true); |
| 1414 | blocks := { t_RLCMAC_LLCBLOCK(payload, blk_hdr) }; |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1415 | ul_data := t_RLCMAC_UL_DATA_TLLI(cs := cs, |
| 1416 | tfi := ms.ul_tbf.tfi, |
Vadim Yanitskiy | ceb1f98 | 2020-10-17 15:58:19 +0700 | [diff] [blame] | 1417 | cv := cv, |
| 1418 | bsn := ms.ul_tbf.bsn, |
| 1419 | blocks := blocks, |
| 1420 | tlli := ms.tlli); |
Pau Espin Pedrol | 5e6844d | 2020-07-01 17:24:02 +0200 | [diff] [blame] | 1421 | f_ultbf_inc_bsn(ms.ul_tbf); |
| 1422 | f_ms_tx_data_ind(ms, enc_RlcmacUlBlock(valueof(ul_data))); |
| 1423 | |
| 1424 | T.start(0.5); |
| 1425 | alt { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1426 | [] BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, ?)) { |
Pau Espin Pedrol | 5e6844d | 2020-07-01 17:24:02 +0200 | [diff] [blame] | 1427 | setverdict(fail, "LLC PDU in Malformed RLC block was forwarded"); |
| 1428 | f_shutdown(__BFILE__, __LINE__); |
| 1429 | } |
| 1430 | [] T.timeout { |
| 1431 | setverdict(pass); |
| 1432 | } |
| 1433 | } |
| 1434 | } |
| 1435 | /* Verify PCU finds out incorrectly formated RLC block and discards it. This |
| 1436 | blocks intentionally contain last byte of data placed in last byte of RLC |
| 1437 | containing padding/spare bits, which is incorrect. Spare bits exist and are |
| 1438 | described for CS2..4 in 3GPP TS 44.060 Table 10.2.1: "RLC data block size, |
| 1439 | discounting padding in octet" */ |
| 1440 | testcase TC_ul_data_toolong_fills_padding() runs on RAW_PCU_Test_CT { |
| 1441 | var GprsMS ms; |
| 1442 | var integer block_len, max_valid_data_len; |
| 1443 | |
| 1444 | /* Initialize NS/BSSGP side */ |
| 1445 | f_init_bssgp(); |
| 1446 | /* Initialize GPRS MS side */ |
| 1447 | f_init_gprs_ms(); |
| 1448 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 1449 | |
| 1450 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1451 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | 5e6844d | 2020-07-01 17:24:02 +0200 | [diff] [blame] | 1452 | |
| 1453 | /* Establish BSSGP connection to the PCU */ |
| 1454 | f_bssgp_establish(); |
| 1455 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 1456 | |
| 1457 | /* Establish an Uplink TBF */ |
| 1458 | f_ms_establish_ul_tbf(ms); |
| 1459 | |
| 1460 | f_TC_ul_data_toolong_fills_padding_cs(ms, CS_2, 2); |
| 1461 | f_TC_ul_data_toolong_fills_padding_cs(ms, CS_3, 1); |
| 1462 | f_TC_ul_data_toolong_fills_padding_cs(ms, CS_4, 0); |
| 1463 | |
Vadim Yanitskiy | 8e6df0c | 2020-10-18 00:13:15 +0700 | [diff] [blame] | 1464 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 5e6844d | 2020-07-01 17:24:02 +0200 | [diff] [blame] | 1465 | } |
| 1466 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1467 | /* Test scenario where MS wants to send some data on PDCH against SGSN and it is |
| 1468 | * answered, so TBFs for uplink and later for downlink are created. |
| 1469 | */ |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1470 | private function f_TC_mo_ping_pong_1phase_access(template (present) CodingScheme exp_cs_mcs := ?) runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1471 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1472 | var octetstring data := f_rnd_octstring(10); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1473 | var uint32_t sched_fn; |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1474 | var uint32_t dl_fn; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1475 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1476 | |
| 1477 | /* Initialize NS/BSSGP side */ |
| 1478 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1479 | /* Initialize GPRS MS side */ |
| 1480 | f_init_gprs_ms(); |
| 1481 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1482 | |
| 1483 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1484 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1485 | |
| 1486 | /* Establish BSSGP connection to the PCU */ |
| 1487 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1488 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1489 | |
| 1490 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1491 | f_ms_establish_ul_tbf(ms); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1492 | |
Pau Espin Pedrol | 4aac3d0 | 2020-05-13 15:13:49 +0200 | [diff] [blame] | 1493 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 1494 | contention resoultion) and make sure it is ACKED fine */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1495 | f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1496 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1497 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1498 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1499 | |
| 1500 | /* UL block should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1501 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1502 | |
| 1503 | /* Now SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1504 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 1505 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1506 | |
| 1507 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 1508 | f_sleep(X2002); |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1509 | f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0, exp_cs_mcs); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1510 | |
| 1511 | /* ACK the DL block */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1512 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B); |
| 1513 | f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc), |
| 1514 | f_dl_block_ack_fn(dl_block, dl_fn)); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 1515 | |
| 1516 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1517 | } |
| 1518 | |
| 1519 | /* Test scenario where MS wants to send some data on PDCH against SGSN and it is |
| 1520 | * answered, so TBFs for uplink and later for downlink are created. |
| 1521 | */ |
| 1522 | testcase TC_mo_ping_pong() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 4fbeefd | 2020-11-05 13:47:24 +0100 | [diff] [blame] | 1523 | var template CodingScheme exp_cs_mcs := cs_gprs_any; |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1524 | f_TC_mo_ping_pong_1phase_access(exp_cs_mcs); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1525 | } |
| 1526 | |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1527 | /* Test scenario where MS wants to send some data on PDCH against SGSN and it is |
| 1528 | * answered, so TBFs for uplink and later for downlink are created. |
| 1529 | */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1530 | private function f_TC_mo_ping_pong_2phase_access(PCUIF_Flags ind_flags, |
| 1531 | template (value) MSRadioAccessCapabilityV ms_racap, |
Pau Espin Pedrol | 42acafc | 2020-05-14 15:18:38 +0200 | [diff] [blame] | 1532 | template (present) CodingScheme exp_ul_cs_mcs := ?, |
| 1533 | template (present) CodingScheme exp_dl_cs_mcs := ?) |
| 1534 | runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1535 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1536 | var octetstring data := f_rnd_octstring(10); |
Pau Espin Pedrol | 8155bf4 | 2020-10-29 17:34:26 +0100 | [diff] [blame] | 1537 | var PollFnCtx pollctx; |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1538 | var uint32_t sched_fn; |
| 1539 | var uint32_t dl_fn; |
Pau Espin Pedrol | adbbe1e | 2020-05-17 00:28:01 +0200 | [diff] [blame] | 1540 | var uint32_t unused_fn; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1541 | var GprsMS ms; |
| 1542 | |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1543 | /* Initialize NS/BSSGP side */ |
| 1544 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1545 | /* Initialize GPRS MS side */ |
| 1546 | f_init_gprs_ms(); |
| 1547 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1548 | |
| 1549 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1550 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(ind_flags)); |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1551 | |
| 1552 | /* Establish BSSGP connection to the PCU */ |
| 1553 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1554 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1555 | |
Pau Espin Pedrol | 8155bf4 | 2020-10-29 17:34:26 +0100 | [diff] [blame] | 1556 | /* Send PACKET RESOURCE REQUEST to upgrade to EGPRS */ |
| 1557 | pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap)); |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1558 | |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1559 | if (not match(ms.ul_tbf.tx_cs_mcs, exp_ul_cs_mcs)) { |
| 1560 | setverdict(fail, "Wrong CS_MCS ", ms.ul_tbf.tx_cs_mcs, " received vs exp ", exp_ul_cs_mcs); |
Pau Espin Pedrol | 42acafc | 2020-05-14 15:18:38 +0200 | [diff] [blame] | 1561 | f_shutdown(__BFILE__, __LINE__); |
| 1562 | } |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1563 | |
| 1564 | /* Send one UL block (without TLLI since we are in Second-Phase Access) |
| 1565 | and make sure it is ACKED fine */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1566 | f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true); |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1567 | |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1568 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 8155bf4 | 2020-10-29 17:34:26 +0100 | [diff] [blame] | 1569 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts); |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1570 | |
| 1571 | /* UL block should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1572 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id)); |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1573 | |
| 1574 | /* Now SGSN sends some DL data, PCU will page on PACCH */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1575 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
Vadim Yanitskiy | 7431e9e | 2020-07-21 01:59:17 +0700 | [diff] [blame] | 1576 | f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_DL_PACKET_ASS); |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1577 | /* DL Ass sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1578 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1579 | |
Pau Espin Pedrol | adbbe1e | 2020-05-17 00:28:01 +0200 | [diff] [blame] | 1580 | /* PCU acks the UL data after having received CV=0) */ |
| 1581 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, unused_fn); |
| 1582 | |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1583 | /* After acking the dl assignment, dl tbf goes into FLOW state and PCU will provide DL data when BTS asks for it */ |
Pau Espin Pedrol | 42acafc | 2020-05-14 15:18:38 +0200 | [diff] [blame] | 1584 | f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0, exp_dl_cs_mcs); |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1585 | |
| 1586 | /* ACK the DL block */ |
Pau Espin Pedrol | e8db673 | 2020-11-12 21:06:41 +0100 | [diff] [blame] | 1587 | f_dltbf_ack_block(ms.dl_tbf, dl_block, '1'B); |
| 1588 | f_ms_tx_ul_block(ms, f_dltbf_ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf, ischosen(dl_block.data_egprs)), |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1589 | f_dl_block_ack_fn(dl_block, dl_fn)); |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1590 | |
| 1591 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 1592 | } |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1593 | |
| 1594 | testcase TC_mo_ping_pong_with_ul_racap() runs on RAW_PCU_Test_CT { |
| 1595 | var MultislotCap_GPRS mscap_gprs := { |
| 1596 | gprsmultislotclass := '00011'B, |
| 1597 | gprsextendeddynalloccap := '0'B |
| 1598 | }; |
| 1599 | var MSRadioAccessCapabilityV ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, omit)) }; |
Pau Espin Pedrol | 4fbeefd | 2020-11-05 13:47:24 +0100 | [diff] [blame] | 1600 | var template CodingScheme exp_ul_cs_mcs := cs_gprs_any; |
| 1601 | var template CodingScheme exp_dl_cs_mcs := cs_gprs_any; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1602 | |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1603 | f_TC_mo_ping_pong_2phase_access(c_PCUIF_Flags_noMCS, ms_racap, exp_ul_cs_mcs, exp_dl_cs_mcs); |
Pau Espin Pedrol | 42acafc | 2020-05-14 15:18:38 +0200 | [diff] [blame] | 1604 | } |
| 1605 | |
| 1606 | testcase TC_mo_ping_pong_with_ul_racap_egprs_only() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 42acafc | 2020-05-14 15:18:38 +0200 | [diff] [blame] | 1607 | var MultislotCap_GPRS mscap_gprs := { |
| 1608 | gprsmultislotclass := '00011'B, |
| 1609 | gprsextendeddynalloccap := '0'B |
| 1610 | }; |
| 1611 | var MultislotCap_EGPRS mscap_egprs := { |
| 1612 | egprsmultislotclass := '00011'B, |
| 1613 | egprsextendeddynalloccap := '0'B |
| 1614 | }; |
| 1615 | var MSRadioAccessCapabilityV ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, mscap_egprs)) }; |
Pau Espin Pedrol | 4fbeefd | 2020-11-05 13:47:24 +0100 | [diff] [blame] | 1616 | var template CodingScheme exp_ul_cs_mcs := mcs_egprs_any; |
| 1617 | var template CodingScheme exp_dl_cs_mcs := mcs_egprs_any; |
Pau Espin Pedrol | 42acafc | 2020-05-14 15:18:38 +0200 | [diff] [blame] | 1618 | |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1619 | f_TC_mo_ping_pong_2phase_access(c_PCUIF_Flags_default, ms_racap, exp_ul_cs_mcs, exp_dl_cs_mcs); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1620 | } |
| 1621 | |
Pau Espin Pedrol | 0c0bf87 | 2020-05-14 15:50:49 +0200 | [diff] [blame] | 1622 | testcase TC_force_two_phase_access() runs on RAW_PCU_Test_CT { |
| 1623 | /* Configure PCU to force two phase access */ |
| 1624 | g_force_two_phase_access := true; |
| 1625 | |
| 1626 | var MultislotCap_GPRS mscap_gprs := { |
| 1627 | gprsmultislotclass := '00011'B, |
| 1628 | gprsextendeddynalloccap := '0'B |
| 1629 | }; |
| 1630 | var MSRadioAccessCapabilityV ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, omit)) }; |
| 1631 | var CodingScheme exp_ul_cs_mcs := f_rlcmac_block_int2cs_mcs(g_mcs_initial_ul, false); |
Pau Espin Pedrol | 4fbeefd | 2020-11-05 13:47:24 +0100 | [diff] [blame] | 1632 | var template CodingScheme exp_dl_cs_mcs := cs_gprs_any; |
Pau Espin Pedrol | 0c0bf87 | 2020-05-14 15:50:49 +0200 | [diff] [blame] | 1633 | |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1634 | f_TC_mo_ping_pong_2phase_access(c_PCUIF_Flags_noMCS, ms_racap, exp_ul_cs_mcs, exp_dl_cs_mcs); |
Pau Espin Pedrol | 0c0bf87 | 2020-05-14 15:50:49 +0200 | [diff] [blame] | 1635 | } |
| 1636 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1637 | /* Test scenario where SGSN wants to send some data against MS and it is |
| 1638 | * answered by the MS on PDCH, so TBFs for downlink and later for uplink are created. |
| 1639 | */ |
Vadim Yanitskiy | c67240a | 2020-10-17 15:59:37 +0700 | [diff] [blame] | 1640 | private function f_TC_mt_ping_pong(template (omit) MSRadioAccessCapabilityV_BSSGP ms_racap := omit, |
| 1641 | template (present) CodingScheme exp_cs_mcs := ?) |
| 1642 | runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1643 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1644 | var octetstring data := f_rnd_octstring(10); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1645 | var uint32_t sched_fn; |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1646 | var uint32_t dl_fn; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1647 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1648 | |
| 1649 | /* Initialize NS/BSSGP side */ |
| 1650 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1651 | /* Initialize GPRS MS side */ |
| 1652 | f_init_gprs_ms(); |
| 1653 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1654 | |
| 1655 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1656 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1657 | |
| 1658 | /* Establish BSSGP connection to the PCU */ |
| 1659 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1660 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1661 | |
| 1662 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1663 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, ms_racap)); |
| 1664 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1665 | |
| 1666 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 1667 | f_sleep(X2002); |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1668 | f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0, exp_cs_mcs); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1669 | |
Pau Espin Pedrol | 6791eb6 | 2020-05-20 18:27:10 +0200 | [diff] [blame] | 1670 | /* ACK the DL block, and request UL TBF at the same time */ |
Pau Espin Pedrol | e8db673 | 2020-11-12 21:06:41 +0100 | [diff] [blame] | 1671 | f_dltbf_ack_block(ms.dl_tbf, dl_block, '1'B); |
| 1672 | f_ms_tx_ul_block(ms, f_dltbf_ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf, ischosen(dl_block.data_egprs), c_ChReqDesc_default), |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1673 | f_dl_block_ack_fn(dl_block, dl_fn)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1674 | |
Pau Espin Pedrol | 6791eb6 | 2020-05-20 18:27:10 +0200 | [diff] [blame] | 1675 | /* Expect UL ass */ |
Vadim Yanitskiy | 7431e9e | 2020-07-21 01:59:17 +0700 | [diff] [blame] | 1676 | f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_UL_PACKET_ASS); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1677 | |
Pau Espin Pedrol | 4aac3d0 | 2020-05-13 15:13:49 +0200 | [diff] [blame] | 1678 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 1679 | contention resoultion) and make sure it is ACKED fine */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1680 | f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1681 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1682 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1683 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1684 | |
| 1685 | /* UL block should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1686 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id)); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 1687 | |
| 1688 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1689 | } |
| 1690 | |
| 1691 | testcase TC_mt_ping_pong() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 4fbeefd | 2020-11-05 13:47:24 +0100 | [diff] [blame] | 1692 | var template CodingScheme exp_cs_mcs := cs_gprs_any; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1693 | f_TC_mt_ping_pong(omit, exp_cs_mcs); |
| 1694 | } |
| 1695 | |
| 1696 | /* TC_mt_ping_pong, but DL-UNITDATA contains RA Access capability with (M)CS |
| 1697 | /* information about the MS */ |
| 1698 | testcase TC_mt_ping_pong_with_dl_racap() runs on RAW_PCU_Test_CT { |
| 1699 | var MultislotCap_GPRS_BSSGP mscap_gprs := { |
| 1700 | gprsmultislotclass := '00011'B, |
| 1701 | gprsextendeddynalloccap := '0'B |
| 1702 | } ; |
| 1703 | var MSRadioAccessCapabilityV_BSSGP ms_racap := { valueof(ts_RaCapRec_BSSGP('0001'B /* E-GSM */, mscap_gprs, omit)) }; |
Pau Espin Pedrol | 4fbeefd | 2020-11-05 13:47:24 +0100 | [diff] [blame] | 1704 | var template CodingScheme exp_cs_mcs := cs_gprs_any; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1705 | f_TC_mt_ping_pong(ms_racap, exp_cs_mcs); |
| 1706 | } |
| 1707 | |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1708 | /* Verify that if PCU doesn't get one of the intermediate UL data blocks in a UL |
| 1709 | * TBF, it will request retransmission through UL ACK/NACK (with missing block |
| 1710 | * in its bitmap) when CV=0 is received (and hence it knows no more data is to |
| 1711 | * be transferred). |
| 1712 | */ |
| 1713 | testcase TC_ul_intermediate_retrans() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1714 | var RlcmacDlBlock dl_block; |
| 1715 | var template (value) RlcmacUlBlock ul_data; |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1716 | var uint32_t sched_fn; |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1717 | var octetstring total_payload; |
| 1718 | var octetstring payload; |
| 1719 | var octetstring lost_payload; |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1720 | var uint5_t tfi; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1721 | var GprsMS ms; |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1722 | var uint32_t payload_fill_len; |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1723 | |
| 1724 | /* Initialize NS/BSSGP side */ |
| 1725 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1726 | /* Initialize GPRS MS side */ |
| 1727 | f_init_gprs_ms(); |
| 1728 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1729 | |
| 1730 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1731 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1732 | |
| 1733 | /* Establish BSSGP connection to the PCU */ |
| 1734 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1735 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1736 | |
| 1737 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1738 | f_ms_establish_ul_tbf(ms); |
| 1739 | tfi := ms.ul_tbf.tfi; |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1740 | |
| 1741 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 1742 | contention resoultion) and make sure it is ACKED fine. */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1743 | payload := f_rnd_octstring(f_ultbf_payload_fill_length(ms.ul_tbf, true)); /* 16 bytes fills the llc block (because TLLI takes 4 bytes) */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1744 | f_ms_tx_ul_data_block(ms, payload, cv := 15, with_tlli := true); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1745 | |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1746 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1747 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1748 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1749 | total_payload := payload; |
| 1750 | |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1751 | payload_fill_len := f_ultbf_payload_fill_length(ms.ul_tbf); |
| 1752 | |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1753 | /* Send 2 packets, skip 1 (inc bsn) and send another one */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1754 | payload := f_rnd_octstring(payload_fill_len); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1755 | f_ms_tx_ul_data_block(ms, payload, cv := 15); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1756 | total_payload := total_payload & payload; |
| 1757 | |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1758 | payload := f_rnd_octstring(payload_fill_len); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1759 | f_ms_tx_ul_data_block(ms, payload, cv := 15); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1760 | total_payload := total_payload & payload; |
| 1761 | |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1762 | lost_payload := f_rnd_octstring(payload_fill_len); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1763 | ms.ul_tbf.bsn := ms.ul_tbf.bsn + 1; /* LOST PAYLOAD bsn=3, will be retransmitted, next bsn is increased +2 */ |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1764 | total_payload := total_payload & lost_payload; |
| 1765 | |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1766 | payload := f_rnd_octstring(payload_fill_len) |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1767 | f_ms_tx_ul_data_block(ms, payload, cv := 15); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1768 | total_payload := total_payload & payload; |
| 1769 | |
| 1770 | /* Send enough blocks to finish the transmission (since we were sending BSN=15, send BS_CV_MAX packets) */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1771 | total_payload := total_payload & f_ms_tx_ul_data_block_multi(ms, g_bs_cv_max); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1772 | |
| 1773 | /* On CV=0, we'll receive a UL ACK asking about missing block */ |
| 1774 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1775 | /* TODO: check ack ack bitmap (URBB) */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1776 | ul_data := t_RLCMAC_UL_DATA(cs := ms.ul_tbf.tx_cs_mcs, |
| 1777 | tfi := tfi, |
| 1778 | cv := 15, |
| 1779 | bsn := 3, |
| 1780 | blocks := {t_RLCMAC_LLCBLOCK(lost_payload)}); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1781 | f_ms_tx_ul_block(ms, ul_data); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1782 | |
| 1783 | /* Now final ack is recieved */ |
| 1784 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1785 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1786 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1787 | |
| 1788 | /* receive one message on BSSGP with all aggregated data in payload: */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1789 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, total_payload)); |
Vadim Yanitskiy | 8e6df0c | 2020-10-18 00:13:15 +0700 | [diff] [blame] | 1790 | |
| 1791 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1792 | } |
| 1793 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1794 | /* Verify that if PCU doesn't get an ACK for first DL block after IMM ASS, it |
| 1795 | * will retry by retransmitting both the IMM ASS + DL block after poll (ack) |
| 1796 | * timeout occurs (specified by sent RRBP on DL block). */ |
| 1797 | testcase TC_imm_ass_dl_block_retrans() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1798 | var RlcmacDlBlock dl_block; |
| 1799 | var octetstring data := f_rnd_octstring(10); |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1800 | var uint32_t dl_fn; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1801 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1802 | |
| 1803 | /* Initialize NS/BSSGP side */ |
| 1804 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1805 | /* Initialize GPRS MS side */ |
| 1806 | f_init_gprs_ms(); |
| 1807 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1808 | |
| 1809 | /* Initialize the PCU interface abstraction */ |
| 1810 | f_init_raw(testcasename()); |
| 1811 | |
| 1812 | /* Establish BSSGP connection to the PCU */ |
| 1813 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1814 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1815 | |
| 1816 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1817 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 1818 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1819 | |
| 1820 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 1821 | f_sleep(X2002); |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1822 | f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1823 | |
| 1824 | /* Now we don't ack the dl block (emulate MS failed receiveing IMM ASS |
| 1825 | * or GPRS DL, or DL ACK was lost for some reason). As a result, PCU |
| 1826 | * should retrigger IMM ASS + GPRS DL procedure after poll timeout. */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1827 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
Vadim Yanitskiy | 2e213ae | 2020-05-06 22:26:17 +0700 | [diff] [blame] | 1828 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1829 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 1830 | f_sleep(X2002); |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1831 | f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1832 | |
| 1833 | /* ACK the DL block */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1834 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B); |
| 1835 | f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc), |
| 1836 | f_dl_block_ack_fn(dl_block, dl_fn)); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 1837 | |
| 1838 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1839 | } |
| 1840 | |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1841 | /* Verify scheduling of multiple Downlink data blocks during one RRBP. */ |
| 1842 | testcase TC_dl_flow_more_blocks() runs on RAW_PCU_Test_CT { |
| 1843 | var AckNackDescription ack_nack_desc := valueof(t_AckNackDescription_init); |
| 1844 | var octetstring data := f_rnd_octstring(16); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1845 | var PacketDlAssign dl_tbf_ass; |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1846 | var RlcmacDlBlock dl_block; |
| 1847 | var uint32_t ack_fn; |
| 1848 | var uint32_t fn; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1849 | var GprsMS ms; |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1850 | timer T := 5.0; |
| 1851 | |
| 1852 | /* Initialize NS/BSSGP side */ |
| 1853 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1854 | /* Initialize GPRS MS side */ |
| 1855 | f_init_gprs_ms(); |
| 1856 | ms := g_ms[0]; /* We only use first MS in this test */ |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1857 | |
| 1858 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1859 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1860 | |
Daniel Willmann | 535aea6 | 2020-09-21 13:27:08 +0200 | [diff] [blame] | 1861 | f_statsd_reset(); |
| 1862 | |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1863 | /* Establish BSSGP connection to the PCU */ |
| 1864 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1865 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1866 | |
| 1867 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1868 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 1869 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1870 | |
| 1871 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS */ |
| 1872 | f_sleep(X2002); |
| 1873 | |
| 1874 | /* Expect the first (GPRS DL) block with bsn=0 and rrbp_valid=1 */ |
| 1875 | f_rx_rlcmac_dl_block_exp_data(dl_block, fn, data, 0); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1876 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1877 | |
| 1878 | /* TDMA frame number on which we are supposed to send the ACK */ |
| 1879 | ack_fn := f_dl_block_ack_fn(dl_block, fn); |
| 1880 | |
| 1881 | /* SGSN sends more blocks during the indicated RRBP */ |
| 1882 | for (var integer bsn := 1; bsn < 63; bsn := bsn + 1) { |
| 1883 | data := f_rnd_octstring(16); /* Random LLC data */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1884 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1885 | |
| 1886 | f_rx_rlcmac_dl_block_exp_data(dl_block, fn, data, bsn); |
| 1887 | |
| 1888 | /* Make sure this block has the same TFI as was assigned |
| 1889 | * FIXME: this is only valid for GPRS, not EGPRS. */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1890 | if (dl_block.data.mac_hdr.hdr_ext.tfi != ms.dl_tbf.tfi) { |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1891 | setverdict(fail, "Rx DL data block with unexpected TFI: ", |
| 1892 | dl_block.data.mac_hdr.hdr_ext.tfi); |
| 1893 | f_shutdown(__BFILE__, __LINE__); |
| 1894 | } |
| 1895 | |
| 1896 | /* Keep Ack/Nack description updated */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1897 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1898 | |
| 1899 | /* Break if this is the end of RRBP */ |
| 1900 | if (fn == ack_fn) { |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1901 | ms.dl_tbf.acknack_desc.final_ack := '1'B; |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1902 | break; |
| 1903 | } |
| 1904 | } |
| 1905 | |
| 1906 | /* This is the end of RRBP, send Packet Downlink Ack/Nack */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1907 | f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc), fn := fn); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1908 | |
| 1909 | /* Make sure that the next block (after the Ack) is dummy */ |
| 1910 | f_rx_rlcmac_dl_block_exp_dummy(dl_block); |
| 1911 | |
Daniel Willmann | 535aea6 | 2020-09-21 13:27:08 +0200 | [diff] [blame] | 1912 | var StatsDExpects expect := { |
| 1913 | { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := 0, max := 0}, |
| 1914 | { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 1, max := 1}, |
| 1915 | { name := "TTCN3.bts.0.immediate.assignment_UL", mtype := "c", min := 0, max := 0}, |
| 1916 | { name := "TTCN3.bts.0.tbf.dl.alloc", mtype := "c", min := 1, max := 1}, |
| 1917 | { name := "TTCN3.bts.0.tbf.ul.alloc", mtype := "c", min := 0, max := 0}, |
| 1918 | { name := "TTCN3.bts.0.rlc.dl_payload_bytes", mtype := "c", min := 112, max := 112}, |
| 1919 | { name := "TTCN3.bts.0.rlc.ul_payload_bytes", mtype := "c", min := 0, max := 0} |
| 1920 | }; |
| 1921 | f_statsd_expect(expect); |
| 1922 | |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1923 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 1924 | } |
| 1925 | |
Pau Espin Pedrol | 05b6c17 | 2020-06-26 17:28:23 +0200 | [diff] [blame] | 1926 | /* Verify Decoding and segmentation of UL LLC PDUs into RLC data blocks, OS#4559. |
| 1927 | * Check "GPRS from A-Z" slide "Example of LI-Field and E-Bit" page 186. |
| 1928 | * Check "3GPP TS 44.060" Annex B. */ |
| 1929 | testcase TC_ul_flow_multiple_llc_blocks() runs on RAW_PCU_Test_CT { |
| 1930 | var RlcmacDlBlock dl_block; |
| 1931 | var octetstring dataA := f_rnd_octstring(20); |
| 1932 | var octetstring dataB := f_rnd_octstring(13); |
| 1933 | var octetstring dataC := f_rnd_octstring(3); |
| 1934 | var octetstring dataD := f_rnd_octstring(12); |
| 1935 | var uint32_t sched_fn; |
| 1936 | var GprsMS ms; |
| 1937 | var template (value) RlcmacUlBlock ul_data; |
| 1938 | |
| 1939 | /* Initialize NS/BSSGP side */ |
| 1940 | f_init_bssgp(); |
| 1941 | /* Initialize GPRS MS side */ |
| 1942 | f_init_gprs_ms(); |
| 1943 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 1944 | |
| 1945 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1946 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | 05b6c17 | 2020-06-26 17:28:23 +0200 | [diff] [blame] | 1947 | |
| 1948 | /* Establish BSSGP connection to the PCU */ |
| 1949 | f_bssgp_establish(); |
| 1950 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 1951 | |
| 1952 | /* Establish an Uplink TBF */ |
| 1953 | f_ms_establish_ul_tbf(ms); |
| 1954 | |
| 1955 | /* Summary of what's transmitted: |
| 1956 | * 1- UL RlcDataBlock(dataA) [BSN=0, CV=3] |
| 1957 | * 2- UL RlcDataBlock(dataA finished, dataB starts) [BSN=1, CV=2] |
| 1958 | * 3- UL RlcDataBlock(dataB finished, dataC starts and finishes, dataD starts) [BSN=2, CV=1] |
| 1959 | * 4- UL RlcDataBlock(dataD finishes) [BSN=3, CV=0] |
| 1960 | * And on SGSN we receive 4 packets, one for each LlcBlock dataA..D. |
| 1961 | * We'll also receive some UL ACK/NACK we need to reply with CTRL ACK. |
| 1962 | */ |
| 1963 | |
| 1964 | /* UL RlcDataBlock(dataA) [BSN=0, CV=3] */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1965 | ul_data := t_RLCMAC_UL_DATA_TLLI(cs := CS_1, |
| 1966 | tfi := ms.ul_tbf.tfi, |
Pau Espin Pedrol | 05b6c17 | 2020-06-26 17:28:23 +0200 | [diff] [blame] | 1967 | cv := 3, |
| 1968 | bsn := ms.ul_tbf.bsn, |
| 1969 | blocks := { t_RLCMAC_LLCBLOCK(substr(dataA, 0, 16)) }, |
| 1970 | tlli := ms.tlli); |
| 1971 | /* Indicate no llc header, meaning first LLC block doesn't finish in current |
| 1972 | * RLCMAC block being sent. */ |
| 1973 | ul_data.data.mac_hdr.e := true; |
| 1974 | f_ultbf_inc_bsn(ms.ul_tbf); |
| 1975 | f_ms_tx_ul_block(ms, ul_data); |
| 1976 | |
| 1977 | /* UL RlcDataBlock(dataA finished, dataB starts) [BSN=1, CV=2] */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1978 | ul_data := t_RLCMAC_UL_DATA_TLLI(cs := CS_1, |
| 1979 | tfi := ms.ul_tbf.tfi, |
Pau Espin Pedrol | 05b6c17 | 2020-06-26 17:28:23 +0200 | [diff] [blame] | 1980 | cv := 2, |
| 1981 | bsn := ms.ul_tbf.bsn, |
| 1982 | blocks := { t_RLCMAC_LLCBLOCK(substr(dataA, 16, 4), |
| 1983 | t_RLCMAC_LLCBLOCK_HDR(length_ind := 4, more := true, e := true)), |
| 1984 | t_RLCMAC_LLCBLOCK(substr(dataB, 0, 11)) |
| 1985 | }, |
| 1986 | tlli := ms.tlli); |
| 1987 | f_ultbf_inc_bsn(ms.ul_tbf); |
| 1988 | f_ms_tx_ul_block(ms, ul_data); |
| 1989 | |
| 1990 | /* UL block dataA should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1991 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, dataA)); |
Pau Espin Pedrol | 05b6c17 | 2020-06-26 17:28:23 +0200 | [diff] [blame] | 1992 | |
| 1993 | /* UL RlcDataBlock(dataB finished, dataC starts and finishes, dataD starts) [BSN=2, CV=1] */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1994 | ul_data := t_RLCMAC_UL_DATA_TLLI(cs := CS_1, |
| 1995 | tfi := ms.ul_tbf.tfi, |
Pau Espin Pedrol | 05b6c17 | 2020-06-26 17:28:23 +0200 | [diff] [blame] | 1996 | cv := 1, |
| 1997 | bsn := ms.ul_tbf.bsn, |
| 1998 | blocks := { t_RLCMAC_LLCBLOCK(substr(dataB, 11, 2), |
| 1999 | t_RLCMAC_LLCBLOCK_HDR(length_ind := 2, more := true, e := false)), |
| 2000 | t_RLCMAC_LLCBLOCK(substr(dataC, 0, 3), |
| 2001 | t_RLCMAC_LLCBLOCK_HDR(length_ind := 3, more := true, e := true)), |
| 2002 | t_RLCMAC_LLCBLOCK(substr(dataD, 0, 9)) |
| 2003 | }, |
| 2004 | tlli := ms.tlli); |
| 2005 | f_ultbf_inc_bsn(ms.ul_tbf); |
| 2006 | f_ms_tx_ul_block(ms, ul_data); |
| 2007 | |
| 2008 | /* UL block dataB and dataC should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 2009 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, dataB)); |
| 2010 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, dataC)); |
Pau Espin Pedrol | 05b6c17 | 2020-06-26 17:28:23 +0200 | [diff] [blame] | 2011 | |
| 2012 | /* UL RlcDataBlock(dataD finishes) [BSN=3, CV=0] */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 2013 | ul_data := t_RLCMAC_UL_DATA_TLLI( |
| 2014 | cs := CS_1, |
| 2015 | tfi := ms.ul_tbf.tfi, |
Pau Espin Pedrol | 05b6c17 | 2020-06-26 17:28:23 +0200 | [diff] [blame] | 2016 | cv := 0, |
| 2017 | bsn := ms.ul_tbf.bsn, |
| 2018 | blocks := { t_RLCMAC_LLCBLOCK(substr(dataD, 9, 3), |
| 2019 | t_RLCMAC_LLCBLOCK_HDR(length_ind := 3, more := false, e := true)) |
| 2020 | }, |
| 2021 | tlli := ms.tlli); |
| 2022 | f_ultbf_inc_bsn(ms.ul_tbf); |
| 2023 | f_ms_tx_ul_block(ms, ul_data); |
| 2024 | |
| 2025 | /* UL block dataB and dataD should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 2026 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, dataD)); |
Pau Espin Pedrol | 05b6c17 | 2020-06-26 17:28:23 +0200 | [diff] [blame] | 2027 | |
| 2028 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 2029 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 2030 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
| 2031 | |
| 2032 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2033 | } |
| 2034 | |
Pau Espin Pedrol | 0ea8b6f | 2020-10-29 20:48:43 +0100 | [diff] [blame] | 2035 | /* Verify allocation and use of multislot tbf, triggered by MS class provided in SGSN. SYS#5131 */ |
| 2036 | testcase TC_dl_multislot_tbf_ms_class_from_sgsn() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 2037 | var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | 0ea8b6f | 2020-10-29 20:48:43 +0100 | [diff] [blame] | 2038 | var octetstring data := f_rnd_octstring(10); |
| 2039 | var PacketDlAssign dl_tbf_ass; |
| 2040 | var RlcmacDlBlock dl_block; |
| 2041 | var uint32_t poll_fn; |
| 2042 | var uint32_t sched_fn; |
| 2043 | var GprsMS ms; |
| 2044 | timer T := 5.0; |
| 2045 | |
| 2046 | /* Initialize NS/BSSGP side */ |
| 2047 | f_init_bssgp(); |
| 2048 | /* Initialize GPRS MS side */ |
| 2049 | f_init_gprs_ms(); |
| 2050 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 2051 | |
| 2052 | /* Only 1 TRX with 8 PDCH */ |
| 2053 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '11111111'B, 0); |
| 2054 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000000'B, (1 .. 7)); |
| 2055 | |
| 2056 | /* Initialize the PCU interface abstraction */ |
| 2057 | f_init_raw(testcasename(), info_ind); |
| 2058 | |
| 2059 | /* Establish BSSGP connection to the PCU */ |
| 2060 | f_bssgp_establish(); |
| 2061 | f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli); |
| 2062 | |
| 2063 | /* Establish an Uplink TBF, this way the PCU can send DL Assignment |
| 2064 | through PDCH (no multiblock assignment possible through PCH) */ |
| 2065 | f_ms_establish_ul_tbf(ms); |
| 2066 | |
| 2067 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 2068 | contention resoultion) and make sure it is ACKED fine */ |
| 2069 | f_ms_tx_ul_data_block(ms, data, with_tlli := true, nr := f_ms_tx_TsTrxBtsNum(ms)); |
| 2070 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 2071 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, poll_fn, nr := f_ms_tx_TsTrxBtsNum(ms)); |
| 2072 | |
| 2073 | /* SGSN sends some DL data, PCU will assign DL TBF through PACCH */ |
| 2074 | var MultislotCap_GPRS_BSSGP mscap_gprs := { |
| 2075 | gprsmultislotclass := '10010'B, /* MS class 18, supports 8 DL and 8 UL */ |
| 2076 | gprsextendeddynalloccap := '0'B |
| 2077 | }; |
| 2078 | var MSRadioAccessCapabilityV_BSSGP ms_racap := { valueof(ts_RaCapRec_BSSGP('0001'B /* E-GSM */, mscap_gprs, omit)) }; |
| 2079 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, ms_racap)); |
| 2080 | dl_block := f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_DL_PACKET_ASS, nr := f_ms_tx_TsTrxBtsNum(ms)); |
| 2081 | if (f_dltbf_num_slots(ms.dl_tbf) != 8) { |
| 2082 | setverdict(fail, "Expected 8 PDCH slots allocated but got ", f_dltbf_num_slots(ms.dl_tbf)); |
| 2083 | f_shutdown(__BFILE__, __LINE__); |
| 2084 | } |
| 2085 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn, nr := f_ms_tx_TsTrxBtsNum(ms)); |
| 2086 | |
| 2087 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2088 | } |
| 2089 | |
Pau Espin Pedrol | 8155bf4 | 2020-10-29 17:34:26 +0100 | [diff] [blame] | 2090 | testcase TC_dl_multislot_tbf_ms_class_from_2phase() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 2091 | var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | 8155bf4 | 2020-10-29 17:34:26 +0100 | [diff] [blame] | 2092 | var RlcmacDlBlock dl_block; |
| 2093 | var octetstring data := f_rnd_octstring(10); |
| 2094 | var PollFnCtx pollctx; |
| 2095 | var uint32_t sched_fn; |
| 2096 | var GprsMS ms; |
| 2097 | |
| 2098 | var MultislotCap_GPRS mscap_gprs := { |
| 2099 | gprsmultislotclass := '10010'B, /* MS class 18, supports 8 DL and 8 UL */ |
| 2100 | gprsextendeddynalloccap := '0'B |
| 2101 | }; |
| 2102 | var MSRadioAccessCapabilityV ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, omit)) }; |
| 2103 | |
| 2104 | |
| 2105 | /* Initialize NS/BSSGP side */ |
| 2106 | f_init_bssgp(); |
| 2107 | /* Initialize GPRS MS side */ |
| 2108 | f_init_gprs_ms(); |
| 2109 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 2110 | |
| 2111 | /* Only 1 TRX with 8 PDCH */ |
| 2112 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '11111111'B, 0); |
| 2113 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000000'B, (1 .. 7)); |
| 2114 | |
| 2115 | /* Initialize the PCU interface abstraction */ |
| 2116 | f_init_raw(testcasename(), info_ind); |
| 2117 | |
| 2118 | /* Establish BSSGP connection to the PCU */ |
| 2119 | f_bssgp_establish(); |
| 2120 | f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli); |
| 2121 | |
| 2122 | /* Send PACKET RESOURCE REQUEST to notify the MultiSlot Class */ |
| 2123 | pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap)); |
| 2124 | |
| 2125 | /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 2126 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts); |
| 2127 | |
| 2128 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 2129 | dl_block := f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_DL_PACKET_ASS, nr := f_ms_tx_TsTrxBtsNum(ms)); |
| 2130 | if (f_dltbf_num_slots(ms.dl_tbf) != 8) { |
| 2131 | setverdict(fail, "Expected 8 PDCH slot allocated but got ", f_dltbf_num_slots(ms.dl_tbf)); |
| 2132 | f_shutdown(__BFILE__, __LINE__); |
| 2133 | } |
| 2134 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn, nr := f_ms_tx_TsTrxBtsNum(ms)); |
| 2135 | |
| 2136 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2137 | } |
| 2138 | |
Pau Espin Pedrol | a9f27fa | 2020-10-30 13:16:21 +0100 | [diff] [blame] | 2139 | testcase TC_ul_multislot_tbf_ms_class_from_2phase() runs on RAW_PCU_Test_CT { |
| 2140 | var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default); |
| 2141 | var RlcmacDlBlock dl_block; |
| 2142 | var octetstring data := f_rnd_octstring(10); |
| 2143 | var PollFnCtx pollctx; |
| 2144 | var uint32_t sched_fn; |
| 2145 | var GprsMS ms; |
| 2146 | |
| 2147 | var MultislotCap_GPRS mscap_gprs := { |
| 2148 | gprsmultislotclass := '10010'B, /* MS class 18, supports 8 DL and 8 UL */ |
| 2149 | gprsextendeddynalloccap := '0'B |
| 2150 | }; |
| 2151 | var MSRadioAccessCapabilityV ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, omit)) }; |
| 2152 | |
| 2153 | |
| 2154 | /* Initialize NS/BSSGP side */ |
| 2155 | f_init_bssgp(); |
| 2156 | /* Initialize GPRS MS side */ |
| 2157 | f_init_gprs_ms(); |
| 2158 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 2159 | |
| 2160 | /* Only 1 TRX with 8 PDCH */ |
| 2161 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '11111111'B, 0); |
| 2162 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000000'B, (1 .. 7)); |
| 2163 | |
| 2164 | /* Initialize the PCU interface abstraction */ |
| 2165 | f_init_raw(testcasename(), info_ind); |
| 2166 | |
| 2167 | /* Establish BSSGP connection to the PCU */ |
| 2168 | f_bssgp_establish(); |
| 2169 | f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli); |
| 2170 | |
| 2171 | /* Send PACKET RESOURCE REQUEST to notify the MultiSlot Class */ |
| 2172 | pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap)); |
| 2173 | |
| 2174 | if (f_ultbf_num_slots(ms.ul_tbf) != 8) { |
| 2175 | setverdict(fail, "Expected 8 PDCH slot allocated but got ", f_ultbf_num_slots(ms.ul_tbf)); |
| 2176 | f_shutdown(__BFILE__, __LINE__); |
| 2177 | } |
| 2178 | |
| 2179 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2180 | } |
| 2181 | |
Pau Espin Pedrol | cdbe903 | 2020-07-07 20:20:42 +0200 | [diff] [blame] | 2182 | /* Test scenario where MS wants to request a new TBF once the current one is |
| 2183 | * ending, by means of sending a Packet Resource Request on ul slot provided by |
| 2184 | * last Pkt Ul ACK's RRBP. |
| 2185 | * See 3GPP TS 44.060 sec 9.3.2.4.2 "Non-extended uplink TBF mode" */ |
| 2186 | testcase TC_ul_tbf_reestablish_with_pkt_resource_req() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | cdbe903 | 2020-07-07 20:20:42 +0200 | [diff] [blame] | 2187 | var RlcmacDlBlock dl_block; |
| 2188 | var octetstring data := f_rnd_octstring(10); |
| 2189 | var uint32_t sched_fn; |
| 2190 | var uint32_t dl_fn; |
| 2191 | var template RlcmacDlBlock acknack_tmpl; |
| 2192 | var GprsMS ms; |
| 2193 | |
| 2194 | /* Initialize NS/BSSGP side */ |
| 2195 | f_init_bssgp(); |
| 2196 | /* Initialize GPRS MS side */ |
| 2197 | f_init_gprs_ms(); |
| 2198 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 2199 | |
| 2200 | /* Initialize the PCU interface abstraction */ |
| 2201 | f_init_raw(testcasename()); |
| 2202 | |
| 2203 | /* Establish BSSGP connection to the PCU */ |
| 2204 | f_bssgp_establish(); |
| 2205 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 2206 | |
| 2207 | /* Establish an Uplink TBF */ |
| 2208 | f_ms_establish_ul_tbf(ms); |
| 2209 | |
| 2210 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 2211 | contention resoultion) and make sure it is ACKED fine */ |
| 2212 | f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true); |
| 2213 | |
| 2214 | /* UL block should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 2215 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id)); |
Pau Espin Pedrol | cdbe903 | 2020-07-07 20:20:42 +0200 | [diff] [blame] | 2216 | |
| 2217 | acknack_tmpl := tr_RLCMAC_UL_ACK_NACK_GPRS(ms.ul_tbf.tfi, |
| 2218 | tr_UlAckNackGprs(ms.tlli, |
| 2219 | tr_AckNackDescription(final_ack := '1'B), |
| 2220 | tr_UlAckNackGprsAdditionsRel99(tbf_est := true))) |
| 2221 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn, acknack_tmpl); |
| 2222 | |
| 2223 | /* TODO: verify TBF_EST and FinalACK are both '1' above */ |
| 2224 | |
| 2225 | /* Send PACKET RESOURCE REQUEST to request a new UL TBF */ |
Vadim Yanitskiy | f3cb4dd | 2020-07-21 01:52:33 +0700 | [diff] [blame] | 2226 | f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, omit)), sched_fn); |
Vadim Yanitskiy | 7431e9e | 2020-07-21 01:59:17 +0700 | [diff] [blame] | 2227 | f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_UL_PACKET_ASS); |
Pau Espin Pedrol | cdbe903 | 2020-07-07 20:20:42 +0200 | [diff] [blame] | 2228 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 2229 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
| 2230 | |
| 2231 | /* Send one UL block (without TLLI since we are in Second-Phase Access) |
| 2232 | and make sure it is ACKED fine */ |
| 2233 | f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := false); /* TODO: send using cs_mcs */ |
| 2234 | |
| 2235 | /* UL block should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 2236 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id)); |
Pau Espin Pedrol | cdbe903 | 2020-07-07 20:20:42 +0200 | [diff] [blame] | 2237 | |
| 2238 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn, acknack_tmpl); |
| 2239 | /* ACK the ACK */ |
| 2240 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
| 2241 | |
| 2242 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2243 | } |
| 2244 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2245 | /* Test CS paging over the BTS<->PCU socket. |
| 2246 | * When a (class B or C, not A) MS has an active TBF (or is on the PDCH), the MS can not react on CS paging over CCCH. |
| 2247 | * Paging should be send on the PACCH. |
| 2248 | * |
| 2249 | * 1. Send a Paging Request over PCU socket. |
| 2250 | * 2. Send a Ready-To-Send message over PCU socket |
| 2251 | * 3. Expect a Paging Frame |
| 2252 | */ |
| 2253 | testcase TC_paging_cs_from_bts() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2254 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2255 | var MobileIdentityLV mi; |
| 2256 | var octetstring mi_enc_lv; |
| 2257 | var hexstring imsi := f_gen_imsi(42); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2258 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2259 | |
| 2260 | /* Initialize NS/BSSGP side */ |
| 2261 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2262 | /* Initialize GPRS MS side */ |
| 2263 | f_init_gprs_ms(); |
| 2264 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2265 | |
| 2266 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 2267 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2268 | |
| 2269 | /* Establish BSSGP connection to the PCU */ |
| 2270 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2271 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2272 | |
| 2273 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2274 | f_ms_establish_ul_tbf(ms); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2275 | |
| 2276 | /* build mobile Identity */ |
| 2277 | mi := valueof(ts_MI_IMSI_LV(imsi)); |
| 2278 | mi_enc_lv := enc_MobileIdentityLV(mi); |
| 2279 | /* Send paging request */ |
| 2280 | BTS.send(ts_PCUIF_PAG_REQ(bts_nr := 0, id_lv := mi_enc_lv, chan_needed := 0, |
| 2281 | sapi :=PCU_IF_SAPI_PDTCH)); |
| 2282 | |
| 2283 | /* Receive it on BTS side towards MS */ |
| 2284 | f_rx_rlcmac_dl_block_exp_pkt_pag_req(dl_block); |
| 2285 | |
| 2286 | /* Make sure that Packet Paging Request contains the same IMSI */ |
Vadim Yanitskiy | 3e5f074 | 2020-11-01 03:30:18 +0700 | [diff] [blame] | 2287 | var PacketPagingReq req := dl_block.ctrl.payload.u.paging; |
| 2288 | if (not f_pkt_paging_match_imsi(req, imsi, ps_domain := false)) { |
| 2289 | setverdict(fail, "Failed to match IMSI ", imsi, " in ", req); |
| 2290 | } |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2291 | |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 2292 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2293 | } |
| 2294 | |
| 2295 | /* Test CS paging over Gb (SGSN->PCU->BTS[PDCH]). |
| 2296 | */ |
| 2297 | private function f_tc_paging_cs_from_sgsn(Nsvci bvci, boolean use_ptmsi := false) |
| 2298 | runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2299 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2300 | var hexstring imsi := f_gen_imsi(42); |
| 2301 | var GsmTmsi tmsi; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2302 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2303 | |
| 2304 | /* Initialize NS/BSSGP side */ |
| 2305 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2306 | /* Initialize GPRS MS side */ |
| 2307 | f_init_gprs_ms(); |
| 2308 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2309 | |
| 2310 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 2311 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2312 | |
| 2313 | /* Establish BSSGP connection to the PCU */ |
| 2314 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2315 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2316 | |
| 2317 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2318 | f_ms_establish_ul_tbf(ms); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2319 | |
| 2320 | /* Send paging request with or without TMSI */ |
| 2321 | if (use_ptmsi) { |
| 2322 | tmsi := oct2int(f_rnd_octstring(4)); /* Random P-TMSI */ |
| 2323 | BSSGP[0].send(ts_BSSGP_CS_PAGING_PTMSI(bvci, imsi, tmsi)); |
| 2324 | } else { |
| 2325 | BSSGP[0].send(ts_BSSGP_CS_PAGING_IMSI(bvci, imsi)); |
| 2326 | } |
| 2327 | |
| 2328 | /* Receive it on BTS side towards MS */ |
| 2329 | f_rx_rlcmac_dl_block_exp_pkt_pag_req(dl_block); |
| 2330 | |
| 2331 | /* Make sure that Packet Paging Request contains the same P-TMSI/IMSI */ |
Vadim Yanitskiy | 3e5f074 | 2020-11-01 03:30:18 +0700 | [diff] [blame] | 2332 | var PacketPagingReq req := dl_block.ctrl.payload.u.paging; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2333 | if (use_ptmsi) { |
Vadim Yanitskiy | 3e5f074 | 2020-11-01 03:30:18 +0700 | [diff] [blame] | 2334 | if (not f_pkt_paging_match_tmsi(req, tmsi, ps_domain := false)) { |
| 2335 | setverdict(fail, "Failed to match P-TMSI ", tmsi, " in ", req); |
| 2336 | } |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2337 | } else { |
Vadim Yanitskiy | 3e5f074 | 2020-11-01 03:30:18 +0700 | [diff] [blame] | 2338 | if (not f_pkt_paging_match_imsi(req, imsi, ps_domain := false)) { |
| 2339 | setverdict(fail, "Failed to match IMSI ", imsi, " in ", req); |
| 2340 | } |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2341 | } |
| 2342 | |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 2343 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2344 | } |
| 2345 | |
| 2346 | testcase TC_paging_cs_from_sgsn_sign_ptmsi() runs on RAW_PCU_Test_CT { |
| 2347 | f_tc_paging_cs_from_sgsn(0, true); |
| 2348 | } |
| 2349 | |
| 2350 | testcase TC_paging_cs_from_sgsn_sign() runs on RAW_PCU_Test_CT { |
| 2351 | f_tc_paging_cs_from_sgsn(0); |
| 2352 | } |
| 2353 | |
| 2354 | testcase TC_paging_cs_from_sgsn_ptp() runs on RAW_PCU_Test_CT { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 2355 | f_tc_paging_cs_from_sgsn(mp_gb_cfg.bvc[0].bvci); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2356 | } |
| 2357 | |
| 2358 | /* Test PS paging over Gb (SGSN->PCU->BTS[CCCH]). |
| 2359 | */ |
| 2360 | private function f_tc_paging_ps_from_sgsn(Nsvci bvci, boolean use_ptmsi := false) |
| 2361 | runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2362 | var integer imsi_suff_tx := 423; |
| 2363 | var hexstring imsi := f_gen_imsi(imsi_suff_tx); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2364 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2365 | |
| 2366 | /* Initialize NS/BSSGP side */ |
| 2367 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2368 | /* Initialize GPRS MS side */ |
| 2369 | f_init_gprs_ms(); |
| 2370 | ms := g_ms[0]; /* We only use first MS in this test */ |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2371 | |
| 2372 | /* Initialize the PCU interface abstraction */ |
| 2373 | f_init_raw(testcasename()); |
| 2374 | |
| 2375 | /* Establish BSSGP connection to the PCU */ |
| 2376 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2377 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2378 | |
| 2379 | /* Send BSSGP PAGING-PS (with or without TMSI), wait for RR Paging Request Type 1. |
| 2380 | * Make sure that both paging group (IMSI suffix) and Mobile Identity match. */ |
| 2381 | if (use_ptmsi) { |
| 2382 | var OCT4 tmsi := f_rnd_octstring(4); /* Random P-TMSI */ |
| 2383 | BSSGP[0].send(ts_BSSGP_PS_PAGING_PTMSI(bvci, imsi, oct2int(tmsi))); |
| 2384 | f_pcuif_rx_pch_pag_req1(t_MI_TMSI(tmsi), imsi_suff_tx); |
| 2385 | } else { |
| 2386 | BSSGP[0].send(ts_BSSGP_PS_PAGING_IMSI(bvci, imsi)); |
| 2387 | f_pcuif_rx_pch_pag_req1(tr_MI_IMSI(imsi), imsi_suff_tx); |
| 2388 | } |
| 2389 | |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 2390 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2391 | } |
| 2392 | |
| 2393 | testcase TC_paging_ps_from_sgsn_sign_ptmsi() runs on RAW_PCU_Test_CT { |
| 2394 | f_tc_paging_ps_from_sgsn(0, true); |
| 2395 | } |
| 2396 | |
| 2397 | testcase TC_paging_ps_from_sgsn_sign() runs on RAW_PCU_Test_CT { |
| 2398 | f_tc_paging_ps_from_sgsn(0); |
| 2399 | } |
| 2400 | |
| 2401 | testcase TC_paging_ps_from_sgsn_ptp() runs on RAW_PCU_Test_CT { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 2402 | f_tc_paging_ps_from_sgsn(mp_gb_cfg.bvc[0].bvci); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2403 | } |
| 2404 | |
Pau Espin Pedrol | c03eb12 | 2020-08-27 18:54:24 +0200 | [diff] [blame] | 2405 | /* Verify osmo-pcu handles DL UNIT_DATA from SGSN with IMSI IE correctly. See OS#4729 */ |
| 2406 | testcase TC_bssgp_dl_unitdata_with_valid_imsi() runs on RAW_PCU_Test_CT { |
| 2407 | var RlcmacDlBlock dl_block; |
| 2408 | var octetstring data := f_rnd_octstring(10); |
| 2409 | var uint32_t sched_fn; |
| 2410 | var uint32_t dl_fn; |
| 2411 | var GprsMS ms; |
| 2412 | |
| 2413 | /* Initialize NS/BSSGP side */ |
| 2414 | f_init_bssgp(); |
| 2415 | /* Initialize GPRS MS side */ |
| 2416 | f_init_gprs_ms(); |
| 2417 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 2418 | |
| 2419 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 2420 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | c03eb12 | 2020-08-27 18:54:24 +0200 | [diff] [blame] | 2421 | |
Daniel Willmann | 535aea6 | 2020-09-21 13:27:08 +0200 | [diff] [blame] | 2422 | f_statsd_reset(); |
| 2423 | |
Pau Espin Pedrol | c03eb12 | 2020-08-27 18:54:24 +0200 | [diff] [blame] | 2424 | /* Establish BSSGP connection to the PCU */ |
| 2425 | f_bssgp_establish(); |
| 2426 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 2427 | |
| 2428 | /* Establish an Uplink TBF */ |
| 2429 | f_ms_establish_ul_tbf(ms); |
| 2430 | |
| 2431 | /* Fake GMM GPRS Attach or similar, PCU doesn't care about upper layers here */ |
| 2432 | f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true); |
| 2433 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 2434 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 2435 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
| 2436 | |
| 2437 | /* UL block should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 2438 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id)); |
Pau Espin Pedrol | c03eb12 | 2020-08-27 18:54:24 +0200 | [diff] [blame] | 2439 | |
| 2440 | /* Now SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
| 2441 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI(ms.imsi))); |
| 2442 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
| 2443 | |
| 2444 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 2445 | f_sleep(X2002); |
| 2446 | f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0); |
| 2447 | |
| 2448 | /* ACK the DL block */ |
| 2449 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B); |
| 2450 | f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc), |
| 2451 | f_dl_block_ack_fn(dl_block, dl_fn)); |
| 2452 | |
Daniel Willmann | 535aea6 | 2020-09-21 13:27:08 +0200 | [diff] [blame] | 2453 | var StatsDExpects expect := { |
| 2454 | { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := 1, max := 1}, |
| 2455 | { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 1, max := 1}, |
| 2456 | { name := "TTCN3.bts.0.tbf.dl.alloc", mtype := "c", min := 1, max := 1}, |
| 2457 | { name := "TTCN3.bts.0.tbf.ul.alloc", mtype := "c", min := 1, max := 1}, |
| 2458 | { name := "TTCN3.bts.0.rlc.dl_payload_bytes", mtype := "c", min := 28, max := 28}, |
Pau Espin Pedrol | 599d56b | 2020-11-17 12:01:46 +0100 | [diff] [blame] | 2459 | { name := "TTCN3.bts.0.rlc.ul_payload_bytes", mtype := "c", min := 26, max := 26} |
Daniel Willmann | 535aea6 | 2020-09-21 13:27:08 +0200 | [diff] [blame] | 2460 | }; |
| 2461 | f_statsd_expect(expect); |
| 2462 | |
Pau Espin Pedrol | c03eb12 | 2020-08-27 18:54:24 +0200 | [diff] [blame] | 2463 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2464 | } |
| 2465 | |
| 2466 | /* Verify osmo-pcu acts on incorrect IMSI IE content in DL UNIT_DATA from SGSN. See OS#4729 */ |
| 2467 | testcase TC_bssgp_dl_unitdata_with_invalid_imsi() runs on RAW_PCU_Test_CT { |
| 2468 | var RlcmacDlBlock dl_block; |
| 2469 | var octetstring data := f_rnd_octstring(10); |
| 2470 | var uint32_t sched_fn; |
| 2471 | var uint32_t dl_fn; |
| 2472 | var GprsMS ms; |
| 2473 | |
| 2474 | /* Initialize NS/BSSGP side */ |
| 2475 | f_init_bssgp(); |
| 2476 | /* Initialize GPRS MS side */ |
| 2477 | f_init_gprs_ms(); |
| 2478 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 2479 | |
| 2480 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 2481 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | c03eb12 | 2020-08-27 18:54:24 +0200 | [diff] [blame] | 2482 | |
| 2483 | /* Establish BSSGP connection to the PCU */ |
| 2484 | f_bssgp_establish(); |
| 2485 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 2486 | |
| 2487 | /* Establish an Uplink TBF */ |
| 2488 | f_ms_establish_ul_tbf(ms); |
| 2489 | |
| 2490 | /* Fake GMM GPRS Attach or similar, PCU doesn't care about upper layers here */ |
| 2491 | f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true); |
| 2492 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 2493 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 2494 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
| 2495 | |
| 2496 | /* UL block should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 2497 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id)); |
Pau Espin Pedrol | c03eb12 | 2020-08-27 18:54:24 +0200 | [diff] [blame] | 2498 | |
| 2499 | /* Now SGSN sends some DL data with an invalid IMSI */ |
| 2500 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI('1122'H))); |
| 2501 | |
| 2502 | BSSGP_SIG[0].receive(tr_BSSGP_STATUS(omit, BSSGP_CAUSE_CONDITIONAL_IE_ERROR, ?)); |
| 2503 | |
| 2504 | /* TODO: make sure no data is sent over PCU -> MS */ |
| 2505 | |
| 2506 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2507 | } |
| 2508 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2509 | private function f_TC_egprs_pkt_chan_req(in EGPRSPktChRequest req, |
Vadim Yanitskiy | 4389390 | 2020-05-29 15:21:50 +0700 | [diff] [blame] | 2510 | template GsmRrMessage t_imm_ass := ?, |
| 2511 | PCUIF_BurstType bt := BURST_TYPE_1) |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2512 | runs on RAW_PCU_Test_CT { |
Vadim Yanitskiy | 4389390 | 2020-05-29 15:21:50 +0700 | [diff] [blame] | 2513 | var GsmRrMessage rr_msg; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2514 | var uint16_t ra11; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2515 | |
| 2516 | ra11 := enc_EGPRSPktChRequest2uint(req); |
| 2517 | log("Sending EGPRS Packet Channel Request (", ra11, "): ", req); |
| 2518 | |
Vadim Yanitskiy | 28d18e1 | 2020-05-29 15:25:59 +0700 | [diff] [blame] | 2519 | rr_msg := f_pcuif_tx_rach_rx_imm_ass(ra := ra11, is_11bit := 1, burst_type := bt); |
Vadim Yanitskiy | 4389390 | 2020-05-29 15:21:50 +0700 | [diff] [blame] | 2520 | if (not match(rr_msg, t_imm_ass)) { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2521 | setverdict(fail, "Immediate Assignment does not match"); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 2522 | f_shutdown(__BFILE__, __LINE__); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2523 | } |
| 2524 | |
| 2525 | setverdict(pass); |
| 2526 | } |
| 2527 | |
| 2528 | testcase TC_egprs_pkt_chan_req_signalling() runs on RAW_PCU_Test_CT { |
| 2529 | var template GsmRrMessage imm_ass; |
| 2530 | var template IaRestOctets rest; |
| 2531 | var template EgprsUlAss ul_ass; |
| 2532 | |
| 2533 | /* Initialize the PCU interface abstraction */ |
| 2534 | f_init_raw(testcasename()); |
| 2535 | |
| 2536 | var EGPRSPktChRequest req := { |
| 2537 | /* NOTE: other fields are set in the loop */ |
| 2538 | signalling := { tag := '110011'B } |
| 2539 | }; |
| 2540 | |
| 2541 | for (var integer i := 0; i < 6; i := i + 1) { |
| 2542 | var BIT5 ext_ra := int2bit(f_rnd_int(32), 5); |
| 2543 | req.signalling.random_bits := ext_ra; |
| 2544 | |
| 2545 | /* For signalling, do we expect Multiblock UL TBF Assignment? */ |
| 2546 | ul_ass := tr_EgprsUlAssMultiblock(ext_ra := ext_ra); |
| 2547 | rest := tr_IaRestOctets_EGPRSULAss(ul_ass); |
| 2548 | imm_ass := tr_IMM_TBF_ASS(dl := false, rest := rest); |
| 2549 | |
| 2550 | f_TC_egprs_pkt_chan_req(req, imm_ass); |
| 2551 | } |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 2552 | |
| 2553 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2554 | } |
| 2555 | |
| 2556 | testcase TC_egprs_pkt_chan_req_one_phase() runs on RAW_PCU_Test_CT { |
| 2557 | var template GsmRrMessage imm_ass; |
| 2558 | var template IaRestOctets rest; |
| 2559 | var template EgprsUlAss ul_ass; |
| 2560 | |
| 2561 | /* Initialize the PCU interface abstraction */ |
| 2562 | f_init_raw(testcasename()); |
| 2563 | |
| 2564 | var EGPRSPktChRequest req := { |
| 2565 | /* NOTE: other fields are set in the loop */ |
| 2566 | one_phase := { tag := '0'B } |
| 2567 | }; |
| 2568 | |
| 2569 | for (var integer i := 0; i < 6; i := i + 1) { |
| 2570 | var BIT5 ext_ra := int2bit(f_rnd_int(32), 5); |
| 2571 | var BIT5 mslot_class := int2bit(f_rnd_int(32), 5); |
| 2572 | var BIT2 priority := substr(ext_ra, 0, 2); |
| 2573 | var BIT3 rand := substr(ext_ra, 2, 3); |
| 2574 | |
| 2575 | req.one_phase.multislot_class := mslot_class; |
| 2576 | req.one_phase.priority := priority; |
| 2577 | req.one_phase.random_bits := rand; |
| 2578 | |
| 2579 | /* For one phase access, do we expect Dynamic UL TBF Assignment? */ |
| 2580 | ul_ass := tr_EgprsUlAssDynamic(ext_ra := ext_ra); |
| 2581 | rest := tr_IaRestOctets_EGPRSULAss(ul_ass); |
| 2582 | imm_ass := tr_IMM_TBF_ASS(dl := false, rest := rest); |
| 2583 | |
| 2584 | f_TC_egprs_pkt_chan_req(req, imm_ass); |
| 2585 | } |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 2586 | |
| 2587 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2588 | } |
| 2589 | |
| 2590 | testcase TC_egprs_pkt_chan_req_two_phase() runs on RAW_PCU_Test_CT { |
| 2591 | var template GsmRrMessage imm_ass; |
| 2592 | var template IaRestOctets rest; |
| 2593 | var template EgprsUlAss ul_ass; |
| 2594 | |
| 2595 | /* Initialize the PCU interface abstraction */ |
| 2596 | f_init_raw(testcasename()); |
| 2597 | |
| 2598 | var EGPRSPktChRequest req := { |
| 2599 | /* NOTE: other fields are set in the loop */ |
| 2600 | two_phase := { tag := '110000'B } |
| 2601 | }; |
| 2602 | |
| 2603 | for (var integer i := 0; i < 6; i := i + 1) { |
| 2604 | var BIT5 ext_ra := int2bit(f_rnd_int(32), 5); |
| 2605 | var BIT2 priority := substr(ext_ra, 0, 2); |
| 2606 | var BIT3 rand := substr(ext_ra, 2, 3); |
| 2607 | |
| 2608 | req.two_phase.priority := priority; |
| 2609 | req.two_phase.random_bits := rand; |
| 2610 | |
| 2611 | /* For two phase access, do we expect Multiblock UL TBF Assignment? */ |
| 2612 | ul_ass := tr_EgprsUlAssMultiblock(ext_ra := ext_ra); |
| 2613 | rest := tr_IaRestOctets_EGPRSULAss(ul_ass); |
| 2614 | imm_ass := tr_IMM_TBF_ASS(dl := false, rest := rest); |
| 2615 | |
| 2616 | f_TC_egprs_pkt_chan_req(req, imm_ass); |
| 2617 | } |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 2618 | |
| 2619 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2620 | } |
| 2621 | |
Vadim Yanitskiy | 4f56d32 | 2020-05-22 20:15:48 +0700 | [diff] [blame] | 2622 | private function f_TC_egprs_pkt_chan_req_reject(bitstring ra11, uint32_t fn, |
| 2623 | template IARRestOctets rest := ?, |
| 2624 | PCUIF_BurstType bt := BURST_TYPE_1) |
| 2625 | runs on RAW_PCU_Test_CT { |
| 2626 | var template ReqRefWaitInd tr_ref; |
| 2627 | var GsmRrMessage rr_msg; |
Vadim Yanitskiy | 4f56d32 | 2020-05-22 20:15:48 +0700 | [diff] [blame] | 2628 | |
| 2629 | /* Send RACH.ind with malformed EGPRS Packet Channel Request */ |
| 2630 | BTS.send(ts_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 0, |
| 2631 | ra := bit2int(ra11), is_11bit := 1, |
| 2632 | burst_type := bt, fn := fn, |
| 2633 | arfcn := 871)); |
| 2634 | |
| 2635 | /* Abuse f_pcuif_rx_imm_ass(): wait for Immediate Assignment Reject */ |
Vadim Yanitskiy | 7466c33 | 2020-05-28 20:41:19 +0700 | [diff] [blame] | 2636 | rr_msg := f_pcuif_rx_imm_ass(t_imm_ass := tr_IMM_ASS_REJ); |
Vadim Yanitskiy | 4f56d32 | 2020-05-22 20:15:48 +0700 | [diff] [blame] | 2637 | |
| 2638 | /* Just to have a short-name reference to the actual message */ |
| 2639 | var ImmediateAssignmentReject iar := rr_msg.payload.imm_ass_rej; |
| 2640 | |
| 2641 | /* Make sure that Request Reference list contains at least one entry |
| 2642 | * with our TDMA frame number, and RA is set to 'reserved' value 127. */ |
| 2643 | tr_ref := tr_ReqRefWaitInd(f_compute_ReqRef(127, fn)); |
| 2644 | if (not match(iar.payload, { *, tr_ref, * })) { |
| 2645 | setverdict(fail, "Request Reference list does not match"); |
| 2646 | f_shutdown(__BFILE__, __LINE__); |
| 2647 | } |
| 2648 | |
| 2649 | /* Match Feature Indicator (must indicate PS domain) */ |
| 2650 | if (not match(iar.feature_ind, FeatureIndicator:{?, false, true})) { |
| 2651 | setverdict(fail, "Feature Indicator does not match"); |
| 2652 | f_shutdown(__BFILE__, __LINE__); |
| 2653 | } |
| 2654 | |
| 2655 | /* Match IAR Rest Octets */ |
| 2656 | if (not match(iar.rest_octets, rest)) { |
| 2657 | setverdict(fail, "IAR Rest Octets does not match: ", |
| 2658 | iar.rest_octets, " vs expected ", rest); |
| 2659 | f_shutdown(__BFILE__, __LINE__); |
| 2660 | } |
| 2661 | |
| 2662 | setverdict(pass); |
| 2663 | } |
| 2664 | |
| 2665 | /* Verify the contents of RR Immediate Assignment Reject message and its |
| 2666 | * Rest Octets sent in response to EGPRS Packet Channel Request (11 bit). */ |
| 2667 | testcase TC_egprs_pkt_chan_req_reject_content() runs on RAW_PCU_Test_CT { |
| 2668 | var template IARRestOctets rest; |
| 2669 | var BIT5 ext_ra; |
| 2670 | |
| 2671 | /* Initialize the PCU interface abstraction */ |
| 2672 | f_init_raw(testcasename()); |
| 2673 | |
| 2674 | for (var integer i := 0; i < 6; i := i + 1) { |
| 2675 | ext_ra := int2bit(f_rnd_int(32), 5); /* 5 LSB's of RA11 */ |
| 2676 | rest := tr_IARRestOctets({ *, tr_ExtRAOpt(ext_ra), * }); |
| 2677 | |
| 2678 | /* Intentionally incorrect message (see table 11.2.5a.2) */ |
| 2679 | f_TC_egprs_pkt_chan_req_reject('111111'B & ext_ra, 1337 + i, rest); |
| 2680 | } |
| 2681 | |
| 2682 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2683 | } |
| 2684 | |
Vadim Yanitskiy | 7e06c25 | 2020-05-22 20:48:53 +0700 | [diff] [blame] | 2685 | /* At the moment, the IUT does not support any emergency services. Make sure |
| 2686 | * that EGPRS Packet Channel Request for an emergency call is properly rejected. */ |
| 2687 | testcase TC_egprs_pkt_chan_req_reject_emergency() runs on RAW_PCU_Test_CT { |
| 2688 | var template IARRestOctets rest; |
| 2689 | var BIT5 ext_ra; |
| 2690 | var BIT11 ra11; |
| 2691 | |
| 2692 | /* Initialize the PCU interface abstraction */ |
| 2693 | f_init_raw(testcasename()); |
| 2694 | |
| 2695 | var EGPRSPktChRequest req := { |
| 2696 | /* NOTE: other fields are set in the loop */ |
| 2697 | emergency := { tag := '110111'B } |
| 2698 | }; |
| 2699 | |
| 2700 | for (var integer i := 0; i < 6; i := i + 1) { |
| 2701 | ext_ra := int2bit(f_rnd_int(32), 5); /* 5 LSB's of RA11 */ |
| 2702 | rest := tr_IARRestOctets({ *, tr_ExtRAOpt(ext_ra), * }); |
| 2703 | |
| 2704 | req.emergency.random_bits := ext_ra; |
| 2705 | ra11 := enc_EGPRSPktChRequest2bits(req); |
| 2706 | |
| 2707 | /* Intentionally incorrect message (see table 11.2.5a.2) */ |
| 2708 | f_TC_egprs_pkt_chan_req_reject(ra11, 1337 + i, rest); |
| 2709 | } |
| 2710 | |
| 2711 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2712 | } |
| 2713 | |
Vadim Yanitskiy | c4324ff | 2020-05-22 21:53:58 +0700 | [diff] [blame] | 2714 | /* Make sure that IUT responds with RR Immediate Assignment Reject due to exhaustion. */ |
| 2715 | testcase TC_egprs_pkt_chan_req_reject_exhaustion() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 7ebc112 | 2020-10-29 13:33:39 +0100 | [diff] [blame] | 2716 | var PCUIF_info_ind info_ind; |
Vadim Yanitskiy | c4324ff | 2020-05-22 21:53:58 +0700 | [diff] [blame] | 2717 | var template IARRestOctets rest; |
| 2718 | var BIT11 ra11; |
| 2719 | |
Pau Espin Pedrol | 7ebc112 | 2020-10-29 13:33:39 +0100 | [diff] [blame] | 2720 | info_ind := valueof(ts_PCUIF_INFO_default); |
Vadim Yanitskiy | d5321fb | 2020-10-31 20:23:47 +0700 | [diff] [blame] | 2721 | |
| 2722 | /* Only the first TRX is enabled. */ |
| 2723 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000000'B, (1 .. 7)); |
| 2724 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000001'B, 0); |
Pau Espin Pedrol | 7ebc112 | 2020-10-29 13:33:39 +0100 | [diff] [blame] | 2725 | |
Vadim Yanitskiy | c4324ff | 2020-05-22 21:53:58 +0700 | [diff] [blame] | 2726 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 7ebc112 | 2020-10-29 13:33:39 +0100 | [diff] [blame] | 2727 | f_init_raw(testcasename(), info_ind); |
Vadim Yanitskiy | c4324ff | 2020-05-22 21:53:58 +0700 | [diff] [blame] | 2728 | |
| 2729 | var EGPRSPktChRequest req := { |
| 2730 | one_phase := { |
| 2731 | tag := '0'B, |
| 2732 | multislot_class := '10101'B, |
| 2733 | priority := '01'B, |
| 2734 | random_bits := '101'B |
| 2735 | } |
| 2736 | }; |
| 2737 | |
| 2738 | /* We send 7 requests, the IUT gives us all available USFs (0..6). |
| 2739 | * TODO: make it configurable: usf_max := mp_pdch_ts_num * 7. */ |
| 2740 | for (var integer i := 0; i < 7; i := i + 1) { |
| 2741 | req.one_phase.random_bits := int2bit(f_rnd_int(8), 3); |
| 2742 | f_TC_egprs_pkt_chan_req(req, tr_IMM_TBF_ASS); |
| 2743 | } |
| 2744 | |
| 2745 | ra11 := enc_EGPRSPktChRequest2bits(req); |
| 2746 | rest := tr_IARRestOctets({ *, tr_ExtRAOpt(substr(ra11, 6, 5)), * }); |
| 2747 | |
| 2748 | /* At this point, the IUT should run out of free USFs */ |
| 2749 | f_TC_egprs_pkt_chan_req_reject(ra11, 1870, rest); |
| 2750 | |
| 2751 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2752 | } |
| 2753 | |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 2754 | /* Randomly generate a set of hopping parameters for one timeslot */ |
Vadim Yanitskiy | 7a04cdd | 2020-09-07 11:43:32 +0700 | [diff] [blame] | 2755 | private function f_TC_pcuif_fh_params_gen(integer max_ma_len) |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 2756 | return template (value) PCUIF_InfoTrxTs { |
Vadim Yanitskiy | 7a04cdd | 2020-09-07 11:43:32 +0700 | [diff] [blame] | 2757 | /* Pick a random MA length in range 2 .. max_ma_len */ |
| 2758 | var integer ma_len := 2 + f_rnd_int(max_ma_len - 2); |
| 2759 | |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 2760 | return ts_PCUIF_InfoTrxTsH1(tsc := f_rnd_int(7), |
| 2761 | hsn := f_rnd_int(63), |
| 2762 | maio := f_rnd_int(63), |
| 2763 | ma := f_rnd_bitstring(ma_len)); |
| 2764 | } |
| 2765 | |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2766 | private function f_TC_pcuif_fh_check_imm_ass(in PCUIF_info_ind info_ind, |
| 2767 | in GsmRrMessage rr_msg) |
| 2768 | { |
| 2769 | var ImmediateAssignment ia := rr_msg.payload.imm_ass; |
| 2770 | var PCUIF_InfoTrxTs ts := info_ind.trx.v10[0].ts[ia.pkt_chan_desc.tn]; |
| 2771 | |
| 2772 | var template PacketChannelDescription tr_pkt_chan_desc := { |
| 2773 | channel_Type_spare := ?, |
| 2774 | tn := ?, |
| 2775 | tsc := ts.tsc, |
| 2776 | presence := '1'B, |
| 2777 | zero := omit, |
| 2778 | one := { |
| 2779 | maio := ts.maio, |
| 2780 | hsn := ts.hsn |
| 2781 | } |
| 2782 | }; |
| 2783 | |
| 2784 | if (not match(ia.pkt_chan_desc, tr_pkt_chan_desc)) { |
| 2785 | setverdict(fail, "Packet Channel Description does not match: ", |
| 2786 | ia.pkt_chan_desc, " vs ", tr_pkt_chan_desc); |
| 2787 | } |
| 2788 | |
Vadim Yanitskiy | 43ccaf5 | 2020-09-05 21:35:13 +0700 | [diff] [blame] | 2789 | /* Mobile Allocation is expected to be octet-aligned */ |
| 2790 | var uint8_t ma_oct_len := (ts.ma_bit_len + 8 - 1) / 8; |
| 2791 | var template MobileAllocationLV tr_ma := { |
| 2792 | len := ma_oct_len, /* in bytes */ |
| 2793 | ma := substr(ts.ma, 0, ma_oct_len * 8) |
| 2794 | }; |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2795 | |
| 2796 | if (not match(ia.mobile_allocation, tr_ma)) { |
| 2797 | setverdict(fail, "Mobile Allocation does not match: ", |
| 2798 | ia.mobile_allocation, " vs ", tr_ma); |
| 2799 | } |
| 2800 | |
| 2801 | setverdict(pass); |
| 2802 | } |
| 2803 | |
| 2804 | /* Make sure that Immediate (UL EGPRS TBF) Assignment contains hopping parameters */ |
| 2805 | testcase TC_pcuif_fh_imm_ass_ul_egprs() runs on RAW_PCU_Test_CT { |
| 2806 | var template PCUIF_info_ind info_ind := ts_PCUIF_INFO_default; |
| 2807 | var GprsMS ms := valueof(t_GprsMS_def); |
| 2808 | |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 2809 | /* Enable frequency hopping on TRX0/TS7 */ |
| 2810 | info_ind.trx.v10[0].ts[7] := f_TC_pcuif_fh_params_gen(32); |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2811 | |
| 2812 | /* Initialize the PCU interface abstraction */ |
| 2813 | f_init_raw(testcasename(), info_ind); |
| 2814 | |
| 2815 | /* EGPRS Packet Channel Request (cause=Signalling) */ |
| 2816 | f_ms_use_ra(ms, bit2int('11001101010'B), ra_is_11bit := 1); |
| 2817 | |
| 2818 | /* Establish an Uplink EGPRS TBF */ |
| 2819 | f_ms_establish_ul_tbf(ms); |
| 2820 | |
| 2821 | f_TC_pcuif_fh_check_imm_ass(valueof(info_ind), ms.ul_tbf.rr_imm_ass); |
| 2822 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2823 | } |
| 2824 | |
| 2825 | /* Make sure that Immediate (UL TBF) Assignment contains hopping parameters */ |
| 2826 | testcase TC_pcuif_fh_imm_ass_ul() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 2827 | var template PCUIF_info_ind info_ind := ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS); |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2828 | var GprsMS ms := valueof(t_GprsMS_def); |
| 2829 | |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 2830 | /* Enable frequency hopping on TRX0/TS7 */ |
| 2831 | info_ind.trx.v10[0].ts[7] := f_TC_pcuif_fh_params_gen(32); |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2832 | |
| 2833 | /* Initialize the PCU interface abstraction */ |
| 2834 | f_init_raw(testcasename(), info_ind); |
| 2835 | |
| 2836 | /* Establish an Uplink TBF */ |
| 2837 | f_ms_establish_ul_tbf(ms); |
| 2838 | |
| 2839 | f_TC_pcuif_fh_check_imm_ass(valueof(info_ind), ms.ul_tbf.rr_imm_ass); |
| 2840 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2841 | } |
| 2842 | |
| 2843 | /* Make sure that Immediate (DL TBF) Assignment contains hopping parameters */ |
| 2844 | testcase TC_pcuif_fh_imm_ass_dl() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 2845 | var template PCUIF_info_ind info_ind := ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS) |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2846 | var GprsMS ms := valueof(t_GprsMS_def); |
| 2847 | |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 2848 | /* Enable frequency hopping on TRX0/TS7 */ |
| 2849 | info_ind.trx.v10[0].ts[7] := f_TC_pcuif_fh_params_gen(16); |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2850 | |
| 2851 | /* Initialize NS/BSSGP side */ |
| 2852 | f_init_bssgp(); |
| 2853 | |
| 2854 | /* Initialize the PCU interface abstraction */ |
| 2855 | f_init_raw(testcasename(), info_ind); |
| 2856 | |
| 2857 | /* Establish BSSGP connection to the PCU */ |
| 2858 | f_bssgp_establish(); |
| 2859 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 2860 | |
| 2861 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
| 2862 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, f_rnd_octstring(12))); |
| 2863 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
| 2864 | |
| 2865 | f_TC_pcuif_fh_check_imm_ass(valueof(info_ind), ms.dl_tbf.rr_imm_ass); |
| 2866 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2867 | } |
| 2868 | |
| 2869 | private function f_TC_pcuif_fh_check_pkt_ass(in PCUIF_info_ind info_ind, |
| 2870 | in FrequencyParameters fp) |
| 2871 | { |
| 2872 | /* FIXME: TRX0/TS7 is a hard-coded expectation, make it configurable */ |
| 2873 | var PCUIF_InfoTrxTs ts := info_ind.trx.v10[0].ts[7]; |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2874 | |
| 2875 | /* Table 12.8.1: Frequency Parameters information elements */ |
| 2876 | var template FrequencyParameters tr_fp := { |
| 2877 | tsc := ts.tsc, |
| 2878 | presence := '10'B, /* Direct encoding 1 */ |
| 2879 | arfcn := omit, |
| 2880 | indirect := omit, |
| 2881 | direct1 := { |
| 2882 | maio := ts.maio, |
| 2883 | /* Table 12.10a.1: GPRS Mobile Allocation information elements */ |
| 2884 | mobile_allocation := { |
| 2885 | hsn := ts.hsn, |
| 2886 | rfl_number_list_present := '0'B, |
| 2887 | rfl_number_list := omit, |
| 2888 | ma_present := '0'B, /* inverted logic */ |
Vadim Yanitskiy | 43ccaf5 | 2020-09-05 21:35:13 +0700 | [diff] [blame] | 2889 | ma_length := ts.ma_bit_len, |
| 2890 | ma_bitmap := substr(ts.ma, 0, ts.ma_bit_len) |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2891 | } |
| 2892 | }, |
| 2893 | direct2 := omit |
| 2894 | }; |
| 2895 | |
| 2896 | if (not match(fp, tr_fp)) { |
| 2897 | setverdict(fail, "Frequency Parameters IE does not match: ", |
| 2898 | fp, " vs ", tr_fp); |
| 2899 | } |
| 2900 | |
| 2901 | setverdict(pass); |
| 2902 | } |
| 2903 | |
| 2904 | /* Make sure that Packet Uplink Assignment contains hopping parameters */ |
| 2905 | testcase TC_pcuif_fh_pkt_ass_ul() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 2906 | var template PCUIF_info_ind info_ind := ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS); |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2907 | var GprsMS ms := valueof(t_GprsMS_def); |
| 2908 | var uint32_t poll_fn; |
| 2909 | |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 2910 | /* Enable frequency hopping on TRX0/TS7 */ |
| 2911 | info_ind.trx.v10[0].ts[7] := f_TC_pcuif_fh_params_gen(33); |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2912 | |
| 2913 | /* Initialize the PCU interface abstraction */ |
| 2914 | f_init_raw(testcasename(), info_ind); |
| 2915 | |
| 2916 | /* Establish an Uplink TBF */ |
| 2917 | f_ms_establish_ul_tbf(ms); |
| 2918 | |
| 2919 | /* Send Packet Resource Request, so the network will allocate an Uplink resource */ |
| 2920 | f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, omit))); |
| 2921 | |
| 2922 | /* Expect an RLC/MAC block with Packet Uplink Assignment on PACCH (see 11.2.29) */ |
| 2923 | var RlcmacDlBlock blk := f_ms_rx_pkt_ass_pacch(ms, poll_fn, tr_RLCMAC_UL_PACKET_ASS); |
| 2924 | var PacketUlAssignment ua := blk.ctrl.payload.u.ul_assignment; |
| 2925 | |
| 2926 | /* 3GPP TS 44.060, section 12.8 "Frequency Parameters" */ |
| 2927 | var template (omit) FrequencyParameters fp; |
| 2928 | if (ua.is_egprs == '1'B) { |
| 2929 | fp := ua.egprs.freq_par; |
| 2930 | } else { |
| 2931 | fp := ua.gprs.freq_par; |
| 2932 | } |
| 2933 | |
| 2934 | /* This is an optional IE, so it's worth to check its presence */ |
| 2935 | if (istemplatekind(fp, "omit")) { |
| 2936 | setverdict(fail, "Frequency Parameters IE is not present"); |
| 2937 | f_shutdown(__BFILE__, __LINE__); |
| 2938 | } |
| 2939 | |
| 2940 | f_TC_pcuif_fh_check_pkt_ass(valueof(info_ind), valueof(fp)); |
| 2941 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2942 | } |
| 2943 | |
| 2944 | /* Make sure that Packet Downlink Assignment contains hopping parameters */ |
| 2945 | testcase TC_pcuif_fh_pkt_ass_dl() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 2946 | var template PCUIF_info_ind info_ind := ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS); |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2947 | var octetstring data := f_rnd_octstring(10); |
| 2948 | var GprsMS ms := valueof(t_GprsMS_def); |
| 2949 | var RlcmacDlBlock dl_block; |
| 2950 | var uint32_t poll_fn; |
| 2951 | |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 2952 | /* Enable frequency hopping on TRX0/TS7 */ |
| 2953 | info_ind.trx.v10[0].ts[7] := f_TC_pcuif_fh_params_gen(33); |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2954 | |
| 2955 | /* Initialize NS/BSSGP side */ |
| 2956 | f_init_bssgp(); |
| 2957 | |
| 2958 | /* Initialize the PCU interface abstraction */ |
| 2959 | f_init_raw(testcasename(), info_ind); |
| 2960 | |
| 2961 | /* Establish BSSGP connection to the PCU */ |
| 2962 | f_bssgp_establish(); |
| 2963 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 2964 | |
| 2965 | /* Establish an Uplink TBF */ |
| 2966 | f_ms_establish_ul_tbf(ms); |
| 2967 | |
| 2968 | /* Send an Uplink block, so this TBF becomes "active" */ |
| 2969 | f_ms_tx_ul_data_block(ms, data, with_tlli := true); |
| 2970 | |
| 2971 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 2972 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, poll_fn); |
| 2973 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), poll_fn); |
| 2974 | |
| 2975 | /* SGSN sends some DL data, PCU will assign Downlink resource on PACCH */ |
| 2976 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 2977 | |
| 2978 | /* Expect an RLC/MAC block with Packet Downlink Assignment on PACCH (see 11.2.29) */ |
| 2979 | dl_block := f_ms_rx_pkt_ass_pacch(ms, poll_fn, tr_RLCMAC_DL_PACKET_ASS); |
| 2980 | var PacketDlAssignment da := dl_block.ctrl.payload.u.dl_assignment; |
| 2981 | |
| 2982 | /* This is an optional IE, so it's worth to check its presence */ |
| 2983 | if (not ispresent(da.freq_par)) { |
| 2984 | setverdict(fail, "Frequency Parameters IE is not present"); |
| 2985 | f_shutdown(__BFILE__, __LINE__); |
| 2986 | } |
| 2987 | |
| 2988 | f_TC_pcuif_fh_check_pkt_ass(valueof(info_ind), da.freq_par); |
| 2989 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2990 | } |
| 2991 | |
Vadim Yanitskiy | d53fb67 | 2020-10-09 16:41:02 +0700 | [diff] [blame] | 2992 | /* Check if the IUT handles subsequent INFO.ind messages */ |
| 2993 | testcase TC_pcuif_info_ind_subsequent() runs on RAW_PCU_Test_CT { |
| 2994 | var template PCUIF_info_ind info_ind := ts_PCUIF_INFO_default; |
| 2995 | var PCUIF_Message pcu_msg; |
| 2996 | |
| 2997 | /* Initialize the PCU interface abstraction */ |
| 2998 | f_init_raw(testcasename(), info_ind); |
| 2999 | |
| 3000 | /* Send 16 conseqtive INFO.ind messages and check that the IUT stays alive */ |
| 3001 | for (var integer i := 0; i < 16; i := i + 1) { |
| 3002 | BTS.send(ts_PCUIF_INFO_IND(0, info_ind)); |
| 3003 | f_pcuif_rx_data_req(pcu_msg); |
| 3004 | } |
| 3005 | |
| 3006 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 3007 | } |
| 3008 | |
Pau Espin Pedrol | bfd69f6 | 2020-10-22 18:06:07 +0200 | [diff] [blame] | 3009 | /* Verify allocation of several MS along PDCH ts of several TRX. See OS#1775, SYS#5030 */ |
| 3010 | testcase TC_multitrx_multims_alloc() runs on RAW_PCU_Test_CT { |
| 3011 | var PCUIF_info_ind info_ind; |
| 3012 | var integer i; |
| 3013 | const integer num_ms := 8; |
| 3014 | |
| 3015 | /* Initialize NS/BSSGP side */ |
| 3016 | f_init_bssgp(); |
| 3017 | /* Initialize GPRS MS side */ |
| 3018 | f_init_gprs_ms(num_ms); |
| 3019 | |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 3020 | info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | bfd69f6 | 2020-10-22 18:06:07 +0200 | [diff] [blame] | 3021 | /* Only the 3 first TRX are enabled. The enabled ones all have same |
| 3022 | amount of resources, hence same amount of initial resources. */ |
Vadim Yanitskiy | d5321fb | 2020-10-31 20:23:47 +0700 | [diff] [blame] | 3023 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000000'B, (3 .. 7)); |
| 3024 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000011'B, 0); |
| 3025 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00001100'B, 1); |
| 3026 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '11000000'B, 2); |
Pau Espin Pedrol | bfd69f6 | 2020-10-22 18:06:07 +0200 | [diff] [blame] | 3027 | |
| 3028 | /* Initialize the PCU interface abstraction */ |
| 3029 | f_init_raw(testcasename(), info_ind); |
| 3030 | |
| 3031 | /* Establish BSSGP connection to the PCU */ |
| 3032 | f_bssgp_establish(); |
Vadim Yanitskiy | 8a02b92 | 2020-10-31 21:57:10 +0700 | [diff] [blame] | 3033 | f_multi_ms_bssgp_register(); |
Pau Espin Pedrol | bfd69f6 | 2020-10-22 18:06:07 +0200 | [diff] [blame] | 3034 | |
Vadim Yanitskiy | 8a02b92 | 2020-10-31 21:57:10 +0700 | [diff] [blame] | 3035 | /* Establish an Uplink TBF for each GprsMS instance */ |
| 3036 | f_multi_ms_establish_tbf(do_activate := false); |
| 3037 | |
| 3038 | /* Check if all TBFs are allocated on different TRX in an uniform way */ |
Pau Espin Pedrol | bfd69f6 | 2020-10-22 18:06:07 +0200 | [diff] [blame] | 3039 | for (i := 0; i < num_ms; i := i + 1) { |
Pau Espin Pedrol | b20b7e5 | 2020-10-28 21:28:45 +0100 | [diff] [blame] | 3040 | if (g_ms[i].ul_tbf.arfcn != info_ind.trx.v10[i mod 3].arfcn) { |
| 3041 | setverdict(fail, "Got assigned ARFCN ", g_ms[i].ul_tbf.arfcn, |
| 3042 | " vs exp ", info_ind.trx.v10[i mod 3].arfcn); |
Pau Espin Pedrol | bfd69f6 | 2020-10-22 18:06:07 +0200 | [diff] [blame] | 3043 | f_shutdown(__BFILE__, __LINE__); |
| 3044 | } |
| 3045 | } |
| 3046 | |
| 3047 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 3048 | } |
| 3049 | |
Vadim Yanitskiy | dbd4b24 | 2020-10-31 05:44:58 +0700 | [diff] [blame] | 3050 | private function f_TC_paging_cs_multi_ms(template (value) TsTrxBtsNum nr, |
| 3051 | boolean exp_imsi, boolean exp_tmsi) |
| 3052 | runs on RAW_PCU_Test_CT { |
| 3053 | var bitstring mask := f_pad_bit(''B, lengthof(g_ms), '0'B); |
| 3054 | var integer pending := lengthof(g_ms); |
| 3055 | var RlcmacDlBlock dl_block; |
| 3056 | var boolean f1, f2; |
| 3057 | |
| 3058 | while (pending > 0) { |
| 3059 | var uint32_t poll_fn; |
| 3060 | |
| 3061 | /* Obtain a Downlink block and make sure it is a paging request */ |
| 3062 | f_rx_rlcmac_dl_block(dl_block, poll_fn, nr := nr); |
| 3063 | if (not match(dl_block, tr_RLCMAC_PACKET_PAG_REQ)) { |
| 3064 | setverdict(fail, "Rx unexpected DL block: ", dl_block); |
| 3065 | break; |
| 3066 | } |
| 3067 | |
| 3068 | /* This should not happen in general, but who knows... */ |
| 3069 | var PacketPagingReq req := dl_block.ctrl.payload.u.paging; |
| 3070 | if (not ispresent(req.repeated_pageinfo)) { |
| 3071 | setverdict(fail, "Repeated Page Info IE is absent?!?"); |
| 3072 | break; |
| 3073 | } |
| 3074 | |
| 3075 | /* A single message may contain several MIs depending on their type */ |
| 3076 | for (var integer i := 0; i < lengthof(g_ms); i := i + 1) { |
| 3077 | f1 := exp_imsi and f_pkt_paging_match_imsi(req, g_ms[i].imsi, |
| 3078 | ps_domain := false); |
| 3079 | f2 := exp_tmsi and f_pkt_paging_match_tmsi(req, oct2int(g_ms[i].tlli), |
| 3080 | ps_domain := false); |
| 3081 | if (not f1 and not f2) |
| 3082 | { continue; } |
| 3083 | |
| 3084 | /* Detect duplicate MIs */ |
| 3085 | if (mask[i] == '1'B) { |
| 3086 | setverdict(fail, "MS is paged twice: ", g_ms[i].imsi); |
| 3087 | continue; |
| 3088 | } |
| 3089 | |
| 3090 | mask[i] := '1'B; |
| 3091 | } |
| 3092 | |
| 3093 | pending := pending - lengthof(req.repeated_pageinfo); |
| 3094 | } |
| 3095 | |
| 3096 | for (var integer i := 0; i < lengthof(mask); i := i + 1) { |
| 3097 | if (mask[i] != '1'B) { |
| 3098 | setverdict(fail, "MS was not paged at all: ", g_ms[i].imsi); |
| 3099 | log("===== mask := ", mask); |
| 3100 | } |
| 3101 | } |
| 3102 | |
| 3103 | /* All messages must have been received by now, expect a dummy block */ |
| 3104 | f_rx_rlcmac_dl_block_exp_dummy(dl_block, nr := nr); |
| 3105 | } |
| 3106 | |
| 3107 | private function f_TC_paging_cs_multi_ms_init(BIT8 pdch_mask) |
| 3108 | runs on RAW_PCU_Test_CT { |
| 3109 | var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default); |
| 3110 | const BssgpBvci bvci := mp_gb_cfg.bvc[0].bvci; |
| 3111 | |
| 3112 | /* Initialize NS/BSSGP side */ |
| 3113 | f_init_bssgp(); |
| 3114 | |
| 3115 | /* Explicitly set the given PDCH slot-mask to all transceivers */ |
| 3116 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, pdch_mask); |
| 3117 | |
| 3118 | /* Allocate 56 GprsMS instances (maximum for 8 PDCH slots) */ |
| 3119 | f_init_gprs_ms(7 * 8); |
| 3120 | |
| 3121 | /* Initialize the PCU interface abstraction */ |
| 3122 | f_init_raw(testcasename(), info_ind); |
| 3123 | |
| 3124 | /* Establish BSSGP connection to the PCU */ |
| 3125 | f_bssgp_establish(); |
| 3126 | f_multi_ms_bssgp_register(); |
| 3127 | |
| 3128 | /* Establish an Uplink TBF for each GprsMS instance */ |
| 3129 | f_multi_ms_establish_tbf(do_activate := true); |
| 3130 | } |
| 3131 | |
| 3132 | testcase TC_paging_cs_multi_ms_imsi() runs on RAW_PCU_Test_CT { |
| 3133 | const BssgpBvci bvci := mp_gb_cfg.bvc[0].bvci; |
| 3134 | |
| 3135 | /* Common part: send INFO.ind, establish TBFs... */ |
| 3136 | f_TC_paging_cs_multi_ms_init(pdch_mask := '00000001'B); |
| 3137 | |
| 3138 | /* Enqueue multiple CS PAGING requests at a time (IMSI only) */ |
| 3139 | for (var integer i := 0; i < lengthof(g_ms); i := i + 1) { |
| 3140 | BSSGP[0].send(ts_BSSGP_CS_PAGING_IMSI(bvci, g_ms[i].imsi)); |
| 3141 | } |
| 3142 | |
| 3143 | /* FIXME: work around a race condition between PCUIF and BSSGP */ |
| 3144 | f_sleep(0.2); /* i.e. give the IUT some time to process everything */ |
| 3145 | |
| 3146 | /* Check what the IUT sends on PACCH, all GprsMS instances must be paged. |
| 3147 | * The IUT is expected to page on all PDCH slots of all transceivers. */ |
| 3148 | for (var integer trx_nr := 0; trx_nr < 8; trx_nr := trx_nr + 1) { |
| 3149 | var template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum(7, trx_nr); |
| 3150 | f_TC_paging_cs_multi_ms(nr, exp_imsi := true, exp_tmsi := false); |
| 3151 | } |
| 3152 | |
| 3153 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 3154 | } |
| 3155 | |
| 3156 | testcase TC_paging_cs_multi_ms_tmsi() runs on RAW_PCU_Test_CT { |
| 3157 | const BssgpBvci bvci := mp_gb_cfg.bvc[0].bvci; |
| 3158 | |
| 3159 | /* Common part: send INFO.ind, establish TBFs... */ |
| 3160 | f_TC_paging_cs_multi_ms_init(pdch_mask := '00000001'B); |
| 3161 | |
| 3162 | /* Enqueue multiple CS PAGING requests at a time (P-TMSI only) */ |
| 3163 | for (var integer i := 0; i < lengthof(g_ms); i := i + 1) { |
| 3164 | var GsmTmsi tmsi := oct2int(g_ms[i].tlli); /* P-TMSI == TLLI */ |
| 3165 | BSSGP[0].send(ts_BSSGP_CS_PAGING_PTMSI(bvci, g_ms[i].imsi, tmsi)); |
| 3166 | } |
| 3167 | |
| 3168 | /* FIXME: work around a race condition between PCUIF and BSSGP */ |
| 3169 | f_sleep(0.2); /* i.e. give the IUT some time to process everything */ |
| 3170 | |
| 3171 | /* Check what the IUT sends on PACCH, all GprsMS instances must be paged. |
| 3172 | * The IUT is expected to page on all PDCH slots of all transceivers. */ |
| 3173 | for (var integer trx_nr := 0; trx_nr < 8; trx_nr := trx_nr + 1) { |
| 3174 | var template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum(7, trx_nr); |
| 3175 | f_TC_paging_cs_multi_ms(nr, exp_imsi := false, exp_tmsi := true); |
| 3176 | } |
| 3177 | |
| 3178 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 3179 | } |
| 3180 | |
| 3181 | testcase TC_paging_cs_multi_ms_imsi_tmsi() runs on RAW_PCU_Test_CT { |
| 3182 | const BssgpBvci bvci := mp_gb_cfg.bvc[0].bvci; |
| 3183 | |
| 3184 | /* Common part: send INFO.ind, establish TBFs... */ |
| 3185 | f_TC_paging_cs_multi_ms_init(pdch_mask := '00000001'B); |
| 3186 | |
| 3187 | /* Enqueue multiple CS PAGING requests at a time (IMSI & P-TMSI) */ |
| 3188 | for (var integer i := 0; i < lengthof(g_ms); i := i + 1) { |
| 3189 | var GsmTmsi tmsi := oct2int(g_ms[i].tlli); /* P-TMSI == TLLI */ |
| 3190 | if (i mod 3 == 0) { /* One PDU fits: 1 IMSI and 2 P-TMSI MIs */ |
| 3191 | BSSGP[0].send(ts_BSSGP_CS_PAGING_PTMSI(bvci, g_ms[i].imsi, tmsi)); |
| 3192 | } else { |
| 3193 | BSSGP[0].send(ts_BSSGP_CS_PAGING_IMSI(bvci, g_ms[i].imsi)); |
| 3194 | } |
| 3195 | } |
| 3196 | |
| 3197 | /* FIXME: work around a race condition between PCUIF and BSSGP */ |
| 3198 | f_sleep(0.2); /* i.e. give the IUT some time to process everything */ |
| 3199 | |
| 3200 | /* Check what the IUT sends on PACCH, all GprsMS instances must be paged. |
| 3201 | * The IUT is expected to page on all PDCH slots of all transceivers. */ |
| 3202 | for (var integer trx_nr := 0; trx_nr < 8; trx_nr := trx_nr + 1) { |
| 3203 | var template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum(7, trx_nr); |
| 3204 | f_TC_paging_cs_multi_ms(nr, exp_imsi := true, exp_tmsi := true); |
| 3205 | } |
| 3206 | |
| 3207 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 3208 | } |
| 3209 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3210 | control { |
| 3211 | execute( TC_pcuif_suspend() ); |
| 3212 | execute( TC_ta_ptcch_idle() ); |
| 3213 | execute( TC_ta_rach_imm_ass() ); |
| 3214 | execute( TC_ta_idle_dl_tbf_ass() ); |
| 3215 | execute( TC_ta_ptcch_ul_multi_tbf() ); |
| 3216 | execute( TC_cs_lqual_ul_tbf() ); |
| 3217 | execute( TC_cs_initial_ul() ); |
| 3218 | execute( TC_cs_max_ul() ); |
Pau Espin Pedrol | 7512259 | 2020-11-03 15:22:59 +0100 | [diff] [blame] | 3219 | execute( TC_cs_initial_dl() ); |
Pau Espin Pedrol | 5d07ae6 | 2020-11-05 17:59:30 +0100 | [diff] [blame] | 3220 | execute( TC_cs_max_dl() ); |
| 3221 | execute( TC_dl_cs1_to_cs4() ); |
Pau Espin Pedrol | 2354d6a | 2020-11-05 18:36:59 +0100 | [diff] [blame] | 3222 | execute( TC_mcs_initial_ul() ); |
Pau Espin Pedrol | db15fa7 | 2020-11-11 12:58:34 +0100 | [diff] [blame] | 3223 | execute( TC_mcs_max_ul() ); |
Pau Espin Pedrol | e4fa45b | 2020-11-11 13:28:31 +0100 | [diff] [blame] | 3224 | execute( TC_mcs_initial_dl() ); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3225 | execute( TC_t3169() ); |
| 3226 | execute( TC_t3193() ); |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 3227 | execute( TC_countdown_procedure() ); |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 3228 | execute( TC_ul_all_sizes() ); |
Pau Espin Pedrol | 5e6844d | 2020-07-01 17:24:02 +0200 | [diff] [blame] | 3229 | execute( TC_ul_data_toolong_fills_padding() ); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3230 | execute( TC_mo_ping_pong() ); |
| 3231 | execute( TC_mo_ping_pong_with_ul_racap() ); |
Pau Espin Pedrol | 0c0bf87 | 2020-05-14 15:50:49 +0200 | [diff] [blame] | 3232 | execute( TC_force_two_phase_access() ); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3233 | execute( TC_mt_ping_pong() ); |
| 3234 | execute( TC_mt_ping_pong_with_dl_racap() ); |
Pau Espin Pedrol | e1195bb | 2020-07-07 13:27:18 +0200 | [diff] [blame] | 3235 | execute( TC_ul_intermediate_retrans() ); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3236 | execute( TC_imm_ass_dl_block_retrans() ); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 3237 | execute( TC_dl_flow_more_blocks() ); |
Pau Espin Pedrol | e1195bb | 2020-07-07 13:27:18 +0200 | [diff] [blame] | 3238 | execute( TC_ul_flow_multiple_llc_blocks() ); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3239 | execute( TC_paging_cs_from_bts() ); |
| 3240 | execute( TC_paging_cs_from_sgsn_sign_ptmsi() ); |
| 3241 | execute( TC_paging_cs_from_sgsn_sign() ); |
| 3242 | execute( TC_paging_cs_from_sgsn_ptp() ); |
| 3243 | execute( TC_paging_ps_from_sgsn_sign_ptmsi() ); |
| 3244 | execute( TC_paging_ps_from_sgsn_sign() ); |
| 3245 | execute( TC_paging_ps_from_sgsn_ptp() ); |
Vadim Yanitskiy | dbd4b24 | 2020-10-31 05:44:58 +0700 | [diff] [blame] | 3246 | execute( TC_paging_cs_multi_ms_imsi_tmsi() ); |
| 3247 | execute( TC_paging_cs_multi_ms_imsi() ); |
| 3248 | execute( TC_paging_cs_multi_ms_tmsi() ); |
Pau Espin Pedrol | c03eb12 | 2020-08-27 18:54:24 +0200 | [diff] [blame] | 3249 | execute( TC_bssgp_dl_unitdata_with_valid_imsi() ); |
| 3250 | execute( TC_bssgp_dl_unitdata_with_invalid_imsi() ); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3251 | |
| 3252 | /* EGPRS specific test cases */ |
| 3253 | execute( TC_egprs_pkt_chan_req_signalling() ); |
| 3254 | execute( TC_egprs_pkt_chan_req_one_phase() ); |
| 3255 | execute( TC_egprs_pkt_chan_req_two_phase() ); |
Vadim Yanitskiy | 4f56d32 | 2020-05-22 20:15:48 +0700 | [diff] [blame] | 3256 | execute( TC_egprs_pkt_chan_req_reject_content() ); |
Vadim Yanitskiy | 7e06c25 | 2020-05-22 20:48:53 +0700 | [diff] [blame] | 3257 | execute( TC_egprs_pkt_chan_req_reject_emergency() ); |
Vadim Yanitskiy | c4324ff | 2020-05-22 21:53:58 +0700 | [diff] [blame] | 3258 | execute( TC_egprs_pkt_chan_req_reject_exhaustion() ); |
Pau Espin Pedrol | 42acafc | 2020-05-14 15:18:38 +0200 | [diff] [blame] | 3259 | |
| 3260 | execute( TC_mo_ping_pong_with_ul_racap_egprs_only() ); |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 3261 | |
| 3262 | /* Frequency hopping specific test cases */ |
| 3263 | if (PCUIF_Types.mp_pcuif_version >= 10) { |
| 3264 | /* Immediate Assignment on AGCH/PCH */ |
| 3265 | execute( TC_pcuif_fh_imm_ass_ul_egprs() ); |
| 3266 | execute( TC_pcuif_fh_imm_ass_ul() ); |
| 3267 | execute( TC_pcuif_fh_imm_ass_dl() ); |
| 3268 | /* Packet Uplink/Downlink Assignment on PACCH */ |
| 3269 | execute( TC_pcuif_fh_pkt_ass_ul() ); |
| 3270 | execute( TC_pcuif_fh_pkt_ass_dl() ); |
Pau Espin Pedrol | bfd69f6 | 2020-10-22 18:06:07 +0200 | [diff] [blame] | 3271 | execute( TC_multitrx_multims_alloc() ); |
Pau Espin Pedrol | 0ea8b6f | 2020-10-29 20:48:43 +0100 | [diff] [blame] | 3272 | execute( TC_dl_multislot_tbf_ms_class_from_sgsn() ); |
Pau Espin Pedrol | 8155bf4 | 2020-10-29 17:34:26 +0100 | [diff] [blame] | 3273 | execute( TC_dl_multislot_tbf_ms_class_from_2phase() ); |
Pau Espin Pedrol | a9f27fa | 2020-10-30 13:16:21 +0100 | [diff] [blame] | 3274 | execute( TC_ul_multislot_tbf_ms_class_from_2phase() ); |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 3275 | } |
Vadim Yanitskiy | d53fb67 | 2020-10-09 16:41:02 +0700 | [diff] [blame] | 3276 | |
| 3277 | execute( TC_pcuif_info_ind_subsequent() ); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3278 | } |
| 3279 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 3280 | } |