xref: /wlan-dirver/qca-wifi-host-cmn/umac/wifi_pos/src/wifi_pos_api.c (revision d0c05845839e5f2ba5a8dcebe0cd3e4cd4e8dfcf)
1 /*
2  * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2022 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 *
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 
55 struct wifi_pos_legacy_ops *
56 wifi_pos_get_legacy_ops(struct wlan_objmgr_psoc *psoc)
57 {
58 	struct wifi_pos_psoc_priv_obj *wifi_pos_obj =
59 			wifi_pos_get_psoc_priv_obj(psoc);
60 
61 	if (!wifi_pos_obj)
62 		return NULL;
63 
64 	return wifi_pos_obj->legacy_ops;
65 }
66 
67 QDF_STATUS
68 wifi_pos_set_legacy_ops(struct wlan_objmgr_psoc *psoc,
69 			struct wifi_pos_legacy_ops *legacy_ops)
70 {
71 	struct wifi_pos_psoc_priv_obj *wifi_pos_obj =
72 			wifi_pos_get_psoc_priv_obj(psoc);
73 
74 	if (!wifi_pos_obj)
75 		return QDF_STATUS_E_FAILURE;
76 
77 	wifi_pos_obj->legacy_ops = legacy_ops;
78 
79 	return QDF_STATUS_SUCCESS;
80 }
81 
82 struct wlan_lmac_if_wifi_pos_tx_ops *
83 wifi_pos_get_tx_ops(struct wlan_objmgr_psoc *psoc)
84 {
85 	struct wlan_lmac_if_tx_ops *tx_ops;
86 
87 	if (!psoc) {
88 		wifi_pos_err("psoc is null");
89 		return NULL;
90 	}
91 
92 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
93 	if (!tx_ops) {
94 		wifi_pos_err("tx_ops is NULL");
95 		return NULL;
96 	}
97 
98 	return &tx_ops->wifi_pos_tx_ops;
99 }
100 
101 QDF_STATUS wifi_pos_init(void)
102 {
103 	QDF_STATUS status;
104 
105 	wifi_pos_lock_init();
106 
107 	/* register psoc create handler functions. */
108 	status = wlan_objmgr_register_psoc_create_handler(
109 		WLAN_UMAC_COMP_WIFI_POS,
110 		wifi_pos_psoc_obj_created_notification,
111 		NULL);
112 	if (QDF_IS_STATUS_ERROR(status)) {
113 		wifi_pos_err("register_psoc_create_handler failed, status: %d",
114 			     status);
115 		return status;
116 	}
117 
118 	/* register psoc delete handler functions. */
119 	status = wlan_objmgr_register_psoc_destroy_handler(
120 		WLAN_UMAC_COMP_WIFI_POS,
121 		wifi_pos_psoc_obj_destroyed_notification,
122 		NULL);
123 	if (QDF_IS_STATUS_ERROR(status)) {
124 		wifi_pos_err("register_psoc_destroy_handler failed, status: %d",
125 			     status);
126 		goto fail_psoc_destroy_handler;
127 	}
128 
129 	status = wlan_objmgr_register_vdev_create_handler(
130 			WLAN_UMAC_COMP_WIFI_POS,
131 			wifi_pos_vdev_created_notification, NULL);
132 	if (QDF_IS_STATUS_ERROR(status)) {
133 		wifi_pos_err("register_vdev_create_handler failed, status: %d",
134 			     status);
135 		goto fail_vdev_create_handler;
136 	}
137 
138 	status = wlan_objmgr_register_vdev_destroy_handler(
139 			WLAN_UMAC_COMP_WIFI_POS,
140 			wifi_pos_vdev_destroyed_notification, NULL);
141 	if (QDF_IS_STATUS_ERROR(status)) {
142 		wifi_pos_err("register_vdev_destroy_handler failed, status: %d",
143 			     status);
144 		goto fail_vdev_destroy_handler;
145 	}
146 
147 	status =  wlan_objmgr_register_peer_create_handler(
148 			WLAN_UMAC_COMP_WIFI_POS,
149 			wifi_pos_peer_object_created_notification,
150 			NULL);
151 	if (QDF_IS_STATUS_ERROR(status)) {
152 		wifi_pos_err("peer create register notification failed");
153 		goto fail_peer_create_handler;
154 	}
155 
156 	status = wlan_objmgr_register_peer_destroy_handler(
157 				WLAN_UMAC_COMP_WIFI_POS,
158 				wifi_pos_peer_object_destroyed_notification,
159 				NULL);
160 	if (QDF_IS_STATUS_ERROR(status)) {
161 		wifi_pos_err("peer destroy register notification failed");
162 		goto fail_peer_destroy_handler;
163 	}
164 
165 	return status;
166 
167 fail_peer_destroy_handler:
168 	wlan_objmgr_unregister_peer_create_handler(
169 			WLAN_UMAC_COMP_WIFI_POS,
170 			wifi_pos_peer_object_created_notification,
171 			NULL);
172 fail_peer_create_handler:
173 	wlan_objmgr_unregister_vdev_destroy_handler(
174 			WLAN_UMAC_COMP_WIFI_POS,
175 			wifi_pos_vdev_destroyed_notification, NULL);
176 
177 fail_vdev_destroy_handler:
178 	wlan_objmgr_unregister_vdev_create_handler(
179 			WLAN_UMAC_COMP_WIFI_POS,
180 			wifi_pos_vdev_created_notification, NULL);
181 
182 fail_vdev_create_handler:
183 	wlan_objmgr_unregister_psoc_destroy_handler(
184 			WLAN_UMAC_COMP_WIFI_POS,
185 			wifi_pos_psoc_obj_destroyed_notification, NULL);
186 
187 fail_psoc_destroy_handler:
188 	wlan_objmgr_unregister_psoc_create_handler(
189 			WLAN_UMAC_COMP_WIFI_POS,
190 			wifi_pos_psoc_obj_created_notification, NULL);
191 
192 	return status;
193 }
194 
195 QDF_STATUS wifi_pos_deinit(void)
196 {
197 	QDF_STATUS status;
198 
199 	status = wlan_objmgr_unregister_peer_destroy_handler(
200 				WLAN_UMAC_COMP_WIFI_POS,
201 				wifi_pos_peer_object_destroyed_notification,
202 				NULL);
203 	if (QDF_IS_STATUS_ERROR(status))
204 		wifi_pos_err("unable to unregister peer destroy handle");
205 
206 	status = wlan_objmgr_unregister_peer_create_handler(
207 				WLAN_UMAC_COMP_WIFI_POS,
208 				wifi_pos_peer_object_created_notification,
209 				NULL);
210 	if (QDF_IS_STATUS_ERROR(status))
211 		wifi_pos_err("unable to unregister peer create handle");
212 
213 	status = wlan_objmgr_unregister_vdev_destroy_handler(
214 				WLAN_UMAC_COMP_WIFI_POS,
215 				wifi_pos_vdev_destroyed_notification, NULL);
216 	if (QDF_IS_STATUS_ERROR(status))
217 		wifi_pos_err("unregister_vdev_destroy_handler failed, status: %d",
218 			     status);
219 
220 	status = wlan_objmgr_unregister_vdev_create_handler(
221 				WLAN_UMAC_COMP_WIFI_POS,
222 				wifi_pos_vdev_created_notification, NULL);
223 	if (QDF_IS_STATUS_ERROR(status))
224 		wifi_pos_err("unregister_vdev_create_handler failed, status: %d",
225 			     status);
226 
227 	/* deregister psoc create handler functions. */
228 	status = wlan_objmgr_unregister_psoc_create_handler(
229 				WLAN_UMAC_COMP_WIFI_POS,
230 				wifi_pos_psoc_obj_created_notification,
231 				NULL);
232 	if (QDF_IS_STATUS_ERROR(status)) {
233 		wifi_pos_err("unregister_psoc_create_handler failed, status: %d",
234 			     status);
235 		return status;
236 	}
237 
238 	/* deregister psoc delete handler functions. */
239 	status = wlan_objmgr_unregister_psoc_destroy_handler(
240 				WLAN_UMAC_COMP_WIFI_POS,
241 				wifi_pos_psoc_obj_destroyed_notification,
242 				NULL);
243 	if (QDF_IS_STATUS_ERROR(status)) {
244 		wifi_pos_err("unregister_psoc_destroy_handler failed, status: %d",
245 			     status);
246 	}
247 
248 	wifi_pos_lock_deinit();
249 
250 	return QDF_STATUS_SUCCESS;
251 }
252 
253 QDF_STATUS wifi_pos_psoc_enable(struct wlan_objmgr_psoc *psoc)
254 {
255 	QDF_STATUS status;
256 	struct wlan_lmac_if_wifi_pos_tx_ops *tx_ops;
257 
258 	tx_ops = wifi_pos_get_tx_ops(psoc);
259 	if (!tx_ops) {
260 		wifi_pos_err("tx_ops is null");
261 		return QDF_STATUS_E_NULL_VALUE;
262 	}
263 
264 	status = tx_ops->wifi_pos_register_events(psoc);
265 
266 	if (QDF_IS_STATUS_ERROR(status))
267 		wifi_pos_err("target_if_wifi_pos_register_events failed");
268 
269 	return status;
270 }
271 
272 QDF_STATUS wifi_pos_psoc_disable(struct wlan_objmgr_psoc *psoc)
273 {
274 	QDF_STATUS status;
275 	struct wlan_lmac_if_wifi_pos_tx_ops *tx_ops;
276 
277 	tx_ops = wifi_pos_get_tx_ops(psoc);
278 	if (!tx_ops) {
279 		wifi_pos_err("tx_ops is null");
280 		return QDF_STATUS_E_NULL_VALUE;
281 	}
282 
283 	status = tx_ops->wifi_pos_deregister_events(psoc);
284 
285 	if (QDF_IS_STATUS_ERROR(status))
286 		wifi_pos_err("target_if_wifi_pos_deregister_events failed");
287 
288 	return QDF_STATUS_SUCCESS;
289 }
290 
291 struct wlan_wifi_pos_peer_priv_obj *
292 wifi_pos_get_peer_private_object(struct wlan_objmgr_peer *peer)
293 {
294 	struct wlan_wifi_pos_peer_priv_obj *peer_priv;
295 
296 	if (!peer) {
297 		wifi_pos_err("Peer is NULL");
298 		return NULL;
299 	}
300 
301 	peer_priv =
302 		wlan_objmgr_peer_get_comp_private_obj(peer,
303 						      WLAN_UMAC_COMP_WIFI_POS);
304 
305 	return peer_priv;
306 }
307 
308 void wifi_pos_set_oem_target_type(struct wlan_objmgr_psoc *psoc, uint32_t val)
309 {
310 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
311 			wifi_pos_get_psoc_priv_obj(psoc);
312 
313 	if (!wifi_pos_psoc) {
314 		wifi_pos_err("wifi_pos priv obj is null");
315 		return;
316 	}
317 
318 	qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
319 	wifi_pos_psoc->oem_target_type = val;
320 	qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
321 }
322 
323 void wifi_pos_set_oem_fw_version(struct wlan_objmgr_psoc *psoc, uint32_t val)
324 {
325 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
326 			wifi_pos_get_psoc_priv_obj(psoc);
327 
328 	if (!wifi_pos_psoc) {
329 		wifi_pos_err("wifi_pos priv obj is null");
330 		return;
331 	}
332 
333 	qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
334 	wifi_pos_psoc->oem_fw_version = val;
335 	qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
336 }
337 
338 void wifi_pos_set_drv_ver_major(struct wlan_objmgr_psoc *psoc, uint8_t val)
339 {
340 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
341 			wifi_pos_get_psoc_priv_obj(psoc);
342 
343 	if (!wifi_pos_psoc) {
344 		wifi_pos_err("wifi_pos priv obj is null");
345 		return;
346 	}
347 
348 	qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
349 	wifi_pos_psoc->driver_version.major = val;
350 	qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
351 }
352 
353 void wifi_pos_set_drv_ver_minor(struct wlan_objmgr_psoc *psoc, uint8_t val)
354 {
355 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
356 			wifi_pos_get_psoc_priv_obj(psoc);
357 
358 	if (!wifi_pos_psoc) {
359 		wifi_pos_err("wifi_pos priv obj is null");
360 		return;
361 	}
362 
363 	qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
364 	wifi_pos_psoc->driver_version.minor = val;
365 	qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
366 }
367 
368 void wifi_pos_set_drv_ver_patch(struct wlan_objmgr_psoc *psoc, uint8_t val)
369 {
370 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
371 			wifi_pos_get_psoc_priv_obj(psoc);
372 
373 	if (!wifi_pos_psoc) {
374 		wifi_pos_err("wifi_pos priv obj is null");
375 		return;
376 	}
377 
378 	qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
379 	wifi_pos_psoc->driver_version.patch = val;
380 	qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
381 }
382 
383 void wifi_pos_set_drv_ver_build(struct wlan_objmgr_psoc *psoc, uint8_t val)
384 {
385 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
386 			wifi_pos_get_psoc_priv_obj(psoc);
387 
388 	if (!wifi_pos_psoc) {
389 		wifi_pos_err("wifi_pos priv obj is null");
390 		return;
391 	}
392 
393 	qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
394 	wifi_pos_psoc->driver_version.build = val;
395 	qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
396 }
397 
398 void wifi_pos_set_dwell_time_min(struct wlan_objmgr_psoc *psoc, uint16_t val)
399 {
400 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
401 			wifi_pos_get_psoc_priv_obj(psoc);
402 
403 	if (!wifi_pos_psoc) {
404 		wifi_pos_err("wifi_pos priv obj is null");
405 		return;
406 	}
407 
408 	qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
409 	wifi_pos_psoc->allowed_dwell_time_min = val;
410 	qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
411 }
412 void wifi_pos_set_dwell_time_max(struct wlan_objmgr_psoc *psoc, uint16_t val)
413 {
414 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
415 			wifi_pos_get_psoc_priv_obj(psoc);
416 
417 	if (!wifi_pos_psoc) {
418 		wifi_pos_err("wifi_pos priv obj is null");
419 		return;
420 	}
421 
422 	qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
423 	wifi_pos_psoc->allowed_dwell_time_max = val;
424 	qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
425 }
426 
427 void wifi_pos_set_current_dwell_time_max(struct wlan_objmgr_psoc *psoc,
428 					 uint16_t val)
429 {
430 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
431 			wifi_pos_get_psoc_priv_obj(psoc);
432 
433 	if (!wifi_pos_psoc) {
434 		wifi_pos_err("wifi_pos priv obj is null");
435 		return;
436 	}
437 
438 	qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
439 	wifi_pos_psoc->current_dwell_time_max = val;
440 	qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
441 }
442 
443 void wifi_pos_set_current_dwell_time_min(struct wlan_objmgr_psoc *psoc,
444 					 uint16_t val)
445 {
446 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
447 			wifi_pos_get_psoc_priv_obj(psoc);
448 
449 	if (!wifi_pos_psoc) {
450 		wifi_pos_err("wifi_pos priv obj is null");
451 		return;
452 	}
453 
454 	qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
455 	wifi_pos_psoc->current_dwell_time_max = val;
456 	qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
457 }
458 
459 uint32_t wifi_pos_get_app_pid(struct wlan_objmgr_psoc *psoc)
460 {
461 	uint32_t app_pid;
462 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
463 				wifi_pos_get_psoc_priv_obj(psoc);
464 
465 	if (!wifi_pos_psoc) {
466 		wifi_pos_err("wifi_pos priv obj is null");
467 		return 0;
468 	}
469 
470 	qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
471 	app_pid = wifi_pos_psoc->app_pid;
472 	qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
473 
474 	return app_pid;
475 
476 }
477 
478 bool wifi_pos_is_app_registered(struct wlan_objmgr_psoc *psoc)
479 {
480 	bool is_app_registered;
481 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc =
482 				wifi_pos_get_psoc_priv_obj(psoc);
483 
484 	if (!wifi_pos_psoc) {
485 		wifi_pos_err("wifi_pos priv obj is null");
486 		return false;
487 	}
488 
489 	qdf_spin_lock_bh(&wifi_pos_psoc->wifi_pos_lock);
490 	is_app_registered = wifi_pos_psoc->is_app_registered;
491 	qdf_spin_unlock_bh(&wifi_pos_psoc->wifi_pos_lock);
492 
493 	return is_app_registered;
494 }
495 
496 #ifdef WLAN_FEATURE_CIF_CFR
497 QDF_STATUS wifi_pos_init_cir_cfr_rings(struct wlan_objmgr_psoc *psoc,
498 				   void *hal_soc, uint8_t num_mac, void *buf)
499 {
500 	return target_if_wifi_pos_init_cir_cfr_rings(psoc, hal_soc,
501 						     num_mac, buf);
502 }
503 #endif
504 
505 QDF_STATUS
506 wifi_pos_register_get_phy_mode_cb(struct wlan_objmgr_psoc *psoc,
507 				  void (*handler)(qdf_freq_t, uint32_t,
508 						  uint32_t *))
509 {
510 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc;
511 
512 	if (!psoc) {
513 		wifi_pos_err("psoc is null");
514 		return QDF_STATUS_E_NULL_VALUE;
515 	}
516 
517 	if (!handler) {
518 		wifi_pos_err("Null callback");
519 		return QDF_STATUS_E_NULL_VALUE;
520 	}
521 	wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(psoc);
522 	if (!wifi_pos_psoc) {
523 		wifi_pos_err("wifi_pos priv obj is null");
524 		return QDF_STATUS_E_NULL_VALUE;
525 	}
526 
527 	wifi_pos_psoc->wifi_pos_get_phy_mode = handler;
528 
529 	return QDF_STATUS_SUCCESS;
530 }
531 
532 QDF_STATUS wifi_pos_register_get_fw_phy_mode_for_freq_cb(
533 				struct wlan_objmgr_psoc *psoc,
534 				void (*handler)(uint32_t, uint32_t, uint32_t *))
535 {
536 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc;
537 
538 	if (!psoc) {
539 		wifi_pos_err("psoc is null");
540 		return QDF_STATUS_E_NULL_VALUE;
541 	}
542 
543 	if (!handler) {
544 		wifi_pos_err("Null callback");
545 		return QDF_STATUS_E_NULL_VALUE;
546 	}
547 	wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(psoc);
548 	if (!wifi_pos_psoc) {
549 		wifi_pos_err("wifi_pos priv obj is null");
550 		return QDF_STATUS_E_NULL_VALUE;
551 	}
552 
553 	wifi_pos_psoc->wifi_pos_get_fw_phy_mode_for_freq = handler;
554 
555 	return QDF_STATUS_SUCCESS;
556 }
557 
558 #ifndef CNSS_GENL
559 QDF_STATUS wifi_pos_register_get_pdev_id_by_dev_name(
560 		struct wlan_objmgr_psoc *psoc,
561 		QDF_STATUS (*handler)(char *dev_name, uint8_t *pdev_id,
562 				      struct wlan_objmgr_psoc **psoc))
563 {
564 	struct wifi_pos_psoc_priv_obj *wifi_pos_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 	wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(psoc);
577 	if (!wifi_pos_psoc) {
578 		wifi_pos_err("wifi_pos priv obj is null");
579 		return QDF_STATUS_E_NULL_VALUE;
580 	}
581 
582 	wifi_pos_psoc->wifi_pos_get_pdev_id_by_dev_name = handler;
583 
584 	return QDF_STATUS_SUCCESS;
585 }
586 
587 #ifdef WLAN_RTT_MEASUREMENT_NOTIFICATION
588 QDF_STATUS wifi_pos_register_measurement_request_notification(
589 		struct wlan_objmgr_psoc *psoc,
590 		QDF_STATUS (*handler)(struct wlan_objmgr_pdev *pdev,
591 				      struct rtt_channel_info *chinfo))
592 {
593 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc;
594 
595 	if (!psoc) {
596 		wifi_pos_err("psoc is null");
597 		return QDF_STATUS_E_NULL_VALUE;
598 	}
599 
600 	if (!handler) {
601 		wifi_pos_err("Null callback");
602 		return QDF_STATUS_E_NULL_VALUE;
603 	}
604 
605 	wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(psoc);
606 	if (!wifi_pos_psoc) {
607 		wifi_pos_err("wifi_pos priv obj is null");
608 		return QDF_STATUS_E_NULL_VALUE;
609 	}
610 
611 	wifi_pos_psoc->wifi_pos_measurement_request_notification = handler;
612 
613 	return QDF_STATUS_SUCCESS;
614 }
615 #endif /* WLAN_RTT_MEASUREMENT_NOTIFICATION */
616 
617 QDF_STATUS wifi_pos_register_get_max_fw_phymode_for_channels(
618 		struct wlan_objmgr_psoc *psoc,
619 		QDF_STATUS (*handler)(struct wlan_objmgr_pdev *pdev,
620 				      struct wifi_pos_channel_power *chan_list,
621 				      uint16_t wifi_pos_num_chans))
622 {
623 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc;
624 
625 	if (!psoc) {
626 		wifi_pos_err("psoc is null");
627 		return QDF_STATUS_E_NULL_VALUE;
628 	}
629 
630 	if (!handler) {
631 		wifi_pos_err("Null callback");
632 		return QDF_STATUS_E_NULL_VALUE;
633 	}
634 
635 	wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(psoc);
636 	if (!wifi_pos_psoc) {
637 		wifi_pos_err("wifi_pos priv obj is null");
638 		return QDF_STATUS_E_NULL_VALUE;
639 	}
640 
641 	wifi_pos_psoc->wifi_pos_get_max_fw_phymode_for_channels = handler;
642 
643 	return QDF_STATUS_SUCCESS;
644 }
645 #endif /* CNSS_GENL */
646 
647 QDF_STATUS wifi_pos_register_send_action(
648 				struct wlan_objmgr_psoc *psoc,
649 				void (*handler)(struct wlan_objmgr_psoc *psoc,
650 						uint32_t sub_type,
651 						uint8_t *buf,
652 						uint32_t buf_len))
653 {
654 	struct wifi_pos_psoc_priv_obj *wifi_pos_psoc;
655 
656 	if (!psoc) {
657 		wifi_pos_err("psoc is null");
658 		return QDF_STATUS_E_NULL_VALUE;
659 	}
660 
661 	if (!handler) {
662 		wifi_pos_err("Null callback");
663 		return QDF_STATUS_E_NULL_VALUE;
664 	}
665 	wifi_pos_psoc = wifi_pos_get_psoc_priv_obj(psoc);
666 	if (!wifi_pos_psoc) {
667 		wifi_pos_err("wifi_pos priv obj is null");
668 		return QDF_STATUS_E_NULL_VALUE;
669 	}
670 
671 	wifi_pos_psoc->wifi_pos_send_action = handler;
672 
673 	return QDF_STATUS_SUCCESS;
674 }
675 
676 QDF_STATUS
677 wifi_pos_register_osif_callbacks(struct wlan_objmgr_psoc *psoc,
678 				 struct wifi_pos_osif_ops *ops)
679 {
680 	struct wifi_pos_psoc_priv_obj *wifi_pos_obj =
681 			wifi_pos_get_psoc_priv_obj(psoc);
682 
683 	if (!wifi_pos_obj) {
684 		wifi_pos_err("wifi_pos priv obj is null");
685 		return QDF_STATUS_E_NULL_VALUE;
686 	}
687 
688 	wifi_pos_obj->osif_cb = ops;
689 
690 	return QDF_STATUS_SUCCESS;
691 }
692 
693 struct wifi_pos_osif_ops *
694 wifi_pos_get_osif_callbacks(struct wlan_objmgr_psoc *psoc)
695 {
696 	struct wifi_pos_psoc_priv_obj *wifi_pos_obj =
697 			wifi_pos_get_psoc_priv_obj(psoc);
698 
699 	if (!wifi_pos_obj) {
700 		wifi_pos_err("wifi_pos priv obj is null");
701 		return NULL;
702 	}
703 
704 	return wifi_pos_obj->osif_cb;
705 }
706