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