1 /*
2 * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
3 * Copyright (c) 2021-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 #ifndef __WMA_TWT_H
21 #define __WMA_TWT_H
22
23 #include "wma.h"
24 #include "wmi_unified_twt_param.h"
25
26 /**
27 * struct twt_enable_disable_conf - TWT enable/disable configuration/parameters
28 * @congestion_timeout: Congestion timer value in ms for firmware controlled TWT
29 * @bcast_en: If bcast TWT enabled
30 * @ext_conf_present: If extended config is present
31 * @role: The configuration is for WMI_TWT_ROLE
32 * @oper: The configuration is for WMI_TWT_OPERATION
33 */
34 struct twt_enable_disable_conf {
35 uint32_t congestion_timeout;
36 bool bcast_en;
37 bool ext_conf_present;
38 enum WMI_TWT_ROLE role;
39 enum WMI_TWT_OPERATION oper;
40 };
41
42 /**
43 * struct wma_twt_add_dialog_complete_event - TWT add dialog complete event
44 * @params: Fixed parameters for TWT add dialog complete event
45 * @additional_params: additional parameters for TWT add dialog complete event
46 *
47 * Holds the fixed and additional parameters from add dialog
48 * complete event
49 */
50 struct wma_twt_add_dialog_complete_event {
51 struct wmi_twt_add_dialog_complete_event_param params;
52 struct wmi_twt_add_dialog_additional_params additional_params;
53 };
54
55 #ifdef WLAN_SUPPORT_TWT
56 /**
57 * wma_send_twt_enable_cmd() - Send TWT Enable command to firmware
58 * @pdev_id: pdev id
59 * @conf: Pointer to twt_enable_disable_conf
60 *
61 * Return: None
62 */
63 void wma_send_twt_enable_cmd(uint32_t pdev_id,
64 struct twt_enable_disable_conf *conf);
65
66 /**
67 * wma_set_twt_peer_caps() - Fill the peer TWT capabilities
68 * @params: STA context params which will store the capabilities
69 * @cmd: Command in which the capabilities should be populated
70 *
71 * Return: None
72 */
73 void wma_set_twt_peer_caps(tpAddStaParams params,
74 struct peer_assoc_params *cmd);
75
76 /**
77 * wma_send_twt_disable_cmd() - Send TWT disable command to firmware
78 * @pdev_id: pdev id
79 * @conf: Pointer to twt_enable_disable_conf
80 *
81 * Return: None
82 */
83 void wma_send_twt_disable_cmd(uint32_t pdev_id,
84 struct twt_enable_disable_conf *conf);
85
86 /**
87 * wma_twt_process_add_dialog() - Process twt add dialog command
88 * @wma_handle: wma handle
89 * @params: add dialog configuration parameters
90 *
91 * Return: QDF_STATUS_SUCCESS on success, other QDF_STATUS error code
92 * on failure
93 */
94
95 QDF_STATUS wma_twt_process_add_dialog(t_wma_handle *wma_handle,
96 struct wmi_twt_add_dialog_param *params);
97
98 /**
99 * wma_twt_process_del_dialog() - Process del dialog command
100 * @wma_handle: wma handle
101 * @params: del dialog configuration parameters
102 *
103 * Return: QDF_STATUS_SUCCESS on success, other QDF_STATUS error code
104 * on failure
105 */
106 QDF_STATUS wma_twt_process_del_dialog(t_wma_handle *wma_handle,
107 struct wmi_twt_del_dialog_param *params);
108
109 /**
110 * wma_twt_process_pause_dialog() - Process pause dialog command
111 * @wma_handle: wma handle
112 * @params: pause dialog configuration parameters
113 *
114 * Return: QDF_STATUS_SUCCESS on success, other QDF_STATUS error code
115 * on failure
116 */
117 QDF_STATUS
118 wma_twt_process_pause_dialog(t_wma_handle *wma_handle,
119 struct wmi_twt_pause_dialog_cmd_param *params);
120
121 /**
122 * wma_twt_process_nudge_dialog() - Process nudge dialog command
123 * @wma_handle: wma handle
124 * @params: nudge dialog configuration parameters
125 *
126 * Return: QDF_STATUS_SUCCESS on success, other QDF_STATUS error code
127 * on failure
128 */
129 QDF_STATUS
130 wma_twt_process_nudge_dialog(t_wma_handle *wma_handle,
131 struct wmi_twt_nudge_dialog_cmd_param *params);
132
133 /**
134 * wma_twt_process_resume_dialog() - Process resume dialog command
135 * @wma_handle: wma handle
136 * @params: resume dialog configuration parameters
137 *
138 * Return: QDF_STATUS_SUCCESS on success, other QDF_STATUS error code
139 * on failure
140 */
141 QDF_STATUS
142 wma_twt_process_resume_dialog(t_wma_handle *wma_handle,
143 struct wmi_twt_resume_dialog_cmd_param *params);
144
145 /**
146 * wma_update_bcast_twt_support() - update bcost twt support
147 * @wh: wma handle
148 * @tgt_cfg: target configuration to be updated
149 *
150 * Update braodcast twt support based on service bit.
151 *
152 * Return: None
153 */
154 void wma_update_bcast_twt_support(tp_wma_handle wh,
155 struct wma_tgt_cfg *tgt_cfg);
156
157 /**
158 * wma_update_twt_tgt_cap()- update the supported twt capabilities
159 * @wh: wma handle
160 * @tgt_cfg: target configuration to be updated
161 *
162 * Update support for twt capabilities based on service bit.
163 *
164 * Return: None
165 */
166 void wma_update_twt_tgt_cap(tp_wma_handle wh, struct wma_tgt_cfg *tgt_cfg);
167
168 /**
169 * wma_register_twt_events() - register for TWT wmi events
170 * @wma_handle : wma handle
171 *
172 * Registers the wmi event handlers for TWT.
173 *
174 * Return: None
175 */
176 void wma_register_twt_events(tp_wma_handle wma_handle);
177 #else
178 static inline void
wma_send_twt_enable_cmd(uint32_t pdev_id,struct twt_enable_disable_conf * conf)179 wma_send_twt_enable_cmd(uint32_t pdev_id,
180 struct twt_enable_disable_conf *conf)
181 {
182 wma_debug("TWT not supported as WLAN_SUPPORT_TWT is disabled");
183 }
184
185 static inline void
wma_send_twt_disable_cmd(uint32_t pdev_id,struct twt_enable_disable_conf * conf)186 wma_send_twt_disable_cmd(uint32_t pdev_id,
187 struct twt_enable_disable_conf *conf)
188 {
189 }
190
wma_set_twt_peer_caps(tpAddStaParams params,struct peer_assoc_params * cmd)191 static inline void wma_set_twt_peer_caps(tpAddStaParams params,
192 struct peer_assoc_params *cmd)
193 {
194 }
195
196 static inline
wma_twt_process_add_dialog(t_wma_handle * wma_handle,struct wmi_twt_add_dialog_param * params)197 QDF_STATUS wma_twt_process_add_dialog(t_wma_handle *wma_handle,
198 struct wmi_twt_add_dialog_param *params)
199 {
200 wma_debug("TWT not supported as WLAN_SUPPORT_TWT is disabled");
201
202 return QDF_STATUS_E_INVAL;
203 }
204
205 static inline
wma_twt_process_del_dialog(t_wma_handle * wma_handle,struct wmi_twt_del_dialog_param * params)206 QDF_STATUS wma_twt_process_del_dialog(t_wma_handle *wma_handle,
207 struct wmi_twt_del_dialog_param *params)
208 {
209 wma_debug("TWT not supported as WLAN_SUPPORT_TWT is disabled");
210
211 return QDF_STATUS_E_INVAL;
212 }
213
214 static inline QDF_STATUS
wma_twt_process_pause_dialog(t_wma_handle * wma_handle,struct wmi_twt_pause_dialog_cmd_param * params)215 wma_twt_process_pause_dialog(t_wma_handle *wma_handle,
216 struct wmi_twt_pause_dialog_cmd_param *params)
217 {
218 wma_debug("TWT not supported as WLAN_SUPPORT_TWT is disabled");
219
220 return QDF_STATUS_E_INVAL;
221 }
222
223 static inline QDF_STATUS
wma_twt_process_nudge_dialog(t_wma_handle * wma_handle,struct wmi_twt_nudge_dialog_cmd_param * params)224 wma_twt_process_nudge_dialog(t_wma_handle *wma_handle,
225 struct wmi_twt_nudge_dialog_cmd_param *params)
226 {
227 wma_debug("TWT not supported as WLAN_SUPPORT_TWT is disabled");
228
229 return QDF_STATUS_E_INVAL;
230 }
231
232 static inline QDF_STATUS
wma_twt_process_resume_dialog(t_wma_handle * wma_handle,struct wmi_twt_resume_dialog_cmd_param * params)233 wma_twt_process_resume_dialog(t_wma_handle *wma_handle,
234 struct wmi_twt_resume_dialog_cmd_param *params)
235 {
236 wma_debug("TWT not supported as WLAN_SUPPORT_TWT is disabled");
237
238 return QDF_STATUS_E_INVAL;
239 }
240
wma_update_bcast_twt_support(tp_wma_handle wh,struct wma_tgt_cfg * tgt_cfg)241 static inline void wma_update_bcast_twt_support(tp_wma_handle wh,
242 struct wma_tgt_cfg *tgt_cfg)
243 {
244 }
245
246 static inline
wma_update_twt_tgt_cap(tp_wma_handle wh,struct wma_tgt_cfg * tgt_cfg)247 void wma_update_twt_tgt_cap(tp_wma_handle wh, struct wma_tgt_cfg *tgt_cfg)
248 {
249 }
wma_register_twt_events(tp_wma_handle wma_handle)250 static inline void wma_register_twt_events(tp_wma_handle wma_handle)
251 {
252 }
253 #endif
254
255 #endif /* __WMA_HE_H */
256