rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2012 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | /******************************************************************************* |
| 37 | * Filename: |
| 38 | * --------- |
| 39 | * dispatcher_ut.c |
| 40 | * |
| 41 | * Project: |
| 42 | * -------- |
| 43 | * VMOLY |
| 44 | * |
| 45 | * Description: |
| 46 | * ------------ |
| 47 | * DISPATCHER unit test implementation. |
| 48 | * |
| 49 | * Author: |
| 50 | * ------- |
| 51 | * ------- |
| 52 | * |
| 53 | *******************************************************************************/ |
| 54 | |
| 55 | #ifdef ATEST_SYS_DISPATCHER |
| 56 | |
| 57 | #include "kal_public_api.h" |
| 58 | #include "sys_test.h" |
| 59 | #include "n3epc_dispatcher_struct.h" |
| 60 | #include "ipcore_dispatcher_struct.h" |
| 61 | #include "dispatcher_struct.h" |
| 62 | #include "dispatcher_if.h" |
| 63 | #include "dispatcher_msgid.h" |
| 64 | |
| 65 | #define DISPATCHER_UT_CASE(_func, _param) { #_func, _func, _param } |
| 66 | #define DISPATCHER_UT_TEST_BEARERID 14 |
| 67 | #define DISPATCHER_UT_TEST_INVALID_BEARERID 18 /*graeter than 15*/ |
| 68 | #define DISPATCHER_UT_TEST_PDNID 15 //as current meta does not store above 32 so taken 15 to check current code |
| 69 | #define DISPATCHER_UT_TEST_CID 100 //any temp cid value |
| 70 | #define DISPATCHER_UT_TEST_NWID 4 //any temp nw_id value |
| 71 | #define DISPATCHER_UT_TEST_NON_WIFI_PDNID 20 |
| 72 | |
| 73 | static kal_uint8 dispatcher_ut_ipv4_dns_packet[] = { |
| 74 | 0x45, 0x00, 0x00, 0x45, 0x50, 0x9e, 0x00, 0x00, 0x80, 0x11, 0x96, 0x3a, 0xac, 0x16, 0x97, 0x53, |
| 75 | 0xac, 0x15, 0x64, 0x50, 0xc0, 0x51, 0x00, 0x35, 0x00, 0x31, 0x7d, 0x15, 0x2d, 0x89, 0x01, 0x00, |
| 76 | 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x50, 0x43, 0x31, 0x30, 0x30, 0x36, 0x30, |
| 77 | 0x30, 0x31, 0x34, 0x08, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x6b, 0x03, 0x69, 0x6e, 0x63, |
| 78 | 0x00, 0x00, 0x1c, 0x00, 0x01}; |
| 79 | |
| 80 | static kal_uint8 dispatcher_ut_ipv6_dhcp_ul_packet[] = { |
| 81 | 0x60, 0x00, 0x00, 0x00, 0x00, 0x56, 0x11, 0x80, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 82 | 0x02, 0x13, 0xd4, 0xff, 0xfe, 0x80, 0x56, 0x15, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 83 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x22, 0x02, 0x23, 0x00, 0x56, 0x98, 0x9b, |
| 84 | 0x01, 0x00, 0x12, 0x69, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x01, 0x00, 0x06, 0x18, 0xc5, 0xe1, 0xd2, |
| 85 | 0x00, 0x13, 0xd4, 0x80, 0x56, 0x15, 0x00, 0x03, 0x00, 0x28, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, |
| 86 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x05, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 87 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, |
| 88 | 0xff, 0xff, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x02, 0x00, 0x17}; |
| 89 | |
| 90 | |
| 91 | |
| 92 | typedef struct { |
| 93 | kal_uint32 type_idx; |
| 94 | kal_uint8 *base_addr; |
| 95 | kal_uint8 read_idx; |
| 96 | kal_uint8 write_idx; |
| 97 | kal_uint8 *buff_addr_base; |
| 98 | }dispatcher_ut_meta_queue_t; |
| 99 | |
| 100 | typedef enum { |
| 101 | DISPATCHER_UT_LHIF_META_AP0 = 0, |
| 102 | DISPATCHER_UT_META_QUEUE_NUM_MAX, |
| 103 | }dispatcher_ut_meta_type_e; |
| 104 | |
| 105 | #define DISPATCHER_UT_META_TABLE_SIZE 70 |
| 106 | static lhif_meta_tbl_t dispatcher_ut_meta_tbl_s[DISPATCHER_UT_META_TABLE_SIZE]; |
| 107 | |
| 108 | static dispatcher_ut_meta_queue_t dispatcher_ut_meta_queues[DISPATCHER_UT_META_QUEUE_NUM_MAX]; |
| 109 | |
| 110 | kal_uint8 g_ul_wtunnel_forwarded_gpd_count; |
| 111 | kal_uint8 g_dl_ipcore_forward_did_count; |
| 112 | kal_uint8 g_dl_drop_did_count; |
| 113 | kal_uint8 g_ul_drop_gpd_count; |
| 114 | kal_uint8 g_ul_upcm_forward_gpd_count; |
| 115 | kal_uint8 g_ul_total_ignr_count; |
| 116 | kal_bool dispatcher_ut_assert_flag = KAL_FALSE; |
| 117 | typedef struct { |
| 118 | kal_uint8 cid; |
| 119 | kal_bool result; |
| 120 | ps_cause_enum error_code; |
| 121 | }dispatcher_bind_cnf_struct; |
| 122 | |
| 123 | typedef struct { |
| 124 | kal_uint8 cid; |
| 125 | kal_bool result; |
| 126 | ps_cause_enum error_code; |
| 127 | }dispatcher_unbind_cnf_struct; |
| 128 | |
| 129 | dispatcher_bind_cnf_struct g_curr_bind_cnf; |
| 130 | dispatcher_bind_cnf_struct g_curr_unbind_cnf; |
| 131 | |
| 132 | kal_bool dispatcher_ut_test_first(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz) { |
| 133 | /*temp test case*/ |
| 134 | return KAL_TRUE; |
| 135 | } |
| 136 | |
| 137 | void dispatcher_ut_bearer_act_req_only(void) |
| 138 | { |
| 139 | |
| 140 | n3epc_dispatcher_bearer_act_req_struct req_struct; |
| 141 | req_struct.bearer_id = DISPATCHER_UT_TEST_BEARERID; |
| 142 | req_struct.linked_bearer_id = DISPATCHER_UT_TEST_BEARERID; |
| 143 | req_struct.context_id = DISPATCHER_UT_TEST_CID; |
| 144 | n3epc_dispatcher_bearer_act_req(&req_struct); |
| 145 | |
| 146 | } |
| 147 | |
| 148 | void dispatcher_ut_invalid_bearer_act_req_only(int bearer_id) |
| 149 | { |
| 150 | |
| 151 | n3epc_dispatcher_bearer_act_req_struct req_struct; |
| 152 | req_struct.bearer_id = bearer_id; |
| 153 | req_struct.linked_bearer_id = bearer_id; |
| 154 | req_struct.context_id = DISPATCHER_UT_TEST_CID; |
| 155 | n3epc_dispatcher_bearer_act_req(&req_struct); |
| 156 | |
| 157 | } |
| 158 | |
| 159 | void dispatcher_ut_bearer_deact_req_only(void) |
| 160 | { |
| 161 | n3epc_dispatcher_bearer_deact_req_struct bearer_deact_req_struct; |
| 162 | bearer_deact_req_struct.bearer_id = DISPATCHER_UT_TEST_BEARERID; |
| 163 | bearer_deact_req_struct.context_id = DISPATCHER_UT_TEST_CID; |
| 164 | n3epc_dispatcher_bearer_deact_req(&bearer_deact_req_struct); |
| 165 | } |
| 166 | |
| 167 | |
| 168 | void dispatcher_ut_invalid_bearer_deact_req_only(int bearer_id) |
| 169 | { |
| 170 | n3epc_dispatcher_bearer_deact_req_struct bearer_deact_req_struct; |
| 171 | bearer_deact_req_struct.bearer_id = bearer_id; |
| 172 | bearer_deact_req_struct.context_id = DISPATCHER_UT_TEST_CID; |
| 173 | n3epc_dispatcher_bearer_deact_req(&bearer_deact_req_struct); |
| 174 | } |
| 175 | |
| 176 | kal_bool dispatcher_ut_bearer_act_req_test(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz) |
| 177 | { |
| 178 | |
| 179 | kal_bool is_active = KAL_FALSE; |
| 180 | /**********reset dispatcher full context************/ |
| 181 | dispatcher_reset(); |
| 182 | |
| 183 | /*activate bearer with invalid value 0 */ |
| 184 | is_active = dispatcher_check_is_bearer_active_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 185 | dispatcher_ut_invalid_bearer_act_req_only(0); |
| 186 | if (dispatcher_ut_assert_flag) { |
| 187 | dispatcher_ut_assert_flag = KAL_FALSE; |
| 188 | } else { |
| 189 | return KAL_FALSE; |
| 190 | } |
| 191 | |
| 192 | /*activate bearer with invalid value 18 */ |
| 193 | dispatcher_ut_invalid_bearer_act_req_only(DISPATCHER_UT_TEST_INVALID_BEARERID); |
| 194 | if (dispatcher_ut_assert_flag) { |
| 195 | dispatcher_ut_assert_flag = KAL_FALSE; |
| 196 | } else { |
| 197 | return KAL_FALSE; |
| 198 | } |
| 199 | /*valid bearer activate*/ |
| 200 | dispatcher_ut_bearer_act_req_only(); |
| 201 | /*check if bearer is really active*/ |
| 202 | is_active = dispatcher_check_is_bearer_active_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 203 | if (is_active != KAL_TRUE) { |
| 204 | return KAL_FALSE; |
| 205 | } |
| 206 | |
| 207 | /*bearer is activate, now try do duplicate bearer req*/ |
| 208 | dispatcher_ut_bearer_act_req_only(); |
| 209 | if (dispatcher_ut_assert_flag) { |
| 210 | dispatcher_ut_assert_flag = KAL_FALSE; |
| 211 | } else { |
| 212 | return KAL_FALSE; |
| 213 | } |
| 214 | /*deactivate the activated bearer, kind of reset*/ |
| 215 | dispatcher_ut_bearer_deact_req_only(); |
| 216 | return KAL_TRUE; |
| 217 | } |
| 218 | |
| 219 | |
| 220 | |
| 221 | kal_bool dispatcher_ut_bearer_deact_req_test(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz) |
| 222 | { |
| 223 | kal_bool is_active = KAL_FALSE; |
| 224 | |
| 225 | dispatcher_reset(); |
| 226 | /*********reset dispatcher full context************/ |
| 227 | |
| 228 | /*invalid req*/ |
| 229 | dispatcher_ut_invalid_bearer_deact_req_only(0); |
| 230 | if (dispatcher_ut_assert_flag) { |
| 231 | dispatcher_ut_assert_flag = KAL_FALSE; |
| 232 | } else { |
| 233 | return KAL_FALSE; |
| 234 | } |
| 235 | /*activate bearer with invalid value 18 */ |
| 236 | dispatcher_ut_invalid_bearer_deact_req_only(DISPATCHER_UT_TEST_INVALID_BEARERID); |
| 237 | if (dispatcher_ut_assert_flag) { |
| 238 | dispatcher_ut_assert_flag = KAL_FALSE; |
| 239 | } else { |
| 240 | return KAL_FALSE; |
| 241 | } |
| 242 | |
| 243 | /*activate a valid bearer*/ |
| 244 | dispatcher_ut_bearer_act_req_only(); |
| 245 | is_active = dispatcher_check_is_bearer_active_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 246 | |
| 247 | dispatcher_ut_bearer_deact_req_only(); |
| 248 | /*check if bearer is really deactive*/ |
| 249 | is_active = dispatcher_check_is_bearer_active_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 250 | if (is_active != KAL_FALSE) { |
| 251 | return KAL_FALSE; |
| 252 | } |
| 253 | return KAL_TRUE; |
| 254 | } |
| 255 | |
| 256 | void dispatcher_ut_pdn_bind_req_only(void) |
| 257 | { |
| 258 | n3epc_dispatcher_pdn_bind_req_struct pdn_bind_struct; |
| 259 | pdn_bind_struct.context_id = DISPATCHER_UT_TEST_CID; |
| 260 | pdn_bind_struct.network_interface_id = DISPATCHER_UT_TEST_NWID; |
| 261 | n3epc_dispatcher_pdn_bind_req(&pdn_bind_struct,MOD_DISPATCHER); |
| 262 | } |
| 263 | |
| 264 | void dispatcher_ut_pdn_unbind_req_only(void) |
| 265 | { |
| 266 | n3epc_dispatcher_pdn_unbind_req_struct pdn_unbind_struct; |
| 267 | pdn_unbind_struct.context_id = DISPATCHER_UT_TEST_CID; |
| 268 | n3epc_dispatcher_pdn_unbind_req(&pdn_unbind_struct, MOD_DISPATCHER); |
| 269 | } |
| 270 | |
| 271 | void dispatcher_ut_pdn_bind_ipc_rsp_only(void) |
| 272 | { |
| 273 | /*ipcore bind OK rsp*/ |
| 274 | ipcore_dispatcher_pdn_bind_rsp_struct ipc_bind_rsp_struct; |
| 275 | ipc_bind_rsp_struct.network_interface_id = DISPATCHER_UT_TEST_NWID; |
| 276 | ipc_bind_rsp_struct.pdn_id = DISPATCHER_UT_TEST_PDNID; |
| 277 | ipc_bind_rsp_struct.result= HIF_IPC_OK; |
| 278 | ipc_bind_rsp_struct.back_info.context_id = DISPATCHER_UT_TEST_CID; |
| 279 | ipc_bind_rsp_struct.back_info.reply_dest_mod_id = MOD_DISPATCHER; |
| 280 | ipcore_dispatcher_pdn_bind_rsp(&ipc_bind_rsp_struct); |
| 281 | } |
| 282 | |
| 283 | void dispatcher_ut_pdn_bind_ipc_error_rsp_only(void) |
| 284 | { |
| 285 | /*ipcore bind OK rsp*/ |
| 286 | ipcore_dispatcher_pdn_bind_rsp_struct ipc_bind_rsp_struct; |
| 287 | ipc_bind_rsp_struct.network_interface_id = DISPATCHER_UT_TEST_NWID; |
| 288 | ipc_bind_rsp_struct.pdn_id = DISPATCHER_UT_TEST_PDNID; |
| 289 | ipc_bind_rsp_struct.result= !(HIF_IPC_OK); |
| 290 | ipc_bind_rsp_struct.back_info.context_id = DISPATCHER_UT_TEST_CID; |
| 291 | ipc_bind_rsp_struct.back_info.reply_dest_mod_id = MOD_DISPATCHER; |
| 292 | ipcore_dispatcher_pdn_bind_rsp(&ipc_bind_rsp_struct); |
| 293 | } |
| 294 | |
| 295 | kal_bool dispatcher_ut_return_compare_bind_cnf(kal_bool result, ps_cause_enum error_code) { |
| 296 | |
| 297 | if (g_curr_bind_cnf.result == KAL_TRUE) { |
| 298 | return KAL_TRUE; |
| 299 | } else { |
| 300 | if (g_curr_bind_cnf.error_code == error_code) { |
| 301 | return KAL_TRUE; |
| 302 | } else { |
| 303 | return KAL_FALSE; |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | kal_bool dispatcher_ut_return_compare_unbind_cnf(kal_bool result, ps_cause_enum error_code) { |
| 309 | |
| 310 | if (g_curr_unbind_cnf.result == KAL_TRUE) { |
| 311 | return KAL_TRUE; |
| 312 | } else { |
| 313 | if (g_curr_unbind_cnf.error_code == error_code) { |
| 314 | return KAL_TRUE; |
| 315 | } else { |
| 316 | return KAL_FALSE; |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | kal_bool dispatcher_ut_pdn_bind_req_test(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz) |
| 322 | { |
| 323 | kal_bool is_continue = KAL_FALSE; |
| 324 | dispatcher_bind_state_enum state; |
| 325 | |
| 326 | /**********reset dispatcher full context************/ |
| 327 | dispatcher_reset(); |
| 328 | |
| 329 | //TEST CASE1 |
| 330 | /*do pdn bind without bearer activation*/ |
| 331 | dispatcher_ut_pdn_bind_req_only(); |
| 332 | if (!dispatcher_ut_return_compare_bind_cnf(KAL_FALSE, N3EPC_DISPATCHER_BIND_ERROR_AS_BEARER_NOT_ACTIVATED_BEFORE)) { |
| 333 | return KAL_FALSE; |
| 334 | } |
| 335 | |
| 336 | /* TEST CASE2 bearer act+ pdn bind req+ bind rsp from ipc*/ |
| 337 | kal_mem_set(&g_curr_bind_cnf, 0, sizeof(g_curr_bind_cnf)); |
| 338 | dispatcher_reset(); |
| 339 | |
| 340 | dispatcher_ut_bearer_act_req_only(); |
| 341 | dispatcher_ut_pdn_bind_req_only(); |
| 342 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 343 | |
| 344 | if (state != DISPATCHER_PDN_ST_BINDING) { |
| 345 | return KAL_FALSE; |
| 346 | } |
| 347 | |
| 348 | /*at binding stage send duplicate bearer act req*/ |
| 349 | dispatcher_ut_bearer_act_req_only(); |
| 350 | if (dispatcher_ut_assert_flag) { |
| 351 | dispatcher_ut_assert_flag = KAL_FALSE; |
| 352 | } else { |
| 353 | return KAL_FALSE; |
| 354 | } |
| 355 | /*at dispatcher binding state send another bind req*/ |
| 356 | dispatcher_ut_pdn_bind_req_only(); |
| 357 | if (!dispatcher_ut_return_compare_bind_cnf(KAL_FALSE, N3EPC_DISPATCHER_BIND_ERROR_AS_PREV_BIND_IN_PROGRESS)) { |
| 358 | return KAL_FALSE; |
| 359 | } |
| 360 | |
| 361 | /*simulate ipc bind rsp*/ |
| 362 | dispatcher_ut_pdn_bind_ipc_rsp_only(); |
| 363 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 364 | if (state != DISPATCHER_PDN_ST_BIND) { |
| 365 | return KAL_FALSE; |
| 366 | } |
| 367 | if (!dispatcher_ut_return_compare_bind_cnf(KAL_TRUE, 0)) { |
| 368 | return KAL_FALSE; |
| 369 | } |
| 370 | |
| 371 | /*at bind stage send duplicate bearer act req*/ |
| 372 | dispatcher_ut_bearer_act_req_only(); |
| 373 | if (dispatcher_ut_assert_flag) { |
| 374 | dispatcher_ut_assert_flag = KAL_FALSE; |
| 375 | } else { |
| 376 | return KAL_FALSE; |
| 377 | } |
| 378 | |
| 379 | /*TEST CASE3 pdn bind success,test remaining 1. send duplicate bind req*/ |
| 380 | kal_mem_set(&g_curr_bind_cnf, 0, sizeof(g_curr_bind_cnf)); |
| 381 | dispatcher_ut_pdn_bind_req_only(); |
| 382 | if (!dispatcher_ut_return_compare_bind_cnf(KAL_FALSE, N3EPC_DISPATCHER_BIND_ERROR_AS_PDN_ALREADY_BIND)) { |
| 383 | return KAL_FALSE; |
| 384 | } |
| 385 | |
| 386 | /*TEST CASE4 */ |
| 387 | /*for BIND state, bearer deact req, send the bearer act req, check assert flag*/ |
| 388 | kal_mem_set(&g_curr_bind_cnf, 0, sizeof(g_curr_bind_cnf)); |
| 389 | dispatcher_reset(); |
| 390 | dispatcher_ut_bearer_act_req_only(); |
| 391 | dispatcher_ut_pdn_bind_req_only(); |
| 392 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 393 | if (state != DISPATCHER_PDN_ST_BINDING) { |
| 394 | return KAL_FALSE; |
| 395 | } |
| 396 | dispatcher_ut_bearer_deact_req_only(); |
| 397 | dispatcher_ut_bearer_act_req_only(); |
| 398 | if (dispatcher_ut_assert_flag) { |
| 399 | dispatcher_ut_assert_flag = KAL_FALSE; |
| 400 | } else { |
| 401 | return KAL_FALSE; |
| 402 | } |
| 403 | |
| 404 | /*TEST CASE5 */ |
| 405 | /*binding going to unbind , bearer deact then bearer act, assert fail as state does not allow bearer to activate here*/ |
| 406 | kal_mem_set(&g_curr_bind_cnf, 0, sizeof(g_curr_bind_cnf)); |
| 407 | dispatcher_reset(); |
| 408 | dispatcher_ut_bearer_act_req_only(); |
| 409 | dispatcher_ut_pdn_bind_req_only(); |
| 410 | dispatcher_ut_pdn_unbind_req_only(); |
| 411 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 412 | if (state != DISPATCHER_PDN_ST_BINDING_GOING_TO_UNBIND) { |
| 413 | return KAL_FALSE; |
| 414 | } |
| 415 | |
| 416 | dispatcher_ut_bearer_deact_req_only(); |
| 417 | dispatcher_ut_bearer_act_req_only(); |
| 418 | if (dispatcher_ut_assert_flag) { |
| 419 | dispatcher_ut_assert_flag = KAL_FALSE; |
| 420 | } else { |
| 421 | return KAL_FALSE; |
| 422 | } |
| 423 | |
| 424 | |
| 425 | /*TEST CASE5 */ |
| 426 | /*BIND state , bearer deact then bearer act, assert fail as state does not allow bearer to activate here*/ |
| 427 | kal_mem_set(&g_curr_bind_cnf, 0, sizeof(g_curr_bind_cnf)); |
| 428 | dispatcher_reset(); |
| 429 | dispatcher_ut_bearer_act_req_only(); |
| 430 | dispatcher_ut_pdn_bind_req_only(); |
| 431 | dispatcher_ut_pdn_bind_ipc_rsp_only(); |
| 432 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 433 | if (state != DISPATCHER_PDN_ST_BIND) { |
| 434 | return KAL_FALSE; |
| 435 | } |
| 436 | |
| 437 | dispatcher_ut_bearer_deact_req_only(); |
| 438 | dispatcher_ut_bearer_act_req_only(); |
| 439 | if (dispatcher_ut_assert_flag) { |
| 440 | dispatcher_ut_assert_flag = KAL_FALSE; |
| 441 | } else { |
| 442 | return KAL_FALSE; |
| 443 | } |
| 444 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 445 | if (state != DISPATCHER_PDN_ST_BIND) { |
| 446 | return KAL_FALSE; |
| 447 | } |
| 448 | /*test pdn bind rsp for unexpected state already bind, assert flag will become true*/ |
| 449 | dispatcher_ut_pdn_bind_ipc_rsp_only(); |
| 450 | if (dispatcher_ut_assert_flag) { |
| 451 | dispatcher_ut_assert_flag = KAL_FALSE; |
| 452 | } else { |
| 453 | return KAL_FALSE; |
| 454 | } |
| 455 | return KAL_TRUE; |
| 456 | |
| 457 | } |
| 458 | |
| 459 | |
| 460 | |
| 461 | kal_bool dispatcher_ut_pdn_unbind_normal_req_test(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz) |
| 462 | { |
| 463 | kal_bool is_continue = KAL_FALSE; |
| 464 | dispatcher_bind_state_enum state; |
| 465 | dispatcher_reset(); |
| 466 | /*TEST CASE 1*/ |
| 467 | dispatcher_ut_bearer_act_req_only(); |
| 468 | dispatcher_ut_pdn_bind_req_only();/*binding state*/ |
| 469 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 470 | if (state != DISPATCHER_PDN_ST_BINDING) { |
| 471 | return KAL_FALSE; |
| 472 | } |
| 473 | /*at binding state send ipc bind rsp failure--->state will become UNBIND*/ |
| 474 | dispatcher_ut_pdn_bind_ipc_error_rsp_only(); |
| 475 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 476 | if (state != DISPATCHER_PDN_ST_UNBIND) { |
| 477 | return KAL_FALSE; |
| 478 | } |
| 479 | if (!dispatcher_ut_return_compare_bind_cnf(KAL_FALSE, 0)) { |
| 480 | return KAL_FALSE; |
| 481 | } |
| 482 | |
| 483 | |
| 484 | /*TEST CASE 2*/ |
| 485 | dispatcher_reset(); |
| 486 | dispatcher_ut_bearer_act_req_only(); |
| 487 | dispatcher_ut_pdn_bind_req_only();/*binding state*/ |
| 488 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 489 | if (state != DISPATCHER_PDN_ST_BINDING) { |
| 490 | return KAL_FALSE; |
| 491 | } |
| 492 | dispatcher_ut_pdn_unbind_req_only();/*this will trigger state binding_going_to_unbind*/ |
| 493 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 494 | if (state != DISPATCHER_PDN_ST_BINDING_GOING_TO_UNBIND) { |
| 495 | return KAL_FALSE; |
| 496 | } |
| 497 | dispatcher_ut_pdn_unbind_req_only();/*another unbind req @ binding_going_to_unbind state*/ |
| 498 | if (!dispatcher_ut_return_compare_unbind_cnf(KAL_FALSE, N3EPC_DISPATCHER_UNBIND_ERROR_AS_DUPLICATE_UNBIND_REQ)) { |
| 499 | return KAL_FALSE; |
| 500 | } |
| 501 | dispatcher_ut_pdn_bind_req_only();/*bind req @ binding going to unbind state*/ |
| 502 | if (!dispatcher_ut_return_compare_bind_cnf(KAL_FALSE, N3EPC_DISPATCHER_BINDING_GOING_TO_UNBIND_ERROR_AS_PREV_BIND_IN_PROGRESS)) { |
| 503 | return KAL_FALSE; |
| 504 | } |
| 505 | /*dispatcher state is binding going to unbind , so send ipc bind rsp failure*/ |
| 506 | dispatcher_ut_pdn_bind_ipc_error_rsp_only(); |
| 507 | /*check both rsp bind cnf as well as unbind cnf along with pdn bind state should become unbind*/ |
| 508 | if (!dispatcher_ut_return_compare_bind_cnf(KAL_FALSE, 0)) { |
| 509 | return KAL_FALSE; |
| 510 | } |
| 511 | if (!dispatcher_ut_return_compare_unbind_cnf(KAL_TRUE, 0)) { |
| 512 | return KAL_FALSE; |
| 513 | } |
| 514 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 515 | if (state != DISPATCHER_PDN_ST_UNBIND) { |
| 516 | return KAL_FALSE; |
| 517 | } |
| 518 | |
| 519 | /*send unbind at unbind state*/ |
| 520 | dispatcher_ut_pdn_unbind_req_only(); |
| 521 | if (!dispatcher_ut_return_compare_unbind_cnf(KAL_FALSE, N3EPC_DISPATCHER_UNBIND_ERROR_AS_DUPLICATE_UNBIND_REQ)) { |
| 522 | return KAL_FALSE; |
| 523 | } |
| 524 | |
| 525 | /*TEST CASE 3 ipc rsp success at binding state*/ |
| 526 | dispatcher_reset(); |
| 527 | dispatcher_ut_bearer_act_req_only(); |
| 528 | dispatcher_ut_pdn_bind_req_only();/*binding state*/ |
| 529 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 530 | if (state != DISPATCHER_PDN_ST_BINDING) { |
| 531 | return KAL_FALSE; |
| 532 | } |
| 533 | dispatcher_ut_pdn_bind_ipc_rsp_only(); |
| 534 | /*state should be BIND*/ |
| 535 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 536 | if (state != DISPATCHER_PDN_ST_BIND) { |
| 537 | return KAL_FALSE; |
| 538 | } |
| 539 | if (!dispatcher_ut_return_compare_bind_cnf(KAL_TRUE, 0)) { |
| 540 | return KAL_FALSE; |
| 541 | } |
| 542 | |
| 543 | |
| 544 | /*TEST CASE 4 ipc rsp success at binding_going_to_unbind state*/ |
| 545 | dispatcher_reset(); |
| 546 | dispatcher_ut_bearer_act_req_only(); |
| 547 | dispatcher_ut_pdn_bind_req_only();/*binding state*/ |
| 548 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 549 | if (state != DISPATCHER_PDN_ST_BINDING) { |
| 550 | return KAL_FALSE; |
| 551 | } |
| 552 | dispatcher_ut_pdn_unbind_req_only();/*another unbind req @ binding_going_to_unbind state*/ |
| 553 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 554 | if (state != DISPATCHER_PDN_ST_BINDING_GOING_TO_UNBIND) { |
| 555 | return KAL_FALSE; |
| 556 | } |
| 557 | dispatcher_ut_pdn_bind_ipc_rsp_only(); |
| 558 | /*check both rsp bind cnf as well as unbind cnf along with pdn bind state should become unbind*/ |
| 559 | if (!dispatcher_ut_return_compare_bind_cnf(KAL_FALSE, HIF_CAUSE_START)) { |
| 560 | return KAL_FALSE; |
| 561 | } |
| 562 | if (!dispatcher_ut_return_compare_unbind_cnf(KAL_TRUE, 0)) { |
| 563 | return KAL_FALSE; |
| 564 | } |
| 565 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 566 | if (state != DISPATCHER_PDN_ST_UNBIND) { |
| 567 | return KAL_FALSE; |
| 568 | } |
| 569 | |
| 570 | /*check some other condition*/ |
| 571 | /*pdn state is binding or binding going to unbind, then bearer deactivate*/ |
| 572 | /*as bearer can be deactivated any time so there should be no assert*/ |
| 573 | dispatcher_reset(); |
| 574 | dispatcher_ut_bearer_act_req_only(); |
| 575 | dispatcher_ut_pdn_bind_req_only();/*binding state*/ |
| 576 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 577 | if (state != DISPATCHER_PDN_ST_BINDING) { |
| 578 | return KAL_FALSE; |
| 579 | } |
| 580 | dispatcher_ut_bearer_deact_req_only(); |
| 581 | if (dispatcher_ut_assert_flag) { |
| 582 | return KAL_FALSE; |
| 583 | } |
| 584 | |
| 585 | |
| 586 | dispatcher_reset(); |
| 587 | dispatcher_ut_bearer_act_req_only(); |
| 588 | dispatcher_ut_pdn_bind_req_only();/*binding state*/ |
| 589 | dispatcher_ut_pdn_unbind_req_only();/*binding going to unbind*/ |
| 590 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 591 | if (state != DISPATCHER_PDN_ST_BINDING_GOING_TO_UNBIND) { |
| 592 | return KAL_FALSE; |
| 593 | } |
| 594 | dispatcher_ut_bearer_deact_req_only(); |
| 595 | if (dispatcher_ut_assert_flag) { |
| 596 | return KAL_FALSE; |
| 597 | } |
| 598 | |
| 599 | return KAL_TRUE; |
| 600 | } |
| 601 | |
| 602 | kal_bool dispatcher_ut_pdn_unbind_handover_req_test(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz) |
| 603 | { |
| 604 | /*first do bind*/ |
| 605 | kal_bool is_continue = KAL_FALSE; |
| 606 | dispatcher_bind_state_enum state; |
| 607 | dispatcher_reset(); |
| 608 | dispatcher_ut_bearer_act_req_only(); |
| 609 | dispatcher_ut_pdn_bind_req_only(); |
| 610 | dispatcher_ut_pdn_bind_ipc_rsp_only(); |
| 611 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 612 | if (state != DISPATCHER_PDN_ST_BIND) { |
| 613 | return KAL_FALSE; |
| 614 | } |
| 615 | /*for handover case unbind will happen before bearre deact*/ |
| 616 | dispatcher_ut_pdn_unbind_req_only(); |
| 617 | state = dispatcher_get_bind_state_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 618 | if (state != DISPATCHER_PDN_ST_UNBIND) { |
| 619 | return KAL_FALSE; |
| 620 | } |
| 621 | |
| 622 | is_continue = dispatcher_check_is_bearer_active_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 623 | if (is_continue != KAL_TRUE) { |
| 624 | return KAL_FALSE; |
| 625 | } |
| 626 | dispatcher_ut_bearer_deact_req_only(); |
| 627 | is_continue = dispatcher_check_is_bearer_active_by_bearerid(DISPATCHER_UT_TEST_BEARERID, 0); |
| 628 | if (is_continue != KAL_FALSE) { |
| 629 | return KAL_FALSE; |
| 630 | } |
| 631 | return KAL_TRUE; |
| 632 | } |
| 633 | |
| 634 | |
| 635 | void dispatcher_ut_prepare_ul_gpd_list(ip_type_e ip, kal_uint32 pkt_count, qbm_gpd **head_gpd, qbm_gpd **tail_gpd) |
| 636 | { |
| 637 | qbm_gpd *curr_gpd; |
| 638 | qbm_gpd *bd; |
| 639 | kal_uint8 *packet_buf; |
| 640 | kal_uint32 packet_len; |
| 641 | kal_uint32 idx; |
| 642 | if (pkt_count != qbmt_alloc_q( |
| 643 | QBM_TYPE_NET_UL_SHRD, |
| 644 | pkt_count, |
| 645 | (void **)(head_gpd), |
| 646 | (void **)(tail_gpd))) { |
| 647 | return; |
| 648 | } |
| 649 | |
| 650 | curr_gpd = *head_gpd; |
| 651 | for (idx = 0; idx < pkt_count; idx++) |
| 652 | { |
| 653 | bd = QBM_DES_GET_DATAPTR(curr_gpd); |
| 654 | if(ip == IP_TYPE_V4) { |
| 655 | packet_buf = dispatcher_ut_ipv4_dns_packet; |
| 656 | packet_len = sizeof(dispatcher_ut_ipv4_dns_packet); |
| 657 | } |
| 658 | if(ip == IP_TYPE_V6) { |
| 659 | packet_buf = dispatcher_ut_ipv6_dhcp_ul_packet; |
| 660 | packet_len = sizeof(dispatcher_ut_ipv6_dhcp_ul_packet); |
| 661 | } |
| 662 | kal_mem_cpy(QBM_DES_GET_DATAPTR(bd), packet_buf, packet_len); |
| 663 | QBM_DES_SET_DATALEN(bd, packet_len); |
| 664 | QBM_DES_SET_DATALEN(curr_gpd, packet_len); |
| 665 | curr_gpd = (qbm_gpd *)QBM_DES_GET_NEXT(curr_gpd); |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | kal_bool dispatcher_ut_prepare_and_recv_gpd_test_case_non_wifipdnId(void) |
| 670 | { |
| 671 | kal_uint32 ipv4_cnt = 2; |
| 672 | qbm_gpd *head_gpd; |
| 673 | qbm_gpd *tail_gpd; |
| 674 | kal_uint8 non_wifi_pdn = DISPATCHER_UT_TEST_NON_WIFI_PDNID; |
| 675 | kal_uint8 proto_idx = 0; |
| 676 | dispatcher_ut_prepare_ul_gpd_list(1, ipv4_cnt, &head_gpd, &tail_gpd); |
| 677 | dispatcher_rcv_ul_gpd_by_pdn((ip_type_e)1, non_wifi_pdn, head_gpd, tail_gpd, proto_idx); |
| 678 | if (g_ul_upcm_forward_gpd_count != ipv4_cnt) { |
| 679 | return KAL_FALSE; |
| 680 | } |
| 681 | return KAL_TRUE; |
| 682 | } |
| 683 | |
| 684 | |
| 685 | kal_bool dispatcher_ut_prepare_and_recv_gpd_test_case() |
| 686 | { |
| 687 | kal_uint32 ipv4_cnt = 2; |
| 688 | kal_uint32 ipv6_cnt = 2; |
| 689 | qbm_gpd *head_gpd; |
| 690 | qbm_gpd *tail_gpd; |
| 691 | kal_uint8 test_pdn_id = DISPATCHER_UT_TEST_PDNID; |
| 692 | kal_uint8 proto_idx = 0; |
| 693 | |
| 694 | dispatcher_bind_state_enum bind_state = dispatcher_get_bind_state_by_pdnid(DISPATCHER_UT_TEST_PDNID, proto_idx); |
| 695 | kal_bool is_bearer_active = dispatcher_check_is_bearer_active_by_pdnid(DISPATCHER_UT_TEST_PDNID, proto_idx); |
| 696 | |
| 697 | if (ipv4_cnt > 0) { |
| 698 | dispatcher_ut_prepare_ul_gpd_list(1, ipv4_cnt, &head_gpd, &tail_gpd); |
| 699 | dispatcher_rcv_ul_gpd_by_pdn((ip_type_e)1, test_pdn_id, head_gpd, tail_gpd, proto_idx); |
| 700 | if((bind_state == DISPATCHER_PDN_ST_BIND) && is_bearer_active) { |
| 701 | if(g_ul_wtunnel_forwarded_gpd_count != ipv4_cnt) { |
| 702 | return KAL_FALSE; |
| 703 | } |
| 704 | g_ul_wtunnel_forwarded_gpd_count = 0; |
| 705 | } else { |
| 706 | if(g_ul_drop_gpd_count != ipv4_cnt) { |
| 707 | return KAL_FALSE; |
| 708 | } |
| 709 | g_ul_drop_gpd_count = 0; |
| 710 | } |
| 711 | |
| 712 | } |
| 713 | if (ipv6_cnt > 0) { |
| 714 | dispatcher_ut_prepare_ul_gpd_list(2, ipv4_cnt, &head_gpd, &tail_gpd); |
| 715 | dispatcher_rcv_ul_gpd_by_pdn((ip_type_e)2, test_pdn_id, head_gpd, tail_gpd, proto_idx); |
| 716 | if((bind_state == DISPATCHER_PDN_ST_BIND) && is_bearer_active) { |
| 717 | if(g_ul_wtunnel_forwarded_gpd_count != ipv6_cnt) { |
| 718 | return KAL_FALSE; |
| 719 | } |
| 720 | g_ul_wtunnel_forwarded_gpd_count = 0; |
| 721 | } else { |
| 722 | if(g_ul_drop_gpd_count != ipv6_cnt) { |
| 723 | return KAL_FALSE; |
| 724 | } |
| 725 | g_ul_drop_gpd_count = 0; |
| 726 | } |
| 727 | |
| 728 | } |
| 729 | return KAL_TRUE; |
| 730 | |
| 731 | } |
| 732 | |
| 733 | kal_bool dispatcher_ut_ul_gpd_req_test(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz) |
| 734 | { |
| 735 | /*1.bearer active + bind |
| 736 | 2.prepare UL GPD list |
| 737 | 3.run the UL GPD test case |
| 738 | 4. bearer deact & unbind*/ |
| 739 | dispatcher_reset(); |
| 740 | /*first do bind*/ |
| 741 | dispatcher_ut_bearer_act_req_only(); |
| 742 | dispatcher_ut_pdn_bind_req_only(); |
| 743 | dispatcher_ut_pdn_bind_ipc_rsp_only(); |
| 744 | |
| 745 | if (!dispatcher_ut_prepare_and_recv_gpd_test_case()) { |
| 746 | return KAL_FALSE; |
| 747 | } |
| 748 | |
| 749 | |
| 750 | /*bearer deact & unbind in advance for next test case*/ |
| 751 | dispatcher_ut_bearer_deact_req_only(); |
| 752 | dispatcher_ut_pdn_unbind_req_only(); |
| 753 | |
| 754 | |
| 755 | //now unbind or bearer inactive check ul for drop gpd list |
| 756 | if (!dispatcher_ut_prepare_and_recv_gpd_test_case()) { |
| 757 | return KAL_FALSE; |
| 758 | } |
| 759 | |
| 760 | //a test case to check non wifi pdn id ul gpd req forwardig to UPCM |
| 761 | if (!dispatcher_ut_prepare_and_recv_gpd_test_case_non_wifipdnId()) { |
| 762 | return KAL_FALSE; |
| 763 | } |
| 764 | |
| 765 | return KAL_TRUE; |
| 766 | } |
| 767 | |
| 768 | |
| 769 | kal_uint32 dispatcher_ut_prepare_did_list(kal_uint8 count, upcm_did** p_head, upcm_did** p_tail) |
| 770 | { |
| 771 | kal_bool end_of_list = KAL_FALSE; |
| 772 | upcm_did *did; |
| 773 | upcm_did *prev_did = NULL; |
| 774 | upcm_did *next_did; |
| 775 | kal_uint8 alloc_num = upcm_did_alloc_q(count, p_head, p_tail); |
| 776 | |
| 777 | for (did = *p_head; did && !end_of_list; did = next_did) { |
| 778 | next_did = UPCM_DID_GET_NEXT(did); |
| 779 | end_of_list = (did == *p_tail); |
| 780 | |
| 781 | if (prev_did) { |
| 782 | UPCM_DID_SET_NEXT(prev_did, did); |
| 783 | } |
| 784 | prev_did = did; |
| 785 | } |
| 786 | |
| 787 | return alloc_num; |
| 788 | } |
| 789 | |
| 790 | |
| 791 | kal_bool dispatcher_ut_dl_did_req_test(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz) |
| 792 | { |
| 793 | /*1. bearer active + bind |
| 794 | 2.prepare DL Did list |
| 795 | 3.run the DL test case |
| 796 | 4. bearer deact & unbind*/ |
| 797 | |
| 798 | kal_uint32 allocated_count = 0; |
| 799 | kal_uint8 proto_idx = 0; |
| 800 | upcm_did* p_head; |
| 801 | upcm_did* p_tail; |
| 802 | kal_uint8 count = 2; |
| 803 | |
| 804 | dispatcher_reset(); |
| 805 | |
| 806 | /*TEST CASE 1*/ |
| 807 | dispatcher_ut_bearer_act_req_only(); |
| 808 | dispatcher_ut_pdn_bind_req_only(); |
| 809 | dispatcher_ut_pdn_bind_ipc_rsp_only(); |
| 810 | /*DL cbk is not registered sp these DID will be dropped*/ |
| 811 | dispatcher_ut_prepare_did_list(count, &p_head, &p_tail); |
| 812 | dispatcher_on_dl_did_cbk(DISPATCHER_UT_TEST_BEARERID, p_head, p_tail, proto_idx); |
| 813 | if (g_dl_drop_did_count != count) { |
| 814 | return KAL_FALSE; |
| 815 | } |
| 816 | g_dl_drop_did_count = 0; |
| 817 | |
| 818 | |
| 819 | /*TEST CASE 2*/ |
| 820 | /*now register DL cbk of ipcore simulation*/ |
| 821 | count = 4; |
| 822 | dispatcher_reg_cbk_dlvr_dl_did(dispatcher_ut_forward_dl_did_to_ipc); |
| 823 | dispatcher_ut_prepare_did_list(count, &p_head, &p_tail); |
| 824 | dispatcher_on_dl_did_cbk(DISPATCHER_UT_TEST_BEARERID, p_head, p_tail, proto_idx); |
| 825 | if (g_dl_ipcore_forward_did_count != count) { |
| 826 | return KAL_FALSE; |
| 827 | } |
| 828 | g_dl_ipcore_forward_did_count = 0; |
| 829 | |
| 830 | /*TEST CASE 3*/ |
| 831 | /*bearer deact & unbind in advance for next test case*/ |
| 832 | dispatcher_ut_bearer_deact_req_only(); |
| 833 | dispatcher_ut_pdn_unbind_req_only(); |
| 834 | // not bind or bearer deact so try again for drop test. |
| 835 | count = 3; |
| 836 | allocated_count = dispatcher_ut_prepare_did_list(count, &p_head, &p_tail); |
| 837 | dispatcher_on_dl_did_cbk(DISPATCHER_UT_TEST_BEARERID, p_head, p_tail, proto_idx); |
| 838 | if (g_dl_drop_did_count != count) { |
| 839 | return KAL_FALSE; |
| 840 | } |
| 841 | g_dl_drop_did_count = 0; |
| 842 | return KAL_TRUE; |
| 843 | |
| 844 | } |
| 845 | |
| 846 | void dispatcher_ut_init_meta(void) { |
| 847 | /*reset Q property*/ |
| 848 | kal_mem_set(dispatcher_ut_meta_queues, 0, sizeof(dispatcher_ut_meta_queue_t)); |
| 849 | /*reset meta tbl values*/ |
| 850 | kal_mem_set(dispatcher_ut_meta_tbl_s, 0, sizeof(dispatcher_ut_meta_tbl_s)); |
| 851 | /*init the Q type & Q base address*/ |
| 852 | dispatcher_ut_meta_queues[DISPATCHER_UT_LHIF_META_AP0].base_addr = (kal_uint8*)dispatcher_ut_meta_tbl_s; |
| 853 | dispatcher_ut_meta_queues[DISPATCHER_UT_LHIF_META_AP0].type_idx = DISPATCHER_UT_LHIF_META_AP0; |
| 854 | } |
| 855 | |
| 856 | kal_uint32 dispatcher_ut_alloc_meta( |
| 857 | dispatcher_ut_meta_type_e q_type, |
| 858 | kal_uint32 request_num, |
| 859 | kal_uint32 *p_head_idx, |
| 860 | kal_uint32 *p_tail_idx) { |
| 861 | kal_uint32 alloc_num, used_num, remain_num; |
| 862 | |
| 863 | kal_uint8 write_idx, read_idx; |
| 864 | |
| 865 | write_idx = dispatcher_ut_meta_queues[q_type].write_idx; |
| 866 | read_idx = dispatcher_ut_meta_queues[q_type].read_idx; |
| 867 | |
| 868 | used_num = (write_idx >= read_idx) |
| 869 | ? (write_idx - read_idx) : |
| 870 | (DISPATCHER_UT_META_TABLE_SIZE - read_idx + write_idx); |
| 871 | remain_num = DISPATCHER_UT_META_TABLE_SIZE - used_num - 1; |
| 872 | alloc_num = (request_num > remain_num) ? remain_num : request_num; |
| 873 | |
| 874 | *p_head_idx = write_idx; |
| 875 | write_idx += alloc_num; |
| 876 | if (write_idx >= DISPATCHER_UT_META_TABLE_SIZE) { |
| 877 | write_idx -= DISPATCHER_UT_META_TABLE_SIZE; |
| 878 | } |
| 879 | *p_tail_idx = write_idx; |
| 880 | |
| 881 | dispatcher_ut_meta_queues[q_type].write_idx = write_idx; |
| 882 | |
| 883 | return alloc_num; |
| 884 | } |
| 885 | |
| 886 | void dispatcher_ut_prepare_ul_meta_list( |
| 887 | kal_uint8 v4_wifi_pdn_meta_cnt, |
| 888 | kal_uint8 v6_wifi_pdn_meta_cnt, |
| 889 | kal_uint32 ipv4_cnt, |
| 890 | kal_uint32 ipv6_cnt, |
| 891 | kal_uint32 *p_head_idx, |
| 892 | kal_uint32 *p_tail_idx, |
| 893 | LHIF_QUEUE_TYPE *q_type, |
| 894 | kal_uint8 proto_idx, |
| 895 | kal_uint8 v4_igr_cnt, |
| 896 | kal_uint8 v6_igr_cnt) { |
| 897 | |
| 898 | kal_uint32 total_cnt = ipv4_cnt + ipv6_cnt; |
| 899 | |
| 900 | kal_uint8 v4_igr = v4_igr_cnt; |
| 901 | kal_uint8 v6_igr = v6_igr_cnt; |
| 902 | kal_uint8 v4_wifi_meta = v4_wifi_pdn_meta_cnt; |
| 903 | kal_uint8 v6_wifi_meta = v6_wifi_pdn_meta_cnt; |
| 904 | kal_uint8 *packet_buf; |
| 905 | kal_uint32 packet_len; |
| 906 | kal_uint8 sequence = 0; |
| 907 | kal_uint32 curr_meta_idx; |
| 908 | lhif_meta_tbl_t *curr_meta; |
| 909 | kal_uint32 idx; |
| 910 | dispatcher_ut_alloc_meta(DISPATCHER_UT_LHIF_META_AP0, total_cnt, p_head_idx, p_tail_idx); |
| 911 | *q_type = DISPATCHER_UT_LHIF_META_AP0; |
| 912 | |
| 913 | |
| 914 | /*now fill each meta as per choice*/ |
| 915 | /*IPV4 first*/ |
| 916 | curr_meta_idx = *p_head_idx; |
| 917 | for (idx = 0; idx < ipv4_cnt; idx++) { |
| 918 | curr_meta = &dispatcher_ut_meta_tbl_s[curr_meta_idx]; |
| 919 | packet_buf = dispatcher_ut_ipv4_dns_packet; |
| 920 | packet_len = sizeof(dispatcher_ut_ipv4_dns_packet); |
| 921 | curr_meta->vrb_addr = packet_buf; |
| 922 | curr_meta->length = packet_len; |
| 923 | curr_meta->psn = sequence; |
| 924 | if (v4_wifi_meta > 0) |
| 925 | { |
| 926 | curr_meta->pdn = DISPATCHER_UT_TEST_PDNID; |
| 927 | v4_wifi_meta --; |
| 928 | } |
| 929 | else |
| 930 | { |
| 931 | curr_meta->pdn = DISPATCHER_UT_TEST_NON_WIFI_PDNID; |
| 932 | } |
| 933 | curr_meta->protocol_idx = proto_idx; |
| 934 | if (v4_igr >0) |
| 935 | { |
| 936 | curr_meta->ignore = KAL_TRUE; |
| 937 | v4_igr --; |
| 938 | } |
| 939 | sequence ++; |
| 940 | curr_meta_idx ++; |
| 941 | if (curr_meta_idx == DISPATCHER_UT_META_TABLE_SIZE) { |
| 942 | curr_meta_idx = 0; |
| 943 | } |
| 944 | if (curr_meta_idx == *p_tail_idx) { |
| 945 | return; |
| 946 | } |
| 947 | } |
| 948 | /*IPV6*/ |
| 949 | for (idx = 0; idx < ipv6_cnt; idx++) { |
| 950 | curr_meta = &dispatcher_ut_meta_tbl_s[curr_meta_idx]; |
| 951 | packet_buf = dispatcher_ut_ipv6_dhcp_ul_packet; |
| 952 | packet_len = sizeof(dispatcher_ut_ipv6_dhcp_ul_packet); |
| 953 | curr_meta->vrb_addr = packet_buf; |
| 954 | curr_meta->length = packet_len; |
| 955 | curr_meta->psn = sequence; |
| 956 | if (v6_wifi_meta > 0) |
| 957 | { |
| 958 | curr_meta->pdn = DISPATCHER_UT_TEST_PDNID; |
| 959 | v6_wifi_meta --; |
| 960 | } |
| 961 | else |
| 962 | { |
| 963 | curr_meta->pdn = DISPATCHER_UT_TEST_NON_WIFI_PDNID; |
| 964 | } |
| 965 | if (v6_igr >0) |
| 966 | { |
| 967 | curr_meta->ignore = KAL_TRUE; |
| 968 | v6_igr --; |
| 969 | } |
| 970 | curr_meta->protocol_idx = proto_idx; |
| 971 | sequence ++; |
| 972 | |
| 973 | curr_meta_idx ++; |
| 974 | if (curr_meta_idx == DISPATCHER_UT_META_TABLE_SIZE) { |
| 975 | curr_meta_idx = 0; |
| 976 | } |
| 977 | if (curr_meta_idx == *p_tail_idx) { |
| 978 | return; |
| 979 | } |
| 980 | } |
| 981 | |
| 982 | } |
| 983 | |
| 984 | kal_bool dispatcher_ut_ul_meta_req(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz) |
| 985 | { |
| 986 | kal_uint32 ipv4_cnt = 5; |
| 987 | kal_uint32 ipv6_cnt = 5; |
| 988 | kal_uint32 head_idx; |
| 989 | kal_uint32 tail_idx; |
| 990 | LHIF_QUEUE_TYPE q_type; |
| 991 | kal_uint8 proto_idx = 0; |
| 992 | kal_uint8 v4_ignore = 1; |
| 993 | kal_uint8 v6_ignore = 1; |
| 994 | kal_uint8 ipv4_wifi_pdn_meta = 2; |
| 995 | kal_uint8 ipv6_wifi_pdn_meta = 2; |
| 996 | kal_uint8 expected_forward_count = 0; |
| 997 | kal_uint8 expected_igr_count = 0; |
| 998 | |
| 999 | dispatcher_reset(); |
| 1000 | |
| 1001 | /*first do bind*/ |
| 1002 | dispatcher_ut_bearer_act_req_only(); |
| 1003 | dispatcher_ut_pdn_bind_req_only(); |
| 1004 | dispatcher_ut_pdn_bind_ipc_rsp_only(); |
| 1005 | |
| 1006 | dispatcher_ut_init_meta(); |
| 1007 | dispatcher_ut_prepare_ul_meta_list(ipv4_wifi_pdn_meta, ipv6_wifi_pdn_meta, ipv4_cnt, ipv6_cnt, &head_idx, &tail_idx, &q_type, proto_idx, v4_ignore, v6_ignore); |
| 1008 | /*test uplink flow*/ |
| 1009 | dispatcher_rcv_ul_meta_queue(head_idx, tail_idx, q_type); |
| 1010 | expected_forward_count = ipv4_wifi_pdn_meta - v4_ignore + ipv6_wifi_pdn_meta - v6_ignore; |
| 1011 | expected_igr_count = v4_ignore + v6_ignore + expected_forward_count; |
| 1012 | ASSERT(expected_forward_count == g_ul_wtunnel_forwarded_gpd_count); |
| 1013 | ASSERT(g_ul_total_ignr_count == g_ul_total_ignr_count); |
| 1014 | g_ul_total_ignr_count = 0; |
| 1015 | g_ul_wtunnel_forwarded_gpd_count = 0; |
| 1016 | |
| 1017 | /*bearer deact & unbind in advance for next test case*/ |
| 1018 | dispatcher_ut_bearer_deact_req_only(); |
| 1019 | dispatcher_ut_pdn_unbind_req_only(); |
| 1020 | |
| 1021 | |
| 1022 | /*first do bind*/ |
| 1023 | dispatcher_ut_bearer_act_req_only(); |
| 1024 | dispatcher_ut_pdn_bind_req_only(); |
| 1025 | dispatcher_ut_pdn_bind_ipc_rsp_only(); |
| 1026 | |
| 1027 | dispatcher_ut_init_meta(); |
| 1028 | dispatcher_ut_pdn_unbind_req_only(); |
| 1029 | /*bearer active but state unbind*/ |
| 1030 | dispatcher_ut_prepare_ul_meta_list(ipv4_wifi_pdn_meta, ipv6_wifi_pdn_meta, ipv4_cnt, ipv6_cnt, &head_idx, &tail_idx, &q_type, proto_idx, v4_ignore, v6_ignore); |
| 1031 | /*test uplink flow*/ |
| 1032 | dispatcher_rcv_ul_meta_queue(head_idx, tail_idx, q_type); |
| 1033 | expected_forward_count = 0; |
| 1034 | expected_igr_count = v4_ignore + v6_ignore + (ipv4_wifi_pdn_meta - v4_ignore) + (ipv6_wifi_pdn_meta - v6_ignore); |
| 1035 | ASSERT(expected_forward_count == g_ul_wtunnel_forwarded_gpd_count); |
| 1036 | ASSERT(g_ul_total_ignr_count == g_ul_total_ignr_count); |
| 1037 | g_ul_total_ignr_count = 0; |
| 1038 | g_ul_wtunnel_forwarded_gpd_count = 0; |
| 1039 | /*deactivate bearer*/ |
| 1040 | dispatcher_ut_bearer_deact_req_only(); |
| 1041 | return KAL_TRUE; |
| 1042 | |
| 1043 | } |
| 1044 | |
| 1045 | kal_bool dispatcher_ut_ul_gpd_bearer_act_and_no_binding(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz) |
| 1046 | { |
| 1047 | /*only bearer act , pdn is unbind |
| 1048 | prepare gpd list & execute TC |
| 1049 | Expected tc to check drop the gpd list*/ |
| 1050 | dispatcher_reset(); |
| 1051 | dispatcher_ut_bearer_act_req_only(); |
| 1052 | if (!dispatcher_ut_prepare_and_recv_gpd_test_case()) { |
| 1053 | return KAL_FALSE; |
| 1054 | } |
| 1055 | |
| 1056 | /*bearer deact & unbind in advance for next test case*/ |
| 1057 | dispatcher_ut_bearer_deact_req_only(); |
| 1058 | return KAL_TRUE; |
| 1059 | |
| 1060 | } |
| 1061 | |
| 1062 | kal_bool dispatcher_ut_ul_gpd_bearer_act_bind_then_bearer_deact(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz) |
| 1063 | { |
| 1064 | dispatcher_reset(); |
| 1065 | /*first do bind*/ |
| 1066 | dispatcher_ut_bearer_act_req_only(); |
| 1067 | dispatcher_ut_pdn_bind_req_only(); |
| 1068 | dispatcher_ut_pdn_bind_ipc_rsp_only(); |
| 1069 | |
| 1070 | /*deactivate bearer*/ |
| 1071 | dispatcher_ut_bearer_deact_req_only(); |
| 1072 | |
| 1073 | /*bearer deactive & pdn bind, UL GPD recv, Drop the gpd*/ |
| 1074 | if (!dispatcher_ut_prepare_and_recv_gpd_test_case()) { |
| 1075 | return KAL_FALSE; |
| 1076 | } |
| 1077 | |
| 1078 | /*reset by unbinding here*/ |
| 1079 | dispatcher_ut_pdn_unbind_req_only(); |
| 1080 | |
| 1081 | return KAL_TRUE; |
| 1082 | } |
| 1083 | |
| 1084 | kal_bool dispatcher_ut_ul_meta_burst_packet_req(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz) |
| 1085 | { |
| 1086 | kal_uint32 ipv4_cnt = 30; |
| 1087 | kal_uint32 ipv6_cnt = 30; |
| 1088 | kal_uint32 head_idx; |
| 1089 | kal_uint32 tail_idx; |
| 1090 | LHIF_QUEUE_TYPE q_type; |
| 1091 | kal_uint8 proto_idx = 0; |
| 1092 | kal_uint8 v4_ignore = 0; |
| 1093 | kal_uint8 v6_ignore = 0; |
| 1094 | kal_uint8 ipv4_wifi_pdn_meta = 30; |
| 1095 | kal_uint8 ipv6_wifi_pdn_meta = 30; |
| 1096 | kal_uint8 expected_forward_count = 0; |
| 1097 | kal_uint8 expected_igr_count = 0; |
| 1098 | kal_uint8 expected_drop_pkt = 0; |
| 1099 | |
| 1100 | dispatcher_reset(); |
| 1101 | |
| 1102 | /*first do bind*/ |
| 1103 | dispatcher_ut_bearer_act_req_only(); |
| 1104 | dispatcher_ut_pdn_bind_req_only(); |
| 1105 | dispatcher_ut_pdn_bind_ipc_rsp_only(); |
| 1106 | |
| 1107 | dispatcher_ut_init_meta(); |
| 1108 | dispatcher_ut_prepare_ul_meta_list(ipv4_wifi_pdn_meta, ipv6_wifi_pdn_meta, ipv4_cnt, ipv6_cnt, &head_idx, &tail_idx, &q_type, proto_idx, v4_ignore, v6_ignore); |
| 1109 | /*test uplink flow*/ |
| 1110 | dispatcher_rcv_ul_meta_queue(head_idx, tail_idx, q_type); |
| 1111 | expected_forward_count = ipv4_wifi_pdn_meta - v4_ignore + ipv6_wifi_pdn_meta - v6_ignore; |
| 1112 | expected_drop_pkt = expected_forward_count - g_ul_wtunnel_forwarded_gpd_count; |
| 1113 | expected_igr_count = v4_ignore + v6_ignore + expected_forward_count; |
| 1114 | ASSERT(expected_igr_count == g_ul_total_ignr_count); |
| 1115 | g_ul_total_ignr_count = 0; |
| 1116 | g_ul_wtunnel_forwarded_gpd_count = 0; |
| 1117 | |
| 1118 | /*bearer deact & unbind in advance for next test case*/ |
| 1119 | dispatcher_ut_bearer_deact_req_only(); |
| 1120 | dispatcher_ut_pdn_unbind_req_only(); |
| 1121 | |
| 1122 | return KAL_TRUE; |
| 1123 | } |
| 1124 | |
| 1125 | kal_bool dispatcher_ut_pdn_binding_ipc_rsp_test(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz) |
| 1126 | { |
| 1127 | dispatcher_bind_state_enum bind_state; |
| 1128 | // BINDING ->IPC RSP OK ->BIND |
| 1129 | dispatcher_reset(); |
| 1130 | dispatcher_ut_bearer_act_req_only(); |
| 1131 | dispatcher_ut_pdn_bind_req_only(); |
| 1132 | bind_state = dispatcher_get_bind_state_by_pdnid(DISPATCHER_UT_TEST_PDNID, 0); |
| 1133 | if (bind_state != DISPATCHER_PDN_ST_BINDING) { |
| 1134 | return KAL_FALSE; |
| 1135 | } |
| 1136 | dispatcher_ut_pdn_bind_ipc_rsp_only(); |
| 1137 | bind_state = dispatcher_get_bind_state_by_pdnid(DISPATCHER_UT_TEST_PDNID, 0); |
| 1138 | if (bind_state != DISPATCHER_PDN_ST_BIND) { |
| 1139 | return KAL_FALSE; |
| 1140 | } |
| 1141 | dispatcher_ut_pdn_unbind_req_only(); |
| 1142 | dispatcher_ut_bearer_deact_req_only(); |
| 1143 | |
| 1144 | // BINDING ->IPC RSP FAIL ->UNBIND |
| 1145 | dispatcher_ut_bearer_act_req_only(); |
| 1146 | dispatcher_ut_pdn_bind_req_only(); |
| 1147 | bind_state = dispatcher_get_bind_state_by_pdnid(DISPATCHER_UT_TEST_PDNID, 0); |
| 1148 | if (bind_state != DISPATCHER_PDN_ST_BINDING) { |
| 1149 | return KAL_FALSE; |
| 1150 | } |
| 1151 | dispatcher_ut_pdn_bind_ipc_error_rsp_only(); |
| 1152 | bind_state = dispatcher_get_bind_state_by_pdnid(DISPATCHER_UT_TEST_PDNID, 0); |
| 1153 | if (bind_state != DISPATCHER_PDN_ST_UNBIND) { |
| 1154 | return KAL_FALSE; |
| 1155 | } |
| 1156 | //already unbind so just deactivate bearer |
| 1157 | dispatcher_ut_bearer_deact_req_only(); |
| 1158 | |
| 1159 | // BINDING->BINDING_GOING_TO_UNBIND ->IPC RSP OK ->UNBIND |
| 1160 | dispatcher_ut_bearer_act_req_only(); |
| 1161 | dispatcher_ut_pdn_bind_req_only(); |
| 1162 | bind_state = dispatcher_get_bind_state_by_pdnid(DISPATCHER_UT_TEST_PDNID, 0); |
| 1163 | if (bind_state != DISPATCHER_PDN_ST_BINDING) { |
| 1164 | return KAL_FALSE; |
| 1165 | } |
| 1166 | dispatcher_ut_pdn_unbind_req_only(); |
| 1167 | bind_state = dispatcher_get_bind_state_by_pdnid(DISPATCHER_UT_TEST_PDNID, 0); |
| 1168 | if (bind_state != DISPATCHER_PDN_ST_BINDING_GOING_TO_UNBIND) { |
| 1169 | return KAL_FALSE; |
| 1170 | } |
| 1171 | dispatcher_ut_pdn_bind_ipc_rsp_only(); |
| 1172 | bind_state = dispatcher_get_bind_state_by_pdnid(DISPATCHER_UT_TEST_PDNID, 0); |
| 1173 | if (bind_state != DISPATCHER_PDN_ST_UNBIND) { |
| 1174 | return KAL_FALSE; |
| 1175 | } |
| 1176 | //already unbind so just deactivate bearer |
| 1177 | dispatcher_ut_bearer_deact_req_only(); |
| 1178 | |
| 1179 | |
| 1180 | // BINDING->BINDING_GOING_TO_UNBIND ->IPC RSP FAIL->UNBIND |
| 1181 | dispatcher_ut_bearer_act_req_only(); |
| 1182 | dispatcher_ut_pdn_bind_req_only(); |
| 1183 | bind_state = dispatcher_get_bind_state_by_pdnid(DISPATCHER_UT_TEST_PDNID, 0); |
| 1184 | if (bind_state != DISPATCHER_PDN_ST_BINDING) { |
| 1185 | return KAL_FALSE; |
| 1186 | } |
| 1187 | dispatcher_ut_pdn_unbind_req_only(); |
| 1188 | bind_state = dispatcher_get_bind_state_by_pdnid(DISPATCHER_UT_TEST_PDNID, 0); |
| 1189 | if (bind_state != DISPATCHER_PDN_ST_BINDING_GOING_TO_UNBIND) { |
| 1190 | return KAL_FALSE; |
| 1191 | } |
| 1192 | dispatcher_ut_pdn_bind_ipc_error_rsp_only(); |
| 1193 | bind_state = dispatcher_get_bind_state_by_pdnid(DISPATCHER_UT_TEST_PDNID, 0); |
| 1194 | if (bind_state != DISPATCHER_PDN_ST_UNBIND) { |
| 1195 | return KAL_FALSE; |
| 1196 | } |
| 1197 | //already unbind so just deactivate bearer |
| 1198 | dispatcher_ut_bearer_deact_req_only(); |
| 1199 | |
| 1200 | return KAL_TRUE; |
| 1201 | } |
| 1202 | |
| 1203 | kal_bool dispatcher_ut_query_meta_table(kal_uint32 **base_addr, kal_uint16 *size, LHIF_QUEUE_TYPE queue_type) { |
| 1204 | *base_addr = (kal_uint32 *)dispatcher_ut_meta_tbl_s; |
| 1205 | *size = DISPATCHER_UT_META_TABLE_SIZE; |
| 1206 | |
| 1207 | return KAL_TRUE; |
| 1208 | } |
| 1209 | |
| 1210 | kal_bool dispatcher_ut_st_create(void) { |
| 1211 | static ST_TCASE_T dispatcher_ut_cases_s[] = { |
| 1212 | DISPATCHER_UT_CASE(dispatcher_ut_test_first, NULL), |
| 1213 | /*only bearer active*/ |
| 1214 | DISPATCHER_UT_CASE(dispatcher_ut_bearer_act_req_test, NULL), |
| 1215 | /*same bearer deactive*/ |
| 1216 | DISPATCHER_UT_CASE(dispatcher_ut_bearer_deact_req_test, NULL), |
| 1217 | /* bearer act + bind*/ |
| 1218 | DISPATCHER_UT_CASE(dispatcher_ut_pdn_bind_req_test, NULL), |
| 1219 | DISPATCHER_UT_CASE(dispatcher_ut_pdn_unbind_normal_req_test, NULL), |
| 1220 | DISPATCHER_UT_CASE(dispatcher_ut_pdn_unbind_handover_req_test, NULL), |
| 1221 | DISPATCHER_UT_CASE(dispatcher_ut_pdn_binding_ipc_rsp_test, NULL), |
| 1222 | DISPATCHER_UT_CASE(dispatcher_ut_ul_gpd_req_test, NULL), |
| 1223 | DISPATCHER_UT_CASE(dispatcher_ut_dl_did_req_test, NULL), |
| 1224 | DISPATCHER_UT_CASE(dispatcher_ut_ul_meta_req, NULL), |
| 1225 | DISPATCHER_UT_CASE(dispatcher_ut_ul_gpd_bearer_act_and_no_binding, NULL), |
| 1226 | DISPATCHER_UT_CASE(dispatcher_ut_ul_gpd_bearer_act_bind_then_bearer_deact, NULL), |
| 1227 | DISPATCHER_UT_CASE(dispatcher_ut_ul_meta_burst_packet_req, NULL), |
| 1228 | |
| 1229 | }; |
| 1230 | return st_reg_test("DISPATCHER", &(dispatcher_ut_cases_s[0]), (sizeof(dispatcher_ut_cases_s)/sizeof(ST_TCASE_T))); |
| 1231 | } |
| 1232 | |
| 1233 | kal_bool dispatcher_ut_register_dl_cbk(dispatcher_dlvr_dl_did_f1 pf_dlvr_did) { |
| 1234 | /*do nothing*/ |
| 1235 | return KAL_TRUE; |
| 1236 | } |
| 1237 | |
| 1238 | void dispatcher_ut_forward_dl_did_to_ipc(kal_uint32 pdn_id, upcm_did* p_head, |
| 1239 | upcm_did* p_tail, kal_uint8 protocol_idx) |
| 1240 | { |
| 1241 | upcm_did *did; |
| 1242 | kal_bool end_of_list = KAL_FALSE; |
| 1243 | upcm_did *next_did; |
| 1244 | kal_uint8 count = 0; |
| 1245 | |
| 1246 | for (did = p_head; did && !end_of_list; did = next_did) { |
| 1247 | next_did = UPCM_DID_GET_NEXT(did); |
| 1248 | count++; |
| 1249 | end_of_list = (did == p_tail); |
| 1250 | } |
| 1251 | upcm_did_dest_q(p_head, p_tail); |
| 1252 | g_dl_ipcore_forward_did_count = count; |
| 1253 | |
| 1254 | } |
| 1255 | |
| 1256 | void dispatcher_ut_drop_dl_did(kal_uint8 bearer_id, upcm_did* p_head, |
| 1257 | upcm_did* p_tail, kal_uint8 protocol_idx) |
| 1258 | { |
| 1259 | /*dispatcher UT is dropping DID due to invalid bearer ID or bearer not active or no cbk set*/ |
| 1260 | |
| 1261 | upcm_did *did; |
| 1262 | kal_bool end_of_list = KAL_FALSE; |
| 1263 | upcm_did *next_did; |
| 1264 | kal_uint8 count = 0; |
| 1265 | |
| 1266 | for (did = p_head; did && !end_of_list; did = next_did) { |
| 1267 | next_did = UPCM_DID_GET_NEXT(did); |
| 1268 | count++; |
| 1269 | end_of_list = (did == p_tail); |
| 1270 | } |
| 1271 | upcm_did_dest_q(p_head, p_tail); |
| 1272 | g_dl_drop_did_count = count; |
| 1273 | } |
| 1274 | |
| 1275 | void dispatcher_ut_forward_upcm_ul_meta(kal_uint16 start_idx, kal_uint16 end_idx, LHIF_QUEUE_TYPE q_type) |
| 1276 | { |
| 1277 | /*dispatcher has processed the queue , now can check the processing of meta is expected or not*/ |
| 1278 | kal_uint16 read_idx; |
| 1279 | kal_uint8 igr_count = 0; |
| 1280 | kal_uint16 wifi_pdn_meta_cnt = 0; |
| 1281 | kal_uint16 non_wifi_pdn_meta_cnt = 0; |
| 1282 | lhif_meta_tbl_t *meta_tbl; |
| 1283 | lhif_meta_tbl_t *meta; |
| 1284 | kal_uint16 tbl_size; |
| 1285 | dispatcher_ut_query_meta_table((kal_uint32 **)&meta_tbl, &tbl_size, q_type); |
| 1286 | read_idx = start_idx; |
| 1287 | |
| 1288 | do { |
| 1289 | meta = &meta_tbl[read_idx]; |
| 1290 | //meta is not ignore & pdn state is bind |
| 1291 | |
| 1292 | if (meta->ignore) { |
| 1293 | igr_count ++; |
| 1294 | } |
| 1295 | |
| 1296 | read_idx ++; |
| 1297 | if(read_idx == tbl_size) { |
| 1298 | read_idx = 0; |
| 1299 | } |
| 1300 | }while(read_idx != end_idx); |
| 1301 | g_ul_total_ignr_count = igr_count; |
| 1302 | |
| 1303 | } |
| 1304 | |
| 1305 | void dispatcher_ut_forward_upcm_ul_gpd(ip_type_e ip_type, |
| 1306 | kal_uint32 pdn_id, |
| 1307 | qbm_gpd* p_head, |
| 1308 | qbm_gpd* p_tail, |
| 1309 | kal_uint8 protocol_idx) |
| 1310 | { |
| 1311 | /*dispatcher is going to forward the gpd queue to upcm as PDN ID is not of WIFI*/ |
| 1312 | |
| 1313 | kal_uint8 count = qbmt_dest_q(p_head, p_tail); |
| 1314 | if (IS_PDNID_OF_WIFI(pdn_id)) { |
| 1315 | ASSERT(0); |
| 1316 | } |
| 1317 | g_ul_upcm_forward_gpd_count = count; |
| 1318 | |
| 1319 | } |
| 1320 | |
| 1321 | |
| 1322 | void dispatcher_ut_forward_upcm_ul_gpd_by_ebi(kal_uint32 ebi, qbm_gpd* p_head, qbm_gpd* p_tail, kal_uint8 protocol_idx) |
| 1323 | { |
| 1324 | /*dispatcher is going to forward the gpd queue to upcm as PDN ID is not of WIFI*/ |
| 1325 | |
| 1326 | kal_uint8 count = qbmt_dest_q(p_head, p_tail); |
| 1327 | |
| 1328 | g_ul_upcm_forward_gpd_count = count; |
| 1329 | |
| 1330 | } |
| 1331 | |
| 1332 | void dispatcher_ut_forward_wtunnel_ul_gpd(kal_uint8 bearer_id, |
| 1333 | qbm_gpd* p_head, |
| 1334 | qbm_gpd* p_tail, |
| 1335 | kal_uint8 protocol_idx) |
| 1336 | { |
| 1337 | /*dispatcher is going to forward the gpd queue to wifi tunnel as PDN ID is of WIFI & bearer active & bind*/ |
| 1338 | kal_uint8 pdn_id = 0; |
| 1339 | dispatcher_bind_state_enum bind_state; |
| 1340 | kal_bool is_bearer_active; |
| 1341 | kal_uint32 forwarded_gpd_count = qbmt_dest_q(p_head, p_tail); |
| 1342 | |
| 1343 | DISPATCHER_CONVERT_BEARERID_TO_PDNID(bearer_id, pdn_id); |
| 1344 | bind_state = dispatcher_get_bind_state_by_pdnid(pdn_id, protocol_idx); |
| 1345 | is_bearer_active = dispatcher_check_is_bearer_active_by_pdnid(pdn_id, protocol_idx); |
| 1346 | if(!((bind_state == DISPATCHER_PDN_ST_BIND) && (is_bearer_active== KAL_TRUE))) { |
| 1347 | ASSERT(0); |
| 1348 | } |
| 1349 | g_ul_wtunnel_forwarded_gpd_count += forwarded_gpd_count; |
| 1350 | |
| 1351 | } |
| 1352 | |
| 1353 | void dispatcher_ut_drop_ul_gpd(kal_uint32 pdn_id, |
| 1354 | qbm_gpd* p_head, qbm_gpd* p_tail, |
| 1355 | kal_uint8 protocol_idx) |
| 1356 | { |
| 1357 | /*dispatcher is going to drop the gpd queue to bearer not active or unbind*/ |
| 1358 | kal_uint8 count = qbmt_dest_q(p_head, p_tail); |
| 1359 | dispatcher_bind_state_enum bind_state = dispatcher_get_bind_state_by_pdnid(pdn_id, protocol_idx); |
| 1360 | kal_bool is_bearer_active = dispatcher_check_is_bearer_active_by_pdnid(pdn_id, protocol_idx); |
| 1361 | if (!((bind_state != DISPATCHER_PDN_ST_BIND) || (is_bearer_active == KAL_FALSE))) |
| 1362 | { |
| 1363 | ASSERT(0); |
| 1364 | } |
| 1365 | g_ul_drop_gpd_count = count; |
| 1366 | |
| 1367 | } |
| 1368 | |
| 1369 | void dispatcher_ut_pdn_bind_cnf_handling(n3epc_dispatcher_pdn_bind_cnf_struct* local_para) { |
| 1370 | g_curr_bind_cnf.cid = local_para->context_id; |
| 1371 | g_curr_bind_cnf.result = local_para->is_successful; |
| 1372 | g_curr_bind_cnf.error_code = local_para->error_result; |
| 1373 | } |
| 1374 | |
| 1375 | |
| 1376 | void dispatcher_ut_pdn_unbind_cnf_handling(n3epc_dispatcher_pdn_unbind_cnf_struct* local_para) { |
| 1377 | g_curr_unbind_cnf.cid = local_para->context_id; |
| 1378 | g_curr_unbind_cnf.result = local_para->is_successful; |
| 1379 | g_curr_unbind_cnf.error_code = local_para->error_result; |
| 1380 | } |
| 1381 | |
| 1382 | void dispatcher_ut_handling_n3epc_ilm(ilm_struct *p_ilm) { |
| 1383 | switch (p_ilm->msg_id) { |
| 1384 | /*WO<-DISPATCHER bind cnf*/ |
| 1385 | case MSG_ID_N3EPC_DISPATCHER_PDN_BIND_CNF: |
| 1386 | dispatcher_ut_pdn_bind_cnf_handling((n3epc_dispatcher_pdn_bind_cnf_struct*)p_ilm->local_para_ptr); |
| 1387 | break; |
| 1388 | /*WO<-DISPATCHER unbind cnf*/ |
| 1389 | case MSG_ID_N3EPC_DISPATCHER_PDN_UNBIND_CNF: |
| 1390 | dispatcher_ut_pdn_unbind_cnf_handling((n3epc_dispatcher_pdn_unbind_cnf_struct*)p_ilm->local_para_ptr); |
| 1391 | break; |
| 1392 | |
| 1393 | default: |
| 1394 | break; |
| 1395 | } |
| 1396 | } |
| 1397 | |
| 1398 | #endif /* ATEST_SYS_DISPATCHER */ |