xref: /wlan-dirver/qca-wifi-host-cmn/spectral/core/spectral_cmn_api_i.h (revision 5ee6661e575b5422cbb88a7703b46f397b551bd9)
1 /*
2  * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
3  *
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 #ifndef _SPECTRAL_CMN_API_I_H_
21 #define _SPECTRAL_CMN_API_I_H_
22 
23 #include "spectral_defs_i.h"
24 
25 /**
26  * wlan_spectral_psoc_obj_create_handler() - handler for psoc object create
27  * @psoc: reference to global psoc object
28  * @arg:  reference to argument provided during registration of handler
29  *
30  * This is a handler to indicate psoc object created. Hence spectral_context
31  * object can be created and attached to psoc component list.
32  *
33  * Return: QDF_STATUS_SUCCESS on success
34  *         QDF_STATUS_E_FAILURE if psoc is null
35  *         QDF_STATUS_E_NOMEM on failure of spectral object allocation
36  */
37 QDF_STATUS wlan_spectral_psoc_obj_create_handler(struct wlan_objmgr_psoc *psoc,
38 						 void *arg);
39 
40 /**
41  * wlan_spectral_psoc_obj_destroy_handler() - handler for psoc object delete
42  * @psoc: reference to global psoc object
43  * @arg:  reference to argument provided during registration of handler
44  *
45  * This is a handler to indicate psoc object going to be deleted.
46  * Hence spectral_context object can be detached from psoc component list.
47  * Then spectral_context object can be deleted.
48  *
49  * Return: QDF_STATUS_SUCCESS on success
50  *         QDF_STATUS_E_FAILURE on failure
51  */
52 QDF_STATUS wlan_spectral_psoc_obj_destroy_handler(struct wlan_objmgr_psoc *psoc,
53 						  void *arg);
54 
55 /**
56  * wlan_spectral_pdev_obj_create_handler() - handler for pdev object create
57  * @pdev: reference to global pdev object
58  * @arg:  reference to argument provided during registration of handler
59  *
60  * This is a handler to indicate pdev object created. Hence pdev specific
61  * spectral object can be created and attached to pdev component list.
62  *
63  * Return: QDF_STATUS_SUCCESS on success
64  *         QDF_STATUS_E_FAILURE if pdev is null
65  *         QDF_STATUS_E_NOMEM on failure of spectral object allocation
66  */
67 QDF_STATUS wlan_spectral_pdev_obj_create_handler(struct wlan_objmgr_pdev *pdev,
68 						 void *arg);
69 
70 /**
71  * wlan_spectral_pdev_obj_destroy_handler() - handler for pdev object delete
72  * @pdev: reference to global pdev object
73  * @arg:  reference to argument provided during registration of handler
74  *
75  * This is a handler to indicate pdev object going to be deleted.
76  * Hence pdev specific spectral object can be detached from pdev component list.
77  * Then pdev_spectral object can be deleted.
78  *
79  * Return: QDF_STATUS_SUCCESS on success
80  *         QDF_STATUS_E_FAILURE on failure
81  */
82 QDF_STATUS wlan_spectral_pdev_obj_destroy_handler(struct wlan_objmgr_pdev *pdev,
83 						  void *arg);
84 
85 /**
86  * spectral_control_cmn()- common handler for demultiplexing requests from
87  *                         higher layer
88  * @pdev:      reference to global pdev object
89  * @sscan_req: pointer to Spectral scan request
90  *
91  * This function processes the spectral config command
92  * and appropriate handlers are invoked.
93  *
94  * Return: QDF_STATUS_SUCCESS/QDF_STATUS_E_FAILURE
95  */
96 QDF_STATUS spectral_control_cmn(struct wlan_objmgr_pdev *pdev,
97 				struct spectral_cp_request *sscan_req);
98 
99 /**
100  * spectral_control_ol(): Offload handler for demultiplexing requests from
101  *                         higher layer
102  * @pdev:    reference to global pdev object
103  * @id:      spectral config command id
104  * @indata:  reference to input data
105  * @insize:  input data size
106  * @outdata: reference to output data
107  * @outsize: reference to output data size
108  *
109  * This function processes the spectral config command
110  * and appropriate handlers are invoked.
111  *
112  * Return: 0 success else failure
113  */
114 int spectral_control_ol(
115 	struct wlan_objmgr_pdev *pdev, u_int id,
116 	void *indata, uint32_t insize, void *outdata, uint32_t *outsize);
117 
118 /**
119  * spectral_get_spectral_ctx_from_pdev() - API to get spectral context object
120  *                                         from pdev
121  * @pdev : Reference to pdev global object
122  *
123  * This API used to get spectral context object from global pdev reference.
124  * Null check should be done before invoking this inline function.
125  *
126  * Return : Reference to spectral_context object
127  */
128 static inline struct spectral_context *
129 spectral_get_spectral_ctx_from_pdev(struct wlan_objmgr_pdev *pdev)
130 {
131 	struct wlan_objmgr_psoc *psoc = NULL;
132 	struct spectral_context *sc = NULL;
133 
134 	psoc = wlan_pdev_get_psoc(pdev);
135 	if (psoc) {
136 		sc = wlan_objmgr_psoc_get_comp_private_obj(
137 			psoc,
138 			WLAN_UMAC_COMP_SPECTRAL);
139 	}
140 
141 	return sc;
142 }
143 
144 /**
145  * spectral_get_spectral_ctx_from_pscoc() - API to get spectral context object
146  *                                         from psoc
147  * @psoc : Reference to psoc global object
148  *
149  * This API used to get spectral context object from global psoc reference.
150  * Null check should be done before invoking this inline function.
151  *
152  * Return : Reference to spectral_context object
153  */
154 static inline struct spectral_context *
155 spectral_get_spectral_ctx_from_psoc(struct wlan_objmgr_psoc *psoc)
156 {
157 	struct spectral_context *sc = NULL;
158 
159 	if (psoc) {
160 		sc = wlan_objmgr_psoc_get_comp_private_obj(
161 			psoc,
162 			WLAN_UMAC_COMP_SPECTRAL);
163 	}
164 
165 	return sc;
166 }
167 
168 /**
169  * spectral_get_spectral_ctx_from_vdev() - API to get spectral context object
170  *                                         from vdev
171  * @vdev : Reference to vdev global object
172  *
173  * This API used to get spectral context object from global vdev reference.
174  * Null check should be done before invoking this inline function.
175  *
176  * Return : Reference to spectral_context object
177  */
178 static inline struct spectral_context *
179 spectral_get_spectral_ctx_from_vdev(struct wlan_objmgr_vdev *vdev)
180 {
181 	struct wlan_objmgr_psoc *psoc = NULL;
182 	struct spectral_context *sc = NULL;
183 
184 	psoc = wlan_vdev_get_psoc(vdev);
185 	if (psoc) {
186 		sc = wlan_objmgr_psoc_get_comp_private_obj(
187 			psoc,
188 			WLAN_UMAC_COMP_SPECTRAL);
189 	}
190 
191 	return sc;
192 }
193 #endif				/* _SPECTRAL_CMN_API_I_H_ */
194