xref: /wlan-dirver/qca-wifi-host-cmn/umac/mlme/connection_mgr/utf/inc/wlan_cm_utf.h (revision 901120c066e139c7f8a2c8e4820561fdd83c67ef)
1 /*
2  * Copyright (c) 2020, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /*
19  * DOC: Implements CM UTF
20  */
21 
22 #ifndef WLAN_CM_UTF_H
23 #define WLAN_CM_UTF_H
24 
25 #include <qdf_debugfs.h>
26 #include <qdf_mem.h>
27 #include <qdf_trace.h>
28 #include <qdf_module.h>
29 #include <qdf_event.h>
30 #include <qdf_defer.h>
31 #include <wlan_cm_public_struct.h>
32 #include <wlan_mgmt_txrx_utils_api.h>
33 #include <wlan_reg_services_api.h>
34 #include <wlan_scan_tgt_api.h>
35 #include <wlan_cfg80211.h>
36 
37 #define NUM_UTF_DEBUGFS_INFOS 2
38 
39 /*
40  * <ini>
41  * wlan_cm_utf - WLAN CM UTF Configuration
42  * @Min: 0
43  * @Max: 1
44  * @Default: 0
45  *
46  * This ini is used to config wlan cm utf
47  *
48  * Related: None
49  *
50  * Usage: External
51  *
52  * </ini>
53  */
54 #define CFG_WLAN_CM_UTF CFG_INI_UINT( \
55 	"wlan_cm_utf", \
56 	0, \
57 	1, \
58 	0, \
59 	CFG_VALUE_OR_DEFAULT, \
60 	"WLAN CM UTF Configuration")
61 
62 #define CFG_WLAN_CM_UTF_PARAM CFG(CFG_WLAN_CM_UTF)
63 /**
64  * enum wlan_cm_utf_test - CM UTF Test ID
65  * @CM_UTF_ID_CONNECT_SUCCESS: Connect Success
66  * @CM_UTF_ID_DISCONNECT_SUCCESS: Disconnect Success
67  * @CM_UTF_ID_PEER_CREATE_FAILURE: Peer Create Failure
68  * @CM_UTF_ID_PEER_CREATE_TIMEOUT: No Peer Create Response
69  * @CM_UTF_ID_PEER_DELETE_TIMEOUT: No Peer Delete Response
70  * @CM_UTF_ID_AUTH_FAILURE: Auth Req Failure
71  * @CM_UTF_ID_AUTH_TIMEOUT: No Auth Response
72  * @CM_UTF_ID_ASSOC_FAILURE: Assoc Req Failure
73  * @CM_UTF_ID_ASSOC_TIMEOUT: No Assoc Response
74  * @CM_UTF_ID_CONNECT_SCAN_FAILURE: SSID Not Found
75  * @CM_UTF_ID_CONNECT_SER_TIMEOUT: Serialization Active Cmd Timeout for Connect
76  * @CM_UTF_ID_DISCONNECT_SER_TIMEOUT: Ser Active Cmd Timeout for Disconnect
77  * @CM_UTF_ID_CONNECT_SER_FAILED: Serialization Cmd Queue Failure for Connect
78  * @CM_UTF_ID_DISCONNECT_SER_FAILED: Ser Cmd Queue Failure for Disconnect
79  */
80 enum wlan_cm_utf_test {
81 	CM_UTF_ID_CONNECT_SUCCESS,
82 	CM_UTF_ID_DISCONNECT_SUCCESS,
83 	CM_UTF_ID_PEER_CREATE_FAILURE,
84 	CM_UTF_ID_PEER_CREATE_TIMEOUT,
85 	CM_UTF_ID_PEER_DELETE_TIMEOUT,
86 	CM_UTF_ID_AUTH_FAILURE,
87 	CM_UTF_ID_AUTH_TIMEOUT,
88 	CM_UTF_ID_ASSOC_FAILURE,
89 	CM_UTF_ID_ASSOC_TIMEOUT,
90 	CM_UTF_ID_CONNECT_SCAN_FAILURE,
91 	CM_UTF_ID_CONNECT_SER_TIMEOUT,
92 	CM_UTF_ID_DISCONNECT_SER_TIMEOUT,
93 	CM_UTF_ID_CONNECT_SER_FAILED,//Need ser utf
94 	CM_UTF_ID_DISCONNECT_SER_FAILED,//Need ser utf
95 	CM_UTF_ID_MAX,
96 };
97 
98 /**
99  * enum wlan_cm_utf_evt - CM UTF Resp event
100  * @CM_UTF_BSS_PEER_CREATE_RESP: Peer Create Response
101  * @CM_UTF_BSS_PEER_DELETE_RESP: Peer Delete Response
102  * @CM_UTF_CONNECT_RESP: Connect Response
103  * @CM_UTF_DISCONNECT_RESP: Disconnect Response
104  * @CM_UTF_PEER_DELETE_IND: Peer Delete Indication
105  */
106 enum wlan_cm_utf_evt {
107 	CM_UTF_BSS_PEER_CREATE_RESP,
108 	CM_UTF_BSS_PEER_DELETE_RESP,
109 	CM_UTF_CONNECT_RESP,
110 	CM_UTF_DISCONNECT_RESP,
111 	CM_UTF_PEER_DELETE_IND,
112 };
113 
114 /**
115  * struct wlan_cm_utf_node- CM UTF node to hold CM req info
116  * @wlan_cm_utf_evt: CM UTF Resp event
117  * @peer_mac: Peer Mac
118  * @conn_req: Connect Request
119  * @disconn_req: Disconnect Request
120  */
121 struct wlan_cm_utf_node {
122 	enum wlan_cm_utf_evt evt_id;
123 	struct qdf_mac_addr *peer_mac;
124 	struct wlan_cm_vdev_connect_req conn_req;
125 	struct wlan_cm_vdev_discon_req disconn_req;
126 };
127 
128 /**
129  * struct wlan_cm_utf- CM UTF handle
130  * @vdev: Vdev object
131  * @debugfs_de: debugfs entry
132  * @test_id: Test case Id
133  * @req: cfg80211 connect request params
134  * @cm_utf_timer: CM UTF timer
135  * @cm_utf_test_timer: CM UTF timer for each test
136  * @utf_node: CM UTF node to hold CM req info
137  * @cm_utf_work: CM UTF work queue for processing events
138  */
139 struct wlan_cm_utf {
140 	qdf_list_node_t cm_utf_node;
141 	struct wlan_objmgr_vdev *vdev;
142 	struct dentry *debugfs_de[NUM_UTF_DEBUGFS_INFOS];
143 	enum wlan_cm_utf_test test_id;
144 	struct wlan_cm_connect_req req;
145 	qdf_timer_t  cm_utf_timer;
146 	qdf_timer_t  cm_utf_test_timer;
147 	struct wlan_cm_utf_node utf_node;
148 	uint32_t last_cmd_id;
149 	enum wlan_cm_source last_cmd_source;
150 	qdf_work_t cm_utf_work;
151 };
152 
153 /*
154  * Debugfs read/write functions
155  */
156 /**
157  * wlan_cm_utf_cm_test_id_show() - debugfs function to display CM test case name
158  * @m: seq_file handle
159  * @v: not used, offset of read
160  */
161 int wlan_cm_utf_cm_test_id_show(qdf_debugfs_file_t m, void *v);
162 
163 int wlan_cm_utf_scan_db_update_show(qdf_debugfs_file_t m, void *v);
164 
165 /**
166  * wlan_cm_utf_cm_test_id_write() - debugfs write to start CM UTF test
167  *
168  * @file: file handler to access cm utf handle
169  * @buf: received data buffer
170  * @count: length of received buffer
171  * @ppos: Not used
172  *
173  * Return: count
174  */
175 ssize_t wlan_cm_utf_cm_test_id_write(struct file *file,
176 				     const char __user *buf,
177 				     size_t count, loff_t *ppos);
178 
179 /**
180  * wlan_cm_utf_scan_db_update_write() - debugfs write to add manual scan entry
181  *
182  * @file: file handler to access cm utf handle
183  * @buf: received data buffer
184  * @count: length of received buffer
185  * @ppos: Not used
186  *
187  * Return: count
188  */
189 ssize_t wlan_cm_utf_scan_db_update_write(struct file *file,
190 					 const char __user *buf,
191 					 size_t count, loff_t *ppos);
192 
193 /**
194  * wlan_cm_utf_attach: Connection manager UTF init API
195  * @vdev: Vdev object
196  *
197  * Return: QDF_STATUS
198  */
199 QDF_STATUS wlan_cm_utf_attach(struct wlan_objmgr_vdev *vdev);
200 
201 /**
202  * wlan_cm_utf_detach: Connection manager UTF deinit API
203  * @vdev: Vdev object
204  *
205  * Return: QDF_STATUS
206  */
207 void wlan_cm_utf_detach(struct wlan_objmgr_vdev *vdev);
208 
209 /**
210  * wlan_cm_utf_bss_peer_create_req: Connection manager UTF bss peer
211  * create request handler
212  * @vdev: VDEV object
213  * @peer_mac: Peer mac address
214  *
215  * Return: QDF_STATUS
216  */
217 QDF_STATUS wlan_cm_utf_bss_peer_create_req(struct wlan_objmgr_vdev *vdev,
218 					   struct qdf_mac_addr *peer_mac);
219 
220 /**
221  * wlan_cm_utf_connect_req_active: Connection manager UTF handler when connect
222  * request is activated
223  * @vdev: VDEV object
224  * @vdev_connect_req: Vdev connect request
225  *
226  * Return: QDF_STATUS
227  */
228 QDF_STATUS wlan_cm_utf_connect_req_active(
229 			struct wlan_objmgr_vdev *vdev,
230 			struct wlan_cm_vdev_connect_req *vdev_connect_req);
231 
232 /**
233  * wlan_cm_utf_connect_req: Connection manager UTF connect request handler
234  * @vdev: VDEV object
235  * @vdev_connect_req: Vdev connect request
236  *
237  * Return: QDF_STATUS
238  */
239 QDF_STATUS wlan_cm_utf_connect_req(
240 			struct wlan_objmgr_vdev *vdev,
241 			struct wlan_cm_vdev_connect_req *vdev_connect_req);
242 
243 /**
244  * wlan_cm_utf_disconnect_req: Connection manager UTF disconnect
245  * request handler
246  * @vdev: VDEV object
247  * @vdev_connect_req: Vdev connect request
248  *
249  * Return: QDF_STATUS
250  */
251 QDF_STATUS wlan_cm_utf_disconnect_req(
252 		struct wlan_objmgr_vdev *vdev,
253 		struct wlan_cm_vdev_discon_req *vdev_disconnect_req);
254 
255 /**
256  * wlan_cm_utf_bss_peer_delete_req: Connection manager UTF bss peer
257  * delete request handler
258  * @vdev: VDEV object
259  *
260  * Return: QDF_STATUS
261  */
262 QDF_STATUS wlan_cm_utf_bss_peer_delete_req(struct wlan_objmgr_vdev *vdev);
263 
264 /**
265  * wlan_cm_utf_vdev_down: Connection manager UTF vdev down request handler
266  * @vdev: VDEV object
267  *
268  * Return: QDF_STATUS
269  */
270 QDF_STATUS wlan_cm_utf_vdev_down(struct wlan_objmgr_vdev *vdev);
271 
272 /**
273  * osif_cm_utf_register_cb() - API to register connection manager callbacks
274  *
275  * Return: QDF_STATUS
276  */
277 QDF_STATUS osif_cm_utf_register_cb(void);
278 #endif //WLAN_CM_UTF_H
279