xref: /wlan-driver/qcacld-3.0/components/p2p/core/src/wlan_p2p_roc.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017-2019, 2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 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: Defines RoC API & structures
22  */
23 
24 #ifndef _WLAN_P2P_ROC_H_
25 #define _WLAN_P2P_ROC_H_
26 
27 #include <qdf_types.h>
28 #include <qdf_mc_timer.h>
29 #include <qdf_list.h>
30 
31 #define P2P_EVENT_PROPAGATE_TIME 10
32 #define P2P_WAIT_CANCEL_ROC      1000
33 #define P2P_WAIT_CLEANUP_ROC     2000
34 #define P2P_MAX_ROC_DURATION     1500
35 #define P2P_MAX_ROC_DURATION_GO_PRESENT           600
36 #define P2P_MAX_ROC_DURATION_DBS_NDP_PRESENT      350
37 #define P2P_MAX_ROC_DURATION_NON_DBS_NDP_PRESENT  250
38 #define P2P_MAX_ROC_DURATION_DBS_NAN_PRESENT      350
39 #define P2P_MAX_ROC_DURATION_NON_DBS_NAN_PRESENT  300
40 
41 #define P2P_ROC_DURATION_MULTI_GO_PRESENT   300
42 #define P2P_ROC_DURATION_MULTI_GO_ABSENT    10
43 #define P2P_ACTION_FRAME_DEFAULT_WAIT       200
44 #define P2P_ROC_DEFAULT_DURATION            200
45 
46 struct wlan_objmgr_vdev;
47 struct scan_event;
48 
49 /**
50  * enum roc_type - user requested or off channel tx
51  * @USER_REQUESTED:   Requested by supplicant
52  * @OFF_CHANNEL_TX:   Issued internally for off channel tx
53  */
54 enum roc_type {
55 	USER_REQUESTED,
56 	OFF_CHANNEL_TX,
57 };
58 
59 /**
60  * enum roc_state - P2P RoC state
61  * @ROC_STATE_IDLE:           RoC not yet started or completed
62  * @ROC_STATE_REQUESTED:      Sent scan command to scan manager
63  * @ROC_STATE_STARTED:        Got started event from scan manager
64  * @ROC_STATE_ON_CHAN:        Got foreign channel event from SCM
65  * @ROC_STATE_CANCEL_IN_PROG: Requested abort scan to SCM
66  * @ROC_STATE_INVALID:        We should not come to this state
67  */
68 enum roc_state {
69 	ROC_STATE_IDLE = 0,
70 	ROC_STATE_REQUESTED,
71 	ROC_STATE_STARTED,
72 	ROC_STATE_ON_CHAN,
73 	ROC_STATE_CANCEL_IN_PROG,
74 	ROC_STATE_INVALID,
75 };
76 
77 /**
78  * struct p2p_roc_context - RoC request context
79  * @node:        Node for next element in the list
80  * @p2p_soc_obj: Pointer to SoC global p2p private object
81  * @vdev_id:     Vdev id on which this request has come
82  * @scan_id:     Scan id given by scan component for this roc req
83  * @tx_ctx:      TX context if this ROC is for tx MGMT
84  * @chan_freq:   Chan frequency for which this RoC has been requested
85  * @phy_mode:    PHY mode
86  * @duration:    Duration for the RoC
87  * @roc_type:    RoC type  User requested or internal
88  * @roc_timer:   RoC timer
89  * @roc_state:   Roc state
90  * @id:          identifier of roc
91  */
92 struct p2p_roc_context {
93 	qdf_list_node_t node;
94 	struct p2p_soc_priv_obj *p2p_soc_obj;
95 	uint32_t vdev_id;
96 	uint32_t scan_id;
97 	void *tx_ctx;
98 	qdf_freq_t chan_freq;
99 	uint8_t phy_mode;
100 	uint32_t duration;
101 	enum roc_type roc_type;
102 	qdf_mc_timer_t roc_timer;
103 	enum roc_state roc_state;
104 	int32_t id;
105 };
106 
107 /**
108  * struct cancel_roc_context - p2p cancel roc context
109  * @p2p_soc_obj:      Pointer to SoC global p2p private object
110  * @cookie:           Cookie which is given by supplicant
111  */
112 struct cancel_roc_context {
113 	struct p2p_soc_priv_obj *p2p_soc_obj;
114 	uint64_t cookie;
115 };
116 
117 /**
118  * struct p2p_cleanup_param - p2p cleanup parameters
119  * @p2p_soc_obj:      Pointer to SoC global p2p private object
120  * @vdev_id:          vdev id
121  */
122 struct p2p_cleanup_param {
123 	struct p2p_soc_priv_obj *p2p_soc_obj;
124 	uint32_t vdev_id;
125 };
126 
127 /**
128  * p2p_mgmt_rx_action_ops() - register or unregister rx action callback
129  * @psoc: psoc object
130  * @isregister: register if true, unregister if false
131  *
132  * This function registers or unregisters rx action frame callback to
133  * mgmt txrx component.
134  *
135  * Return: QDF_STATUS_SUCCESS - in case of success
136  */
137 QDF_STATUS p2p_mgmt_rx_action_ops(struct wlan_objmgr_psoc *psoc,
138 	bool isregister);
139 
140 /**
141  * p2p_find_current_roc_ctx() - Find out roc context in progressing
142  * @p2p_soc_obj: p2p psoc private object
143  *
144  * This function finds out roc context in progressing from p2p psoc
145  * private object
146  *
147  * Return: Pointer to roc context - success
148  *         NULL                   - failure
149  */
150 struct p2p_roc_context *p2p_find_current_roc_ctx(
151 	struct p2p_soc_priv_obj *p2p_soc_obj);
152 
153 /**
154  * p2p_find_roc_by_tx_ctx() - Find out roc context by tx context
155  * @p2p_soc_obj: p2p psoc private object
156  * @cookie: cookie is the key to find out roc context
157  *
158  * This function finds out roc context by tx context from p2p psoc
159  * private object
160  *
161  * Return: Pointer to roc context - success
162  *         NULL                   - failure
163  */
164 struct p2p_roc_context *p2p_find_roc_by_tx_ctx(
165 	struct p2p_soc_priv_obj *p2p_soc_obj, uint64_t cookie);
166 
167 /**
168  * p2p_find_roc_by_chan_freq() - Find out roc context by channel
169  * @p2p_soc_obj: p2p psoc private object
170  * @chan_freq: channel frequency of the ROC
171  *
172  * This function finds out roc context by channel from p2p psoc
173  * private object
174  *
175  * Return: Pointer to roc context - success
176  *         NULL                   - failure
177  */
178 struct p2p_roc_context *p2p_find_roc_by_chan_freq(
179 	struct p2p_soc_priv_obj *p2p_soc_obj, qdf_freq_t chan_freq);
180 
181 /**
182  * p2p_restart_roc_timer() - Restarts roc timer
183  * @roc_ctx: remain on channel context
184  *
185  * This function restarts roc timer with updated duration.
186  *
187  * Return: QDF_STATUS_SUCCESS - in case of success
188  */
189 QDF_STATUS p2p_restart_roc_timer(struct p2p_roc_context *roc_ctx);
190 
191 /**
192  * p2p_cleanup_roc() - Cleanup roc context in queue
193  * @p2p_soc_obj: p2p psoc private object
194  * @vdev:        vdev object
195  * @sync: whether to wait for complete event
196  *
197  * This function cleanup roc context in queue, include the roc
198  * context in progressing until cancellation done. To avoid deadlock,
199  * don't call from scheduler thread.
200  *
201  * Return: QDF_STATUS_SUCCESS - in case of success
202  */
203 QDF_STATUS p2p_cleanup_roc(struct p2p_soc_priv_obj *p2p_soc_obj,
204 			   struct wlan_objmgr_vdev *vdev,
205 			   bool sync);
206 
207 /**
208  * p2p_process_cleanup_roc_queue() - process the message to cleanup roc
209  * @param: pointer to cleanup parameters
210  *
211  * This function process the message to cleanup roc context in queue,
212  * include the roc context in progressing.
213  *
214  * Return: QDF_STATUS_SUCCESS - in case of success
215  */
216 QDF_STATUS p2p_process_cleanup_roc_queue(
217 	struct p2p_cleanup_param *param);
218 
219 /**
220  * p2p_process_roc_req() - Process roc request
221  * @roc_ctx: roc request context
222  *
223  * This function handles roc request. It will call API from scan/mgmt
224  * txrx component.
225  *
226  * Return: QDF_STATUS_SUCCESS - in case of success
227  */
228 QDF_STATUS p2p_process_roc_req(struct p2p_roc_context *roc_ctx);
229 
230 /**
231  * p2p_process_cancel_roc_req() - Process cancel roc request
232  * @cancel_roc_ctx: cancel roc request context
233  *
234  * This function cancel roc request by cookie.
235  *
236  * Return: QDF_STATUS_SUCCESS - in case of success
237  */
238 QDF_STATUS p2p_process_cancel_roc_req(
239 	struct cancel_roc_context *cancel_roc_ctx);
240 
241 /**
242  * p2p_scan_event_cb() - Process scan event
243  * @vdev: vdev associated to this scan event
244  * @event: event information
245  * @arg: registered arguments
246  *
247  * This function handles P2P scan event and deliver P2P event to HDD
248  * layer by registered callback.
249  *
250  * Return: None
251  */
252 void p2p_scan_event_cb(struct wlan_objmgr_vdev *vdev,
253 	struct scan_event *event, void *arg);
254 
255 #endif /* _WLAN_P2P_ROC_H_ */
256