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