xref: /wlan-driver/qcacld-3.0/components/p2p/dispatcher/inc/wlan_p2p_ucfg_api.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017-2018, 2020-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 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 p2p north bound interface definitions
22  */
23 
24 #ifndef _WLAN_P2P_UCFG_API_H_
25 #define _WLAN_P2P_UCFG_API_H_
26 
27 #include "wlan_p2p_cfg_api.h"
28 #include <qdf_types.h>
29 
30 struct wlan_objmgr_psoc;
31 struct p2p_roc_req;
32 struct p2p_event;
33 struct p2p_rx_mgmt_frame;
34 struct p2p_tx_cnf;
35 struct p2p_mgmt_tx;
36 struct p2p_ps_config;
37 struct p2p_lo_start;
38 struct p2p_lo_event;
39 struct p2p_protocol_callbacks;
40 struct mcc_quota_info;
41 
42 /**
43  * typedef p2p_rx_callback() - Callback for rx mgmt frame
44  * @user_data: user data associated to this rx mgmt frame.
45  * @rx_frame: RX mgmt frame
46  *
47  * This callback will be used to give rx frames to hdd.
48  *
49  * Return: None
50  */
51 typedef void (*p2p_rx_callback)(void *user_data,
52 	struct p2p_rx_mgmt_frame *rx_frame);
53 
54 /**
55  * typedef p2p_action_tx_cnf_callback() - Callback for tx confirmation
56  * @user_data: user data associated to this tx confirmation
57  * @tx_cnf: tx confirmation information
58  *
59  * This callback will be used to give tx mgmt frame confirmation to
60  * hdd.
61  *
62  * Return: None
63  */
64 typedef void (*p2p_action_tx_cnf_callback)(void *user_data,
65 	struct p2p_tx_cnf *tx_cnf);
66 
67 /**
68  * typedef p2p_lo_event_callback() - Callback for listen offload event
69  * @user_data: user data associated to this lo event
70  * @p2p_lo_event: listen offload event information
71  *
72  * This callback will be used to give listen offload event to hdd.
73  *
74  * Return: None
75  */
76 typedef void (*p2p_lo_event_callback)(void *user_data,
77 	struct p2p_lo_event *p2p_lo_event);
78 
79 /**
80  * typedef p2p_event_callback() - Callback for P2P event
81  * @user_data: user data associated to this p2p event
82  * @p2p_event: p2p event information
83  *
84  * This callback will be used to give p2p event to hdd.
85  *
86  * Return: None
87  */
88 typedef void (*p2p_event_callback)(void *user_data,
89 	struct p2p_event *p2p_event);
90 
91 /**
92  * typedef mcc_quota_event_callback() - Callback for mcc quota
93  * @psoc: psoc object
94  * @vdev: vdev object
95  * @mcc_quota: mcc quota event information
96  *
97  * Callback to notify mcc quota event.
98  *
99  * Return: None
100  */
101 typedef QDF_STATUS (*mcc_quota_event_callback)(struct wlan_objmgr_psoc *psoc,
102 					       struct wlan_objmgr_vdev *vdev,
103 					       struct mcc_quota_info *mcc_quota);
104 
105 /**
106  * struct p2p_start_param - p2p soc start parameters. Below callbacks
107  *                          will be registered by the HDD
108  * @rx_cb:            Function pointer to hdd rx callback. This
109  *                    function will be used to give rx frames to hdd
110  * @rx_cb_data:       RX callback user data
111  * @event_cb:         Function pointer to hdd p2p event callback.
112  *                    This function will be used to give p2p event
113  *                    to hdd
114  * @event_cb_data:    Pointer to p2p event callback user data
115  * @tx_cnf_cb:        Function pointer to hdd tx confirm callback.
116  *                    This function will be used to give tx confirm
117  *                    to hdd
118  * @tx_cnf_cb_data:   Pointer to p2p tx confirm callback user data
119  * @lo_event_cb:      Function pointer to p2p listen offload
120  *                    callback. This function will be used to give
121  *                    listen offload stopped event to hdd
122  * @lo_event_cb_data: Pointer to p2p listen offload callback user data
123  */
124 struct p2p_start_param {
125 	p2p_rx_callback rx_cb;
126 	void *rx_cb_data;
127 	p2p_event_callback event_cb;
128 	void *event_cb_data;
129 	p2p_action_tx_cnf_callback tx_cnf_cb;
130 	void *tx_cnf_cb_data;
131 #ifdef FEATURE_P2P_LISTEN_OFFLOAD
132 	p2p_lo_event_callback lo_event_cb;
133 	void *lo_event_cb_data;
134 #endif
135 };
136 
137 /**
138  * ucfg_p2p_init() - P2P component initialization
139  *
140  * This function gets called when dispatcher initializing.
141  *
142  * Return: QDF_STATUS_SUCCESS - in case of success
143  */
144 QDF_STATUS ucfg_p2p_init(void);
145 
146 /**
147  * ucfg_p2p_deinit() - P2P component de-init
148  *
149  * This function gets called when dispatcher de-init.
150  *
151  * Return: QDF_STATUS_SUCCESS - in case of success
152  */
153 QDF_STATUS ucfg_p2p_deinit(void);
154 
155 /**
156  * ucfg_p2p_psoc_open() - Open P2P component
157  * @soc: soc context
158  *
159  * This function gets called when dispatcher opening.
160  *
161  * Return: QDF_STATUS_SUCCESS - in case of success
162  */
163 QDF_STATUS ucfg_p2p_psoc_open(struct wlan_objmgr_psoc *soc);
164 
165 /**
166  * ucfg_p2p_psoc_close() - Close P2P component
167  * @soc: soc context
168  *
169  * This function gets called when dispatcher closing.
170  *
171  * Return: QDF_STATUS_SUCCESS - in case of success
172  */
173 QDF_STATUS ucfg_p2p_psoc_close(struct wlan_objmgr_psoc *soc);
174 
175 /**
176  * ucfg_p2p_psoc_start() - Start P2P component
177  * @soc: soc context
178  * @req: P2P start parameters
179  *
180  * This function gets called when up layer starting up.
181  *
182  * Return: QDF_STATUS_SUCCESS - in case of success
183  */
184 QDF_STATUS ucfg_p2p_psoc_start(struct wlan_objmgr_psoc *soc,
185 	struct p2p_start_param *req);
186 
187 /**
188  * ucfg_p2p_psoc_stop() - Stop P2P component
189  * @soc: soc context
190  *
191  * This function gets called when up layer exit.
192  *
193  * Return: QDF_STATUS_SUCCESS - in case of success
194  */
195 QDF_STATUS ucfg_p2p_psoc_stop(struct wlan_objmgr_psoc *soc);
196 
197 /**
198  * ucfg_p2p_roc_req() - Roc request
199  * @soc: soc context
200  * @roc_req: Roc request parameters
201  * @cookie: return cookie to caller
202  *
203  * This function delivers roc request to P2P component.
204  *
205  * Return: QDF_STATUS_SUCCESS - in case of success
206  */
207 QDF_STATUS ucfg_p2p_roc_req(struct wlan_objmgr_psoc *soc,
208 	struct p2p_roc_req *roc_req, uint64_t *cookie);
209 
210 /**
211  * ucfg_p2p_roc_cancel_req() - Cancel roc request
212  * @soc: soc context
213  * @cookie: Find out the roc request by cookie
214  *
215  * This function delivers cancel roc request to P2P component.
216  *
217  * Return: QDF_STATUS_SUCCESS - in case of success
218  */
219 QDF_STATUS ucfg_p2p_roc_cancel_req(struct wlan_objmgr_psoc *soc,
220 	uint64_t cookie);
221 
222 /**
223  * ucfg_p2p_cleanup_roc_by_vdev() - Cleanup roc request by vdev
224  * @vdev: pointer to vdev object
225  *
226  * This function call P2P API to cleanup roc request by vdev
227  *
228  * Return: QDF_STATUS_SUCCESS - in case of success
229  */
230 QDF_STATUS ucfg_p2p_cleanup_roc_by_vdev(struct wlan_objmgr_vdev *vdev);
231 
232 /**
233  * ucfg_p2p_cleanup_roc_by_psoc() - Cleanup roc request by psoc
234  * @psoc: pointer to psoc object
235  *
236  * This function call P2P API to cleanup roc request by psoc
237  *
238  * Return: QDF_STATUS_SUCCESS - in case of success
239  */
240 QDF_STATUS ucfg_p2p_cleanup_roc_by_psoc(struct wlan_objmgr_psoc *psoc);
241 
242 /**
243  * ucfg_p2p_cleanup_tx_by_vdev() - Cleanup tx request by vdev
244  * @vdev: pointer to vdev object
245  *
246  * This function call P2P API to cleanup tx action frame request by vdev
247  *
248  * Return: QDF_STATUS_SUCCESS - in case of success
249  */
250 QDF_STATUS ucfg_p2p_cleanup_tx_by_vdev(struct wlan_objmgr_vdev *vdev);
251 
252 /**
253  * ucfg_p2p_cleanup_tx_by_psoc() - Cleanup tx request by psoc
254  * @psoc: pointer to psoc object
255  *
256  * This function call P2P API to cleanup tx action frame request by psoc
257  *
258  * Return: QDF_STATUS_SUCCESS - in case of success
259  */
260 QDF_STATUS ucfg_p2p_cleanup_tx_by_psoc(struct wlan_objmgr_psoc *psoc);
261 
262 /**
263  * ucfg_p2p_mgmt_tx() - Mgmt frame tx request
264  * @soc: soc context
265  * @mgmt_frm: TX mgmt frame parameters
266  * @cookie: Return the cookie to caller
267  * @pdev: pdev object
268  *
269  * This function delivers mgmt frame tx request to P2P component.
270  *
271  * Return: QDF_STATUS_SUCCESS - in case of success
272  */
273 QDF_STATUS ucfg_p2p_mgmt_tx(struct wlan_objmgr_psoc *soc,
274 			    struct p2p_mgmt_tx *mgmt_frm,
275 			    uint64_t *cookie,
276 			    struct wlan_objmgr_pdev *pdev);
277 
278 /**
279  * ucfg_p2p_mgmt_tx_cancel() - Cancel mgmt frame tx request
280  * @soc: soc context
281  * @vdev: vdev object
282  * @cookie: Find out the mgmt tx request by cookie
283  *
284  * This function delivers cancel mgmt frame tx request request to P2P
285  * component.
286  *
287  * Return: QDF_STATUS_SUCCESS - in case of success
288  */
289 QDF_STATUS ucfg_p2p_mgmt_tx_cancel(struct wlan_objmgr_psoc *soc,
290 	struct wlan_objmgr_vdev *vdev, uint64_t cookie);
291 
292 /**
293  * ucfg_p2p_set_ps() - P2P set power save
294  * @soc: soc context
295  * @ps_config: power save configure
296  *
297  * This function delivers p2p power save request to P2P component.
298  *
299  * Return: QDF_STATUS_SUCCESS - in case of success
300  */
301 QDF_STATUS ucfg_p2p_set_ps(struct wlan_objmgr_psoc *soc,
302 	struct p2p_ps_config *ps_config);
303 
304 #ifdef FEATURE_P2P_LISTEN_OFFLOAD
305 /**
306  * ucfg_p2p_lo_start() - Listen offload start request
307  * @soc: soc context
308  * @p2p_lo_start: lo start parameters
309  *
310  * This function delivers listen offload start request to P2P
311  * component.
312  *
313  * Return: QDF_STATUS_SUCCESS - in case of success
314  */
315 QDF_STATUS ucfg_p2p_lo_start(struct wlan_objmgr_psoc *soc,
316 	struct p2p_lo_start *p2p_lo_start);
317 
318 /**
319  * ucfg_p2p_lo_stop() - Listen offload stop request
320  * @soc: soc context
321  * @vdev_id: vdev id
322  *
323  * This function delivers listen offload stop request to P2P component.
324  *
325  * Return: QDF_STATUS_SUCCESS - in case of success
326  */
327 QDF_STATUS ucfg_p2p_lo_stop(struct wlan_objmgr_psoc *soc,
328 	uint32_t vdev_id);
329 #endif
330 
331 /**
332  * p2p_peer_authorized() - Process peer authorized event
333  * @vdev: vdev structure to which peer is associated
334  * @mac_addr: peer mac address
335  *
336  * This function handles disables noa whenever a legacy station
337  * complete 4-way handshake after association.
338  *
339  * Return: void
340  */
341 void p2p_peer_authorized(struct wlan_objmgr_vdev *vdev, uint8_t *mac_addr);
342 
343 /**
344  * ucfg_p2p_set_noa() - Disable/Enable NOA
345  * @soc: soc context
346  * @vdev_id: vdev id
347  * @disable_noa: TRUE - Disable NoA, FALSE - Enable NoA
348  *
349  * This function send wmi command to enable / disable NoA.
350  *
351  * Return: QDF_STATUS_SUCCESS - in case of success
352  */
353 QDF_STATUS ucfg_p2p_set_noa(struct wlan_objmgr_psoc *soc,
354 	uint32_t vdev_id, bool disable_noa);
355 
356 /**
357  * ucfg_p2p_check_random_mac() - check random mac addr or not
358  * @soc: soc context
359  * @vdev_id: vdev id
360  * @random_mac_addr: mac addr to be checked
361  *
362  * This function check the input addr is random mac addr or not for vdev.
363  *
364  * Return: true if addr is random mac address else false.
365  */
366 bool ucfg_p2p_check_random_mac(struct wlan_objmgr_psoc *soc, uint32_t vdev_id,
367 			       uint8_t *random_mac_addr);
368 
369 /**
370  * ucfg_p2p_register_callbacks() - register p2p callbacks
371  * @soc: soc context
372  * @cb_obj: p2p_protocol_callbacks struct
373  *
374  * This function registers lim callbacks to p2p components to provide
375  * protocol information.
376  *
377  * Return: QDF_STATUS_SUCCESS - in case of success
378  */
379 QDF_STATUS ucfg_p2p_register_callbacks(struct wlan_objmgr_psoc *soc,
380 	    struct p2p_protocol_callbacks *cb_obj);
381 
382 #ifdef WLAN_FEATURE_MCC_QUOTA
383 /**
384  * ucfg_p2p_register_mcc_quota_event_os_if_cb() - Register OS IF mcc quota
385  * event callback
386  * @psoc: soc object
387  * @cb: os if callback for mcc quota event
388  *
389  * Return: QDF_STATUS_SUCCESS for success
390  */
391 QDF_STATUS
392 ucfg_p2p_register_mcc_quota_event_os_if_cb(struct wlan_objmgr_psoc *psoc,
393 					   mcc_quota_event_callback cb);
394 #else
395 static inline QDF_STATUS
ucfg_p2p_register_mcc_quota_event_os_if_cb(struct wlan_objmgr_psoc * psoc,mcc_quota_event_callback cb)396 ucfg_p2p_register_mcc_quota_event_os_if_cb(struct wlan_objmgr_psoc *psoc,
397 					   mcc_quota_event_callback cb)
398 {
399 	return QDF_STATUS_SUCCESS;
400 }
401 #endif
402 
403 /**
404  * ucfg_p2p_status_scan() - Show P2P connection status when scanning
405  * @vdev: vdev context
406  *
407  * This function shows P2P connection status when scanning.
408  *
409  * Return: QDF_STATUS_SUCCESS - in case of success
410  */
411 QDF_STATUS ucfg_p2p_status_scan(struct wlan_objmgr_vdev *vdev);
412 
413 /**
414  * ucfg_p2p_status_connect() - Update P2P connection status
415  * @vdev:        vdev context
416  *
417  * Updates P2P connection status by up layer when connecting.
418  *
419  * Return: QDF_STATUS_SUCCESS - in case of success
420  */
421 QDF_STATUS ucfg_p2p_status_connect(struct wlan_objmgr_vdev *vdev);
422 
423 /**
424  * ucfg_p2p_status_disconnect() - Update P2P connection status
425  * @vdev:        vdev context
426  *
427  * Updates P2P connection status by up layer when disconnecting.
428  *
429  * Return: QDF_STATUS_SUCCESS - in case of success
430  */
431 QDF_STATUS ucfg_p2p_status_disconnect(struct wlan_objmgr_vdev *vdev);
432 
433 /**
434  * ucfg_p2p_status_start_bss() - Update P2P connection status
435  * @vdev:        vdev context
436  *
437  * Updates P2P connection status by up layer when starting bss.
438  *
439  * Return: QDF_STATUS_SUCCESS - in case of success
440  */
441 QDF_STATUS ucfg_p2p_status_start_bss(struct wlan_objmgr_vdev *vdev);
442 
443 /**
444  * ucfg_p2p_status_stop_bss() - Update P2P connection status
445  * @vdev:        vdev context
446  *
447  * Updates P2P connection status by up layer when stopping bss.
448  *
449  * Return: QDF_STATUS_SUCCESS - in case of success
450  */
451 QDF_STATUS ucfg_p2p_status_stop_bss(struct wlan_objmgr_vdev *vdev);
452 
453 /**
454  * ucfg_p2p_is_roam_config_disabled() - Roam disable config during p2p
455  * connection
456  * @psoc: psoc context
457  *
458  * During P2P connection disable roam on STA interface
459  *
460  * Return: p2p disable roam - in case of success else false
461  */
462 static inline
ucfg_p2p_is_roam_config_disabled(struct wlan_objmgr_psoc * psoc)463 bool ucfg_p2p_is_roam_config_disabled(struct wlan_objmgr_psoc *psoc)
464 {
465 	return cfg_p2p_is_roam_config_disabled(psoc);
466 }
467 
468 /**
469  * ucfg_p2p_get_indoor_ch_support() - Get indoor channel support
470  * for P2P GO
471  *
472  * @psoc: pointer to psoc obj
473  *
474  * Get the indoor channel support for P2P GO
475  *
476  * Return: p2p go supported on indoor channel
477  */
478 bool ucfg_p2p_get_indoor_ch_support(struct wlan_objmgr_psoc *psoc);
479 
480 #ifdef WLAN_FEATURE_DYNAMIC_MAC_ADDR_UPDATE
481 /**
482  * ucfg_is_p2p_device_dynamic_set_mac_addr_supported() - API to check P2P device
483  * dynamic MAC address update is supported or not
484  *
485  * @psoc: Pointer to psoc
486  *
487  * Return: true or false
488  */
489 bool
490 ucfg_is_p2p_device_dynamic_set_mac_addr_supported(struct wlan_objmgr_psoc *psoc);
491 #else
492 static inline bool
ucfg_is_p2p_device_dynamic_set_mac_addr_supported(struct wlan_objmgr_psoc * psoc)493 ucfg_is_p2p_device_dynamic_set_mac_addr_supported(struct wlan_objmgr_psoc *psoc)
494 {
495 	return false;
496 }
497 #endif
498 #endif /* _WLAN_P2P_UCFG_API_H_ */
499