Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /* |
| 29 | * Host WMI unified implementation |
| 30 | */ |
| 31 | #include "athdefs.h" |
| 32 | #include "osapi_linux.h" |
| 33 | #include "a_types.h" |
| 34 | #include "a_debug.h" |
| 35 | #include "ol_if_athvar.h" |
| 36 | #include "ol_defines.h" |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 37 | #ifndef WMI_NON_TLV_SUPPORT |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 38 | #include "ol_fw.h" |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 39 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 40 | #include "htc_api.h" |
| 41 | #include "htc_api.h" |
| 42 | #include "dbglog_host.h" |
| 43 | #include "wmi.h" |
| 44 | #include "wmi_unified_priv.h" |
Govind Singh | 5eb5153 | 2016-03-09 11:34:12 +0530 | [diff] [blame] | 45 | #include "wmi_unified_param.h" |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 46 | |
| 47 | #define WMI_MIN_HEAD_ROOM 64 |
| 48 | |
| 49 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
| 50 | /* WMI commands */ |
| 51 | uint32_t g_wmi_command_buf_idx = 0; |
| 52 | struct wmi_command_debug wmi_command_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY]; |
| 53 | |
| 54 | /* WMI commands TX completed */ |
| 55 | uint32_t g_wmi_command_tx_cmp_buf_idx = 0; |
| 56 | struct wmi_command_debug |
| 57 | wmi_command_tx_cmp_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY]; |
| 58 | |
| 59 | /* WMI events when processed */ |
| 60 | uint32_t g_wmi_event_buf_idx = 0; |
| 61 | struct wmi_event_debug wmi_event_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY]; |
| 62 | |
| 63 | /* WMI events when queued */ |
| 64 | uint32_t g_wmi_rx_event_buf_idx = 0; |
| 65 | struct wmi_event_debug wmi_rx_event_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY]; |
| 66 | |
| 67 | #define WMI_COMMAND_RECORD(a, b) { \ |
| 68 | if (WMI_EVENT_DEBUG_MAX_ENTRY <= g_wmi_command_buf_idx) \ |
| 69 | g_wmi_command_buf_idx = 0; \ |
| 70 | wmi_command_log_buffer[g_wmi_command_buf_idx].command = a; \ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 71 | qdf_mem_copy(wmi_command_log_buffer[g_wmi_command_buf_idx].data, b, 16); \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 72 | wmi_command_log_buffer[g_wmi_command_buf_idx].time = \ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 73 | qdf_get_log_timestamp(); \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 74 | g_wmi_command_buf_idx++; \ |
| 75 | } |
| 76 | |
| 77 | #define WMI_COMMAND_TX_CMP_RECORD(a, b) { \ |
| 78 | if (WMI_EVENT_DEBUG_MAX_ENTRY <= g_wmi_command_tx_cmp_buf_idx) \ |
| 79 | g_wmi_command_tx_cmp_buf_idx = 0; \ |
| 80 | wmi_command_tx_cmp_log_buffer[g_wmi_command_tx_cmp_buf_idx].command = a; \ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 81 | qdf_mem_copy(wmi_command_tx_cmp_log_buffer \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 82 | [g_wmi_command_tx_cmp_buf_idx].data, b, 16); \ |
| 83 | wmi_command_tx_cmp_log_buffer[g_wmi_command_tx_cmp_buf_idx].time = \ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 84 | qdf_get_log_timestamp(); \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 85 | g_wmi_command_tx_cmp_buf_idx++; \ |
| 86 | } |
| 87 | |
| 88 | #define WMI_EVENT_RECORD(a, b) { \ |
| 89 | if (WMI_EVENT_DEBUG_MAX_ENTRY <= g_wmi_event_buf_idx) \ |
| 90 | g_wmi_event_buf_idx = 0; \ |
| 91 | wmi_event_log_buffer[g_wmi_event_buf_idx].event = a; \ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 92 | qdf_mem_copy(wmi_event_log_buffer[g_wmi_event_buf_idx].data, b, 16); \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 93 | wmi_event_log_buffer[g_wmi_event_buf_idx].time = \ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 94 | qdf_get_log_timestamp(); \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 95 | g_wmi_event_buf_idx++; \ |
| 96 | } |
| 97 | |
| 98 | #define WMI_RX_EVENT_RECORD(a, b) { \ |
| 99 | if (WMI_EVENT_DEBUG_MAX_ENTRY <= g_wmi_rx_event_buf_idx) \ |
| 100 | g_wmi_rx_event_buf_idx = 0; \ |
| 101 | wmi_rx_event_log_buffer[g_wmi_rx_event_buf_idx].event = a; \ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 102 | qdf_mem_copy(wmi_rx_event_log_buffer[g_wmi_rx_event_buf_idx].data, b, 16); \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 103 | wmi_rx_event_log_buffer[g_wmi_rx_event_buf_idx].time = \ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 104 | qdf_get_log_timestamp(); \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 105 | g_wmi_rx_event_buf_idx++; \ |
| 106 | } |
| 107 | /* wmi_mgmt commands */ |
| 108 | #define WMI_MGMT_EVENT_DEBUG_MAX_ENTRY (256) |
| 109 | |
| 110 | uint32_t g_wmi_mgmt_command_buf_idx = 0; |
| 111 | struct |
| 112 | wmi_command_debug wmi_mgmt_command_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY]; |
| 113 | |
| 114 | /* wmi_mgmt commands TX completed */ |
| 115 | uint32_t g_wmi_mgmt_command_tx_cmp_buf_idx = 0; |
| 116 | struct wmi_command_debug |
| 117 | wmi_mgmt_command_tx_cmp_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY]; |
| 118 | |
| 119 | /* wmi_mgmt events when processed */ |
| 120 | uint32_t g_wmi_mgmt_event_buf_idx = 0; |
| 121 | struct wmi_event_debug |
| 122 | wmi_mgmt_event_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY]; |
| 123 | |
| 124 | #define WMI_MGMT_COMMAND_RECORD(a, b) { \ |
| 125 | if (WMI_MGMT_EVENT_DEBUG_MAX_ENTRY <= \ |
| 126 | g_wmi_mgmt_command_buf_idx) \ |
| 127 | g_wmi_mgmt_command_buf_idx = 0; \ |
| 128 | wmi_mgmt_command_log_buffer[g_wmi_mgmt_command_buf_idx].command = a; \ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 129 | qdf_mem_copy( \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 130 | wmi_mgmt_command_log_buffer[g_wmi_mgmt_command_buf_idx].data,\ |
| 131 | b, 16); \ |
| 132 | wmi_mgmt_command_log_buffer[g_wmi_mgmt_command_buf_idx].time = \ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 133 | qdf_get_log_timestamp(); \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 134 | g_wmi_mgmt_command_buf_idx++; \ |
| 135 | } |
| 136 | |
| 137 | #define WMI_MGMT_COMMAND_TX_CMP_RECORD(a, b) { \ |
| 138 | if (WMI_MGMT_EVENT_DEBUG_MAX_ENTRY <= \ |
| 139 | g_wmi_mgmt_command_tx_cmp_buf_idx) \ |
| 140 | g_wmi_mgmt_command_tx_cmp_buf_idx = 0; \ |
| 141 | wmi_mgmt_command_tx_cmp_log_buffer[g_wmi_mgmt_command_tx_cmp_buf_idx].\ |
| 142 | command = a; \ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 143 | qdf_mem_copy(wmi_mgmt_command_tx_cmp_log_buffer \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 144 | [g_wmi_mgmt_command_tx_cmp_buf_idx].data, b, 16); \ |
| 145 | wmi_mgmt_command_tx_cmp_log_buffer[g_wmi_mgmt_command_tx_cmp_buf_idx].\ |
| 146 | time =\ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 147 | qdf_get_log_timestamp(); \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 148 | g_wmi_mgmt_command_tx_cmp_buf_idx++; \ |
| 149 | } |
| 150 | |
| 151 | #define WMI_MGMT_EVENT_RECORD(a, b) { \ |
| 152 | if (WMI_MGMT_EVENT_DEBUG_MAX_ENTRY <= g_wmi_mgmt_event_buf_idx) \ |
| 153 | g_wmi_mgmt_event_buf_idx = 0; \ |
| 154 | wmi_mgmt_event_log_buffer[g_wmi_mgmt_event_buf_idx].event = a; \ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 155 | qdf_mem_copy(wmi_mgmt_event_log_buffer[g_wmi_mgmt_event_buf_idx].data,\ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 156 | b, 16); \ |
| 157 | wmi_mgmt_event_log_buffer[g_wmi_mgmt_event_buf_idx].time = \ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 158 | qdf_get_log_timestamp(); \ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 159 | g_wmi_mgmt_event_buf_idx++; \ |
| 160 | } |
| 161 | |
| 162 | #endif /*WMI_INTERFACE_EVENT_LOGGING */ |
| 163 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 164 | int wmi_get_host_credits(wmi_unified_t wmi_handle); |
| 165 | /* WMI buffer APIs */ |
| 166 | |
| 167 | #ifdef MEMORY_DEBUG |
| 168 | wmi_buf_t |
| 169 | wmi_buf_alloc_debug(wmi_unified_t wmi_handle, uint16_t len, uint8_t *file_name, |
| 170 | uint32_t line_num) |
| 171 | { |
| 172 | wmi_buf_t wmi_buf; |
| 173 | |
| 174 | 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] | 175 | QDF_ASSERT(0); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 176 | return NULL; |
| 177 | } |
| 178 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 179 | wmi_buf = qdf_nbuf_alloc_debug(NULL, |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 180 | roundup(len + WMI_MIN_HEAD_ROOM, 4), |
| 181 | WMI_MIN_HEAD_ROOM, 4, false, file_name, |
| 182 | line_num); |
| 183 | |
| 184 | if (!wmi_buf) |
| 185 | return NULL; |
| 186 | |
| 187 | /* Clear the wmi buffer */ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 188 | OS_MEMZERO(qdf_nbuf_data(wmi_buf), len); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 189 | |
| 190 | /* |
| 191 | * Set the length of the buffer to match the allocation size. |
| 192 | */ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 193 | qdf_nbuf_set_pktlen(wmi_buf, len); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 194 | |
| 195 | return wmi_buf; |
| 196 | } |
| 197 | |
| 198 | void wmi_buf_free(wmi_buf_t net_buf) |
| 199 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 200 | qdf_nbuf_free(net_buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 201 | } |
| 202 | #else |
| 203 | wmi_buf_t wmi_buf_alloc(wmi_unified_t wmi_handle, uint16_t len) |
| 204 | { |
| 205 | wmi_buf_t wmi_buf; |
| 206 | |
| 207 | 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] | 208 | QDF_ASSERT(0); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 209 | return NULL; |
| 210 | } |
| 211 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 212 | wmi_buf = qdf_nbuf_alloc(NULL, roundup(len + WMI_MIN_HEAD_ROOM, 4), |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 213 | WMI_MIN_HEAD_ROOM, 4, false); |
| 214 | if (!wmi_buf) |
| 215 | return NULL; |
| 216 | |
| 217 | /* Clear the wmi buffer */ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 218 | OS_MEMZERO(qdf_nbuf_data(wmi_buf), len); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 219 | |
| 220 | /* |
| 221 | * Set the length of the buffer to match the allocation size. |
| 222 | */ |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 223 | qdf_nbuf_set_pktlen(wmi_buf, len); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 224 | return wmi_buf; |
| 225 | } |
| 226 | |
| 227 | void wmi_buf_free(wmi_buf_t net_buf) |
| 228 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 229 | qdf_nbuf_free(net_buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 230 | } |
| 231 | #endif |
| 232 | |
| 233 | /** |
| 234 | * wmi_get_max_msg_len() - get maximum WMI message length |
| 235 | * @wmi_handle: WMI handle. |
| 236 | * |
| 237 | * This function returns the maximum WMI message length |
| 238 | * |
| 239 | * Return: maximum WMI message length |
| 240 | */ |
| 241 | uint16_t wmi_get_max_msg_len(wmi_unified_t wmi_handle) |
| 242 | { |
| 243 | return wmi_handle->max_msg_len - WMI_MIN_HEAD_ROOM; |
| 244 | } |
| 245 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 246 | #ifndef WMI_NON_TLV_SUPPORT |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 247 | static uint8_t *get_wmi_cmd_string(WMI_CMD_ID wmi_command) |
| 248 | { |
| 249 | switch (wmi_command) { |
| 250 | /* initialize the wlan sub system */ |
| 251 | CASE_RETURN_STRING(WMI_INIT_CMDID); |
| 252 | |
| 253 | /* Scan specific commands */ |
| 254 | |
| 255 | /* start scan request to FW */ |
| 256 | CASE_RETURN_STRING(WMI_START_SCAN_CMDID); |
| 257 | /* stop scan request to FW */ |
| 258 | CASE_RETURN_STRING(WMI_STOP_SCAN_CMDID); |
| 259 | /* full list of channels as defined by the regulatory |
| 260 | * that will be used by scanner */ |
| 261 | CASE_RETURN_STRING(WMI_SCAN_CHAN_LIST_CMDID); |
| 262 | /* overwrite default priority table in scan scheduler */ |
| 263 | CASE_RETURN_STRING(WMI_SCAN_SCH_PRIO_TBL_CMDID); |
| 264 | /* This command to adjust the priority and min.max_rest_time |
| 265 | * of an on ongoing scan request. |
| 266 | */ |
| 267 | CASE_RETURN_STRING(WMI_SCAN_UPDATE_REQUEST_CMDID); |
| 268 | |
| 269 | /* PDEV(physical device) specific commands */ |
| 270 | /* set regulatorty ctl id used by FW to determine the exact |
| 271 | * ctl power limits */ |
| 272 | CASE_RETURN_STRING(WMI_PDEV_SET_REGDOMAIN_CMDID); |
| 273 | /* set channel. mainly used for supporting monitor mode */ |
| 274 | CASE_RETURN_STRING(WMI_PDEV_SET_CHANNEL_CMDID); |
| 275 | /* set pdev specific parameters */ |
| 276 | CASE_RETURN_STRING(WMI_PDEV_SET_PARAM_CMDID); |
| 277 | /* enable packet log */ |
| 278 | CASE_RETURN_STRING(WMI_PDEV_PKTLOG_ENABLE_CMDID); |
| 279 | /* disable packet log*/ |
| 280 | CASE_RETURN_STRING(WMI_PDEV_PKTLOG_DISABLE_CMDID); |
| 281 | /* set wmm parameters */ |
| 282 | CASE_RETURN_STRING(WMI_PDEV_SET_WMM_PARAMS_CMDID); |
| 283 | /* set HT cap ie that needs to be carried probe requests |
| 284 | * HT/VHT channels */ |
| 285 | CASE_RETURN_STRING(WMI_PDEV_SET_HT_CAP_IE_CMDID); |
| 286 | /* set VHT cap ie that needs to be carried on probe |
| 287 | * requests on VHT channels */ |
| 288 | CASE_RETURN_STRING(WMI_PDEV_SET_VHT_CAP_IE_CMDID); |
| 289 | |
| 290 | /* Command to send the DSCP-to-TID map to the target */ |
| 291 | CASE_RETURN_STRING(WMI_PDEV_SET_DSCP_TID_MAP_CMDID); |
| 292 | /* set quiet ie parameters. primarily used in AP mode */ |
| 293 | CASE_RETURN_STRING(WMI_PDEV_SET_QUIET_MODE_CMDID); |
| 294 | /* Enable/Disable Green AP Power Save */ |
| 295 | CASE_RETURN_STRING(WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID); |
| 296 | /* get TPC config for the current operating channel */ |
| 297 | CASE_RETURN_STRING(WMI_PDEV_GET_TPC_CONFIG_CMDID); |
| 298 | |
| 299 | /* set the base MAC address for the physical device before |
| 300 | * a VDEV is created. For firmware that does not support |
| 301 | * this feature and this command, the pdev MAC address will |
| 302 | * not be changed. */ |
| 303 | CASE_RETURN_STRING(WMI_PDEV_SET_BASE_MACADDR_CMDID); |
| 304 | |
| 305 | /* eeprom content dump , the same to bdboard data */ |
| 306 | CASE_RETURN_STRING(WMI_PDEV_DUMP_CMDID); |
| 307 | |
| 308 | /* VDEV(virtual device) specific commands */ |
| 309 | /* vdev create */ |
| 310 | CASE_RETURN_STRING(WMI_VDEV_CREATE_CMDID); |
| 311 | /* vdev delete */ |
| 312 | CASE_RETURN_STRING(WMI_VDEV_DELETE_CMDID); |
| 313 | /* vdev start request */ |
| 314 | CASE_RETURN_STRING(WMI_VDEV_START_REQUEST_CMDID); |
| 315 | /* vdev restart request (RX only, NO TX, used for CAC period)*/ |
| 316 | CASE_RETURN_STRING(WMI_VDEV_RESTART_REQUEST_CMDID); |
| 317 | /* vdev up request */ |
| 318 | CASE_RETURN_STRING(WMI_VDEV_UP_CMDID); |
| 319 | /* vdev stop request */ |
| 320 | CASE_RETURN_STRING(WMI_VDEV_STOP_CMDID); |
| 321 | /* vdev down request */ |
| 322 | CASE_RETURN_STRING(WMI_VDEV_DOWN_CMDID); |
| 323 | /* set a vdev param */ |
| 324 | CASE_RETURN_STRING(WMI_VDEV_SET_PARAM_CMDID); |
| 325 | /* set a key (used for setting per peer unicast |
| 326 | * and per vdev multicast) */ |
| 327 | CASE_RETURN_STRING(WMI_VDEV_INSTALL_KEY_CMDID); |
| 328 | |
| 329 | /* wnm sleep mode command */ |
| 330 | CASE_RETURN_STRING(WMI_VDEV_WNM_SLEEPMODE_CMDID); |
| 331 | CASE_RETURN_STRING(WMI_VDEV_WMM_ADDTS_CMDID); |
| 332 | CASE_RETURN_STRING(WMI_VDEV_WMM_DELTS_CMDID); |
| 333 | CASE_RETURN_STRING(WMI_VDEV_SET_WMM_PARAMS_CMDID); |
| 334 | CASE_RETURN_STRING(WMI_VDEV_SET_GTX_PARAMS_CMDID); |
| 335 | CASE_RETURN_STRING(WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID); |
| 336 | |
| 337 | CASE_RETURN_STRING(WMI_VDEV_PLMREQ_START_CMDID); |
| 338 | CASE_RETURN_STRING(WMI_VDEV_PLMREQ_STOP_CMDID); |
| 339 | CASE_RETURN_STRING(WMI_VDEV_TSF_TSTAMP_ACTION_CMDID); |
| 340 | CASE_RETURN_STRING(WMI_VDEV_SET_IE_CMDID); |
| 341 | |
| 342 | /* peer specific commands */ |
| 343 | |
| 344 | /** create a peer */ |
| 345 | CASE_RETURN_STRING(WMI_PEER_CREATE_CMDID); |
| 346 | /** delete a peer */ |
| 347 | CASE_RETURN_STRING(WMI_PEER_DELETE_CMDID); |
| 348 | /** flush specific tid queues of a peer */ |
| 349 | CASE_RETURN_STRING(WMI_PEER_FLUSH_TIDS_CMDID); |
| 350 | /** set a parameter of a peer */ |
| 351 | CASE_RETURN_STRING(WMI_PEER_SET_PARAM_CMDID); |
| 352 | /* set peer to associated state. will cary all parameters |
| 353 | * determined during assocication time */ |
| 354 | CASE_RETURN_STRING(WMI_PEER_ASSOC_CMDID); |
| 355 | /* add a wds (4 address ) entry. used only for testing |
| 356 | * WDS feature on AP products */ |
| 357 | CASE_RETURN_STRING(WMI_PEER_ADD_WDS_ENTRY_CMDID); |
| 358 | /* remove wds (4 address ) entry. used only for testing WDS |
| 359 | * feature on AP products */ |
| 360 | CASE_RETURN_STRING(WMI_PEER_REMOVE_WDS_ENTRY_CMDID); |
| 361 | /* set up mcast info for multicast to unicast conversion */ |
| 362 | CASE_RETURN_STRING(WMI_PEER_MCAST_GROUP_CMDID); |
| 363 | /* request peer info from FW to get PEER_INFO_EVENTID */ |
| 364 | CASE_RETURN_STRING(WMI_PEER_INFO_REQ_CMDID); |
| 365 | |
| 366 | /* beacon/management specific commands */ |
| 367 | |
| 368 | /* transmit beacon by reference. used for transmitting beacon |
| 369 | * on low latency interface like pcie */ |
| 370 | CASE_RETURN_STRING(WMI_BCN_TX_CMDID); |
| 371 | /* transmit beacon by value */ |
| 372 | CASE_RETURN_STRING(WMI_PDEV_SEND_BCN_CMDID); |
| 373 | /* set the beacon template. used in beacon offload mode to setup |
| 374 | * the common beacon template with the FW to be used by FW to |
| 375 | * generate beacons */ |
| 376 | CASE_RETURN_STRING(WMI_BCN_TMPL_CMDID); |
| 377 | /* set beacon filter with FW */ |
| 378 | CASE_RETURN_STRING(WMI_BCN_FILTER_RX_CMDID); |
| 379 | /* enable/disable filtering of probe requests in the firmware */ |
| 380 | CASE_RETURN_STRING(WMI_PRB_REQ_FILTER_RX_CMDID); |
| 381 | /* transmit management frame by value. will be deprecated */ |
| 382 | CASE_RETURN_STRING(WMI_MGMT_TX_CMDID); |
| 383 | /* set the probe response template. used in beacon offload mode |
| 384 | * to setup the common probe response template with the FW to |
| 385 | * be used by FW to generate probe responses */ |
| 386 | CASE_RETURN_STRING(WMI_PRB_TMPL_CMDID); |
| 387 | |
| 388 | /* commands to directly control ba negotiation directly from |
| 389 | * host. only used in test mode */ |
| 390 | |
| 391 | /* turn off FW Auto addba mode and let host control addba */ |
| 392 | CASE_RETURN_STRING(WMI_ADDBA_CLEAR_RESP_CMDID); |
| 393 | /* send add ba request */ |
| 394 | CASE_RETURN_STRING(WMI_ADDBA_SEND_CMDID); |
| 395 | CASE_RETURN_STRING(WMI_ADDBA_STATUS_CMDID); |
| 396 | /* send del ba */ |
| 397 | CASE_RETURN_STRING(WMI_DELBA_SEND_CMDID); |
| 398 | /* set add ba response will be used by FW to generate |
| 399 | * addba response*/ |
| 400 | CASE_RETURN_STRING(WMI_ADDBA_SET_RESP_CMDID); |
| 401 | /* send single VHT MPDU with AMSDU */ |
| 402 | CASE_RETURN_STRING(WMI_SEND_SINGLEAMSDU_CMDID); |
| 403 | |
| 404 | /* Station power save specific config */ |
| 405 | /* enable/disable station powersave */ |
| 406 | CASE_RETURN_STRING(WMI_STA_POWERSAVE_MODE_CMDID); |
| 407 | /* set station power save specific parameter */ |
| 408 | CASE_RETURN_STRING(WMI_STA_POWERSAVE_PARAM_CMDID); |
| 409 | /* set station mimo powersave mode */ |
| 410 | CASE_RETURN_STRING(WMI_STA_MIMO_PS_MODE_CMDID); |
| 411 | |
| 412 | /* DFS-specific commands */ |
| 413 | /* enable DFS (radar detection)*/ |
| 414 | CASE_RETURN_STRING(WMI_PDEV_DFS_ENABLE_CMDID); |
| 415 | /* disable DFS (radar detection)*/ |
| 416 | CASE_RETURN_STRING(WMI_PDEV_DFS_DISABLE_CMDID); |
| 417 | /* enable DFS phyerr/parse filter offload */ |
| 418 | CASE_RETURN_STRING(WMI_DFS_PHYERR_FILTER_ENA_CMDID); |
| 419 | /* enable DFS phyerr/parse filter offload */ |
| 420 | CASE_RETURN_STRING(WMI_DFS_PHYERR_FILTER_DIS_CMDID); |
| 421 | |
| 422 | /* Roaming specific commands */ |
| 423 | /* set roam scan mode */ |
| 424 | CASE_RETURN_STRING(WMI_ROAM_SCAN_MODE); |
| 425 | /* set roam scan rssi threshold below which roam |
| 426 | * scan is enabled */ |
| 427 | CASE_RETURN_STRING(WMI_ROAM_SCAN_RSSI_THRESHOLD); |
| 428 | /* set roam scan period for periodic roam scan mode */ |
| 429 | CASE_RETURN_STRING(WMI_ROAM_SCAN_PERIOD); |
| 430 | /* set roam scan trigger rssi change threshold */ |
| 431 | CASE_RETURN_STRING(WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD); |
| 432 | /* set roam AP profile */ |
| 433 | CASE_RETURN_STRING(WMI_ROAM_AP_PROFILE); |
| 434 | /* set channel list for roam scans */ |
| 435 | CASE_RETURN_STRING(WMI_ROAM_CHAN_LIST); |
| 436 | /* offload scan specific commands */ |
| 437 | /* set offload scan AP profile */ |
| 438 | CASE_RETURN_STRING(WMI_OFL_SCAN_ADD_AP_PROFILE); |
| 439 | /* remove offload scan AP profile */ |
| 440 | CASE_RETURN_STRING(WMI_OFL_SCAN_REMOVE_AP_PROFILE); |
| 441 | /* set offload scan period */ |
| 442 | CASE_RETURN_STRING(WMI_OFL_SCAN_PERIOD); |
| 443 | |
| 444 | /* P2P specific commands */ |
| 445 | /* set P2P device info. FW will used by FW to create P2P IE |
| 446 | * to be carried in probe response generated during p2p listen |
| 447 | * and for p2p discoverability */ |
| 448 | CASE_RETURN_STRING(WMI_P2P_DEV_SET_DEVICE_INFO); |
| 449 | /* enable/disable p2p discoverability on STA/AP VDEVs */ |
| 450 | CASE_RETURN_STRING(WMI_P2P_DEV_SET_DISCOVERABILITY); |
| 451 | /* set p2p ie to be carried in beacons generated by FW for GO */ |
| 452 | CASE_RETURN_STRING(WMI_P2P_GO_SET_BEACON_IE); |
| 453 | /* set p2p ie to be carried in probe response frames generated |
| 454 | * by FW for GO */ |
| 455 | CASE_RETURN_STRING(WMI_P2P_GO_SET_PROBE_RESP_IE); |
| 456 | /* set the vendor specific p2p ie data. |
| 457 | * FW will use this to parse the P2P NoA |
| 458 | * attribute in the beacons/probe responses received. |
| 459 | */ |
| 460 | CASE_RETURN_STRING(WMI_P2P_SET_VENDOR_IE_DATA_CMDID); |
| 461 | /* set the configure of p2p find offload */ |
| 462 | CASE_RETURN_STRING(WMI_P2P_DISC_OFFLOAD_CONFIG_CMDID); |
| 463 | /* set the vendor specific p2p ie data for p2p find offload */ |
| 464 | CASE_RETURN_STRING(WMI_P2P_DISC_OFFLOAD_APPIE_CMDID); |
| 465 | /* set the BSSID/device name pattern of p2p find offload */ |
| 466 | CASE_RETURN_STRING(WMI_P2P_DISC_OFFLOAD_PATTERN_CMDID); |
| 467 | /* set OppPS related parameters **/ |
| 468 | CASE_RETURN_STRING(WMI_P2P_SET_OPPPS_PARAM_CMDID); |
| 469 | |
| 470 | /* AP power save specific config |
| 471 | * set AP power save specific param */ |
| 472 | CASE_RETURN_STRING(WMI_AP_PS_PEER_PARAM_CMDID); |
| 473 | /* set AP UAPSD coex pecific param */ |
| 474 | CASE_RETURN_STRING(WMI_AP_PS_PEER_UAPSD_COEX_CMDID); |
| 475 | |
| 476 | /* Rate-control specific commands */ |
| 477 | CASE_RETURN_STRING(WMI_PEER_RATE_RETRY_SCHED_CMDID); |
| 478 | |
| 479 | /* WLAN Profiling commands. */ |
| 480 | CASE_RETURN_STRING(WMI_WLAN_PROFILE_TRIGGER_CMDID); |
| 481 | CASE_RETURN_STRING(WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID); |
| 482 | CASE_RETURN_STRING(WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID); |
| 483 | CASE_RETURN_STRING(WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID); |
| 484 | CASE_RETURN_STRING(WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID); |
| 485 | |
| 486 | /* Suspend resume command Ids */ |
| 487 | CASE_RETURN_STRING(WMI_PDEV_SUSPEND_CMDID); |
| 488 | CASE_RETURN_STRING(WMI_PDEV_RESUME_CMDID); |
| 489 | |
| 490 | /* Beacon filter commands */ |
| 491 | /* add a beacon filter */ |
| 492 | CASE_RETURN_STRING(WMI_ADD_BCN_FILTER_CMDID); |
| 493 | /* remove a beacon filter */ |
| 494 | CASE_RETURN_STRING(WMI_RMV_BCN_FILTER_CMDID); |
| 495 | |
| 496 | /* WOW Specific WMI commands */ |
| 497 | /* add pattern for awake */ |
| 498 | CASE_RETURN_STRING(WMI_WOW_ADD_WAKE_PATTERN_CMDID); |
| 499 | /* deleta a wake pattern */ |
| 500 | CASE_RETURN_STRING(WMI_WOW_DEL_WAKE_PATTERN_CMDID); |
| 501 | /* enable/deisable wake event */ |
| 502 | CASE_RETURN_STRING(WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID); |
| 503 | /* enable WOW */ |
| 504 | CASE_RETURN_STRING(WMI_WOW_ENABLE_CMDID); |
| 505 | /* host woke up from sleep event to FW. Generated in response |
| 506 | * to WOW Hardware event */ |
| 507 | CASE_RETURN_STRING(WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID); |
| 508 | |
| 509 | /* RTT measurement related cmd */ |
| 510 | /* reques to make an RTT measurement */ |
| 511 | CASE_RETURN_STRING(WMI_RTT_MEASREQ_CMDID); |
| 512 | /* reques to report a tsf measurement */ |
| 513 | CASE_RETURN_STRING(WMI_RTT_TSF_CMDID); |
| 514 | |
| 515 | /* spectral scan command */ |
| 516 | /* configure spectral scan */ |
| 517 | CASE_RETURN_STRING(WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID); |
| 518 | /* enable/disable spectral scan and trigger */ |
| 519 | CASE_RETURN_STRING(WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID); |
| 520 | |
| 521 | /* F/W stats */ |
| 522 | /* one time request for stats */ |
| 523 | CASE_RETURN_STRING(WMI_REQUEST_STATS_CMDID); |
| 524 | /* Push MCC Adaptive Scheduler Stats to Firmware */ |
| 525 | CASE_RETURN_STRING(WMI_MCC_SCHED_TRAFFIC_STATS_CMDID); |
| 526 | |
| 527 | /* ARP OFFLOAD REQUEST*/ |
| 528 | CASE_RETURN_STRING(WMI_SET_ARP_NS_OFFLOAD_CMDID); |
| 529 | |
| 530 | /* Proactive ARP Response Add Pattern Command*/ |
| 531 | CASE_RETURN_STRING(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID); |
| 532 | |
| 533 | /* Proactive ARP Response Del Pattern Command*/ |
| 534 | CASE_RETURN_STRING(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID); |
| 535 | |
| 536 | /* NS offload confid*/ |
| 537 | CASE_RETURN_STRING(WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID); |
| 538 | |
| 539 | /* GTK offload Specific WMI commands */ |
| 540 | CASE_RETURN_STRING(WMI_GTK_OFFLOAD_CMDID); |
| 541 | |
| 542 | /* CSA offload Specific WMI commands */ |
| 543 | /* csa offload enable */ |
| 544 | CASE_RETURN_STRING(WMI_CSA_OFFLOAD_ENABLE_CMDID); |
| 545 | /* chan switch command */ |
| 546 | CASE_RETURN_STRING(WMI_CSA_OFFLOAD_CHANSWITCH_CMDID); |
| 547 | |
| 548 | /* Chatter commands */ |
| 549 | /* Change chatter mode of operation */ |
| 550 | CASE_RETURN_STRING(WMI_CHATTER_SET_MODE_CMDID); |
| 551 | /* chatter add coalescing filter command */ |
| 552 | CASE_RETURN_STRING(WMI_CHATTER_ADD_COALESCING_FILTER_CMDID); |
| 553 | /* chatter delete coalescing filter command */ |
| 554 | CASE_RETURN_STRING(WMI_CHATTER_DELETE_COALESCING_FILTER_CMDID); |
| 555 | /* chatter coalecing query command */ |
| 556 | CASE_RETURN_STRING(WMI_CHATTER_COALESCING_QUERY_CMDID); |
| 557 | |
| 558 | /* addba specific commands */ |
| 559 | /* start the aggregation on this TID */ |
| 560 | CASE_RETURN_STRING(WMI_PEER_TID_ADDBA_CMDID); |
| 561 | /* stop the aggregation on this TID */ |
| 562 | CASE_RETURN_STRING(WMI_PEER_TID_DELBA_CMDID); |
| 563 | |
| 564 | /* set station mimo powersave method */ |
| 565 | CASE_RETURN_STRING(WMI_STA_DTIM_PS_METHOD_CMDID); |
| 566 | /* Configure the Station UAPSD AC Auto Trigger Parameters */ |
| 567 | CASE_RETURN_STRING(WMI_STA_UAPSD_AUTO_TRIG_CMDID); |
| 568 | /* Configure the Keep Alive Parameters */ |
| 569 | CASE_RETURN_STRING(WMI_STA_KEEPALIVE_CMDID); |
| 570 | |
| 571 | /* Request ssn from target for a sta/tid pair */ |
| 572 | CASE_RETURN_STRING(WMI_BA_REQ_SSN_CMDID); |
| 573 | /* misc command group */ |
| 574 | /* echo command mainly used for testing */ |
| 575 | CASE_RETURN_STRING(WMI_ECHO_CMDID); |
| 576 | |
| 577 | /* !!IMPORTANT!! |
| 578 | * If you need to add a new WMI command to the CASE_RETURN_STRING(WMI_GRP_MISC sub-group, |
| 579 | * please make sure you add it BEHIND CASE_RETURN_STRING(WMI_PDEV_UTF_CMDID); |
| 580 | * as we MUST have a fixed value here to maintain compatibility between |
| 581 | * UTF and the ART2 driver |
| 582 | */ |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 583 | /* UTF WMI commands */ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 584 | CASE_RETURN_STRING(WMI_PDEV_UTF_CMDID); |
| 585 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 586 | /* set debug log config */ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 587 | CASE_RETURN_STRING(WMI_DBGLOG_CFG_CMDID); |
| 588 | /* QVIT specific command id */ |
| 589 | CASE_RETURN_STRING(WMI_PDEV_QVIT_CMDID); |
| 590 | /* Factory Testing Mode request command |
| 591 | * used for integrated chipsets */ |
| 592 | CASE_RETURN_STRING(WMI_PDEV_FTM_INTG_CMDID); |
| 593 | /* set and get keepalive parameters command */ |
| 594 | CASE_RETURN_STRING(WMI_VDEV_SET_KEEPALIVE_CMDID); |
| 595 | CASE_RETURN_STRING(WMI_VDEV_GET_KEEPALIVE_CMDID); |
| 596 | /* For fw recovery test command */ |
| 597 | CASE_RETURN_STRING(WMI_FORCE_FW_HANG_CMDID); |
| 598 | /* Set Mcast/Bdcast filter */ |
| 599 | CASE_RETURN_STRING(WMI_SET_MCASTBCAST_FILTER_CMDID); |
| 600 | /* set thermal management params */ |
| 601 | CASE_RETURN_STRING(WMI_THERMAL_MGMT_CMDID); |
| 602 | CASE_RETURN_STRING(WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID); |
| 603 | CASE_RETURN_STRING(WMI_LRO_CONFIG_CMDID); |
| 604 | CASE_RETURN_STRING(WMI_TRANSFER_DATA_TO_FLASH_CMDID); |
Sreelakshmi Konamki | 57a2c04 | 2016-04-14 18:04:17 +0530 | [diff] [blame] | 605 | CASE_RETURN_STRING(WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 606 | CASE_RETURN_STRING(WMI_MAWC_SENSOR_REPORT_IND_CMDID); |
| 607 | CASE_RETURN_STRING(WMI_ROAM_CONFIGURE_MAWC_CMDID); |
| 608 | CASE_RETURN_STRING(WMI_NLO_CONFIGURE_MAWC_CMDID); |
| 609 | CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_MAWC_CMDID); |
| 610 | /* GPIO Configuration */ |
| 611 | CASE_RETURN_STRING(WMI_GPIO_CONFIG_CMDID); |
| 612 | CASE_RETURN_STRING(WMI_GPIO_OUTPUT_CMDID); |
| 613 | |
| 614 | /* Txbf configuration command */ |
| 615 | CASE_RETURN_STRING(WMI_TXBF_CMDID); |
| 616 | |
| 617 | /* FWTEST Commands */ |
| 618 | CASE_RETURN_STRING(WMI_FWTEST_VDEV_MCC_SET_TBTT_MODE_CMDID); |
| 619 | /* set NoA descs */ |
| 620 | CASE_RETURN_STRING(WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID); |
| 621 | |
| 622 | /* TDLS Configuration */ |
| 623 | /* enable/disable TDLS */ |
| 624 | CASE_RETURN_STRING(WMI_TDLS_SET_STATE_CMDID); |
| 625 | /* set tdls peer state */ |
| 626 | CASE_RETURN_STRING(WMI_TDLS_PEER_UPDATE_CMDID); |
| 627 | |
| 628 | /* Resmgr Configuration */ |
| 629 | /* Adaptive OCS is enabled by default in the FW. |
| 630 | * This command is used to disable FW based adaptive OCS. |
| 631 | */ |
| 632 | CASE_RETURN_STRING |
| 633 | (WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID); |
| 634 | /* set the requested channel time quota for the home channels */ |
| 635 | CASE_RETURN_STRING(WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID); |
| 636 | /* set the requested latency for the home channels */ |
| 637 | CASE_RETURN_STRING(WMI_RESMGR_SET_CHAN_LATENCY_CMDID); |
| 638 | |
| 639 | /* STA SMPS Configuration */ |
| 640 | /* force SMPS mode */ |
| 641 | CASE_RETURN_STRING(WMI_STA_SMPS_FORCE_MODE_CMDID); |
| 642 | /* set SMPS parameters */ |
| 643 | CASE_RETURN_STRING(WMI_STA_SMPS_PARAM_CMDID); |
| 644 | |
| 645 | /* Wlan HB commands */ |
| 646 | /* enalbe/disable wlan HB */ |
| 647 | CASE_RETURN_STRING(WMI_HB_SET_ENABLE_CMDID); |
| 648 | /* set tcp parameters for wlan HB */ |
| 649 | CASE_RETURN_STRING(WMI_HB_SET_TCP_PARAMS_CMDID); |
| 650 | /* set tcp pkt filter for wlan HB */ |
| 651 | CASE_RETURN_STRING(WMI_HB_SET_TCP_PKT_FILTER_CMDID); |
| 652 | /* set udp parameters for wlan HB */ |
| 653 | CASE_RETURN_STRING(WMI_HB_SET_UDP_PARAMS_CMDID); |
| 654 | /* set udp pkt filter for wlan HB */ |
| 655 | CASE_RETURN_STRING(WMI_HB_SET_UDP_PKT_FILTER_CMDID); |
| 656 | |
| 657 | /* Wlan RMC commands*/ |
| 658 | /* enable/disable RMC */ |
| 659 | CASE_RETURN_STRING(WMI_RMC_SET_MODE_CMDID); |
| 660 | /* configure action frame period */ |
| 661 | CASE_RETURN_STRING(WMI_RMC_SET_ACTION_PERIOD_CMDID); |
| 662 | /* For debug/future enhancement purposes only, |
| 663 | * configures/finetunes RMC algorithms */ |
| 664 | CASE_RETURN_STRING(WMI_RMC_CONFIG_CMDID); |
| 665 | |
| 666 | /* WLAN MHF offload commands */ |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 667 | /* enable/disable MHF offload */ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 668 | CASE_RETURN_STRING(WMI_MHF_OFFLOAD_SET_MODE_CMDID); |
| 669 | /* Plumb routing table for MHF offload */ |
| 670 | CASE_RETURN_STRING(WMI_MHF_OFFLOAD_PLUMB_ROUTING_TBL_CMDID); |
| 671 | |
| 672 | /* location scan commands */ |
| 673 | /* start batch scan */ |
| 674 | CASE_RETURN_STRING(WMI_BATCH_SCAN_ENABLE_CMDID); |
| 675 | /* stop batch scan */ |
| 676 | CASE_RETURN_STRING(WMI_BATCH_SCAN_DISABLE_CMDID); |
| 677 | /* get batch scan result */ |
| 678 | CASE_RETURN_STRING(WMI_BATCH_SCAN_TRIGGER_RESULT_CMDID); |
| 679 | /* OEM related cmd */ |
| 680 | CASE_RETURN_STRING(WMI_OEM_REQ_CMDID); |
| 681 | CASE_RETURN_STRING(WMI_OEM_REQUEST_CMDID); |
| 682 | /* NAN request cmd */ |
| 683 | CASE_RETURN_STRING(WMI_NAN_CMDID); |
| 684 | /* Modem power state cmd */ |
| 685 | CASE_RETURN_STRING(WMI_MODEM_POWER_STATE_CMDID); |
| 686 | CASE_RETURN_STRING(WMI_REQUEST_STATS_EXT_CMDID); |
| 687 | CASE_RETURN_STRING(WMI_OBSS_SCAN_ENABLE_CMDID); |
| 688 | CASE_RETURN_STRING(WMI_OBSS_SCAN_DISABLE_CMDID); |
| 689 | CASE_RETURN_STRING(WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID); |
| 690 | CASE_RETURN_STRING(WMI_ROAM_SCAN_CMD); |
| 691 | CASE_RETURN_STRING(WMI_PDEV_SET_LED_CONFIG_CMDID); |
| 692 | CASE_RETURN_STRING(WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID); |
| 693 | CASE_RETURN_STRING(WMI_CHAN_AVOID_UPDATE_CMDID); |
Sreelakshmi Konamki | 084f3d3 | 2016-04-14 17:46:26 +0530 | [diff] [blame] | 694 | CASE_RETURN_STRING(WMI_COEX_CONFIG_CMDID); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 695 | CASE_RETURN_STRING(WMI_WOW_IOAC_ADD_KEEPALIVE_CMDID); |
| 696 | CASE_RETURN_STRING(WMI_WOW_IOAC_DEL_KEEPALIVE_CMDID); |
| 697 | CASE_RETURN_STRING(WMI_WOW_IOAC_ADD_WAKE_PATTERN_CMDID); |
| 698 | CASE_RETURN_STRING(WMI_WOW_IOAC_DEL_WAKE_PATTERN_CMDID); |
| 699 | CASE_RETURN_STRING(WMI_REQUEST_LINK_STATS_CMDID); |
| 700 | CASE_RETURN_STRING(WMI_START_LINK_STATS_CMDID); |
| 701 | CASE_RETURN_STRING(WMI_CLEAR_LINK_STATS_CMDID); |
| 702 | CASE_RETURN_STRING(WMI_GET_FW_MEM_DUMP_CMDID); |
| 703 | CASE_RETURN_STRING(WMI_LPI_MGMT_SNOOPING_CONFIG_CMDID); |
| 704 | CASE_RETURN_STRING(WMI_LPI_START_SCAN_CMDID); |
| 705 | CASE_RETURN_STRING(WMI_LPI_STOP_SCAN_CMDID); |
| 706 | CASE_RETURN_STRING(WMI_EXTSCAN_START_CMDID); |
| 707 | CASE_RETURN_STRING(WMI_EXTSCAN_STOP_CMDID); |
| 708 | CASE_RETURN_STRING |
| 709 | (WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID); |
| 710 | CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID); |
| 711 | CASE_RETURN_STRING(WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID); |
| 712 | CASE_RETURN_STRING(WMI_EXTSCAN_GET_WLAN_CHANGE_RESULTS_CMDID); |
| 713 | CASE_RETURN_STRING(WMI_EXTSCAN_SET_CAPABILITIES_CMDID); |
| 714 | CASE_RETURN_STRING(WMI_EXTSCAN_GET_CAPABILITIES_CMDID); |
| 715 | CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID); |
| 716 | CASE_RETURN_STRING(WMI_ROAM_SYNCH_COMPLETE); |
| 717 | CASE_RETURN_STRING(WMI_D0_WOW_ENABLE_DISABLE_CMDID); |
| 718 | CASE_RETURN_STRING(WMI_EXTWOW_ENABLE_CMDID); |
| 719 | CASE_RETURN_STRING(WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID); |
| 720 | CASE_RETURN_STRING(WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID); |
| 721 | CASE_RETURN_STRING(WMI_UNIT_TEST_CMDID); |
| 722 | CASE_RETURN_STRING(WMI_ROAM_SET_RIC_REQUEST_CMDID); |
| 723 | CASE_RETURN_STRING(WMI_PDEV_GET_TEMPERATURE_CMDID); |
| 724 | CASE_RETURN_STRING(WMI_SET_DHCP_SERVER_OFFLOAD_CMDID); |
| 725 | CASE_RETURN_STRING(WMI_TPC_CHAINMASK_CONFIG_CMDID); |
| 726 | CASE_RETURN_STRING(WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID); |
| 727 | CASE_RETURN_STRING(WMI_SCAN_PROB_REQ_OUI_CMDID); |
| 728 | CASE_RETURN_STRING(WMI_TDLS_SET_OFFCHAN_MODE_CMDID); |
| 729 | CASE_RETURN_STRING(WMI_PDEV_SET_LED_FLASHING_CMDID); |
| 730 | CASE_RETURN_STRING(WMI_MDNS_OFFLOAD_ENABLE_CMDID); |
| 731 | CASE_RETURN_STRING(WMI_MDNS_SET_FQDN_CMDID); |
| 732 | CASE_RETURN_STRING(WMI_MDNS_SET_RESPONSE_CMDID); |
| 733 | CASE_RETURN_STRING(WMI_MDNS_GET_STATS_CMDID); |
| 734 | CASE_RETURN_STRING(WMI_ROAM_INVOKE_CMDID); |
| 735 | CASE_RETURN_STRING(WMI_SET_ANTENNA_DIVERSITY_CMDID); |
| 736 | CASE_RETURN_STRING(WMI_SAP_OFL_ENABLE_CMDID); |
| 737 | CASE_RETURN_STRING(WMI_APFIND_CMDID); |
| 738 | CASE_RETURN_STRING(WMI_PASSPOINT_LIST_CONFIG_CMDID); |
| 739 | CASE_RETURN_STRING(WMI_OCB_SET_SCHED_CMDID); |
| 740 | CASE_RETURN_STRING(WMI_OCB_SET_CONFIG_CMDID); |
| 741 | CASE_RETURN_STRING(WMI_OCB_SET_UTC_TIME_CMDID); |
| 742 | CASE_RETURN_STRING(WMI_OCB_START_TIMING_ADVERT_CMDID); |
| 743 | CASE_RETURN_STRING(WMI_OCB_STOP_TIMING_ADVERT_CMDID); |
| 744 | CASE_RETURN_STRING(WMI_OCB_GET_TSF_TIMER_CMDID); |
| 745 | CASE_RETURN_STRING(WMI_DCC_GET_STATS_CMDID); |
| 746 | CASE_RETURN_STRING(WMI_DCC_CLEAR_STATS_CMDID); |
| 747 | CASE_RETURN_STRING(WMI_DCC_UPDATE_NDL_CMDID); |
| 748 | CASE_RETURN_STRING(WMI_ROAM_FILTER_CMDID); |
| 749 | CASE_RETURN_STRING(WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID); |
| 750 | CASE_RETURN_STRING(WMI_DEBUG_MESG_FLUSH_CMDID); |
| 751 | CASE_RETURN_STRING(WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID); |
| 752 | CASE_RETURN_STRING(WMI_SOC_SET_PCL_CMDID); |
| 753 | CASE_RETURN_STRING(WMI_SOC_SET_HW_MODE_CMDID); |
| 754 | CASE_RETURN_STRING(WMI_SOC_SET_DUAL_MAC_CONFIG_CMDID); |
| 755 | CASE_RETURN_STRING(WMI_WOW_ENABLE_ICMPV6_NA_FLT_CMDID); |
| 756 | CASE_RETURN_STRING(WMI_DIAG_EVENT_LOG_CONFIG_CMDID); |
| 757 | CASE_RETURN_STRING(WMI_PACKET_FILTER_CONFIG_CMDID); |
| 758 | CASE_RETURN_STRING(WMI_PACKET_FILTER_ENABLE_CMDID); |
| 759 | CASE_RETURN_STRING(WMI_SAP_SET_BLACKLIST_PARAM_CMDID); |
| 760 | CASE_RETURN_STRING(WMI_WOW_UDP_SVC_OFLD_CMDID); |
| 761 | CASE_RETURN_STRING(WMI_MGMT_TX_SEND_CMDID); |
| 762 | CASE_RETURN_STRING(WMI_SOC_SET_ANTENNA_MODE_CMDID); |
| 763 | CASE_RETURN_STRING(WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID); |
| 764 | CASE_RETURN_STRING(WMI_AP_PS_EGAP_PARAM_CMDID); |
| 765 | CASE_RETURN_STRING(WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID); |
| 766 | CASE_RETURN_STRING(WMI_BPF_GET_CAPABILITY_CMDID); |
| 767 | CASE_RETURN_STRING(WMI_BPF_GET_VDEV_STATS_CMDID); |
| 768 | CASE_RETURN_STRING(WMI_BPF_SET_VDEV_INSTRUCTIONS_CMDID); |
| 769 | CASE_RETURN_STRING(WMI_BPF_DEL_VDEV_INSTRUCTIONS_CMDID); |
Govind Singh | 8b1466e | 2016-03-16 16:27:50 +0530 | [diff] [blame] | 770 | CASE_RETURN_STRING(WMI_NDI_GET_CAP_REQ_CMDID); |
| 771 | CASE_RETURN_STRING(WMI_NDP_INITIATOR_REQ_CMDID); |
| 772 | CASE_RETURN_STRING(WMI_NDP_RESPONDER_REQ_CMDID); |
| 773 | CASE_RETURN_STRING(WMI_NDP_END_REQ_CMDID); |
| 774 | CASE_RETURN_STRING(WMI_PEER_UPDATE_WDS_ENTRY_CMDID); |
| 775 | CASE_RETURN_STRING(WMI_PEER_ADD_PROXY_STA_ENTRY_CMDID); |
| 776 | CASE_RETURN_STRING(WMI_PDEV_FIPS_CMDID); |
| 777 | CASE_RETURN_STRING(WMI_PDEV_SMART_ANT_ENABLE_CMDID); |
| 778 | CASE_RETURN_STRING(WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID); |
| 779 | CASE_RETURN_STRING(WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID); |
| 780 | CASE_RETURN_STRING(WMI_PDEV_SET_CTL_TABLE_CMDID); |
| 781 | CASE_RETURN_STRING(WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID); |
| 782 | CASE_RETURN_STRING(WMI_PDEV_GET_TPC_CMDID); |
| 783 | CASE_RETURN_STRING(WMI_MIB_STATS_ENABLE_CMDID); |
| 784 | CASE_RETURN_STRING(WMI_PDEV_GET_ANI_CCK_CONFIG_CMDID); |
| 785 | CASE_RETURN_STRING(WMI_PDEV_GET_ANI_OFDM_CONFIG_CMDID); |
| 786 | CASE_RETURN_STRING(WMI_VDEV_RATEMASK_CMDID); |
| 787 | CASE_RETURN_STRING(WMI_VDEV_ATF_REQUEST_CMDID); |
| 788 | CASE_RETURN_STRING(WMI_VDEV_SET_DSCP_TID_MAP_CMDID); |
| 789 | CASE_RETURN_STRING(WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID); |
| 790 | CASE_RETURN_STRING(WMI_VDEV_SET_QUIET_MODE_CMDID); |
| 791 | CASE_RETURN_STRING(WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID); |
| 792 | CASE_RETURN_STRING(WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID); |
| 793 | CASE_RETURN_STRING(WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID); |
| 794 | CASE_RETURN_STRING(WMI_PEER_ATF_REQUEST_CMDID); |
| 795 | CASE_RETURN_STRING(WMI_FWTEST_CMDID); |
| 796 | CASE_RETURN_STRING(WMI_QBOOST_CFG_CMDID); |
| 797 | CASE_RETURN_STRING(WMI_PDEV_GET_NFCAL_POWER_CMDID); |
| 798 | CASE_RETURN_STRING(WMI_PDEV_SET_PCL_CMDID); |
| 799 | CASE_RETURN_STRING(WMI_PDEV_SET_HW_MODE_CMDID); |
| 800 | CASE_RETURN_STRING(WMI_PDEV_SET_MAC_CONFIG_CMDID); |
| 801 | CASE_RETURN_STRING(WMI_PDEV_SET_ANTENNA_MODE_CMDID); |
| 802 | CASE_RETURN_STRING(WMI_ROAM_SET_MBO_PARAM_CMDID); |
Naveen Rawat | 8cf610b | 2016-04-14 20:10:15 -0700 | [diff] [blame] | 803 | CASE_RETURN_STRING(WMI_CHAN_AVOID_RPT_ALLOW_CMDID); |
Sandeep Puligilla | cc28f4e | 2016-04-16 13:35:09 +0530 | [diff] [blame] | 804 | CASE_RETURN_STRING(WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID); |
Krishna Kumaar Natarajan | c285c10 | 2016-04-16 14:09:58 +0530 | [diff] [blame] | 805 | CASE_RETURN_STRING(WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID); |
Krishna Kumaar Natarajan | 0d2a1bd | 2016-04-16 16:47:07 +0530 | [diff] [blame] | 806 | CASE_RETURN_STRING(WMI_PDEV_WAL_POWER_DEBUG_CMDID); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 807 | } |
| 808 | |
| 809 | return "Invalid WMI cmd"; |
| 810 | } |
| 811 | |
| 812 | #ifdef QCA_WIFI_3_0_EMU |
| 813 | static inline void wma_log_cmd_id(WMI_CMD_ID cmd_id) |
| 814 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 815 | WMI_LOGE("Send WMI command:%s command_id:%d", |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 816 | get_wmi_cmd_string(cmd_id), cmd_id); |
| 817 | } |
| 818 | #else |
| 819 | static inline void wma_log_cmd_id(WMI_CMD_ID cmd_id) |
| 820 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 821 | WMI_LOGD("Send WMI command:%s command_id:%d", |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 822 | get_wmi_cmd_string(cmd_id), cmd_id); |
| 823 | } |
| 824 | #endif |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 825 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 826 | |
| 827 | /** |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 828 | * wmi_is_runtime_pm_cmd() - check if a cmd is from suspend resume sequence |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 829 | * @cmd: command to check |
| 830 | * |
| 831 | * Return: true if the command is part of the suspend resume sequence. |
| 832 | */ |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 833 | #ifndef WMI_NON_TLV_SUPPORT |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 834 | static bool wmi_is_runtime_pm_cmd(WMI_CMD_ID cmd_id) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 835 | { |
| 836 | switch (cmd_id) { |
| 837 | case WMI_WOW_ENABLE_CMDID: |
| 838 | case WMI_PDEV_SUSPEND_CMDID: |
| 839 | case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID: |
| 840 | case WMI_WOW_ADD_WAKE_PATTERN_CMDID: |
| 841 | case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID: |
| 842 | case WMI_PDEV_RESUME_CMDID: |
| 843 | case WMI_WOW_DEL_WAKE_PATTERN_CMDID: |
| 844 | case WMI_D0_WOW_ENABLE_DISABLE_CMDID: |
| 845 | return true; |
| 846 | |
| 847 | default: |
| 848 | return false; |
| 849 | } |
| 850 | } |
| 851 | |
| 852 | /** |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 853 | * wmi_is_pm_resume_cmd() - check if a cmd is part of the resume sequence |
| 854 | * @cmd_id: command to check |
| 855 | * |
| 856 | * Return: true if the command is part of the resume sequence. |
| 857 | */ |
| 858 | static bool wmi_is_pm_resume_cmd(WMI_CMD_ID cmd_id) |
| 859 | { |
| 860 | switch (cmd_id) { |
| 861 | case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID: |
| 862 | case WMI_PDEV_RESUME_CMDID: |
| 863 | return true; |
| 864 | |
| 865 | default: |
| 866 | return false; |
| 867 | } |
| 868 | } |
| 869 | #else |
| 870 | static bool wmi_is_runtime_pm_cmd(WMI_CMD_ID cmd_id) |
| 871 | { |
| 872 | return false; |
| 873 | } |
| 874 | static bool wmi_is_pm_resume_cmd(WMI_CMD_ID cmd_id) |
| 875 | { |
| 876 | return false; |
| 877 | } |
| 878 | #endif |
| 879 | |
| 880 | /** |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 881 | * wmi_unified_cmd_send() - WMI command API |
| 882 | * @wmi_handle: handle to wmi |
| 883 | * @buf: wmi buf |
| 884 | * @len: wmi buffer length |
| 885 | * @cmd_id: wmi command id |
| 886 | * |
| 887 | * Return: 0 on success |
| 888 | */ |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 889 | int wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf, uint32_t len, |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 890 | WMI_CMD_ID cmd_id) |
| 891 | { |
| 892 | HTC_PACKET *pkt; |
| 893 | A_STATUS status; |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 894 | uint16_t htc_tag = 0; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 895 | |
| 896 | if (wmi_get_runtime_pm_inprogress(wmi_handle)) { |
| 897 | if (wmi_is_runtime_pm_cmd(cmd_id)) |
| 898 | htc_tag = HTC_TX_PACKET_TAG_AUTO_PM; |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 899 | } else if (qdf_atomic_read(&wmi_handle->is_target_suspended) && |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 900 | (!wmi_is_pm_resume_cmd(cmd_id))) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 901 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 902 | "%s: Target is suspended", __func__); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 903 | QDF_ASSERT(0); |
Govind Singh | 67922e8 | 2016-04-01 16:48:57 +0530 | [diff] [blame] | 904 | return QDF_STATUS_E_BUSY; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 905 | } |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 906 | if (wmi_handle->wmi_stopinprogress) { |
| 907 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
| 908 | "WMI stop in progress\n"); |
| 909 | return -EINVAL; |
| 910 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 911 | |
| 912 | /* Do sanity check on the TLV parameter structure */ |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 913 | #ifndef WMI_NON_TLV_SUPPORT |
| 914 | if (wmi_handle->target_type == WMI_TLV_TARGET) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 915 | void *buf_ptr = (void *)qdf_nbuf_data(buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 916 | |
| 917 | if (wmitlv_check_command_tlv_params(NULL, buf_ptr, len, cmd_id) |
| 918 | != 0) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 919 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 920 | "\nERROR: %s: Invalid WMI Param Buffer for Cmd:%d", |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 921 | __func__, cmd_id); |
Govind Singh | 67922e8 | 2016-04-01 16:48:57 +0530 | [diff] [blame] | 922 | return QDF_STATUS_E_INVAL; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 923 | } |
| 924 | } |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 925 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 926 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 927 | if (qdf_nbuf_push_head(buf, sizeof(WMI_CMD_HDR)) == NULL) { |
| 928 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 929 | "%s, Failed to send cmd %x, no memory", |
| 930 | __func__, cmd_id); |
Govind Singh | 67922e8 | 2016-04-01 16:48:57 +0530 | [diff] [blame] | 931 | return QDF_STATUS_E_NOMEM; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 932 | } |
| 933 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 934 | 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] | 935 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 936 | qdf_atomic_inc(&wmi_handle->pending_cmds); |
| 937 | if (qdf_atomic_read(&wmi_handle->pending_cmds) >= WMI_MAX_CMDS) { |
| 938 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 939 | "\n%s: hostcredits = %d", __func__, |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 940 | wmi_get_host_credits(wmi_handle)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 941 | htc_dump_counter_info(wmi_handle->htc_handle); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 942 | qdf_atomic_dec(&wmi_handle->pending_cmds); |
| 943 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 944 | "%s: MAX 1024 WMI Pending cmds reached.", __func__); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 945 | QDF_BUG(0); |
Govind Singh | 67922e8 | 2016-04-01 16:48:57 +0530 | [diff] [blame] | 946 | return QDF_STATUS_E_BUSY; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 947 | } |
| 948 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 949 | pkt = qdf_mem_malloc(sizeof(*pkt)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 950 | if (!pkt) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 951 | qdf_atomic_dec(&wmi_handle->pending_cmds); |
| 952 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 953 | "%s, Failed to alloc htc packet %x, no memory", |
| 954 | __func__, cmd_id); |
Govind Singh | 67922e8 | 2016-04-01 16:48:57 +0530 | [diff] [blame] | 955 | return QDF_STATUS_E_NOMEM; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 956 | } |
| 957 | |
| 958 | SET_HTC_PACKET_INFO_TX(pkt, |
| 959 | NULL, |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 960 | qdf_nbuf_data(buf), len + sizeof(WMI_CMD_HDR), |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 961 | wmi_handle->wmi_endpoint_id, htc_tag); |
| 962 | |
| 963 | SET_HTC_PACKET_NET_BUF_CONTEXT(pkt, buf); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 964 | #ifndef WMI_NON_TLV_SUPPORT |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 965 | wma_log_cmd_id(cmd_id); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 966 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 967 | |
| 968 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 969 | qdf_spin_lock_bh(&wmi_handle->wmi_record_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 970 | /*Record 16 bytes of WMI cmd data - exclude TLV and WMI headers */ |
| 971 | if (cmd_id == WMI_MGMT_TX_SEND_CMDID) { |
| 972 | WMI_MGMT_COMMAND_RECORD(cmd_id, |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 973 | ((uint32_t *)qdf_nbuf_data(buf) + 2)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 974 | } else { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 975 | WMI_COMMAND_RECORD(cmd_id, ((uint32_t *) qdf_nbuf_data(buf) + |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 976 | 2)); |
| 977 | } |
| 978 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 979 | qdf_spin_unlock_bh(&wmi_handle->wmi_record_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 980 | #endif |
| 981 | |
| 982 | status = htc_send_pkt(wmi_handle->htc_handle, pkt); |
| 983 | |
| 984 | if (A_OK != status) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 985 | qdf_atomic_dec(&wmi_handle->pending_cmds); |
| 986 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 987 | "%s %d, htc_send_pkt failed", __func__, __LINE__); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 988 | } |
| 989 | if (status) |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 990 | return QDF_STATUS_E_FAILURE; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 991 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 992 | return QDF_STATUS_SUCCESS; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 993 | } |
| 994 | |
| 995 | /** |
| 996 | * wmi_unified_get_event_handler_ix() - gives event handler's index |
| 997 | * @wmi_handle: handle to wmi |
| 998 | * @event_id: wmi event id |
| 999 | * |
| 1000 | * Return: event handler's index |
| 1001 | */ |
| 1002 | int wmi_unified_get_event_handler_ix(wmi_unified_t wmi_handle, |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1003 | uint32_t event_id) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1004 | { |
| 1005 | uint32_t idx = 0; |
| 1006 | int32_t invalid_idx = -1; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1007 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1008 | for (idx = 0; (idx < wmi_handle->max_event_idx && |
| 1009 | idx < WMI_UNIFIED_MAX_EVENT); ++idx) { |
| 1010 | if (wmi_handle->event_id[idx] == event_id && |
| 1011 | wmi_handle->event_handler[idx] != NULL) { |
| 1012 | return idx; |
| 1013 | } |
| 1014 | } |
| 1015 | |
| 1016 | return invalid_idx; |
| 1017 | } |
| 1018 | |
| 1019 | /** |
| 1020 | * wmi_unified_register_event_handler() - register wmi event handler |
| 1021 | * @wmi_handle: handle to wmi |
| 1022 | * @event_id: wmi event id |
| 1023 | * @handler_func: wmi event handler function |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1024 | * @rx_ctx: rx execution context for wmi rx events |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1025 | * |
| 1026 | * Return: 0 on success |
| 1027 | */ |
| 1028 | int wmi_unified_register_event_handler(wmi_unified_t wmi_handle, |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1029 | uint32_t event_id, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1030 | wmi_unified_event_handler handler_func, |
| 1031 | uint8_t rx_ctx) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1032 | { |
| 1033 | uint32_t idx = 0; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1034 | uint32_t evt_id; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1035 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1036 | #ifdef WMI_TLV_AND_NON_TLV_SUPPORT |
| 1037 | if (event_id >= wmi_events_max || |
| 1038 | wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) { |
| 1039 | qdf_print("%s: Event id %d is unavailable\n", |
| 1040 | __func__, event_id); |
| 1041 | return QDF_STATUS_E_FAILURE; |
| 1042 | } |
| 1043 | evt_id = wmi_handle->wmi_events[event_id]; |
| 1044 | #else |
| 1045 | evt_id = event_id; |
| 1046 | #endif |
| 1047 | if (wmi_unified_get_event_handler_ix(wmi_handle, evt_id) != -1) { |
| 1048 | qdf_print("%s : event handler already registered 0x%x\n", |
| 1049 | __func__, evt_id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1050 | return QDF_STATUS_E_FAILURE; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1051 | } |
| 1052 | if (wmi_handle->max_event_idx == WMI_UNIFIED_MAX_EVENT) { |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1053 | qdf_print("%s : no more event handlers 0x%x\n", |
| 1054 | __func__, evt_id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1055 | return QDF_STATUS_E_FAILURE; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1056 | } |
| 1057 | idx = wmi_handle->max_event_idx; |
| 1058 | wmi_handle->event_handler[idx] = handler_func; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1059 | wmi_handle->event_id[idx] = evt_id; |
Govind Singh | 813fdac | 2016-03-12 09:26:52 +0530 | [diff] [blame] | 1060 | qdf_spin_lock_bh(&wmi_handle->ctx_lock); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1061 | wmi_handle->ctx[idx] = rx_ctx; |
Govind Singh | 813fdac | 2016-03-12 09:26:52 +0530 | [diff] [blame] | 1062 | qdf_spin_unlock_bh(&wmi_handle->ctx_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1063 | wmi_handle->max_event_idx++; |
| 1064 | |
| 1065 | return 0; |
| 1066 | } |
| 1067 | |
| 1068 | /** |
| 1069 | * wmi_unified_unregister_event_handler() - unregister wmi event handler |
| 1070 | * @wmi_handle: handle to wmi |
| 1071 | * @event_id: wmi event id |
| 1072 | * |
| 1073 | * Return: 0 on success |
| 1074 | */ |
| 1075 | int wmi_unified_unregister_event_handler(wmi_unified_t wmi_handle, |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1076 | uint32_t event_id) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1077 | { |
| 1078 | uint32_t idx = 0; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1079 | uint32_t evt_id; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1080 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1081 | #ifdef WMI_TLV_AND_NON_TLV_SUPPORT |
| 1082 | if (event_id >= wmi_events_max || |
| 1083 | wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) { |
| 1084 | qdf_print("%s: Event id %d is unavailable\n", |
| 1085 | __func__, event_id); |
| 1086 | return QDF_STATUS_E_FAILURE; |
| 1087 | } |
| 1088 | evt_id = wmi_handle->wmi_events[event_id]; |
| 1089 | #else |
| 1090 | evt_id = event_id; |
| 1091 | #endif |
| 1092 | |
| 1093 | idx = wmi_unified_get_event_handler_ix(wmi_handle, evt_id); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1094 | if (idx == -1) { |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1095 | qdf_print("%s : event handler is not registered: evt id 0x%x\n", |
| 1096 | __func__, evt_id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1097 | return QDF_STATUS_E_FAILURE; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1098 | } |
| 1099 | wmi_handle->event_handler[idx] = NULL; |
| 1100 | wmi_handle->event_id[idx] = 0; |
| 1101 | --wmi_handle->max_event_idx; |
| 1102 | wmi_handle->event_handler[idx] = |
| 1103 | wmi_handle->event_handler[wmi_handle->max_event_idx]; |
| 1104 | wmi_handle->event_id[idx] = |
| 1105 | wmi_handle->event_id[wmi_handle->max_event_idx]; |
| 1106 | |
| 1107 | return 0; |
| 1108 | } |
| 1109 | |
| 1110 | /** |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1111 | * wmi_process_fw_event_default_ctx() - process in default caller context |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1112 | * @wmi_handle: handle to wmi |
| 1113 | * @htc_packet: pointer to htc packet |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1114 | * @exec_ctx: execution context for wmi fw event |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1115 | * |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1116 | * Event process by below function will be in default caller context. |
| 1117 | * wmi internally provides rx work thread processing context. |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1118 | * |
| 1119 | * Return: none |
| 1120 | */ |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1121 | static void wmi_process_fw_event_default_ctx(struct wmi_unified *wmi_handle, |
| 1122 | HTC_PACKET *htc_packet, uint8_t exec_ctx) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1123 | { |
| 1124 | wmi_buf_t evt_buf; |
| 1125 | evt_buf = (wmi_buf_t) htc_packet->pPktContext; |
| 1126 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1127 | #ifdef WMI_NON_TLV_SUPPORT |
| 1128 | wmi_handle->rx_ops.wma_process_fw_event_handler_cbk |
| 1129 | (wmi_handle->scn_handle, evt_buf, exec_ctx); |
| 1130 | #else |
Govind Singh | 5eb5153 | 2016-03-09 11:34:12 +0530 | [diff] [blame] | 1131 | wmi_handle->rx_ops.wma_process_fw_event_handler_cbk(wmi_handle, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1132 | evt_buf, exec_ctx); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1133 | #endif |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1134 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1135 | return; |
| 1136 | } |
| 1137 | |
| 1138 | /** |
| 1139 | * wmi_process_fw_event_worker_thread_ctx() - process in worker thread context |
| 1140 | * @wmi_handle: handle to wmi |
| 1141 | * @htc_packet: pointer to htc packet |
| 1142 | * |
| 1143 | * Event process by below function will be in worker thread context. |
| 1144 | * Use this method for events which are not critical and not |
| 1145 | * handled in protocol stack. |
| 1146 | * |
| 1147 | * Return: none |
| 1148 | */ |
| 1149 | static void wmi_process_fw_event_worker_thread_ctx |
| 1150 | (struct wmi_unified *wmi_handle, HTC_PACKET *htc_packet) |
| 1151 | { |
| 1152 | wmi_buf_t evt_buf; |
| 1153 | uint32_t id; |
| 1154 | uint8_t *data; |
| 1155 | |
| 1156 | evt_buf = (wmi_buf_t) htc_packet->pPktContext; |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1157 | id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID); |
| 1158 | data = qdf_nbuf_data(evt_buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1159 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1160 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1161 | qdf_spin_lock_bh(&wmi_handle->wmi_record_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1162 | /* Exclude 4 bytes of TLV header */ |
| 1163 | WMI_RX_EVENT_RECORD(id, ((uint8_t *) data + 4)); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1164 | qdf_spin_unlock_bh(&wmi_handle->wmi_record_lock); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1165 | #endif |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1166 | qdf_spin_lock_bh(&wmi_handle->eventq_lock); |
| 1167 | qdf_nbuf_queue_add(&wmi_handle->event_queue, evt_buf); |
| 1168 | qdf_spin_unlock_bh(&wmi_handle->eventq_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1169 | schedule_work(&wmi_handle->rx_event_work); |
| 1170 | return; |
| 1171 | } |
| 1172 | |
| 1173 | /** |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1174 | * wmi_control_rx() - process fw events callbacks |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1175 | * @ctx: handle to wmi |
| 1176 | * @htc_packet: pointer to htc packet |
| 1177 | * |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1178 | * Return: none |
| 1179 | */ |
| 1180 | void wmi_control_rx(void *ctx, HTC_PACKET *htc_packet) |
| 1181 | { |
| 1182 | struct wmi_unified *wmi_handle = (struct wmi_unified *)ctx; |
| 1183 | wmi_buf_t evt_buf; |
| 1184 | uint32_t id; |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1185 | uint32_t idx = 0; |
| 1186 | enum wmi_rx_exec_ctx exec_ctx; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1187 | |
| 1188 | evt_buf = (wmi_buf_t) htc_packet->pPktContext; |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1189 | 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] | 1190 | idx = wmi_unified_get_event_handler_ix(wmi_handle, id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1191 | if (qdf_unlikely(idx == A_ERROR)) { |
| 1192 | qdf_print |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1193 | ("%s :event handler is not registered: event id 0x%x\n", |
| 1194 | __func__, id); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1195 | qdf_nbuf_free(evt_buf); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1196 | return; |
| 1197 | } |
Govind Singh | 813fdac | 2016-03-12 09:26:52 +0530 | [diff] [blame] | 1198 | qdf_spin_lock_bh(&wmi_handle->ctx_lock); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1199 | exec_ctx = wmi_handle->ctx[idx]; |
Govind Singh | 813fdac | 2016-03-12 09:26:52 +0530 | [diff] [blame] | 1200 | qdf_spin_unlock_bh(&wmi_handle->ctx_lock); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1201 | |
| 1202 | if (exec_ctx == WMI_RX_WORK_CTX) { |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1203 | wmi_process_fw_event_worker_thread_ctx |
| 1204 | (wmi_handle, htc_packet); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1205 | } else if (exec_ctx > WMI_RX_WORK_CTX) { |
| 1206 | wmi_process_fw_event_default_ctx |
| 1207 | (wmi_handle, htc_packet, exec_ctx); |
| 1208 | } else { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1209 | qdf_print("%s :Invalid event context %d\n", __func__, exec_ctx); |
| 1210 | qdf_nbuf_free(evt_buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1211 | } |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1212 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1213 | } |
| 1214 | |
| 1215 | /** |
| 1216 | * wmi_process_fw_event() - process any fw event |
| 1217 | * @wmi_handle: wmi handle |
| 1218 | * @evt_buf: fw event buffer |
| 1219 | * |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1220 | * This function process fw event in caller context |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1221 | * |
| 1222 | * Return: none |
| 1223 | */ |
| 1224 | void wmi_process_fw_event(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf) |
| 1225 | { |
| 1226 | __wmi_control_rx(wmi_handle, evt_buf); |
| 1227 | } |
| 1228 | |
| 1229 | /** |
| 1230 | * __wmi_control_rx() - process serialize wmi event callback |
| 1231 | * @wmi_handle: wmi handle |
| 1232 | * @evt_buf: fw event buffer |
| 1233 | * |
| 1234 | * Return: none |
| 1235 | */ |
| 1236 | void __wmi_control_rx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf) |
| 1237 | { |
| 1238 | uint32_t id; |
| 1239 | uint8_t *data; |
| 1240 | uint32_t len; |
| 1241 | void *wmi_cmd_struct_ptr = NULL; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1242 | #ifndef WMI_NON_TLV_SUPPORT |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1243 | int tlv_ok_status = 0; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1244 | #endif |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1245 | uint32_t idx = 0; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1246 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1247 | 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] | 1248 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1249 | if (qdf_nbuf_pull_head(evt_buf, sizeof(WMI_CMD_HDR)) == NULL) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1250 | goto end; |
| 1251 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1252 | data = qdf_nbuf_data(evt_buf); |
| 1253 | len = qdf_nbuf_len(evt_buf); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1254 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1255 | #ifndef WMI_NON_TLV_SUPPORT |
| 1256 | if (wmi_handle->target_type == WMI_TLV_TARGET) { |
| 1257 | /* Validate and pad(if necessary) the TLVs */ |
| 1258 | tlv_ok_status = |
| 1259 | wmitlv_check_and_pad_event_tlvs(wmi_handle->scn_handle, |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1260 | data, len, id, |
| 1261 | &wmi_cmd_struct_ptr); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1262 | if (tlv_ok_status != 0) { |
| 1263 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
| 1264 | "%s: Error: id=0x%d, wmitlv check status=%d\n", |
| 1265 | __func__, id, tlv_ok_status); |
| 1266 | goto end; |
| 1267 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1268 | } |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1269 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1270 | |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1271 | idx = wmi_unified_get_event_handler_ix(wmi_handle, id); |
| 1272 | if (idx == A_ERROR) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1273 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1274 | "%s : event handler is not registered: event id 0x%x\n", |
| 1275 | __func__, id); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1276 | goto end; |
| 1277 | } |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1278 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1279 | qdf_spin_lock_bh(&wmi_handle->wmi_record_lock); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1280 | /* Exclude 4 bytes of TLV header */ |
| 1281 | if (id == WMI_MGMT_TX_COMPLETION_EVENTID) { |
| 1282 | WMI_MGMT_EVENT_RECORD(id, ((uint8_t *) data + 4)); |
| 1283 | } else { |
| 1284 | WMI_EVENT_RECORD(id, ((uint8_t *) data + 4)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1285 | } |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1286 | qdf_spin_unlock_bh(&wmi_handle->wmi_record_lock); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1287 | #endif |
| 1288 | /* Call the WMI registered event handler */ |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1289 | if (wmi_handle->target_type == WMI_TLV_TARGET) |
| 1290 | wmi_handle->event_handler[idx] (wmi_handle->scn_handle, |
| 1291 | wmi_cmd_struct_ptr, len); |
| 1292 | else |
| 1293 | wmi_handle->event_handler[idx] (wmi_handle->scn_handle, |
| 1294 | data, len); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1295 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1296 | end: |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1297 | /* Free event buffer and allocated event tlv */ |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1298 | #ifndef WMI_NON_TLV_SUPPORT |
| 1299 | if (wmi_handle->target_type == WMI_TLV_TARGET) |
| 1300 | wmitlv_free_allocated_event_tlvs(id, &wmi_cmd_struct_ptr); |
| 1301 | #endif |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1302 | qdf_nbuf_free(evt_buf); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1303 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1304 | } |
| 1305 | |
| 1306 | /** |
| 1307 | * wmi_rx_event_work() - process rx event in rx work queue context |
| 1308 | * @work: rx work queue struct |
| 1309 | * |
| 1310 | * This function process any fw event to serialize it through rx worker thread. |
| 1311 | * |
| 1312 | * Return: none |
| 1313 | */ |
| 1314 | void wmi_rx_event_work(struct work_struct *work) |
| 1315 | { |
| 1316 | struct wmi_unified *wmi = container_of(work, struct wmi_unified, |
| 1317 | rx_event_work); |
| 1318 | wmi_buf_t buf; |
| 1319 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1320 | qdf_spin_lock_bh(&wmi->eventq_lock); |
| 1321 | buf = qdf_nbuf_queue_remove(&wmi->event_queue); |
| 1322 | qdf_spin_unlock_bh(&wmi->eventq_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1323 | while (buf) { |
| 1324 | __wmi_control_rx(wmi, buf); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1325 | qdf_spin_lock_bh(&wmi->eventq_lock); |
| 1326 | buf = qdf_nbuf_queue_remove(&wmi->event_queue); |
| 1327 | qdf_spin_unlock_bh(&wmi->eventq_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1328 | } |
| 1329 | } |
| 1330 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1331 | #ifdef FEATURE_RUNTIME_PM |
| 1332 | /** |
| 1333 | * wmi_runtime_pm_init() - initialize runtime pm wmi variables |
| 1334 | * @wmi_handle: wmi context |
| 1335 | */ |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1336 | static void wmi_runtime_pm_init(struct wmi_unified *wmi_handle) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1337 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1338 | qdf_atomic_init(&wmi_handle->runtime_pm_inprogress); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1339 | } |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1340 | |
| 1341 | /** |
| 1342 | * wmi_set_runtime_pm_inprogress() - set runtime pm progress flag |
| 1343 | * @wmi_handle: wmi context |
| 1344 | * @val: runtime pm progress flag |
| 1345 | */ |
| 1346 | void wmi_set_runtime_pm_inprogress(wmi_unified_t wmi_handle, A_BOOL val) |
| 1347 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1348 | qdf_atomic_set(&wmi_handle->runtime_pm_inprogress, val); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1349 | } |
| 1350 | |
| 1351 | /** |
| 1352 | * wmi_get_runtime_pm_inprogress() - get runtime pm progress flag |
| 1353 | * @wmi_handle: wmi context |
| 1354 | */ |
| 1355 | inline bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle) |
| 1356 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1357 | return qdf_atomic_read(&wmi_handle->runtime_pm_inprogress); |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1358 | } |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1359 | #else |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1360 | static void wmi_runtime_pm_init(struct wmi_unified *wmi_handle) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1361 | { |
| 1362 | } |
| 1363 | #endif |
| 1364 | |
| 1365 | /** |
| 1366 | * wmi_unified_attach() - attach for unified WMI |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 1367 | * @scn_handle: handle to SCN |
| 1368 | * @osdev: OS device context |
| 1369 | * @target_type: TLV or not-TLV based target |
| 1370 | * @use_cookie: cookie based allocation enabled/disabled |
| 1371 | * @ops: umac rx callbacks |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1372 | * |
| 1373 | * @Return: wmi handle. |
| 1374 | */ |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 1375 | void *wmi_unified_attach(void *scn_handle, |
| 1376 | osdev_t osdev, enum wmi_target_type target_type, |
Govind Singh | 5eb5153 | 2016-03-09 11:34:12 +0530 | [diff] [blame] | 1377 | bool use_cookie, struct wmi_rx_ops *rx_ops) |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1378 | { |
| 1379 | struct wmi_unified *wmi_handle; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1380 | |
| 1381 | #ifndef WMI_NON_TLV_SUPPORT |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1382 | wmi_handle = |
| 1383 | (struct wmi_unified *)os_malloc(NULL, |
| 1384 | sizeof(struct wmi_unified), |
| 1385 | GFP_ATOMIC); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1386 | #else |
| 1387 | wmi_handle = |
| 1388 | (struct wmi_unified *) qdf_mem_malloc( |
| 1389 | sizeof(struct wmi_unified)); |
| 1390 | #endif |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1391 | if (wmi_handle == NULL) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1392 | qdf_print("allocation of wmi handle failed %zu\n", |
Govind Singh | d52faac | 2016-03-09 12:03:29 +0530 | [diff] [blame] | 1393 | sizeof(struct wmi_unified)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1394 | return NULL; |
| 1395 | } |
| 1396 | OS_MEMZERO(wmi_handle, sizeof(struct wmi_unified)); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1397 | wmi_handle->scn_handle = scn_handle; |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1398 | qdf_atomic_init(&wmi_handle->pending_cmds); |
| 1399 | qdf_atomic_init(&wmi_handle->is_target_suspended); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1400 | wmi_runtime_pm_init(wmi_handle); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1401 | qdf_spinlock_create(&wmi_handle->eventq_lock); |
| 1402 | qdf_nbuf_queue_init(&wmi_handle->event_queue); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1403 | #ifdef CONFIG_CNSS |
| 1404 | cnss_init_work(&wmi_handle->rx_event_work, wmi_rx_event_work); |
| 1405 | #else |
| 1406 | INIT_WORK(&wmi_handle->rx_event_work, wmi_rx_event_work); |
| 1407 | #endif |
| 1408 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1409 | qdf_spinlock_create(&wmi_handle->wmi_record_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1410 | #endif |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 1411 | /* Attach mc_thread context processing function */ |
Govind Singh | 5eb5153 | 2016-03-09 11:34:12 +0530 | [diff] [blame] | 1412 | wmi_handle->rx_ops.wma_process_fw_event_handler_cbk = |
| 1413 | rx_ops->wma_process_fw_event_handler_cbk; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1414 | wmi_handle->target_type = target_type; |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 1415 | if (target_type == WMI_TLV_TARGET) |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1416 | wmi_tlv_attach(wmi_handle); |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 1417 | else |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1418 | wmi_non_tlv_attach(wmi_handle); |
Govind Singh | c458f38 | 2016-02-04 18:42:30 +0530 | [diff] [blame] | 1419 | /* Assign target cookie capablity */ |
| 1420 | wmi_handle->use_cookie = use_cookie; |
| 1421 | wmi_handle->osdev = osdev; |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1422 | wmi_handle->wmi_stopinprogress = 0; |
Govind Singh | 813fdac | 2016-03-12 09:26:52 +0530 | [diff] [blame] | 1423 | qdf_spinlock_create(&wmi_handle->ctx_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1424 | |
| 1425 | return wmi_handle; |
| 1426 | } |
| 1427 | |
| 1428 | /** |
| 1429 | * wmi_unified_detach() - detach for unified WMI |
| 1430 | * |
| 1431 | * @wmi_handle : handle to wmi. |
| 1432 | * |
| 1433 | * @Return: none. |
| 1434 | */ |
| 1435 | void wmi_unified_detach(struct wmi_unified *wmi_handle) |
| 1436 | { |
| 1437 | wmi_buf_t buf; |
| 1438 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1439 | cancel_work_sync(&wmi_handle->rx_event_work); |
| 1440 | qdf_spin_lock_bh(&wmi_handle->eventq_lock); |
| 1441 | buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1442 | while (buf) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1443 | qdf_nbuf_free(buf); |
| 1444 | buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1445 | } |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1446 | qdf_spin_unlock_bh(&wmi_handle->eventq_lock); |
Govind Singh | 813fdac | 2016-03-12 09:26:52 +0530 | [diff] [blame] | 1447 | qdf_spinlock_destroy(&wmi_handle->ctx_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1448 | if (wmi_handle != NULL) { |
| 1449 | OS_FREE(wmi_handle); |
| 1450 | wmi_handle = NULL; |
| 1451 | } |
| 1452 | } |
| 1453 | |
| 1454 | /** |
| 1455 | * wmi_unified_remove_work() - detach for WMI work |
| 1456 | * @wmi_handle: handle to WMI |
| 1457 | * |
| 1458 | * A function that does not fully detach WMI, but just remove work |
| 1459 | * queue items associated with it. This is used to make sure that |
| 1460 | * before any other processing code that may destroy related contexts |
| 1461 | * (HTC, etc), work queue processing on WMI has already been stopped. |
| 1462 | * |
| 1463 | * Return: None |
| 1464 | */ |
| 1465 | void |
| 1466 | wmi_unified_remove_work(struct wmi_unified *wmi_handle) |
| 1467 | { |
| 1468 | wmi_buf_t buf; |
| 1469 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1470 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO, |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1471 | "Enter: %s", __func__); |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1472 | cancel_work_sync(&wmi_handle->rx_event_work); |
| 1473 | qdf_spin_lock_bh(&wmi_handle->eventq_lock); |
| 1474 | buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1475 | while (buf) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1476 | qdf_nbuf_free(buf); |
| 1477 | buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1478 | } |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1479 | qdf_spin_unlock_bh(&wmi_handle->eventq_lock); |
| 1480 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO, |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1481 | "Done: %s", __func__); |
| 1482 | } |
| 1483 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1484 | /** |
| 1485 | * wmi_htc_tx_complete() - Process htc tx completion |
| 1486 | * |
| 1487 | * @ctx: handle to wmi |
| 1488 | * @htc_packet: pointer to htc packet |
| 1489 | * |
| 1490 | * @Return: none. |
| 1491 | */ |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1492 | void wmi_htc_tx_complete(void *ctx, HTC_PACKET *htc_pkt) |
| 1493 | { |
| 1494 | struct wmi_unified *wmi_handle = (struct wmi_unified *)ctx; |
| 1495 | wmi_buf_t wmi_cmd_buf = GET_HTC_PACKET_NET_BUF_CONTEXT(htc_pkt); |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1496 | |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1497 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
| 1498 | uint32_t cmd_id; |
| 1499 | #endif |
| 1500 | |
| 1501 | ASSERT(wmi_cmd_buf); |
| 1502 | #ifdef WMI_INTERFACE_EVENT_LOGGING |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1503 | cmd_id = WMI_GET_FIELD(qdf_nbuf_data(wmi_cmd_buf), |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1504 | WMI_CMD_HDR, COMMANDID); |
| 1505 | |
| 1506 | #ifdef QCA_WIFI_3_0_EMU |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1507 | qdf_print |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1508 | ("\nSent WMI command:%s command_id:0x%x over dma and recieved tx complete interupt\n", |
| 1509 | get_wmi_cmd_string(cmd_id), cmd_id); |
| 1510 | #endif |
| 1511 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1512 | qdf_spin_lock_bh(&wmi_handle->wmi_record_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1513 | /* Record 16 bytes of WMI cmd tx complete data |
| 1514 | - exclude TLV and WMI headers */ |
| 1515 | if (cmd_id == WMI_MGMT_TX_SEND_CMDID) { |
| 1516 | WMI_MGMT_COMMAND_TX_CMP_RECORD(cmd_id, |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1517 | ((uint32_t *) qdf_nbuf_data(wmi_cmd_buf) + 2)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1518 | } else { |
| 1519 | WMI_COMMAND_TX_CMP_RECORD(cmd_id, |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1520 | ((uint32_t *) qdf_nbuf_data(wmi_cmd_buf) + 2)); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1521 | } |
| 1522 | |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1523 | qdf_spin_unlock_bh(&wmi_handle->wmi_record_lock); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1524 | #endif |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1525 | qdf_nbuf_free(wmi_cmd_buf); |
| 1526 | qdf_mem_free(htc_pkt); |
| 1527 | qdf_atomic_dec(&wmi_handle->pending_cmds); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1528 | } |
| 1529 | |
| 1530 | /** |
| 1531 | * wmi_get_host_credits() - WMI API to get updated host_credits |
| 1532 | * |
| 1533 | * @wmi_handle: handle to WMI. |
| 1534 | * |
| 1535 | * @Return: updated host_credits. |
| 1536 | */ |
| 1537 | int |
| 1538 | wmi_unified_connect_htc_service(struct wmi_unified *wmi_handle, |
| 1539 | void *htc_handle) |
| 1540 | { |
| 1541 | |
| 1542 | int status; |
| 1543 | HTC_SERVICE_CONNECT_RESP response; |
| 1544 | HTC_SERVICE_CONNECT_REQ connect; |
| 1545 | |
| 1546 | OS_MEMZERO(&connect, sizeof(connect)); |
| 1547 | OS_MEMZERO(&response, sizeof(response)); |
| 1548 | |
| 1549 | /* meta data is unused for now */ |
| 1550 | connect.pMetaData = NULL; |
| 1551 | connect.MetaDataLength = 0; |
| 1552 | /* these fields are the same for all service endpoints */ |
| 1553 | connect.EpCallbacks.pContext = wmi_handle; |
| 1554 | connect.EpCallbacks.EpTxCompleteMultiple = |
| 1555 | NULL /* Control path completion ar6000_tx_complete */; |
| 1556 | connect.EpCallbacks.EpRecv = wmi_control_rx /* Control path rx */; |
| 1557 | connect.EpCallbacks.EpRecvRefill = NULL /* ar6000_rx_refill */; |
| 1558 | connect.EpCallbacks.EpSendFull = NULL /* ar6000_tx_queue_full */; |
| 1559 | connect.EpCallbacks.EpTxComplete = |
| 1560 | wmi_htc_tx_complete /* ar6000_tx_queue_full */; |
| 1561 | |
| 1562 | /* connect to control service */ |
| 1563 | connect.service_id = WMI_CONTROL_SVC; |
| 1564 | status = htc_connect_service(htc_handle, &connect, |
| 1565 | &response); |
| 1566 | |
| 1567 | if (status != EOK) { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1568 | qdf_print |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1569 | ("Failed to connect to WMI CONTROL service status:%d \n", |
| 1570 | status); |
| 1571 | return status; |
| 1572 | } |
| 1573 | wmi_handle->wmi_endpoint_id = response.Endpoint; |
| 1574 | wmi_handle->htc_handle = htc_handle; |
| 1575 | wmi_handle->max_msg_len = response.MaxMsgLength; |
| 1576 | |
| 1577 | return EOK; |
| 1578 | } |
| 1579 | |
| 1580 | /** |
| 1581 | * wmi_get_host_credits() - WMI API to get updated host_credits |
| 1582 | * |
| 1583 | * @wmi_handle: handle to WMI. |
| 1584 | * |
| 1585 | * @Return: updated host_credits. |
| 1586 | */ |
| 1587 | int wmi_get_host_credits(wmi_unified_t wmi_handle) |
| 1588 | { |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1589 | int host_credits = 0; |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1590 | |
| 1591 | htc_get_control_endpoint_tx_host_credits(wmi_handle->htc_handle, |
| 1592 | &host_credits); |
| 1593 | return host_credits; |
| 1594 | } |
| 1595 | |
| 1596 | /** |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1597 | * wmi_get_pending_cmds() - WMI API to get WMI Pending Commands in the HTC |
| 1598 | * queue |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1599 | * |
| 1600 | * @wmi_handle: handle to WMI. |
| 1601 | * |
| 1602 | * @Return: Pending Commands in the HTC queue. |
| 1603 | */ |
| 1604 | int wmi_get_pending_cmds(wmi_unified_t wmi_handle) |
| 1605 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1606 | return qdf_atomic_read(&wmi_handle->pending_cmds); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1607 | } |
| 1608 | |
| 1609 | /** |
| 1610 | * wmi_set_target_suspend() - WMI API to set target suspend state |
| 1611 | * |
| 1612 | * @wmi_handle: handle to WMI. |
| 1613 | * @val: suspend state boolean. |
| 1614 | * |
| 1615 | * @Return: none. |
| 1616 | */ |
| 1617 | void wmi_set_target_suspend(wmi_unified_t wmi_handle, A_BOOL val) |
| 1618 | { |
Govind Singh | b53420c | 2016-03-09 14:32:57 +0530 | [diff] [blame] | 1619 | qdf_atomic_set(&wmi_handle->is_target_suspended, val); |
Govind Singh | 6b411b5 | 2016-03-06 19:55:02 +0530 | [diff] [blame] | 1620 | } |
| 1621 | |
Govind Singh | e7d9f3e | 2016-04-15 13:58:27 +0530 | [diff] [blame^] | 1622 | #ifdef WMI_NON_TLV_SUPPORT |
| 1623 | /** |
| 1624 | * API to flush all the previous packets associated with the wmi endpoint |
| 1625 | * |
| 1626 | * @param wmi_handle : handle to WMI. |
| 1627 | */ |
| 1628 | void |
| 1629 | wmi_flush_endpoint(wmi_unified_t wmi_handle) |
| 1630 | { |
| 1631 | htc_flush_endpoint(wmi_handle->htc_handle, |
| 1632 | wmi_handle->wmi_endpoint_id, 0); |
| 1633 | } |
| 1634 | |
| 1635 | /** |
| 1636 | * generic function to block unified WMI command |
| 1637 | * @param wmi_handle : handle to WMI. |
| 1638 | * @return 0 on success and -ve on failure. |
| 1639 | */ |
| 1640 | int |
| 1641 | wmi_stop(wmi_unified_t wmi_handle) |
| 1642 | { |
| 1643 | QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO, |
| 1644 | "WMI Stop\n"); |
| 1645 | wmi_handle->wmi_stopinprogress = 1; |
| 1646 | return 0; |
| 1647 | } |
| 1648 | #endif |