xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852be/phl/phl_test_def.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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 #ifndef _TEST_MODULE_DEF_H_
16 #define _TEST_MODULE_DEF_H_
17 
18 #ifdef CONFIG_PHL_TEST_SUITE
19 #define TEST_NAME_LEN		32
20 #define TEST_RPT_RSN_LEN	32
21 
22 #define TEST_LVL_LOW_TO		1000
23 #define TEST_LVL_NORMAL_TO	50
24 #define TEST_LVL_HIGH_TO	20
25 
26 /*add cusstomized BP types in the following enum,
27 and hanle them in corresponding bp handler*/
28 enum TEST_BP_INFO_TYPE{
29 	BP_INFO_TYPE_NONE = 0,
30 	BP_INFO_TYPE_WAIT_BEACON_JOIN = 0x1,
31 	BP_INFO_TYPE_SEND_AUTH_ODD = 0x2,
32 	BP_INFO_TYPE_SEND_ASOC_REQ = 0x3,
33 	BP_INFO_TYPE_SEND_DISASSOC = 0x4,
34 	BP_INFO_TYPE_FILL_DISASSOC_RSN = 0x5,
35 	BP_INFO_TYPE_SEND_PROBE_REQ = 0x6,
36 	BP_INFO_TYPE_MP_CMD_EVENT = 0x7,
37 	BP_INFO_TYPE_RX_TEST_WPRPT = 0x8,
38 	BP_INFO_TYPE_RX_TEST_PATTERN = 0x9,
39 	BP_INFO_TYPE_MP_RX_PHYSTS = 0xA,
40 	BP_INFO_TYPE_TX_4_WAY = 0xB,
41 	BP_INFO_TYPE_RX_4_WAY = 0xC,
42 	BP_INFO_TYPE_MAX
43 };
44 
45 enum TEST_RUN_LVL{
46 	TEST_LVL_NONE = 0,
47 	TEST_LVL_LOW,
48 	TEST_LVL_NORMAL,
49 	TEST_LVL_HIGH,
50 	TEST_LVL_MAX
51 };
52 
53 enum TEST_BP_RETURN_TYPE{
54 	BP_RET_SKIP_SECTION = 0,
55 	BP_RET_RUN_ORIGIN_SEC,
56 	BP_RET_LEAVE_FUNC,
57 	BP_RET_MAX
58 };
59 
60 enum TEST_SUB_MODULE {
61 	TEST_SUB_MODULE_MP = 0,
62 	TEST_SUB_MODULE_FPGA = 1,
63 	TEST_SUB_MODULE_VERIFY = 2,
64 	TEST_SUB_MODULE_TOOL = 3,
65 	TEST_SUB_MODULE_TRX = 4,
66 	TEST_SUB_MODULE_UNKNOWN,
67 };
68 
69 enum TEST_MODULE_MODE_TYPE {
70 	UNIT_TEST_MODE = 0,
71 	INTGR_TEST_MODE = 1,
72 	FUNC_TEST_MODE = 2
73 };
74 
75 struct test_bp_info{
76 	enum TEST_BP_INFO_TYPE type;
77 	u32 len;
78 	void* ptr;
79 };
80 
81 /**
82  * test_obj_ctrl_interface - basic test control methods for generic management.
83  * @start_test: test entry, initiate & run a test
84  * @is_test_end: return true when test ends.
85  *		 NOTE: Do not use evt/lock inside this method for sync.
86  * @is_test_pass: return true when test passed.
87  * @get_fail_rsn: if test fails, construct a reasonable string as fail description,
88  *		  not just a status code.
89  * @bp_handler: handle break point which is currently being hit,
90  *		use rtw_phl_test_setup_bp to add new break point in source code
91  *		and add customized BP type in TEST_BP_INFO_TYPE for recognition.
92  */
93 
94 struct test_obj_ctrl_interface{
95 	u8 (*start_test)(void *priv);
96 	u8 (*is_test_end)(void *priv);
97 	u8 (*is_test_pass)(void *priv);
98 	u8 (*get_fail_rsn)(void *priv,char* rsn, u32 max_len);
99 	u8 (*bp_handler)(void *priv, struct test_bp_info* bp_info);
100 };
101 
102 struct test_object {
103 	_os_list list;
104 	void* priv;
105 	enum TEST_RUN_LVL run_lvl;
106 	char name[TEST_NAME_LEN];
107 	struct test_obj_ctrl_interface ctrl;
108 	s32 total_time_ms; // optional, set 0 to use default see TEST_LVL_LOW_TO
109 };
110 
111 struct test_rpt {
112 	char name[TEST_NAME_LEN];
113 	u8 status;
114 	char rsn[TEST_RPT_RSN_LEN];
115 	u32 total_time; // in ms
116 };
117 
118 void rtw_phl_test_submodule_init(struct rtw_phl_com_t* phl_com, void *buf);
119 void rtw_phl_test_submodule_deinit(struct rtw_phl_com_t* phl_com, void *buf);
120 void rtw_phl_test_submodule_cmd_process(struct rtw_phl_com_t* phl_com, void *buf, u32 buf_len);
121 void rtw_phl_test_submodule_get_rpt(struct rtw_phl_com_t* phl_com, void *buf, u32 buf_len);
122 
123 u8 rtw_phl_test_add_new_test_obj(struct rtw_phl_com_t* phl_com,
124                                  char *name,
125                                  void* priv,
126                                  enum TEST_RUN_LVL lvl,
127                                  struct test_obj_ctrl_interface* ctrl_intf,
128                                  s32 total_time_ms,
129                                  u8 objid,
130                                  u8 test_mode);
131 u8 rtw_phl_test_setup_bp(struct rtw_phl_com_t* phl_com,
132                          struct test_bp_info* bp_info,
133                          u8 submdid);
134 u8 rtw_phl_test_is_test_complete(struct rtw_phl_com_t* phl_com);
135 u8 rtw_phl_test_get_rpt(struct rtw_phl_com_t* phl_com, u8* buf, u32 len);
136 u8 rtw_phl_test_set_max_run_time(struct rtw_phl_com_t* phl_com, enum TEST_RUN_LVL lvl, u32 timeout_ms);
137 
138 enum rtw_phl_status rtw_phl_reset(void *phl);
139 #else
140 #define rtw_phl_test_submodule_init(phl_com, buf)
141 #define rtw_phl_test_submodule_deinit(phl_com, buf)
142 #define rtw_phl_test_submodule_cmd_process(phl_com, buf, buf_len)
143 #define rtw_phl_test_submodule_get_rpt(phl_com, buf, buf_len)
144 
145 #define rtw_phl_test_add_new_test_obj(phl_com, name, priv, lvl, ctrl_intf, total_time_ms, objid, test_mode) true
146 #define rtw_phl_test_setup_bp(phl_com, bp_info, submdid) true
147 #define rtw_phl_test_is_test_complete(phl_com) true
148 #define rtw_phl_test_get_rpt(phl_com, buf, len) true
149 #define rtw_phl_test_set_max_run_time(phl_com, lvl, timeout_ms) true
150 #endif /*CONFIG_PHL_TEST_SUITE*/
151 
152 #endif	/* _TEST_MODULE_DEF_H_ */
153