Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-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 | /* |
| 29 | * Host WMI unified implementation |
| 30 | */ |
| 31 | #include "athdefs.h" |
| 32 | #include "osapi_linux.h" |
| 33 | #include "a_types.h" |
| 34 | #include "a_debug.h" |
| 35 | #include "ol_if_athvar.h" |
| 36 | #include "ol_defines.h" |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 37 | #include "htc_api.h" |
| 38 | #include "htc_api.h" |
| 39 | #include "dbglog_host.h" |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 40 | #include "wmi_unified_priv.h" |
Govind Singh | 5eb5153 | 2016-03-09 11:34:12 +0530 | [diff] [blame] | 41 | #include "wmi_unified_param.h" |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 42 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 43 | #include <linux/debugfs.h> |
| 44 | |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 45 | /* This check for CONFIG_WIN temporary added due to redeclaration compilation |
| 46 | error in MCL. Error is caused due to inclusion of wmi.h in wmi_unified_api.h |
| 47 | which gets included here through ol_if_athvar.h. Eventually it is expected that |
| 48 | wmi.h will be removed from wmi_unified_api.h after cleanup, which will need |
| 49 | WMI_CMD_HDR to be defined here. */ |
| 50 | #ifdef CONFIG_WIN |
| 51 | /* Copied from wmi.h */ |
| 52 | #undef MS |
| 53 | #define MS(_v, _f) (((_v) & _f##_MASK) >> _f##_LSB) |
| 54 | #undef SM |
| 55 | #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK) |
| 56 | #undef WO |
| 57 | #define WO(_f) ((_f##_OFFSET) >> 2) |
| 58 | |
| 59 | #undef GET_FIELD |
| 60 | #define GET_FIELD(_addr, _f) MS(*((A_UINT32 *)(_addr) + WO(_f)), _f) |
| 61 | #undef SET_FIELD |
| 62 | #define SET_FIELD(_addr, _f, _val) \ |
| 63 | (*((A_UINT32 *)(_addr) + WO(_f)) = \ |
| 64 | (*((A_UINT32 *)(_addr) + WO(_f)) & ~_f##_MASK) | SM(_val, _f)) |
| 65 | |
| 66 | #define WMI_GET_FIELD(_msg_buf, _msg_type, _f) \ |
| 67 | GET_FIELD(_msg_buf, _msg_type ## _ ## _f) |
| 68 | |
| 69 | #define WMI_SET_FIELD(_msg_buf, _msg_type, _f, _val) \ |
| 70 | SET_FIELD(_msg_buf, _msg_type ## _ ## _f, _val) |
| 71 | |
| 72 | #define WMI_EP_APASS 0x0 |
| 73 | #define WMI_EP_LPASS 0x1 |
| 74 | #define WMI_EP_SENSOR 0x2 |
| 75 | |
| 76 | /* |
| 77 | * * Control Path |
| 78 | * */ |
| 79 | typedef PREPACK struct { |
| 80 | A_UINT32 commandId:24, |
| 81 | reserved:2, /* used for WMI endpoint ID */ |
| 82 | plt_priv:6; /* platform private */ |
| 83 | } POSTPACK WMI_CMD_HDR; /* used for commands and events */ |
| 84 | |
| 85 | #define WMI_CMD_HDR_COMMANDID_LSB 0 |
| 86 | #define WMI_CMD_HDR_COMMANDID_MASK 0x00ffffff |
| 87 | #define WMI_CMD_HDR_COMMANDID_OFFSET 0x00000000 |
| 88 | #define WMI_CMD_HDR_WMI_ENDPOINTID_MASK 0x03000000 |
| 89 | #define WMI_CMD_HDR_WMI_ENDPOINTID_OFFSET 24 |
| 90 | #define WMI_CMD_HDR_PLT_PRIV_LSB 24 |
| 91 | #define WMI_CMD_HDR_PLT_PRIV_MASK 0xff000000 |
| 92 | #define WMI_CMD_HDR_PLT_PRIV_OFFSET 0x00000000 |
| 93 | /* end of copy wmi.h */ |
| 94 | #endif /* CONFIG_WIN */ |
| 95 | |
Manikandan Mohan | 5826ae9 | 2016-06-08 16:29:39 -0700 | [diff] [blame] | 96 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)) |
| 97 | /* TODO Cleanup this backported function */ |
| 98 | int qcacld_bp_seq_printf(struct seq_file *m, const char *f, ...) |
| 99 | { |
| 100 | va_list args; |
| 101 | |
| 102 | va_start(args, f); |
| 103 | seq_printf(m, f, args); |
| 104 | va_end(args); |
| 105 | |
| 106 | return m->count; |
| 107 | } |
| 108 | |
| 109 | #define seq_printf(m, fmt, ...) qcacld_bp_seq_printf((m), fmt, ##__VA_ARGS__) |
| 110 | #endif |
| 111 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 112 | #define WMI_MIN_HEAD_ROOM 64 |
| 113 | |
| 114 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 115 | #ifndef MAX_WMI_INSTANCES |
| 116 | #ifdef CONFIG_MCL |
| 117 | #define MAX_WMI_INSTANCES 1 |
| 118 | #else |
| 119 | #define MAX_WMI_INSTANCES 3 |
| 120 | #endif |
| 121 | #endif |
| 122 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 123 | /* WMI commands */ |
| 124 | uint32_t g_wmi_command_buf_idx = 0; |
| 125 | struct wmi_command_debug wmi_command_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY]; |
| 126 | |
| 127 | /* WMI commands TX completed */ |
| 128 | uint32_t g_wmi_command_tx_cmp_buf_idx = 0; |
| 129 | struct wmi_command_debug |
| 130 | wmi_command_tx_cmp_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY]; |
| 131 | |
| 132 | /* WMI events when processed */ |
| 133 | uint32_t g_wmi_event_buf_idx = 0; |
| 134 | struct wmi_event_debug wmi_event_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY]; |
| 135 | |
| 136 | /* WMI events when queued */ |
| 137 | uint32_t g_wmi_rx_event_buf_idx = 0; |
| 138 | struct wmi_event_debug wmi_rx_event_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY]; |
| 139 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 140 | #define WMI_COMMAND_RECORD(h, a, b) { \ |
| 141 | if (wmi_log_max_entry <= \ |
| 142 | *(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)) \ |
| 143 | *(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx) = 0;\ |
| 144 | ((struct wmi_command_debug *)h->log_info.wmi_command_log_buf_info.buf)\ |
| 145 | [*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)]\ |
| 146 | .command = a; \ |
| 147 | qdf_mem_copy(((struct wmi_command_debug *)h->log_info. \ |
| 148 | wmi_command_log_buf_info.buf) \ |
| 149 | [*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)].data,\ |
| 150 | b, wmi_record_max_length); \ |
| 151 | ((struct wmi_command_debug *)h->log_info.wmi_command_log_buf_info.buf)\ |
| 152 | [*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)].\ |
| 153 | time = qdf_get_log_timestamp(); \ |
| 154 | (*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx))++; \ |
| 155 | h->log_info.wmi_command_log_buf_info.length++; \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 156 | } |
| 157 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 158 | #define WMI_COMMAND_TX_CMP_RECORD(h, a, b) { \ |
| 159 | if (wmi_log_max_entry <= \ |
| 160 | *(h->log_info.wmi_command_tx_cmp_log_buf_info.p_buf_tail_idx))\ |
| 161 | *(h->log_info.wmi_command_tx_cmp_log_buf_info.p_buf_tail_idx) = 0;\ |
| 162 | ((struct wmi_command_debug *)h->log_info. \ |
| 163 | wmi_command_tx_cmp_log_buf_info.buf) \ |
| 164 | [*(h->log_info.wmi_command_tx_cmp_log_buf_info. \ |
| 165 | p_buf_tail_idx)]. \ |
| 166 | command = a; \ |
| 167 | qdf_mem_copy(((struct wmi_command_debug *)h->log_info. \ |
| 168 | wmi_command_tx_cmp_log_buf_info.buf) \ |
| 169 | [*(h->log_info.wmi_command_tx_cmp_log_buf_info. \ |
| 170 | p_buf_tail_idx)]. \ |
| 171 | data, b, wmi_record_max_length); \ |
| 172 | ((struct wmi_command_debug *)h->log_info. \ |
| 173 | wmi_command_tx_cmp_log_buf_info.buf) \ |
| 174 | [*(h->log_info.wmi_command_tx_cmp_log_buf_info. \ |
| 175 | p_buf_tail_idx)]. \ |
| 176 | time = qdf_get_log_timestamp(); \ |
| 177 | (*(h->log_info.wmi_command_tx_cmp_log_buf_info.p_buf_tail_idx))++;\ |
| 178 | h->log_info.wmi_command_tx_cmp_log_buf_info.length++; \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 179 | } |
| 180 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 181 | #define WMI_EVENT_RECORD(h, a, b) { \ |
| 182 | if (wmi_log_max_entry <= \ |
| 183 | *(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx)) \ |
| 184 | *(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx) = 0;\ |
| 185 | ((struct wmi_event_debug *)h->log_info.wmi_event_log_buf_info.buf)\ |
| 186 | [*(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx)]. \ |
| 187 | event = a; \ |
| 188 | qdf_mem_copy(((struct wmi_event_debug *)h->log_info. \ |
| 189 | wmi_event_log_buf_info.buf) \ |
| 190 | [*(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx)].data, b,\ |
| 191 | wmi_record_max_length); \ |
| 192 | ((struct wmi_event_debug *)h->log_info.wmi_event_log_buf_info.buf)\ |
| 193 | [*(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx)].time =\ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 194 | qdf_get_log_timestamp(); \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 195 | (*(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx))++; \ |
| 196 | h->log_info.wmi_event_log_buf_info.length++; \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 197 | } |
| 198 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 199 | #define WMI_RX_EVENT_RECORD(h, a, b) { \ |
| 200 | if (wmi_log_max_entry <= \ |
| 201 | *(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx))\ |
| 202 | *(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx) = 0;\ |
| 203 | ((struct wmi_event_debug *)h->log_info.wmi_rx_event_log_buf_info.buf)\ |
| 204 | [*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx)].\ |
| 205 | event = a; \ |
| 206 | qdf_mem_copy(((struct wmi_event_debug *)h->log_info. \ |
| 207 | wmi_rx_event_log_buf_info.buf) \ |
| 208 | [*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx)].\ |
| 209 | data, b, wmi_record_max_length); \ |
| 210 | ((struct wmi_event_debug *)h->log_info.wmi_rx_event_log_buf_info.buf)\ |
| 211 | [*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx)].\ |
| 212 | time = qdf_get_log_timestamp(); \ |
| 213 | (*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx))++; \ |
| 214 | h->log_info.wmi_rx_event_log_buf_info.length++; \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 215 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 216 | |
| 217 | uint32_t g_wmi_mgmt_command_buf_idx = 0; |
| 218 | struct |
| 219 | wmi_command_debug wmi_mgmt_command_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY]; |
| 220 | |
| 221 | /* wmi_mgmt commands TX completed */ |
| 222 | uint32_t g_wmi_mgmt_command_tx_cmp_buf_idx = 0; |
| 223 | struct wmi_command_debug |
| 224 | wmi_mgmt_command_tx_cmp_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY]; |
| 225 | |
| 226 | /* wmi_mgmt events when processed */ |
| 227 | uint32_t g_wmi_mgmt_event_buf_idx = 0; |
| 228 | struct wmi_event_debug |
| 229 | wmi_mgmt_event_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY]; |
| 230 | |
Sandeep Puligilla | b74958d | 2016-06-13 15:42:55 -0700 | [diff] [blame] | 231 | #define WMI_MGMT_COMMAND_RECORD(a, b, c, d, e) { \ |
| 232 | if (WMI_MGMT_EVENT_DEBUG_MAX_ENTRY <= \ |
| 233 | g_wmi_mgmt_command_buf_idx) \ |
| 234 | g_wmi_mgmt_command_buf_idx = 0; \ |
| 235 | wmi_mgmt_command_log_buffer[g_wmi_mgmt_command_buf_idx].command = a; \ |
| 236 | wmi_mgmt_command_log_buffer[g_wmi_mgmt_command_buf_idx].data[0] = b; \ |
| 237 | wmi_mgmt_command_log_buffer[g_wmi_mgmt_command_buf_idx].data[1] = c; \ |
| 238 | wmi_mgmt_command_log_buffer[g_wmi_mgmt_command_buf_idx].data[2] = d; \ |
| 239 | wmi_mgmt_command_log_buffer[g_wmi_mgmt_command_buf_idx].data[3] = e; \ |
| 240 | wmi_mgmt_command_log_buffer[g_wmi_mgmt_command_buf_idx].time = \ |
| 241 | qdf_get_log_timestamp(); \ |
| 242 | g_wmi_mgmt_command_buf_idx++; \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 243 | } |
| 244 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 245 | #define WMI_MGMT_COMMAND_TX_CMP_RECORD(h, a, b) { \ |
| 246 | if (wmi_mgmt_log_max_entry <= \ |
| 247 | *(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \ |
| 248 | p_buf_tail_idx)) \ |
| 249 | *(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \ |
| 250 | p_buf_tail_idx) = 0; \ |
| 251 | ((struct wmi_command_debug *)h->log_info. \ |
| 252 | wmi_mgmt_command_tx_cmp_log_buf_info.buf) \ |
| 253 | [*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \ |
| 254 | p_buf_tail_idx)].command = a; \ |
| 255 | qdf_mem_copy(((struct wmi_command_debug *)h->log_info. \ |
| 256 | wmi_mgmt_command_tx_cmp_log_buf_info.buf)\ |
| 257 | [*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \ |
| 258 | p_buf_tail_idx)].data, b, \ |
| 259 | wmi_record_max_length); \ |
| 260 | ((struct wmi_command_debug *)h->log_info. \ |
| 261 | wmi_mgmt_command_tx_cmp_log_buf_info.buf) \ |
| 262 | [*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \ |
| 263 | p_buf_tail_idx)].time = \ |
| 264 | qdf_get_log_timestamp(); \ |
| 265 | (*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \ |
| 266 | p_buf_tail_idx))++; \ |
| 267 | h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info.length++; \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 268 | } |
| 269 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 270 | #define WMI_MGMT_EVENT_RECORD(h, a, b) { \ |
| 271 | if (wmi_mgmt_log_max_entry <= \ |
| 272 | *(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx))\ |
| 273 | *(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx) = 0;\ |
| 274 | ((struct wmi_event_debug *)h->log_info.wmi_mgmt_event_log_buf_info.buf)\ |
| 275 | [*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx)]\ |
| 276 | .event = a; \ |
| 277 | qdf_mem_copy(((struct wmi_event_debug *)h->log_info. \ |
| 278 | wmi_mgmt_event_log_buf_info.buf) \ |
| 279 | [*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx)].\ |
| 280 | data, b, wmi_record_max_length); \ |
| 281 | ((struct wmi_event_debug *)h->log_info.wmi_mgmt_event_log_buf_info.buf)\ |
| 282 | [*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx)].\ |
| 283 | time = qdf_get_log_timestamp(); \ |
| 284 | (*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx))++; \ |
| 285 | h->log_info.wmi_mgmt_event_log_buf_info.length++; \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 286 | } |
| 287 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 288 | /* These are defined to made it as module param, which can be configured */ |
| 289 | uint32_t wmi_log_max_entry = WMI_EVENT_DEBUG_MAX_ENTRY; |
| 290 | uint32_t wmi_mgmt_log_max_entry = WMI_MGMT_EVENT_DEBUG_MAX_ENTRY; |
| 291 | uint32_t wmi_record_max_length = WMI_EVENT_DEBUG_ENTRY_MAX_LENGTH; |
| 292 | uint32_t wmi_display_size = 100; |
| 293 | |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 294 | static uint8_t *wmi_id_to_name(uint32_t wmi_command); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 295 | |
| 296 | /** |
| 297 | * wmi_log_init() - Initialize WMI event logging |
| 298 | * @wmi_handle: WMI handle. |
| 299 | * |
| 300 | * Return: Initialization status |
| 301 | */ |
| 302 | #ifdef CONFIG_MCL |
| 303 | static QDF_STATUS wmi_log_init(struct wmi_unified *wmi_handle) |
| 304 | { |
| 305 | struct wmi_log_buf_t *cmd_log_buf = |
| 306 | &wmi_handle->log_info.wmi_command_log_buf_info; |
| 307 | struct wmi_log_buf_t *cmd_tx_cmpl_log_buf = |
| 308 | &wmi_handle->log_info.wmi_command_tx_cmp_log_buf_info; |
| 309 | |
| 310 | struct wmi_log_buf_t *event_log_buf = |
| 311 | &wmi_handle->log_info.wmi_event_log_buf_info; |
| 312 | struct wmi_log_buf_t *rx_event_log_buf = |
| 313 | &wmi_handle->log_info.wmi_rx_event_log_buf_info; |
| 314 | |
| 315 | struct wmi_log_buf_t *mgmt_cmd_log_buf = |
| 316 | &wmi_handle->log_info.wmi_mgmt_command_log_buf_info; |
| 317 | struct wmi_log_buf_t *mgmt_cmd_tx_cmp_log_buf = |
| 318 | &wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info; |
| 319 | struct wmi_log_buf_t *mgmt_event_log_buf = |
| 320 | &wmi_handle->log_info.wmi_mgmt_event_log_buf_info; |
| 321 | |
| 322 | /* WMI commands */ |
| 323 | cmd_log_buf->length = 0; |
| 324 | cmd_log_buf->buf_tail_idx = 0; |
| 325 | cmd_log_buf->buf = wmi_command_log_buffer; |
| 326 | cmd_log_buf->p_buf_tail_idx = &g_wmi_command_buf_idx; |
| 327 | |
| 328 | /* WMI commands TX completed */ |
| 329 | cmd_tx_cmpl_log_buf->length = 0; |
| 330 | cmd_tx_cmpl_log_buf->buf_tail_idx = 0; |
| 331 | cmd_tx_cmpl_log_buf->buf = wmi_command_tx_cmp_log_buffer; |
| 332 | cmd_tx_cmpl_log_buf->p_buf_tail_idx = &g_wmi_command_tx_cmp_buf_idx; |
| 333 | |
| 334 | /* WMI events when processed */ |
| 335 | event_log_buf->length = 0; |
| 336 | event_log_buf->buf_tail_idx = 0; |
| 337 | event_log_buf->buf = wmi_event_log_buffer; |
| 338 | event_log_buf->p_buf_tail_idx = &g_wmi_event_buf_idx; |
| 339 | |
| 340 | /* WMI events when queued */ |
| 341 | rx_event_log_buf->length = 0; |
| 342 | rx_event_log_buf->buf_tail_idx = 0; |
| 343 | rx_event_log_buf->buf = wmi_rx_event_log_buffer; |
| 344 | rx_event_log_buf->p_buf_tail_idx = &g_wmi_rx_event_buf_idx; |
| 345 | |
| 346 | /* WMI Management commands */ |
| 347 | mgmt_cmd_log_buf->length = 0; |
| 348 | mgmt_cmd_log_buf->buf_tail_idx = 0; |
| 349 | mgmt_cmd_log_buf->buf = wmi_mgmt_command_log_buffer; |
| 350 | mgmt_cmd_log_buf->p_buf_tail_idx = &g_wmi_mgmt_command_buf_idx; |
| 351 | |
| 352 | /* WMI Management commands Tx completed*/ |
| 353 | mgmt_cmd_tx_cmp_log_buf->length = 0; |
| 354 | mgmt_cmd_tx_cmp_log_buf->buf_tail_idx = 0; |
| 355 | mgmt_cmd_tx_cmp_log_buf->buf = wmi_mgmt_command_tx_cmp_log_buffer; |
| 356 | mgmt_cmd_tx_cmp_log_buf->p_buf_tail_idx = |
| 357 | &g_wmi_mgmt_command_tx_cmp_buf_idx; |
| 358 | |
| 359 | /* WMI Management events when processed*/ |
| 360 | mgmt_event_log_buf->length = 0; |
| 361 | mgmt_event_log_buf->buf_tail_idx = 0; |
| 362 | mgmt_event_log_buf->buf = wmi_mgmt_event_log_buffer; |
| 363 | mgmt_event_log_buf->p_buf_tail_idx = &g_wmi_mgmt_event_buf_idx; |
| 364 | |
| 365 | qdf_spinlock_create(&wmi_handle->log_info.wmi_record_lock); |
| 366 | wmi_handle->log_info.wmi_logging_enable = 1; |
| 367 | |
| 368 | return QDF_STATUS_SUCCESS; |
| 369 | } |
| 370 | #else |
| 371 | static QDF_STATUS wmi_log_init(struct wmi_unified *wmi_handle) |
| 372 | { |
| 373 | struct wmi_log_buf_t *cmd_log_buf = |
| 374 | &wmi_handle->log_info.wmi_command_log_buf_info; |
| 375 | struct wmi_log_buf_t *cmd_tx_cmpl_log_buf = |
| 376 | &wmi_handle->log_info.wmi_command_tx_cmp_log_buf_info; |
| 377 | |
| 378 | struct wmi_log_buf_t *event_log_buf = |
| 379 | &wmi_handle->log_info.wmi_event_log_buf_info; |
| 380 | struct wmi_log_buf_t *rx_event_log_buf = |
| 381 | &wmi_handle->log_info.wmi_rx_event_log_buf_info; |
| 382 | |
| 383 | struct wmi_log_buf_t *mgmt_cmd_log_buf = |
| 384 | &wmi_handle->log_info.wmi_mgmt_command_log_buf_info; |
| 385 | struct wmi_log_buf_t *mgmt_cmd_tx_cmp_log_buf = |
| 386 | &wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info; |
| 387 | struct wmi_log_buf_t *mgmt_event_log_buf = |
| 388 | &wmi_handle->log_info.wmi_mgmt_event_log_buf_info; |
| 389 | |
| 390 | wmi_handle->log_info.wmi_logging_enable = 0; |
| 391 | |
| 392 | /* WMI commands */ |
| 393 | cmd_log_buf->length = 0; |
| 394 | cmd_log_buf->buf_tail_idx = 0; |
| 395 | cmd_log_buf->buf = (struct wmi_command_debug *) qdf_mem_malloc( |
| 396 | wmi_log_max_entry * sizeof(struct wmi_command_debug)); |
| 397 | |
| 398 | if (!cmd_log_buf->buf) { |
| 399 | qdf_print("no memory for WMI command log buffer..\n"); |
| 400 | return QDF_STATUS_E_NOMEM; |
| 401 | } |
| 402 | cmd_log_buf->p_buf_tail_idx = &cmd_log_buf->buf_tail_idx; |
| 403 | |
| 404 | /* WMI commands TX completed */ |
| 405 | cmd_tx_cmpl_log_buf->length = 0; |
| 406 | cmd_tx_cmpl_log_buf->buf_tail_idx = 0; |
| 407 | cmd_tx_cmpl_log_buf->buf = (struct wmi_command_debug *) qdf_mem_malloc( |
| 408 | wmi_log_max_entry * sizeof(struct wmi_command_debug)); |
| 409 | |
| 410 | if (!cmd_tx_cmpl_log_buf->buf) { |
| 411 | qdf_print("no memory for WMI Command Tx Complete log buffer..\n"); |
| 412 | return QDF_STATUS_E_NOMEM; |
| 413 | } |
| 414 | cmd_tx_cmpl_log_buf->p_buf_tail_idx = |
| 415 | &cmd_tx_cmpl_log_buf->buf_tail_idx; |
| 416 | |
| 417 | /* WMI events when processed */ |
| 418 | event_log_buf->length = 0; |
| 419 | event_log_buf->buf_tail_idx = 0; |
| 420 | event_log_buf->buf = (struct wmi_event_debug *) qdf_mem_malloc( |
| 421 | wmi_log_max_entry * sizeof(struct wmi_event_debug)); |
| 422 | |
| 423 | if (!event_log_buf->buf) { |
| 424 | qdf_print("no memory for WMI Event log buffer..\n"); |
| 425 | return QDF_STATUS_E_NOMEM; |
| 426 | } |
| 427 | event_log_buf->p_buf_tail_idx = &event_log_buf->buf_tail_idx; |
| 428 | |
| 429 | /* WMI events when queued */ |
| 430 | rx_event_log_buf->length = 0; |
| 431 | rx_event_log_buf->buf_tail_idx = 0; |
| 432 | rx_event_log_buf->buf = (struct wmi_event_debug *) qdf_mem_malloc( |
| 433 | wmi_log_max_entry * sizeof(struct wmi_event_debug)); |
| 434 | |
| 435 | if (!rx_event_log_buf->buf) { |
| 436 | qdf_print("no memory for WMI Event Rx log buffer..\n"); |
| 437 | return QDF_STATUS_E_NOMEM; |
| 438 | } |
| 439 | rx_event_log_buf->p_buf_tail_idx = &rx_event_log_buf->buf_tail_idx; |
| 440 | |
| 441 | /* WMI Management commands */ |
| 442 | mgmt_cmd_log_buf->length = 0; |
| 443 | mgmt_cmd_log_buf->buf_tail_idx = 0; |
| 444 | mgmt_cmd_log_buf->buf = (struct wmi_command_debug *) qdf_mem_malloc( |
| 445 | wmi_mgmt_log_max_entry * |
| 446 | sizeof(struct wmi_command_debug)); |
| 447 | |
| 448 | if (!mgmt_cmd_log_buf->buf) { |
| 449 | qdf_print("no memory for WMI Management Command log buffer..\n"); |
| 450 | return QDF_STATUS_E_NOMEM; |
| 451 | } |
| 452 | mgmt_cmd_log_buf->p_buf_tail_idx = &mgmt_cmd_log_buf->buf_tail_idx; |
| 453 | |
| 454 | /* WMI Management commands Tx completed*/ |
| 455 | mgmt_cmd_tx_cmp_log_buf->length = 0; |
| 456 | mgmt_cmd_tx_cmp_log_buf->buf_tail_idx = 0; |
| 457 | mgmt_cmd_tx_cmp_log_buf->buf = (struct wmi_command_debug *) |
| 458 | qdf_mem_malloc( |
| 459 | wmi_mgmt_log_max_entry * |
| 460 | sizeof(struct wmi_command_debug)); |
| 461 | |
| 462 | if (!mgmt_cmd_tx_cmp_log_buf->buf) { |
| 463 | qdf_print("no memory for WMI Management Command Tx complete log buffer..\n"); |
| 464 | return QDF_STATUS_E_NOMEM; |
| 465 | } |
| 466 | mgmt_cmd_tx_cmp_log_buf->p_buf_tail_idx = |
| 467 | &mgmt_cmd_tx_cmp_log_buf->buf_tail_idx; |
| 468 | |
| 469 | /* WMI Management events when processed*/ |
| 470 | mgmt_event_log_buf->length = 0; |
| 471 | mgmt_event_log_buf->buf_tail_idx = 0; |
| 472 | |
| 473 | mgmt_event_log_buf->buf = (struct wmi_event_debug *) qdf_mem_malloc( |
| 474 | wmi_mgmt_log_max_entry * |
| 475 | sizeof(struct wmi_event_debug)); |
| 476 | |
| 477 | if (!mgmt_event_log_buf->buf) { |
| 478 | qdf_print("no memory for WMI Management Event log buffer..\n"); |
| 479 | return QDF_STATUS_E_NOMEM; |
| 480 | } |
| 481 | mgmt_event_log_buf->p_buf_tail_idx = &mgmt_event_log_buf->buf_tail_idx; |
| 482 | |
| 483 | qdf_spinlock_create(&wmi_handle->log_info.wmi_record_lock); |
| 484 | wmi_handle->log_info.wmi_logging_enable = 1; |
| 485 | |
| 486 | return QDF_STATUS_SUCCESS; |
| 487 | } |
| 488 | #endif |
| 489 | |
| 490 | /** |
| 491 | * wmi_log_buffer_free() - Free all dynamic allocated buffer memory for |
| 492 | * event logging |
| 493 | * @wmi_handle: WMI handle. |
| 494 | * |
| 495 | * Return: None |
| 496 | */ |
| 497 | #ifndef CONFIG_MCL |
| 498 | static inline void wmi_log_buffer_free(struct wmi_unified *wmi_handle) |
| 499 | { |
| 500 | if (wmi_handle->log_info.wmi_command_log_buf_info.buf) |
| 501 | qdf_mem_free(wmi_handle->log_info.wmi_command_log_buf_info.buf); |
| 502 | if (wmi_handle->log_info.wmi_command_tx_cmp_log_buf_info.buf) |
| 503 | qdf_mem_free( |
| 504 | wmi_handle->log_info.wmi_command_tx_cmp_log_buf_info.buf); |
| 505 | if (wmi_handle->log_info.wmi_event_log_buf_info.buf) |
| 506 | qdf_mem_free(wmi_handle->log_info.wmi_event_log_buf_info.buf); |
| 507 | if (wmi_handle->log_info.wmi_rx_event_log_buf_info.buf) |
| 508 | qdf_mem_free( |
| 509 | wmi_handle->log_info.wmi_rx_event_log_buf_info.buf); |
| 510 | if (wmi_handle->log_info.wmi_mgmt_command_log_buf_info.buf) |
| 511 | qdf_mem_free( |
| 512 | wmi_handle->log_info.wmi_mgmt_command_log_buf_info.buf); |
| 513 | if (wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info.buf) |
| 514 | qdf_mem_free( |
| 515 | wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info.buf); |
| 516 | if (wmi_handle->log_info.wmi_mgmt_event_log_buf_info.buf) |
| 517 | qdf_mem_free( |
| 518 | wmi_handle->log_info.wmi_mgmt_event_log_buf_info.buf); |
| 519 | wmi_handle->log_info.wmi_logging_enable = 0; |
| 520 | qdf_spinlock_destroy(&wmi_handle->log_info.wmi_record_lock); |
| 521 | } |
| 522 | #else |
| 523 | static inline void wmi_log_buffer_free(struct wmi_unified *wmi_handle) |
| 524 | { |
| 525 | /* Do Nothing */ |
| 526 | } |
| 527 | #endif |
| 528 | |
| 529 | #ifdef CONFIG_MCL |
| 530 | const int8_t * const debugfs_dir[] = {"WMI0", "WMI1", "WMI2"}; |
| 531 | #else |
| 532 | const int8_t * const debugfs_dir[] = {"WMI0"}; |
| 533 | #endif |
| 534 | |
| 535 | /* debugfs routines*/ |
| 536 | |
| 537 | /** |
| 538 | * debug_wmi_##func_base##_show() - debugfs functions to display content of |
| 539 | * command and event buffers. Macro uses max buffer length to display |
| 540 | * buffer when it is wraparound. |
| 541 | * |
| 542 | * @m: debugfs handler to access wmi_handle |
| 543 | * @v: Variable arguments (not used) |
| 544 | * |
| 545 | * Return: Length of characters printed |
| 546 | */ |
| 547 | #define GENERATE_COMMAND_DEBUG_SHOW_FUNCS(func_base, wmi_ring_size) \ |
| 548 | static int debug_wmi_##func_base##_show(struct seq_file *m, \ |
| 549 | void *v) \ |
| 550 | { \ |
| 551 | wmi_unified_t wmi_handle = (wmi_unified_t) m->private; \ |
| 552 | struct wmi_log_buf_t *wmi_log = \ |
| 553 | &wmi_handle->log_info.wmi_##func_base##_buf_info;\ |
| 554 | int pos, nread, outlen; \ |
| 555 | int i; \ |
| 556 | \ |
| 557 | if (!wmi_log->length) \ |
| 558 | return seq_printf(m, \ |
| 559 | "no elements to read from ring buffer!\n"); \ |
| 560 | \ |
| 561 | if (wmi_log->length <= wmi_ring_size) \ |
| 562 | nread = wmi_log->length; \ |
| 563 | else \ |
| 564 | nread = wmi_ring_size; \ |
| 565 | \ |
| 566 | if (*(wmi_log->p_buf_tail_idx) == 0) \ |
| 567 | /* tail can be 0 after wrap-around */ \ |
| 568 | pos = wmi_ring_size - 1; \ |
| 569 | else \ |
| 570 | pos = *(wmi_log->p_buf_tail_idx) - 1; \ |
| 571 | \ |
| 572 | outlen = 0; \ |
| 573 | qdf_spin_lock(&wmi_handle->log_info.wmi_record_lock); \ |
| 574 | while (nread--) { \ |
| 575 | struct wmi_command_debug *wmi_record; \ |
| 576 | \ |
| 577 | wmi_record = (struct wmi_command_debug *) \ |
| 578 | &(((struct wmi_command_debug *)wmi_log->buf)[pos]);\ |
| 579 | outlen += seq_printf(m, "CMD ID = %x\n", \ |
| 580 | (wmi_record->command)); \ |
| 581 | outlen += seq_printf(m, "CMD = "); \ |
| 582 | for (i = 0; i < (wmi_record_max_length/ \ |
| 583 | sizeof(uint32_t)); i++) \ |
| 584 | outlen += seq_printf(m, "%x ", \ |
| 585 | wmi_record->data[i]); \ |
| 586 | outlen += seq_printf(m, "\n"); \ |
| 587 | \ |
| 588 | if (pos == 0) \ |
| 589 | pos = wmi_ring_size - 1; \ |
| 590 | else \ |
| 591 | pos--; \ |
| 592 | } \ |
| 593 | outlen += seq_printf(m, "Length = %d\n", wmi_log->length);\ |
| 594 | qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock); \ |
| 595 | \ |
| 596 | return outlen; \ |
| 597 | } \ |
| 598 | |
| 599 | #define GENERATE_EVENT_DEBUG_SHOW_FUNCS(func_base, wmi_ring_size) \ |
| 600 | static int debug_wmi_##func_base##_show(struct seq_file *m, \ |
| 601 | void *v) \ |
| 602 | { \ |
| 603 | wmi_unified_t wmi_handle = (wmi_unified_t) m->private; \ |
| 604 | struct wmi_log_buf_t *wmi_log = \ |
| 605 | &wmi_handle->log_info.wmi_##func_base##_buf_info;\ |
| 606 | int pos, nread, outlen; \ |
| 607 | int i; \ |
| 608 | \ |
| 609 | if (!wmi_log->length) \ |
| 610 | return seq_printf(m, \ |
| 611 | "no elements to read from ring buffer!\n"); \ |
| 612 | \ |
| 613 | if (wmi_log->length <= wmi_ring_size) \ |
| 614 | nread = wmi_log->length; \ |
| 615 | else \ |
| 616 | nread = wmi_ring_size; \ |
| 617 | \ |
| 618 | if (*(wmi_log->p_buf_tail_idx) == 0) \ |
| 619 | /* tail can be 0 after wrap-around */ \ |
| 620 | pos = wmi_ring_size - 1; \ |
| 621 | else \ |
| 622 | pos = *(wmi_log->p_buf_tail_idx) - 1; \ |
| 623 | \ |
| 624 | outlen = 0; \ |
| 625 | qdf_spin_lock(&wmi_handle->log_info.wmi_record_lock); \ |
| 626 | while (nread--) { \ |
| 627 | struct wmi_event_debug *wmi_record; \ |
| 628 | \ |
| 629 | wmi_record = (struct wmi_event_debug *) \ |
| 630 | &(((struct wmi_event_debug *)wmi_log->buf)[pos]);\ |
| 631 | outlen += seq_printf(m, "Event ID = %x\n", \ |
| 632 | (wmi_record->event)); \ |
| 633 | outlen += seq_printf(m, "CMD = "); \ |
| 634 | for (i = 0; i < (wmi_record_max_length/ \ |
| 635 | sizeof(uint32_t)); i++) \ |
| 636 | outlen += seq_printf(m, "%x ", \ |
| 637 | wmi_record->data[i]); \ |
| 638 | outlen += seq_printf(m, "\n"); \ |
| 639 | \ |
| 640 | if (pos == 0) \ |
| 641 | pos = wmi_ring_size - 1; \ |
| 642 | else \ |
| 643 | pos--; \ |
| 644 | } \ |
| 645 | outlen += seq_printf(m, "Length = %d\n", wmi_log->length);\ |
| 646 | qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock); \ |
| 647 | \ |
| 648 | return outlen; \ |
| 649 | } |
| 650 | |
| 651 | GENERATE_COMMAND_DEBUG_SHOW_FUNCS(command_log, wmi_display_size); |
| 652 | GENERATE_COMMAND_DEBUG_SHOW_FUNCS(command_tx_cmp_log, wmi_display_size); |
| 653 | GENERATE_EVENT_DEBUG_SHOW_FUNCS(event_log, wmi_display_size); |
| 654 | GENERATE_EVENT_DEBUG_SHOW_FUNCS(rx_event_log, wmi_display_size); |
| 655 | GENERATE_COMMAND_DEBUG_SHOW_FUNCS(mgmt_command_log, wmi_display_size); |
| 656 | GENERATE_COMMAND_DEBUG_SHOW_FUNCS(mgmt_command_tx_cmp_log, |
| 657 | wmi_display_size); |
| 658 | GENERATE_EVENT_DEBUG_SHOW_FUNCS(mgmt_event_log, wmi_display_size); |
| 659 | |
| 660 | /** |
| 661 | * debug_wmi_enable_show() - debugfs functions to display enable state of |
| 662 | * wmi logging feature. |
| 663 | * |
| 664 | * @m: debugfs handler to access wmi_handle |
| 665 | * @v: Variable arguments (not used) |
| 666 | * |
| 667 | * Return: always 1 |
| 668 | */ |
| 669 | static int debug_wmi_enable_show(struct seq_file *m, void *v) |
| 670 | { |
| 671 | wmi_unified_t wmi_handle = (wmi_unified_t) m->private; |
| 672 | |
| 673 | return seq_printf(m, "%d\n", wmi_handle->log_info.wmi_logging_enable); |
| 674 | |
| 675 | } |
| 676 | |
| 677 | /** |
| 678 | * debug_wmi_log_size_show() - debugfs functions to display configured size of |
| 679 | * wmi logging command/event buffer and management command/event buffer. |
| 680 | * |
| 681 | * @m: debugfs handler to access wmi_handle |
| 682 | * @v: Variable arguments (not used) |
| 683 | * |
| 684 | * Return: Length of characters printed |
| 685 | */ |
| 686 | static int debug_wmi_log_size_show(struct seq_file *m, void *v) |
| 687 | { |
| 688 | |
| 689 | seq_printf(m, "WMI command/event log max size:%d\n", wmi_log_max_entry); |
| 690 | return seq_printf(m, "WMI management command/events log max size:%d\n", |
| 691 | wmi_mgmt_log_max_entry); |
| 692 | } |
| 693 | |
| 694 | /** |
| 695 | * debug_wmi_##func_base##_write() - debugfs functions to clear |
| 696 | * wmi logging command/event buffer and management command/event buffer. |
| 697 | * |
| 698 | * @file: file handler to access wmi_handle |
| 699 | * @buf: received data buffer |
| 700 | * @count: length of received buffer |
| 701 | * @ppos: Not used |
| 702 | * |
| 703 | * Return: count |
| 704 | */ |
| 705 | #define GENERATE_DEBUG_WRITE_FUNCS(func_base, wmi_ring_size, wmi_record_type)\ |
| 706 | static ssize_t debug_wmi_##func_base##_write(struct file *file, \ |
| 707 | const char __user *buf, \ |
| 708 | size_t count, loff_t *ppos) \ |
| 709 | { \ |
| 710 | int k, ret; \ |
| 711 | wmi_unified_t wmi_handle = file->private_data; \ |
| 712 | struct wmi_log_buf_t *wmi_log = &wmi_handle->log_info. \ |
| 713 | wmi_##func_base##_buf_info; \ |
| 714 | \ |
| 715 | ret = sscanf(buf, "%d", &k); \ |
| 716 | if ((ret != 1) || (k != 0)) { \ |
| 717 | qdf_print("Wrong input, echo 0 to clear the wmi buffer\n");\ |
| 718 | return -EINVAL; \ |
| 719 | } \ |
| 720 | \ |
| 721 | qdf_spin_lock(&wmi_handle->log_info.wmi_record_lock); \ |
| 722 | qdf_mem_zero(wmi_log->buf, wmi_ring_size * \ |
| 723 | sizeof(struct wmi_record_type)); \ |
| 724 | wmi_log->length = 0; \ |
| 725 | *(wmi_log->p_buf_tail_idx) = 0; \ |
| 726 | qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock); \ |
| 727 | \ |
| 728 | return count; \ |
| 729 | } |
| 730 | |
| 731 | GENERATE_DEBUG_WRITE_FUNCS(command_log, wmi_log_max_entry, |
| 732 | wmi_command_debug); |
| 733 | GENERATE_DEBUG_WRITE_FUNCS(command_tx_cmp_log, wmi_log_max_entry, |
| 734 | wmi_command_debug); |
| 735 | GENERATE_DEBUG_WRITE_FUNCS(event_log, wmi_log_max_entry, |
| 736 | wmi_event_debug); |
| 737 | GENERATE_DEBUG_WRITE_FUNCS(rx_event_log, wmi_log_max_entry, |
| 738 | wmi_event_debug); |
| 739 | GENERATE_DEBUG_WRITE_FUNCS(mgmt_command_log, wmi_mgmt_log_max_entry, |
| 740 | wmi_command_debug); |
| 741 | GENERATE_DEBUG_WRITE_FUNCS(mgmt_command_tx_cmp_log, |
| 742 | wmi_mgmt_log_max_entry, wmi_command_debug); |
| 743 | GENERATE_DEBUG_WRITE_FUNCS(mgmt_event_log, wmi_mgmt_log_max_entry, |
| 744 | wmi_event_debug); |
| 745 | |
| 746 | /** |
| 747 | * debug_wmi_enable_write() - debugfs functions to enable/disable |
| 748 | * wmi logging feature. |
| 749 | * |
| 750 | * @file: file handler to access wmi_handle |
| 751 | * @buf: received data buffer |
| 752 | * @count: length of received buffer |
| 753 | * @ppos: Not used |
| 754 | * |
| 755 | * Return: count |
| 756 | */ |
| 757 | static ssize_t debug_wmi_enable_write(struct file *file, const char __user *buf, |
| 758 | size_t count, loff_t *ppos) |
| 759 | { |
| 760 | wmi_unified_t wmi_handle = file->private_data; |
| 761 | int k, ret; |
| 762 | |
| 763 | ret = sscanf(buf, "%d", &k); |
| 764 | if ((ret != 1) || ((k != 0) && (k != 1))) |
| 765 | return -EINVAL; |
| 766 | |
| 767 | wmi_handle->log_info.wmi_logging_enable = k; |
| 768 | return count; |
| 769 | } |
| 770 | |
| 771 | /** |
| 772 | * debug_wmi_log_size_write() - reserved. |
| 773 | * |
| 774 | * @file: file handler to access wmi_handle |
| 775 | * @buf: received data buffer |
| 776 | * @count: length of received buffer |
| 777 | * @ppos: Not used |
| 778 | * |
| 779 | * Return: count |
| 780 | */ |
| 781 | static ssize_t debug_wmi_log_size_write(struct file *file, |
| 782 | const char __user *buf, size_t count, loff_t *ppos) |
| 783 | { |
| 784 | return -EINVAL; |
| 785 | } |
| 786 | |
| 787 | /* Structure to maintain debug information */ |
| 788 | struct wmi_debugfs_info { |
| 789 | const char *name; |
| 790 | struct dentry *de[MAX_WMI_INSTANCES]; |
| 791 | const struct file_operations *ops; |
| 792 | }; |
| 793 | |
| 794 | #define DEBUG_FOO(func_base) { .name = #func_base, \ |
| 795 | .ops = &debug_##func_base##_ops } |
| 796 | |
| 797 | /** |
| 798 | * debug_##func_base##_open() - Open debugfs entry for respective command |
| 799 | * and event buffer. |
| 800 | * |
| 801 | * @inode: node for debug dir entry |
| 802 | * @file: file handler |
| 803 | * |
| 804 | * Return: open status |
| 805 | */ |
| 806 | #define GENERATE_DEBUG_STRUCTS(func_base) \ |
| 807 | static int debug_##func_base##_open(struct inode *inode, \ |
| 808 | struct file *file) \ |
| 809 | { \ |
| 810 | return single_open(file, debug_##func_base##_show, \ |
| 811 | inode->i_private); \ |
| 812 | } \ |
| 813 | \ |
| 814 | \ |
| 815 | static struct file_operations debug_##func_base##_ops = { \ |
| 816 | .open = debug_##func_base##_open, \ |
| 817 | .read = seq_read, \ |
| 818 | .llseek = seq_lseek, \ |
| 819 | .write = debug_##func_base##_write, \ |
| 820 | .release = single_release, \ |
| 821 | }; |
| 822 | |
| 823 | GENERATE_DEBUG_STRUCTS(wmi_command_log); |
| 824 | GENERATE_DEBUG_STRUCTS(wmi_command_tx_cmp_log); |
| 825 | GENERATE_DEBUG_STRUCTS(wmi_event_log); |
| 826 | GENERATE_DEBUG_STRUCTS(wmi_rx_event_log); |
| 827 | GENERATE_DEBUG_STRUCTS(wmi_mgmt_command_log); |
| 828 | GENERATE_DEBUG_STRUCTS(wmi_mgmt_command_tx_cmp_log); |
| 829 | GENERATE_DEBUG_STRUCTS(wmi_mgmt_event_log); |
| 830 | GENERATE_DEBUG_STRUCTS(wmi_enable); |
| 831 | GENERATE_DEBUG_STRUCTS(wmi_log_size); |
| 832 | |
| 833 | struct wmi_debugfs_info wmi_debugfs_infos[] = { |
| 834 | DEBUG_FOO(wmi_command_log), |
| 835 | DEBUG_FOO(wmi_command_tx_cmp_log), |
| 836 | DEBUG_FOO(wmi_event_log), |
| 837 | DEBUG_FOO(wmi_rx_event_log), |
| 838 | DEBUG_FOO(wmi_mgmt_command_log), |
| 839 | DEBUG_FOO(wmi_mgmt_command_tx_cmp_log), |
| 840 | DEBUG_FOO(wmi_mgmt_event_log), |
| 841 | DEBUG_FOO(wmi_enable), |
| 842 | DEBUG_FOO(wmi_log_size), |
| 843 | }; |
| 844 | |
| 845 | #define NUM_DEBUG_INFOS (sizeof(wmi_debugfs_infos) / \ |
| 846 | sizeof(wmi_debugfs_infos[0])) |
| 847 | |
| 848 | /** |
| 849 | * wmi_debugfs_create() - Create debug_fs entry for wmi logging. |
| 850 | * |
| 851 | * @wmi_handle: wmi handle |
| 852 | * @par_entry: debug directory entry |
| 853 | * @id: Index to debug info data array |
| 854 | * |
| 855 | * Return: none |
| 856 | */ |
| 857 | static void wmi_debugfs_create(wmi_unified_t wmi_handle, |
| 858 | struct dentry *par_entry, int id) |
| 859 | { |
| 860 | int i; |
| 861 | |
| 862 | if (par_entry == NULL || (id < 0) || (id >= MAX_WMI_INSTANCES)) |
| 863 | goto out; |
| 864 | |
| 865 | for (i = 0; i < NUM_DEBUG_INFOS; ++i) { |
| 866 | |
| 867 | wmi_debugfs_infos[i].de[id] = debugfs_create_file( |
| 868 | wmi_debugfs_infos[i].name, 0644, par_entry, |
| 869 | wmi_handle, wmi_debugfs_infos[i].ops); |
| 870 | |
| 871 | if (wmi_debugfs_infos[i].de[id] == NULL) { |
| 872 | qdf_print("%s: debug Entry creation failed!\n", |
| 873 | __func__); |
| 874 | goto out; |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | return; |
| 879 | |
| 880 | out: |
| 881 | qdf_print("%s: debug Entry creation failed!\n", __func__); |
| 882 | wmi_log_buffer_free(wmi_handle); |
| 883 | return; |
| 884 | } |
| 885 | |
| 886 | /** |
| 887 | * wmi_debugfs_remove() - Remove debugfs entry for wmi logging. |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 888 | * @wmi_handle: wmi handle |
| 889 | * @dentry: debugfs directory entry |
| 890 | * @id: Index to debug info data array |
| 891 | * |
| 892 | * Return: none |
| 893 | */ |
Govind Singh | 06c1839 | 2016-06-10 10:33:19 +0530 | [diff] [blame] | 894 | static void wmi_debugfs_remove(wmi_unified_t wmi_handle) |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 895 | { |
| 896 | int i; |
Govind Singh | 06c1839 | 2016-06-10 10:33:19 +0530 | [diff] [blame] | 897 | struct dentry *dentry = wmi_handle->log_info.wmi_log_debugfs_dir; |
| 898 | int id = wmi_handle->log_info.wmi_instance_id; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 899 | |
| 900 | if (dentry && (!(id < 0) || (id >= MAX_WMI_INSTANCES))) { |
| 901 | for (i = 0; i < NUM_DEBUG_INFOS; ++i) { |
| 902 | if (wmi_debugfs_infos[i].de[id]) |
| 903 | wmi_debugfs_infos[i].de[id] = NULL; |
| 904 | } |
| 905 | } |
| 906 | |
| 907 | if (dentry) |
| 908 | debugfs_remove_recursive(dentry); |
| 909 | } |
| 910 | |
| 911 | /** |
| 912 | * wmi_debugfs_init() - debugfs functions to create debugfs directory and to |
| 913 | * create debugfs enteries. |
| 914 | * |
| 915 | * @h: wmi handler |
| 916 | * |
| 917 | * Return: init status |
| 918 | */ |
| 919 | static QDF_STATUS wmi_debugfs_init(wmi_unified_t wmi_handle) |
| 920 | { |
| 921 | static int wmi_index; |
| 922 | |
| 923 | if (wmi_index < MAX_WMI_INSTANCES) |
| 924 | wmi_handle->log_info.wmi_log_debugfs_dir = |
| 925 | debugfs_create_dir(debugfs_dir[wmi_index], NULL); |
| 926 | |
| 927 | if (wmi_handle->log_info.wmi_log_debugfs_dir == NULL) { |
| 928 | qdf_print("error while creating debugfs dir for %s\n", |
| 929 | debugfs_dir[wmi_index]); |
| 930 | return QDF_STATUS_E_FAILURE; |
| 931 | } |
| 932 | |
| 933 | wmi_debugfs_create(wmi_handle, wmi_handle->log_info.wmi_log_debugfs_dir, |
| 934 | wmi_index); |
| 935 | wmi_handle->log_info.wmi_instance_id = wmi_index++; |
| 936 | |
| 937 | return QDF_STATUS_SUCCESS; |
| 938 | } |
Sandeep Puligilla | b74958d | 2016-06-13 15:42:55 -0700 | [diff] [blame] | 939 | |
| 940 | /** |
| 941 | * wmi_mgmt_cmd_record() - Wrapper function for mgmt command logging macro |
| 942 | * |
| 943 | * @wmi_handle: wmi handle |
| 944 | * @cmd: mgmt command |
Sandeep Puligilla | 828a45f | 2016-07-19 13:20:57 -0700 | [diff] [blame] | 945 | * @header: pointer to 802.11 header |
Sandeep Puligilla | b74958d | 2016-06-13 15:42:55 -0700 | [diff] [blame] | 946 | * @vdev_id: vdev id |
| 947 | * @chanfreq: channel frequency |
| 948 | * |
| 949 | * Return: none |
| 950 | */ |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 951 | void wmi_mgmt_cmd_record(wmi_unified_t wmi_handle, uint32_t cmd, |
Sandeep Puligilla | 828a45f | 2016-07-19 13:20:57 -0700 | [diff] [blame] | 952 | void *header, uint32_t vdev_id, uint32_t chanfreq) |
Sandeep Puligilla | b74958d | 2016-06-13 15:42:55 -0700 | [diff] [blame] | 953 | { |
| 954 | qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock); |
| 955 | |
Sandeep Puligilla | 828a45f | 2016-07-19 13:20:57 -0700 | [diff] [blame] | 956 | WMI_MGMT_COMMAND_RECORD(cmd, |
| 957 | ((struct wmi_command_header *)header)->type, |
| 958 | ((struct wmi_command_header *)header)->sub_type, |
| 959 | vdev_id, chanfreq); |
Sandeep Puligilla | b74958d | 2016-06-13 15:42:55 -0700 | [diff] [blame] | 960 | |
| 961 | qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock); |
| 962 | } |
Rajeev Kumar | ae91c40 | 2016-05-25 16:07:23 -0700 | [diff] [blame] | 963 | #else |
| 964 | /** |
| 965 | * wmi_debugfs_remove() - Remove debugfs entry for wmi logging. |
| 966 | * @wmi_handle: wmi handle |
| 967 | * @dentry: debugfs directory entry |
| 968 | * @id: Index to debug info data array |
| 969 | * |
| 970 | * Return: none |
| 971 | */ |
Govind Singh | 06c1839 | 2016-06-10 10:33:19 +0530 | [diff] [blame] | 972 | static void wmi_debugfs_remove(wmi_unified_t wmi_handle) { } |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 973 | void wmi_mgmt_cmd_record(wmi_unified_t wmi_handle, uint32_t cmd, |
Sandeep Puligilla | 828a45f | 2016-07-19 13:20:57 -0700 | [diff] [blame] | 974 | void *header, uint32_t vdev_id, uint32_t chanfreq) { } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 975 | #endif /*WMI_INTERFACE_EVENT_LOGGING */ |
| 976 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 977 | int wmi_get_host_credits(wmi_unified_t wmi_handle); |
| 978 | /* WMI buffer APIs */ |
| 979 | |
| 980 | #ifdef MEMORY_DEBUG |
| 981 | wmi_buf_t |
| 982 | wmi_buf_alloc_debug(wmi_unified_t wmi_handle, uint16_t len, uint8_t *file_name, |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 983 | uint32_t line_num) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 984 | { |
| 985 | wmi_buf_t wmi_buf; |
| 986 | |
| 987 | if (roundup(len + WMI_MIN_HEAD_ROOM, 4) > wmi_handle->max_msg_len) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 988 | QDF_ASSERT(0); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 989 | return NULL; |
| 990 | } |
| 991 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 992 | wmi_buf = qdf_nbuf_alloc_debug(NULL, |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 993 | roundup(len + WMI_MIN_HEAD_ROOM, 4), |
| 994 | WMI_MIN_HEAD_ROOM, 4, false, file_name, |
| 995 | line_num); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 996 | |
| 997 | if (!wmi_buf) |
| 998 | return NULL; |
| 999 | |
| 1000 | /* Clear the wmi buffer */ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1001 | OS_MEMZERO(qdf_nbuf_data(wmi_buf), len); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1002 | |
| 1003 | /* |
| 1004 | * Set the length of the buffer to match the allocation size. |
| 1005 | */ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1006 | qdf_nbuf_set_pktlen(wmi_buf, len); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1007 | |
| 1008 | return wmi_buf; |
| 1009 | } |
| 1010 | |
| 1011 | void wmi_buf_free(wmi_buf_t net_buf) |
| 1012 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1013 | qdf_nbuf_free(net_buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1014 | } |
| 1015 | #else |
| 1016 | wmi_buf_t wmi_buf_alloc(wmi_unified_t wmi_handle, uint16_t len) |
| 1017 | { |
| 1018 | wmi_buf_t wmi_buf; |
| 1019 | |
| 1020 | if (roundup(len + WMI_MIN_HEAD_ROOM, 4) > wmi_handle->max_msg_len) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1021 | QDF_ASSERT(0); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1022 | return NULL; |
| 1023 | } |
| 1024 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1025 | wmi_buf = qdf_nbuf_alloc(NULL, roundup(len + WMI_MIN_HEAD_ROOM, 4), |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1026 | WMI_MIN_HEAD_ROOM, 4, false); |
| 1027 | if (!wmi_buf) |
| 1028 | return NULL; |
| 1029 | |
| 1030 | /* Clear the wmi buffer */ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1031 | OS_MEMZERO(qdf_nbuf_data(wmi_buf), len); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1032 | |
| 1033 | /* |
| 1034 | * Set the length of the buffer to match the allocation size. |
| 1035 | */ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1036 | qdf_nbuf_set_pktlen(wmi_buf, len); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1037 | return wmi_buf; |
| 1038 | } |
| 1039 | |
| 1040 | void wmi_buf_free(wmi_buf_t net_buf) |
| 1041 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1042 | qdf_nbuf_free(net_buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1043 | } |
| 1044 | #endif |
| 1045 | |
| 1046 | /** |
| 1047 | * wmi_get_max_msg_len() - get maximum WMI message length |
| 1048 | * @wmi_handle: WMI handle. |
| 1049 | * |
| 1050 | * This function returns the maximum WMI message length |
| 1051 | * |
| 1052 | * Return: maximum WMI message length |
| 1053 | */ |
| 1054 | uint16_t wmi_get_max_msg_len(wmi_unified_t wmi_handle) |
| 1055 | { |
| 1056 | return wmi_handle->max_msg_len - WMI_MIN_HEAD_ROOM; |
| 1057 | } |
| 1058 | |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 1059 | #ifdef CONFIG_MCL |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 1060 | static uint8_t *wmi_id_to_name(uint32_t wmi_command) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1061 | { |
| 1062 | switch (wmi_command) { |
| 1063 | /* initialize the wlan sub system */ |
| 1064 | CASE_RETURN_STRING(WMI_INIT_CMDID); |
| 1065 | |
| 1066 | /* Scan specific commands */ |
| 1067 | |
| 1068 | /* start scan request to FW */ |
| 1069 | CASE_RETURN_STRING(WMI_START_SCAN_CMDID); |
| 1070 | /* stop scan request to FW */ |
| 1071 | CASE_RETURN_STRING(WMI_STOP_SCAN_CMDID); |
| 1072 | /* full list of channels as defined by the regulatory |
| 1073 | * that will be used by scanner */ |
| 1074 | CASE_RETURN_STRING(WMI_SCAN_CHAN_LIST_CMDID); |
| 1075 | /* overwrite default priority table in scan scheduler */ |
| 1076 | CASE_RETURN_STRING(WMI_SCAN_SCH_PRIO_TBL_CMDID); |
| 1077 | /* This command to adjust the priority and min.max_rest_time |
| 1078 | * of an on ongoing scan request. |
| 1079 | */ |
| 1080 | CASE_RETURN_STRING(WMI_SCAN_UPDATE_REQUEST_CMDID); |
| 1081 | |
| 1082 | /* PDEV(physical device) specific commands */ |
| 1083 | /* set regulatorty ctl id used by FW to determine the exact |
| 1084 | * ctl power limits */ |
| 1085 | CASE_RETURN_STRING(WMI_PDEV_SET_REGDOMAIN_CMDID); |
| 1086 | /* set channel. mainly used for supporting monitor mode */ |
| 1087 | CASE_RETURN_STRING(WMI_PDEV_SET_CHANNEL_CMDID); |
| 1088 | /* set pdev specific parameters */ |
| 1089 | CASE_RETURN_STRING(WMI_PDEV_SET_PARAM_CMDID); |
| 1090 | /* enable packet log */ |
| 1091 | CASE_RETURN_STRING(WMI_PDEV_PKTLOG_ENABLE_CMDID); |
| 1092 | /* disable packet log*/ |
| 1093 | CASE_RETURN_STRING(WMI_PDEV_PKTLOG_DISABLE_CMDID); |
| 1094 | /* set wmm parameters */ |
| 1095 | CASE_RETURN_STRING(WMI_PDEV_SET_WMM_PARAMS_CMDID); |
| 1096 | /* set HT cap ie that needs to be carried probe requests |
| 1097 | * HT/VHT channels */ |
| 1098 | CASE_RETURN_STRING(WMI_PDEV_SET_HT_CAP_IE_CMDID); |
| 1099 | /* set VHT cap ie that needs to be carried on probe |
| 1100 | * requests on VHT channels */ |
| 1101 | CASE_RETURN_STRING(WMI_PDEV_SET_VHT_CAP_IE_CMDID); |
| 1102 | |
| 1103 | /* Command to send the DSCP-to-TID map to the target */ |
| 1104 | CASE_RETURN_STRING(WMI_PDEV_SET_DSCP_TID_MAP_CMDID); |
| 1105 | /* set quiet ie parameters. primarily used in AP mode */ |
| 1106 | CASE_RETURN_STRING(WMI_PDEV_SET_QUIET_MODE_CMDID); |
| 1107 | /* Enable/Disable Green AP Power Save */ |
| 1108 | CASE_RETURN_STRING(WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID); |
| 1109 | /* get TPC config for the current operating channel */ |
| 1110 | CASE_RETURN_STRING(WMI_PDEV_GET_TPC_CONFIG_CMDID); |
| 1111 | |
| 1112 | /* set the base MAC address for the physical device before |
| 1113 | * a VDEV is created. For firmware that does not support |
| 1114 | * this feature and this command, the pdev MAC address will |
| 1115 | * not be changed. */ |
| 1116 | CASE_RETURN_STRING(WMI_PDEV_SET_BASE_MACADDR_CMDID); |
| 1117 | |
| 1118 | /* eeprom content dump , the same to bdboard data */ |
| 1119 | CASE_RETURN_STRING(WMI_PDEV_DUMP_CMDID); |
| 1120 | |
| 1121 | /* VDEV(virtual device) specific commands */ |
| 1122 | /* vdev create */ |
| 1123 | CASE_RETURN_STRING(WMI_VDEV_CREATE_CMDID); |
| 1124 | /* vdev delete */ |
| 1125 | CASE_RETURN_STRING(WMI_VDEV_DELETE_CMDID); |
| 1126 | /* vdev start request */ |
| 1127 | CASE_RETURN_STRING(WMI_VDEV_START_REQUEST_CMDID); |
| 1128 | /* vdev restart request (RX only, NO TX, used for CAC period)*/ |
| 1129 | CASE_RETURN_STRING(WMI_VDEV_RESTART_REQUEST_CMDID); |
| 1130 | /* vdev up request */ |
| 1131 | CASE_RETURN_STRING(WMI_VDEV_UP_CMDID); |
| 1132 | /* vdev stop request */ |
| 1133 | CASE_RETURN_STRING(WMI_VDEV_STOP_CMDID); |
| 1134 | /* vdev down request */ |
| 1135 | CASE_RETURN_STRING(WMI_VDEV_DOWN_CMDID); |
| 1136 | /* set a vdev param */ |
| 1137 | CASE_RETURN_STRING(WMI_VDEV_SET_PARAM_CMDID); |
| 1138 | /* set a key (used for setting per peer unicast |
| 1139 | * and per vdev multicast) */ |
| 1140 | CASE_RETURN_STRING(WMI_VDEV_INSTALL_KEY_CMDID); |
| 1141 | |
| 1142 | /* wnm sleep mode command */ |
| 1143 | CASE_RETURN_STRING(WMI_VDEV_WNM_SLEEPMODE_CMDID); |
| 1144 | CASE_RETURN_STRING(WMI_VDEV_WMM_ADDTS_CMDID); |
| 1145 | CASE_RETURN_STRING(WMI_VDEV_WMM_DELTS_CMDID); |
| 1146 | CASE_RETURN_STRING(WMI_VDEV_SET_WMM_PARAMS_CMDID); |
| 1147 | CASE_RETURN_STRING(WMI_VDEV_SET_GTX_PARAMS_CMDID); |
| 1148 | CASE_RETURN_STRING(WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID); |
| 1149 | |
| 1150 | CASE_RETURN_STRING(WMI_VDEV_PLMREQ_START_CMDID); |
| 1151 | CASE_RETURN_STRING(WMI_VDEV_PLMREQ_STOP_CMDID); |
| 1152 | CASE_RETURN_STRING(WMI_VDEV_TSF_TSTAMP_ACTION_CMDID); |
| 1153 | CASE_RETURN_STRING(WMI_VDEV_SET_IE_CMDID); |
| 1154 | |
| 1155 | /* peer specific commands */ |
| 1156 | |
| 1157 | /** create a peer */ |
| 1158 | CASE_RETURN_STRING(WMI_PEER_CREATE_CMDID); |
| 1159 | /** delete a peer */ |
| 1160 | CASE_RETURN_STRING(WMI_PEER_DELETE_CMDID); |
| 1161 | /** flush specific tid queues of a peer */ |
| 1162 | CASE_RETURN_STRING(WMI_PEER_FLUSH_TIDS_CMDID); |
| 1163 | /** set a parameter of a peer */ |
| 1164 | CASE_RETURN_STRING(WMI_PEER_SET_PARAM_CMDID); |
| 1165 | /* set peer to associated state. will cary all parameters |
| 1166 | * determined during assocication time */ |
| 1167 | CASE_RETURN_STRING(WMI_PEER_ASSOC_CMDID); |
| 1168 | /* add a wds (4 address ) entry. used only for testing |
| 1169 | * WDS feature on AP products */ |
| 1170 | CASE_RETURN_STRING(WMI_PEER_ADD_WDS_ENTRY_CMDID); |
| 1171 | /* remove wds (4 address ) entry. used only for testing WDS |
| 1172 | * feature on AP products */ |
| 1173 | CASE_RETURN_STRING(WMI_PEER_REMOVE_WDS_ENTRY_CMDID); |
| 1174 | /* set up mcast info for multicast to unicast conversion */ |
| 1175 | CASE_RETURN_STRING(WMI_PEER_MCAST_GROUP_CMDID); |
| 1176 | /* request peer info from FW to get PEER_INFO_EVENTID */ |
| 1177 | CASE_RETURN_STRING(WMI_PEER_INFO_REQ_CMDID); |
| 1178 | |
| 1179 | /* beacon/management specific commands */ |
| 1180 | |
| 1181 | /* transmit beacon by reference. used for transmitting beacon |
| 1182 | * on low latency interface like pcie */ |
| 1183 | CASE_RETURN_STRING(WMI_BCN_TX_CMDID); |
| 1184 | /* transmit beacon by value */ |
| 1185 | CASE_RETURN_STRING(WMI_PDEV_SEND_BCN_CMDID); |
| 1186 | /* set the beacon template. used in beacon offload mode to setup |
| 1187 | * the common beacon template with the FW to be used by FW to |
| 1188 | * generate beacons */ |
| 1189 | CASE_RETURN_STRING(WMI_BCN_TMPL_CMDID); |
| 1190 | /* set beacon filter with FW */ |
| 1191 | CASE_RETURN_STRING(WMI_BCN_FILTER_RX_CMDID); |
| 1192 | /* enable/disable filtering of probe requests in the firmware */ |
| 1193 | CASE_RETURN_STRING(WMI_PRB_REQ_FILTER_RX_CMDID); |
| 1194 | /* transmit management frame by value. will be deprecated */ |
| 1195 | CASE_RETURN_STRING(WMI_MGMT_TX_CMDID); |
| 1196 | /* set the probe response template. used in beacon offload mode |
| 1197 | * to setup the common probe response template with the FW to |
| 1198 | * be used by FW to generate probe responses */ |
| 1199 | CASE_RETURN_STRING(WMI_PRB_TMPL_CMDID); |
| 1200 | |
| 1201 | /* commands to directly control ba negotiation directly from |
| 1202 | * host. only used in test mode */ |
| 1203 | |
| 1204 | /* turn off FW Auto addba mode and let host control addba */ |
| 1205 | CASE_RETURN_STRING(WMI_ADDBA_CLEAR_RESP_CMDID); |
| 1206 | /* send add ba request */ |
| 1207 | CASE_RETURN_STRING(WMI_ADDBA_SEND_CMDID); |
| 1208 | CASE_RETURN_STRING(WMI_ADDBA_STATUS_CMDID); |
| 1209 | /* send del ba */ |
| 1210 | CASE_RETURN_STRING(WMI_DELBA_SEND_CMDID); |
| 1211 | /* set add ba response will be used by FW to generate |
| 1212 | * addba response*/ |
| 1213 | CASE_RETURN_STRING(WMI_ADDBA_SET_RESP_CMDID); |
| 1214 | /* send single VHT MPDU with AMSDU */ |
| 1215 | CASE_RETURN_STRING(WMI_SEND_SINGLEAMSDU_CMDID); |
| 1216 | |
| 1217 | /* Station power save specific config */ |
| 1218 | /* enable/disable station powersave */ |
| 1219 | CASE_RETURN_STRING(WMI_STA_POWERSAVE_MODE_CMDID); |
| 1220 | /* set station power save specific parameter */ |
| 1221 | CASE_RETURN_STRING(WMI_STA_POWERSAVE_PARAM_CMDID); |
| 1222 | /* set station mimo powersave mode */ |
| 1223 | CASE_RETURN_STRING(WMI_STA_MIMO_PS_MODE_CMDID); |
| 1224 | |
| 1225 | /* DFS-specific commands */ |
| 1226 | /* enable DFS (radar detection)*/ |
| 1227 | CASE_RETURN_STRING(WMI_PDEV_DFS_ENABLE_CMDID); |
| 1228 | /* disable DFS (radar detection)*/ |
| 1229 | CASE_RETURN_STRING(WMI_PDEV_DFS_DISABLE_CMDID); |
| 1230 | /* enable DFS phyerr/parse filter offload */ |
| 1231 | CASE_RETURN_STRING(WMI_DFS_PHYERR_FILTER_ENA_CMDID); |
| 1232 | /* enable DFS phyerr/parse filter offload */ |
| 1233 | CASE_RETURN_STRING(WMI_DFS_PHYERR_FILTER_DIS_CMDID); |
| 1234 | |
| 1235 | /* Roaming specific commands */ |
| 1236 | /* set roam scan mode */ |
| 1237 | CASE_RETURN_STRING(WMI_ROAM_SCAN_MODE); |
| 1238 | /* set roam scan rssi threshold below which roam |
| 1239 | * scan is enabled */ |
| 1240 | CASE_RETURN_STRING(WMI_ROAM_SCAN_RSSI_THRESHOLD); |
| 1241 | /* set roam scan period for periodic roam scan mode */ |
| 1242 | CASE_RETURN_STRING(WMI_ROAM_SCAN_PERIOD); |
| 1243 | /* set roam scan trigger rssi change threshold */ |
| 1244 | CASE_RETURN_STRING(WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD); |
| 1245 | /* set roam AP profile */ |
| 1246 | CASE_RETURN_STRING(WMI_ROAM_AP_PROFILE); |
| 1247 | /* set channel list for roam scans */ |
| 1248 | CASE_RETURN_STRING(WMI_ROAM_CHAN_LIST); |
| 1249 | /* offload scan specific commands */ |
| 1250 | /* set offload scan AP profile */ |
| 1251 | CASE_RETURN_STRING(WMI_OFL_SCAN_ADD_AP_PROFILE); |
| 1252 | /* remove offload scan AP profile */ |
| 1253 | CASE_RETURN_STRING(WMI_OFL_SCAN_REMOVE_AP_PROFILE); |
| 1254 | /* set offload scan period */ |
| 1255 | CASE_RETURN_STRING(WMI_OFL_SCAN_PERIOD); |
| 1256 | |
| 1257 | /* P2P specific commands */ |
| 1258 | /* set P2P device info. FW will used by FW to create P2P IE |
| 1259 | * to be carried in probe response generated during p2p listen |
| 1260 | * and for p2p discoverability */ |
| 1261 | CASE_RETURN_STRING(WMI_P2P_DEV_SET_DEVICE_INFO); |
| 1262 | /* enable/disable p2p discoverability on STA/AP VDEVs */ |
| 1263 | CASE_RETURN_STRING(WMI_P2P_DEV_SET_DISCOVERABILITY); |
| 1264 | /* set p2p ie to be carried in beacons generated by FW for GO */ |
| 1265 | CASE_RETURN_STRING(WMI_P2P_GO_SET_BEACON_IE); |
| 1266 | /* set p2p ie to be carried in probe response frames generated |
| 1267 | * by FW for GO */ |
| 1268 | CASE_RETURN_STRING(WMI_P2P_GO_SET_PROBE_RESP_IE); |
| 1269 | /* set the vendor specific p2p ie data. |
| 1270 | * FW will use this to parse the P2P NoA |
| 1271 | * attribute in the beacons/probe responses received. |
| 1272 | */ |
| 1273 | CASE_RETURN_STRING(WMI_P2P_SET_VENDOR_IE_DATA_CMDID); |
| 1274 | /* set the configure of p2p find offload */ |
| 1275 | CASE_RETURN_STRING(WMI_P2P_DISC_OFFLOAD_CONFIG_CMDID); |
| 1276 | /* set the vendor specific p2p ie data for p2p find offload */ |
| 1277 | CASE_RETURN_STRING(WMI_P2P_DISC_OFFLOAD_APPIE_CMDID); |
| 1278 | /* set the BSSID/device name pattern of p2p find offload */ |
| 1279 | CASE_RETURN_STRING(WMI_P2P_DISC_OFFLOAD_PATTERN_CMDID); |
| 1280 | /* set OppPS related parameters **/ |
| 1281 | CASE_RETURN_STRING(WMI_P2P_SET_OPPPS_PARAM_CMDID); |
| 1282 | |
| 1283 | /* AP power save specific config |
| 1284 | * set AP power save specific param */ |
| 1285 | CASE_RETURN_STRING(WMI_AP_PS_PEER_PARAM_CMDID); |
| 1286 | /* set AP UAPSD coex pecific param */ |
| 1287 | CASE_RETURN_STRING(WMI_AP_PS_PEER_UAPSD_COEX_CMDID); |
| 1288 | |
| 1289 | /* Rate-control specific commands */ |
| 1290 | CASE_RETURN_STRING(WMI_PEER_RATE_RETRY_SCHED_CMDID); |
| 1291 | |
| 1292 | /* WLAN Profiling commands. */ |
| 1293 | CASE_RETURN_STRING(WMI_WLAN_PROFILE_TRIGGER_CMDID); |
| 1294 | CASE_RETURN_STRING(WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID); |
| 1295 | CASE_RETURN_STRING(WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID); |
| 1296 | CASE_RETURN_STRING(WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID); |
| 1297 | CASE_RETURN_STRING(WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID); |
| 1298 | |
| 1299 | /* Suspend resume command Ids */ |
| 1300 | CASE_RETURN_STRING(WMI_PDEV_SUSPEND_CMDID); |
| 1301 | CASE_RETURN_STRING(WMI_PDEV_RESUME_CMDID); |
| 1302 | |
| 1303 | /* Beacon filter commands */ |
| 1304 | /* add a beacon filter */ |
| 1305 | CASE_RETURN_STRING(WMI_ADD_BCN_FILTER_CMDID); |
| 1306 | /* remove a beacon filter */ |
| 1307 | CASE_RETURN_STRING(WMI_RMV_BCN_FILTER_CMDID); |
| 1308 | |
| 1309 | /* WOW Specific WMI commands */ |
| 1310 | /* add pattern for awake */ |
| 1311 | CASE_RETURN_STRING(WMI_WOW_ADD_WAKE_PATTERN_CMDID); |
| 1312 | /* deleta a wake pattern */ |
| 1313 | CASE_RETURN_STRING(WMI_WOW_DEL_WAKE_PATTERN_CMDID); |
| 1314 | /* enable/deisable wake event */ |
| 1315 | CASE_RETURN_STRING(WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID); |
| 1316 | /* enable WOW */ |
| 1317 | CASE_RETURN_STRING(WMI_WOW_ENABLE_CMDID); |
| 1318 | /* host woke up from sleep event to FW. Generated in response |
| 1319 | * to WOW Hardware event */ |
| 1320 | CASE_RETURN_STRING(WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID); |
| 1321 | |
| 1322 | /* RTT measurement related cmd */ |
| 1323 | /* reques to make an RTT measurement */ |
| 1324 | CASE_RETURN_STRING(WMI_RTT_MEASREQ_CMDID); |
| 1325 | /* reques to report a tsf measurement */ |
| 1326 | CASE_RETURN_STRING(WMI_RTT_TSF_CMDID); |
| 1327 | |
| 1328 | /* spectral scan command */ |
| 1329 | /* configure spectral scan */ |
| 1330 | CASE_RETURN_STRING(WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID); |
| 1331 | /* enable/disable spectral scan and trigger */ |
| 1332 | CASE_RETURN_STRING(WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID); |
| 1333 | |
| 1334 | /* F/W stats */ |
| 1335 | /* one time request for stats */ |
| 1336 | CASE_RETURN_STRING(WMI_REQUEST_STATS_CMDID); |
| 1337 | /* Push MCC Adaptive Scheduler Stats to Firmware */ |
| 1338 | CASE_RETURN_STRING(WMI_MCC_SCHED_TRAFFIC_STATS_CMDID); |
| 1339 | |
| 1340 | /* ARP OFFLOAD REQUEST*/ |
| 1341 | CASE_RETURN_STRING(WMI_SET_ARP_NS_OFFLOAD_CMDID); |
| 1342 | |
| 1343 | /* Proactive ARP Response Add Pattern Command*/ |
| 1344 | CASE_RETURN_STRING(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID); |
| 1345 | |
| 1346 | /* Proactive ARP Response Del Pattern Command*/ |
| 1347 | CASE_RETURN_STRING(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID); |
| 1348 | |
| 1349 | /* NS offload confid*/ |
| 1350 | CASE_RETURN_STRING(WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID); |
| 1351 | |
| 1352 | /* GTK offload Specific WMI commands */ |
| 1353 | CASE_RETURN_STRING(WMI_GTK_OFFLOAD_CMDID); |
| 1354 | |
| 1355 | /* CSA offload Specific WMI commands */ |
| 1356 | /* csa offload enable */ |
| 1357 | CASE_RETURN_STRING(WMI_CSA_OFFLOAD_ENABLE_CMDID); |
| 1358 | /* chan switch command */ |
| 1359 | CASE_RETURN_STRING(WMI_CSA_OFFLOAD_CHANSWITCH_CMDID); |
| 1360 | |
| 1361 | /* Chatter commands */ |
| 1362 | /* Change chatter mode of operation */ |
| 1363 | CASE_RETURN_STRING(WMI_CHATTER_SET_MODE_CMDID); |
| 1364 | /* chatter add coalescing filter command */ |
| 1365 | CASE_RETURN_STRING(WMI_CHATTER_ADD_COALESCING_FILTER_CMDID); |
| 1366 | /* chatter delete coalescing filter command */ |
| 1367 | CASE_RETURN_STRING(WMI_CHATTER_DELETE_COALESCING_FILTER_CMDID); |
| 1368 | /* chatter coalecing query command */ |
| 1369 | CASE_RETURN_STRING(WMI_CHATTER_COALESCING_QUERY_CMDID); |
| 1370 | |
| 1371 | /* addba specific commands */ |
| 1372 | /* start the aggregation on this TID */ |
| 1373 | CASE_RETURN_STRING(WMI_PEER_TID_ADDBA_CMDID); |
| 1374 | /* stop the aggregation on this TID */ |
| 1375 | CASE_RETURN_STRING(WMI_PEER_TID_DELBA_CMDID); |
| 1376 | |
| 1377 | /* set station mimo powersave method */ |
| 1378 | CASE_RETURN_STRING(WMI_STA_DTIM_PS_METHOD_CMDID); |
| 1379 | /* Configure the Station UAPSD AC Auto Trigger Parameters */ |
| 1380 | CASE_RETURN_STRING(WMI_STA_UAPSD_AUTO_TRIG_CMDID); |
| 1381 | /* Configure the Keep Alive Parameters */ |
| 1382 | CASE_RETURN_STRING(WMI_STA_KEEPALIVE_CMDID); |
| 1383 | |
| 1384 | /* Request ssn from target for a sta/tid pair */ |
| 1385 | CASE_RETURN_STRING(WMI_BA_REQ_SSN_CMDID); |
| 1386 | /* misc command group */ |
| 1387 | /* echo command mainly used for testing */ |
| 1388 | CASE_RETURN_STRING(WMI_ECHO_CMDID); |
| 1389 | |
| 1390 | /* !!IMPORTANT!! |
| 1391 | * If you need to add a new WMI command to the CASE_RETURN_STRING(WMI_GRP_MISC sub-group, |
| 1392 | * please make sure you add it BEHIND CASE_RETURN_STRING(WMI_PDEV_UTF_CMDID); |
| 1393 | * as we MUST have a fixed value here to maintain compatibility between |
| 1394 | * UTF and the ART2 driver |
| 1395 | */ |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1396 | /* UTF WMI commands */ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1397 | CASE_RETURN_STRING(WMI_PDEV_UTF_CMDID); |
| 1398 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1399 | /* set debug log config */ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1400 | CASE_RETURN_STRING(WMI_DBGLOG_CFG_CMDID); |
| 1401 | /* QVIT specific command id */ |
| 1402 | CASE_RETURN_STRING(WMI_PDEV_QVIT_CMDID); |
| 1403 | /* Factory Testing Mode request command |
| 1404 | * used for integrated chipsets */ |
| 1405 | CASE_RETURN_STRING(WMI_PDEV_FTM_INTG_CMDID); |
| 1406 | /* set and get keepalive parameters command */ |
| 1407 | CASE_RETURN_STRING(WMI_VDEV_SET_KEEPALIVE_CMDID); |
| 1408 | CASE_RETURN_STRING(WMI_VDEV_GET_KEEPALIVE_CMDID); |
| 1409 | /* For fw recovery test command */ |
| 1410 | CASE_RETURN_STRING(WMI_FORCE_FW_HANG_CMDID); |
| 1411 | /* Set Mcast/Bdcast filter */ |
| 1412 | CASE_RETURN_STRING(WMI_SET_MCASTBCAST_FILTER_CMDID); |
| 1413 | /* set thermal management params */ |
| 1414 | CASE_RETURN_STRING(WMI_THERMAL_MGMT_CMDID); |
| 1415 | CASE_RETURN_STRING(WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID); |
| 1416 | CASE_RETURN_STRING(WMI_LRO_CONFIG_CMDID); |
| 1417 | CASE_RETURN_STRING(WMI_TRANSFER_DATA_TO_FLASH_CMDID); |
Sreelakshmi Konamki | 57a2c04 | 2016-04-14 18:04:17 +0530 | [diff] [blame] | 1418 | CASE_RETURN_STRING(WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID); |
Anurag Chouhan | 2568939 | 2016-04-18 17:10:41 +0530 | [diff] [blame] | 1419 | CASE_RETURN_STRING(WMI_VDEV_WISA_CMDID); |
Anurag Chouhan | 7dd6554 | 2016-04-18 17:27:12 +0530 | [diff] [blame] | 1420 | CASE_RETURN_STRING(WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID); |
Anurag Chouhan | b4a65bc | 2016-04-21 16:26:34 +0530 | [diff] [blame] | 1421 | CASE_RETURN_STRING(WMI_WOW_SET_ACTION_WAKE_UP_CMDID); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1422 | CASE_RETURN_STRING(WMI_MAWC_SENSOR_REPORT_IND_CMDID); |
| 1423 | CASE_RETURN_STRING(WMI_ROAM_CONFIGURE_MAWC_CMDID); |
| 1424 | CASE_RETURN_STRING(WMI_NLO_CONFIGURE_MAWC_CMDID); |
| 1425 | CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_MAWC_CMDID); |
| 1426 | /* GPIO Configuration */ |
| 1427 | CASE_RETURN_STRING(WMI_GPIO_CONFIG_CMDID); |
| 1428 | CASE_RETURN_STRING(WMI_GPIO_OUTPUT_CMDID); |
| 1429 | |
| 1430 | /* Txbf configuration command */ |
| 1431 | CASE_RETURN_STRING(WMI_TXBF_CMDID); |
| 1432 | |
| 1433 | /* FWTEST Commands */ |
| 1434 | CASE_RETURN_STRING(WMI_FWTEST_VDEV_MCC_SET_TBTT_MODE_CMDID); |
| 1435 | /* set NoA descs */ |
| 1436 | CASE_RETURN_STRING(WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID); |
| 1437 | |
| 1438 | /* TDLS Configuration */ |
| 1439 | /* enable/disable TDLS */ |
| 1440 | CASE_RETURN_STRING(WMI_TDLS_SET_STATE_CMDID); |
| 1441 | /* set tdls peer state */ |
| 1442 | CASE_RETURN_STRING(WMI_TDLS_PEER_UPDATE_CMDID); |
| 1443 | |
| 1444 | /* Resmgr Configuration */ |
| 1445 | /* Adaptive OCS is enabled by default in the FW. |
| 1446 | * This command is used to disable FW based adaptive OCS. |
| 1447 | */ |
| 1448 | CASE_RETURN_STRING |
| 1449 | (WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID); |
| 1450 | /* set the requested channel time quota for the home channels */ |
| 1451 | CASE_RETURN_STRING(WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID); |
| 1452 | /* set the requested latency for the home channels */ |
| 1453 | CASE_RETURN_STRING(WMI_RESMGR_SET_CHAN_LATENCY_CMDID); |
| 1454 | |
| 1455 | /* STA SMPS Configuration */ |
| 1456 | /* force SMPS mode */ |
| 1457 | CASE_RETURN_STRING(WMI_STA_SMPS_FORCE_MODE_CMDID); |
| 1458 | /* set SMPS parameters */ |
| 1459 | CASE_RETURN_STRING(WMI_STA_SMPS_PARAM_CMDID); |
| 1460 | |
| 1461 | /* Wlan HB commands */ |
| 1462 | /* enalbe/disable wlan HB */ |
| 1463 | CASE_RETURN_STRING(WMI_HB_SET_ENABLE_CMDID); |
| 1464 | /* set tcp parameters for wlan HB */ |
| 1465 | CASE_RETURN_STRING(WMI_HB_SET_TCP_PARAMS_CMDID); |
| 1466 | /* set tcp pkt filter for wlan HB */ |
| 1467 | CASE_RETURN_STRING(WMI_HB_SET_TCP_PKT_FILTER_CMDID); |
| 1468 | /* set udp parameters for wlan HB */ |
| 1469 | CASE_RETURN_STRING(WMI_HB_SET_UDP_PARAMS_CMDID); |
| 1470 | /* set udp pkt filter for wlan HB */ |
| 1471 | CASE_RETURN_STRING(WMI_HB_SET_UDP_PKT_FILTER_CMDID); |
| 1472 | |
| 1473 | /* Wlan RMC commands*/ |
| 1474 | /* enable/disable RMC */ |
| 1475 | CASE_RETURN_STRING(WMI_RMC_SET_MODE_CMDID); |
| 1476 | /* configure action frame period */ |
| 1477 | CASE_RETURN_STRING(WMI_RMC_SET_ACTION_PERIOD_CMDID); |
| 1478 | /* For debug/future enhancement purposes only, |
| 1479 | * configures/finetunes RMC algorithms */ |
| 1480 | CASE_RETURN_STRING(WMI_RMC_CONFIG_CMDID); |
| 1481 | |
| 1482 | /* WLAN MHF offload commands */ |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1483 | /* enable/disable MHF offload */ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1484 | CASE_RETURN_STRING(WMI_MHF_OFFLOAD_SET_MODE_CMDID); |
| 1485 | /* Plumb routing table for MHF offload */ |
| 1486 | CASE_RETURN_STRING(WMI_MHF_OFFLOAD_PLUMB_ROUTING_TBL_CMDID); |
| 1487 | |
| 1488 | /* location scan commands */ |
| 1489 | /* start batch scan */ |
| 1490 | CASE_RETURN_STRING(WMI_BATCH_SCAN_ENABLE_CMDID); |
| 1491 | /* stop batch scan */ |
| 1492 | CASE_RETURN_STRING(WMI_BATCH_SCAN_DISABLE_CMDID); |
| 1493 | /* get batch scan result */ |
| 1494 | CASE_RETURN_STRING(WMI_BATCH_SCAN_TRIGGER_RESULT_CMDID); |
| 1495 | /* OEM related cmd */ |
| 1496 | CASE_RETURN_STRING(WMI_OEM_REQ_CMDID); |
| 1497 | CASE_RETURN_STRING(WMI_OEM_REQUEST_CMDID); |
| 1498 | /* NAN request cmd */ |
| 1499 | CASE_RETURN_STRING(WMI_NAN_CMDID); |
| 1500 | /* Modem power state cmd */ |
| 1501 | CASE_RETURN_STRING(WMI_MODEM_POWER_STATE_CMDID); |
| 1502 | CASE_RETURN_STRING(WMI_REQUEST_STATS_EXT_CMDID); |
| 1503 | CASE_RETURN_STRING(WMI_OBSS_SCAN_ENABLE_CMDID); |
| 1504 | CASE_RETURN_STRING(WMI_OBSS_SCAN_DISABLE_CMDID); |
| 1505 | CASE_RETURN_STRING(WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID); |
| 1506 | CASE_RETURN_STRING(WMI_ROAM_SCAN_CMD); |
| 1507 | CASE_RETURN_STRING(WMI_PDEV_SET_LED_CONFIG_CMDID); |
| 1508 | CASE_RETURN_STRING(WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID); |
| 1509 | CASE_RETURN_STRING(WMI_CHAN_AVOID_UPDATE_CMDID); |
Sreelakshmi Konamki | 084f3d3 | 2016-04-14 17:46:26 +0530 | [diff] [blame] | 1510 | CASE_RETURN_STRING(WMI_COEX_CONFIG_CMDID); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1511 | CASE_RETURN_STRING(WMI_WOW_IOAC_ADD_KEEPALIVE_CMDID); |
| 1512 | CASE_RETURN_STRING(WMI_WOW_IOAC_DEL_KEEPALIVE_CMDID); |
| 1513 | CASE_RETURN_STRING(WMI_WOW_IOAC_ADD_WAKE_PATTERN_CMDID); |
| 1514 | CASE_RETURN_STRING(WMI_WOW_IOAC_DEL_WAKE_PATTERN_CMDID); |
| 1515 | CASE_RETURN_STRING(WMI_REQUEST_LINK_STATS_CMDID); |
| 1516 | CASE_RETURN_STRING(WMI_START_LINK_STATS_CMDID); |
| 1517 | CASE_RETURN_STRING(WMI_CLEAR_LINK_STATS_CMDID); |
| 1518 | CASE_RETURN_STRING(WMI_GET_FW_MEM_DUMP_CMDID); |
| 1519 | CASE_RETURN_STRING(WMI_LPI_MGMT_SNOOPING_CONFIG_CMDID); |
| 1520 | CASE_RETURN_STRING(WMI_LPI_START_SCAN_CMDID); |
| 1521 | CASE_RETURN_STRING(WMI_LPI_STOP_SCAN_CMDID); |
| 1522 | CASE_RETURN_STRING(WMI_EXTSCAN_START_CMDID); |
| 1523 | CASE_RETURN_STRING(WMI_EXTSCAN_STOP_CMDID); |
| 1524 | CASE_RETURN_STRING |
| 1525 | (WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID); |
| 1526 | CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID); |
| 1527 | CASE_RETURN_STRING(WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID); |
| 1528 | CASE_RETURN_STRING(WMI_EXTSCAN_GET_WLAN_CHANGE_RESULTS_CMDID); |
| 1529 | CASE_RETURN_STRING(WMI_EXTSCAN_SET_CAPABILITIES_CMDID); |
| 1530 | CASE_RETURN_STRING(WMI_EXTSCAN_GET_CAPABILITIES_CMDID); |
| 1531 | CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID); |
| 1532 | CASE_RETURN_STRING(WMI_ROAM_SYNCH_COMPLETE); |
| 1533 | CASE_RETURN_STRING(WMI_D0_WOW_ENABLE_DISABLE_CMDID); |
| 1534 | CASE_RETURN_STRING(WMI_EXTWOW_ENABLE_CMDID); |
| 1535 | CASE_RETURN_STRING(WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID); |
| 1536 | CASE_RETURN_STRING(WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID); |
| 1537 | CASE_RETURN_STRING(WMI_UNIT_TEST_CMDID); |
| 1538 | CASE_RETURN_STRING(WMI_ROAM_SET_RIC_REQUEST_CMDID); |
| 1539 | CASE_RETURN_STRING(WMI_PDEV_GET_TEMPERATURE_CMDID); |
| 1540 | CASE_RETURN_STRING(WMI_SET_DHCP_SERVER_OFFLOAD_CMDID); |
| 1541 | CASE_RETURN_STRING(WMI_TPC_CHAINMASK_CONFIG_CMDID); |
| 1542 | CASE_RETURN_STRING(WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID); |
| 1543 | CASE_RETURN_STRING(WMI_SCAN_PROB_REQ_OUI_CMDID); |
| 1544 | CASE_RETURN_STRING(WMI_TDLS_SET_OFFCHAN_MODE_CMDID); |
| 1545 | CASE_RETURN_STRING(WMI_PDEV_SET_LED_FLASHING_CMDID); |
| 1546 | CASE_RETURN_STRING(WMI_MDNS_OFFLOAD_ENABLE_CMDID); |
| 1547 | CASE_RETURN_STRING(WMI_MDNS_SET_FQDN_CMDID); |
| 1548 | CASE_RETURN_STRING(WMI_MDNS_SET_RESPONSE_CMDID); |
| 1549 | CASE_RETURN_STRING(WMI_MDNS_GET_STATS_CMDID); |
| 1550 | CASE_RETURN_STRING(WMI_ROAM_INVOKE_CMDID); |
| 1551 | CASE_RETURN_STRING(WMI_SET_ANTENNA_DIVERSITY_CMDID); |
| 1552 | CASE_RETURN_STRING(WMI_SAP_OFL_ENABLE_CMDID); |
| 1553 | CASE_RETURN_STRING(WMI_APFIND_CMDID); |
| 1554 | CASE_RETURN_STRING(WMI_PASSPOINT_LIST_CONFIG_CMDID); |
| 1555 | CASE_RETURN_STRING(WMI_OCB_SET_SCHED_CMDID); |
| 1556 | CASE_RETURN_STRING(WMI_OCB_SET_CONFIG_CMDID); |
| 1557 | CASE_RETURN_STRING(WMI_OCB_SET_UTC_TIME_CMDID); |
| 1558 | CASE_RETURN_STRING(WMI_OCB_START_TIMING_ADVERT_CMDID); |
| 1559 | CASE_RETURN_STRING(WMI_OCB_STOP_TIMING_ADVERT_CMDID); |
| 1560 | CASE_RETURN_STRING(WMI_OCB_GET_TSF_TIMER_CMDID); |
| 1561 | CASE_RETURN_STRING(WMI_DCC_GET_STATS_CMDID); |
| 1562 | CASE_RETURN_STRING(WMI_DCC_CLEAR_STATS_CMDID); |
| 1563 | CASE_RETURN_STRING(WMI_DCC_UPDATE_NDL_CMDID); |
| 1564 | CASE_RETURN_STRING(WMI_ROAM_FILTER_CMDID); |
| 1565 | CASE_RETURN_STRING(WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID); |
| 1566 | CASE_RETURN_STRING(WMI_DEBUG_MESG_FLUSH_CMDID); |
| 1567 | CASE_RETURN_STRING(WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID); |
| 1568 | CASE_RETURN_STRING(WMI_SOC_SET_PCL_CMDID); |
| 1569 | CASE_RETURN_STRING(WMI_SOC_SET_HW_MODE_CMDID); |
| 1570 | CASE_RETURN_STRING(WMI_SOC_SET_DUAL_MAC_CONFIG_CMDID); |
| 1571 | CASE_RETURN_STRING(WMI_WOW_ENABLE_ICMPV6_NA_FLT_CMDID); |
| 1572 | CASE_RETURN_STRING(WMI_DIAG_EVENT_LOG_CONFIG_CMDID); |
| 1573 | CASE_RETURN_STRING(WMI_PACKET_FILTER_CONFIG_CMDID); |
| 1574 | CASE_RETURN_STRING(WMI_PACKET_FILTER_ENABLE_CMDID); |
| 1575 | CASE_RETURN_STRING(WMI_SAP_SET_BLACKLIST_PARAM_CMDID); |
| 1576 | CASE_RETURN_STRING(WMI_WOW_UDP_SVC_OFLD_CMDID); |
| 1577 | CASE_RETURN_STRING(WMI_MGMT_TX_SEND_CMDID); |
| 1578 | CASE_RETURN_STRING(WMI_SOC_SET_ANTENNA_MODE_CMDID); |
| 1579 | CASE_RETURN_STRING(WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID); |
| 1580 | CASE_RETURN_STRING(WMI_AP_PS_EGAP_PARAM_CMDID); |
| 1581 | CASE_RETURN_STRING(WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID); |
| 1582 | CASE_RETURN_STRING(WMI_BPF_GET_CAPABILITY_CMDID); |
| 1583 | CASE_RETURN_STRING(WMI_BPF_GET_VDEV_STATS_CMDID); |
| 1584 | CASE_RETURN_STRING(WMI_BPF_SET_VDEV_INSTRUCTIONS_CMDID); |
| 1585 | CASE_RETURN_STRING(WMI_BPF_DEL_VDEV_INSTRUCTIONS_CMDID); |
Govind Singh | 8b1466e | 2016-03-16 16:27:50 +0530 | [diff] [blame] | 1586 | CASE_RETURN_STRING(WMI_NDI_GET_CAP_REQ_CMDID); |
| 1587 | CASE_RETURN_STRING(WMI_NDP_INITIATOR_REQ_CMDID); |
| 1588 | CASE_RETURN_STRING(WMI_NDP_RESPONDER_REQ_CMDID); |
| 1589 | CASE_RETURN_STRING(WMI_NDP_END_REQ_CMDID); |
| 1590 | CASE_RETURN_STRING(WMI_PEER_UPDATE_WDS_ENTRY_CMDID); |
| 1591 | CASE_RETURN_STRING(WMI_PEER_ADD_PROXY_STA_ENTRY_CMDID); |
| 1592 | CASE_RETURN_STRING(WMI_PDEV_FIPS_CMDID); |
| 1593 | CASE_RETURN_STRING(WMI_PDEV_SMART_ANT_ENABLE_CMDID); |
| 1594 | CASE_RETURN_STRING(WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID); |
| 1595 | CASE_RETURN_STRING(WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID); |
| 1596 | CASE_RETURN_STRING(WMI_PDEV_SET_CTL_TABLE_CMDID); |
| 1597 | CASE_RETURN_STRING(WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID); |
| 1598 | CASE_RETURN_STRING(WMI_PDEV_GET_TPC_CMDID); |
| 1599 | CASE_RETURN_STRING(WMI_MIB_STATS_ENABLE_CMDID); |
| 1600 | CASE_RETURN_STRING(WMI_PDEV_GET_ANI_CCK_CONFIG_CMDID); |
| 1601 | CASE_RETURN_STRING(WMI_PDEV_GET_ANI_OFDM_CONFIG_CMDID); |
| 1602 | CASE_RETURN_STRING(WMI_VDEV_RATEMASK_CMDID); |
| 1603 | CASE_RETURN_STRING(WMI_VDEV_ATF_REQUEST_CMDID); |
| 1604 | CASE_RETURN_STRING(WMI_VDEV_SET_DSCP_TID_MAP_CMDID); |
| 1605 | CASE_RETURN_STRING(WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID); |
| 1606 | CASE_RETURN_STRING(WMI_VDEV_SET_QUIET_MODE_CMDID); |
| 1607 | CASE_RETURN_STRING(WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID); |
| 1608 | CASE_RETURN_STRING(WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID); |
| 1609 | CASE_RETURN_STRING(WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID); |
| 1610 | CASE_RETURN_STRING(WMI_PEER_ATF_REQUEST_CMDID); |
| 1611 | CASE_RETURN_STRING(WMI_FWTEST_CMDID); |
| 1612 | CASE_RETURN_STRING(WMI_QBOOST_CFG_CMDID); |
| 1613 | CASE_RETURN_STRING(WMI_PDEV_GET_NFCAL_POWER_CMDID); |
| 1614 | CASE_RETURN_STRING(WMI_PDEV_SET_PCL_CMDID); |
| 1615 | CASE_RETURN_STRING(WMI_PDEV_SET_HW_MODE_CMDID); |
| 1616 | CASE_RETURN_STRING(WMI_PDEV_SET_MAC_CONFIG_CMDID); |
| 1617 | CASE_RETURN_STRING(WMI_PDEV_SET_ANTENNA_MODE_CMDID); |
| 1618 | CASE_RETURN_STRING(WMI_ROAM_SET_MBO_PARAM_CMDID); |
Naveen Rawat | 8cf610b | 2016-04-14 20:10:15 -0700 | [diff] [blame] | 1619 | CASE_RETURN_STRING(WMI_CHAN_AVOID_RPT_ALLOW_CMDID); |
Sandeep Puligilla | cc28f4e | 2016-04-16 13:35:09 +0530 | [diff] [blame] | 1620 | CASE_RETURN_STRING(WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID); |
Krishna Kumaar Natarajan | c285c10 | 2016-04-16 14:09:58 +0530 | [diff] [blame] | 1621 | CASE_RETURN_STRING(WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID); |
Krishna Kumaar Natarajan | 0d2a1bd | 2016-04-16 16:47:07 +0530 | [diff] [blame] | 1622 | CASE_RETURN_STRING(WMI_PDEV_WAL_POWER_DEBUG_CMDID); |
Himanshu Agarwal | de99272 | 2016-05-13 20:31:57 +0530 | [diff] [blame] | 1623 | CASE_RETURN_STRING(WMI_PEER_BWF_REQUEST_CMDID); |
Himanshu Agarwal | dc8d1ae | 2016-05-13 21:04:17 +0530 | [diff] [blame] | 1624 | CASE_RETURN_STRING(WMI_DBGLOG_TIME_STAMP_SYNC_CMDID); |
Himanshu Agarwal | fc302f9 | 2016-05-30 21:06:16 +0530 | [diff] [blame] | 1625 | CASE_RETURN_STRING(WMI_P2P_LISTEN_OFFLOAD_START_CMDID); |
| 1626 | CASE_RETURN_STRING(WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID); |
Pradeep Reddy POTTETI | 18f8fbb | 2016-06-13 17:59:38 +0530 | [diff] [blame] | 1627 | CASE_RETURN_STRING(WMI_PEER_REORDER_QUEUE_SETUP_CMDID); |
| 1628 | CASE_RETURN_STRING(WMI_PEER_REORDER_QUEUE_REMOVE_CMDID); |
Pradeep Reddy POTTETI | 4b997fd | 2016-06-20 13:25:31 +0530 | [diff] [blame] | 1629 | CASE_RETURN_STRING(WMI_SET_MULTIPLE_MCAST_FILTER_CMDID); |
Pradeep Reddy POTTETI | 10ca69d | 2016-06-20 14:50:42 +0530 | [diff] [blame] | 1630 | CASE_RETURN_STRING(WMI_READ_DATA_FROM_FLASH_CMDID); |
Nitesh Shah | 70e1104 | 2016-06-29 20:16:16 +0530 | [diff] [blame] | 1631 | CASE_RETURN_STRING(WMI_PDEV_SET_REORDER_TIMEOUT_VAL_CMDID); |
| 1632 | CASE_RETURN_STRING(WMI_PEER_SET_RX_BLOCKSIZE_CMDID); |
Nitesh Shah | c048265 | 2016-07-08 11:45:33 +0530 | [diff] [blame] | 1633 | CASE_RETURN_STRING(WMI_PDEV_SET_WAKEUP_CONFIG_CMDID); |
Nitesh Shah | 33b9540 | 2016-07-21 17:25:55 +0530 | [diff] [blame] | 1634 | CASE_RETURN_STRING(WMI_PDEV_GET_ANTDIV_STATUS_CMDID); |
| 1635 | CASE_RETURN_STRING(WMI_PEER_ANTDIV_INFO_REQ_CMDID); |
Anurag Chouhan | 40865b4 | 2016-08-01 14:01:54 +0530 | [diff] [blame] | 1636 | CASE_RETURN_STRING(WMI_MNT_FILTER_CMDID); |
Anurag Chouhan | 7f6f1d5 | 2016-08-04 18:46:29 +0530 | [diff] [blame] | 1637 | CASE_RETURN_STRING(WMI_PDEV_GET_CHIP_POWER_STATS_CMDID); |
Manjeet Singh | c026bde | 2016-09-01 16:42:29 +0530 | [diff] [blame] | 1638 | CASE_RETURN_STRING(WMI_COEX_GET_ANTENNA_ISOLATION_CMDID); |
Manjeet Singh | bea1671 | 2016-08-18 15:50:30 +0530 | [diff] [blame] | 1639 | CASE_RETURN_STRING(WMI_PDEV_SET_STATS_THRESHOLD_CMDID); |
| 1640 | CASE_RETURN_STRING(WMI_REQUEST_WLAN_STATS_CMDID); |
Himanshu Agarwal | 91c9d67 | 2016-09-14 20:43:24 +0530 | [diff] [blame] | 1641 | CASE_RETURN_STRING(WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1642 | } |
| 1643 | |
| 1644 | return "Invalid WMI cmd"; |
| 1645 | } |
| 1646 | |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 1647 | static inline void wma_log_cmd_id(uint32_t cmd_id) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1648 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1649 | WMI_LOGD("Send WMI command:%s command_id:%d", |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1650 | wmi_id_to_name(cmd_id), cmd_id); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1651 | } |
Houston Hoffman | 0a0b2d0 | 2016-06-08 20:00:03 -0700 | [diff] [blame] | 1652 | #else |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 1653 | static uint8_t *wmi_id_to_name(uint32_t wmi_command) |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1654 | { |
| 1655 | return "Invalid WMI cmd"; |
| 1656 | } |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1657 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1658 | |
Houston Hoffman | 0a0b2d0 | 2016-06-08 20:00:03 -0700 | [diff] [blame] | 1659 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1660 | /** |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1661 | * wmi_is_runtime_pm_cmd() - check if a cmd is from suspend resume sequence |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1662 | * @cmd: command to check |
| 1663 | * |
| 1664 | * Return: true if the command is part of the suspend resume sequence. |
| 1665 | */ |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 1666 | #ifdef CONFIG_MCL |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 1667 | static bool wmi_is_runtime_pm_cmd(uint32_t cmd_id) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1668 | { |
| 1669 | switch (cmd_id) { |
| 1670 | case WMI_WOW_ENABLE_CMDID: |
| 1671 | case WMI_PDEV_SUSPEND_CMDID: |
| 1672 | case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID: |
| 1673 | case WMI_WOW_ADD_WAKE_PATTERN_CMDID: |
| 1674 | case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID: |
| 1675 | case WMI_PDEV_RESUME_CMDID: |
| 1676 | case WMI_WOW_DEL_WAKE_PATTERN_CMDID: |
| 1677 | case WMI_D0_WOW_ENABLE_DISABLE_CMDID: |
| 1678 | return true; |
| 1679 | |
| 1680 | default: |
| 1681 | return false; |
| 1682 | } |
| 1683 | } |
| 1684 | |
| 1685 | /** |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1686 | * wmi_is_pm_resume_cmd() - check if a cmd is part of the resume sequence |
| 1687 | * @cmd_id: command to check |
| 1688 | * |
| 1689 | * Return: true if the command is part of the resume sequence. |
| 1690 | */ |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 1691 | static bool wmi_is_pm_resume_cmd(uint32_t cmd_id) |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1692 | { |
| 1693 | switch (cmd_id) { |
| 1694 | case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID: |
| 1695 | case WMI_PDEV_RESUME_CMDID: |
| 1696 | return true; |
| 1697 | |
| 1698 | default: |
| 1699 | return false; |
| 1700 | } |
| 1701 | } |
| 1702 | #else |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 1703 | static bool wmi_is_runtime_pm_cmd(uint32_t cmd_id) |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1704 | { |
| 1705 | return false; |
| 1706 | } |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 1707 | static bool wmi_is_pm_resume_cmd(uint32_t cmd_id) |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1708 | { |
| 1709 | return false; |
| 1710 | } |
| 1711 | #endif |
| 1712 | |
| 1713 | /** |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1714 | * wmi_unified_cmd_send() - WMI command API |
| 1715 | * @wmi_handle: handle to wmi |
| 1716 | * @buf: wmi buf |
| 1717 | * @len: wmi buffer length |
| 1718 | * @cmd_id: wmi command id |
| 1719 | * |
| 1720 | * Return: 0 on success |
| 1721 | */ |
Houston Hoffman | cdd5eda | 2016-09-27 23:29:49 -0700 | [diff] [blame^] | 1722 | QDF_STATUS wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf, |
| 1723 | uint32_t len, uint32_t cmd_id) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1724 | { |
| 1725 | HTC_PACKET *pkt; |
| 1726 | A_STATUS status; |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1727 | uint16_t htc_tag = 0; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1728 | |
| 1729 | if (wmi_get_runtime_pm_inprogress(wmi_handle)) { |
| 1730 | if (wmi_is_runtime_pm_cmd(cmd_id)) |
| 1731 | htc_tag = HTC_TX_PACKET_TAG_AUTO_PM; |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1732 | } else if (qdf_atomic_read(&wmi_handle->is_target_suspended) && |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1733 | (!wmi_is_pm_resume_cmd(cmd_id))) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1734 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1735 | "%s: Target is suspended", __func__); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1736 | QDF_ASSERT(0); |
Govind Singh | 67922e8 | 2016-04-01 16:48:57 +0530 | [diff] [blame] | 1737 | return QDF_STATUS_E_BUSY; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1738 | } |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1739 | if (wmi_handle->wmi_stopinprogress) { |
| 1740 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
| 1741 | "WMI stop in progress\n"); |
Houston Hoffman | cdd5eda | 2016-09-27 23:29:49 -0700 | [diff] [blame^] | 1742 | return QDF_STATUS_E_INVAL; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1743 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1744 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1745 | #ifndef WMI_NON_TLV_SUPPORT |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 1746 | /* Do sanity check on the TLV parameter structure */ |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1747 | if (wmi_handle->target_type == WMI_TLV_TARGET) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1748 | void *buf_ptr = (void *)qdf_nbuf_data(buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1749 | |
| 1750 | if (wmitlv_check_command_tlv_params(NULL, buf_ptr, len, cmd_id) |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1751 | != 0) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1752 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1753 | "\nERROR: %s: Invalid WMI Param Buffer for Cmd:%d", |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1754 | __func__, cmd_id); |
Govind Singh | 67922e8 | 2016-04-01 16:48:57 +0530 | [diff] [blame] | 1755 | return QDF_STATUS_E_INVAL; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1756 | } |
| 1757 | } |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1758 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1759 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1760 | if (qdf_nbuf_push_head(buf, sizeof(WMI_CMD_HDR)) == NULL) { |
| 1761 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1762 | "%s, Failed to send cmd %x, no memory", |
| 1763 | __func__, cmd_id); |
Govind Singh | 67922e8 | 2016-04-01 16:48:57 +0530 | [diff] [blame] | 1764 | return QDF_STATUS_E_NOMEM; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1765 | } |
| 1766 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1767 | WMI_SET_FIELD(qdf_nbuf_data(buf), WMI_CMD_HDR, COMMANDID, cmd_id); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1768 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1769 | qdf_atomic_inc(&wmi_handle->pending_cmds); |
| 1770 | if (qdf_atomic_read(&wmi_handle->pending_cmds) >= WMI_MAX_CMDS) { |
| 1771 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1772 | "\n%s: hostcredits = %d", __func__, |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1773 | wmi_get_host_credits(wmi_handle)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1774 | htc_dump_counter_info(wmi_handle->htc_handle); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1775 | qdf_atomic_dec(&wmi_handle->pending_cmds); |
| 1776 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1777 | "%s: MAX 1024 WMI Pending cmds reached.", __func__); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1778 | QDF_BUG(0); |
Govind Singh | 67922e8 | 2016-04-01 16:48:57 +0530 | [diff] [blame] | 1779 | return QDF_STATUS_E_BUSY; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1780 | } |
| 1781 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1782 | pkt = qdf_mem_malloc(sizeof(*pkt)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1783 | if (!pkt) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1784 | qdf_atomic_dec(&wmi_handle->pending_cmds); |
| 1785 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1786 | "%s, Failed to alloc htc packet %x, no memory", |
| 1787 | __func__, cmd_id); |
Govind Singh | 67922e8 | 2016-04-01 16:48:57 +0530 | [diff] [blame] | 1788 | return QDF_STATUS_E_NOMEM; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1789 | } |
| 1790 | |
| 1791 | SET_HTC_PACKET_INFO_TX(pkt, |
| 1792 | NULL, |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1793 | qdf_nbuf_data(buf), len + sizeof(WMI_CMD_HDR), |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1794 | wmi_handle->wmi_endpoint_id, htc_tag); |
| 1795 | |
| 1796 | SET_HTC_PACKET_NET_BUF_CONTEXT(pkt, buf); |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 1797 | #ifdef CONFIG_MCL |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1798 | wma_log_cmd_id(cmd_id); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1799 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1800 | |
| 1801 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1802 | if (wmi_handle->log_info.wmi_logging_enable) { |
| 1803 | qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock); |
Sandeep Puligilla | b74958d | 2016-06-13 15:42:55 -0700 | [diff] [blame] | 1804 | if (!wmi_handle->log_info.is_management_record(cmd_id)) { |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1805 | WMI_COMMAND_RECORD(wmi_handle, cmd_id, |
| 1806 | ((uint32_t *) qdf_nbuf_data(buf) + |
| 1807 | wmi_handle->log_info.buf_offset_command)); |
| 1808 | } |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1809 | qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock); |
| 1810 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1811 | #endif |
| 1812 | |
| 1813 | status = htc_send_pkt(wmi_handle->htc_handle, pkt); |
| 1814 | |
| 1815 | if (A_OK != status) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1816 | qdf_atomic_dec(&wmi_handle->pending_cmds); |
| 1817 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1818 | "%s %d, htc_send_pkt failed", __func__, __LINE__); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1819 | } |
| 1820 | if (status) |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1821 | return QDF_STATUS_E_FAILURE; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1822 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1823 | return QDF_STATUS_SUCCESS; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1824 | } |
| 1825 | |
| 1826 | /** |
| 1827 | * wmi_unified_get_event_handler_ix() - gives event handler's index |
| 1828 | * @wmi_handle: handle to wmi |
| 1829 | * @event_id: wmi event id |
| 1830 | * |
| 1831 | * Return: event handler's index |
| 1832 | */ |
| 1833 | int wmi_unified_get_event_handler_ix(wmi_unified_t wmi_handle, |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1834 | uint32_t event_id) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1835 | { |
| 1836 | uint32_t idx = 0; |
| 1837 | int32_t invalid_idx = -1; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1838 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1839 | for (idx = 0; (idx < wmi_handle->max_event_idx && |
| 1840 | idx < WMI_UNIFIED_MAX_EVENT); ++idx) { |
| 1841 | if (wmi_handle->event_id[idx] == event_id && |
| 1842 | wmi_handle->event_handler[idx] != NULL) { |
| 1843 | return idx; |
| 1844 | } |
| 1845 | } |
| 1846 | |
| 1847 | return invalid_idx; |
| 1848 | } |
| 1849 | |
| 1850 | /** |
| 1851 | * wmi_unified_register_event_handler() - register wmi event handler |
| 1852 | * @wmi_handle: handle to wmi |
| 1853 | * @event_id: wmi event id |
| 1854 | * @handler_func: wmi event handler function |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1855 | * @rx_ctx: rx execution context for wmi rx events |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1856 | * |
| 1857 | * Return: 0 on success |
| 1858 | */ |
| 1859 | int wmi_unified_register_event_handler(wmi_unified_t wmi_handle, |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1860 | uint32_t event_id, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1861 | wmi_unified_event_handler handler_func, |
| 1862 | uint8_t rx_ctx) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1863 | { |
| 1864 | uint32_t idx = 0; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1865 | uint32_t evt_id; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1866 | |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 1867 | #ifndef CONFIG_MCL |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1868 | if (event_id >= wmi_events_max || |
| 1869 | wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) { |
| 1870 | qdf_print("%s: Event id %d is unavailable\n", |
| 1871 | __func__, event_id); |
| 1872 | return QDF_STATUS_E_FAILURE; |
| 1873 | } |
| 1874 | evt_id = wmi_handle->wmi_events[event_id]; |
| 1875 | #else |
| 1876 | evt_id = event_id; |
| 1877 | #endif |
| 1878 | if (wmi_unified_get_event_handler_ix(wmi_handle, evt_id) != -1) { |
| 1879 | qdf_print("%s : event handler already registered 0x%x\n", |
| 1880 | __func__, evt_id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1881 | return QDF_STATUS_E_FAILURE; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1882 | } |
| 1883 | if (wmi_handle->max_event_idx == WMI_UNIFIED_MAX_EVENT) { |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1884 | qdf_print("%s : no more event handlers 0x%x\n", |
| 1885 | __func__, evt_id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1886 | return QDF_STATUS_E_FAILURE; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1887 | } |
| 1888 | idx = wmi_handle->max_event_idx; |
| 1889 | wmi_handle->event_handler[idx] = handler_func; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1890 | wmi_handle->event_id[idx] = evt_id; |
Govind Singh | 813fdac | 2016-03-12 09:26:52 +0530 | [diff] [blame] | 1891 | qdf_spin_lock_bh(&wmi_handle->ctx_lock); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1892 | wmi_handle->ctx[idx] = rx_ctx; |
Govind Singh | 813fdac | 2016-03-12 09:26:52 +0530 | [diff] [blame] | 1893 | qdf_spin_unlock_bh(&wmi_handle->ctx_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1894 | wmi_handle->max_event_idx++; |
| 1895 | |
| 1896 | return 0; |
| 1897 | } |
| 1898 | |
| 1899 | /** |
| 1900 | * wmi_unified_unregister_event_handler() - unregister wmi event handler |
| 1901 | * @wmi_handle: handle to wmi |
| 1902 | * @event_id: wmi event id |
| 1903 | * |
| 1904 | * Return: 0 on success |
| 1905 | */ |
| 1906 | int wmi_unified_unregister_event_handler(wmi_unified_t wmi_handle, |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1907 | uint32_t event_id) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1908 | { |
| 1909 | uint32_t idx = 0; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1910 | uint32_t evt_id; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1911 | |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 1912 | #ifndef CONFIG_MCL |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1913 | if (event_id >= wmi_events_max || |
| 1914 | wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) { |
| 1915 | qdf_print("%s: Event id %d is unavailable\n", |
| 1916 | __func__, event_id); |
| 1917 | return QDF_STATUS_E_FAILURE; |
| 1918 | } |
| 1919 | evt_id = wmi_handle->wmi_events[event_id]; |
| 1920 | #else |
| 1921 | evt_id = event_id; |
| 1922 | #endif |
| 1923 | |
| 1924 | idx = wmi_unified_get_event_handler_ix(wmi_handle, evt_id); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1925 | if (idx == -1) { |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1926 | qdf_print("%s : event handler is not registered: evt id 0x%x\n", |
| 1927 | __func__, evt_id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1928 | return QDF_STATUS_E_FAILURE; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1929 | } |
| 1930 | wmi_handle->event_handler[idx] = NULL; |
| 1931 | wmi_handle->event_id[idx] = 0; |
| 1932 | --wmi_handle->max_event_idx; |
| 1933 | wmi_handle->event_handler[idx] = |
| 1934 | wmi_handle->event_handler[wmi_handle->max_event_idx]; |
| 1935 | wmi_handle->event_id[idx] = |
| 1936 | wmi_handle->event_id[wmi_handle->max_event_idx]; |
| 1937 | |
| 1938 | return 0; |
| 1939 | } |
| 1940 | |
| 1941 | /** |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1942 | * wmi_process_fw_event_default_ctx() - process in default caller context |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1943 | * @wmi_handle: handle to wmi |
| 1944 | * @htc_packet: pointer to htc packet |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1945 | * @exec_ctx: execution context for wmi fw event |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1946 | * |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1947 | * Event process by below function will be in default caller context. |
| 1948 | * wmi internally provides rx work thread processing context. |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1949 | * |
| 1950 | * Return: none |
| 1951 | */ |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1952 | static void wmi_process_fw_event_default_ctx(struct wmi_unified *wmi_handle, |
| 1953 | HTC_PACKET *htc_packet, uint8_t exec_ctx) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1954 | { |
| 1955 | wmi_buf_t evt_buf; |
| 1956 | evt_buf = (wmi_buf_t) htc_packet->pPktContext; |
| 1957 | |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 1958 | #ifndef CONFIG_MCL |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1959 | wmi_handle->rx_ops.wma_process_fw_event_handler_cbk |
| 1960 | (wmi_handle->scn_handle, evt_buf, exec_ctx); |
| 1961 | #else |
Govind Singh | 5eb5153 | 2016-03-09 11:34:12 +0530 | [diff] [blame] | 1962 | wmi_handle->rx_ops.wma_process_fw_event_handler_cbk(wmi_handle, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1963 | evt_buf, exec_ctx); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1964 | #endif |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1965 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1966 | return; |
| 1967 | } |
| 1968 | |
| 1969 | /** |
| 1970 | * wmi_process_fw_event_worker_thread_ctx() - process in worker thread context |
| 1971 | * @wmi_handle: handle to wmi |
| 1972 | * @htc_packet: pointer to htc packet |
| 1973 | * |
| 1974 | * Event process by below function will be in worker thread context. |
| 1975 | * Use this method for events which are not critical and not |
| 1976 | * handled in protocol stack. |
| 1977 | * |
| 1978 | * Return: none |
| 1979 | */ |
| 1980 | static void wmi_process_fw_event_worker_thread_ctx |
| 1981 | (struct wmi_unified *wmi_handle, HTC_PACKET *htc_packet) |
| 1982 | { |
| 1983 | wmi_buf_t evt_buf; |
| 1984 | uint32_t id; |
| 1985 | uint8_t *data; |
| 1986 | |
| 1987 | evt_buf = (wmi_buf_t) htc_packet->pPktContext; |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1988 | id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID); |
| 1989 | data = qdf_nbuf_data(evt_buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1990 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1991 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1992 | if (wmi_handle->log_info.wmi_logging_enable) { |
| 1993 | qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock); |
| 1994 | /* Exclude 4 bytes of TLV header */ |
| 1995 | WMI_RX_EVENT_RECORD(wmi_handle, id, ((uint8_t *) data + |
| 1996 | wmi_handle->log_info.buf_offset_event)); |
| 1997 | qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock); |
| 1998 | } |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1999 | #endif |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2000 | qdf_spin_lock_bh(&wmi_handle->eventq_lock); |
| 2001 | qdf_nbuf_queue_add(&wmi_handle->event_queue, evt_buf); |
| 2002 | qdf_spin_unlock_bh(&wmi_handle->eventq_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2003 | schedule_work(&wmi_handle->rx_event_work); |
| 2004 | return; |
| 2005 | } |
| 2006 | |
| 2007 | /** |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2008 | * wmi_control_rx() - process fw events callbacks |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2009 | * @ctx: handle to wmi |
| 2010 | * @htc_packet: pointer to htc packet |
| 2011 | * |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2012 | * Return: none |
| 2013 | */ |
| 2014 | void wmi_control_rx(void *ctx, HTC_PACKET *htc_packet) |
| 2015 | { |
| 2016 | struct wmi_unified *wmi_handle = (struct wmi_unified *)ctx; |
| 2017 | wmi_buf_t evt_buf; |
| 2018 | uint32_t id; |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2019 | uint32_t idx = 0; |
| 2020 | enum wmi_rx_exec_ctx exec_ctx; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2021 | |
| 2022 | evt_buf = (wmi_buf_t) htc_packet->pPktContext; |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2023 | id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2024 | idx = wmi_unified_get_event_handler_ix(wmi_handle, id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2025 | if (qdf_unlikely(idx == A_ERROR)) { |
| 2026 | qdf_print |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2027 | ("%s :event handler is not registered: event id 0x%x\n", |
| 2028 | __func__, id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2029 | qdf_nbuf_free(evt_buf); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2030 | return; |
| 2031 | } |
Govind Singh | 813fdac | 2016-03-12 09:26:52 +0530 | [diff] [blame] | 2032 | qdf_spin_lock_bh(&wmi_handle->ctx_lock); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2033 | exec_ctx = wmi_handle->ctx[idx]; |
Govind Singh | 813fdac | 2016-03-12 09:26:52 +0530 | [diff] [blame] | 2034 | qdf_spin_unlock_bh(&wmi_handle->ctx_lock); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2035 | |
| 2036 | if (exec_ctx == WMI_RX_WORK_CTX) { |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2037 | wmi_process_fw_event_worker_thread_ctx |
| 2038 | (wmi_handle, htc_packet); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2039 | } else if (exec_ctx > WMI_RX_WORK_CTX) { |
| 2040 | wmi_process_fw_event_default_ctx |
| 2041 | (wmi_handle, htc_packet, exec_ctx); |
| 2042 | } else { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2043 | qdf_print("%s :Invalid event context %d\n", __func__, exec_ctx); |
| 2044 | qdf_nbuf_free(evt_buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2045 | } |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2046 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2047 | } |
| 2048 | |
| 2049 | /** |
| 2050 | * wmi_process_fw_event() - process any fw event |
| 2051 | * @wmi_handle: wmi handle |
| 2052 | * @evt_buf: fw event buffer |
| 2053 | * |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2054 | * This function process fw event in caller context |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2055 | * |
| 2056 | * Return: none |
| 2057 | */ |
| 2058 | void wmi_process_fw_event(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf) |
| 2059 | { |
| 2060 | __wmi_control_rx(wmi_handle, evt_buf); |
| 2061 | } |
| 2062 | |
| 2063 | /** |
| 2064 | * __wmi_control_rx() - process serialize wmi event callback |
| 2065 | * @wmi_handle: wmi handle |
| 2066 | * @evt_buf: fw event buffer |
| 2067 | * |
| 2068 | * Return: none |
| 2069 | */ |
| 2070 | void __wmi_control_rx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf) |
| 2071 | { |
| 2072 | uint32_t id; |
| 2073 | uint8_t *data; |
| 2074 | uint32_t len; |
| 2075 | void *wmi_cmd_struct_ptr = NULL; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2076 | #ifndef WMI_NON_TLV_SUPPORT |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2077 | int tlv_ok_status = 0; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2078 | #endif |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2079 | uint32_t idx = 0; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2080 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2081 | id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2082 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2083 | if (qdf_nbuf_pull_head(evt_buf, sizeof(WMI_CMD_HDR)) == NULL) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2084 | goto end; |
| 2085 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2086 | data = qdf_nbuf_data(evt_buf); |
| 2087 | len = qdf_nbuf_len(evt_buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2088 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2089 | #ifndef WMI_NON_TLV_SUPPORT |
| 2090 | if (wmi_handle->target_type == WMI_TLV_TARGET) { |
| 2091 | /* Validate and pad(if necessary) the TLVs */ |
| 2092 | tlv_ok_status = |
| 2093 | wmitlv_check_and_pad_event_tlvs(wmi_handle->scn_handle, |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2094 | data, len, id, |
| 2095 | &wmi_cmd_struct_ptr); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2096 | if (tlv_ok_status != 0) { |
| 2097 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
| 2098 | "%s: Error: id=0x%d, wmitlv check status=%d\n", |
| 2099 | __func__, id, tlv_ok_status); |
| 2100 | goto end; |
| 2101 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2102 | } |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2103 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2104 | |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2105 | idx = wmi_unified_get_event_handler_ix(wmi_handle, id); |
| 2106 | if (idx == A_ERROR) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2107 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2108 | "%s : event handler is not registered: event id 0x%x\n", |
| 2109 | __func__, id); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2110 | goto end; |
| 2111 | } |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2112 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2113 | if (wmi_handle->log_info.wmi_logging_enable) { |
| 2114 | qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock); |
| 2115 | /* Exclude 4 bytes of TLV header */ |
| 2116 | if (wmi_handle->log_info.is_management_record(id)) { |
| 2117 | WMI_MGMT_EVENT_RECORD(wmi_handle, id, ((uint8_t *) data |
| 2118 | + wmi_handle->log_info.buf_offset_event)); |
| 2119 | } else { |
| 2120 | WMI_EVENT_RECORD(wmi_handle, id, ((uint8_t *) data + |
| 2121 | wmi_handle->log_info.buf_offset_event)); |
| 2122 | } |
| 2123 | qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2124 | } |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2125 | #endif |
| 2126 | /* Call the WMI registered event handler */ |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2127 | if (wmi_handle->target_type == WMI_TLV_TARGET) |
| 2128 | wmi_handle->event_handler[idx] (wmi_handle->scn_handle, |
| 2129 | wmi_cmd_struct_ptr, len); |
| 2130 | else |
| 2131 | wmi_handle->event_handler[idx] (wmi_handle->scn_handle, |
| 2132 | data, len); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2133 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2134 | end: |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2135 | /* Free event buffer and allocated event tlv */ |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2136 | #ifndef WMI_NON_TLV_SUPPORT |
| 2137 | if (wmi_handle->target_type == WMI_TLV_TARGET) |
| 2138 | wmitlv_free_allocated_event_tlvs(id, &wmi_cmd_struct_ptr); |
| 2139 | #endif |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 2140 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2141 | qdf_nbuf_free(evt_buf); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2142 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2143 | } |
| 2144 | |
| 2145 | /** |
| 2146 | * wmi_rx_event_work() - process rx event in rx work queue context |
| 2147 | * @work: rx work queue struct |
| 2148 | * |
| 2149 | * This function process any fw event to serialize it through rx worker thread. |
| 2150 | * |
| 2151 | * Return: none |
| 2152 | */ |
| 2153 | void wmi_rx_event_work(struct work_struct *work) |
| 2154 | { |
| 2155 | struct wmi_unified *wmi = container_of(work, struct wmi_unified, |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2156 | rx_event_work); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2157 | wmi_buf_t buf; |
| 2158 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2159 | qdf_spin_lock_bh(&wmi->eventq_lock); |
| 2160 | buf = qdf_nbuf_queue_remove(&wmi->event_queue); |
| 2161 | qdf_spin_unlock_bh(&wmi->eventq_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2162 | while (buf) { |
| 2163 | __wmi_control_rx(wmi, buf); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2164 | qdf_spin_lock_bh(&wmi->eventq_lock); |
| 2165 | buf = qdf_nbuf_queue_remove(&wmi->event_queue); |
| 2166 | qdf_spin_unlock_bh(&wmi->eventq_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2167 | } |
| 2168 | } |
| 2169 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2170 | #ifdef FEATURE_RUNTIME_PM |
| 2171 | /** |
| 2172 | * wmi_runtime_pm_init() - initialize runtime pm wmi variables |
| 2173 | * @wmi_handle: wmi context |
| 2174 | */ |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2175 | static void wmi_runtime_pm_init(struct wmi_unified *wmi_handle) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2176 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2177 | qdf_atomic_init(&wmi_handle->runtime_pm_inprogress); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2178 | } |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2179 | |
| 2180 | /** |
| 2181 | * wmi_set_runtime_pm_inprogress() - set runtime pm progress flag |
| 2182 | * @wmi_handle: wmi context |
| 2183 | * @val: runtime pm progress flag |
| 2184 | */ |
| 2185 | void wmi_set_runtime_pm_inprogress(wmi_unified_t wmi_handle, A_BOOL val) |
| 2186 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2187 | qdf_atomic_set(&wmi_handle->runtime_pm_inprogress, val); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2188 | } |
| 2189 | |
| 2190 | /** |
| 2191 | * wmi_get_runtime_pm_inprogress() - get runtime pm progress flag |
| 2192 | * @wmi_handle: wmi context |
| 2193 | */ |
| 2194 | inline bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle) |
| 2195 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2196 | return qdf_atomic_read(&wmi_handle->runtime_pm_inprogress); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2197 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2198 | #else |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2199 | static void wmi_runtime_pm_init(struct wmi_unified *wmi_handle) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2200 | { |
| 2201 | } |
| 2202 | #endif |
| 2203 | |
| 2204 | /** |
| 2205 | * wmi_unified_attach() - attach for unified WMI |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 2206 | * @scn_handle: handle to SCN |
| 2207 | * @osdev: OS device context |
| 2208 | * @target_type: TLV or not-TLV based target |
| 2209 | * @use_cookie: cookie based allocation enabled/disabled |
| 2210 | * @ops: umac rx callbacks |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2211 | * |
| 2212 | * @Return: wmi handle. |
| 2213 | */ |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 2214 | void *wmi_unified_attach(void *scn_handle, |
| 2215 | osdev_t osdev, enum wmi_target_type target_type, |
Govind Singh | 5eb5153 | 2016-03-09 11:34:12 +0530 | [diff] [blame] | 2216 | bool use_cookie, struct wmi_rx_ops *rx_ops) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2217 | { |
| 2218 | struct wmi_unified *wmi_handle; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2219 | |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 2220 | #ifdef CONFIG_MCL |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2221 | wmi_handle = |
| 2222 | (struct wmi_unified *)os_malloc(NULL, |
| 2223 | sizeof(struct wmi_unified), |
| 2224 | GFP_ATOMIC); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2225 | #else |
| 2226 | wmi_handle = |
| 2227 | (struct wmi_unified *) qdf_mem_malloc( |
| 2228 | sizeof(struct wmi_unified)); |
| 2229 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2230 | if (wmi_handle == NULL) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2231 | qdf_print("allocation of wmi handle failed %zu\n", |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2232 | sizeof(struct wmi_unified)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2233 | return NULL; |
| 2234 | } |
| 2235 | OS_MEMZERO(wmi_handle, sizeof(struct wmi_unified)); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2236 | wmi_handle->scn_handle = scn_handle; |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2237 | qdf_atomic_init(&wmi_handle->pending_cmds); |
| 2238 | qdf_atomic_init(&wmi_handle->is_target_suspended); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2239 | wmi_runtime_pm_init(wmi_handle); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2240 | qdf_spinlock_create(&wmi_handle->eventq_lock); |
| 2241 | qdf_nbuf_queue_init(&wmi_handle->event_queue); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2242 | INIT_WORK(&wmi_handle->rx_event_work, wmi_rx_event_work); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2243 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2244 | if (QDF_STATUS_SUCCESS == wmi_log_init(wmi_handle)) { |
| 2245 | qdf_spinlock_create(&wmi_handle->log_info.wmi_record_lock); |
| 2246 | wmi_debugfs_init(wmi_handle); |
| 2247 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2248 | #endif |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 2249 | /* Attach mc_thread context processing function */ |
Govind Singh | 5eb5153 | 2016-03-09 11:34:12 +0530 | [diff] [blame] | 2250 | wmi_handle->rx_ops.wma_process_fw_event_handler_cbk = |
| 2251 | rx_ops->wma_process_fw_event_handler_cbk; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2252 | wmi_handle->target_type = target_type; |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 2253 | if (target_type == WMI_TLV_TARGET) |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2254 | wmi_tlv_attach(wmi_handle); |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 2255 | else |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2256 | wmi_non_tlv_attach(wmi_handle); |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 2257 | /* Assign target cookie capablity */ |
| 2258 | wmi_handle->use_cookie = use_cookie; |
| 2259 | wmi_handle->osdev = osdev; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2260 | wmi_handle->wmi_stopinprogress = 0; |
Govind Singh | 813fdac | 2016-03-12 09:26:52 +0530 | [diff] [blame] | 2261 | qdf_spinlock_create(&wmi_handle->ctx_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2262 | |
| 2263 | return wmi_handle; |
| 2264 | } |
| 2265 | |
| 2266 | /** |
| 2267 | * wmi_unified_detach() - detach for unified WMI |
| 2268 | * |
| 2269 | * @wmi_handle : handle to wmi. |
| 2270 | * |
| 2271 | * @Return: none. |
| 2272 | */ |
| 2273 | void wmi_unified_detach(struct wmi_unified *wmi_handle) |
| 2274 | { |
| 2275 | wmi_buf_t buf; |
| 2276 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2277 | cancel_work_sync(&wmi_handle->rx_event_work); |
Rajeev Kumar | ae91c40 | 2016-05-25 16:07:23 -0700 | [diff] [blame] | 2278 | |
Govind Singh | 06c1839 | 2016-06-10 10:33:19 +0530 | [diff] [blame] | 2279 | wmi_debugfs_remove(wmi_handle); |
Rajeev Kumar | ae91c40 | 2016-05-25 16:07:23 -0700 | [diff] [blame] | 2280 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2281 | buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2282 | while (buf) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2283 | qdf_nbuf_free(buf); |
| 2284 | buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2285 | } |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2286 | |
| 2287 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2288 | wmi_log_buffer_free(wmi_handle); |
| 2289 | #endif |
| 2290 | |
Govind Singh | 20e7a06 | 2016-05-26 18:15:36 +0530 | [diff] [blame] | 2291 | qdf_spinlock_destroy(&wmi_handle->eventq_lock); |
Govind Singh | 813fdac | 2016-03-12 09:26:52 +0530 | [diff] [blame] | 2292 | qdf_spinlock_destroy(&wmi_handle->ctx_lock); |
Rajeev Kumar | fec0401 | 2016-06-10 14:27:46 -0700 | [diff] [blame] | 2293 | OS_FREE(wmi_handle); |
| 2294 | wmi_handle = NULL; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2295 | } |
| 2296 | |
| 2297 | /** |
| 2298 | * wmi_unified_remove_work() - detach for WMI work |
| 2299 | * @wmi_handle: handle to WMI |
| 2300 | * |
| 2301 | * A function that does not fully detach WMI, but just remove work |
| 2302 | * queue items associated with it. This is used to make sure that |
| 2303 | * before any other processing code that may destroy related contexts |
| 2304 | * (HTC, etc), work queue processing on WMI has already been stopped. |
| 2305 | * |
| 2306 | * Return: None |
| 2307 | */ |
| 2308 | void |
| 2309 | wmi_unified_remove_work(struct wmi_unified *wmi_handle) |
| 2310 | { |
| 2311 | wmi_buf_t buf; |
| 2312 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2313 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO, |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2314 | "Enter: %s", __func__); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2315 | cancel_work_sync(&wmi_handle->rx_event_work); |
| 2316 | qdf_spin_lock_bh(&wmi_handle->eventq_lock); |
| 2317 | buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2318 | while (buf) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2319 | qdf_nbuf_free(buf); |
| 2320 | buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2321 | } |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2322 | qdf_spin_unlock_bh(&wmi_handle->eventq_lock); |
| 2323 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO, |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2324 | "Done: %s", __func__); |
| 2325 | } |
| 2326 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2327 | /** |
| 2328 | * wmi_htc_tx_complete() - Process htc tx completion |
| 2329 | * |
| 2330 | * @ctx: handle to wmi |
| 2331 | * @htc_packet: pointer to htc packet |
| 2332 | * |
| 2333 | * @Return: none. |
| 2334 | */ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2335 | void wmi_htc_tx_complete(void *ctx, HTC_PACKET *htc_pkt) |
| 2336 | { |
| 2337 | struct wmi_unified *wmi_handle = (struct wmi_unified *)ctx; |
| 2338 | wmi_buf_t wmi_cmd_buf = GET_HTC_PACKET_NET_BUF_CONTEXT(htc_pkt); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2339 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2340 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
| 2341 | uint32_t cmd_id; |
| 2342 | #endif |
| 2343 | |
| 2344 | ASSERT(wmi_cmd_buf); |
| 2345 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2346 | if (wmi_handle->log_info.wmi_logging_enable) { |
| 2347 | cmd_id = WMI_GET_FIELD(qdf_nbuf_data(wmi_cmd_buf), |
| 2348 | WMI_CMD_HDR, COMMANDID); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2349 | |
Houston Hoffman | 0a0b2d0 | 2016-06-08 20:00:03 -0700 | [diff] [blame] | 2350 | WMI_LOGD("Sent WMI command:%s command_id:0x%x over dma and recieved tx complete interupt", |
| 2351 | wmi_id_to_name(cmd_id), cmd_id); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2352 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2353 | qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2354 | /* Record 16 bytes of WMI cmd tx complete data |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2355 | - exclude TLV and WMI headers */ |
| 2356 | if (wmi_handle->log_info.is_management_record(cmd_id)) { |
| 2357 | WMI_MGMT_COMMAND_TX_CMP_RECORD(wmi_handle, cmd_id, |
| 2358 | ((uint32_t *) qdf_nbuf_data(wmi_cmd_buf) + |
| 2359 | wmi_handle->log_info.buf_offset_command)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2360 | } else { |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2361 | WMI_COMMAND_TX_CMP_RECORD(wmi_handle, cmd_id, |
| 2362 | ((uint32_t *) qdf_nbuf_data(wmi_cmd_buf) + |
| 2363 | wmi_handle->log_info.buf_offset_command)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2364 | } |
| 2365 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2366 | qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock); |
| 2367 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2368 | #endif |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2369 | qdf_nbuf_free(wmi_cmd_buf); |
| 2370 | qdf_mem_free(htc_pkt); |
| 2371 | qdf_atomic_dec(&wmi_handle->pending_cmds); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2372 | } |
| 2373 | |
| 2374 | /** |
| 2375 | * wmi_get_host_credits() - WMI API to get updated host_credits |
| 2376 | * |
| 2377 | * @wmi_handle: handle to WMI. |
| 2378 | * |
| 2379 | * @Return: updated host_credits. |
| 2380 | */ |
| 2381 | int |
| 2382 | wmi_unified_connect_htc_service(struct wmi_unified *wmi_handle, |
| 2383 | void *htc_handle) |
| 2384 | { |
| 2385 | |
| 2386 | int status; |
| 2387 | HTC_SERVICE_CONNECT_RESP response; |
| 2388 | HTC_SERVICE_CONNECT_REQ connect; |
| 2389 | |
| 2390 | OS_MEMZERO(&connect, sizeof(connect)); |
| 2391 | OS_MEMZERO(&response, sizeof(response)); |
| 2392 | |
| 2393 | /* meta data is unused for now */ |
| 2394 | connect.pMetaData = NULL; |
| 2395 | connect.MetaDataLength = 0; |
| 2396 | /* these fields are the same for all service endpoints */ |
| 2397 | connect.EpCallbacks.pContext = wmi_handle; |
| 2398 | connect.EpCallbacks.EpTxCompleteMultiple = |
| 2399 | NULL /* Control path completion ar6000_tx_complete */; |
| 2400 | connect.EpCallbacks.EpRecv = wmi_control_rx /* Control path rx */; |
| 2401 | connect.EpCallbacks.EpRecvRefill = NULL /* ar6000_rx_refill */; |
| 2402 | connect.EpCallbacks.EpSendFull = NULL /* ar6000_tx_queue_full */; |
| 2403 | connect.EpCallbacks.EpTxComplete = |
| 2404 | wmi_htc_tx_complete /* ar6000_tx_queue_full */; |
| 2405 | |
| 2406 | /* connect to control service */ |
| 2407 | connect.service_id = WMI_CONTROL_SVC; |
| 2408 | status = htc_connect_service(htc_handle, &connect, |
| 2409 | &response); |
| 2410 | |
| 2411 | if (status != EOK) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2412 | qdf_print |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2413 | ("Failed to connect to WMI CONTROL service status:%d \n", |
| 2414 | status); |
| 2415 | return status; |
| 2416 | } |
| 2417 | wmi_handle->wmi_endpoint_id = response.Endpoint; |
| 2418 | wmi_handle->htc_handle = htc_handle; |
| 2419 | wmi_handle->max_msg_len = response.MaxMsgLength; |
| 2420 | |
| 2421 | return EOK; |
| 2422 | } |
| 2423 | |
| 2424 | /** |
| 2425 | * wmi_get_host_credits() - WMI API to get updated host_credits |
| 2426 | * |
| 2427 | * @wmi_handle: handle to WMI. |
| 2428 | * |
| 2429 | * @Return: updated host_credits. |
| 2430 | */ |
| 2431 | int wmi_get_host_credits(wmi_unified_t wmi_handle) |
| 2432 | { |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2433 | int host_credits = 0; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2434 | |
| 2435 | htc_get_control_endpoint_tx_host_credits(wmi_handle->htc_handle, |
| 2436 | &host_credits); |
| 2437 | return host_credits; |
| 2438 | } |
| 2439 | |
| 2440 | /** |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2441 | * wmi_get_pending_cmds() - WMI API to get WMI Pending Commands in the HTC |
| 2442 | * queue |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2443 | * |
| 2444 | * @wmi_handle: handle to WMI. |
| 2445 | * |
| 2446 | * @Return: Pending Commands in the HTC queue. |
| 2447 | */ |
| 2448 | int wmi_get_pending_cmds(wmi_unified_t wmi_handle) |
| 2449 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2450 | return qdf_atomic_read(&wmi_handle->pending_cmds); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2451 | } |
| 2452 | |
| 2453 | /** |
| 2454 | * wmi_set_target_suspend() - WMI API to set target suspend state |
| 2455 | * |
| 2456 | * @wmi_handle: handle to WMI. |
| 2457 | * @val: suspend state boolean. |
| 2458 | * |
| 2459 | * @Return: none. |
| 2460 | */ |
| 2461 | void wmi_set_target_suspend(wmi_unified_t wmi_handle, A_BOOL val) |
| 2462 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2463 | qdf_atomic_set(&wmi_handle->is_target_suspended, val); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2464 | } |
| 2465 | |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 2466 | #ifndef CONFIG_MCL |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2467 | /** |
| 2468 | * API to flush all the previous packets associated with the wmi endpoint |
| 2469 | * |
| 2470 | * @param wmi_handle : handle to WMI. |
| 2471 | */ |
| 2472 | void |
| 2473 | wmi_flush_endpoint(wmi_unified_t wmi_handle) |
| 2474 | { |
| 2475 | htc_flush_endpoint(wmi_handle->htc_handle, |
| 2476 | wmi_handle->wmi_endpoint_id, 0); |
| 2477 | } |
| 2478 | |
| 2479 | /** |
| 2480 | * generic function to block unified WMI command |
| 2481 | * @param wmi_handle : handle to WMI. |
| 2482 | * @return 0 on success and -ve on failure. |
| 2483 | */ |
| 2484 | int |
| 2485 | wmi_stop(wmi_unified_t wmi_handle) |
| 2486 | { |
| 2487 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO, |
| 2488 | "WMI Stop\n"); |
| 2489 | wmi_handle->wmi_stopinprogress = 1; |
| 2490 | return 0; |
| 2491 | } |
| 2492 | #endif |