1 /*
2  * Copyright (c) 2018 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: Defines the data structures used by the unit test framework for
22  * serialization module
23  */
24 
25 #ifndef _WLAN_SERIALIZATION_UTF_I_H_
26 #define _WLAN_SERIALIZATION_UTF_I_H_
27 
28 #define WLAN_SER_UTF_MAX_VDEVS 4
29 #define WLAN_SER_UTF_SCAN_CMD_TESTS 33
30 #define WLAN_SER_UTF_TIMER_TIMEOUT_MS 5000
31 #define WLAN_SER_UTF_TEST_CMD_TIMEOUT_MS 30000
32 
33 /* Sample string: SER_Vxx_Cxx */
34 #define WLAN_SER_UTF_STR_SIZE 15
35 #define WLAN_SER_DATA_STR(_s, _v, _i) \
36 	scnprintf(_s, WLAN_SER_UTF_STR_SIZE, "SER_V%u_C%u", _v, _i)
37 
38 #define SER_UTF_BLOCK_STR(_x) (_x ? "BLOCK" : "NON-BLOCK")
39 
40 char *wlan_serialization_status_strings[] = {
41 	"WLAN_SER_CMD_PENDING",
42 	"WLAN_SER_CMD_ACTIVE",
43 	"WLAN_SER_CMD_DENIED_RULES_FAILED",
44 	"WLAN_SER_CMD_DENIED_LIST_FULL",
45 	"WLAN_SER_CMD_DENIED_UNSPECIFIED",
46 };
47 
48 /**
49  * enum wlan_ser_utf_tc_id - Test case id
50  * @SER_UTF_TC_DEINIT: Deinit UTF
51  * @SER_UTF_TC_INIT: Init UTF
52  * @SER_UTF_TC_ADD: Add a custom cmd to queue
53  * @SER_UTF_TC_REMOVE: Remove a custom cmd from queue
54  * @SER_UTF_TC_CANCEL: Cancel a custom cmd from queue
55  * @SER_UTF_TC_SINGLE_SCAN: Add and remove a single scan cmd
56  * @SER_UTF_TC_MULTI_SCAN: Add and remove a multiple scan cmd
57  * @SER_UTF_TC_MAX_SCAN: Add and remove a maximum scan cmd
58  * @SER_UTF_TC_SINGLE_NONSCAN: Add and remove a single nonscan cmd
59  * @SER_UTF_TC_MULTI_NONSCAN: Add and remove a multiple nonscan cmd
60  * @SER_UTF_TC_MAX_NONSCAN: Add and remove a maximum nonscan cmd
61  * @SER_UTF_TC_MULTI_VDEV_NONSCAN: Add nonscan cmd across multiple vdev
62  * @SER_UTF_TC_CANCEL_SCAN_AC_SINGLE: Cancel single scan from active queue
63  * @SER_UTF_TC_CANCEL_SCAN_AC_PDEV: Cancel pdev scan from active queue
64  * @SER_UTF_TC_CANCEL_SCAN_AC_VDEV: Cancel vdev scan from active queue
65  * @SER_UTF_TC_CANCEL_SCAN_PD_SINGLE: Cancel single scan from pending queue
66  * @SER_UTF_TC_CANCEL_SCAN_PD_PDEV: Cancel pdev scan from pending queue
67  * @SER_UTF_TC_CANCEL_SCAN_PD_VDEV: Cancel vdev scan from pending queue
68  * @SER_UTF_TC_CANCEL_NONSCAN_AC_SINGLE: Cancel single nonscan from active queue
69  * @SER_UTF_TC_CANCEL_NONSCAN_AC_PDEV: Cancel pdev nonscan from active queue
70  * @SER_UTF_TC_CANCEL_NONSCAN_AC_VDEV: Cancel vdev nonscan from active queue
71  * @SER_UTF_TC_CANCEL_NONSCAN_PD_SINGLE: Cancel nonscan from pending queue
72  * @SER_UTF_TC_CANCEL_NONSCAN_PD_PDEV: Cancel pdev nonscan from pending queue
73  * @SER_UTF_TC_CANCEL_NONSCAN_PD_VDEV: Cancel vdev nonscan from pending queue
74  * @SER_UTF_TC_START_BSS_FILTERING: Test start_bss filtering logic
75  * @SER_UTF_TC_STOP_BSS_FILTERING: Test stop_bss filtering logic
76  * @SER_UTF_TC_ADD_BLOCKING_NONSCAN_AC_1: Add blocking cmd to active queue
77  * @SER_UTF_TC_ADD_BLOCKING_NONSCAN_PD_1: Add blocking cmd to pending queue with
78  *			blocking cmd in active queue
79  * @SER_UTF_TC_ADD_BLOCKING_NONSCAN_PD_2: Add blocking cmd to pending queue with
80  *			non-blocking cmd in active queue
81  * @SER_UTF_TC_ADD_BLOCKING_NONSCAN_PD_3: Add blocking cmd to tail of
82  *			pending queue with non-blocking cmd in active queue
83  * @SER_UTF_TC_ADD_BLOCKING_NONSCAN_PD_4: Add blocking cmd to pending between
84  *			non-blocking cmd in pending and active queue
85  * @SER_UTF_TC_MULTI_VDEV_BL_NONSCAN_1: Add blocking nonscan cmd
86  *			across multiple vdev
87  * @SER_UTF_TC_MULTI_VDEV_BL_NONSCAN_2: Add blocking nonscan cmd
88  *		to a pending queue of vdev with non-blocking across multi vdev
89  * @SER_UTF_TC_MULTI_VDEV_BL_NONSCAN_3: Add blocking nonscan cmd
90  *		to a active queue of vdev with non-blocking across multiple vdev
91  * @SER_UTF_TC_MULTI_VDEV_BL_NONSCAN_4: Add blocking nonscan cmd to the
92  *		pending queue of multi vdev with non-blocking across multi vdev
93  * @SER_UTF_TC_MULTI_VDEV_BL_NONSCAN_5: Add blocking nonscan cmd to the
94  *		pending queue of multi vdev with non-blocking across multi vdev
95  *		in pending and active queue
96  * @SER_UTF_TC_HIGH_PRIO_NONSCAN_WO_BL: Add high priority nonscan cmd
97  *		to the tail of pending queue
98  * @SER_UTF_TC_HIGH_PRIO_NONSCAN_W_BL: Add high priority nonscan cmd
99  *		to the pending queue between normal priority command
100  * @SER_UTF_TC_HIGH_PRIO_BL_NONSCAN: Add high priority blocking
101  *		nonscan cmd to the tail of pending queue
102  */
103 enum wlan_ser_utf_tc_id {
104 	SER_UTF_TC_DEINIT,
105 	SER_UTF_TC_INIT,
106 	SER_UTF_TC_ADD,
107 	SER_UTF_TC_REMOVE,
108 	SER_UTF_TC_CANCEL,
109 	SER_UTF_TC_SINGLE_SCAN,
110 	SER_UTF_TC_MULTI_SCAN,
111 	SER_UTF_TC_MAX_SCAN,
112 	SER_UTF_TC_SINGLE_NONSCAN,
113 	SER_UTF_TC_MULTI_NONSCAN,
114 	SER_UTF_TC_MAX_NONSCAN,
115 	SER_UTF_TC_MULTI_VDEV_NONSCAN,
116 	SER_UTF_TC_CANCEL_SCAN_AC_SINGLE,
117 	SER_UTF_TC_CANCEL_SCAN_AC_PDEV,
118 	SER_UTF_TC_CANCEL_SCAN_AC_VDEV,
119 	SER_UTF_TC_CANCEL_SCAN_PD_SINGLE,
120 	SER_UTF_TC_CANCEL_SCAN_PD_PDEV,
121 	SER_UTF_TC_CANCEL_SCAN_PD_VDEV,
122 	SER_UTF_TC_CANCEL_NONSCAN_AC_SINGLE,
123 	SER_UTF_TC_CANCEL_NONSCAN_AC_PDEV,
124 	SER_UTF_TC_CANCEL_NONSCAN_AC_VDEV,
125 	SER_UTF_TC_CANCEL_NONSCAN_PD_SINGLE,
126 	SER_UTF_TC_CANCEL_NONSCAN_PD_PDEV,
127 	SER_UTF_TC_CANCEL_NONSCAN_PD_VDEV,
128 	SER_UTF_TC_START_BSS_FILTERING,
129 	SER_UTF_TC_STOP_BSS_FILTERING,
130 	SER_UTF_TC_ADD_BLOCKING_NONSCAN_AC_1,
131 	SER_UTF_TC_ADD_BLOCKING_NONSCAN_PD_1,
132 	SER_UTF_TC_ADD_BLOCKING_NONSCAN_PD_2,
133 	SER_UTF_TC_ADD_BLOCKING_NONSCAN_PD_3,
134 	SER_UTF_TC_ADD_BLOCKING_NONSCAN_PD_4,
135 	SER_UTF_TC_MULTI_VDEV_BL_NONSCAN_1,
136 	SER_UTF_TC_MULTI_VDEV_BL_NONSCAN_2,
137 	SER_UTF_TC_MULTI_VDEV_BL_NONSCAN_3,
138 	SER_UTF_TC_MULTI_VDEV_BL_NONSCAN_4,
139 	SER_UTF_TC_MULTI_VDEV_BL_NONSCAN_5,
140 	SER_UTF_TC_HIGH_PRIO_NONSCAN_WO_BL,
141 	SER_UTF_TC_HIGH_PRIO_NONSCAN_W_BL,
142 	SER_UTF_TC_HIGH_PRIO_BL_NONSCAN,
143 };
144 
145 /**
146  * struct wlan_ser_utf_data - Test data
147  * @id: Test variable
148  * @str: String tag associated with the command
149  */
150 struct wlan_ser_utf_data {
151 	uint8_t id;
152 	char str[WLAN_SER_UTF_STR_SIZE + 1];
153 };
154 
155 /**
156  * struct wlan_ser_utf_vdev_info - Information used by the vdevs
157  * @vdev: Vdev object manager information
158  * @ser_count: Serialization command count for the vdev
159  * @utf_scan_timer: Timer for scan commands
160  * @utf_nonscan_timer: Timer for non-scan commands
161  */
162 struct wlan_ser_utf_vdev_info {
163 	struct wlan_objmgr_vdev *vdev;
164 	uint8_t ser_count;
165 	qdf_timer_t utf_scan_timer[WLAN_SER_UTF_SCAN_CMD_TESTS];
166 	qdf_timer_t utf_nonscan_timer[WLAN_SER_UTF_SCAN_CMD_TESTS];
167 };
168 
169 /**
170  * wlan_ser_utf_cb() - Serialization callback function
171  * @cmd: Serialization command info
172  * @reason: Serialization reason for callback execution
173  *
174  * Return: Status of callback execution
175  */
176 QDF_STATUS wlan_ser_utf_cb(struct wlan_serialization_command *cmd,
177 			   enum wlan_serialization_cb_reason reason);
178 
179 #endif /* _WLAN_SERIALIZATION_UTF_I_H_ */
180 
181