xref: /wlan-driver/qca-wifi-host-cmn/umac/mlme/connection_mgr/core/src/wlan_cm_roam.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2011-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 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: wlan_cm_roam.h
20  *
21  * This header file maintain APIs required for connection mgr roam functions
22  */
23 
24 #ifndef __WLAN_CM_ROAM_H__
25 #define __WLAN_CM_ROAM_H__
26 
27 #include "wlan_cm_main.h"
28 #include "wlan_cm_sm.h"
29 
30 #ifdef WLAN_FEATURE_HOST_ROAM
31 /**
32  * cm_is_host_roam_enabled() - Check if WLAN_FEATURE_HOST_ROAM is enabled
33  *
34  * Return: Return true if WLAN_FEATURE_HOST_ROAM is enabled
35  */
cm_is_host_roam_enabled(void)36 static inline bool cm_is_host_roam_enabled(void)
37 {
38 	return true;
39 }
40 
41 /**
42  * cm_roam_bss_peer_create_rsp() - handle bss peer create response for roam
43  * @vdev: vdev
44  * @status: bss peer create status
45  * @peer_mac: peer mac
46  *
47  * Return: QDF status
48  */
49 QDF_STATUS cm_roam_bss_peer_create_rsp(struct wlan_objmgr_vdev *vdev,
50 				       QDF_STATUS status,
51 				       struct qdf_mac_addr *peer_mac);
52 
53 /**
54  * cm_reassoc_rsp() - Connection manager reassoc response
55  * @vdev: vdev pointer
56  * @resp: Connect response
57  *
58  * Return: QDF_STATUS
59  */
60 QDF_STATUS cm_reassoc_rsp(struct wlan_objmgr_vdev *vdev,
61 			  struct wlan_cm_connect_resp *resp);
62 
63 /**
64  * cm_roam_disconnect_rsp() - Connection manager api to post connect event
65  * @vdev: VDEV object
66  * @resp: Disconnect response
67  *
68  * Context: Any context.
69  *
70  * Return: QDF_STATUS
71  */
72 QDF_STATUS cm_roam_disconnect_rsp(struct wlan_objmgr_vdev *vdev,
73 				  struct wlan_cm_discon_rsp *resp);
74 
75 /**
76  * cm_reassoc_complete() - This API would be called after reassoc complete
77  * request from the serialization.
78  * @cm_ctx: connection manager context
79  * @resp: connect resp.
80  *
81  * This API would be called after roam completion resp from VDEV mgr
82  *
83  * Return: QDF status
84  */
85 QDF_STATUS cm_reassoc_complete(struct cnx_mgr *cm_ctx,
86 			       struct wlan_cm_connect_resp *resp);
87 
88 /**
89  * cm_get_active_reassoc_req() - Get copy of active reassoc request
90  * @vdev: vdev pointer
91  * @req: pointer to the copy of the active reassoc request
92  *
93  * Context: Should be called only in the context of the
94  * cm request activation
95  *
96  * Return: true and reassoc req if any request is active
97  */
98 bool cm_get_active_reassoc_req(struct wlan_objmgr_vdev *vdev,
99 			       struct wlan_cm_vdev_reassoc_req *req);
100 /**
101  * cm_host_roam_start_req() - Start host roam request
102  * @cm_ctx: Connection manager context
103  * @cm_req: Struct containing the roam request
104  *
105  * Return: QDF_STATUS_SUCCESS on delivering the event
106  * to connection state machine else error value.
107  */
108 QDF_STATUS cm_host_roam_start_req(struct cnx_mgr *cm_ctx,
109 				  struct cm_req *cm_req);
110 
111 /**
112  * cm_reassoc_start() - This API will be called to initiate the reassoc
113  * process
114  * @cm_ctx: connection manager context
115  * @req: roam request.
116  *
117  * Return: QDF status
118  */
119 QDF_STATUS cm_reassoc_start(struct cnx_mgr *cm_ctx, struct cm_roam_req *req);
120 
121 #ifdef WLAN_POLICY_MGR_ENABLE
122 /**
123  * cm_reassoc_hw_mode_change_resp() - HW mode change response
124  * @pdev: pdev pointer
125  * @vdev_id: vdev id
126  * @cm_id: reassoc ID which gave the hw mode change request
127  * @status: status of the HW mode change.
128  *
129  * Return: void
130  */
131 void cm_reassoc_hw_mode_change_resp(struct wlan_objmgr_pdev *pdev,
132 				    uint8_t vdev_id,
133 				    wlan_cm_id cm_id, QDF_STATUS status);
134 
135 /**
136  * cm_handle_reassoc_hw_mode_change() - SM handling of reassoc hw mode change
137  * resp
138  * @cm_ctx: connection manager context
139  * @cm_id: Connection mgr ID assigned to this connect request.
140  * @event: HW mode success or failure event
141  *
142  * Return: QDF_STATUS
143  */
144 QDF_STATUS
145 cm_handle_reassoc_hw_mode_change(struct cnx_mgr *cm_ctx, wlan_cm_id *cm_id,
146 				 enum wlan_cm_sm_evt event);
147 #else
148 static inline QDF_STATUS
cm_handle_reassoc_hw_mode_change(struct cnx_mgr * cm_ctx,wlan_cm_id * cm_id,enum wlan_cm_sm_evt event)149 cm_handle_reassoc_hw_mode_change(struct cnx_mgr *cm_ctx, wlan_cm_id *cm_id,
150 				 enum wlan_cm_sm_evt event)
151 {
152 	return QDF_STATUS_SUCCESS;
153 }
154 #endif
155 
156 /**
157  * cm_reassoc_active() - This API would be called after the reassoc
158  * request gets activated in serialization.
159  * @cm_ctx: connection manager context
160  * @cm_id: Connection mgr ID assigned to this reassoc request.
161  *
162  * Return: QDF status
163  */
164 QDF_STATUS cm_reassoc_active(struct cnx_mgr *cm_ctx, wlan_cm_id *cm_id);
165 
166 /**
167  * cm_reassoc_disconnect_complete() - This API would be called after
168  * disconnect complete due to reassoc request.
169  * @cm_ctx: connection manager context
170  * @resp: disconnection complete resp.
171  *
172  * This API would be called after disconnection completion resp from VDEV mgr
173  *
174  * Return: QDF status
175  */
176 
177 QDF_STATUS cm_reassoc_disconnect_complete(struct cnx_mgr *cm_ctx,
178 					  struct wlan_cm_discon_rsp *resp);
179 
180 /**
181  * cm_resume_reassoc_after_peer_create() - Called after bss create rsp
182  * @cm_ctx: connection manager context
183  * @cm_id: Connection mgr ID assigned to this reassoc request.
184  *
185  * Return: QDF status
186  */
187 QDF_STATUS
188 cm_resume_reassoc_after_peer_create(struct cnx_mgr *cm_ctx, wlan_cm_id *cm_id);
189 
190 /**
191  * cm_roam_resp_cmid_match_list_head() - Check if resp cmid is same as list
192  * head
193  * @cm_ctx: connection manager context
194  * @resp: connect resp
195  *
196  * Return: bool
197  */
198 bool cm_roam_resp_cmid_match_list_head(struct cnx_mgr *cm_ctx,
199 				       struct wlan_cm_connect_resp *resp);
200 
201 /**
202  * cm_send_reassoc_start_fail() - initiate reassoc failure
203  * @cm_ctx: connection manager context
204  * @cm_id: active command id
205  * @reason: failure reason
206  * @sync: Indicate if the event has to be dispatched in sync or async mode
207  *
208  * Return: QDF_STATUS
209  */
210 QDF_STATUS
211 cm_send_reassoc_start_fail(struct cnx_mgr *cm_ctx,
212 			   wlan_cm_id cm_id,
213 			   enum wlan_cm_connect_fail_reason reason,
214 			   bool sync);
215 
216 #ifdef CONN_MGR_ADV_FEATURE
217 /**
218  * cm_update_advance_roam_scan_filter() - fill scan filter for roam
219  * @vdev: vdev
220  * @filter: scan filter
221  *
222  * Return QDF_STATUS
223  */
224 QDF_STATUS cm_update_advance_roam_scan_filter(
225 		struct wlan_objmgr_vdev *vdev, struct scan_filter *filter);
226 #endif
227 
228 #ifdef WLAN_FEATURE_PREAUTH_ENABLE
229 /**
230  * cm_host_roam_preauth_start() - start preauth process
231  * @cm_ctx: Connection manager context
232  * @cm_req: Struct containing the roam request
233  *
234  * Return QDF_STATUS
235  */
236 QDF_STATUS cm_host_roam_preauth_start(struct cnx_mgr *cm_ctx,
237 				      struct cm_req *cm_req);
238 
239 /**
240  * cm_preauth_active() - This API would be called after the preauth
241  * request gets activated in serialization.
242  * @cm_ctx: connection manager context
243  * @cm_id: Connection mgr ID assigned to this preauth request.
244  *
245  * Return: QDF status
246  */
247 QDF_STATUS cm_preauth_active(struct cnx_mgr *cm_ctx, wlan_cm_id *cm_id);
248 
249 /**
250  * cm_preauth_done_resp() - This API would be called when preauth
251  * response msg handling
252  * @cm_ctx: connection manager context
253  * @rsp: Preauth resp
254  *
255  * Return: void
256  */
257 void cm_preauth_done_resp(struct cnx_mgr *cm_ctx, struct wlan_preauth_rsp *rsp);
258 
259 /**
260  * cm_preauth_success() - Preauth is successfully completed
261  * @cm_ctx: connection manager context
262  * @rsp: Preauth resp
263  *
264  * Return: void
265  */
266 void cm_preauth_success(struct cnx_mgr *cm_ctx, struct wlan_preauth_rsp *rsp);
267 
268 /**
269  * cm_preauth_fail() - This API would be called after the preauth
270  * request gets failed.
271  * @cm_ctx: connection manager context
272  * @preauth_fail_rsp: preauth fail response
273  *
274  * Return: none
275  */
276 void cm_preauth_fail(struct cnx_mgr *cm_ctx,
277 		     struct wlan_cm_preauth_fail *preauth_fail_rsp);
278 
279 /**
280  * cm_send_preauth_start_fail() - This API would be called after send preauth
281  * request failed.
282  * @cm_ctx: connection manager context
283  * @cm_id: connection mgr ID assigned to this preauth request.
284  * @reason: connect fail reason
285  *
286  * Return: QDF status
287  */
288 QDF_STATUS cm_send_preauth_start_fail(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id,
289 				      enum wlan_cm_connect_fail_reason reason);
290 
291 /**
292  * cm_handle_reassoc_timer() - handle ressoc timer expiry
293  * @cm_ctx: connection manager context
294  * @cm_id: connection mgr ID assigned to this preauth request.
295  *
296  * Return: QDF status
297  */
298 QDF_STATUS cm_handle_reassoc_timer(struct cnx_mgr *cm_ctx, wlan_cm_id *cm_id);
299 #endif /* WLAN_FEATURE_PREAUTH_ENABLE */
300 #else /* WLAN_FEATURE_HOST_ROAM */
301 
cm_is_host_roam_enabled(void)302 static inline bool cm_is_host_roam_enabled(void)
303 {
304 	return false;
305 }
306 
307 #ifdef WLAN_POLICY_MGR_ENABLE
308 static inline
cm_reassoc_hw_mode_change_resp(struct wlan_objmgr_pdev * pdev,uint8_t vdev_id,wlan_cm_id cm_id,QDF_STATUS status)309 void cm_reassoc_hw_mode_change_resp(struct wlan_objmgr_pdev *pdev,
310 				    uint8_t vdev_id,
311 				    wlan_cm_id cm_id, QDF_STATUS status) {}
312 #endif
313 
cm_reassoc_complete(struct cnx_mgr * cm_ctx,struct wlan_cm_connect_resp * resp)314 static inline QDF_STATUS cm_reassoc_complete(struct cnx_mgr *cm_ctx,
315 					     struct wlan_cm_connect_resp *resp)
316 {
317 	return QDF_STATUS_SUCCESS;
318 }
319 
320 static inline
cm_roam_disconnect_rsp(struct wlan_objmgr_vdev * vdev,struct wlan_cm_discon_rsp * resp)321 QDF_STATUS cm_roam_disconnect_rsp(struct wlan_objmgr_vdev *vdev,
322 				  struct wlan_cm_discon_rsp *resp)
323 {
324 	return QDF_STATUS_SUCCESS;
325 }
326 
327 static inline
cm_roam_bss_peer_create_rsp(struct wlan_objmgr_vdev * vdev,QDF_STATUS status,struct qdf_mac_addr * peer_mac)328 QDF_STATUS cm_roam_bss_peer_create_rsp(struct wlan_objmgr_vdev *vdev,
329 				       QDF_STATUS status,
330 				       struct qdf_mac_addr *peer_mac)
331 {
332 	return QDF_STATUS_SUCCESS;
333 }
334 #endif /* WLAN_FEATURE_HOST_ROAM */
335 
336 #if defined(WLAN_FEATURE_HOST_ROAM) || defined(WLAN_FEATURE_ROAM_OFFLOAD)
337 /**
338  * cm_check_and_prepare_roam_req() - Initiate roam request
339  * @cm_ctx: connection manager context
340  * @connect_req: connection manager request
341  * @roam_req: Roam request
342  *
343  * Context: Can be called only while handling connection manager event
344  *          ie holding state machine lock
345  *
346  * Return: QDF_STATUS
347  */
348 QDF_STATUS
349 cm_check_and_prepare_roam_req(struct cnx_mgr *cm_ctx,
350 			      struct cm_connect_req *connect_req,
351 			      struct cm_req **roam_req);
352 /**
353  * cm_free_roam_req_mem() - free croam req internal memory, to be called
354  * before cm_req is freed
355  * @roam_req: roam req
356  *
357  * Return: void
358  */
359 void cm_free_roam_req_mem(struct cm_roam_req *roam_req);
360 
361 /**
362  * cm_add_roam_req_to_list() - add connect req to the connection manager
363  * req list
364  * @cm_ctx: connection manager context
365  * @cm_req: Roam req provided
366  *
367  * Return: QDF status
368  */
369 QDF_STATUS cm_add_roam_req_to_list(struct cnx_mgr *cm_ctx,
370 				   struct cm_req *cm_req);
371 
372 /**
373  * cm_fill_bss_info_in_roam_rsp_by_cm_id() - fill bss info for the cm id
374  * @cm_ctx: connection manager context
375  * @cm_id: cm id of connect/disconnect req
376  * @resp: resp to copy bss info like ssid/bssid and freq
377  *
378  * Return: Success if entry was found else failure
379  */
380 QDF_STATUS
381 cm_fill_bss_info_in_roam_rsp_by_cm_id(struct cnx_mgr *cm_ctx,
382 				      wlan_cm_id cm_id,
383 				      struct wlan_cm_connect_resp *resp);
384 
385 /**
386  * cm_is_roam_enabled() - Check if host roam or roam offload is enabled.
387  * @psoc: psoc context
388  *
389  * Return: true if any of the roaming mode is enabled
390  */
391 bool cm_is_roam_enabled(struct wlan_objmgr_psoc *psoc);
392 #else
393 static inline QDF_STATUS
cm_check_and_prepare_roam_req(struct cnx_mgr * cm_ctx,struct cm_connect_req * connect_req,struct cm_req ** roam_req)394 cm_check_and_prepare_roam_req(struct cnx_mgr *cm_ctx,
395 			      struct cm_connect_req *connect_req,
396 			      struct cm_req **roam_req)
397 {
398 	return QDF_STATUS_E_NOSUPPORT;
399 }
400 
cm_free_roam_req_mem(struct cm_roam_req * roam_req)401 static inline void cm_free_roam_req_mem(struct cm_roam_req *roam_req) {}
402 
403 static inline QDF_STATUS
cm_add_roam_req_to_list(struct cnx_mgr * cm_ctx,struct cm_req * cm_req)404 cm_add_roam_req_to_list(struct cnx_mgr *cm_ctx, struct cm_req *cm_req)
405 {
406 	return QDF_STATUS_E_NOSUPPORT;
407 }
408 
409 static inline QDF_STATUS
cm_fill_bss_info_in_roam_rsp_by_cm_id(struct cnx_mgr * cm_ctx,wlan_cm_id cm_id,struct wlan_cm_connect_resp * resp)410 cm_fill_bss_info_in_roam_rsp_by_cm_id(struct cnx_mgr *cm_ctx,
411 				      wlan_cm_id cm_id,
412 				      struct wlan_cm_connect_resp *resp)
413 {
414 	return QDF_STATUS_E_NOSUPPORT;
415 }
416 
cm_is_roam_enabled(struct wlan_objmgr_psoc * psoc)417 static inline bool cm_is_roam_enabled(struct wlan_objmgr_psoc *psoc)
418 {
419 	mlme_rl_debug("Roaming is disabled");
420 	return false;
421 }
422 #endif
423 
424 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
425 /**
426  * cm_fw_roam_start() - Handle roam start event
427  * @cm_ctx: connection mgr context
428  *
429  * This function handles the roam start event received from FW.
430  *
431  * Return: QDF_STATUS
432  */
433 QDF_STATUS cm_fw_roam_start(struct cnx_mgr *cm_ctx);
434 
435 /**
436  * cm_send_roam_invoke_req() - Send Roam invoke req to FW
437  * @cm_ctx: connection manager context
438  * @req: connection manager request
439  *
440  * Return: QDF_STATUS
441  */
442 QDF_STATUS
443 cm_send_roam_invoke_req(struct cnx_mgr *cm_ctx, struct cm_req *req);
444 
445 /**
446  * cm_roam_offload_enabled() - check if roam offload(LFR3) is enabled
447  * @psoc: psoc pointer to get the INI
448  *
449  * Return: bool
450  */
451 bool cm_roam_offload_enabled(struct wlan_objmgr_psoc *psoc);
452 
453 /**
454  * cm_get_first_roam_command() - Get first roam request from list
455  * @vdev: vdev pointer
456  *
457  * Context: Can be called from any context and to be used only after posting a
458  * msg to SM (ie holding the SM lock) to avoid use after free. also returned req
459  * should only be used till SM lock is hold.
460  *
461  * Return: cm roam req from the req list
462  */
463 struct cm_roam_req *cm_get_first_roam_command(struct wlan_objmgr_vdev *vdev);
464 
465 /**
466  * cm_prepare_roam_cmd() - Prepare roam req
467  * @cm_ctx: connection mgr context
468  * @roam_req: connection mgr req
469  * @source: connection mgr req source
470  *
471  * This function prepares roam request when roam start ind is received
472  * when CM SM is in connected state.
473  *
474  * Return: QDF_STATUS
475  */
476 QDF_STATUS cm_prepare_roam_cmd(struct cnx_mgr *cm_ctx,
477 			       struct cm_req **roam_req,
478 			       enum wlan_cm_source source);
479 
480 /**
481  * cm_add_fw_roam_cmd_to_list_n_ser() - Add roam req to list and serialize req
482  * @cm_ctx: connection mgr context
483  * @cm_req: connection mgr req
484  *
485  * This function adds roam request to list and the serialization queue.
486  *
487  * Return: QDF_STATUS
488  */
489 QDF_STATUS cm_add_fw_roam_cmd_to_list_n_ser(struct cnx_mgr *cm_ctx,
490 					    struct cm_req *cm_req);
491 
492 /**
493  * cm_fw_send_vdev_roam_event() - CM send VDEV ROAM Event
494  * @cm_ctx: connection mgr context
495  * @data_len: data size
496  * @data: event data
497  *
498  * This function sends ROAM Event to vdev manager
499  * state machine
500  *
501  * Return: QDF_STATUS
502  */
503 QDF_STATUS
504 cm_fw_send_vdev_roam_event(struct cnx_mgr *cm_ctx, uint16_t data_len,
505 			   void *data);
506 
507 /**
508  * cm_fw_roam_complete() - CM handle roam complete
509  * @cm_ctx: connection mgr context
510  * @data: join rsp data
511  *
512  * This function CM handle roam complete
513  *
514  * Return: QDF_STATUS
515  */
516 QDF_STATUS
517 cm_fw_roam_complete(struct cnx_mgr *cm_ctx, void *data);
518 
519 #else
cm_roam_offload_enabled(struct wlan_objmgr_psoc * psoc)520 static inline bool cm_roam_offload_enabled(struct wlan_objmgr_psoc *psoc)
521 {
522 	return false;
523 }
524 #endif
525 
526 #endif /* __WLAN_CM_ROAM_H__ */
527