xref: /wlan-driver/qca-wifi-host-cmn/umac/scan/core/src/wlan_scan_main.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /*
20  * DOC: contains core scan function definitions
21  */
22 #include <wlan_scan_ucfg_api.h>
23 #include <wlan_scan_utils_api.h>
24 #include "wlan_scan_main.h"
25 
wlan_scan_psoc_created_notification(struct wlan_objmgr_psoc * psoc,void * arg_list)26 QDF_STATUS wlan_scan_psoc_created_notification(struct wlan_objmgr_psoc *psoc,
27 						void *arg_list)
28 {
29 	struct wlan_scan_obj *scan_obj;
30 	QDF_STATUS status = QDF_STATUS_SUCCESS;
31 
32 	scan_obj = qdf_mem_malloc_atomic(sizeof(struct wlan_scan_obj));
33 	if (!scan_obj) {
34 		scm_err("Failed to allocate memory");
35 		return QDF_STATUS_E_NOMEM;
36 	}
37 
38 	/* Attach scan private date to psoc */
39 	status = wlan_objmgr_psoc_component_obj_attach(psoc,
40 		WLAN_UMAC_COMP_SCAN, (void *)scan_obj,
41 		QDF_STATUS_SUCCESS);
42 	if (QDF_IS_STATUS_ERROR(status))
43 		scm_err("Failed to attach psoc scan component");
44 	else
45 		scm_debug("Scan object attach to psoc successful");
46 
47 	return status;
48 }
49 
wlan_scan_psoc_destroyed_notification(struct wlan_objmgr_psoc * psoc,void * arg_list)50 QDF_STATUS wlan_scan_psoc_destroyed_notification(
51 				struct wlan_objmgr_psoc *psoc,
52 				void *arg_list)
53 {
54 	void *scan_obj = NULL;
55 	QDF_STATUS status = QDF_STATUS_SUCCESS;
56 
57 	scan_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
58 			WLAN_UMAC_COMP_SCAN);
59 
60 	if (!scan_obj) {
61 		scm_err("Failed to detach scan in psoc ctx");
62 		return QDF_STATUS_E_FAILURE;
63 	}
64 
65 	status = wlan_objmgr_psoc_component_obj_detach(psoc,
66 		WLAN_UMAC_COMP_SCAN, scan_obj);
67 	if (QDF_IS_STATUS_ERROR(status))
68 		scm_err("Failed to detach psoc scan component");
69 
70 	qdf_mem_free(scan_obj);
71 
72 	return status;
73 }
74 
wlan_scan_vdev_created_notification(struct wlan_objmgr_vdev * vdev,void * arg_list)75 QDF_STATUS wlan_scan_vdev_created_notification(struct wlan_objmgr_vdev *vdev,
76 	void *arg_list)
77 {
78 	struct scan_vdev_obj *scan_vdev_obj;
79 	QDF_STATUS status = QDF_STATUS_SUCCESS;
80 
81 	scan_vdev_obj = qdf_mem_malloc_atomic(sizeof(struct scan_vdev_obj));
82 	if (!scan_vdev_obj) {
83 		scm_err("Failed to allocate memory");
84 		return QDF_STATUS_E_NOMEM;
85 	}
86 
87 	/* Attach scan private date to vdev */
88 	status = wlan_objmgr_vdev_component_obj_attach(vdev,
89 		WLAN_UMAC_COMP_SCAN, (void *)scan_vdev_obj,
90 		QDF_STATUS_SUCCESS);
91 	if (QDF_IS_STATUS_ERROR(status)) {
92 		scm_err("Failed to attach vdev scan component");
93 		qdf_mem_free(scan_vdev_obj);
94 	} else {
95 		scm_debug("vdev scan object attach successful");
96 	}
97 
98 	return status;
99 }
100 
wlan_scan_vdev_destroyed_notification(struct wlan_objmgr_vdev * vdev,void * arg_list)101 QDF_STATUS wlan_scan_vdev_destroyed_notification(
102 	struct wlan_objmgr_vdev *vdev,
103 	void *arg_list)
104 {
105 	void *scan_vdev_obj = NULL;
106 	QDF_STATUS status = QDF_STATUS_SUCCESS;
107 
108 	scan_vdev_obj = wlan_objmgr_vdev_get_comp_private_obj(vdev,
109 			WLAN_UMAC_COMP_SCAN);
110 
111 	if (!scan_vdev_obj) {
112 		scm_err("Failed to detach scan in vdev ctx");
113 		return QDF_STATUS_E_FAILURE;
114 	}
115 
116 	status = wlan_objmgr_vdev_component_obj_detach(vdev,
117 		WLAN_UMAC_COMP_SCAN, scan_vdev_obj);
118 	if (QDF_IS_STATUS_ERROR(status))
119 		scm_err("Failed to detach vdev scan component");
120 
121 	qdf_mem_free(scan_vdev_obj);
122 
123 	return status;
124 }
125