xref: /wlan-driver/qcacld-3.0/components/umac/twt/core/src/wlan_twt_main.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #if defined(WLAN_SUPPORT_TWT)
20 
21 /**
22  * wlan_twt_is_max_sessions_reached() - Check if the maximum number of
23  * TWT sessions reached or not excluding the given dialog_id
24  * @psoc: Pointer to global PSOC object
25  * @peer_mac: Global peer mac address
26  * @dialog_id: dialog id
27  *
28  * Check if the number of active TWT sessions is equal to the maximum number
29  * of TWT sessions supported. Only count the TWT session slot if it not
30  * TWT_ALL_SESSIONS_DIALOG_ID and dialog id is different from input dialog_id,
31  * because if same dialog_id already exists in the TWT sessions, we should
32  * return false since re-negotiation is supported on existing dialog_id.
33  *
34  * Return: True if slot is available for dialog_id, false otherwise
35  */
36 bool
37 wlan_twt_is_max_sessions_reached(struct wlan_objmgr_psoc *psoc,
38 				 struct qdf_mac_addr *peer_mac,
39 				 uint8_t dialog_id);
40 
41 /**
42  * wlan_twt_set_command_in_progress() - Set TWT command is in progress
43  * @psoc: Pointer to psoc object
44  * @peer_mac: Pointer to peer mac address
45  * @dialog_id: Dialog id
46  * @cmd: TWT command
47  *
48  * Return: QDF_STATUS
49  */
50 QDF_STATUS
51 wlan_twt_set_command_in_progress(struct wlan_objmgr_psoc *psoc,
52 				 struct qdf_mac_addr *peer_mac,
53 				 uint8_t dialog_id,
54 				 enum wlan_twt_commands cmd);
55 
56 /**
57  * wlan_twt_setup_req() - twt setup request
58  * @psoc: Pointer to psoc object
59  * @req: TWT setup request
60  * @context: context
61  *
62  * Return: QDF_STATUS
63  */
64 QDF_STATUS
65 wlan_twt_setup_req(struct wlan_objmgr_psoc *psoc,
66 		   struct twt_add_dialog_param *req,
67 		   void *context);
68 
69 /**
70  * wlan_twt_teardown_req() - twt teardown request
71  * @psoc: Pointer to psoc object
72  * @req: TWT setup request
73  * @context: context
74  *
75  * Return: QDF_STATUS
76  */
77 QDF_STATUS
78 wlan_twt_teardown_req(struct wlan_objmgr_psoc *psoc,
79 		      struct twt_del_dialog_param *req,
80 		      void *context);
81 
82 /**
83  * wlan_twt_pause_req() - Process TWT pause req
84  * @psoc: psoc
85  * @req: pause dialog cmd param
86  * @context: context
87  *
88  * Return: QDF_STATUS
89  */
90 QDF_STATUS
91 wlan_twt_pause_req(struct wlan_objmgr_psoc *psoc,
92 		   struct twt_pause_dialog_cmd_param *req,
93 		   void *context);
94 
95 /**
96  * wlan_twt_resume_req() - Process TWT resume req
97  * @psoc: psoc
98  * @req: resume dialog cmd param
99  * @context: context
100  *
101  * Return: QDF_STATUS
102  */
103 QDF_STATUS
104 wlan_twt_resume_req(struct wlan_objmgr_psoc *psoc,
105 		    struct twt_resume_dialog_cmd_param *req,
106 		    void *context);
107 
108 /**
109  * wlan_twt_nudge_req() - Process TWT nudge req
110  * @psoc: psoc
111  * @req: nudge dialog cmd param
112  * @context: context
113  *
114  * Return: QDF_STATUS
115  */
116 QDF_STATUS
117 wlan_twt_nudge_req(struct wlan_objmgr_psoc *psoc,
118 		   struct twt_nudge_dialog_cmd_param *req,
119 		   void *context);
120 
121 /**
122  * wlan_twt_ac_pdev_param_send() - pdev TWT param send
123  * @psoc: Pointer to psoc object
124  * @twt_ac: TWT access category
125  *
126  * Return: QDF Status
127  */
128 QDF_STATUS wlan_twt_ac_pdev_param_send(struct wlan_objmgr_psoc *psoc,
129 				       enum twt_traffic_ac twt_ac);
130 
131 /**
132  * wlan_twt_is_setup_in_progress() - Get if TWT setup command is in progress
133  * for given dialog id
134  * @psoc: Pointer to global psoc object
135  * @peer_mac: Global peer mac address
136  * @dialog_id: Dialog ID
137  *
138  * Return: True if Setup is in progress
139  */
140 bool
141 wlan_twt_is_setup_in_progress(struct wlan_objmgr_psoc *psoc,
142 			      struct qdf_mac_addr *peer_mac,
143 			      uint8_t dialog_id);
144 
145 /**
146  * wlan_twt_setup_complete_event_handler() - twt setup complete event handler
147  * @psoc: Pointer to global psoc object
148  * @event: add dialog event
149  *
150  * Return: QDF_STATUS
151  */
152 QDF_STATUS
153 wlan_twt_setup_complete_event_handler(struct wlan_objmgr_psoc *psoc,
154 				   struct twt_add_dialog_complete_event *event);
155 
156 /**
157  * wlan_twt_ack_event_handler() - ack complete event handler
158  * @psoc: Pointer to global psoc object
159  * @event: ack complete event
160  *
161  * Return: QDF_STATUS
162  */
163 QDF_STATUS
164 wlan_twt_ack_event_handler(struct wlan_objmgr_psoc *psoc,
165 			   struct twt_ack_complete_event_param *event);
166 
167 /**
168  * wlan_twt_teardown_complete_event_handler() - teardown complete event handler
169  * @psoc: Pointer to global psoc object
170  * @event: del complete event
171  *
172  * Return: QDF_STATUS
173  */
174 QDF_STATUS
175 wlan_twt_teardown_complete_event_handler(struct wlan_objmgr_psoc *psoc,
176 			     struct twt_del_dialog_complete_event_param *event);
177 
178 /**
179  * wlan_twt_pause_complete_event_handler() - pause complete event handler
180  * @psoc: Pointer to global psoc object
181  * @event: pause complete event
182  *
183  * Return: QDF_STATUS
184  */
185 QDF_STATUS
186 wlan_twt_pause_complete_event_handler(struct wlan_objmgr_psoc *psoc,
187 			  struct twt_pause_dialog_complete_event_param *event);
188 
189 /**
190  * wlan_twt_resume_complete_event_handler() - resume complete event handler
191  * @psoc: Pointer to global psoc object
192  * @event: resume complete event
193  *
194  * Return: QDF_STATUS
195  */
196 QDF_STATUS
197 wlan_twt_resume_complete_event_handler(struct wlan_objmgr_psoc *psoc,
198 			  struct twt_resume_dialog_complete_event_param *event);
199 
200 /**
201  * wlan_twt_nudge_complete_event_handler() - nudge complete event handler
202  * @psoc: Pointer to global psoc object
203  * @event: nudge complete event
204  *
205  * Return: QDF_STATUS
206  */
207 QDF_STATUS
208 wlan_twt_nudge_complete_event_handler(struct wlan_objmgr_psoc *psoc,
209 			   struct twt_nudge_dialog_complete_event_param *event);
210 
211 /**
212  * wlan_twt_notify_event_handler() - notify event handler
213  * @psoc: Pointer to global psoc object
214  * @event: notify complete event
215  *
216  * Return: QDF_STATUS
217  */
218 QDF_STATUS
219 wlan_twt_notify_event_handler(struct wlan_objmgr_psoc *psoc,
220 			      struct twt_notify_event_param *event);
221 
222 /**
223  * wlan_twt_init_context() - Initialize TWT context structure
224  * @psoc: Pointer to psoc object
225  * @peer_mac: Pointer to peer mac address
226  * @dialog_id: Dialog id
227  *
228  * Return: QDF_STATUS
229  */
230 QDF_STATUS
231 wlan_twt_init_context(struct wlan_objmgr_psoc *psoc,
232 		      struct qdf_mac_addr *peer_mac,
233 		      uint8_t dialog_id);
234 
235 /**
236  * wlan_twt_update_beacon_template() - update beacon template
237  *
238  * SoftAP (SAP) is the beaconing entity, as per current requirement
239  * during Single Channel Concurrency (SCC) or Multi-Channel Concurrency (MCC)
240  * TWT is not supported on STA as well as SAP.
241  *
242  * Whenever SAP is forming SCC/MCC, this function shall be called to update the
243  * beacon, underlying LIM layer based the TWT responder flag, it disables the
244  * TWT responder advertisement bit in the beacon.
245  *
246  * When SAP moves from SCC/MCC to Standalone, this function shall be called
247  * to update the beacon, underlying LIM layer based the TWT responder flag,
248  * it enables  the TWT responder advertisement bit in the beacon.
249  *
250  * Return: QDF_STATUS
251  */
252 QDF_STATUS wlan_twt_update_beacon_template(void);
253 
254 /**
255  * wlan_twt_is_setup_done() - Check if TWT setup exists for a given dialog id
256  * @psoc: Pointer to psoc object
257  * @peer_mac: Pointer to peer mac address
258  * @dialog_id: Dialog id
259  *
260  * Return: true if TWT setup exists, false otherwise
261  */
262 bool wlan_twt_is_setup_done(struct wlan_objmgr_psoc *psoc,
263 			    struct qdf_mac_addr *peer_mac, uint8_t dialog_id);
264 
265 /**
266  * wlan_twt_get_session_state() - Get TWT session state
267  * @psoc: Pointer to psoc object
268  * @peer_mac: Pointer to peer mac address
269  * @dialog_id: Dialog id
270  *
271  * Return: enum wlan_twt_session_state
272  */
273 enum wlan_twt_session_state
274 wlan_twt_get_session_state(struct wlan_objmgr_psoc *psoc,
275 			   struct qdf_mac_addr *peer_mac, uint8_t dialog_id);
276 
277 /**
278  * wlan_twt_is_command_in_progress() - Check if given command is in progress
279  * @psoc: Pointer to psoc object
280  * @peer_mac: Pointer to peer mac address
281  * @dialog_id: Dialog id
282  * @cmd: TWT command
283  * @pactive_cmd: Fill the active command in this output parameter
284  *
285  * Return: True if given command is in progress.
286  */
287 bool wlan_twt_is_command_in_progress(struct wlan_objmgr_psoc *psoc,
288 				     struct qdf_mac_addr *peer_mac,
289 				     uint8_t dialog_id,
290 				     enum wlan_twt_commands cmd,
291 				     enum wlan_twt_commands *pactive_cmd);
292 
293 /**
294  * wlan_twt_set_work_params() - Set TWT work params
295  * @vdev: vdev pointer
296  * @peer_mac: mac address of peer
297  * @dialog_id: dialog_id of TWT session
298  * @is_ps_disabled: Whether power save is disabled or not
299  * @twt_next_action: Set next action to do before work scheduled
300  *
301  * Return: None
302  */
303 void wlan_twt_set_work_params(
304 			struct wlan_objmgr_vdev *vdev,
305 			struct qdf_mac_addr *peer_mac,
306 			uint8_t dialog_id,
307 			bool is_ps_disabled,
308 			uint32_t twt_next_action);
309 
310 /**
311  * wlan_twt_get_work_params() - Get TWT work params
312  * @vdev: vdev pointer
313  * @params: pointer to TWT work params
314  * @next_action: Get next action to do after work scheduled
315  *
316  * Return: None
317  */
318 void wlan_twt_get_work_params(struct wlan_objmgr_vdev *vdev,
319 			      struct twt_work_params *params,
320 			      uint32_t *next_action);
321 #else
322 
323 static inline bool
wlan_twt_is_max_sessions_reached(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id)324 wlan_twt_is_max_sessions_reached(struct wlan_objmgr_psoc *psoc,
325 				 struct qdf_mac_addr *peer_mac,
326 				 uint8_t dialog_id)
327 {
328 	return true;
329 }
330 
331 static inline QDF_STATUS
wlan_twt_set_command_in_progress(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id,enum wlan_twt_commands cmd)332 wlan_twt_set_command_in_progress(struct wlan_objmgr_psoc *psoc,
333 				 struct qdf_mac_addr *peer_mac,
334 				 uint8_t dialog_id,
335 				 enum wlan_twt_commands cmd)
336 {
337 	return QDF_STATUS_SUCCESS;
338 }
339 
340 static inline QDF_STATUS
wlan_twt_setup_req(struct wlan_objmgr_psoc * psoc,struct twt_add_dialog_param * req,void * context)341 wlan_twt_setup_req(struct wlan_objmgr_psoc *psoc,
342 		   struct twt_add_dialog_param *req,
343 		   void *context)
344 {
345 	return QDF_STATUS_SUCCESS;
346 }
347 
348 static inline QDF_STATUS
wlan_twt_teardown_req(struct wlan_objmgr_psoc * psoc,struct twt_del_dialog_param * req,void * context)349 wlan_twt_teardown_req(struct wlan_objmgr_psoc *psoc,
350 		      struct twt_del_dialog_param *req,
351 		      void *context)
352 {
353 	return QDF_STATUS_SUCCESS;
354 }
355 
356 static inline QDF_STATUS
wlan_twt_pause_req(struct wlan_objmgr_psoc * psoc,struct twt_pause_dialog_cmd_param * req,void * context)357 wlan_twt_pause_req(struct wlan_objmgr_psoc *psoc,
358 		   struct twt_pause_dialog_cmd_param *req,
359 		   void *context)
360 {
361 	return QDF_STATUS_SUCCESS;
362 }
363 
364 static inline QDF_STATUS
wlan_twt_resume_req(struct wlan_objmgr_psoc * psoc,struct twt_resume_dialog_cmd_param * req,void * context)365 wlan_twt_resume_req(struct wlan_objmgr_psoc *psoc,
366 		    struct twt_resume_dialog_cmd_param *req,
367 		    void *context)
368 {
369 	return QDF_STATUS_SUCCESS;
370 }
371 
372 static inline QDF_STATUS
wlan_twt_nudge_req(struct wlan_objmgr_psoc * psoc,struct twt_nudge_dialog_cmd_param * req,void * context)373 wlan_twt_nudge_req(struct wlan_objmgr_psoc *psoc,
374 		   struct twt_nudge_dialog_cmd_param *req,
375 		   void *context)
376 {
377 	return QDF_STATUS_SUCCESS;
378 }
379 
380 static inline QDF_STATUS
wlan_twt_ac_pdev_param_send(struct wlan_objmgr_psoc * psoc,enum twt_traffic_ac twt_ac)381 wlan_twt_ac_pdev_param_send(struct wlan_objmgr_psoc *psoc,
382 			    enum twt_traffic_ac twt_ac)
383 {
384 	return QDF_STATUS_SUCCESS;
385 }
386 
387 static inline bool
wlan_twt_is_setup_in_progress(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id)388 wlan_twt_is_setup_in_progress(struct wlan_objmgr_psoc *psoc,
389 			      struct qdf_mac_addr *peer_mac,
390 			      uint8_t dialog_id)
391 {
392 	return true;
393 }
394 
395 static inline QDF_STATUS
wlan_twt_setup_complete_event_handler(struct wlan_objmgr_psoc * psoc,struct twt_add_dialog_complete_event * event)396 wlan_twt_setup_complete_event_handler(struct wlan_objmgr_psoc *psoc,
397 				   struct twt_add_dialog_complete_event *event)
398 {
399 	return QDF_STATUS_SUCCESS;
400 }
401 
402 static inline QDF_STATUS
wlan_twt_ack_event_handler(struct wlan_objmgr_psoc * psoc,struct twt_ack_complete_event_param * event)403 wlan_twt_ack_event_handler(struct wlan_objmgr_psoc *psoc,
404 			   struct twt_ack_complete_event_param *event)
405 {
406 	return QDF_STATUS_SUCCESS;
407 }
408 
409 static inline QDF_STATUS
wlan_twt_teardown_complete_event_handler(struct wlan_objmgr_psoc * psoc,struct twt_del_dialog_complete_event_param * event)410 wlan_twt_teardown_complete_event_handler(struct wlan_objmgr_psoc *psoc,
411 			     struct twt_del_dialog_complete_event_param *event)
412 {
413 	return QDF_STATUS_SUCCESS;
414 }
415 
416 static inline QDF_STATUS
wlan_twt_pause_complete_event_handler(struct wlan_objmgr_psoc * psoc,struct twt_pause_dialog_complete_event_param * event)417 wlan_twt_pause_complete_event_handler(struct wlan_objmgr_psoc *psoc,
418 			  struct twt_pause_dialog_complete_event_param *event)
419 {
420 	return QDF_STATUS_SUCCESS;
421 }
422 
423 static inline QDF_STATUS
wlan_twt_resume_complete_event_handler(struct wlan_objmgr_psoc * psoc,struct twt_resume_dialog_complete_event_param * event)424 wlan_twt_resume_complete_event_handler(struct wlan_objmgr_psoc *psoc,
425 			  struct twt_resume_dialog_complete_event_param *event)
426 {
427 	return QDF_STATUS_SUCCESS;
428 }
429 
430 static inline QDF_STATUS
wlan_twt_nudge_complete_event_handler(struct wlan_objmgr_psoc * psoc,struct twt_nudge_dialog_complete_event_param * event)431 wlan_twt_nudge_complete_event_handler(struct wlan_objmgr_psoc *psoc,
432 			   struct twt_nudge_dialog_complete_event_param *event)
433 {
434 	return QDF_STATUS_SUCCESS;
435 }
436 
437 static inline QDF_STATUS
wlan_twt_notify_event_handler(struct wlan_objmgr_psoc * psoc,struct twt_notify_event_param * event)438 wlan_twt_notify_event_handler(struct wlan_objmgr_psoc *psoc,
439 			      struct twt_notify_event_param *event)
440 {
441 	return QDF_STATUS_SUCCESS;
442 }
443 
444 static inline QDF_STATUS
wlan_twt_init_context(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id)445 wlan_twt_init_context(struct wlan_objmgr_psoc *psoc,
446 		      struct qdf_mac_addr *peer_mac,
447 		      uint8_t dialog_id)
448 {
449 	return QDF_STATUS_SUCCESS;
450 }
451 
452 static inline
wlan_twt_update_beacon_template(void)453 QDF_STATUS wlan_twt_update_beacon_template(void)
454 {
455 	return QDF_STATUS_SUCCESS;
456 }
457 
458 static inline
wlan_twt_is_setup_done(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id)459 bool wlan_twt_is_setup_done(struct wlan_objmgr_psoc *psoc,
460 			    struct qdf_mac_addr *peer_mac, uint8_t dialog_id)
461 {
462 	return true;
463 }
464 
465 static inline
466 enum wlan_twt_session_state
wlan_twt_get_session_state(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id)467 wlan_twt_get_session_state(struct wlan_objmgr_psoc *psoc,
468 			   struct qdf_mac_addr *peer_mac, uint8_t dialog_id)
469 {
470 	return WLAN_TWT_SETUP_STATE_NOT_ESTABLISHED;
471 }
472 
473 static inline
wlan_twt_is_command_in_progress(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id,enum wlan_twt_commands cmd,enum wlan_twt_commands * pactive_cmd)474 bool wlan_twt_is_command_in_progress(struct wlan_objmgr_psoc *psoc,
475 				     struct qdf_mac_addr *peer_mac,
476 				     uint8_t dialog_id,
477 				     enum wlan_twt_commands cmd,
478 				     enum wlan_twt_commands *pactive_cmd)
479 {
480 	return true;
481 }
482 
483 static inline
wlan_twt_set_work_params(struct wlan_objmgr_vdev * vdev,struct twt_add_dialog_complete_event_param * params,uint32_t twt_next_action)484 void wlan_twt_set_work_params(
485 			struct wlan_objmgr_vdev *vdev,
486 			struct twt_add_dialog_complete_event_param *params,
487 			uint32_t twt_next_action)
488 {
489 }
490 
491 static inline
wlan_twt_get_work_params(struct wlan_objmgr_vdev * vdev,struct twt_work_params * params,uint32_t * next_action)492 void wlan_twt_get_work_params(struct wlan_objmgr_vdev *vdev,
493 			      struct twt_work_params *params,
494 			      uint32_t *next_action)
495 {
496 }
497 #endif
498