xref: /wlan-driver/qcacld-3.0/components/umac/twt/dispatcher/inc/wlan_twt_ucfg_ext_api.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 #ifndef _WLAN_TWT_UCFG_EXT_API_H
20 #define _WLAN_TWT_UCFG_EXT_API_H
21 
22 
23 #include <wlan_objmgr_psoc_obj.h>
24 #include <wlan_twt_public_structs.h>
25 #include <include/wlan_mlme_cmn.h>
26 
27 /* dialog_id used to get all peer's twt session parameters */
28 #define TWT_GET_ALL_PEER_PARAMS_DIALOG_ID (0xFF)
29 
30 /* Valid dialog_id 0 to (0xFF - 1) */
31 #define TWT_MAX_DIALOG_ID (TWT_GET_ALL_PEER_PARAMS_DIALOG_ID - 1)
32 
33 #if defined(WLAN_SUPPORT_TWT) && defined(WLAN_TWT_CONV_SUPPORTED)
34 /**
35  * ucfg_twt_psoc_open() - TWT psoc open
36  * @psoc: Pointer to global PSOC object
37  *
38  * Upon psoc open, this function initializes the twt config params
39  *
40  * Return: QDF_STATUS_SUCCESS
41  */
42 QDF_STATUS ucfg_twt_psoc_open(struct wlan_objmgr_psoc *psoc);
43 
44 /**
45  * ucfg_twt_psoc_close() - TWT psoc close
46  * @psoc: Pointer to global PSOC object
47  *
48  * Return: QDF_STATUS_SUCCESS
49  */
50 QDF_STATUS ucfg_twt_psoc_close(struct wlan_objmgr_psoc *psoc);
51 
52 /**
53  * ucfg_twt_update_psoc_config() - TWT update config
54  * @psoc: Pointer to global PSOC object
55  *
56  * Return: QDF_STATUS_SUCCESS
57  */
58 QDF_STATUS ucfg_twt_update_psoc_config(struct wlan_objmgr_psoc *psoc);
59 
60 /**
61  * ucfg_twt_setup_req() - TWT setup
62  * @psoc: Pointer to global PSOC object
63  * @params: add dialog params
64  * @context: twt context
65  *
66  * Return: QDF_STATUS_SUCCESS
67  */
68 QDF_STATUS ucfg_twt_setup_req(struct wlan_objmgr_psoc *psoc,
69 			      struct twt_add_dialog_param *params,
70 			      void *context);
71 
72 /**
73  * ucfg_twt_teardown_req() - TWT teardown
74  * @psoc: Pointer to global PSOC object
75  * @params: delete dialog params
76  * @context: twt context
77  *
78  * Return: QDF_STATUS_SUCCESS
79  */
80 QDF_STATUS ucfg_twt_teardown_req(struct wlan_objmgr_psoc *psoc,
81 				 struct twt_del_dialog_param *params,
82 				 void *context);
83 
84 /**
85  * ucfg_twt_pause_req() - Process TWT pause req
86  * @psoc: psoc
87  * @params: pause dialog cmd param
88  * @context: context
89  *
90  * Perform validations and set WLAN_TWT_SUSPEND
91  * in progress
92  *
93  * Return: QDF_STATUS
94  */
95 QDF_STATUS ucfg_twt_pause_req(struct wlan_objmgr_psoc *psoc,
96 			      struct twt_pause_dialog_cmd_param *params,
97 			      void *context);
98 
99 /**
100  * ucfg_twt_resume_req() - Process TWT resume req
101  * @psoc: psoc
102  * @params: resume dialog cmd param
103  * @context: context
104  *
105  * Perform validations and set WLAN_TWT_RESUME
106  * in progress
107  *
108  * Return: QDF_STATUS
109  */
110 QDF_STATUS ucfg_twt_resume_req(struct wlan_objmgr_psoc *psoc,
111 			      struct twt_resume_dialog_cmd_param *params,
112 			      void *context);
113 
114 /**
115  * ucfg_twt_nudge_req() - Process TWT nudge req
116  * @psoc: psoc
117  * @params: nudge dialog cmd param
118  * @context: context
119  *
120  * Perform validations and set WLAN_TWT_NUDGE
121  * in progress
122  *
123  * Return: QDF_STATUS
124  */
125 QDF_STATUS ucfg_twt_nudge_req(struct wlan_objmgr_psoc *psoc,
126 			      struct twt_nudge_dialog_cmd_param *params,
127 			      void *context);
128 
129 /**
130  * ucfg_twt_ac_pdev_param_send() - pdev TWT param send
131  * @psoc: Pointer to psoc object
132  * @twt_ac: TWT access category
133  *
134  * Return: QDF Status
135  */
136 QDF_STATUS
137 ucfg_twt_ac_pdev_param_send(struct wlan_objmgr_psoc *psoc,
138 			    enum twt_traffic_ac twt_ac);
139 
140 /**
141  * ucfg_twt_is_max_sessions_reached() - Check if the maximum number of
142  * TWT sessions reached or not excluding the given dialog_id
143  * @psoc: Pointer to global PSOC object
144  * @peer_mac: Global peer mac address
145  * @dialog_id: dialog id
146  *
147  * Check if the number of active TWT sessions is equal to the maximum number
148  * of TWT sessions supported. Only count the TWT session slot if it not
149  * TWT_ALL_SESSIONS_DIALOG_ID and dialog id is different from input dialog_id,
150  * because if same dialog_id already exists in the TWT sessions, we should
151  * return false since re-negotiation is supported on existing dialog_id.
152  *
153  * Return: True if slot is available for dialog_id, false otherwise
154  */
155 bool ucfg_twt_is_max_sessions_reached(struct wlan_objmgr_psoc *psoc,
156 				      struct qdf_mac_addr *peer_mac,
157 				      uint8_t dialog_id);
158 
159 /**
160  * ucfg_twt_is_setup_in_progress() - Get if TWT setup command is in progress
161  * for given dialog id
162  * @psoc: Pointer to global psoc object
163  * @peer_mac: Global peer mac address
164  * @dialog_id: Dialog ID
165  *
166  * Return: True if Setup is in progress
167  */
168 bool ucfg_twt_is_setup_in_progress(struct wlan_objmgr_psoc *psoc,
169 				   struct qdf_mac_addr *peer_mac,
170 				   uint8_t dialog_id);
171 
172 /**
173  * ucfg_twt_cfg_is_twt_enabled() - Get if TWT is enabled
174  * @psoc: PSOC pointer
175  *
176  * Return: True if TWT is enabled
177  */
178 bool ucfg_twt_cfg_is_twt_enabled(struct wlan_objmgr_psoc *psoc);
179 
180 /**
181  * ucfg_twt_set_command_in_progress() - Set TWT command is in progress
182  * @psoc: Pointer to psoc object
183  * @peer_mac: Pointer to peer mac address
184  * @dialog_id: Dialog id
185  * @cmd: TWT command
186  *
187  * Return: QDF_STATUS
188  */
189 QDF_STATUS
190 ucfg_twt_set_command_in_progress(struct wlan_objmgr_psoc *psoc,
191 				 struct qdf_mac_addr *peer_mac,
192 				 uint8_t dialog_id,
193 				 enum wlan_twt_commands cmd);
194 
195 /**
196  * ucfg_twt_reset_active_command() - Reset active command to WLAN_TWT_NONE
197  * @psoc: Pointer to psoc object
198  * @peer_mac: Pointer to peer mac address
199  * @dialog_id: Dialog id
200  *
201  * Return: QDF_STATUS
202  */
203 QDF_STATUS
204 ucfg_twt_reset_active_command(struct wlan_objmgr_psoc *psoc,
205 			      struct qdf_mac_addr *peer_mac,
206 			      uint8_t dialog_id);
207 
208 /**
209  * ucfg_twt_init_context() - Initialize TWT context
210  * @psoc: Pointer to global psoc object
211  * @peer_mac: Global peer mac address
212  * @dialog_id: Dialog ID
213  *
214  * Return: QDF_STATUS_SUCCESS
215  */
216 QDF_STATUS
217 ucfg_twt_init_context(struct wlan_objmgr_psoc *psoc,
218 		      struct qdf_mac_addr *peer_mac,
219 		      uint8_t dialog_id);
220 
221 /**
222  * ucfg_twt_set_osif_cb() - Set TWT osif callbacks
223  * @osif_twt_ops: pointer to global osif ops
224  *
225  * Return: QDF_STATUS_SUCCESS
226  */
227 QDF_STATUS
228 ucfg_twt_set_osif_cb(osif_twt_get_global_ops_cb osif_twt_ops);
229 
230 /**
231  * ucfg_twt_update_beacon_template() - update beacon template
232  *
233  * SoftAP (SAP) is the beaconing entity, as per current requirement
234  * during Single Channel Concurrency (SCC) or Multi-Channel Concurrency (MCC)
235  * TWT is not supported on STA as well as SAP.
236  *
237  * Whenever SAP is forming SCC/MCC, this function shall be called to update the
238  * beacon, underlying LIM layer based the TWT responder flag, it disables the
239  * TWT responder advertisement bit in the beacon.
240  *
241  * When SAP moves from SCC/MCC to Standalone, this function shall be called
242  * to update the beacon, underlying LIM layer based the TWT responder flag,
243  * it enables  the TWT responder advertisement bit in the beacon.
244  *
245  * Return: QDF_STATUS_SUCCESS
246  */
247 QDF_STATUS ucfg_twt_update_beacon_template(void);
248 
249 /**
250  * ucfg_twt_is_setup_done() - check if TWT setup is done or not
251  * for given dialog id
252  * @psoc: Pointer to global psoc object
253  * @peer_mac: Global peer mac address
254  * @dialog_id: Dialog ID
255  *
256  * Return: True if Setup is done, false otherwise
257  */
258 bool
259 ucfg_twt_is_setup_done(struct wlan_objmgr_psoc *psoc,
260 		       struct qdf_mac_addr *peer_mac,
261 		       uint8_t dialog_id);
262 
263 /**
264  * ucfg_twt_get_session_state() - get TWT session state for a given dialog id
265  * @psoc: Pointer to global psoc object
266  * @peer_mac: Global peer mac address
267  * @dialog_id: Dialog ID
268  *
269  * Return: TWT session state
270  */
271 enum wlan_twt_session_state
272 ucfg_twt_get_session_state(struct wlan_objmgr_psoc *psoc,
273 			   struct qdf_mac_addr *peer_mac, uint8_t dialog_id);
274 
275 bool ucfg_twt_is_command_in_progress(struct wlan_objmgr_psoc *psoc,
276 				     struct qdf_mac_addr *peer_mac,
277 				     uint8_t dialog_id,
278 				     enum wlan_twt_commands cmd,
279 				     enum wlan_twt_commands *pactive_cmd);
280 
281 /**
282  * ucfg_twt_set_work_params() - Set TWT work params
283  * @vdev: Vdev pointer
284  * @peer_mac: peer mac address
285  * @dialog_id: dialog_id
286  * @is_ps_disabled: Whether Power saave is disabled or not
287  * @twt_next_action: Set TWT next action to do before work schedule
288  *
289  * Return: None
290  */
291 void ucfg_twt_set_work_params(
292 		struct wlan_objmgr_vdev *vdev,
293 		struct qdf_mac_addr *peer_mac,
294 		uint8_t dialog_id,
295 		bool is_ps_disabled,
296 		uint32_t twt_next_action);
297 
298 /**
299  * ucfg_twt_get_work_params() - Get TWT work params
300  * @vdev: vdev pointer
301  * @params: TWT work params
302  * @next_action: Get TWT next action to do after work scheduled
303  *
304  * Return: None
305  */
306 void ucfg_twt_get_work_params(struct wlan_objmgr_vdev *vdev,
307 			      struct twt_work_params *params,
308 			      uint32_t *next_action);
309 
310 /**
311  * ucfg_twt_cfg_set_responder() - Set TWT responder capability
312  * @psoc: Pointer to global PSOC object
313  * @val: pointer to value to be set
314  *
315  * Return: QDF_STATUS
316  */
317 QDF_STATUS ucfg_twt_cfg_set_responder(struct wlan_objmgr_psoc *psoc, bool val);
318 /**
319  * ucfg_twt_get_pmo_allowed() - Get twt allowed
320  * @psoc: psoc handler
321  *
322  * Return: QDF_STATUS_SUCCESS
323  */
324 bool ucfg_twt_get_pmo_allowed(struct wlan_objmgr_psoc *psoc);
325 #else
326 static inline
ucfg_twt_psoc_open(struct wlan_objmgr_psoc * psoc)327 QDF_STATUS ucfg_twt_psoc_open(struct wlan_objmgr_psoc *psoc)
328 {
329 	return QDF_STATUS_SUCCESS;
330 }
331 
332 static inline
ucfg_twt_psoc_close(struct wlan_objmgr_psoc * psoc)333 QDF_STATUS ucfg_twt_psoc_close(struct wlan_objmgr_psoc *psoc)
334 {
335 	return QDF_STATUS_SUCCESS;
336 }
337 
338 static inline
ucfg_twt_update_psoc_config(struct wlan_objmgr_psoc * psoc)339 QDF_STATUS ucfg_twt_update_psoc_config(struct wlan_objmgr_psoc *psoc)
340 {
341 	return QDF_STATUS_SUCCESS;
342 }
343 
344 static inline
ucfg_twt_setup_req(struct wlan_objmgr_psoc * psoc,struct twt_add_dialog_param * params,void * context)345 QDF_STATUS ucfg_twt_setup_req(struct wlan_objmgr_psoc *psoc,
346 			      struct twt_add_dialog_param *params,
347 			      void *context)
348 {
349 	return QDF_STATUS_SUCCESS;
350 }
351 
352 static inline
ucfg_twt_teardown_req(struct wlan_objmgr_psoc * psoc,struct twt_del_dialog_param * params,void * context)353 QDF_STATUS ucfg_twt_teardown_req(struct wlan_objmgr_psoc *psoc,
354 				     struct twt_del_dialog_param *params,
355 				     void *context)
356 {
357 	return QDF_STATUS_SUCCESS;
358 }
359 
360 static inline
ucfg_twt_pause_req(struct wlan_objmgr_psoc * psoc,struct twt_pause_dialog_cmd_param * params,void * context)361 QDF_STATUS ucfg_twt_pause_req(struct wlan_objmgr_psoc *psoc,
362 			      struct twt_pause_dialog_cmd_param *params,
363 			      void *context)
364 {
365 	return QDF_STATUS_SUCCESS;
366 }
367 
368 static inline
ucfg_twt_resume_req(struct wlan_objmgr_psoc * psoc,struct twt_resume_dialog_cmd_param * params,void * context)369 QDF_STATUS ucfg_twt_resume_req(struct wlan_objmgr_psoc *psoc,
370 			      struct twt_resume_dialog_cmd_param *params,
371 			      void *context)
372 {
373 	return QDF_STATUS_SUCCESS;
374 }
375 
376 static inline QDF_STATUS
ucfg_twt_init_context(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id)377 ucfg_twt_init_context(struct wlan_objmgr_psoc *psoc,
378 		      struct qdf_mac_addr *peer_mac,
379 		      uint8_t dialog_id)
380 {
381 	return QDF_STATUS_E_NOSUPPORT;
382 }
383 
384 static inline QDF_STATUS
ucfg_twt_set_osif_cb(osif_twt_get_global_ops_cb osif_twt_ops)385 ucfg_twt_set_osif_cb(osif_twt_get_global_ops_cb osif_twt_ops)
386 {
387 	return QDF_STATUS_E_NOSUPPORT;
388 }
389 
390 static inline bool
ucfg_twt_is_setup_done(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id)391 ucfg_twt_is_setup_done(struct wlan_objmgr_psoc *psoc,
392 		       struct qdf_mac_addr *peer_mac,
393 		       uint8_t dialog_id)
394 {
395 	return false;
396 }
397 
398 static inline enum wlan_twt_session_state
ucfg_twt_get_session_state(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * peer_mac,uint8_t dialog_id)399 ucfg_twt_get_session_state(struct wlan_objmgr_psoc *psoc,
400 			   struct qdf_mac_addr *peer_mac, uint8_t dialog_id)
401 {
402 	return WLAN_TWT_SETUP_STATE_NOT_ESTABLISHED;
403 }
404 
405 static inline bool
ucfg_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)406 ucfg_twt_is_command_in_progress(struct wlan_objmgr_psoc *psoc,
407 				struct qdf_mac_addr *peer_mac,
408 				uint8_t dialog_id,
409 				enum wlan_twt_commands cmd,
410 				enum wlan_twt_commands *pactive_cmd)
411 {
412 	return false;
413 }
414 
415 static inline void
ucfg_twt_set_work_params(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr * peer_mac,uint8_t dialog_id,bool is_ps_disabled,uint32_t twt_next_action)416 ucfg_twt_set_work_params(
417 		struct wlan_objmgr_vdev *vdev,
418 		struct qdf_mac_addr *peer_mac,
419 		uint8_t dialog_id,
420 		bool is_ps_disabled,
421 		uint32_t twt_next_action)
422 {
423 }
424 
425 static inline void
ucfg_twt_get_work_params(struct wlan_objmgr_vdev * vdev,struct twt_work_params * params,uint32_t * next_action)426 ucfg_twt_get_work_params(
427 		struct wlan_objmgr_vdev *vdev,
428 		struct twt_work_params *params,
429 		uint32_t *next_action)
430 {
431 }
432 
433 static inline
ucfg_twt_cfg_set_responder(struct wlan_objmgr_psoc * psoc,bool val)434 QDF_STATUS ucfg_twt_cfg_set_responder(struct wlan_objmgr_psoc *psoc, bool val)
435 {
436 	return QDF_STATUS_SUCCESS;
437 }
438 
439 static inline
ucfg_twt_cfg_is_twt_enabled(struct wlan_objmgr_psoc * psoc)440 bool ucfg_twt_cfg_is_twt_enabled(struct wlan_objmgr_psoc *psoc)
441 {
442 	return false;
443 }
444 
445 static inline
ucfg_twt_get_pmo_allowed(struct wlan_objmgr_psoc * psoc)446 bool ucfg_twt_get_pmo_allowed(struct wlan_objmgr_psoc *psoc)
447 {
448 	return false;
449 }
450 
451 #endif
452 #endif
453