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