1 /*
2 * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
3 * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for
6 * any purpose with or without fee is hereby granted, provided that the
7 * above copyright notice and this permission notice appear in all
8 * copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 */
19 /**
20 * DOC: wifi_pos_api.c
21 * This file defines the APIs wifi_pos component.
22 */
23
24 #include <wlan_lmac_if_def.h>
25 #include "wifi_pos_api.h"
26 #include "wifi_pos_utils_i.h"
27 #include "wifi_pos_main_i.h"
28 #include "os_if_wifi_pos.h"
29 #include "target_if_wifi_pos.h"
30 #include "wlan_objmgr_cmn.h"
31 #include "wlan_objmgr_global_obj.h"
32 #include "wlan_objmgr_psoc_obj.h"
33 #include "wlan_objmgr_peer_obj.h"
34 #include "wlan_lmac_if_def.h"
35
36 struct wlan_lmac_if_wifi_pos_rx_ops *
wifi_pos_get_rx_ops(struct wlan_objmgr_psoc * psoc)37 wifi_pos_get_rx_ops(struct wlan_objmgr_psoc *psoc)
38 {
39 struct wlan_lmac_if_rx_ops *rx_ops;
40
41 if (!psoc) {
42 wifi_pos_err("psoc is null");
43 return NULL;
44 }
45
46 rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
47 if (!rx_ops) {
48 wifi_pos_err("rx_ops is NULL");
49 return NULL;
50 }
51
52 return &rx_ops->wifi_pos_rx_ops;
53 }
54
wifi_pos_get_legacy_ops(void)55 struct wifi_pos_legacy_ops *wifi_pos_get_legacy_ops(void)
56 {
57 struct wifi_pos_psoc_priv_obj *wifi_pos_obj =
58 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc());
59
60 if (!wifi_pos_obj)
61 return NULL;
62
63 return wifi_pos_obj->legacy_ops;
64 }
65
66 QDF_STATUS
wifi_pos_set_legacy_ops(struct wlan_objmgr_psoc * psoc,struct wifi_pos_legacy_ops * legacy_ops)67 wifi_pos_set_legacy_ops(struct wlan_objmgr_psoc *psoc,
68 struct wifi_pos_legacy_ops *legacy_ops)
69 {
70 struct wifi_pos_psoc_priv_obj *wifi_pos_obj =
71 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc());
72
73 if (!wifi_pos_obj)
74 return QDF_STATUS_E_FAILURE;
75
76 wifi_pos_obj->legacy_ops = legacy_ops;
77
78 return QDF_STATUS_SUCCESS;
79 }
80
81 struct wlan_lmac_if_wifi_pos_tx_ops *
wifi_pos_get_tx_ops(struct wlan_objmgr_psoc * psoc)82 wifi_pos_get_tx_ops(struct wlan_objmgr_psoc *psoc)
83 {
84 struct wlan_lmac_if_tx_ops *tx_ops;
85
86 if (!psoc) {
87 wifi_pos_err("psoc is null");
88 return NULL;
89 }
90
91 tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
92 if (!tx_ops) {
93 wifi_pos_err("tx_ops is NULL");
94 return NULL;
95 }
96
97 return &tx_ops->wifi_pos_tx_ops;
98 }
99
wifi_pos_init(void)100 QDF_STATUS wifi_pos_init(void)
101 {
102 QDF_STATUS status;
103
104 wifi_pos_lock_init();
105
106 /* register psoc create handler functions. */
107 status = wlan_objmgr_register_psoc_create_handler(
108 WLAN_UMAC_COMP_WIFI_POS,
109 wifi_pos_psoc_obj_created_notification,
110 NULL);
111 if (QDF_IS_STATUS_ERROR(status)) {
112 wifi_pos_err("register_psoc_create_handler failed, status: %d",
113 status);
114 return status;
115 }
116
117 /* register psoc delete handler functions. */
118 status = wlan_objmgr_register_psoc_destroy_handler(
119 WLAN_UMAC_COMP_WIFI_POS,
120 wifi_pos_psoc_obj_destroyed_notification,
121 NULL);
122 if (QDF_IS_STATUS_ERROR(status)) {
123 wifi_pos_err("register_psoc_destroy_handler failed, status: %d",
124 status);
125 goto fail_psoc_destroy_handler;
126 }
127
128 status = wlan_objmgr_register_vdev_create_handler(
129 WLAN_UMAC_COMP_WIFI_POS,
130 wifi_pos_vdev_created_notification, NULL);
131 if (QDF_IS_STATUS_ERROR(status)) {
132 wifi_pos_err("register_vdev_create_handler failed, status: %d",
133 status);
134 goto fail_vdev_create_handler;
135 }
136
137 status = wlan_objmgr_register_vdev_destroy_handler(
138 WLAN_UMAC_COMP_WIFI_POS,
139 wifi_pos_vdev_destroyed_notification, NULL);
140 if (QDF_IS_STATUS_ERROR(status)) {
141 wifi_pos_err("register_vdev_destroy_handler failed, status: %d",
142 status);
143 goto fail_vdev_destroy_handler;
144 }
145
146 status = wlan_objmgr_register_peer_create_handler(
147 WLAN_UMAC_COMP_WIFI_POS,
148 wifi_pos_peer_object_created_notification,
149 NULL);
150 if (QDF_IS_STATUS_ERROR(status)) {
151 wifi_pos_err("peer create register notification failed");
152 goto fail_peer_create_handler;
153 }
154
155 status = wlan_objmgr_register_peer_destroy_handler(
156 WLAN_UMAC_COMP_WIFI_POS,
157 wifi_pos_peer_object_destroyed_notification,
158 NULL);
159 if (QDF_IS_STATUS_ERROR(status)) {
160 wifi_pos_err("peer destroy register notification failed");
161 goto fail_peer_destroy_handler;
162 }
163
164 return status;
165
166 fail_peer_destroy_handler:
167 wlan_objmgr_unregister_peer_create_handler(
168 WLAN_UMAC_COMP_WIFI_POS,
169 wifi_pos_peer_object_created_notification,
170 NULL);
171 fail_peer_create_handler:
172 wlan_objmgr_unregister_vdev_destroy_handler(
173 WLAN_UMAC_COMP_WIFI_POS,
174 wifi_pos_vdev_destroyed_notification, NULL);
175
176 fail_vdev_destroy_handler:
177 wlan_objmgr_unregister_vdev_create_handler(
178 WLAN_UMAC_COMP_WIFI_POS,
179 wifi_pos_vdev_created_notification, NULL);
180
181 fail_vdev_create_handler:
182 wlan_objmgr_unregister_psoc_destroy_handler(
183 WLAN_UMAC_COMP_WIFI_POS,
184 wifi_pos_psoc_obj_destroyed_notification, NULL);
185
186 fail_psoc_destroy_handler:
187 wlan_objmgr_unregister_psoc_create_handler(
188 WLAN_UMAC_COMP_WIFI_POS,
189 wifi_pos_psoc_obj_created_notification, NULL);
190
191 return status;
192 }
193
wifi_pos_deinit(void)194 QDF_STATUS wifi_pos_deinit(void)
195 {
196 QDF_STATUS status;
197
198 status = wlan_objmgr_unregister_peer_destroy_handler(
199 WLAN_UMAC_COMP_WIFI_POS,
200 wifi_pos_peer_object_destroyed_notification,
201 NULL);
202 if (QDF_IS_STATUS_ERROR(status))
203 wifi_pos_err("unable to unregister peer destroy handle");
204
205 status = wlan_objmgr_unregister_peer_create_handler(
206 WLAN_UMAC_COMP_WIFI_POS,
207 wifi_pos_peer_object_created_notification,
208 NULL);
209 if (QDF_IS_STATUS_ERROR(status))
210 wifi_pos_err("unable to unregister peer create handle");
211
212 status = wlan_objmgr_unregister_vdev_destroy_handler(
213 WLAN_UMAC_COMP_WIFI_POS,
214 wifi_pos_vdev_destroyed_notification, NULL);
215 if (QDF_IS_STATUS_ERROR(status))
216 wifi_pos_err("unregister_vdev_destroy_handler failed, status: %d",
217 status);
218
219 status = wlan_objmgr_unregister_vdev_create_handler(
220 WLAN_UMAC_COMP_WIFI_POS,
221 wifi_pos_vdev_created_notification, NULL);
222 if (QDF_IS_STATUS_ERROR(status))
223 wifi_pos_err("unregister_vdev_create_handler failed, status: %d",
224 status);
225
226 /* deregister psoc create handler functions. */
227 status = wlan_objmgr_unregister_psoc_create_handler(
228 WLAN_UMAC_COMP_WIFI_POS,
229 wifi_pos_psoc_obj_created_notification,
230 NULL);
231 if (QDF_IS_STATUS_ERROR(status)) {
232 wifi_pos_err("unregister_psoc_create_handler failed, status: %d",
233 status);
234 return status;
235 }
236
237 /* deregister psoc delete handler functions. */
238 status = wlan_objmgr_unregister_psoc_destroy_handler(
239 WLAN_UMAC_COMP_WIFI_POS,
240 wifi_pos_psoc_obj_destroyed_notification,
241 NULL);
242 if (QDF_IS_STATUS_ERROR(status)) {
243 wifi_pos_err("unregister_psoc_destroy_handler failed, status: %d",
244 status);
245 }
246
247 wifi_pos_lock_deinit();
248
249 return QDF_STATUS_SUCCESS;
250 }
251
wifi_pos_psoc_enable(struct wlan_objmgr_psoc * psoc)252 QDF_STATUS wifi_pos_psoc_enable(struct wlan_objmgr_psoc *psoc)
253 {
254 QDF_STATUS status;
255 struct wlan_lmac_if_wifi_pos_tx_ops *tx_ops;
256
257 tx_ops = wifi_pos_get_tx_ops(psoc);
258 if (!tx_ops) {
259 wifi_pos_err("tx_ops is null");
260 return QDF_STATUS_E_NULL_VALUE;
261 }
262
263 status = tx_ops->wifi_pos_register_events(psoc);
264
265 if (QDF_IS_STATUS_ERROR(status))
266 wifi_pos_err("target_if_wifi_pos_register_events failed");
267
268 return status;
269 }
270
wifi_pos_psoc_disable(struct wlan_objmgr_psoc * psoc)271 QDF_STATUS wifi_pos_psoc_disable(struct wlan_objmgr_psoc *psoc)
272 {
273 QDF_STATUS status;
274 struct wlan_lmac_if_wifi_pos_tx_ops *tx_ops;
275
276 tx_ops = wifi_pos_get_tx_ops(psoc);
277 if (!tx_ops) {
278 wifi_pos_err("tx_ops is null");
279 return QDF_STATUS_E_NULL_VALUE;
280 }
281
282 status = tx_ops->wifi_pos_deregister_events(psoc);
283
284 if (QDF_IS_STATUS_ERROR(status))
285 wifi_pos_err("target_if_wifi_pos_deregister_events failed");
286
287 return QDF_STATUS_SUCCESS;
288 }
289
290 struct wlan_wifi_pos_peer_priv_obj *
wifi_pos_get_peer_private_object(struct wlan_objmgr_peer * peer)291 wifi_pos_get_peer_private_object(struct wlan_objmgr_peer *peer)
292 {
293 struct wlan_wifi_pos_peer_priv_obj *peer_priv;
294
295 if (!peer) {
296 wifi_pos_err("Peer is NULL");
297 return NULL;
298 }
299
300 peer_priv =
301 wlan_objmgr_peer_get_comp_private_obj(peer,
302 WLAN_UMAC_COMP_WIFI_POS);
303
304 return peer_priv;
305 }
306
wifi_pos_set_oem_target_type(struct wlan_objmgr_psoc * psoc,uint32_t val)307 void wifi_pos_set_oem_target_type(struct wlan_objmgr_psoc *psoc, uint32_t val)
308 {
309 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
310 wifi_pos_get_psoc_priv_obj(psoc);
311
312 if (!wifi_pos_psoc) {
313 wifi_pos_err("wifi_pos priv obj is null");
314 return;
315 }
316
317 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
318 wifi_pos_psoc->oem_target_type = val;
319 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
320 }
321
wifi_pos_set_oem_fw_version(struct wlan_objmgr_psoc * psoc,uint32_t val)322 void wifi_pos_set_oem_fw_version(struct wlan_objmgr_psoc *psoc, uint32_t val)
323 {
324 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
325 wifi_pos_get_psoc_priv_obj(psoc);
326
327 if (!wifi_pos_psoc) {
328 wifi_pos_err("wifi_pos priv obj is null");
329 return;
330 }
331
332 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
333 wifi_pos_psoc->oem_fw_version = val;
334 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
335 }
336
wifi_pos_set_drv_ver_major(struct wlan_objmgr_psoc * psoc,uint8_t val)337 void wifi_pos_set_drv_ver_major(struct wlan_objmgr_psoc *psoc, uint8_t val)
338 {
339 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
340 wifi_pos_get_psoc_priv_obj(psoc);
341
342 if (!wifi_pos_psoc) {
343 wifi_pos_err("wifi_pos priv obj is null");
344 return;
345 }
346
347 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
348 wifi_pos_psoc->driver_version.major = val;
349 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
350 }
351
wifi_pos_set_drv_ver_minor(struct wlan_objmgr_psoc * psoc,uint8_t val)352 void wifi_pos_set_drv_ver_minor(struct wlan_objmgr_psoc *psoc, uint8_t val)
353 {
354 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
355 wifi_pos_get_psoc_priv_obj(psoc);
356
357 if (!wifi_pos_psoc) {
358 wifi_pos_err("wifi_pos priv obj is null");
359 return;
360 }
361
362 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
363 wifi_pos_psoc->driver_version.minor = val;
364 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
365 }
366
wifi_pos_set_drv_ver_patch(struct wlan_objmgr_psoc * psoc,uint8_t val)367 void wifi_pos_set_drv_ver_patch(struct wlan_objmgr_psoc *psoc, uint8_t val)
368 {
369 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
370 wifi_pos_get_psoc_priv_obj(psoc);
371
372 if (!wifi_pos_psoc) {
373 wifi_pos_err("wifi_pos priv obj is null");
374 return;
375 }
376
377 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
378 wifi_pos_psoc->driver_version.patch = val;
379 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
380 }
381
wifi_pos_set_drv_ver_build(struct wlan_objmgr_psoc * psoc,uint8_t val)382 void wifi_pos_set_drv_ver_build(struct wlan_objmgr_psoc *psoc, uint8_t val)
383 {
384 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
385 wifi_pos_get_psoc_priv_obj(psoc);
386
387 if (!wifi_pos_psoc) {
388 wifi_pos_err("wifi_pos priv obj is null");
389 return;
390 }
391
392 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
393 wifi_pos_psoc->driver_version.build = val;
394 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
395 }
396
wifi_pos_set_dwell_time_min(struct wlan_objmgr_psoc * psoc,uint16_t val)397 void wifi_pos_set_dwell_time_min(struct wlan_objmgr_psoc *psoc, uint16_t val)
398 {
399 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
400 wifi_pos_get_psoc_priv_obj(psoc);
401
402 if (!wifi_pos_psoc) {
403 wifi_pos_err("wifi_pos priv obj is null");
404 return;
405 }
406
407 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
408 wifi_pos_psoc->allowed_dwell_time_min = val;
409 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
410 }
wifi_pos_set_dwell_time_max(struct wlan_objmgr_psoc * psoc,uint16_t val)411 void wifi_pos_set_dwell_time_max(struct wlan_objmgr_psoc *psoc, uint16_t val)
412 {
413 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
414 wifi_pos_get_psoc_priv_obj(psoc);
415
416 if (!wifi_pos_psoc) {
417 wifi_pos_err("wifi_pos priv obj is null");
418 return;
419 }
420
421 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
422 wifi_pos_psoc->allowed_dwell_time_max = val;
423 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
424 }
425
wifi_pos_set_current_dwell_time_max(struct wlan_objmgr_psoc * psoc,uint16_t val)426 void wifi_pos_set_current_dwell_time_max(struct wlan_objmgr_psoc *psoc,
427 uint16_t val)
428 {
429 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
430 wifi_pos_get_psoc_priv_obj(psoc);
431
432 if (!wifi_pos_psoc) {
433 wifi_pos_err("wifi_pos priv obj is null");
434 return;
435 }
436
437 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
438 wifi_pos_psoc->current_dwell_time_max = val;
439 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
440 }
441
wifi_pos_set_current_dwell_time_min(struct wlan_objmgr_psoc * psoc,uint16_t val)442 void wifi_pos_set_current_dwell_time_min(struct wlan_objmgr_psoc *psoc,
443 uint16_t val)
444 {
445 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
446 wifi_pos_get_psoc_priv_obj(psoc);
447
448 if (!wifi_pos_psoc) {
449 wifi_pos_err("wifi_pos priv obj is null");
450 return;
451 }
452
453 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
454 wifi_pos_psoc->current_dwell_time_max = val;
455 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
456 }
457
wifi_pos_get_app_pid(struct wlan_objmgr_psoc * psoc)458 uint32_t wifi_pos_get_app_pid(struct wlan_objmgr_psoc *psoc)
459 {
460 uint32_t app_pid;
461 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
462 wifi_pos_get_psoc_priv_obj(psoc);
463
464 if (!wifi_pos_psoc) {
465 wifi_pos_err("wifi_pos priv obj is null");
466 return 0;
467 }
468
469 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
470 app_pid = wifi_pos_psoc->app_pid;
471 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
472
473 return app_pid;
474
475 }
476
wifi_pos_is_app_registered(struct wlan_objmgr_psoc * psoc)477 bool wifi_pos_is_app_registered(struct wlan_objmgr_psoc *psoc)
478 {
479 bool is_app_registered;
480 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
481 wifi_pos_get_psoc_priv_obj(psoc);
482
483 if (!wifi_pos_psoc) {
484 wifi_pos_err("wifi_pos priv obj is null");
485 return false;
486 }
487
488 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
489 is_app_registered = wifi_pos_psoc->is_app_registered;
490 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
491
492 return is_app_registered;
493 }
494
495 #ifdef WLAN_FEATURE_CIF_CFR
wifi_pos_init_cir_cfr_rings(struct wlan_objmgr_psoc * psoc,void * hal_soc,uint8_t num_mac,void * buf)496 QDF_STATUS wifi_pos_init_cir_cfr_rings(struct wlan_objmgr_psoc *psoc,
497 void *hal_soc, uint8_t num_mac, void *buf)
498 {
499 return target_if_wifi_pos_init_cir_cfr_rings(psoc, hal_soc,
500 num_mac, buf);
501 }
502 #endif
503
504 QDF_STATUS
wifi_pos_register_get_phy_mode_cb(struct wlan_objmgr_psoc * psoc,void (* handler)(qdf_freq_t,uint32_t,uint32_t *))505 wifi_pos_register_get_phy_mode_cb(struct wlan_objmgr_psoc *psoc,
506 void (*handler)(qdf_freq_t, uint32_t,
507 uint32_t *))
508 {
509 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc;
510
511 if (!psoc) {
512 wifi_pos_err("psoc is null");
513 return QDF_STATUS_E_NULL_VALUE;
514 }
515
516 if (!handler) {
517 wifi_pos_err("Null callback");
518 return QDF_STATUS_E_NULL_VALUE;
519 }
520 wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(psoc);
521 if (!wifi_pos_psoc) {
522 wifi_pos_err("wifi_pos priv obj is null");
523 return QDF_STATUS_E_NULL_VALUE;
524 }
525
526 wifi_pos_psoc->wifi_pos_get_phy_mode = handler;
527
528 return QDF_STATUS_SUCCESS;
529 }
530
wifi_pos_register_get_fw_phy_mode_for_freq_cb(struct wlan_objmgr_psoc * psoc,void (* handler)(uint32_t,uint32_t,uint32_t *))531 QDF_STATUS wifi_pos_register_get_fw_phy_mode_for_freq_cb(
532 struct wlan_objmgr_psoc *psoc,
533 void (*handler)(uint32_t, uint32_t, uint32_t *))
534 {
535 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc;
536
537 if (!psoc) {
538 wifi_pos_err("psoc is null");
539 return QDF_STATUS_E_NULL_VALUE;
540 }
541
542 if (!handler) {
543 wifi_pos_err("Null callback");
544 return QDF_STATUS_E_NULL_VALUE;
545 }
546 wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(psoc);
547 if (!wifi_pos_psoc) {
548 wifi_pos_err("wifi_pos priv obj is null");
549 return QDF_STATUS_E_NULL_VALUE;
550 }
551
552 wifi_pos_psoc->wifi_pos_get_fw_phy_mode_for_freq = handler;
553
554 return QDF_STATUS_SUCCESS;
555 }
556
557 #ifndef CNSS_GENL
wifi_pos_register_get_pdev_id_by_dev_name(struct wlan_objmgr_psoc * psoc,QDF_STATUS (* handler)(char * dev_name,uint8_t * pdev_id,struct wlan_objmgr_psoc ** psoc))558 QDF_STATUS wifi_pos_register_get_pdev_id_by_dev_name(
559 struct wlan_objmgr_psoc *psoc,
560 QDF_STATUS (*handler)(char *dev_name, uint8_t *pdev_id,
561 struct wlan_objmgr_psoc **psoc))
562 {
563 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = NULL;
564 struct wlan_objmgr_psoc *tmp_psoc = wifi_pos_get_psoc();
565
566 if (!psoc) {
567 wifi_pos_err("psoc is null");
568 return QDF_STATUS_E_NULL_VALUE;
569 }
570
571 if (!handler) {
572 wifi_pos_err("Null callback");
573 return QDF_STATUS_E_NULL_VALUE;
574 }
575
576 if (tmp_psoc)
577 wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(tmp_psoc);
578
579 if (!wifi_pos_psoc) {
580 wifi_pos_err("wifi_pos priv obj is null");
581 return QDF_STATUS_E_NULL_VALUE;
582 }
583
584 wifi_pos_psoc->wifi_pos_get_pdev_id_by_dev_name = handler;
585
586 return QDF_STATUS_SUCCESS;
587 }
588
589 #ifdef WLAN_RTT_MEASUREMENT_NOTIFICATION
wifi_pos_register_measurement_request_notification(struct wlan_objmgr_psoc * psoc,QDF_STATUS (* handler)(struct wlan_objmgr_pdev * pdev,struct rtt_channel_info * chinfo))590 QDF_STATUS wifi_pos_register_measurement_request_notification(
591 struct wlan_objmgr_psoc *psoc,
592 QDF_STATUS (*handler)(struct wlan_objmgr_pdev *pdev,
593 struct rtt_channel_info *chinfo))
594 {
595 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = NULL;
596 struct wlan_objmgr_psoc *tmp_psoc = wifi_pos_get_psoc();
597
598 if (!psoc) {
599 wifi_pos_err("psoc is null");
600 return QDF_STATUS_E_NULL_VALUE;
601 }
602
603 if (!handler) {
604 wifi_pos_err("Null callback");
605 return QDF_STATUS_E_NULL_VALUE;
606 }
607
608 if (tmp_psoc)
609 wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(tmp_psoc);
610
611 if (!wifi_pos_psoc) {
612 wifi_pos_err("wifi_pos priv obj is null");
613 return QDF_STATUS_E_NULL_VALUE;
614 }
615
616 wifi_pos_psoc->wifi_pos_measurement_request_notification = handler;
617
618 return QDF_STATUS_SUCCESS;
619 }
620 #endif /* WLAN_RTT_MEASUREMENT_NOTIFICATION */
621
wifi_pos_register_get_max_fw_phymode_for_channels(struct wlan_objmgr_psoc * psoc,QDF_STATUS (* handler)(struct wlan_objmgr_pdev * pdev,struct wifi_pos_channel_power * chan_list,uint16_t wifi_pos_num_chans))622 QDF_STATUS wifi_pos_register_get_max_fw_phymode_for_channels(
623 struct wlan_objmgr_psoc *psoc,
624 QDF_STATUS (*handler)(struct wlan_objmgr_pdev *pdev,
625 struct wifi_pos_channel_power *chan_list,
626 uint16_t wifi_pos_num_chans))
627 {
628 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = NULL;
629 struct wlan_objmgr_psoc *tmp_psoc = wifi_pos_get_psoc();
630
631 if (!psoc) {
632 wifi_pos_err("psoc is null");
633 return QDF_STATUS_E_NULL_VALUE;
634 }
635
636 if (!handler) {
637 wifi_pos_err("Null callback");
638 return QDF_STATUS_E_NULL_VALUE;
639 }
640
641 if (tmp_psoc)
642 wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(tmp_psoc);
643
644 if (!wifi_pos_psoc) {
645 wifi_pos_err("wifi_pos priv obj is null");
646 return QDF_STATUS_E_NULL_VALUE;
647 }
648
649 wifi_pos_psoc->wifi_pos_get_max_fw_phymode_for_channels = handler;
650
651 return QDF_STATUS_SUCCESS;
652 }
653 #endif /* CNSS_GENL */
654
wifi_pos_register_send_action(struct wlan_objmgr_psoc * psoc,void (* handler)(struct wlan_objmgr_psoc * psoc,uint32_t sub_type,uint8_t * buf,uint32_t buf_len))655 QDF_STATUS wifi_pos_register_send_action(
656 struct wlan_objmgr_psoc *psoc,
657 void (*handler)(struct wlan_objmgr_psoc *psoc,
658 uint32_t sub_type,
659 uint8_t *buf,
660 uint32_t buf_len))
661 {
662 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc = NULL;
663 struct wlan_objmgr_psoc *tmp_psoc = wifi_pos_get_psoc();
664
665 if (!psoc) {
666 wifi_pos_err("psoc is null");
667 return QDF_STATUS_E_NULL_VALUE;
668 }
669
670 if (!handler) {
671 wifi_pos_err("Null callback");
672 return QDF_STATUS_E_NULL_VALUE;
673 }
674
675 if (tmp_psoc)
676 wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(tmp_psoc);
677
678 if (!wifi_pos_psoc) {
679 wifi_pos_err("wifi_pos priv obj is null");
680 return QDF_STATUS_E_NULL_VALUE;
681 }
682
683 wifi_pos_psoc->wifi_pos_send_action = handler;
684
685 return QDF_STATUS_SUCCESS;
686 }
687
wifi_pos_register_osif_callbacks(struct wifi_pos_osif_ops * ops)688 QDF_STATUS wifi_pos_register_osif_callbacks(struct wifi_pos_osif_ops *ops)
689 {
690 struct wifi_pos_psoc_priv_obj *wifi_pos_obj =
691 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc());
692
693 if (!wifi_pos_obj) {
694 wifi_pos_err("wifi_pos priv obj is null");
695 return QDF_STATUS_E_NULL_VALUE;
696 }
697
698 wifi_pos_obj->osif_cb = ops;
699
700 return QDF_STATUS_SUCCESS;
701 }
702
wifi_pos_get_osif_callbacks(void)703 struct wifi_pos_osif_ops *wifi_pos_get_osif_callbacks(void)
704 {
705 struct wifi_pos_psoc_priv_obj *wifi_pos_obj =
706 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc());
707
708 if (!wifi_pos_obj) {
709 wifi_pos_err("wifi_pos priv obj is null");
710 return NULL;
711 }
712
713 return wifi_pos_obj->osif_cb;
714 }
715
716 #if defined(WIFI_POS_CONVERGED) && defined(WLAN_FEATURE_RTT_11AZ_SUPPORT)
wifi_pos_set_rsta_sec_ltf_cap(bool val)717 void wifi_pos_set_rsta_sec_ltf_cap(bool val)
718 {
719 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
720 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc());
721
722 if (!wifi_pos_psoc) {
723 wifi_pos_alert("unable to get wifi_pos psoc obj");
724 return;
725 }
726
727 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
728 wifi_pos_psoc->enable_rsta_secure_ltf_support = val;
729 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
730 }
731
wifi_pos_get_rsta_sec_ltf_cap(void)732 bool wifi_pos_get_rsta_sec_ltf_cap(void)
733 {
734 bool value;
735 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
736 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc());
737
738 if (!wifi_pos_psoc) {
739 wifi_pos_alert("unable to get wifi_pos psoc obj");
740 return false;
741 }
742
743 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
744 value = wifi_pos_psoc->enable_rsta_secure_ltf_support;
745 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
746
747 return value;
748 }
749
wifi_pos_set_rsta_11az_ranging_cap(uint32_t val)750 void wifi_pos_set_rsta_11az_ranging_cap(uint32_t val)
751 {
752 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
753 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc());
754
755 if (!wifi_pos_psoc) {
756 wifi_pos_alert("unable to get wifi_pos psoc obj");
757 return;
758 }
759
760 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
761 wifi_pos_psoc->enable_rsta_11az_ranging = val;
762 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
763 }
764
wifi_pos_get_rsta_11az_ranging_cap(void)765 uint32_t wifi_pos_get_rsta_11az_ranging_cap(void)
766 {
767 uint32_t value;
768 struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
769 wifi_pos_get_psoc_priv_obj(wifi_pos_get_psoc());
770
771 if (!wifi_pos_psoc) {
772 wifi_pos_alert("unable to get wifi_pos psoc obj");
773 return false;
774 }
775
776 qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
777 value = wifi_pos_psoc->enable_rsta_11az_ranging;
778 qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
779
780 return value;
781 }
782 #endif
783