xref: /wlan-driver/qca-wifi-host-cmn/umac/afc/dispatcher/src/wlan_afc_ucfg_api.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
3*5113495bSYour Name  *
4*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for any
5*5113495bSYour Name  * purpose with or without fee is hereby granted, provided that the above
6*5113495bSYour Name  * copyright notice and this permission notice appear in all copies.
7*5113495bSYour Name  *
8*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9*5113495bSYour Name  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10*5113495bSYour Name  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11*5113495bSYour Name  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12*5113495bSYour Name  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13*5113495bSYour Name  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14*5113495bSYour Name  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*5113495bSYour Name  */
16*5113495bSYour Name 
17*5113495bSYour Name /**
18*5113495bSYour Name  * DOC: wlan_afc_ucfg_api.c
19*5113495bSYour Name  *
20*5113495bSYour Name  * This file has the AFC dispatcher API implementation which is exposed
21*5113495bSYour Name  * to outside of AFC component.
22*5113495bSYour Name  */
23*5113495bSYour Name 
24*5113495bSYour Name #include <wlan_afc_main.h>
25*5113495bSYour Name #include <wlan_afc_ucfg_api.h>
26*5113495bSYour Name #include <wlan_objmgr_global_obj.h>
27*5113495bSYour Name 
ucfg_afc_register_data_send_cb(struct wlan_objmgr_psoc * psoc,send_response_to_afcmem func)28*5113495bSYour Name QDF_STATUS ucfg_afc_register_data_send_cb(struct wlan_objmgr_psoc *psoc,
29*5113495bSYour Name 					  send_response_to_afcmem func)
30*5113495bSYour Name {
31*5113495bSYour Name 	return wlan_afc_register_data_send_cb(psoc, func);
32*5113495bSYour Name }
33*5113495bSYour Name 
ucfg_afc_data_send(struct wlan_objmgr_psoc * psoc,struct wlan_objmgr_pdev * pdev,struct wlan_afc_host_resp * data,uint32_t len)34*5113495bSYour Name int ucfg_afc_data_send(struct wlan_objmgr_psoc *psoc,
35*5113495bSYour Name 		       struct wlan_objmgr_pdev *pdev,
36*5113495bSYour Name 		       struct wlan_afc_host_resp *data,
37*5113495bSYour Name 		       uint32_t len)
38*5113495bSYour Name {
39*5113495bSYour Name 	return wlan_afc_data_send(psoc, pdev, data, len);
40*5113495bSYour Name }
41*5113495bSYour Name 
ucfg_afc_init(void)42*5113495bSYour Name QDF_STATUS ucfg_afc_init(void)
43*5113495bSYour Name {
44*5113495bSYour Name 	QDF_STATUS status;
45*5113495bSYour Name 
46*5113495bSYour Name 	status = wlan_objmgr_register_psoc_create_handler(WLAN_UMAC_COMP_AFC,
47*5113495bSYour Name 							  wlan_afc_psoc_created_notification,
48*5113495bSYour Name 							  NULL);
49*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status)) {
50*5113495bSYour Name 		afc_err("Failed to register psoc create handler");
51*5113495bSYour Name 		goto fail_create_psoc;
52*5113495bSYour Name 	}
53*5113495bSYour Name 
54*5113495bSYour Name 	status = wlan_objmgr_register_psoc_destroy_handler(WLAN_UMAC_COMP_AFC,
55*5113495bSYour Name 							   wlan_afc_psoc_destroyed_notification,
56*5113495bSYour Name 							   NULL);
57*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status)) {
58*5113495bSYour Name 		afc_err("Failed to register psoc delete handler");
59*5113495bSYour Name 		goto fail_psoc_destroy;
60*5113495bSYour Name 	}
61*5113495bSYour Name 
62*5113495bSYour Name 	status = wlan_objmgr_register_pdev_create_handler(WLAN_UMAC_COMP_AFC,
63*5113495bSYour Name 							  wlan_afc_pdev_obj_create_handler,
64*5113495bSYour Name 							  NULL);
65*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status)) {
66*5113495bSYour Name 		afc_err("Failed to register pdev create handler");
67*5113495bSYour Name 		goto fail_create_pdev;
68*5113495bSYour Name 	}
69*5113495bSYour Name 
70*5113495bSYour Name 	status = wlan_objmgr_register_pdev_destroy_handler(WLAN_UMAC_COMP_AFC,
71*5113495bSYour Name 							   wlan_afc_pdev_obj_destroy_handler,
72*5113495bSYour Name 							   NULL);
73*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status)) {
74*5113495bSYour Name 		afc_err("Failed to register pdev delete handler");
75*5113495bSYour Name 		goto fail_pdev_destroy;
76*5113495bSYour Name 	}
77*5113495bSYour Name 
78*5113495bSYour Name 	return status;
79*5113495bSYour Name 
80*5113495bSYour Name fail_pdev_destroy:
81*5113495bSYour Name 	wlan_objmgr_unregister_pdev_create_handler(WLAN_UMAC_COMP_AFC,
82*5113495bSYour Name 						   wlan_afc_pdev_obj_create_handler,
83*5113495bSYour Name 						   NULL);
84*5113495bSYour Name fail_create_pdev:
85*5113495bSYour Name 	wlan_objmgr_unregister_psoc_destroy_handler(WLAN_UMAC_COMP_AFC,
86*5113495bSYour Name 						    wlan_afc_psoc_destroyed_notification,
87*5113495bSYour Name 						    NULL);
88*5113495bSYour Name fail_psoc_destroy:
89*5113495bSYour Name 	wlan_objmgr_unregister_psoc_create_handler(WLAN_UMAC_COMP_AFC,
90*5113495bSYour Name 						   wlan_afc_psoc_created_notification,
91*5113495bSYour Name 						   NULL);
92*5113495bSYour Name fail_create_psoc:
93*5113495bSYour Name 	return status;
94*5113495bSYour Name }
95*5113495bSYour Name 
ucfg_afc_deinit(void)96*5113495bSYour Name QDF_STATUS ucfg_afc_deinit(void)
97*5113495bSYour Name {
98*5113495bSYour Name 	QDF_STATUS status;
99*5113495bSYour Name 
100*5113495bSYour Name 	status = wlan_objmgr_unregister_pdev_destroy_handler(WLAN_UMAC_COMP_AFC,
101*5113495bSYour Name 							     wlan_afc_pdev_obj_destroy_handler,
102*5113495bSYour Name 							     NULL);
103*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status))
104*5113495bSYour Name 		afc_err("Failed to unregister pdev destroy handler");
105*5113495bSYour Name 
106*5113495bSYour Name 	status = wlan_objmgr_unregister_pdev_create_handler(WLAN_UMAC_COMP_AFC,
107*5113495bSYour Name 							    wlan_afc_pdev_obj_create_handler,
108*5113495bSYour Name 							    NULL);
109*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status))
110*5113495bSYour Name 		afc_err("Failed to unregister pdev create handler");
111*5113495bSYour Name 
112*5113495bSYour Name 	status = wlan_objmgr_unregister_psoc_destroy_handler(WLAN_UMAC_COMP_AFC,
113*5113495bSYour Name 							     wlan_afc_psoc_destroyed_notification,
114*5113495bSYour Name 							     NULL);
115*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status))
116*5113495bSYour Name 		afc_err("Failed to unregister psoc destroy handler");
117*5113495bSYour Name 
118*5113495bSYour Name 	status = wlan_objmgr_unregister_psoc_create_handler(WLAN_UMAC_COMP_AFC,
119*5113495bSYour Name 							    wlan_afc_psoc_created_notification,
120*5113495bSYour Name 							    NULL);
121*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status))
122*5113495bSYour Name 		afc_err("Failed to unregister psoc create handler");
123*5113495bSYour Name 
124*5113495bSYour Name 	return status;
125*5113495bSYour Name }
126