1 /*
2 * Copyright (c) 2012-2015, 2020-2021, The Linux Foundation. All rights reserved.
3 * Copyright (c) 2022-2024 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_main_api.h
20 *
21 * This header file maintain connect, disconnect APIs of connection manager
22 */
23
24 #ifndef __WLAN_CM_MAIN_API_H__
25 #define __WLAN_CM_MAIN_API_H__
26
27 #include "wlan_cm_main.h"
28 #include "wlan_cm_sm.h"
29 #include <include/wlan_mlme_cmn.h>
30 #include <wlan_crypto_global_api.h>
31 #include <wlan_if_mgr_api.h>
32 #ifdef WLAN_CM_USE_SPINLOCK
33 #include <scheduler_api.h>
34 #endif
35 #include <wlan_cp_stats_chipset_stats.h>
36
37 #define CONNECT_REQ_PREFIX 0x0C000000
38 #define DISCONNECT_REQ_PREFIX 0x0D000000
39 #define ROAM_REQ_PREFIX 0x0F000000
40
41 #define CM_ID_MASK 0x0000FFFF
42
43 #define CM_ID_GET_PREFIX(cm_id) cm_id & 0x0F000000
44 #define CM_VDEV_ID_SHIFT 16
45 #define CM_VDEV_ID_MASK 0x00FF0000
46 #define CM_ID_GET_VDEV_ID(cm_id) (cm_id & CM_VDEV_ID_MASK) >> CM_VDEV_ID_SHIFT
47 #define CM_ID_SET_VDEV_ID(cm_id, vdev_id) ((vdev_id << CM_VDEV_ID_SHIFT) & \
48 CM_VDEV_ID_MASK) | cm_id
49
50 #define CM_PREFIX_FMT "vdev %d cm_id 0x%x: "
51 #define CM_PREFIX_REF(vdev_id, cm_id) (vdev_id), (cm_id)
52
53 /*************** CONNECT APIs ****************/
54
55 /**
56 * cm_fill_failure_resp_from_cm_id() - This API will fill failure connect
57 * response
58 * @cm_ctx: connection manager context
59 * @resp: connect failure resp
60 * @cm_id: cm_id for connect response to be filled.
61 * @reason: connect failure reason
62 *
63 * This function will fill connect failure response structure with the provided
64 * reason with the help of given cm id.
65 *
66 * Return: void
67 */
68 void cm_fill_failure_resp_from_cm_id(struct cnx_mgr *cm_ctx,
69 struct wlan_cm_connect_resp *resp,
70 wlan_cm_id cm_id,
71 enum wlan_cm_connect_fail_reason reason);
72
73 /**
74 * cm_connect_start() - This API will be called to initiate the connect
75 * process
76 * @cm_ctx: connection manager context
77 * @req: Connect request.
78 *
79 * Return: QDF status
80 */
81 QDF_STATUS cm_connect_start(struct cnx_mgr *cm_ctx, struct cm_connect_req *req);
82
83 /**
84 * cm_if_mgr_inform_connect_complete() - inform ifmanager the connect complete
85 * @vdev: vdev for which connect cmpleted
86 * @connect_status: connect status
87 *
88 * Return: QDF_STATUS
89 */
90 QDF_STATUS cm_if_mgr_inform_connect_complete(struct wlan_objmgr_vdev *vdev,
91 QDF_STATUS connect_status);
92
93 /**
94 * cm_handle_connect_req_in_non_init_state() - Handle connect request in non
95 * init state.
96 * @cm_ctx: connection manager context
97 * @cm_req: cm request
98 * @cm_state_substate: state of CM SM
99 *
100 * Context: Can be called only while handling connection manager event
101 * ie holding state machine lock
102 *
103 * Return: QDF_STATUS
104 */
105 QDF_STATUS
106 cm_handle_connect_req_in_non_init_state(struct cnx_mgr *cm_ctx,
107 struct cm_connect_req *cm_req,
108 enum wlan_cm_sm_state cm_state_substate);
109
110 /**
111 * cm_handle_discon_req_in_non_connected_state() - Handle disconnect req in non
112 * connected state.
113 * @cm_ctx: connection manager context
114 * @cm_req: cm request
115 * @cm_state_substate: state of CM SM
116 *
117 * Context: Can be called only while handling connection manager event
118 * ie holding state machine lock
119 *
120 * Return: QDF_STATUS
121 */
122 QDF_STATUS
123 cm_handle_discon_req_in_non_connected_state(struct cnx_mgr *cm_ctx,
124 struct cm_disconnect_req *cm_req,
125 enum wlan_cm_sm_state cm_state_substate);
126
127 /**
128 * cm_connect_scan_start() - This API will be called to initiate the connect
129 * scan if no candidate are found in scan db.
130 * @cm_ctx: connection manager context
131 * @req: Connect request.
132 *
133 * Return: QDF status
134 */
135 QDF_STATUS cm_connect_scan_start(struct cnx_mgr *cm_ctx,
136 struct cm_connect_req *req);
137
138 /**
139 * cm_connect_scan_resp() - Handle the connect scan resp and next action
140 * scan if no candidate are found in scan db.
141 * @cm_ctx: connection manager context
142 * @scan_id: scan id of the req
143 * @status: Connect scan status
144 *
145 * Return: QDF status
146 */
147 QDF_STATUS cm_connect_scan_resp(struct cnx_mgr *cm_ctx, wlan_scan_id *scan_id,
148 QDF_STATUS status);
149
150 /**
151 * cm_connect_handle_event_post_fail() - initiate connect failure if msg posting
152 * to SM fails
153 * @cm_ctx: connection manager context
154 * @cm_id: cm_id for connect req for which post fails
155 *
156 * Context: Can be called from any context and to be used only after posting a
157 * msg to SM fails from external event e.g. peer create resp,
158 * HW mode change resp serialization cb.
159 *
160 * Return: QDF_STATUS
161 */
162 void
163 cm_connect_handle_event_post_fail(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id);
164
165 /**
166 * wlan_cm_scan_cb() - Callback function for scan for ssid
167 * @vdev: VDEV MLME comp object
168 * @event: scan event definition
169 * @arg: reference to connection manager context
170 *
171 * API handles scan success/failure case
172 *
173 * Context: Can be called from any context.
174 * Return: None
175 */
176 void wlan_cm_scan_cb(struct wlan_objmgr_vdev *vdev,
177 struct scan_event *event, void *arg);
178
179 /**
180 * cm_connect_resp_cmid_match_list_head() - Check if resp cmid is same as list
181 * head
182 * @cm_ctx: connection manager context
183 * @resp: connect resp
184 *
185 * Return: bool
186 */
187 bool cm_connect_resp_cmid_match_list_head(struct cnx_mgr *cm_ctx,
188 struct wlan_cm_connect_resp *resp);
189
190 /**
191 * cm_connect_active() - This API would be called after the connect
192 * request gets activated in serialization.
193 * @cm_ctx: connection manager context
194 * @cm_id: Connection mgr ID assigned to this connect request.
195 *
196 * Return: QDF status
197 */
198 QDF_STATUS cm_connect_active(struct cnx_mgr *cm_ctx, wlan_cm_id *cm_id);
199
200 /**
201 * cm_try_next_candidate() - This API would try to connect to next valid
202 * candidate and fail if no candidate left
203 * request gets activated in serialization.
204 * @cm_ctx: connection manager context
205 * @connect_resp: connect resp.
206 *
207 * Return: QDF status
208 */
209 QDF_STATUS cm_try_next_candidate(struct cnx_mgr *cm_ctx,
210 struct wlan_cm_connect_resp *connect_resp);
211
212 /**
213 * cm_resume_connect_after_peer_create() - Called after bss create rsp
214 * @cm_ctx: connection manager context
215 * @cm_id: Connection mgr ID assigned to this connect request.
216 *
217 * Return: QDF status
218 */
219 QDF_STATUS
220 cm_resume_connect_after_peer_create(struct cnx_mgr *cm_ctx, wlan_cm_id *cm_id);
221
222 #if defined(CONN_MGR_ADV_FEATURE) && defined(WLAN_FEATURE_11BE_MLO)
223 /**
224 * cm_bss_peer_create_resp_mlo_attach() - Create MLO peer and attach objmgr peer
225 * @vdev: VDEV object manager pointer
226 * @peer_mac: MAC addr pointer for BSS peer created
227 *
228 * Creates MLO peer for the peer with @peer_mac and adds the objmgr peer to
229 * the created MLO peer context and holds reference for the MLO peer.
230 *
231 * Return: QDF_STATUS
232 */
233 QDF_STATUS cm_bss_peer_create_resp_mlo_attach(struct wlan_objmgr_vdev *vdev,
234 struct qdf_mac_addr *peer_mac);
235 #else
236 static inline QDF_STATUS
cm_bss_peer_create_resp_mlo_attach(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr * peer_mac)237 cm_bss_peer_create_resp_mlo_attach(struct wlan_objmgr_vdev *vdev,
238 struct qdf_mac_addr *peer_mac)
239 {
240 return QDF_STATUS_SUCCESS;
241 }
242 #endif
243
244 /**
245 * cm_bss_peer_create_rsp() - handle bss peer create response
246 * @vdev: vdev
247 * @status: bss peer create status
248 * @peer_mac: peer mac
249 *
250 * Return: QDF status
251 */
252 QDF_STATUS cm_bss_peer_create_rsp(struct wlan_objmgr_vdev *vdev,
253 QDF_STATUS status,
254 struct qdf_mac_addr *peer_mac);
255
256 /**
257 * cm_connect_rsp() - Connection manager connect response
258 * @vdev: vdev pointer
259 * @resp: Connect response
260 *
261 * Return: QDF_STATUS
262 */
263 QDF_STATUS cm_connect_rsp(struct wlan_objmgr_vdev *vdev,
264 struct wlan_cm_connect_resp *resp);
265
266 /**
267 * cm_notify_connect_complete() - This API would be called for sending
268 * connect response notification
269 * @cm_ctx: connection manager context
270 * @resp: connection complete resp.
271 * @acquire_lock: Flag to indicate whether this function needs
272 * cm_ctx lock or not.
273 *
274 * This API would be called after connection completion resp from VDEV mgr
275 *
276 * Return: QDF status
277 */
278 QDF_STATUS cm_notify_connect_complete(struct cnx_mgr *cm_ctx,
279 struct wlan_cm_connect_resp *resp,
280 bool acquire_lock);
281
282 /**
283 * cm_update_scan_mlme_info() - This API would be called after connect complete
284 * request or roam synch completion.
285 * @cm_ctx: connection manager context
286 * @resp: Connection complete resp.
287 *
288 * This API would be called after connection completion resp or roam synch
289 * propagation completion. This will update the assoc state in the scan
290 * entries
291 *
292 * Return: QDF status
293 */
294 void cm_update_scan_mlme_info(struct cnx_mgr *cm_ctx,
295 struct wlan_cm_connect_resp *resp);
296
297 /**
298 * cm_update_scan_mlme_info() - This API would be called after connect complete
299 * request or roam synch completion.
300 * @cm_ctx: connection manager context
301 * @resp: Connection complete resp.
302 *
303 * This API would be called after connection completion resp or roam synch
304 * propagation completion. This will update the assoc state in the scan
305 * entries
306 *
307 * Return: QDF status
308 */
309 void cm_update_scan_mlme_info(struct cnx_mgr *cm_ctx,
310 struct wlan_cm_connect_resp *resp);
311
312 /**
313 * cm_connect_complete() - This API would be called after connect complete
314 * request from the serialization.
315 * @cm_ctx: connection manager context
316 * @resp: Connection complete resp.
317 *
318 * This API would be called after connection completion resp from VDEV mgr
319 *
320 * Return: QDF status
321 */
322 QDF_STATUS cm_connect_complete(struct cnx_mgr *cm_ctx,
323 struct wlan_cm_connect_resp *resp);
324
325 /**
326 * cm_add_connect_req_to_list() - add connect req to the connection manager
327 * req list
328 * @cm_ctx: connection manager context
329 * @req: Connection req provided
330 *
331 * Return: QDF status
332 */
333 QDF_STATUS cm_add_connect_req_to_list(struct cnx_mgr *cm_ctx,
334 struct cm_connect_req *req);
335
336 /**
337 * cm_connect_start_req() - Connect start req from the requester
338 * @vdev: vdev on which connect is received
339 * @req: Connection req provided
340 *
341 * Return: QDF status
342 */
343 QDF_STATUS cm_connect_start_req(struct wlan_objmgr_vdev *vdev,
344 struct wlan_cm_connect_req *req);
345
346 /**
347 * cm_send_connect_start_fail() - initiate connect failure
348 * @cm_ctx: connection manager context
349 * @req: connect req for which connect failed
350 * @reason: failure reason
351 *
352 * Context: Can be called from any context and to be used only after posting a
353 * msg to SM (ie holding the SM lock) to avoid use after free for req.
354 *
355 * Return: QDF_STATUS
356 */
357 QDF_STATUS
358 cm_send_connect_start_fail(struct cnx_mgr *cm_ctx,
359 struct cm_connect_req *req,
360 enum wlan_cm_connect_fail_reason reason);
361
362 /**
363 * cm_find_bss_from_candidate_list() - get bss entry by bssid value
364 * @candidate_list: candidate list
365 * @bssid: bssid to find
366 * @entry_found: found bss entry
367 *
368 * Return: true if find bss entry with bssid
369 */
370 bool cm_find_bss_from_candidate_list(qdf_list_t *candidate_list,
371 struct qdf_mac_addr *bssid,
372 struct scan_cache_node **entry_found);
373
374 #ifdef WLAN_POLICY_MGR_ENABLE
375 /**
376 * cm_hw_mode_change_resp() - HW mode change response
377 * @pdev: pdev pointer
378 * @vdev_id: vdev id
379 * @cm_id: connection ID which gave the hw mode change request
380 * @status: status of the HW mode change.
381 *
382 * Return: void
383 */
384 void cm_hw_mode_change_resp(struct wlan_objmgr_pdev *pdev, uint8_t vdev_id,
385 wlan_cm_id cm_id, QDF_STATUS status);
386
387 /**
388 * cm_ser_connect_after_mode_change_resp() - SM handling of
389 * hw mode change/bearer switch resp
390 * @cm_ctx: connection manager context
391 * @cm_id: Connection mgr ID assigned to this connect request.
392 * @event: success or failure event
393 *
394 * Return: QDF_STATUS
395 */
396 QDF_STATUS cm_ser_connect_after_mode_change_resp(struct cnx_mgr *cm_ctx,
397 wlan_cm_id *cm_id,
398 enum wlan_cm_sm_evt event);
399 #else
400 static inline
cm_ser_connect_after_mode_change_resp(struct cnx_mgr * cm_ctx,wlan_cm_id * cm_id,enum wlan_cm_sm_evt event)401 QDF_STATUS cm_ser_connect_after_mode_change_resp(struct cnx_mgr *cm_ctx,
402 wlan_cm_id *cm_id,
403 enum wlan_cm_sm_evt event)
404 {
405 return QDF_STATUS_SUCCESS;
406 }
407 #endif
408
409 /*************** DISCONNECT APIs ****************/
410
411 /**
412 * cm_disconnect_start() - Initiate the disconnect process
413 * @cm_ctx: connection manager context
414 * @req: Disconnect request.
415 *
416 * Return: QDF status
417 */
418 QDF_STATUS cm_disconnect_start(struct cnx_mgr *cm_ctx,
419 struct cm_disconnect_req *req);
420
421 /**
422 * cm_disconnect_active() - This API would be called after the disconnect
423 * request gets activated in serialization.
424 * @cm_ctx: connection manager context
425 * @cm_id: Connection mgr ID assigned to this connect request.
426 *
427 * Return: QDF status
428 */
429 QDF_STATUS cm_disconnect_active(struct cnx_mgr *cm_ctx, wlan_cm_id *cm_id);
430
431 /**
432 * cm_notify_disconnect_complete() - This API would be called for sending
433 * disconnect response notification
434 * @cm_ctx: connection manager context
435 * @resp: disconnection complete resp.
436 *
437 * This API would be called after disconnect completion resp from VDEV mgr
438 *
439 * Return: QDF status
440 */
441 QDF_STATUS cm_notify_disconnect_complete(struct cnx_mgr *cm_ctx,
442 struct wlan_cm_discon_rsp *resp);
443 /**
444 * cm_disconnect_complete() - This API would be called after disconnect complete
445 * request from the serialization.
446 * @cm_ctx: connection manager context
447 * @resp: disconnection complete resp.
448 *
449 * This API would be called after connection completion resp from VDEV mgr
450 *
451 * Return: QDF status
452 */
453 QDF_STATUS cm_disconnect_complete(struct cnx_mgr *cm_ctx,
454 struct wlan_cm_discon_rsp *resp);
455
456 /**
457 * cm_add_disconnect_req_to_list() - add disconnect req to the connection
458 * manager req list
459 * @cm_ctx: connection manager context
460 * @req: Disconnection req provided
461 *
462 * Return: QDF status
463 */
464 QDF_STATUS cm_add_disconnect_req_to_list(struct cnx_mgr *cm_ctx,
465 struct cm_disconnect_req *req);
466
467 /**
468 * cm_disconnect_start_req() - Disconnect start req from the requester
469 * @vdev: vdev on which connect is received
470 * @req: disconnection req provided
471 *
472 * Return: QDF status
473 */
474 QDF_STATUS cm_disconnect_start_req(struct wlan_objmgr_vdev *vdev,
475 struct wlan_cm_disconnect_req *req);
476
477 /**
478 * cm_disconnect_start_req_sync() - disconnect request with wait till
479 * completed
480 * @vdev: vdev pointer
481 * @req: disconnect req
482 *
483 * Context: Only call for north bound disconnect req, if wait till complete
484 * is required, e.g. during vdev delete. Do not call from scheduler context.
485 *
486 * Return: QDF_STATUS
487 */
488 QDF_STATUS cm_disconnect_start_req_sync(struct wlan_objmgr_vdev *vdev,
489 struct wlan_cm_disconnect_req *req);
490
491 /**
492 * cm_bss_peer_delete_req() - Connection manager bss peer delete
493 * request
494 * @vdev: VDEV object
495 * @peer_mac: Peer mac address
496 *
497 * This function is called on peer delete indication and sends peer delete
498 * request to mlme.
499 *
500 * Context: Any context.
501 *
502 * Return: QDF_STATUS
503 */
504 QDF_STATUS cm_bss_peer_delete_req(struct wlan_objmgr_vdev *vdev,
505 struct qdf_mac_addr *peer_mac);
506
507 /**
508 * cm_vdev_down_req() - Connection manager req to send vdev down to FW
509 * @vdev: VDEV object
510 * @status: status
511 *
512 * This function is called when peer delete response is received, to send
513 * vdev down request to mlme
514 *
515 * Context: Any context.
516 *
517 * Return: QDF_STATUS
518 */
519 QDF_STATUS cm_vdev_down_req(struct wlan_objmgr_vdev *vdev, uint32_t status);
520
521 /**
522 * cm_disconnect_rsp() - Connection manager api to post connect event
523 * @vdev: VDEV object
524 * @resp: Disconnect response
525 *
526 * This function is called when disconnect response is received, to deliver
527 * disconnect event to SM
528 *
529 * Context: Any context.
530 *
531 * Return: QDF_STATUS
532 */
533 QDF_STATUS cm_disconnect_rsp(struct wlan_objmgr_vdev *vdev,
534 struct wlan_cm_discon_rsp *resp);
535
536 /**
537 * cm_initiate_internal_disconnect() - Initiate internal disconnect to cleanup
538 * a active connect in case of back to back request
539 * @cm_ctx: connection manager context
540 *
541 * Context: Can be called from any context. Hold the SM lock while calling this
542 * api.
543 *
544 * Return: void
545 */
546 void cm_initiate_internal_disconnect(struct cnx_mgr *cm_ctx);
547
548 /**
549 * cm_send_disconnect_resp() - Initiate disconnect resp for the cm_id
550 * @cm_ctx: connection manager context
551 * @cm_id: cm id to send disconnect resp for
552 *
553 * Context: Can be called from any context. Hold the SM lock while calling this
554 * api.
555 *
556 * Return: void
557 */
558 void cm_send_disconnect_resp(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id);
559
560 /**
561 * cm_disconnect_continue_after_rso_stop() - Continue disconnect after RSO stop
562 * @vdev: Objmgr vdev
563 * @req: pointer to cm vdev disconnect req
564 *
565 * Return: QDF_STATUS
566 */
567 QDF_STATUS
568 cm_disconnect_continue_after_rso_stop(struct wlan_objmgr_vdev *vdev,
569 struct wlan_cm_vdev_discon_req *req);
570
571 /**
572 * cm_handle_rso_stop_rsp() - Handle RSO stop response
573 * @vdev: Objmgr vdev
574 * @req: pointer to cm vdev disconnect req
575 *
576 * Return: QDF_STATUS
577 */
578 QDF_STATUS
579 cm_handle_rso_stop_rsp(struct wlan_objmgr_vdev *vdev,
580 struct wlan_cm_vdev_discon_req *req);
581
582 /*************** UTIL APIs ****************/
583
584 /**
585 * cm_ser_get_blocking_cmd() - check if serialization command needs to be
586 * blocking
587 *
588 * Return: bool
589 */
590 #ifdef CONN_MGR_ADV_FEATURE
cm_ser_get_blocking_cmd(void)591 static inline bool cm_ser_get_blocking_cmd(void)
592 {
593 return true;
594 }
595 #else
cm_ser_get_blocking_cmd(void)596 static inline bool cm_ser_get_blocking_cmd(void)
597 {
598 return false;
599 }
600 #endif
601
602 /**
603 * cm_get_cm_id() - Get unique cm id for connect/disconnect request
604 * @cm_ctx: connection manager context
605 * @source: source of the request (can be connect or disconnect request)
606 *
607 * Return: cm id
608 */
609 wlan_cm_id cm_get_cm_id(struct cnx_mgr *cm_ctx, enum wlan_cm_source source);
610
611 struct cnx_mgr *cm_get_cm_ctx_fl(struct wlan_objmgr_vdev *vdev,
612 const char *func, uint32_t line);
613
614 /**
615 * cm_get_cm_ctx() - Get connection manager context from vdev
616 * @vdev: vdev object pointer
617 *
618 * Return: pointer to connection manager context
619 */
620 #define cm_get_cm_ctx(vdev) \
621 cm_get_cm_ctx_fl(vdev, __func__, __LINE__)
622
623 cm_ext_t *cm_get_ext_hdl_fl(struct wlan_objmgr_vdev *vdev,
624 const char *func, uint32_t line);
625
626 /**
627 * cm_get_ext_hdl() - Get connection manager ext context from vdev
628 * @vdev: vdev object pointer
629 *
630 * Return: pointer to connection manager ext context
631 */
632 #define cm_get_ext_hdl(vdev) \
633 cm_get_ext_hdl_fl(vdev, __func__, __LINE__)
634
635 /**
636 * cm_reset_active_cm_id() - Reset active cm_id from cm context, if its same as
637 * passed cm_id
638 * @vdev: vdev object pointer
639 * @cm_id: cmid to match
640 *
641 * Return: void
642 */
643 void cm_reset_active_cm_id(struct wlan_objmgr_vdev *vdev, wlan_cm_id cm_id);
644
645 #ifdef CRYPTO_SET_KEY_CONVERGED
646 /**
647 * cm_set_key() - set wep or fils key on connection completion
648 * @cm_ctx: connection manager context
649 * @unicast: if key is unicast
650 * @key_idx: Key index
651 * @bssid: bssid of the connected AP
652 *
653 * Return: void
654 */
655 QDF_STATUS cm_set_key(struct cnx_mgr *cm_ctx, bool unicast,
656 uint8_t key_idx, struct qdf_mac_addr *bssid);
657 #endif
658
659 #ifdef CONN_MGR_ADV_FEATURE
660 /**
661 * cm_store_wep_key() - store wep keys in crypto on connect active
662 * @cm_ctx: connection manager context
663 * @crypto: connection crypto info
664 * @cm_id: cm_id of the connection
665 *
666 * Return: void
667 */
668 void cm_store_wep_key(struct cnx_mgr *cm_ctx,
669 struct wlan_cm_connect_crypto_info *crypto,
670 wlan_cm_id cm_id);
671
672 /**
673 * cm_inform_dlm_connect_complete() - inform bsl about connect complete
674 * @vdev: vdev
675 * @resp: connect resp
676 *
677 * Return: QDF_STATUS
678 */
679 QDF_STATUS
680 cm_inform_dlm_connect_complete(struct wlan_objmgr_vdev *vdev,
681 struct wlan_cm_connect_resp *resp);
682
683 static inline QDF_STATUS
cm_peer_create_on_bss_select_ind_resp(struct cnx_mgr * cm_ctx,wlan_cm_id * cm_id)684 cm_peer_create_on_bss_select_ind_resp(struct cnx_mgr *cm_ctx,
685 wlan_cm_id *cm_id)
686 {
687 return QDF_STATUS_SUCCESS;
688 }
689
690 static inline
cm_bss_select_ind_rsp(struct wlan_objmgr_vdev * vdev,QDF_STATUS status)691 QDF_STATUS cm_bss_select_ind_rsp(struct wlan_objmgr_vdev *vdev,
692 QDF_STATUS status)
693 {
694 return QDF_STATUS_SUCCESS;
695 }
696
697 /**
698 * cm_is_link_switch_connect_req() - API to check if connect request
699 * is for link switch.
700 * @req: Connect request
701 *
702 * Return true if the request for connection is due to link switch or else
703 * return false.
704 *
705 * Return: bool
706 */
cm_is_link_switch_connect_req(struct cm_connect_req * req)707 static inline bool cm_is_link_switch_connect_req(struct cm_connect_req *req)
708 {
709 return req->req.source == CM_MLO_LINK_SWITCH_CONNECT;
710 }
711
712 /**
713 * cm_is_link_switch_disconnect_req() - API to check if disconnect request is
714 * for link switch.
715 * @req: Disconnect request.
716 *
717 * Return true if the request for disconnection is due to link switch or else
718 * return false.
719 *
720 * Return: bool
721 */
722 static inline bool
cm_is_link_switch_disconnect_req(struct cm_disconnect_req * req)723 cm_is_link_switch_disconnect_req(struct cm_disconnect_req *req)
724 {
725 return req->req.source == CM_MLO_LINK_SWITCH_DISCONNECT;
726 }
727
728 /**
729 * cm_is_link_switch_cmd() - Check if the CM ID is for link switch
730 * @cm_id: Connection manager request ID
731 *
732 * Return true if the bit corresponding to link switch is set for @cm_id or
733 * else return false.
734 *
735 * Return: bool
736 */
cm_is_link_switch_cmd(wlan_cm_id cm_id)737 static inline bool cm_is_link_switch_cmd(wlan_cm_id cm_id)
738 {
739 return cm_id & CM_ID_LSWITCH_BIT;
740 }
741
742 /**
743 * cm_is_link_switch_disconnect_resp() - API to check if the disconnect
744 * response is for link switch.
745 * @resp: Disconnect response.
746 *
747 * Return true if the disconnect response is for link switch or else return
748 * false.
749 *
750 * Return: bool
751 */
752 static inline bool
cm_is_link_switch_disconnect_resp(struct wlan_cm_discon_rsp * resp)753 cm_is_link_switch_disconnect_resp(struct wlan_cm_discon_rsp *resp)
754 {
755 return cm_is_link_switch_cmd(resp->req.cm_id);
756 }
757
758 /**
759 * cm_is_link_switch_connect_resp() - API to check if the connect response
760 * is for link switch.
761 * @resp: Connect response.
762 *
763 * Return true if the connect response is for link switch or else return
764 * false.
765 *
766 * Return: bool
767 */
768 static inline bool
cm_is_link_switch_connect_resp(struct wlan_cm_connect_resp * resp)769 cm_is_link_switch_connect_resp(struct wlan_cm_connect_resp *resp)
770 {
771 return cm_is_link_switch_cmd(resp->cm_id);
772 }
773 #else
cm_store_wep_key(struct cnx_mgr * cm_ctx,struct wlan_cm_connect_crypto_info * crypto,wlan_cm_id cm_id)774 static inline void cm_store_wep_key(struct cnx_mgr *cm_ctx,
775 struct wlan_cm_connect_crypto_info *crypto,
776 wlan_cm_id cm_id)
777 {}
778
779 static inline QDF_STATUS
cm_inform_dlm_connect_complete(struct wlan_objmgr_vdev * vdev,struct wlan_cm_connect_resp * resp)780 cm_inform_dlm_connect_complete(struct wlan_objmgr_vdev *vdev,
781 struct wlan_cm_connect_resp *resp)
782 {
783 return QDF_STATUS_SUCCESS;
784 }
785
786 /**
787 * cm_peer_create_on_bss_select_ind_resp() - Called to create peer
788 * if bss select inidication's resp was success
789 * @cm_ctx: connection manager context
790 * @cm_id: Connection mgr ID assigned to this connect request.
791 *
792 * Return: QDF status
793 */
794 QDF_STATUS
795 cm_peer_create_on_bss_select_ind_resp(struct cnx_mgr *cm_ctx,
796 wlan_cm_id *cm_id);
797
798 /**
799 * cm_bss_select_ind_rsp() - Connection manager resp for bss
800 * select indication
801 * @vdev: vdev pointer
802 * @status: Status
803 *
804 * Return: QDF_STATUS
805 */
806 QDF_STATUS cm_bss_select_ind_rsp(struct wlan_objmgr_vdev *vdev,
807 QDF_STATUS status);
808
cm_is_link_switch_connect_req(struct cm_connect_req * req)809 static inline bool cm_is_link_switch_connect_req(struct cm_connect_req *req)
810 {
811 return false;
812 }
813
814 static inline bool
cm_is_link_switch_disconnect_req(struct cm_disconnect_req * req)815 cm_is_link_switch_disconnect_req(struct cm_disconnect_req *req)
816 {
817 return false;
818 }
819
cm_is_link_switch_cmd(wlan_cm_id cm_id)820 static inline bool cm_is_link_switch_cmd(wlan_cm_id cm_id)
821 {
822 return false;
823 }
824
825 static inline bool
cm_is_link_switch_disconnect_resp(struct wlan_cm_discon_rsp * resp)826 cm_is_link_switch_disconnect_resp(struct wlan_cm_discon_rsp *resp)
827 {
828 return false;
829 }
830
831 static inline bool
cm_is_link_switch_connect_resp(struct wlan_cm_connect_resp * resp)832 cm_is_link_switch_connect_resp(struct wlan_cm_connect_resp *resp)
833 {
834 return false;
835 }
836 #endif
837
838 #ifdef WLAN_FEATURE_FILS_SK
839 /**
840 * cm_store_fils_key() - store fils keys in crypto on connection complete
841 * @cm_ctx: connection manager context
842 * @unicast: if key is unicast
843 * @key_id: Key index
844 * @key_length: key length
845 * @key: key data
846 * @bssid: bssid of the connected AP
847 * @cm_id: cm_id of the connection
848 *
849 * Return: void
850 */
851 void cm_store_fils_key(struct cnx_mgr *cm_ctx, bool unicast,
852 uint8_t key_id, uint16_t key_length,
853 uint8_t *key, struct qdf_mac_addr *bssid,
854 wlan_cm_id cm_id);
855 #endif
856
857 /**
858 * cm_check_cmid_match_list_head() - check if list head command matches the
859 * given cm_id
860 * @cm_ctx: connection manager context
861 * @cm_id: cm id of connect/disconnect req
862 *
863 * Check if front req command matches the given
864 * cm_id, this can be used to check if the latest (head) is same we are
865 * trying to processing
866 *
867 * Return: true if match else false
868 */
869 bool cm_check_cmid_match_list_head(struct cnx_mgr *cm_ctx, wlan_cm_id *cm_id);
870
871 /**
872 * cm_check_scanid_match_list_head() - check if list head command matches the
873 * given scan_id
874 * @cm_ctx: connection manager context
875 * @scan_id: scan_id of connect req
876 *
877 * Check if front req command is connect command and matches the given
878 * scan_id, this can be used to check if the latest (head) is same we are
879 * trying to processing
880 *
881 * Return: true if match else false
882 */
883 bool cm_check_scanid_match_list_head(struct cnx_mgr *cm_ctx,
884 wlan_scan_id *scan_id);
885
886 /**
887 * cm_free_connect_req_mem() - free connect req internal memory, to be called
888 * before cm_req is freed
889 * @connect_req: connect req
890 *
891 * Return: void
892 */
893 void cm_free_connect_req_mem(struct cm_connect_req *connect_req);
894
895 /**
896 * cm_delete_req_from_list() - Delete the request matching cm id
897 * @cm_ctx: connection manager context
898 * @cm_id: cm id of connect/disconnect req
899 *
900 * Context: Can be called from any context.
901 *
902 * Return: QDF_STATUS
903 */
904 QDF_STATUS cm_delete_req_from_list(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id);
905
906 /**
907 * cm_fill_bss_info_in_connect_rsp_by_cm_id() - fill bss info for the cm id
908 * @cm_ctx: connection manager context
909 * @cm_id: cm id of connect/disconnect req
910 * @resp: resp to copy bss info like ssid/bssid and freq
911 *
912 * Fill the SSID form the connect req.
913 * Fill freq and bssid from current candidate if available (i.e the connection
914 * has tried to connect to a candidate), else get the bssid from req bssid or
915 * bssid hint which ever is present.
916 *
917 * Return: Success if entry was found else failure
918 */
919 QDF_STATUS
920 cm_fill_bss_info_in_connect_rsp_by_cm_id(struct cnx_mgr *cm_ctx,
921 wlan_cm_id cm_id,
922 struct wlan_cm_connect_resp *resp);
923
924 #if defined(WLAN_SAE_SINGLE_PMK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
925 bool cm_is_cm_id_current_candidate_single_pmk(struct cnx_mgr *cm_ctx,
926 wlan_cm_id cm_id);
927 #else
928 static inline
cm_is_cm_id_current_candidate_single_pmk(struct cnx_mgr * cm_ctx,wlan_cm_id cm_id)929 bool cm_is_cm_id_current_candidate_single_pmk(struct cnx_mgr *cm_ctx,
930 wlan_cm_id cm_id)
931 {
932 return false;
933 }
934 #endif
935
936 /**
937 * cm_remove_cmd_from_serialization() - Remove requests matching cm id
938 * from serialization.
939 * @cm_ctx: connection manager context
940 * @cm_id: cmd id to remove from serialization
941 *
942 * Context: Can be called from any context.
943 *
944 * Return: void
945 */
946 void cm_remove_cmd_from_serialization(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id);
947
948 /**
949 * cm_flush_pending_request() - Flush all pending requests matching flush prefix
950 * @cm_ctx: connection manager context
951 * @prefix: prefix for the type of command to flush
952 * @only_failed_req: flush only the failed pending req
953 *
954 * Context: Can be called from any context.
955 *
956 * Return: void
957 */
958 void cm_flush_pending_request(struct cnx_mgr *cm_ctx, uint32_t prefix,
959 bool only_failed_req);
960
961 /**
962 * cm_remove_cmd() - Remove cmd from req list and serialization
963 * @cm_ctx: connection manager context
964 * @cm_id_to_remove: cm id of connect/disconnect/roam req
965 *
966 * Return: void
967 */
968 void cm_remove_cmd(struct cnx_mgr *cm_ctx, wlan_cm_id *cm_id_to_remove);
969
970 /**
971 * cm_add_req_to_list_and_indicate_osif() - Add the request to request list in
972 * cm ctx and indicate same to osif
973 * @cm_ctx: connection manager context
974 * @cm_req: cm request
975 * @source: source of request
976 *
977 * Context: Can be called from any context.
978 *
979 * Return: QDF_STATUS
980 */
981 QDF_STATUS cm_add_req_to_list_and_indicate_osif(struct cnx_mgr *cm_ctx,
982 struct cm_req *cm_req,
983 enum wlan_cm_source source);
984
985 struct cm_req *cm_get_req_by_cm_id_fl(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id,
986 const char *func, uint32_t line);
987
988 /**
989 * cm_get_req_by_cm_id() - Get cm req matching the cm id
990 * @cm_ctx: connection manager context
991 * @cm_id: cm id of connect/disconnect req
992 *
993 * Context: Can be called from any context and to be used only after posting a
994 * msg to SM (ie holding the SM lock) to avoid use after free. also returned req
995 * should only be used till SM lock is hold.
996 *
997 * Return: cm req from the req list whose cm id matches the argument
998 */
999 #define cm_get_req_by_cm_id(cm_ctx, cm_id) \
1000 cm_get_req_by_cm_id_fl(cm_ctx, cm_id, __func__, __LINE__)
1001
1002 /**
1003 * cm_vdev_scan_cancel() - cancel all scans for vdev
1004 * @pdev: pdev pointer
1005 * @vdev: vdev for which scan to be canceled
1006 *
1007 * Return: void
1008 */
1009 void cm_vdev_scan_cancel(struct wlan_objmgr_pdev *pdev,
1010 struct wlan_objmgr_vdev *vdev);
1011
1012 /**
1013 * cm_fill_disconnect_resp_from_cm_id() - Fill disconnect response
1014 * @cm_ctx: connection manager context
1015 * @cm_id: cm id of connect/disconnect req
1016 * @resp: Disconnect response which needs to filled
1017 *
1018 * This function is called to fill disconnect response from cm id
1019 *
1020 * Context: Any Context.
1021 *
1022 * Return: Success if disconnect
1023 */
1024 QDF_STATUS
1025 cm_fill_disconnect_resp_from_cm_id(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id,
1026 struct wlan_cm_discon_rsp *resp);
1027
1028 /**
1029 * cm_inform_bcn_probe() - update scan db with beacon or probe resp
1030 * @cm_ctx: connection manager context
1031 * @bcn_probe: beacon or probe resp received during connect
1032 * @len: beacon or probe resp length
1033 * @freq: scan frequency in MHz
1034 * @rssi: rssi of the beacon or probe resp
1035 * @cm_id: cm id of connect/disconnect req
1036 *
1037 * update scan db, so that kernel and driver do not age out
1038 * the connected AP entry.
1039 *
1040 * Context: Any Context.
1041 *
1042 * Return: void
1043 */
1044 void cm_inform_bcn_probe(struct cnx_mgr *cm_ctx, uint8_t *bcn_probe,
1045 uint32_t len, qdf_freq_t freq, int32_t rssi,
1046 wlan_cm_id cm_id);
1047
1048 /**
1049 * cm_set_max_connect_attempts() - Set max connect attempts
1050 * @vdev: vdev pointer
1051 * @max_connect_attempts: max connect attempts to be set.
1052 *
1053 * Set max connect attempts. Max value is limited to CM_MAX_CONNECT_ATTEMPTS.
1054 *
1055 * Return: void
1056 */
1057 void cm_set_max_connect_attempts(struct wlan_objmgr_vdev *vdev,
1058 uint8_t max_connect_attempts);
1059
1060 /**
1061 * cm_trigger_panic_on_cmd_timeout() - trigger panic on active command timeout
1062 * @vdev: vdev pointer
1063 * @reason: Hang reason code
1064 *
1065 * Return: void
1066 */
1067 void cm_trigger_panic_on_cmd_timeout(struct wlan_objmgr_vdev *vdev,
1068 enum qdf_hang_reason reason);
1069
1070 /**
1071 * cm_set_max_connect_timeout() - Set max connect timeout
1072 * @vdev: vdev pointer
1073 * @max_connect_timeout: max connect timeout to be set.
1074 *
1075 * Set max connect timeout.
1076 *
1077 * Return: void
1078 */
1079 void cm_set_max_connect_timeout(struct wlan_objmgr_vdev *vdev,
1080 uint32_t max_connect_timeout);
1081
1082 /**
1083 * cm_is_vdev_connecting() - check if vdev is in conneting state
1084 * @vdev: vdev pointer
1085 *
1086 * Return: bool
1087 */
1088 bool cm_is_vdev_connecting(struct wlan_objmgr_vdev *vdev);
1089
1090 /**
1091 * cm_is_vdev_connected() - check if vdev is in conneted state
1092 * @vdev: vdev pointer
1093 *
1094 * Return: bool
1095 */
1096 bool cm_is_vdev_connected(struct wlan_objmgr_vdev *vdev);
1097
1098 /**
1099 * cm_is_vdev_active() - check if vdev is in active state ie conneted or roaming
1100 * state
1101 * @vdev: vdev pointer
1102 *
1103 * Return: bool
1104 */
1105 bool cm_is_vdev_active(struct wlan_objmgr_vdev *vdev);
1106
1107 /**
1108 * cm_is_vdev_disconnecting() - check if vdev is in disconnecting state
1109 * @vdev: vdev pointer
1110 *
1111 * Return: bool
1112 */
1113 bool cm_is_vdev_disconnecting(struct wlan_objmgr_vdev *vdev);
1114
1115 /**
1116 * cm_is_vdev_disconnected() - check if vdev is disconnected/init state
1117 * @vdev: vdev pointer
1118 *
1119 * Return: bool
1120 */
1121 bool cm_is_vdev_disconnected(struct wlan_objmgr_vdev *vdev);
1122
1123 #ifdef CONN_MGR_ADV_FEATURE
1124 /**
1125 * cm_is_vdev_idle_due_to_link_switch() - Check if VDEV is in
1126 * IDLE state due to link switch
1127 * @vdev: VDEV objmgr pointer
1128 *
1129 * Returns true if the current CM SS is WLAN_CM_SS_IDLE_DUE_TO_LINK_SWITCH or
1130 * returns false.
1131 *
1132 * Return: bool
1133 */
1134 bool cm_is_vdev_idle_due_to_link_switch(struct wlan_objmgr_vdev *vdev);
1135 #else
1136 static inline bool
cm_is_vdev_idle_due_to_link_switch(struct wlan_objmgr_vdev * vdev)1137 cm_is_vdev_idle_due_to_link_switch(struct wlan_objmgr_vdev *vdev)
1138 {
1139 return false;
1140 }
1141 #endif
1142
1143 /**
1144 * cm_is_vdev_roaming() - check if vdev is in roaming state
1145 * @vdev: vdev pointer
1146 *
1147 * Return: bool
1148 */
1149 bool cm_is_vdev_roaming(struct wlan_objmgr_vdev *vdev);
1150
1151 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
1152 /**
1153 * cm_is_vdev_roam_started() - check if vdev is in roaming state and
1154 * roam started sub stated
1155 * @vdev: vdev pointer
1156 *
1157 * Return: bool
1158 */
1159 bool cm_is_vdev_roam_started(struct wlan_objmgr_vdev *vdev);
1160
1161 /**
1162 * cm_is_vdev_roam_sync_inprogress() - check if vdev is in roaming state
1163 * and roam sync substate
1164 * @vdev: vdev pointer
1165 *
1166 * Return: bool
1167 */
1168 bool cm_is_vdev_roam_sync_inprogress(struct wlan_objmgr_vdev *vdev);
1169 #endif
1170
1171 #ifdef WLAN_FEATURE_HOST_ROAM
1172 /**
1173 * cm_is_vdev_roam_preauth_state() - check if vdev is in roaming state and
1174 * preauth is in progress
1175 * @vdev: vdev pointer
1176 *
1177 * Return: bool
1178 */
1179 bool cm_is_vdev_roam_preauth_state(struct wlan_objmgr_vdev *vdev);
1180
1181 /**
1182 * cm_is_vdev_roam_reassoc_state() - check if vdev is in roaming state
1183 * and reassoc is in progress
1184 * @vdev: vdev pointer
1185 *
1186 * Return: bool
1187 */
1188 bool cm_is_vdev_roam_reassoc_state(struct wlan_objmgr_vdev *vdev);
1189 #endif
1190
1191 /**
1192 * cm_get_active_req_type() - CM active req type
1193 * @vdev: vdev pointer
1194 *
1195 * Return: CM active req type
1196 */
1197 enum wlan_cm_active_request_type
1198 cm_get_active_req_type(struct wlan_objmgr_vdev *vdev);
1199
1200 /**
1201 * cm_get_active_connect_req() - Get copy of active connect request
1202 * @vdev: vdev pointer
1203 * @req: pointer to the copy of the active connect request
1204 * *
1205 * Context: Should be called only in the context of the
1206 * cm request activation
1207 *
1208 * Return: true and connect req if any request is active
1209 */
1210 bool cm_get_active_connect_req(struct wlan_objmgr_vdev *vdev,
1211 struct wlan_cm_vdev_connect_req *req);
1212
1213 /**
1214 * cm_get_active_disconnect_req() - Get copy of active disconnect request
1215 * @vdev: vdev pointer
1216 * @req: pointer to the copy of the active disconnect request
1217 * *
1218 * Context: Should be called only in the context of the
1219 * cm request activation
1220 *
1221 * Return: true and disconnect req if any request is active
1222 */
1223 bool cm_get_active_disconnect_req(struct wlan_objmgr_vdev *vdev,
1224 struct wlan_cm_vdev_discon_req *req);
1225
1226 /**
1227 * cm_connect_handle_event_post_fail() - initiate connect failure if msg posting
1228 * to SM fails
1229 * @cm_ctx: connection manager context
1230 * @cm_id: cm_id for connect req for which post fails
1231 *
1232 * Context: Can be called from any context and to be used only after posting a
1233 * msg to SM fails from external event e.g. peer create resp,
1234 * HW mode change resp serialization cb.
1235 *
1236 * Return: QDF_STATUS
1237 */
1238 void
1239 cm_connect_handle_event_post_fail(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id);
1240
1241 /**
1242 * cm_get_req_by_scan_id() - Get cm req matching the scan id
1243 * @cm_ctx: connection manager context
1244 * @scan_id: scan id of scan req
1245 *
1246 * Context: Can be called from any context and to be used only after posting a
1247 * msg to SM (ie holding the SM lock) to avoid use after free. also returned req
1248 * should only be used till SM lock is hold.
1249 *
1250 * Return: cm req from the req list whose scan id matches the argument
1251 */
1252 struct cm_req *cm_get_req_by_scan_id(struct cnx_mgr *cm_ctx,
1253 wlan_scan_id scan_id);
1254
1255 #ifdef WLAN_FEATURE_11BE_MLO
1256 /**
1257 * cm_connect_resp_fill_mld_addr_from_candidate() - API to fill MLD
1258 * address in connect resp from scan entry.
1259 * @vdev: VDEV objmgr pointer.
1260 * @entry: Scan entry.
1261 * @resp: connect response pointer.
1262 *
1263 * If the MLO VDEV flag is set, get the MLD address from the scan
1264 * entry and fill in MLD address field in @resp.
1265 *
1266 * Return: void
1267 */
1268 void
1269 cm_connect_resp_fill_mld_addr_from_candidate(struct wlan_objmgr_vdev *vdev,
1270 struct scan_cache_entry *entry,
1271 struct wlan_cm_connect_resp *resp);
1272 /**
1273 * cm_connect_resp_fill_mld_addr_from_cm_id() - API to fill MLD address
1274 * in connect resp from connect request ID.
1275 * @vdev: VDEV objmgr pointer.
1276 * @cm_id: connect request ID.
1277 * @rsp: connect resp pointer.
1278 *
1279 * The API gets scan entry from the connect request using the connect request
1280 * ID and fills MLD address from the scan entry into the connect response.
1281 *
1282 * Return: void
1283 */
1284 void
1285 cm_connect_resp_fill_mld_addr_from_cm_id(struct wlan_objmgr_vdev *vdev,
1286 wlan_cm_id cm_id,
1287 struct wlan_cm_connect_resp *rsp);
1288
1289 static inline void
cm_connect_rsp_get_mld_addr_or_bssid(struct wlan_cm_connect_resp * resp,struct qdf_mac_addr * bssid)1290 cm_connect_rsp_get_mld_addr_or_bssid(struct wlan_cm_connect_resp *resp,
1291 struct qdf_mac_addr *bssid)
1292 {
1293 if (!qdf_is_macaddr_zero(&resp->mld_addr))
1294 qdf_copy_macaddr(bssid, &resp->mld_addr);
1295 else
1296 qdf_copy_macaddr(bssid, &resp->bssid);
1297 }
1298 #else
1299 static inline void
cm_connect_resp_fill_mld_addr_from_candidate(struct wlan_objmgr_vdev * vdev,struct scan_cache_entry * entry,struct wlan_cm_connect_resp * resp)1300 cm_connect_resp_fill_mld_addr_from_candidate(struct wlan_objmgr_vdev *vdev,
1301 struct scan_cache_entry *entry,
1302 struct wlan_cm_connect_resp *resp)
1303 {
1304 }
1305
1306 static inline void
cm_connect_resp_fill_mld_addr_from_cm_id(struct wlan_objmgr_vdev * vdev,wlan_cm_id cm_id,struct wlan_cm_connect_resp * rsp)1307 cm_connect_resp_fill_mld_addr_from_cm_id(struct wlan_objmgr_vdev *vdev,
1308 wlan_cm_id cm_id,
1309 struct wlan_cm_connect_resp *rsp)
1310 {
1311 }
1312
1313 static inline void
cm_connect_rsp_get_mld_addr_or_bssid(struct wlan_cm_connect_resp * resp,struct qdf_mac_addr * bssid)1314 cm_connect_rsp_get_mld_addr_or_bssid(struct wlan_cm_connect_resp *resp,
1315 struct qdf_mac_addr *bssid)
1316 {
1317 qdf_copy_macaddr(bssid, &resp->bssid);
1318 }
1319 #endif
1320
1321 #ifdef WLAN_FEATURE_11BE_MLO_ADV_FEATURE
1322 /**
1323 * cm_standby_link_update_mlme_by_bssid() - update the scan mlme info for
1324 * standby_link
1325 * @vdev: Object manager vdev
1326 * @assoc_state: association state
1327 * @ssid: SSID of the connection
1328 *
1329 * Return: void
1330 */
1331 void cm_standby_link_update_mlme_by_bssid(struct wlan_objmgr_vdev *vdev,
1332 uint32_t assoc_state,
1333 struct wlan_ssid ssid);
1334 #else
1335 static inline void
cm_standby_link_update_mlme_by_bssid(struct wlan_objmgr_vdev * vdev,uint32_t assoc_state,struct wlan_ssid ssid)1336 cm_standby_link_update_mlme_by_bssid(struct wlan_objmgr_vdev *vdev,
1337 uint32_t assoc_state,
1338 struct wlan_ssid ssid)
1339 {
1340 }
1341 #endif
1342
1343 /**
1344 * cm_get_cm_id_by_scan_id() - Get cm id by matching the scan id
1345 * @cm_ctx: connection manager context
1346 * @scan_id: scan id of scan req
1347 *
1348 * Context: Can be called from any context and used to get cm_id
1349 * from scan id when SM lock is not held
1350 *
1351 * Return: cm id from the req list whose scan id matches the argument
1352 */
1353 wlan_cm_id cm_get_cm_id_by_scan_id(struct cnx_mgr *cm_ctx,
1354 wlan_scan_id scan_id);
1355
1356 /**
1357 * cm_update_scan_mlme_on_disconnect() - update the scan mlme info
1358 * on disconnect completion
1359 * @vdev: Object manager vdev
1360 * @req: Disconnect request
1361 *
1362 * Return: void
1363 */
1364 void
1365 cm_update_scan_mlme_on_disconnect(struct wlan_objmgr_vdev *vdev,
1366 struct cm_disconnect_req *req);
1367
1368 /**
1369 * cm_calculate_scores() - Score the candidates obtained from scan
1370 * manager after filtering
1371 * @cm_ctx: Connection manager context
1372 * @pdev: Object manager pdev
1373 * @filter: Scan filter params
1374 * @list: List of candidates to be scored
1375 *
1376 * Return: void
1377 */
1378 void cm_calculate_scores(struct cnx_mgr *cm_ctx,
1379 struct wlan_objmgr_pdev *pdev,
1380 struct scan_filter *filter, qdf_list_t *list);
1381
1382 /**
1383 * cm_req_lock_acquire() - Acquire connection manager request lock
1384 * @cm_ctx: Connection manager context
1385 *
1386 * Return: void
1387 */
1388 void cm_req_lock_acquire(struct cnx_mgr *cm_ctx);
1389
1390 /**
1391 * cm_req_lock_release() - Release connection manager request lock
1392 * @cm_ctx: Connection manager context
1393 *
1394 * Return: void
1395 */
1396 void cm_req_lock_release(struct cnx_mgr *cm_ctx);
1397
1398 #ifdef SM_ENG_HIST_ENABLE
1399 /**
1400 * cm_req_history_add() - Save request history
1401 * @cm_ctx: Connection manager context
1402 * @cm_req: Connection manager request
1403 *
1404 * Return: void
1405 */
1406 void cm_req_history_add(struct cnx_mgr *cm_ctx,
1407 struct cm_req *cm_req);
1408 /**
1409 * cm_req_history_del() - Update history on request deletion
1410 * @cm_ctx: Connection manager context
1411 * @cm_req: Connection manager request
1412 * @del_type: Context in which the request is deleted
1413 *
1414 * Return: void
1415 */
1416 void cm_req_history_del(struct cnx_mgr *cm_ctx,
1417 struct cm_req *cm_req,
1418 enum cm_req_del_type del_type);
1419
1420 /**
1421 * cm_req_history_init() - Initialize the history data struct
1422 * @cm_ctx: Connection manager context
1423 *
1424 * Return: void
1425 */
1426 void cm_req_history_init(struct cnx_mgr *cm_ctx);
1427
1428 /**
1429 * cm_req_history_deinit() - Deinitialize the history data struct
1430 * @cm_ctx: Connection manager context
1431 *
1432 * Return: void
1433 */
1434 void cm_req_history_deinit(struct cnx_mgr *cm_ctx);
1435
1436 /**
1437 * cm_req_history_print() - Print the history data struct
1438 * @cm_ctx: Connection manager context
1439 *
1440 * Return: void
1441 */
1442 void cm_req_history_print(struct cnx_mgr *cm_ctx);
1443 extern struct wlan_sm_state_info cm_sm_info[];
1444 #else
1445 static inline
cm_req_history_add(struct cnx_mgr * cm_ctx,struct cm_req * cm_req)1446 void cm_req_history_add(struct cnx_mgr *cm_ctx,
1447 struct cm_req *cm_req)
1448 {}
1449
1450 static inline
cm_req_history_del(struct cnx_mgr * cm_ctx,struct cm_req * cm_req,enum cm_req_del_type del_type)1451 void cm_req_history_del(struct cnx_mgr *cm_ctx,
1452 struct cm_req *cm_req,
1453 enum cm_req_del_type del_type)
1454 {}
1455
cm_req_history_init(struct cnx_mgr * cm_ctx)1456 static inline void cm_req_history_init(struct cnx_mgr *cm_ctx)
1457 {}
1458
cm_req_history_deinit(struct cnx_mgr * cm_ctx)1459 static inline void cm_req_history_deinit(struct cnx_mgr *cm_ctx)
1460 {}
1461
cm_req_history_print(struct cnx_mgr * cm_ctx)1462 static inline void cm_req_history_print(struct cnx_mgr *cm_ctx)
1463 {}
1464 #endif
1465
1466 #ifdef WLAN_CM_USE_SPINLOCK
1467 /**
1468 * cm_activate_cmd_req_flush_cb() - Callback when the scheduler msg is flushed
1469 * @msg: scheduler message
1470 *
1471 * Return: QDF_STATUS
1472 */
1473 QDF_STATUS cm_activate_cmd_req_flush_cb(struct scheduler_msg *msg);
1474 #endif
1475
1476 #ifndef CONN_MGR_ADV_FEATURE
1477 /**
1478 * cm_set_candidate_advance_filter_cb() - Set CM candidate advance
1479 * filter cb
1480 * @vdev: Objmgr vdev
1481 * @filter_fun: CM candidate advance filter cb
1482 *
1483 * Return: void
1484 */
1485 void cm_set_candidate_advance_filter_cb(
1486 struct wlan_objmgr_vdev *vdev,
1487 void (*filter_fun)(struct wlan_objmgr_vdev *vdev,
1488 struct scan_filter *filter));
1489
1490 /**
1491 * cm_set_candidate_custom_sort_cb() - Set CM candidate custom sort cb
1492 * @vdev: Objmgr vdev
1493 * @sort_fun: CM candidate custom sort cb
1494 *
1495 * Return: void
1496 */
1497 void cm_set_candidate_custom_sort_cb(
1498 struct wlan_objmgr_vdev *vdev,
1499 void (*sort_fun)(struct wlan_objmgr_vdev *vdev,
1500 qdf_list_t *list));
1501
1502 #endif
1503
1504 /**
1505 * cm_is_connect_req_reassoc() - Is connect req for reassoc
1506 * @req: connect req
1507 *
1508 * Return: void
1509 */
1510 bool cm_is_connect_req_reassoc(struct wlan_cm_connect_req *req);
1511
1512 /**
1513 * cm_is_first_candidate_connect_attempt() - Is it a first attempt to
1514 * connect to a candidate after receiving connect request
1515 * @vdev: vdev pointer
1516 *
1517 * Return: True if it is the first connect attempt to a candidate
1518 * after receiving the connect request from the userspace
1519 */
1520 bool cm_is_first_candidate_connect_attempt(struct wlan_objmgr_vdev *vdev);
1521
1522 /**
1523 * cm_get_active_connect_req_param() - Get Connect request parameter
1524 * @vdev: vdev pointer
1525 * @req: Connection request buffer to be filled
1526 *
1527 * Return: QDF_STATUS
1528 */
1529 QDF_STATUS
1530 cm_get_active_connect_req_param(struct wlan_objmgr_vdev *vdev,
1531 struct wlan_cm_connect_req *req);
1532
1533 /**
1534 * cm_get_rnr() - get rnr
1535 * @vdev:vdev
1536 * @cm_id: connect mgr id
1537 * @rnr: pointer to copy rnr info
1538 *
1539 * Return: QDF_STATUS
1540 */
1541 QDF_STATUS cm_get_rnr(struct wlan_objmgr_vdev *vdev, wlan_cm_id cm_id,
1542 struct reduced_neighbor_report *rnr);
1543
1544 /**
1545 * cm_get_curr_candidate_entry() - Get the current candidate from cnx mgr
1546 * @vdev: VDEV object manager.
1547 * @cm_id: cnx mgr ID.
1548 *
1549 * Get current entry of connection from the cnx mgr list.
1550 * Caller to free the returned scan entry if not NULL.
1551 *
1552 * Return: Scan entry
1553 */
1554 struct scan_cache_entry *
1555 cm_get_curr_candidate_entry(struct wlan_objmgr_vdev *vdev, wlan_cm_id cm_id);
1556
1557 /**
1558 * cm_free_connect_rsp_ies() - Function to free all connection IEs.
1559 * @connect_rsp: pointer to connect rsp
1560 *
1561 * Function to free up all the IE in connect response structure.
1562 *
1563 * Return: void
1564 */
1565 void cm_free_connect_rsp_ies(struct wlan_cm_connect_resp *connect_rsp);
1566
1567 /**
1568 * cm_free_connect_req() - Function to free up connect request and its sub memory.
1569 * @connect_req: pointer to connect req
1570 *
1571 * Function to free up connect request and its sub memory.
1572 *
1573 * Return: void
1574 */
1575 void cm_free_connect_req(struct wlan_cm_connect_req *connect_req);
1576
1577 /**
1578 * cm_free_connect_rsp() - Function to free up connect response and its sub memory.
1579 * @connect_rsp: pointer to connect rsp
1580 *
1581 * Function to free up connect response and its sub memory.
1582 *
1583 * Return: void
1584 */
1585 void cm_free_connect_rsp(struct wlan_cm_connect_resp *connect_rsp);
1586
1587 /**
1588 * cm_free_connect_req_param() - Function to free up connect request sub memory.
1589 * @req: pointer to connect req
1590 *
1591 * Function to free up connect request sub memory parameters.
1592 *
1593 * Return: void
1594 */
1595 void cm_free_connect_req_param(struct wlan_cm_connect_req *req);
1596
1597 /**
1598 * cm_free_wep_key_params() - Function to free up connect request wep key params
1599 * sub memory
1600 * @req: pointer to connect req
1601 *
1602 * Function to free up connect request wep key params sub memory.
1603 *
1604 * Return: void
1605 */
1606 void cm_free_wep_key_params(struct wlan_cm_connect_req *req);
1607
1608 #ifdef CONN_MGR_ADV_FEATURE
1609 /**
1610 * cm_store_first_candidate_rsp() - store the connection failure response
1611 * @cm_ctx: connection manager context
1612 * @cm_id: cm_id for connect response to be filled
1613 * @resp: first connect failure response
1614 *
1615 * This API would be called when candidate fails to connect. It will cache the
1616 * first connect failure response in connect req structure.
1617 *
1618 * Return: void
1619 */
1620 void cm_store_first_candidate_rsp(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id,
1621 struct wlan_cm_connect_resp *resp);
1622
1623 /**
1624 * cm_get_first_candidate_rsp() - fetch first candidate response
1625 * @cm_ctx: connection manager context
1626 * @cm_id: cm_id for connect response to be filled
1627 * @first_candid_rsp: first connect failure response
1628 *
1629 * This API would be called when last candidate is failed to connect. It will
1630 * fetch the first candidate failure response which was cached in connect
1631 * request structure.
1632 *
1633 * Return: QDF_STATUS_SUCCESS when rsp is fetch successfully
1634 */
1635 QDF_STATUS
1636 cm_get_first_candidate_rsp(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id,
1637 struct wlan_cm_connect_resp *first_candid_rsp);
1638
1639 /**
1640 * cm_store_n_send_failed_candidate() - stored failed connect response and sent
1641 * it to osif.
1642 * @cm_ctx: connection manager context
1643 * @cm_id: connection manager id
1644 *
1645 * This API will stored failed connect response in connect request structure
1646 * and sent it to osif layer.
1647 *
1648 * Return: void
1649 */
1650 void cm_store_n_send_failed_candidate(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id);
1651 #else
1652 static inline
cm_store_first_candidate_rsp(struct cnx_mgr * cm_ctx,wlan_cm_id cm_id,struct wlan_cm_connect_resp * resp)1653 void cm_store_first_candidate_rsp(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id,
1654 struct wlan_cm_connect_resp *resp)
1655 {
1656 }
1657
1658 static inline
cm_store_n_send_failed_candidate(struct cnx_mgr * cm_ctx,wlan_cm_id cm_id)1659 void cm_store_n_send_failed_candidate(struct cnx_mgr *cm_ctx, wlan_cm_id cm_id)
1660 {
1661 }
1662 #endif /* CONN_MGR_ADV_FEATURE */
1663
1664 #ifdef WLAN_FEATURE_11BE_MLO
1665 /**
1666 * cm_bss_mlo_type() - Check if the scan entry is of MLO type
1667 * @psoc: Pointer to psoc
1668 * @entry: scan cache entry
1669 * @scan_list: list of scan entries to look for if @entry is of ML type
1670 *
1671 * Return: MLO AP type: SLO, MLMR or EMLSR.
1672 */
1673 enum MLO_TYPE cm_bss_mlo_type(struct wlan_objmgr_psoc *psoc,
1674 struct scan_cache_entry *entry,
1675 qdf_list_t *scan_list);
1676 #else
1677 static inline enum MLO_TYPE
cm_bss_mlo_type(struct wlan_objmgr_psoc * psoc,struct scan_cache_entry * entry,qdf_list_t * scan_list)1678 cm_bss_mlo_type(struct wlan_objmgr_psoc *psoc,
1679 struct scan_cache_entry *entry,
1680 qdf_list_t *scan_list)
1681 {
1682 return SLO;
1683 }
1684 #endif
1685
1686 #ifdef WLAN_FEATURE_LL_LT_SAP
1687 /**
1688 * cm_bearer_switch_resp() - Bearer switch response
1689 * @psoc: Psoc pointer
1690 * @vdev_id: vdev id
1691 * @cm_id: connection ID which gave the hw mode change request
1692 * @status: status of the bearer switch
1693 *
1694 * Return: void
1695 */
1696 void cm_bearer_switch_resp(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id,
1697 wlan_cm_id cm_id, QDF_STATUS status);
1698 #endif
1699 #ifdef WLAN_CHIPSET_STATS
1700 /**
1701 * cm_cp_stats_cstats_log_connecting_event : Chipset stats connecting event
1702 * @vdev: pointer to vdev object
1703 * @req: pointer to wlan_cm_vdev_connect_req object
1704 * @cm_req: pointer to cm_req object
1705 *
1706 * Return: void
1707 */
1708 void
1709 cm_cp_stats_cstats_log_connecting_event(struct wlan_objmgr_vdev *vdev,
1710 struct wlan_cm_vdev_connect_req *req,
1711 struct cm_req *cm_req);
1712 #else
1713 static inline void
cm_cp_stats_cstats_log_connecting_event(struct wlan_objmgr_vdev * vdev,struct wlan_cm_vdev_connect_req * req,struct cm_req * cm_req)1714 cm_cp_stats_cstats_log_connecting_event(struct wlan_objmgr_vdev *vdev,
1715 struct wlan_cm_vdev_connect_req *req,
1716 struct cm_req *cm_req)
1717 {
1718 }
1719 #endif /* WLAN_CHIPSET_STATS */
1720 #endif /* __WLAN_CM_MAIN_API_H__ */
1721