blob: 7e86d2c48fb53ed3b55fa0b61d11705107ab43f4 [file] [log] [blame]
Govind Singhd475ea92016-03-06 19:55:02 +05301/*
2 * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
Govind Singh6ad6ada2016-02-04 18:42:30 +053029 * This file contains the API definitions for the Unified Wireless Module
30 * Interface (WMI).
Govind Singhd475ea92016-03-06 19:55:02 +053031 */
32
33#ifndef _WMI_UNIFIED_API_H_
34#define _WMI_UNIFIED_API_H_
35
36#include <osdep.h>
37#include "a_types.h"
38#include "ol_defines.h"
39#include "wmi.h"
40#include "htc_api.h"
Govind Singh3ddda1f2016-03-09 11:34:12 +053041#include "wmi_unified_param.h"
Govind Singhd475ea92016-03-06 19:55:02 +053042
43typedef cdf_nbuf_t wmi_buf_t;
44#define wmi_buf_data(_buf) cdf_nbuf_data(_buf)
45
46/**
Govind Singh6ad6ada2016-02-04 18:42:30 +053047 * struct wmi_ops - service callbacks to upper layer
48 * @service_ready_cbk: service ready callback
49 * @service_ready_ext_cbk: service ready ext callback
50 * @ready_cbk: ready calback
51 * @wma_process_fw_event_handler_cbk: generic event handler callback
52 */
Govind Singh3ddda1f2016-03-09 11:34:12 +053053struct wmi_rx_ops {
Govind Singh4ec6ff92016-03-09 12:03:29 +053054
Govind Singh6ad6ada2016-02-04 18:42:30 +053055 int (*wma_process_fw_event_handler_cbk)(void *ctx,
Govind Singh4ec6ff92016-03-09 12:03:29 +053056 void *ev, uint8_t rx_ctx);
Govind Singh6ad6ada2016-02-04 18:42:30 +053057};
58
59/**
60 * enum wmi_target_type - type of supported wmi command
61 * @WMI_TLV_TARGET: tlv based target
62 * @WMI_NON_TLV_TARGET: non-tlv based target
63 *
64 */
65enum wmi_target_type {
66 WMI_TLV_TARGET,
67 WMI_NON_TLV_TARGET
68};
69
70/**
Govind Singh4ec6ff92016-03-09 12:03:29 +053071 * enum wmi_rx_exec_ctx - wmi rx execution context
72 * @WMI_RX_WORK_CTX: work queue context execution provided by WMI layer
73 * @WMI_RX_UMAC_CTX: execution context provided by umac layer
74 *
75 */
76enum wmi_rx_exec_ctx {
77 WMI_RX_WORK_CTX,
78 WMI_RX_UMAC_CTX
79};
80
81/**
Govind Singhd475ea92016-03-06 19:55:02 +053082 * attach for unified WMI
83 *
84 * @param scn_handle : handle to SCN.
85 * @return opaque handle.
86 */
87void *wmi_unified_attach(void *scn_handle,
Govind Singh6ad6ada2016-02-04 18:42:30 +053088 osdev_t osdev, enum wmi_target_type target_type,
Govind Singh3ddda1f2016-03-09 11:34:12 +053089 bool use_cookie, struct wmi_rx_ops *ops);
Govind Singh6ad6ada2016-02-04 18:42:30 +053090
Govind Singhd475ea92016-03-06 19:55:02 +053091/**
92 * detach for unified WMI
93 *
94 * @param wmi_handle : handle to WMI.
95 * @return void.
96 */
97void wmi_unified_detach(struct wmi_unified *wmi_handle);
98
99void
100wmi_unified_remove_work(struct wmi_unified *wmi_handle);
101
102/**
103 * generic function to allocate WMI buffer
104 *
105 * @param wmi_handle : handle to WMI.
106 * @param len : length of the buffer
107 * @return wmi_buf_t.
108 */
109#ifdef MEMORY_DEBUG
110#define wmi_buf_alloc(h, l) wmi_buf_alloc_debug(h, l, __FILE__, __LINE__)
111wmi_buf_t
112wmi_buf_alloc_debug(wmi_unified_t wmi_handle, uint16_t len,
113 uint8_t *file_name, uint32_t line_num);
114#else
115wmi_buf_t wmi_buf_alloc(wmi_unified_t wmi_handle, uint16_t len);
116#endif
117
118/**
119 * generic function frees WMI net buffer
120 *
121 * @param net_buf : Pointer ot net_buf to be freed
122 */
123void wmi_buf_free(wmi_buf_t net_buf);
124
125/**
126 * generic function to send unified WMI command
127 *
128 * @param wmi_handle : handle to WMI.
129 * @param buf : wmi command buffer
130 * @param buflen : wmi command buffer length
131 * @return 0 on success and -ve on failure.
132 */
133int
Govind Singh6ad6ada2016-02-04 18:42:30 +0530134wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf, uint32_t buflen,
Govind Singhd475ea92016-03-06 19:55:02 +0530135 WMI_CMD_ID cmd_id);
136
137/**
Govind Singh4ec6ff92016-03-09 12:03:29 +0530138 * wmi_unified_register_event_handler() - WMI event handler
139 * registration function
Govind Singhd475ea92016-03-06 19:55:02 +0530140 *
Govind Singh4ec6ff92016-03-09 12:03:29 +0530141 * @wmi_handle: handle to WMI.
142 * @event_id: WMI event ID
143 * @handler_func: Event handler call back function
144 * @rx_ctx: rx event processing context
145 *
Govind Singhd475ea92016-03-06 19:55:02 +0530146 * @return 0 on success and -ve on failure.
147 */
148int
149wmi_unified_register_event_handler(wmi_unified_t wmi_handle,
150 WMI_EVT_ID event_id,
Govind Singh4ec6ff92016-03-09 12:03:29 +0530151 wmi_unified_event_handler handler_func,
152 uint8_t rx_ctx);
Govind Singhd475ea92016-03-06 19:55:02 +0530153
154/**
155 * WMI event handler unregister function
156 *
157 * @param wmi_handle : handle to WMI.
158 * @param event_id : WMI event ID
159 * @return 0 on success and -ve on failure.
160 */
161int
162wmi_unified_unregister_event_handler(wmi_unified_t wmi_handle,
163 WMI_EVT_ID event_id);
164
165/**
166 * request wmi to connet its htc service.
167 * @param wmi_handle : handle to WMI.
168 * @return void
169 */
170int
171wmi_unified_connect_htc_service(struct wmi_unified *wmi_handle,
172 void *htc_handle);
173
174/*
175 * WMI API to verify the host has enough credits to suspend
176 */
177
178int wmi_is_suspend_ready(wmi_unified_t wmi_handle);
179
180/**
181 WMI API to get updated host_credits
182 */
183
184int wmi_get_host_credits(wmi_unified_t wmi_handle);
185
186/**
187 WMI API to get WMI Pending Commands in the HTC queue
188 */
189
190int wmi_get_pending_cmds(wmi_unified_t wmi_handle);
191
192/**
193 WMI API to set target suspend state
194 */
Govind Singhd475ea92016-03-06 19:55:02 +0530195void wmi_set_target_suspend(wmi_unified_t wmi_handle, bool val);
196
197#ifdef FEATURE_RUNTIME_PM
198void
199wmi_set_runtime_pm_inprogress(wmi_unified_t wmi_handle, bool val);
200bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle);
201#else
202static inline void
203wmi_set_runtime_pm_inprogress(wmi_unified_t wmi_handle, bool val)
204{
205 return;
206}
207static inline bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle)
208{
209 return false;
210}
211#endif
212
Govind Singh4ec6ff92016-03-09 12:03:29 +0530213
Govind Singhd475ea92016-03-06 19:55:02 +0530214/**
215 * WMA Callback to process fw event.
216 */
Govind Singhd475ea92016-03-06 19:55:02 +0530217void wmi_process_fw_event(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf);
218uint16_t wmi_get_max_msg_len(wmi_unified_t wmi_handle);
Govind Singh3ddda1f2016-03-09 11:34:12 +0530219
220
221int32_t wmi_unified_vdev_create_send(void *wmi_hdl,
222 uint8_t macaddr[IEEE80211_ADDR_LEN],
223 struct vdev_create_params *param);
224
225int32_t wmi_unified_vdev_delete_send(void *wmi_hdl,
226 uint8_t if_id);
227
228int32_t wmi_unified_vdev_start_send(void *wmi_hdl,
229 uint8_t macaddr[IEEE80211_ADDR_LEN],
230 struct vdev_start_params *param);
231
232int32_t wmi_unified_vdev_restart_send(void *wmi_hdl,
233 uint8_t macaddr[IEEE80211_ADDR_LEN],
234 struct vdev_start_params *param);
235
236int32_t wmi_unified_vdev_stop_send(void *wmi_hdl,
237 uint8_t vdev_id);
238
239int32_t wmi_unified_vdev_up_send(void *wmi_hdl,
240 uint8_t bssid[IEEE80211_ADDR_LEN],
241 struct vdev_up_params *params);
242
243int32_t wmi_unified_vdev_down_send(void *wmi_hdl,
244 uint8_t vdev_id);
245
246int32_t wmi_unified_vdev_set_param_send(void *wmi_hdl,
247 struct vdev_set_params *param);
248
249int32_t wmi_unified_peer_delete_send(void *wmi_hdl,
250 uint8_t
251 peer_addr[IEEE80211_ADDR_LEN],
252 uint8_t vdev_id);
253
254int32_t wmi_unified_peer_flush_tids_send(void *wmi_hdl,
255 uint8_t peer_addr[IEEE80211_ADDR_LEN],
256 struct peer_flush_params *param);
257
258int32_t wmi_set_peer_param_send(void *wmi_hdl,
259 uint8_t peer_addr[IEEE80211_ADDR_LEN],
260 struct peer_set_params *param);
261
262int32_t wmi_unified_peer_create_send(void *wmi_hdl,
263 struct peer_create_params *param);
264
265int32_t wmi_unified_stats_request_send(void *wmi_hdl,
266 uint8_t macaddr[IEEE80211_ADDR_LEN],
267 struct stats_request_params *param);
268
269int32_t wmi_unified_green_ap_ps_send(void *wmi_hdl,
270 uint32_t value, uint8_t mac_id);
271
272
273int32_t wmi_unified_wow_enable_send(void *wmi_hdl,
274 struct wow_cmd_params *param,
275 uint8_t mac_id);
276
277int32_t wmi_unified_packet_log_enable_send(void *wmi_hdl,
278 uint8_t macaddr[IEEE80211_ADDR_LEN],
279 struct packet_enable_params *param);
280
281
282int32_t wmi_unified_suspend_send(void *wmi_hdl,
283 struct suspend_params *param,
284 uint8_t mac_id);
285
286int32_t wmi_unified_resume_send(void *wmi_hdl,
287 uint8_t mac_id);
288
289int32_t
290wmi_unified_pdev_param_send(void *wmi_hdl,
291 struct pdev_params *param,
292 uint8_t mac_id);
293
294int32_t wmi_unified_beacon_send_cmd(void *wmi_hdl,
295 uint8_t macaddr[IEEE80211_ADDR_LEN],
296 struct beacon_params *param);
297
298int32_t wmi_unified_peer_assoc_send(void *wmi_hdl,
299 uint8_t macaddr[IEEE80211_ADDR_LEN],
300 struct peer_assoc_params *param);
301
302int32_t wmi_unified_sta_ps_cmd_send(void *wmi_hdl,
303 struct sta_ps_params *param);
304
305int32_t wmi_unified_ap_ps_cmd_send(void *wmi_hdl,
306 uint8_t macaddr[IEEE80211_ADDR_LEN],
307 struct ap_ps_params *param);
308
309int32_t wmi_unified_scan_start_cmd_send(void *wmi_hdl,
310 uint8_t macaddr[IEEE80211_ADDR_LEN],
311 struct scan_start_params *param);
312
313int32_t wmi_unified_scan_stop_cmd_send(void *wmi_hdl,
314 uint8_t macaddr[IEEE80211_ADDR_LEN],
315 struct scan_stop_params *param);
316
317int32_t wmi_unified_scan_chan_list_cmd_send(void *wmi_hdl,
318 uint8_t macaddr[IEEE80211_ADDR_LEN],
319 struct scan_chan_list_params *param);
320
321
322int32_t wmi_crash_inject(void *wmi_hdl,
323 struct crash_inject *param);
324
325int32_t wmi_unified_pdev_utf_cmd_send(void *wmi_hdl,
326 struct pdev_utf_params *param,
327 uint8_t mac_id);
328
329int32_t wmi_unified_dbglog_cmd_send(void *wmi_hdl,
330 struct dbglog_params *param);
331
Govind Singhd475ea92016-03-06 19:55:02 +0530332#endif /* _WMI_UNIFIED_API_H_ */