xref: /wlan-driver/qcacld-3.0/components/nan/core/inc/wlan_nan_api.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2024 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 /**
21  * DOC: contains nan definitions exposed to other modules
22  */
23 
24 #ifndef _WLAN_NAN_API_H_
25 #define _WLAN_NAN_API_H_
26 
27 #include "wlan_objmgr_peer_obj.h"
28 #include "wlan_policy_mgr_public_struct.h"
29 #include "qdf_status.h"
30 #include <nan_public_structs.h>
31 #include <wlan_cp_stats_chipset_stats.h>
32 
33 #ifdef WLAN_FEATURE_NAN
34 
35 #include "../src/nan_main_i.h"
36 
37 struct wlan_objmgr_psoc;
38 
39 /**
40  * nan_init: initializes NAN component, called by dispatcher init
41  *
42  * Return: status of operation
43  */
44 QDF_STATUS nan_init(void);
45 
46 /**
47  * nan_deinit: de-initializes NAN component, called by dispatcher init
48  *
49  * Return: status of operation
50  */
51 QDF_STATUS nan_deinit(void);
52 
53 /**
54  * nan_psoc_enable: psoc enable API for NANitioning component
55  * @psoc: pointer to PSOC
56  *
57  * Return: status of operation
58  */
59 QDF_STATUS nan_psoc_enable(struct wlan_objmgr_psoc *psoc);
60 
61 /**
62  * nan_psoc_disable: psoc disable API for NANitioning component
63  * @psoc: pointer to PSOC
64  *
65  * Return: status of operation
66  */
67 QDF_STATUS nan_psoc_disable(struct wlan_objmgr_psoc *psoc);
68 
69 /**
70  * nan_get_peer_priv_obj: get NAN priv object from peer object
71  * @peer: pointer to peer object
72  *
73  * Return: pointer to NAN peer private object
74  */
75 static inline
nan_get_peer_priv_obj(struct wlan_objmgr_peer * peer)76 struct nan_peer_priv_obj *nan_get_peer_priv_obj(struct wlan_objmgr_peer *peer)
77 {
78 	struct nan_peer_priv_obj *obj;
79 
80 	if (!peer) {
81 		nan_err("peer is null");
82 		return NULL;
83 	}
84 	obj = wlan_objmgr_peer_get_comp_private_obj(peer, WLAN_UMAC_COMP_NAN);
85 
86 	return obj;
87 }
88 
89 /**
90  * nan_get_vdev_priv_obj: get NAN priv object from vdev object
91  * @vdev: pointer to vdev object
92  *
93  * Return: pointer to NAN vdev private object
94  */
95 static inline
nan_get_vdev_priv_obj(struct wlan_objmgr_vdev * vdev)96 struct nan_vdev_priv_obj *nan_get_vdev_priv_obj(struct wlan_objmgr_vdev *vdev)
97 {
98 	struct nan_vdev_priv_obj *obj;
99 
100 	if (!vdev) {
101 		nan_err("vdev is null");
102 		return NULL;
103 	}
104 	obj = wlan_objmgr_vdev_get_comp_private_obj(vdev, WLAN_UMAC_COMP_NAN);
105 
106 	return obj;
107 }
108 
109 /**
110  * nan_get_psoc_priv_obj: get NAN priv object from psoc object
111  * @psoc: pointer to psoc object
112  *
113  * Return: pointer to NAN psoc private object
114  */
115 static inline
nan_get_psoc_priv_obj(struct wlan_objmgr_psoc * psoc)116 struct nan_psoc_priv_obj *nan_get_psoc_priv_obj(struct wlan_objmgr_psoc *psoc)
117 {
118 	struct nan_psoc_priv_obj *obj;
119 
120 	if (!psoc) {
121 		nan_err("psoc is null");
122 		return NULL;
123 	}
124 	obj = wlan_objmgr_psoc_get_comp_private_obj(psoc, WLAN_UMAC_COMP_NAN);
125 
126 	return obj;
127 }
128 
129 /**
130  * nan_psoc_get_tx_ops: get TX ops from the NAN private object
131  * @psoc: pointer to psoc object
132  *
133  * Return: pointer to TX op callback
134  */
135 static inline
nan_psoc_get_tx_ops(struct wlan_objmgr_psoc * psoc)136 struct wlan_nan_tx_ops *nan_psoc_get_tx_ops(struct wlan_objmgr_psoc *psoc)
137 {
138 	struct nan_psoc_priv_obj *nan_priv;
139 
140 	if (!psoc) {
141 		nan_err("psoc is null");
142 		return NULL;
143 	}
144 
145 	nan_priv = nan_get_psoc_priv_obj(psoc);
146 	if (!nan_priv) {
147 		nan_err("psoc private object is null");
148 		return NULL;
149 	}
150 
151 	return &nan_priv->tx_ops;
152 }
153 
154 /**
155  * nan_psoc_get_rx_ops: get RX ops from the NAN private object
156  * @psoc: pointer to psoc object
157  *
158  * Return: pointer to RX op callback
159  */
160 static inline
nan_psoc_get_rx_ops(struct wlan_objmgr_psoc * psoc)161 struct wlan_nan_rx_ops *nan_psoc_get_rx_ops(struct wlan_objmgr_psoc *psoc)
162 {
163 	struct nan_psoc_priv_obj *nan_priv;
164 
165 	if (!psoc) {
166 		nan_err("psoc is null");
167 		return NULL;
168 	}
169 
170 	nan_priv = nan_get_psoc_priv_obj(psoc);
171 	if (!nan_priv) {
172 		nan_err("psoc private object is null");
173 		return NULL;
174 	}
175 
176 	return &nan_priv->rx_ops;
177 }
178 
179 /**
180  * wlan_nan_get_connection_info: Get NAN related connection info
181  * @psoc: pointer to psoc object
182  * @conn_info: Coonection info structure pointer
183  *
184  * Return: status of operation
185  */
186 QDF_STATUS
187 wlan_nan_get_connection_info(struct wlan_objmgr_psoc *psoc,
188 			     struct policy_mgr_vdev_entry_info *conn_info);
189 
190 /**
191  * wlan_nan_get_disc_5g_ch_freq: Get NAN Disc 5G channel frequency
192  * @psoc: pointer to psoc object
193  *
194  * Return: NAN Disc 5G channel frequency
195  */
196 uint32_t wlan_nan_get_disc_5g_ch_freq(struct wlan_objmgr_psoc *psoc);
197 
198 /**
199  * wlan_nan_get_sap_conc_support: Get NAN+SAP conc support
200  * @psoc: pointer to psoc object
201  *
202  * Return: True if NAN+SAP supported else false
203  */
204 bool wlan_nan_get_sap_conc_support(struct wlan_objmgr_psoc *psoc);
205 
206 /**
207  * nan_disable_cleanup: Cleanup NAN state upon NAN disable
208  * @psoc: pointer to psoc object
209  *
210  * Return: Cleanup NAN state upon NAN disable
211  */
212 QDF_STATUS nan_disable_cleanup(struct wlan_objmgr_psoc *psoc);
213 
214 /**
215  * wlan_nan_is_beamforming_supported- Get support for beamforing
216  * @psoc: pointer to psoc object
217  *
218  * Return: True if beamforming is supported, false if not.
219  */
220 bool wlan_nan_is_beamforming_supported(struct wlan_objmgr_psoc *psoc);
221 
222 /**
223  * wlan_is_nan_allowed_on_freq() - Check if NAN is allowed on given freq
224  * @pdev: pdev context
225  * @freq: Frequency to be checked
226  *
227  * Check if NAN/NDP can be enabled on given frequency.
228  *
229  * Return: True if NAN is allowed on the given frequency
230  */
231 bool wlan_is_nan_allowed_on_freq(struct wlan_objmgr_pdev *pdev, uint32_t freq);
232 
233 /**
234  * nan_handle_emlsr_concurrency()- Handle NAN+eMLSR concurrency
235  * @psoc: pointer to psoc object
236  * @nan_enable: Carries true if NAN is getting enabled.
237  *		Carries false upon NAN enable failure/NAN disabled indication
238  *
239  * Return: void
240  */
241 void nan_handle_emlsr_concurrency(struct wlan_objmgr_psoc *psoc,
242 				  bool nan_enable);
243 #else /* WLAN_FEATURE_NAN */
nan_init(void)244 static inline QDF_STATUS nan_init(void)
245 {
246 	return QDF_STATUS_SUCCESS;
247 }
248 
nan_deinit(void)249 static inline QDF_STATUS nan_deinit(void)
250 {
251 	return QDF_STATUS_SUCCESS;
252 }
253 
nan_psoc_enable(struct wlan_objmgr_psoc * psoc)254 static inline QDF_STATUS nan_psoc_enable(struct wlan_objmgr_psoc *psoc)
255 {
256 	return QDF_STATUS_SUCCESS;
257 }
258 
nan_psoc_disable(struct wlan_objmgr_psoc * psoc)259 static inline QDF_STATUS nan_psoc_disable(struct wlan_objmgr_psoc *psoc)
260 {
261 	return QDF_STATUS_SUCCESS;
262 }
263 
264 static inline QDF_STATUS
wlan_nan_get_connection_info(struct wlan_objmgr_psoc * psoc,struct policy_mgr_vdev_entry_info * conn_info)265 wlan_nan_get_connection_info(struct wlan_objmgr_psoc *psoc,
266 			     struct policy_mgr_vdev_entry_info *conn_info)
267 {
268 	return QDF_STATUS_E_FAILURE;
269 }
270 
271 static inline uint32_t
wlan_nan_get_disc_5g_ch_freq(struct wlan_objmgr_psoc * psoc)272 wlan_nan_get_disc_5g_ch_freq(struct wlan_objmgr_psoc *psoc)
273 {
274 	return 0;
275 }
276 
277 static inline
wlan_nan_get_sap_conc_support(struct wlan_objmgr_psoc * psoc)278 bool wlan_nan_get_sap_conc_support(struct wlan_objmgr_psoc *psoc)
279 {
280 	return false;
281 }
282 
283 static inline
nan_disable_cleanup(struct wlan_objmgr_psoc * psoc)284 QDF_STATUS nan_disable_cleanup(struct wlan_objmgr_psoc *psoc)
285 {
286 	return QDF_STATUS_E_FAILURE;
287 }
288 
289 static inline
wlan_nan_is_beamforming_supported(struct wlan_objmgr_psoc * psoc)290 bool wlan_nan_is_beamforming_supported(struct wlan_objmgr_psoc *psoc)
291 {
292 	return false;
293 }
294 
295 static inline
wlan_is_nan_allowed_on_freq(struct wlan_objmgr_pdev * pdev,uint32_t freq)296 bool wlan_is_nan_allowed_on_freq(struct wlan_objmgr_pdev *pdev, uint32_t freq)
297 {
298 	return false;
299 }
300 
301 static inline void
nan_handle_emlsr_concurrency(struct wlan_objmgr_psoc * psoc,bool nan_enable)302 nan_handle_emlsr_concurrency(struct wlan_objmgr_psoc *psoc, bool nan_enable)
303 {}
304 #endif /* WLAN_FEATURE_NAN */
305 
306 #if defined(WLAN_FEATURE_NAN) && defined(WLAN_FEATURE_11BE_MLO)
307 /**
308  * wlan_is_mlo_sta_nan_ndi_allowed()- Get support for MLO STA +
309  * NAN Disc + NDI concurrency
310  * @psoc: pointer to psoc object
311  *
312  * Return: True if mlo sta + nan + ndi concurrency allowed or not.
313  */
314 bool wlan_is_mlo_sta_nan_ndi_allowed(struct wlan_objmgr_psoc *psoc);
315 #else
316 static inline bool
wlan_is_mlo_sta_nan_ndi_allowed(struct wlan_objmgr_psoc * psoc)317 wlan_is_mlo_sta_nan_ndi_allowed(struct wlan_objmgr_psoc *psoc)
318 {
319 	return false;
320 }
321 #endif
322 
323 #if defined(WLAN_FEATURE_NAN) && defined(WLAN_CHIPSET_STATS)
324 /**
325  * nan_cstats_log_nan_enable_resp_evt() - Chipset stats NAN enable
326  * response event
327  *
328  * @nan_event: pointer to nan_event_params object
329  *
330  * Return: void
331  */
332 void nan_cstats_log_nan_enable_resp_evt(struct nan_event_params *nan_event);
333 
334 /**
335  * nan_cstats_log_nan_disable_resp_evt() - Chipset stats NAN disable
336  * response event
337  *
338  * @vdev_id: vdev ID
339  * @psoc: pointer to psoc object
340  *
341  * Return: void
342  */
343 void
344 nan_cstats_log_nan_disable_resp_evt(uint8_t vdev_id,
345 				    struct wlan_objmgr_psoc *psoc);
346 #else
347 static inline void
nan_cstats_log_nan_enable_resp_evt(struct nan_event_params * nan_event)348 nan_cstats_log_nan_enable_resp_evt(struct nan_event_params *nan_event)
349 {
350 }
351 
352 static inline void
nan_cstats_log_nan_disable_resp_evt(uint8_t vdev_id,struct wlan_objmgr_psoc * psoc)353 nan_cstats_log_nan_disable_resp_evt(uint8_t vdev_id,
354 				    struct wlan_objmgr_psoc *psoc)
355 {
356 }
357 #endif /* WLAN_FEATURE_NAN && WLAN_CHIPSET_STATS */
358 #endif /* _WLAN_NAN_API_H_ */
359