1 /*
2 * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
3 * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4 *
5 *
6 * Permission to use, copy, modify, and/or distribute this software for
7 * any purpose with or without fee is hereby granted, provided that the
8 * above copyright notice and this permission notice appear in all
9 * copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
12 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
15 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
16 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
17 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18 * PERFORMANCE OF THIS SOFTWARE.
19 */
20
21 #ifndef _SPECTRAL_CMN_API_I_H_
22 #define _SPECTRAL_CMN_API_I_H_
23
24 #include "spectral_defs_i.h"
25
26 /**
27 * wlan_spectral_psoc_obj_create_handler() - handler for psoc object create
28 * @psoc: reference to global psoc object
29 * @arg: reference to argument provided during registration of handler
30 *
31 * This is a handler to indicate psoc object created. Hence spectral_context
32 * object can be created and attached to psoc component list.
33 *
34 * Return: QDF_STATUS_SUCCESS on success
35 * QDF_STATUS_E_FAILURE if psoc is null
36 * QDF_STATUS_E_NOMEM on failure of spectral object allocation
37 */
38 QDF_STATUS wlan_spectral_psoc_obj_create_handler(struct wlan_objmgr_psoc *psoc,
39 void *arg);
40
41 /**
42 * wlan_spectral_psoc_obj_destroy_handler() - handler for psoc object delete
43 * @psoc: reference to global psoc object
44 * @arg: reference to argument provided during registration of handler
45 *
46 * This is a handler to indicate psoc object going to be deleted.
47 * Hence spectral_context object can be detached from psoc component list.
48 * Then spectral_context object can be deleted.
49 *
50 * Return: QDF_STATUS_SUCCESS on success
51 * QDF_STATUS_E_FAILURE on failure
52 */
53 QDF_STATUS wlan_spectral_psoc_obj_destroy_handler(struct wlan_objmgr_psoc *psoc,
54 void *arg);
55
56 /**
57 * wlan_spectral_pdev_obj_create_handler() - handler for pdev object create
58 * @pdev: reference to global pdev object
59 * @arg: reference to argument provided during registration of handler
60 *
61 * This is a handler to indicate pdev object created. Hence pdev specific
62 * spectral object can be created and attached to pdev component list.
63 *
64 * Return: QDF_STATUS_SUCCESS on success
65 * QDF_STATUS_E_FAILURE if pdev is null
66 * QDF_STATUS_E_NOMEM on failure of spectral object allocation
67 */
68 QDF_STATUS wlan_spectral_pdev_obj_create_handler(struct wlan_objmgr_pdev *pdev,
69 void *arg);
70
71 /**
72 * wlan_spectral_pdev_obj_destroy_handler() - handler for pdev object delete
73 * @pdev: reference to global pdev object
74 * @arg: reference to argument provided during registration of handler
75 *
76 * This is a handler to indicate pdev object going to be deleted.
77 * Hence pdev specific spectral object can be detached from pdev component list.
78 * Then pdev_spectral object can be deleted.
79 *
80 * Return: QDF_STATUS_SUCCESS on success
81 * QDF_STATUS_E_FAILURE on failure
82 */
83 QDF_STATUS wlan_spectral_pdev_obj_destroy_handler(struct wlan_objmgr_pdev *pdev,
84 void *arg);
85
86 /**
87 * spectral_control_cmn()- common handler for demultiplexing requests from
88 * higher layer
89 * @pdev: reference to global pdev object
90 * @sscan_req: pointer to Spectral scan request
91 *
92 * This function processes the spectral config command
93 * and appropriate handlers are invoked.
94 *
95 * Return: QDF_STATUS_SUCCESS/QDF_STATUS_E_FAILURE
96 */
97 QDF_STATUS spectral_control_cmn(struct wlan_objmgr_pdev *pdev,
98 struct spectral_cp_request *sscan_req);
99
100 /**
101 * spectral_control_ol(): Offload handler for demultiplexing requests from
102 * higher layer
103 * @pdev: reference to global pdev object
104 * @id: spectral config command id
105 * @indata: reference to input data
106 * @insize: input data size
107 * @outdata: reference to output data
108 * @outsize: reference to output data size
109 *
110 * This function processes the spectral config command
111 * and appropriate handlers are invoked.
112 *
113 * Return: 0 success else failure
114 */
115 int spectral_control_ol(
116 struct wlan_objmgr_pdev *pdev, u_int id,
117 void *indata, uint32_t insize, void *outdata, uint32_t *outsize);
118
119 /**
120 * spectral_get_spectral_ctx_from_pdev() - API to get spectral context object
121 * from pdev
122 * @pdev: Reference to pdev global object
123 *
124 * This API used to get spectral context object from global pdev reference.
125 * Null check should be done before invoking this inline function.
126 *
127 * Return: Reference to spectral_context object
128 */
129 static inline struct spectral_context *
spectral_get_spectral_ctx_from_pdev(struct wlan_objmgr_pdev * pdev)130 spectral_get_spectral_ctx_from_pdev(struct wlan_objmgr_pdev *pdev)
131 {
132 struct wlan_objmgr_psoc *psoc = NULL;
133 struct spectral_context *sc = NULL;
134
135 psoc = wlan_pdev_get_psoc(pdev);
136 if (psoc) {
137 sc = wlan_objmgr_psoc_get_comp_private_obj(
138 psoc,
139 WLAN_UMAC_COMP_SPECTRAL);
140 }
141
142 return sc;
143 }
144
145 /**
146 * spectral_get_spectral_ctx_from_psoc() - API to get spectral context object
147 * from psoc
148 * @psoc: Reference to psoc global object
149 *
150 * This API used to get spectral context object from global psoc reference.
151 * Null check should be done before invoking this inline function.
152 *
153 * Return: Reference to spectral_context object
154 */
155 static inline struct spectral_context *
spectral_get_spectral_ctx_from_psoc(struct wlan_objmgr_psoc * psoc)156 spectral_get_spectral_ctx_from_psoc(struct wlan_objmgr_psoc *psoc)
157 {
158 struct spectral_context *sc = NULL;
159
160 if (psoc) {
161 sc = wlan_objmgr_psoc_get_comp_private_obj(
162 psoc,
163 WLAN_UMAC_COMP_SPECTRAL);
164 }
165
166 return sc;
167 }
168
169 /**
170 * spectral_get_spectral_ctx_from_vdev() - API to get spectral context object
171 * from vdev
172 * @vdev: Reference to vdev global object
173 *
174 * This API used to get spectral context object from global vdev reference.
175 * Null check should be done before invoking this inline function.
176 *
177 * Return: Reference to spectral_context object
178 */
179 static inline struct spectral_context *
spectral_get_spectral_ctx_from_vdev(struct wlan_objmgr_vdev * vdev)180 spectral_get_spectral_ctx_from_vdev(struct wlan_objmgr_vdev *vdev)
181 {
182 struct wlan_objmgr_psoc *psoc = NULL;
183 struct spectral_context *sc = NULL;
184
185 psoc = wlan_vdev_get_psoc(vdev);
186 if (psoc) {
187 sc = wlan_objmgr_psoc_get_comp_private_obj(
188 psoc,
189 WLAN_UMAC_COMP_SPECTRAL);
190 }
191
192 return sc;
193 }
194 #endif /* _SPECTRAL_CMN_API_I_H_ */
195