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