xref: /wlan-driver/qcacld-3.0/os_if/nan/inc/os_if_nan.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2012-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: declares nan component os interface APIs
22  */
23 
24 #ifndef _OS_IF_NAN_H_
25 #define _OS_IF_NAN_H_
26 
27 #include "qdf_types.h"
28 #ifdef WLAN_FEATURE_NAN
29 #include "nan_public_structs.h"
30 #include "nan_ucfg_api.h"
31 #include "qca_vendor.h"
32 #include <wlan_cp_stats_chipset_stats.h>
33 
34 /* QCA_NL80211_VENDOR_SUBCMD_NAN_EXT policy */
35 extern const struct nla_policy nan_attr_policy[
36 			QCA_WLAN_VENDOR_ATTR_NAN_PARAMS_MAX + 1];
37 
38 /* QCA_NL80211_VENDOR_SUBCMD_NDP policy */
39 extern const struct nla_policy vendor_attr_policy[
40 			QCA_WLAN_VENDOR_ATTR_NDP_PARAMS_MAX + 1];
41 
42 /**
43  * struct ndi_find_vdev_filter - find vdev filter object. this can be extended
44  * @ifname:           interface name of vdev
45  * @found_vdev:       found vdev object matching one or more of above params
46  */
47 struct ndi_find_vdev_filter {
48 	const char *ifname;
49 	struct wlan_objmgr_vdev *found_vdev;
50 };
51 
52 /**
53  * os_if_nan_process_ndp_cmd: os_if api to handle nan request message
54  * @psoc: pointer to psoc object
55  * @data: request data. contains vendor cmd tlvs
56  * @data_len: length of data
57  * @is_ndp_allowed: Indicates whether to allow NDP creation.
58  *		    NDI creation is always allowed.
59  * @wdev: Wireless device structure pointer
60  *
61  * Return: status of operation
62  */
63 int os_if_nan_process_ndp_cmd(struct wlan_objmgr_psoc *psoc,
64 			      const void *data, int data_len,
65 			      bool is_ndp_allowed,
66 			      struct wireless_dev *wdev);
67 
68 /**
69  * os_if_nan_register_hdd_callbacks: os_if api to register hdd callbacks
70  * @psoc: pointer to psoc object
71  * @cb_obj: struct pointer containing callbacks
72  *
73  * Return: status of operation
74  */
75 int os_if_nan_register_hdd_callbacks(struct wlan_objmgr_psoc *psoc,
76 				     struct nan_callbacks *cb_obj);
77 
78 /**
79  * os_if_nan_register_lim_callbacks: os_if api to register lim callbacks
80  * @psoc: pointer to psoc object
81  * @cb_obj: struct pointer containing callbacks
82  *
83  * Return: status of operation
84  */
85 int os_if_nan_register_lim_callbacks(struct wlan_objmgr_psoc *psoc,
86 				     struct nan_callbacks *cb_obj);
87 
88 /**
89  * os_if_nan_post_ndi_create_rsp: os_if api to pos ndi create rsp to umac nan
90  * component
91  * @psoc: pointer to psoc object
92  * @vdev_id: vdev id of ndi
93  * @success: if create was success or failure
94  *
95  * Return: None
96  */
97 void os_if_nan_post_ndi_create_rsp(struct wlan_objmgr_psoc *psoc,
98 				   uint8_t vdev_id, bool success);
99 
100 /**
101  * os_if_nan_post_ndi_delete_rsp: os_if api to pos ndi delete rsp to umac nan
102  * component
103  * @psoc: pointer to psoc object
104  * @vdev_id: vdev id of ndi
105  * @success: if delete was success or failure
106  *
107  * Return: None
108  */
109 void os_if_nan_post_ndi_delete_rsp(struct wlan_objmgr_psoc *psoc,
110 				   uint8_t vdev_id, bool success);
111 
112 /**
113  * os_if_nan_ndi_session_end: os_if api to process ndi session end
114  * component
115  * @vdev: pointer to vdev deleted
116  *
117  * Return: None
118  */
119 void os_if_nan_ndi_session_end(struct wlan_objmgr_vdev *vdev);
120 
121 /**
122  * os_if_nan_set_ndi_state: os_if api set NDI state
123  * @vdev: pointer to vdev deleted
124  * @state: value to set
125  *
126  * Return: status of operation
127  */
os_if_nan_set_ndi_state(struct wlan_objmgr_vdev * vdev,uint32_t state)128 static inline QDF_STATUS os_if_nan_set_ndi_state(struct wlan_objmgr_vdev *vdev,
129 						 uint32_t state)
130 {
131 	return ucfg_nan_set_ndi_state(vdev, state);
132 }
133 
134 /**
135  * os_if_nan_set_ndp_create_transaction_id: set ndp create transaction id
136  * @vdev: pointer to vdev object
137  * @val: value to set
138  *
139  * Return: status of operation
140  */
os_if_nan_set_ndp_create_transaction_id(struct wlan_objmgr_vdev * vdev,uint16_t val)141 static inline QDF_STATUS os_if_nan_set_ndp_create_transaction_id(
142 						struct wlan_objmgr_vdev *vdev,
143 						uint16_t val)
144 {
145 	return ucfg_nan_set_ndp_create_transaction_id(vdev, val);
146 }
147 
148 /**
149  * os_if_nan_set_ndp_delete_transaction_id: set ndp delete transaction id
150  * @vdev: pointer to vdev object
151  * @val: value to set
152  *
153  * Return: status of operation
154  */
os_if_nan_set_ndp_delete_transaction_id(struct wlan_objmgr_vdev * vdev,uint16_t val)155 static inline QDF_STATUS os_if_nan_set_ndp_delete_transaction_id(
156 						struct wlan_objmgr_vdev *vdev,
157 						uint16_t val)
158 {
159 	return ucfg_nan_set_ndp_delete_transaction_id(vdev, val);
160 }
161 
162 /**
163  * os_if_process_nan_req: os_if api to handle NAN requests attached to the
164  * vendor command QCA_NL80211_VENDOR_SUBCMD_NAN_EXT
165  * @pdev: pointer to pdev object
166  * @vdev_id: NAN vdev id
167  * @data: request data. contains vendor cmd tlvs
168  * @data_len: length of data
169  *
170  * Return: status of operation
171  */
172 int os_if_process_nan_req(struct wlan_objmgr_pdev *pdev, uint8_t vdev_id,
173 			  const void *data, int data_len);
174 #else
175 
os_if_nan_post_ndi_create_rsp(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,bool success)176 static inline void os_if_nan_post_ndi_create_rsp(struct wlan_objmgr_psoc *psoc,
177 						 uint8_t vdev_id, bool success)
178 {
179 }
180 
os_if_nan_post_ndi_delete_rsp(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,bool success)181 static inline void os_if_nan_post_ndi_delete_rsp(struct wlan_objmgr_psoc *psoc,
182 						 uint8_t vdev_id, bool success)
183 {
184 }
185 
186 #endif /* WLAN_FEATURE_NAN */
187 
188 #if defined(WLAN_FEATURE_NAN) && defined(WLAN_CHIPSET_STATS)
189 /**
190  * os_if_cstats_log_ndp_initiator_req_evt() - Chipset stats for ndp
191  * initiator request
192  *
193  * @req : pointer to nan_datapath_initiator_req
194  *
195  * Return : void
196  */
197 void
198 os_if_cstats_log_ndp_initiator_req_evt(struct nan_datapath_initiator_req *req);
199 
200 /**
201  * os_if_cstats_log_ndp_responder_req_evt() - Chipset stats for ndp
202  * responder request
203  *
204  * @vdev : pointer to vdev object
205  * @req : pointer to nan_datapath_responder_req
206  *
207  * Return : void
208  */
209 void
210 os_if_cstats_log_ndp_responder_req_evt(struct wlan_objmgr_vdev *vdev,
211 				       struct nan_datapath_responder_req *req);
212 
213 /**
214  * os_if_cstats_log_ndp_end_req_evt() - Chipset stats for ndp end
215  * request event
216  *
217  * @vdev : pointer to vdev object
218  * @rq : pointer to nan_datapath_end_req
219  *
220  * Return : void
221  */
222 void os_if_cstats_log_ndp_end_req_evt(struct wlan_objmgr_vdev *vdev,
223 				      struct nan_datapath_end_req *rq);
224 
225 /**
226  * os_if_cstats_log_ndp_initiator_resp_evt() - Chipset stats for ndp
227  * initiator request event
228  *
229  * @vdev : pointer to vdev object
230  * @rsp : pointer to nan_datapath_end_req
231  *
232  * Return : void
233  */
234 void
235 os_if_cstats_log_ndp_initiator_resp_evt(struct wlan_objmgr_vdev *vdev,
236 					struct nan_datapath_initiator_rsp *rsp);
237 
238 /**
239  * os_if_cstats_log_ndp_responder_resp_evt() - Chipset stats for ndp
240  * responder response event
241  *
242  * @vdev : pointer to vdev object
243  * @rsp : pointer to nan_datapath_responder_rsp
244  *
245  * Return : void
246  */
247 void
248 os_if_cstats_log_ndp_responder_resp_evt(struct wlan_objmgr_vdev *vdev,
249 					struct nan_datapath_responder_rsp *rsp);
250 
251 /**
252  * os_if_cstats_log_ndp_indication_evt() - Chipset stats for ndp
253  * indication event
254  *
255  * @vdev : pointer to vdev object
256  * @evt : pointer to nan_datapath_indication_event object
257  *
258  * Return : void
259  */
260 void
261 os_if_cstats_log_ndp_indication_evt(struct wlan_objmgr_vdev *vdev,
262 				    struct nan_datapath_indication_event *evt);
263 
264 /**
265  * os_if_cstats_log_ndp_confirm_evt() - Chipset stats for ndp
266  * confirm event
267  *
268  * @vdev : pointer to vdev object
269  * @nc : pointer to nan_datapath_confirm_event
270  *
271  * Return : void
272  */
273 void os_if_cstats_log_ndp_confirm_evt(struct wlan_objmgr_vdev *vdev,
274 				      struct nan_datapath_confirm_event *nc);
275 
276 /**
277  * os_if_cstats_log_ndp_end_rsp_evt() - Chipset stats for ndp
278  * end response event
279  *
280  * @vdev : pointer to vdev object
281  * @rsp : pointer to nan_datapath_end_rsp_event object
282  *
283  * Return : void
284  */
285 void os_if_cstats_log_ndp_end_rsp_evt(struct wlan_objmgr_vdev *vdev,
286 				      struct nan_datapath_end_rsp_event *rsp);
287 
288 /**
289  * os_if_cstats_log_ndp_new_peer_evt() - Chipset stats for ndp
290  * new peer event
291  *
292  * @vdev : pointer to vdev object
293  * @peer_ind : pointer to nan_datapath_peer_ind object
294  *
295  * Return : void
296  */
297 void os_if_cstats_log_ndp_new_peer_evt(struct wlan_objmgr_vdev *vdev,
298 				       struct nan_datapath_peer_ind *peer_ind);
299 
300 /**
301  * os_if_cstats_log_ndi_delete_resp_evt() - Chipset stats for ndi
302  * delete response event
303  *
304  * @vdev : pointer to vdev object
305  * @rsp : pointer to nan_datapath_inf_delete_rsp object
306  *
307  * Return : void
308  */
309 void
310 os_if_cstats_log_ndi_delete_resp_evt(struct wlan_objmgr_vdev *vdev,
311 				     struct nan_datapath_inf_delete_rsp *rsp);
312 
313 /**
314  * os_if_cstats_log_nan_disc_enable_req_evt() - Chipset stats for nan
315  * discovery enable request
316  *
317  * @vdev_id : pointer to vdev object
318  * @nan_req : pointer to nan_enable_req object
319  *
320  * Return : void
321  */
322 void os_if_cstats_log_nan_disc_enable_req_evt(uint8_t vdev_id,
323 					      struct nan_enable_req *nan_req);
324 
325 /**
326  * os_if_cstats_log_disable_nan_disc_evt() - Chipset stats for nan
327  * discovery disable event
328  *
329  * @pdev : pointer to pdev object
330  * @vdev_id : vdev ID
331  *
332  * Return : void
333  */
334 void os_if_cstats_log_disable_nan_disc_evt(struct wlan_objmgr_pdev *pdev,
335 					   uint8_t vdev_id);
336 #else
337 static inline void
os_if_cstats_log_ndp_initiator_req_evt(struct nan_datapath_initiator_req * req)338 os_if_cstats_log_ndp_initiator_req_evt(struct nan_datapath_initiator_req *req)
339 {
340 }
341 
342 static inline void
os_if_cstats_log_ndp_responder_req_evt(struct wlan_objmgr_vdev * vdev,struct nan_datapath_responder_req * req)343 os_if_cstats_log_ndp_responder_req_evt(struct wlan_objmgr_vdev *vdev,
344 				       struct nan_datapath_responder_req *req)
345 {
346 }
347 
348 static inline void
os_if_cstats_log_ndp_end_req_evt(struct wlan_objmgr_vdev * vdev,struct nan_datapath_end_req * rq)349 os_if_cstats_log_ndp_end_req_evt(struct wlan_objmgr_vdev *vdev,
350 				 struct nan_datapath_end_req *rq)
351 {
352 }
353 
354 static inline void
os_if_cstats_log_ndp_initiator_resp_evt(struct wlan_objmgr_vdev * vdev,struct nan_datapath_initiator_rsp * rsp)355 os_if_cstats_log_ndp_initiator_resp_evt(struct wlan_objmgr_vdev *vdev,
356 					struct nan_datapath_initiator_rsp *rsp)
357 {
358 }
359 
360 static inline void
os_if_cstats_log_ndp_responder_resp_evt(struct wlan_objmgr_vdev * vdev,struct nan_datapath_responder_rsp * rsp)361 os_if_cstats_log_ndp_responder_resp_evt(struct wlan_objmgr_vdev *vdev,
362 					struct nan_datapath_responder_rsp *rsp)
363 {
364 }
365 
366 static inline void
os_if_cstats_log_ndp_indication_evt(struct wlan_objmgr_vdev * vdev,struct nan_datapath_indication_event * event)367 os_if_cstats_log_ndp_indication_evt(struct wlan_objmgr_vdev *vdev,
368 				    struct nan_datapath_indication_event *event)
369 {
370 }
371 
372 static inline void
os_if_cstats_log_ndp_confirm_evt(struct wlan_objmgr_vdev * vdev,struct nan_datapath_confirm_event * nc)373 os_if_cstats_log_ndp_confirm_evt(struct wlan_objmgr_vdev *vdev,
374 				 struct nan_datapath_confirm_event *nc)
375 {
376 }
377 
378 static inline void
os_if_cstats_log_ndp_end_rsp_evt(struct wlan_objmgr_vdev * vdev,struct nan_datapath_end_rsp_event * rsp)379 os_if_cstats_log_ndp_end_rsp_evt(struct wlan_objmgr_vdev *vdev,
380 				 struct nan_datapath_end_rsp_event *rsp)
381 {
382 }
383 
384 static inline void
os_if_cstats_log_ndp_new_peer_evt(struct wlan_objmgr_vdev * vdev,struct nan_datapath_peer_ind * peer_ind)385 os_if_cstats_log_ndp_new_peer_evt(struct wlan_objmgr_vdev *vdev,
386 				  struct nan_datapath_peer_ind *peer_ind)
387 {
388 }
389 
390 static inline void
os_if_cstats_log_ndi_delete_resp_evt(struct wlan_objmgr_vdev * vdev,struct nan_datapath_inf_delete_rsp * rsp)391 os_if_cstats_log_ndi_delete_resp_evt(struct wlan_objmgr_vdev *vdev,
392 				     struct nan_datapath_inf_delete_rsp *rsp)
393 {
394 }
395 
396 static inline void
os_if_cstats_log_nan_disc_enable_req_evt(uint8_t vdev_id,struct nan_enable_req * nan_req)397 os_if_cstats_log_nan_disc_enable_req_evt(uint8_t vdev_id,
398 					 struct nan_enable_req *nan_req)
399 {
400 }
401 
402 static inline void
os_if_cstats_log_disable_nan_disc_evt(struct wlan_objmgr_pdev * pdev,uint8_t vdev_id)403 os_if_cstats_log_disable_nan_disc_evt(struct wlan_objmgr_pdev *pdev,
404 				      uint8_t vdev_id)
405 {
406 }
407 #endif /* WLAN_CHIPSET_STATS */
408 #endif
409