Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1 | /* |
Rakesh Pillai | 0511046 | 2017-12-27 14:08:59 +0530 | [diff] [blame] | 2 | * Copyright (c) 2015-2018 The Linux Foundation. All rights reserved. |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 3 | * |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
| 19 | /* |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 20 | * Host WMI unified implementation |
| 21 | */ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 22 | #include "htc_api.h" |
| 23 | #include "htc_api.h" |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 24 | #include "wmi_unified_priv.h" |
Amar Singhal | 66d1ed5 | 2018-06-26 16:45:54 -0700 | [diff] [blame] | 25 | #include "wmi_unified_api.h" |
Pratik Gandhi | 67da1bb | 2018-01-30 19:05:41 +0530 | [diff] [blame] | 26 | #include "qdf_module.h" |
Venkat Karthik Kantamneni | bc8d329 | 2018-05-21 19:13:02 +0530 | [diff] [blame] | 27 | #ifdef WMI_EXT_DBG |
| 28 | #include "qdf_list.h" |
| 29 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 30 | |
Kiran Venkatappa | 23e6e08 | 2016-11-11 16:49:40 +0530 | [diff] [blame] | 31 | #ifndef WMI_NON_TLV_SUPPORT |
| 32 | #include "wmi_tlv_helper.h" |
| 33 | #endif |
| 34 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 35 | #include <linux/debugfs.h> |
| 36 | |
Venkat Karthik Kantamneni | bc8d329 | 2018-05-21 19:13:02 +0530 | [diff] [blame] | 37 | #ifdef WMI_EXT_DBG |
| 38 | |
| 39 | /** |
| 40 | * wmi_ext_dbg_msg_enqueue() - enqueue wmi message |
| 41 | * |
| 42 | * @wmi_handle: wmi handler |
| 43 | * |
| 44 | * Return: size of wmi message queue after enqueue |
| 45 | */ |
| 46 | static uint32_t wmi_ext_dbg_msg_enqueue(struct wmi_unified *wmi_handle, |
| 47 | struct wmi_ext_dbg_msg *msg) |
| 48 | { |
| 49 | uint32_t list_size; |
| 50 | |
| 51 | qdf_spinlock_acquire(&wmi_handle->wmi_ext_dbg_msg_queue_lock); |
| 52 | qdf_list_insert_back_size(&wmi_handle->wmi_ext_dbg_msg_queue, |
| 53 | &msg->node, &list_size); |
| 54 | qdf_spinlock_release(&wmi_handle->wmi_ext_dbg_msg_queue_lock); |
| 55 | |
| 56 | return list_size; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * wmi_ext_dbg_msg_dequeue() - dequeue wmi message |
| 61 | * |
| 62 | * @wmi_handle: wmi handler |
| 63 | * |
| 64 | * Return: wmi msg on success else NULL |
| 65 | */ |
| 66 | static struct wmi_ext_dbg_msg *wmi_ext_dbg_msg_dequeue(struct wmi_unified |
| 67 | *wmi_handle) |
| 68 | { |
| 69 | qdf_list_node_t *list_node = NULL; |
| 70 | |
| 71 | qdf_spinlock_acquire(&wmi_handle->wmi_ext_dbg_msg_queue_lock); |
| 72 | qdf_list_remove_front(&wmi_handle->wmi_ext_dbg_msg_queue, &list_node); |
| 73 | qdf_spinlock_release(&wmi_handle->wmi_ext_dbg_msg_queue_lock); |
| 74 | |
| 75 | if (!list_node) |
| 76 | return NULL; |
| 77 | |
| 78 | return qdf_container_of(list_node, struct wmi_ext_dbg_msg, node); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * wmi_ext_dbg_msg_record() - record wmi messages |
| 83 | * |
| 84 | * @wmi_handle: wmi handler |
| 85 | * @buf: wmi message buffer |
| 86 | * @len: wmi message length |
| 87 | * @type: wmi message type |
| 88 | * |
| 89 | * Return: QDF_STATUS_SUCCESS on successful recording else failure. |
| 90 | */ |
| 91 | static QDF_STATUS wmi_ext_dbg_msg_record(struct wmi_unified *wmi_handle, |
| 92 | uint8_t *buf, uint32_t len, |
| 93 | enum WMI_MSG_TYPE type) |
| 94 | { |
| 95 | struct wmi_ext_dbg_msg *msg; |
| 96 | uint32_t list_size; |
| 97 | |
| 98 | msg = wmi_ext_dbg_msg_get(len); |
| 99 | if (!msg) |
| 100 | return QDF_STATUS_E_NOMEM; |
| 101 | |
| 102 | msg->len = len; |
| 103 | msg->type = type; |
| 104 | qdf_mem_copy(msg->buf, buf, len); |
| 105 | msg->ts = qdf_get_log_timestamp(); |
| 106 | list_size = wmi_ext_dbg_msg_enqueue(wmi_handle, msg); |
| 107 | |
| 108 | if (list_size >= wmi_handle->wmi_ext_dbg_msg_queue_size) { |
| 109 | msg = wmi_ext_dbg_msg_dequeue(wmi_handle); |
| 110 | wmi_ext_dbg_msg_put(msg); |
| 111 | } |
| 112 | |
| 113 | return QDF_STATUS_SUCCESS; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * wmi_ext_dbg_msg_cmd_record() - record wmi command messages |
| 118 | * |
| 119 | * @wmi_handle: wmi handler |
| 120 | * @buf: wmi command buffer |
| 121 | * @len: wmi command message length |
| 122 | * |
| 123 | * Return: QDF_STATUS_SUCCESS on successful recording else failure. |
| 124 | */ |
| 125 | static QDF_STATUS wmi_ext_dbg_msg_cmd_record(struct wmi_unified *wmi_handle, |
| 126 | uint8_t *buf, uint32_t len) |
| 127 | { |
| 128 | return wmi_ext_dbg_msg_record(wmi_handle, buf, len, |
| 129 | WMI_MSG_TYPE_CMD); |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * wmi_ext_dbg_msg_event_record() - record wmi event messages |
| 134 | * |
| 135 | * @wmi_handle: wmi handler |
| 136 | * @buf: wmi event buffer |
| 137 | * @len: wmi event message length |
| 138 | * |
| 139 | * Return: QDF_STATUS_SUCCESS on successful recording else failure. |
| 140 | */ |
| 141 | static QDF_STATUS wmi_ext_dbg_msg_event_record(struct wmi_unified *wmi_handle, |
| 142 | uint8_t *buf, uint32_t len) |
| 143 | { |
| 144 | uint32_t id; |
| 145 | |
| 146 | id = WMI_GET_FIELD(buf, WMI_CMD_HDR, COMMANDID); |
Karthik Kantamneni | fa613b4 | 2018-09-17 17:53:24 +0530 | [diff] [blame] | 147 | if (id != wmi_handle->wmi_events[wmi_diag_event_id]) |
Venkat Karthik Kantamneni | bc8d329 | 2018-05-21 19:13:02 +0530 | [diff] [blame] | 148 | return wmi_ext_dbg_msg_record(wmi_handle, buf, len, |
| 149 | WMI_MSG_TYPE_EVENT); |
| 150 | |
| 151 | return QDF_STATUS_SUCCESS; |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * wmi_ext_dbg_msg_queue_init() - create debugfs queue and associated lock |
| 156 | * |
| 157 | * @wmi_handle: wmi handler |
| 158 | * |
| 159 | * Return: none |
| 160 | */ |
| 161 | static void wmi_ext_dbg_msg_queue_init(struct wmi_unified *wmi_handle) |
| 162 | { |
| 163 | qdf_list_create(&wmi_handle->wmi_ext_dbg_msg_queue, |
| 164 | wmi_handle->wmi_ext_dbg_msg_queue_size); |
| 165 | qdf_spinlock_create(&wmi_handle->wmi_ext_dbg_msg_queue_lock); |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * wmi_ext_dbg_msg_queue_deinit() - destroy debugfs queue and associated lock |
| 170 | * |
| 171 | * @wmi_handle: wmi handler |
| 172 | * |
| 173 | * Return: none |
| 174 | */ |
| 175 | static void wmi_ext_dbg_msg_queue_deinit(struct wmi_unified *wmi_handle) |
| 176 | { |
| 177 | qdf_list_destroy(&wmi_handle->wmi_ext_dbg_msg_queue); |
| 178 | qdf_spinlock_destroy(&wmi_handle->wmi_ext_dbg_msg_queue_lock); |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * wmi_ext_dbg_msg_show() - debugfs function to display whole content of |
| 183 | * wmi command/event messages including headers. |
| 184 | * |
| 185 | * @file: qdf debugfs file handler |
| 186 | * @arg: pointer to wmi handler |
| 187 | * |
| 188 | * Return: QDF_STATUS_SUCCESS if all the messages are shown successfully, |
| 189 | * else QDF_STATUS_E_AGAIN if more data to show. |
| 190 | */ |
| 191 | static QDF_STATUS wmi_ext_dbg_msg_show(qdf_debugfs_file_t file, void *arg) |
| 192 | { |
| 193 | struct wmi_unified *wmi_handle = (struct wmi_unified *)arg; |
| 194 | struct wmi_ext_dbg_msg *msg; |
| 195 | uint64_t secs, usecs; |
| 196 | |
| 197 | msg = wmi_ext_dbg_msg_dequeue(wmi_handle); |
| 198 | if (!msg) |
| 199 | return QDF_STATUS_SUCCESS; |
| 200 | |
| 201 | qdf_debugfs_printf(file, "%s: 0x%x\n", |
| 202 | msg->type == WMI_MSG_TYPE_CMD ? "COMMAND" : |
| 203 | "EVENT", WMI_GET_FIELD(msg->buf, WMI_CMD_HDR, |
| 204 | COMMANDID)); |
| 205 | qdf_log_timestamp_to_secs(msg->ts, &secs, &usecs); |
| 206 | qdf_debugfs_printf(file, "Time: %llu.%llu\n", secs, usecs); |
| 207 | qdf_debugfs_printf(file, "Length:%d\n", msg->len); |
| 208 | qdf_debugfs_hexdump(file, msg->buf, msg->len, |
| 209 | WMI_EXT_DBG_DUMP_ROW_SIZE, |
| 210 | WMI_EXT_DBG_DUMP_GROUP_SIZE); |
| 211 | qdf_debugfs_printf(file, "\n"); |
| 212 | |
| 213 | if (qdf_debugfs_overflow(file)) { |
| 214 | qdf_spinlock_acquire(&wmi_handle->wmi_ext_dbg_msg_queue_lock); |
| 215 | qdf_list_insert_front(&wmi_handle->wmi_ext_dbg_msg_queue, |
| 216 | &msg->node); |
| 217 | qdf_spinlock_release(&wmi_handle->wmi_ext_dbg_msg_queue_lock); |
| 218 | |
| 219 | } else { |
| 220 | wmi_ext_dbg_msg_put(msg); |
| 221 | } |
| 222 | |
| 223 | return QDF_STATUS_E_AGAIN; |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * wmi_ext_dbg_msg_write() - debugfs write not supported |
| 228 | * |
| 229 | * @priv: private data |
| 230 | * @buf: received data buffer |
| 231 | * @len: length of received buffer |
| 232 | * |
| 233 | * Return: QDF_STATUS_E_NOSUPPORT. |
| 234 | */ |
| 235 | static QDF_STATUS wmi_ext_dbg_msg_write(void *priv, const char *buf, |
| 236 | qdf_size_t len) |
| 237 | { |
| 238 | return QDF_STATUS_E_NOSUPPORT; |
| 239 | } |
| 240 | |
| 241 | static struct qdf_debugfs_fops wmi_ext_dbgfs_ops = { |
| 242 | .show = wmi_ext_dbg_msg_show, |
| 243 | .write = wmi_ext_dbg_msg_write, |
| 244 | .priv = NULL, |
| 245 | }; |
| 246 | |
| 247 | /** |
| 248 | * wmi_ext_debugfs_init() - init debugfs items for extended wmi dump. |
| 249 | * |
| 250 | * @wmi_handle: wmi handler |
| 251 | * |
| 252 | * Return: QDF_STATUS_SUCCESS if debugfs is initialized else |
| 253 | * QDF_STATUS_E_FAILURE |
| 254 | */ |
| 255 | static QDF_STATUS wmi_ext_dbgfs_init(struct wmi_unified *wmi_handle) |
| 256 | { |
| 257 | qdf_dentry_t dentry; |
| 258 | |
| 259 | dentry = qdf_debugfs_create_dir(WMI_EXT_DBG_DIR, NULL); |
| 260 | if (!dentry) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 261 | WMI_LOGE("error while creating extended wmi debugfs dir"); |
Venkat Karthik Kantamneni | bc8d329 | 2018-05-21 19:13:02 +0530 | [diff] [blame] | 262 | return QDF_STATUS_E_FAILURE; |
| 263 | } |
| 264 | |
| 265 | wmi_ext_dbgfs_ops.priv = wmi_handle; |
| 266 | if (!qdf_debugfs_create_file(WMI_EXT_DBG_FILE, WMI_EXT_DBG_FILE_PERM, |
| 267 | dentry, &wmi_ext_dbgfs_ops)) { |
| 268 | qdf_debugfs_remove_dir(dentry); |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 269 | WMI_LOGE("error while creating extended wmi debugfs file"); |
Venkat Karthik Kantamneni | bc8d329 | 2018-05-21 19:13:02 +0530 | [diff] [blame] | 270 | return QDF_STATUS_E_FAILURE; |
| 271 | } |
| 272 | |
| 273 | wmi_handle->wmi_ext_dbg_dentry = dentry; |
| 274 | wmi_handle->wmi_ext_dbg_msg_queue_size = WMI_EXT_DBG_QUEUE_SIZE; |
| 275 | wmi_ext_dbg_msg_queue_init(wmi_handle); |
| 276 | |
| 277 | return QDF_STATUS_SUCCESS; |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * wmi_ext_debugfs_deinit() - cleanup/deinit debugfs items of extended wmi dump. |
| 282 | * |
| 283 | * @wmi_handle: wmi handler |
| 284 | * |
| 285 | * Return: QDF_STATUS_SUCCESS if cleanup is successful |
| 286 | */ |
| 287 | static QDF_STATUS wmi_ext_dbgfs_deinit(struct wmi_unified *wmi_handle) |
| 288 | { |
| 289 | struct wmi_ext_dbg_msg *msg; |
| 290 | |
| 291 | while ((msg = wmi_ext_dbg_msg_dequeue(wmi_handle))) |
| 292 | wmi_ext_dbg_msg_put(msg); |
| 293 | |
| 294 | wmi_ext_dbg_msg_queue_deinit(wmi_handle); |
| 295 | qdf_debugfs_remove_dir_recursive(wmi_handle->wmi_ext_dbg_dentry); |
| 296 | |
| 297 | return QDF_STATUS_SUCCESS; |
| 298 | } |
| 299 | |
| 300 | #endif /*WMI_EXT_DBG */ |
| 301 | |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 302 | /* This check for CONFIG_WIN temporary added due to redeclaration compilation |
| 303 | error in MCL. Error is caused due to inclusion of wmi.h in wmi_unified_api.h |
| 304 | which gets included here through ol_if_athvar.h. Eventually it is expected that |
| 305 | wmi.h will be removed from wmi_unified_api.h after cleanup, which will need |
| 306 | WMI_CMD_HDR to be defined here. */ |
| 307 | #ifdef CONFIG_WIN |
| 308 | /* Copied from wmi.h */ |
| 309 | #undef MS |
| 310 | #define MS(_v, _f) (((_v) & _f##_MASK) >> _f##_LSB) |
| 311 | #undef SM |
| 312 | #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK) |
| 313 | #undef WO |
| 314 | #define WO(_f) ((_f##_OFFSET) >> 2) |
| 315 | |
| 316 | #undef GET_FIELD |
Vivek | c582309 | 2018-03-22 23:27:21 +0530 | [diff] [blame] | 317 | #define GET_FIELD(_addr, _f) MS(*((uint32_t *)(_addr) + WO(_f)), _f) |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 318 | #undef SET_FIELD |
| 319 | #define SET_FIELD(_addr, _f, _val) \ |
Vivek | c582309 | 2018-03-22 23:27:21 +0530 | [diff] [blame] | 320 | (*((uint32_t *)(_addr) + WO(_f)) = \ |
| 321 | (*((uint32_t *)(_addr) + WO(_f)) & ~_f##_MASK) | SM(_val, _f)) |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 322 | |
| 323 | #define WMI_GET_FIELD(_msg_buf, _msg_type, _f) \ |
| 324 | GET_FIELD(_msg_buf, _msg_type ## _ ## _f) |
| 325 | |
| 326 | #define WMI_SET_FIELD(_msg_buf, _msg_type, _f, _val) \ |
| 327 | SET_FIELD(_msg_buf, _msg_type ## _ ## _f, _val) |
| 328 | |
| 329 | #define WMI_EP_APASS 0x0 |
| 330 | #define WMI_EP_LPASS 0x1 |
| 331 | #define WMI_EP_SENSOR 0x2 |
| 332 | |
| 333 | /* |
| 334 | * * Control Path |
| 335 | * */ |
| 336 | typedef PREPACK struct { |
Vivek | c582309 | 2018-03-22 23:27:21 +0530 | [diff] [blame] | 337 | uint32_t commandId:24, |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 338 | reserved:2, /* used for WMI endpoint ID */ |
| 339 | plt_priv:6; /* platform private */ |
| 340 | } POSTPACK WMI_CMD_HDR; /* used for commands and events */ |
| 341 | |
| 342 | #define WMI_CMD_HDR_COMMANDID_LSB 0 |
| 343 | #define WMI_CMD_HDR_COMMANDID_MASK 0x00ffffff |
| 344 | #define WMI_CMD_HDR_COMMANDID_OFFSET 0x00000000 |
| 345 | #define WMI_CMD_HDR_WMI_ENDPOINTID_MASK 0x03000000 |
| 346 | #define WMI_CMD_HDR_WMI_ENDPOINTID_OFFSET 24 |
| 347 | #define WMI_CMD_HDR_PLT_PRIV_LSB 24 |
| 348 | #define WMI_CMD_HDR_PLT_PRIV_MASK 0xff000000 |
| 349 | #define WMI_CMD_HDR_PLT_PRIV_OFFSET 0x00000000 |
| 350 | /* end of copy wmi.h */ |
| 351 | #endif /* CONFIG_WIN */ |
| 352 | |
Rachit Kankane | 799d2c9 | 2018-02-19 11:28:10 +0530 | [diff] [blame] | 353 | #define WMI_MIN_HEAD_ROOM 64 |
| 354 | |
Rakshith Suresh Patkar | 9eb15ee | 2018-09-12 16:51:30 +0530 | [diff] [blame] | 355 | /* WBUFF pool sizes for WMI */ |
| 356 | /* Allocation of size 256 bytes */ |
| 357 | #define WMI_WBUFF_POOL_0_SIZE 128 |
| 358 | /* Allocation of size 512 bytes */ |
| 359 | #define WMI_WBUFF_POOL_1_SIZE 16 |
| 360 | /* Allocation of size 1024 bytes */ |
| 361 | #define WMI_WBUFF_POOL_2_SIZE 8 |
| 362 | /* Allocation of size 2048 bytes */ |
| 363 | #define WMI_WBUFF_POOL_3_SIZE 8 |
| 364 | |
Rachit Kankane | 799d2c9 | 2018-02-19 11:28:10 +0530 | [diff] [blame] | 365 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Manikandan Mohan | 5826ae9 | 2016-06-08 16:29:39 -0700 | [diff] [blame] | 366 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)) |
| 367 | /* TODO Cleanup this backported function */ |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 368 | 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] | 369 | { |
| 370 | va_list args; |
| 371 | |
| 372 | va_start(args, f); |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 373 | seq_vprintf(m, f, args); |
Manikandan Mohan | 5826ae9 | 2016-06-08 16:29:39 -0700 | [diff] [blame] | 374 | va_end(args); |
| 375 | |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 376 | return 0; |
Manikandan Mohan | 5826ae9 | 2016-06-08 16:29:39 -0700 | [diff] [blame] | 377 | } |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 378 | #else |
| 379 | #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] | 380 | #endif |
| 381 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 382 | #ifndef MAX_WMI_INSTANCES |
Pratik Gandhi | 29e33f0 | 2016-09-16 01:32:51 +0530 | [diff] [blame] | 383 | #define CUSTOM_MGMT_CMD_DATA_SIZE 4 |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 384 | #endif |
| 385 | |
Pratik Gandhi | 29e33f0 | 2016-09-16 01:32:51 +0530 | [diff] [blame] | 386 | #ifdef CONFIG_MCL |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 387 | /* WMI commands */ |
| 388 | uint32_t g_wmi_command_buf_idx = 0; |
| 389 | struct wmi_command_debug wmi_command_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY]; |
| 390 | |
| 391 | /* WMI commands TX completed */ |
| 392 | uint32_t g_wmi_command_tx_cmp_buf_idx = 0; |
| 393 | struct wmi_command_debug |
| 394 | wmi_command_tx_cmp_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY]; |
| 395 | |
| 396 | /* WMI events when processed */ |
| 397 | uint32_t g_wmi_event_buf_idx = 0; |
| 398 | struct wmi_event_debug wmi_event_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY]; |
| 399 | |
| 400 | /* WMI events when queued */ |
| 401 | uint32_t g_wmi_rx_event_buf_idx = 0; |
| 402 | 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] | 403 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 404 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 405 | #define WMI_COMMAND_RECORD(h, a, b) { \ |
| 406 | if (wmi_log_max_entry <= \ |
| 407 | *(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)) \ |
| 408 | *(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx) = 0;\ |
| 409 | ((struct wmi_command_debug *)h->log_info.wmi_command_log_buf_info.buf)\ |
| 410 | [*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)]\ |
| 411 | .command = a; \ |
| 412 | qdf_mem_copy(((struct wmi_command_debug *)h->log_info. \ |
| 413 | wmi_command_log_buf_info.buf) \ |
| 414 | [*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)].data,\ |
| 415 | b, wmi_record_max_length); \ |
| 416 | ((struct wmi_command_debug *)h->log_info.wmi_command_log_buf_info.buf)\ |
| 417 | [*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)].\ |
| 418 | time = qdf_get_log_timestamp(); \ |
| 419 | (*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx))++; \ |
| 420 | h->log_info.wmi_command_log_buf_info.length++; \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 421 | } |
| 422 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 423 | #define WMI_COMMAND_TX_CMP_RECORD(h, a, b) { \ |
| 424 | if (wmi_log_max_entry <= \ |
| 425 | *(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] | 426 | *(h->log_info.wmi_command_tx_cmp_log_buf_info. \ |
| 427 | p_buf_tail_idx) = 0; \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 428 | ((struct wmi_command_debug *)h->log_info. \ |
| 429 | wmi_command_tx_cmp_log_buf_info.buf) \ |
| 430 | [*(h->log_info.wmi_command_tx_cmp_log_buf_info. \ |
| 431 | p_buf_tail_idx)]. \ |
| 432 | command = a; \ |
| 433 | qdf_mem_copy(((struct wmi_command_debug *)h->log_info. \ |
| 434 | wmi_command_tx_cmp_log_buf_info.buf) \ |
| 435 | [*(h->log_info.wmi_command_tx_cmp_log_buf_info. \ |
| 436 | p_buf_tail_idx)]. \ |
| 437 | data, b, wmi_record_max_length); \ |
| 438 | ((struct wmi_command_debug *)h->log_info. \ |
| 439 | wmi_command_tx_cmp_log_buf_info.buf) \ |
| 440 | [*(h->log_info.wmi_command_tx_cmp_log_buf_info. \ |
| 441 | p_buf_tail_idx)]. \ |
| 442 | time = qdf_get_log_timestamp(); \ |
| 443 | (*(h->log_info.wmi_command_tx_cmp_log_buf_info.p_buf_tail_idx))++;\ |
| 444 | h->log_info.wmi_command_tx_cmp_log_buf_info.length++; \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 445 | } |
| 446 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 447 | #define WMI_EVENT_RECORD(h, a, b) { \ |
| 448 | if (wmi_log_max_entry <= \ |
| 449 | *(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx)) \ |
| 450 | *(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx) = 0;\ |
| 451 | ((struct wmi_event_debug *)h->log_info.wmi_event_log_buf_info.buf)\ |
| 452 | [*(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx)]. \ |
| 453 | event = a; \ |
| 454 | qdf_mem_copy(((struct wmi_event_debug *)h->log_info. \ |
| 455 | wmi_event_log_buf_info.buf) \ |
| 456 | [*(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx)].data, b,\ |
| 457 | wmi_record_max_length); \ |
| 458 | ((struct wmi_event_debug *)h->log_info.wmi_event_log_buf_info.buf)\ |
| 459 | [*(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] | 460 | qdf_get_log_timestamp(); \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 461 | (*(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx))++; \ |
| 462 | h->log_info.wmi_event_log_buf_info.length++; \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 463 | } |
| 464 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 465 | #define WMI_RX_EVENT_RECORD(h, a, b) { \ |
| 466 | if (wmi_log_max_entry <= \ |
| 467 | *(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx))\ |
| 468 | *(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx) = 0;\ |
| 469 | ((struct wmi_event_debug *)h->log_info.wmi_rx_event_log_buf_info.buf)\ |
| 470 | [*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx)].\ |
| 471 | event = a; \ |
| 472 | qdf_mem_copy(((struct wmi_event_debug *)h->log_info. \ |
| 473 | wmi_rx_event_log_buf_info.buf) \ |
| 474 | [*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx)].\ |
| 475 | data, b, wmi_record_max_length); \ |
| 476 | ((struct wmi_event_debug *)h->log_info.wmi_rx_event_log_buf_info.buf)\ |
| 477 | [*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx)].\ |
| 478 | time = qdf_get_log_timestamp(); \ |
| 479 | (*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx))++; \ |
| 480 | h->log_info.wmi_rx_event_log_buf_info.length++; \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 481 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 482 | |
Pratik Gandhi | 29e33f0 | 2016-09-16 01:32:51 +0530 | [diff] [blame] | 483 | #ifdef CONFIG_MCL |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 484 | uint32_t g_wmi_mgmt_command_buf_idx = 0; |
| 485 | struct |
| 486 | wmi_command_debug wmi_mgmt_command_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY]; |
| 487 | |
| 488 | /* wmi_mgmt commands TX completed */ |
| 489 | uint32_t g_wmi_mgmt_command_tx_cmp_buf_idx = 0; |
| 490 | struct wmi_command_debug |
| 491 | wmi_mgmt_command_tx_cmp_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY]; |
| 492 | |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 493 | /* wmi_mgmt events when received */ |
| 494 | uint32_t g_wmi_mgmt_rx_event_buf_idx = 0; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 495 | struct wmi_event_debug |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 496 | wmi_mgmt_rx_event_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY]; |
| 497 | |
| 498 | /* wmi_diag events when received */ |
| 499 | uint32_t g_wmi_diag_rx_event_buf_idx = 0; |
| 500 | struct wmi_event_debug |
| 501 | wmi_diag_rx_event_log_buffer[WMI_DIAG_RX_EVENT_DEBUG_MAX_ENTRY]; |
Pratik Gandhi | 29e33f0 | 2016-09-16 01:32:51 +0530 | [diff] [blame] | 502 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 503 | |
Pratik Gandhi | 29e33f0 | 2016-09-16 01:32:51 +0530 | [diff] [blame] | 504 | #define WMI_MGMT_COMMAND_RECORD(h, a, b) { \ |
| 505 | if (wmi_mgmt_log_max_entry <= \ |
| 506 | *(h->log_info.wmi_mgmt_command_log_buf_info.p_buf_tail_idx)) \ |
| 507 | *(h->log_info.wmi_mgmt_command_log_buf_info. \ |
| 508 | p_buf_tail_idx) = 0; \ |
| 509 | ((struct wmi_command_debug *)h->log_info. \ |
| 510 | wmi_mgmt_command_log_buf_info.buf) \ |
| 511 | [*(h->log_info.wmi_mgmt_command_log_buf_info.p_buf_tail_idx)].\ |
| 512 | command = a; \ |
| 513 | qdf_mem_copy(((struct wmi_command_debug *)h->log_info. \ |
| 514 | wmi_mgmt_command_log_buf_info.buf) \ |
| 515 | [*(h->log_info.wmi_mgmt_command_log_buf_info.p_buf_tail_idx)].\ |
| 516 | data, b, \ |
| 517 | wmi_record_max_length); \ |
| 518 | ((struct wmi_command_debug *)h->log_info. \ |
| 519 | wmi_mgmt_command_log_buf_info.buf) \ |
| 520 | [*(h->log_info.wmi_mgmt_command_log_buf_info.p_buf_tail_idx)].\ |
| 521 | time = qdf_get_log_timestamp(); \ |
| 522 | (*(h->log_info.wmi_mgmt_command_log_buf_info.p_buf_tail_idx))++;\ |
| 523 | h->log_info.wmi_mgmt_command_log_buf_info.length++; \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 524 | } |
| 525 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 526 | #define WMI_MGMT_COMMAND_TX_CMP_RECORD(h, a, b) { \ |
| 527 | if (wmi_mgmt_log_max_entry <= \ |
| 528 | *(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \ |
| 529 | p_buf_tail_idx)) \ |
| 530 | *(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \ |
| 531 | p_buf_tail_idx) = 0; \ |
| 532 | ((struct wmi_command_debug *)h->log_info. \ |
| 533 | wmi_mgmt_command_tx_cmp_log_buf_info.buf) \ |
| 534 | [*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \ |
| 535 | p_buf_tail_idx)].command = a; \ |
| 536 | qdf_mem_copy(((struct wmi_command_debug *)h->log_info. \ |
| 537 | wmi_mgmt_command_tx_cmp_log_buf_info.buf)\ |
| 538 | [*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \ |
| 539 | p_buf_tail_idx)].data, b, \ |
| 540 | wmi_record_max_length); \ |
| 541 | ((struct wmi_command_debug *)h->log_info. \ |
| 542 | wmi_mgmt_command_tx_cmp_log_buf_info.buf) \ |
| 543 | [*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \ |
| 544 | p_buf_tail_idx)].time = \ |
| 545 | qdf_get_log_timestamp(); \ |
| 546 | (*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \ |
| 547 | p_buf_tail_idx))++; \ |
| 548 | h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info.length++; \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 549 | } |
| 550 | |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 551 | #define WMI_MGMT_RX_EVENT_RECORD(h, a, b) do { \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 552 | if (wmi_mgmt_log_max_entry <= \ |
| 553 | *(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx))\ |
| 554 | *(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx) = 0;\ |
| 555 | ((struct wmi_event_debug *)h->log_info.wmi_mgmt_event_log_buf_info.buf)\ |
| 556 | [*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx)]\ |
| 557 | .event = a; \ |
| 558 | qdf_mem_copy(((struct wmi_event_debug *)h->log_info. \ |
| 559 | wmi_mgmt_event_log_buf_info.buf) \ |
| 560 | [*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx)].\ |
| 561 | data, b, wmi_record_max_length); \ |
| 562 | ((struct wmi_event_debug *)h->log_info.wmi_mgmt_event_log_buf_info.buf)\ |
| 563 | [*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx)].\ |
| 564 | time = qdf_get_log_timestamp(); \ |
| 565 | (*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx))++; \ |
| 566 | h->log_info.wmi_mgmt_event_log_buf_info.length++; \ |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 567 | } while (0); |
| 568 | |
| 569 | #define WMI_DIAG_RX_EVENT_RECORD(h, a, b) do { \ |
| 570 | if (wmi_mgmt_log_max_entry <= \ |
| 571 | *(h->log_info.wmi_diag_event_log_buf_info.p_buf_tail_idx))\ |
| 572 | *(h->log_info.wmi_diag_event_log_buf_info.p_buf_tail_idx) = 0;\ |
| 573 | ((struct wmi_event_debug *)h->log_info.wmi_diag_event_log_buf_info.buf)\ |
| 574 | [*(h->log_info.wmi_diag_event_log_buf_info.p_buf_tail_idx)]\ |
| 575 | .event = a; \ |
| 576 | qdf_mem_copy(((struct wmi_event_debug *)h->log_info. \ |
| 577 | wmi_diag_event_log_buf_info.buf) \ |
| 578 | [*(h->log_info.wmi_diag_event_log_buf_info.p_buf_tail_idx)].\ |
| 579 | data, b, wmi_record_max_length); \ |
| 580 | ((struct wmi_event_debug *)h->log_info.wmi_diag_event_log_buf_info.buf)\ |
| 581 | [*(h->log_info.wmi_diag_event_log_buf_info.p_buf_tail_idx)].\ |
| 582 | time = qdf_get_log_timestamp(); \ |
| 583 | (*(h->log_info.wmi_diag_event_log_buf_info.p_buf_tail_idx))++; \ |
| 584 | h->log_info.wmi_diag_event_log_buf_info.length++; \ |
| 585 | } while (0); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 586 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 587 | /* These are defined to made it as module param, which can be configured */ |
| 588 | uint32_t wmi_log_max_entry = WMI_EVENT_DEBUG_MAX_ENTRY; |
| 589 | uint32_t wmi_mgmt_log_max_entry = WMI_MGMT_EVENT_DEBUG_MAX_ENTRY; |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 590 | uint32_t wmi_diag_log_max_entry = WMI_DIAG_RX_EVENT_DEBUG_MAX_ENTRY; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 591 | uint32_t wmi_record_max_length = WMI_EVENT_DEBUG_ENTRY_MAX_LENGTH; |
| 592 | uint32_t wmi_display_size = 100; |
| 593 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 594 | /** |
| 595 | * wmi_log_init() - Initialize WMI event logging |
| 596 | * @wmi_handle: WMI handle. |
| 597 | * |
| 598 | * Return: Initialization status |
| 599 | */ |
| 600 | #ifdef CONFIG_MCL |
| 601 | static QDF_STATUS wmi_log_init(struct wmi_unified *wmi_handle) |
| 602 | { |
| 603 | struct wmi_log_buf_t *cmd_log_buf = |
| 604 | &wmi_handle->log_info.wmi_command_log_buf_info; |
| 605 | struct wmi_log_buf_t *cmd_tx_cmpl_log_buf = |
| 606 | &wmi_handle->log_info.wmi_command_tx_cmp_log_buf_info; |
| 607 | |
| 608 | struct wmi_log_buf_t *event_log_buf = |
| 609 | &wmi_handle->log_info.wmi_event_log_buf_info; |
| 610 | struct wmi_log_buf_t *rx_event_log_buf = |
| 611 | &wmi_handle->log_info.wmi_rx_event_log_buf_info; |
| 612 | |
| 613 | struct wmi_log_buf_t *mgmt_cmd_log_buf = |
| 614 | &wmi_handle->log_info.wmi_mgmt_command_log_buf_info; |
| 615 | struct wmi_log_buf_t *mgmt_cmd_tx_cmp_log_buf = |
| 616 | &wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info; |
| 617 | struct wmi_log_buf_t *mgmt_event_log_buf = |
| 618 | &wmi_handle->log_info.wmi_mgmt_event_log_buf_info; |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 619 | struct wmi_log_buf_t *diag_event_log_buf = |
| 620 | &wmi_handle->log_info.wmi_diag_event_log_buf_info; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 621 | |
| 622 | /* WMI commands */ |
| 623 | cmd_log_buf->length = 0; |
| 624 | cmd_log_buf->buf_tail_idx = 0; |
| 625 | cmd_log_buf->buf = wmi_command_log_buffer; |
| 626 | cmd_log_buf->p_buf_tail_idx = &g_wmi_command_buf_idx; |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 627 | cmd_log_buf->size = WMI_EVENT_DEBUG_MAX_ENTRY; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 628 | |
| 629 | /* WMI commands TX completed */ |
| 630 | cmd_tx_cmpl_log_buf->length = 0; |
| 631 | cmd_tx_cmpl_log_buf->buf_tail_idx = 0; |
| 632 | cmd_tx_cmpl_log_buf->buf = wmi_command_tx_cmp_log_buffer; |
| 633 | 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] | 634 | cmd_tx_cmpl_log_buf->size = WMI_EVENT_DEBUG_MAX_ENTRY; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 635 | |
| 636 | /* WMI events when processed */ |
| 637 | event_log_buf->length = 0; |
| 638 | event_log_buf->buf_tail_idx = 0; |
| 639 | event_log_buf->buf = wmi_event_log_buffer; |
| 640 | event_log_buf->p_buf_tail_idx = &g_wmi_event_buf_idx; |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 641 | event_log_buf->size = WMI_EVENT_DEBUG_MAX_ENTRY; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 642 | |
| 643 | /* WMI events when queued */ |
| 644 | rx_event_log_buf->length = 0; |
| 645 | rx_event_log_buf->buf_tail_idx = 0; |
| 646 | rx_event_log_buf->buf = wmi_rx_event_log_buffer; |
| 647 | 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] | 648 | rx_event_log_buf->size = WMI_EVENT_DEBUG_MAX_ENTRY; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 649 | |
| 650 | /* WMI Management commands */ |
| 651 | mgmt_cmd_log_buf->length = 0; |
| 652 | mgmt_cmd_log_buf->buf_tail_idx = 0; |
| 653 | mgmt_cmd_log_buf->buf = wmi_mgmt_command_log_buffer; |
| 654 | 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] | 655 | mgmt_cmd_log_buf->size = WMI_MGMT_EVENT_DEBUG_MAX_ENTRY; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 656 | |
| 657 | /* WMI Management commands Tx completed*/ |
| 658 | mgmt_cmd_tx_cmp_log_buf->length = 0; |
| 659 | mgmt_cmd_tx_cmp_log_buf->buf_tail_idx = 0; |
| 660 | mgmt_cmd_tx_cmp_log_buf->buf = wmi_mgmt_command_tx_cmp_log_buffer; |
| 661 | mgmt_cmd_tx_cmp_log_buf->p_buf_tail_idx = |
| 662 | &g_wmi_mgmt_command_tx_cmp_buf_idx; |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 663 | 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] | 664 | |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 665 | /* WMI Management events when received */ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 666 | mgmt_event_log_buf->length = 0; |
| 667 | mgmt_event_log_buf->buf_tail_idx = 0; |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 668 | mgmt_event_log_buf->buf = wmi_mgmt_rx_event_log_buffer; |
| 669 | mgmt_event_log_buf->p_buf_tail_idx = &g_wmi_mgmt_rx_event_buf_idx; |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 670 | mgmt_event_log_buf->size = WMI_MGMT_EVENT_DEBUG_MAX_ENTRY; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 671 | |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 672 | /* WMI diag events when received */ |
| 673 | diag_event_log_buf->length = 0; |
| 674 | diag_event_log_buf->buf_tail_idx = 0; |
| 675 | diag_event_log_buf->buf = wmi_diag_rx_event_log_buffer; |
| 676 | diag_event_log_buf->p_buf_tail_idx = &g_wmi_diag_rx_event_buf_idx; |
| 677 | diag_event_log_buf->size = WMI_DIAG_RX_EVENT_DEBUG_MAX_ENTRY; |
| 678 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 679 | qdf_spinlock_create(&wmi_handle->log_info.wmi_record_lock); |
| 680 | wmi_handle->log_info.wmi_logging_enable = 1; |
| 681 | |
| 682 | return QDF_STATUS_SUCCESS; |
| 683 | } |
| 684 | #else |
| 685 | static QDF_STATUS wmi_log_init(struct wmi_unified *wmi_handle) |
| 686 | { |
| 687 | struct wmi_log_buf_t *cmd_log_buf = |
| 688 | &wmi_handle->log_info.wmi_command_log_buf_info; |
| 689 | struct wmi_log_buf_t *cmd_tx_cmpl_log_buf = |
| 690 | &wmi_handle->log_info.wmi_command_tx_cmp_log_buf_info; |
| 691 | |
| 692 | struct wmi_log_buf_t *event_log_buf = |
| 693 | &wmi_handle->log_info.wmi_event_log_buf_info; |
| 694 | struct wmi_log_buf_t *rx_event_log_buf = |
| 695 | &wmi_handle->log_info.wmi_rx_event_log_buf_info; |
| 696 | |
| 697 | struct wmi_log_buf_t *mgmt_cmd_log_buf = |
| 698 | &wmi_handle->log_info.wmi_mgmt_command_log_buf_info; |
| 699 | struct wmi_log_buf_t *mgmt_cmd_tx_cmp_log_buf = |
| 700 | &wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info; |
| 701 | struct wmi_log_buf_t *mgmt_event_log_buf = |
| 702 | &wmi_handle->log_info.wmi_mgmt_event_log_buf_info; |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 703 | struct wmi_log_buf_t *diag_event_log_buf = |
| 704 | &wmi_handle->log_info.wmi_diag_event_log_buf_info; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 705 | |
| 706 | wmi_handle->log_info.wmi_logging_enable = 0; |
| 707 | |
| 708 | /* WMI commands */ |
| 709 | cmd_log_buf->length = 0; |
| 710 | cmd_log_buf->buf_tail_idx = 0; |
| 711 | cmd_log_buf->buf = (struct wmi_command_debug *) qdf_mem_malloc( |
| 712 | wmi_log_max_entry * sizeof(struct wmi_command_debug)); |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 713 | cmd_log_buf->size = wmi_log_max_entry; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 714 | |
| 715 | if (!cmd_log_buf->buf) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 716 | WMI_LOGE("no memory for WMI command log buffer.."); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 717 | return QDF_STATUS_E_NOMEM; |
| 718 | } |
| 719 | cmd_log_buf->p_buf_tail_idx = &cmd_log_buf->buf_tail_idx; |
| 720 | |
| 721 | /* WMI commands TX completed */ |
| 722 | cmd_tx_cmpl_log_buf->length = 0; |
| 723 | cmd_tx_cmpl_log_buf->buf_tail_idx = 0; |
| 724 | cmd_tx_cmpl_log_buf->buf = (struct wmi_command_debug *) qdf_mem_malloc( |
| 725 | wmi_log_max_entry * sizeof(struct wmi_command_debug)); |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 726 | cmd_tx_cmpl_log_buf->size = wmi_log_max_entry; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 727 | |
| 728 | if (!cmd_tx_cmpl_log_buf->buf) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 729 | WMI_LOGE("no memory for WMI Command Tx Complete log buffer.."); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 730 | return QDF_STATUS_E_NOMEM; |
| 731 | } |
| 732 | cmd_tx_cmpl_log_buf->p_buf_tail_idx = |
| 733 | &cmd_tx_cmpl_log_buf->buf_tail_idx; |
| 734 | |
| 735 | /* WMI events when processed */ |
| 736 | event_log_buf->length = 0; |
| 737 | event_log_buf->buf_tail_idx = 0; |
| 738 | event_log_buf->buf = (struct wmi_event_debug *) qdf_mem_malloc( |
| 739 | wmi_log_max_entry * sizeof(struct wmi_event_debug)); |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 740 | event_log_buf->size = wmi_log_max_entry; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 741 | |
| 742 | if (!event_log_buf->buf) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 743 | WMI_LOGE("no memory for WMI Event log buffer.."); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 744 | return QDF_STATUS_E_NOMEM; |
| 745 | } |
| 746 | event_log_buf->p_buf_tail_idx = &event_log_buf->buf_tail_idx; |
| 747 | |
| 748 | /* WMI events when queued */ |
| 749 | rx_event_log_buf->length = 0; |
| 750 | rx_event_log_buf->buf_tail_idx = 0; |
| 751 | rx_event_log_buf->buf = (struct wmi_event_debug *) qdf_mem_malloc( |
| 752 | wmi_log_max_entry * sizeof(struct wmi_event_debug)); |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 753 | rx_event_log_buf->size = wmi_log_max_entry; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 754 | |
| 755 | if (!rx_event_log_buf->buf) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 756 | WMI_LOGE("no memory for WMI Event Rx log buffer.."); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 757 | return QDF_STATUS_E_NOMEM; |
| 758 | } |
| 759 | rx_event_log_buf->p_buf_tail_idx = &rx_event_log_buf->buf_tail_idx; |
| 760 | |
| 761 | /* WMI Management commands */ |
| 762 | mgmt_cmd_log_buf->length = 0; |
| 763 | mgmt_cmd_log_buf->buf_tail_idx = 0; |
| 764 | mgmt_cmd_log_buf->buf = (struct wmi_command_debug *) qdf_mem_malloc( |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 765 | wmi_mgmt_log_max_entry * sizeof(struct wmi_command_debug)); |
| 766 | mgmt_cmd_log_buf->size = wmi_mgmt_log_max_entry; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 767 | |
| 768 | if (!mgmt_cmd_log_buf->buf) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 769 | WMI_LOGE("no memory for WMI Management Command log buffer.."); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 770 | return QDF_STATUS_E_NOMEM; |
| 771 | } |
| 772 | mgmt_cmd_log_buf->p_buf_tail_idx = &mgmt_cmd_log_buf->buf_tail_idx; |
| 773 | |
| 774 | /* WMI Management commands Tx completed*/ |
| 775 | mgmt_cmd_tx_cmp_log_buf->length = 0; |
| 776 | mgmt_cmd_tx_cmp_log_buf->buf_tail_idx = 0; |
| 777 | mgmt_cmd_tx_cmp_log_buf->buf = (struct wmi_command_debug *) |
| 778 | qdf_mem_malloc( |
| 779 | wmi_mgmt_log_max_entry * |
| 780 | sizeof(struct wmi_command_debug)); |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 781 | mgmt_cmd_tx_cmp_log_buf->size = wmi_mgmt_log_max_entry; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 782 | |
| 783 | if (!mgmt_cmd_tx_cmp_log_buf->buf) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 784 | WMI_LOGE("no memory for WMI Management Command Tx complete log buffer.."); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 785 | return QDF_STATUS_E_NOMEM; |
| 786 | } |
| 787 | mgmt_cmd_tx_cmp_log_buf->p_buf_tail_idx = |
| 788 | &mgmt_cmd_tx_cmp_log_buf->buf_tail_idx; |
| 789 | |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 790 | /* WMI Management events when received */ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 791 | mgmt_event_log_buf->length = 0; |
| 792 | mgmt_event_log_buf->buf_tail_idx = 0; |
| 793 | |
| 794 | mgmt_event_log_buf->buf = (struct wmi_event_debug *) qdf_mem_malloc( |
| 795 | wmi_mgmt_log_max_entry * |
| 796 | sizeof(struct wmi_event_debug)); |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 797 | mgmt_event_log_buf->size = wmi_mgmt_log_max_entry; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 798 | |
| 799 | if (!mgmt_event_log_buf->buf) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 800 | WMI_LOGE("no memory for WMI Management Event log buffer.."); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 801 | return QDF_STATUS_E_NOMEM; |
| 802 | } |
| 803 | mgmt_event_log_buf->p_buf_tail_idx = &mgmt_event_log_buf->buf_tail_idx; |
| 804 | |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 805 | /* WMI diag events when received */ |
| 806 | diag_event_log_buf->length = 0; |
| 807 | diag_event_log_buf->buf_tail_idx = 0; |
| 808 | |
| 809 | diag_event_log_buf->buf = (struct wmi_event_debug *) qdf_mem_malloc( |
| 810 | wmi_diag_log_max_entry * |
| 811 | sizeof(struct wmi_event_debug)); |
| 812 | diag_event_log_buf->size = wmi_diag_log_max_entry; |
| 813 | |
| 814 | if (!diag_event_log_buf->buf) { |
| 815 | qdf_print("no memory for WMI diag event log buffer..\n"); |
| 816 | return QDF_STATUS_E_NOMEM; |
| 817 | } |
| 818 | diag_event_log_buf->p_buf_tail_idx = &diag_event_log_buf->buf_tail_idx; |
| 819 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 820 | qdf_spinlock_create(&wmi_handle->log_info.wmi_record_lock); |
| 821 | wmi_handle->log_info.wmi_logging_enable = 1; |
| 822 | |
| 823 | return QDF_STATUS_SUCCESS; |
| 824 | } |
| 825 | #endif |
| 826 | |
| 827 | /** |
| 828 | * wmi_log_buffer_free() - Free all dynamic allocated buffer memory for |
| 829 | * event logging |
| 830 | * @wmi_handle: WMI handle. |
| 831 | * |
| 832 | * Return: None |
| 833 | */ |
| 834 | #ifndef CONFIG_MCL |
| 835 | static inline void wmi_log_buffer_free(struct wmi_unified *wmi_handle) |
| 836 | { |
| 837 | if (wmi_handle->log_info.wmi_command_log_buf_info.buf) |
| 838 | qdf_mem_free(wmi_handle->log_info.wmi_command_log_buf_info.buf); |
| 839 | if (wmi_handle->log_info.wmi_command_tx_cmp_log_buf_info.buf) |
| 840 | qdf_mem_free( |
| 841 | wmi_handle->log_info.wmi_command_tx_cmp_log_buf_info.buf); |
| 842 | if (wmi_handle->log_info.wmi_event_log_buf_info.buf) |
| 843 | qdf_mem_free(wmi_handle->log_info.wmi_event_log_buf_info.buf); |
| 844 | if (wmi_handle->log_info.wmi_rx_event_log_buf_info.buf) |
| 845 | qdf_mem_free( |
| 846 | wmi_handle->log_info.wmi_rx_event_log_buf_info.buf); |
| 847 | if (wmi_handle->log_info.wmi_mgmt_command_log_buf_info.buf) |
| 848 | qdf_mem_free( |
| 849 | wmi_handle->log_info.wmi_mgmt_command_log_buf_info.buf); |
| 850 | if (wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info.buf) |
| 851 | qdf_mem_free( |
| 852 | wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info.buf); |
| 853 | if (wmi_handle->log_info.wmi_mgmt_event_log_buf_info.buf) |
| 854 | qdf_mem_free( |
| 855 | wmi_handle->log_info.wmi_mgmt_event_log_buf_info.buf); |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 856 | if (wmi_handle->log_info.wmi_diag_event_log_buf_info.buf) |
| 857 | qdf_mem_free( |
| 858 | wmi_handle->log_info.wmi_diag_event_log_buf_info.buf); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 859 | wmi_handle->log_info.wmi_logging_enable = 0; |
| 860 | qdf_spinlock_destroy(&wmi_handle->log_info.wmi_record_lock); |
| 861 | } |
| 862 | #else |
| 863 | static inline void wmi_log_buffer_free(struct wmi_unified *wmi_handle) |
| 864 | { |
| 865 | /* Do Nothing */ |
| 866 | } |
| 867 | #endif |
| 868 | |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 869 | /** |
| 870 | * wmi_print_cmd_log_buffer() - an output agnostic wmi command log printer |
| 871 | * @log_buffer: the command log buffer metadata of the buffer to print |
| 872 | * @count: the maximum number of entries to print |
| 873 | * @print: an abstract print method, e.g. a qdf_print() or seq_printf() wrapper |
| 874 | * @print_priv: any data required by the print method, e.g. a file handle |
| 875 | * |
| 876 | * Return: None |
| 877 | */ |
| 878 | static void |
| 879 | wmi_print_cmd_log_buffer(struct wmi_log_buf_t *log_buffer, uint32_t count, |
| 880 | qdf_abstract_print *print, void *print_priv) |
| 881 | { |
| 882 | static const int data_len = |
| 883 | WMI_EVENT_DEBUG_ENTRY_MAX_LENGTH / sizeof(uint32_t); |
| 884 | char str[128]; |
| 885 | uint32_t idx; |
| 886 | |
| 887 | if (count > log_buffer->size) |
| 888 | count = log_buffer->size; |
| 889 | if (count > log_buffer->length) |
| 890 | count = log_buffer->length; |
| 891 | |
| 892 | /* subtract count from index, and wrap if necessary */ |
| 893 | idx = log_buffer->size + *log_buffer->p_buf_tail_idx - count; |
| 894 | idx %= log_buffer->size; |
| 895 | |
| 896 | print(print_priv, "Time (seconds) Cmd Id Payload"); |
| 897 | while (count) { |
| 898 | struct wmi_command_debug *cmd_log = (struct wmi_command_debug *) |
| 899 | &((struct wmi_command_debug *)log_buffer->buf)[idx]; |
Dustin Brown | 8ea3912 | 2017-04-10 13:26:56 -0700 | [diff] [blame] | 900 | uint64_t secs, usecs; |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 901 | int len = 0; |
| 902 | int i; |
| 903 | |
Dustin Brown | 8ea3912 | 2017-04-10 13:26:56 -0700 | [diff] [blame] | 904 | qdf_log_timestamp_to_secs(cmd_log->time, &secs, &usecs); |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 905 | len += scnprintf(str + len, sizeof(str) - len, |
| 906 | "% 8lld.%06lld %6u (0x%06x) ", |
Dustin Brown | 8ea3912 | 2017-04-10 13:26:56 -0700 | [diff] [blame] | 907 | secs, usecs, |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 908 | cmd_log->command, cmd_log->command); |
| 909 | for (i = 0; i < data_len; ++i) { |
| 910 | len += scnprintf(str + len, sizeof(str) - len, |
| 911 | "0x%08x ", cmd_log->data[i]); |
| 912 | } |
| 913 | |
| 914 | print(print_priv, str); |
| 915 | |
| 916 | --count; |
| 917 | ++idx; |
| 918 | if (idx >= log_buffer->size) |
| 919 | idx = 0; |
| 920 | } |
| 921 | } |
| 922 | |
| 923 | /** |
| 924 | * wmi_print_event_log_buffer() - an output agnostic wmi event log printer |
| 925 | * @log_buffer: the event log buffer metadata of the buffer to print |
| 926 | * @count: the maximum number of entries to print |
| 927 | * @print: an abstract print method, e.g. a qdf_print() or seq_printf() wrapper |
| 928 | * @print_priv: any data required by the print method, e.g. a file handle |
| 929 | * |
| 930 | * Return: None |
| 931 | */ |
| 932 | static void |
| 933 | wmi_print_event_log_buffer(struct wmi_log_buf_t *log_buffer, uint32_t count, |
| 934 | qdf_abstract_print *print, void *print_priv) |
| 935 | { |
| 936 | static const int data_len = |
| 937 | WMI_EVENT_DEBUG_ENTRY_MAX_LENGTH / sizeof(uint32_t); |
| 938 | char str[128]; |
| 939 | uint32_t idx; |
| 940 | |
| 941 | if (count > log_buffer->size) |
| 942 | count = log_buffer->size; |
| 943 | if (count > log_buffer->length) |
| 944 | count = log_buffer->length; |
| 945 | |
| 946 | /* subtract count from index, and wrap if necessary */ |
| 947 | idx = log_buffer->size + *log_buffer->p_buf_tail_idx - count; |
| 948 | idx %= log_buffer->size; |
| 949 | |
| 950 | print(print_priv, "Time (seconds) Event Id Payload"); |
| 951 | while (count) { |
| 952 | struct wmi_event_debug *event_log = (struct wmi_event_debug *) |
| 953 | &((struct wmi_event_debug *)log_buffer->buf)[idx]; |
Dustin Brown | 8ea3912 | 2017-04-10 13:26:56 -0700 | [diff] [blame] | 954 | uint64_t secs, usecs; |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 955 | int len = 0; |
| 956 | int i; |
| 957 | |
Dustin Brown | 8ea3912 | 2017-04-10 13:26:56 -0700 | [diff] [blame] | 958 | qdf_log_timestamp_to_secs(event_log->time, &secs, &usecs); |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 959 | len += scnprintf(str + len, sizeof(str) - len, |
| 960 | "% 8lld.%06lld %6u (0x%06x) ", |
Dustin Brown | 8ea3912 | 2017-04-10 13:26:56 -0700 | [diff] [blame] | 961 | secs, usecs, |
Dustin Brown | f24bf9b | 2017-04-03 17:00:07 -0700 | [diff] [blame] | 962 | event_log->event, event_log->event); |
| 963 | for (i = 0; i < data_len; ++i) { |
| 964 | len += scnprintf(str + len, sizeof(str) - len, |
| 965 | "0x%08x ", event_log->data[i]); |
| 966 | } |
| 967 | |
| 968 | print(print_priv, str); |
| 969 | |
| 970 | --count; |
| 971 | ++idx; |
| 972 | if (idx >= log_buffer->size) |
| 973 | idx = 0; |
| 974 | } |
| 975 | } |
| 976 | |
| 977 | inline void |
| 978 | wmi_print_cmd_log(wmi_unified_t wmi, uint32_t count, |
| 979 | qdf_abstract_print *print, void *print_priv) |
| 980 | { |
| 981 | wmi_print_cmd_log_buffer( |
| 982 | &wmi->log_info.wmi_command_log_buf_info, |
| 983 | count, print, print_priv); |
| 984 | } |
| 985 | |
| 986 | inline void |
| 987 | wmi_print_cmd_tx_cmp_log(wmi_unified_t wmi, uint32_t count, |
| 988 | qdf_abstract_print *print, void *print_priv) |
| 989 | { |
| 990 | wmi_print_cmd_log_buffer( |
| 991 | &wmi->log_info.wmi_command_tx_cmp_log_buf_info, |
| 992 | count, print, print_priv); |
| 993 | } |
| 994 | |
| 995 | inline void |
| 996 | wmi_print_mgmt_cmd_log(wmi_unified_t wmi, uint32_t count, |
| 997 | qdf_abstract_print *print, void *print_priv) |
| 998 | { |
| 999 | wmi_print_cmd_log_buffer( |
| 1000 | &wmi->log_info.wmi_mgmt_command_log_buf_info, |
| 1001 | count, print, print_priv); |
| 1002 | } |
| 1003 | |
| 1004 | inline void |
| 1005 | wmi_print_mgmt_cmd_tx_cmp_log(wmi_unified_t wmi, uint32_t count, |
| 1006 | qdf_abstract_print *print, void *print_priv) |
| 1007 | { |
| 1008 | wmi_print_cmd_log_buffer( |
| 1009 | &wmi->log_info.wmi_mgmt_command_tx_cmp_log_buf_info, |
| 1010 | count, print, print_priv); |
| 1011 | } |
| 1012 | |
| 1013 | inline void |
| 1014 | wmi_print_event_log(wmi_unified_t wmi, uint32_t count, |
| 1015 | qdf_abstract_print *print, void *print_priv) |
| 1016 | { |
| 1017 | wmi_print_event_log_buffer( |
| 1018 | &wmi->log_info.wmi_event_log_buf_info, |
| 1019 | count, print, print_priv); |
| 1020 | } |
| 1021 | |
| 1022 | inline void |
| 1023 | wmi_print_rx_event_log(wmi_unified_t wmi, uint32_t count, |
| 1024 | qdf_abstract_print *print, void *print_priv) |
| 1025 | { |
| 1026 | wmi_print_event_log_buffer( |
| 1027 | &wmi->log_info.wmi_rx_event_log_buf_info, |
| 1028 | count, print, print_priv); |
| 1029 | } |
| 1030 | |
| 1031 | inline void |
| 1032 | wmi_print_mgmt_event_log(wmi_unified_t wmi, uint32_t count, |
| 1033 | qdf_abstract_print *print, void *print_priv) |
| 1034 | { |
| 1035 | wmi_print_event_log_buffer( |
| 1036 | &wmi->log_info.wmi_mgmt_event_log_buf_info, |
| 1037 | count, print, print_priv); |
| 1038 | } |
| 1039 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1040 | |
| 1041 | /* debugfs routines*/ |
| 1042 | |
| 1043 | /** |
| 1044 | * debug_wmi_##func_base##_show() - debugfs functions to display content of |
| 1045 | * command and event buffers. Macro uses max buffer length to display |
| 1046 | * buffer when it is wraparound. |
| 1047 | * |
| 1048 | * @m: debugfs handler to access wmi_handle |
| 1049 | * @v: Variable arguments (not used) |
| 1050 | * |
| 1051 | * Return: Length of characters printed |
| 1052 | */ |
| 1053 | #define GENERATE_COMMAND_DEBUG_SHOW_FUNCS(func_base, wmi_ring_size) \ |
| 1054 | static int debug_wmi_##func_base##_show(struct seq_file *m, \ |
| 1055 | void *v) \ |
| 1056 | { \ |
| 1057 | wmi_unified_t wmi_handle = (wmi_unified_t) m->private; \ |
| 1058 | struct wmi_log_buf_t *wmi_log = \ |
| 1059 | &wmi_handle->log_info.wmi_##func_base##_buf_info;\ |
| 1060 | int pos, nread, outlen; \ |
| 1061 | int i; \ |
nobelj | 2a6da6f | 2017-12-11 23:18:27 -0800 | [diff] [blame] | 1062 | uint64_t secs, usecs; \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1063 | \ |
Pratik Gandhi | 29e33f0 | 2016-09-16 01:32:51 +0530 | [diff] [blame] | 1064 | qdf_spin_lock(&wmi_handle->log_info.wmi_record_lock); \ |
| 1065 | if (!wmi_log->length) { \ |
| 1066 | qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock);\ |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1067 | return wmi_bp_seq_printf(m, \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1068 | "no elements to read from ring buffer!\n"); \ |
Pratik Gandhi | 29e33f0 | 2016-09-16 01:32:51 +0530 | [diff] [blame] | 1069 | } \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1070 | \ |
| 1071 | if (wmi_log->length <= wmi_ring_size) \ |
| 1072 | nread = wmi_log->length; \ |
| 1073 | else \ |
| 1074 | nread = wmi_ring_size; \ |
| 1075 | \ |
| 1076 | if (*(wmi_log->p_buf_tail_idx) == 0) \ |
| 1077 | /* tail can be 0 after wrap-around */ \ |
| 1078 | pos = wmi_ring_size - 1; \ |
| 1079 | else \ |
| 1080 | pos = *(wmi_log->p_buf_tail_idx) - 1; \ |
| 1081 | \ |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1082 | outlen = wmi_bp_seq_printf(m, "Length = %d\n", wmi_log->length);\ |
Pratik Gandhi | 29e33f0 | 2016-09-16 01:32:51 +0530 | [diff] [blame] | 1083 | qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock); \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1084 | while (nread--) { \ |
| 1085 | struct wmi_command_debug *wmi_record; \ |
| 1086 | \ |
| 1087 | wmi_record = (struct wmi_command_debug *) \ |
| 1088 | &(((struct wmi_command_debug *)wmi_log->buf)[pos]);\ |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1089 | outlen += wmi_bp_seq_printf(m, "CMD ID = %x\n", \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1090 | (wmi_record->command)); \ |
nobelj | 2a6da6f | 2017-12-11 23:18:27 -0800 | [diff] [blame] | 1091 | qdf_log_timestamp_to_secs(wmi_record->time, &secs,\ |
| 1092 | &usecs); \ |
| 1093 | outlen += \ |
| 1094 | wmi_bp_seq_printf(m, "CMD TIME = [%llu.%06llu]\n",\ |
| 1095 | secs, usecs); \ |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1096 | outlen += wmi_bp_seq_printf(m, "CMD = "); \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1097 | for (i = 0; i < (wmi_record_max_length/ \ |
| 1098 | sizeof(uint32_t)); i++) \ |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1099 | outlen += wmi_bp_seq_printf(m, "%x ", \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1100 | wmi_record->data[i]); \ |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1101 | outlen += wmi_bp_seq_printf(m, "\n"); \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1102 | \ |
| 1103 | if (pos == 0) \ |
| 1104 | pos = wmi_ring_size - 1; \ |
| 1105 | else \ |
| 1106 | pos--; \ |
| 1107 | } \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1108 | return outlen; \ |
| 1109 | } \ |
| 1110 | |
| 1111 | #define GENERATE_EVENT_DEBUG_SHOW_FUNCS(func_base, wmi_ring_size) \ |
| 1112 | static int debug_wmi_##func_base##_show(struct seq_file *m, \ |
| 1113 | void *v) \ |
| 1114 | { \ |
| 1115 | wmi_unified_t wmi_handle = (wmi_unified_t) m->private; \ |
| 1116 | struct wmi_log_buf_t *wmi_log = \ |
| 1117 | &wmi_handle->log_info.wmi_##func_base##_buf_info;\ |
| 1118 | int pos, nread, outlen; \ |
| 1119 | int i; \ |
nobelj | 2a6da6f | 2017-12-11 23:18:27 -0800 | [diff] [blame] | 1120 | uint64_t secs, usecs; \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1121 | \ |
Pratik Gandhi | 29e33f0 | 2016-09-16 01:32:51 +0530 | [diff] [blame] | 1122 | qdf_spin_lock(&wmi_handle->log_info.wmi_record_lock); \ |
| 1123 | if (!wmi_log->length) { \ |
| 1124 | qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock);\ |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1125 | return wmi_bp_seq_printf(m, \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1126 | "no elements to read from ring buffer!\n"); \ |
Pratik Gandhi | 29e33f0 | 2016-09-16 01:32:51 +0530 | [diff] [blame] | 1127 | } \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1128 | \ |
| 1129 | if (wmi_log->length <= wmi_ring_size) \ |
| 1130 | nread = wmi_log->length; \ |
| 1131 | else \ |
| 1132 | nread = wmi_ring_size; \ |
| 1133 | \ |
| 1134 | if (*(wmi_log->p_buf_tail_idx) == 0) \ |
| 1135 | /* tail can be 0 after wrap-around */ \ |
| 1136 | pos = wmi_ring_size - 1; \ |
| 1137 | else \ |
| 1138 | pos = *(wmi_log->p_buf_tail_idx) - 1; \ |
| 1139 | \ |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1140 | outlen = wmi_bp_seq_printf(m, "Length = %d\n", wmi_log->length);\ |
Pratik Gandhi | 29e33f0 | 2016-09-16 01:32:51 +0530 | [diff] [blame] | 1141 | qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock); \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1142 | while (nread--) { \ |
| 1143 | struct wmi_event_debug *wmi_record; \ |
| 1144 | \ |
| 1145 | wmi_record = (struct wmi_event_debug *) \ |
| 1146 | &(((struct wmi_event_debug *)wmi_log->buf)[pos]);\ |
nobelj | 2a6da6f | 2017-12-11 23:18:27 -0800 | [diff] [blame] | 1147 | qdf_log_timestamp_to_secs(wmi_record->time, &secs,\ |
| 1148 | &usecs); \ |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1149 | outlen += wmi_bp_seq_printf(m, "Event ID = %x\n",\ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1150 | (wmi_record->event)); \ |
nobelj | 2a6da6f | 2017-12-11 23:18:27 -0800 | [diff] [blame] | 1151 | outlen += \ |
| 1152 | wmi_bp_seq_printf(m, "Event TIME = [%llu.%06llu]\n",\ |
| 1153 | secs, usecs); \ |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1154 | outlen += wmi_bp_seq_printf(m, "CMD = "); \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1155 | for (i = 0; i < (wmi_record_max_length/ \ |
| 1156 | sizeof(uint32_t)); i++) \ |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1157 | outlen += wmi_bp_seq_printf(m, "%x ", \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1158 | wmi_record->data[i]); \ |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1159 | outlen += wmi_bp_seq_printf(m, "\n"); \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1160 | \ |
| 1161 | if (pos == 0) \ |
| 1162 | pos = wmi_ring_size - 1; \ |
| 1163 | else \ |
| 1164 | pos--; \ |
| 1165 | } \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1166 | return outlen; \ |
| 1167 | } |
| 1168 | |
| 1169 | GENERATE_COMMAND_DEBUG_SHOW_FUNCS(command_log, wmi_display_size); |
| 1170 | GENERATE_COMMAND_DEBUG_SHOW_FUNCS(command_tx_cmp_log, wmi_display_size); |
| 1171 | GENERATE_EVENT_DEBUG_SHOW_FUNCS(event_log, wmi_display_size); |
| 1172 | GENERATE_EVENT_DEBUG_SHOW_FUNCS(rx_event_log, wmi_display_size); |
| 1173 | GENERATE_COMMAND_DEBUG_SHOW_FUNCS(mgmt_command_log, wmi_display_size); |
| 1174 | GENERATE_COMMAND_DEBUG_SHOW_FUNCS(mgmt_command_tx_cmp_log, |
| 1175 | wmi_display_size); |
| 1176 | GENERATE_EVENT_DEBUG_SHOW_FUNCS(mgmt_event_log, wmi_display_size); |
| 1177 | |
| 1178 | /** |
| 1179 | * debug_wmi_enable_show() - debugfs functions to display enable state of |
| 1180 | * wmi logging feature. |
| 1181 | * |
| 1182 | * @m: debugfs handler to access wmi_handle |
| 1183 | * @v: Variable arguments (not used) |
| 1184 | * |
| 1185 | * Return: always 1 |
| 1186 | */ |
| 1187 | static int debug_wmi_enable_show(struct seq_file *m, void *v) |
| 1188 | { |
| 1189 | wmi_unified_t wmi_handle = (wmi_unified_t) m->private; |
| 1190 | |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1191 | return wmi_bp_seq_printf(m, "%d\n", |
| 1192 | wmi_handle->log_info.wmi_logging_enable); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1193 | } |
| 1194 | |
| 1195 | /** |
| 1196 | * debug_wmi_log_size_show() - debugfs functions to display configured size of |
| 1197 | * wmi logging command/event buffer and management command/event buffer. |
| 1198 | * |
| 1199 | * @m: debugfs handler to access wmi_handle |
| 1200 | * @v: Variable arguments (not used) |
| 1201 | * |
| 1202 | * Return: Length of characters printed |
| 1203 | */ |
| 1204 | static int debug_wmi_log_size_show(struct seq_file *m, void *v) |
| 1205 | { |
| 1206 | |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1207 | wmi_bp_seq_printf(m, "WMI command/event log max size:%d\n", |
| 1208 | wmi_log_max_entry); |
| 1209 | return wmi_bp_seq_printf(m, |
| 1210 | "WMI management command/events log max size:%d\n", |
| 1211 | wmi_mgmt_log_max_entry); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1212 | } |
| 1213 | |
| 1214 | /** |
| 1215 | * debug_wmi_##func_base##_write() - debugfs functions to clear |
| 1216 | * wmi logging command/event buffer and management command/event buffer. |
| 1217 | * |
| 1218 | * @file: file handler to access wmi_handle |
| 1219 | * @buf: received data buffer |
| 1220 | * @count: length of received buffer |
| 1221 | * @ppos: Not used |
| 1222 | * |
| 1223 | * Return: count |
| 1224 | */ |
| 1225 | #define GENERATE_DEBUG_WRITE_FUNCS(func_base, wmi_ring_size, wmi_record_type)\ |
| 1226 | static ssize_t debug_wmi_##func_base##_write(struct file *file, \ |
| 1227 | const char __user *buf, \ |
| 1228 | size_t count, loff_t *ppos) \ |
| 1229 | { \ |
| 1230 | int k, ret; \ |
Pratik Gandhi | dad75ff | 2017-01-16 12:50:27 +0530 | [diff] [blame] | 1231 | wmi_unified_t wmi_handle = \ |
| 1232 | ((struct seq_file *)file->private_data)->private;\ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1233 | struct wmi_log_buf_t *wmi_log = &wmi_handle->log_info. \ |
| 1234 | wmi_##func_base##_buf_info; \ |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1235 | char locbuf[50]; \ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1236 | \ |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1237 | if ((!buf) || (count > 50)) \ |
| 1238 | return -EFAULT; \ |
| 1239 | \ |
| 1240 | if (copy_from_user(locbuf, buf, count)) \ |
| 1241 | return -EFAULT; \ |
| 1242 | \ |
| 1243 | ret = sscanf(locbuf, "%d", &k); \ |
| 1244 | if ((ret != 1) || (k != 0)) { \ |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 1245 | WMI_LOGE("Wrong input, echo 0 to clear the wmi buffer");\ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1246 | return -EINVAL; \ |
| 1247 | } \ |
| 1248 | \ |
| 1249 | qdf_spin_lock(&wmi_handle->log_info.wmi_record_lock); \ |
| 1250 | qdf_mem_zero(wmi_log->buf, wmi_ring_size * \ |
| 1251 | sizeof(struct wmi_record_type)); \ |
| 1252 | wmi_log->length = 0; \ |
| 1253 | *(wmi_log->p_buf_tail_idx) = 0; \ |
| 1254 | qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock); \ |
| 1255 | \ |
| 1256 | return count; \ |
| 1257 | } |
| 1258 | |
| 1259 | GENERATE_DEBUG_WRITE_FUNCS(command_log, wmi_log_max_entry, |
| 1260 | wmi_command_debug); |
| 1261 | GENERATE_DEBUG_WRITE_FUNCS(command_tx_cmp_log, wmi_log_max_entry, |
| 1262 | wmi_command_debug); |
| 1263 | GENERATE_DEBUG_WRITE_FUNCS(event_log, wmi_log_max_entry, |
| 1264 | wmi_event_debug); |
| 1265 | GENERATE_DEBUG_WRITE_FUNCS(rx_event_log, wmi_log_max_entry, |
| 1266 | wmi_event_debug); |
| 1267 | GENERATE_DEBUG_WRITE_FUNCS(mgmt_command_log, wmi_mgmt_log_max_entry, |
| 1268 | wmi_command_debug); |
| 1269 | GENERATE_DEBUG_WRITE_FUNCS(mgmt_command_tx_cmp_log, |
| 1270 | wmi_mgmt_log_max_entry, wmi_command_debug); |
| 1271 | GENERATE_DEBUG_WRITE_FUNCS(mgmt_event_log, wmi_mgmt_log_max_entry, |
| 1272 | wmi_event_debug); |
| 1273 | |
| 1274 | /** |
| 1275 | * debug_wmi_enable_write() - debugfs functions to enable/disable |
| 1276 | * wmi logging feature. |
| 1277 | * |
| 1278 | * @file: file handler to access wmi_handle |
| 1279 | * @buf: received data buffer |
| 1280 | * @count: length of received buffer |
| 1281 | * @ppos: Not used |
| 1282 | * |
| 1283 | * Return: count |
| 1284 | */ |
| 1285 | static ssize_t debug_wmi_enable_write(struct file *file, const char __user *buf, |
| 1286 | size_t count, loff_t *ppos) |
| 1287 | { |
Pratik Gandhi | dad75ff | 2017-01-16 12:50:27 +0530 | [diff] [blame] | 1288 | wmi_unified_t wmi_handle = |
| 1289 | ((struct seq_file *)file->private_data)->private; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1290 | int k, ret; |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1291 | char locbuf[50]; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1292 | |
Pratik Gandhi | 795ab91 | 2017-05-03 20:15:50 +0530 | [diff] [blame] | 1293 | if ((!buf) || (count > 50)) |
| 1294 | return -EFAULT; |
| 1295 | |
| 1296 | if (copy_from_user(locbuf, buf, count)) |
| 1297 | return -EFAULT; |
| 1298 | |
| 1299 | ret = sscanf(locbuf, "%d", &k); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1300 | if ((ret != 1) || ((k != 0) && (k != 1))) |
| 1301 | return -EINVAL; |
| 1302 | |
| 1303 | wmi_handle->log_info.wmi_logging_enable = k; |
| 1304 | return count; |
| 1305 | } |
| 1306 | |
| 1307 | /** |
| 1308 | * debug_wmi_log_size_write() - reserved. |
| 1309 | * |
| 1310 | * @file: file handler to access wmi_handle |
| 1311 | * @buf: received data buffer |
| 1312 | * @count: length of received buffer |
| 1313 | * @ppos: Not used |
| 1314 | * |
| 1315 | * Return: count |
| 1316 | */ |
| 1317 | static ssize_t debug_wmi_log_size_write(struct file *file, |
| 1318 | const char __user *buf, size_t count, loff_t *ppos) |
| 1319 | { |
| 1320 | return -EINVAL; |
| 1321 | } |
| 1322 | |
| 1323 | /* Structure to maintain debug information */ |
| 1324 | struct wmi_debugfs_info { |
| 1325 | const char *name; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1326 | const struct file_operations *ops; |
| 1327 | }; |
| 1328 | |
| 1329 | #define DEBUG_FOO(func_base) { .name = #func_base, \ |
| 1330 | .ops = &debug_##func_base##_ops } |
| 1331 | |
| 1332 | /** |
| 1333 | * debug_##func_base##_open() - Open debugfs entry for respective command |
| 1334 | * and event buffer. |
| 1335 | * |
| 1336 | * @inode: node for debug dir entry |
| 1337 | * @file: file handler |
| 1338 | * |
| 1339 | * Return: open status |
| 1340 | */ |
| 1341 | #define GENERATE_DEBUG_STRUCTS(func_base) \ |
| 1342 | static int debug_##func_base##_open(struct inode *inode, \ |
| 1343 | struct file *file) \ |
| 1344 | { \ |
| 1345 | return single_open(file, debug_##func_base##_show, \ |
| 1346 | inode->i_private); \ |
| 1347 | } \ |
| 1348 | \ |
| 1349 | \ |
| 1350 | static struct file_operations debug_##func_base##_ops = { \ |
| 1351 | .open = debug_##func_base##_open, \ |
| 1352 | .read = seq_read, \ |
| 1353 | .llseek = seq_lseek, \ |
| 1354 | .write = debug_##func_base##_write, \ |
| 1355 | .release = single_release, \ |
| 1356 | }; |
| 1357 | |
| 1358 | GENERATE_DEBUG_STRUCTS(wmi_command_log); |
| 1359 | GENERATE_DEBUG_STRUCTS(wmi_command_tx_cmp_log); |
| 1360 | GENERATE_DEBUG_STRUCTS(wmi_event_log); |
| 1361 | GENERATE_DEBUG_STRUCTS(wmi_rx_event_log); |
| 1362 | GENERATE_DEBUG_STRUCTS(wmi_mgmt_command_log); |
| 1363 | GENERATE_DEBUG_STRUCTS(wmi_mgmt_command_tx_cmp_log); |
| 1364 | GENERATE_DEBUG_STRUCTS(wmi_mgmt_event_log); |
| 1365 | GENERATE_DEBUG_STRUCTS(wmi_enable); |
| 1366 | GENERATE_DEBUG_STRUCTS(wmi_log_size); |
| 1367 | |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 1368 | struct wmi_debugfs_info wmi_debugfs_infos[NUM_DEBUG_INFOS] = { |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1369 | DEBUG_FOO(wmi_command_log), |
| 1370 | DEBUG_FOO(wmi_command_tx_cmp_log), |
| 1371 | DEBUG_FOO(wmi_event_log), |
| 1372 | DEBUG_FOO(wmi_rx_event_log), |
| 1373 | DEBUG_FOO(wmi_mgmt_command_log), |
| 1374 | DEBUG_FOO(wmi_mgmt_command_tx_cmp_log), |
| 1375 | DEBUG_FOO(wmi_mgmt_event_log), |
| 1376 | DEBUG_FOO(wmi_enable), |
| 1377 | DEBUG_FOO(wmi_log_size), |
| 1378 | }; |
| 1379 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1380 | |
| 1381 | /** |
| 1382 | * wmi_debugfs_create() - Create debug_fs entry for wmi logging. |
| 1383 | * |
| 1384 | * @wmi_handle: wmi handle |
| 1385 | * @par_entry: debug directory entry |
| 1386 | * @id: Index to debug info data array |
| 1387 | * |
| 1388 | * Return: none |
| 1389 | */ |
| 1390 | static void wmi_debugfs_create(wmi_unified_t wmi_handle, |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 1391 | struct dentry *par_entry) |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1392 | { |
| 1393 | int i; |
| 1394 | |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 1395 | if (!par_entry) |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1396 | goto out; |
| 1397 | |
| 1398 | for (i = 0; i < NUM_DEBUG_INFOS; ++i) { |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 1399 | wmi_handle->debugfs_de[i] = debugfs_create_file( |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1400 | wmi_debugfs_infos[i].name, 0644, par_entry, |
| 1401 | wmi_handle, wmi_debugfs_infos[i].ops); |
| 1402 | |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 1403 | if (!wmi_handle->debugfs_de[i]) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 1404 | WMI_LOGE("debug Entry creation failed!"); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1405 | goto out; |
| 1406 | } |
| 1407 | } |
| 1408 | |
| 1409 | return; |
| 1410 | |
| 1411 | out: |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 1412 | WMI_LOGE("debug Entry creation failed!"); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1413 | wmi_log_buffer_free(wmi_handle); |
| 1414 | return; |
| 1415 | } |
| 1416 | |
| 1417 | /** |
| 1418 | * wmi_debugfs_remove() - Remove debugfs entry for wmi logging. |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1419 | * @wmi_handle: wmi handle |
| 1420 | * @dentry: debugfs directory entry |
| 1421 | * @id: Index to debug info data array |
| 1422 | * |
| 1423 | * Return: none |
| 1424 | */ |
Govind Singh | 06c1839 | 2016-06-10 10:33:19 +0530 | [diff] [blame] | 1425 | static void wmi_debugfs_remove(wmi_unified_t wmi_handle) |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1426 | { |
| 1427 | int i; |
Govind Singh | 06c1839 | 2016-06-10 10:33:19 +0530 | [diff] [blame] | 1428 | struct dentry *dentry = wmi_handle->log_info.wmi_log_debugfs_dir; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1429 | |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 1430 | if (dentry) { |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1431 | for (i = 0; i < NUM_DEBUG_INFOS; ++i) { |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 1432 | if (wmi_handle->debugfs_de[i]) |
| 1433 | wmi_handle->debugfs_de[i] = NULL; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1434 | } |
| 1435 | } |
| 1436 | |
| 1437 | if (dentry) |
| 1438 | debugfs_remove_recursive(dentry); |
| 1439 | } |
| 1440 | |
| 1441 | /** |
| 1442 | * wmi_debugfs_init() - debugfs functions to create debugfs directory and to |
| 1443 | * create debugfs enteries. |
| 1444 | * |
| 1445 | * @h: wmi handler |
| 1446 | * |
| 1447 | * Return: init status |
| 1448 | */ |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 1449 | static QDF_STATUS wmi_debugfs_init(wmi_unified_t wmi_handle, uint32_t pdev_idx) |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1450 | { |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 1451 | char buf[32]; |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1452 | |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 1453 | snprintf(buf, sizeof(buf), "WMI_SOC%u_PDEV%u", |
| 1454 | wmi_handle->soc->soc_idx, pdev_idx); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1455 | |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 1456 | wmi_handle->log_info.wmi_log_debugfs_dir = |
| 1457 | debugfs_create_dir(buf, NULL); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1458 | |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 1459 | if (!wmi_handle->log_info.wmi_log_debugfs_dir) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 1460 | WMI_LOGE("error while creating debugfs dir for %s", buf); |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 1461 | return QDF_STATUS_E_FAILURE; |
Rakesh Pillai | 24c7f8a | 2017-12-26 19:02:35 +0530 | [diff] [blame] | 1462 | } |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 1463 | wmi_debugfs_create(wmi_handle, |
| 1464 | wmi_handle->log_info.wmi_log_debugfs_dir); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1465 | |
| 1466 | return QDF_STATUS_SUCCESS; |
| 1467 | } |
Sandeep Puligilla | b74958d | 2016-06-13 15:42:55 -0700 | [diff] [blame] | 1468 | |
| 1469 | /** |
| 1470 | * wmi_mgmt_cmd_record() - Wrapper function for mgmt command logging macro |
| 1471 | * |
| 1472 | * @wmi_handle: wmi handle |
| 1473 | * @cmd: mgmt command |
Sandeep Puligilla | 828a45f | 2016-07-19 13:20:57 -0700 | [diff] [blame] | 1474 | * @header: pointer to 802.11 header |
Sandeep Puligilla | b74958d | 2016-06-13 15:42:55 -0700 | [diff] [blame] | 1475 | * @vdev_id: vdev id |
| 1476 | * @chanfreq: channel frequency |
| 1477 | * |
| 1478 | * Return: none |
| 1479 | */ |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 1480 | 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] | 1481 | void *header, uint32_t vdev_id, uint32_t chanfreq) |
Sandeep Puligilla | b74958d | 2016-06-13 15:42:55 -0700 | [diff] [blame] | 1482 | { |
Pratik Gandhi | 29e33f0 | 2016-09-16 01:32:51 +0530 | [diff] [blame] | 1483 | |
| 1484 | uint32_t data[CUSTOM_MGMT_CMD_DATA_SIZE]; |
| 1485 | |
| 1486 | data[0] = ((struct wmi_command_header *)header)->type; |
| 1487 | data[1] = ((struct wmi_command_header *)header)->sub_type; |
| 1488 | data[2] = vdev_id; |
| 1489 | data[3] = chanfreq; |
| 1490 | |
Sandeep Puligilla | b74958d | 2016-06-13 15:42:55 -0700 | [diff] [blame] | 1491 | qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock); |
| 1492 | |
Rakesh Pillai | 0511046 | 2017-12-27 14:08:59 +0530 | [diff] [blame] | 1493 | WMI_MGMT_COMMAND_RECORD(wmi_handle, cmd, (uint8_t *)data); |
Sandeep Puligilla | b74958d | 2016-06-13 15:42:55 -0700 | [diff] [blame] | 1494 | |
| 1495 | qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock); |
| 1496 | } |
Rajeev Kumar | ae91c40 | 2016-05-25 16:07:23 -0700 | [diff] [blame] | 1497 | #else |
| 1498 | /** |
| 1499 | * wmi_debugfs_remove() - Remove debugfs entry for wmi logging. |
| 1500 | * @wmi_handle: wmi handle |
| 1501 | * @dentry: debugfs directory entry |
| 1502 | * @id: Index to debug info data array |
| 1503 | * |
| 1504 | * Return: none |
| 1505 | */ |
Govind Singh | 06c1839 | 2016-06-10 10:33:19 +0530 | [diff] [blame] | 1506 | static void wmi_debugfs_remove(wmi_unified_t wmi_handle) { } |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 1507 | 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] | 1508 | void *header, uint32_t vdev_id, uint32_t chanfreq) { } |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 1509 | static inline void wmi_log_buffer_free(struct wmi_unified *wmi_handle) { } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1510 | #endif /*WMI_INTERFACE_EVENT_LOGGING */ |
Pratik Gandhi | 67da1bb | 2018-01-30 19:05:41 +0530 | [diff] [blame] | 1511 | qdf_export_symbol(wmi_mgmt_cmd_record); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1512 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1513 | int wmi_get_host_credits(wmi_unified_t wmi_handle); |
| 1514 | /* WMI buffer APIs */ |
| 1515 | |
Shiva Krishna Pittala | 7929337 | 2018-04-02 17:23:42 +0530 | [diff] [blame] | 1516 | #ifdef NBUF_MEMORY_DEBUG |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1517 | wmi_buf_t |
Debasis Das | eaf8a8b | 2018-04-04 17:17:55 +0530 | [diff] [blame] | 1518 | wmi_buf_alloc_debug(wmi_unified_t wmi_handle, uint32_t len, uint8_t *file_name, |
| 1519 | uint32_t line_num) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1520 | { |
| 1521 | wmi_buf_t wmi_buf; |
| 1522 | |
| 1523 | 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] | 1524 | QDF_ASSERT(0); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1525 | return NULL; |
| 1526 | } |
| 1527 | |
Rakshith Suresh Patkar | 539912b | 2018-10-05 15:21:37 +0530 | [diff] [blame] | 1528 | wmi_buf = wbuff_buff_get(wmi_handle->wbuff_handle, len, file_name, |
| 1529 | line_num); |
Rakshith Suresh Patkar | 9eb15ee | 2018-09-12 16:51:30 +0530 | [diff] [blame] | 1530 | if (!wmi_buf) |
| 1531 | wmi_buf = qdf_nbuf_alloc_debug(NULL, |
| 1532 | roundup(len + WMI_MIN_HEAD_ROOM, |
| 1533 | 4), |
| 1534 | WMI_MIN_HEAD_ROOM, 4, false, |
| 1535 | file_name, line_num); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1536 | |
| 1537 | if (!wmi_buf) |
| 1538 | return NULL; |
| 1539 | |
| 1540 | /* Clear the wmi buffer */ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1541 | OS_MEMZERO(qdf_nbuf_data(wmi_buf), len); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1542 | |
| 1543 | /* |
| 1544 | * Set the length of the buffer to match the allocation size. |
| 1545 | */ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1546 | qdf_nbuf_set_pktlen(wmi_buf, len); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1547 | |
| 1548 | return wmi_buf; |
| 1549 | } |
Pratik Gandhi | 67da1bb | 2018-01-30 19:05:41 +0530 | [diff] [blame] | 1550 | qdf_export_symbol(wmi_buf_alloc_debug); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1551 | |
| 1552 | void wmi_buf_free(wmi_buf_t net_buf) |
| 1553 | { |
Rakshith Suresh Patkar | 9eb15ee | 2018-09-12 16:51:30 +0530 | [diff] [blame] | 1554 | net_buf = wbuff_buff_put(net_buf); |
| 1555 | if (net_buf) |
| 1556 | qdf_nbuf_free(net_buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1557 | } |
Pratik Gandhi | 67da1bb | 2018-01-30 19:05:41 +0530 | [diff] [blame] | 1558 | qdf_export_symbol(wmi_buf_free); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1559 | #else |
Arif Hussain | 3f6ad3d | 2018-07-19 14:15:36 -0700 | [diff] [blame] | 1560 | wmi_buf_t wmi_buf_alloc_fl(wmi_unified_t wmi_handle, uint32_t len, |
| 1561 | const char *func, uint32_t line) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1562 | { |
| 1563 | wmi_buf_t wmi_buf; |
| 1564 | |
| 1565 | if (roundup(len + WMI_MIN_HEAD_ROOM, 4) > wmi_handle->max_msg_len) { |
Arif Hussain | 3f6ad3d | 2018-07-19 14:15:36 -0700 | [diff] [blame] | 1566 | wmi_nofl_err("%s:%d, Invalid len:%d", func, line, len); |
| 1567 | QDF_DEBUG_PANIC(); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1568 | return NULL; |
| 1569 | } |
| 1570 | |
Rakshith Suresh Patkar | 539912b | 2018-10-05 15:21:37 +0530 | [diff] [blame] | 1571 | wmi_buf = wbuff_buff_get(wmi_handle->wbuff_handle, len, __FILE__, |
| 1572 | __LINE__); |
Rakshith Suresh Patkar | 9eb15ee | 2018-09-12 16:51:30 +0530 | [diff] [blame] | 1573 | if (!wmi_buf) |
| 1574 | wmi_buf = qdf_nbuf_alloc_fl(NULL, roundup(len + |
| 1575 | WMI_MIN_HEAD_ROOM, 4), WMI_MIN_HEAD_ROOM, 4, |
| 1576 | false, func, line); |
| 1577 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1578 | if (!wmi_buf) |
| 1579 | return NULL; |
| 1580 | |
| 1581 | /* Clear the wmi buffer */ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1582 | OS_MEMZERO(qdf_nbuf_data(wmi_buf), len); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1583 | |
| 1584 | /* |
| 1585 | * Set the length of the buffer to match the allocation size. |
| 1586 | */ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1587 | qdf_nbuf_set_pktlen(wmi_buf, len); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1588 | return wmi_buf; |
| 1589 | } |
Arif Hussain | 3f6ad3d | 2018-07-19 14:15:36 -0700 | [diff] [blame] | 1590 | qdf_export_symbol(wmi_buf_alloc_fl); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1591 | |
| 1592 | void wmi_buf_free(wmi_buf_t net_buf) |
| 1593 | { |
Rakshith Suresh Patkar | 9eb15ee | 2018-09-12 16:51:30 +0530 | [diff] [blame] | 1594 | net_buf = wbuff_buff_put(net_buf); |
| 1595 | if (net_buf) |
| 1596 | qdf_nbuf_free(net_buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1597 | } |
Pratik Gandhi | 67da1bb | 2018-01-30 19:05:41 +0530 | [diff] [blame] | 1598 | qdf_export_symbol(wmi_buf_free); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1599 | #endif |
| 1600 | |
| 1601 | /** |
| 1602 | * wmi_get_max_msg_len() - get maximum WMI message length |
| 1603 | * @wmi_handle: WMI handle. |
| 1604 | * |
| 1605 | * This function returns the maximum WMI message length |
| 1606 | * |
| 1607 | * Return: maximum WMI message length |
| 1608 | */ |
| 1609 | uint16_t wmi_get_max_msg_len(wmi_unified_t wmi_handle) |
| 1610 | { |
| 1611 | return wmi_handle->max_msg_len - WMI_MIN_HEAD_ROOM; |
| 1612 | } |
Pratik Gandhi | 67da1bb | 2018-01-30 19:05:41 +0530 | [diff] [blame] | 1613 | qdf_export_symbol(wmi_get_max_msg_len); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1614 | |
Ashish Kumar Dhanotiya | 4f873ff | 2017-03-16 18:03:32 +0530 | [diff] [blame] | 1615 | #ifndef WMI_CMD_STRINGS |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 1616 | static uint8_t *wmi_id_to_name(uint32_t wmi_command) |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1617 | { |
| 1618 | return "Invalid WMI cmd"; |
| 1619 | } |
Ashish Kumar Dhanotiya | 4f873ff | 2017-03-16 18:03:32 +0530 | [diff] [blame] | 1620 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1621 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1622 | |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 1623 | #ifdef CONFIG_MCL |
Govind Singh | 2d8bfc6 | 2017-03-21 13:02:00 +0530 | [diff] [blame] | 1624 | static inline void wmi_log_cmd_id(uint32_t cmd_id, uint32_t tag) |
| 1625 | { |
| 1626 | WMI_LOGD("Send WMI command:%s command_id:%d htc_tag:%d\n", |
| 1627 | wmi_id_to_name(cmd_id), cmd_id, tag); |
| 1628 | } |
| 1629 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1630 | /** |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1631 | * wmi_is_pm_resume_cmd() - check if a cmd is part of the resume sequence |
| 1632 | * @cmd_id: command to check |
| 1633 | * |
| 1634 | * Return: true if the command is part of the resume sequence. |
| 1635 | */ |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 1636 | static bool wmi_is_pm_resume_cmd(uint32_t cmd_id) |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1637 | { |
| 1638 | switch (cmd_id) { |
| 1639 | case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID: |
| 1640 | case WMI_PDEV_RESUME_CMDID: |
| 1641 | return true; |
| 1642 | |
| 1643 | default: |
| 1644 | return false; |
| 1645 | } |
| 1646 | } |
| 1647 | #else |
Himanshu Agarwal | 7c83dcd | 2016-07-19 15:41:51 +0530 | [diff] [blame] | 1648 | static bool wmi_is_pm_resume_cmd(uint32_t cmd_id) |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1649 | { |
| 1650 | return false; |
| 1651 | } |
| 1652 | #endif |
| 1653 | |
Arif Hussain | 07d902a | 2018-07-19 15:05:16 -0700 | [diff] [blame] | 1654 | QDF_STATUS wmi_unified_cmd_send_fl(wmi_unified_t wmi_handle, wmi_buf_t buf, |
| 1655 | uint32_t len, uint32_t cmd_id, |
| 1656 | const char *func, uint32_t line) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1657 | { |
| 1658 | HTC_PACKET *pkt; |
Rakesh Pillai | 943a6c1 | 2017-06-22 12:52:31 +0530 | [diff] [blame] | 1659 | QDF_STATUS status; |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1660 | uint16_t htc_tag = 0; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1661 | |
| 1662 | if (wmi_get_runtime_pm_inprogress(wmi_handle)) { |
Sarada Prasanna Garnayak | 17b9e9e | 2017-01-05 19:30:07 +0530 | [diff] [blame] | 1663 | htc_tag = |
Vivek | c582309 | 2018-03-22 23:27:21 +0530 | [diff] [blame] | 1664 | (uint16_t)wmi_handle->ops->wmi_set_htc_tx_tag( |
Sarada Prasanna Garnayak | 17b9e9e | 2017-01-05 19:30:07 +0530 | [diff] [blame] | 1665 | wmi_handle, buf, cmd_id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1666 | } else if (qdf_atomic_read(&wmi_handle->is_target_suspended) && |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1667 | (!wmi_is_pm_resume_cmd(cmd_id))) { |
Arif Hussain | 07d902a | 2018-07-19 15:05:16 -0700 | [diff] [blame] | 1668 | wmi_nofl_err("%s:%d, Target is suspended", func, line); |
| 1669 | QDF_DEBUG_PANIC(); |
Govind Singh | 67922e8 | 2016-04-01 16:48:57 +0530 | [diff] [blame] | 1670 | return QDF_STATUS_E_BUSY; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1671 | } |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1672 | if (wmi_handle->wmi_stopinprogress) { |
Arif Hussain | 07d902a | 2018-07-19 15:05:16 -0700 | [diff] [blame] | 1673 | wmi_nofl_err("%s:%d, WMI stop in progress", func, line); |
Houston Hoffman | cdd5eda | 2016-09-27 23:29:49 -0700 | [diff] [blame] | 1674 | return QDF_STATUS_E_INVAL; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1675 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1676 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1677 | #ifndef WMI_NON_TLV_SUPPORT |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 1678 | /* Do sanity check on the TLV parameter structure */ |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1679 | if (wmi_handle->target_type == WMI_TLV_TARGET) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1680 | void *buf_ptr = (void *)qdf_nbuf_data(buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1681 | |
Pratik Gandhi | 67da1bb | 2018-01-30 19:05:41 +0530 | [diff] [blame] | 1682 | if (wmi_handle->ops->wmi_check_command_params(NULL, buf_ptr, len, cmd_id) |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1683 | != 0) { |
Arif Hussain | 07d902a | 2018-07-19 15:05:16 -0700 | [diff] [blame] | 1684 | wmi_nofl_err("%s:%d, Invalid WMI Param Buffer for Cmd:%d", |
| 1685 | func, line, cmd_id); |
Govind Singh | 67922e8 | 2016-04-01 16:48:57 +0530 | [diff] [blame] | 1686 | return QDF_STATUS_E_INVAL; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1687 | } |
| 1688 | } |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1689 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1690 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1691 | if (qdf_nbuf_push_head(buf, sizeof(WMI_CMD_HDR)) == NULL) { |
Arif Hussain | 07d902a | 2018-07-19 15:05:16 -0700 | [diff] [blame] | 1692 | wmi_nofl_err("%s:%d, Failed to send cmd %x, no memory", |
| 1693 | func, line, cmd_id); |
Govind Singh | 67922e8 | 2016-04-01 16:48:57 +0530 | [diff] [blame] | 1694 | return QDF_STATUS_E_NOMEM; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1695 | } |
| 1696 | |
Vignesh Viswanathan | 737cef7 | 2018-06-15 12:42:45 +0530 | [diff] [blame] | 1697 | qdf_mem_zero(qdf_nbuf_data(buf), sizeof(WMI_CMD_HDR)); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1698 | 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] | 1699 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1700 | qdf_atomic_inc(&wmi_handle->pending_cmds); |
Chaithanya Garrepalli | 6327e8a | 2017-12-01 14:55:26 +0530 | [diff] [blame] | 1701 | if (qdf_atomic_read(&wmi_handle->pending_cmds) >= |
| 1702 | wmi_handle->wmi_max_cmds) { |
Arif Hussain | 07d902a | 2018-07-19 15:05:16 -0700 | [diff] [blame] | 1703 | wmi_nofl_err("hostcredits = %d", |
| 1704 | wmi_get_host_credits(wmi_handle)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1705 | htc_dump_counter_info(wmi_handle->htc_handle); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1706 | qdf_atomic_dec(&wmi_handle->pending_cmds); |
Arif Hussain | 07d902a | 2018-07-19 15:05:16 -0700 | [diff] [blame] | 1707 | wmi_nofl_err("%s:%d, MAX %d WMI Pending cmds reached", |
| 1708 | func, line, wmi_handle->wmi_max_cmds); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1709 | QDF_BUG(0); |
Govind Singh | 67922e8 | 2016-04-01 16:48:57 +0530 | [diff] [blame] | 1710 | return QDF_STATUS_E_BUSY; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1711 | } |
| 1712 | |
Arif Hussain | 07d902a | 2018-07-19 15:05:16 -0700 | [diff] [blame] | 1713 | pkt = qdf_mem_malloc_fl(sizeof(*pkt), func, line); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1714 | if (!pkt) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1715 | qdf_atomic_dec(&wmi_handle->pending_cmds); |
Govind Singh | 67922e8 | 2016-04-01 16:48:57 +0530 | [diff] [blame] | 1716 | return QDF_STATUS_E_NOMEM; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1717 | } |
| 1718 | |
| 1719 | SET_HTC_PACKET_INFO_TX(pkt, |
| 1720 | NULL, |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1721 | qdf_nbuf_data(buf), len + sizeof(WMI_CMD_HDR), |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1722 | wmi_handle->wmi_endpoint_id, htc_tag); |
| 1723 | |
| 1724 | SET_HTC_PACKET_NET_BUF_CONTEXT(pkt, buf); |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 1725 | #ifdef CONFIG_MCL |
Govind Singh | 2d8bfc6 | 2017-03-21 13:02:00 +0530 | [diff] [blame] | 1726 | wmi_log_cmd_id(cmd_id, htc_tag); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1727 | #endif |
Venkat Karthik Kantamneni | bc8d329 | 2018-05-21 19:13:02 +0530 | [diff] [blame] | 1728 | wmi_ext_dbg_msg_cmd_record(wmi_handle, |
| 1729 | qdf_nbuf_data(buf), qdf_nbuf_len(buf)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1730 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1731 | if (wmi_handle->log_info.wmi_logging_enable) { |
| 1732 | qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock); |
jiad | 36c94d2 | 2018-01-22 15:37:03 +0800 | [diff] [blame] | 1733 | /* |
| 1734 | * Record 16 bytes of WMI cmd data - |
| 1735 | * exclude TLV and WMI headers |
| 1736 | * |
| 1737 | * WMI mgmt command already recorded in wmi_mgmt_cmd_record |
| 1738 | */ |
| 1739 | if (wmi_handle->ops->is_management_record(cmd_id) == false) { |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1740 | WMI_COMMAND_RECORD(wmi_handle, cmd_id, |
Rakesh Pillai | 0511046 | 2017-12-27 14:08:59 +0530 | [diff] [blame] | 1741 | qdf_nbuf_data(buf) + |
Pratik Gandhi | 44811d0 | 2018-10-10 12:12:32 +0530 | [diff] [blame] | 1742 | wmi_handle->soc->buf_offset_command); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1743 | } |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 1744 | qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock); |
| 1745 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1746 | #endif |
| 1747 | |
| 1748 | status = htc_send_pkt(wmi_handle->htc_handle, pkt); |
| 1749 | |
Rakesh Pillai | 943a6c1 | 2017-06-22 12:52:31 +0530 | [diff] [blame] | 1750 | if (QDF_STATUS_SUCCESS != status) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1751 | qdf_atomic_dec(&wmi_handle->pending_cmds); |
Arif Hussain | 07d902a | 2018-07-19 15:05:16 -0700 | [diff] [blame] | 1752 | wmi_nofl_err("%s:%d, htc_send_pkt failed, status:%d", |
| 1753 | func, line, status); |
Houston Hoffman | 40805b8 | 2016-10-13 15:30:52 -0700 | [diff] [blame] | 1754 | qdf_mem_free(pkt); |
Rakesh Pillai | 943a6c1 | 2017-06-22 12:52:31 +0530 | [diff] [blame] | 1755 | return status; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1756 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1757 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1758 | return QDF_STATUS_SUCCESS; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1759 | } |
Arif Hussain | 07d902a | 2018-07-19 15:05:16 -0700 | [diff] [blame] | 1760 | qdf_export_symbol(wmi_unified_cmd_send_fl); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1761 | |
| 1762 | /** |
| 1763 | * wmi_unified_get_event_handler_ix() - gives event handler's index |
| 1764 | * @wmi_handle: handle to wmi |
| 1765 | * @event_id: wmi event id |
| 1766 | * |
| 1767 | * Return: event handler's index |
| 1768 | */ |
Jeff Johnson | 9366d7a | 2016-10-07 13:03:02 -0700 | [diff] [blame] | 1769 | static int wmi_unified_get_event_handler_ix(wmi_unified_t wmi_handle, |
| 1770 | uint32_t event_id) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1771 | { |
| 1772 | uint32_t idx = 0; |
| 1773 | int32_t invalid_idx = -1; |
Kiran Venkatappa | f285aba | 2017-03-20 20:38:44 +0530 | [diff] [blame] | 1774 | struct wmi_soc *soc = wmi_handle->soc; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1775 | |
Kiran Venkatappa | f285aba | 2017-03-20 20:38:44 +0530 | [diff] [blame] | 1776 | for (idx = 0; (idx < soc->max_event_idx && |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1777 | idx < WMI_UNIFIED_MAX_EVENT); ++idx) { |
| 1778 | if (wmi_handle->event_id[idx] == event_id && |
| 1779 | wmi_handle->event_handler[idx] != NULL) { |
| 1780 | return idx; |
| 1781 | } |
| 1782 | } |
| 1783 | |
| 1784 | return invalid_idx; |
| 1785 | } |
| 1786 | |
| 1787 | /** |
Soumya Bhat | 488092d | 2017-03-22 14:41:01 +0530 | [diff] [blame] | 1788 | * wmi_unified_register_event() - register wmi event handler |
| 1789 | * @wmi_handle: handle to wmi |
| 1790 | * @event_id: wmi event id |
| 1791 | * @handler_func: wmi event handler function |
| 1792 | * |
| 1793 | * Return: 0 on success |
| 1794 | */ |
| 1795 | int wmi_unified_register_event(wmi_unified_t wmi_handle, |
| 1796 | uint32_t event_id, |
| 1797 | wmi_unified_event_handler handler_func) |
| 1798 | { |
| 1799 | uint32_t idx = 0; |
| 1800 | uint32_t evt_id; |
| 1801 | struct wmi_soc *soc = wmi_handle->soc; |
| 1802 | |
| 1803 | if (event_id >= wmi_events_max || |
| 1804 | wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) { |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 1805 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
| 1806 | "%s: Event id %d is unavailable", |
| 1807 | __func__, event_id); |
Soumya Bhat | 488092d | 2017-03-22 14:41:01 +0530 | [diff] [blame] | 1808 | return QDF_STATUS_E_FAILURE; |
| 1809 | } |
| 1810 | evt_id = wmi_handle->wmi_events[event_id]; |
| 1811 | if (wmi_unified_get_event_handler_ix(wmi_handle, evt_id) != -1) { |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 1812 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
| 1813 | "%s : event handler already registered 0x%x", |
| 1814 | __func__, evt_id); |
Soumya Bhat | 488092d | 2017-03-22 14:41:01 +0530 | [diff] [blame] | 1815 | return QDF_STATUS_E_FAILURE; |
| 1816 | } |
| 1817 | if (soc->max_event_idx == WMI_UNIFIED_MAX_EVENT) { |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 1818 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
| 1819 | "%s : no more event handlers 0x%x", |
| 1820 | __func__, evt_id); |
Soumya Bhat | 488092d | 2017-03-22 14:41:01 +0530 | [diff] [blame] | 1821 | return QDF_STATUS_E_FAILURE; |
| 1822 | } |
| 1823 | idx = soc->max_event_idx; |
| 1824 | wmi_handle->event_handler[idx] = handler_func; |
| 1825 | wmi_handle->event_id[idx] = evt_id; |
| 1826 | qdf_spin_lock_bh(&soc->ctx_lock); |
| 1827 | wmi_handle->ctx[idx] = WMI_RX_UMAC_CTX; |
| 1828 | qdf_spin_unlock_bh(&soc->ctx_lock); |
| 1829 | soc->max_event_idx++; |
| 1830 | |
| 1831 | return 0; |
| 1832 | } |
| 1833 | |
| 1834 | /** |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1835 | * wmi_unified_register_event_handler() - register wmi event handler |
| 1836 | * @wmi_handle: handle to wmi |
| 1837 | * @event_id: wmi event id |
| 1838 | * @handler_func: wmi event handler function |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1839 | * @rx_ctx: rx execution context for wmi rx events |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1840 | * |
Soumya Bhat | 488092d | 2017-03-22 14:41:01 +0530 | [diff] [blame] | 1841 | * This API is to support legacy requirements. Will be deprecated in future. |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1842 | * Return: 0 on success |
| 1843 | */ |
| 1844 | int wmi_unified_register_event_handler(wmi_unified_t wmi_handle, |
Mukul Sharma | 2c66f7e | 2017-11-03 19:26:54 +0530 | [diff] [blame] | 1845 | wmi_conv_event_id event_id, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1846 | wmi_unified_event_handler handler_func, |
| 1847 | uint8_t rx_ctx) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1848 | { |
| 1849 | uint32_t idx = 0; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1850 | uint32_t evt_id; |
Kiran Venkatappa | f285aba | 2017-03-20 20:38:44 +0530 | [diff] [blame] | 1851 | struct wmi_soc *soc = wmi_handle->soc; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1852 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1853 | if (event_id >= wmi_events_max || |
| 1854 | wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) { |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 1855 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
| 1856 | "%s: Event id %d is unavailable", |
| 1857 | __func__, event_id); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1858 | return QDF_STATUS_E_FAILURE; |
| 1859 | } |
| 1860 | evt_id = wmi_handle->wmi_events[event_id]; |
Mukul Sharma | 2c66f7e | 2017-11-03 19:26:54 +0530 | [diff] [blame] | 1861 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1862 | if (wmi_unified_get_event_handler_ix(wmi_handle, evt_id) != -1) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 1863 | WMI_LOGE("event handler already registered 0x%x", |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 1864 | evt_id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1865 | return QDF_STATUS_E_FAILURE; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1866 | } |
Kiran Venkatappa | f285aba | 2017-03-20 20:38:44 +0530 | [diff] [blame] | 1867 | if (soc->max_event_idx == WMI_UNIFIED_MAX_EVENT) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 1868 | WMI_LOGE("no more event handlers 0x%x", |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 1869 | evt_id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1870 | return QDF_STATUS_E_FAILURE; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1871 | } |
Adil Saeed Musthafa | 4f2c98f | 2017-07-05 14:43:51 -0700 | [diff] [blame] | 1872 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG, |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 1873 | "Registered event handler for event 0x%8x", evt_id); |
Kiran Venkatappa | f285aba | 2017-03-20 20:38:44 +0530 | [diff] [blame] | 1874 | idx = soc->max_event_idx; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1875 | wmi_handle->event_handler[idx] = handler_func; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1876 | wmi_handle->event_id[idx] = evt_id; |
Kiran Venkatappa | f285aba | 2017-03-20 20:38:44 +0530 | [diff] [blame] | 1877 | qdf_spin_lock_bh(&soc->ctx_lock); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1878 | wmi_handle->ctx[idx] = rx_ctx; |
Kiran Venkatappa | f285aba | 2017-03-20 20:38:44 +0530 | [diff] [blame] | 1879 | qdf_spin_unlock_bh(&soc->ctx_lock); |
| 1880 | soc->max_event_idx++; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1881 | |
| 1882 | return 0; |
| 1883 | } |
Pratik Gandhi | 67da1bb | 2018-01-30 19:05:41 +0530 | [diff] [blame] | 1884 | qdf_export_symbol(wmi_unified_register_event_handler); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1885 | |
| 1886 | /** |
Soumya Bhat | 8eb0b93 | 2017-03-27 12:26:56 +0530 | [diff] [blame] | 1887 | * wmi_unified_unregister_event() - unregister wmi event handler |
| 1888 | * @wmi_handle: handle to wmi |
| 1889 | * @event_id: wmi event id |
| 1890 | * |
| 1891 | * Return: 0 on success |
| 1892 | */ |
| 1893 | int wmi_unified_unregister_event(wmi_unified_t wmi_handle, |
| 1894 | uint32_t event_id) |
| 1895 | { |
| 1896 | uint32_t idx = 0; |
| 1897 | uint32_t evt_id; |
| 1898 | struct wmi_soc *soc = wmi_handle->soc; |
| 1899 | |
| 1900 | if (event_id >= wmi_events_max || |
| 1901 | wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) { |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 1902 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
| 1903 | "%s: Event id %d is unavailable", |
| 1904 | __func__, event_id); |
Soumya Bhat | 8eb0b93 | 2017-03-27 12:26:56 +0530 | [diff] [blame] | 1905 | return QDF_STATUS_E_FAILURE; |
| 1906 | } |
| 1907 | evt_id = wmi_handle->wmi_events[event_id]; |
| 1908 | |
| 1909 | idx = wmi_unified_get_event_handler_ix(wmi_handle, evt_id); |
| 1910 | if (idx == -1) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 1911 | WMI_LOGE("event handler is not registered: evt id 0x%x", |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 1912 | evt_id); |
Soumya Bhat | 8eb0b93 | 2017-03-27 12:26:56 +0530 | [diff] [blame] | 1913 | return QDF_STATUS_E_FAILURE; |
| 1914 | } |
| 1915 | wmi_handle->event_handler[idx] = NULL; |
| 1916 | wmi_handle->event_id[idx] = 0; |
| 1917 | --soc->max_event_idx; |
| 1918 | wmi_handle->event_handler[idx] = |
| 1919 | wmi_handle->event_handler[soc->max_event_idx]; |
| 1920 | wmi_handle->event_id[idx] = |
| 1921 | wmi_handle->event_id[soc->max_event_idx]; |
| 1922 | |
| 1923 | return 0; |
| 1924 | } |
| 1925 | |
| 1926 | /** |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1927 | * wmi_unified_unregister_event_handler() - unregister wmi event handler |
| 1928 | * @wmi_handle: handle to wmi |
| 1929 | * @event_id: wmi event id |
| 1930 | * |
| 1931 | * Return: 0 on success |
| 1932 | */ |
| 1933 | int wmi_unified_unregister_event_handler(wmi_unified_t wmi_handle, |
Mukul Sharma | 2c66f7e | 2017-11-03 19:26:54 +0530 | [diff] [blame] | 1934 | wmi_conv_event_id event_id) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1935 | { |
| 1936 | uint32_t idx = 0; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1937 | uint32_t evt_id; |
Kiran Venkatappa | f285aba | 2017-03-20 20:38:44 +0530 | [diff] [blame] | 1938 | struct wmi_soc *soc = wmi_handle->soc; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1939 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1940 | if (event_id >= wmi_events_max || |
| 1941 | wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 1942 | WMI_LOGE("Event id %d is unavailable", |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 1943 | event_id); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1944 | return QDF_STATUS_E_FAILURE; |
| 1945 | } |
| 1946 | evt_id = wmi_handle->wmi_events[event_id]; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1947 | |
| 1948 | idx = wmi_unified_get_event_handler_ix(wmi_handle, evt_id); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1949 | if (idx == -1) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 1950 | WMI_LOGE("event handler is not registered: evt id 0x%x", |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 1951 | evt_id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1952 | return QDF_STATUS_E_FAILURE; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1953 | } |
| 1954 | wmi_handle->event_handler[idx] = NULL; |
| 1955 | wmi_handle->event_id[idx] = 0; |
Kiran Venkatappa | f285aba | 2017-03-20 20:38:44 +0530 | [diff] [blame] | 1956 | --soc->max_event_idx; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1957 | wmi_handle->event_handler[idx] = |
Kiran Venkatappa | f285aba | 2017-03-20 20:38:44 +0530 | [diff] [blame] | 1958 | wmi_handle->event_handler[soc->max_event_idx]; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1959 | wmi_handle->event_id[idx] = |
Kiran Venkatappa | f285aba | 2017-03-20 20:38:44 +0530 | [diff] [blame] | 1960 | wmi_handle->event_id[soc->max_event_idx]; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1961 | |
| 1962 | return 0; |
| 1963 | } |
Pratik Gandhi | 67da1bb | 2018-01-30 19:05:41 +0530 | [diff] [blame] | 1964 | qdf_export_symbol(wmi_unified_unregister_event_handler); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1965 | |
| 1966 | /** |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1967 | * wmi_process_fw_event_default_ctx() - process in default caller context |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1968 | * @wmi_handle: handle to wmi |
| 1969 | * @htc_packet: pointer to htc packet |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1970 | * @exec_ctx: execution context for wmi fw event |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1971 | * |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1972 | * Event process by below function will be in default caller context. |
| 1973 | * wmi internally provides rx work thread processing context. |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1974 | * |
| 1975 | * Return: none |
| 1976 | */ |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1977 | static void wmi_process_fw_event_default_ctx(struct wmi_unified *wmi_handle, |
| 1978 | HTC_PACKET *htc_packet, uint8_t exec_ctx) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1979 | { |
| 1980 | wmi_buf_t evt_buf; |
| 1981 | evt_buf = (wmi_buf_t) htc_packet->pPktContext; |
| 1982 | |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 1983 | #ifndef CONFIG_MCL |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1984 | wmi_handle->rx_ops.wma_process_fw_event_handler_cbk |
| 1985 | (wmi_handle->scn_handle, evt_buf, exec_ctx); |
| 1986 | #else |
Govind Singh | 5eb5153 | 2016-03-09 11:34:12 +0530 | [diff] [blame] | 1987 | wmi_handle->rx_ops.wma_process_fw_event_handler_cbk(wmi_handle, |
Amar Singhal | 66d1ed5 | 2018-06-26 16:45:54 -0700 | [diff] [blame] | 1988 | htc_packet, exec_ctx); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 1989 | #endif |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1990 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1991 | return; |
| 1992 | } |
| 1993 | |
| 1994 | /** |
| 1995 | * wmi_process_fw_event_worker_thread_ctx() - process in worker thread context |
| 1996 | * @wmi_handle: handle to wmi |
| 1997 | * @htc_packet: pointer to htc packet |
| 1998 | * |
| 1999 | * Event process by below function will be in worker thread context. |
| 2000 | * Use this method for events which are not critical and not |
| 2001 | * handled in protocol stack. |
| 2002 | * |
| 2003 | * Return: none |
| 2004 | */ |
Amar Singhal | 66d1ed5 | 2018-06-26 16:45:54 -0700 | [diff] [blame] | 2005 | void wmi_process_fw_event_worker_thread_ctx(struct wmi_unified *wmi_handle, |
| 2006 | HTC_PACKET *htc_packet) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2007 | { |
| 2008 | wmi_buf_t evt_buf; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2009 | |
| 2010 | evt_buf = (wmi_buf_t) htc_packet->pPktContext; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2011 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2012 | qdf_spin_lock_bh(&wmi_handle->eventq_lock); |
| 2013 | qdf_nbuf_queue_add(&wmi_handle->event_queue, evt_buf); |
| 2014 | qdf_spin_unlock_bh(&wmi_handle->eventq_lock); |
Rajeev Kumar | 2ec8d47 | 2017-03-29 17:14:14 -0700 | [diff] [blame] | 2015 | qdf_queue_work(0, wmi_handle->wmi_rx_work_queue, |
| 2016 | &wmi_handle->rx_event_work); |
| 2017 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2018 | return; |
| 2019 | } |
| 2020 | |
Amar Singhal | 66d1ed5 | 2018-06-26 16:45:54 -0700 | [diff] [blame] | 2021 | qdf_export_symbol(wmi_process_fw_event_worker_thread_ctx); |
| 2022 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2023 | /** |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2024 | * wmi_get_pdev_ep: Get wmi handle based on endpoint |
| 2025 | * @soc: handle to wmi soc |
| 2026 | * @ep: endpoint id |
| 2027 | * |
| 2028 | * Return: none |
| 2029 | */ |
| 2030 | static struct wmi_unified *wmi_get_pdev_ep(struct wmi_soc *soc, |
| 2031 | HTC_ENDPOINT_ID ep) |
| 2032 | { |
| 2033 | uint32_t i; |
| 2034 | |
| 2035 | for (i = 0; i < WMI_MAX_RADIOS; i++) |
| 2036 | if (soc->wmi_endpoint_id[i] == ep) |
| 2037 | break; |
| 2038 | |
| 2039 | if (i == WMI_MAX_RADIOS) |
| 2040 | return NULL; |
| 2041 | |
| 2042 | return soc->wmi_pdev[i]; |
| 2043 | } |
| 2044 | |
| 2045 | /** |
gaurank kathpalia | 496e66e | 2018-08-03 12:00:12 +0530 | [diff] [blame] | 2046 | * wmi_mtrace_rx() - Wrappper function for qdf_mtrace api |
| 2047 | * @message_id: 32-Bit Wmi message ID |
| 2048 | * @vdev_id: Vdev ID |
| 2049 | * @data: Actual message contents |
| 2050 | * |
| 2051 | * This function converts the 32-bit WMI message ID in 15-bit message ID |
| 2052 | * format for qdf_mtrace as in qdf_mtrace message there are only 15 |
| 2053 | * bits reserved for message ID. |
| 2054 | * out of these 15-bits, 8-bits (From LSB) specifies the WMI_GRP_ID |
| 2055 | * and remaining 7-bits specifies the actual WMI command. With this |
| 2056 | * notation there can be maximum 256 groups and each group can have |
| 2057 | * max 128 commands can be supported. |
| 2058 | * |
| 2059 | * Return: None |
| 2060 | */ |
| 2061 | static void wmi_mtrace_rx(uint32_t message_id, uint16_t vdev_id, uint32_t data) |
| 2062 | { |
| 2063 | uint16_t mtrace_message_id; |
| 2064 | |
| 2065 | mtrace_message_id = QDF_WMI_MTRACE_CMD_ID(message_id) | |
| 2066 | (QDF_WMI_MTRACE_GRP_ID(message_id) << |
| 2067 | QDF_WMI_MTRACE_CMD_NUM_BITS); |
| 2068 | qdf_mtrace(QDF_MODULE_ID_WMI, QDF_MODULE_ID_WMA, |
| 2069 | mtrace_message_id, vdev_id, data); |
| 2070 | } |
| 2071 | |
| 2072 | /** |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2073 | * wmi_control_rx() - process fw events callbacks |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2074 | * @ctx: handle to wmi |
| 2075 | * @htc_packet: pointer to htc packet |
| 2076 | * |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2077 | * Return: none |
| 2078 | */ |
Jeff Johnson | 9366d7a | 2016-10-07 13:03:02 -0700 | [diff] [blame] | 2079 | static void wmi_control_rx(void *ctx, HTC_PACKET *htc_packet) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2080 | { |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2081 | struct wmi_soc *soc = (struct wmi_soc *) ctx; |
| 2082 | struct wmi_unified *wmi_handle; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2083 | wmi_buf_t evt_buf; |
| 2084 | uint32_t id; |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2085 | uint32_t idx = 0; |
| 2086 | enum wmi_rx_exec_ctx exec_ctx; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2087 | |
| 2088 | evt_buf = (wmi_buf_t) htc_packet->pPktContext; |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2089 | |
| 2090 | wmi_handle = wmi_get_pdev_ep(soc, htc_packet->Endpoint); |
| 2091 | if (wmi_handle == NULL) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 2092 | WMI_LOGE |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 2093 | ("unable to get wmi_handle to Endpoint %d\n", |
| 2094 | htc_packet->Endpoint); |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2095 | qdf_nbuf_free(evt_buf); |
| 2096 | return; |
| 2097 | } |
| 2098 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2099 | 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] | 2100 | idx = wmi_unified_get_event_handler_ix(wmi_handle, id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2101 | if (qdf_unlikely(idx == A_ERROR)) { |
Dustin Brown | e7110f0 | 2018-10-30 10:00:37 -0700 | [diff] [blame] | 2102 | wmi_debug("no handler registered for event id 0x%x", id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2103 | qdf_nbuf_free(evt_buf); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2104 | return; |
| 2105 | } |
gaurank kathpalia | 496e66e | 2018-08-03 12:00:12 +0530 | [diff] [blame] | 2106 | wmi_mtrace_rx(id, 0xFF, idx); |
Kiran Venkatappa | f285aba | 2017-03-20 20:38:44 +0530 | [diff] [blame] | 2107 | qdf_spin_lock_bh(&soc->ctx_lock); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2108 | exec_ctx = wmi_handle->ctx[idx]; |
Kiran Venkatappa | f285aba | 2017-03-20 20:38:44 +0530 | [diff] [blame] | 2109 | qdf_spin_unlock_bh(&soc->ctx_lock); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2110 | |
Houston Hoffman | c85276b | 2017-10-11 14:50:30 -0700 | [diff] [blame] | 2111 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
| 2112 | if (wmi_handle->log_info.wmi_logging_enable) { |
| 2113 | uint8_t *data; |
| 2114 | data = qdf_nbuf_data(evt_buf); |
| 2115 | |
| 2116 | qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock); |
| 2117 | /* Exclude 4 bytes of TLV header */ |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 2118 | if (wmi_handle->ops->is_diag_event(id)) { |
| 2119 | WMI_DIAG_RX_EVENT_RECORD(wmi_handle, id, |
| 2120 | ((uint8_t *) data + |
Pratik Gandhi | 44811d0 | 2018-10-10 12:12:32 +0530 | [diff] [blame] | 2121 | wmi_handle->soc->buf_offset_event)); |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 2122 | } else if (wmi_handle->ops->is_management_record(id)) { |
| 2123 | WMI_MGMT_RX_EVENT_RECORD(wmi_handle, id, |
| 2124 | ((uint8_t *) data + |
Pratik Gandhi | 44811d0 | 2018-10-10 12:12:32 +0530 | [diff] [blame] | 2125 | wmi_handle->soc->buf_offset_event)); |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 2126 | } else { |
| 2127 | WMI_RX_EVENT_RECORD(wmi_handle, id, ((uint8_t *) data + |
Pratik Gandhi | 44811d0 | 2018-10-10 12:12:32 +0530 | [diff] [blame] | 2128 | wmi_handle->soc->buf_offset_event)); |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 2129 | } |
Houston Hoffman | c85276b | 2017-10-11 14:50:30 -0700 | [diff] [blame] | 2130 | qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock); |
| 2131 | } |
| 2132 | #endif |
| 2133 | |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2134 | if (exec_ctx == WMI_RX_WORK_CTX) { |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2135 | wmi_process_fw_event_worker_thread_ctx |
| 2136 | (wmi_handle, htc_packet); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2137 | } else if (exec_ctx > WMI_RX_WORK_CTX) { |
| 2138 | wmi_process_fw_event_default_ctx |
| 2139 | (wmi_handle, htc_packet, exec_ctx); |
| 2140 | } else { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 2141 | WMI_LOGE("Invalid event context %d", exec_ctx); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2142 | qdf_nbuf_free(evt_buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2143 | } |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2144 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2145 | } |
| 2146 | |
| 2147 | /** |
| 2148 | * wmi_process_fw_event() - process any fw event |
| 2149 | * @wmi_handle: wmi handle |
| 2150 | * @evt_buf: fw event buffer |
| 2151 | * |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2152 | * This function process fw event in caller context |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2153 | * |
| 2154 | * Return: none |
| 2155 | */ |
| 2156 | void wmi_process_fw_event(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf) |
| 2157 | { |
| 2158 | __wmi_control_rx(wmi_handle, evt_buf); |
| 2159 | } |
| 2160 | |
| 2161 | /** |
| 2162 | * __wmi_control_rx() - process serialize wmi event callback |
| 2163 | * @wmi_handle: wmi handle |
| 2164 | * @evt_buf: fw event buffer |
| 2165 | * |
| 2166 | * Return: none |
| 2167 | */ |
| 2168 | void __wmi_control_rx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf) |
| 2169 | { |
| 2170 | uint32_t id; |
| 2171 | uint8_t *data; |
| 2172 | uint32_t len; |
| 2173 | void *wmi_cmd_struct_ptr = NULL; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2174 | #ifndef WMI_NON_TLV_SUPPORT |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2175 | int tlv_ok_status = 0; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2176 | #endif |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2177 | uint32_t idx = 0; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2178 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2179 | 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] | 2180 | |
Venkat Karthik Kantamneni | bc8d329 | 2018-05-21 19:13:02 +0530 | [diff] [blame] | 2181 | wmi_ext_dbg_msg_event_record(wmi_handle, qdf_nbuf_data(evt_buf), |
| 2182 | qdf_nbuf_len(evt_buf)); |
| 2183 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2184 | if (qdf_nbuf_pull_head(evt_buf, sizeof(WMI_CMD_HDR)) == NULL) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2185 | goto end; |
| 2186 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2187 | data = qdf_nbuf_data(evt_buf); |
| 2188 | len = qdf_nbuf_len(evt_buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2189 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2190 | #ifndef WMI_NON_TLV_SUPPORT |
| 2191 | if (wmi_handle->target_type == WMI_TLV_TARGET) { |
| 2192 | /* Validate and pad(if necessary) the TLVs */ |
| 2193 | tlv_ok_status = |
Pratik Gandhi | 67da1bb | 2018-01-30 19:05:41 +0530 | [diff] [blame] | 2194 | wmi_handle->ops->wmi_check_and_pad_event(wmi_handle->scn_handle, |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2195 | data, len, id, |
| 2196 | &wmi_cmd_struct_ptr); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2197 | if (tlv_ok_status != 0) { |
| 2198 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 2199 | "%s: Error: id=0x%x, wmitlv check status=%d", |
| 2200 | __func__, id, tlv_ok_status); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2201 | goto end; |
| 2202 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2203 | } |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2204 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2205 | |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2206 | idx = wmi_unified_get_event_handler_ix(wmi_handle, id); |
| 2207 | if (idx == A_ERROR) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2208 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 2209 | "%s : event handler is not registered: event id 0x%x", |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2210 | __func__, id); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2211 | goto end; |
| 2212 | } |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2213 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2214 | if (wmi_handle->log_info.wmi_logging_enable) { |
| 2215 | qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock); |
| 2216 | /* Exclude 4 bytes of TLV header */ |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 2217 | if (wmi_handle->ops->is_diag_event(id)) { |
| 2218 | /* |
| 2219 | * skip diag event logging in WMI event buffer |
| 2220 | * as its already logged in WMI RX event buffer |
| 2221 | */ |
| 2222 | } else if (wmi_handle->ops->is_management_record(id)) { |
| 2223 | /* |
| 2224 | * skip wmi mgmt event logging in WMI event buffer |
| 2225 | * as its already logged in WMI RX event buffer |
| 2226 | */ |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2227 | } else { |
Rajeev Kumar | b64e128 | 2018-09-19 13:02:23 -0700 | [diff] [blame] | 2228 | WMI_EVENT_RECORD(wmi_handle, id, ((uint8_t *) data + |
Pratik Gandhi | 44811d0 | 2018-10-10 12:12:32 +0530 | [diff] [blame] | 2229 | wmi_handle->soc->buf_offset_event)); |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2230 | } |
| 2231 | qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2232 | } |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2233 | #endif |
| 2234 | /* Call the WMI registered event handler */ |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2235 | if (wmi_handle->target_type == WMI_TLV_TARGET) |
| 2236 | wmi_handle->event_handler[idx] (wmi_handle->scn_handle, |
| 2237 | wmi_cmd_struct_ptr, len); |
| 2238 | else |
| 2239 | wmi_handle->event_handler[idx] (wmi_handle->scn_handle, |
| 2240 | data, len); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2241 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2242 | end: |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2243 | /* Free event buffer and allocated event tlv */ |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2244 | #ifndef WMI_NON_TLV_SUPPORT |
| 2245 | if (wmi_handle->target_type == WMI_TLV_TARGET) |
Pratik Gandhi | 67da1bb | 2018-01-30 19:05:41 +0530 | [diff] [blame] | 2246 | wmi_handle->ops->wmi_free_allocated_event(id, &wmi_cmd_struct_ptr); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2247 | #endif |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 2248 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2249 | qdf_nbuf_free(evt_buf); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2250 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2251 | } |
| 2252 | |
Arunk Khandavalli | b6ba21f | 2017-12-06 15:47:10 +0530 | [diff] [blame] | 2253 | #define WMI_WQ_WD_TIMEOUT (30 * 1000) /* 30s */ |
Govind Singh | 97b8e7c | 2017-09-07 18:23:39 +0530 | [diff] [blame] | 2254 | |
Surabhi Vishnoi | 209f7d4 | 2017-11-29 15:07:10 +0530 | [diff] [blame] | 2255 | static inline void wmi_workqueue_watchdog_warn(uint32_t msg_type_id) |
Govind Singh | 97b8e7c | 2017-09-07 18:23:39 +0530 | [diff] [blame] | 2256 | { |
| 2257 | QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, |
Kabilan Kannan | f1311ec | 2018-03-08 14:34:28 -0800 | [diff] [blame] | 2258 | "%s: WLAN_BUG_RCA: Message type %x has exceeded its alloted time of %ds", |
Govind Singh | 97b8e7c | 2017-09-07 18:23:39 +0530 | [diff] [blame] | 2259 | __func__, msg_type_id, WMI_WQ_WD_TIMEOUT / 1000); |
| 2260 | } |
| 2261 | |
| 2262 | #ifdef CONFIG_SLUB_DEBUG_ON |
| 2263 | static void wmi_workqueue_watchdog_bite(void *arg) |
| 2264 | { |
Govind Singh | c646e10 | 2017-11-21 10:53:40 +0530 | [diff] [blame] | 2265 | struct wmi_wq_dbg_info *info = arg; |
| 2266 | |
| 2267 | wmi_workqueue_watchdog_warn(info->wd_msg_type_id); |
| 2268 | qdf_print_thread_trace(info->task); |
| 2269 | |
Govind Singh | 97b8e7c | 2017-09-07 18:23:39 +0530 | [diff] [blame] | 2270 | QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, |
| 2271 | "%s: Going down for WMI WQ Watchdog Bite!", __func__); |
| 2272 | QDF_BUG(0); |
| 2273 | } |
| 2274 | #else |
| 2275 | static inline void wmi_workqueue_watchdog_bite(void *arg) |
| 2276 | { |
Govind Singh | c646e10 | 2017-11-21 10:53:40 +0530 | [diff] [blame] | 2277 | struct wmi_wq_dbg_info *info = arg; |
| 2278 | |
| 2279 | wmi_workqueue_watchdog_warn(info->wd_msg_type_id); |
Govind Singh | 97b8e7c | 2017-09-07 18:23:39 +0530 | [diff] [blame] | 2280 | } |
| 2281 | #endif |
| 2282 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2283 | /** |
| 2284 | * wmi_rx_event_work() - process rx event in rx work queue context |
Rajeev Kumar | 2ec8d47 | 2017-03-29 17:14:14 -0700 | [diff] [blame] | 2285 | * @arg: opaque pointer to wmi handle |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2286 | * |
| 2287 | * This function process any fw event to serialize it through rx worker thread. |
| 2288 | * |
| 2289 | * Return: none |
| 2290 | */ |
Rajeev Kumar | 2ec8d47 | 2017-03-29 17:14:14 -0700 | [diff] [blame] | 2291 | static void wmi_rx_event_work(void *arg) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2292 | { |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2293 | wmi_buf_t buf; |
Rajeev Kumar | 2ec8d47 | 2017-03-29 17:14:14 -0700 | [diff] [blame] | 2294 | struct wmi_unified *wmi = arg; |
Govind Singh | 97b8e7c | 2017-09-07 18:23:39 +0530 | [diff] [blame] | 2295 | qdf_timer_t wd_timer; |
Govind Singh | c646e10 | 2017-11-21 10:53:40 +0530 | [diff] [blame] | 2296 | struct wmi_wq_dbg_info info; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2297 | |
Govind Singh | 97b8e7c | 2017-09-07 18:23:39 +0530 | [diff] [blame] | 2298 | /* initialize WMI workqueue watchdog timer */ |
| 2299 | qdf_timer_init(NULL, &wd_timer, &wmi_workqueue_watchdog_bite, |
Govind Singh | c646e10 | 2017-11-21 10:53:40 +0530 | [diff] [blame] | 2300 | &info, QDF_TIMER_TYPE_SW); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2301 | qdf_spin_lock_bh(&wmi->eventq_lock); |
| 2302 | buf = qdf_nbuf_queue_remove(&wmi->event_queue); |
| 2303 | qdf_spin_unlock_bh(&wmi->eventq_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2304 | while (buf) { |
Govind Singh | 97b8e7c | 2017-09-07 18:23:39 +0530 | [diff] [blame] | 2305 | qdf_timer_start(&wd_timer, WMI_WQ_WD_TIMEOUT); |
Govind Singh | c646e10 | 2017-11-21 10:53:40 +0530 | [diff] [blame] | 2306 | info.wd_msg_type_id = |
Govind Singh | 97b8e7c | 2017-09-07 18:23:39 +0530 | [diff] [blame] | 2307 | WMI_GET_FIELD(qdf_nbuf_data(buf), WMI_CMD_HDR, COMMANDID); |
Govind Singh | c646e10 | 2017-11-21 10:53:40 +0530 | [diff] [blame] | 2308 | info.wmi_wq = wmi->wmi_rx_work_queue; |
| 2309 | info.task = qdf_get_current_task(); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2310 | __wmi_control_rx(wmi, buf); |
Govind Singh | 97b8e7c | 2017-09-07 18:23:39 +0530 | [diff] [blame] | 2311 | qdf_timer_stop(&wd_timer); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2312 | qdf_spin_lock_bh(&wmi->eventq_lock); |
| 2313 | buf = qdf_nbuf_queue_remove(&wmi->event_queue); |
| 2314 | qdf_spin_unlock_bh(&wmi->eventq_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2315 | } |
Govind Singh | 97b8e7c | 2017-09-07 18:23:39 +0530 | [diff] [blame] | 2316 | qdf_timer_free(&wd_timer); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2317 | } |
| 2318 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2319 | #ifdef FEATURE_RUNTIME_PM |
| 2320 | /** |
| 2321 | * wmi_runtime_pm_init() - initialize runtime pm wmi variables |
| 2322 | * @wmi_handle: wmi context |
| 2323 | */ |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2324 | static void wmi_runtime_pm_init(struct wmi_unified *wmi_handle) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2325 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2326 | qdf_atomic_init(&wmi_handle->runtime_pm_inprogress); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2327 | } |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2328 | |
| 2329 | /** |
| 2330 | * wmi_set_runtime_pm_inprogress() - set runtime pm progress flag |
| 2331 | * @wmi_handle: wmi context |
| 2332 | * @val: runtime pm progress flag |
| 2333 | */ |
| 2334 | void wmi_set_runtime_pm_inprogress(wmi_unified_t wmi_handle, A_BOOL val) |
| 2335 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2336 | qdf_atomic_set(&wmi_handle->runtime_pm_inprogress, val); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2337 | } |
| 2338 | |
| 2339 | /** |
| 2340 | * wmi_get_runtime_pm_inprogress() - get runtime pm progress flag |
| 2341 | * @wmi_handle: wmi context |
| 2342 | */ |
| 2343 | inline bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle) |
| 2344 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2345 | return qdf_atomic_read(&wmi_handle->runtime_pm_inprogress); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2346 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2347 | #else |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 2348 | static void wmi_runtime_pm_init(struct wmi_unified *wmi_handle) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2349 | { |
| 2350 | } |
| 2351 | #endif |
| 2352 | |
| 2353 | /** |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2354 | * wmi_unified_get_soc_handle: Get WMI SoC handle |
| 2355 | * @param wmi_handle: WMI context got from wmi_attach |
| 2356 | * |
| 2357 | * return: Pointer to Soc handle |
| 2358 | */ |
| 2359 | void *wmi_unified_get_soc_handle(struct wmi_unified *wmi_handle) |
| 2360 | { |
| 2361 | return wmi_handle->soc; |
| 2362 | } |
| 2363 | |
| 2364 | /** |
| 2365 | * wmi_interface_logging_init: Interface looging init |
| 2366 | * @param wmi_handle: Pointer to wmi handle object |
| 2367 | * |
| 2368 | * return: None |
| 2369 | */ |
| 2370 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 2371 | static inline void wmi_interface_logging_init(struct wmi_unified *wmi_handle, |
| 2372 | uint32_t pdev_idx) |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2373 | { |
| 2374 | if (QDF_STATUS_SUCCESS == wmi_log_init(wmi_handle)) { |
| 2375 | qdf_spinlock_create(&wmi_handle->log_info.wmi_record_lock); |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 2376 | wmi_debugfs_init(wmi_handle, pdev_idx); |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2377 | } |
| 2378 | } |
| 2379 | #else |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 2380 | static inline void wmi_interface_logging_init(struct wmi_unified *wmi_handle, |
| 2381 | uint32_t pdev_idx) |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2382 | { |
| 2383 | } |
| 2384 | #endif |
| 2385 | |
| 2386 | /** |
| 2387 | * wmi_target_params_init: Target specific params init |
| 2388 | * @param wmi_soc: Pointer to wmi soc object |
| 2389 | * @param wmi_handle: Pointer to wmi handle object |
| 2390 | * |
| 2391 | * return: None |
| 2392 | */ |
| 2393 | #ifndef CONFIG_MCL |
| 2394 | static inline void wmi_target_params_init(struct wmi_soc *soc, |
| 2395 | struct wmi_unified *wmi_handle) |
| 2396 | { |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2397 | wmi_handle->pdev_param = soc->pdev_param; |
| 2398 | wmi_handle->vdev_param = soc->vdev_param; |
Kris Muthusamy | 76e2241 | 2018-01-26 16:18:37 -0800 | [diff] [blame] | 2399 | wmi_handle->services = soc->services; |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2400 | } |
| 2401 | #else |
| 2402 | static inline void wmi_target_params_init(struct wmi_soc *soc, |
| 2403 | struct wmi_unified *wmi_handle) |
| 2404 | { |
Kris Muthusamy | 76e2241 | 2018-01-26 16:18:37 -0800 | [diff] [blame] | 2405 | wmi_handle->services = soc->services; |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2406 | } |
| 2407 | #endif |
| 2408 | |
| 2409 | /** |
| 2410 | * wmi_unified_get_pdev_handle: Get WMI SoC handle |
| 2411 | * @param wmi_soc: Pointer to wmi soc object |
| 2412 | * @param pdev_idx: pdev index |
| 2413 | * |
| 2414 | * return: Pointer to wmi handle or NULL on failure |
| 2415 | */ |
| 2416 | void *wmi_unified_get_pdev_handle(struct wmi_soc *soc, uint32_t pdev_idx) |
| 2417 | { |
| 2418 | struct wmi_unified *wmi_handle; |
| 2419 | |
| 2420 | if (pdev_idx >= WMI_MAX_RADIOS) |
| 2421 | return NULL; |
| 2422 | |
Kiran Venkatappa | ea88a4e | 2017-06-15 17:27:38 +0530 | [diff] [blame] | 2423 | if (soc->wmi_pdev[pdev_idx] == NULL) { |
| 2424 | wmi_handle = |
| 2425 | (struct wmi_unified *) qdf_mem_malloc( |
| 2426 | sizeof(struct wmi_unified)); |
| 2427 | if (wmi_handle == NULL) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 2428 | WMI_LOGE("allocation of wmi handle failed %zu", |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 2429 | sizeof(struct wmi_unified)); |
Kiran Venkatappa | ea88a4e | 2017-06-15 17:27:38 +0530 | [diff] [blame] | 2430 | return NULL; |
| 2431 | } |
| 2432 | wmi_handle->scn_handle = soc->scn_handle; |
| 2433 | wmi_handle->event_id = soc->event_id; |
| 2434 | wmi_handle->event_handler = soc->event_handler; |
| 2435 | wmi_handle->ctx = soc->ctx; |
| 2436 | wmi_handle->ops = soc->ops; |
| 2437 | qdf_spinlock_create(&wmi_handle->eventq_lock); |
| 2438 | qdf_nbuf_queue_init(&wmi_handle->event_queue); |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2439 | |
Kiran Venkatappa | ea88a4e | 2017-06-15 17:27:38 +0530 | [diff] [blame] | 2440 | qdf_create_work(0, &wmi_handle->rx_event_work, |
| 2441 | wmi_rx_event_work, wmi_handle); |
| 2442 | wmi_handle->wmi_rx_work_queue = |
Shashikala Prabhu | d73876f | 2018-11-20 17:53:05 +0530 | [diff] [blame] | 2443 | qdf_alloc_unbound_workqueue("wmi_rx_event_work_queue"); |
Kiran Venkatappa | ea88a4e | 2017-06-15 17:27:38 +0530 | [diff] [blame] | 2444 | if (NULL == wmi_handle->wmi_rx_work_queue) { |
| 2445 | WMI_LOGE("failed to create wmi_rx_event_work_queue"); |
| 2446 | goto error; |
| 2447 | } |
| 2448 | wmi_handle->wmi_events = soc->wmi_events; |
| 2449 | wmi_target_params_init(soc, wmi_handle); |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 2450 | wmi_handle->soc = soc; |
| 2451 | wmi_interface_logging_init(wmi_handle, pdev_idx); |
Kiran Venkatappa | ea88a4e | 2017-06-15 17:27:38 +0530 | [diff] [blame] | 2452 | qdf_atomic_init(&wmi_handle->pending_cmds); |
| 2453 | qdf_atomic_init(&wmi_handle->is_target_suspended); |
| 2454 | wmi_handle->target_type = soc->target_type; |
Chaithanya Garrepalli | 6327e8a | 2017-12-01 14:55:26 +0530 | [diff] [blame] | 2455 | wmi_handle->wmi_max_cmds = soc->wmi_max_cmds; |
Rajeev Kumar | 2ec8d47 | 2017-03-29 17:14:14 -0700 | [diff] [blame] | 2456 | |
Kiran Venkatappa | ea88a4e | 2017-06-15 17:27:38 +0530 | [diff] [blame] | 2457 | soc->wmi_pdev[pdev_idx] = wmi_handle; |
| 2458 | } else |
| 2459 | wmi_handle = soc->wmi_pdev[pdev_idx]; |
| 2460 | |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2461 | wmi_handle->wmi_stopinprogress = 0; |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2462 | wmi_handle->wmi_endpoint_id = soc->wmi_endpoint_id[pdev_idx]; |
| 2463 | wmi_handle->htc_handle = soc->htc_handle; |
| 2464 | wmi_handle->max_msg_len = soc->max_msg_len[pdev_idx]; |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2465 | |
| 2466 | return wmi_handle; |
Rajeev Kumar | 2ec8d47 | 2017-03-29 17:14:14 -0700 | [diff] [blame] | 2467 | |
| 2468 | error: |
| 2469 | qdf_mem_free(wmi_handle); |
| 2470 | |
| 2471 | return NULL; |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2472 | } |
Pratik Gandhi | 67da1bb | 2018-01-30 19:05:41 +0530 | [diff] [blame] | 2473 | qdf_export_symbol(wmi_unified_get_pdev_handle); |
| 2474 | |
| 2475 | static void (*wmi_attach_register[WMI_MAX_TARGET_TYPE])(wmi_unified_t); |
| 2476 | |
| 2477 | void wmi_unified_register_module(enum wmi_target_type target_type, |
| 2478 | void (*wmi_attach)(wmi_unified_t wmi_handle)) |
| 2479 | { |
| 2480 | if (target_type < WMI_MAX_TARGET_TYPE) |
| 2481 | wmi_attach_register[target_type] = wmi_attach; |
| 2482 | |
| 2483 | return; |
| 2484 | } |
| 2485 | qdf_export_symbol(wmi_unified_register_module); |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2486 | |
| 2487 | /** |
Rakshith Suresh Patkar | 9eb15ee | 2018-09-12 16:51:30 +0530 | [diff] [blame] | 2488 | * wmi_wbuff_register() - register wmi with wbuff |
| 2489 | * @wmi_handle: handle to wmi |
| 2490 | * |
| 2491 | * @Return: void |
| 2492 | */ |
| 2493 | static void wmi_wbuff_register(struct wmi_unified *wmi_handle) |
| 2494 | { |
| 2495 | struct wbuff_alloc_request wbuff_alloc[4]; |
| 2496 | |
| 2497 | wbuff_alloc[0].slot = WBUFF_POOL_0; |
| 2498 | wbuff_alloc[0].size = WMI_WBUFF_POOL_0_SIZE; |
| 2499 | wbuff_alloc[1].slot = WBUFF_POOL_1; |
| 2500 | wbuff_alloc[1].size = WMI_WBUFF_POOL_1_SIZE; |
| 2501 | wbuff_alloc[2].slot = WBUFF_POOL_2; |
| 2502 | wbuff_alloc[2].size = WMI_WBUFF_POOL_2_SIZE; |
| 2503 | wbuff_alloc[3].slot = WBUFF_POOL_3; |
| 2504 | wbuff_alloc[3].size = WMI_WBUFF_POOL_3_SIZE; |
| 2505 | |
| 2506 | wmi_handle->wbuff_handle = wbuff_module_register(wbuff_alloc, 4, |
| 2507 | WMI_MIN_HEAD_ROOM, 4); |
| 2508 | } |
| 2509 | |
| 2510 | /** |
| 2511 | * wmi_wbuff_deregister() - deregister wmi with wbuff |
| 2512 | * @wmi_handle: handle to wmi |
| 2513 | * |
| 2514 | * @Return: void |
| 2515 | */ |
| 2516 | static inline void wmi_wbuff_deregister(struct wmi_unified *wmi_handle) |
| 2517 | { |
| 2518 | wbuff_module_deregister(wmi_handle->wbuff_handle); |
| 2519 | wmi_handle->wbuff_handle = NULL; |
| 2520 | } |
| 2521 | |
| 2522 | /** |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2523 | * wmi_unified_attach() - attach for unified WMI |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 2524 | * @scn_handle: handle to SCN |
| 2525 | * @osdev: OS device context |
| 2526 | * @target_type: TLV or not-TLV based target |
| 2527 | * @use_cookie: cookie based allocation enabled/disabled |
| 2528 | * @ops: umac rx callbacks |
Mukul Sharma | f8a1708 | 2017-01-30 19:55:40 +0530 | [diff] [blame] | 2529 | * @psoc: objmgr psoc |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2530 | * |
| 2531 | * @Return: wmi handle. |
| 2532 | */ |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 2533 | void *wmi_unified_attach(void *scn_handle, |
Chaithanya Garrepalli | 6327e8a | 2017-12-01 14:55:26 +0530 | [diff] [blame] | 2534 | struct wmi_unified_attach_params *param) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2535 | { |
| 2536 | struct wmi_unified *wmi_handle; |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2537 | struct wmi_soc *soc; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2538 | |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2539 | soc = (struct wmi_soc *) qdf_mem_malloc(sizeof(struct wmi_soc)); |
| 2540 | if (soc == NULL) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 2541 | WMI_LOGE("Allocation of wmi_soc failed %zu", |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 2542 | sizeof(struct wmi_soc)); |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2543 | return NULL; |
| 2544 | } |
Mukul Sharma | 2c66f7e | 2017-11-03 19:26:54 +0530 | [diff] [blame] | 2545 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2546 | wmi_handle = |
| 2547 | (struct wmi_unified *) qdf_mem_malloc( |
| 2548 | sizeof(struct wmi_unified)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2549 | if (wmi_handle == NULL) { |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2550 | qdf_mem_free(soc); |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 2551 | WMI_LOGE("allocation of wmi handle failed %zu", |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 2552 | sizeof(struct wmi_unified)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2553 | return NULL; |
| 2554 | } |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2555 | wmi_handle->soc = soc; |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 2556 | wmi_handle->soc->soc_idx = param->soc_id; |
phadiman | ae15076 | 2018-11-13 12:04:07 +0530 | [diff] [blame] | 2557 | wmi_handle->soc->is_async_ep = param->is_async_ep; |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2558 | wmi_handle->event_id = soc->event_id; |
| 2559 | wmi_handle->event_handler = soc->event_handler; |
| 2560 | wmi_handle->ctx = soc->ctx; |
Soumya Bhat | 488092d | 2017-03-22 14:41:01 +0530 | [diff] [blame] | 2561 | wmi_handle->wmi_events = soc->wmi_events; |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2562 | wmi_target_params_init(soc, wmi_handle); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2563 | wmi_handle->scn_handle = scn_handle; |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2564 | soc->scn_handle = scn_handle; |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2565 | qdf_atomic_init(&wmi_handle->pending_cmds); |
| 2566 | qdf_atomic_init(&wmi_handle->is_target_suspended); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2567 | wmi_runtime_pm_init(wmi_handle); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2568 | qdf_spinlock_create(&wmi_handle->eventq_lock); |
| 2569 | qdf_nbuf_queue_init(&wmi_handle->event_queue); |
Rajeev Kumar | 2ec8d47 | 2017-03-29 17:14:14 -0700 | [diff] [blame] | 2570 | qdf_create_work(0, &wmi_handle->rx_event_work, |
| 2571 | wmi_rx_event_work, wmi_handle); |
| 2572 | wmi_handle->wmi_rx_work_queue = |
Shashikala Prabhu | d73876f | 2018-11-20 17:53:05 +0530 | [diff] [blame] | 2573 | qdf_alloc_unbound_workqueue("wmi_rx_event_work_queue"); |
Rajeev Kumar | 2ec8d47 | 2017-03-29 17:14:14 -0700 | [diff] [blame] | 2574 | if (NULL == wmi_handle->wmi_rx_work_queue) { |
| 2575 | WMI_LOGE("failed to create wmi_rx_event_work_queue"); |
| 2576 | goto error; |
| 2577 | } |
c_priys | b5f94a8 | 2018-06-12 16:53:51 +0530 | [diff] [blame] | 2578 | wmi_interface_logging_init(wmi_handle, WMI_HOST_PDEV_ID_0); |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 2579 | /* Attach mc_thread context processing function */ |
Govind Singh | 5eb5153 | 2016-03-09 11:34:12 +0530 | [diff] [blame] | 2580 | wmi_handle->rx_ops.wma_process_fw_event_handler_cbk = |
Chaithanya Garrepalli | 6327e8a | 2017-12-01 14:55:26 +0530 | [diff] [blame] | 2581 | param->rx_ops->wma_process_fw_event_handler_cbk; |
| 2582 | wmi_handle->target_type = param->target_type; |
| 2583 | soc->target_type = param->target_type; |
Abhiram Jogadenu | 429ab53 | 2018-05-14 17:13:28 +0530 | [diff] [blame] | 2584 | |
| 2585 | if (param->target_type >= WMI_MAX_TARGET_TYPE) |
| 2586 | goto error; |
| 2587 | |
Chaithanya Garrepalli | 6327e8a | 2017-12-01 14:55:26 +0530 | [diff] [blame] | 2588 | if (wmi_attach_register[param->target_type]) { |
| 2589 | wmi_attach_register[param->target_type](wmi_handle); |
Pratik Gandhi | 67da1bb | 2018-01-30 19:05:41 +0530 | [diff] [blame] | 2590 | } else { |
| 2591 | WMI_LOGE("wmi attach is not registered"); |
| 2592 | goto error; |
| 2593 | } |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 2594 | /* Assign target cookie capablity */ |
Chaithanya Garrepalli | 6327e8a | 2017-12-01 14:55:26 +0530 | [diff] [blame] | 2595 | wmi_handle->use_cookie = param->use_cookie; |
| 2596 | wmi_handle->osdev = param->osdev; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2597 | wmi_handle->wmi_stopinprogress = 0; |
Chaithanya Garrepalli | 6327e8a | 2017-12-01 14:55:26 +0530 | [diff] [blame] | 2598 | wmi_handle->wmi_max_cmds = param->max_commands; |
| 2599 | soc->wmi_max_cmds = param->max_commands; |
Mukul Sharma | f8a1708 | 2017-01-30 19:55:40 +0530 | [diff] [blame] | 2600 | /* Increase the ref count once refcount infra is present */ |
Chaithanya Garrepalli | 6327e8a | 2017-12-01 14:55:26 +0530 | [diff] [blame] | 2601 | soc->wmi_psoc = param->psoc; |
Kiran Venkatappa | f285aba | 2017-03-20 20:38:44 +0530 | [diff] [blame] | 2602 | qdf_spinlock_create(&soc->ctx_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2603 | |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2604 | soc->ops = wmi_handle->ops; |
| 2605 | soc->wmi_pdev[0] = wmi_handle; |
Venkat Karthik Kantamneni | bc8d329 | 2018-05-21 19:13:02 +0530 | [diff] [blame] | 2606 | if (wmi_ext_dbgfs_init(wmi_handle) != QDF_STATUS_SUCCESS) |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 2607 | WMI_LOGE("failed to initialize wmi extended debugfs"); |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2608 | |
Rakshith Suresh Patkar | 9eb15ee | 2018-09-12 16:51:30 +0530 | [diff] [blame] | 2609 | wmi_wbuff_register(wmi_handle); |
| 2610 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2611 | return wmi_handle; |
Rajeev Kumar | 2ec8d47 | 2017-03-29 17:14:14 -0700 | [diff] [blame] | 2612 | |
| 2613 | error: |
| 2614 | qdf_mem_free(soc); |
| 2615 | qdf_mem_free(wmi_handle); |
| 2616 | |
| 2617 | return NULL; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2618 | } |
| 2619 | |
| 2620 | /** |
| 2621 | * wmi_unified_detach() - detach for unified WMI |
| 2622 | * |
| 2623 | * @wmi_handle : handle to wmi. |
| 2624 | * |
| 2625 | * @Return: none. |
| 2626 | */ |
| 2627 | void wmi_unified_detach(struct wmi_unified *wmi_handle) |
| 2628 | { |
| 2629 | wmi_buf_t buf; |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2630 | struct wmi_soc *soc; |
| 2631 | uint8_t i; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2632 | |
Rakshith Suresh Patkar | 9eb15ee | 2018-09-12 16:51:30 +0530 | [diff] [blame] | 2633 | wmi_wbuff_deregister(wmi_handle); |
| 2634 | |
Venkat Karthik Kantamneni | bc8d329 | 2018-05-21 19:13:02 +0530 | [diff] [blame] | 2635 | wmi_ext_dbgfs_deinit(wmi_handle); |
Rakshith Suresh Patkar | 9eb15ee | 2018-09-12 16:51:30 +0530 | [diff] [blame] | 2636 | |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2637 | soc = wmi_handle->soc; |
| 2638 | for (i = 0; i < WMI_MAX_RADIOS; i++) { |
| 2639 | if (soc->wmi_pdev[i]) { |
Rajeev Kumar | 2ec8d47 | 2017-03-29 17:14:14 -0700 | [diff] [blame] | 2640 | qdf_flush_workqueue(0, |
| 2641 | soc->wmi_pdev[i]->wmi_rx_work_queue); |
| 2642 | qdf_destroy_workqueue(0, |
| 2643 | soc->wmi_pdev[i]->wmi_rx_work_queue); |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2644 | wmi_debugfs_remove(soc->wmi_pdev[i]); |
| 2645 | buf = qdf_nbuf_queue_remove( |
| 2646 | &soc->wmi_pdev[i]->event_queue); |
| 2647 | while (buf) { |
| 2648 | qdf_nbuf_free(buf); |
| 2649 | buf = qdf_nbuf_queue_remove( |
| 2650 | &soc->wmi_pdev[i]->event_queue); |
| 2651 | } |
Rajeev Kumar | ae91c40 | 2016-05-25 16:07:23 -0700 | [diff] [blame] | 2652 | |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2653 | wmi_log_buffer_free(soc->wmi_pdev[i]); |
Wu Gao | 21e6938 | 2017-06-23 16:39:17 +0800 | [diff] [blame] | 2654 | |
| 2655 | /* Free events logs list */ |
| 2656 | if (soc->wmi_pdev[i]->events_logs_list) |
| 2657 | qdf_mem_free( |
| 2658 | soc->wmi_pdev[i]->events_logs_list); |
| 2659 | |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2660 | qdf_spinlock_destroy(&soc->wmi_pdev[i]->eventq_lock); |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2661 | qdf_mem_free(soc->wmi_pdev[i]); |
| 2662 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2663 | } |
Kiran Venkatappa | f285aba | 2017-03-20 20:38:44 +0530 | [diff] [blame] | 2664 | qdf_spinlock_destroy(&soc->ctx_lock); |
Kiran Venkatappa | 7d73914 | 2017-09-01 17:02:34 +0530 | [diff] [blame] | 2665 | |
| 2666 | if (soc->wmi_service_bitmap) { |
| 2667 | qdf_mem_free(soc->wmi_service_bitmap); |
| 2668 | soc->wmi_service_bitmap = NULL; |
| 2669 | } |
| 2670 | |
| 2671 | if (soc->wmi_ext_service_bitmap) { |
| 2672 | qdf_mem_free(soc->wmi_ext_service_bitmap); |
| 2673 | soc->wmi_ext_service_bitmap = NULL; |
| 2674 | } |
| 2675 | |
Mukul Sharma | f8a1708 | 2017-01-30 19:55:40 +0530 | [diff] [blame] | 2676 | /* Decrease the ref count once refcount infra is present */ |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2677 | soc->wmi_psoc = NULL; |
| 2678 | qdf_mem_free(soc); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2679 | } |
| 2680 | |
| 2681 | /** |
| 2682 | * wmi_unified_remove_work() - detach for WMI work |
| 2683 | * @wmi_handle: handle to WMI |
| 2684 | * |
| 2685 | * A function that does not fully detach WMI, but just remove work |
| 2686 | * queue items associated with it. This is used to make sure that |
| 2687 | * before any other processing code that may destroy related contexts |
| 2688 | * (HTC, etc), work queue processing on WMI has already been stopped. |
| 2689 | * |
| 2690 | * Return: None |
| 2691 | */ |
| 2692 | void |
| 2693 | wmi_unified_remove_work(struct wmi_unified *wmi_handle) |
| 2694 | { |
| 2695 | wmi_buf_t buf; |
| 2696 | |
Rajeev Kumar | 2ec8d47 | 2017-03-29 17:14:14 -0700 | [diff] [blame] | 2697 | qdf_flush_workqueue(0, wmi_handle->wmi_rx_work_queue); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2698 | qdf_spin_lock_bh(&wmi_handle->eventq_lock); |
| 2699 | buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2700 | while (buf) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2701 | qdf_nbuf_free(buf); |
| 2702 | buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2703 | } |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2704 | qdf_spin_unlock_bh(&wmi_handle->eventq_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2705 | } |
| 2706 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2707 | /** |
| 2708 | * wmi_htc_tx_complete() - Process htc tx completion |
| 2709 | * |
| 2710 | * @ctx: handle to wmi |
| 2711 | * @htc_packet: pointer to htc packet |
| 2712 | * |
| 2713 | * @Return: none. |
| 2714 | */ |
Jeff Johnson | 9366d7a | 2016-10-07 13:03:02 -0700 | [diff] [blame] | 2715 | static void wmi_htc_tx_complete(void *ctx, HTC_PACKET *htc_pkt) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2716 | { |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2717 | struct wmi_soc *soc = (struct wmi_soc *) ctx; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2718 | 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] | 2719 | u_int8_t *buf_ptr; |
| 2720 | u_int32_t len; |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2721 | struct wmi_unified *wmi_handle; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2722 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
| 2723 | uint32_t cmd_id; |
| 2724 | #endif |
| 2725 | |
| 2726 | ASSERT(wmi_cmd_buf); |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2727 | wmi_handle = wmi_get_pdev_ep(soc, htc_pkt->Endpoint); |
| 2728 | if (wmi_handle == NULL) { |
| 2729 | WMI_LOGE("%s: Unable to get wmi handle\n", __func__); |
| 2730 | QDF_ASSERT(0); |
| 2731 | return; |
| 2732 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2733 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2734 | if (wmi_handle && wmi_handle->log_info.wmi_logging_enable) { |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2735 | cmd_id = WMI_GET_FIELD(qdf_nbuf_data(wmi_cmd_buf), |
| 2736 | WMI_CMD_HDR, COMMANDID); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2737 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2738 | qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2739 | /* Record 16 bytes of WMI cmd tx complete data |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2740 | - exclude TLV and WMI headers */ |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2741 | if (wmi_handle->ops->is_management_record(cmd_id)) { |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2742 | WMI_MGMT_COMMAND_TX_CMP_RECORD(wmi_handle, cmd_id, |
Rakesh Pillai | 0511046 | 2017-12-27 14:08:59 +0530 | [diff] [blame] | 2743 | qdf_nbuf_data(wmi_cmd_buf) + |
Pratik Gandhi | 44811d0 | 2018-10-10 12:12:32 +0530 | [diff] [blame] | 2744 | wmi_handle->soc->buf_offset_command); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2745 | } else { |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2746 | WMI_COMMAND_TX_CMP_RECORD(wmi_handle, cmd_id, |
Rakesh Pillai | 0511046 | 2017-12-27 14:08:59 +0530 | [diff] [blame] | 2747 | qdf_nbuf_data(wmi_cmd_buf) + |
Pratik Gandhi | 44811d0 | 2018-10-10 12:12:32 +0530 | [diff] [blame] | 2748 | wmi_handle->soc->buf_offset_command); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2749 | } |
| 2750 | |
Govind Singh | ecf03cd | 2016-05-12 12:45:51 +0530 | [diff] [blame] | 2751 | qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock); |
| 2752 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2753 | #endif |
Govind Singh | 82ea326 | 2016-09-02 15:24:25 +0530 | [diff] [blame] | 2754 | buf_ptr = (u_int8_t *) wmi_buf_data(wmi_cmd_buf); |
| 2755 | len = qdf_nbuf_len(wmi_cmd_buf); |
| 2756 | qdf_mem_zero(buf_ptr, len); |
Rakshith Suresh Patkar | 9eb15ee | 2018-09-12 16:51:30 +0530 | [diff] [blame] | 2757 | wmi_buf_free(wmi_cmd_buf); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2758 | qdf_mem_free(htc_pkt); |
| 2759 | qdf_atomic_dec(&wmi_handle->pending_cmds); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2760 | } |
| 2761 | |
| 2762 | /** |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2763 | * 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] | 2764 | * |
| 2765 | * @wmi_handle: handle to WMI. |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2766 | * @pdev_idx: Pdev index |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2767 | * |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2768 | * @Return: status. |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2769 | */ |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2770 | static int wmi_connect_pdev_htc_service(struct wmi_soc *soc, |
| 2771 | uint32_t pdev_idx) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2772 | { |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2773 | int status; |
Manikandan Mohan | f940db8 | 2017-04-13 20:19:26 -0700 | [diff] [blame] | 2774 | struct htc_service_connect_resp response; |
| 2775 | struct htc_service_connect_req connect; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2776 | |
| 2777 | OS_MEMZERO(&connect, sizeof(connect)); |
| 2778 | OS_MEMZERO(&response, sizeof(response)); |
| 2779 | |
| 2780 | /* meta data is unused for now */ |
| 2781 | connect.pMetaData = NULL; |
| 2782 | connect.MetaDataLength = 0; |
| 2783 | /* these fields are the same for all service endpoints */ |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2784 | connect.EpCallbacks.pContext = soc; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2785 | connect.EpCallbacks.EpTxCompleteMultiple = |
| 2786 | NULL /* Control path completion ar6000_tx_complete */; |
| 2787 | connect.EpCallbacks.EpRecv = wmi_control_rx /* Control path rx */; |
| 2788 | connect.EpCallbacks.EpRecvRefill = NULL /* ar6000_rx_refill */; |
| 2789 | connect.EpCallbacks.EpSendFull = NULL /* ar6000_tx_queue_full */; |
| 2790 | connect.EpCallbacks.EpTxComplete = |
| 2791 | wmi_htc_tx_complete /* ar6000_tx_queue_full */; |
| 2792 | |
| 2793 | /* connect to control service */ |
Pratik Gandhi | cf3b8b9 | 2018-02-05 17:22:41 +0530 | [diff] [blame] | 2794 | connect.service_id = soc->svc_ids[pdev_idx]; |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2795 | status = htc_connect_service(soc->htc_handle, &connect, |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2796 | &response); |
| 2797 | |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2798 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2799 | if (status != EOK) { |
Sathish Kumar | f1ab58a | 2018-09-20 16:07:20 +0530 | [diff] [blame] | 2800 | WMI_LOGE |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2801 | ("Failed to connect to WMI CONTROL service status:%d\n", |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2802 | status); |
| 2803 | return status; |
| 2804 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2805 | |
phadiman | ae15076 | 2018-11-13 12:04:07 +0530 | [diff] [blame] | 2806 | if (soc->is_async_ep) |
| 2807 | htc_set_async_ep(soc->htc_handle, response.Endpoint, true); |
phadiman | 84180fc | 2018-10-10 15:53:03 +0530 | [diff] [blame] | 2808 | |
Kiran Venkatappa | 5bffce5 | 2017-02-10 16:57:59 +0530 | [diff] [blame] | 2809 | soc->wmi_endpoint_id[pdev_idx] = response.Endpoint; |
| 2810 | soc->max_msg_len[pdev_idx] = response.MaxMsgLength; |
| 2811 | |
| 2812 | return 0; |
| 2813 | } |
| 2814 | |
| 2815 | /** |
| 2816 | * wmi_unified_connect_htc_service() - WMI API to get connect to HTC service |
| 2817 | * |
| 2818 | * @wmi_handle: handle to WMI. |
| 2819 | * |
| 2820 | * @Return: status. |
| 2821 | */ |
| 2822 | QDF_STATUS |
| 2823 | wmi_unified_connect_htc_service(struct wmi_unified *wmi_handle, |
| 2824 | void *htc_handle) |
| 2825 | { |
| 2826 | uint32_t i; |
| 2827 | uint8_t wmi_ep_count; |
| 2828 | |
| 2829 | wmi_handle->soc->htc_handle = htc_handle; |
| 2830 | |
| 2831 | wmi_ep_count = htc_get_wmi_endpoint_count(htc_handle); |
| 2832 | if (wmi_ep_count > WMI_MAX_RADIOS) |
| 2833 | return QDF_STATUS_E_FAULT; |
| 2834 | |
| 2835 | for (i = 0; i < wmi_ep_count; i++) |
| 2836 | wmi_connect_pdev_htc_service(wmi_handle->soc, i); |
| 2837 | |
| 2838 | wmi_handle->htc_handle = htc_handle; |
| 2839 | wmi_handle->wmi_endpoint_id = wmi_handle->soc->wmi_endpoint_id[0]; |
| 2840 | wmi_handle->max_msg_len = wmi_handle->soc->max_msg_len[0]; |
| 2841 | |
| 2842 | return QDF_STATUS_SUCCESS; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2843 | } |
| 2844 | |
| 2845 | /** |
| 2846 | * wmi_get_host_credits() - WMI API to get updated host_credits |
| 2847 | * |
| 2848 | * @wmi_handle: handle to WMI. |
| 2849 | * |
| 2850 | * @Return: updated host_credits. |
| 2851 | */ |
| 2852 | int wmi_get_host_credits(wmi_unified_t wmi_handle) |
| 2853 | { |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2854 | int host_credits = 0; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2855 | |
| 2856 | htc_get_control_endpoint_tx_host_credits(wmi_handle->htc_handle, |
| 2857 | &host_credits); |
| 2858 | return host_credits; |
| 2859 | } |
| 2860 | |
| 2861 | /** |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2862 | * wmi_get_pending_cmds() - WMI API to get WMI Pending Commands in the HTC |
| 2863 | * queue |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2864 | * |
| 2865 | * @wmi_handle: handle to WMI. |
| 2866 | * |
| 2867 | * @Return: Pending Commands in the HTC queue. |
| 2868 | */ |
| 2869 | int wmi_get_pending_cmds(wmi_unified_t wmi_handle) |
| 2870 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2871 | return qdf_atomic_read(&wmi_handle->pending_cmds); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2872 | } |
| 2873 | |
| 2874 | /** |
| 2875 | * wmi_set_target_suspend() - WMI API to set target suspend state |
| 2876 | * |
| 2877 | * @wmi_handle: handle to WMI. |
| 2878 | * @val: suspend state boolean. |
| 2879 | * |
| 2880 | * @Return: none. |
| 2881 | */ |
| 2882 | void wmi_set_target_suspend(wmi_unified_t wmi_handle, A_BOOL val) |
| 2883 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 2884 | qdf_atomic_set(&wmi_handle->is_target_suspended, val); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 2885 | } |
| 2886 | |
Sarada Prasanna Garnayak | 17b9e9e | 2017-01-05 19:30:07 +0530 | [diff] [blame] | 2887 | /** |
| 2888 | * WMI API to set crash injection state |
| 2889 | * @param wmi_handle: handle to WMI. |
| 2890 | * @param val: crash injection state boolean. |
| 2891 | */ |
| 2892 | void wmi_tag_crash_inject(wmi_unified_t wmi_handle, A_BOOL flag) |
| 2893 | { |
| 2894 | wmi_handle->tag_crash_inject = flag; |
| 2895 | } |
| 2896 | |
| 2897 | /** |
| 2898 | * WMI API to set bus suspend state |
| 2899 | * @param wmi_handle: handle to WMI. |
| 2900 | * @param val: suspend state boolean. |
| 2901 | */ |
| 2902 | void wmi_set_is_wow_bus_suspended(wmi_unified_t wmi_handle, A_BOOL val) |
| 2903 | { |
| 2904 | qdf_atomic_set(&wmi_handle->is_wow_bus_suspended, val); |
| 2905 | } |
| 2906 | |
Ravi Kumar Bokka | 7aec5b5 | 2016-11-09 18:07:56 +0530 | [diff] [blame] | 2907 | void wmi_set_tgt_assert(wmi_unified_t wmi_handle, bool val) |
| 2908 | { |
| 2909 | wmi_handle->tgt_force_assert_enable = val; |
| 2910 | } |
| 2911 | |
Kabilan Kannan | 66084ce | 2018-02-21 13:41:00 -0800 | [diff] [blame] | 2912 | /** |
| 2913 | * wmi_stop() - generic function to block unified WMI command |
| 2914 | * @wmi_handle: handle to WMI. |
| 2915 | * |
| 2916 | * @Return: success always. |
| 2917 | */ |
| 2918 | int |
| 2919 | wmi_stop(wmi_unified_t wmi_handle) |
| 2920 | { |
| 2921 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO, |
Aditya Sathish | 45d7ada | 2018-07-02 17:31:55 +0530 | [diff] [blame] | 2922 | "WMI Stop"); |
Kabilan Kannan | 66084ce | 2018-02-21 13:41:00 -0800 | [diff] [blame] | 2923 | wmi_handle->wmi_stopinprogress = 1; |
| 2924 | return 0; |
| 2925 | } |
| 2926 | |
Kiran Venkatappa | 1d5f5ab | 2016-08-09 22:52:35 +0530 | [diff] [blame] | 2927 | #ifndef CONFIG_MCL |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2928 | /** |
| 2929 | * API to flush all the previous packets associated with the wmi endpoint |
| 2930 | * |
| 2931 | * @param wmi_handle : handle to WMI. |
| 2932 | */ |
| 2933 | void |
| 2934 | wmi_flush_endpoint(wmi_unified_t wmi_handle) |
| 2935 | { |
| 2936 | htc_flush_endpoint(wmi_handle->htc_handle, |
| 2937 | wmi_handle->wmi_endpoint_id, 0); |
| 2938 | } |
Pratik Gandhi | 67da1bb | 2018-01-30 19:05:41 +0530 | [diff] [blame] | 2939 | qdf_export_symbol(wmi_flush_endpoint); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2940 | |
| 2941 | /** |
Kiran Venkatappa | 1241bb8 | 2017-05-10 16:24:51 +0530 | [diff] [blame] | 2942 | * wmi_pdev_id_conversion_enable() - API to enable pdev_id conversion in WMI |
| 2943 | * By default pdev_id conversion is not done in WMI. |
| 2944 | * This API can be used enable conversion in WMI. |
| 2945 | * @param wmi_handle : handle to WMI |
| 2946 | * Return none |
| 2947 | */ |
| 2948 | void wmi_pdev_id_conversion_enable(wmi_unified_t wmi_handle) |
| 2949 | { |
| 2950 | if (wmi_handle->target_type == WMI_TLV_TARGET) |
Pratik Gandhi | 67da1bb | 2018-01-30 19:05:41 +0530 | [diff] [blame] | 2951 | wmi_handle->ops->wmi_pdev_id_conversion_enable(wmi_handle); |
Kiran Venkatappa | 1241bb8 | 2017-05-10 16:24:51 +0530 | [diff] [blame] | 2952 | } |
| 2953 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame] | 2954 | #endif |