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 */ |
Pau Espin Pedrol | 1b9aa78 | 2020-11-12 21:14:16 +0100 | [diff] [blame] | 871 | function f_dl_data_exp_cs(template CodingScheme exp_final_cs := ?, template MSRadioAccessCapabilityV_BSSGP ms_racap := omit) runs on RAW_PCU_Test_CT { |
| 872 | var octetstring data := f_rnd_octstring(1400); |
Pau Espin Pedrol | 5d07ae6 | 2020-11-05 17:59:30 +0100 | [diff] [blame] | 873 | var RlcmacDlBlock prev_dl_block, dl_block; |
| 874 | var uint32_t ack_fn; |
| 875 | var uint32_t fn; |
| 876 | var GprsMS ms; |
Pau Espin Pedrol | 1b9aa78 | 2020-11-12 21:14:16 +0100 | [diff] [blame] | 877 | var integer tx_data_remain := 10; |
Pau Espin Pedrol | 5d07ae6 | 2020-11-05 17:59:30 +0100 | [diff] [blame] | 878 | var integer bsn := 0; |
Pau Espin Pedrol | 1b9aa78 | 2020-11-12 21:14:16 +0100 | [diff] [blame] | 879 | var boolean using_egprs := f_rlcmac_cs_mcs_is_mcs(valueof(exp_final_cs)); |
| 880 | var integer bsn_mod; |
| 881 | var template CodingScheme exp_tmp_csmcs; |
| 882 | |
| 883 | if (using_egprs) { |
| 884 | exp_tmp_csmcs := mcs_egprs_any; |
| 885 | bsn_mod := 2048; |
| 886 | } else { |
| 887 | exp_tmp_csmcs := cs_gprs_any; |
| 888 | bsn_mod := 128; |
| 889 | } |
Pau Espin Pedrol | 5d07ae6 | 2020-11-05 17:59:30 +0100 | [diff] [blame] | 890 | |
| 891 | /* Establish BSSGP connection to the PCU */ |
| 892 | f_bssgp_establish(); |
| 893 | |
| 894 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 895 | f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli); |
| 896 | |
| 897 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
Pau Espin Pedrol | 1b9aa78 | 2020-11-12 21:14:16 +0100 | [diff] [blame] | 898 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, ms_racap)); |
Pau Espin Pedrol | 5d07ae6 | 2020-11-05 17:59:30 +0100 | [diff] [blame] | 899 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
| 900 | |
| 901 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS */ |
| 902 | f_sleep(X2002); |
| 903 | |
Pau Espin Pedrol | 1b9aa78 | 2020-11-12 21:14:16 +0100 | [diff] [blame] | 904 | for (var integer i := 0; i < 800; i := i + 1) { |
| 905 | bsn := i mod bsn_mod; |
Pau Espin Pedrol | 5d07ae6 | 2020-11-05 17:59:30 +0100 | [diff] [blame] | 906 | f_rx_rlcmac_dl_block(dl_block, fn); |
| 907 | |
| 908 | if (match(dl_block, tr_RLCMAC_DUMMY_CTRL)) { |
| 909 | /* No more data to receive, done */ |
| 910 | break; |
| 911 | } |
| 912 | |
Pau Espin Pedrol | 1b9aa78 | 2020-11-12 21:14:16 +0100 | [diff] [blame] | 913 | f_rlcmac_dl_block_exp_data(dl_block, ?, bsn, exp_tmp_csmcs); |
Pau Espin Pedrol | 5d07ae6 | 2020-11-05 17:59:30 +0100 | [diff] [blame] | 914 | |
| 915 | /* Keep Ack/Nack description updated */ |
Pau Espin Pedrol | 1b9aa78 | 2020-11-12 21:14:16 +0100 | [diff] [blame] | 916 | f_dltbf_ack_block(ms.dl_tbf, dl_block); |
Pau Espin Pedrol | 5d07ae6 | 2020-11-05 17:59:30 +0100 | [diff] [blame] | 917 | |
| 918 | /* TDMA frame number on which we are supposed to send the ACK */ |
Pau Espin Pedrol | 1b9aa78 | 2020-11-12 21:14:16 +0100 | [diff] [blame] | 919 | if (f_dl_block_rrbp_valid(dl_block)) { |
Pau Espin Pedrol | 5d07ae6 | 2020-11-05 17:59:30 +0100 | [diff] [blame] | 920 | ack_fn := f_dl_block_ack_fn(dl_block, fn); |
Pau Espin Pedrol | 1b9aa78 | 2020-11-12 21:14:16 +0100 | [diff] [blame] | 921 | f_ms_tx_ul_block(ms, f_dltbf_ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf, using_egprs), ack_fn); |
Pau Espin Pedrol | 5d07ae6 | 2020-11-05 17:59:30 +0100 | [diff] [blame] | 922 | if (tx_data_remain != 0) { |
| 923 | /* Submit more data from time to time to keep the TBF ongoing */ |
| 924 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 925 | tx_data_remain := tx_data_remain - 1; |
| 926 | } |
| 927 | } |
| 928 | prev_dl_block := dl_block; |
| 929 | } |
| 930 | |
Pau Espin Pedrol | 1b9aa78 | 2020-11-12 21:14:16 +0100 | [diff] [blame] | 931 | bsn := (bsn + (bsn_mod-1)) mod bsn_mod; /* previous bsn: bsn -1 */ |
| 932 | f_rlcmac_dl_block_exp_data(prev_dl_block, ?, bsn, exp_final_cs); |
Pau Espin Pedrol | 5d07ae6 | 2020-11-05 17:59:30 +0100 | [diff] [blame] | 933 | |
| 934 | |
| 935 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 936 | } |
| 937 | |
| 938 | /* Verify DL CS above "cs max" set by VTY is never used */ |
| 939 | testcase TC_cs_max_dl() runs on RAW_PCU_Test_CT { |
| 940 | /* Initialize NS/BSSGP side */ |
| 941 | f_init_bssgp(); |
| 942 | /* Initialize GPRS MS side */ |
| 943 | f_init_gprs_ms(); |
| 944 | |
| 945 | /* Initialize the PCU interface abstraction */ |
| 946 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
| 947 | |
| 948 | /* Set maximum allowed DL CS to 3 */ |
| 949 | g_cs_initial_dl := 1; |
| 950 | g_cs_max_dl := 3; |
| 951 | f_pcuvty_set_allowed_cs_mcs(); |
| 952 | f_pcuvty_set_link_quality_ranges(); |
| 953 | |
| 954 | f_dl_data_exp_cs(f_rlcmac_block_int2cs_mcs(g_cs_max_dl, false)); |
| 955 | } |
| 956 | |
| 957 | /* Check DL CS4 is used in good link conditions if allowed by config */ |
| 958 | testcase TC_dl_cs1_to_cs4() runs on RAW_PCU_Test_CT { |
| 959 | /* Initialize NS/BSSGP side */ |
| 960 | f_init_bssgp(); |
| 961 | /* Initialize GPRS MS side */ |
| 962 | f_init_gprs_ms(); |
| 963 | |
| 964 | /* Initialize the PCU interface abstraction */ |
| 965 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
| 966 | |
| 967 | /* Set initial DL CS to 1 & maximum allowed DL CS to 4 */ |
| 968 | g_cs_initial_dl := 1; |
| 969 | g_cs_max_dl := 4; |
| 970 | f_pcuvty_set_allowed_cs_mcs(); |
| 971 | f_pcuvty_set_link_quality_ranges(); |
| 972 | |
| 973 | f_dl_data_exp_cs(f_rlcmac_block_int2cs_mcs(g_cs_max_dl, false)); |
| 974 | } |
| 975 | |
Pau Espin Pedrol | 2354d6a | 2020-11-05 18:36:59 +0100 | [diff] [blame] | 976 | /* Test the initial UL MCS set by VTY works fine */ |
| 977 | testcase TC_mcs_initial_ul() runs on RAW_PCU_Test_CT { |
| 978 | var RlcmacDlBlock dl_block; |
| 979 | var PollFnCtx pollctx; |
| 980 | var EgprsChCodingCommand last_ch_coding; |
| 981 | var uint32_t unused_fn, sched_fn; |
| 982 | var GprsMS ms; |
| 983 | var CodingScheme exp_ul_mcs; |
| 984 | var MultislotCap_GPRS mscap_gprs := { |
| 985 | gprsmultislotclass := '00011'B, |
| 986 | gprsextendeddynalloccap := '0'B |
| 987 | }; |
| 988 | var MultislotCap_EGPRS mscap_egprs := { |
| 989 | egprsmultislotclass := '00011'B, |
| 990 | egprsextendeddynalloccap := '0'B |
| 991 | }; |
| 992 | var MSRadioAccessCapabilityV ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, mscap_egprs)) }; |
| 993 | |
| 994 | /* Initialize GPRS MS side */ |
| 995 | f_init_gprs_ms(); |
| 996 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 997 | |
| 998 | /* Initialize the PCU interface abstraction */ |
| 999 | f_init_raw(testcasename()); |
| 1000 | |
| 1001 | /* Set initial UL MCS to 3 */ |
| 1002 | g_mcs_initial_ul := 3; |
| 1003 | exp_ul_mcs := f_rlcmac_block_int2cs_mcs(g_mcs_initial_ul, true); |
| 1004 | f_pcuvty_set_allowed_cs_mcs(); |
| 1005 | f_pcuvty_set_link_quality_ranges(); |
| 1006 | |
| 1007 | /* Take lqual (dB->cB) so that we stay in that MCS */ |
| 1008 | ms.lqual_cb := g_mcs_lqual_ranges[2].low * 10; |
| 1009 | |
| 1010 | /* Send PACKET RESOURCE REQUEST to upgrade to EGPRS */ |
| 1011 | pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap)); |
| 1012 | |
| 1013 | if (not match(ms.ul_tbf.tx_cs_mcs, exp_ul_mcs)) { |
| 1014 | setverdict(fail, "Wrong CS_MCS ", ms.ul_tbf.tx_cs_mcs, " received vs exp ", exp_ul_mcs); |
| 1015 | f_shutdown(__BFILE__, __LINE__); |
| 1016 | } |
| 1017 | |
| 1018 | /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 1019 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts); |
| 1020 | |
| 1021 | /* Send UL blocks, until we receive UL ACK/NACK and check we are in same initial CS: */ |
| 1022 | while (true) { |
| 1023 | f_ms_tx_ul_data_block(ms, f_rnd_octstring(10), cv := 15); |
| 1024 | f_rx_rlcmac_dl_block(dl_block, unused_fn); |
| 1025 | if (match(dl_block, tr_RLCMAC_DUMMY_CTRL())) { |
| 1026 | continue; |
| 1027 | } |
| 1028 | |
| 1029 | if (not match(dl_block, tr_RLCMAC_UL_ACK_NACK_EGPRS(ul_tfi := ?))) { |
| 1030 | setverdict(fail, "Failed to match Packet Uplink ACK / NACK:", dl_block); |
| 1031 | f_shutdown(__BFILE__, __LINE__); |
| 1032 | break; |
| 1033 | } |
| 1034 | |
| 1035 | last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.egprs.ch_coding_cmd; |
| 1036 | break; |
| 1037 | } |
| 1038 | if (f_rlcmac_block_EgprsChCodingCommand2cs_mcs(last_ch_coding) != exp_ul_mcs) { |
| 1039 | setverdict(fail, "Channel Coding does not match our expectations ", exp_ul_mcs, ": ", last_ch_coding); |
| 1040 | f_shutdown(__BFILE__, __LINE__); |
| 1041 | } |
| 1042 | |
| 1043 | /* Remaining UL blocks are used to make sure regardless of initial |
| 1044 | * lqual, we can go lower at any time |
| 1045 | * 0 dB, make sure we downgrade MCS */ |
| 1046 | ms.lqual_cb := 0; |
| 1047 | /* 5 UL blocks, check we are in same initial MCS: */ |
| 1048 | f_ms_tx_ul_data_block_multi(ms, 5); |
| 1049 | /* Enqueue RTS.req, expect DATA.req with UL ACK from the PCU */ |
| 1050 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, unused_fn); |
| 1051 | last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.egprs.ch_coding_cmd; |
| 1052 | |
| 1053 | if (last_ch_coding != CH_CODING_MCS1) { |
| 1054 | setverdict(fail, "Channel Coding does not match our expectations (MCS-1): ", last_ch_coding); |
| 1055 | f_shutdown(__BFILE__, __LINE__); |
| 1056 | } |
| 1057 | |
| 1058 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 1059 | } |
| 1060 | |
Pau Espin Pedrol | db15fa7 | 2020-11-11 12:58:34 +0100 | [diff] [blame] | 1061 | /* Test the maximum UL MCS set by VTY works fine */ |
| 1062 | testcase TC_mcs_max_ul() runs on RAW_PCU_Test_CT { |
| 1063 | var RlcmacDlBlock dl_block; |
| 1064 | var EgprsChCodingCommand last_ch_coding; |
| 1065 | var PollFnCtx pollctx; |
| 1066 | var uint32_t unused_fn, sched_fn; |
| 1067 | var GprsMS ms; |
| 1068 | var MultislotCap_GPRS mscap_gprs := { |
| 1069 | gprsmultislotclass := '00011'B, |
| 1070 | gprsextendeddynalloccap := '0'B |
| 1071 | }; |
| 1072 | var MultislotCap_EGPRS mscap_egprs := { |
| 1073 | egprsmultislotclass := '00011'B, |
| 1074 | egprsextendeddynalloccap := '0'B |
| 1075 | }; |
| 1076 | var MSRadioAccessCapabilityV ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, mscap_egprs)) }; |
| 1077 | |
| 1078 | |
| 1079 | /* Initialize GPRS MS side */ |
| 1080 | f_init_gprs_ms(); |
| 1081 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 1082 | |
| 1083 | /* Initialize the PCU interface abstraction */ |
| 1084 | f_init_raw(testcasename()); |
| 1085 | |
| 1086 | /* Set maximum allowed UL MCS to 5 */ |
| 1087 | g_mcs_max_ul := 5; |
| 1088 | f_pcuvty_set_allowed_cs_mcs(); |
| 1089 | f_pcuvty_set_link_quality_ranges(); |
| 1090 | |
| 1091 | /* Send PACKET RESOURCE REQUEST to upgrade to EGPRS */ |
| 1092 | pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap)); |
| 1093 | /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 1094 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts); |
| 1095 | |
| 1096 | ms.lqual_cb := 40*10; /* 40 dB */ |
| 1097 | f_ms_tx_ul_data_block_multi(ms, 16); |
| 1098 | |
| 1099 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, unused_fn); |
| 1100 | last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.egprs.ch_coding_cmd; |
| 1101 | |
| 1102 | if (last_ch_coding != CH_CODING_MCS5) { |
| 1103 | setverdict(fail, "Channel Coding does not match our expectations (MCS-5): ", last_ch_coding); |
| 1104 | f_shutdown(__BFILE__, __LINE__); |
| 1105 | } |
| 1106 | |
| 1107 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 1108 | } |
| 1109 | |
Pau Espin Pedrol | e4fa45b | 2020-11-11 13:28:31 +0100 | [diff] [blame] | 1110 | /* Test the initial DL CS set by VTY works fine */ |
| 1111 | testcase TC_mcs_initial_dl() runs on RAW_PCU_Test_CT { |
| 1112 | var octetstring data := f_rnd_octstring(10); |
| 1113 | var CodingScheme exp_dl_cs_mcs; |
| 1114 | var RlcmacDlBlock dl_block; |
| 1115 | var uint32_t poll_fn; |
| 1116 | var GprsMS ms; |
| 1117 | var MultislotCap_GPRS_BSSGP mscap_gprs := { |
| 1118 | gprsmultislotclass := '00011'B, |
| 1119 | gprsextendeddynalloccap := '0'B |
| 1120 | }; |
| 1121 | var MultislotCap_EGPRS_BSSGP mscap_egprs := { |
| 1122 | egprsmultislotclass := '00011'B, |
| 1123 | egprsextendeddynalloccap := '0'B |
| 1124 | }; |
| 1125 | var MSRadioAccessCapabilityV_BSSGP ms_racap := { valueof(ts_RaCapRec_BSSGP('0001'B /* E-GSM */, mscap_gprs, mscap_egprs)) }; |
| 1126 | |
| 1127 | /* Initialize NS/BSSGP side */ |
| 1128 | f_init_bssgp(); |
| 1129 | /* Initialize GPRS MS side */ |
| 1130 | f_init_gprs_ms(); |
| 1131 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 1132 | |
| 1133 | /* Initialize the PCU interface abstraction */ |
| 1134 | f_init_raw(testcasename()); |
| 1135 | |
| 1136 | /* Set initial allowed DL MCS to 3 */ |
| 1137 | g_mcs_initial_dl := 3; |
| 1138 | exp_dl_cs_mcs := MCS_3; |
| 1139 | /* Set maximum allowed DL MCS to 4 */ |
| 1140 | g_mcs_max_dl := 4; |
| 1141 | f_pcuvty_set_allowed_cs_mcs(); |
| 1142 | f_pcuvty_set_link_quality_ranges(); |
| 1143 | |
| 1144 | /* Establish BSSGP connection to the PCU */ |
| 1145 | f_bssgp_establish(); |
| 1146 | f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli); |
| 1147 | |
| 1148 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
| 1149 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, ms_racap)); |
| 1150 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
| 1151 | |
| 1152 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 1153 | f_sleep(X2002); |
| 1154 | f_rx_rlcmac_dl_block_exp_data(dl_block, poll_fn, data, 0, exp_dl_cs_mcs); |
| 1155 | |
| 1156 | /* ACK the DL block */ |
Pau Espin Pedrol | e8db673 | 2020-11-12 21:06:41 +0100 | [diff] [blame] | 1157 | f_dltbf_ack_block(ms.dl_tbf, dl_block, '1'B); |
| 1158 | 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] | 1159 | f_dl_block_ack_fn(dl_block, poll_fn)); |
| 1160 | |
| 1161 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 1162 | } |
| 1163 | |
Pau Espin Pedrol | 1b9aa78 | 2020-11-12 21:14:16 +0100 | [diff] [blame] | 1164 | /* Verify DL MCS above "mcs max" set by VTY is never used */ |
| 1165 | testcase TC_mcs_max_dl() runs on RAW_PCU_Test_CT { |
| 1166 | /* Initialize NS/BSSGP side */ |
| 1167 | f_init_bssgp(); |
| 1168 | /* Initialize GPRS MS side */ |
| 1169 | f_init_gprs_ms(); |
| 1170 | |
| 1171 | /* Initialize the PCU interface abstraction */ |
| 1172 | f_init_raw(testcasename()); |
| 1173 | |
| 1174 | /* Set maximum allowed DL CS to 3 */ |
| 1175 | g_mcs_initial_dl := 1; |
| 1176 | g_mcs_max_dl := 3; |
| 1177 | f_pcuvty_set_allowed_cs_mcs(); |
| 1178 | f_pcuvty_set_link_quality_ranges(); |
| 1179 | |
| 1180 | var MultislotCap_GPRS_BSSGP mscap_gprs := { |
| 1181 | gprsmultislotclass := '00011'B, |
| 1182 | gprsextendeddynalloccap := '0'B |
| 1183 | }; |
| 1184 | var MultislotCap_EGPRS_BSSGP mscap_egprs := { |
| 1185 | egprsmultislotclass := '00011'B, |
| 1186 | egprsextendeddynalloccap := '0'B |
| 1187 | }; |
| 1188 | var MSRadioAccessCapabilityV_BSSGP ms_racap := { valueof(ts_RaCapRec_BSSGP('0001'B /* E-GSM */, mscap_gprs, mscap_egprs)) }; |
| 1189 | |
| 1190 | f_dl_data_exp_cs(f_rlcmac_block_int2cs_mcs(g_mcs_max_dl, true), ms_racap); |
| 1191 | } |
| 1192 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1193 | /* Verify PCU drops TBF after some time of inactivity. */ |
| 1194 | testcase TC_t3169() runs on RAW_PCU_Test_CT { |
| 1195 | var PCUIF_info_ind info_ind; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1196 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1197 | var uint32_t unused_fn; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1198 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1199 | |
| 1200 | /* Initialize NS/BSSGP side */ |
| 1201 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1202 | /* Initialize GPRS MS side */ |
| 1203 | f_init_gprs_ms(); |
| 1204 | 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] | 1205 | |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1206 | info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1207 | /* Set timer to 1 sec (default 5) to speedup test: */ |
| 1208 | info_ind.t3169 := 1; |
| 1209 | |
| 1210 | /* Initialize the PCU interface abstraction */ |
| 1211 | f_init_raw(testcasename(), info_ind); |
| 1212 | |
| 1213 | /* Establish BSSGP connection to the PCU */ |
| 1214 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1215 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1216 | |
| 1217 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1218 | f_ms_establish_ul_tbf(ms); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1219 | |
Pau Espin Pedrol | 4aac3d0 | 2020-05-13 15:13:49 +0200 | [diff] [blame] | 1220 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 1221 | contention resoultion) and make sure it is ACKED fine */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1222 | 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] | 1223 | 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] | 1224 | /* 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] | 1225 | |
| 1226 | /* Wait until T3169 fires (plus 1 extra sec to make sure) */ |
| 1227 | f_sleep(int2float(info_ind.t3169) + 1.0); |
| 1228 | |
| 1229 | /* 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] | 1230 | 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] | 1231 | f_rx_rlcmac_dl_block_exp_dummy(dl_block); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 1232 | |
| 1233 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1234 | } |
| 1235 | |
| 1236 | /* Verify that a Downlink TBF can be assigned using PACCH shortly after the |
| 1237 | * release of prev DL TBF due to MS staying in PDCH for a while (T3192, in PCU |
| 1238 | * T3193) after DL TBF release */ |
| 1239 | testcase TC_t3193() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1240 | var RlcmacDlBlock dl_block; |
| 1241 | var octetstring data := f_rnd_octstring(10); |
| 1242 | var boolean ok; |
| 1243 | var uint32_t sched_fn; |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1244 | var uint32_t dl_fn; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1245 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1246 | var AckNackDescription ack_nack_desc := valueof(t_AckNackDescription_init); |
| 1247 | |
| 1248 | /* Initialize NS/BSSGP side */ |
| 1249 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1250 | /* Initialize GPRS MS side */ |
| 1251 | f_init_gprs_ms(); |
| 1252 | 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] | 1253 | |
| 1254 | /* Initialize the PCU interface abstraction */ |
| 1255 | f_init_raw(testcasename()); |
| 1256 | |
| 1257 | /* Establish BSSGP connection to the PCU */ |
| 1258 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1259 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1260 | |
| 1261 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1262 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 1263 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
Vadim Yanitskiy | 2e213ae | 2020-05-06 22:26:17 +0700 | [diff] [blame] | 1264 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1265 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 1266 | f_sleep(X2002); |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1267 | 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] | 1268 | |
| 1269 | /* ACK the DL block */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1270 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B); |
| 1271 | f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc), |
| 1272 | f_dl_block_ack_fn(dl_block, dl_fn)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1273 | |
| 1274 | /* 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] | 1275 | (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] | 1276 | 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] | 1277 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
Vadim Yanitskiy | 7431e9e | 2020-07-21 01:59:17 +0700 | [diff] [blame] | 1278 | 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] | 1279 | |
| 1280 | 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] | 1281 | |
| 1282 | /* 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] | 1283 | 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] | 1284 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B); |
| 1285 | f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc), |
| 1286 | f_dl_block_ack_fn(dl_block, dl_fn)); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 1287 | |
| 1288 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1289 | } |
| 1290 | |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1291 | /* Verify PCU handles correctly Countdown Procedure based on BS_CV_MAX */ |
| 1292 | testcase TC_countdown_procedure() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1293 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1294 | var uint32_t sched_fn; |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1295 | var octetstring total_payload; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1296 | var GprsMS ms; |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1297 | |
| 1298 | /* Initialize NS/BSSGP side */ |
| 1299 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1300 | /* Initialize GPRS MS side */ |
| 1301 | f_init_gprs_ms(); |
| 1302 | 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] | 1303 | |
| 1304 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1305 | 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] | 1306 | |
| 1307 | /* Establish BSSGP connection to the PCU */ |
| 1308 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1309 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1310 | |
| 1311 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1312 | f_ms_establish_ul_tbf(ms); |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1313 | |
| 1314 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 1315 | contention resoultion) and make sure it is ACKED fine. */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1316 | 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] | 1317 | /* Set CV = 15 to signal there's still more than BS_CV_MAX blocks to be sent */ |
| 1318 | 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] | 1319 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1320 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1321 | 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] | 1322 | |
| 1323 | /* Send enough blocks to test whole procedure: Until Nth block |
| 1324 | (N=BS_CV_MAX), CV=15 is sent, and then the decreasing countdown value is sent. |
| 1325 | */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1326 | 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] | 1327 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1328 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1329 | 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] | 1330 | |
| 1331 | /* receive one message on BSSGP with all aggregated data in payload: */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1332 | 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] | 1333 | |
| 1334 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 1335 | } |
| 1336 | |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1337 | /* Verify PCU handles correctly CS1..4 with all possible LLC payload sizes fitting alone in one RLC block */ |
| 1338 | testcase TC_ul_all_sizes() runs on RAW_PCU_Test_CT { |
| 1339 | var RlcmacDlBlock dl_block; |
| 1340 | var uint32_t dl_fn, sched_fn; |
| 1341 | var octetstring payload; |
| 1342 | var template (value) RlcmacUlBlock ul_data; |
Vadim Yanitskiy | ceb1f98 | 2020-10-17 15:58:19 +0700 | [diff] [blame] | 1343 | var template (value) LlcBlockHdr blk_hdr; |
| 1344 | var template (value) LlcBlocks blocks; |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1345 | var integer blk_len; |
| 1346 | var CodingScheme tx_cs; |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1347 | var GprsMS ms; |
| 1348 | |
| 1349 | /* Initialize NS/BSSGP side */ |
| 1350 | f_init_bssgp(); |
| 1351 | /* Initialize GPRS MS side */ |
| 1352 | f_init_gprs_ms(); |
| 1353 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 1354 | |
| 1355 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1356 | 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] | 1357 | |
| 1358 | /* Establish BSSGP connection to the PCU */ |
| 1359 | f_bssgp_establish(); |
| 1360 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 1361 | |
| 1362 | /* Establish an Uplink TBF */ |
| 1363 | f_ms_establish_ul_tbf(ms); |
| 1364 | |
| 1365 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 1366 | contention resoultion) and make sure it is ACKED fine. */ |
| 1367 | 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] | 1368 | blk_hdr := t_RLCMAC_LLCBLOCK_HDR(length_ind := lengthof(payload), |
| 1369 | more := false, e := true); |
| 1370 | blocks := { t_RLCMAC_LLCBLOCK(payload, blk_hdr) }; |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1371 | /* 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] | 1372 | ul_data := t_RLCMAC_UL_DATA_TLLI(cs := ms.ul_tbf.tx_cs_mcs, |
| 1373 | tfi := ms.ul_tbf.tfi, |
Vadim Yanitskiy | ceb1f98 | 2020-10-17 15:58:19 +0700 | [diff] [blame] | 1374 | cv := 15, |
| 1375 | bsn := ms.ul_tbf.bsn, |
| 1376 | blocks := blocks, |
| 1377 | tlli := ms.tlli); |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1378 | f_ultbf_inc_bsn(ms.ul_tbf); |
| 1379 | f_ms_tx_ul_block(ms, ul_data); |
| 1380 | |
| 1381 | /* ACK and check it was received fine */ |
| 1382 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1383 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 1384 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
| 1385 | /* receive one message on BSSGP with all aggregated data in payload: */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1386 | 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] | 1387 | |
| 1388 | /* Test sending LLC PDUS of incrementing size */ |
| 1389 | var integer max_size := 49; |
| 1390 | for (var integer i := 1; i <= max_size; i := i + 1) { |
| 1391 | var integer cv; |
| 1392 | /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */ |
| 1393 | log("Sending DATA.ind with LLC payload size ", i); |
| 1394 | if (i < max_size - g_bs_cv_max) { |
| 1395 | cv := 15; |
| 1396 | } else { |
| 1397 | cv := max_size - i; |
| 1398 | } |
| 1399 | |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1400 | blk_len := 3 + 1 + i; /* 3 Header bytes + LI byte + payload length */ |
| 1401 | 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] | 1402 | payload := f_rnd_octstring(i); |
Vadim Yanitskiy | ceb1f98 | 2020-10-17 15:58:19 +0700 | [diff] [blame] | 1403 | blk_hdr := t_RLCMAC_LLCBLOCK_HDR(length_ind := lengthof(payload), |
| 1404 | more := false, e := true); |
| 1405 | blocks := { t_RLCMAC_LLCBLOCK(payload, blk_hdr) }; |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1406 | /* 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] | 1407 | ul_data := t_RLCMAC_UL_DATA(cs := tx_cs, |
| 1408 | tfi := ms.ul_tbf.tfi, |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1409 | cv := cv, |
| 1410 | bsn := ms.ul_tbf.bsn, |
Vadim Yanitskiy | ceb1f98 | 2020-10-17 15:58:19 +0700 | [diff] [blame] | 1411 | blocks := blocks); |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1412 | f_ultbf_inc_bsn(ms.ul_tbf); |
| 1413 | f_ms_tx_ul_block(ms, ul_data); |
| 1414 | |
| 1415 | /* receive one message on BSSGP with all aggregated data in payload: */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1416 | 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] | 1417 | |
| 1418 | /* we will receive UL ACK/NACK from time to time, handle it. */ |
| 1419 | f_rx_rlcmac_dl_block(dl_block, dl_fn); |
| 1420 | if (match(dl_block, tr_RLCMAC_DUMMY_CTRL())) { |
| 1421 | continue; |
| 1422 | } |
| 1423 | if (not match(dl_block, tr_RLCMAC_UL_ACK_NACK_GPRS(ul_tfi := ?)) and |
| 1424 | not match(dl_block, tr_RLCMAC_UL_ACK_NACK_EGPRS(ul_tfi := ?))) { |
| 1425 | setverdict(fail, "Failed to match Packet Uplink ACK / NACK:", dl_block); |
| 1426 | f_shutdown(__BFILE__, __LINE__); |
| 1427 | } |
| 1428 | |
| 1429 | log("Rx Packet Uplink ACK / NACK"); |
| 1430 | sched_fn := f_rrbp_ack_fn(dl_fn, dl_block.ctrl.mac_hdr.rrbp); |
| 1431 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 1432 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
| 1433 | } |
Vadim Yanitskiy | 8e6df0c | 2020-10-18 00:13:15 +0700 | [diff] [blame] | 1434 | |
| 1435 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 1436 | } |
| 1437 | |
Pau Espin Pedrol | 5e6844d | 2020-07-01 17:24:02 +0200 | [diff] [blame] | 1438 | function f_TC_ul_data_toolong_fills_padding_cs(inout GprsMS ms, CodingScheme cs, integer cv) runs on RAW_PCU_Test_CT { |
| 1439 | var octetstring payload; |
| 1440 | var template (value) RlcmacUlBlock ul_data; |
Vadim Yanitskiy | ceb1f98 | 2020-10-17 15:58:19 +0700 | [diff] [blame] | 1441 | var template (value) LlcBlockHdr blk_hdr; |
| 1442 | var template (value) LlcBlocks blocks; |
Pau Espin Pedrol | 5e6844d | 2020-07-01 17:24:02 +0200 | [diff] [blame] | 1443 | var integer block_len, max_valid_data_len; |
| 1444 | timer T; |
| 1445 | |
| 1446 | block_len := f_rlcmac_cs_mcs2block_len(cs); |
| 1447 | /* We need to send with TLLI since we are in One-Phase Access Contenion |
| 1448 | * resoultion), so that's -4 bytes of data, -3 for headers, -1 for LI |
| 1449 | * indicator, -1 for spare bits octet at the end */ |
| 1450 | max_valid_data_len := block_len - 4 - 3 - 1 - 1; |
| 1451 | 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] | 1452 | blk_hdr := t_RLCMAC_LLCBLOCK_HDR(length_ind := lengthof(payload), |
| 1453 | more := false, e := true); |
| 1454 | blocks := { t_RLCMAC_LLCBLOCK(payload, blk_hdr) }; |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1455 | ul_data := t_RLCMAC_UL_DATA_TLLI(cs := cs, |
| 1456 | tfi := ms.ul_tbf.tfi, |
Vadim Yanitskiy | ceb1f98 | 2020-10-17 15:58:19 +0700 | [diff] [blame] | 1457 | cv := cv, |
| 1458 | bsn := ms.ul_tbf.bsn, |
| 1459 | blocks := blocks, |
| 1460 | tlli := ms.tlli); |
Pau Espin Pedrol | 5e6844d | 2020-07-01 17:24:02 +0200 | [diff] [blame] | 1461 | f_ultbf_inc_bsn(ms.ul_tbf); |
| 1462 | f_ms_tx_data_ind(ms, enc_RlcmacUlBlock(valueof(ul_data))); |
| 1463 | |
| 1464 | T.start(0.5); |
| 1465 | alt { |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1466 | [] 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] | 1467 | setverdict(fail, "LLC PDU in Malformed RLC block was forwarded"); |
| 1468 | f_shutdown(__BFILE__, __LINE__); |
| 1469 | } |
| 1470 | [] T.timeout { |
| 1471 | setverdict(pass); |
| 1472 | } |
| 1473 | } |
| 1474 | } |
| 1475 | /* Verify PCU finds out incorrectly formated RLC block and discards it. This |
| 1476 | blocks intentionally contain last byte of data placed in last byte of RLC |
| 1477 | containing padding/spare bits, which is incorrect. Spare bits exist and are |
| 1478 | described for CS2..4 in 3GPP TS 44.060 Table 10.2.1: "RLC data block size, |
| 1479 | discounting padding in octet" */ |
| 1480 | testcase TC_ul_data_toolong_fills_padding() runs on RAW_PCU_Test_CT { |
| 1481 | var GprsMS ms; |
| 1482 | var integer block_len, max_valid_data_len; |
| 1483 | |
| 1484 | /* Initialize NS/BSSGP side */ |
| 1485 | f_init_bssgp(); |
| 1486 | /* Initialize GPRS MS side */ |
| 1487 | f_init_gprs_ms(); |
| 1488 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 1489 | |
| 1490 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1491 | 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] | 1492 | |
| 1493 | /* Establish BSSGP connection to the PCU */ |
| 1494 | f_bssgp_establish(); |
| 1495 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 1496 | |
| 1497 | /* Establish an Uplink TBF */ |
| 1498 | f_ms_establish_ul_tbf(ms); |
| 1499 | |
| 1500 | f_TC_ul_data_toolong_fills_padding_cs(ms, CS_2, 2); |
| 1501 | f_TC_ul_data_toolong_fills_padding_cs(ms, CS_3, 1); |
| 1502 | f_TC_ul_data_toolong_fills_padding_cs(ms, CS_4, 0); |
| 1503 | |
Vadim Yanitskiy | 8e6df0c | 2020-10-18 00:13:15 +0700 | [diff] [blame] | 1504 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 5e6844d | 2020-07-01 17:24:02 +0200 | [diff] [blame] | 1505 | } |
| 1506 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1507 | /* Test scenario where MS wants to send some data on PDCH against SGSN and it is |
| 1508 | * answered, so TBFs for uplink and later for downlink are created. |
| 1509 | */ |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1510 | 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] | 1511 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1512 | var octetstring data := f_rnd_octstring(10); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1513 | var uint32_t sched_fn; |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1514 | var uint32_t dl_fn; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1515 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1516 | |
| 1517 | /* Initialize NS/BSSGP side */ |
| 1518 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1519 | /* Initialize GPRS MS side */ |
| 1520 | f_init_gprs_ms(); |
| 1521 | 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] | 1522 | |
| 1523 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1524 | 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] | 1525 | |
| 1526 | /* Establish BSSGP connection to the PCU */ |
| 1527 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1528 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1529 | |
| 1530 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1531 | f_ms_establish_ul_tbf(ms); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1532 | |
Pau Espin Pedrol | 4aac3d0 | 2020-05-13 15:13:49 +0200 | [diff] [blame] | 1533 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 1534 | contention resoultion) and make sure it is ACKED fine */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1535 | 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] | 1536 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1537 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1538 | 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] | 1539 | |
| 1540 | /* UL block should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1541 | 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] | 1542 | |
| 1543 | /* 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] | 1544 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 1545 | 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] | 1546 | |
| 1547 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 1548 | f_sleep(X2002); |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1549 | 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] | 1550 | |
| 1551 | /* ACK the DL block */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1552 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B); |
| 1553 | f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc), |
| 1554 | f_dl_block_ack_fn(dl_block, dl_fn)); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 1555 | |
| 1556 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1557 | } |
| 1558 | |
| 1559 | /* Test scenario where MS wants to send some data on PDCH against SGSN and it is |
| 1560 | * answered, so TBFs for uplink and later for downlink are created. |
| 1561 | */ |
| 1562 | testcase TC_mo_ping_pong() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 4fbeefd | 2020-11-05 13:47:24 +0100 | [diff] [blame] | 1563 | var template CodingScheme exp_cs_mcs := cs_gprs_any; |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1564 | f_TC_mo_ping_pong_1phase_access(exp_cs_mcs); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1565 | } |
| 1566 | |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1567 | /* Test scenario where MS wants to send some data on PDCH against SGSN and it is |
| 1568 | * answered, so TBFs for uplink and later for downlink are created. |
| 1569 | */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1570 | private function f_TC_mo_ping_pong_2phase_access(PCUIF_Flags ind_flags, |
| 1571 | template (value) MSRadioAccessCapabilityV ms_racap, |
Pau Espin Pedrol | 42acafc | 2020-05-14 15:18:38 +0200 | [diff] [blame] | 1572 | template (present) CodingScheme exp_ul_cs_mcs := ?, |
| 1573 | template (present) CodingScheme exp_dl_cs_mcs := ?) |
| 1574 | runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1575 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1576 | var octetstring data := f_rnd_octstring(10); |
Pau Espin Pedrol | 8155bf4 | 2020-10-29 17:34:26 +0100 | [diff] [blame] | 1577 | var PollFnCtx pollctx; |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1578 | var uint32_t sched_fn; |
| 1579 | var uint32_t dl_fn; |
Pau Espin Pedrol | adbbe1e | 2020-05-17 00:28:01 +0200 | [diff] [blame] | 1580 | var uint32_t unused_fn; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1581 | var GprsMS ms; |
| 1582 | |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1583 | /* Initialize NS/BSSGP side */ |
| 1584 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1585 | /* Initialize GPRS MS side */ |
| 1586 | f_init_gprs_ms(); |
| 1587 | 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] | 1588 | |
| 1589 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1590 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(ind_flags)); |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1591 | |
| 1592 | /* Establish BSSGP connection to the PCU */ |
| 1593 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1594 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1595 | |
Pau Espin Pedrol | 8155bf4 | 2020-10-29 17:34:26 +0100 | [diff] [blame] | 1596 | /* Send PACKET RESOURCE REQUEST to upgrade to EGPRS */ |
| 1597 | 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] | 1598 | |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1599 | if (not match(ms.ul_tbf.tx_cs_mcs, exp_ul_cs_mcs)) { |
| 1600 | 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] | 1601 | f_shutdown(__BFILE__, __LINE__); |
| 1602 | } |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1603 | |
| 1604 | /* Send one UL block (without TLLI since we are in Second-Phase Access) |
| 1605 | and make sure it is ACKED fine */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1606 | 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] | 1607 | |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1608 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 8155bf4 | 2020-10-29 17:34:26 +0100 | [diff] [blame] | 1609 | 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] | 1610 | |
| 1611 | /* UL block should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1612 | 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] | 1613 | |
| 1614 | /* Now SGSN sends some DL data, PCU will page on PACCH */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1615 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
Vadim Yanitskiy | 7431e9e | 2020-07-21 01:59:17 +0700 | [diff] [blame] | 1616 | 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] | 1617 | /* DL Ass sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1618 | 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] | 1619 | |
Pau Espin Pedrol | adbbe1e | 2020-05-17 00:28:01 +0200 | [diff] [blame] | 1620 | /* PCU acks the UL data after having received CV=0) */ |
| 1621 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, unused_fn); |
| 1622 | |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1623 | /* 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] | 1624 | 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] | 1625 | |
| 1626 | /* ACK the DL block */ |
Pau Espin Pedrol | e8db673 | 2020-11-12 21:06:41 +0100 | [diff] [blame] | 1627 | f_dltbf_ack_block(ms.dl_tbf, dl_block, '1'B); |
| 1628 | 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] | 1629 | f_dl_block_ack_fn(dl_block, dl_fn)); |
Pau Espin Pedrol | 02c972d | 2020-05-13 15:56:16 +0200 | [diff] [blame] | 1630 | |
| 1631 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 1632 | } |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1633 | |
| 1634 | testcase TC_mo_ping_pong_with_ul_racap() runs on RAW_PCU_Test_CT { |
| 1635 | var MultislotCap_GPRS mscap_gprs := { |
| 1636 | gprsmultislotclass := '00011'B, |
| 1637 | gprsextendeddynalloccap := '0'B |
| 1638 | }; |
| 1639 | 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] | 1640 | var template CodingScheme exp_ul_cs_mcs := cs_gprs_any; |
| 1641 | var template CodingScheme exp_dl_cs_mcs := cs_gprs_any; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1642 | |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1643 | 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] | 1644 | } |
| 1645 | |
| 1646 | 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] | 1647 | var MultislotCap_GPRS mscap_gprs := { |
| 1648 | gprsmultislotclass := '00011'B, |
| 1649 | gprsextendeddynalloccap := '0'B |
| 1650 | }; |
| 1651 | var MultislotCap_EGPRS mscap_egprs := { |
| 1652 | egprsmultislotclass := '00011'B, |
| 1653 | egprsextendeddynalloccap := '0'B |
| 1654 | }; |
| 1655 | 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] | 1656 | var template CodingScheme exp_ul_cs_mcs := mcs_egprs_any; |
| 1657 | var template CodingScheme exp_dl_cs_mcs := mcs_egprs_any; |
Pau Espin Pedrol | 42acafc | 2020-05-14 15:18:38 +0200 | [diff] [blame] | 1658 | |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1659 | 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] | 1660 | } |
| 1661 | |
Pau Espin Pedrol | 0c0bf87 | 2020-05-14 15:50:49 +0200 | [diff] [blame] | 1662 | testcase TC_force_two_phase_access() runs on RAW_PCU_Test_CT { |
| 1663 | /* Configure PCU to force two phase access */ |
| 1664 | g_force_two_phase_access := true; |
| 1665 | |
| 1666 | var MultislotCap_GPRS mscap_gprs := { |
| 1667 | gprsmultislotclass := '00011'B, |
| 1668 | gprsextendeddynalloccap := '0'B |
| 1669 | }; |
| 1670 | var MSRadioAccessCapabilityV ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, omit)) }; |
| 1671 | 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] | 1672 | var template CodingScheme exp_dl_cs_mcs := cs_gprs_any; |
Pau Espin Pedrol | 0c0bf87 | 2020-05-14 15:50:49 +0200 | [diff] [blame] | 1673 | |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1674 | 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] | 1675 | } |
| 1676 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1677 | /* Test scenario where SGSN wants to send some data against MS and it is |
| 1678 | * answered by the MS on PDCH, so TBFs for downlink and later for uplink are created. |
| 1679 | */ |
Vadim Yanitskiy | c67240a | 2020-10-17 15:59:37 +0700 | [diff] [blame] | 1680 | private function f_TC_mt_ping_pong(template (omit) MSRadioAccessCapabilityV_BSSGP ms_racap := omit, |
| 1681 | template (present) CodingScheme exp_cs_mcs := ?) |
| 1682 | runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1683 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1684 | var octetstring data := f_rnd_octstring(10); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1685 | var uint32_t sched_fn; |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1686 | var uint32_t dl_fn; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1687 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1688 | |
| 1689 | /* Initialize NS/BSSGP side */ |
| 1690 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1691 | /* Initialize GPRS MS side */ |
| 1692 | f_init_gprs_ms(); |
| 1693 | 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] | 1694 | |
| 1695 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1696 | 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] | 1697 | |
| 1698 | /* Establish BSSGP connection to the PCU */ |
| 1699 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1700 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1701 | |
| 1702 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1703 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, ms_racap)); |
| 1704 | 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] | 1705 | |
| 1706 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 1707 | f_sleep(X2002); |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1708 | 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] | 1709 | |
Pau Espin Pedrol | 6791eb6 | 2020-05-20 18:27:10 +0200 | [diff] [blame] | 1710 | /* 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] | 1711 | f_dltbf_ack_block(ms.dl_tbf, dl_block, '1'B); |
| 1712 | 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] | 1713 | f_dl_block_ack_fn(dl_block, dl_fn)); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1714 | |
Pau Espin Pedrol | 6791eb6 | 2020-05-20 18:27:10 +0200 | [diff] [blame] | 1715 | /* Expect UL ass */ |
Vadim Yanitskiy | 7431e9e | 2020-07-21 01:59:17 +0700 | [diff] [blame] | 1716 | 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] | 1717 | |
Pau Espin Pedrol | 4aac3d0 | 2020-05-13 15:13:49 +0200 | [diff] [blame] | 1718 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 1719 | contention resoultion) and make sure it is ACKED fine */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1720 | 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] | 1721 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1722 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1723 | 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] | 1724 | |
| 1725 | /* UL block should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1726 | 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] | 1727 | |
| 1728 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1729 | } |
| 1730 | |
| 1731 | testcase TC_mt_ping_pong() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 4fbeefd | 2020-11-05 13:47:24 +0100 | [diff] [blame] | 1732 | var template CodingScheme exp_cs_mcs := cs_gprs_any; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1733 | f_TC_mt_ping_pong(omit, exp_cs_mcs); |
| 1734 | } |
| 1735 | |
| 1736 | /* TC_mt_ping_pong, but DL-UNITDATA contains RA Access capability with (M)CS |
| 1737 | /* information about the MS */ |
| 1738 | testcase TC_mt_ping_pong_with_dl_racap() runs on RAW_PCU_Test_CT { |
| 1739 | var MultislotCap_GPRS_BSSGP mscap_gprs := { |
| 1740 | gprsmultislotclass := '00011'B, |
| 1741 | gprsextendeddynalloccap := '0'B |
| 1742 | } ; |
| 1743 | 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] | 1744 | var template CodingScheme exp_cs_mcs := cs_gprs_any; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1745 | f_TC_mt_ping_pong(ms_racap, exp_cs_mcs); |
| 1746 | } |
| 1747 | |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1748 | /* Verify that if PCU doesn't get one of the intermediate UL data blocks in a UL |
| 1749 | * TBF, it will request retransmission through UL ACK/NACK (with missing block |
| 1750 | * in its bitmap) when CV=0 is received (and hence it knows no more data is to |
| 1751 | * be transferred). |
| 1752 | */ |
| 1753 | testcase TC_ul_intermediate_retrans() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1754 | var RlcmacDlBlock dl_block; |
| 1755 | var template (value) RlcmacUlBlock ul_data; |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1756 | var uint32_t sched_fn; |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1757 | var octetstring total_payload; |
| 1758 | var octetstring payload; |
| 1759 | var octetstring lost_payload; |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1760 | var uint5_t tfi; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1761 | var GprsMS ms; |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1762 | var uint32_t payload_fill_len; |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1763 | |
| 1764 | /* Initialize NS/BSSGP side */ |
| 1765 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1766 | /* Initialize GPRS MS side */ |
| 1767 | f_init_gprs_ms(); |
| 1768 | 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] | 1769 | |
| 1770 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1771 | 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] | 1772 | |
| 1773 | /* Establish BSSGP connection to the PCU */ |
| 1774 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1775 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1776 | |
| 1777 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1778 | f_ms_establish_ul_tbf(ms); |
| 1779 | tfi := ms.ul_tbf.tfi; |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1780 | |
| 1781 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 1782 | contention resoultion) and make sure it is ACKED fine. */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1783 | 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] | 1784 | 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] | 1785 | |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1786 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1787 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1788 | 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] | 1789 | total_payload := payload; |
| 1790 | |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1791 | payload_fill_len := f_ultbf_payload_fill_length(ms.ul_tbf); |
| 1792 | |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1793 | /* Send 2 packets, skip 1 (inc bsn) and send another one */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1794 | payload := f_rnd_octstring(payload_fill_len); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1795 | f_ms_tx_ul_data_block(ms, payload, cv := 15); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1796 | total_payload := total_payload & payload; |
| 1797 | |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1798 | payload := f_rnd_octstring(payload_fill_len); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1799 | f_ms_tx_ul_data_block(ms, payload, cv := 15); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1800 | total_payload := total_payload & payload; |
| 1801 | |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1802 | lost_payload := f_rnd_octstring(payload_fill_len); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1803 | 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] | 1804 | total_payload := total_payload & lost_payload; |
| 1805 | |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1806 | payload := f_rnd_octstring(payload_fill_len) |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1807 | f_ms_tx_ul_data_block(ms, payload, cv := 15); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1808 | total_payload := total_payload & payload; |
| 1809 | |
| 1810 | /* 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] | 1811 | 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] | 1812 | |
| 1813 | /* On CV=0, we'll receive a UL ACK asking about missing block */ |
| 1814 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1815 | /* TODO: check ack ack bitmap (URBB) */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 1816 | ul_data := t_RLCMAC_UL_DATA(cs := ms.ul_tbf.tx_cs_mcs, |
| 1817 | tfi := tfi, |
| 1818 | cv := 15, |
| 1819 | bsn := 3, |
| 1820 | blocks := {t_RLCMAC_LLCBLOCK(lost_payload)}); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1821 | f_ms_tx_ul_block(ms, ul_data); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1822 | |
| 1823 | /* Now final ack is recieved */ |
| 1824 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 1825 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1826 | 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] | 1827 | |
| 1828 | /* receive one message on BSSGP with all aggregated data in payload: */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 1829 | 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] | 1830 | |
| 1831 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | a416cb8 | 2020-05-15 14:09:02 +0200 | [diff] [blame] | 1832 | } |
| 1833 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1834 | /* Verify that if PCU doesn't get an ACK for first DL block after IMM ASS, it |
| 1835 | * will retry by retransmitting both the IMM ASS + DL block after poll (ack) |
| 1836 | * timeout occurs (specified by sent RRBP on DL block). */ |
| 1837 | 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] | 1838 | var RlcmacDlBlock dl_block; |
| 1839 | var octetstring data := f_rnd_octstring(10); |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1840 | var uint32_t dl_fn; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1841 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1842 | |
| 1843 | /* Initialize NS/BSSGP side */ |
| 1844 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1845 | /* Initialize GPRS MS side */ |
| 1846 | f_init_gprs_ms(); |
| 1847 | 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] | 1848 | |
| 1849 | /* Initialize the PCU interface abstraction */ |
| 1850 | f_init_raw(testcasename()); |
| 1851 | |
| 1852 | /* Establish BSSGP connection to the PCU */ |
| 1853 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1854 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1855 | |
| 1856 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1857 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 1858 | 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] | 1859 | |
| 1860 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 1861 | f_sleep(X2002); |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1862 | 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] | 1863 | |
| 1864 | /* Now we don't ack the dl block (emulate MS failed receiveing IMM ASS |
| 1865 | * or GPRS DL, or DL ACK was lost for some reason). As a result, PCU |
| 1866 | * should retrigger IMM ASS + GPRS DL procedure after poll timeout. */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1867 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
Vadim Yanitskiy | 2e213ae | 2020-05-06 22:26:17 +0700 | [diff] [blame] | 1868 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1869 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 1870 | f_sleep(X2002); |
Vadim Yanitskiy | b6733a6 | 2020-05-10 14:39:00 +0700 | [diff] [blame] | 1871 | 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] | 1872 | |
| 1873 | /* ACK the DL block */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1874 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B); |
| 1875 | f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc), |
| 1876 | f_dl_block_ack_fn(dl_block, dl_fn)); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 1877 | |
| 1878 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1879 | } |
| 1880 | |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1881 | /* Verify scheduling of multiple Downlink data blocks during one RRBP. */ |
| 1882 | testcase TC_dl_flow_more_blocks() runs on RAW_PCU_Test_CT { |
| 1883 | var AckNackDescription ack_nack_desc := valueof(t_AckNackDescription_init); |
| 1884 | var octetstring data := f_rnd_octstring(16); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1885 | var PacketDlAssign dl_tbf_ass; |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1886 | var RlcmacDlBlock dl_block; |
| 1887 | var uint32_t ack_fn; |
| 1888 | var uint32_t fn; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1889 | var GprsMS ms; |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1890 | timer T := 5.0; |
| 1891 | |
| 1892 | /* Initialize NS/BSSGP side */ |
| 1893 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1894 | /* Initialize GPRS MS side */ |
| 1895 | f_init_gprs_ms(); |
| 1896 | ms := g_ms[0]; /* We only use first MS in this test */ |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1897 | |
| 1898 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1899 | f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1900 | |
Daniel Willmann | 535aea6 | 2020-09-21 13:27:08 +0200 | [diff] [blame] | 1901 | f_statsd_reset(); |
| 1902 | |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1903 | /* Establish BSSGP connection to the PCU */ |
| 1904 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1905 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1906 | |
| 1907 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1908 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 1909 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1910 | |
| 1911 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS */ |
| 1912 | f_sleep(X2002); |
| 1913 | |
| 1914 | /* Expect the first (GPRS DL) block with bsn=0 and rrbp_valid=1 */ |
| 1915 | 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] | 1916 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1917 | |
| 1918 | /* TDMA frame number on which we are supposed to send the ACK */ |
| 1919 | ack_fn := f_dl_block_ack_fn(dl_block, fn); |
| 1920 | |
| 1921 | /* SGSN sends more blocks during the indicated RRBP */ |
| 1922 | for (var integer bsn := 1; bsn < 63; bsn := bsn + 1) { |
| 1923 | data := f_rnd_octstring(16); /* Random LLC data */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1924 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1925 | |
| 1926 | f_rx_rlcmac_dl_block_exp_data(dl_block, fn, data, bsn); |
| 1927 | |
| 1928 | /* Make sure this block has the same TFI as was assigned |
| 1929 | * FIXME: this is only valid for GPRS, not EGPRS. */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1930 | 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] | 1931 | setverdict(fail, "Rx DL data block with unexpected TFI: ", |
| 1932 | dl_block.data.mac_hdr.hdr_ext.tfi); |
| 1933 | f_shutdown(__BFILE__, __LINE__); |
| 1934 | } |
| 1935 | |
| 1936 | /* Keep Ack/Nack description updated */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1937 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1938 | |
| 1939 | /* Break if this is the end of RRBP */ |
| 1940 | if (fn == ack_fn) { |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1941 | ms.dl_tbf.acknack_desc.final_ack := '1'B; |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1942 | break; |
| 1943 | } |
| 1944 | } |
| 1945 | |
| 1946 | /* This is the end of RRBP, send Packet Downlink Ack/Nack */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 1947 | 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] | 1948 | |
| 1949 | /* Make sure that the next block (after the Ack) is dummy */ |
| 1950 | f_rx_rlcmac_dl_block_exp_dummy(dl_block); |
| 1951 | |
Daniel Willmann | 535aea6 | 2020-09-21 13:27:08 +0200 | [diff] [blame] | 1952 | var StatsDExpects expect := { |
| 1953 | { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := 0, max := 0}, |
| 1954 | { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 1, max := 1}, |
| 1955 | { name := "TTCN3.bts.0.immediate.assignment_UL", mtype := "c", min := 0, max := 0}, |
| 1956 | { name := "TTCN3.bts.0.tbf.dl.alloc", mtype := "c", min := 1, max := 1}, |
| 1957 | { name := "TTCN3.bts.0.tbf.ul.alloc", mtype := "c", min := 0, max := 0}, |
| 1958 | { name := "TTCN3.bts.0.rlc.dl_payload_bytes", mtype := "c", min := 112, max := 112}, |
| 1959 | { name := "TTCN3.bts.0.rlc.ul_payload_bytes", mtype := "c", min := 0, max := 0} |
| 1960 | }; |
| 1961 | f_statsd_expect(expect); |
| 1962 | |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 1963 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 1964 | } |
| 1965 | |
Pau Espin Pedrol | 05b6c17 | 2020-06-26 17:28:23 +0200 | [diff] [blame] | 1966 | /* Verify Decoding and segmentation of UL LLC PDUs into RLC data blocks, OS#4559. |
| 1967 | * Check "GPRS from A-Z" slide "Example of LI-Field and E-Bit" page 186. |
| 1968 | * Check "3GPP TS 44.060" Annex B. */ |
| 1969 | testcase TC_ul_flow_multiple_llc_blocks() runs on RAW_PCU_Test_CT { |
| 1970 | var RlcmacDlBlock dl_block; |
| 1971 | var octetstring dataA := f_rnd_octstring(20); |
| 1972 | var octetstring dataB := f_rnd_octstring(13); |
| 1973 | var octetstring dataC := f_rnd_octstring(3); |
| 1974 | var octetstring dataD := f_rnd_octstring(12); |
| 1975 | var uint32_t sched_fn; |
| 1976 | var GprsMS ms; |
| 1977 | var template (value) RlcmacUlBlock ul_data; |
| 1978 | |
| 1979 | /* Initialize NS/BSSGP side */ |
| 1980 | f_init_bssgp(); |
| 1981 | /* Initialize GPRS MS side */ |
| 1982 | f_init_gprs_ms(); |
| 1983 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 1984 | |
| 1985 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 1986 | 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] | 1987 | |
| 1988 | /* Establish BSSGP connection to the PCU */ |
| 1989 | f_bssgp_establish(); |
| 1990 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 1991 | |
| 1992 | /* Establish an Uplink TBF */ |
| 1993 | f_ms_establish_ul_tbf(ms); |
| 1994 | |
| 1995 | /* Summary of what's transmitted: |
| 1996 | * 1- UL RlcDataBlock(dataA) [BSN=0, CV=3] |
| 1997 | * 2- UL RlcDataBlock(dataA finished, dataB starts) [BSN=1, CV=2] |
| 1998 | * 3- UL RlcDataBlock(dataB finished, dataC starts and finishes, dataD starts) [BSN=2, CV=1] |
| 1999 | * 4- UL RlcDataBlock(dataD finishes) [BSN=3, CV=0] |
| 2000 | * And on SGSN we receive 4 packets, one for each LlcBlock dataA..D. |
| 2001 | * We'll also receive some UL ACK/NACK we need to reply with CTRL ACK. |
| 2002 | */ |
| 2003 | |
| 2004 | /* UL RlcDataBlock(dataA) [BSN=0, CV=3] */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 2005 | ul_data := t_RLCMAC_UL_DATA_TLLI(cs := CS_1, |
| 2006 | tfi := ms.ul_tbf.tfi, |
Pau Espin Pedrol | 05b6c17 | 2020-06-26 17:28:23 +0200 | [diff] [blame] | 2007 | cv := 3, |
| 2008 | bsn := ms.ul_tbf.bsn, |
| 2009 | blocks := { t_RLCMAC_LLCBLOCK(substr(dataA, 0, 16)) }, |
| 2010 | tlli := ms.tlli); |
| 2011 | /* Indicate no llc header, meaning first LLC block doesn't finish in current |
| 2012 | * RLCMAC block being sent. */ |
| 2013 | ul_data.data.mac_hdr.e := true; |
| 2014 | f_ultbf_inc_bsn(ms.ul_tbf); |
| 2015 | f_ms_tx_ul_block(ms, ul_data); |
| 2016 | |
| 2017 | /* UL RlcDataBlock(dataA finished, dataB starts) [BSN=1, CV=2] */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 2018 | ul_data := t_RLCMAC_UL_DATA_TLLI(cs := CS_1, |
| 2019 | tfi := ms.ul_tbf.tfi, |
Pau Espin Pedrol | 05b6c17 | 2020-06-26 17:28:23 +0200 | [diff] [blame] | 2020 | cv := 2, |
| 2021 | bsn := ms.ul_tbf.bsn, |
| 2022 | blocks := { t_RLCMAC_LLCBLOCK(substr(dataA, 16, 4), |
| 2023 | t_RLCMAC_LLCBLOCK_HDR(length_ind := 4, more := true, e := true)), |
| 2024 | t_RLCMAC_LLCBLOCK(substr(dataB, 0, 11)) |
| 2025 | }, |
| 2026 | tlli := ms.tlli); |
| 2027 | f_ultbf_inc_bsn(ms.ul_tbf); |
| 2028 | f_ms_tx_ul_block(ms, ul_data); |
| 2029 | |
| 2030 | /* UL block dataA should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 2031 | 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] | 2032 | |
| 2033 | /* 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] | 2034 | ul_data := t_RLCMAC_UL_DATA_TLLI(cs := CS_1, |
| 2035 | tfi := ms.ul_tbf.tfi, |
Pau Espin Pedrol | 05b6c17 | 2020-06-26 17:28:23 +0200 | [diff] [blame] | 2036 | cv := 1, |
| 2037 | bsn := ms.ul_tbf.bsn, |
| 2038 | blocks := { t_RLCMAC_LLCBLOCK(substr(dataB, 11, 2), |
| 2039 | t_RLCMAC_LLCBLOCK_HDR(length_ind := 2, more := true, e := false)), |
| 2040 | t_RLCMAC_LLCBLOCK(substr(dataC, 0, 3), |
| 2041 | t_RLCMAC_LLCBLOCK_HDR(length_ind := 3, more := true, e := true)), |
| 2042 | t_RLCMAC_LLCBLOCK(substr(dataD, 0, 9)) |
| 2043 | }, |
| 2044 | tlli := ms.tlli); |
| 2045 | f_ultbf_inc_bsn(ms.ul_tbf); |
| 2046 | f_ms_tx_ul_block(ms, ul_data); |
| 2047 | |
| 2048 | /* UL block dataB and dataC should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 2049 | BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, dataB)); |
| 2050 | 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] | 2051 | |
| 2052 | /* UL RlcDataBlock(dataD finishes) [BSN=3, CV=0] */ |
Pau Espin Pedrol | cb00c52 | 2020-11-06 19:52:05 +0100 | [diff] [blame] | 2053 | ul_data := t_RLCMAC_UL_DATA_TLLI( |
| 2054 | cs := CS_1, |
| 2055 | tfi := ms.ul_tbf.tfi, |
Pau Espin Pedrol | 05b6c17 | 2020-06-26 17:28:23 +0200 | [diff] [blame] | 2056 | cv := 0, |
| 2057 | bsn := ms.ul_tbf.bsn, |
| 2058 | blocks := { t_RLCMAC_LLCBLOCK(substr(dataD, 9, 3), |
| 2059 | t_RLCMAC_LLCBLOCK_HDR(length_ind := 3, more := false, e := true)) |
| 2060 | }, |
| 2061 | tlli := ms.tlli); |
| 2062 | f_ultbf_inc_bsn(ms.ul_tbf); |
| 2063 | f_ms_tx_ul_block(ms, ul_data); |
| 2064 | |
| 2065 | /* UL block dataB and dataD should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 2066 | 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] | 2067 | |
| 2068 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 2069 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 2070 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
| 2071 | |
| 2072 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2073 | } |
| 2074 | |
Pau Espin Pedrol | 0ea8b6f | 2020-10-29 20:48:43 +0100 | [diff] [blame] | 2075 | /* Verify allocation and use of multislot tbf, triggered by MS class provided in SGSN. SYS#5131 */ |
| 2076 | 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] | 2077 | 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] | 2078 | var octetstring data := f_rnd_octstring(10); |
| 2079 | var PacketDlAssign dl_tbf_ass; |
| 2080 | var RlcmacDlBlock dl_block; |
| 2081 | var uint32_t poll_fn; |
| 2082 | var uint32_t sched_fn; |
| 2083 | var GprsMS ms; |
| 2084 | timer T := 5.0; |
| 2085 | |
| 2086 | /* Initialize NS/BSSGP side */ |
| 2087 | f_init_bssgp(); |
| 2088 | /* Initialize GPRS MS side */ |
| 2089 | f_init_gprs_ms(); |
| 2090 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 2091 | |
| 2092 | /* Only 1 TRX with 8 PDCH */ |
| 2093 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '11111111'B, 0); |
| 2094 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000000'B, (1 .. 7)); |
| 2095 | |
| 2096 | /* Initialize the PCU interface abstraction */ |
| 2097 | f_init_raw(testcasename(), info_ind); |
| 2098 | |
| 2099 | /* Establish BSSGP connection to the PCU */ |
| 2100 | f_bssgp_establish(); |
| 2101 | f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli); |
| 2102 | |
| 2103 | /* Establish an Uplink TBF, this way the PCU can send DL Assignment |
| 2104 | through PDCH (no multiblock assignment possible through PCH) */ |
| 2105 | f_ms_establish_ul_tbf(ms); |
| 2106 | |
| 2107 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 2108 | contention resoultion) and make sure it is ACKED fine */ |
| 2109 | f_ms_tx_ul_data_block(ms, data, with_tlli := true, nr := f_ms_tx_TsTrxBtsNum(ms)); |
| 2110 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 2111 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, poll_fn, nr := f_ms_tx_TsTrxBtsNum(ms)); |
| 2112 | |
| 2113 | /* SGSN sends some DL data, PCU will assign DL TBF through PACCH */ |
| 2114 | var MultislotCap_GPRS_BSSGP mscap_gprs := { |
| 2115 | gprsmultislotclass := '10010'B, /* MS class 18, supports 8 DL and 8 UL */ |
| 2116 | gprsextendeddynalloccap := '0'B |
| 2117 | }; |
| 2118 | var MSRadioAccessCapabilityV_BSSGP ms_racap := { valueof(ts_RaCapRec_BSSGP('0001'B /* E-GSM */, mscap_gprs, omit)) }; |
| 2119 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, ms_racap)); |
| 2120 | dl_block := f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_DL_PACKET_ASS, nr := f_ms_tx_TsTrxBtsNum(ms)); |
| 2121 | if (f_dltbf_num_slots(ms.dl_tbf) != 8) { |
| 2122 | setverdict(fail, "Expected 8 PDCH slots allocated but got ", f_dltbf_num_slots(ms.dl_tbf)); |
| 2123 | f_shutdown(__BFILE__, __LINE__); |
| 2124 | } |
| 2125 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn, nr := f_ms_tx_TsTrxBtsNum(ms)); |
| 2126 | |
| 2127 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2128 | } |
| 2129 | |
Pau Espin Pedrol | 8155bf4 | 2020-10-29 17:34:26 +0100 | [diff] [blame] | 2130 | 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] | 2131 | 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] | 2132 | var RlcmacDlBlock dl_block; |
| 2133 | var octetstring data := f_rnd_octstring(10); |
| 2134 | var PollFnCtx pollctx; |
| 2135 | var uint32_t sched_fn; |
| 2136 | var GprsMS ms; |
| 2137 | |
| 2138 | var MultislotCap_GPRS mscap_gprs := { |
| 2139 | gprsmultislotclass := '10010'B, /* MS class 18, supports 8 DL and 8 UL */ |
| 2140 | gprsextendeddynalloccap := '0'B |
| 2141 | }; |
| 2142 | var MSRadioAccessCapabilityV ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, omit)) }; |
| 2143 | |
| 2144 | |
| 2145 | /* Initialize NS/BSSGP side */ |
| 2146 | f_init_bssgp(); |
| 2147 | /* Initialize GPRS MS side */ |
| 2148 | f_init_gprs_ms(); |
| 2149 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 2150 | |
| 2151 | /* Only 1 TRX with 8 PDCH */ |
| 2152 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '11111111'B, 0); |
| 2153 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000000'B, (1 .. 7)); |
| 2154 | |
| 2155 | /* Initialize the PCU interface abstraction */ |
| 2156 | f_init_raw(testcasename(), info_ind); |
| 2157 | |
| 2158 | /* Establish BSSGP connection to the PCU */ |
| 2159 | f_bssgp_establish(); |
| 2160 | f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli); |
| 2161 | |
| 2162 | /* Send PACKET RESOURCE REQUEST to notify the MultiSlot Class */ |
| 2163 | pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap)); |
| 2164 | |
| 2165 | /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 2166 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts); |
| 2167 | |
| 2168 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 2169 | dl_block := f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_DL_PACKET_ASS, nr := f_ms_tx_TsTrxBtsNum(ms)); |
| 2170 | if (f_dltbf_num_slots(ms.dl_tbf) != 8) { |
| 2171 | setverdict(fail, "Expected 8 PDCH slot allocated but got ", f_dltbf_num_slots(ms.dl_tbf)); |
| 2172 | f_shutdown(__BFILE__, __LINE__); |
| 2173 | } |
| 2174 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn, nr := f_ms_tx_TsTrxBtsNum(ms)); |
| 2175 | |
| 2176 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2177 | } |
| 2178 | |
Pau Espin Pedrol | a9f27fa | 2020-10-30 13:16:21 +0100 | [diff] [blame] | 2179 | testcase TC_ul_multislot_tbf_ms_class_from_2phase() runs on RAW_PCU_Test_CT { |
| 2180 | var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default); |
| 2181 | var RlcmacDlBlock dl_block; |
| 2182 | var octetstring data := f_rnd_octstring(10); |
| 2183 | var PollFnCtx pollctx; |
| 2184 | var uint32_t sched_fn; |
| 2185 | var GprsMS ms; |
| 2186 | |
| 2187 | var MultislotCap_GPRS mscap_gprs := { |
| 2188 | gprsmultislotclass := '10010'B, /* MS class 18, supports 8 DL and 8 UL */ |
| 2189 | gprsextendeddynalloccap := '0'B |
| 2190 | }; |
| 2191 | var MSRadioAccessCapabilityV ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, omit)) }; |
| 2192 | |
| 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 | /* Only 1 TRX with 8 PDCH */ |
| 2201 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '11111111'B, 0); |
| 2202 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000000'B, (1 .. 7)); |
| 2203 | |
| 2204 | /* Initialize the PCU interface abstraction */ |
| 2205 | f_init_raw(testcasename(), info_ind); |
| 2206 | |
| 2207 | /* Establish BSSGP connection to the PCU */ |
| 2208 | f_bssgp_establish(); |
| 2209 | f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli); |
| 2210 | |
| 2211 | /* Send PACKET RESOURCE REQUEST to notify the MultiSlot Class */ |
| 2212 | pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap)); |
| 2213 | |
| 2214 | if (f_ultbf_num_slots(ms.ul_tbf) != 8) { |
| 2215 | setverdict(fail, "Expected 8 PDCH slot allocated but got ", f_ultbf_num_slots(ms.ul_tbf)); |
| 2216 | f_shutdown(__BFILE__, __LINE__); |
| 2217 | } |
| 2218 | |
| 2219 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2220 | } |
| 2221 | |
Pau Espin Pedrol | cdbe903 | 2020-07-07 20:20:42 +0200 | [diff] [blame] | 2222 | /* Test scenario where MS wants to request a new TBF once the current one is |
| 2223 | * ending, by means of sending a Packet Resource Request on ul slot provided by |
| 2224 | * last Pkt Ul ACK's RRBP. |
| 2225 | * See 3GPP TS 44.060 sec 9.3.2.4.2 "Non-extended uplink TBF mode" */ |
| 2226 | 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] | 2227 | var RlcmacDlBlock dl_block; |
| 2228 | var octetstring data := f_rnd_octstring(10); |
| 2229 | var uint32_t sched_fn; |
| 2230 | var uint32_t dl_fn; |
| 2231 | var template RlcmacDlBlock acknack_tmpl; |
| 2232 | var GprsMS ms; |
| 2233 | |
| 2234 | /* Initialize NS/BSSGP side */ |
| 2235 | f_init_bssgp(); |
| 2236 | /* Initialize GPRS MS side */ |
| 2237 | f_init_gprs_ms(); |
| 2238 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 2239 | |
| 2240 | /* Initialize the PCU interface abstraction */ |
| 2241 | f_init_raw(testcasename()); |
| 2242 | |
| 2243 | /* Establish BSSGP connection to the PCU */ |
| 2244 | f_bssgp_establish(); |
| 2245 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 2246 | |
| 2247 | /* Establish an Uplink TBF */ |
| 2248 | f_ms_establish_ul_tbf(ms); |
| 2249 | |
| 2250 | /* Send one UL block (with TLLI since we are in One-Phase Access |
| 2251 | contention resoultion) and make sure it is ACKED fine */ |
| 2252 | f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true); |
| 2253 | |
| 2254 | /* UL block should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 2255 | 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] | 2256 | |
| 2257 | acknack_tmpl := tr_RLCMAC_UL_ACK_NACK_GPRS(ms.ul_tbf.tfi, |
| 2258 | tr_UlAckNackGprs(ms.tlli, |
| 2259 | tr_AckNackDescription(final_ack := '1'B), |
| 2260 | tr_UlAckNackGprsAdditionsRel99(tbf_est := true))) |
| 2261 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn, acknack_tmpl); |
| 2262 | |
| 2263 | /* TODO: verify TBF_EST and FinalACK are both '1' above */ |
| 2264 | |
| 2265 | /* Send PACKET RESOURCE REQUEST to request a new UL TBF */ |
Vadim Yanitskiy | f3cb4dd | 2020-07-21 01:52:33 +0700 | [diff] [blame] | 2266 | 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] | 2267 | 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] | 2268 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 2269 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
| 2270 | |
| 2271 | /* Send one UL block (without TLLI since we are in Second-Phase Access) |
| 2272 | and make sure it is ACKED fine */ |
| 2273 | f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := false); /* TODO: send using cs_mcs */ |
| 2274 | |
| 2275 | /* UL block should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 2276 | 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] | 2277 | |
| 2278 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn, acknack_tmpl); |
| 2279 | /* ACK the ACK */ |
| 2280 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
| 2281 | |
| 2282 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2283 | } |
| 2284 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2285 | /* Test CS paging over the BTS<->PCU socket. |
| 2286 | * 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. |
| 2287 | * Paging should be send on the PACCH. |
| 2288 | * |
| 2289 | * 1. Send a Paging Request over PCU socket. |
| 2290 | * 2. Send a Ready-To-Send message over PCU socket |
| 2291 | * 3. Expect a Paging Frame |
| 2292 | */ |
| 2293 | 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] | 2294 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2295 | var MobileIdentityLV mi; |
| 2296 | var octetstring mi_enc_lv; |
| 2297 | var hexstring imsi := f_gen_imsi(42); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2298 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2299 | |
| 2300 | /* Initialize NS/BSSGP side */ |
| 2301 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2302 | /* Initialize GPRS MS side */ |
| 2303 | f_init_gprs_ms(); |
| 2304 | 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] | 2305 | |
| 2306 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 2307 | 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] | 2308 | |
| 2309 | /* Establish BSSGP connection to the PCU */ |
| 2310 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2311 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2312 | |
| 2313 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2314 | f_ms_establish_ul_tbf(ms); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2315 | |
| 2316 | /* build mobile Identity */ |
| 2317 | mi := valueof(ts_MI_IMSI_LV(imsi)); |
| 2318 | mi_enc_lv := enc_MobileIdentityLV(mi); |
| 2319 | /* Send paging request */ |
| 2320 | BTS.send(ts_PCUIF_PAG_REQ(bts_nr := 0, id_lv := mi_enc_lv, chan_needed := 0, |
| 2321 | sapi :=PCU_IF_SAPI_PDTCH)); |
| 2322 | |
| 2323 | /* Receive it on BTS side towards MS */ |
| 2324 | f_rx_rlcmac_dl_block_exp_pkt_pag_req(dl_block); |
| 2325 | |
| 2326 | /* Make sure that Packet Paging Request contains the same IMSI */ |
Vadim Yanitskiy | 3e5f074 | 2020-11-01 03:30:18 +0700 | [diff] [blame] | 2327 | var PacketPagingReq req := dl_block.ctrl.payload.u.paging; |
| 2328 | if (not f_pkt_paging_match_imsi(req, imsi, ps_domain := false)) { |
| 2329 | setverdict(fail, "Failed to match IMSI ", imsi, " in ", req); |
| 2330 | } |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2331 | |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 2332 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2333 | } |
| 2334 | |
| 2335 | /* Test CS paging over Gb (SGSN->PCU->BTS[PDCH]). |
| 2336 | */ |
| 2337 | private function f_tc_paging_cs_from_sgsn(Nsvci bvci, boolean use_ptmsi := false) |
| 2338 | runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2339 | var RlcmacDlBlock dl_block; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2340 | var hexstring imsi := f_gen_imsi(42); |
| 2341 | var GsmTmsi tmsi; |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2342 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2343 | |
| 2344 | /* Initialize NS/BSSGP side */ |
| 2345 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2346 | /* Initialize GPRS MS side */ |
| 2347 | f_init_gprs_ms(); |
| 2348 | 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] | 2349 | |
| 2350 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 2351 | 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] | 2352 | |
| 2353 | /* Establish BSSGP connection to the PCU */ |
| 2354 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2355 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2356 | |
| 2357 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2358 | f_ms_establish_ul_tbf(ms); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2359 | |
| 2360 | /* Send paging request with or without TMSI */ |
| 2361 | if (use_ptmsi) { |
| 2362 | tmsi := oct2int(f_rnd_octstring(4)); /* Random P-TMSI */ |
| 2363 | BSSGP[0].send(ts_BSSGP_CS_PAGING_PTMSI(bvci, imsi, tmsi)); |
| 2364 | } else { |
| 2365 | BSSGP[0].send(ts_BSSGP_CS_PAGING_IMSI(bvci, imsi)); |
| 2366 | } |
| 2367 | |
| 2368 | /* Receive it on BTS side towards MS */ |
| 2369 | f_rx_rlcmac_dl_block_exp_pkt_pag_req(dl_block); |
| 2370 | |
| 2371 | /* Make sure that Packet Paging Request contains the same P-TMSI/IMSI */ |
Vadim Yanitskiy | 3e5f074 | 2020-11-01 03:30:18 +0700 | [diff] [blame] | 2372 | var PacketPagingReq req := dl_block.ctrl.payload.u.paging; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2373 | if (use_ptmsi) { |
Vadim Yanitskiy | 3e5f074 | 2020-11-01 03:30:18 +0700 | [diff] [blame] | 2374 | if (not f_pkt_paging_match_tmsi(req, tmsi, ps_domain := false)) { |
| 2375 | setverdict(fail, "Failed to match P-TMSI ", tmsi, " in ", req); |
| 2376 | } |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2377 | } else { |
Vadim Yanitskiy | 3e5f074 | 2020-11-01 03:30:18 +0700 | [diff] [blame] | 2378 | if (not f_pkt_paging_match_imsi(req, imsi, ps_domain := false)) { |
| 2379 | setverdict(fail, "Failed to match IMSI ", imsi, " in ", req); |
| 2380 | } |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2381 | } |
| 2382 | |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 2383 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2384 | } |
| 2385 | |
| 2386 | testcase TC_paging_cs_from_sgsn_sign_ptmsi() runs on RAW_PCU_Test_CT { |
| 2387 | f_tc_paging_cs_from_sgsn(0, true); |
| 2388 | } |
| 2389 | |
| 2390 | testcase TC_paging_cs_from_sgsn_sign() runs on RAW_PCU_Test_CT { |
| 2391 | f_tc_paging_cs_from_sgsn(0); |
| 2392 | } |
| 2393 | |
| 2394 | 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] | 2395 | 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] | 2396 | } |
| 2397 | |
| 2398 | /* Test PS paging over Gb (SGSN->PCU->BTS[CCCH]). |
| 2399 | */ |
| 2400 | private function f_tc_paging_ps_from_sgsn(Nsvci bvci, boolean use_ptmsi := false) |
| 2401 | runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2402 | var integer imsi_suff_tx := 423; |
| 2403 | var hexstring imsi := f_gen_imsi(imsi_suff_tx); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2404 | var GprsMS ms; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2405 | |
| 2406 | /* Initialize NS/BSSGP side */ |
| 2407 | f_init_bssgp(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2408 | /* Initialize GPRS MS side */ |
| 2409 | f_init_gprs_ms(); |
| 2410 | 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] | 2411 | |
| 2412 | /* Initialize the PCU interface abstraction */ |
| 2413 | f_init_raw(testcasename()); |
| 2414 | |
| 2415 | /* Establish BSSGP connection to the PCU */ |
| 2416 | f_bssgp_establish(); |
Pau Espin Pedrol | 4f7b8fd | 2020-05-18 18:28:17 +0200 | [diff] [blame] | 2417 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2418 | |
| 2419 | /* Send BSSGP PAGING-PS (with or without TMSI), wait for RR Paging Request Type 1. |
| 2420 | * Make sure that both paging group (IMSI suffix) and Mobile Identity match. */ |
| 2421 | if (use_ptmsi) { |
| 2422 | var OCT4 tmsi := f_rnd_octstring(4); /* Random P-TMSI */ |
| 2423 | BSSGP[0].send(ts_BSSGP_PS_PAGING_PTMSI(bvci, imsi, oct2int(tmsi))); |
| 2424 | f_pcuif_rx_pch_pag_req1(t_MI_TMSI(tmsi), imsi_suff_tx); |
| 2425 | } else { |
| 2426 | BSSGP[0].send(ts_BSSGP_PS_PAGING_IMSI(bvci, imsi)); |
| 2427 | f_pcuif_rx_pch_pag_req1(tr_MI_IMSI(imsi), imsi_suff_tx); |
| 2428 | } |
| 2429 | |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 2430 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2431 | } |
| 2432 | |
| 2433 | testcase TC_paging_ps_from_sgsn_sign_ptmsi() runs on RAW_PCU_Test_CT { |
| 2434 | f_tc_paging_ps_from_sgsn(0, true); |
| 2435 | } |
| 2436 | |
| 2437 | testcase TC_paging_ps_from_sgsn_sign() runs on RAW_PCU_Test_CT { |
| 2438 | f_tc_paging_ps_from_sgsn(0); |
| 2439 | } |
| 2440 | |
| 2441 | 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] | 2442 | 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] | 2443 | } |
| 2444 | |
Pau Espin Pedrol | c03eb12 | 2020-08-27 18:54:24 +0200 | [diff] [blame] | 2445 | /* Verify osmo-pcu handles DL UNIT_DATA from SGSN with IMSI IE correctly. See OS#4729 */ |
| 2446 | testcase TC_bssgp_dl_unitdata_with_valid_imsi() runs on RAW_PCU_Test_CT { |
| 2447 | var RlcmacDlBlock dl_block; |
| 2448 | var octetstring data := f_rnd_octstring(10); |
| 2449 | var uint32_t sched_fn; |
| 2450 | var uint32_t dl_fn; |
| 2451 | var GprsMS ms; |
| 2452 | |
| 2453 | /* Initialize NS/BSSGP side */ |
| 2454 | f_init_bssgp(); |
| 2455 | /* Initialize GPRS MS side */ |
| 2456 | f_init_gprs_ms(); |
| 2457 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 2458 | |
| 2459 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 2460 | 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] | 2461 | |
Daniel Willmann | 535aea6 | 2020-09-21 13:27:08 +0200 | [diff] [blame] | 2462 | f_statsd_reset(); |
| 2463 | |
Pau Espin Pedrol | c03eb12 | 2020-08-27 18:54:24 +0200 | [diff] [blame] | 2464 | /* Establish BSSGP connection to the PCU */ |
| 2465 | f_bssgp_establish(); |
| 2466 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 2467 | |
| 2468 | /* Establish an Uplink TBF */ |
| 2469 | f_ms_establish_ul_tbf(ms); |
| 2470 | |
| 2471 | /* Fake GMM GPRS Attach or similar, PCU doesn't care about upper layers here */ |
| 2472 | f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true); |
| 2473 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 2474 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 2475 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
| 2476 | |
| 2477 | /* UL block should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 2478 | 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] | 2479 | |
| 2480 | /* Now SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
| 2481 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI(ms.imsi))); |
| 2482 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
| 2483 | |
| 2484 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 2485 | f_sleep(X2002); |
| 2486 | f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0); |
| 2487 | |
| 2488 | /* ACK the DL block */ |
| 2489 | f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B); |
| 2490 | f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc), |
| 2491 | f_dl_block_ack_fn(dl_block, dl_fn)); |
| 2492 | |
Daniel Willmann | 535aea6 | 2020-09-21 13:27:08 +0200 | [diff] [blame] | 2493 | var StatsDExpects expect := { |
| 2494 | { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := 1, max := 1}, |
| 2495 | { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 1, max := 1}, |
| 2496 | { name := "TTCN3.bts.0.tbf.dl.alloc", mtype := "c", min := 1, max := 1}, |
| 2497 | { name := "TTCN3.bts.0.tbf.ul.alloc", mtype := "c", min := 1, max := 1}, |
| 2498 | { 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] | 2499 | { 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] | 2500 | }; |
| 2501 | f_statsd_expect(expect); |
| 2502 | |
Pau Espin Pedrol | c03eb12 | 2020-08-27 18:54:24 +0200 | [diff] [blame] | 2503 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2504 | } |
| 2505 | |
| 2506 | /* Verify osmo-pcu acts on incorrect IMSI IE content in DL UNIT_DATA from SGSN. See OS#4729 */ |
| 2507 | testcase TC_bssgp_dl_unitdata_with_invalid_imsi() runs on RAW_PCU_Test_CT { |
| 2508 | var RlcmacDlBlock dl_block; |
| 2509 | var octetstring data := f_rnd_octstring(10); |
| 2510 | var uint32_t sched_fn; |
| 2511 | var uint32_t dl_fn; |
| 2512 | var GprsMS ms; |
| 2513 | |
| 2514 | /* Initialize NS/BSSGP side */ |
| 2515 | f_init_bssgp(); |
| 2516 | /* Initialize GPRS MS side */ |
| 2517 | f_init_gprs_ms(); |
| 2518 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 2519 | |
| 2520 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 2521 | 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] | 2522 | |
| 2523 | /* Establish BSSGP connection to the PCU */ |
| 2524 | f_bssgp_establish(); |
| 2525 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 2526 | |
| 2527 | /* Establish an Uplink TBF */ |
| 2528 | f_ms_establish_ul_tbf(ms); |
| 2529 | |
| 2530 | /* Fake GMM GPRS Attach or similar, PCU doesn't care about upper layers here */ |
| 2531 | f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true); |
| 2532 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn); |
| 2533 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 2534 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn); |
| 2535 | |
| 2536 | /* UL block should be received in SGSN */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 2537 | 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] | 2538 | |
| 2539 | /* Now SGSN sends some DL data with an invalid IMSI */ |
| 2540 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI('1122'H))); |
| 2541 | |
| 2542 | BSSGP_SIG[0].receive(tr_BSSGP_STATUS(omit, BSSGP_CAUSE_CONDITIONAL_IE_ERROR, ?)); |
| 2543 | |
| 2544 | /* TODO: make sure no data is sent over PCU -> MS */ |
| 2545 | |
| 2546 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2547 | } |
| 2548 | |
Pau Espin Pedrol | 2e459d6 | 2020-11-30 19:34:16 +0100 | [diff] [blame] | 2549 | private function f_tc_dl_data_no_llc_ui_dummy(template (omit) MSRadioAccessCapabilityV_BSSGP ms_racap := omit) runs on RAW_PCU_Test_CT { |
| 2550 | var AckNackDescription ack_nack_desc := valueof(t_AckNackDescription_init); |
| 2551 | var octetstring data := f_rnd_octstring(6); |
| 2552 | var RlcmacDlBlock dl_block; |
| 2553 | var GprsMS ms; |
| 2554 | var uint32_t fn; |
| 2555 | |
| 2556 | /* Initialize NS/BSSGP side */ |
| 2557 | f_init_bssgp(); |
| 2558 | /* Initialize GPRS MS side */ |
| 2559 | f_init_gprs_ms(); |
| 2560 | ms := g_ms[0]; /* We only use first MS in this test */ |
| 2561 | |
| 2562 | /* Initialize the PCU interface abstraction */ |
| 2563 | f_init_raw(testcasename()); |
| 2564 | |
| 2565 | /* Establish BSSGP connection to the PCU */ |
| 2566 | f_bssgp_establish(); |
| 2567 | f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli); |
| 2568 | |
| 2569 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
| 2570 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, ms_racap)); |
| 2571 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
| 2572 | |
| 2573 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS */ |
| 2574 | f_sleep(X2002); |
| 2575 | |
| 2576 | /* Expect the first (GPRS DL) block with bsn=0 and rrbp_valid=1 */ |
| 2577 | f_rx_rlcmac_dl_block_exp_data(dl_block, fn, data, 0); |
| 2578 | |
| 2579 | if (ischosen(dl_block.data_egprs)) { |
| 2580 | if (lengthof(dl_block.data_egprs.blocks) != 2) { |
| 2581 | setverdict(fail, "DL EGPRS block has unexpected number of LLC frames: ", dl_block.data_egprs); |
| 2582 | f_shutdown(__BFILE__, __LINE__); |
| 2583 | } |
| 2584 | if (dl_block.data_egprs.blocks[1].hdr.length_ind != 127) { |
| 2585 | setverdict(fail, "DL EGPRS block 2nd llc frame is not padding!: ", dl_block.data_egprs); |
| 2586 | f_shutdown(__BFILE__, __LINE__); |
| 2587 | } |
| 2588 | if (not match(dl_block.data_egprs.blocks[1].payload, |
| 2589 | f_pad_oct(''O, lengthof(dl_block.data_egprs.blocks[1].payload), '2B'O))) { |
| 2590 | setverdict(fail, "DL EGPRS block 2nd llc frame is not padding!: ", dl_block.data_egprs); |
| 2591 | f_shutdown(__BFILE__, __LINE__); |
| 2592 | } |
| 2593 | } else if (lengthof(dl_block.data.blocks) > 1) { |
| 2594 | setverdict(fail, "DL GPRS block has extra unexpected LLC frames: ", dl_block.data); |
| 2595 | f_shutdown(__BFILE__, __LINE__); |
| 2596 | } |
| 2597 | |
| 2598 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2599 | } |
| 2600 | |
| 2601 | /* Verify osmo-pcu Doesn't append LLC UI dummy frames to rlcmac blocks |
| 2602 | * containing llc data. See OS#4849 */ |
| 2603 | testcase TC_dl_gprs_data_no_llc_ui_dummy() runs on RAW_PCU_Test_CT { |
| 2604 | f_tc_dl_data_no_llc_ui_dummy(omit); |
| 2605 | } |
| 2606 | |
| 2607 | /* Verify osmo-pcu Doesn't append LLC UI dummy frames to rlcmac blocks |
| 2608 | * containing llc data. See OS#4849 */ |
| 2609 | testcase TC_dl_egprs_data_no_llc_ui_dummy() runs on RAW_PCU_Test_CT { |
| 2610 | |
| 2611 | var MultislotCap_GPRS_BSSGP mscap_gprs := { |
| 2612 | gprsmultislotclass := '00011'B, |
| 2613 | gprsextendeddynalloccap := '0'B |
| 2614 | }; |
| 2615 | var MultislotCap_EGPRS_BSSGP mscap_egprs := { |
| 2616 | egprsmultislotclass := '00011'B, |
| 2617 | egprsextendeddynalloccap := '0'B |
| 2618 | }; |
| 2619 | var MSRadioAccessCapabilityV_BSSGP ms_racap := { valueof(ts_RaCapRec_BSSGP('0001'B /* E-GSM */, mscap_gprs, mscap_egprs)) }; |
| 2620 | |
| 2621 | f_tc_dl_data_no_llc_ui_dummy(ms_racap); |
| 2622 | } |
| 2623 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2624 | private function f_TC_egprs_pkt_chan_req(in EGPRSPktChRequest req, |
Vadim Yanitskiy | 4389390 | 2020-05-29 15:21:50 +0700 | [diff] [blame] | 2625 | template GsmRrMessage t_imm_ass := ?, |
| 2626 | PCUIF_BurstType bt := BURST_TYPE_1) |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2627 | runs on RAW_PCU_Test_CT { |
Vadim Yanitskiy | 4389390 | 2020-05-29 15:21:50 +0700 | [diff] [blame] | 2628 | var GsmRrMessage rr_msg; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2629 | var uint16_t ra11; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2630 | |
| 2631 | ra11 := enc_EGPRSPktChRequest2uint(req); |
| 2632 | log("Sending EGPRS Packet Channel Request (", ra11, "): ", req); |
| 2633 | |
Vadim Yanitskiy | 28d18e1 | 2020-05-29 15:25:59 +0700 | [diff] [blame] | 2634 | 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] | 2635 | if (not match(rr_msg, t_imm_ass)) { |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2636 | setverdict(fail, "Immediate Assignment does not match"); |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 2637 | f_shutdown(__BFILE__, __LINE__); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2638 | } |
| 2639 | |
| 2640 | setverdict(pass); |
| 2641 | } |
| 2642 | |
| 2643 | testcase TC_egprs_pkt_chan_req_signalling() runs on RAW_PCU_Test_CT { |
| 2644 | var template GsmRrMessage imm_ass; |
| 2645 | var template IaRestOctets rest; |
| 2646 | var template EgprsUlAss ul_ass; |
| 2647 | |
| 2648 | /* Initialize the PCU interface abstraction */ |
| 2649 | f_init_raw(testcasename()); |
| 2650 | |
| 2651 | var EGPRSPktChRequest req := { |
| 2652 | /* NOTE: other fields are set in the loop */ |
| 2653 | signalling := { tag := '110011'B } |
| 2654 | }; |
| 2655 | |
| 2656 | for (var integer i := 0; i < 6; i := i + 1) { |
| 2657 | var BIT5 ext_ra := int2bit(f_rnd_int(32), 5); |
| 2658 | req.signalling.random_bits := ext_ra; |
| 2659 | |
| 2660 | /* For signalling, do we expect Multiblock UL TBF Assignment? */ |
| 2661 | ul_ass := tr_EgprsUlAssMultiblock(ext_ra := ext_ra); |
| 2662 | rest := tr_IaRestOctets_EGPRSULAss(ul_ass); |
| 2663 | imm_ass := tr_IMM_TBF_ASS(dl := false, rest := rest); |
| 2664 | |
| 2665 | f_TC_egprs_pkt_chan_req(req, imm_ass); |
| 2666 | } |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 2667 | |
| 2668 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2669 | } |
| 2670 | |
| 2671 | testcase TC_egprs_pkt_chan_req_one_phase() runs on RAW_PCU_Test_CT { |
| 2672 | var template GsmRrMessage imm_ass; |
| 2673 | var template IaRestOctets rest; |
| 2674 | var template EgprsUlAss ul_ass; |
| 2675 | |
| 2676 | /* Initialize the PCU interface abstraction */ |
| 2677 | f_init_raw(testcasename()); |
| 2678 | |
| 2679 | var EGPRSPktChRequest req := { |
| 2680 | /* NOTE: other fields are set in the loop */ |
| 2681 | one_phase := { tag := '0'B } |
| 2682 | }; |
| 2683 | |
| 2684 | for (var integer i := 0; i < 6; i := i + 1) { |
| 2685 | var BIT5 ext_ra := int2bit(f_rnd_int(32), 5); |
| 2686 | var BIT5 mslot_class := int2bit(f_rnd_int(32), 5); |
| 2687 | var BIT2 priority := substr(ext_ra, 0, 2); |
| 2688 | var BIT3 rand := substr(ext_ra, 2, 3); |
| 2689 | |
| 2690 | req.one_phase.multislot_class := mslot_class; |
| 2691 | req.one_phase.priority := priority; |
| 2692 | req.one_phase.random_bits := rand; |
| 2693 | |
| 2694 | /* For one phase access, do we expect Dynamic UL TBF Assignment? */ |
| 2695 | ul_ass := tr_EgprsUlAssDynamic(ext_ra := ext_ra); |
| 2696 | rest := tr_IaRestOctets_EGPRSULAss(ul_ass); |
| 2697 | imm_ass := tr_IMM_TBF_ASS(dl := false, rest := rest); |
| 2698 | |
| 2699 | f_TC_egprs_pkt_chan_req(req, imm_ass); |
| 2700 | } |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 2701 | |
| 2702 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2703 | } |
| 2704 | |
| 2705 | testcase TC_egprs_pkt_chan_req_two_phase() runs on RAW_PCU_Test_CT { |
| 2706 | var template GsmRrMessage imm_ass; |
| 2707 | var template IaRestOctets rest; |
| 2708 | var template EgprsUlAss ul_ass; |
| 2709 | |
| 2710 | /* Initialize the PCU interface abstraction */ |
| 2711 | f_init_raw(testcasename()); |
| 2712 | |
| 2713 | var EGPRSPktChRequest req := { |
| 2714 | /* NOTE: other fields are set in the loop */ |
| 2715 | two_phase := { tag := '110000'B } |
| 2716 | }; |
| 2717 | |
| 2718 | for (var integer i := 0; i < 6; i := i + 1) { |
| 2719 | var BIT5 ext_ra := int2bit(f_rnd_int(32), 5); |
| 2720 | var BIT2 priority := substr(ext_ra, 0, 2); |
| 2721 | var BIT3 rand := substr(ext_ra, 2, 3); |
| 2722 | |
| 2723 | req.two_phase.priority := priority; |
| 2724 | req.two_phase.random_bits := rand; |
| 2725 | |
| 2726 | /* For two phase access, do we expect Multiblock UL TBF Assignment? */ |
| 2727 | ul_ass := tr_EgprsUlAssMultiblock(ext_ra := ext_ra); |
| 2728 | rest := tr_IaRestOctets_EGPRSULAss(ul_ass); |
| 2729 | imm_ass := tr_IMM_TBF_ASS(dl := false, rest := rest); |
| 2730 | |
| 2731 | f_TC_egprs_pkt_chan_req(req, imm_ass); |
| 2732 | } |
Vadim Yanitskiy | 91f8a09 | 2020-05-06 21:41:05 +0700 | [diff] [blame] | 2733 | |
| 2734 | f_shutdown(__BFILE__, __LINE__, final := true); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 2735 | } |
| 2736 | |
Vadim Yanitskiy | 4f56d32 | 2020-05-22 20:15:48 +0700 | [diff] [blame] | 2737 | private function f_TC_egprs_pkt_chan_req_reject(bitstring ra11, uint32_t fn, |
| 2738 | template IARRestOctets rest := ?, |
| 2739 | PCUIF_BurstType bt := BURST_TYPE_1) |
| 2740 | runs on RAW_PCU_Test_CT { |
| 2741 | var template ReqRefWaitInd tr_ref; |
| 2742 | var GsmRrMessage rr_msg; |
Vadim Yanitskiy | 4f56d32 | 2020-05-22 20:15:48 +0700 | [diff] [blame] | 2743 | |
| 2744 | /* Send RACH.ind with malformed EGPRS Packet Channel Request */ |
| 2745 | BTS.send(ts_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 0, |
| 2746 | ra := bit2int(ra11), is_11bit := 1, |
| 2747 | burst_type := bt, fn := fn, |
| 2748 | arfcn := 871)); |
| 2749 | |
| 2750 | /* Abuse f_pcuif_rx_imm_ass(): wait for Immediate Assignment Reject */ |
Vadim Yanitskiy | 7466c33 | 2020-05-28 20:41:19 +0700 | [diff] [blame] | 2751 | 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] | 2752 | |
| 2753 | /* Just to have a short-name reference to the actual message */ |
| 2754 | var ImmediateAssignmentReject iar := rr_msg.payload.imm_ass_rej; |
| 2755 | |
| 2756 | /* Make sure that Request Reference list contains at least one entry |
| 2757 | * with our TDMA frame number, and RA is set to 'reserved' value 127. */ |
| 2758 | tr_ref := tr_ReqRefWaitInd(f_compute_ReqRef(127, fn)); |
| 2759 | if (not match(iar.payload, { *, tr_ref, * })) { |
| 2760 | setverdict(fail, "Request Reference list does not match"); |
| 2761 | f_shutdown(__BFILE__, __LINE__); |
| 2762 | } |
| 2763 | |
| 2764 | /* Match Feature Indicator (must indicate PS domain) */ |
| 2765 | if (not match(iar.feature_ind, FeatureIndicator:{?, false, true})) { |
| 2766 | setverdict(fail, "Feature Indicator does not match"); |
| 2767 | f_shutdown(__BFILE__, __LINE__); |
| 2768 | } |
| 2769 | |
| 2770 | /* Match IAR Rest Octets */ |
| 2771 | if (not match(iar.rest_octets, rest)) { |
| 2772 | setverdict(fail, "IAR Rest Octets does not match: ", |
| 2773 | iar.rest_octets, " vs expected ", rest); |
| 2774 | f_shutdown(__BFILE__, __LINE__); |
| 2775 | } |
| 2776 | |
| 2777 | setverdict(pass); |
| 2778 | } |
| 2779 | |
| 2780 | /* Verify the contents of RR Immediate Assignment Reject message and its |
| 2781 | * Rest Octets sent in response to EGPRS Packet Channel Request (11 bit). */ |
| 2782 | testcase TC_egprs_pkt_chan_req_reject_content() runs on RAW_PCU_Test_CT { |
| 2783 | var template IARRestOctets rest; |
| 2784 | var BIT5 ext_ra; |
| 2785 | |
| 2786 | /* Initialize the PCU interface abstraction */ |
| 2787 | f_init_raw(testcasename()); |
| 2788 | |
| 2789 | for (var integer i := 0; i < 6; i := i + 1) { |
| 2790 | ext_ra := int2bit(f_rnd_int(32), 5); /* 5 LSB's of RA11 */ |
| 2791 | rest := tr_IARRestOctets({ *, tr_ExtRAOpt(ext_ra), * }); |
| 2792 | |
| 2793 | /* Intentionally incorrect message (see table 11.2.5a.2) */ |
| 2794 | f_TC_egprs_pkt_chan_req_reject('111111'B & ext_ra, 1337 + i, rest); |
| 2795 | } |
| 2796 | |
| 2797 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2798 | } |
| 2799 | |
Vadim Yanitskiy | 7e06c25 | 2020-05-22 20:48:53 +0700 | [diff] [blame] | 2800 | /* At the moment, the IUT does not support any emergency services. Make sure |
| 2801 | * that EGPRS Packet Channel Request for an emergency call is properly rejected. */ |
| 2802 | testcase TC_egprs_pkt_chan_req_reject_emergency() runs on RAW_PCU_Test_CT { |
| 2803 | var template IARRestOctets rest; |
| 2804 | var BIT5 ext_ra; |
| 2805 | var BIT11 ra11; |
| 2806 | |
| 2807 | /* Initialize the PCU interface abstraction */ |
| 2808 | f_init_raw(testcasename()); |
| 2809 | |
| 2810 | var EGPRSPktChRequest req := { |
| 2811 | /* NOTE: other fields are set in the loop */ |
| 2812 | emergency := { tag := '110111'B } |
| 2813 | }; |
| 2814 | |
| 2815 | for (var integer i := 0; i < 6; i := i + 1) { |
| 2816 | ext_ra := int2bit(f_rnd_int(32), 5); /* 5 LSB's of RA11 */ |
| 2817 | rest := tr_IARRestOctets({ *, tr_ExtRAOpt(ext_ra), * }); |
| 2818 | |
| 2819 | req.emergency.random_bits := ext_ra; |
| 2820 | ra11 := enc_EGPRSPktChRequest2bits(req); |
| 2821 | |
| 2822 | /* Intentionally incorrect message (see table 11.2.5a.2) */ |
| 2823 | f_TC_egprs_pkt_chan_req_reject(ra11, 1337 + i, rest); |
| 2824 | } |
| 2825 | |
| 2826 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2827 | } |
| 2828 | |
Vadim Yanitskiy | c4324ff | 2020-05-22 21:53:58 +0700 | [diff] [blame] | 2829 | /* Make sure that IUT responds with RR Immediate Assignment Reject due to exhaustion. */ |
| 2830 | 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] | 2831 | var PCUIF_info_ind info_ind; |
Vadim Yanitskiy | c4324ff | 2020-05-22 21:53:58 +0700 | [diff] [blame] | 2832 | var template IARRestOctets rest; |
| 2833 | var BIT11 ra11; |
| 2834 | |
Pau Espin Pedrol | 7ebc112 | 2020-10-29 13:33:39 +0100 | [diff] [blame] | 2835 | info_ind := valueof(ts_PCUIF_INFO_default); |
Vadim Yanitskiy | d5321fb | 2020-10-31 20:23:47 +0700 | [diff] [blame] | 2836 | |
| 2837 | /* Only the first TRX is enabled. */ |
| 2838 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000000'B, (1 .. 7)); |
| 2839 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000001'B, 0); |
Pau Espin Pedrol | 7ebc112 | 2020-10-29 13:33:39 +0100 | [diff] [blame] | 2840 | |
Vadim Yanitskiy | c4324ff | 2020-05-22 21:53:58 +0700 | [diff] [blame] | 2841 | /* Initialize the PCU interface abstraction */ |
Pau Espin Pedrol | 7ebc112 | 2020-10-29 13:33:39 +0100 | [diff] [blame] | 2842 | f_init_raw(testcasename(), info_ind); |
Vadim Yanitskiy | c4324ff | 2020-05-22 21:53:58 +0700 | [diff] [blame] | 2843 | |
| 2844 | var EGPRSPktChRequest req := { |
| 2845 | one_phase := { |
| 2846 | tag := '0'B, |
| 2847 | multislot_class := '10101'B, |
| 2848 | priority := '01'B, |
| 2849 | random_bits := '101'B |
| 2850 | } |
| 2851 | }; |
| 2852 | |
| 2853 | /* We send 7 requests, the IUT gives us all available USFs (0..6). |
| 2854 | * TODO: make it configurable: usf_max := mp_pdch_ts_num * 7. */ |
| 2855 | for (var integer i := 0; i < 7; i := i + 1) { |
| 2856 | req.one_phase.random_bits := int2bit(f_rnd_int(8), 3); |
| 2857 | f_TC_egprs_pkt_chan_req(req, tr_IMM_TBF_ASS); |
| 2858 | } |
| 2859 | |
| 2860 | ra11 := enc_EGPRSPktChRequest2bits(req); |
| 2861 | rest := tr_IARRestOctets({ *, tr_ExtRAOpt(substr(ra11, 6, 5)), * }); |
| 2862 | |
| 2863 | /* At this point, the IUT should run out of free USFs */ |
| 2864 | f_TC_egprs_pkt_chan_req_reject(ra11, 1870, rest); |
| 2865 | |
| 2866 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2867 | } |
| 2868 | |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 2869 | /* Randomly generate a set of hopping parameters for one timeslot */ |
Vadim Yanitskiy | 7a04cdd | 2020-09-07 11:43:32 +0700 | [diff] [blame] | 2870 | private function f_TC_pcuif_fh_params_gen(integer max_ma_len) |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 2871 | return template (value) PCUIF_InfoTrxTs { |
Vadim Yanitskiy | 7a04cdd | 2020-09-07 11:43:32 +0700 | [diff] [blame] | 2872 | /* Pick a random MA length in range 2 .. max_ma_len */ |
| 2873 | var integer ma_len := 2 + f_rnd_int(max_ma_len - 2); |
| 2874 | |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 2875 | return ts_PCUIF_InfoTrxTsH1(tsc := f_rnd_int(7), |
| 2876 | hsn := f_rnd_int(63), |
| 2877 | maio := f_rnd_int(63), |
| 2878 | ma := f_rnd_bitstring(ma_len)); |
| 2879 | } |
| 2880 | |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2881 | private function f_TC_pcuif_fh_check_imm_ass(in PCUIF_info_ind info_ind, |
| 2882 | in GsmRrMessage rr_msg) |
| 2883 | { |
| 2884 | var ImmediateAssignment ia := rr_msg.payload.imm_ass; |
| 2885 | var PCUIF_InfoTrxTs ts := info_ind.trx.v10[0].ts[ia.pkt_chan_desc.tn]; |
| 2886 | |
| 2887 | var template PacketChannelDescription tr_pkt_chan_desc := { |
| 2888 | channel_Type_spare := ?, |
| 2889 | tn := ?, |
| 2890 | tsc := ts.tsc, |
| 2891 | presence := '1'B, |
| 2892 | zero := omit, |
| 2893 | one := { |
| 2894 | maio := ts.maio, |
| 2895 | hsn := ts.hsn |
| 2896 | } |
| 2897 | }; |
| 2898 | |
| 2899 | if (not match(ia.pkt_chan_desc, tr_pkt_chan_desc)) { |
| 2900 | setverdict(fail, "Packet Channel Description does not match: ", |
| 2901 | ia.pkt_chan_desc, " vs ", tr_pkt_chan_desc); |
| 2902 | } |
| 2903 | |
Vadim Yanitskiy | 43ccaf5 | 2020-09-05 21:35:13 +0700 | [diff] [blame] | 2904 | /* Mobile Allocation is expected to be octet-aligned */ |
| 2905 | var uint8_t ma_oct_len := (ts.ma_bit_len + 8 - 1) / 8; |
| 2906 | var template MobileAllocationLV tr_ma := { |
| 2907 | len := ma_oct_len, /* in bytes */ |
| 2908 | ma := substr(ts.ma, 0, ma_oct_len * 8) |
| 2909 | }; |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2910 | |
| 2911 | if (not match(ia.mobile_allocation, tr_ma)) { |
| 2912 | setverdict(fail, "Mobile Allocation does not match: ", |
| 2913 | ia.mobile_allocation, " vs ", tr_ma); |
| 2914 | } |
| 2915 | |
| 2916 | setverdict(pass); |
| 2917 | } |
| 2918 | |
| 2919 | /* Make sure that Immediate (UL EGPRS TBF) Assignment contains hopping parameters */ |
| 2920 | testcase TC_pcuif_fh_imm_ass_ul_egprs() runs on RAW_PCU_Test_CT { |
| 2921 | var template PCUIF_info_ind info_ind := ts_PCUIF_INFO_default; |
| 2922 | var GprsMS ms := valueof(t_GprsMS_def); |
| 2923 | |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 2924 | /* Enable frequency hopping on TRX0/TS7 */ |
| 2925 | 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] | 2926 | |
| 2927 | /* Initialize the PCU interface abstraction */ |
| 2928 | f_init_raw(testcasename(), info_ind); |
| 2929 | |
| 2930 | /* EGPRS Packet Channel Request (cause=Signalling) */ |
| 2931 | f_ms_use_ra(ms, bit2int('11001101010'B), ra_is_11bit := 1); |
| 2932 | |
| 2933 | /* Establish an Uplink EGPRS TBF */ |
| 2934 | f_ms_establish_ul_tbf(ms); |
| 2935 | |
| 2936 | f_TC_pcuif_fh_check_imm_ass(valueof(info_ind), ms.ul_tbf.rr_imm_ass); |
| 2937 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2938 | } |
| 2939 | |
| 2940 | /* Make sure that Immediate (UL TBF) Assignment contains hopping parameters */ |
| 2941 | 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] | 2942 | 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] | 2943 | var GprsMS ms := valueof(t_GprsMS_def); |
| 2944 | |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 2945 | /* Enable frequency hopping on TRX0/TS7 */ |
| 2946 | 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] | 2947 | |
| 2948 | /* Initialize the PCU interface abstraction */ |
| 2949 | f_init_raw(testcasename(), info_ind); |
| 2950 | |
| 2951 | /* Establish an Uplink TBF */ |
| 2952 | f_ms_establish_ul_tbf(ms); |
| 2953 | |
| 2954 | f_TC_pcuif_fh_check_imm_ass(valueof(info_ind), ms.ul_tbf.rr_imm_ass); |
| 2955 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2956 | } |
| 2957 | |
| 2958 | /* Make sure that Immediate (DL TBF) Assignment contains hopping parameters */ |
| 2959 | 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] | 2960 | 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] | 2961 | var GprsMS ms := valueof(t_GprsMS_def); |
| 2962 | |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 2963 | /* Enable frequency hopping on TRX0/TS7 */ |
| 2964 | 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] | 2965 | |
| 2966 | /* Initialize NS/BSSGP side */ |
| 2967 | f_init_bssgp(); |
| 2968 | |
| 2969 | /* Initialize the PCU interface abstraction */ |
| 2970 | f_init_raw(testcasename(), info_ind); |
| 2971 | |
| 2972 | /* Establish BSSGP connection to the PCU */ |
| 2973 | f_bssgp_establish(); |
| 2974 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 2975 | |
| 2976 | /* SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
| 2977 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, f_rnd_octstring(12))); |
| 2978 | f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_PCH); |
| 2979 | |
| 2980 | f_TC_pcuif_fh_check_imm_ass(valueof(info_ind), ms.dl_tbf.rr_imm_ass); |
| 2981 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 2982 | } |
| 2983 | |
| 2984 | private function f_TC_pcuif_fh_check_pkt_ass(in PCUIF_info_ind info_ind, |
| 2985 | in FrequencyParameters fp) |
| 2986 | { |
| 2987 | /* FIXME: TRX0/TS7 is a hard-coded expectation, make it configurable */ |
| 2988 | var PCUIF_InfoTrxTs ts := info_ind.trx.v10[0].ts[7]; |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 2989 | |
| 2990 | /* Table 12.8.1: Frequency Parameters information elements */ |
| 2991 | var template FrequencyParameters tr_fp := { |
| 2992 | tsc := ts.tsc, |
| 2993 | presence := '10'B, /* Direct encoding 1 */ |
| 2994 | arfcn := omit, |
| 2995 | indirect := omit, |
| 2996 | direct1 := { |
| 2997 | maio := ts.maio, |
| 2998 | /* Table 12.10a.1: GPRS Mobile Allocation information elements */ |
| 2999 | mobile_allocation := { |
| 3000 | hsn := ts.hsn, |
| 3001 | rfl_number_list_present := '0'B, |
| 3002 | rfl_number_list := omit, |
| 3003 | ma_present := '0'B, /* inverted logic */ |
Vadim Yanitskiy | 43ccaf5 | 2020-09-05 21:35:13 +0700 | [diff] [blame] | 3004 | ma_length := ts.ma_bit_len, |
| 3005 | ma_bitmap := substr(ts.ma, 0, ts.ma_bit_len) |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 3006 | } |
| 3007 | }, |
| 3008 | direct2 := omit |
| 3009 | }; |
| 3010 | |
| 3011 | if (not match(fp, tr_fp)) { |
| 3012 | setverdict(fail, "Frequency Parameters IE does not match: ", |
| 3013 | fp, " vs ", tr_fp); |
| 3014 | } |
| 3015 | |
| 3016 | setverdict(pass); |
| 3017 | } |
| 3018 | |
| 3019 | /* Make sure that Packet Uplink Assignment contains hopping parameters */ |
| 3020 | 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] | 3021 | 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] | 3022 | var GprsMS ms := valueof(t_GprsMS_def); |
| 3023 | var uint32_t poll_fn; |
| 3024 | |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 3025 | /* Enable frequency hopping on TRX0/TS7 */ |
| 3026 | 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] | 3027 | |
| 3028 | /* Initialize the PCU interface abstraction */ |
| 3029 | f_init_raw(testcasename(), info_ind); |
| 3030 | |
| 3031 | /* Establish an Uplink TBF */ |
| 3032 | f_ms_establish_ul_tbf(ms); |
| 3033 | |
| 3034 | /* Send Packet Resource Request, so the network will allocate an Uplink resource */ |
| 3035 | f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, omit))); |
| 3036 | |
| 3037 | /* Expect an RLC/MAC block with Packet Uplink Assignment on PACCH (see 11.2.29) */ |
| 3038 | var RlcmacDlBlock blk := f_ms_rx_pkt_ass_pacch(ms, poll_fn, tr_RLCMAC_UL_PACKET_ASS); |
| 3039 | var PacketUlAssignment ua := blk.ctrl.payload.u.ul_assignment; |
| 3040 | |
| 3041 | /* 3GPP TS 44.060, section 12.8 "Frequency Parameters" */ |
| 3042 | var template (omit) FrequencyParameters fp; |
| 3043 | if (ua.is_egprs == '1'B) { |
| 3044 | fp := ua.egprs.freq_par; |
| 3045 | } else { |
| 3046 | fp := ua.gprs.freq_par; |
| 3047 | } |
| 3048 | |
| 3049 | /* This is an optional IE, so it's worth to check its presence */ |
| 3050 | if (istemplatekind(fp, "omit")) { |
| 3051 | setverdict(fail, "Frequency Parameters IE is not present"); |
| 3052 | f_shutdown(__BFILE__, __LINE__); |
| 3053 | } |
| 3054 | |
| 3055 | f_TC_pcuif_fh_check_pkt_ass(valueof(info_ind), valueof(fp)); |
| 3056 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 3057 | } |
| 3058 | |
| 3059 | /* Make sure that Packet Downlink Assignment contains hopping parameters */ |
| 3060 | 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] | 3061 | 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] | 3062 | var octetstring data := f_rnd_octstring(10); |
| 3063 | var GprsMS ms := valueof(t_GprsMS_def); |
| 3064 | var RlcmacDlBlock dl_block; |
| 3065 | var uint32_t poll_fn; |
| 3066 | |
Vadim Yanitskiy | ef0c1b5 | 2020-09-05 21:32:18 +0700 | [diff] [blame] | 3067 | /* Enable frequency hopping on TRX0/TS7 */ |
| 3068 | 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] | 3069 | |
| 3070 | /* Initialize NS/BSSGP side */ |
| 3071 | f_init_bssgp(); |
| 3072 | |
| 3073 | /* Initialize the PCU interface abstraction */ |
| 3074 | f_init_raw(testcasename(), info_ind); |
| 3075 | |
| 3076 | /* Establish BSSGP connection to the PCU */ |
| 3077 | f_bssgp_establish(); |
| 3078 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, ms.tlli); |
| 3079 | |
| 3080 | /* Establish an Uplink TBF */ |
| 3081 | f_ms_establish_ul_tbf(ms); |
| 3082 | |
| 3083 | /* Send an Uplink block, so this TBF becomes "active" */ |
| 3084 | f_ms_tx_ul_data_block(ms, data, with_tlli := true); |
| 3085 | |
| 3086 | /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 3087 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, poll_fn); |
| 3088 | f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), poll_fn); |
| 3089 | |
| 3090 | /* SGSN sends some DL data, PCU will assign Downlink resource on PACCH */ |
| 3091 | BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data)); |
| 3092 | |
| 3093 | /* Expect an RLC/MAC block with Packet Downlink Assignment on PACCH (see 11.2.29) */ |
| 3094 | dl_block := f_ms_rx_pkt_ass_pacch(ms, poll_fn, tr_RLCMAC_DL_PACKET_ASS); |
| 3095 | var PacketDlAssignment da := dl_block.ctrl.payload.u.dl_assignment; |
| 3096 | |
| 3097 | /* This is an optional IE, so it's worth to check its presence */ |
| 3098 | if (not ispresent(da.freq_par)) { |
| 3099 | setverdict(fail, "Frequency Parameters IE is not present"); |
| 3100 | f_shutdown(__BFILE__, __LINE__); |
| 3101 | } |
| 3102 | |
| 3103 | f_TC_pcuif_fh_check_pkt_ass(valueof(info_ind), da.freq_par); |
| 3104 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 3105 | } |
| 3106 | |
Vadim Yanitskiy | d53fb67 | 2020-10-09 16:41:02 +0700 | [diff] [blame] | 3107 | /* Check if the IUT handles subsequent INFO.ind messages */ |
| 3108 | testcase TC_pcuif_info_ind_subsequent() runs on RAW_PCU_Test_CT { |
| 3109 | var template PCUIF_info_ind info_ind := ts_PCUIF_INFO_default; |
| 3110 | var PCUIF_Message pcu_msg; |
| 3111 | |
| 3112 | /* Initialize the PCU interface abstraction */ |
| 3113 | f_init_raw(testcasename(), info_ind); |
| 3114 | |
| 3115 | /* Send 16 conseqtive INFO.ind messages and check that the IUT stays alive */ |
| 3116 | for (var integer i := 0; i < 16; i := i + 1) { |
| 3117 | BTS.send(ts_PCUIF_INFO_IND(0, info_ind)); |
| 3118 | f_pcuif_rx_data_req(pcu_msg); |
| 3119 | } |
| 3120 | |
| 3121 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 3122 | } |
| 3123 | |
Pau Espin Pedrol | bfd69f6 | 2020-10-22 18:06:07 +0200 | [diff] [blame] | 3124 | /* Verify allocation of several MS along PDCH ts of several TRX. See OS#1775, SYS#5030 */ |
| 3125 | testcase TC_multitrx_multims_alloc() runs on RAW_PCU_Test_CT { |
| 3126 | var PCUIF_info_ind info_ind; |
| 3127 | var integer i; |
| 3128 | const integer num_ms := 8; |
| 3129 | |
| 3130 | /* Initialize NS/BSSGP side */ |
| 3131 | f_init_bssgp(); |
| 3132 | /* Initialize GPRS MS side */ |
| 3133 | f_init_gprs_ms(num_ms); |
| 3134 | |
Pau Espin Pedrol | 745a48b | 2020-10-30 15:31:07 +0100 | [diff] [blame] | 3135 | info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS)); |
Pau Espin Pedrol | bfd69f6 | 2020-10-22 18:06:07 +0200 | [diff] [blame] | 3136 | /* Only the 3 first TRX are enabled. The enabled ones all have same |
| 3137 | amount of resources, hence same amount of initial resources. */ |
Vadim Yanitskiy | d5321fb | 2020-10-31 20:23:47 +0700 | [diff] [blame] | 3138 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000000'B, (3 .. 7)); |
| 3139 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000011'B, 0); |
| 3140 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00001100'B, 1); |
| 3141 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '11000000'B, 2); |
Pau Espin Pedrol | bfd69f6 | 2020-10-22 18:06:07 +0200 | [diff] [blame] | 3142 | |
| 3143 | /* Initialize the PCU interface abstraction */ |
| 3144 | f_init_raw(testcasename(), info_ind); |
| 3145 | |
| 3146 | /* Establish BSSGP connection to the PCU */ |
| 3147 | f_bssgp_establish(); |
Vadim Yanitskiy | 8a02b92 | 2020-10-31 21:57:10 +0700 | [diff] [blame] | 3148 | f_multi_ms_bssgp_register(); |
Pau Espin Pedrol | bfd69f6 | 2020-10-22 18:06:07 +0200 | [diff] [blame] | 3149 | |
Vadim Yanitskiy | 8a02b92 | 2020-10-31 21:57:10 +0700 | [diff] [blame] | 3150 | /* Establish an Uplink TBF for each GprsMS instance */ |
| 3151 | f_multi_ms_establish_tbf(do_activate := false); |
| 3152 | |
| 3153 | /* 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] | 3154 | for (i := 0; i < num_ms; i := i + 1) { |
Pau Espin Pedrol | b20b7e5 | 2020-10-28 21:28:45 +0100 | [diff] [blame] | 3155 | if (g_ms[i].ul_tbf.arfcn != info_ind.trx.v10[i mod 3].arfcn) { |
| 3156 | setverdict(fail, "Got assigned ARFCN ", g_ms[i].ul_tbf.arfcn, |
| 3157 | " vs exp ", info_ind.trx.v10[i mod 3].arfcn); |
Pau Espin Pedrol | bfd69f6 | 2020-10-22 18:06:07 +0200 | [diff] [blame] | 3158 | f_shutdown(__BFILE__, __LINE__); |
| 3159 | } |
| 3160 | } |
| 3161 | |
| 3162 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 3163 | } |
| 3164 | |
Pau Espin Pedrol | e130305 | 2020-11-16 11:13:51 +0100 | [diff] [blame] | 3165 | /* Verify concurrent PDCH use of EGPRS and GPRS (EGPRS dl rlcmac blk is |
| 3166 | * downgraded to CS1-4 so that GPRS can read the USF). |
| 3167 | * See 3GPP TS 44.060 5.2.4a "Multiplexing of GPRS, EGPRS and EGPRS2 capable mobile stations" |
| 3168 | */ |
| 3169 | testcase TC_multiplex_dl_gprs_egprs() runs on RAW_PCU_Test_CT { |
| 3170 | var PCUIF_info_ind info_ind; |
| 3171 | const integer num_ms := 2; /* 2 MS, first one is GPRS-only, second one is EGPRS */ |
| 3172 | var PollFnCtx pollctx; |
| 3173 | var MSRadioAccessCapabilityV ms_racap; |
| 3174 | var uint32_t sched_fn, dl_fn, ack_fn; |
| 3175 | var octetstring data := f_rnd_octstring(10); |
| 3176 | var RlcmacDlBlock dl_block; |
| 3177 | var integer tx_data_remain := 5; |
| 3178 | var integer tgt_ms; |
| 3179 | var integer ms_gprs_usf_count[num_ms] := { 0, 0 }; |
| 3180 | var integer ms_egprs_usf_count[num_ms] := { 0, 0 }; |
| 3181 | |
| 3182 | /* Initialize NS/BSSGP side */ |
| 3183 | f_init_bssgp(); |
| 3184 | /* Initialize GPRS MS side */ |
| 3185 | f_init_gprs_ms(num_ms); |
| 3186 | |
| 3187 | info_ind := valueof(ts_PCUIF_INFO_default); |
| 3188 | /* Only use 1 PDCH to make sure both end up in the same slot: */ |
| 3189 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000001'B, 0); |
| 3190 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, '00000000'B, (1 .. 7)); |
| 3191 | |
| 3192 | /* Initialize the PCU interface abstraction */ |
| 3193 | f_init_raw(testcasename(), info_ind); |
| 3194 | |
| 3195 | /* Set Initial MCS > 4 and maintain it non-variable to simplify test */ |
| 3196 | g_mcs_initial_dl := 5; |
| 3197 | g_mcs_max_dl := 5; |
| 3198 | f_pcuvty_set_allowed_cs_mcs(); |
| 3199 | |
| 3200 | /* Establish BSSGP connection to the PCU */ |
| 3201 | f_bssgp_establish(); |
| 3202 | f_multi_ms_bssgp_register(); |
| 3203 | |
| 3204 | var MultislotCap_GPRS mscap_gprs := { |
| 3205 | gprsmultislotclass := '00011'B, |
| 3206 | gprsextendeddynalloccap := '0'B |
| 3207 | }; |
| 3208 | var MultislotCap_EGPRS mscap_egprs := { |
| 3209 | egprsmultislotclass := '00011'B, |
| 3210 | egprsextendeddynalloccap := '0'B |
| 3211 | }; |
| 3212 | |
| 3213 | /* Establish UL TBF for MS0 (GPRS-only) */ |
| 3214 | ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, omit)) }; |
| 3215 | pollctx := f_ms_establish_ul_tbf_2phase_access(g_ms[0], ts_RlcMacUlCtrl_PKT_RES_REQ(g_ms[0].tlli, ms_racap)); |
| 3216 | if (not match(g_ms[0].ul_tbf.tx_cs_mcs, cs_gprs_any)) { |
| 3217 | setverdict(fail, "Wrong CS_MCS ", g_ms[0].ul_tbf.tx_cs_mcs, " received vs exp ", cs_gprs_any); |
| 3218 | f_shutdown(__BFILE__, __LINE__); |
| 3219 | } |
| 3220 | /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 3221 | f_ms_tx_ul_block(g_ms[0], ts_RLCMAC_CTRL_ACK(g_ms[0].tlli), pollctx.fn, nr := pollctx.tstrxbts); |
| 3222 | |
| 3223 | /* Establish UL TBF for MS1 (EGPRS) */ |
| 3224 | ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, mscap_egprs)) }; |
| 3225 | pollctx := f_ms_establish_ul_tbf_2phase_access(g_ms[1], ts_RlcMacUlCtrl_PKT_RES_REQ(g_ms[1].tlli, ms_racap)); |
| 3226 | if (not match(g_ms[1].ul_tbf.tx_cs_mcs, mcs_egprs_any)) { |
| 3227 | setverdict(fail, "Wrong CS_MCS ", g_ms[1].ul_tbf.tx_cs_mcs, " received vs exp ", mcs_egprs_any); |
| 3228 | f_shutdown(__BFILE__, __LINE__); |
| 3229 | } |
| 3230 | /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 3231 | f_ms_tx_ul_block(g_ms[1], ts_RLCMAC_CTRL_ACK(g_ms[1].tlli), pollctx.fn, nr := pollctx.tstrxbts); |
| 3232 | |
| 3233 | /* Now SGSN sends some DL data to MS0, PCU will assign a GPRS DL TBF on PACCH */ |
| 3234 | BSSGP[0].send(ts_BSSGP_DL_UD(g_ms[0].tlli, data)); |
| 3235 | f_sleep(0.1); |
| 3236 | f_ms_rx_pkt_ass_pacch(g_ms[0], sched_fn, tr_RLCMAC_DL_PACKET_ASS); |
| 3237 | /* DL Ass sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 3238 | f_ms_tx_ul_block(g_ms[0], ts_RLCMAC_CTRL_ACK(g_ms[0].tlli), sched_fn); |
| 3239 | /* After acking the dl assignment, dl tbf goes into FLOW state and PCU will provide DL data when BTS asks for it */ |
| 3240 | f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0, cs_gprs_any); |
| 3241 | /* ACK the DL block */ |
| 3242 | f_dltbf_ack_block(g_ms[0].dl_tbf, dl_block, '0'B); |
| 3243 | f_ms_tx_ul_block(g_ms[0], f_dltbf_ts_RLCMAC_DL_ACK_NACK(g_ms[0].dl_tbf, false), |
| 3244 | f_dl_block_ack_fn(dl_block, dl_fn)); |
| 3245 | |
| 3246 | /* Now SGSN sends some DL data to MS1, PCU will assign a EGPRS DL TBF on PACCH */ |
| 3247 | BSSGP[0].send(ts_BSSGP_DL_UD(g_ms[1].tlli, data)); |
| 3248 | f_sleep(0.1); |
| 3249 | f_ms_rx_pkt_ass_pacch(g_ms[1], sched_fn, tr_RLCMAC_DL_PACKET_ASS); |
| 3250 | /* DL Ass sets poll+rrbp requesting PACKET CONTROL ACK */ |
| 3251 | f_ms_tx_ul_block(g_ms[1], ts_RLCMAC_CTRL_ACK(g_ms[1].tlli), sched_fn); |
| 3252 | /* After acking the dl assignment, dl tbf goes into FLOW state and PCU will provide DL data when BTS asks for it */ |
| 3253 | f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0, mcs_egprs_any); |
| 3254 | /* ACK the DL block */ |
| 3255 | f_dltbf_ack_block(g_ms[1].dl_tbf, dl_block, '0'B); |
| 3256 | f_ms_tx_ul_block(g_ms[1], f_dltbf_ts_RLCMAC_DL_ACK_NACK(g_ms[1].dl_tbf, true), |
| 3257 | f_dl_block_ack_fn(dl_block, dl_fn)); |
| 3258 | |
| 3259 | data := f_rnd_octstring(1400); |
| 3260 | BSSGP[0].send(ts_BSSGP_DL_UD(g_ms[0].tlli, data)); |
| 3261 | BSSGP[0].send(ts_BSSGP_DL_UD(g_ms[1].tlli, data)); |
| 3262 | |
| 3263 | for (var integer i := 0; i < 800; i := i + 1) { |
| 3264 | f_rx_rlcmac_dl_block(dl_block, dl_fn); |
| 3265 | |
| 3266 | if (match(dl_block, tr_RLCMAC_DUMMY_CTRL)) { |
| 3267 | /* No more data to receive, done */ |
| 3268 | break; |
| 3269 | } |
| 3270 | |
| 3271 | if (ischosen(dl_block.ctrl)) { |
| 3272 | setverdict(fail, "Unexpected DL CTRL block ", dl_block); |
| 3273 | f_shutdown(__BFILE__, __LINE__); |
| 3274 | } else if (ischosen(dl_block.data_egprs)) { |
| 3275 | if (not match(dl_block.data_egprs.mac_hdr.tfi, g_ms[1].dl_tbf.tfi)) { |
| 3276 | setverdict(fail, "EGPRS DL DATA not matching EGPRS MS TFI (", g_ms[1].dl_tbf.tfi, "): ", dl_block.data_egprs.mac_hdr.tfi); |
| 3277 | f_shutdown(__BFILE__, __LINE__); |
| 3278 | } |
| 3279 | tgt_ms := 1; |
| 3280 | if (match(dl_block.data_egprs.mac_hdr.usf, g_ms[0].ul_tbf.usf[7])) { |
| 3281 | if (dl_block.data_egprs.mcs > MCS_4) { |
| 3282 | setverdict(fail, "Signalling USF ", dl_block.data_egprs.mac_hdr.usf, " for GPRS-only MS using MCS > 4: ", dl_block); |
| 3283 | f_shutdown(__BFILE__, __LINE__); |
| 3284 | } |
| 3285 | ms_egprs_usf_count[0] := ms_egprs_usf_count[0] + 1; |
| 3286 | } else { |
| 3287 | if (dl_block.data_egprs.mcs <= MCS_4) { |
| 3288 | setverdict(fail, "Using too-low MCS for EGPRS MS: ", dl_block.data_egprs.mcs); |
| 3289 | f_shutdown(__BFILE__, __LINE__); |
| 3290 | } |
| 3291 | if (match(dl_block.data_egprs.mac_hdr.usf, g_ms[1].ul_tbf.usf[7])) { |
| 3292 | ms_egprs_usf_count[1] := ms_egprs_usf_count[1] + 1; |
| 3293 | } |
| 3294 | } |
| 3295 | } else { |
| 3296 | if (not match(dl_block.data.mac_hdr.hdr_ext.tfi, g_ms[0].dl_tbf.tfi)) { |
| 3297 | setverdict(fail, "GPRS DL DATA not matching GPRS MS TFI (", g_ms[0].dl_tbf.tfi, "): ", dl_block.data.mac_hdr.hdr_ext.tfi); |
| 3298 | f_shutdown(__BFILE__, __LINE__); |
| 3299 | } |
| 3300 | tgt_ms := 0; |
| 3301 | if (match(dl_block.data.mac_hdr.mac_hdr.usf, g_ms[0].ul_tbf.usf[7])) { |
| 3302 | ms_gprs_usf_count[0] := ms_gprs_usf_count[0] + 1; |
| 3303 | } else if (match(dl_block.data.mac_hdr.mac_hdr.usf, g_ms[1].ul_tbf.usf[7])) { |
| 3304 | ms_gprs_usf_count[1] := ms_gprs_usf_count[1] + 1; |
| 3305 | } |
| 3306 | } |
| 3307 | |
| 3308 | /* Keep Ack/Nack description updated */ |
| 3309 | f_dltbf_ack_block(g_ms[tgt_ms].dl_tbf, dl_block); |
| 3310 | |
| 3311 | /* TDMA frame number on which we are supposed to send the ACK */ |
| 3312 | if (f_dl_block_rrbp_valid(dl_block)) { |
| 3313 | ack_fn := f_dl_block_ack_fn(dl_block, dl_fn); |
| 3314 | f_ms_tx_ul_block(g_ms[tgt_ms], f_dltbf_ts_RLCMAC_DL_ACK_NACK(g_ms[tgt_ms].dl_tbf, ischosen(dl_block.data_egprs)), ack_fn); |
| 3315 | if (tx_data_remain != 0) { |
| 3316 | /* Submit more data from time to time to keep the TBF ongoing */ |
| 3317 | BSSGP[0].send(ts_BSSGP_DL_UD(g_ms[0].tlli, data)); |
| 3318 | BSSGP[0].send(ts_BSSGP_DL_UD(g_ms[1].tlli, data)); |
| 3319 | tx_data_remain := tx_data_remain - 1; |
| 3320 | } |
| 3321 | } |
| 3322 | } |
| 3323 | |
| 3324 | log("results: ms_gprs_usf_count=", ms_gprs_usf_count, " / ms_egprs_usf_count=", ms_egprs_usf_count); |
| 3325 | if (ms_gprs_usf_count[0] == 0 or ms_gprs_usf_count[1] == 0 or |
| 3326 | ms_egprs_usf_count[0] == 0 or ms_egprs_usf_count[1] == 0) { |
| 3327 | setverdict(fail, "USF thresholds not met!"); |
| 3328 | f_shutdown(__BFILE__, __LINE__); |
| 3329 | } |
| 3330 | |
| 3331 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 3332 | } |
| 3333 | |
| 3334 | |
Vadim Yanitskiy | dbd4b24 | 2020-10-31 05:44:58 +0700 | [diff] [blame] | 3335 | private function f_TC_paging_cs_multi_ms(template (value) TsTrxBtsNum nr, |
| 3336 | boolean exp_imsi, boolean exp_tmsi) |
| 3337 | runs on RAW_PCU_Test_CT { |
| 3338 | var bitstring mask := f_pad_bit(''B, lengthof(g_ms), '0'B); |
| 3339 | var integer pending := lengthof(g_ms); |
| 3340 | var RlcmacDlBlock dl_block; |
| 3341 | var boolean f1, f2; |
| 3342 | |
| 3343 | while (pending > 0) { |
| 3344 | var uint32_t poll_fn; |
| 3345 | |
| 3346 | /* Obtain a Downlink block and make sure it is a paging request */ |
| 3347 | f_rx_rlcmac_dl_block(dl_block, poll_fn, nr := nr); |
| 3348 | if (not match(dl_block, tr_RLCMAC_PACKET_PAG_REQ)) { |
| 3349 | setverdict(fail, "Rx unexpected DL block: ", dl_block); |
| 3350 | break; |
| 3351 | } |
| 3352 | |
| 3353 | /* This should not happen in general, but who knows... */ |
| 3354 | var PacketPagingReq req := dl_block.ctrl.payload.u.paging; |
| 3355 | if (not ispresent(req.repeated_pageinfo)) { |
| 3356 | setverdict(fail, "Repeated Page Info IE is absent?!?"); |
| 3357 | break; |
| 3358 | } |
| 3359 | |
| 3360 | /* A single message may contain several MIs depending on their type */ |
| 3361 | for (var integer i := 0; i < lengthof(g_ms); i := i + 1) { |
| 3362 | f1 := exp_imsi and f_pkt_paging_match_imsi(req, g_ms[i].imsi, |
| 3363 | ps_domain := false); |
| 3364 | f2 := exp_tmsi and f_pkt_paging_match_tmsi(req, oct2int(g_ms[i].tlli), |
| 3365 | ps_domain := false); |
| 3366 | if (not f1 and not f2) |
| 3367 | { continue; } |
| 3368 | |
| 3369 | /* Detect duplicate MIs */ |
| 3370 | if (mask[i] == '1'B) { |
| 3371 | setverdict(fail, "MS is paged twice: ", g_ms[i].imsi); |
| 3372 | continue; |
| 3373 | } |
| 3374 | |
| 3375 | mask[i] := '1'B; |
| 3376 | } |
| 3377 | |
| 3378 | pending := pending - lengthof(req.repeated_pageinfo); |
| 3379 | } |
| 3380 | |
| 3381 | for (var integer i := 0; i < lengthof(mask); i := i + 1) { |
| 3382 | if (mask[i] != '1'B) { |
| 3383 | setverdict(fail, "MS was not paged at all: ", g_ms[i].imsi); |
| 3384 | log("===== mask := ", mask); |
| 3385 | } |
| 3386 | } |
| 3387 | |
| 3388 | /* All messages must have been received by now, expect a dummy block */ |
| 3389 | f_rx_rlcmac_dl_block_exp_dummy(dl_block, nr := nr); |
| 3390 | } |
| 3391 | |
| 3392 | private function f_TC_paging_cs_multi_ms_init(BIT8 pdch_mask) |
| 3393 | runs on RAW_PCU_Test_CT { |
| 3394 | var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default); |
| 3395 | const BssgpBvci bvci := mp_gb_cfg.bvc[0].bvci; |
| 3396 | |
| 3397 | /* Initialize NS/BSSGP side */ |
| 3398 | f_init_bssgp(); |
| 3399 | |
| 3400 | /* Explicitly set the given PDCH slot-mask to all transceivers */ |
| 3401 | f_PCUIF_ver_INFO_PDCHMask_set(info_ind, pdch_mask); |
| 3402 | |
| 3403 | /* Allocate 56 GprsMS instances (maximum for 8 PDCH slots) */ |
| 3404 | f_init_gprs_ms(7 * 8); |
| 3405 | |
| 3406 | /* Initialize the PCU interface abstraction */ |
| 3407 | f_init_raw(testcasename(), info_ind); |
| 3408 | |
| 3409 | /* Establish BSSGP connection to the PCU */ |
| 3410 | f_bssgp_establish(); |
| 3411 | f_multi_ms_bssgp_register(); |
| 3412 | |
| 3413 | /* Establish an Uplink TBF for each GprsMS instance */ |
| 3414 | f_multi_ms_establish_tbf(do_activate := true); |
| 3415 | } |
| 3416 | |
| 3417 | testcase TC_paging_cs_multi_ms_imsi() runs on RAW_PCU_Test_CT { |
| 3418 | const BssgpBvci bvci := mp_gb_cfg.bvc[0].bvci; |
| 3419 | |
| 3420 | /* Common part: send INFO.ind, establish TBFs... */ |
| 3421 | f_TC_paging_cs_multi_ms_init(pdch_mask := '00000001'B); |
| 3422 | |
| 3423 | /* Enqueue multiple CS PAGING requests at a time (IMSI only) */ |
| 3424 | for (var integer i := 0; i < lengthof(g_ms); i := i + 1) { |
| 3425 | BSSGP[0].send(ts_BSSGP_CS_PAGING_IMSI(bvci, g_ms[i].imsi)); |
| 3426 | } |
| 3427 | |
| 3428 | /* FIXME: work around a race condition between PCUIF and BSSGP */ |
| 3429 | f_sleep(0.2); /* i.e. give the IUT some time to process everything */ |
| 3430 | |
| 3431 | /* Check what the IUT sends on PACCH, all GprsMS instances must be paged. |
| 3432 | * The IUT is expected to page on all PDCH slots of all transceivers. */ |
| 3433 | for (var integer trx_nr := 0; trx_nr < 8; trx_nr := trx_nr + 1) { |
| 3434 | var template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum(7, trx_nr); |
| 3435 | f_TC_paging_cs_multi_ms(nr, exp_imsi := true, exp_tmsi := false); |
| 3436 | } |
| 3437 | |
| 3438 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 3439 | } |
| 3440 | |
| 3441 | testcase TC_paging_cs_multi_ms_tmsi() runs on RAW_PCU_Test_CT { |
| 3442 | const BssgpBvci bvci := mp_gb_cfg.bvc[0].bvci; |
| 3443 | |
| 3444 | /* Common part: send INFO.ind, establish TBFs... */ |
| 3445 | f_TC_paging_cs_multi_ms_init(pdch_mask := '00000001'B); |
| 3446 | |
| 3447 | /* Enqueue multiple CS PAGING requests at a time (P-TMSI only) */ |
| 3448 | for (var integer i := 0; i < lengthof(g_ms); i := i + 1) { |
| 3449 | var GsmTmsi tmsi := oct2int(g_ms[i].tlli); /* P-TMSI == TLLI */ |
| 3450 | BSSGP[0].send(ts_BSSGP_CS_PAGING_PTMSI(bvci, g_ms[i].imsi, tmsi)); |
| 3451 | } |
| 3452 | |
| 3453 | /* FIXME: work around a race condition between PCUIF and BSSGP */ |
| 3454 | f_sleep(0.2); /* i.e. give the IUT some time to process everything */ |
| 3455 | |
| 3456 | /* Check what the IUT sends on PACCH, all GprsMS instances must be paged. |
| 3457 | * The IUT is expected to page on all PDCH slots of all transceivers. */ |
| 3458 | for (var integer trx_nr := 0; trx_nr < 8; trx_nr := trx_nr + 1) { |
| 3459 | var template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum(7, trx_nr); |
| 3460 | f_TC_paging_cs_multi_ms(nr, exp_imsi := false, exp_tmsi := true); |
| 3461 | } |
| 3462 | |
| 3463 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 3464 | } |
| 3465 | |
| 3466 | testcase TC_paging_cs_multi_ms_imsi_tmsi() runs on RAW_PCU_Test_CT { |
| 3467 | const BssgpBvci bvci := mp_gb_cfg.bvc[0].bvci; |
| 3468 | |
| 3469 | /* Common part: send INFO.ind, establish TBFs... */ |
| 3470 | f_TC_paging_cs_multi_ms_init(pdch_mask := '00000001'B); |
| 3471 | |
| 3472 | /* Enqueue multiple CS PAGING requests at a time (IMSI & P-TMSI) */ |
| 3473 | for (var integer i := 0; i < lengthof(g_ms); i := i + 1) { |
| 3474 | var GsmTmsi tmsi := oct2int(g_ms[i].tlli); /* P-TMSI == TLLI */ |
| 3475 | if (i mod 3 == 0) { /* One PDU fits: 1 IMSI and 2 P-TMSI MIs */ |
| 3476 | BSSGP[0].send(ts_BSSGP_CS_PAGING_PTMSI(bvci, g_ms[i].imsi, tmsi)); |
| 3477 | } else { |
| 3478 | BSSGP[0].send(ts_BSSGP_CS_PAGING_IMSI(bvci, g_ms[i].imsi)); |
| 3479 | } |
| 3480 | } |
| 3481 | |
| 3482 | /* FIXME: work around a race condition between PCUIF and BSSGP */ |
| 3483 | f_sleep(0.2); /* i.e. give the IUT some time to process everything */ |
| 3484 | |
| 3485 | /* Check what the IUT sends on PACCH, all GprsMS instances must be paged. |
| 3486 | * The IUT is expected to page on all PDCH slots of all transceivers. */ |
| 3487 | for (var integer trx_nr := 0; trx_nr < 8; trx_nr := trx_nr + 1) { |
| 3488 | var template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum(7, trx_nr); |
| 3489 | f_TC_paging_cs_multi_ms(nr, exp_imsi := true, exp_tmsi := true); |
| 3490 | } |
| 3491 | |
| 3492 | f_shutdown(__BFILE__, __LINE__, final := true); |
| 3493 | } |
| 3494 | |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3495 | control { |
| 3496 | execute( TC_pcuif_suspend() ); |
| 3497 | execute( TC_ta_ptcch_idle() ); |
| 3498 | execute( TC_ta_rach_imm_ass() ); |
| 3499 | execute( TC_ta_idle_dl_tbf_ass() ); |
| 3500 | execute( TC_ta_ptcch_ul_multi_tbf() ); |
| 3501 | execute( TC_cs_lqual_ul_tbf() ); |
| 3502 | execute( TC_cs_initial_ul() ); |
| 3503 | execute( TC_cs_max_ul() ); |
Pau Espin Pedrol | 7512259 | 2020-11-03 15:22:59 +0100 | [diff] [blame] | 3504 | execute( TC_cs_initial_dl() ); |
Pau Espin Pedrol | 5d07ae6 | 2020-11-05 17:59:30 +0100 | [diff] [blame] | 3505 | execute( TC_cs_max_dl() ); |
| 3506 | execute( TC_dl_cs1_to_cs4() ); |
Pau Espin Pedrol | 2354d6a | 2020-11-05 18:36:59 +0100 | [diff] [blame] | 3507 | execute( TC_mcs_initial_ul() ); |
Pau Espin Pedrol | db15fa7 | 2020-11-11 12:58:34 +0100 | [diff] [blame] | 3508 | execute( TC_mcs_max_ul() ); |
Pau Espin Pedrol | e4fa45b | 2020-11-11 13:28:31 +0100 | [diff] [blame] | 3509 | execute( TC_mcs_initial_dl() ); |
Pau Espin Pedrol | 1b9aa78 | 2020-11-12 21:14:16 +0100 | [diff] [blame] | 3510 | execute( TC_mcs_max_dl() ); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3511 | execute( TC_t3169() ); |
| 3512 | execute( TC_t3193() ); |
Pau Espin Pedrol | 487d634 | 2020-05-14 19:22:33 +0200 | [diff] [blame] | 3513 | execute( TC_countdown_procedure() ); |
Pau Espin Pedrol | fb2301e | 2020-06-30 20:46:54 +0200 | [diff] [blame] | 3514 | execute( TC_ul_all_sizes() ); |
Pau Espin Pedrol | 5e6844d | 2020-07-01 17:24:02 +0200 | [diff] [blame] | 3515 | execute( TC_ul_data_toolong_fills_padding() ); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3516 | execute( TC_mo_ping_pong() ); |
| 3517 | execute( TC_mo_ping_pong_with_ul_racap() ); |
Pau Espin Pedrol | 0c0bf87 | 2020-05-14 15:50:49 +0200 | [diff] [blame] | 3518 | execute( TC_force_two_phase_access() ); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3519 | execute( TC_mt_ping_pong() ); |
| 3520 | execute( TC_mt_ping_pong_with_dl_racap() ); |
Pau Espin Pedrol | e1195bb | 2020-07-07 13:27:18 +0200 | [diff] [blame] | 3521 | execute( TC_ul_intermediate_retrans() ); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3522 | execute( TC_imm_ass_dl_block_retrans() ); |
Vadim Yanitskiy | 71238c1 | 2020-05-11 03:48:06 +0700 | [diff] [blame] | 3523 | execute( TC_dl_flow_more_blocks() ); |
Pau Espin Pedrol | e1195bb | 2020-07-07 13:27:18 +0200 | [diff] [blame] | 3524 | execute( TC_ul_flow_multiple_llc_blocks() ); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3525 | execute( TC_paging_cs_from_bts() ); |
| 3526 | execute( TC_paging_cs_from_sgsn_sign_ptmsi() ); |
| 3527 | execute( TC_paging_cs_from_sgsn_sign() ); |
| 3528 | execute( TC_paging_cs_from_sgsn_ptp() ); |
| 3529 | execute( TC_paging_ps_from_sgsn_sign_ptmsi() ); |
| 3530 | execute( TC_paging_ps_from_sgsn_sign() ); |
| 3531 | execute( TC_paging_ps_from_sgsn_ptp() ); |
Vadim Yanitskiy | dbd4b24 | 2020-10-31 05:44:58 +0700 | [diff] [blame] | 3532 | execute( TC_paging_cs_multi_ms_imsi_tmsi() ); |
| 3533 | execute( TC_paging_cs_multi_ms_imsi() ); |
| 3534 | execute( TC_paging_cs_multi_ms_tmsi() ); |
Pau Espin Pedrol | c03eb12 | 2020-08-27 18:54:24 +0200 | [diff] [blame] | 3535 | execute( TC_bssgp_dl_unitdata_with_valid_imsi() ); |
| 3536 | execute( TC_bssgp_dl_unitdata_with_invalid_imsi() ); |
Pau Espin Pedrol | 2e459d6 | 2020-11-30 19:34:16 +0100 | [diff] [blame] | 3537 | execute( TC_dl_gprs_data_no_llc_ui_dummy() ); |
| 3538 | execute( TC_dl_egprs_data_no_llc_ui_dummy() ); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3539 | |
| 3540 | /* EGPRS specific test cases */ |
| 3541 | execute( TC_egprs_pkt_chan_req_signalling() ); |
| 3542 | execute( TC_egprs_pkt_chan_req_one_phase() ); |
| 3543 | execute( TC_egprs_pkt_chan_req_two_phase() ); |
Vadim Yanitskiy | 4f56d32 | 2020-05-22 20:15:48 +0700 | [diff] [blame] | 3544 | execute( TC_egprs_pkt_chan_req_reject_content() ); |
Vadim Yanitskiy | 7e06c25 | 2020-05-22 20:48:53 +0700 | [diff] [blame] | 3545 | execute( TC_egprs_pkt_chan_req_reject_emergency() ); |
Vadim Yanitskiy | c4324ff | 2020-05-22 21:53:58 +0700 | [diff] [blame] | 3546 | execute( TC_egprs_pkt_chan_req_reject_exhaustion() ); |
Pau Espin Pedrol | 42acafc | 2020-05-14 15:18:38 +0200 | [diff] [blame] | 3547 | |
| 3548 | execute( TC_mo_ping_pong_with_ul_racap_egprs_only() ); |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 3549 | |
| 3550 | /* Frequency hopping specific test cases */ |
| 3551 | if (PCUIF_Types.mp_pcuif_version >= 10) { |
| 3552 | /* Immediate Assignment on AGCH/PCH */ |
| 3553 | execute( TC_pcuif_fh_imm_ass_ul_egprs() ); |
| 3554 | execute( TC_pcuif_fh_imm_ass_ul() ); |
| 3555 | execute( TC_pcuif_fh_imm_ass_dl() ); |
| 3556 | /* Packet Uplink/Downlink Assignment on PACCH */ |
| 3557 | execute( TC_pcuif_fh_pkt_ass_ul() ); |
| 3558 | execute( TC_pcuif_fh_pkt_ass_dl() ); |
Pau Espin Pedrol | bfd69f6 | 2020-10-22 18:06:07 +0200 | [diff] [blame] | 3559 | execute( TC_multitrx_multims_alloc() ); |
Pau Espin Pedrol | 0ea8b6f | 2020-10-29 20:48:43 +0100 | [diff] [blame] | 3560 | execute( TC_dl_multislot_tbf_ms_class_from_sgsn() ); |
Pau Espin Pedrol | 8155bf4 | 2020-10-29 17:34:26 +0100 | [diff] [blame] | 3561 | execute( TC_dl_multislot_tbf_ms_class_from_2phase() ); |
Pau Espin Pedrol | a9f27fa | 2020-10-30 13:16:21 +0100 | [diff] [blame] | 3562 | execute( TC_ul_multislot_tbf_ms_class_from_2phase() ); |
Vadim Yanitskiy | 94fe83e | 2020-07-20 04:03:13 +0700 | [diff] [blame] | 3563 | } |
Pau Espin Pedrol | e130305 | 2020-11-16 11:13:51 +0100 | [diff] [blame] | 3564 | execute( TC_multiplex_dl_gprs_egprs() ); |
Vadim Yanitskiy | d53fb67 | 2020-10-09 16:41:02 +0700 | [diff] [blame] | 3565 | |
| 3566 | execute( TC_pcuif_info_ind_subsequent() ); |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 3567 | } |
| 3568 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 3569 | } |