1 /*
2  * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-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: Implements MLME global APIs
20  */
21 
22 #include <wlan_objmgr_cmn.h>
23 #include <include/wlan_mlme_cmn.h>
24 #include <include/wlan_pdev_mlme.h>
25 #include <include/wlan_vdev_mlme.h>
26 #include <include/wlan_mlme_cmn.h>
27 #include <wlan_psoc_mlme_main.h>
28 #include <wlan_pdev_mlme_main.h>
29 #include <wlan_vdev_mlme_main.h>
30 #include <wlan_psoc_mlme_api.h>
31 
32 struct mlme_ext_ops *glbl_ops;
33 mlme_get_global_ops_cb glbl_ops_cb;
34 
35 struct mlme_cm_ops *glbl_cm_ops;
36 osif_cm_get_global_ops_cb glbl_cm_ops_cb;
37 
38 struct mlme_twt_ops *glbl_twt_ops;
39 osif_twt_get_global_ops_cb glbl_twt_ops_cb;
40 
mlme_cm_ops_init(void)41 static void mlme_cm_ops_init(void)
42 {
43 	if (glbl_cm_ops_cb)
44 		glbl_cm_ops = glbl_cm_ops_cb();
45 }
46 
mlme_cm_ops_deinit(void)47 static void mlme_cm_ops_deinit(void)
48 {
49 	if (glbl_cm_ops_cb)
50 		glbl_cm_ops = NULL;
51 }
52 
53 struct mlme_vdev_mgr_ops *glbl_vdev_mgr_ops;
54 osif_vdev_mgr_get_global_ops_cb glbl_vdev_mgr_ops_cb;
55 
mlme_vdev_mgr_ops_init(void)56 static void mlme_vdev_mgr_ops_init(void)
57 {
58 	if (glbl_vdev_mgr_ops_cb)
59 		glbl_vdev_mgr_ops = glbl_vdev_mgr_ops_cb();
60 }
61 
mlme_vdev_mgr_ops_deinit(void)62 static void mlme_vdev_mgr_ops_deinit(void)
63 {
64 	if (glbl_vdev_mgr_ops_cb)
65 		glbl_vdev_mgr_ops = NULL;
66 }
67 
mlme_twt_ops_init(void)68 static void mlme_twt_ops_init(void)
69 {
70 	if (glbl_twt_ops_cb)
71 		glbl_twt_ops = glbl_twt_ops_cb();
72 }
73 
mlme_twt_ops_deinit(void)74 static void mlme_twt_ops_deinit(void)
75 {
76 	if (glbl_twt_ops_cb)
77 		glbl_twt_ops = NULL;
78 }
79 
wlan_cmn_mlme_init(void)80 QDF_STATUS wlan_cmn_mlme_init(void)
81 {
82 	QDF_STATUS status;
83 
84 	status = wlan_psoc_mlme_init();
85 	if (status != QDF_STATUS_SUCCESS)
86 		return status;
87 
88 	status = wlan_pdev_mlme_init();
89 	if (status != QDF_STATUS_SUCCESS)
90 		return status;
91 
92 	status = wlan_vdev_mlme_init();
93 	if (status != QDF_STATUS_SUCCESS)
94 		return status;
95 
96 	if (glbl_ops_cb)
97 		glbl_ops = glbl_ops_cb();
98 
99 	mlme_cm_ops_init();
100 
101 	mlme_vdev_mgr_ops_init();
102 
103 	mlme_twt_ops_init();
104 
105 	return QDF_STATUS_SUCCESS;
106 }
107 
wlan_cmn_mlme_deinit(void)108 QDF_STATUS wlan_cmn_mlme_deinit(void)
109 {
110 	QDF_STATUS status;
111 
112 	mlme_twt_ops_deinit();
113 
114 	mlme_vdev_mgr_ops_deinit();
115 
116 	mlme_cm_ops_deinit();
117 
118 	status = wlan_vdev_mlme_deinit();
119 	if (status != QDF_STATUS_SUCCESS)
120 		return status;
121 
122 	status = wlan_pdev_mlme_deinit();
123 	if (status != QDF_STATUS_SUCCESS)
124 		return status;
125 
126 	status = wlan_psoc_mlme_deinit();
127 	if (status != QDF_STATUS_SUCCESS)
128 		return status;
129 
130 	return QDF_STATUS_SUCCESS;
131 }
132 
mlme_psoc_ops_ext_hdl_create(struct psoc_mlme_obj * psoc_mlme)133 QDF_STATUS mlme_psoc_ops_ext_hdl_create(struct psoc_mlme_obj *psoc_mlme)
134 {
135 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
136 
137 	if (glbl_ops && glbl_ops->mlme_psoc_ext_hdl_create)
138 		ret = glbl_ops->mlme_psoc_ext_hdl_create(psoc_mlme);
139 
140 	return ret;
141 }
142 
mlme_psoc_ext_enable_cb(struct wlan_objmgr_psoc * psoc)143 QDF_STATUS mlme_psoc_ext_enable_cb(struct wlan_objmgr_psoc *psoc)
144 {
145 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
146 
147 	if (glbl_ops && glbl_ops->mlme_psoc_ext_hdl_enable)
148 		ret = glbl_ops->mlme_psoc_ext_hdl_enable(psoc);
149 
150 	return ret;
151 }
152 
mlme_psoc_ext_disable_cb(struct wlan_objmgr_psoc * psoc)153 QDF_STATUS mlme_psoc_ext_disable_cb(struct wlan_objmgr_psoc *psoc)
154 {
155 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
156 
157 	if (glbl_ops && glbl_ops->mlme_psoc_ext_hdl_disable)
158 		ret = glbl_ops->mlme_psoc_ext_hdl_disable(psoc);
159 
160 	return ret;
161 }
162 
mlme_psoc_ops_ext_hdl_destroy(struct psoc_mlme_obj * psoc_mlme)163 QDF_STATUS mlme_psoc_ops_ext_hdl_destroy(struct psoc_mlme_obj *psoc_mlme)
164 {
165 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
166 
167 	if (glbl_ops && glbl_ops->mlme_psoc_ext_hdl_destroy)
168 		ret = glbl_ops->mlme_psoc_ext_hdl_destroy(psoc_mlme);
169 
170 	return ret;
171 }
172 
mlme_pdev_ops_ext_hdl_create(struct pdev_mlme_obj * pdev_mlme)173 QDF_STATUS mlme_pdev_ops_ext_hdl_create(struct pdev_mlme_obj *pdev_mlme)
174 {
175 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
176 
177 	if (glbl_ops && glbl_ops->mlme_pdev_ext_hdl_create)
178 		ret = glbl_ops->mlme_pdev_ext_hdl_create(pdev_mlme);
179 
180 	return ret;
181 }
182 
mlme_pdev_ops_ext_hdl_destroy(struct pdev_mlme_obj * pdev_mlme)183 QDF_STATUS mlme_pdev_ops_ext_hdl_destroy(struct pdev_mlme_obj *pdev_mlme)
184 {
185 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
186 
187 	if (glbl_ops && glbl_ops->mlme_pdev_ext_hdl_destroy)
188 		ret = glbl_ops->mlme_pdev_ext_hdl_destroy(pdev_mlme);
189 
190 	return ret;
191 }
192 
mlme_vdev_ops_ext_hdl_create(struct vdev_mlme_obj * vdev_mlme)193 QDF_STATUS mlme_vdev_ops_ext_hdl_create(struct vdev_mlme_obj *vdev_mlme)
194 {
195 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
196 
197 	if (glbl_ops && glbl_ops->mlme_vdev_ext_hdl_create)
198 		ret = glbl_ops->mlme_vdev_ext_hdl_create(vdev_mlme);
199 
200 	return ret;
201 }
202 
mlme_vdev_ops_ext_hdl_post_create(struct vdev_mlme_obj * vdev_mlme)203 QDF_STATUS mlme_vdev_ops_ext_hdl_post_create(struct vdev_mlme_obj *vdev_mlme)
204 {
205 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
206 
207 	if (glbl_ops && glbl_ops->mlme_vdev_ext_hdl_post_create)
208 		ret = glbl_ops->mlme_vdev_ext_hdl_post_create(vdev_mlme);
209 
210 	return ret;
211 }
212 
mlme_vdev_ops_ext_hdl_destroy(struct vdev_mlme_obj * vdev_mlme)213 QDF_STATUS mlme_vdev_ops_ext_hdl_destroy(struct vdev_mlme_obj *vdev_mlme)
214 {
215 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
216 
217 	if (glbl_ops && glbl_ops->mlme_vdev_ext_hdl_destroy)
218 		ret = glbl_ops->mlme_vdev_ext_hdl_destroy(vdev_mlme);
219 
220 	return ret;
221 }
222 
mlme_vdev_ops_start_fw_send(struct wlan_objmgr_vdev * vdev,uint8_t restart)223 QDF_STATUS mlme_vdev_ops_start_fw_send(struct wlan_objmgr_vdev *vdev,
224 				       uint8_t restart)
225 {
226 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
227 
228 	if (glbl_ops && glbl_ops->mlme_vdev_start_fw_send)
229 		ret = glbl_ops->mlme_vdev_start_fw_send(vdev, restart);
230 
231 	return ret;
232 }
233 
mlme_vdev_ops_multivdev_restart_fw_cmd_send(struct wlan_objmgr_pdev * pdev)234 QDF_STATUS mlme_vdev_ops_multivdev_restart_fw_cmd_send(
235 						struct wlan_objmgr_pdev *pdev)
236 {
237 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
238 
239 	if (glbl_ops && glbl_ops->mlme_multivdev_restart_fw_send)
240 		ret = glbl_ops->mlme_multivdev_restart_fw_send(pdev);
241 
242 	return ret;
243 }
244 
mlme_vdev_ops_stop_fw_send(struct wlan_objmgr_vdev * vdev)245 QDF_STATUS mlme_vdev_ops_stop_fw_send(struct wlan_objmgr_vdev *vdev)
246 {
247 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
248 
249 	if (glbl_ops && glbl_ops->mlme_vdev_stop_fw_send)
250 		ret = glbl_ops->mlme_vdev_stop_fw_send(vdev);
251 
252 	return ret;
253 }
254 
mlme_vdev_ops_down_fw_send(struct wlan_objmgr_vdev * vdev)255 QDF_STATUS mlme_vdev_ops_down_fw_send(struct wlan_objmgr_vdev *vdev)
256 {
257 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
258 
259 	if (glbl_ops && glbl_ops->mlme_vdev_down_fw_send)
260 		ret = glbl_ops->mlme_vdev_down_fw_send(vdev);
261 
262 	return ret;
263 }
264 
mlme_vdev_enqueue_exp_ser_cmd(struct vdev_mlme_obj * vdev_mlme,uint8_t cmd_type)265 QDF_STATUS mlme_vdev_enqueue_exp_ser_cmd(struct vdev_mlme_obj *vdev_mlme,
266 					 uint8_t cmd_type)
267 {
268 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
269 
270 	if (glbl_ops && glbl_ops->mlme_vdev_enqueue_exp_cmd)
271 		ret = glbl_ops->mlme_vdev_enqueue_exp_cmd(vdev_mlme, cmd_type);
272 
273 	return ret;
274 }
275 
mlme_vdev_ops_ext_hdl_delete_rsp(struct wlan_objmgr_psoc * psoc,struct vdev_delete_response * rsp)276 QDF_STATUS mlme_vdev_ops_ext_hdl_delete_rsp(struct wlan_objmgr_psoc *psoc,
277 					    struct vdev_delete_response *rsp)
278 {
279 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
280 
281 	if ((glbl_ops) && glbl_ops->mlme_vdev_ext_delete_rsp)
282 		ret = glbl_ops->mlme_vdev_ext_delete_rsp(psoc, rsp);
283 
284 	return ret;
285 }
286 
mlme_vdev_ops_ext_hdl_multivdev_restart_resp(struct wlan_objmgr_psoc * psoc,struct multi_vdev_restart_resp * resp)287 QDF_STATUS mlme_vdev_ops_ext_hdl_multivdev_restart_resp(
288 					struct wlan_objmgr_psoc *psoc,
289 					struct multi_vdev_restart_resp *resp)
290 {
291 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
292 
293 	if ((glbl_ops) && glbl_ops->mlme_multi_vdev_restart_resp)
294 		ret = glbl_ops->mlme_multi_vdev_restart_resp(psoc, resp);
295 
296 	return ret;
297 }
298 
mlme_cm_ext_hdl_create(struct wlan_objmgr_vdev * vdev,cm_ext_t ** ext_cm_ptr)299 QDF_STATUS mlme_cm_ext_hdl_create(struct wlan_objmgr_vdev *vdev,
300 				  cm_ext_t **ext_cm_ptr)
301 {
302 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
303 
304 	if (glbl_ops && glbl_ops->mlme_cm_ext_hdl_create_cb)
305 		ret = glbl_ops->mlme_cm_ext_hdl_create_cb(vdev, ext_cm_ptr);
306 
307 	return ret;
308 }
309 
mlme_cm_ext_hdl_destroy(struct wlan_objmgr_vdev * vdev,cm_ext_t * ext_cm_ptr)310 QDF_STATUS mlme_cm_ext_hdl_destroy(struct wlan_objmgr_vdev *vdev,
311 				   cm_ext_t *ext_cm_ptr)
312 {
313 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
314 
315 	if (glbl_ops && glbl_ops->mlme_cm_ext_hdl_destroy_cb)
316 		ret = glbl_ops->mlme_cm_ext_hdl_destroy_cb(vdev, ext_cm_ptr);
317 
318 	return ret;
319 }
320 
mlme_cm_connect_start_ind(struct wlan_objmgr_vdev * vdev,struct wlan_cm_connect_req * req)321 QDF_STATUS mlme_cm_connect_start_ind(struct wlan_objmgr_vdev *vdev,
322 				     struct wlan_cm_connect_req *req)
323 {
324 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
325 
326 	if ((glbl_ops) && glbl_ops->mlme_cm_ext_connect_start_ind_cb)
327 		ret = glbl_ops->mlme_cm_ext_connect_start_ind_cb(vdev, req);
328 
329 	return ret;
330 }
331 
mlme_ext_hdl_get_acs_in_progress(struct wlan_objmgr_vdev * vdev,bool * acs_in_progress)332 QDF_STATUS mlme_ext_hdl_get_acs_in_progress(struct wlan_objmgr_vdev *vdev,
333 					    bool *acs_in_progress)
334 {
335 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
336 
337 	if ((glbl_ops) && glbl_ops->mlme_ext_get_acs_inprogress)
338 		ret = glbl_ops->mlme_ext_get_acs_inprogress(vdev,
339 							    acs_in_progress);
340 
341 	return ret;
342 }
343 
mlme_cm_bss_select_ind(struct wlan_objmgr_vdev * vdev,struct wlan_cm_vdev_connect_req * req)344 QDF_STATUS mlme_cm_bss_select_ind(struct wlan_objmgr_vdev *vdev,
345 				  struct wlan_cm_vdev_connect_req *req)
346 {
347 	QDF_STATUS ret = QDF_STATUS_E_NOSUPPORT;
348 
349 	if ((glbl_ops) && glbl_ops->mlme_cm_ext_bss_select_ind_cb)
350 		ret = glbl_ops->mlme_cm_ext_bss_select_ind_cb(vdev, req);
351 
352 	return ret;
353 }
354 
mlme_cm_bss_peer_create_req(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr * peer_mac,struct qdf_mac_addr * mld_mac,bool is_assoc_link)355 QDF_STATUS mlme_cm_bss_peer_create_req(struct wlan_objmgr_vdev *vdev,
356 				       struct qdf_mac_addr *peer_mac,
357 				       struct qdf_mac_addr *mld_mac,
358 				       bool is_assoc_link)
359 {
360 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
361 
362 	if ((glbl_ops) && glbl_ops->mlme_cm_ext_bss_peer_create_req_cb)
363 		ret = glbl_ops->mlme_cm_ext_bss_peer_create_req_cb(
364 				vdev, peer_mac, mld_mac, is_assoc_link);
365 
366 	return ret;
367 }
368 
mlme_cm_connect_req(struct wlan_objmgr_vdev * vdev,struct wlan_cm_vdev_connect_req * req)369 QDF_STATUS mlme_cm_connect_req(struct wlan_objmgr_vdev *vdev,
370 			       struct wlan_cm_vdev_connect_req *req)
371 {
372 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
373 
374 	if ((glbl_ops) && glbl_ops->mlme_cm_ext_connect_req_cb)
375 		ret = glbl_ops->mlme_cm_ext_connect_req_cb(vdev, req);
376 
377 	return ret;
378 }
379 
mlme_cm_roam_start_ind(struct wlan_objmgr_vdev * vdev,struct wlan_cm_roam_req * req)380 QDF_STATUS mlme_cm_roam_start_ind(struct wlan_objmgr_vdev *vdev,
381 				  struct wlan_cm_roam_req *req)
382 {
383 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
384 
385 	if ((glbl_ops) && glbl_ops->mlme_cm_ext_roam_start_ind_cb)
386 		ret = glbl_ops->mlme_cm_ext_roam_start_ind_cb(vdev, req);
387 
388 	return ret;
389 }
390 
mlme_cm_rso_stop_req(struct wlan_objmgr_vdev * vdev)391 QDF_STATUS mlme_cm_rso_stop_req(struct wlan_objmgr_vdev *vdev)
392 {
393 	QDF_STATUS ret = QDF_STATUS_E_NOSUPPORT;
394 
395 	if ((glbl_ops) && glbl_ops->mlme_cm_ext_rso_stop_cb)
396 		ret = glbl_ops->mlme_cm_ext_rso_stop_cb(vdev);
397 
398 	return ret;
399 }
400 
mlme_cm_reassoc_req(struct wlan_objmgr_vdev * vdev,struct wlan_cm_vdev_reassoc_req * req)401 QDF_STATUS mlme_cm_reassoc_req(struct wlan_objmgr_vdev *vdev,
402 			       struct wlan_cm_vdev_reassoc_req *req)
403 {
404 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
405 
406 	if ((glbl_ops) && glbl_ops->mlme_cm_ext_reassoc_req_cb)
407 		ret = glbl_ops->mlme_cm_ext_reassoc_req_cb(vdev, req);
408 
409 	return ret;
410 }
411 
412 #ifdef CONN_MGR_ADV_FEATURE
mlme_cm_osif_connect_active_notify(uint8_t vdev_id)413 void mlme_cm_osif_connect_active_notify(uint8_t vdev_id)
414 {
415 	if (glbl_cm_ops && glbl_cm_ops->mlme_cm_connect_active_notify_cb)
416 		glbl_cm_ops->mlme_cm_connect_active_notify_cb(vdev_id);
417 }
418 #endif
419 
mlme_cm_connect_complete_ind(struct wlan_objmgr_vdev * vdev,struct wlan_cm_connect_resp * rsp)420 QDF_STATUS mlme_cm_connect_complete_ind(struct wlan_objmgr_vdev *vdev,
421 					struct wlan_cm_connect_resp *rsp)
422 {
423 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
424 
425 	if ((glbl_ops) && glbl_ops->mlme_cm_ext_connect_complete_ind_cb)
426 		ret = glbl_ops->mlme_cm_ext_connect_complete_ind_cb(vdev, rsp);
427 
428 	return ret;
429 }
430 
mlme_cm_disconnect_start_ind(struct wlan_objmgr_vdev * vdev,struct wlan_cm_disconnect_req * req)431 QDF_STATUS mlme_cm_disconnect_start_ind(struct wlan_objmgr_vdev *vdev,
432 					struct wlan_cm_disconnect_req *req)
433 {
434 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
435 
436 	if ((glbl_ops) && glbl_ops->mlme_cm_ext_disconnect_start_ind_cb)
437 		ret = glbl_ops->mlme_cm_ext_disconnect_start_ind_cb(vdev, req);
438 
439 	return ret;
440 }
441 
mlme_cm_disconnect_req(struct wlan_objmgr_vdev * vdev,struct wlan_cm_vdev_discon_req * req)442 QDF_STATUS mlme_cm_disconnect_req(struct wlan_objmgr_vdev *vdev,
443 				  struct wlan_cm_vdev_discon_req *req)
444 {
445 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
446 
447 	if ((glbl_ops) && glbl_ops->mlme_cm_ext_disconnect_req_cb)
448 		ret = glbl_ops->mlme_cm_ext_disconnect_req_cb(vdev, req);
449 
450 	return ret;
451 }
452 
mlme_cm_bss_peer_delete_req(struct wlan_objmgr_vdev * vdev)453 QDF_STATUS mlme_cm_bss_peer_delete_req(struct wlan_objmgr_vdev *vdev)
454 {
455 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
456 
457 	if ((glbl_ops) && glbl_ops->mlme_cm_ext_bss_peer_delete_req_cb)
458 		ret = glbl_ops->mlme_cm_ext_bss_peer_delete_req_cb(vdev);
459 
460 	return ret;
461 }
462 
mlme_cm_disconnect_complete_ind(struct wlan_objmgr_vdev * vdev,struct wlan_cm_discon_rsp * rsp)463 QDF_STATUS mlme_cm_disconnect_complete_ind(struct wlan_objmgr_vdev *vdev,
464 					   struct wlan_cm_discon_rsp *rsp)
465 {
466 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
467 
468 	if ((glbl_ops) && glbl_ops->mlme_cm_ext_disconnect_complete_ind_cb)
469 		ret = glbl_ops->mlme_cm_ext_disconnect_complete_ind_cb(vdev,
470 								       rsp);
471 
472 	return ret;
473 }
474 
mlme_cm_vdev_down_req(struct wlan_objmgr_vdev * vdev)475 QDF_STATUS mlme_cm_vdev_down_req(struct wlan_objmgr_vdev *vdev)
476 {
477 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
478 
479 	if ((glbl_ops) && glbl_ops->mlme_cm_ext_vdev_down_req_cb)
480 		ret = glbl_ops->mlme_cm_ext_vdev_down_req_cb(vdev);
481 	return ret;
482 }
483 
mlme_cm_osif_connect_complete(struct wlan_objmgr_vdev * vdev,struct wlan_cm_connect_resp * rsp)484 QDF_STATUS mlme_cm_osif_connect_complete(struct wlan_objmgr_vdev *vdev,
485 				    struct wlan_cm_connect_resp *rsp)
486 {
487 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
488 
489 	if (glbl_cm_ops && glbl_cm_ops->mlme_cm_connect_complete_cb)
490 		ret = glbl_cm_ops->mlme_cm_connect_complete_cb(vdev, rsp);
491 
492 	return ret;
493 }
494 
495 QDF_STATUS
mlme_cm_osif_failed_candidate_ind(struct wlan_objmgr_vdev * vdev,struct wlan_cm_connect_resp * rsp)496 mlme_cm_osif_failed_candidate_ind(struct wlan_objmgr_vdev *vdev,
497 				  struct wlan_cm_connect_resp *rsp)
498 {
499 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
500 
501 	if (glbl_cm_ops &&
502 	    glbl_cm_ops->mlme_cm_failed_candidate_cb)
503 		ret = glbl_cm_ops->mlme_cm_failed_candidate_cb(vdev, rsp);
504 
505 	return ret;
506 }
507 
mlme_cm_osif_update_id_and_src(struct wlan_objmgr_vdev * vdev,enum wlan_cm_source source,wlan_cm_id cm_id)508 QDF_STATUS mlme_cm_osif_update_id_and_src(struct wlan_objmgr_vdev *vdev,
509 					  enum wlan_cm_source source,
510 					  wlan_cm_id cm_id)
511 {
512 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
513 
514 	if (glbl_cm_ops &&
515 	    glbl_cm_ops->mlme_cm_update_id_and_src_cb)
516 		ret = glbl_cm_ops->mlme_cm_update_id_and_src_cb(vdev, source,
517 								cm_id);
518 
519 	return ret;
520 }
521 
mlme_cm_osif_disconnect_complete(struct wlan_objmgr_vdev * vdev,struct wlan_cm_discon_rsp * rsp)522 QDF_STATUS mlme_cm_osif_disconnect_complete(struct wlan_objmgr_vdev *vdev,
523 					    struct wlan_cm_discon_rsp *rsp)
524 {
525 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
526 
527 	if (glbl_cm_ops &&
528 	    glbl_cm_ops->mlme_cm_disconnect_complete_cb)
529 		ret = glbl_cm_ops->mlme_cm_disconnect_complete_cb(vdev, rsp);
530 
531 	return ret;
532 }
533 
mlme_cm_osif_disconnect_start_ind(struct wlan_objmgr_vdev * vdev,enum wlan_cm_source source)534 QDF_STATUS mlme_cm_osif_disconnect_start_ind(struct wlan_objmgr_vdev *vdev,
535 					     enum wlan_cm_source source)
536 {
537 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
538 
539 	if (glbl_cm_ops &&
540 	    glbl_cm_ops->mlme_cm_disconnect_start_cb)
541 		ret = glbl_cm_ops->mlme_cm_disconnect_start_cb(vdev, source);
542 
543 	return ret;
544 }
545 
546 #ifdef WLAN_VENDOR_HANDOFF_CONTROL
mlme_cm_osif_get_vendor_handoff_params(struct wlan_objmgr_psoc * psoc,void * vendor_handoff_context)547 QDF_STATUS mlme_cm_osif_get_vendor_handoff_params(struct wlan_objmgr_psoc *psoc,
548 						  void *vendor_handoff_context)
549 {
550 	if (glbl_cm_ops && glbl_cm_ops->mlme_cm_get_vendor_handoff_params_cb)
551 		return glbl_cm_ops->mlme_cm_get_vendor_handoff_params_cb(psoc,
552 							vendor_handoff_context);
553 
554 	return QDF_STATUS_E_FAILURE;
555 }
556 #endif
557 
558 #ifdef CONN_MGR_ADV_FEATURE
mlme_cm_osif_roam_sync_ind(struct wlan_objmgr_vdev * vdev)559 QDF_STATUS mlme_cm_osif_roam_sync_ind(struct wlan_objmgr_vdev *vdev)
560 {
561 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
562 
563 	if (glbl_cm_ops &&
564 	    glbl_cm_ops->mlme_cm_roam_sync_cb)
565 		ret = glbl_cm_ops->mlme_cm_roam_sync_cb(vdev);
566 
567 	return ret;
568 }
569 
mlme_cm_osif_pmksa_candidate_notify(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr * bssid,int index,bool preauth)570 QDF_STATUS mlme_cm_osif_pmksa_candidate_notify(struct wlan_objmgr_vdev *vdev,
571 					       struct qdf_mac_addr *bssid,
572 					       int index, bool preauth)
573 {
574 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
575 
576 	if (glbl_cm_ops &&
577 	    glbl_cm_ops->mlme_cm_pmksa_candidate_notify_cb)
578 		ret = glbl_cm_ops->mlme_cm_pmksa_candidate_notify_cb(
579 						vdev, bssid, index, preauth);
580 
581 	return ret;
582 }
583 
mlme_cm_osif_send_keys(struct wlan_objmgr_vdev * vdev,uint8_t key_index,bool pairwise,enum wlan_crypto_cipher_type cipher_type)584 QDF_STATUS mlme_cm_osif_send_keys(struct wlan_objmgr_vdev *vdev,
585 				  uint8_t key_index, bool pairwise,
586 				  enum wlan_crypto_cipher_type cipher_type)
587 {
588 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
589 
590 	if (glbl_cm_ops && glbl_cm_ops->mlme_cm_send_keys_cb)
591 		ret = glbl_cm_ops->mlme_cm_send_keys_cb(vdev, key_index,
592 							pairwise,
593 							cipher_type);
594 
595 	return ret;
596 }
597 
mlme_cm_osif_link_reconfig_notify(struct wlan_objmgr_vdev * vdev)598 QDF_STATUS mlme_cm_osif_link_reconfig_notify(struct wlan_objmgr_vdev *vdev)
599 {
600 	QDF_STATUS ret = QDF_STATUS_E_INVAL;
601 
602 	if (glbl_cm_ops &&
603 	    glbl_cm_ops->mlme_cm_link_reconfig_notify_cb)
604 		ret = glbl_cm_ops->mlme_cm_link_reconfig_notify_cb(vdev);
605 
606 	return ret;
607 }
608 #endif
609 
610 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
mlme_cm_osif_roam_start_ind(struct wlan_objmgr_vdev * vdev)611 QDF_STATUS mlme_cm_osif_roam_start_ind(struct wlan_objmgr_vdev *vdev)
612 {
613 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
614 
615 	if (glbl_cm_ops &&
616 	    glbl_cm_ops->mlme_cm_roam_start_cb)
617 		ret = glbl_cm_ops->mlme_cm_roam_start_cb(vdev);
618 
619 	return ret;
620 }
621 
mlme_cm_osif_roam_abort_ind(struct wlan_objmgr_vdev * vdev)622 QDF_STATUS mlme_cm_osif_roam_abort_ind(struct wlan_objmgr_vdev *vdev)
623 {
624 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
625 
626 	if (glbl_cm_ops &&
627 	    glbl_cm_ops->mlme_cm_roam_abort_cb)
628 		ret = glbl_cm_ops->mlme_cm_roam_abort_cb(vdev);
629 
630 	return ret;
631 }
632 
633 QDF_STATUS
mlme_cm_osif_roam_complete(struct wlan_objmgr_vdev * vdev)634 mlme_cm_osif_roam_complete(struct wlan_objmgr_vdev *vdev)
635 {
636 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
637 
638 	if (glbl_cm_ops &&
639 	    glbl_cm_ops->mlme_cm_roam_cmpl_cb)
640 		ret = glbl_cm_ops->mlme_cm_roam_cmpl_cb(vdev);
641 
642 	return ret;
643 }
644 
645 void
mlme_cm_osif_roam_rt_stats(struct roam_stats_event * roam_stats,uint8_t idx)646 mlme_cm_osif_roam_rt_stats(struct roam_stats_event *roam_stats,
647 			   uint8_t idx)
648 {
649 	if (glbl_cm_ops &&
650 	    glbl_cm_ops->mlme_cm_roam_rt_stats_cb)
651 		glbl_cm_ops->mlme_cm_roam_rt_stats_cb(roam_stats,
652 						      idx);
653 }
654 
655 QDF_STATUS
mlme_cm_osif_roam_get_scan_params(struct wlan_objmgr_vdev * vdev,struct element_info * scan_ie,enum dot11_mode_filter * dot11mode_filter)656 mlme_cm_osif_roam_get_scan_params(struct wlan_objmgr_vdev *vdev,
657 				  struct element_info *scan_ie,
658 				  enum dot11_mode_filter *dot11mode_filter)
659 {
660 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
661 
662 	if (glbl_cm_ops &&
663 	    glbl_cm_ops->mlme_cm_roam_get_scan_ie_cb)
664 		ret = glbl_cm_ops->mlme_cm_roam_get_scan_ie_cb(vdev,
665 						scan_ie, dot11mode_filter);
666 
667 	return ret;
668 }
669 
670 #endif
671 
672 #ifdef WLAN_FEATURE_PREAUTH_ENABLE
673 QDF_STATUS
mlme_cm_osif_ft_preauth_complete(struct wlan_objmgr_vdev * vdev,struct wlan_preauth_rsp * rsp)674 mlme_cm_osif_ft_preauth_complete(struct wlan_objmgr_vdev *vdev,
675 				 struct wlan_preauth_rsp *rsp)
676 {
677 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
678 
679 	if (glbl_cm_ops &&
680 	    glbl_cm_ops->mlme_cm_ft_preauth_cmpl_cb)
681 		ret = glbl_cm_ops->mlme_cm_ft_preauth_cmpl_cb(vdev, rsp);
682 
683 	return ret;
684 }
685 
686 #ifdef FEATURE_WLAN_ESE
687 QDF_STATUS
mlme_cm_osif_cckm_preauth_complete(struct wlan_objmgr_vdev * vdev,struct wlan_preauth_rsp * rsp)688 mlme_cm_osif_cckm_preauth_complete(struct wlan_objmgr_vdev *vdev,
689 				   struct wlan_preauth_rsp *rsp)
690 {
691 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
692 
693 	if (glbl_cm_ops &&
694 	    glbl_cm_ops->mlme_cm_cckm_preauth_cmpl_cb)
695 		ret = glbl_cm_ops->mlme_cm_cckm_preauth_cmpl_cb(vdev, rsp);
696 
697 	return ret;
698 }
699 #endif
700 #endif
701 
mlme_set_osif_cm_cb(osif_cm_get_global_ops_cb osif_cm_ops)702 void mlme_set_osif_cm_cb(osif_cm_get_global_ops_cb osif_cm_ops)
703 {
704 	glbl_cm_ops_cb = osif_cm_ops;
705 }
706 
mlme_set_osif_twt_cb(osif_twt_get_global_ops_cb osif_twt_ops)707 void mlme_set_osif_twt_cb(osif_twt_get_global_ops_cb osif_twt_ops)
708 {
709 	glbl_twt_ops_cb = osif_twt_ops;
710 }
711 
mlme_set_ops_register_cb(mlme_get_global_ops_cb ops_cb)712 void mlme_set_ops_register_cb(mlme_get_global_ops_cb ops_cb)
713 {
714 	glbl_ops_cb = ops_cb;
715 }
716 
mlme_send_scan_done_complete_cb(uint8_t vdev_id)717 void mlme_send_scan_done_complete_cb(uint8_t vdev_id)
718 {
719 	if (glbl_vdev_mgr_ops &&
720 	    glbl_vdev_mgr_ops->mlme_vdev_mgr_send_scan_done_complete_cb)
721 		glbl_vdev_mgr_ops->mlme_vdev_mgr_send_scan_done_complete_cb(
722 							vdev_id);
723 }
724 
mlme_max_chan_switch_is_set(struct wlan_objmgr_psoc * psoc)725 bool mlme_max_chan_switch_is_set(struct wlan_objmgr_psoc *psoc)
726 {
727 	struct psoc_mlme_obj *mlme_psoc_obj;
728 	struct psoc_phy_config *phy_config;
729 
730 	if (!psoc)
731 		return false;
732 
733 	mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc);
734 	if (!mlme_psoc_obj)
735 		return false;
736 
737 	phy_config = &mlme_psoc_obj->psoc_cfg.phy_config;
738 
739 	return phy_config->max_chan_switch_ie;
740 }
741 
mlme_set_osif_vdev_mgr_cb(osif_vdev_mgr_get_global_ops_cb mlme_vdev_mgr_osif_ops)742 void mlme_set_osif_vdev_mgr_cb(
743 			osif_vdev_mgr_get_global_ops_cb mlme_vdev_mgr_osif_ops)
744 {
745 	glbl_vdev_mgr_ops_cb = mlme_vdev_mgr_osif_ops;
746 }
747 
748 #ifdef WLAN_FEATURE_DYNAMIC_MAC_ADDR_UPDATE
mlme_vdev_ops_send_set_mac_address(struct qdf_mac_addr mac_addr,struct qdf_mac_addr mld_addr,struct wlan_objmgr_vdev * vdev)749 QDF_STATUS mlme_vdev_ops_send_set_mac_address(struct qdf_mac_addr mac_addr,
750 					      struct qdf_mac_addr mld_addr,
751 					      struct wlan_objmgr_vdev *vdev)
752 {
753 	QDF_STATUS ret = QDF_STATUS_E_FAILURE;
754 
755 	if (glbl_ops && glbl_ops->mlme_vdev_send_set_mac_addr)
756 		ret = glbl_ops->mlme_vdev_send_set_mac_addr(mac_addr, mld_addr,
757 							    vdev);
758 
759 	return ret;
760 }
761 
mlme_vdev_mgr_notify_set_mac_addr_response(uint8_t vdev_id,uint8_t resp_status)762 void mlme_vdev_mgr_notify_set_mac_addr_response(uint8_t vdev_id,
763 						uint8_t resp_status)
764 {
765 	if (glbl_vdev_mgr_ops &&
766 	    glbl_vdev_mgr_ops->mlme_vdev_mgr_set_mac_addr_response)
767 		glbl_vdev_mgr_ops->mlme_vdev_mgr_set_mac_addr_response(
768 							vdev_id, resp_status);
769 }
770 #endif
771 
772 #if defined(WLAN_SUPPORT_TWT) && defined(WLAN_TWT_CONV_SUPPORTED)
773 QDF_STATUS
mlme_twt_osif_enable_complete_ind(struct wlan_objmgr_psoc * psoc,struct twt_enable_complete_event_param * event,void * context)774 mlme_twt_osif_enable_complete_ind(struct wlan_objmgr_psoc *psoc,
775 				  struct twt_enable_complete_event_param *event,
776 				  void *context)
777 {
778 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
779 
780 	if (glbl_twt_ops && glbl_twt_ops->mlme_twt_enable_complete_cb)
781 		ret = glbl_twt_ops->mlme_twt_enable_complete_cb(psoc,
782 								event, context);
783 
784 	return ret;
785 }
786 
787 QDF_STATUS
mlme_twt_osif_disable_complete_ind(struct wlan_objmgr_psoc * psoc,struct twt_disable_complete_event_param * event,void * context)788 mlme_twt_osif_disable_complete_ind(struct wlan_objmgr_psoc *psoc,
789 				 struct twt_disable_complete_event_param *event,
790 				 void *context)
791 {
792 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
793 
794 	if (glbl_twt_ops && glbl_twt_ops->mlme_twt_disable_complete_cb)
795 		ret = glbl_twt_ops->mlme_twt_disable_complete_cb(psoc,
796 								event, context);
797 
798 	return ret;
799 }
800 
801 QDF_STATUS
mlme_twt_osif_ack_complete_ind(struct wlan_objmgr_psoc * psoc,struct twt_ack_complete_event_param * event,void * context)802 mlme_twt_osif_ack_complete_ind(struct wlan_objmgr_psoc *psoc,
803 			       struct twt_ack_complete_event_param *event,
804 			       void *context)
805 {
806 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
807 
808 	if (glbl_twt_ops && glbl_twt_ops->mlme_twt_ack_complete_cb)
809 		ret = glbl_twt_ops->mlme_twt_ack_complete_cb(psoc,
810 							     event, context);
811 
812 	return ret;
813 }
814 
815 QDF_STATUS
mlme_twt_osif_setup_complete_ind(struct wlan_objmgr_psoc * psoc,struct twt_add_dialog_complete_event * event,bool renego)816 mlme_twt_osif_setup_complete_ind(struct wlan_objmgr_psoc *psoc,
817 				 struct twt_add_dialog_complete_event *event,
818 				 bool renego)
819 {
820 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
821 
822 	if (glbl_twt_ops && glbl_twt_ops->mlme_twt_setup_complete_cb)
823 		ret = glbl_twt_ops->mlme_twt_setup_complete_cb(psoc, event,
824 							       renego);
825 
826 	return ret;
827 }
828 
829 QDF_STATUS
mlme_twt_osif_teardown_complete_ind(struct wlan_objmgr_psoc * psoc,struct twt_del_dialog_complete_event_param * event)830 mlme_twt_osif_teardown_complete_ind(struct wlan_objmgr_psoc *psoc,
831 			    struct twt_del_dialog_complete_event_param *event)
832 {
833 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
834 
835 	if (glbl_twt_ops && glbl_twt_ops->mlme_twt_teardown_complete_cb)
836 		ret = glbl_twt_ops->mlme_twt_teardown_complete_cb(psoc, event);
837 
838 	return ret;
839 }
840 
841 QDF_STATUS
mlme_twt_osif_pause_complete_ind(struct wlan_objmgr_psoc * psoc,struct twt_pause_dialog_complete_event_param * event)842 mlme_twt_osif_pause_complete_ind(struct wlan_objmgr_psoc *psoc,
843 			    struct twt_pause_dialog_complete_event_param *event)
844 {
845 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
846 
847 	if (glbl_twt_ops && glbl_twt_ops->mlme_twt_pause_complete_cb)
848 		ret = glbl_twt_ops->mlme_twt_pause_complete_cb(psoc, event);
849 
850 	return ret;
851 }
852 
853 QDF_STATUS
mlme_twt_osif_resume_complete_ind(struct wlan_objmgr_psoc * psoc,struct twt_resume_dialog_complete_event_param * event)854 mlme_twt_osif_resume_complete_ind(struct wlan_objmgr_psoc *psoc,
855 			   struct twt_resume_dialog_complete_event_param *event)
856 {
857 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
858 
859 	if (glbl_twt_ops && glbl_twt_ops->mlme_twt_resume_complete_cb)
860 		ret = glbl_twt_ops->mlme_twt_resume_complete_cb(psoc, event);
861 
862 	return ret;
863 }
864 
865 QDF_STATUS
mlme_twt_osif_nudge_complete_ind(struct wlan_objmgr_psoc * psoc,struct twt_nudge_dialog_complete_event_param * event)866 mlme_twt_osif_nudge_complete_ind(struct wlan_objmgr_psoc *psoc,
867 			    struct twt_nudge_dialog_complete_event_param *event)
868 {
869 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
870 
871 	if (glbl_twt_ops && glbl_twt_ops->mlme_twt_nudge_complete_cb)
872 		ret = glbl_twt_ops->mlme_twt_nudge_complete_cb(psoc, event);
873 
874 	return ret;
875 }
876 
877 QDF_STATUS
mlme_twt_osif_notify_complete_ind(struct wlan_objmgr_psoc * psoc,struct twt_notify_event_param * event)878 mlme_twt_osif_notify_complete_ind(struct wlan_objmgr_psoc *psoc,
879 				  struct twt_notify_event_param *event)
880 {
881 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
882 
883 	if (glbl_twt_ops && glbl_twt_ops->mlme_twt_notify_complete_cb)
884 		ret = glbl_twt_ops->mlme_twt_notify_complete_cb(psoc, event);
885 
886 	return ret;
887 }
888 
889 QDF_STATUS
mlme_twt_vdev_create_notification(struct wlan_objmgr_vdev * vdev)890 mlme_twt_vdev_create_notification(struct wlan_objmgr_vdev *vdev)
891 {
892 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
893 
894 	if (glbl_twt_ops && glbl_twt_ops->mlme_twt_vdev_create_cb)
895 		ret = glbl_twt_ops->mlme_twt_vdev_create_cb(vdev);
896 
897 	return ret;
898 }
899 
900 QDF_STATUS
mlme_twt_vdev_destroy_notification(struct wlan_objmgr_vdev * vdev)901 mlme_twt_vdev_destroy_notification(struct wlan_objmgr_vdev *vdev)
902 {
903 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
904 
905 	if (glbl_twt_ops && glbl_twt_ops->mlme_twt_vdev_destroy_cb)
906 		ret = glbl_twt_ops->mlme_twt_vdev_destroy_cb(vdev);
907 
908 	return ret;
909 }
910 
911 #endif
912 
mlme_vdev_reconfig_timer_cb(void * arg)913 void mlme_vdev_reconfig_timer_cb(void *arg)
914 {
915 	struct vdev_mlme_obj *vdev_mlme;
916 
917 	vdev_mlme = (struct vdev_mlme_obj *)arg;
918 	if (!vdev_mlme)
919 		return;
920 
921 	if ((vdev_mlme->ops) &&
922 	    vdev_mlme->ops->mlme_vdev_reconfig_timer_complete)
923 		vdev_mlme->ops->mlme_vdev_reconfig_timer_complete(vdev_mlme);
924 }
925 
mlme_mlo_is_reconfig_reassoc_enable(struct wlan_objmgr_psoc * psoc)926 bool mlme_mlo_is_reconfig_reassoc_enable(struct wlan_objmgr_psoc *psoc)
927 {
928 	struct psoc_mlme_obj *mlme_psoc_obj;
929 	struct psoc_mlo_config *mlo_config;
930 
931 	if (!psoc)
932 		return false;
933 
934 	mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc);
935 	if (!mlme_psoc_obj)
936 		return false;
937 
938 	mlo_config = &mlme_psoc_obj->psoc_cfg.mlo_config;
939 
940 	return mlo_config->reconfig_reassoc_en;
941 }
942 
943 #ifdef WLAN_BOOST_CPU_FREQ_IN_ROAM
mlme_cm_osif_perfd_reset_cpufreq(void)944 void mlme_cm_osif_perfd_reset_cpufreq(void)
945 {
946 	if (glbl_cm_ops && glbl_cm_ops->mlme_cm_perfd_reset_cpufreq_ctrl_cb)
947 		glbl_cm_ops->mlme_cm_perfd_reset_cpufreq_ctrl_cb();
948 }
949 #endif
950