1 /******************************************************************************
2 *
3 * Copyright(c) 2019 Realtek Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 *****************************************************************************/
15 #define _CMD_DISP_TEST_C_
16 #include "../phl_headers.h"
17 #include "../phl_api.h"
18
19 #ifdef CONFIG_PHL_TEST_SUITE
20 #ifdef ENABLE_CMD_DISP_TEST
21
22 struct test_case_init {
23 u8 init_cnt;
24 u8 start_cnt;
25 };
26 struct test_case_msg {
27 u32 msg_cnt[2];
28 u8 pending[2];
29 u8 forcefail;
30 };
31 struct test_case_cmd {
32 u32 token_cnt[2];
33 u32 cmd_msg[2];
34 u8 abort[2];
35 };
36 struct test_case_prio_msg {
37 u32 msg_idx;
38 };
39 struct test_case_cannot_io {
40 bool cannot_io;
41 u32 last_evt;
42 };
43
44 struct test_case_self_def_seq {
45 u32 seq;
46 u32 cnt;
47 };
48
49 struct cmd_disp_test_ctx {
50 struct test_obj_ctrl_interface intf;
51 struct phl_info_t* phl;
52 u8 is_test_end;
53 u8 test_case;
54 u8 is_pass;
55 u8 thread_mode;
56 char rsn[32];
57 struct phl_bk_module_ops ops;
58 struct phl_cmd_token_req req;
59 struct test_case_init case_init;
60 struct test_case_msg case_msg;
61 struct test_case_cmd case_cmd;
62 struct test_case_prio_msg case_prio_msg;
63 struct test_case_cannot_io case_cannot_io;
64 struct test_case_self_def_seq case_self_def_seq;
65 };
66 struct cmd_disp_test_ctx disp_test_ctx;
67
68 enum CMD_DISP_TEST_CASE {
69 DISP_TEST_INIT = 1,
70 DISP_TEST_SEND_MSG = 2,
71 DISP_TEST_CMD_TOKEN_REQ = 3,
72 DISP_TEST_CANNOT_IO = 4,
73 DISP_TEST_PRIORITIZE_MSG = 5,
74 DISP_TEST_SELF_DEF_SEQ = 6
75 };
76
77 char err_rsn[][32] = {
78 "init eng fail", /*0*/
79 "register mdl fail", /*1*/
80 "init mdl fail", /*2*/
81 "init mdl count err", /*3*/
82 "start eng fail", /*4*/
83 "start mdl count err", /*5*/
84 "stop eng fail", /*6*/
85 "stop mdl count err", /*7*/
86 "deinit mdl count err", /*8*/
87 "msg mdl id chk err", /*9*/
88 "send msg err", /*10*/
89 "msg cnt chk err", /*11*/
90 "msg fail hdl err", /*12*/
91 "add token err", /*13*/
92 "acquire token err", /*14*/
93 "free token chk err", /*15*/
94 "free token err", /*16*/
95 "cmd order err", /*17*/
96 "cancel cmd fail", /*18*/
97 "pending msg fail", /*19*/
98 "hook next req fail", /*20*/
99 "msg order err", /*21*/
100 "msg status indicator err", /*22*/
101 "msg completion not received", /*23*/
102 "set dispr attr fail", /*24*/
103 "self def seq not match", /*25*/
104 "none"};
test_req_acquired(void * dispr,void * priv)105 enum phl_mdl_ret_code test_req_acquired(void* dispr, void* priv)
106 {
107 u8 idx = 0;
108 void *d = phl_to_drvpriv(disp_test_ctx.phl);
109 struct phl_msg msg;
110 struct phl_msg_attribute attr;
111 enum rtw_phl_status status = RTW_PHL_STATUS_SUCCESS;
112
113 if(disp_test_ctx.test_case == DISP_TEST_CMD_TOKEN_REQ) {
114 if(phl_dispr_get_idx(dispr, &idx) != RTW_PHL_STATUS_SUCCESS)
115 return MDL_RET_FAIL;
116 disp_test_ctx.case_cmd.token_cnt[idx]++;
117 //wait for 2nd cmd req to send msg
118 if(disp_test_ctx.case_cmd.token_cnt[idx] == 2) {
119 _os_mem_set(d, &msg, 0, sizeof(struct phl_msg));
120 _os_mem_set(d, &attr, 0, sizeof(struct phl_msg_attribute));
121 SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_START + 1);
122 SET_MSG_EVT_ID_FIELD(msg.msg_id, 125);
123 msg.band_idx = idx;
124 status = phl_disp_eng_send_msg(disp_test_ctx.phl, &msg, &attr, NULL);
125 disp_test_ctx.case_cmd.cmd_msg[idx]++;
126 }
127 }
128 return MDL_RET_SUCCESS;
129 }
test_req_abort(void * dispr,void * priv)130 enum phl_mdl_ret_code test_req_abort(void* dispr, void* priv)
131 {
132 u8 idx = 0;
133 struct phl_msg msg = {0};
134 struct phl_msg_attribute attr = {0};
135
136 if(disp_test_ctx.test_case == DISP_TEST_CMD_TOKEN_REQ) {
137 if(phl_dispr_get_idx(dispr, &idx) != RTW_PHL_STATUS_SUCCESS)
138 return MDL_RET_FAIL;
139 disp_test_ctx.case_cmd.abort[idx] = true;
140 attr.opt = MSG_OPT_SEND_IN_ABORT;
141 SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_MDL_PHY_MGNT);
142 SET_MSG_EVT_ID_FIELD(msg.msg_id, 0x123);
143 msg.band_idx = idx;
144 phl_disp_eng_send_msg(disp_test_ctx.phl, &msg, &attr, NULL);
145 }
146 return MDL_RET_SUCCESS;
147 }
test_req_msg_hdlr(void * dispr,void * priv,struct phl_msg * msg)148 enum phl_mdl_ret_code test_req_msg_hdlr(void* dispr, void* priv, struct phl_msg* msg)
149 {
150 u8 idx = 0;
151 if(disp_test_ctx.test_case == DISP_TEST_CMD_TOKEN_REQ) {
152 if(phl_dispr_get_idx(dispr, &idx) != RTW_PHL_STATUS_SUCCESS)
153 return MDL_RET_FAIL;
154 if( MSG_EVT_ID_FIELD(msg->msg_id) == 125)
155 disp_test_ctx.case_cmd.cmd_msg[idx]++;
156 }
157 return MDL_RET_SUCCESS;
158
159 }
test_req_set_info(void * dispr,void * priv,struct phl_module_op_info * info)160 enum phl_mdl_ret_code test_req_set_info(void* dispr, void* priv,
161 struct phl_module_op_info* info)
162 {
163 return MDL_RET_SUCCESS;
164
165 }
test_req_query_info(void * dispr,void * priv,struct phl_module_op_info * info)166 enum phl_mdl_ret_code test_req_query_info(void* dispr, void* priv,
167 struct phl_module_op_info* info)
168 {
169 return MDL_RET_SUCCESS;
170
171 }
test_mdl_init(void * phl_info,void * dispr,void ** priv)172 enum phl_mdl_ret_code test_mdl_init(void* phl_info, void* dispr, void** priv)
173 {
174 if(disp_test_ctx.test_case == DISP_TEST_INIT)
175 disp_test_ctx.case_init.init_cnt++;
176 return MDL_RET_SUCCESS;
177 }
test_mdl_deinit(void * dispr,void * priv)178 void test_mdl_deinit(void* dispr, void* priv)
179 {
180 if(disp_test_ctx.test_case == DISP_TEST_INIT)
181 disp_test_ctx.case_init.init_cnt--;
182 return;
183 }
test_mdl_start(void * dispr,void * priv)184 enum phl_mdl_ret_code test_mdl_start(void* dispr, void* priv)
185 {
186 if(disp_test_ctx.test_case == DISP_TEST_INIT)
187 disp_test_ctx.case_init.start_cnt++;
188 return MDL_RET_SUCCESS;
189 }
test_mdl_stop(void * dispr,void * priv)190 enum phl_mdl_ret_code test_mdl_stop(void* dispr, void* priv)
191 {
192 if(disp_test_ctx.test_case == DISP_TEST_INIT)
193 disp_test_ctx.case_init.start_cnt--;
194 return MDL_RET_SUCCESS;
195 }
test_mdl_msg_hdlr(void * dispr,void * priv,struct phl_msg * msg)196 enum phl_mdl_ret_code test_mdl_msg_hdlr(void* dispr, void* priv, struct phl_msg* msg)
197 {
198 u8 idx = 0;
199 void *d = phl_to_drvpriv(disp_test_ctx.phl);
200 if(disp_test_ctx.test_case == DISP_TEST_SEND_MSG &&
201 phl_dispr_get_idx(dispr, &idx) == RTW_PHL_STATUS_SUCCESS) {
202 disp_test_ctx.case_msg.msg_cnt[idx]++;
203 if(MSG_EVT_ID_FIELD(msg->msg_id) == 4 && disp_test_ctx.case_msg.pending[idx] == false) {
204 disp_test_ctx.case_msg.pending[idx] = true;
205 return MDL_RET_PENDING; /* reschedule msg*/
206 }
207 if(MSG_EVT_ID_FIELD(msg->msg_id) == 15) {
208 if(!IS_MSG_FAIL(msg->msg_id)) {
209 disp_test_ctx.case_msg.forcefail = true;
210 return MDL_RET_FAIL; /* force msg fail*/
211 }
212 else {
213 disp_test_ctx.case_msg.forcefail = false;
214 }
215 }
216 if(MSG_EVT_ID_FIELD(msg->msg_id) == 10) {
217 _os_sleep_ms(d, 100);
218 }
219 }
220 if(disp_test_ctx.test_case == DISP_TEST_CMD_TOKEN_REQ) {
221 if(phl_dispr_get_idx(dispr, &idx) != RTW_PHL_STATUS_SUCCESS)
222 return MDL_RET_FAIL;
223 if(MSG_EVT_ID_FIELD(msg->msg_id) == 125 &&
224 disp_test_ctx.case_cmd.cmd_msg[idx] != 1)
225 disp_test_ctx.case_cmd.cmd_msg[idx]++;
226 if(MSG_EVT_ID_FIELD(msg->msg_id) == 0x123) {
227 SET_MSG_EVT_ID_FIELD(msg->msg_id, 0x124);
228 return MDL_RET_PENDING;
229 }
230 }
231 if (disp_test_ctx.test_case == DISP_TEST_PRIORITIZE_MSG) {
232 if(MSG_EVT_ID_FIELD(msg->msg_id) == 1 && IS_MSG_IN_PRE_PHASE(msg->msg_id)) {
233 disp_test_ctx.case_prio_msg.msg_idx = 1;
234 _os_sleep_ms(d, 100);
235 }
236 if (disp_test_ctx.case_prio_msg.msg_idx + 1 == MSG_EVT_ID_FIELD(msg->msg_id))
237 disp_test_ctx.case_prio_msg.msg_idx = MSG_EVT_ID_FIELD(msg->msg_id);
238 }
239 return MDL_RET_SUCCESS;
240 }
test_mdl_set_info(void * dispr,void * priv,struct phl_module_op_info * info)241 enum phl_mdl_ret_code test_mdl_set_info(void* dispr, void* priv,
242 struct phl_module_op_info* info)
243
244 {
245 return MDL_RET_SUCCESS;
246 }
test_mdl_query_info(void * dispr,void * priv,struct phl_module_op_info * info)247 enum phl_mdl_ret_code test_mdl_query_info(void* dispr, void* priv,
248 struct phl_module_op_info* info)
249 {
250 return MDL_RET_SUCCESS;
251 }
252
test_btc_mdl_msg_hdlr(void * dispr,void * priv,struct phl_msg * msg)253 enum phl_mdl_ret_code test_btc_mdl_msg_hdlr(void* dispr, void* priv, struct phl_msg* msg)
254 {
255 if(disp_test_ctx.test_case == DISP_TEST_SELF_DEF_SEQ) {
256 disp_test_ctx.case_self_def_seq.cnt++;
257 if (IS_MSG_IN_PRE_PHASE(msg->msg_id)) {
258 if (disp_test_ctx.case_self_def_seq.seq == 1)
259 disp_test_ctx.case_self_def_seq.seq = 2;
260 }
261 else {
262 if (disp_test_ctx.case_self_def_seq.seq == 6)
263 disp_test_ctx.case_self_def_seq.seq = 7;
264 }
265 }
266 return MDL_RET_SUCCESS;
267 }
268 /************************************************************************/
269
test_gen_mdl_msg_hdlr(void * dispr,void * priv,struct phl_msg * msg)270 enum phl_mdl_ret_code test_gen_mdl_msg_hdlr(void* dispr, void* priv, struct phl_msg* msg)
271 {
272 if(disp_test_ctx.test_case == DISP_TEST_SELF_DEF_SEQ) {
273 disp_test_ctx.case_self_def_seq.cnt++;
274 if (IS_MSG_IN_PRE_PHASE(msg->msg_id)) {
275 if (disp_test_ctx.case_self_def_seq.seq == 2)
276 disp_test_ctx.case_self_def_seq.seq = 3;
277 }
278 else {
279 if (disp_test_ctx.case_self_def_seq.seq == 4)
280 disp_test_ctx.case_self_def_seq.seq = 5;
281 }
282 }
283 return MDL_RET_SUCCESS;
284 }
285
286 /************************************************************************/
287
test_mcc_mdl_msg_hdlr(void * dispr,void * priv,struct phl_msg * msg)288 enum phl_mdl_ret_code test_mcc_mdl_msg_hdlr(void* dispr, void* priv, struct phl_msg* msg)
289 {
290 if(disp_test_ctx.test_case == DISP_TEST_SELF_DEF_SEQ) {
291 disp_test_ctx.case_self_def_seq.cnt++;
292 if (IS_MSG_IN_PRE_PHASE(msg->msg_id)) {
293 if (disp_test_ctx.case_self_def_seq.seq == 3)
294 disp_test_ctx.case_self_def_seq.seq = 4;
295 }
296 else {
297 if (disp_test_ctx.case_self_def_seq.seq == 5)
298 disp_test_ctx.case_self_def_seq.seq = 6;
299 }
300 }
301 return MDL_RET_SUCCESS;
302 }
303
304 /************************************************************************/
305
test_ser_mdl_msg_hdlr(void * dispr,void * priv,struct phl_msg * msg)306 enum phl_mdl_ret_code test_ser_mdl_msg_hdlr(void* dispr, void* priv, struct phl_msg* msg)
307 {
308 void *d = phl_to_drvpriv(disp_test_ctx.phl);
309
310 if(disp_test_ctx.test_case == DISP_TEST_SELF_DEF_SEQ) {
311 disp_test_ctx.case_self_def_seq.cnt++;
312 if (IS_MSG_IN_PRE_PHASE(msg->msg_id)) {
313 if (disp_test_ctx.case_self_def_seq.seq == 0)
314 disp_test_ctx.case_self_def_seq.seq = 1;
315 if (disp_test_ctx.case_self_def_seq.seq == 8)
316 _os_delay_ms(d, 100);
317 }
318 else {
319 if (disp_test_ctx.case_self_def_seq.seq == 7)
320 disp_test_ctx.case_self_def_seq.seq = 8;
321 }
322 }
323 return MDL_RET_SUCCESS;
324 }
325
disp_init_test(void)326 void disp_init_test( void )
327 {
328 u8 i = 0;
329 u8 mdl_cnt = 10;
330 void *d = phl_to_drvpriv(disp_test_ctx.phl);
331 enum rtw_phl_status status = RTW_PHL_STATUS_SUCCESS;
332 struct phl_cmd_dispatch_engine *disp_eng = NULL;
333 disp_test_ctx.is_pass = true;
334 u32 offset[] = {PHL_BK_MDL_ROLE_START, PHL_BK_MDL_OPT_START, PHL_BK_MDL_MDRY_START};
335 u32 idx = 0;
336
337 for(i = 0; i < 5; i++) {
338 status = phl_disp_eng_init(disp_test_ctx.phl, 3);
339 if( (!i && status != RTW_PHL_STATUS_SUCCESS) ||
340 (i && status == RTW_PHL_STATUS_SUCCESS)) {
341 disp_test_ctx.is_pass = false;
342 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[0], sizeof(err_rsn[0]));
343 goto test_err;
344 }
345 }
346 disp_eng = &(disp_test_ctx.phl->disp_eng);
347 for( i = 0 ; i < mdl_cnt; i++) {
348 idx = i % PHL_MDL_PRI_MAX;
349 status = dispr_register_module(disp_eng->dispatcher[2],
350 i+offset[idx],
351 &(disp_test_ctx.ops));
352 if(status != RTW_PHL_STATUS_SUCCESS) {
353 disp_test_ctx.is_pass = false;
354 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[1], sizeof(err_rsn[1]));
355 goto test_err;
356 }
357 }
358
359 status = phl_disp_eng_start(disp_test_ctx.phl);
360 if(status != RTW_PHL_STATUS_SUCCESS ) {
361 disp_test_ctx.is_pass = false;
362 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[4], sizeof(err_rsn[4]));
363 goto test_err;
364 }
365 if(disp_test_ctx.case_init.start_cnt != mdl_cnt) {
366 disp_test_ctx.is_pass = false;
367 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[5], sizeof(err_rsn[5]));
368 goto test_err;
369 }
370
371 status = phl_disp_eng_stop(disp_test_ctx.phl);
372 if(status != RTW_PHL_STATUS_SUCCESS ) {
373 disp_test_ctx.is_pass = false;
374 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[6], sizeof(err_rsn[6]));
375 goto test_err;
376 }
377 if(disp_test_ctx.case_init.start_cnt) {
378 disp_test_ctx.is_pass = false;
379 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[7], sizeof(err_rsn[7]));
380 goto test_err;
381 }
382
383 status = phl_disp_eng_deinit(disp_test_ctx.phl);
384 if( status != RTW_PHL_STATUS_SUCCESS)
385 disp_test_ctx.is_pass = false;
386 if(disp_test_ctx.case_init.init_cnt) {
387 disp_test_ctx.is_pass = false;
388 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[8], sizeof(err_rsn[8]));
389 }
390 goto test_end;
391 test_err:
392 status = phl_disp_eng_deinit(disp_test_ctx.phl);
393 test_end:
394 disp_test_ctx.is_test_end = true;
395 }
396
disp_send_msg_test(void)397 void disp_send_msg_test( void )
398 {
399 u32 i = 0;
400 struct phl_msg msg;
401 struct phl_msg_attribute attr;
402 u8 mdl_cnt = 10;
403 u8 phy_num = 2;
404 void *d = phl_to_drvpriv(disp_test_ctx.phl);
405 enum rtw_phl_status status = RTW_PHL_STATUS_SUCCESS;
406 struct phl_cmd_dispatch_engine *disp_eng = NULL;
407 u8 man_num = 0;
408 u8 opt_num = 0;
409 u8 role_num = 0;
410 u8 total_num = 0;
411 u32 msg_hdl = 0;
412 u32 offset[] = {PHL_BK_MDL_ROLE_START, PHL_BK_MDL_OPT_START, PHL_BK_MDL_MDRY_START};
413 u32 idx = 0;
414 u32 tmp = 0;
415
416 disp_test_ctx.is_pass = true;
417 status = phl_disp_eng_init(disp_test_ctx.phl, phy_num);
418 if(status != RTW_PHL_STATUS_SUCCESS) {
419 disp_test_ctx.is_pass = false;
420 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[0], sizeof(err_rsn[0]));
421 goto test_end;
422 }
423 disp_eng = &(disp_test_ctx.phl->disp_eng);
424 status = phl_disp_eng_start(disp_test_ctx.phl);
425 if(status != RTW_PHL_STATUS_SUCCESS ) {
426 disp_test_ctx.is_pass = false;
427 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[4], sizeof(err_rsn[4]));
428 goto test_end;
429 }
430
431 _os_mem_set(d, &msg, 0, sizeof(struct phl_msg));
432 _os_mem_set(d, &attr, 0, sizeof(struct phl_msg_attribute));
433 /* check recycle flow */
434 for( i = 0 ; i < 100; i++) {
435 if( !(i % 10 ))
436 SET_MSG_MDL_ID_FIELD(msg.msg_id, 10);
437 else
438 SET_MSG_MDL_ID_FIELD(msg.msg_id, 0);
439 SET_MSG_EVT_ID_FIELD(msg.msg_id, i);
440 msg.band_idx = 0;
441 status = phl_disp_eng_send_msg(disp_test_ctx.phl, &msg, &attr, NULL);
442 if((!(i %10) && status == RTW_PHL_STATUS_SUCCESS) ||
443 ((i %10) && status == RTW_PHL_STATUS_FAILURE)) {
444 disp_test_ctx.is_pass = false;
445 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[9], sizeof(err_rsn[9]));
446 goto test_end;
447 }
448 msg.band_idx = 1;
449 status = phl_disp_eng_send_msg(disp_test_ctx.phl, &msg, &attr, NULL);
450 if((!(i %10) && status == RTW_PHL_STATUS_SUCCESS) ||
451 ((i %10) && status == RTW_PHL_STATUS_FAILURE)) {
452 disp_test_ctx.is_pass = false;
453 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[9], sizeof(err_rsn[9]));
454 goto test_end;
455 }
456
457 }
458 _os_sleep_ms(d, 100);
459 /* check dispatch flow */
460 for( i = 0 ; i < mdl_cnt; i++) {
461 /* num of wifi role module: 4 (10, 13, 16, 19)
462 * num of optional module: 3 (72, 75, 78)
463 * num of mandatory module: 3 (43, 46, 49)
464 * for modules at mandatory & wifi role priority,
465 * they would receive every msg
466 * for modules at optional priority,
467 * they only receive msg when bitmap is set in phl_disp_eng_send_msg
468 */
469 man_num = 3;
470 opt_num = 3;
471 role_num = 4;
472 idx = i % PHL_MDL_PRI_MAX;
473 status = dispr_register_module(disp_eng->dispatcher[0],
474 i+offset[idx],
475 &(disp_test_ctx.ops));
476 if(status != RTW_PHL_STATUS_SUCCESS) {
477 disp_test_ctx.is_pass = false;
478 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[1], sizeof(err_rsn[1]));
479 goto test_end;
480 }
481 status = dispr_register_module(disp_eng->dispatcher[1],
482 i+offset[idx],
483 &(disp_test_ctx.ops));
484 if(status != RTW_PHL_STATUS_SUCCESS) {
485 disp_test_ctx.is_pass = false;
486 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[1], sizeof(err_rsn[1]));
487 goto test_end;
488 }
489 }
490 for( i = 0 ; i < mdl_cnt; i++) {
491 idx = i % PHL_MDL_PRI_MAX;
492 SET_MSG_MDL_ID_FIELD(msg.msg_id, i+offset[idx]);
493 SET_MSG_EVT_ID_FIELD(msg.msg_id, i);
494 if(i == 3)
495 tmp = 72;
496 else if( i == 6)
497 tmp = 78;
498 else
499 tmp = 0;
500 attr.notify.id_arr = (u8*)&tmp;
501 attr.notify.len = 1;
502 attr.opt |= MSG_OPT_SKIP_NOTIFY_OPT_MDL;
503 msg.band_idx = 0;
504 status = phl_disp_eng_send_msg(disp_test_ctx.phl, &msg, &attr, NULL);
505 if(status != RTW_PHL_STATUS_SUCCESS) {
506 disp_test_ctx.is_pass = false;
507 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[10], sizeof(err_rsn[10]));
508 goto test_end;
509 }
510 msg.band_idx = 1;
511 phl_disp_eng_send_msg(disp_test_ctx.phl, &msg, &attr, NULL);
512 }
513 attr.opt = 0;
514 attr.notify.id_arr = NULL;
515 attr.notify.len = 0;
516 _os_sleep_ms(d, 100);
517 total_num = 2* (((man_num+role_num) * mdl_cnt) + 3 + 2) + 1;
518 if(disp_test_ctx.case_msg.msg_cnt[0] == total_num ||
519 disp_test_ctx.case_msg.msg_cnt[1] == total_num) {
520 disp_test_ctx.is_pass = false;
521 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[11], sizeof(err_rsn[19]));
522 goto test_end;
523 }
524 phl_disp_eng_clr_pending_msg(disp_test_ctx.phl, 0);
525 phl_disp_eng_clr_pending_msg(disp_test_ctx.phl, 1);
526 /*
527 * we send 10 msgs above & expect the msg cnt to be as below
528 * total = 2 * ((man_num + role_num) * msg_cnt + 3 + 2) + 1
529 * regarding multiply * 2, since we have pre_phase & post_phase handle
530 * 3: opt module number
531 * 2: when module id = {13, 16}, we indicate one optional module to notify
532 * 1: since module id 43 should be entered twice because of reschedule
533 */
534 _os_sleep_ms(d, 100);
535 disp_test_ctx.case_msg.pending[0] = false;
536 disp_test_ctx.case_msg.pending[1] = false;
537 total_num = 2* (((man_num+role_num) * mdl_cnt) + 3 + 2) + 1;
538 if(disp_test_ctx.case_msg.msg_cnt[0] != total_num ||
539 disp_test_ctx.case_msg.msg_cnt[1] != total_num) {
540 disp_test_ctx.is_pass = false;
541 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[11], sizeof(err_rsn[11]));
542 goto test_end;
543 }
544 SET_MSG_MDL_ID_FIELD(msg.msg_id, 78);
545 SET_MSG_EVT_ID_FIELD(msg.msg_id, 15);
546 msg.band_idx = 0;
547 phl_disp_eng_send_msg(disp_test_ctx.phl, &msg, &attr, NULL);
548 _os_sleep_ms(d, 10);
549 if(disp_test_ctx.case_msg.forcefail == true) {
550 disp_test_ctx.is_pass = false;
551 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[11], sizeof(err_rsn[11]));
552 goto test_end;
553 }
554 SET_MSG_MDL_ID_FIELD(msg.msg_id, 78);
555 SET_MSG_EVT_ID_FIELD(msg.msg_id, 10);
556 phl_disp_eng_send_msg(disp_test_ctx.phl, &msg, &attr, &msg_hdl);
557 _os_sleep_ms(d, 100);
558 phl_disp_eng_cancel_msg(disp_test_ctx.phl, 0, &msg_hdl);
559 test_end:
560 status = phl_disp_eng_stop(disp_test_ctx.phl);
561 status = phl_disp_eng_deinit(disp_test_ctx.phl);
562 disp_test_ctx.is_test_end = true;
563 }
564
disp_cmd_token_test(void)565 void disp_cmd_token_test( void )
566 {
567 u32 i = 0;
568 u32 j = 0;
569 u8 phy_num = 2;
570 void *d = phl_to_drvpriv(disp_test_ctx.phl);
571 enum rtw_phl_status status = RTW_PHL_STATUS_SUCCESS;
572 struct phl_cmd_dispatch_engine *disp_eng = NULL;
573 u32 req_hdl[2][10] = {0};
574 disp_test_ctx.is_pass = true;
575 status = phl_disp_eng_init(disp_test_ctx.phl, phy_num);
576 if(status != RTW_PHL_STATUS_SUCCESS) {
577 disp_test_ctx.is_pass = false;
578 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[0], sizeof(err_rsn[0]));
579 goto test_end;
580 }
581 disp_eng = &(disp_test_ctx.phl->disp_eng);
582 status = phl_disp_eng_start(disp_test_ctx.phl);
583 if(status != RTW_PHL_STATUS_SUCCESS ) {
584 disp_test_ctx.is_pass = false;
585 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[4], sizeof(err_rsn[4]));
586 goto test_end;
587 }
588 for( i = 0 ; i < phy_num ; i++) {
589 status = dispr_register_module(disp_eng->dispatcher[i],
590 PHL_BK_MDL_MDRY_START,
591 &(disp_test_ctx.ops));
592 if(status != RTW_PHL_STATUS_SUCCESS) {
593 disp_test_ctx.is_pass = false;
594 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[1], sizeof(err_rsn[1]));
595 goto test_end;
596 }
597 for( j = 0 ; j < 10 ; j++) {
598 disp_test_ctx.req.module_id = (u8)(PHL_FG_MDL_START + j);
599 status = phl_disp_eng_add_token_req(disp_test_ctx.phl, (u8)i, &(disp_test_ctx.req), &(req_hdl[i][j]));
600 _os_sleep_ms(d, 1);
601 if( (j == 0 && status != RTW_PHL_STATUS_SUCCESS ) ||
602 ( j && j < 8 && status != RTW_PHL_STATUS_PENDING) ||
603 (j >= 8 && status != RTW_PHL_STATUS_RESOURCE)) {
604 PHL_INFO("[DISP_TEST] idx: %d status:%d\n", j, status);
605 disp_test_ctx.is_pass = false;
606 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[13], sizeof(err_rsn[13]));
607 goto test_end;
608 }
609 }
610 }
611 _os_sleep_ms(d, 100);
612 if(disp_test_ctx.case_cmd.token_cnt[0] != 1||
613 disp_test_ctx.case_cmd.token_cnt[1] != 1) {
614 disp_test_ctx.is_pass = false;
615 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[14], sizeof(err_rsn[14]));
616 goto test_end;
617 }
618 for(i = 0 ; i < phy_num; i++) {
619 status = phl_disp_eng_free_token(disp_test_ctx.phl, (u8)i, &(req_hdl[i][1]));
620 if(status == RTW_PHL_STATUS_SUCCESS ) {
621 disp_test_ctx.is_pass = false;
622 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[15], sizeof(err_rsn[15]));
623 goto test_end;
624 }
625 status = phl_disp_eng_free_token(disp_test_ctx.phl, (u8)i, &(req_hdl[i][0]));
626 if(status != RTW_PHL_STATUS_SUCCESS ) {
627 disp_test_ctx.is_pass = false;
628 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[16], sizeof(err_rsn[16]));
629 goto test_end;
630 }
631 }
632 _os_sleep_ms(d, 100);
633 if(disp_test_ctx.case_cmd.cmd_msg[0] != 2 ||
634 disp_test_ctx.case_cmd.cmd_msg[1] != 2) {
635 disp_test_ctx.is_pass = false;
636 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[17], sizeof(err_rsn[17]));
637 goto test_end;
638 }
639 for(i = 0 ; i < phy_num; i++) {
640 disp_test_ctx.case_cmd.abort[i] = false;
641 phl_disp_eng_cancel_token_req(disp_test_ctx.phl, (u8)i, &(req_hdl[i][1]));
642 _os_sleep_ms(d, 100);
643 if(disp_test_ctx.case_cmd.abort[i] == false ||
644 disp_test_ctx.case_cmd.token_cnt[i] == 3) {
645 disp_test_ctx.is_pass = false;
646 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[18], sizeof(err_rsn[18]));
647 goto test_end;
648 }
649 phl_disp_eng_clr_pending_msg(disp_test_ctx.phl, (u8)i);
650 _os_sleep_ms(d, 100);
651 if( disp_test_ctx.case_cmd.token_cnt[i] != 3) {
652 disp_test_ctx.is_pass = false;
653 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[20], sizeof(err_rsn[20]));
654 goto test_end;
655 }
656 }
657 test_end:
658 status = phl_disp_eng_stop(disp_test_ctx.phl);
659 status = phl_disp_eng_deinit(disp_test_ctx.phl);
660 disp_test_ctx.is_test_end = true;
661
662 }
663
664
disp_prioritize_msg_test(void)665 void disp_prioritize_msg_test( void )
666 {
667 u32 i = 0;
668 struct phl_msg msg = {0};
669 struct phl_msg_attribute attr = {0};
670 u8 ctrl_msg_cnt = 4;
671 u8 msg_cnt = 10;
672 u8 ctrl_msg_start = 2;
673 u8 msg_start = ctrl_msg_start + ctrl_msg_cnt;
674 u8 phy_num = 1;
675 void *d = phl_to_drvpriv(disp_test_ctx.phl);
676 enum rtw_phl_status status = RTW_PHL_STATUS_SUCCESS;
677 struct phl_cmd_dispatch_engine *disp_eng = NULL;
678
679 disp_test_ctx.is_pass = true;
680 status = phl_disp_eng_init(disp_test_ctx.phl, phy_num);
681 if(status != RTW_PHL_STATUS_SUCCESS) {
682 disp_test_ctx.is_pass = false;
683 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[0], sizeof(err_rsn[0]));
684 goto test_end;
685 }
686 disp_eng = &(disp_test_ctx.phl->disp_eng);
687 status = phl_disp_eng_start(disp_test_ctx.phl);
688 if(status != RTW_PHL_STATUS_SUCCESS ) {
689 disp_test_ctx.is_pass = false;
690 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[4], sizeof(err_rsn[4]));
691 goto test_end;
692 }
693
694 /* check dispatch flow */
695 status = dispr_register_module(disp_eng->dispatcher[0],
696 PHL_MDL_GENERAL,
697 &(disp_test_ctx.ops));
698 if(status != RTW_PHL_STATUS_SUCCESS) {
699 disp_test_ctx.is_pass = false;
700 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[1], sizeof(err_rsn[1]));
701 goto test_end;
702 }
703 SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_MDL_GENERAL);
704 SET_MSG_EVT_ID_FIELD(msg.msg_id, 1);
705 msg.band_idx = 0;
706 status = phl_disp_eng_send_msg(disp_test_ctx.phl, &msg, &attr, NULL);
707 if(status != RTW_PHL_STATUS_SUCCESS) {
708 disp_test_ctx.is_pass = false;
709 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[10], sizeof(err_rsn[10]));
710 goto test_end;
711 }
712 _os_sleep_ms(d, 10);
713 for( i = 0 ; i < (u32) (msg_cnt + ctrl_msg_cnt); i++) {
714 if (i % 3) {
715 SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_MDL_GENERAL);
716 SET_MSG_EVT_ID_FIELD(msg.msg_id, msg_start);
717 msg_start++;
718 }
719 else {
720 SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_MDL_PHY_MGNT);
721 SET_MSG_EVT_ID_FIELD(msg.msg_id, ctrl_msg_start);
722 ctrl_msg_start++;
723 }
724 status = phl_disp_eng_send_msg(disp_test_ctx.phl, &msg, &attr, NULL);
725 }
726 _os_sleep_ms(d, 200);
727 PHL_INFO("[DISP_TEST] msg_idx:0x%x\n",disp_test_ctx.case_prio_msg.msg_idx);
728 if(disp_test_ctx.case_prio_msg.msg_idx != (u32) (msg_start - 1)) {
729 disp_test_ctx.is_pass = false;
730 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[21], sizeof(err_rsn[21]));
731 goto test_end;
732 }
733
734 test_end:
735 status = phl_disp_eng_stop(disp_test_ctx.phl);
736 status = phl_disp_eng_deinit(disp_test_ctx.phl);
737 disp_test_ctx.is_test_end = true;
738 }
739
_msg_completion(void * priv,struct phl_msg * msg)740 void _msg_completion(void* priv, struct phl_msg* msg)
741 {
742 void *d = phl_to_drvpriv(disp_test_ctx.phl);
743
744 PHL_INFO("[DISP_TEST] msg_id:0x%x\n", msg->msg_id);
745 if (MSG_EVT_ID_FIELD(msg->msg_id) == 10) {
746 if ( (!IS_MSG_CANCEL(msg->msg_id) || !IS_MSG_CANNOT_IO(msg->msg_id))) {
747 disp_test_ctx.is_pass = false;
748 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[22], sizeof(err_rsn[22]));
749 }
750 }
751 else {
752 disp_test_ctx.case_cannot_io.last_evt = MSG_EVT_ID_FIELD(msg->msg_id);
753 if (disp_test_ctx.case_cannot_io.cannot_io == true) {
754 disp_test_ctx.is_pass = false;
755 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[19], sizeof(err_rsn[19]));
756 }
757 else if (IS_MSG_CANCEL(msg->msg_id) || IS_MSG_FAIL(msg->msg_id) || IS_MSG_CANNOT_IO(msg->msg_id)) {
758 disp_test_ctx.is_pass = false;
759 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[22], sizeof(err_rsn[22]));
760 }
761 }
762 }
763
disp_cannot_io_test(void)764 void disp_cannot_io_test( void )
765 {
766 struct phl_msg msg = {0};
767 struct phl_msg_attribute attr = {0};
768 u8 phy_num = 1;
769 void *d = phl_to_drvpriv(disp_test_ctx.phl);
770 enum rtw_phl_status status = RTW_PHL_STATUS_SUCCESS;
771 struct phl_cmd_dispatch_engine *disp_eng = NULL;
772
773 disp_test_ctx.is_pass = true;
774 status = phl_disp_eng_init(disp_test_ctx.phl, phy_num);
775 if(status != RTW_PHL_STATUS_SUCCESS) {
776 disp_test_ctx.is_pass = false;
777 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[0], sizeof(err_rsn[0]));
778 goto test_end;
779 }
780 disp_eng = &(disp_test_ctx.phl->disp_eng);
781 status = phl_disp_eng_start(disp_test_ctx.phl);
782 if(status != RTW_PHL_STATUS_SUCCESS ) {
783 disp_test_ctx.is_pass = false;
784 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[4], sizeof(err_rsn[4]));
785 goto test_end;
786 }
787
788 disp_test_ctx.case_cannot_io.cannot_io = true;
789 phl_disp_eng_notify_dev_io_status(disp_test_ctx.phl, HW_BAND_MAX, 0, false);
790
791 SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_MDL_PHY_MGNT);
792 SET_MSG_EVT_ID_FIELD(msg.msg_id, 10);
793 msg.band_idx = 0;
794 attr.completion.completion = _msg_completion;
795 attr.completion.priv = &disp_test_ctx;
796
797 status = phl_disp_eng_send_msg(disp_test_ctx.phl, &msg, &attr, NULL);
798 if(status != RTW_PHL_STATUS_SUCCESS) {
799 disp_test_ctx.is_pass = false;
800 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[10], sizeof(err_rsn[10]));
801 goto test_end;
802 }
803 _os_sleep_ms(d, 100);
804 if (disp_test_ctx.is_pass == false)
805 goto test_end;
806
807 SET_MSG_EVT_ID_FIELD(msg.msg_id, 20);
808 attr.opt |= MSG_OPT_PENDING_DURING_CANNOT_IO;
809 status = phl_disp_eng_send_msg(disp_test_ctx.phl, &msg, &attr, NULL);
810 if(status != RTW_PHL_STATUS_SUCCESS) {
811 disp_test_ctx.is_pass = false;
812 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[10], sizeof(err_rsn[10]));
813 goto test_end;
814 }
815 _os_sleep_ms(d, 100);
816 if (disp_test_ctx.is_pass == false)
817 goto test_end;
818
819 disp_test_ctx.case_cannot_io.cannot_io = false;
820 phl_disp_eng_notify_dev_io_status(disp_test_ctx.phl, HW_BAND_MAX, 0, true);
821
822 _os_sleep_ms(d, 100);
823 if (disp_test_ctx.case_cannot_io.last_evt != 20) {
824 disp_test_ctx.is_pass = false;
825 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[23], sizeof(err_rsn[23]));
826 }
827
828 test_end:
829 status = phl_disp_eng_stop(disp_test_ctx.phl);
830 status = phl_disp_eng_deinit(disp_test_ctx.phl);
831 disp_test_ctx.is_test_end = true;
832 }
disp_self_def_msg_test(void)833 void disp_self_def_msg_test( void )
834 {
835 u32 i = 0;
836 struct phl_msg msg;
837 struct phl_msg_attribute attr;
838 u8 phy_num = 2;
839 void *d = phl_to_drvpriv(disp_test_ctx.phl);
840 enum rtw_phl_status status = RTW_PHL_STATUS_SUCCESS;
841 struct phl_cmd_dispatch_engine *disp_eng = NULL;
842 struct msg_self_def_seq seq = {0};
843 u8 pre_proct_seq[] = {PHL_MDL_BTC, PHL_MDL_GENERAL, PHL_MDL_MRC, PHL_MDL_SER, PHL_MDL_POWER_MGNT};
844 u8 post_proct_seq[] = {PHL_MDL_GENERAL, PHL_MDL_MRC, PHL_MDL_SER, PHL_MDL_POWER_MGNT};
845
846 disp_test_ctx.is_pass = true;
847 status = phl_disp_eng_init(disp_test_ctx.phl, phy_num);
848 if(status != RTW_PHL_STATUS_SUCCESS) {
849 disp_test_ctx.is_pass = false;
850 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[0], sizeof(err_rsn[0]));
851 goto test_end;
852 }
853 disp_eng = &(disp_test_ctx.phl->disp_eng);
854 status = phl_disp_eng_start(disp_test_ctx.phl);
855 if(status != RTW_PHL_STATUS_SUCCESS ) {
856 disp_test_ctx.is_pass = false;
857 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[4], sizeof(err_rsn[4]));
858 goto test_end;
859 }
860 disp_test_ctx.ops.msg_hdlr = test_btc_mdl_msg_hdlr;
861 if(dispr_register_module(disp_eng->dispatcher[0], PHL_MDL_BTC, &(disp_test_ctx.ops)) != RTW_PHL_STATUS_SUCCESS) {
862 disp_test_ctx.is_pass = false;
863 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[1], sizeof(err_rsn[1]));
864 goto test_end;
865 }
866 disp_test_ctx.ops.msg_hdlr = test_gen_mdl_msg_hdlr;
867 if(dispr_register_module(disp_eng->dispatcher[0], PHL_MDL_GENERAL, &(disp_test_ctx.ops)) != RTW_PHL_STATUS_SUCCESS) {
868 disp_test_ctx.is_pass = false;
869 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[1], sizeof(err_rsn[1]));
870 goto test_end;
871 }
872 disp_test_ctx.ops.msg_hdlr = test_mcc_mdl_msg_hdlr;
873 if(dispr_register_module(disp_eng->dispatcher[0], PHL_MDL_MRC, &(disp_test_ctx.ops)) != RTW_PHL_STATUS_SUCCESS) {
874 disp_test_ctx.is_pass = false;
875 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[1], sizeof(err_rsn[1]));
876 goto test_end;
877 }
878 disp_test_ctx.ops.msg_hdlr = test_ser_mdl_msg_hdlr;
879 if(dispr_register_module(disp_eng->dispatcher[0], PHL_MDL_SER, &(disp_test_ctx.ops)) != RTW_PHL_STATUS_SUCCESS) {
880 disp_test_ctx.is_pass = false;
881 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[1], sizeof(err_rsn[1]));
882 goto test_end;
883 }
884 disp_test_ctx.ops.msg_hdlr = test_mdl_msg_hdlr;
885
886 _os_mem_set(d, &msg, 0, sizeof(struct phl_msg));
887 _os_mem_set(d, &attr, 0, sizeof(struct phl_msg_attribute));
888 seq.pre_prot_phase.map[PHL_MDL_PRI_OPTIONAL].len = sizeof(pre_proct_seq);
889 seq.pre_prot_phase.map[PHL_MDL_PRI_OPTIONAL].id_arr = pre_proct_seq;
890 seq.pre_prot_phase.map[PHL_MDL_PRI_MANDATORY].len = sizeof(pre_proct_seq);
891 seq.pre_prot_phase.map[PHL_MDL_PRI_MANDATORY].id_arr = pre_proct_seq;
892 seq.post_prot_phase.map[PHL_MDL_PRI_OPTIONAL].len = sizeof(post_proct_seq);
893 seq.post_prot_phase.map[PHL_MDL_PRI_OPTIONAL].id_arr = post_proct_seq;
894 seq.post_prot_phase.map[PHL_MDL_PRI_MANDATORY].len = sizeof(post_proct_seq);
895 seq.post_prot_phase.map[PHL_MDL_PRI_MANDATORY].id_arr = post_proct_seq;
896 for (i = 0 ; i < 3; i++) {
897 status = phl_disp_eng_set_msg_disp_seq(disp_test_ctx.phl, &attr, &seq);
898 if(status != RTW_PHL_STATUS_SUCCESS || attr.dispr_attr == NULL) {
899 disp_test_ctx.is_pass = false;
900 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[24], sizeof(err_rsn[24]));
901 goto test_end;
902 }
903 }
904 msg.band_idx = 0;
905 SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_MDL_SER);
906 SET_MSG_EVT_ID_FIELD(msg.msg_id, 10);
907 status = phl_disp_eng_send_msg(disp_test_ctx.phl, &msg, &attr, NULL);
908 if(status != RTW_PHL_STATUS_SUCCESS) {
909 disp_test_ctx.is_pass = false;
910 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[10], sizeof(err_rsn[10]));
911 goto test_end;
912 }
913 if (attr.dispr_attr != NULL) {
914 disp_test_ctx.is_pass = false;
915 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[24], sizeof(err_rsn[24]));
916 goto test_end;
917 }
918 _os_sleep_ms(d, 100);
919 PHL_INFO("[DISP_TEST] seq:%d, cnt: %d\n",disp_test_ctx.case_self_def_seq.seq, disp_test_ctx.case_self_def_seq.cnt);
920 if(disp_test_ctx.case_self_def_seq.seq != 8 || disp_test_ctx.case_self_def_seq.cnt != 8) {
921 disp_test_ctx.is_pass = false;
922 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[25], sizeof(err_rsn[25]));
923 goto test_end;
924 }
925 status = phl_disp_eng_set_msg_disp_seq(disp_test_ctx.phl, &attr, &seq);
926 if(status != RTW_PHL_STATUS_SUCCESS || attr.dispr_attr == NULL) {
927 disp_test_ctx.is_pass = false;
928 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[24], sizeof(err_rsn[24]));
929 goto test_end;
930 }
931 SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_MDL_POWER_MGNT);
932 SET_MSG_EVT_ID_FIELD(msg.msg_id, 10);
933 status = phl_disp_eng_send_msg(disp_test_ctx.phl, &msg, &attr, NULL);
934 if(status == RTW_PHL_STATUS_SUCCESS) {
935 disp_test_ctx.is_pass = false;
936 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[10], sizeof(err_rsn[10]));
937 goto test_end;
938 }
939 if (attr.dispr_attr != NULL) {
940 disp_test_ctx.is_pass = false;
941 _os_mem_cpy(d, disp_test_ctx.rsn, err_rsn[24], sizeof(err_rsn[24]));
942 goto test_end;
943 }
944 test_end:
945 status = phl_disp_eng_stop(disp_test_ctx.phl);
946 status = phl_disp_eng_deinit(disp_test_ctx.phl);
947 disp_test_ctx.is_test_end = true;
948 }
949
950
disp_test_bp_handler(void * priv,struct test_bp_info * bp_info)951 u8 disp_test_bp_handler(void *priv, struct test_bp_info* bp_info)
952 {
953 return true;
954 }
955
disp_test_fail_rsn(void * priv,char * rsn,u32 max_len)956 u8 disp_test_fail_rsn(void *priv,char* rsn, u32 max_len)
957 {
958 void *d = phl_to_drvpriv(disp_test_ctx.phl);
959 _os_mem_cpy(d, rsn, disp_test_ctx.rsn, (_os_strlen((u8*)disp_test_ctx.rsn) > max_len)?(max_len):(_os_strlen((u8*)disp_test_ctx.rsn)));
960 return true;
961 }
962
disp_test_is_test_end(void * priv)963 u8 disp_test_is_test_end(void *priv)
964 {
965 return disp_test_ctx.is_test_end;
966 }
967
disp_test_is_test_pass(void * priv)968 u8 disp_test_is_test_pass(void *priv)
969 {
970 PHL_INFO("[DISP_TEST] case(%s) pass(%d)\n", disp_test_ctx.test_case,
971 disp_test_ctx.is_pass);
972 return disp_test_ctx.is_pass;
973 }
974
disp_test_start_test(void * priv)975 u8 disp_test_start_test(void *priv)
976 {
977 PHL_INFO("[DISP_TEST] case(%s) start\n", disp_test_ctx.test_case);
978 switch(disp_test_ctx.test_case) {
979 case DISP_TEST_INIT:
980 /* verify items:
981 * 1: dispatch engine & dispatcher:
982 * init, start, stop, deinit
983 * 2: module ops:
984 * init, start, stop, deinit
985 * 3: double init
986 */
987 disp_init_test();
988 break;
989 case DISP_TEST_SEND_MSG:
990 /* verify items:
991 * 1: msg send, cancel, recycle efficiency
992 * 2: msg process flow in background, including
993 * pre-phase, post phase, reschedule, fail handle
994 */
995 disp_send_msg_test();
996 break;
997 case DISP_TEST_CMD_TOKEN_REQ:
998 /* verify items:
999 * 1: cmd send, cancel, recycle
1000 * 2: cmd token process flow in token mgnt thread
1001 * 3: cmd req ops verification
1002 */
1003 disp_cmd_token_test();
1004 break;
1005 case DISP_TEST_CANNOT_IO:
1006 disp_cannot_io_test();
1007 break;
1008 case DISP_TEST_PRIORITIZE_MSG:
1009 disp_prioritize_msg_test();
1010 break;
1011 case DISP_TEST_SELF_DEF_SEQ:
1012 disp_self_def_msg_test();
1013 break;
1014 default:
1015 disp_test_ctx.is_test_end = true;
1016 disp_test_ctx.is_pass = false;
1017 break;
1018 }
1019 PHL_INFO("[DISP_TEST] case(%s) pass(%d)\n", disp_test_ctx.test_case,
1020 disp_test_ctx.is_pass);
1021 return true;
1022 }
1023
phl_cmd_disp_test_start(void * phl_info,u8 test_case)1024 void phl_cmd_disp_test_start(void* phl_info, u8 test_case)
1025 {
1026 struct phl_info_t *phl = (struct phl_info_t *)phl_info;
1027 void *d = phl_to_drvpriv(phl);
1028 struct test_obj_ctrl_interface *intf = NULL;
1029 _os_mem_set(d, &disp_test_ctx, 0, sizeof(struct cmd_disp_test_ctx));
1030 disp_test_ctx.phl = phl;
1031 disp_test_ctx.is_test_end = false;
1032 disp_test_ctx.is_pass = false;
1033 disp_test_ctx.test_case = test_case;
1034 _os_mem_cpy(d, &(disp_test_ctx.rsn), "none", sizeof("none"));
1035 intf = &(disp_test_ctx.intf);
1036
1037 /* test obj ops*/
1038 intf->bp_handler = disp_test_bp_handler;
1039 intf->get_fail_rsn = disp_test_fail_rsn;
1040 intf->is_test_end = disp_test_is_test_end;
1041 intf->is_test_pass = disp_test_is_test_pass;
1042 intf->start_test = disp_test_start_test;
1043
1044 /* phl bk module ops*/
1045 disp_test_ctx.ops.init = test_mdl_init;
1046 disp_test_ctx.ops.deinit = test_mdl_deinit;
1047 disp_test_ctx.ops.start = test_mdl_start;
1048 disp_test_ctx.ops.stop = test_mdl_stop;
1049 disp_test_ctx.ops.msg_hdlr = test_mdl_msg_hdlr;
1050 disp_test_ctx.ops.set_info = test_mdl_set_info;
1051 disp_test_ctx.ops.query_info = test_mdl_query_info;
1052 /* cmd token req*/
1053 disp_test_ctx.req.acquired = test_req_acquired;
1054 disp_test_ctx.req.abort = test_req_abort;
1055 disp_test_ctx.req.msg_hdlr = test_req_msg_hdlr;
1056 disp_test_ctx.req.set_info = test_req_set_info;
1057 disp_test_ctx.req.query_info = test_req_query_info;
1058 rtw_phl_test_add_new_test_obj(phl->phl_com,
1059 "phl_cmd_disp_test_init",
1060 &disp_test_ctx,
1061 TEST_LVL_LOW,
1062 intf,
1063 10000,
1064 TEST_SUB_MODULE_TRX,
1065 UNIT_TEST_MODE);
1066 PHL_INFO("%s\n",__FUNCTION__);
1067 }
1068 #endif
1069 #endif /* #ifdef CONFIG_PHL_TEST_SUITE */
1070