linux/drivers/net/wireless/ath/ath10k/wmi.c
<<
>>
Prefs
   1/*
   2 * Copyright (c) 2005-2011 Atheros Communications Inc.
   3 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
   4 *
   5 * Permission to use, copy, modify, and/or distribute this software for any
   6 * purpose with or without fee is hereby granted, provided that the above
   7 * copyright notice and this permission notice appear in all copies.
   8 *
   9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16 */
  17
  18#include <linux/skbuff.h>
  19#include <linux/ctype.h>
  20
  21#include "core.h"
  22#include "htc.h"
  23#include "debug.h"
  24#include "wmi.h"
  25#include "wmi-tlv.h"
  26#include "mac.h"
  27#include "testmode.h"
  28#include "wmi-ops.h"
  29#include "p2p.h"
  30#include "hw.h"
  31#include "hif.h"
  32#include "txrx.h"
  33
  34#define ATH10K_WMI_BARRIER_ECHO_ID 0xBA991E9
  35#define ATH10K_WMI_BARRIER_TIMEOUT_HZ (3 * HZ)
  36
  37/* MAIN WMI cmd track */
  38static struct wmi_cmd_map wmi_cmd_map = {
  39        .init_cmdid = WMI_INIT_CMDID,
  40        .start_scan_cmdid = WMI_START_SCAN_CMDID,
  41        .stop_scan_cmdid = WMI_STOP_SCAN_CMDID,
  42        .scan_chan_list_cmdid = WMI_SCAN_CHAN_LIST_CMDID,
  43        .scan_sch_prio_tbl_cmdid = WMI_SCAN_SCH_PRIO_TBL_CMDID,
  44        .pdev_set_regdomain_cmdid = WMI_PDEV_SET_REGDOMAIN_CMDID,
  45        .pdev_set_channel_cmdid = WMI_PDEV_SET_CHANNEL_CMDID,
  46        .pdev_set_param_cmdid = WMI_PDEV_SET_PARAM_CMDID,
  47        .pdev_pktlog_enable_cmdid = WMI_PDEV_PKTLOG_ENABLE_CMDID,
  48        .pdev_pktlog_disable_cmdid = WMI_PDEV_PKTLOG_DISABLE_CMDID,
  49        .pdev_set_wmm_params_cmdid = WMI_PDEV_SET_WMM_PARAMS_CMDID,
  50        .pdev_set_ht_cap_ie_cmdid = WMI_PDEV_SET_HT_CAP_IE_CMDID,
  51        .pdev_set_vht_cap_ie_cmdid = WMI_PDEV_SET_VHT_CAP_IE_CMDID,
  52        .pdev_set_dscp_tid_map_cmdid = WMI_PDEV_SET_DSCP_TID_MAP_CMDID,
  53        .pdev_set_quiet_mode_cmdid = WMI_PDEV_SET_QUIET_MODE_CMDID,
  54        .pdev_green_ap_ps_enable_cmdid = WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID,
  55        .pdev_get_tpc_config_cmdid = WMI_PDEV_GET_TPC_CONFIG_CMDID,
  56        .pdev_set_base_macaddr_cmdid = WMI_PDEV_SET_BASE_MACADDR_CMDID,
  57        .vdev_create_cmdid = WMI_VDEV_CREATE_CMDID,
  58        .vdev_delete_cmdid = WMI_VDEV_DELETE_CMDID,
  59        .vdev_start_request_cmdid = WMI_VDEV_START_REQUEST_CMDID,
  60        .vdev_restart_request_cmdid = WMI_VDEV_RESTART_REQUEST_CMDID,
  61        .vdev_up_cmdid = WMI_VDEV_UP_CMDID,
  62        .vdev_stop_cmdid = WMI_VDEV_STOP_CMDID,
  63        .vdev_down_cmdid = WMI_VDEV_DOWN_CMDID,
  64        .vdev_set_param_cmdid = WMI_VDEV_SET_PARAM_CMDID,
  65        .vdev_install_key_cmdid = WMI_VDEV_INSTALL_KEY_CMDID,
  66        .peer_create_cmdid = WMI_PEER_CREATE_CMDID,
  67        .peer_delete_cmdid = WMI_PEER_DELETE_CMDID,
  68        .peer_flush_tids_cmdid = WMI_PEER_FLUSH_TIDS_CMDID,
  69        .peer_set_param_cmdid = WMI_PEER_SET_PARAM_CMDID,
  70        .peer_assoc_cmdid = WMI_PEER_ASSOC_CMDID,
  71        .peer_add_wds_entry_cmdid = WMI_PEER_ADD_WDS_ENTRY_CMDID,
  72        .peer_remove_wds_entry_cmdid = WMI_PEER_REMOVE_WDS_ENTRY_CMDID,
  73        .peer_mcast_group_cmdid = WMI_PEER_MCAST_GROUP_CMDID,
  74        .bcn_tx_cmdid = WMI_BCN_TX_CMDID,
  75        .pdev_send_bcn_cmdid = WMI_PDEV_SEND_BCN_CMDID,
  76        .bcn_tmpl_cmdid = WMI_BCN_TMPL_CMDID,
  77        .bcn_filter_rx_cmdid = WMI_BCN_FILTER_RX_CMDID,
  78        .prb_req_filter_rx_cmdid = WMI_PRB_REQ_FILTER_RX_CMDID,
  79        .mgmt_tx_cmdid = WMI_MGMT_TX_CMDID,
  80        .prb_tmpl_cmdid = WMI_PRB_TMPL_CMDID,
  81        .addba_clear_resp_cmdid = WMI_ADDBA_CLEAR_RESP_CMDID,
  82        .addba_send_cmdid = WMI_ADDBA_SEND_CMDID,
  83        .addba_status_cmdid = WMI_ADDBA_STATUS_CMDID,
  84        .delba_send_cmdid = WMI_DELBA_SEND_CMDID,
  85        .addba_set_resp_cmdid = WMI_ADDBA_SET_RESP_CMDID,
  86        .send_singleamsdu_cmdid = WMI_SEND_SINGLEAMSDU_CMDID,
  87        .sta_powersave_mode_cmdid = WMI_STA_POWERSAVE_MODE_CMDID,
  88        .sta_powersave_param_cmdid = WMI_STA_POWERSAVE_PARAM_CMDID,
  89        .sta_mimo_ps_mode_cmdid = WMI_STA_MIMO_PS_MODE_CMDID,
  90        .pdev_dfs_enable_cmdid = WMI_PDEV_DFS_ENABLE_CMDID,
  91        .pdev_dfs_disable_cmdid = WMI_PDEV_DFS_DISABLE_CMDID,
  92        .roam_scan_mode = WMI_ROAM_SCAN_MODE,
  93        .roam_scan_rssi_threshold = WMI_ROAM_SCAN_RSSI_THRESHOLD,
  94        .roam_scan_period = WMI_ROAM_SCAN_PERIOD,
  95        .roam_scan_rssi_change_threshold = WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
  96        .roam_ap_profile = WMI_ROAM_AP_PROFILE,
  97        .ofl_scan_add_ap_profile = WMI_ROAM_AP_PROFILE,
  98        .ofl_scan_remove_ap_profile = WMI_OFL_SCAN_REMOVE_AP_PROFILE,
  99        .ofl_scan_period = WMI_OFL_SCAN_PERIOD,
 100        .p2p_dev_set_device_info = WMI_P2P_DEV_SET_DEVICE_INFO,
 101        .p2p_dev_set_discoverability = WMI_P2P_DEV_SET_DISCOVERABILITY,
 102        .p2p_go_set_beacon_ie = WMI_P2P_GO_SET_BEACON_IE,
 103        .p2p_go_set_probe_resp_ie = WMI_P2P_GO_SET_PROBE_RESP_IE,
 104        .p2p_set_vendor_ie_data_cmdid = WMI_P2P_SET_VENDOR_IE_DATA_CMDID,
 105        .ap_ps_peer_param_cmdid = WMI_AP_PS_PEER_PARAM_CMDID,
 106        .ap_ps_peer_uapsd_coex_cmdid = WMI_AP_PS_PEER_UAPSD_COEX_CMDID,
 107        .peer_rate_retry_sched_cmdid = WMI_PEER_RATE_RETRY_SCHED_CMDID,
 108        .wlan_profile_trigger_cmdid = WMI_WLAN_PROFILE_TRIGGER_CMDID,
 109        .wlan_profile_set_hist_intvl_cmdid =
 110                                WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
 111        .wlan_profile_get_profile_data_cmdid =
 112                                WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
 113        .wlan_profile_enable_profile_id_cmdid =
 114                                WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
 115        .wlan_profile_list_profile_id_cmdid =
 116                                WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
 117        .pdev_suspend_cmdid = WMI_PDEV_SUSPEND_CMDID,
 118        .pdev_resume_cmdid = WMI_PDEV_RESUME_CMDID,
 119        .add_bcn_filter_cmdid = WMI_ADD_BCN_FILTER_CMDID,
 120        .rmv_bcn_filter_cmdid = WMI_RMV_BCN_FILTER_CMDID,
 121        .wow_add_wake_pattern_cmdid = WMI_WOW_ADD_WAKE_PATTERN_CMDID,
 122        .wow_del_wake_pattern_cmdid = WMI_WOW_DEL_WAKE_PATTERN_CMDID,
 123        .wow_enable_disable_wake_event_cmdid =
 124                                WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
 125        .wow_enable_cmdid = WMI_WOW_ENABLE_CMDID,
 126        .wow_hostwakeup_from_sleep_cmdid = WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
 127        .rtt_measreq_cmdid = WMI_RTT_MEASREQ_CMDID,
 128        .rtt_tsf_cmdid = WMI_RTT_TSF_CMDID,
 129        .vdev_spectral_scan_configure_cmdid =
 130                                WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
 131        .vdev_spectral_scan_enable_cmdid = WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
 132        .request_stats_cmdid = WMI_REQUEST_STATS_CMDID,
 133        .set_arp_ns_offload_cmdid = WMI_SET_ARP_NS_OFFLOAD_CMDID,
 134        .network_list_offload_config_cmdid =
 135                                WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID,
 136        .gtk_offload_cmdid = WMI_GTK_OFFLOAD_CMDID,
 137        .csa_offload_enable_cmdid = WMI_CSA_OFFLOAD_ENABLE_CMDID,
 138        .csa_offload_chanswitch_cmdid = WMI_CSA_OFFLOAD_CHANSWITCH_CMDID,
 139        .chatter_set_mode_cmdid = WMI_CHATTER_SET_MODE_CMDID,
 140        .peer_tid_addba_cmdid = WMI_PEER_TID_ADDBA_CMDID,
 141        .peer_tid_delba_cmdid = WMI_PEER_TID_DELBA_CMDID,
 142        .sta_dtim_ps_method_cmdid = WMI_STA_DTIM_PS_METHOD_CMDID,
 143        .sta_uapsd_auto_trig_cmdid = WMI_STA_UAPSD_AUTO_TRIG_CMDID,
 144        .sta_keepalive_cmd = WMI_STA_KEEPALIVE_CMD,
 145        .echo_cmdid = WMI_ECHO_CMDID,
 146        .pdev_utf_cmdid = WMI_PDEV_UTF_CMDID,
 147        .dbglog_cfg_cmdid = WMI_DBGLOG_CFG_CMDID,
 148        .pdev_qvit_cmdid = WMI_PDEV_QVIT_CMDID,
 149        .pdev_ftm_intg_cmdid = WMI_PDEV_FTM_INTG_CMDID,
 150        .vdev_set_keepalive_cmdid = WMI_VDEV_SET_KEEPALIVE_CMDID,
 151        .vdev_get_keepalive_cmdid = WMI_VDEV_GET_KEEPALIVE_CMDID,
 152        .force_fw_hang_cmdid = WMI_FORCE_FW_HANG_CMDID,
 153        .gpio_config_cmdid = WMI_GPIO_CONFIG_CMDID,
 154        .gpio_output_cmdid = WMI_GPIO_OUTPUT_CMDID,
 155        .pdev_get_temperature_cmdid = WMI_CMD_UNSUPPORTED,
 156        .pdev_enable_adaptive_cca_cmdid = WMI_CMD_UNSUPPORTED,
 157        .scan_update_request_cmdid = WMI_CMD_UNSUPPORTED,
 158        .vdev_standby_response_cmdid = WMI_CMD_UNSUPPORTED,
 159        .vdev_resume_response_cmdid = WMI_CMD_UNSUPPORTED,
 160        .wlan_peer_caching_add_peer_cmdid = WMI_CMD_UNSUPPORTED,
 161        .wlan_peer_caching_evict_peer_cmdid = WMI_CMD_UNSUPPORTED,
 162        .wlan_peer_caching_restore_peer_cmdid = WMI_CMD_UNSUPPORTED,
 163        .wlan_peer_caching_print_all_peers_info_cmdid = WMI_CMD_UNSUPPORTED,
 164        .peer_update_wds_entry_cmdid = WMI_CMD_UNSUPPORTED,
 165        .peer_add_proxy_sta_entry_cmdid = WMI_CMD_UNSUPPORTED,
 166        .rtt_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
 167        .oem_req_cmdid = WMI_CMD_UNSUPPORTED,
 168        .nan_cmdid = WMI_CMD_UNSUPPORTED,
 169        .vdev_ratemask_cmdid = WMI_CMD_UNSUPPORTED,
 170        .qboost_cfg_cmdid = WMI_CMD_UNSUPPORTED,
 171        .pdev_smart_ant_enable_cmdid = WMI_CMD_UNSUPPORTED,
 172        .pdev_smart_ant_set_rx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
 173        .peer_smart_ant_set_tx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
 174        .peer_smart_ant_set_train_info_cmdid = WMI_CMD_UNSUPPORTED,
 175        .peer_smart_ant_set_node_config_ops_cmdid = WMI_CMD_UNSUPPORTED,
 176        .pdev_set_antenna_switch_table_cmdid = WMI_CMD_UNSUPPORTED,
 177        .pdev_set_ctl_table_cmdid = WMI_CMD_UNSUPPORTED,
 178        .pdev_set_mimogain_table_cmdid = WMI_CMD_UNSUPPORTED,
 179        .pdev_ratepwr_table_cmdid = WMI_CMD_UNSUPPORTED,
 180        .pdev_ratepwr_chainmsk_table_cmdid = WMI_CMD_UNSUPPORTED,
 181        .pdev_fips_cmdid = WMI_CMD_UNSUPPORTED,
 182        .tt_set_conf_cmdid = WMI_CMD_UNSUPPORTED,
 183        .fwtest_cmdid = WMI_CMD_UNSUPPORTED,
 184        .vdev_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
 185        .peer_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
 186        .pdev_get_ani_cck_config_cmdid = WMI_CMD_UNSUPPORTED,
 187        .pdev_get_ani_ofdm_config_cmdid = WMI_CMD_UNSUPPORTED,
 188        .pdev_reserve_ast_entry_cmdid = WMI_CMD_UNSUPPORTED,
 189        .pdev_get_nfcal_power_cmdid = WMI_CMD_UNSUPPORTED,
 190        .pdev_get_tpc_cmdid = WMI_CMD_UNSUPPORTED,
 191        .pdev_get_ast_info_cmdid = WMI_CMD_UNSUPPORTED,
 192        .vdev_set_dscp_tid_map_cmdid = WMI_CMD_UNSUPPORTED,
 193        .pdev_get_info_cmdid = WMI_CMD_UNSUPPORTED,
 194        .vdev_get_info_cmdid = WMI_CMD_UNSUPPORTED,
 195        .vdev_filter_neighbor_rx_packets_cmdid = WMI_CMD_UNSUPPORTED,
 196        .mu_cal_start_cmdid = WMI_CMD_UNSUPPORTED,
 197        .set_cca_params_cmdid = WMI_CMD_UNSUPPORTED,
 198        .pdev_bss_chan_info_request_cmdid = WMI_CMD_UNSUPPORTED,
 199};
 200
 201/* 10.X WMI cmd track */
 202static struct wmi_cmd_map wmi_10x_cmd_map = {
 203        .init_cmdid = WMI_10X_INIT_CMDID,
 204        .start_scan_cmdid = WMI_10X_START_SCAN_CMDID,
 205        .stop_scan_cmdid = WMI_10X_STOP_SCAN_CMDID,
 206        .scan_chan_list_cmdid = WMI_10X_SCAN_CHAN_LIST_CMDID,
 207        .scan_sch_prio_tbl_cmdid = WMI_CMD_UNSUPPORTED,
 208        .pdev_set_regdomain_cmdid = WMI_10X_PDEV_SET_REGDOMAIN_CMDID,
 209        .pdev_set_channel_cmdid = WMI_10X_PDEV_SET_CHANNEL_CMDID,
 210        .pdev_set_param_cmdid = WMI_10X_PDEV_SET_PARAM_CMDID,
 211        .pdev_pktlog_enable_cmdid = WMI_10X_PDEV_PKTLOG_ENABLE_CMDID,
 212        .pdev_pktlog_disable_cmdid = WMI_10X_PDEV_PKTLOG_DISABLE_CMDID,
 213        .pdev_set_wmm_params_cmdid = WMI_10X_PDEV_SET_WMM_PARAMS_CMDID,
 214        .pdev_set_ht_cap_ie_cmdid = WMI_10X_PDEV_SET_HT_CAP_IE_CMDID,
 215        .pdev_set_vht_cap_ie_cmdid = WMI_10X_PDEV_SET_VHT_CAP_IE_CMDID,
 216        .pdev_set_dscp_tid_map_cmdid = WMI_10X_PDEV_SET_DSCP_TID_MAP_CMDID,
 217        .pdev_set_quiet_mode_cmdid = WMI_10X_PDEV_SET_QUIET_MODE_CMDID,
 218        .pdev_green_ap_ps_enable_cmdid = WMI_10X_PDEV_GREEN_AP_PS_ENABLE_CMDID,
 219        .pdev_get_tpc_config_cmdid = WMI_10X_PDEV_GET_TPC_CONFIG_CMDID,
 220        .pdev_set_base_macaddr_cmdid = WMI_10X_PDEV_SET_BASE_MACADDR_CMDID,
 221        .vdev_create_cmdid = WMI_10X_VDEV_CREATE_CMDID,
 222        .vdev_delete_cmdid = WMI_10X_VDEV_DELETE_CMDID,
 223        .vdev_start_request_cmdid = WMI_10X_VDEV_START_REQUEST_CMDID,
 224        .vdev_restart_request_cmdid = WMI_10X_VDEV_RESTART_REQUEST_CMDID,
 225        .vdev_up_cmdid = WMI_10X_VDEV_UP_CMDID,
 226        .vdev_stop_cmdid = WMI_10X_VDEV_STOP_CMDID,
 227        .vdev_down_cmdid = WMI_10X_VDEV_DOWN_CMDID,
 228        .vdev_set_param_cmdid = WMI_10X_VDEV_SET_PARAM_CMDID,
 229        .vdev_install_key_cmdid = WMI_10X_VDEV_INSTALL_KEY_CMDID,
 230        .peer_create_cmdid = WMI_10X_PEER_CREATE_CMDID,
 231        .peer_delete_cmdid = WMI_10X_PEER_DELETE_CMDID,
 232        .peer_flush_tids_cmdid = WMI_10X_PEER_FLUSH_TIDS_CMDID,
 233        .peer_set_param_cmdid = WMI_10X_PEER_SET_PARAM_CMDID,
 234        .peer_assoc_cmdid = WMI_10X_PEER_ASSOC_CMDID,
 235        .peer_add_wds_entry_cmdid = WMI_10X_PEER_ADD_WDS_ENTRY_CMDID,
 236        .peer_remove_wds_entry_cmdid = WMI_10X_PEER_REMOVE_WDS_ENTRY_CMDID,
 237        .peer_mcast_group_cmdid = WMI_10X_PEER_MCAST_GROUP_CMDID,
 238        .bcn_tx_cmdid = WMI_10X_BCN_TX_CMDID,
 239        .pdev_send_bcn_cmdid = WMI_10X_PDEV_SEND_BCN_CMDID,
 240        .bcn_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
 241        .bcn_filter_rx_cmdid = WMI_10X_BCN_FILTER_RX_CMDID,
 242        .prb_req_filter_rx_cmdid = WMI_10X_PRB_REQ_FILTER_RX_CMDID,
 243        .mgmt_tx_cmdid = WMI_10X_MGMT_TX_CMDID,
 244        .prb_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
 245        .addba_clear_resp_cmdid = WMI_10X_ADDBA_CLEAR_RESP_CMDID,
 246        .addba_send_cmdid = WMI_10X_ADDBA_SEND_CMDID,
 247        .addba_status_cmdid = WMI_10X_ADDBA_STATUS_CMDID,
 248        .delba_send_cmdid = WMI_10X_DELBA_SEND_CMDID,
 249        .addba_set_resp_cmdid = WMI_10X_ADDBA_SET_RESP_CMDID,
 250        .send_singleamsdu_cmdid = WMI_10X_SEND_SINGLEAMSDU_CMDID,
 251        .sta_powersave_mode_cmdid = WMI_10X_STA_POWERSAVE_MODE_CMDID,
 252        .sta_powersave_param_cmdid = WMI_10X_STA_POWERSAVE_PARAM_CMDID,
 253        .sta_mimo_ps_mode_cmdid = WMI_10X_STA_MIMO_PS_MODE_CMDID,
 254        .pdev_dfs_enable_cmdid = WMI_10X_PDEV_DFS_ENABLE_CMDID,
 255        .pdev_dfs_disable_cmdid = WMI_10X_PDEV_DFS_DISABLE_CMDID,
 256        .roam_scan_mode = WMI_10X_ROAM_SCAN_MODE,
 257        .roam_scan_rssi_threshold = WMI_10X_ROAM_SCAN_RSSI_THRESHOLD,
 258        .roam_scan_period = WMI_10X_ROAM_SCAN_PERIOD,
 259        .roam_scan_rssi_change_threshold =
 260                                WMI_10X_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
 261        .roam_ap_profile = WMI_10X_ROAM_AP_PROFILE,
 262        .ofl_scan_add_ap_profile = WMI_10X_OFL_SCAN_ADD_AP_PROFILE,
 263        .ofl_scan_remove_ap_profile = WMI_10X_OFL_SCAN_REMOVE_AP_PROFILE,
 264        .ofl_scan_period = WMI_10X_OFL_SCAN_PERIOD,
 265        .p2p_dev_set_device_info = WMI_10X_P2P_DEV_SET_DEVICE_INFO,
 266        .p2p_dev_set_discoverability = WMI_10X_P2P_DEV_SET_DISCOVERABILITY,
 267        .p2p_go_set_beacon_ie = WMI_10X_P2P_GO_SET_BEACON_IE,
 268        .p2p_go_set_probe_resp_ie = WMI_10X_P2P_GO_SET_PROBE_RESP_IE,
 269        .p2p_set_vendor_ie_data_cmdid = WMI_CMD_UNSUPPORTED,
 270        .ap_ps_peer_param_cmdid = WMI_10X_AP_PS_PEER_PARAM_CMDID,
 271        .ap_ps_peer_uapsd_coex_cmdid = WMI_CMD_UNSUPPORTED,
 272        .peer_rate_retry_sched_cmdid = WMI_10X_PEER_RATE_RETRY_SCHED_CMDID,
 273        .wlan_profile_trigger_cmdid = WMI_10X_WLAN_PROFILE_TRIGGER_CMDID,
 274        .wlan_profile_set_hist_intvl_cmdid =
 275                                WMI_10X_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
 276        .wlan_profile_get_profile_data_cmdid =
 277                                WMI_10X_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
 278        .wlan_profile_enable_profile_id_cmdid =
 279                                WMI_10X_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
 280        .wlan_profile_list_profile_id_cmdid =
 281                                WMI_10X_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
 282        .pdev_suspend_cmdid = WMI_10X_PDEV_SUSPEND_CMDID,
 283        .pdev_resume_cmdid = WMI_10X_PDEV_RESUME_CMDID,
 284        .add_bcn_filter_cmdid = WMI_10X_ADD_BCN_FILTER_CMDID,
 285        .rmv_bcn_filter_cmdid = WMI_10X_RMV_BCN_FILTER_CMDID,
 286        .wow_add_wake_pattern_cmdid = WMI_10X_WOW_ADD_WAKE_PATTERN_CMDID,
 287        .wow_del_wake_pattern_cmdid = WMI_10X_WOW_DEL_WAKE_PATTERN_CMDID,
 288        .wow_enable_disable_wake_event_cmdid =
 289                                WMI_10X_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
 290        .wow_enable_cmdid = WMI_10X_WOW_ENABLE_CMDID,
 291        .wow_hostwakeup_from_sleep_cmdid =
 292                                WMI_10X_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
 293        .rtt_measreq_cmdid = WMI_10X_RTT_MEASREQ_CMDID,
 294        .rtt_tsf_cmdid = WMI_10X_RTT_TSF_CMDID,
 295        .vdev_spectral_scan_configure_cmdid =
 296                                WMI_10X_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
 297        .vdev_spectral_scan_enable_cmdid =
 298                                WMI_10X_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
 299        .request_stats_cmdid = WMI_10X_REQUEST_STATS_CMDID,
 300        .set_arp_ns_offload_cmdid = WMI_CMD_UNSUPPORTED,
 301        .network_list_offload_config_cmdid = WMI_CMD_UNSUPPORTED,
 302        .gtk_offload_cmdid = WMI_CMD_UNSUPPORTED,
 303        .csa_offload_enable_cmdid = WMI_CMD_UNSUPPORTED,
 304        .csa_offload_chanswitch_cmdid = WMI_CMD_UNSUPPORTED,
 305        .chatter_set_mode_cmdid = WMI_CMD_UNSUPPORTED,
 306        .peer_tid_addba_cmdid = WMI_CMD_UNSUPPORTED,
 307        .peer_tid_delba_cmdid = WMI_CMD_UNSUPPORTED,
 308        .sta_dtim_ps_method_cmdid = WMI_CMD_UNSUPPORTED,
 309        .sta_uapsd_auto_trig_cmdid = WMI_CMD_UNSUPPORTED,
 310        .sta_keepalive_cmd = WMI_CMD_UNSUPPORTED,
 311        .echo_cmdid = WMI_10X_ECHO_CMDID,
 312        .pdev_utf_cmdid = WMI_10X_PDEV_UTF_CMDID,
 313        .dbglog_cfg_cmdid = WMI_10X_DBGLOG_CFG_CMDID,
 314        .pdev_qvit_cmdid = WMI_10X_PDEV_QVIT_CMDID,
 315        .pdev_ftm_intg_cmdid = WMI_CMD_UNSUPPORTED,
 316        .vdev_set_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
 317        .vdev_get_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
 318        .force_fw_hang_cmdid = WMI_CMD_UNSUPPORTED,
 319        .gpio_config_cmdid = WMI_10X_GPIO_CONFIG_CMDID,
 320        .gpio_output_cmdid = WMI_10X_GPIO_OUTPUT_CMDID,
 321        .pdev_get_temperature_cmdid = WMI_CMD_UNSUPPORTED,
 322        .pdev_enable_adaptive_cca_cmdid = WMI_CMD_UNSUPPORTED,
 323        .scan_update_request_cmdid = WMI_CMD_UNSUPPORTED,
 324        .vdev_standby_response_cmdid = WMI_CMD_UNSUPPORTED,
 325        .vdev_resume_response_cmdid = WMI_CMD_UNSUPPORTED,
 326        .wlan_peer_caching_add_peer_cmdid = WMI_CMD_UNSUPPORTED,
 327        .wlan_peer_caching_evict_peer_cmdid = WMI_CMD_UNSUPPORTED,
 328        .wlan_peer_caching_restore_peer_cmdid = WMI_CMD_UNSUPPORTED,
 329        .wlan_peer_caching_print_all_peers_info_cmdid = WMI_CMD_UNSUPPORTED,
 330        .peer_update_wds_entry_cmdid = WMI_CMD_UNSUPPORTED,
 331        .peer_add_proxy_sta_entry_cmdid = WMI_CMD_UNSUPPORTED,
 332        .rtt_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
 333        .oem_req_cmdid = WMI_CMD_UNSUPPORTED,
 334        .nan_cmdid = WMI_CMD_UNSUPPORTED,
 335        .vdev_ratemask_cmdid = WMI_CMD_UNSUPPORTED,
 336        .qboost_cfg_cmdid = WMI_CMD_UNSUPPORTED,
 337        .pdev_smart_ant_enable_cmdid = WMI_CMD_UNSUPPORTED,
 338        .pdev_smart_ant_set_rx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
 339        .peer_smart_ant_set_tx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
 340        .peer_smart_ant_set_train_info_cmdid = WMI_CMD_UNSUPPORTED,
 341        .peer_smart_ant_set_node_config_ops_cmdid = WMI_CMD_UNSUPPORTED,
 342        .pdev_set_antenna_switch_table_cmdid = WMI_CMD_UNSUPPORTED,
 343        .pdev_set_ctl_table_cmdid = WMI_CMD_UNSUPPORTED,
 344        .pdev_set_mimogain_table_cmdid = WMI_CMD_UNSUPPORTED,
 345        .pdev_ratepwr_table_cmdid = WMI_CMD_UNSUPPORTED,
 346        .pdev_ratepwr_chainmsk_table_cmdid = WMI_CMD_UNSUPPORTED,
 347        .pdev_fips_cmdid = WMI_CMD_UNSUPPORTED,
 348        .tt_set_conf_cmdid = WMI_CMD_UNSUPPORTED,
 349        .fwtest_cmdid = WMI_CMD_UNSUPPORTED,
 350        .vdev_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
 351        .peer_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
 352        .pdev_get_ani_cck_config_cmdid = WMI_CMD_UNSUPPORTED,
 353        .pdev_get_ani_ofdm_config_cmdid = WMI_CMD_UNSUPPORTED,
 354        .pdev_reserve_ast_entry_cmdid = WMI_CMD_UNSUPPORTED,
 355        .pdev_get_nfcal_power_cmdid = WMI_CMD_UNSUPPORTED,
 356        .pdev_get_tpc_cmdid = WMI_CMD_UNSUPPORTED,
 357        .pdev_get_ast_info_cmdid = WMI_CMD_UNSUPPORTED,
 358        .vdev_set_dscp_tid_map_cmdid = WMI_CMD_UNSUPPORTED,
 359        .pdev_get_info_cmdid = WMI_CMD_UNSUPPORTED,
 360        .vdev_get_info_cmdid = WMI_CMD_UNSUPPORTED,
 361        .vdev_filter_neighbor_rx_packets_cmdid = WMI_CMD_UNSUPPORTED,
 362        .mu_cal_start_cmdid = WMI_CMD_UNSUPPORTED,
 363        .set_cca_params_cmdid = WMI_CMD_UNSUPPORTED,
 364        .pdev_bss_chan_info_request_cmdid = WMI_CMD_UNSUPPORTED,
 365};
 366
 367/* 10.2.4 WMI cmd track */
 368static struct wmi_cmd_map wmi_10_2_4_cmd_map = {
 369        .init_cmdid = WMI_10_2_INIT_CMDID,
 370        .start_scan_cmdid = WMI_10_2_START_SCAN_CMDID,
 371        .stop_scan_cmdid = WMI_10_2_STOP_SCAN_CMDID,
 372        .scan_chan_list_cmdid = WMI_10_2_SCAN_CHAN_LIST_CMDID,
 373        .scan_sch_prio_tbl_cmdid = WMI_CMD_UNSUPPORTED,
 374        .pdev_set_regdomain_cmdid = WMI_10_2_PDEV_SET_REGDOMAIN_CMDID,
 375        .pdev_set_channel_cmdid = WMI_10_2_PDEV_SET_CHANNEL_CMDID,
 376        .pdev_set_param_cmdid = WMI_10_2_PDEV_SET_PARAM_CMDID,
 377        .pdev_pktlog_enable_cmdid = WMI_10_2_PDEV_PKTLOG_ENABLE_CMDID,
 378        .pdev_pktlog_disable_cmdid = WMI_10_2_PDEV_PKTLOG_DISABLE_CMDID,
 379        .pdev_set_wmm_params_cmdid = WMI_10_2_PDEV_SET_WMM_PARAMS_CMDID,
 380        .pdev_set_ht_cap_ie_cmdid = WMI_10_2_PDEV_SET_HT_CAP_IE_CMDID,
 381        .pdev_set_vht_cap_ie_cmdid = WMI_10_2_PDEV_SET_VHT_CAP_IE_CMDID,
 382        .pdev_set_quiet_mode_cmdid = WMI_10_2_PDEV_SET_QUIET_MODE_CMDID,
 383        .pdev_green_ap_ps_enable_cmdid = WMI_10_2_PDEV_GREEN_AP_PS_ENABLE_CMDID,
 384        .pdev_get_tpc_config_cmdid = WMI_10_2_PDEV_GET_TPC_CONFIG_CMDID,
 385        .pdev_set_base_macaddr_cmdid = WMI_10_2_PDEV_SET_BASE_MACADDR_CMDID,
 386        .vdev_create_cmdid = WMI_10_2_VDEV_CREATE_CMDID,
 387        .vdev_delete_cmdid = WMI_10_2_VDEV_DELETE_CMDID,
 388        .vdev_start_request_cmdid = WMI_10_2_VDEV_START_REQUEST_CMDID,
 389        .vdev_restart_request_cmdid = WMI_10_2_VDEV_RESTART_REQUEST_CMDID,
 390        .vdev_up_cmdid = WMI_10_2_VDEV_UP_CMDID,
 391        .vdev_stop_cmdid = WMI_10_2_VDEV_STOP_CMDID,
 392        .vdev_down_cmdid = WMI_10_2_VDEV_DOWN_CMDID,
 393        .vdev_set_param_cmdid = WMI_10_2_VDEV_SET_PARAM_CMDID,
 394        .vdev_install_key_cmdid = WMI_10_2_VDEV_INSTALL_KEY_CMDID,
 395        .peer_create_cmdid = WMI_10_2_PEER_CREATE_CMDID,
 396        .peer_delete_cmdid = WMI_10_2_PEER_DELETE_CMDID,
 397        .peer_flush_tids_cmdid = WMI_10_2_PEER_FLUSH_TIDS_CMDID,
 398        .peer_set_param_cmdid = WMI_10_2_PEER_SET_PARAM_CMDID,
 399        .peer_assoc_cmdid = WMI_10_2_PEER_ASSOC_CMDID,
 400        .peer_add_wds_entry_cmdid = WMI_10_2_PEER_ADD_WDS_ENTRY_CMDID,
 401        .peer_remove_wds_entry_cmdid = WMI_10_2_PEER_REMOVE_WDS_ENTRY_CMDID,
 402        .peer_mcast_group_cmdid = WMI_10_2_PEER_MCAST_GROUP_CMDID,
 403        .bcn_tx_cmdid = WMI_10_2_BCN_TX_CMDID,
 404        .pdev_send_bcn_cmdid = WMI_10_2_PDEV_SEND_BCN_CMDID,
 405        .bcn_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
 406        .bcn_filter_rx_cmdid = WMI_10_2_BCN_FILTER_RX_CMDID,
 407        .prb_req_filter_rx_cmdid = WMI_10_2_PRB_REQ_FILTER_RX_CMDID,
 408        .mgmt_tx_cmdid = WMI_10_2_MGMT_TX_CMDID,
 409        .prb_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
 410        .addba_clear_resp_cmdid = WMI_10_2_ADDBA_CLEAR_RESP_CMDID,
 411        .addba_send_cmdid = WMI_10_2_ADDBA_SEND_CMDID,
 412        .addba_status_cmdid = WMI_10_2_ADDBA_STATUS_CMDID,
 413        .delba_send_cmdid = WMI_10_2_DELBA_SEND_CMDID,
 414        .addba_set_resp_cmdid = WMI_10_2_ADDBA_SET_RESP_CMDID,
 415        .send_singleamsdu_cmdid = WMI_10_2_SEND_SINGLEAMSDU_CMDID,
 416        .sta_powersave_mode_cmdid = WMI_10_2_STA_POWERSAVE_MODE_CMDID,
 417        .sta_powersave_param_cmdid = WMI_10_2_STA_POWERSAVE_PARAM_CMDID,
 418        .sta_mimo_ps_mode_cmdid = WMI_10_2_STA_MIMO_PS_MODE_CMDID,
 419        .pdev_dfs_enable_cmdid = WMI_10_2_PDEV_DFS_ENABLE_CMDID,
 420        .pdev_dfs_disable_cmdid = WMI_10_2_PDEV_DFS_DISABLE_CMDID,
 421        .roam_scan_mode = WMI_10_2_ROAM_SCAN_MODE,
 422        .roam_scan_rssi_threshold = WMI_10_2_ROAM_SCAN_RSSI_THRESHOLD,
 423        .roam_scan_period = WMI_10_2_ROAM_SCAN_PERIOD,
 424        .roam_scan_rssi_change_threshold =
 425                                WMI_10_2_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
 426        .roam_ap_profile = WMI_10_2_ROAM_AP_PROFILE,
 427        .ofl_scan_add_ap_profile = WMI_10_2_OFL_SCAN_ADD_AP_PROFILE,
 428        .ofl_scan_remove_ap_profile = WMI_10_2_OFL_SCAN_REMOVE_AP_PROFILE,
 429        .ofl_scan_period = WMI_10_2_OFL_SCAN_PERIOD,
 430        .p2p_dev_set_device_info = WMI_10_2_P2P_DEV_SET_DEVICE_INFO,
 431        .p2p_dev_set_discoverability = WMI_10_2_P2P_DEV_SET_DISCOVERABILITY,
 432        .p2p_go_set_beacon_ie = WMI_10_2_P2P_GO_SET_BEACON_IE,
 433        .p2p_go_set_probe_resp_ie = WMI_10_2_P2P_GO_SET_PROBE_RESP_IE,
 434        .p2p_set_vendor_ie_data_cmdid = WMI_CMD_UNSUPPORTED,
 435        .ap_ps_peer_param_cmdid = WMI_10_2_AP_PS_PEER_PARAM_CMDID,
 436        .ap_ps_peer_uapsd_coex_cmdid = WMI_CMD_UNSUPPORTED,
 437        .peer_rate_retry_sched_cmdid = WMI_10_2_PEER_RATE_RETRY_SCHED_CMDID,
 438        .wlan_profile_trigger_cmdid = WMI_10_2_WLAN_PROFILE_TRIGGER_CMDID,
 439        .wlan_profile_set_hist_intvl_cmdid =
 440                                WMI_10_2_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
 441        .wlan_profile_get_profile_data_cmdid =
 442                                WMI_10_2_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
 443        .wlan_profile_enable_profile_id_cmdid =
 444                                WMI_10_2_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
 445        .wlan_profile_list_profile_id_cmdid =
 446                                WMI_10_2_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
 447        .pdev_suspend_cmdid = WMI_10_2_PDEV_SUSPEND_CMDID,
 448        .pdev_resume_cmdid = WMI_10_2_PDEV_RESUME_CMDID,
 449        .add_bcn_filter_cmdid = WMI_10_2_ADD_BCN_FILTER_CMDID,
 450        .rmv_bcn_filter_cmdid = WMI_10_2_RMV_BCN_FILTER_CMDID,
 451        .wow_add_wake_pattern_cmdid = WMI_10_2_WOW_ADD_WAKE_PATTERN_CMDID,
 452        .wow_del_wake_pattern_cmdid = WMI_10_2_WOW_DEL_WAKE_PATTERN_CMDID,
 453        .wow_enable_disable_wake_event_cmdid =
 454                                WMI_10_2_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
 455        .wow_enable_cmdid = WMI_10_2_WOW_ENABLE_CMDID,
 456        .wow_hostwakeup_from_sleep_cmdid =
 457                                WMI_10_2_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
 458        .rtt_measreq_cmdid = WMI_10_2_RTT_MEASREQ_CMDID,
 459        .rtt_tsf_cmdid = WMI_10_2_RTT_TSF_CMDID,
 460        .vdev_spectral_scan_configure_cmdid =
 461                                WMI_10_2_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
 462        .vdev_spectral_scan_enable_cmdid =
 463                                WMI_10_2_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
 464        .request_stats_cmdid = WMI_10_2_REQUEST_STATS_CMDID,
 465        .set_arp_ns_offload_cmdid = WMI_CMD_UNSUPPORTED,
 466        .network_list_offload_config_cmdid = WMI_CMD_UNSUPPORTED,
 467        .gtk_offload_cmdid = WMI_CMD_UNSUPPORTED,
 468        .csa_offload_enable_cmdid = WMI_CMD_UNSUPPORTED,
 469        .csa_offload_chanswitch_cmdid = WMI_CMD_UNSUPPORTED,
 470        .chatter_set_mode_cmdid = WMI_CMD_UNSUPPORTED,
 471        .peer_tid_addba_cmdid = WMI_CMD_UNSUPPORTED,
 472        .peer_tid_delba_cmdid = WMI_CMD_UNSUPPORTED,
 473        .sta_dtim_ps_method_cmdid = WMI_CMD_UNSUPPORTED,
 474        .sta_uapsd_auto_trig_cmdid = WMI_CMD_UNSUPPORTED,
 475        .sta_keepalive_cmd = WMI_CMD_UNSUPPORTED,
 476        .echo_cmdid = WMI_10_2_ECHO_CMDID,
 477        .pdev_utf_cmdid = WMI_10_2_PDEV_UTF_CMDID,
 478        .dbglog_cfg_cmdid = WMI_10_2_DBGLOG_CFG_CMDID,
 479        .pdev_qvit_cmdid = WMI_10_2_PDEV_QVIT_CMDID,
 480        .pdev_ftm_intg_cmdid = WMI_CMD_UNSUPPORTED,
 481        .vdev_set_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
 482        .vdev_get_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
 483        .force_fw_hang_cmdid = WMI_CMD_UNSUPPORTED,
 484        .gpio_config_cmdid = WMI_10_2_GPIO_CONFIG_CMDID,
 485        .gpio_output_cmdid = WMI_10_2_GPIO_OUTPUT_CMDID,
 486        .pdev_get_temperature_cmdid = WMI_10_2_PDEV_GET_TEMPERATURE_CMDID,
 487        .pdev_enable_adaptive_cca_cmdid = WMI_10_2_SET_CCA_PARAMS,
 488        .scan_update_request_cmdid = WMI_CMD_UNSUPPORTED,
 489        .vdev_standby_response_cmdid = WMI_CMD_UNSUPPORTED,
 490        .vdev_resume_response_cmdid = WMI_CMD_UNSUPPORTED,
 491        .wlan_peer_caching_add_peer_cmdid = WMI_CMD_UNSUPPORTED,
 492        .wlan_peer_caching_evict_peer_cmdid = WMI_CMD_UNSUPPORTED,
 493        .wlan_peer_caching_restore_peer_cmdid = WMI_CMD_UNSUPPORTED,
 494        .wlan_peer_caching_print_all_peers_info_cmdid = WMI_CMD_UNSUPPORTED,
 495        .peer_update_wds_entry_cmdid = WMI_CMD_UNSUPPORTED,
 496        .peer_add_proxy_sta_entry_cmdid = WMI_CMD_UNSUPPORTED,
 497        .rtt_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
 498        .oem_req_cmdid = WMI_CMD_UNSUPPORTED,
 499        .nan_cmdid = WMI_CMD_UNSUPPORTED,
 500        .vdev_ratemask_cmdid = WMI_CMD_UNSUPPORTED,
 501        .qboost_cfg_cmdid = WMI_CMD_UNSUPPORTED,
 502        .pdev_smart_ant_enable_cmdid = WMI_CMD_UNSUPPORTED,
 503        .pdev_smart_ant_set_rx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
 504        .peer_smart_ant_set_tx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
 505        .peer_smart_ant_set_train_info_cmdid = WMI_CMD_UNSUPPORTED,
 506        .peer_smart_ant_set_node_config_ops_cmdid = WMI_CMD_UNSUPPORTED,
 507        .pdev_set_antenna_switch_table_cmdid = WMI_CMD_UNSUPPORTED,
 508        .pdev_set_ctl_table_cmdid = WMI_CMD_UNSUPPORTED,
 509        .pdev_set_mimogain_table_cmdid = WMI_CMD_UNSUPPORTED,
 510        .pdev_ratepwr_table_cmdid = WMI_CMD_UNSUPPORTED,
 511        .pdev_ratepwr_chainmsk_table_cmdid = WMI_CMD_UNSUPPORTED,
 512        .pdev_fips_cmdid = WMI_CMD_UNSUPPORTED,
 513        .tt_set_conf_cmdid = WMI_CMD_UNSUPPORTED,
 514        .fwtest_cmdid = WMI_CMD_UNSUPPORTED,
 515        .vdev_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
 516        .peer_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
 517        .pdev_get_ani_cck_config_cmdid = WMI_CMD_UNSUPPORTED,
 518        .pdev_get_ani_ofdm_config_cmdid = WMI_CMD_UNSUPPORTED,
 519        .pdev_reserve_ast_entry_cmdid = WMI_CMD_UNSUPPORTED,
 520        .pdev_get_nfcal_power_cmdid = WMI_CMD_UNSUPPORTED,
 521        .pdev_get_tpc_cmdid = WMI_CMD_UNSUPPORTED,
 522        .pdev_get_ast_info_cmdid = WMI_CMD_UNSUPPORTED,
 523        .vdev_set_dscp_tid_map_cmdid = WMI_CMD_UNSUPPORTED,
 524        .pdev_get_info_cmdid = WMI_CMD_UNSUPPORTED,
 525        .vdev_get_info_cmdid = WMI_CMD_UNSUPPORTED,
 526        .vdev_filter_neighbor_rx_packets_cmdid = WMI_CMD_UNSUPPORTED,
 527        .mu_cal_start_cmdid = WMI_CMD_UNSUPPORTED,
 528        .set_cca_params_cmdid = WMI_CMD_UNSUPPORTED,
 529        .pdev_bss_chan_info_request_cmdid =
 530                WMI_10_2_PDEV_BSS_CHAN_INFO_REQUEST_CMDID,
 531};
 532
 533/* 10.4 WMI cmd track */
 534static struct wmi_cmd_map wmi_10_4_cmd_map = {
 535        .init_cmdid = WMI_10_4_INIT_CMDID,
 536        .start_scan_cmdid = WMI_10_4_START_SCAN_CMDID,
 537        .stop_scan_cmdid = WMI_10_4_STOP_SCAN_CMDID,
 538        .scan_chan_list_cmdid = WMI_10_4_SCAN_CHAN_LIST_CMDID,
 539        .scan_sch_prio_tbl_cmdid = WMI_10_4_SCAN_SCH_PRIO_TBL_CMDID,
 540        .pdev_set_regdomain_cmdid = WMI_10_4_PDEV_SET_REGDOMAIN_CMDID,
 541        .pdev_set_channel_cmdid = WMI_10_4_PDEV_SET_CHANNEL_CMDID,
 542        .pdev_set_param_cmdid = WMI_10_4_PDEV_SET_PARAM_CMDID,
 543        .pdev_pktlog_enable_cmdid = WMI_10_4_PDEV_PKTLOG_ENABLE_CMDID,
 544        .pdev_pktlog_disable_cmdid = WMI_10_4_PDEV_PKTLOG_DISABLE_CMDID,
 545        .pdev_set_wmm_params_cmdid = WMI_10_4_PDEV_SET_WMM_PARAMS_CMDID,
 546        .pdev_set_ht_cap_ie_cmdid = WMI_10_4_PDEV_SET_HT_CAP_IE_CMDID,
 547        .pdev_set_vht_cap_ie_cmdid = WMI_10_4_PDEV_SET_VHT_CAP_IE_CMDID,
 548        .pdev_set_dscp_tid_map_cmdid = WMI_10_4_PDEV_SET_DSCP_TID_MAP_CMDID,
 549        .pdev_set_quiet_mode_cmdid = WMI_10_4_PDEV_SET_QUIET_MODE_CMDID,
 550        .pdev_green_ap_ps_enable_cmdid = WMI_10_4_PDEV_GREEN_AP_PS_ENABLE_CMDID,
 551        .pdev_get_tpc_config_cmdid = WMI_10_4_PDEV_GET_TPC_CONFIG_CMDID,
 552        .pdev_set_base_macaddr_cmdid = WMI_10_4_PDEV_SET_BASE_MACADDR_CMDID,
 553        .vdev_create_cmdid = WMI_10_4_VDEV_CREATE_CMDID,
 554        .vdev_delete_cmdid = WMI_10_4_VDEV_DELETE_CMDID,
 555        .vdev_start_request_cmdid = WMI_10_4_VDEV_START_REQUEST_CMDID,
 556        .vdev_restart_request_cmdid = WMI_10_4_VDEV_RESTART_REQUEST_CMDID,
 557        .vdev_up_cmdid = WMI_10_4_VDEV_UP_CMDID,
 558        .vdev_stop_cmdid = WMI_10_4_VDEV_STOP_CMDID,
 559        .vdev_down_cmdid = WMI_10_4_VDEV_DOWN_CMDID,
 560        .vdev_set_param_cmdid = WMI_10_4_VDEV_SET_PARAM_CMDID,
 561        .vdev_install_key_cmdid = WMI_10_4_VDEV_INSTALL_KEY_CMDID,
 562        .peer_create_cmdid = WMI_10_4_PEER_CREATE_CMDID,
 563        .peer_delete_cmdid = WMI_10_4_PEER_DELETE_CMDID,
 564        .peer_flush_tids_cmdid = WMI_10_4_PEER_FLUSH_TIDS_CMDID,
 565        .peer_set_param_cmdid = WMI_10_4_PEER_SET_PARAM_CMDID,
 566        .peer_assoc_cmdid = WMI_10_4_PEER_ASSOC_CMDID,
 567        .peer_add_wds_entry_cmdid = WMI_10_4_PEER_ADD_WDS_ENTRY_CMDID,
 568        .peer_remove_wds_entry_cmdid = WMI_10_4_PEER_REMOVE_WDS_ENTRY_CMDID,
 569        .peer_mcast_group_cmdid = WMI_10_4_PEER_MCAST_GROUP_CMDID,
 570        .bcn_tx_cmdid = WMI_10_4_BCN_TX_CMDID,
 571        .pdev_send_bcn_cmdid = WMI_10_4_PDEV_SEND_BCN_CMDID,
 572        .bcn_tmpl_cmdid = WMI_10_4_BCN_PRB_TMPL_CMDID,
 573        .bcn_filter_rx_cmdid = WMI_10_4_BCN_FILTER_RX_CMDID,
 574        .prb_req_filter_rx_cmdid = WMI_10_4_PRB_REQ_FILTER_RX_CMDID,
 575        .mgmt_tx_cmdid = WMI_10_4_MGMT_TX_CMDID,
 576        .prb_tmpl_cmdid = WMI_10_4_PRB_TMPL_CMDID,
 577        .addba_clear_resp_cmdid = WMI_10_4_ADDBA_CLEAR_RESP_CMDID,
 578        .addba_send_cmdid = WMI_10_4_ADDBA_SEND_CMDID,
 579        .addba_status_cmdid = WMI_10_4_ADDBA_STATUS_CMDID,
 580        .delba_send_cmdid = WMI_10_4_DELBA_SEND_CMDID,
 581        .addba_set_resp_cmdid = WMI_10_4_ADDBA_SET_RESP_CMDID,
 582        .send_singleamsdu_cmdid = WMI_10_4_SEND_SINGLEAMSDU_CMDID,
 583        .sta_powersave_mode_cmdid = WMI_10_4_STA_POWERSAVE_MODE_CMDID,
 584        .sta_powersave_param_cmdid = WMI_10_4_STA_POWERSAVE_PARAM_CMDID,
 585        .sta_mimo_ps_mode_cmdid = WMI_10_4_STA_MIMO_PS_MODE_CMDID,
 586        .pdev_dfs_enable_cmdid = WMI_10_4_PDEV_DFS_ENABLE_CMDID,
 587        .pdev_dfs_disable_cmdid = WMI_10_4_PDEV_DFS_DISABLE_CMDID,
 588        .roam_scan_mode = WMI_10_4_ROAM_SCAN_MODE,
 589        .roam_scan_rssi_threshold = WMI_10_4_ROAM_SCAN_RSSI_THRESHOLD,
 590        .roam_scan_period = WMI_10_4_ROAM_SCAN_PERIOD,
 591        .roam_scan_rssi_change_threshold =
 592                                WMI_10_4_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
 593        .roam_ap_profile = WMI_10_4_ROAM_AP_PROFILE,
 594        .ofl_scan_add_ap_profile = WMI_10_4_OFL_SCAN_ADD_AP_PROFILE,
 595        .ofl_scan_remove_ap_profile = WMI_10_4_OFL_SCAN_REMOVE_AP_PROFILE,
 596        .ofl_scan_period = WMI_10_4_OFL_SCAN_PERIOD,
 597        .p2p_dev_set_device_info = WMI_10_4_P2P_DEV_SET_DEVICE_INFO,
 598        .p2p_dev_set_discoverability = WMI_10_4_P2P_DEV_SET_DISCOVERABILITY,
 599        .p2p_go_set_beacon_ie = WMI_10_4_P2P_GO_SET_BEACON_IE,
 600        .p2p_go_set_probe_resp_ie = WMI_10_4_P2P_GO_SET_PROBE_RESP_IE,
 601        .p2p_set_vendor_ie_data_cmdid = WMI_10_4_P2P_SET_VENDOR_IE_DATA_CMDID,
 602        .ap_ps_peer_param_cmdid = WMI_10_4_AP_PS_PEER_PARAM_CMDID,
 603        .ap_ps_peer_uapsd_coex_cmdid = WMI_10_4_AP_PS_PEER_UAPSD_COEX_CMDID,
 604        .peer_rate_retry_sched_cmdid = WMI_10_4_PEER_RATE_RETRY_SCHED_CMDID,
 605        .wlan_profile_trigger_cmdid = WMI_10_4_WLAN_PROFILE_TRIGGER_CMDID,
 606        .wlan_profile_set_hist_intvl_cmdid =
 607                                WMI_10_4_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
 608        .wlan_profile_get_profile_data_cmdid =
 609                                WMI_10_4_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
 610        .wlan_profile_enable_profile_id_cmdid =
 611                                WMI_10_4_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
 612        .wlan_profile_list_profile_id_cmdid =
 613                                WMI_10_4_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
 614        .pdev_suspend_cmdid = WMI_10_4_PDEV_SUSPEND_CMDID,
 615        .pdev_resume_cmdid = WMI_10_4_PDEV_RESUME_CMDID,
 616        .add_bcn_filter_cmdid = WMI_10_4_ADD_BCN_FILTER_CMDID,
 617        .rmv_bcn_filter_cmdid = WMI_10_4_RMV_BCN_FILTER_CMDID,
 618        .wow_add_wake_pattern_cmdid = WMI_10_4_WOW_ADD_WAKE_PATTERN_CMDID,
 619        .wow_del_wake_pattern_cmdid = WMI_10_4_WOW_DEL_WAKE_PATTERN_CMDID,
 620        .wow_enable_disable_wake_event_cmdid =
 621                                WMI_10_4_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
 622        .wow_enable_cmdid = WMI_10_4_WOW_ENABLE_CMDID,
 623        .wow_hostwakeup_from_sleep_cmdid =
 624                                WMI_10_4_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
 625        .rtt_measreq_cmdid = WMI_10_4_RTT_MEASREQ_CMDID,
 626        .rtt_tsf_cmdid = WMI_10_4_RTT_TSF_CMDID,
 627        .vdev_spectral_scan_configure_cmdid =
 628                                WMI_10_4_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
 629        .vdev_spectral_scan_enable_cmdid =
 630                                WMI_10_4_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
 631        .request_stats_cmdid = WMI_10_4_REQUEST_STATS_CMDID,
 632        .set_arp_ns_offload_cmdid = WMI_CMD_UNSUPPORTED,
 633        .network_list_offload_config_cmdid = WMI_CMD_UNSUPPORTED,
 634        .gtk_offload_cmdid = WMI_10_4_GTK_OFFLOAD_CMDID,
 635        .csa_offload_enable_cmdid = WMI_10_4_CSA_OFFLOAD_ENABLE_CMDID,
 636        .csa_offload_chanswitch_cmdid = WMI_10_4_CSA_OFFLOAD_CHANSWITCH_CMDID,
 637        .chatter_set_mode_cmdid = WMI_CMD_UNSUPPORTED,
 638        .peer_tid_addba_cmdid = WMI_CMD_UNSUPPORTED,
 639        .peer_tid_delba_cmdid = WMI_CMD_UNSUPPORTED,
 640        .sta_dtim_ps_method_cmdid = WMI_CMD_UNSUPPORTED,
 641        .sta_uapsd_auto_trig_cmdid = WMI_CMD_UNSUPPORTED,
 642        .sta_keepalive_cmd = WMI_CMD_UNSUPPORTED,
 643        .echo_cmdid = WMI_10_4_ECHO_CMDID,
 644        .pdev_utf_cmdid = WMI_10_4_PDEV_UTF_CMDID,
 645        .dbglog_cfg_cmdid = WMI_10_4_DBGLOG_CFG_CMDID,
 646        .pdev_qvit_cmdid = WMI_10_4_PDEV_QVIT_CMDID,
 647        .pdev_ftm_intg_cmdid = WMI_CMD_UNSUPPORTED,
 648        .vdev_set_keepalive_cmdid = WMI_10_4_VDEV_SET_KEEPALIVE_CMDID,
 649        .vdev_get_keepalive_cmdid = WMI_10_4_VDEV_GET_KEEPALIVE_CMDID,
 650        .force_fw_hang_cmdid = WMI_10_4_FORCE_FW_HANG_CMDID,
 651        .gpio_config_cmdid = WMI_10_4_GPIO_CONFIG_CMDID,
 652        .gpio_output_cmdid = WMI_10_4_GPIO_OUTPUT_CMDID,
 653        .pdev_get_temperature_cmdid = WMI_10_4_PDEV_GET_TEMPERATURE_CMDID,
 654        .vdev_set_wmm_params_cmdid = WMI_CMD_UNSUPPORTED,
 655        .adaptive_qcs_cmdid = WMI_CMD_UNSUPPORTED,
 656        .scan_update_request_cmdid = WMI_10_4_SCAN_UPDATE_REQUEST_CMDID,
 657        .vdev_standby_response_cmdid = WMI_10_4_VDEV_STANDBY_RESPONSE_CMDID,
 658        .vdev_resume_response_cmdid = WMI_10_4_VDEV_RESUME_RESPONSE_CMDID,
 659        .wlan_peer_caching_add_peer_cmdid =
 660                        WMI_10_4_WLAN_PEER_CACHING_ADD_PEER_CMDID,
 661        .wlan_peer_caching_evict_peer_cmdid =
 662                        WMI_10_4_WLAN_PEER_CACHING_EVICT_PEER_CMDID,
 663        .wlan_peer_caching_restore_peer_cmdid =
 664                        WMI_10_4_WLAN_PEER_CACHING_RESTORE_PEER_CMDID,
 665        .wlan_peer_caching_print_all_peers_info_cmdid =
 666                        WMI_10_4_WLAN_PEER_CACHING_PRINT_ALL_PEERS_INFO_CMDID,
 667        .peer_update_wds_entry_cmdid = WMI_10_4_PEER_UPDATE_WDS_ENTRY_CMDID,
 668        .peer_add_proxy_sta_entry_cmdid =
 669                        WMI_10_4_PEER_ADD_PROXY_STA_ENTRY_CMDID,
 670        .rtt_keepalive_cmdid = WMI_10_4_RTT_KEEPALIVE_CMDID,
 671        .oem_req_cmdid = WMI_10_4_OEM_REQ_CMDID,
 672        .nan_cmdid = WMI_10_4_NAN_CMDID,
 673        .vdev_ratemask_cmdid = WMI_10_4_VDEV_RATEMASK_CMDID,
 674        .qboost_cfg_cmdid = WMI_10_4_QBOOST_CFG_CMDID,
 675        .pdev_smart_ant_enable_cmdid = WMI_10_4_PDEV_SMART_ANT_ENABLE_CMDID,
 676        .pdev_smart_ant_set_rx_antenna_cmdid =
 677                        WMI_10_4_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID,
 678        .peer_smart_ant_set_tx_antenna_cmdid =
 679                        WMI_10_4_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID,
 680        .peer_smart_ant_set_train_info_cmdid =
 681                        WMI_10_4_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID,
 682        .peer_smart_ant_set_node_config_ops_cmdid =
 683                        WMI_10_4_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID,
 684        .pdev_set_antenna_switch_table_cmdid =
 685                        WMI_10_4_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID,
 686        .pdev_set_ctl_table_cmdid = WMI_10_4_PDEV_SET_CTL_TABLE_CMDID,
 687        .pdev_set_mimogain_table_cmdid = WMI_10_4_PDEV_SET_MIMOGAIN_TABLE_CMDID,
 688        .pdev_ratepwr_table_cmdid = WMI_10_4_PDEV_RATEPWR_TABLE_CMDID,
 689        .pdev_ratepwr_chainmsk_table_cmdid =
 690                        WMI_10_4_PDEV_RATEPWR_CHAINMSK_TABLE_CMDID,
 691        .pdev_fips_cmdid = WMI_10_4_PDEV_FIPS_CMDID,
 692        .tt_set_conf_cmdid = WMI_10_4_TT_SET_CONF_CMDID,
 693        .fwtest_cmdid = WMI_10_4_FWTEST_CMDID,
 694        .vdev_atf_request_cmdid = WMI_10_4_VDEV_ATF_REQUEST_CMDID,
 695        .peer_atf_request_cmdid = WMI_10_4_PEER_ATF_REQUEST_CMDID,
 696        .pdev_get_ani_cck_config_cmdid = WMI_10_4_PDEV_GET_ANI_CCK_CONFIG_CMDID,
 697        .pdev_get_ani_ofdm_config_cmdid =
 698                        WMI_10_4_PDEV_GET_ANI_OFDM_CONFIG_CMDID,
 699        .pdev_reserve_ast_entry_cmdid = WMI_10_4_PDEV_RESERVE_AST_ENTRY_CMDID,
 700        .pdev_get_nfcal_power_cmdid = WMI_10_4_PDEV_GET_NFCAL_POWER_CMDID,
 701        .pdev_get_tpc_cmdid = WMI_10_4_PDEV_GET_TPC_CMDID,
 702        .pdev_get_ast_info_cmdid = WMI_10_4_PDEV_GET_AST_INFO_CMDID,
 703        .vdev_set_dscp_tid_map_cmdid = WMI_10_4_VDEV_SET_DSCP_TID_MAP_CMDID,
 704        .pdev_get_info_cmdid = WMI_10_4_PDEV_GET_INFO_CMDID,
 705        .vdev_get_info_cmdid = WMI_10_4_VDEV_GET_INFO_CMDID,
 706        .vdev_filter_neighbor_rx_packets_cmdid =
 707                        WMI_10_4_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID,
 708        .mu_cal_start_cmdid = WMI_10_4_MU_CAL_START_CMDID,
 709        .set_cca_params_cmdid = WMI_10_4_SET_CCA_PARAMS_CMDID,
 710        .pdev_bss_chan_info_request_cmdid =
 711                        WMI_10_4_PDEV_BSS_CHAN_INFO_REQUEST_CMDID,
 712        .ext_resource_cfg_cmdid = WMI_10_4_EXT_RESOURCE_CFG_CMDID,
 713        .vdev_set_ie_cmdid = WMI_10_4_VDEV_SET_IE_CMDID,
 714        .set_lteu_config_cmdid = WMI_10_4_SET_LTEU_CONFIG_CMDID,
 715        .atf_ssid_grouping_request_cmdid =
 716                        WMI_10_4_ATF_SSID_GROUPING_REQUEST_CMDID,
 717        .peer_atf_ext_request_cmdid = WMI_10_4_PEER_ATF_EXT_REQUEST_CMDID,
 718        .set_periodic_channel_stats_cfg_cmdid =
 719                        WMI_10_4_SET_PERIODIC_CHANNEL_STATS_CONFIG,
 720        .peer_bwf_request_cmdid = WMI_10_4_PEER_BWF_REQUEST_CMDID,
 721        .btcoex_cfg_cmdid = WMI_10_4_BTCOEX_CFG_CMDID,
 722        .peer_tx_mu_txmit_count_cmdid = WMI_10_4_PEER_TX_MU_TXMIT_COUNT_CMDID,
 723        .peer_tx_mu_txmit_rstcnt_cmdid = WMI_10_4_PEER_TX_MU_TXMIT_RSTCNT_CMDID,
 724        .peer_gid_userpos_list_cmdid = WMI_10_4_PEER_GID_USERPOS_LIST_CMDID,
 725        .pdev_check_cal_version_cmdid = WMI_10_4_PDEV_CHECK_CAL_VERSION_CMDID,
 726        .coex_version_cfg_cmid = WMI_10_4_COEX_VERSION_CFG_CMID,
 727        .pdev_get_rx_filter_cmdid = WMI_10_4_PDEV_GET_RX_FILTER_CMDID,
 728        .pdev_extended_nss_cfg_cmdid = WMI_10_4_PDEV_EXTENDED_NSS_CFG_CMDID,
 729        .vdev_set_scan_nac_rssi_cmdid = WMI_10_4_VDEV_SET_SCAN_NAC_RSSI_CMDID,
 730        .prog_gpio_band_select_cmdid = WMI_10_4_PROG_GPIO_BAND_SELECT_CMDID,
 731        .config_smart_logging_cmdid = WMI_10_4_CONFIG_SMART_LOGGING_CMDID,
 732        .debug_fatal_condition_cmdid = WMI_10_4_DEBUG_FATAL_CONDITION_CMDID,
 733        .get_tsf_timer_cmdid = WMI_10_4_GET_TSF_TIMER_CMDID,
 734        .pdev_get_tpc_table_cmdid = WMI_10_4_PDEV_GET_TPC_TABLE_CMDID,
 735        .vdev_sifs_trigger_time_cmdid = WMI_10_4_VDEV_SIFS_TRIGGER_TIME_CMDID,
 736        .pdev_wds_entry_list_cmdid = WMI_10_4_PDEV_WDS_ENTRY_LIST_CMDID,
 737        .tdls_set_state_cmdid = WMI_10_4_TDLS_SET_STATE_CMDID,
 738        .tdls_peer_update_cmdid = WMI_10_4_TDLS_PEER_UPDATE_CMDID,
 739        .tdls_set_offchan_mode_cmdid = WMI_10_4_TDLS_SET_OFFCHAN_MODE_CMDID,
 740};
 741
 742/* MAIN WMI VDEV param map */
 743static struct wmi_vdev_param_map wmi_vdev_param_map = {
 744        .rts_threshold = WMI_VDEV_PARAM_RTS_THRESHOLD,
 745        .fragmentation_threshold = WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
 746        .beacon_interval = WMI_VDEV_PARAM_BEACON_INTERVAL,
 747        .listen_interval = WMI_VDEV_PARAM_LISTEN_INTERVAL,
 748        .multicast_rate = WMI_VDEV_PARAM_MULTICAST_RATE,
 749        .mgmt_tx_rate = WMI_VDEV_PARAM_MGMT_TX_RATE,
 750        .slot_time = WMI_VDEV_PARAM_SLOT_TIME,
 751        .preamble = WMI_VDEV_PARAM_PREAMBLE,
 752        .swba_time = WMI_VDEV_PARAM_SWBA_TIME,
 753        .wmi_vdev_stats_update_period = WMI_VDEV_STATS_UPDATE_PERIOD,
 754        .wmi_vdev_pwrsave_ageout_time = WMI_VDEV_PWRSAVE_AGEOUT_TIME,
 755        .wmi_vdev_host_swba_interval = WMI_VDEV_HOST_SWBA_INTERVAL,
 756        .dtim_period = WMI_VDEV_PARAM_DTIM_PERIOD,
 757        .wmi_vdev_oc_scheduler_air_time_limit =
 758                                        WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
 759        .wds = WMI_VDEV_PARAM_WDS,
 760        .atim_window = WMI_VDEV_PARAM_ATIM_WINDOW,
 761        .bmiss_count_max = WMI_VDEV_PARAM_BMISS_COUNT_MAX,
 762        .bmiss_first_bcnt = WMI_VDEV_PARAM_BMISS_FIRST_BCNT,
 763        .bmiss_final_bcnt = WMI_VDEV_PARAM_BMISS_FINAL_BCNT,
 764        .feature_wmm = WMI_VDEV_PARAM_FEATURE_WMM,
 765        .chwidth = WMI_VDEV_PARAM_CHWIDTH,
 766        .chextoffset = WMI_VDEV_PARAM_CHEXTOFFSET,
 767        .disable_htprotection = WMI_VDEV_PARAM_DISABLE_HTPROTECTION,
 768        .sta_quickkickout = WMI_VDEV_PARAM_STA_QUICKKICKOUT,
 769        .mgmt_rate = WMI_VDEV_PARAM_MGMT_RATE,
 770        .protection_mode = WMI_VDEV_PARAM_PROTECTION_MODE,
 771        .fixed_rate = WMI_VDEV_PARAM_FIXED_RATE,
 772        .sgi = WMI_VDEV_PARAM_SGI,
 773        .ldpc = WMI_VDEV_PARAM_LDPC,
 774        .tx_stbc = WMI_VDEV_PARAM_TX_STBC,
 775        .rx_stbc = WMI_VDEV_PARAM_RX_STBC,
 776        .intra_bss_fwd = WMI_VDEV_PARAM_INTRA_BSS_FWD,
 777        .def_keyid = WMI_VDEV_PARAM_DEF_KEYID,
 778        .nss = WMI_VDEV_PARAM_NSS,
 779        .bcast_data_rate = WMI_VDEV_PARAM_BCAST_DATA_RATE,
 780        .mcast_data_rate = WMI_VDEV_PARAM_MCAST_DATA_RATE,
 781        .mcast_indicate = WMI_VDEV_PARAM_MCAST_INDICATE,
 782        .dhcp_indicate = WMI_VDEV_PARAM_DHCP_INDICATE,
 783        .unknown_dest_indicate = WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
 784        .ap_keepalive_min_idle_inactive_time_secs =
 785                        WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
 786        .ap_keepalive_max_idle_inactive_time_secs =
 787                        WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
 788        .ap_keepalive_max_unresponsive_time_secs =
 789                        WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
 790        .ap_enable_nawds = WMI_VDEV_PARAM_AP_ENABLE_NAWDS,
 791        .mcast2ucast_set = WMI_VDEV_PARAM_UNSUPPORTED,
 792        .enable_rtscts = WMI_VDEV_PARAM_ENABLE_RTSCTS,
 793        .txbf = WMI_VDEV_PARAM_TXBF,
 794        .packet_powersave = WMI_VDEV_PARAM_PACKET_POWERSAVE,
 795        .drop_unencry = WMI_VDEV_PARAM_DROP_UNENCRY,
 796        .tx_encap_type = WMI_VDEV_PARAM_TX_ENCAP_TYPE,
 797        .ap_detect_out_of_sync_sleeping_sta_time_secs =
 798                                        WMI_VDEV_PARAM_UNSUPPORTED,
 799        .rc_num_retries = WMI_VDEV_PARAM_UNSUPPORTED,
 800        .cabq_maxdur = WMI_VDEV_PARAM_UNSUPPORTED,
 801        .mfptest_set = WMI_VDEV_PARAM_UNSUPPORTED,
 802        .rts_fixed_rate = WMI_VDEV_PARAM_UNSUPPORTED,
 803        .vht_sgimask = WMI_VDEV_PARAM_UNSUPPORTED,
 804        .vht80_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
 805        .early_rx_adjust_enable = WMI_VDEV_PARAM_UNSUPPORTED,
 806        .early_rx_tgt_bmiss_num = WMI_VDEV_PARAM_UNSUPPORTED,
 807        .early_rx_bmiss_sample_cycle = WMI_VDEV_PARAM_UNSUPPORTED,
 808        .early_rx_slop_step = WMI_VDEV_PARAM_UNSUPPORTED,
 809        .early_rx_init_slop = WMI_VDEV_PARAM_UNSUPPORTED,
 810        .early_rx_adjust_pause = WMI_VDEV_PARAM_UNSUPPORTED,
 811        .proxy_sta = WMI_VDEV_PARAM_UNSUPPORTED,
 812        .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED,
 813        .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED,
 814        .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
 815};
 816
 817/* 10.X WMI VDEV param map */
 818static struct wmi_vdev_param_map wmi_10x_vdev_param_map = {
 819        .rts_threshold = WMI_10X_VDEV_PARAM_RTS_THRESHOLD,
 820        .fragmentation_threshold = WMI_10X_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
 821        .beacon_interval = WMI_10X_VDEV_PARAM_BEACON_INTERVAL,
 822        .listen_interval = WMI_10X_VDEV_PARAM_LISTEN_INTERVAL,
 823        .multicast_rate = WMI_10X_VDEV_PARAM_MULTICAST_RATE,
 824        .mgmt_tx_rate = WMI_10X_VDEV_PARAM_MGMT_TX_RATE,
 825        .slot_time = WMI_10X_VDEV_PARAM_SLOT_TIME,
 826        .preamble = WMI_10X_VDEV_PARAM_PREAMBLE,
 827        .swba_time = WMI_10X_VDEV_PARAM_SWBA_TIME,
 828        .wmi_vdev_stats_update_period = WMI_10X_VDEV_STATS_UPDATE_PERIOD,
 829        .wmi_vdev_pwrsave_ageout_time = WMI_10X_VDEV_PWRSAVE_AGEOUT_TIME,
 830        .wmi_vdev_host_swba_interval = WMI_10X_VDEV_HOST_SWBA_INTERVAL,
 831        .dtim_period = WMI_10X_VDEV_PARAM_DTIM_PERIOD,
 832        .wmi_vdev_oc_scheduler_air_time_limit =
 833                                WMI_10X_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
 834        .wds = WMI_10X_VDEV_PARAM_WDS,
 835        .atim_window = WMI_10X_VDEV_PARAM_ATIM_WINDOW,
 836        .bmiss_count_max = WMI_10X_VDEV_PARAM_BMISS_COUNT_MAX,
 837        .bmiss_first_bcnt = WMI_VDEV_PARAM_UNSUPPORTED,
 838        .bmiss_final_bcnt = WMI_VDEV_PARAM_UNSUPPORTED,
 839        .feature_wmm = WMI_10X_VDEV_PARAM_FEATURE_WMM,
 840        .chwidth = WMI_10X_VDEV_PARAM_CHWIDTH,
 841        .chextoffset = WMI_10X_VDEV_PARAM_CHEXTOFFSET,
 842        .disable_htprotection = WMI_10X_VDEV_PARAM_DISABLE_HTPROTECTION,
 843        .sta_quickkickout = WMI_10X_VDEV_PARAM_STA_QUICKKICKOUT,
 844        .mgmt_rate = WMI_10X_VDEV_PARAM_MGMT_RATE,
 845        .protection_mode = WMI_10X_VDEV_PARAM_PROTECTION_MODE,
 846        .fixed_rate = WMI_10X_VDEV_PARAM_FIXED_RATE,
 847        .sgi = WMI_10X_VDEV_PARAM_SGI,
 848        .ldpc = WMI_10X_VDEV_PARAM_LDPC,
 849        .tx_stbc = WMI_10X_VDEV_PARAM_TX_STBC,
 850        .rx_stbc = WMI_10X_VDEV_PARAM_RX_STBC,
 851        .intra_bss_fwd = WMI_10X_VDEV_PARAM_INTRA_BSS_FWD,
 852        .def_keyid = WMI_10X_VDEV_PARAM_DEF_KEYID,
 853        .nss = WMI_10X_VDEV_PARAM_NSS,
 854        .bcast_data_rate = WMI_10X_VDEV_PARAM_BCAST_DATA_RATE,
 855        .mcast_data_rate = WMI_10X_VDEV_PARAM_MCAST_DATA_RATE,
 856        .mcast_indicate = WMI_10X_VDEV_PARAM_MCAST_INDICATE,
 857        .dhcp_indicate = WMI_10X_VDEV_PARAM_DHCP_INDICATE,
 858        .unknown_dest_indicate = WMI_10X_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
 859        .ap_keepalive_min_idle_inactive_time_secs =
 860                WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
 861        .ap_keepalive_max_idle_inactive_time_secs =
 862                WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
 863        .ap_keepalive_max_unresponsive_time_secs =
 864                WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
 865        .ap_enable_nawds = WMI_10X_VDEV_PARAM_AP_ENABLE_NAWDS,
 866        .mcast2ucast_set = WMI_10X_VDEV_PARAM_MCAST2UCAST_SET,
 867        .enable_rtscts = WMI_10X_VDEV_PARAM_ENABLE_RTSCTS,
 868        .txbf = WMI_VDEV_PARAM_UNSUPPORTED,
 869        .packet_powersave = WMI_VDEV_PARAM_UNSUPPORTED,
 870        .drop_unencry = WMI_VDEV_PARAM_UNSUPPORTED,
 871        .tx_encap_type = WMI_VDEV_PARAM_UNSUPPORTED,
 872        .ap_detect_out_of_sync_sleeping_sta_time_secs =
 873                WMI_10X_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS,
 874        .rc_num_retries = WMI_VDEV_PARAM_UNSUPPORTED,
 875        .cabq_maxdur = WMI_VDEV_PARAM_UNSUPPORTED,
 876        .mfptest_set = WMI_VDEV_PARAM_UNSUPPORTED,
 877        .rts_fixed_rate = WMI_VDEV_PARAM_UNSUPPORTED,
 878        .vht_sgimask = WMI_VDEV_PARAM_UNSUPPORTED,
 879        .vht80_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
 880        .early_rx_adjust_enable = WMI_VDEV_PARAM_UNSUPPORTED,
 881        .early_rx_tgt_bmiss_num = WMI_VDEV_PARAM_UNSUPPORTED,
 882        .early_rx_bmiss_sample_cycle = WMI_VDEV_PARAM_UNSUPPORTED,
 883        .early_rx_slop_step = WMI_VDEV_PARAM_UNSUPPORTED,
 884        .early_rx_init_slop = WMI_VDEV_PARAM_UNSUPPORTED,
 885        .early_rx_adjust_pause = WMI_VDEV_PARAM_UNSUPPORTED,
 886        .proxy_sta = WMI_VDEV_PARAM_UNSUPPORTED,
 887        .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED,
 888        .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED,
 889        .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
 890};
 891
 892static struct wmi_vdev_param_map wmi_10_2_4_vdev_param_map = {
 893        .rts_threshold = WMI_10X_VDEV_PARAM_RTS_THRESHOLD,
 894        .fragmentation_threshold = WMI_10X_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
 895        .beacon_interval = WMI_10X_VDEV_PARAM_BEACON_INTERVAL,
 896        .listen_interval = WMI_10X_VDEV_PARAM_LISTEN_INTERVAL,
 897        .multicast_rate = WMI_10X_VDEV_PARAM_MULTICAST_RATE,
 898        .mgmt_tx_rate = WMI_10X_VDEV_PARAM_MGMT_TX_RATE,
 899        .slot_time = WMI_10X_VDEV_PARAM_SLOT_TIME,
 900        .preamble = WMI_10X_VDEV_PARAM_PREAMBLE,
 901        .swba_time = WMI_10X_VDEV_PARAM_SWBA_TIME,
 902        .wmi_vdev_stats_update_period = WMI_10X_VDEV_STATS_UPDATE_PERIOD,
 903        .wmi_vdev_pwrsave_ageout_time = WMI_10X_VDEV_PWRSAVE_AGEOUT_TIME,
 904        .wmi_vdev_host_swba_interval = WMI_10X_VDEV_HOST_SWBA_INTERVAL,
 905        .dtim_period = WMI_10X_VDEV_PARAM_DTIM_PERIOD,
 906        .wmi_vdev_oc_scheduler_air_time_limit =
 907                                WMI_10X_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
 908        .wds = WMI_10X_VDEV_PARAM_WDS,
 909        .atim_window = WMI_10X_VDEV_PARAM_ATIM_WINDOW,
 910        .bmiss_count_max = WMI_10X_VDEV_PARAM_BMISS_COUNT_MAX,
 911        .bmiss_first_bcnt = WMI_VDEV_PARAM_UNSUPPORTED,
 912        .bmiss_final_bcnt = WMI_VDEV_PARAM_UNSUPPORTED,
 913        .feature_wmm = WMI_10X_VDEV_PARAM_FEATURE_WMM,
 914        .chwidth = WMI_10X_VDEV_PARAM_CHWIDTH,
 915        .chextoffset = WMI_10X_VDEV_PARAM_CHEXTOFFSET,
 916        .disable_htprotection = WMI_10X_VDEV_PARAM_DISABLE_HTPROTECTION,
 917        .sta_quickkickout = WMI_10X_VDEV_PARAM_STA_QUICKKICKOUT,
 918        .mgmt_rate = WMI_10X_VDEV_PARAM_MGMT_RATE,
 919        .protection_mode = WMI_10X_VDEV_PARAM_PROTECTION_MODE,
 920        .fixed_rate = WMI_10X_VDEV_PARAM_FIXED_RATE,
 921        .sgi = WMI_10X_VDEV_PARAM_SGI,
 922        .ldpc = WMI_10X_VDEV_PARAM_LDPC,
 923        .tx_stbc = WMI_10X_VDEV_PARAM_TX_STBC,
 924        .rx_stbc = WMI_10X_VDEV_PARAM_RX_STBC,
 925        .intra_bss_fwd = WMI_10X_VDEV_PARAM_INTRA_BSS_FWD,
 926        .def_keyid = WMI_10X_VDEV_PARAM_DEF_KEYID,
 927        .nss = WMI_10X_VDEV_PARAM_NSS,
 928        .bcast_data_rate = WMI_10X_VDEV_PARAM_BCAST_DATA_RATE,
 929        .mcast_data_rate = WMI_10X_VDEV_PARAM_MCAST_DATA_RATE,
 930        .mcast_indicate = WMI_10X_VDEV_PARAM_MCAST_INDICATE,
 931        .dhcp_indicate = WMI_10X_VDEV_PARAM_DHCP_INDICATE,
 932        .unknown_dest_indicate = WMI_10X_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
 933        .ap_keepalive_min_idle_inactive_time_secs =
 934                WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
 935        .ap_keepalive_max_idle_inactive_time_secs =
 936                WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
 937        .ap_keepalive_max_unresponsive_time_secs =
 938                WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
 939        .ap_enable_nawds = WMI_10X_VDEV_PARAM_AP_ENABLE_NAWDS,
 940        .mcast2ucast_set = WMI_10X_VDEV_PARAM_MCAST2UCAST_SET,
 941        .enable_rtscts = WMI_10X_VDEV_PARAM_ENABLE_RTSCTS,
 942        .txbf = WMI_VDEV_PARAM_UNSUPPORTED,
 943        .packet_powersave = WMI_VDEV_PARAM_UNSUPPORTED,
 944        .drop_unencry = WMI_VDEV_PARAM_UNSUPPORTED,
 945        .tx_encap_type = WMI_VDEV_PARAM_UNSUPPORTED,
 946        .ap_detect_out_of_sync_sleeping_sta_time_secs =
 947                WMI_10X_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS,
 948        .rc_num_retries = WMI_VDEV_PARAM_UNSUPPORTED,
 949        .cabq_maxdur = WMI_VDEV_PARAM_UNSUPPORTED,
 950        .mfptest_set = WMI_VDEV_PARAM_UNSUPPORTED,
 951        .rts_fixed_rate = WMI_VDEV_PARAM_UNSUPPORTED,
 952        .vht_sgimask = WMI_VDEV_PARAM_UNSUPPORTED,
 953        .vht80_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
 954        .early_rx_adjust_enable = WMI_VDEV_PARAM_UNSUPPORTED,
 955        .early_rx_tgt_bmiss_num = WMI_VDEV_PARAM_UNSUPPORTED,
 956        .early_rx_bmiss_sample_cycle = WMI_VDEV_PARAM_UNSUPPORTED,
 957        .early_rx_slop_step = WMI_VDEV_PARAM_UNSUPPORTED,
 958        .early_rx_init_slop = WMI_VDEV_PARAM_UNSUPPORTED,
 959        .early_rx_adjust_pause = WMI_VDEV_PARAM_UNSUPPORTED,
 960        .proxy_sta = WMI_VDEV_PARAM_UNSUPPORTED,
 961        .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED,
 962        .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED,
 963        .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
 964};
 965
 966static struct wmi_vdev_param_map wmi_10_4_vdev_param_map = {
 967        .rts_threshold = WMI_10_4_VDEV_PARAM_RTS_THRESHOLD,
 968        .fragmentation_threshold = WMI_10_4_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
 969        .beacon_interval = WMI_10_4_VDEV_PARAM_BEACON_INTERVAL,
 970        .listen_interval = WMI_10_4_VDEV_PARAM_LISTEN_INTERVAL,
 971        .multicast_rate = WMI_10_4_VDEV_PARAM_MULTICAST_RATE,
 972        .mgmt_tx_rate = WMI_10_4_VDEV_PARAM_MGMT_TX_RATE,
 973        .slot_time = WMI_10_4_VDEV_PARAM_SLOT_TIME,
 974        .preamble = WMI_10_4_VDEV_PARAM_PREAMBLE,
 975        .swba_time = WMI_10_4_VDEV_PARAM_SWBA_TIME,
 976        .wmi_vdev_stats_update_period = WMI_10_4_VDEV_STATS_UPDATE_PERIOD,
 977        .wmi_vdev_pwrsave_ageout_time = WMI_10_4_VDEV_PWRSAVE_AGEOUT_TIME,
 978        .wmi_vdev_host_swba_interval = WMI_10_4_VDEV_HOST_SWBA_INTERVAL,
 979        .dtim_period = WMI_10_4_VDEV_PARAM_DTIM_PERIOD,
 980        .wmi_vdev_oc_scheduler_air_time_limit =
 981               WMI_10_4_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
 982        .wds = WMI_10_4_VDEV_PARAM_WDS,
 983        .atim_window = WMI_10_4_VDEV_PARAM_ATIM_WINDOW,
 984        .bmiss_count_max = WMI_10_4_VDEV_PARAM_BMISS_COUNT_MAX,
 985        .bmiss_first_bcnt = WMI_10_4_VDEV_PARAM_BMISS_FIRST_BCNT,
 986        .bmiss_final_bcnt = WMI_10_4_VDEV_PARAM_BMISS_FINAL_BCNT,
 987        .feature_wmm = WMI_10_4_VDEV_PARAM_FEATURE_WMM,
 988        .chwidth = WMI_10_4_VDEV_PARAM_CHWIDTH,
 989        .chextoffset = WMI_10_4_VDEV_PARAM_CHEXTOFFSET,
 990        .disable_htprotection = WMI_10_4_VDEV_PARAM_DISABLE_HTPROTECTION,
 991        .sta_quickkickout = WMI_10_4_VDEV_PARAM_STA_QUICKKICKOUT,
 992        .mgmt_rate = WMI_10_4_VDEV_PARAM_MGMT_RATE,
 993        .protection_mode = WMI_10_4_VDEV_PARAM_PROTECTION_MODE,
 994        .fixed_rate = WMI_10_4_VDEV_PARAM_FIXED_RATE,
 995        .sgi = WMI_10_4_VDEV_PARAM_SGI,
 996        .ldpc = WMI_10_4_VDEV_PARAM_LDPC,
 997        .tx_stbc = WMI_10_4_VDEV_PARAM_TX_STBC,
 998        .rx_stbc = WMI_10_4_VDEV_PARAM_RX_STBC,
 999        .intra_bss_fwd = WMI_10_4_VDEV_PARAM_INTRA_BSS_FWD,
1000        .def_keyid = WMI_10_4_VDEV_PARAM_DEF_KEYID,
1001        .nss = WMI_10_4_VDEV_PARAM_NSS,
1002        .bcast_data_rate = WMI_10_4_VDEV_PARAM_BCAST_DATA_RATE,
1003        .mcast_data_rate = WMI_10_4_VDEV_PARAM_MCAST_DATA_RATE,
1004        .mcast_indicate = WMI_10_4_VDEV_PARAM_MCAST_INDICATE,
1005        .dhcp_indicate = WMI_10_4_VDEV_PARAM_DHCP_INDICATE,
1006        .unknown_dest_indicate = WMI_10_4_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
1007        .ap_keepalive_min_idle_inactive_time_secs =
1008               WMI_10_4_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
1009        .ap_keepalive_max_idle_inactive_time_secs =
1010               WMI_10_4_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
1011        .ap_keepalive_max_unresponsive_time_secs =
1012               WMI_10_4_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
1013        .ap_enable_nawds = WMI_10_4_VDEV_PARAM_AP_ENABLE_NAWDS,
1014        .mcast2ucast_set = WMI_10_4_VDEV_PARAM_MCAST2UCAST_SET,
1015        .enable_rtscts = WMI_10_4_VDEV_PARAM_ENABLE_RTSCTS,
1016        .txbf = WMI_10_4_VDEV_PARAM_TXBF,
1017        .packet_powersave = WMI_10_4_VDEV_PARAM_PACKET_POWERSAVE,
1018        .drop_unencry = WMI_10_4_VDEV_PARAM_DROP_UNENCRY,
1019        .tx_encap_type = WMI_10_4_VDEV_PARAM_TX_ENCAP_TYPE,
1020        .ap_detect_out_of_sync_sleeping_sta_time_secs =
1021               WMI_10_4_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS,
1022        .rc_num_retries = WMI_10_4_VDEV_PARAM_RC_NUM_RETRIES,
1023        .cabq_maxdur = WMI_10_4_VDEV_PARAM_CABQ_MAXDUR,
1024        .mfptest_set = WMI_10_4_VDEV_PARAM_MFPTEST_SET,
1025        .rts_fixed_rate = WMI_10_4_VDEV_PARAM_RTS_FIXED_RATE,
1026        .vht_sgimask = WMI_10_4_VDEV_PARAM_VHT_SGIMASK,
1027        .vht80_ratemask = WMI_10_4_VDEV_PARAM_VHT80_RATEMASK,
1028        .early_rx_adjust_enable = WMI_10_4_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
1029        .early_rx_tgt_bmiss_num = WMI_10_4_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
1030        .early_rx_bmiss_sample_cycle =
1031               WMI_10_4_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
1032        .early_rx_slop_step = WMI_10_4_VDEV_PARAM_EARLY_RX_SLOP_STEP,
1033        .early_rx_init_slop = WMI_10_4_VDEV_PARAM_EARLY_RX_INIT_SLOP,
1034        .early_rx_adjust_pause = WMI_10_4_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
1035        .proxy_sta = WMI_10_4_VDEV_PARAM_PROXY_STA,
1036        .meru_vc = WMI_10_4_VDEV_PARAM_MERU_VC,
1037        .rx_decap_type = WMI_10_4_VDEV_PARAM_RX_DECAP_TYPE,
1038        .bw_nss_ratemask = WMI_10_4_VDEV_PARAM_BW_NSS_RATEMASK,
1039        .inc_tsf = WMI_10_4_VDEV_PARAM_TSF_INCREMENT,
1040        .dec_tsf = WMI_10_4_VDEV_PARAM_TSF_DECREMENT,
1041};
1042
1043static struct wmi_pdev_param_map wmi_pdev_param_map = {
1044        .tx_chain_mask = WMI_PDEV_PARAM_TX_CHAIN_MASK,
1045        .rx_chain_mask = WMI_PDEV_PARAM_RX_CHAIN_MASK,
1046        .txpower_limit2g = WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
1047        .txpower_limit5g = WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
1048        .txpower_scale = WMI_PDEV_PARAM_TXPOWER_SCALE,
1049        .beacon_gen_mode = WMI_PDEV_PARAM_BEACON_GEN_MODE,
1050        .beacon_tx_mode = WMI_PDEV_PARAM_BEACON_TX_MODE,
1051        .resmgr_offchan_mode = WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
1052        .protection_mode = WMI_PDEV_PARAM_PROTECTION_MODE,
1053        .dynamic_bw = WMI_PDEV_PARAM_DYNAMIC_BW,
1054        .non_agg_sw_retry_th = WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
1055        .agg_sw_retry_th = WMI_PDEV_PARAM_AGG_SW_RETRY_TH,
1056        .sta_kickout_th = WMI_PDEV_PARAM_STA_KICKOUT_TH,
1057        .ac_aggrsize_scaling = WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING,
1058        .ltr_enable = WMI_PDEV_PARAM_LTR_ENABLE,
1059        .ltr_ac_latency_be = WMI_PDEV_PARAM_LTR_AC_LATENCY_BE,
1060        .ltr_ac_latency_bk = WMI_PDEV_PARAM_LTR_AC_LATENCY_BK,
1061        .ltr_ac_latency_vi = WMI_PDEV_PARAM_LTR_AC_LATENCY_VI,
1062        .ltr_ac_latency_vo = WMI_PDEV_PARAM_LTR_AC_LATENCY_VO,
1063        .ltr_ac_latency_timeout = WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
1064        .ltr_sleep_override = WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
1065        .ltr_rx_override = WMI_PDEV_PARAM_LTR_RX_OVERRIDE,
1066        .ltr_tx_activity_timeout = WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
1067        .l1ss_enable = WMI_PDEV_PARAM_L1SS_ENABLE,
1068        .dsleep_enable = WMI_PDEV_PARAM_DSLEEP_ENABLE,
1069        .pcielp_txbuf_flush = WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH,
1070        .pcielp_txbuf_watermark = WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
1071        .pcielp_txbuf_tmo_en = WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
1072        .pcielp_txbuf_tmo_value = WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE,
1073        .pdev_stats_update_period = WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
1074        .vdev_stats_update_period = WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
1075        .peer_stats_update_period = WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
1076        .bcnflt_stats_update_period = WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
1077        .pmf_qos = WMI_PDEV_PARAM_PMF_QOS,
1078        .arp_ac_override = WMI_PDEV_PARAM_ARP_AC_OVERRIDE,
1079        .dcs = WMI_PDEV_PARAM_DCS,
1080        .ani_enable = WMI_PDEV_PARAM_ANI_ENABLE,
1081        .ani_poll_period = WMI_PDEV_PARAM_ANI_POLL_PERIOD,
1082        .ani_listen_period = WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
1083        .ani_ofdm_level = WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
1084        .ani_cck_level = WMI_PDEV_PARAM_ANI_CCK_LEVEL,
1085        .dyntxchain = WMI_PDEV_PARAM_DYNTXCHAIN,
1086        .proxy_sta = WMI_PDEV_PARAM_PROXY_STA,
1087        .idle_ps_config = WMI_PDEV_PARAM_IDLE_PS_CONFIG,
1088        .power_gating_sleep = WMI_PDEV_PARAM_POWER_GATING_SLEEP,
1089        .fast_channel_reset = WMI_PDEV_PARAM_UNSUPPORTED,
1090        .burst_dur = WMI_PDEV_PARAM_UNSUPPORTED,
1091        .burst_enable = WMI_PDEV_PARAM_UNSUPPORTED,
1092        .cal_period = WMI_PDEV_PARAM_UNSUPPORTED,
1093        .aggr_burst = WMI_PDEV_PARAM_UNSUPPORTED,
1094        .rx_decap_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1095        .smart_antenna_default_antenna = WMI_PDEV_PARAM_UNSUPPORTED,
1096        .igmpmld_override = WMI_PDEV_PARAM_UNSUPPORTED,
1097        .igmpmld_tid = WMI_PDEV_PARAM_UNSUPPORTED,
1098        .antenna_gain = WMI_PDEV_PARAM_UNSUPPORTED,
1099        .rx_filter = WMI_PDEV_PARAM_UNSUPPORTED,
1100        .set_mcast_to_ucast_tid = WMI_PDEV_PARAM_UNSUPPORTED,
1101        .proxy_sta_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1102        .set_mcast2ucast_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1103        .set_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
1104        .remove_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
1105        .peer_sta_ps_statechg_enable = WMI_PDEV_PARAM_UNSUPPORTED,
1106        .igmpmld_ac_override = WMI_PDEV_PARAM_UNSUPPORTED,
1107        .block_interbss = WMI_PDEV_PARAM_UNSUPPORTED,
1108        .set_disable_reset_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1109        .set_msdu_ttl_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1110        .set_ppdu_duration_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1111        .txbf_sound_period_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1112        .set_promisc_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1113        .set_burst_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1114        .en_stats = WMI_PDEV_PARAM_UNSUPPORTED,
1115        .mu_group_policy = WMI_PDEV_PARAM_UNSUPPORTED,
1116        .noise_detection = WMI_PDEV_PARAM_UNSUPPORTED,
1117        .noise_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
1118        .dpd_enable = WMI_PDEV_PARAM_UNSUPPORTED,
1119        .set_mcast_bcast_echo = WMI_PDEV_PARAM_UNSUPPORTED,
1120        .atf_strict_sch = WMI_PDEV_PARAM_UNSUPPORTED,
1121        .atf_sched_duration = WMI_PDEV_PARAM_UNSUPPORTED,
1122        .ant_plzn = WMI_PDEV_PARAM_UNSUPPORTED,
1123        .mgmt_retry_limit = WMI_PDEV_PARAM_UNSUPPORTED,
1124        .sensitivity_level = WMI_PDEV_PARAM_UNSUPPORTED,
1125        .signed_txpower_2g = WMI_PDEV_PARAM_UNSUPPORTED,
1126        .signed_txpower_5g = WMI_PDEV_PARAM_UNSUPPORTED,
1127        .enable_per_tid_amsdu = WMI_PDEV_PARAM_UNSUPPORTED,
1128        .enable_per_tid_ampdu = WMI_PDEV_PARAM_UNSUPPORTED,
1129        .cca_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
1130        .rts_fixed_rate = WMI_PDEV_PARAM_UNSUPPORTED,
1131        .pdev_reset = WMI_PDEV_PARAM_UNSUPPORTED,
1132        .wapi_mbssid_offset = WMI_PDEV_PARAM_UNSUPPORTED,
1133        .arp_srcaddr = WMI_PDEV_PARAM_UNSUPPORTED,
1134        .arp_dstaddr = WMI_PDEV_PARAM_UNSUPPORTED,
1135        .enable_btcoex = WMI_PDEV_PARAM_UNSUPPORTED,
1136};
1137
1138static struct wmi_pdev_param_map wmi_10x_pdev_param_map = {
1139        .tx_chain_mask = WMI_10X_PDEV_PARAM_TX_CHAIN_MASK,
1140        .rx_chain_mask = WMI_10X_PDEV_PARAM_RX_CHAIN_MASK,
1141        .txpower_limit2g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT2G,
1142        .txpower_limit5g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT5G,
1143        .txpower_scale = WMI_10X_PDEV_PARAM_TXPOWER_SCALE,
1144        .beacon_gen_mode = WMI_10X_PDEV_PARAM_BEACON_GEN_MODE,
1145        .beacon_tx_mode = WMI_10X_PDEV_PARAM_BEACON_TX_MODE,
1146        .resmgr_offchan_mode = WMI_10X_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
1147        .protection_mode = WMI_10X_PDEV_PARAM_PROTECTION_MODE,
1148        .dynamic_bw = WMI_10X_PDEV_PARAM_DYNAMIC_BW,
1149        .non_agg_sw_retry_th = WMI_10X_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
1150        .agg_sw_retry_th = WMI_10X_PDEV_PARAM_AGG_SW_RETRY_TH,
1151        .sta_kickout_th = WMI_10X_PDEV_PARAM_STA_KICKOUT_TH,
1152        .ac_aggrsize_scaling = WMI_10X_PDEV_PARAM_AC_AGGRSIZE_SCALING,
1153        .ltr_enable = WMI_10X_PDEV_PARAM_LTR_ENABLE,
1154        .ltr_ac_latency_be = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BE,
1155        .ltr_ac_latency_bk = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BK,
1156        .ltr_ac_latency_vi = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VI,
1157        .ltr_ac_latency_vo = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VO,
1158        .ltr_ac_latency_timeout = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
1159        .ltr_sleep_override = WMI_10X_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
1160        .ltr_rx_override = WMI_10X_PDEV_PARAM_LTR_RX_OVERRIDE,
1161        .ltr_tx_activity_timeout = WMI_10X_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
1162        .l1ss_enable = WMI_10X_PDEV_PARAM_L1SS_ENABLE,
1163        .dsleep_enable = WMI_10X_PDEV_PARAM_DSLEEP_ENABLE,
1164        .pcielp_txbuf_flush = WMI_PDEV_PARAM_UNSUPPORTED,
1165        .pcielp_txbuf_watermark = WMI_PDEV_PARAM_UNSUPPORTED,
1166        .pcielp_txbuf_tmo_en = WMI_PDEV_PARAM_UNSUPPORTED,
1167        .pcielp_txbuf_tmo_value = WMI_PDEV_PARAM_UNSUPPORTED,
1168        .pdev_stats_update_period = WMI_10X_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
1169        .vdev_stats_update_period = WMI_10X_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
1170        .peer_stats_update_period = WMI_10X_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
1171        .bcnflt_stats_update_period =
1172                                WMI_10X_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
1173        .pmf_qos = WMI_10X_PDEV_PARAM_PMF_QOS,
1174        .arp_ac_override = WMI_10X_PDEV_PARAM_ARPDHCP_AC_OVERRIDE,
1175        .dcs = WMI_10X_PDEV_PARAM_DCS,
1176        .ani_enable = WMI_10X_PDEV_PARAM_ANI_ENABLE,
1177        .ani_poll_period = WMI_10X_PDEV_PARAM_ANI_POLL_PERIOD,
1178        .ani_listen_period = WMI_10X_PDEV_PARAM_ANI_LISTEN_PERIOD,
1179        .ani_ofdm_level = WMI_10X_PDEV_PARAM_ANI_OFDM_LEVEL,
1180        .ani_cck_level = WMI_10X_PDEV_PARAM_ANI_CCK_LEVEL,
1181        .dyntxchain = WMI_10X_PDEV_PARAM_DYNTXCHAIN,
1182        .proxy_sta = WMI_PDEV_PARAM_UNSUPPORTED,
1183        .idle_ps_config = WMI_PDEV_PARAM_UNSUPPORTED,
1184        .power_gating_sleep = WMI_PDEV_PARAM_UNSUPPORTED,
1185        .fast_channel_reset = WMI_10X_PDEV_PARAM_FAST_CHANNEL_RESET,
1186        .burst_dur = WMI_10X_PDEV_PARAM_BURST_DUR,
1187        .burst_enable = WMI_10X_PDEV_PARAM_BURST_ENABLE,
1188        .cal_period = WMI_10X_PDEV_PARAM_CAL_PERIOD,
1189        .aggr_burst = WMI_PDEV_PARAM_UNSUPPORTED,
1190        .rx_decap_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1191        .smart_antenna_default_antenna = WMI_PDEV_PARAM_UNSUPPORTED,
1192        .igmpmld_override = WMI_PDEV_PARAM_UNSUPPORTED,
1193        .igmpmld_tid = WMI_PDEV_PARAM_UNSUPPORTED,
1194        .antenna_gain = WMI_PDEV_PARAM_UNSUPPORTED,
1195        .rx_filter = WMI_PDEV_PARAM_UNSUPPORTED,
1196        .set_mcast_to_ucast_tid = WMI_PDEV_PARAM_UNSUPPORTED,
1197        .proxy_sta_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1198        .set_mcast2ucast_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1199        .set_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
1200        .remove_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
1201        .peer_sta_ps_statechg_enable = WMI_PDEV_PARAM_UNSUPPORTED,
1202        .igmpmld_ac_override = WMI_PDEV_PARAM_UNSUPPORTED,
1203        .block_interbss = WMI_PDEV_PARAM_UNSUPPORTED,
1204        .set_disable_reset_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1205        .set_msdu_ttl_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1206        .set_ppdu_duration_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1207        .txbf_sound_period_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1208        .set_promisc_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1209        .set_burst_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1210        .en_stats = WMI_PDEV_PARAM_UNSUPPORTED,
1211        .mu_group_policy = WMI_PDEV_PARAM_UNSUPPORTED,
1212        .noise_detection = WMI_PDEV_PARAM_UNSUPPORTED,
1213        .noise_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
1214        .dpd_enable = WMI_PDEV_PARAM_UNSUPPORTED,
1215        .set_mcast_bcast_echo = WMI_PDEV_PARAM_UNSUPPORTED,
1216        .atf_strict_sch = WMI_PDEV_PARAM_UNSUPPORTED,
1217        .atf_sched_duration = WMI_PDEV_PARAM_UNSUPPORTED,
1218        .ant_plzn = WMI_PDEV_PARAM_UNSUPPORTED,
1219        .mgmt_retry_limit = WMI_PDEV_PARAM_UNSUPPORTED,
1220        .sensitivity_level = WMI_PDEV_PARAM_UNSUPPORTED,
1221        .signed_txpower_2g = WMI_PDEV_PARAM_UNSUPPORTED,
1222        .signed_txpower_5g = WMI_PDEV_PARAM_UNSUPPORTED,
1223        .enable_per_tid_amsdu = WMI_PDEV_PARAM_UNSUPPORTED,
1224        .enable_per_tid_ampdu = WMI_PDEV_PARAM_UNSUPPORTED,
1225        .cca_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
1226        .rts_fixed_rate = WMI_PDEV_PARAM_UNSUPPORTED,
1227        .pdev_reset = WMI_PDEV_PARAM_UNSUPPORTED,
1228        .wapi_mbssid_offset = WMI_PDEV_PARAM_UNSUPPORTED,
1229        .arp_srcaddr = WMI_PDEV_PARAM_UNSUPPORTED,
1230        .arp_dstaddr = WMI_PDEV_PARAM_UNSUPPORTED,
1231        .enable_btcoex = WMI_PDEV_PARAM_UNSUPPORTED,
1232};
1233
1234static struct wmi_pdev_param_map wmi_10_2_4_pdev_param_map = {
1235        .tx_chain_mask = WMI_10X_PDEV_PARAM_TX_CHAIN_MASK,
1236        .rx_chain_mask = WMI_10X_PDEV_PARAM_RX_CHAIN_MASK,
1237        .txpower_limit2g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT2G,
1238        .txpower_limit5g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT5G,
1239        .txpower_scale = WMI_10X_PDEV_PARAM_TXPOWER_SCALE,
1240        .beacon_gen_mode = WMI_10X_PDEV_PARAM_BEACON_GEN_MODE,
1241        .beacon_tx_mode = WMI_10X_PDEV_PARAM_BEACON_TX_MODE,
1242        .resmgr_offchan_mode = WMI_10X_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
1243        .protection_mode = WMI_10X_PDEV_PARAM_PROTECTION_MODE,
1244        .dynamic_bw = WMI_10X_PDEV_PARAM_DYNAMIC_BW,
1245        .non_agg_sw_retry_th = WMI_10X_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
1246        .agg_sw_retry_th = WMI_10X_PDEV_PARAM_AGG_SW_RETRY_TH,
1247        .sta_kickout_th = WMI_10X_PDEV_PARAM_STA_KICKOUT_TH,
1248        .ac_aggrsize_scaling = WMI_10X_PDEV_PARAM_AC_AGGRSIZE_SCALING,
1249        .ltr_enable = WMI_10X_PDEV_PARAM_LTR_ENABLE,
1250        .ltr_ac_latency_be = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BE,
1251        .ltr_ac_latency_bk = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BK,
1252        .ltr_ac_latency_vi = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VI,
1253        .ltr_ac_latency_vo = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VO,
1254        .ltr_ac_latency_timeout = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
1255        .ltr_sleep_override = WMI_10X_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
1256        .ltr_rx_override = WMI_10X_PDEV_PARAM_LTR_RX_OVERRIDE,
1257        .ltr_tx_activity_timeout = WMI_10X_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
1258        .l1ss_enable = WMI_10X_PDEV_PARAM_L1SS_ENABLE,
1259        .dsleep_enable = WMI_10X_PDEV_PARAM_DSLEEP_ENABLE,
1260        .pcielp_txbuf_flush = WMI_PDEV_PARAM_UNSUPPORTED,
1261        .pcielp_txbuf_watermark = WMI_PDEV_PARAM_UNSUPPORTED,
1262        .pcielp_txbuf_tmo_en = WMI_PDEV_PARAM_UNSUPPORTED,
1263        .pcielp_txbuf_tmo_value = WMI_PDEV_PARAM_UNSUPPORTED,
1264        .pdev_stats_update_period = WMI_10X_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
1265        .vdev_stats_update_period = WMI_10X_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
1266        .peer_stats_update_period = WMI_10X_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
1267        .bcnflt_stats_update_period =
1268                                WMI_10X_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
1269        .pmf_qos = WMI_10X_PDEV_PARAM_PMF_QOS,
1270        .arp_ac_override = WMI_10X_PDEV_PARAM_ARPDHCP_AC_OVERRIDE,
1271        .dcs = WMI_10X_PDEV_PARAM_DCS,
1272        .ani_enable = WMI_10X_PDEV_PARAM_ANI_ENABLE,
1273        .ani_poll_period = WMI_10X_PDEV_PARAM_ANI_POLL_PERIOD,
1274        .ani_listen_period = WMI_10X_PDEV_PARAM_ANI_LISTEN_PERIOD,
1275        .ani_ofdm_level = WMI_10X_PDEV_PARAM_ANI_OFDM_LEVEL,
1276        .ani_cck_level = WMI_10X_PDEV_PARAM_ANI_CCK_LEVEL,
1277        .dyntxchain = WMI_10X_PDEV_PARAM_DYNTXCHAIN,
1278        .proxy_sta = WMI_PDEV_PARAM_UNSUPPORTED,
1279        .idle_ps_config = WMI_PDEV_PARAM_UNSUPPORTED,
1280        .power_gating_sleep = WMI_PDEV_PARAM_UNSUPPORTED,
1281        .fast_channel_reset = WMI_10X_PDEV_PARAM_FAST_CHANNEL_RESET,
1282        .burst_dur = WMI_10X_PDEV_PARAM_BURST_DUR,
1283        .burst_enable = WMI_10X_PDEV_PARAM_BURST_ENABLE,
1284        .cal_period = WMI_10X_PDEV_PARAM_CAL_PERIOD,
1285        .aggr_burst = WMI_PDEV_PARAM_UNSUPPORTED,
1286        .rx_decap_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1287        .smart_antenna_default_antenna = WMI_PDEV_PARAM_UNSUPPORTED,
1288        .igmpmld_override = WMI_PDEV_PARAM_UNSUPPORTED,
1289        .igmpmld_tid = WMI_PDEV_PARAM_UNSUPPORTED,
1290        .antenna_gain = WMI_PDEV_PARAM_UNSUPPORTED,
1291        .rx_filter = WMI_PDEV_PARAM_UNSUPPORTED,
1292        .set_mcast_to_ucast_tid = WMI_PDEV_PARAM_UNSUPPORTED,
1293        .proxy_sta_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1294        .set_mcast2ucast_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1295        .set_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
1296        .remove_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
1297        .peer_sta_ps_statechg_enable = WMI_PDEV_PARAM_UNSUPPORTED,
1298        .igmpmld_ac_override = WMI_PDEV_PARAM_UNSUPPORTED,
1299        .block_interbss = WMI_PDEV_PARAM_UNSUPPORTED,
1300        .set_disable_reset_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1301        .set_msdu_ttl_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1302        .set_ppdu_duration_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1303        .txbf_sound_period_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1304        .set_promisc_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1305        .set_burst_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1306        .en_stats = WMI_PDEV_PARAM_UNSUPPORTED,
1307        .mu_group_policy = WMI_PDEV_PARAM_UNSUPPORTED,
1308        .noise_detection = WMI_PDEV_PARAM_UNSUPPORTED,
1309        .noise_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
1310        .dpd_enable = WMI_PDEV_PARAM_UNSUPPORTED,
1311        .set_mcast_bcast_echo = WMI_PDEV_PARAM_UNSUPPORTED,
1312        .atf_strict_sch = WMI_PDEV_PARAM_UNSUPPORTED,
1313        .atf_sched_duration = WMI_PDEV_PARAM_UNSUPPORTED,
1314        .ant_plzn = WMI_PDEV_PARAM_UNSUPPORTED,
1315        .mgmt_retry_limit = WMI_PDEV_PARAM_UNSUPPORTED,
1316        .sensitivity_level = WMI_PDEV_PARAM_UNSUPPORTED,
1317        .signed_txpower_2g = WMI_PDEV_PARAM_UNSUPPORTED,
1318        .signed_txpower_5g = WMI_PDEV_PARAM_UNSUPPORTED,
1319        .enable_per_tid_amsdu = WMI_PDEV_PARAM_UNSUPPORTED,
1320        .enable_per_tid_ampdu = WMI_PDEV_PARAM_UNSUPPORTED,
1321        .cca_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
1322        .rts_fixed_rate = WMI_PDEV_PARAM_UNSUPPORTED,
1323        .pdev_reset = WMI_PDEV_PARAM_UNSUPPORTED,
1324        .wapi_mbssid_offset = WMI_PDEV_PARAM_UNSUPPORTED,
1325        .arp_srcaddr = WMI_PDEV_PARAM_UNSUPPORTED,
1326        .arp_dstaddr = WMI_PDEV_PARAM_UNSUPPORTED,
1327        .enable_btcoex = WMI_PDEV_PARAM_UNSUPPORTED,
1328};
1329
1330/* firmware 10.2 specific mappings */
1331static struct wmi_cmd_map wmi_10_2_cmd_map = {
1332        .init_cmdid = WMI_10_2_INIT_CMDID,
1333        .start_scan_cmdid = WMI_10_2_START_SCAN_CMDID,
1334        .stop_scan_cmdid = WMI_10_2_STOP_SCAN_CMDID,
1335        .scan_chan_list_cmdid = WMI_10_2_SCAN_CHAN_LIST_CMDID,
1336        .scan_sch_prio_tbl_cmdid = WMI_CMD_UNSUPPORTED,
1337        .pdev_set_regdomain_cmdid = WMI_10_2_PDEV_SET_REGDOMAIN_CMDID,
1338        .pdev_set_channel_cmdid = WMI_10_2_PDEV_SET_CHANNEL_CMDID,
1339        .pdev_set_param_cmdid = WMI_10_2_PDEV_SET_PARAM_CMDID,
1340        .pdev_pktlog_enable_cmdid = WMI_10_2_PDEV_PKTLOG_ENABLE_CMDID,
1341        .pdev_pktlog_disable_cmdid = WMI_10_2_PDEV_PKTLOG_DISABLE_CMDID,
1342        .pdev_set_wmm_params_cmdid = WMI_10_2_PDEV_SET_WMM_PARAMS_CMDID,
1343        .pdev_set_ht_cap_ie_cmdid = WMI_10_2_PDEV_SET_HT_CAP_IE_CMDID,
1344        .pdev_set_vht_cap_ie_cmdid = WMI_10_2_PDEV_SET_VHT_CAP_IE_CMDID,
1345        .pdev_set_quiet_mode_cmdid = WMI_10_2_PDEV_SET_QUIET_MODE_CMDID,
1346        .pdev_green_ap_ps_enable_cmdid = WMI_10_2_PDEV_GREEN_AP_PS_ENABLE_CMDID,
1347        .pdev_get_tpc_config_cmdid = WMI_10_2_PDEV_GET_TPC_CONFIG_CMDID,
1348        .pdev_set_base_macaddr_cmdid = WMI_10_2_PDEV_SET_BASE_MACADDR_CMDID,
1349        .vdev_create_cmdid = WMI_10_2_VDEV_CREATE_CMDID,
1350        .vdev_delete_cmdid = WMI_10_2_VDEV_DELETE_CMDID,
1351        .vdev_start_request_cmdid = WMI_10_2_VDEV_START_REQUEST_CMDID,
1352        .vdev_restart_request_cmdid = WMI_10_2_VDEV_RESTART_REQUEST_CMDID,
1353        .vdev_up_cmdid = WMI_10_2_VDEV_UP_CMDID,
1354        .vdev_stop_cmdid = WMI_10_2_VDEV_STOP_CMDID,
1355        .vdev_down_cmdid = WMI_10_2_VDEV_DOWN_CMDID,
1356        .vdev_set_param_cmdid = WMI_10_2_VDEV_SET_PARAM_CMDID,
1357        .vdev_install_key_cmdid = WMI_10_2_VDEV_INSTALL_KEY_CMDID,
1358        .peer_create_cmdid = WMI_10_2_PEER_CREATE_CMDID,
1359        .peer_delete_cmdid = WMI_10_2_PEER_DELETE_CMDID,
1360        .peer_flush_tids_cmdid = WMI_10_2_PEER_FLUSH_TIDS_CMDID,
1361        .peer_set_param_cmdid = WMI_10_2_PEER_SET_PARAM_CMDID,
1362        .peer_assoc_cmdid = WMI_10_2_PEER_ASSOC_CMDID,
1363        .peer_add_wds_entry_cmdid = WMI_10_2_PEER_ADD_WDS_ENTRY_CMDID,
1364        .peer_remove_wds_entry_cmdid = WMI_10_2_PEER_REMOVE_WDS_ENTRY_CMDID,
1365        .peer_mcast_group_cmdid = WMI_10_2_PEER_MCAST_GROUP_CMDID,
1366        .bcn_tx_cmdid = WMI_10_2_BCN_TX_CMDID,
1367        .pdev_send_bcn_cmdid = WMI_10_2_PDEV_SEND_BCN_CMDID,
1368        .bcn_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
1369        .bcn_filter_rx_cmdid = WMI_10_2_BCN_FILTER_RX_CMDID,
1370        .prb_req_filter_rx_cmdid = WMI_10_2_PRB_REQ_FILTER_RX_CMDID,
1371        .mgmt_tx_cmdid = WMI_10_2_MGMT_TX_CMDID,
1372        .prb_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
1373        .addba_clear_resp_cmdid = WMI_10_2_ADDBA_CLEAR_RESP_CMDID,
1374        .addba_send_cmdid = WMI_10_2_ADDBA_SEND_CMDID,
1375        .addba_status_cmdid = WMI_10_2_ADDBA_STATUS_CMDID,
1376        .delba_send_cmdid = WMI_10_2_DELBA_SEND_CMDID,
1377        .addba_set_resp_cmdid = WMI_10_2_ADDBA_SET_RESP_CMDID,
1378        .send_singleamsdu_cmdid = WMI_10_2_SEND_SINGLEAMSDU_CMDID,
1379        .sta_powersave_mode_cmdid = WMI_10_2_STA_POWERSAVE_MODE_CMDID,
1380        .sta_powersave_param_cmdid = WMI_10_2_STA_POWERSAVE_PARAM_CMDID,
1381        .sta_mimo_ps_mode_cmdid = WMI_10_2_STA_MIMO_PS_MODE_CMDID,
1382        .pdev_dfs_enable_cmdid = WMI_10_2_PDEV_DFS_ENABLE_CMDID,
1383        .pdev_dfs_disable_cmdid = WMI_10_2_PDEV_DFS_DISABLE_CMDID,
1384        .roam_scan_mode = WMI_10_2_ROAM_SCAN_MODE,
1385        .roam_scan_rssi_threshold = WMI_10_2_ROAM_SCAN_RSSI_THRESHOLD,
1386        .roam_scan_period = WMI_10_2_ROAM_SCAN_PERIOD,
1387        .roam_scan_rssi_change_threshold =
1388                                WMI_10_2_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
1389        .roam_ap_profile = WMI_10_2_ROAM_AP_PROFILE,
1390        .ofl_scan_add_ap_profile = WMI_10_2_OFL_SCAN_ADD_AP_PROFILE,
1391        .ofl_scan_remove_ap_profile = WMI_10_2_OFL_SCAN_REMOVE_AP_PROFILE,
1392        .ofl_scan_period = WMI_10_2_OFL_SCAN_PERIOD,
1393        .p2p_dev_set_device_info = WMI_10_2_P2P_DEV_SET_DEVICE_INFO,
1394        .p2p_dev_set_discoverability = WMI_10_2_P2P_DEV_SET_DISCOVERABILITY,
1395        .p2p_go_set_beacon_ie = WMI_10_2_P2P_GO_SET_BEACON_IE,
1396        .p2p_go_set_probe_resp_ie = WMI_10_2_P2P_GO_SET_PROBE_RESP_IE,
1397        .p2p_set_vendor_ie_data_cmdid = WMI_CMD_UNSUPPORTED,
1398        .ap_ps_peer_param_cmdid = WMI_10_2_AP_PS_PEER_PARAM_CMDID,
1399        .ap_ps_peer_uapsd_coex_cmdid = WMI_CMD_UNSUPPORTED,
1400        .peer_rate_retry_sched_cmdid = WMI_10_2_PEER_RATE_RETRY_SCHED_CMDID,
1401        .wlan_profile_trigger_cmdid = WMI_10_2_WLAN_PROFILE_TRIGGER_CMDID,
1402        .wlan_profile_set_hist_intvl_cmdid =
1403                                WMI_10_2_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1404        .wlan_profile_get_profile_data_cmdid =
1405                                WMI_10_2_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1406        .wlan_profile_enable_profile_id_cmdid =
1407                                WMI_10_2_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1408        .wlan_profile_list_profile_id_cmdid =
1409                                WMI_10_2_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1410        .pdev_suspend_cmdid = WMI_10_2_PDEV_SUSPEND_CMDID,
1411        .pdev_resume_cmdid = WMI_10_2_PDEV_RESUME_CMDID,
1412        .add_bcn_filter_cmdid = WMI_10_2_ADD_BCN_FILTER_CMDID,
1413        .rmv_bcn_filter_cmdid = WMI_10_2_RMV_BCN_FILTER_CMDID,
1414        .wow_add_wake_pattern_cmdid = WMI_10_2_WOW_ADD_WAKE_PATTERN_CMDID,
1415        .wow_del_wake_pattern_cmdid = WMI_10_2_WOW_DEL_WAKE_PATTERN_CMDID,
1416        .wow_enable_disable_wake_event_cmdid =
1417                                WMI_10_2_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
1418        .wow_enable_cmdid = WMI_10_2_WOW_ENABLE_CMDID,
1419        .wow_hostwakeup_from_sleep_cmdid =
1420                                WMI_10_2_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
1421        .rtt_measreq_cmdid = WMI_10_2_RTT_MEASREQ_CMDID,
1422        .rtt_tsf_cmdid = WMI_10_2_RTT_TSF_CMDID,
1423        .vdev_spectral_scan_configure_cmdid =
1424                                WMI_10_2_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
1425        .vdev_spectral_scan_enable_cmdid =
1426                                WMI_10_2_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
1427        .request_stats_cmdid = WMI_10_2_REQUEST_STATS_CMDID,
1428        .set_arp_ns_offload_cmdid = WMI_CMD_UNSUPPORTED,
1429        .network_list_offload_config_cmdid = WMI_CMD_UNSUPPORTED,
1430        .gtk_offload_cmdid = WMI_CMD_UNSUPPORTED,
1431        .csa_offload_enable_cmdid = WMI_CMD_UNSUPPORTED,
1432        .csa_offload_chanswitch_cmdid = WMI_CMD_UNSUPPORTED,
1433        .chatter_set_mode_cmdid = WMI_CMD_UNSUPPORTED,
1434        .peer_tid_addba_cmdid = WMI_CMD_UNSUPPORTED,
1435        .peer_tid_delba_cmdid = WMI_CMD_UNSUPPORTED,
1436        .sta_dtim_ps_method_cmdid = WMI_CMD_UNSUPPORTED,
1437        .sta_uapsd_auto_trig_cmdid = WMI_CMD_UNSUPPORTED,
1438        .sta_keepalive_cmd = WMI_CMD_UNSUPPORTED,
1439        .echo_cmdid = WMI_10_2_ECHO_CMDID,
1440        .pdev_utf_cmdid = WMI_10_2_PDEV_UTF_CMDID,
1441        .dbglog_cfg_cmdid = WMI_10_2_DBGLOG_CFG_CMDID,
1442        .pdev_qvit_cmdid = WMI_10_2_PDEV_QVIT_CMDID,
1443        .pdev_ftm_intg_cmdid = WMI_CMD_UNSUPPORTED,
1444        .vdev_set_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
1445        .vdev_get_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
1446        .force_fw_hang_cmdid = WMI_CMD_UNSUPPORTED,
1447        .gpio_config_cmdid = WMI_10_2_GPIO_CONFIG_CMDID,
1448        .gpio_output_cmdid = WMI_10_2_GPIO_OUTPUT_CMDID,
1449        .pdev_get_temperature_cmdid = WMI_CMD_UNSUPPORTED,
1450        .pdev_enable_adaptive_cca_cmdid = WMI_CMD_UNSUPPORTED,
1451        .scan_update_request_cmdid = WMI_CMD_UNSUPPORTED,
1452        .vdev_standby_response_cmdid = WMI_CMD_UNSUPPORTED,
1453        .vdev_resume_response_cmdid = WMI_CMD_UNSUPPORTED,
1454        .wlan_peer_caching_add_peer_cmdid = WMI_CMD_UNSUPPORTED,
1455        .wlan_peer_caching_evict_peer_cmdid = WMI_CMD_UNSUPPORTED,
1456        .wlan_peer_caching_restore_peer_cmdid = WMI_CMD_UNSUPPORTED,
1457        .wlan_peer_caching_print_all_peers_info_cmdid = WMI_CMD_UNSUPPORTED,
1458        .peer_update_wds_entry_cmdid = WMI_CMD_UNSUPPORTED,
1459        .peer_add_proxy_sta_entry_cmdid = WMI_CMD_UNSUPPORTED,
1460        .rtt_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
1461        .oem_req_cmdid = WMI_CMD_UNSUPPORTED,
1462        .nan_cmdid = WMI_CMD_UNSUPPORTED,
1463        .vdev_ratemask_cmdid = WMI_CMD_UNSUPPORTED,
1464        .qboost_cfg_cmdid = WMI_CMD_UNSUPPORTED,
1465        .pdev_smart_ant_enable_cmdid = WMI_CMD_UNSUPPORTED,
1466        .pdev_smart_ant_set_rx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
1467        .peer_smart_ant_set_tx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
1468        .peer_smart_ant_set_train_info_cmdid = WMI_CMD_UNSUPPORTED,
1469        .peer_smart_ant_set_node_config_ops_cmdid = WMI_CMD_UNSUPPORTED,
1470        .pdev_set_antenna_switch_table_cmdid = WMI_CMD_UNSUPPORTED,
1471        .pdev_set_ctl_table_cmdid = WMI_CMD_UNSUPPORTED,
1472        .pdev_set_mimogain_table_cmdid = WMI_CMD_UNSUPPORTED,
1473        .pdev_ratepwr_table_cmdid = WMI_CMD_UNSUPPORTED,
1474        .pdev_ratepwr_chainmsk_table_cmdid = WMI_CMD_UNSUPPORTED,
1475        .pdev_fips_cmdid = WMI_CMD_UNSUPPORTED,
1476        .tt_set_conf_cmdid = WMI_CMD_UNSUPPORTED,
1477        .fwtest_cmdid = WMI_CMD_UNSUPPORTED,
1478        .vdev_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
1479        .peer_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
1480        .pdev_get_ani_cck_config_cmdid = WMI_CMD_UNSUPPORTED,
1481        .pdev_get_ani_ofdm_config_cmdid = WMI_CMD_UNSUPPORTED,
1482        .pdev_reserve_ast_entry_cmdid = WMI_CMD_UNSUPPORTED,
1483};
1484
1485static struct wmi_pdev_param_map wmi_10_4_pdev_param_map = {
1486        .tx_chain_mask = WMI_10_4_PDEV_PARAM_TX_CHAIN_MASK,
1487        .rx_chain_mask = WMI_10_4_PDEV_PARAM_RX_CHAIN_MASK,
1488        .txpower_limit2g = WMI_10_4_PDEV_PARAM_TXPOWER_LIMIT2G,
1489        .txpower_limit5g = WMI_10_4_PDEV_PARAM_TXPOWER_LIMIT5G,
1490        .txpower_scale = WMI_10_4_PDEV_PARAM_TXPOWER_SCALE,
1491        .beacon_gen_mode = WMI_10_4_PDEV_PARAM_BEACON_GEN_MODE,
1492        .beacon_tx_mode = WMI_10_4_PDEV_PARAM_BEACON_TX_MODE,
1493        .resmgr_offchan_mode = WMI_10_4_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
1494        .protection_mode = WMI_10_4_PDEV_PARAM_PROTECTION_MODE,
1495        .dynamic_bw = WMI_10_4_PDEV_PARAM_DYNAMIC_BW,
1496        .non_agg_sw_retry_th = WMI_10_4_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
1497        .agg_sw_retry_th = WMI_10_4_PDEV_PARAM_AGG_SW_RETRY_TH,
1498        .sta_kickout_th = WMI_10_4_PDEV_PARAM_STA_KICKOUT_TH,
1499        .ac_aggrsize_scaling = WMI_10_4_PDEV_PARAM_AC_AGGRSIZE_SCALING,
1500        .ltr_enable = WMI_10_4_PDEV_PARAM_LTR_ENABLE,
1501        .ltr_ac_latency_be = WMI_10_4_PDEV_PARAM_LTR_AC_LATENCY_BE,
1502        .ltr_ac_latency_bk = WMI_10_4_PDEV_PARAM_LTR_AC_LATENCY_BK,
1503        .ltr_ac_latency_vi = WMI_10_4_PDEV_PARAM_LTR_AC_LATENCY_VI,
1504        .ltr_ac_latency_vo = WMI_10_4_PDEV_PARAM_LTR_AC_LATENCY_VO,
1505        .ltr_ac_latency_timeout = WMI_10_4_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
1506        .ltr_sleep_override = WMI_10_4_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
1507        .ltr_rx_override = WMI_10_4_PDEV_PARAM_LTR_RX_OVERRIDE,
1508        .ltr_tx_activity_timeout = WMI_10_4_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
1509        .l1ss_enable = WMI_10_4_PDEV_PARAM_L1SS_ENABLE,
1510        .dsleep_enable = WMI_10_4_PDEV_PARAM_DSLEEP_ENABLE,
1511        .pcielp_txbuf_flush = WMI_10_4_PDEV_PARAM_PCIELP_TXBUF_FLUSH,
1512        .pcielp_txbuf_watermark = WMI_10_4_PDEV_PARAM_PCIELP_TXBUF_WATERMARK,
1513        .pcielp_txbuf_tmo_en = WMI_10_4_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
1514        .pcielp_txbuf_tmo_value = WMI_10_4_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE,
1515        .pdev_stats_update_period =
1516                        WMI_10_4_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
1517        .vdev_stats_update_period =
1518                        WMI_10_4_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
1519        .peer_stats_update_period =
1520                        WMI_10_4_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
1521        .bcnflt_stats_update_period =
1522                        WMI_10_4_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
1523        .pmf_qos = WMI_10_4_PDEV_PARAM_PMF_QOS,
1524        .arp_ac_override = WMI_10_4_PDEV_PARAM_ARP_AC_OVERRIDE,
1525        .dcs = WMI_10_4_PDEV_PARAM_DCS,
1526        .ani_enable = WMI_10_4_PDEV_PARAM_ANI_ENABLE,
1527        .ani_poll_period = WMI_10_4_PDEV_PARAM_ANI_POLL_PERIOD,
1528        .ani_listen_period = WMI_10_4_PDEV_PARAM_ANI_LISTEN_PERIOD,
1529        .ani_ofdm_level = WMI_10_4_PDEV_PARAM_ANI_OFDM_LEVEL,
1530        .ani_cck_level = WMI_10_4_PDEV_PARAM_ANI_CCK_LEVEL,
1531        .dyntxchain = WMI_10_4_PDEV_PARAM_DYNTXCHAIN,
1532        .proxy_sta = WMI_10_4_PDEV_PARAM_PROXY_STA,
1533        .idle_ps_config = WMI_10_4_PDEV_PARAM_IDLE_PS_CONFIG,
1534        .power_gating_sleep = WMI_10_4_PDEV_PARAM_POWER_GATING_SLEEP,
1535        .fast_channel_reset = WMI_10_4_PDEV_PARAM_FAST_CHANNEL_RESET,
1536        .burst_dur = WMI_10_4_PDEV_PARAM_BURST_DUR,
1537        .burst_enable = WMI_10_4_PDEV_PARAM_BURST_ENABLE,
1538        .cal_period = WMI_10_4_PDEV_PARAM_CAL_PERIOD,
1539        .aggr_burst = WMI_10_4_PDEV_PARAM_AGGR_BURST,
1540        .rx_decap_mode = WMI_10_4_PDEV_PARAM_RX_DECAP_MODE,
1541        .smart_antenna_default_antenna =
1542                        WMI_10_4_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA,
1543        .igmpmld_override = WMI_10_4_PDEV_PARAM_IGMPMLD_OVERRIDE,
1544        .igmpmld_tid = WMI_10_4_PDEV_PARAM_IGMPMLD_TID,
1545        .antenna_gain = WMI_10_4_PDEV_PARAM_ANTENNA_GAIN,
1546        .rx_filter = WMI_10_4_PDEV_PARAM_RX_FILTER,
1547        .set_mcast_to_ucast_tid = WMI_10_4_PDEV_SET_MCAST_TO_UCAST_TID,
1548        .proxy_sta_mode = WMI_10_4_PDEV_PARAM_PROXY_STA_MODE,
1549        .set_mcast2ucast_mode = WMI_10_4_PDEV_PARAM_SET_MCAST2UCAST_MODE,
1550        .set_mcast2ucast_buffer = WMI_10_4_PDEV_PARAM_SET_MCAST2UCAST_BUFFER,
1551        .remove_mcast2ucast_buffer =
1552                        WMI_10_4_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER,
1553        .peer_sta_ps_statechg_enable =
1554                        WMI_10_4_PDEV_PEER_STA_PS_STATECHG_ENABLE,
1555        .igmpmld_ac_override = WMI_10_4_PDEV_PARAM_IGMPMLD_AC_OVERRIDE,
1556        .block_interbss = WMI_10_4_PDEV_PARAM_BLOCK_INTERBSS,
1557        .set_disable_reset_cmdid = WMI_10_4_PDEV_PARAM_SET_DISABLE_RESET_CMDID,
1558        .set_msdu_ttl_cmdid = WMI_10_4_PDEV_PARAM_SET_MSDU_TTL_CMDID,
1559        .set_ppdu_duration_cmdid = WMI_10_4_PDEV_PARAM_SET_PPDU_DURATION_CMDID,
1560        .txbf_sound_period_cmdid = WMI_10_4_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID,
1561        .set_promisc_mode_cmdid = WMI_10_4_PDEV_PARAM_SET_PROMISC_MODE_CMDID,
1562        .set_burst_mode_cmdid = WMI_10_4_PDEV_PARAM_SET_BURST_MODE_CMDID,
1563        .en_stats = WMI_10_4_PDEV_PARAM_EN_STATS,
1564        .mu_group_policy = WMI_10_4_PDEV_PARAM_MU_GROUP_POLICY,
1565        .noise_detection = WMI_10_4_PDEV_PARAM_NOISE_DETECTION,
1566        .noise_threshold = WMI_10_4_PDEV_PARAM_NOISE_THRESHOLD,
1567        .dpd_enable = WMI_10_4_PDEV_PARAM_DPD_ENABLE,
1568        .set_mcast_bcast_echo = WMI_10_4_PDEV_PARAM_SET_MCAST_BCAST_ECHO,
1569        .atf_strict_sch = WMI_10_4_PDEV_PARAM_ATF_STRICT_SCH,
1570        .atf_sched_duration = WMI_10_4_PDEV_PARAM_ATF_SCHED_DURATION,
1571        .ant_plzn = WMI_10_4_PDEV_PARAM_ANT_PLZN,
1572        .mgmt_retry_limit = WMI_10_4_PDEV_PARAM_MGMT_RETRY_LIMIT,
1573        .sensitivity_level = WMI_10_4_PDEV_PARAM_SENSITIVITY_LEVEL,
1574        .signed_txpower_2g = WMI_10_4_PDEV_PARAM_SIGNED_TXPOWER_2G,
1575        .signed_txpower_5g = WMI_10_4_PDEV_PARAM_SIGNED_TXPOWER_5G,
1576        .enable_per_tid_amsdu = WMI_10_4_PDEV_PARAM_ENABLE_PER_TID_AMSDU,
1577        .enable_per_tid_ampdu = WMI_10_4_PDEV_PARAM_ENABLE_PER_TID_AMPDU,
1578        .cca_threshold = WMI_10_4_PDEV_PARAM_CCA_THRESHOLD,
1579        .rts_fixed_rate = WMI_10_4_PDEV_PARAM_RTS_FIXED_RATE,
1580        .pdev_reset = WMI_10_4_PDEV_PARAM_PDEV_RESET,
1581        .wapi_mbssid_offset = WMI_10_4_PDEV_PARAM_WAPI_MBSSID_OFFSET,
1582        .arp_srcaddr = WMI_10_4_PDEV_PARAM_ARP_SRCADDR,
1583        .arp_dstaddr = WMI_10_4_PDEV_PARAM_ARP_DSTADDR,
1584        .enable_btcoex = WMI_10_4_PDEV_PARAM_ENABLE_BTCOEX,
1585};
1586
1587static const struct wmi_peer_flags_map wmi_peer_flags_map = {
1588        .auth = WMI_PEER_AUTH,
1589        .qos = WMI_PEER_QOS,
1590        .need_ptk_4_way = WMI_PEER_NEED_PTK_4_WAY,
1591        .need_gtk_2_way = WMI_PEER_NEED_GTK_2_WAY,
1592        .apsd = WMI_PEER_APSD,
1593        .ht = WMI_PEER_HT,
1594        .bw40 = WMI_PEER_40MHZ,
1595        .stbc = WMI_PEER_STBC,
1596        .ldbc = WMI_PEER_LDPC,
1597        .dyn_mimops = WMI_PEER_DYN_MIMOPS,
1598        .static_mimops = WMI_PEER_STATIC_MIMOPS,
1599        .spatial_mux = WMI_PEER_SPATIAL_MUX,
1600        .vht = WMI_PEER_VHT,
1601        .bw80 = WMI_PEER_80MHZ,
1602        .vht_2g = WMI_PEER_VHT_2G,
1603        .pmf = WMI_PEER_PMF,
1604        .bw160 = WMI_PEER_160MHZ,
1605};
1606
1607static const struct wmi_peer_flags_map wmi_10x_peer_flags_map = {
1608        .auth = WMI_10X_PEER_AUTH,
1609        .qos = WMI_10X_PEER_QOS,
1610        .need_ptk_4_way = WMI_10X_PEER_NEED_PTK_4_WAY,
1611        .need_gtk_2_way = WMI_10X_PEER_NEED_GTK_2_WAY,
1612        .apsd = WMI_10X_PEER_APSD,
1613        .ht = WMI_10X_PEER_HT,
1614        .bw40 = WMI_10X_PEER_40MHZ,
1615        .stbc = WMI_10X_PEER_STBC,
1616        .ldbc = WMI_10X_PEER_LDPC,
1617        .dyn_mimops = WMI_10X_PEER_DYN_MIMOPS,
1618        .static_mimops = WMI_10X_PEER_STATIC_MIMOPS,
1619        .spatial_mux = WMI_10X_PEER_SPATIAL_MUX,
1620        .vht = WMI_10X_PEER_VHT,
1621        .bw80 = WMI_10X_PEER_80MHZ,
1622        .bw160 = WMI_10X_PEER_160MHZ,
1623};
1624
1625static const struct wmi_peer_flags_map wmi_10_2_peer_flags_map = {
1626        .auth = WMI_10_2_PEER_AUTH,
1627        .qos = WMI_10_2_PEER_QOS,
1628        .need_ptk_4_way = WMI_10_2_PEER_NEED_PTK_4_WAY,
1629        .need_gtk_2_way = WMI_10_2_PEER_NEED_GTK_2_WAY,
1630        .apsd = WMI_10_2_PEER_APSD,
1631        .ht = WMI_10_2_PEER_HT,
1632        .bw40 = WMI_10_2_PEER_40MHZ,
1633        .stbc = WMI_10_2_PEER_STBC,
1634        .ldbc = WMI_10_2_PEER_LDPC,
1635        .dyn_mimops = WMI_10_2_PEER_DYN_MIMOPS,
1636        .static_mimops = WMI_10_2_PEER_STATIC_MIMOPS,
1637        .spatial_mux = WMI_10_2_PEER_SPATIAL_MUX,
1638        .vht = WMI_10_2_PEER_VHT,
1639        .bw80 = WMI_10_2_PEER_80MHZ,
1640        .vht_2g = WMI_10_2_PEER_VHT_2G,
1641        .pmf = WMI_10_2_PEER_PMF,
1642        .bw160 = WMI_10_2_PEER_160MHZ,
1643};
1644
1645void ath10k_wmi_put_wmi_channel(struct wmi_channel *ch,
1646                                const struct wmi_channel_arg *arg)
1647{
1648        u32 flags = 0;
1649
1650        memset(ch, 0, sizeof(*ch));
1651
1652        if (arg->passive)
1653                flags |= WMI_CHAN_FLAG_PASSIVE;
1654        if (arg->allow_ibss)
1655                flags |= WMI_CHAN_FLAG_ADHOC_ALLOWED;
1656        if (arg->allow_ht)
1657                flags |= WMI_CHAN_FLAG_ALLOW_HT;
1658        if (arg->allow_vht)
1659                flags |= WMI_CHAN_FLAG_ALLOW_VHT;
1660        if (arg->ht40plus)
1661                flags |= WMI_CHAN_FLAG_HT40_PLUS;
1662        if (arg->chan_radar)
1663                flags |= WMI_CHAN_FLAG_DFS;
1664
1665        ch->mhz = __cpu_to_le32(arg->freq);
1666        ch->band_center_freq1 = __cpu_to_le32(arg->band_center_freq1);
1667        if (arg->mode == MODE_11AC_VHT80_80)
1668                ch->band_center_freq2 = __cpu_to_le32(arg->band_center_freq2);
1669        else
1670                ch->band_center_freq2 = 0;
1671        ch->min_power = arg->min_power;
1672        ch->max_power = arg->max_power;
1673        ch->reg_power = arg->max_reg_power;
1674        ch->antenna_max = arg->max_antenna_gain;
1675        ch->max_tx_power = arg->max_power;
1676
1677        /* mode & flags share storage */
1678        ch->mode = arg->mode;
1679        ch->flags |= __cpu_to_le32(flags);
1680}
1681
1682int ath10k_wmi_wait_for_service_ready(struct ath10k *ar)
1683{
1684        unsigned long time_left;
1685
1686        time_left = wait_for_completion_timeout(&ar->wmi.service_ready,
1687                                                WMI_SERVICE_READY_TIMEOUT_HZ);
1688        if (!time_left)
1689                return -ETIMEDOUT;
1690        return 0;
1691}
1692
1693int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar)
1694{
1695        unsigned long time_left;
1696
1697        time_left = wait_for_completion_timeout(&ar->wmi.unified_ready,
1698                                                WMI_UNIFIED_READY_TIMEOUT_HZ);
1699        if (!time_left)
1700                return -ETIMEDOUT;
1701        return 0;
1702}
1703
1704struct sk_buff *ath10k_wmi_alloc_skb(struct ath10k *ar, u32 len)
1705{
1706        struct sk_buff *skb;
1707        u32 round_len = roundup(len, 4);
1708
1709        skb = ath10k_htc_alloc_skb(ar, WMI_SKB_HEADROOM + round_len);
1710        if (!skb)
1711                return NULL;
1712
1713        skb_reserve(skb, WMI_SKB_HEADROOM);
1714        if (!IS_ALIGNED((unsigned long)skb->data, 4))
1715                ath10k_warn(ar, "Unaligned WMI skb\n");
1716
1717        skb_put(skb, round_len);
1718        memset(skb->data, 0, round_len);
1719
1720        return skb;
1721}
1722
1723static void ath10k_wmi_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb)
1724{
1725        dev_kfree_skb(skb);
1726}
1727
1728int ath10k_wmi_cmd_send_nowait(struct ath10k *ar, struct sk_buff *skb,
1729                               u32 cmd_id)
1730{
1731        struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb);
1732        struct wmi_cmd_hdr *cmd_hdr;
1733        int ret;
1734        u32 cmd = 0;
1735
1736        if (skb_push(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
1737                return -ENOMEM;
1738
1739        cmd |= SM(cmd_id, WMI_CMD_HDR_CMD_ID);
1740
1741        cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
1742        cmd_hdr->cmd_id = __cpu_to_le32(cmd);
1743
1744        memset(skb_cb, 0, sizeof(*skb_cb));
1745        ret = ath10k_htc_send(&ar->htc, ar->wmi.eid, skb);
1746        trace_ath10k_wmi_cmd(ar, cmd_id, skb->data, skb->len, ret);
1747
1748        if (ret)
1749                goto err_pull;
1750
1751        return 0;
1752
1753err_pull:
1754        skb_pull(skb, sizeof(struct wmi_cmd_hdr));
1755        return ret;
1756}
1757
1758static void ath10k_wmi_tx_beacon_nowait(struct ath10k_vif *arvif)
1759{
1760        struct ath10k *ar = arvif->ar;
1761        struct ath10k_skb_cb *cb;
1762        struct sk_buff *bcn;
1763        bool dtim_zero;
1764        bool deliver_cab;
1765        int ret;
1766
1767        spin_lock_bh(&ar->data_lock);
1768
1769        bcn = arvif->beacon;
1770
1771        if (!bcn)
1772                goto unlock;
1773
1774        cb = ATH10K_SKB_CB(bcn);
1775
1776        switch (arvif->beacon_state) {
1777        case ATH10K_BEACON_SENDING:
1778        case ATH10K_BEACON_SENT:
1779                break;
1780        case ATH10K_BEACON_SCHEDULED:
1781                arvif->beacon_state = ATH10K_BEACON_SENDING;
1782                spin_unlock_bh(&ar->data_lock);
1783
1784                dtim_zero = !!(cb->flags & ATH10K_SKB_F_DTIM_ZERO);
1785                deliver_cab = !!(cb->flags & ATH10K_SKB_F_DELIVER_CAB);
1786                ret = ath10k_wmi_beacon_send_ref_nowait(arvif->ar,
1787                                                        arvif->vdev_id,
1788                                                        bcn->data, bcn->len,
1789                                                        cb->paddr,
1790                                                        dtim_zero,
1791                                                        deliver_cab);
1792
1793                spin_lock_bh(&ar->data_lock);
1794
1795                if (ret == 0)
1796                        arvif->beacon_state = ATH10K_BEACON_SENT;
1797                else
1798                        arvif->beacon_state = ATH10K_BEACON_SCHEDULED;
1799        }
1800
1801unlock:
1802        spin_unlock_bh(&ar->data_lock);
1803}
1804
1805static void ath10k_wmi_tx_beacons_iter(void *data, u8 *mac,
1806                                       struct ieee80211_vif *vif)
1807{
1808        struct ath10k_vif *arvif = (void *)vif->drv_priv;
1809
1810        ath10k_wmi_tx_beacon_nowait(arvif);
1811}
1812
1813static void ath10k_wmi_tx_beacons_nowait(struct ath10k *ar)
1814{
1815        ieee80211_iterate_active_interfaces_atomic(ar->hw,
1816                                                   IEEE80211_IFACE_ITER_NORMAL,
1817                                                   ath10k_wmi_tx_beacons_iter,
1818                                                   NULL);
1819}
1820
1821static void ath10k_wmi_op_ep_tx_credits(struct ath10k *ar)
1822{
1823        /* try to send pending beacons first. they take priority */
1824        ath10k_wmi_tx_beacons_nowait(ar);
1825
1826        wake_up(&ar->wmi.tx_credits_wq);
1827}
1828
1829int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id)
1830{
1831        int ret = -EOPNOTSUPP;
1832
1833        might_sleep();
1834
1835        if (cmd_id == WMI_CMD_UNSUPPORTED) {
1836                ath10k_warn(ar, "wmi command %d is not supported by firmware\n",
1837                            cmd_id);
1838                return ret;
1839        }
1840
1841        wait_event_timeout(ar->wmi.tx_credits_wq, ({
1842                /* try to send pending beacons first. they take priority */
1843                ath10k_wmi_tx_beacons_nowait(ar);
1844
1845                ret = ath10k_wmi_cmd_send_nowait(ar, skb, cmd_id);
1846
1847                if (ret && test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags))
1848                        ret = -ESHUTDOWN;
1849
1850                (ret != -EAGAIN);
1851        }), 3 * HZ);
1852
1853        if (ret)
1854                dev_kfree_skb_any(skb);
1855
1856        return ret;
1857}
1858
1859static struct sk_buff *
1860ath10k_wmi_op_gen_mgmt_tx(struct ath10k *ar, struct sk_buff *msdu)
1861{
1862        struct ath10k_skb_cb *cb = ATH10K_SKB_CB(msdu);
1863        struct ath10k_vif *arvif;
1864        struct wmi_mgmt_tx_cmd *cmd;
1865        struct ieee80211_hdr *hdr;
1866        struct sk_buff *skb;
1867        int len;
1868        u32 vdev_id;
1869        u32 buf_len = msdu->len;
1870        u16 fc;
1871
1872        hdr = (struct ieee80211_hdr *)msdu->data;
1873        fc = le16_to_cpu(hdr->frame_control);
1874
1875        if (cb->vif) {
1876                arvif = (void *)cb->vif->drv_priv;
1877                vdev_id = arvif->vdev_id;
1878        } else {
1879                vdev_id = 0;
1880        }
1881
1882        if (WARN_ON_ONCE(!ieee80211_is_mgmt(hdr->frame_control)))
1883                return ERR_PTR(-EINVAL);
1884
1885        len = sizeof(cmd->hdr) + msdu->len;
1886
1887        if ((ieee80211_is_action(hdr->frame_control) ||
1888             ieee80211_is_deauth(hdr->frame_control) ||
1889             ieee80211_is_disassoc(hdr->frame_control)) &&
1890             ieee80211_has_protected(hdr->frame_control)) {
1891                len += IEEE80211_CCMP_MIC_LEN;
1892                buf_len += IEEE80211_CCMP_MIC_LEN;
1893        }
1894
1895        len = round_up(len, 4);
1896
1897        skb = ath10k_wmi_alloc_skb(ar, len);
1898        if (!skb)
1899                return ERR_PTR(-ENOMEM);
1900
1901        cmd = (struct wmi_mgmt_tx_cmd *)skb->data;
1902
1903        cmd->hdr.vdev_id = __cpu_to_le32(vdev_id);
1904        cmd->hdr.tx_rate = 0;
1905        cmd->hdr.tx_power = 0;
1906        cmd->hdr.buf_len = __cpu_to_le32(buf_len);
1907
1908        ether_addr_copy(cmd->hdr.peer_macaddr.addr, ieee80211_get_DA(hdr));
1909        memcpy(cmd->buf, msdu->data, msdu->len);
1910
1911        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi mgmt tx skb %pK len %d ftype %02x stype %02x\n",
1912                   msdu, skb->len, fc & IEEE80211_FCTL_FTYPE,
1913                   fc & IEEE80211_FCTL_STYPE);
1914        trace_ath10k_tx_hdr(ar, skb->data, skb->len);
1915        trace_ath10k_tx_payload(ar, skb->data, skb->len);
1916
1917        return skb;
1918}
1919
1920static void ath10k_wmi_event_scan_started(struct ath10k *ar)
1921{
1922        lockdep_assert_held(&ar->data_lock);
1923
1924        switch (ar->scan.state) {
1925        case ATH10K_SCAN_IDLE:
1926        case ATH10K_SCAN_RUNNING:
1927        case ATH10K_SCAN_ABORTING:
1928                ath10k_warn(ar, "received scan started event in an invalid scan state: %s (%d)\n",
1929                            ath10k_scan_state_str(ar->scan.state),
1930                            ar->scan.state);
1931                break;
1932        case ATH10K_SCAN_STARTING:
1933                ar->scan.state = ATH10K_SCAN_RUNNING;
1934
1935                if (ar->scan.is_roc)
1936                        ieee80211_ready_on_channel(ar->hw);
1937
1938                complete(&ar->scan.started);
1939                break;
1940        }
1941}
1942
1943static void ath10k_wmi_event_scan_start_failed(struct ath10k *ar)
1944{
1945        lockdep_assert_held(&ar->data_lock);
1946
1947        switch (ar->scan.state) {
1948        case ATH10K_SCAN_IDLE:
1949        case ATH10K_SCAN_RUNNING:
1950        case ATH10K_SCAN_ABORTING:
1951                ath10k_warn(ar, "received scan start failed event in an invalid scan state: %s (%d)\n",
1952                            ath10k_scan_state_str(ar->scan.state),
1953                            ar->scan.state);
1954                break;
1955        case ATH10K_SCAN_STARTING:
1956                complete(&ar->scan.started);
1957                __ath10k_scan_finish(ar);
1958                break;
1959        }
1960}
1961
1962static void ath10k_wmi_event_scan_completed(struct ath10k *ar)
1963{
1964        lockdep_assert_held(&ar->data_lock);
1965
1966        switch (ar->scan.state) {
1967        case ATH10K_SCAN_IDLE:
1968        case ATH10K_SCAN_STARTING:
1969                /* One suspected reason scan can be completed while starting is
1970                 * if firmware fails to deliver all scan events to the host,
1971                 * e.g. when transport pipe is full. This has been observed
1972                 * with spectral scan phyerr events starving wmi transport
1973                 * pipe. In such case the "scan completed" event should be (and
1974                 * is) ignored by the host as it may be just firmware's scan
1975                 * state machine recovering.
1976                 */
1977                ath10k_warn(ar, "received scan completed event in an invalid scan state: %s (%d)\n",
1978                            ath10k_scan_state_str(ar->scan.state),
1979                            ar->scan.state);
1980                break;
1981        case ATH10K_SCAN_RUNNING:
1982        case ATH10K_SCAN_ABORTING:
1983                __ath10k_scan_finish(ar);
1984                break;
1985        }
1986}
1987
1988static void ath10k_wmi_event_scan_bss_chan(struct ath10k *ar)
1989{
1990        lockdep_assert_held(&ar->data_lock);
1991
1992        switch (ar->scan.state) {
1993        case ATH10K_SCAN_IDLE:
1994        case ATH10K_SCAN_STARTING:
1995                ath10k_warn(ar, "received scan bss chan event in an invalid scan state: %s (%d)\n",
1996                            ath10k_scan_state_str(ar->scan.state),
1997                            ar->scan.state);
1998                break;
1999        case ATH10K_SCAN_RUNNING:
2000        case ATH10K_SCAN_ABORTING:
2001                ar->scan_channel = NULL;
2002                break;
2003        }
2004}
2005
2006static void ath10k_wmi_event_scan_foreign_chan(struct ath10k *ar, u32 freq)
2007{
2008        lockdep_assert_held(&ar->data_lock);
2009
2010        switch (ar->scan.state) {
2011        case ATH10K_SCAN_IDLE:
2012        case ATH10K_SCAN_STARTING:
2013                ath10k_warn(ar, "received scan foreign chan event in an invalid scan state: %s (%d)\n",
2014                            ath10k_scan_state_str(ar->scan.state),
2015                            ar->scan.state);
2016                break;
2017        case ATH10K_SCAN_RUNNING:
2018        case ATH10K_SCAN_ABORTING:
2019                ar->scan_channel = ieee80211_get_channel(ar->hw->wiphy, freq);
2020
2021                if (ar->scan.is_roc && ar->scan.roc_freq == freq)
2022                        complete(&ar->scan.on_channel);
2023                break;
2024        }
2025}
2026
2027static const char *
2028ath10k_wmi_event_scan_type_str(enum wmi_scan_event_type type,
2029                               enum wmi_scan_completion_reason reason)
2030{
2031        switch (type) {
2032        case WMI_SCAN_EVENT_STARTED:
2033                return "started";
2034        case WMI_SCAN_EVENT_COMPLETED:
2035                switch (reason) {
2036                case WMI_SCAN_REASON_COMPLETED:
2037                        return "completed";
2038                case WMI_SCAN_REASON_CANCELLED:
2039                        return "completed [cancelled]";
2040                case WMI_SCAN_REASON_PREEMPTED:
2041                        return "completed [preempted]";
2042                case WMI_SCAN_REASON_TIMEDOUT:
2043                        return "completed [timedout]";
2044                case WMI_SCAN_REASON_INTERNAL_FAILURE:
2045                        return "completed [internal err]";
2046                case WMI_SCAN_REASON_MAX:
2047                        break;
2048                }
2049                return "completed [unknown]";
2050        case WMI_SCAN_EVENT_BSS_CHANNEL:
2051                return "bss channel";
2052        case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
2053                return "foreign channel";
2054        case WMI_SCAN_EVENT_DEQUEUED:
2055                return "dequeued";
2056        case WMI_SCAN_EVENT_PREEMPTED:
2057                return "preempted";
2058        case WMI_SCAN_EVENT_START_FAILED:
2059                return "start failed";
2060        case WMI_SCAN_EVENT_RESTARTED:
2061                return "restarted";
2062        case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
2063                return "foreign channel exit";
2064        default:
2065                return "unknown";
2066        }
2067}
2068
2069static int ath10k_wmi_op_pull_scan_ev(struct ath10k *ar, struct sk_buff *skb,
2070                                      struct wmi_scan_ev_arg *arg)
2071{
2072        struct wmi_scan_event *ev = (void *)skb->data;
2073
2074        if (skb->len < sizeof(*ev))
2075                return -EPROTO;
2076
2077        skb_pull(skb, sizeof(*ev));
2078        arg->event_type = ev->event_type;
2079        arg->reason = ev->reason;
2080        arg->channel_freq = ev->channel_freq;
2081        arg->scan_req_id = ev->scan_req_id;
2082        arg->scan_id = ev->scan_id;
2083        arg->vdev_id = ev->vdev_id;
2084
2085        return 0;
2086}
2087
2088int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb)
2089{
2090        struct wmi_scan_ev_arg arg = {};
2091        enum wmi_scan_event_type event_type;
2092        enum wmi_scan_completion_reason reason;
2093        u32 freq;
2094        u32 req_id;
2095        u32 scan_id;
2096        u32 vdev_id;
2097        int ret;
2098
2099        ret = ath10k_wmi_pull_scan(ar, skb, &arg);
2100        if (ret) {
2101                ath10k_warn(ar, "failed to parse scan event: %d\n", ret);
2102                return ret;
2103        }
2104
2105        event_type = __le32_to_cpu(arg.event_type);
2106        reason = __le32_to_cpu(arg.reason);
2107        freq = __le32_to_cpu(arg.channel_freq);
2108        req_id = __le32_to_cpu(arg.scan_req_id);
2109        scan_id = __le32_to_cpu(arg.scan_id);
2110        vdev_id = __le32_to_cpu(arg.vdev_id);
2111
2112        spin_lock_bh(&ar->data_lock);
2113
2114        ath10k_dbg(ar, ATH10K_DBG_WMI,
2115                   "scan event %s type %d reason %d freq %d req_id %d scan_id %d vdev_id %d state %s (%d)\n",
2116                   ath10k_wmi_event_scan_type_str(event_type, reason),
2117                   event_type, reason, freq, req_id, scan_id, vdev_id,
2118                   ath10k_scan_state_str(ar->scan.state), ar->scan.state);
2119
2120        switch (event_type) {
2121        case WMI_SCAN_EVENT_STARTED:
2122                ath10k_wmi_event_scan_started(ar);
2123                break;
2124        case WMI_SCAN_EVENT_COMPLETED:
2125                ath10k_wmi_event_scan_completed(ar);
2126                break;
2127        case WMI_SCAN_EVENT_BSS_CHANNEL:
2128                ath10k_wmi_event_scan_bss_chan(ar);
2129                break;
2130        case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
2131                ath10k_wmi_event_scan_foreign_chan(ar, freq);
2132                break;
2133        case WMI_SCAN_EVENT_START_FAILED:
2134                ath10k_warn(ar, "received scan start failure event\n");
2135                ath10k_wmi_event_scan_start_failed(ar);
2136                break;
2137        case WMI_SCAN_EVENT_DEQUEUED:
2138        case WMI_SCAN_EVENT_PREEMPTED:
2139        case WMI_SCAN_EVENT_RESTARTED:
2140        case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
2141        default:
2142                break;
2143        }
2144
2145        spin_unlock_bh(&ar->data_lock);
2146        return 0;
2147}
2148
2149/* If keys are configured, HW decrypts all frames
2150 * with protected bit set. Mark such frames as decrypted.
2151 */
2152static void ath10k_wmi_handle_wep_reauth(struct ath10k *ar,
2153                                         struct sk_buff *skb,
2154                                         struct ieee80211_rx_status *status)
2155{
2156        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2157        unsigned int hdrlen;
2158        bool peer_key;
2159        u8 *addr, keyidx;
2160
2161        if (!ieee80211_is_auth(hdr->frame_control) ||
2162            !ieee80211_has_protected(hdr->frame_control))
2163                return;
2164
2165        hdrlen = ieee80211_hdrlen(hdr->frame_control);
2166        if (skb->len < (hdrlen + IEEE80211_WEP_IV_LEN))
2167                return;
2168
2169        keyidx = skb->data[hdrlen + (IEEE80211_WEP_IV_LEN - 1)] >> WEP_KEYID_SHIFT;
2170        addr = ieee80211_get_SA(hdr);
2171
2172        spin_lock_bh(&ar->data_lock);
2173        peer_key = ath10k_mac_is_peer_wep_key_set(ar, addr, keyidx);
2174        spin_unlock_bh(&ar->data_lock);
2175
2176        if (peer_key) {
2177                ath10k_dbg(ar, ATH10K_DBG_MAC,
2178                           "mac wep key present for peer %pM\n", addr);
2179                status->flag |= RX_FLAG_DECRYPTED;
2180        }
2181}
2182
2183static int ath10k_wmi_op_pull_mgmt_rx_ev(struct ath10k *ar, struct sk_buff *skb,
2184                                         struct wmi_mgmt_rx_ev_arg *arg)
2185{
2186        struct wmi_mgmt_rx_event_v1 *ev_v1;
2187        struct wmi_mgmt_rx_event_v2 *ev_v2;
2188        struct wmi_mgmt_rx_hdr_v1 *ev_hdr;
2189        struct wmi_mgmt_rx_ext_info *ext_info;
2190        size_t pull_len;
2191        u32 msdu_len;
2192        u32 len;
2193
2194        if (test_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX,
2195                     ar->running_fw->fw_file.fw_features)) {
2196                ev_v2 = (struct wmi_mgmt_rx_event_v2 *)skb->data;
2197                ev_hdr = &ev_v2->hdr.v1;
2198                pull_len = sizeof(*ev_v2);
2199        } else {
2200                ev_v1 = (struct wmi_mgmt_rx_event_v1 *)skb->data;
2201                ev_hdr = &ev_v1->hdr;
2202                pull_len = sizeof(*ev_v1);
2203        }
2204
2205        if (skb->len < pull_len)
2206                return -EPROTO;
2207
2208        skb_pull(skb, pull_len);
2209        arg->channel = ev_hdr->channel;
2210        arg->buf_len = ev_hdr->buf_len;
2211        arg->status = ev_hdr->status;
2212        arg->snr = ev_hdr->snr;
2213        arg->phy_mode = ev_hdr->phy_mode;
2214        arg->rate = ev_hdr->rate;
2215
2216        msdu_len = __le32_to_cpu(arg->buf_len);
2217        if (skb->len < msdu_len)
2218                return -EPROTO;
2219
2220        if (le32_to_cpu(arg->status) & WMI_RX_STATUS_EXT_INFO) {
2221                len = ALIGN(le32_to_cpu(arg->buf_len), 4);
2222                ext_info = (struct wmi_mgmt_rx_ext_info *)(skb->data + len);
2223                memcpy(&arg->ext_info, ext_info,
2224                       sizeof(struct wmi_mgmt_rx_ext_info));
2225        }
2226        /* the WMI buffer might've ended up being padded to 4 bytes due to HTC
2227         * trailer with credit update. Trim the excess garbage.
2228         */
2229        skb_trim(skb, msdu_len);
2230
2231        return 0;
2232}
2233
2234static int ath10k_wmi_10_4_op_pull_mgmt_rx_ev(struct ath10k *ar,
2235                                              struct sk_buff *skb,
2236                                              struct wmi_mgmt_rx_ev_arg *arg)
2237{
2238        struct wmi_10_4_mgmt_rx_event *ev;
2239        struct wmi_10_4_mgmt_rx_hdr *ev_hdr;
2240        size_t pull_len;
2241        u32 msdu_len;
2242        struct wmi_mgmt_rx_ext_info *ext_info;
2243        u32 len;
2244
2245        ev = (struct wmi_10_4_mgmt_rx_event *)skb->data;
2246        ev_hdr = &ev->hdr;
2247        pull_len = sizeof(*ev);
2248
2249        if (skb->len < pull_len)
2250                return -EPROTO;
2251
2252        skb_pull(skb, pull_len);
2253        arg->channel = ev_hdr->channel;
2254        arg->buf_len = ev_hdr->buf_len;
2255        arg->status = ev_hdr->status;
2256        arg->snr = ev_hdr->snr;
2257        arg->phy_mode = ev_hdr->phy_mode;
2258        arg->rate = ev_hdr->rate;
2259
2260        msdu_len = __le32_to_cpu(arg->buf_len);
2261        if (skb->len < msdu_len)
2262                return -EPROTO;
2263
2264        if (le32_to_cpu(arg->status) & WMI_RX_STATUS_EXT_INFO) {
2265                len = ALIGN(le32_to_cpu(arg->buf_len), 4);
2266                ext_info = (struct wmi_mgmt_rx_ext_info *)(skb->data + len);
2267                memcpy(&arg->ext_info, ext_info,
2268                       sizeof(struct wmi_mgmt_rx_ext_info));
2269        }
2270
2271        /* Make sure bytes added for padding are removed. */
2272        skb_trim(skb, msdu_len);
2273
2274        return 0;
2275}
2276
2277static bool ath10k_wmi_rx_is_decrypted(struct ath10k *ar,
2278                                       struct ieee80211_hdr *hdr)
2279{
2280        if (!ieee80211_has_protected(hdr->frame_control))
2281                return false;
2282
2283        /* FW delivers WEP Shared Auth frame with Protected Bit set and
2284         * encrypted payload. However in case of PMF it delivers decrypted
2285         * frames with Protected Bit set.
2286         */
2287        if (ieee80211_is_auth(hdr->frame_control))
2288                return false;
2289
2290        /* qca99x0 based FW delivers broadcast or multicast management frames
2291         * (ex: group privacy action frames in mesh) as encrypted payload.
2292         */
2293        if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) &&
2294            ar->hw_params.sw_decrypt_mcast_mgmt)
2295                return false;
2296
2297        return true;
2298}
2299
2300int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
2301{
2302        struct wmi_mgmt_rx_ev_arg arg = {};
2303        struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
2304        struct ieee80211_hdr *hdr;
2305        struct ieee80211_supported_band *sband;
2306        u32 rx_status;
2307        u32 channel;
2308        u32 phy_mode;
2309        u32 snr;
2310        u32 rate;
2311        u32 buf_len;
2312        u16 fc;
2313        int ret;
2314
2315        ret = ath10k_wmi_pull_mgmt_rx(ar, skb, &arg);
2316        if (ret) {
2317                ath10k_warn(ar, "failed to parse mgmt rx event: %d\n", ret);
2318                dev_kfree_skb(skb);
2319                return ret;
2320        }
2321
2322        channel = __le32_to_cpu(arg.channel);
2323        buf_len = __le32_to_cpu(arg.buf_len);
2324        rx_status = __le32_to_cpu(arg.status);
2325        snr = __le32_to_cpu(arg.snr);
2326        phy_mode = __le32_to_cpu(arg.phy_mode);
2327        rate = __le32_to_cpu(arg.rate);
2328
2329        memset(status, 0, sizeof(*status));
2330
2331        ath10k_dbg(ar, ATH10K_DBG_MGMT,
2332                   "event mgmt rx status %08x\n", rx_status);
2333
2334        if ((test_bit(ATH10K_CAC_RUNNING, &ar->dev_flags)) ||
2335            (rx_status & (WMI_RX_STATUS_ERR_DECRYPT |
2336            WMI_RX_STATUS_ERR_KEY_CACHE_MISS | WMI_RX_STATUS_ERR_CRC))) {
2337                dev_kfree_skb(skb);
2338                return 0;
2339        }
2340
2341        if (rx_status & WMI_RX_STATUS_ERR_MIC)
2342                status->flag |= RX_FLAG_MMIC_ERROR;
2343
2344        if (rx_status & WMI_RX_STATUS_EXT_INFO) {
2345                status->mactime =
2346                        __le64_to_cpu(arg.ext_info.rx_mac_timestamp);
2347                status->flag |= RX_FLAG_MACTIME_END;
2348        }
2349        /* Hardware can Rx CCK rates on 5GHz. In that case phy_mode is set to
2350         * MODE_11B. This means phy_mode is not a reliable source for the band
2351         * of mgmt rx.
2352         */
2353        if (channel >= 1 && channel <= 14) {
2354                status->band = NL80211_BAND_2GHZ;
2355        } else if (channel >= 36 && channel <= 169) {
2356                status->band = NL80211_BAND_5GHZ;
2357        } else {
2358                /* Shouldn't happen unless list of advertised channels to
2359                 * mac80211 has been changed.
2360                 */
2361                WARN_ON_ONCE(1);
2362                dev_kfree_skb(skb);
2363                return 0;
2364        }
2365
2366        if (phy_mode == MODE_11B && status->band == NL80211_BAND_5GHZ)
2367                ath10k_dbg(ar, ATH10K_DBG_MGMT, "wmi mgmt rx 11b (CCK) on 5GHz\n");
2368
2369        sband = &ar->mac.sbands[status->band];
2370
2371        status->freq = ieee80211_channel_to_frequency(channel, status->band);
2372        status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR;
2373        status->rate_idx = ath10k_mac_bitrate_to_idx(sband, rate / 100);
2374
2375        hdr = (struct ieee80211_hdr *)skb->data;
2376        fc = le16_to_cpu(hdr->frame_control);
2377
2378        /* Firmware is guaranteed to report all essential management frames via
2379         * WMI while it can deliver some extra via HTT. Since there can be
2380         * duplicates split the reporting wrt monitor/sniffing.
2381         */
2382        status->flag |= RX_FLAG_SKIP_MONITOR;
2383
2384        ath10k_wmi_handle_wep_reauth(ar, skb, status);
2385
2386        if (ath10k_wmi_rx_is_decrypted(ar, hdr)) {
2387                status->flag |= RX_FLAG_DECRYPTED;
2388
2389                if (!ieee80211_is_action(hdr->frame_control) &&
2390                    !ieee80211_is_deauth(hdr->frame_control) &&
2391                    !ieee80211_is_disassoc(hdr->frame_control)) {
2392                        status->flag |= RX_FLAG_IV_STRIPPED |
2393                                        RX_FLAG_MMIC_STRIPPED;
2394                        hdr->frame_control = __cpu_to_le16(fc &
2395                                        ~IEEE80211_FCTL_PROTECTED);
2396                }
2397        }
2398
2399        if (ieee80211_is_beacon(hdr->frame_control))
2400                ath10k_mac_handle_beacon(ar, skb);
2401
2402        ath10k_dbg(ar, ATH10K_DBG_MGMT,
2403                   "event mgmt rx skb %pK len %d ftype %02x stype %02x\n",
2404                   skb, skb->len,
2405                   fc & IEEE80211_FCTL_FTYPE, fc & IEEE80211_FCTL_STYPE);
2406
2407        ath10k_dbg(ar, ATH10K_DBG_MGMT,
2408                   "event mgmt rx freq %d band %d snr %d, rate_idx %d\n",
2409                   status->freq, status->band, status->signal,
2410                   status->rate_idx);
2411
2412        ieee80211_rx(ar->hw, skb);
2413        return 0;
2414}
2415
2416static int freq_to_idx(struct ath10k *ar, int freq)
2417{
2418        struct ieee80211_supported_band *sband;
2419        int band, ch, idx = 0;
2420
2421        for (band = NL80211_BAND_2GHZ; band < NUM_NL80211_BANDS; band++) {
2422                sband = ar->hw->wiphy->bands[band];
2423                if (!sband)
2424                        continue;
2425
2426                for (ch = 0; ch < sband->n_channels; ch++, idx++)
2427                        if (sband->channels[ch].center_freq == freq)
2428                                goto exit;
2429        }
2430
2431exit:
2432        return idx;
2433}
2434
2435static int ath10k_wmi_op_pull_ch_info_ev(struct ath10k *ar, struct sk_buff *skb,
2436                                         struct wmi_ch_info_ev_arg *arg)
2437{
2438        struct wmi_chan_info_event *ev = (void *)skb->data;
2439
2440        if (skb->len < sizeof(*ev))
2441                return -EPROTO;
2442
2443        skb_pull(skb, sizeof(*ev));
2444        arg->err_code = ev->err_code;
2445        arg->freq = ev->freq;
2446        arg->cmd_flags = ev->cmd_flags;
2447        arg->noise_floor = ev->noise_floor;
2448        arg->rx_clear_count = ev->rx_clear_count;
2449        arg->cycle_count = ev->cycle_count;
2450
2451        return 0;
2452}
2453
2454static int ath10k_wmi_10_4_op_pull_ch_info_ev(struct ath10k *ar,
2455                                              struct sk_buff *skb,
2456                                              struct wmi_ch_info_ev_arg *arg)
2457{
2458        struct wmi_10_4_chan_info_event *ev = (void *)skb->data;
2459
2460        if (skb->len < sizeof(*ev))
2461                return -EPROTO;
2462
2463        skb_pull(skb, sizeof(*ev));
2464        arg->err_code = ev->err_code;
2465        arg->freq = ev->freq;
2466        arg->cmd_flags = ev->cmd_flags;
2467        arg->noise_floor = ev->noise_floor;
2468        arg->rx_clear_count = ev->rx_clear_count;
2469        arg->cycle_count = ev->cycle_count;
2470        arg->chan_tx_pwr_range = ev->chan_tx_pwr_range;
2471        arg->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
2472        arg->rx_frame_count = ev->rx_frame_count;
2473
2474        return 0;
2475}
2476
2477void ath10k_wmi_event_chan_info(struct ath10k *ar, struct sk_buff *skb)
2478{
2479        struct wmi_ch_info_ev_arg arg = {};
2480        struct survey_info *survey;
2481        u32 err_code, freq, cmd_flags, noise_floor, rx_clear_count, cycle_count;
2482        int idx, ret;
2483
2484        ret = ath10k_wmi_pull_ch_info(ar, skb, &arg);
2485        if (ret) {
2486                ath10k_warn(ar, "failed to parse chan info event: %d\n", ret);
2487                return;
2488        }
2489
2490        err_code = __le32_to_cpu(arg.err_code);
2491        freq = __le32_to_cpu(arg.freq);
2492        cmd_flags = __le32_to_cpu(arg.cmd_flags);
2493        noise_floor = __le32_to_cpu(arg.noise_floor);
2494        rx_clear_count = __le32_to_cpu(arg.rx_clear_count);
2495        cycle_count = __le32_to_cpu(arg.cycle_count);
2496
2497        ath10k_dbg(ar, ATH10K_DBG_WMI,
2498                   "chan info err_code %d freq %d cmd_flags %d noise_floor %d rx_clear_count %d cycle_count %d\n",
2499                   err_code, freq, cmd_flags, noise_floor, rx_clear_count,
2500                   cycle_count);
2501
2502        spin_lock_bh(&ar->data_lock);
2503
2504        switch (ar->scan.state) {
2505        case ATH10K_SCAN_IDLE:
2506        case ATH10K_SCAN_STARTING:
2507                ath10k_warn(ar, "received chan info event without a scan request, ignoring\n");
2508                goto exit;
2509        case ATH10K_SCAN_RUNNING:
2510        case ATH10K_SCAN_ABORTING:
2511                break;
2512        }
2513
2514        idx = freq_to_idx(ar, freq);
2515        if (idx >= ARRAY_SIZE(ar->survey)) {
2516                ath10k_warn(ar, "chan info: invalid frequency %d (idx %d out of bounds)\n",
2517                            freq, idx);
2518                goto exit;
2519        }
2520
2521        if (cmd_flags & WMI_CHAN_INFO_FLAG_COMPLETE) {
2522                if (ar->ch_info_can_report_survey) {
2523                        survey = &ar->survey[idx];
2524                        survey->noise = noise_floor;
2525                        survey->filled = SURVEY_INFO_NOISE_DBM;
2526
2527                        ath10k_hw_fill_survey_time(ar,
2528                                                   survey,
2529                                                   cycle_count,
2530                                                   rx_clear_count,
2531                                                   ar->survey_last_cycle_count,
2532                                                   ar->survey_last_rx_clear_count);
2533                }
2534
2535                ar->ch_info_can_report_survey = false;
2536        } else {
2537                ar->ch_info_can_report_survey = true;
2538        }
2539
2540        if (!(cmd_flags & WMI_CHAN_INFO_FLAG_PRE_COMPLETE)) {
2541                ar->survey_last_rx_clear_count = rx_clear_count;
2542                ar->survey_last_cycle_count = cycle_count;
2543        }
2544
2545exit:
2546        spin_unlock_bh(&ar->data_lock);
2547}
2548
2549void ath10k_wmi_event_echo(struct ath10k *ar, struct sk_buff *skb)
2550{
2551        struct wmi_echo_ev_arg arg = {};
2552        int ret;
2553
2554        ret = ath10k_wmi_pull_echo_ev(ar, skb, &arg);
2555        if (ret) {
2556                ath10k_warn(ar, "failed to parse echo: %d\n", ret);
2557                return;
2558        }
2559
2560        ath10k_dbg(ar, ATH10K_DBG_WMI,
2561                   "wmi event echo value 0x%08x\n",
2562                   le32_to_cpu(arg.value));
2563
2564        if (le32_to_cpu(arg.value) == ATH10K_WMI_BARRIER_ECHO_ID)
2565                complete(&ar->wmi.barrier);
2566}
2567
2568int ath10k_wmi_event_debug_mesg(struct ath10k *ar, struct sk_buff *skb)
2569{
2570        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event debug mesg len %d\n",
2571                   skb->len);
2572
2573        trace_ath10k_wmi_dbglog(ar, skb->data, skb->len);
2574
2575        return 0;
2576}
2577
2578void ath10k_wmi_pull_pdev_stats_base(const struct wmi_pdev_stats_base *src,
2579                                     struct ath10k_fw_stats_pdev *dst)
2580{
2581        dst->ch_noise_floor = __le32_to_cpu(src->chan_nf);
2582        dst->tx_frame_count = __le32_to_cpu(src->tx_frame_count);
2583        dst->rx_frame_count = __le32_to_cpu(src->rx_frame_count);
2584        dst->rx_clear_count = __le32_to_cpu(src->rx_clear_count);
2585        dst->cycle_count = __le32_to_cpu(src->cycle_count);
2586        dst->phy_err_count = __le32_to_cpu(src->phy_err_count);
2587        dst->chan_tx_power = __le32_to_cpu(src->chan_tx_pwr);
2588}
2589
2590void ath10k_wmi_pull_pdev_stats_tx(const struct wmi_pdev_stats_tx *src,
2591                                   struct ath10k_fw_stats_pdev *dst)
2592{
2593        dst->comp_queued = __le32_to_cpu(src->comp_queued);
2594        dst->comp_delivered = __le32_to_cpu(src->comp_delivered);
2595        dst->msdu_enqued = __le32_to_cpu(src->msdu_enqued);
2596        dst->mpdu_enqued = __le32_to_cpu(src->mpdu_enqued);
2597        dst->wmm_drop = __le32_to_cpu(src->wmm_drop);
2598        dst->local_enqued = __le32_to_cpu(src->local_enqued);
2599        dst->local_freed = __le32_to_cpu(src->local_freed);
2600        dst->hw_queued = __le32_to_cpu(src->hw_queued);
2601        dst->hw_reaped = __le32_to_cpu(src->hw_reaped);
2602        dst->underrun = __le32_to_cpu(src->underrun);
2603        dst->tx_abort = __le32_to_cpu(src->tx_abort);
2604        dst->mpdus_requed = __le32_to_cpu(src->mpdus_requed);
2605        dst->tx_ko = __le32_to_cpu(src->tx_ko);
2606        dst->data_rc = __le32_to_cpu(src->data_rc);
2607        dst->self_triggers = __le32_to_cpu(src->self_triggers);
2608        dst->sw_retry_failure = __le32_to_cpu(src->sw_retry_failure);
2609        dst->illgl_rate_phy_err = __le32_to_cpu(src->illgl_rate_phy_err);
2610        dst->pdev_cont_xretry = __le32_to_cpu(src->pdev_cont_xretry);
2611        dst->pdev_tx_timeout = __le32_to_cpu(src->pdev_tx_timeout);
2612        dst->pdev_resets = __le32_to_cpu(src->pdev_resets);
2613        dst->phy_underrun = __le32_to_cpu(src->phy_underrun);
2614        dst->txop_ovf = __le32_to_cpu(src->txop_ovf);
2615}
2616
2617static void
2618ath10k_wmi_10_4_pull_pdev_stats_tx(const struct wmi_10_4_pdev_stats_tx *src,
2619                                   struct ath10k_fw_stats_pdev *dst)
2620{
2621        dst->comp_queued = __le32_to_cpu(src->comp_queued);
2622        dst->comp_delivered = __le32_to_cpu(src->comp_delivered);
2623        dst->msdu_enqued = __le32_to_cpu(src->msdu_enqued);
2624        dst->mpdu_enqued = __le32_to_cpu(src->mpdu_enqued);
2625        dst->wmm_drop = __le32_to_cpu(src->wmm_drop);
2626        dst->local_enqued = __le32_to_cpu(src->local_enqued);
2627        dst->local_freed = __le32_to_cpu(src->local_freed);
2628        dst->hw_queued = __le32_to_cpu(src->hw_queued);
2629        dst->hw_reaped = __le32_to_cpu(src->hw_reaped);
2630        dst->underrun = __le32_to_cpu(src->underrun);
2631        dst->tx_abort = __le32_to_cpu(src->tx_abort);
2632        dst->mpdus_requed = __le32_to_cpu(src->mpdus_requed);
2633        dst->tx_ko = __le32_to_cpu(src->tx_ko);
2634        dst->data_rc = __le32_to_cpu(src->data_rc);
2635        dst->self_triggers = __le32_to_cpu(src->self_triggers);
2636        dst->sw_retry_failure = __le32_to_cpu(src->sw_retry_failure);
2637        dst->illgl_rate_phy_err = __le32_to_cpu(src->illgl_rate_phy_err);
2638        dst->pdev_cont_xretry = __le32_to_cpu(src->pdev_cont_xretry);
2639        dst->pdev_tx_timeout = __le32_to_cpu(src->pdev_tx_timeout);
2640        dst->pdev_resets = __le32_to_cpu(src->pdev_resets);
2641        dst->phy_underrun = __le32_to_cpu(src->phy_underrun);
2642        dst->txop_ovf = __le32_to_cpu(src->txop_ovf);
2643        dst->hw_paused = __le32_to_cpu(src->hw_paused);
2644        dst->seq_posted = __le32_to_cpu(src->seq_posted);
2645        dst->seq_failed_queueing =
2646                __le32_to_cpu(src->seq_failed_queueing);
2647        dst->seq_completed = __le32_to_cpu(src->seq_completed);
2648        dst->seq_restarted = __le32_to_cpu(src->seq_restarted);
2649        dst->mu_seq_posted = __le32_to_cpu(src->mu_seq_posted);
2650        dst->mpdus_sw_flush = __le32_to_cpu(src->mpdus_sw_flush);
2651        dst->mpdus_hw_filter = __le32_to_cpu(src->mpdus_hw_filter);
2652        dst->mpdus_truncated = __le32_to_cpu(src->mpdus_truncated);
2653        dst->mpdus_ack_failed = __le32_to_cpu(src->mpdus_ack_failed);
2654        dst->mpdus_hw_filter = __le32_to_cpu(src->mpdus_hw_filter);
2655        dst->mpdus_expired = __le32_to_cpu(src->mpdus_expired);
2656}
2657
2658void ath10k_wmi_pull_pdev_stats_rx(const struct wmi_pdev_stats_rx *src,
2659                                   struct ath10k_fw_stats_pdev *dst)
2660{
2661        dst->mid_ppdu_route_change = __le32_to_cpu(src->mid_ppdu_route_change);
2662        dst->status_rcvd = __le32_to_cpu(src->status_rcvd);
2663        dst->r0_frags = __le32_to_cpu(src->r0_frags);
2664        dst->r1_frags = __le32_to_cpu(src->r1_frags);
2665        dst->r2_frags = __le32_to_cpu(src->r2_frags);
2666        dst->r3_frags = __le32_to_cpu(src->r3_frags);
2667        dst->htt_msdus = __le32_to_cpu(src->htt_msdus);
2668        dst->htt_mpdus = __le32_to_cpu(src->htt_mpdus);
2669        dst->loc_msdus = __le32_to_cpu(src->loc_msdus);
2670        dst->loc_mpdus = __le32_to_cpu(src->loc_mpdus);
2671        dst->oversize_amsdu = __le32_to_cpu(src->oversize_amsdu);
2672        dst->phy_errs = __le32_to_cpu(src->phy_errs);
2673        dst->phy_err_drop = __le32_to_cpu(src->phy_err_drop);
2674        dst->mpdu_errs = __le32_to_cpu(src->mpdu_errs);
2675}
2676
2677void ath10k_wmi_pull_pdev_stats_extra(const struct wmi_pdev_stats_extra *src,
2678                                      struct ath10k_fw_stats_pdev *dst)
2679{
2680        dst->ack_rx_bad = __le32_to_cpu(src->ack_rx_bad);
2681        dst->rts_bad = __le32_to_cpu(src->rts_bad);
2682        dst->rts_good = __le32_to_cpu(src->rts_good);
2683        dst->fcs_bad = __le32_to_cpu(src->fcs_bad);
2684        dst->no_beacons = __le32_to_cpu(src->no_beacons);
2685        dst->mib_int_count = __le32_to_cpu(src->mib_int_count);
2686}
2687
2688void ath10k_wmi_pull_peer_stats(const struct wmi_peer_stats *src,
2689                                struct ath10k_fw_stats_peer *dst)
2690{
2691        ether_addr_copy(dst->peer_macaddr, src->peer_macaddr.addr);
2692        dst->peer_rssi = __le32_to_cpu(src->peer_rssi);
2693        dst->peer_tx_rate = __le32_to_cpu(src->peer_tx_rate);
2694}
2695
2696static void
2697ath10k_wmi_10_4_pull_peer_stats(const struct wmi_10_4_peer_stats *src,
2698                                struct ath10k_fw_stats_peer *dst)
2699{
2700        ether_addr_copy(dst->peer_macaddr, src->peer_macaddr.addr);
2701        dst->peer_rssi = __le32_to_cpu(src->peer_rssi);
2702        dst->peer_tx_rate = __le32_to_cpu(src->peer_tx_rate);
2703        dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
2704}
2705
2706static int ath10k_wmi_main_op_pull_fw_stats(struct ath10k *ar,
2707                                            struct sk_buff *skb,
2708                                            struct ath10k_fw_stats *stats)
2709{
2710        const struct wmi_stats_event *ev = (void *)skb->data;
2711        u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
2712        int i;
2713
2714        if (!skb_pull(skb, sizeof(*ev)))
2715                return -EPROTO;
2716
2717        num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2718        num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2719        num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2720
2721        for (i = 0; i < num_pdev_stats; i++) {
2722                const struct wmi_pdev_stats *src;
2723                struct ath10k_fw_stats_pdev *dst;
2724
2725                src = (void *)skb->data;
2726                if (!skb_pull(skb, sizeof(*src)))
2727                        return -EPROTO;
2728
2729                dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2730                if (!dst)
2731                        continue;
2732
2733                ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2734                ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2735                ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2736
2737                list_add_tail(&dst->list, &stats->pdevs);
2738        }
2739
2740        /* fw doesn't implement vdev stats */
2741
2742        for (i = 0; i < num_peer_stats; i++) {
2743                const struct wmi_peer_stats *src;
2744                struct ath10k_fw_stats_peer *dst;
2745
2746                src = (void *)skb->data;
2747                if (!skb_pull(skb, sizeof(*src)))
2748                        return -EPROTO;
2749
2750                dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2751                if (!dst)
2752                        continue;
2753
2754                ath10k_wmi_pull_peer_stats(src, dst);
2755                list_add_tail(&dst->list, &stats->peers);
2756        }
2757
2758        return 0;
2759}
2760
2761static int ath10k_wmi_10x_op_pull_fw_stats(struct ath10k *ar,
2762                                           struct sk_buff *skb,
2763                                           struct ath10k_fw_stats *stats)
2764{
2765        const struct wmi_stats_event *ev = (void *)skb->data;
2766        u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
2767        int i;
2768
2769        if (!skb_pull(skb, sizeof(*ev)))
2770                return -EPROTO;
2771
2772        num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2773        num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2774        num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2775
2776        for (i = 0; i < num_pdev_stats; i++) {
2777                const struct wmi_10x_pdev_stats *src;
2778                struct ath10k_fw_stats_pdev *dst;
2779
2780                src = (void *)skb->data;
2781                if (!skb_pull(skb, sizeof(*src)))
2782                        return -EPROTO;
2783
2784                dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2785                if (!dst)
2786                        continue;
2787
2788                ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2789                ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2790                ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2791                ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2792
2793                list_add_tail(&dst->list, &stats->pdevs);
2794        }
2795
2796        /* fw doesn't implement vdev stats */
2797
2798        for (i = 0; i < num_peer_stats; i++) {
2799                const struct wmi_10x_peer_stats *src;
2800                struct ath10k_fw_stats_peer *dst;
2801
2802                src = (void *)skb->data;
2803                if (!skb_pull(skb, sizeof(*src)))
2804                        return -EPROTO;
2805
2806                dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2807                if (!dst)
2808                        continue;
2809
2810                ath10k_wmi_pull_peer_stats(&src->old, dst);
2811
2812                dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
2813
2814                list_add_tail(&dst->list, &stats->peers);
2815        }
2816
2817        return 0;
2818}
2819
2820static int ath10k_wmi_10_2_op_pull_fw_stats(struct ath10k *ar,
2821                                            struct sk_buff *skb,
2822                                            struct ath10k_fw_stats *stats)
2823{
2824        const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2825        u32 num_pdev_stats;
2826        u32 num_pdev_ext_stats;
2827        u32 num_vdev_stats;
2828        u32 num_peer_stats;
2829        int i;
2830
2831        if (!skb_pull(skb, sizeof(*ev)))
2832                return -EPROTO;
2833
2834        num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2835        num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
2836        num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2837        num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2838
2839        for (i = 0; i < num_pdev_stats; i++) {
2840                const struct wmi_10_2_pdev_stats *src;
2841                struct ath10k_fw_stats_pdev *dst;
2842
2843                src = (void *)skb->data;
2844                if (!skb_pull(skb, sizeof(*src)))
2845                        return -EPROTO;
2846
2847                dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2848                if (!dst)
2849                        continue;
2850
2851                ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2852                ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2853                ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2854                ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2855                /* FIXME: expose 10.2 specific values */
2856
2857                list_add_tail(&dst->list, &stats->pdevs);
2858        }
2859
2860        for (i = 0; i < num_pdev_ext_stats; i++) {
2861                const struct wmi_10_2_pdev_ext_stats *src;
2862
2863                src = (void *)skb->data;
2864                if (!skb_pull(skb, sizeof(*src)))
2865                        return -EPROTO;
2866
2867                /* FIXME: expose values to userspace
2868                 *
2869                 * Note: Even though this loop seems to do nothing it is
2870                 * required to parse following sub-structures properly.
2871                 */
2872        }
2873
2874        /* fw doesn't implement vdev stats */
2875
2876        for (i = 0; i < num_peer_stats; i++) {
2877                const struct wmi_10_2_peer_stats *src;
2878                struct ath10k_fw_stats_peer *dst;
2879
2880                src = (void *)skb->data;
2881                if (!skb_pull(skb, sizeof(*src)))
2882                        return -EPROTO;
2883
2884                dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2885                if (!dst)
2886                        continue;
2887
2888                ath10k_wmi_pull_peer_stats(&src->old, dst);
2889
2890                dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
2891                /* FIXME: expose 10.2 specific values */
2892
2893                list_add_tail(&dst->list, &stats->peers);
2894        }
2895
2896        return 0;
2897}
2898
2899static int ath10k_wmi_10_2_4_op_pull_fw_stats(struct ath10k *ar,
2900                                              struct sk_buff *skb,
2901                                              struct ath10k_fw_stats *stats)
2902{
2903        const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2904        u32 num_pdev_stats;
2905        u32 num_pdev_ext_stats;
2906        u32 num_vdev_stats;
2907        u32 num_peer_stats;
2908        int i;
2909
2910        if (!skb_pull(skb, sizeof(*ev)))
2911                return -EPROTO;
2912
2913        num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2914        num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
2915        num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2916        num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2917
2918        for (i = 0; i < num_pdev_stats; i++) {
2919                const struct wmi_10_2_pdev_stats *src;
2920                struct ath10k_fw_stats_pdev *dst;
2921
2922                src = (void *)skb->data;
2923                if (!skb_pull(skb, sizeof(*src)))
2924                        return -EPROTO;
2925
2926                dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2927                if (!dst)
2928                        continue;
2929
2930                ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2931                ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2932                ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2933                ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2934                /* FIXME: expose 10.2 specific values */
2935
2936                list_add_tail(&dst->list, &stats->pdevs);
2937        }
2938
2939        for (i = 0; i < num_pdev_ext_stats; i++) {
2940                const struct wmi_10_2_pdev_ext_stats *src;
2941
2942                src = (void *)skb->data;
2943                if (!skb_pull(skb, sizeof(*src)))
2944                        return -EPROTO;
2945
2946                /* FIXME: expose values to userspace
2947                 *
2948                 * Note: Even though this loop seems to do nothing it is
2949                 * required to parse following sub-structures properly.
2950                 */
2951        }
2952
2953        /* fw doesn't implement vdev stats */
2954
2955        for (i = 0; i < num_peer_stats; i++) {
2956                const struct wmi_10_2_4_ext_peer_stats *src;
2957                struct ath10k_fw_stats_peer *dst;
2958                int stats_len;
2959
2960                if (test_bit(WMI_SERVICE_PEER_STATS, ar->wmi.svc_map))
2961                        stats_len = sizeof(struct wmi_10_2_4_ext_peer_stats);
2962                else
2963                        stats_len = sizeof(struct wmi_10_2_4_peer_stats);
2964
2965                src = (void *)skb->data;
2966                if (!skb_pull(skb, stats_len))
2967                        return -EPROTO;
2968
2969                dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2970                if (!dst)
2971                        continue;
2972
2973                ath10k_wmi_pull_peer_stats(&src->common.old, dst);
2974
2975                dst->peer_rx_rate = __le32_to_cpu(src->common.peer_rx_rate);
2976
2977                if (ath10k_peer_stats_enabled(ar))
2978                        dst->rx_duration = __le32_to_cpu(src->rx_duration);
2979                /* FIXME: expose 10.2 specific values */
2980
2981                list_add_tail(&dst->list, &stats->peers);
2982        }
2983
2984        return 0;
2985}
2986
2987static int ath10k_wmi_10_4_op_pull_fw_stats(struct ath10k *ar,
2988                                            struct sk_buff *skb,
2989                                            struct ath10k_fw_stats *stats)
2990{
2991        const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2992        u32 num_pdev_stats;
2993        u32 num_pdev_ext_stats;
2994        u32 num_vdev_stats;
2995        u32 num_peer_stats;
2996        u32 num_bcnflt_stats;
2997        u32 stats_id;
2998        int i;
2999
3000        if (!skb_pull(skb, sizeof(*ev)))
3001                return -EPROTO;
3002
3003        num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
3004        num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
3005        num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
3006        num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
3007        num_bcnflt_stats = __le32_to_cpu(ev->num_bcnflt_stats);
3008        stats_id = __le32_to_cpu(ev->stats_id);
3009
3010        for (i = 0; i < num_pdev_stats; i++) {
3011                const struct wmi_10_4_pdev_stats *src;
3012                struct ath10k_fw_stats_pdev *dst;
3013
3014                src = (void *)skb->data;
3015                if (!skb_pull(skb, sizeof(*src)))
3016                        return -EPROTO;
3017
3018                dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
3019                if (!dst)
3020                        continue;
3021
3022                ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
3023                ath10k_wmi_10_4_pull_pdev_stats_tx(&src->tx, dst);
3024                ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
3025                dst->rx_ovfl_errs = __le32_to_cpu(src->rx_ovfl_errs);
3026                ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
3027
3028                list_add_tail(&dst->list, &stats->pdevs);
3029        }
3030
3031        for (i = 0; i < num_pdev_ext_stats; i++) {
3032                const struct wmi_10_2_pdev_ext_stats *src;
3033
3034                src = (void *)skb->data;
3035                if (!skb_pull(skb, sizeof(*src)))
3036                        return -EPROTO;
3037
3038                /* FIXME: expose values to userspace
3039                 *
3040                 * Note: Even though this loop seems to do nothing it is
3041                 * required to parse following sub-structures properly.
3042                 */
3043        }
3044
3045        /* fw doesn't implement vdev stats */
3046
3047        for (i = 0; i < num_peer_stats; i++) {
3048                const struct wmi_10_4_peer_stats *src;
3049                struct ath10k_fw_stats_peer *dst;
3050
3051                src = (void *)skb->data;
3052                if (!skb_pull(skb, sizeof(*src)))
3053                        return -EPROTO;
3054
3055                dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
3056                if (!dst)
3057                        continue;
3058
3059                ath10k_wmi_10_4_pull_peer_stats(src, dst);
3060                list_add_tail(&dst->list, &stats->peers);
3061        }
3062
3063        for (i = 0; i < num_bcnflt_stats; i++) {
3064                const struct wmi_10_4_bss_bcn_filter_stats *src;
3065
3066                src = (void *)skb->data;
3067                if (!skb_pull(skb, sizeof(*src)))
3068                        return -EPROTO;
3069
3070                /* FIXME: expose values to userspace
3071                 *
3072                 * Note: Even though this loop seems to do nothing it is
3073                 * required to parse following sub-structures properly.
3074                 */
3075        }
3076
3077        if ((stats_id & WMI_10_4_STAT_PEER_EXTD) == 0)
3078                return 0;
3079
3080        stats->extended = true;
3081
3082        for (i = 0; i < num_peer_stats; i++) {
3083                const struct wmi_10_4_peer_extd_stats *src;
3084                struct ath10k_fw_extd_stats_peer *dst;
3085
3086                src = (void *)skb->data;
3087                if (!skb_pull(skb, sizeof(*src)))
3088                        return -EPROTO;
3089
3090                dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
3091                if (!dst)
3092                        continue;
3093
3094                ether_addr_copy(dst->peer_macaddr, src->peer_macaddr.addr);
3095                dst->rx_duration = __le32_to_cpu(src->rx_duration);
3096                list_add_tail(&dst->list, &stats->peers_extd);
3097        }
3098
3099        return 0;
3100}
3101
3102void ath10k_wmi_event_update_stats(struct ath10k *ar, struct sk_buff *skb)
3103{
3104        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_UPDATE_STATS_EVENTID\n");
3105        ath10k_debug_fw_stats_process(ar, skb);
3106}
3107
3108static int
3109ath10k_wmi_op_pull_vdev_start_ev(struct ath10k *ar, struct sk_buff *skb,
3110                                 struct wmi_vdev_start_ev_arg *arg)
3111{
3112        struct wmi_vdev_start_response_event *ev = (void *)skb->data;
3113
3114        if (skb->len < sizeof(*ev))
3115                return -EPROTO;
3116
3117        skb_pull(skb, sizeof(*ev));
3118        arg->vdev_id = ev->vdev_id;
3119        arg->req_id = ev->req_id;
3120        arg->resp_type = ev->resp_type;
3121        arg->status = ev->status;
3122
3123        return 0;
3124}
3125
3126void ath10k_wmi_event_vdev_start_resp(struct ath10k *ar, struct sk_buff *skb)
3127{
3128        struct wmi_vdev_start_ev_arg arg = {};
3129        int ret;
3130
3131        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_START_RESP_EVENTID\n");
3132
3133        ret = ath10k_wmi_pull_vdev_start(ar, skb, &arg);
3134        if (ret) {
3135                ath10k_warn(ar, "failed to parse vdev start event: %d\n", ret);
3136                return;
3137        }
3138
3139        if (WARN_ON(__le32_to_cpu(arg.status)))
3140                return;
3141
3142        complete(&ar->vdev_setup_done);
3143}
3144
3145void ath10k_wmi_event_vdev_stopped(struct ath10k *ar, struct sk_buff *skb)
3146{
3147        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STOPPED_EVENTID\n");
3148        complete(&ar->vdev_setup_done);
3149}
3150
3151static int
3152ath10k_wmi_op_pull_peer_kick_ev(struct ath10k *ar, struct sk_buff *skb,
3153                                struct wmi_peer_kick_ev_arg *arg)
3154{
3155        struct wmi_peer_sta_kickout_event *ev = (void *)skb->data;
3156
3157        if (skb->len < sizeof(*ev))
3158                return -EPROTO;
3159
3160        skb_pull(skb, sizeof(*ev));
3161        arg->mac_addr = ev->peer_macaddr.addr;
3162
3163        return 0;
3164}
3165
3166void ath10k_wmi_event_peer_sta_kickout(struct ath10k *ar, struct sk_buff *skb)
3167{
3168        struct wmi_peer_kick_ev_arg arg = {};
3169        struct ieee80211_sta *sta;
3170        int ret;
3171
3172        ret = ath10k_wmi_pull_peer_kick(ar, skb, &arg);
3173        if (ret) {
3174                ath10k_warn(ar, "failed to parse peer kickout event: %d\n",
3175                            ret);
3176                return;
3177        }
3178
3179        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event peer sta kickout %pM\n",
3180                   arg.mac_addr);
3181
3182        rcu_read_lock();
3183
3184        sta = ieee80211_find_sta_by_ifaddr(ar->hw, arg.mac_addr, NULL);
3185        if (!sta) {
3186                ath10k_warn(ar, "Spurious quick kickout for STA %pM\n",
3187                            arg.mac_addr);
3188                goto exit;
3189        }
3190
3191        ieee80211_report_low_ack(sta, 10);
3192
3193exit:
3194        rcu_read_unlock();
3195}
3196
3197/*
3198 * FIXME
3199 *
3200 * We don't report to mac80211 sleep state of connected
3201 * stations. Due to this mac80211 can't fill in TIM IE
3202 * correctly.
3203 *
3204 * I know of no way of getting nullfunc frames that contain
3205 * sleep transition from connected stations - these do not
3206 * seem to be sent from the target to the host. There also
3207 * doesn't seem to be a dedicated event for that. So the
3208 * only way left to do this would be to read tim_bitmap
3209 * during SWBA.
3210 *
3211 * We could probably try using tim_bitmap from SWBA to tell
3212 * mac80211 which stations are asleep and which are not. The
3213 * problem here is calling mac80211 functions so many times
3214 * could take too long and make us miss the time to submit
3215 * the beacon to the target.
3216 *
3217 * So as a workaround we try to extend the TIM IE if there
3218 * is unicast buffered for stations with aid > 7 and fill it
3219 * in ourselves.
3220 */
3221static void ath10k_wmi_update_tim(struct ath10k *ar,
3222                                  struct ath10k_vif *arvif,
3223                                  struct sk_buff *bcn,
3224                                  const struct wmi_tim_info_arg *tim_info)
3225{
3226        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)bcn->data;
3227        struct ieee80211_tim_ie *tim;
3228        u8 *ies, *ie;
3229        u8 ie_len, pvm_len;
3230        __le32 t;
3231        u32 v, tim_len;
3232
3233        /* When FW reports 0 in tim_len, ensure atleast first byte
3234         * in tim_bitmap is considered for pvm calculation.
3235         */
3236        tim_len = tim_info->tim_len ? __le32_to_cpu(tim_info->tim_len) : 1;
3237
3238        /* if next SWBA has no tim_changed the tim_bitmap is garbage.
3239         * we must copy the bitmap upon change and reuse it later
3240         */
3241        if (__le32_to_cpu(tim_info->tim_changed)) {
3242                int i;
3243
3244                if (sizeof(arvif->u.ap.tim_bitmap) < tim_len) {
3245                        ath10k_warn(ar, "SWBA TIM field is too big (%u), truncated it to %zu",
3246                                    tim_len, sizeof(arvif->u.ap.tim_bitmap));
3247                        tim_len = sizeof(arvif->u.ap.tim_bitmap);
3248                }
3249
3250                for (i = 0; i < tim_len; i++) {
3251                        t = tim_info->tim_bitmap[i / 4];
3252                        v = __le32_to_cpu(t);
3253                        arvif->u.ap.tim_bitmap[i] = (v >> ((i % 4) * 8)) & 0xFF;
3254                }
3255
3256                /* FW reports either length 0 or length based on max supported
3257                 * station. so we calculate this on our own
3258                 */
3259                arvif->u.ap.tim_len = 0;
3260                for (i = 0; i < tim_len; i++)
3261                        if (arvif->u.ap.tim_bitmap[i])
3262                                arvif->u.ap.tim_len = i;
3263
3264                arvif->u.ap.tim_len++;
3265        }
3266
3267        ies = bcn->data;
3268        ies += ieee80211_hdrlen(hdr->frame_control);
3269        ies += 12; /* fixed parameters */
3270
3271        ie = (u8 *)cfg80211_find_ie(WLAN_EID_TIM, ies,
3272                                    (u8 *)skb_tail_pointer(bcn) - ies);
3273        if (!ie) {
3274                if (arvif->vdev_type != WMI_VDEV_TYPE_IBSS)
3275                        ath10k_warn(ar, "no tim ie found;\n");
3276                return;
3277        }
3278
3279        tim = (void *)ie + 2;
3280        ie_len = ie[1];
3281        pvm_len = ie_len - 3; /* exclude dtim count, dtim period, bmap ctl */
3282
3283        if (pvm_len < arvif->u.ap.tim_len) {
3284                int expand_size = tim_len - pvm_len;
3285                int move_size = skb_tail_pointer(bcn) - (ie + 2 + ie_len);
3286                void *next_ie = ie + 2 + ie_len;
3287
3288                if (skb_put(bcn, expand_size)) {
3289                        memmove(next_ie + expand_size, next_ie, move_size);
3290
3291                        ie[1] += expand_size;
3292                        ie_len += expand_size;
3293                        pvm_len += expand_size;
3294                } else {
3295                        ath10k_warn(ar, "tim expansion failed\n");
3296                }
3297        }
3298
3299        if (pvm_len > tim_len) {
3300                ath10k_warn(ar, "tim pvm length is too great (%d)\n", pvm_len);
3301                return;
3302        }
3303
3304        tim->bitmap_ctrl = !!__le32_to_cpu(tim_info->tim_mcast);
3305        memcpy(tim->virtual_map, arvif->u.ap.tim_bitmap, pvm_len);
3306
3307        if (tim->dtim_count == 0) {
3308                ATH10K_SKB_CB(bcn)->flags |= ATH10K_SKB_F_DTIM_ZERO;
3309
3310                if (__le32_to_cpu(tim_info->tim_mcast) == 1)
3311                        ATH10K_SKB_CB(bcn)->flags |= ATH10K_SKB_F_DELIVER_CAB;
3312        }
3313
3314        ath10k_dbg(ar, ATH10K_DBG_MGMT, "dtim %d/%d mcast %d pvmlen %d\n",
3315                   tim->dtim_count, tim->dtim_period,
3316                   tim->bitmap_ctrl, pvm_len);
3317}
3318
3319static void ath10k_wmi_update_noa(struct ath10k *ar, struct ath10k_vif *arvif,
3320                                  struct sk_buff *bcn,
3321                                  const struct wmi_p2p_noa_info *noa)
3322{
3323        if (!arvif->vif->p2p)
3324                return;
3325
3326        ath10k_dbg(ar, ATH10K_DBG_MGMT, "noa changed: %d\n", noa->changed);
3327
3328        if (noa->changed & WMI_P2P_NOA_CHANGED_BIT)
3329                ath10k_p2p_noa_update(arvif, noa);
3330
3331        if (arvif->u.ap.noa_data)
3332                if (!pskb_expand_head(bcn, 0, arvif->u.ap.noa_len, GFP_ATOMIC))
3333                        skb_put_data(bcn, arvif->u.ap.noa_data,
3334                                     arvif->u.ap.noa_len);
3335}
3336
3337static int ath10k_wmi_op_pull_swba_ev(struct ath10k *ar, struct sk_buff *skb,
3338                                      struct wmi_swba_ev_arg *arg)
3339{
3340        struct wmi_host_swba_event *ev = (void *)skb->data;
3341        u32 map;
3342        size_t i;
3343
3344        if (skb->len < sizeof(*ev))
3345                return -EPROTO;
3346
3347        skb_pull(skb, sizeof(*ev));
3348        arg->vdev_map = ev->vdev_map;
3349
3350        for (i = 0, map = __le32_to_cpu(ev->vdev_map); map; map >>= 1) {
3351                if (!(map & BIT(0)))
3352                        continue;
3353
3354                /* If this happens there were some changes in firmware and
3355                 * ath10k should update the max size of tim_info array.
3356                 */
3357                if (WARN_ON_ONCE(i == ARRAY_SIZE(arg->tim_info)))
3358                        break;
3359
3360                if (__le32_to_cpu(ev->bcn_info[i].tim_info.tim_len) >
3361                     sizeof(ev->bcn_info[i].tim_info.tim_bitmap)) {
3362                        ath10k_warn(ar, "refusing to parse invalid swba structure\n");
3363                        return -EPROTO;
3364                }
3365
3366                arg->tim_info[i].tim_len = ev->bcn_info[i].tim_info.tim_len;
3367                arg->tim_info[i].tim_mcast = ev->bcn_info[i].tim_info.tim_mcast;
3368                arg->tim_info[i].tim_bitmap =
3369                                ev->bcn_info[i].tim_info.tim_bitmap;
3370                arg->tim_info[i].tim_changed =
3371                                ev->bcn_info[i].tim_info.tim_changed;
3372                arg->tim_info[i].tim_num_ps_pending =
3373                                ev->bcn_info[i].tim_info.tim_num_ps_pending;
3374
3375                arg->noa_info[i] = &ev->bcn_info[i].p2p_noa_info;
3376                i++;
3377        }
3378
3379        return 0;
3380}
3381
3382static int ath10k_wmi_10_2_4_op_pull_swba_ev(struct ath10k *ar,
3383                                             struct sk_buff *skb,
3384                                             struct wmi_swba_ev_arg *arg)
3385{
3386        struct wmi_10_2_4_host_swba_event *ev = (void *)skb->data;
3387        u32 map;
3388        size_t i;
3389
3390        if (skb->len < sizeof(*ev))
3391                return -EPROTO;
3392
3393        skb_pull(skb, sizeof(*ev));
3394        arg->vdev_map = ev->vdev_map;
3395
3396        for (i = 0, map = __le32_to_cpu(ev->vdev_map); map; map >>= 1) {
3397                if (!(map & BIT(0)))
3398                        continue;
3399
3400                /* If this happens there were some changes in firmware and
3401                 * ath10k should update the max size of tim_info array.
3402                 */
3403                if (WARN_ON_ONCE(i == ARRAY_SIZE(arg->tim_info)))
3404                        break;
3405
3406                if (__le32_to_cpu(ev->bcn_info[i].tim_info.tim_len) >
3407                     sizeof(ev->bcn_info[i].tim_info.tim_bitmap)) {
3408                        ath10k_warn(ar, "refusing to parse invalid swba structure\n");
3409                        return -EPROTO;
3410                }
3411
3412                arg->tim_info[i].tim_len = ev->bcn_info[i].tim_info.tim_len;
3413                arg->tim_info[i].tim_mcast = ev->bcn_info[i].tim_info.tim_mcast;
3414                arg->tim_info[i].tim_bitmap =
3415                                ev->bcn_info[i].tim_info.tim_bitmap;
3416                arg->tim_info[i].tim_changed =
3417                                ev->bcn_info[i].tim_info.tim_changed;
3418                arg->tim_info[i].tim_num_ps_pending =
3419                                ev->bcn_info[i].tim_info.tim_num_ps_pending;
3420                i++;
3421        }
3422
3423        return 0;
3424}
3425
3426static int ath10k_wmi_10_4_op_pull_swba_ev(struct ath10k *ar,
3427                                           struct sk_buff *skb,
3428                                           struct wmi_swba_ev_arg *arg)
3429{
3430        struct wmi_10_4_host_swba_event *ev = (void *)skb->data;
3431        u32 map, tim_len;
3432        size_t i;
3433
3434        if (skb->len < sizeof(*ev))
3435                return -EPROTO;
3436
3437        skb_pull(skb, sizeof(*ev));
3438        arg->vdev_map = ev->vdev_map;
3439
3440        for (i = 0, map = __le32_to_cpu(ev->vdev_map); map; map >>= 1) {
3441                if (!(map & BIT(0)))
3442                        continue;
3443
3444                /* If this happens there were some changes in firmware and
3445                 * ath10k should update the max size of tim_info array.
3446                 */
3447                if (WARN_ON_ONCE(i == ARRAY_SIZE(arg->tim_info)))
3448                        break;
3449
3450                if (__le32_to_cpu(ev->bcn_info[i].tim_info.tim_len) >
3451                      sizeof(ev->bcn_info[i].tim_info.tim_bitmap)) {
3452                        ath10k_warn(ar, "refusing to parse invalid swba structure\n");
3453                        return -EPROTO;
3454                }
3455
3456                tim_len = __le32_to_cpu(ev->bcn_info[i].tim_info.tim_len);
3457                if (tim_len) {
3458                        /* Exclude 4 byte guard length */
3459                        tim_len -= 4;
3460                        arg->tim_info[i].tim_len = __cpu_to_le32(tim_len);
3461                } else {
3462                        arg->tim_info[i].tim_len = 0;
3463                }
3464
3465                arg->tim_info[i].tim_mcast = ev->bcn_info[i].tim_info.tim_mcast;
3466                arg->tim_info[i].tim_bitmap =
3467                                ev->bcn_info[i].tim_info.tim_bitmap;
3468                arg->tim_info[i].tim_changed =
3469                                ev->bcn_info[i].tim_info.tim_changed;
3470                arg->tim_info[i].tim_num_ps_pending =
3471                                ev->bcn_info[i].tim_info.tim_num_ps_pending;
3472
3473                /* 10.4 firmware doesn't have p2p support. notice of absence
3474                 * info can be ignored for now.
3475                 */
3476
3477                i++;
3478        }
3479
3480        return 0;
3481}
3482
3483static enum wmi_txbf_conf ath10k_wmi_10_4_txbf_conf_scheme(struct ath10k *ar)
3484{
3485        return WMI_TXBF_CONF_BEFORE_ASSOC;
3486}
3487
3488void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
3489{
3490        struct wmi_swba_ev_arg arg = {};
3491        u32 map;
3492        int i = -1;
3493        const struct wmi_tim_info_arg *tim_info;
3494        const struct wmi_p2p_noa_info *noa_info;
3495        struct ath10k_vif *arvif;
3496        struct sk_buff *bcn;
3497        dma_addr_t paddr;
3498        int ret, vdev_id = 0;
3499
3500        ret = ath10k_wmi_pull_swba(ar, skb, &arg);
3501        if (ret) {
3502                ath10k_warn(ar, "failed to parse swba event: %d\n", ret);
3503                return;
3504        }
3505
3506        map = __le32_to_cpu(arg.vdev_map);
3507
3508        ath10k_dbg(ar, ATH10K_DBG_MGMT, "mgmt swba vdev_map 0x%x\n",
3509                   map);
3510
3511        for (; map; map >>= 1, vdev_id++) {
3512                if (!(map & 0x1))
3513                        continue;
3514
3515                i++;
3516
3517                if (i >= WMI_MAX_AP_VDEV) {
3518                        ath10k_warn(ar, "swba has corrupted vdev map\n");
3519                        break;
3520                }
3521
3522                tim_info = &arg.tim_info[i];
3523                noa_info = arg.noa_info[i];
3524
3525                ath10k_dbg(ar, ATH10K_DBG_MGMT,
3526                           "mgmt event bcn_info %d tim_len %d mcast %d changed %d num_ps_pending %d bitmap 0x%08x%08x%08x%08x\n",
3527                           i,
3528                           __le32_to_cpu(tim_info->tim_len),
3529                           __le32_to_cpu(tim_info->tim_mcast),
3530                           __le32_to_cpu(tim_info->tim_changed),
3531                           __le32_to_cpu(tim_info->tim_num_ps_pending),
3532                           __le32_to_cpu(tim_info->tim_bitmap[3]),
3533                           __le32_to_cpu(tim_info->tim_bitmap[2]),
3534                           __le32_to_cpu(tim_info->tim_bitmap[1]),
3535                           __le32_to_cpu(tim_info->tim_bitmap[0]));
3536
3537                /* TODO: Only first 4 word from tim_bitmap is dumped.
3538                 * Extend debug code to dump full tim_bitmap.
3539                 */
3540
3541                arvif = ath10k_get_arvif(ar, vdev_id);
3542                if (arvif == NULL) {
3543                        ath10k_warn(ar, "no vif for vdev_id %d found\n",
3544                                    vdev_id);
3545                        continue;
3546                }
3547
3548                /* mac80211 would have already asked us to stop beaconing and
3549                 * bring the vdev down, so continue in that case
3550                 */
3551                if (!arvif->is_up)
3552                        continue;
3553
3554                /* There are no completions for beacons so wait for next SWBA
3555                 * before telling mac80211 to decrement CSA counter
3556                 *
3557                 * Once CSA counter is completed stop sending beacons until
3558                 * actual channel switch is done
3559                 */
3560                if (arvif->vif->csa_active &&
3561                    ieee80211_csa_is_complete(arvif->vif)) {
3562                        ieee80211_csa_finish(arvif->vif);
3563                        continue;
3564                }
3565
3566                bcn = ieee80211_beacon_get(ar->hw, arvif->vif);
3567                if (!bcn) {
3568                        ath10k_warn(ar, "could not get mac80211 beacon\n");
3569                        continue;
3570                }
3571
3572                ath10k_tx_h_seq_no(arvif->vif, bcn);
3573                ath10k_wmi_update_tim(ar, arvif, bcn, tim_info);
3574                ath10k_wmi_update_noa(ar, arvif, bcn, noa_info);
3575
3576                spin_lock_bh(&ar->data_lock);
3577
3578                if (arvif->beacon) {
3579                        switch (arvif->beacon_state) {
3580                        case ATH10K_BEACON_SENT:
3581                                break;
3582                        case ATH10K_BEACON_SCHEDULED:
3583                                ath10k_warn(ar, "SWBA overrun on vdev %d, skipped old beacon\n",
3584                                            arvif->vdev_id);
3585                                break;
3586                        case ATH10K_BEACON_SENDING:
3587                                ath10k_warn(ar, "SWBA overrun on vdev %d, skipped new beacon\n",
3588                                            arvif->vdev_id);
3589                                dev_kfree_skb(bcn);
3590                                goto skip;
3591                        }
3592
3593                        ath10k_mac_vif_beacon_free(arvif);
3594                }
3595
3596                if (!arvif->beacon_buf) {
3597                        paddr = dma_map_single(arvif->ar->dev, bcn->data,
3598                                               bcn->len, DMA_TO_DEVICE);
3599                        ret = dma_mapping_error(arvif->ar->dev, paddr);
3600                        if (ret) {
3601                                ath10k_warn(ar, "failed to map beacon: %d\n",
3602                                            ret);
3603                                dev_kfree_skb_any(bcn);
3604                                goto skip;
3605                        }
3606
3607                        ATH10K_SKB_CB(bcn)->paddr = paddr;
3608                } else {
3609                        if (bcn->len > IEEE80211_MAX_FRAME_LEN) {
3610                                ath10k_warn(ar, "trimming beacon %d -> %d bytes!\n",
3611                                            bcn->len, IEEE80211_MAX_FRAME_LEN);
3612                                skb_trim(bcn, IEEE80211_MAX_FRAME_LEN);
3613                        }
3614                        memcpy(arvif->beacon_buf, bcn->data, bcn->len);
3615                        ATH10K_SKB_CB(bcn)->paddr = arvif->beacon_paddr;
3616                }
3617
3618                arvif->beacon = bcn;
3619                arvif->beacon_state = ATH10K_BEACON_SCHEDULED;
3620
3621                trace_ath10k_tx_hdr(ar, bcn->data, bcn->len);
3622                trace_ath10k_tx_payload(ar, bcn->data, bcn->len);
3623
3624skip:
3625                spin_unlock_bh(&ar->data_lock);
3626        }
3627
3628        ath10k_wmi_tx_beacons_nowait(ar);
3629}
3630
3631void ath10k_wmi_event_tbttoffset_update(struct ath10k *ar, struct sk_buff *skb)
3632{
3633        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TBTTOFFSET_UPDATE_EVENTID\n");
3634}
3635
3636static void ath10k_dfs_radar_report(struct ath10k *ar,
3637                                    struct wmi_phyerr_ev_arg *phyerr,
3638                                    const struct phyerr_radar_report *rr,
3639                                    u64 tsf)
3640{
3641        u32 reg0, reg1, tsf32l;
3642        struct ieee80211_channel *ch;
3643        struct pulse_event pe;
3644        u64 tsf64;
3645        u8 rssi, width;
3646
3647        reg0 = __le32_to_cpu(rr->reg0);
3648        reg1 = __le32_to_cpu(rr->reg1);
3649
3650        ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3651                   "wmi phyerr radar report chirp %d max_width %d agc_total_gain %d pulse_delta_diff %d\n",
3652                   MS(reg0, RADAR_REPORT_REG0_PULSE_IS_CHIRP),
3653                   MS(reg0, RADAR_REPORT_REG0_PULSE_IS_MAX_WIDTH),
3654                   MS(reg0, RADAR_REPORT_REG0_AGC_TOTAL_GAIN),
3655                   MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_DIFF));
3656        ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3657                   "wmi phyerr radar report pulse_delta_pean %d pulse_sidx %d fft_valid %d agc_mb_gain %d subchan_mask %d\n",
3658                   MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_PEAK),
3659                   MS(reg0, RADAR_REPORT_REG0_PULSE_SIDX),
3660                   MS(reg1, RADAR_REPORT_REG1_PULSE_SRCH_FFT_VALID),
3661                   MS(reg1, RADAR_REPORT_REG1_PULSE_AGC_MB_GAIN),
3662                   MS(reg1, RADAR_REPORT_REG1_PULSE_SUBCHAN_MASK));
3663        ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3664                   "wmi phyerr radar report pulse_tsf_offset 0x%X pulse_dur: %d\n",
3665                   MS(reg1, RADAR_REPORT_REG1_PULSE_TSF_OFFSET),
3666                   MS(reg1, RADAR_REPORT_REG1_PULSE_DUR));
3667
3668        if (!ar->dfs_detector)
3669                return;
3670
3671        spin_lock_bh(&ar->data_lock);
3672        ch = ar->rx_channel;
3673
3674        /* fetch target operating channel during channel change */
3675        if (!ch)
3676                ch = ar->tgt_oper_chan;
3677
3678        spin_unlock_bh(&ar->data_lock);
3679
3680        if (!ch) {
3681                ath10k_warn(ar, "failed to derive channel for radar pulse, treating as radar\n");
3682                goto radar_detected;
3683        }
3684
3685        /* report event to DFS pattern detector */
3686        tsf32l = phyerr->tsf_timestamp;
3687        tsf64 = tsf & (~0xFFFFFFFFULL);
3688        tsf64 |= tsf32l;
3689
3690        width = MS(reg1, RADAR_REPORT_REG1_PULSE_DUR);
3691        rssi = phyerr->rssi_combined;
3692
3693        /* hardware store this as 8 bit signed value,
3694         * set to zero if negative number
3695         */
3696        if (rssi & 0x80)
3697                rssi = 0;
3698
3699        pe.ts = tsf64;
3700        pe.freq = ch->center_freq;
3701        pe.width = width;
3702        pe.rssi = rssi;
3703        pe.chirp = (MS(reg0, RADAR_REPORT_REG0_PULSE_IS_CHIRP) != 0);
3704        ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3705                   "dfs add pulse freq: %d, width: %d, rssi %d, tsf: %llX\n",
3706                   pe.freq, pe.width, pe.rssi, pe.ts);
3707
3708        ATH10K_DFS_STAT_INC(ar, pulses_detected);
3709
3710        if (!ar->dfs_detector->add_pulse(ar->dfs_detector, &pe)) {
3711                ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3712                           "dfs no pulse pattern detected, yet\n");
3713                return;
3714        }
3715
3716radar_detected:
3717        ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs radar detected\n");
3718        ATH10K_DFS_STAT_INC(ar, radar_detected);
3719
3720        /* Control radar events reporting in debugfs file
3721         * dfs_block_radar_events
3722         */
3723        if (ar->dfs_block_radar_events) {
3724                ath10k_info(ar, "DFS Radar detected, but ignored as requested\n");
3725                return;
3726        }
3727
3728        ieee80211_radar_detected(ar->hw);
3729}
3730
3731static int ath10k_dfs_fft_report(struct ath10k *ar,
3732                                 struct wmi_phyerr_ev_arg *phyerr,
3733                                 const struct phyerr_fft_report *fftr,
3734                                 u64 tsf)
3735{
3736        u32 reg0, reg1;
3737        u8 rssi, peak_mag;
3738
3739        reg0 = __le32_to_cpu(fftr->reg0);
3740        reg1 = __le32_to_cpu(fftr->reg1);
3741        rssi = phyerr->rssi_combined;
3742
3743        ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3744                   "wmi phyerr fft report total_gain_db %d base_pwr_db %d fft_chn_idx %d peak_sidx %d\n",
3745                   MS(reg0, SEARCH_FFT_REPORT_REG0_TOTAL_GAIN_DB),
3746                   MS(reg0, SEARCH_FFT_REPORT_REG0_BASE_PWR_DB),
3747                   MS(reg0, SEARCH_FFT_REPORT_REG0_FFT_CHN_IDX),
3748                   MS(reg0, SEARCH_FFT_REPORT_REG0_PEAK_SIDX));
3749        ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3750                   "wmi phyerr fft report rel_pwr_db %d avgpwr_db %d peak_mag %d num_store_bin %d\n",
3751                   MS(reg1, SEARCH_FFT_REPORT_REG1_RELPWR_DB),
3752                   MS(reg1, SEARCH_FFT_REPORT_REG1_AVGPWR_DB),
3753                   MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG),
3754                   MS(reg1, SEARCH_FFT_REPORT_REG1_NUM_STR_BINS_IB));
3755
3756        peak_mag = MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG);
3757
3758        /* false event detection */
3759        if (rssi == DFS_RSSI_POSSIBLY_FALSE &&
3760            peak_mag < 2 * DFS_PEAK_MAG_THOLD_POSSIBLY_FALSE) {
3761                ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs false pulse detected\n");
3762                ATH10K_DFS_STAT_INC(ar, pulses_discarded);
3763                return -EINVAL;
3764        }
3765
3766        return 0;
3767}
3768
3769void ath10k_wmi_event_dfs(struct ath10k *ar,
3770                          struct wmi_phyerr_ev_arg *phyerr,
3771                          u64 tsf)
3772{
3773        int buf_len, tlv_len, res, i = 0;
3774        const struct phyerr_tlv *tlv;
3775        const struct phyerr_radar_report *rr;
3776        const struct phyerr_fft_report *fftr;
3777        const u8 *tlv_buf;
3778
3779        buf_len = phyerr->buf_len;
3780        ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3781                   "wmi event dfs err_code %d rssi %d tsfl 0x%X tsf64 0x%llX len %d\n",
3782                   phyerr->phy_err_code, phyerr->rssi_combined,
3783                   phyerr->tsf_timestamp, tsf, buf_len);
3784
3785        /* Skip event if DFS disabled */
3786        if (!IS_ENABLED(CONFIG_ATH10K_DFS_CERTIFIED))
3787                return;
3788
3789        ATH10K_DFS_STAT_INC(ar, pulses_total);
3790
3791        while (i < buf_len) {
3792                if (i + sizeof(*tlv) > buf_len) {
3793                        ath10k_warn(ar, "too short buf for tlv header (%d)\n",
3794                                    i);
3795                        return;
3796                }
3797
3798                tlv = (struct phyerr_tlv *)&phyerr->buf[i];
3799                tlv_len = __le16_to_cpu(tlv->len);
3800                tlv_buf = &phyerr->buf[i + sizeof(*tlv)];
3801                ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3802                           "wmi event dfs tlv_len %d tlv_tag 0x%02X tlv_sig 0x%02X\n",
3803                           tlv_len, tlv->tag, tlv->sig);
3804
3805                switch (tlv->tag) {
3806                case PHYERR_TLV_TAG_RADAR_PULSE_SUMMARY:
3807                        if (i + sizeof(*tlv) + sizeof(*rr) > buf_len) {
3808                                ath10k_warn(ar, "too short radar pulse summary (%d)\n",
3809                                            i);
3810                                return;
3811                        }
3812
3813                        rr = (struct phyerr_radar_report *)tlv_buf;
3814                        ath10k_dfs_radar_report(ar, phyerr, rr, tsf);
3815                        break;
3816                case PHYERR_TLV_TAG_SEARCH_FFT_REPORT:
3817                        if (i + sizeof(*tlv) + sizeof(*fftr) > buf_len) {
3818                                ath10k_warn(ar, "too short fft report (%d)\n",
3819                                            i);
3820                                return;
3821                        }
3822
3823                        fftr = (struct phyerr_fft_report *)tlv_buf;
3824                        res = ath10k_dfs_fft_report(ar, phyerr, fftr, tsf);
3825                        if (res)
3826                                return;
3827                        break;
3828                }
3829
3830                i += sizeof(*tlv) + tlv_len;
3831        }
3832}
3833
3834void ath10k_wmi_event_spectral_scan(struct ath10k *ar,
3835                                    struct wmi_phyerr_ev_arg *phyerr,
3836                                    u64 tsf)
3837{
3838        int buf_len, tlv_len, res, i = 0;
3839        struct phyerr_tlv *tlv;
3840        const void *tlv_buf;
3841        const struct phyerr_fft_report *fftr;
3842        size_t fftr_len;
3843
3844        buf_len = phyerr->buf_len;
3845
3846        while (i < buf_len) {
3847                if (i + sizeof(*tlv) > buf_len) {
3848                        ath10k_warn(ar, "failed to parse phyerr tlv header at byte %d\n",
3849                                    i);
3850                        return;
3851                }
3852
3853                tlv = (struct phyerr_tlv *)&phyerr->buf[i];
3854                tlv_len = __le16_to_cpu(tlv->len);
3855                tlv_buf = &phyerr->buf[i + sizeof(*tlv)];
3856
3857                if (i + sizeof(*tlv) + tlv_len > buf_len) {
3858                        ath10k_warn(ar, "failed to parse phyerr tlv payload at byte %d\n",
3859                                    i);
3860                        return;
3861                }
3862
3863                switch (tlv->tag) {
3864                case PHYERR_TLV_TAG_SEARCH_FFT_REPORT:
3865                        if (sizeof(*fftr) > tlv_len) {
3866                                ath10k_warn(ar, "failed to parse fft report at byte %d\n",
3867                                            i);
3868                                return;
3869                        }
3870
3871                        fftr_len = tlv_len - sizeof(*fftr);
3872                        fftr = tlv_buf;
3873                        res = ath10k_spectral_process_fft(ar, phyerr,
3874                                                          fftr, fftr_len,
3875                                                          tsf);
3876                        if (res < 0) {
3877                                ath10k_dbg(ar, ATH10K_DBG_WMI, "failed to process fft report: %d\n",
3878                                           res);
3879                                return;
3880                        }
3881                        break;
3882                }
3883
3884                i += sizeof(*tlv) + tlv_len;
3885        }
3886}
3887
3888static int ath10k_wmi_op_pull_phyerr_ev_hdr(struct ath10k *ar,
3889                                            struct sk_buff *skb,
3890                                            struct wmi_phyerr_hdr_arg *arg)
3891{
3892        struct wmi_phyerr_event *ev = (void *)skb->data;
3893
3894        if (skb->len < sizeof(*ev))
3895                return -EPROTO;
3896
3897        arg->num_phyerrs = __le32_to_cpu(ev->num_phyerrs);
3898        arg->tsf_l32 = __le32_to_cpu(ev->tsf_l32);
3899        arg->tsf_u32 = __le32_to_cpu(ev->tsf_u32);
3900        arg->buf_len = skb->len - sizeof(*ev);
3901        arg->phyerrs = ev->phyerrs;
3902
3903        return 0;
3904}
3905
3906static int ath10k_wmi_10_4_op_pull_phyerr_ev_hdr(struct ath10k *ar,
3907                                                 struct sk_buff *skb,
3908                                                 struct wmi_phyerr_hdr_arg *arg)
3909{
3910        struct wmi_10_4_phyerr_event *ev = (void *)skb->data;
3911
3912        if (skb->len < sizeof(*ev))
3913                return -EPROTO;
3914
3915        /* 10.4 firmware always reports only one phyerr */
3916        arg->num_phyerrs = 1;
3917
3918        arg->tsf_l32 = __le32_to_cpu(ev->tsf_l32);
3919        arg->tsf_u32 = __le32_to_cpu(ev->tsf_u32);
3920        arg->buf_len = skb->len;
3921        arg->phyerrs = skb->data;
3922
3923        return 0;
3924}
3925
3926int ath10k_wmi_op_pull_phyerr_ev(struct ath10k *ar,
3927                                 const void *phyerr_buf,
3928                                 int left_len,
3929                                 struct wmi_phyerr_ev_arg *arg)
3930{
3931        const struct wmi_phyerr *phyerr = phyerr_buf;
3932        int i;
3933
3934        if (left_len < sizeof(*phyerr)) {
3935                ath10k_warn(ar, "wrong phyerr event head len %d (need: >=%zd)\n",
3936                            left_len, sizeof(*phyerr));
3937                return -EINVAL;
3938        }
3939
3940        arg->tsf_timestamp = __le32_to_cpu(phyerr->tsf_timestamp);
3941        arg->freq1 = __le16_to_cpu(phyerr->freq1);
3942        arg->freq2 = __le16_to_cpu(phyerr->freq2);
3943        arg->rssi_combined = phyerr->rssi_combined;
3944        arg->chan_width_mhz = phyerr->chan_width_mhz;
3945        arg->buf_len = __le32_to_cpu(phyerr->buf_len);
3946        arg->buf = phyerr->buf;
3947        arg->hdr_len = sizeof(*phyerr);
3948
3949        for (i = 0; i < 4; i++)
3950                arg->nf_chains[i] = __le16_to_cpu(phyerr->nf_chains[i]);
3951
3952        switch (phyerr->phy_err_code) {
3953        case PHY_ERROR_GEN_SPECTRAL_SCAN:
3954                arg->phy_err_code = PHY_ERROR_SPECTRAL_SCAN;
3955                break;
3956        case PHY_ERROR_GEN_FALSE_RADAR_EXT:
3957                arg->phy_err_code = PHY_ERROR_FALSE_RADAR_EXT;
3958                break;
3959        case PHY_ERROR_GEN_RADAR:
3960                arg->phy_err_code = PHY_ERROR_RADAR;
3961                break;
3962        default:
3963                arg->phy_err_code = PHY_ERROR_UNKNOWN;
3964                break;
3965        }
3966
3967        return 0;
3968}
3969
3970static int ath10k_wmi_10_4_op_pull_phyerr_ev(struct ath10k *ar,
3971                                             const void *phyerr_buf,
3972                                             int left_len,
3973                                             struct wmi_phyerr_ev_arg *arg)
3974{
3975        const struct wmi_10_4_phyerr_event *phyerr = phyerr_buf;
3976        u32 phy_err_mask;
3977        int i;
3978
3979        if (left_len < sizeof(*phyerr)) {
3980                ath10k_warn(ar, "wrong phyerr event head len %d (need: >=%zd)\n",
3981                            left_len, sizeof(*phyerr));
3982                return -EINVAL;
3983        }
3984
3985        arg->tsf_timestamp = __le32_to_cpu(phyerr->tsf_timestamp);
3986        arg->freq1 = __le16_to_cpu(phyerr->freq1);
3987        arg->freq2 = __le16_to_cpu(phyerr->freq2);
3988        arg->rssi_combined = phyerr->rssi_combined;
3989        arg->chan_width_mhz = phyerr->chan_width_mhz;
3990        arg->buf_len = __le32_to_cpu(phyerr->buf_len);
3991        arg->buf = phyerr->buf;
3992        arg->hdr_len = sizeof(*phyerr);
3993
3994        for (i = 0; i < 4; i++)
3995                arg->nf_chains[i] = __le16_to_cpu(phyerr->nf_chains[i]);
3996
3997        phy_err_mask = __le32_to_cpu(phyerr->phy_err_mask[0]);
3998
3999        if (phy_err_mask & PHY_ERROR_10_4_SPECTRAL_SCAN_MASK)
4000                arg->phy_err_code = PHY_ERROR_SPECTRAL_SCAN;
4001        else if (phy_err_mask & PHY_ERROR_10_4_RADAR_MASK)
4002                arg->phy_err_code = PHY_ERROR_RADAR;
4003        else
4004                arg->phy_err_code = PHY_ERROR_UNKNOWN;
4005
4006        return 0;
4007}
4008
4009void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb)
4010{
4011        struct wmi_phyerr_hdr_arg hdr_arg = {};
4012        struct wmi_phyerr_ev_arg phyerr_arg = {};
4013        const void *phyerr;
4014        u32 count, i, buf_len, phy_err_code;
4015        u64 tsf;
4016        int left_len, ret;
4017
4018        ATH10K_DFS_STAT_INC(ar, phy_errors);
4019
4020        ret = ath10k_wmi_pull_phyerr_hdr(ar, skb, &hdr_arg);
4021        if (ret) {
4022                ath10k_warn(ar, "failed to parse phyerr event hdr: %d\n", ret);
4023                return;
4024        }
4025
4026        /* Check number of included events */
4027        count = hdr_arg.num_phyerrs;
4028
4029        left_len = hdr_arg.buf_len;
4030
4031        tsf = hdr_arg.tsf_u32;
4032        tsf <<= 32;
4033        tsf |= hdr_arg.tsf_l32;
4034
4035        ath10k_dbg(ar, ATH10K_DBG_WMI,
4036                   "wmi event phyerr count %d tsf64 0x%llX\n",
4037                   count, tsf);
4038
4039        phyerr = hdr_arg.phyerrs;
4040        for (i = 0; i < count; i++) {
4041                ret = ath10k_wmi_pull_phyerr(ar, phyerr, left_len, &phyerr_arg);
4042                if (ret) {
4043                        ath10k_warn(ar, "failed to parse phyerr event (%d)\n",
4044                                    i);
4045                        return;
4046                }
4047
4048                left_len -= phyerr_arg.hdr_len;
4049                buf_len = phyerr_arg.buf_len;
4050                phy_err_code = phyerr_arg.phy_err_code;
4051
4052                if (left_len < buf_len) {
4053                        ath10k_warn(ar, "single event (%d) wrong buf len\n", i);
4054                        return;
4055                }
4056
4057                left_len -= buf_len;
4058
4059                switch (phy_err_code) {
4060                case PHY_ERROR_RADAR:
4061                        ath10k_wmi_event_dfs(ar, &phyerr_arg, tsf);
4062                        break;
4063                case PHY_ERROR_SPECTRAL_SCAN:
4064                        ath10k_wmi_event_spectral_scan(ar, &phyerr_arg, tsf);
4065                        break;
4066                case PHY_ERROR_FALSE_RADAR_EXT:
4067                        ath10k_wmi_event_dfs(ar, &phyerr_arg, tsf);
4068                        ath10k_wmi_event_spectral_scan(ar, &phyerr_arg, tsf);
4069                        break;
4070                default:
4071                        break;
4072                }
4073
4074                phyerr = phyerr + phyerr_arg.hdr_len + buf_len;
4075        }
4076}
4077
4078void ath10k_wmi_event_roam(struct ath10k *ar, struct sk_buff *skb)
4079{
4080        struct wmi_roam_ev_arg arg = {};
4081        int ret;
4082        u32 vdev_id;
4083        u32 reason;
4084        s32 rssi;
4085
4086        ret = ath10k_wmi_pull_roam_ev(ar, skb, &arg);
4087        if (ret) {
4088                ath10k_warn(ar, "failed to parse roam event: %d\n", ret);
4089                return;
4090        }
4091
4092        vdev_id = __le32_to_cpu(arg.vdev_id);
4093        reason = __le32_to_cpu(arg.reason);
4094        rssi = __le32_to_cpu(arg.rssi);
4095        rssi += WMI_SPECTRAL_NOISE_FLOOR_REF_DEFAULT;
4096
4097        ath10k_dbg(ar, ATH10K_DBG_WMI,
4098                   "wmi roam event vdev %u reason 0x%08x rssi %d\n",
4099                   vdev_id, reason, rssi);
4100
4101        if (reason >= WMI_ROAM_REASON_MAX)
4102                ath10k_warn(ar, "ignoring unknown roam event reason %d on vdev %i\n",
4103                            reason, vdev_id);
4104
4105        switch (reason) {
4106        case WMI_ROAM_REASON_BEACON_MISS:
4107                ath10k_mac_handle_beacon_miss(ar, vdev_id);
4108                break;
4109        case WMI_ROAM_REASON_BETTER_AP:
4110        case WMI_ROAM_REASON_LOW_RSSI:
4111        case WMI_ROAM_REASON_SUITABLE_AP_FOUND:
4112        case WMI_ROAM_REASON_HO_FAILED:
4113                ath10k_warn(ar, "ignoring not implemented roam event reason %d on vdev %i\n",
4114                            reason, vdev_id);
4115                break;
4116        }
4117}
4118
4119void ath10k_wmi_event_profile_match(struct ath10k *ar, struct sk_buff *skb)
4120{
4121        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PROFILE_MATCH\n");
4122}
4123
4124void ath10k_wmi_event_debug_print(struct ath10k *ar, struct sk_buff *skb)
4125{
4126        char buf[101], c;
4127        int i;
4128
4129        for (i = 0; i < sizeof(buf) - 1; i++) {
4130                if (i >= skb->len)
4131                        break;
4132
4133                c = skb->data[i];
4134
4135                if (c == '\0')
4136                        break;
4137
4138                if (isascii(c) && isprint(c))
4139                        buf[i] = c;
4140                else
4141                        buf[i] = '.';
4142        }
4143
4144        if (i == sizeof(buf) - 1)
4145                ath10k_warn(ar, "wmi debug print truncated: %d\n", skb->len);
4146
4147        /* for some reason the debug prints end with \n, remove that */
4148        if (skb->data[i - 1] == '\n')
4149                i--;
4150
4151        /* the last byte is always reserved for the null character */
4152        buf[i] = '\0';
4153
4154        ath10k_dbg(ar, ATH10K_DBG_WMI_PRINT, "wmi print '%s'\n", buf);
4155}
4156
4157void ath10k_wmi_event_pdev_qvit(struct ath10k *ar, struct sk_buff *skb)
4158{
4159        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_QVIT_EVENTID\n");
4160}
4161
4162void ath10k_wmi_event_wlan_profile_data(struct ath10k *ar, struct sk_buff *skb)
4163{
4164        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_WLAN_PROFILE_DATA_EVENTID\n");
4165}
4166
4167void ath10k_wmi_event_rtt_measurement_report(struct ath10k *ar,
4168                                             struct sk_buff *skb)
4169{
4170        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_MEASUREMENT_REPORT_EVENTID\n");
4171}
4172
4173void ath10k_wmi_event_tsf_measurement_report(struct ath10k *ar,
4174                                             struct sk_buff *skb)
4175{
4176        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TSF_MEASUREMENT_REPORT_EVENTID\n");
4177}
4178
4179void ath10k_wmi_event_rtt_error_report(struct ath10k *ar, struct sk_buff *skb)
4180{
4181        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_ERROR_REPORT_EVENTID\n");
4182}
4183
4184void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, struct sk_buff *skb)
4185{
4186        struct wmi_wow_ev_arg ev = {};
4187        int ret;
4188
4189        complete(&ar->wow.wakeup_completed);
4190
4191        ret = ath10k_wmi_pull_wow_event(ar, skb, &ev);
4192        if (ret) {
4193                ath10k_warn(ar, "failed to parse wow wakeup event: %d\n", ret);
4194                return;
4195        }
4196
4197        ath10k_dbg(ar, ATH10K_DBG_WMI, "wow wakeup host reason %s\n",
4198                   wow_reason(ev.wake_reason));
4199}
4200
4201void ath10k_wmi_event_dcs_interference(struct ath10k *ar, struct sk_buff *skb)
4202{
4203        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_DCS_INTERFERENCE_EVENTID\n");
4204}
4205
4206static u8 ath10k_tpc_config_get_rate(struct ath10k *ar,
4207                                     struct wmi_pdev_tpc_config_event *ev,
4208                                     u32 rate_idx, u32 num_chains,
4209                                     u32 rate_code, u8 type)
4210{
4211        u8 tpc, num_streams, preamble, ch, stm_idx;
4212
4213        num_streams = ATH10K_HW_NSS(rate_code);
4214        preamble = ATH10K_HW_PREAMBLE(rate_code);
4215        ch = num_chains - 1;
4216
4217        tpc = min_t(u8, ev->rates_array[rate_idx], ev->max_reg_allow_pow[ch]);
4218
4219        if (__le32_to_cpu(ev->num_tx_chain) <= 1)
4220                goto out;
4221
4222        if (preamble == WMI_RATE_PREAMBLE_CCK)
4223                goto out;
4224
4225        stm_idx = num_streams - 1;
4226        if (num_chains <= num_streams)
4227                goto out;
4228
4229        switch (type) {
4230        case WMI_TPC_TABLE_TYPE_STBC:
4231                tpc = min_t(u8, tpc,
4232                            ev->max_reg_allow_pow_agstbc[ch - 1][stm_idx]);
4233                break;
4234        case WMI_TPC_TABLE_TYPE_TXBF:
4235                tpc = min_t(u8, tpc,
4236                            ev->max_reg_allow_pow_agtxbf[ch - 1][stm_idx]);
4237                break;
4238        case WMI_TPC_TABLE_TYPE_CDD:
4239                tpc = min_t(u8, tpc,
4240                            ev->max_reg_allow_pow_agcdd[ch - 1][stm_idx]);
4241                break;
4242        default:
4243                ath10k_warn(ar, "unknown wmi tpc table type: %d\n", type);
4244                tpc = 0;
4245                break;
4246        }
4247
4248out:
4249        return tpc;
4250}
4251
4252static void ath10k_tpc_config_disp_tables(struct ath10k *ar,
4253                                          struct wmi_pdev_tpc_config_event *ev,
4254                                          struct ath10k_tpc_stats *tpc_stats,
4255                                          u8 *rate_code, u16 *pream_table, u8 type)
4256{
4257        u32 i, j, pream_idx, flags;
4258        u8 tpc[WMI_TPC_TX_N_CHAIN];
4259        char tpc_value[WMI_TPC_TX_N_CHAIN * WMI_TPC_BUF_SIZE];
4260        char buff[WMI_TPC_BUF_SIZE];
4261
4262        flags = __le32_to_cpu(ev->flags);
4263
4264        switch (type) {
4265        case WMI_TPC_TABLE_TYPE_CDD:
4266                if (!(flags & WMI_TPC_CONFIG_EVENT_FLAG_TABLE_CDD)) {
4267                        ath10k_dbg(ar, ATH10K_DBG_WMI, "CDD not supported\n");
4268                        tpc_stats->flag[type] = ATH10K_TPC_TABLE_TYPE_FLAG;
4269                        return;
4270                }
4271                break;
4272        case WMI_TPC_TABLE_TYPE_STBC:
4273                if (!(flags & WMI_TPC_CONFIG_EVENT_FLAG_TABLE_STBC)) {
4274                        ath10k_dbg(ar, ATH10K_DBG_WMI, "STBC not supported\n");
4275                        tpc_stats->flag[type] = ATH10K_TPC_TABLE_TYPE_FLAG;
4276                        return;
4277                }
4278                break;
4279        case WMI_TPC_TABLE_TYPE_TXBF:
4280                if (!(flags & WMI_TPC_CONFIG_EVENT_FLAG_TABLE_TXBF)) {
4281                        ath10k_dbg(ar, ATH10K_DBG_WMI, "TXBF not supported\n");
4282                        tpc_stats->flag[type] = ATH10K_TPC_TABLE_TYPE_FLAG;
4283                        return;
4284                }
4285                break;
4286        default:
4287                ath10k_dbg(ar, ATH10K_DBG_WMI,
4288                           "invalid table type in wmi tpc event: %d\n", type);
4289                return;
4290        }
4291
4292        pream_idx = 0;
4293        for (i = 0; i < __le32_to_cpu(ev->rate_max); i++) {
4294                memset(tpc_value, 0, sizeof(tpc_value));
4295                memset(buff, 0, sizeof(buff));
4296                if (i == pream_table[pream_idx])
4297                        pream_idx++;
4298
4299                for (j = 0; j < WMI_TPC_TX_N_CHAIN; j++) {
4300                        if (j >= __le32_to_cpu(ev->num_tx_chain))
4301                                break;
4302
4303                        tpc[j] = ath10k_tpc_config_get_rate(ar, ev, i, j + 1,
4304                                                            rate_code[i],
4305                                                            type);
4306                        snprintf(buff, sizeof(buff), "%8d ", tpc[j]);
4307                        strncat(tpc_value, buff, strlen(buff));
4308                }
4309                tpc_stats->tpc_table[type].pream_idx[i] = pream_idx;
4310                tpc_stats->tpc_table[type].rate_code[i] = rate_code[i];
4311                memcpy(tpc_stats->tpc_table[type].tpc_value[i],
4312                       tpc_value, sizeof(tpc_value));
4313        }
4314}
4315
4316void ath10k_wmi_event_pdev_tpc_config(struct ath10k *ar, struct sk_buff *skb)
4317{
4318        u32 i, j, pream_idx, num_tx_chain;
4319        u8 rate_code[WMI_TPC_RATE_MAX], rate_idx;
4320        u16 pream_table[WMI_TPC_PREAM_TABLE_MAX];
4321        struct wmi_pdev_tpc_config_event *ev;
4322        struct ath10k_tpc_stats *tpc_stats;
4323
4324        ev = (struct wmi_pdev_tpc_config_event *)skb->data;
4325
4326        tpc_stats = kzalloc(sizeof(*tpc_stats), GFP_ATOMIC);
4327        if (!tpc_stats)
4328                return;
4329
4330        /* Create the rate code table based on the chains supported */
4331        rate_idx = 0;
4332        pream_idx = 0;
4333
4334        /* Fill CCK rate code */
4335        for (i = 0; i < 4; i++) {
4336                rate_code[rate_idx] =
4337                        ATH10K_HW_RATECODE(i, 0, WMI_RATE_PREAMBLE_CCK);
4338                rate_idx++;
4339        }
4340        pream_table[pream_idx] = rate_idx;
4341        pream_idx++;
4342
4343        /* Fill OFDM rate code */
4344        for (i = 0; i < 8; i++) {
4345                rate_code[rate_idx] =
4346                        ATH10K_HW_RATECODE(i, 0, WMI_RATE_PREAMBLE_OFDM);
4347                rate_idx++;
4348        }
4349        pream_table[pream_idx] = rate_idx;
4350        pream_idx++;
4351
4352        num_tx_chain = __le32_to_cpu(ev->num_tx_chain);
4353
4354        /* Fill HT20 rate code */
4355        for (i = 0; i < num_tx_chain; i++) {
4356                for (j = 0; j < 8; j++) {
4357                        rate_code[rate_idx] =
4358                        ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_HT);
4359                        rate_idx++;
4360                }
4361        }
4362        pream_table[pream_idx] = rate_idx;
4363        pream_idx++;
4364
4365        /* Fill HT40 rate code */
4366        for (i = 0; i < num_tx_chain; i++) {
4367                for (j = 0; j < 8; j++) {
4368                        rate_code[rate_idx] =
4369                        ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_HT);
4370                        rate_idx++;
4371                }
4372        }
4373        pream_table[pream_idx] = rate_idx;
4374        pream_idx++;
4375
4376        /* Fill VHT20 rate code */
4377        for (i = 0; i < __le32_to_cpu(ev->num_tx_chain); i++) {
4378                for (j = 0; j < 10; j++) {
4379                        rate_code[rate_idx] =
4380                        ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_VHT);
4381                        rate_idx++;
4382                }
4383        }
4384        pream_table[pream_idx] = rate_idx;
4385        pream_idx++;
4386
4387        /* Fill VHT40 rate code */
4388        for (i = 0; i < num_tx_chain; i++) {
4389                for (j = 0; j < 10; j++) {
4390                        rate_code[rate_idx] =
4391                        ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_VHT);
4392                        rate_idx++;
4393                }
4394        }
4395        pream_table[pream_idx] = rate_idx;
4396        pream_idx++;
4397
4398        /* Fill VHT80 rate code */
4399        for (i = 0; i < num_tx_chain; i++) {
4400                for (j = 0; j < 10; j++) {
4401                        rate_code[rate_idx] =
4402                        ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_VHT);
4403                        rate_idx++;
4404                }
4405        }
4406        pream_table[pream_idx] = rate_idx;
4407        pream_idx++;
4408
4409        rate_code[rate_idx++] =
4410                ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_CCK);
4411        rate_code[rate_idx++] =
4412                ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_OFDM);
4413        rate_code[rate_idx++] =
4414                ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_CCK);
4415        rate_code[rate_idx++] =
4416                ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_OFDM);
4417        rate_code[rate_idx++] =
4418                ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_OFDM);
4419
4420        pream_table[pream_idx] = ATH10K_TPC_PREAM_TABLE_END;
4421
4422        tpc_stats->chan_freq = __le32_to_cpu(ev->chan_freq);
4423        tpc_stats->phy_mode = __le32_to_cpu(ev->phy_mode);
4424        tpc_stats->ctl = __le32_to_cpu(ev->ctl);
4425        tpc_stats->reg_domain = __le32_to_cpu(ev->reg_domain);
4426        tpc_stats->twice_antenna_gain = a_sle32_to_cpu(ev->twice_antenna_gain);
4427        tpc_stats->twice_antenna_reduction =
4428                __le32_to_cpu(ev->twice_antenna_reduction);
4429        tpc_stats->power_limit = __le32_to_cpu(ev->power_limit);
4430        tpc_stats->twice_max_rd_power = __le32_to_cpu(ev->twice_max_rd_power);
4431        tpc_stats->num_tx_chain = __le32_to_cpu(ev->num_tx_chain);
4432        tpc_stats->rate_max = __le32_to_cpu(ev->rate_max);
4433
4434        ath10k_tpc_config_disp_tables(ar, ev, tpc_stats,
4435                                      rate_code, pream_table,
4436                                      WMI_TPC_TABLE_TYPE_CDD);
4437        ath10k_tpc_config_disp_tables(ar, ev,  tpc_stats,
4438                                      rate_code, pream_table,
4439                                      WMI_TPC_TABLE_TYPE_STBC);
4440        ath10k_tpc_config_disp_tables(ar, ev, tpc_stats,
4441                                      rate_code, pream_table,
4442                                      WMI_TPC_TABLE_TYPE_TXBF);
4443
4444        ath10k_debug_tpc_stats_process(ar, tpc_stats);
4445
4446        ath10k_dbg(ar, ATH10K_DBG_WMI,
4447                   "wmi event tpc config channel %d mode %d ctl %d regd %d gain %d %d limit %d max_power %d tx_chanins %d rates %d\n",
4448                   __le32_to_cpu(ev->chan_freq),
4449                   __le32_to_cpu(ev->phy_mode),
4450                   __le32_to_cpu(ev->ctl),
4451                   __le32_to_cpu(ev->reg_domain),
4452                   a_sle32_to_cpu(ev->twice_antenna_gain),
4453                   __le32_to_cpu(ev->twice_antenna_reduction),
4454                   __le32_to_cpu(ev->power_limit),
4455                   __le32_to_cpu(ev->twice_max_rd_power) / 2,
4456                   __le32_to_cpu(ev->num_tx_chain),
4457                   __le32_to_cpu(ev->rate_max));
4458}
4459
4460static void
4461ath10k_wmi_handle_tdls_peer_event(struct ath10k *ar, struct sk_buff *skb)
4462{
4463        struct wmi_tdls_peer_event *ev;
4464        struct ath10k_peer *peer;
4465        struct ath10k_vif *arvif;
4466        int vdev_id;
4467        int peer_status;
4468        int peer_reason;
4469        u8 reason;
4470
4471        if (skb->len < sizeof(*ev)) {
4472                ath10k_err(ar, "received tdls peer event with invalid size (%d bytes)\n",
4473                           skb->len);
4474                return;
4475        }
4476
4477        ev = (struct wmi_tdls_peer_event *)skb->data;
4478        vdev_id = __le32_to_cpu(ev->vdev_id);
4479        peer_status = __le32_to_cpu(ev->peer_status);
4480        peer_reason = __le32_to_cpu(ev->peer_reason);
4481
4482        spin_lock_bh(&ar->data_lock);
4483        peer = ath10k_peer_find(ar, vdev_id, ev->peer_macaddr.addr);
4484        spin_unlock_bh(&ar->data_lock);
4485
4486        if (!peer) {
4487                ath10k_warn(ar, "failed to find peer entry for %pM\n",
4488                            ev->peer_macaddr.addr);
4489                return;
4490        }
4491
4492        switch (peer_status) {
4493        case WMI_TDLS_SHOULD_TEARDOWN:
4494                switch (peer_reason) {
4495                case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
4496                case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
4497                case WMI_TDLS_TEARDOWN_REASON_RSSI:
4498                        reason = WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE;
4499                        break;
4500                default:
4501                        reason = WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED;
4502                        break;
4503                }
4504
4505                arvif = ath10k_get_arvif(ar, vdev_id);
4506                if (!arvif) {
4507                        ath10k_warn(ar, "received tdls peer event for invalid vdev id %u\n",
4508                                    vdev_id);
4509                        return;
4510                }
4511
4512                ieee80211_tdls_oper_request(arvif->vif, ev->peer_macaddr.addr,
4513                                            NL80211_TDLS_TEARDOWN, reason,
4514                                            GFP_ATOMIC);
4515
4516                ath10k_dbg(ar, ATH10K_DBG_WMI,
4517                           "received tdls teardown event for peer %pM reason %u\n",
4518                           ev->peer_macaddr.addr, peer_reason);
4519                break;
4520        default:
4521                ath10k_dbg(ar, ATH10K_DBG_WMI,
4522                           "received unknown tdls peer event %u\n",
4523                           peer_status);
4524                break;
4525        }
4526}
4527
4528void ath10k_wmi_event_pdev_ftm_intg(struct ath10k *ar, struct sk_buff *skb)
4529{
4530        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_FTM_INTG_EVENTID\n");
4531}
4532
4533void ath10k_wmi_event_gtk_offload_status(struct ath10k *ar, struct sk_buff *skb)
4534{
4535        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_OFFLOAD_STATUS_EVENTID\n");
4536}
4537
4538void ath10k_wmi_event_gtk_rekey_fail(struct ath10k *ar, struct sk_buff *skb)
4539{
4540        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_REKEY_FAIL_EVENTID\n");
4541}
4542
4543void ath10k_wmi_event_delba_complete(struct ath10k *ar, struct sk_buff *skb)
4544{
4545        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_DELBA_COMPLETE_EVENTID\n");
4546}
4547
4548void ath10k_wmi_event_addba_complete(struct ath10k *ar, struct sk_buff *skb)
4549{
4550        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_ADDBA_COMPLETE_EVENTID\n");
4551}
4552
4553void ath10k_wmi_event_vdev_install_key_complete(struct ath10k *ar,
4554                                                struct sk_buff *skb)
4555{
4556        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID\n");
4557}
4558
4559void ath10k_wmi_event_inst_rssi_stats(struct ath10k *ar, struct sk_buff *skb)
4560{
4561        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_INST_RSSI_STATS_EVENTID\n");
4562}
4563
4564void ath10k_wmi_event_vdev_standby_req(struct ath10k *ar, struct sk_buff *skb)
4565{
4566        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STANDBY_REQ_EVENTID\n");
4567}
4568
4569void ath10k_wmi_event_vdev_resume_req(struct ath10k *ar, struct sk_buff *skb)
4570{
4571        ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_RESUME_REQ_EVENTID\n");
4572}
4573
4574static int ath10k_wmi_alloc_chunk(struct ath10k *ar, u32 req_id,
4575                                  u32 num_units, u32 unit_len)
4576{
4577        dma_addr_t paddr;
4578        u32 pool_size;
4579        int idx = ar->wmi.num_mem_chunks;
4580        void *vaddr;
4581
4582        pool_size = num_units * round_up(unit_len, 4);
4583        vaddr = dma_alloc_coherent(ar->dev, pool_size, &paddr, GFP_KERNEL);
4584
4585        if (!vaddr)
4586                return -ENOMEM;
4587
4588        memset(vaddr, 0, pool_size);
4589
4590        ar->wmi.mem_chunks[idx].vaddr = vaddr;
4591        ar->wmi.mem_chunks[idx].paddr = paddr;
4592        ar->wmi.mem_chunks[idx].len = pool_size;
4593        ar->wmi.mem_chunks[idx].req_id = req_id;
4594        ar->wmi.num_mem_chunks++;
4595
4596        return num_units;
4597}
4598
4599static int ath10k_wmi_alloc_host_mem(struct ath10k *ar, u32 req_id,
4600                                     u32 num_units, u32 unit_len)
4601{
4602        int ret;
4603
4604        while (num_units) {
4605                ret = ath10k_wmi_alloc_chunk(ar, req_id, num_units, unit_len);
4606                if (ret < 0)
4607                        return ret;
4608
4609                num_units -= ret;
4610        }
4611
4612        return 0;
4613}
4614
4615static bool
4616ath10k_wmi_is_host_mem_allocated(struct ath10k *ar,
4617                                 const struct wlan_host_mem_req **mem_reqs,
4618                                 u32 num_mem_reqs)
4619{
4620        u32 req_id, num_units, unit_size, num_unit_info;
4621        u32 pool_size;
4622        int i, j;
4623        bool found;
4624
4625        if (ar->wmi.num_mem_chunks != num_mem_reqs)
4626                return false;
4627
4628        for (i = 0; i < num_mem_reqs; ++i) {
4629                req_id = __le32_to_cpu(mem_reqs[i]->req_id);
4630                num_units = __le32_to_cpu(mem_reqs[i]->num_units);
4631                unit_size = __le32_to_cpu(mem_reqs[i]->unit_size);
4632                num_unit_info = __le32_to_cpu(mem_reqs[i]->num_unit_info);
4633
4634                if (num_unit_info & NUM_UNITS_IS_NUM_ACTIVE_PEERS) {
4635                        if (ar->num_active_peers)
4636                                num_units = ar->num_active_peers + 1;
4637                        else
4638                                num_units = ar->max_num_peers + 1;
4639                } else if (num_unit_info & NUM_UNITS_IS_NUM_PEERS) {
4640                        num_units = ar->max_num_peers + 1;
4641                } else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS) {
4642                        num_units = ar->max_num_vdevs + 1;
4643                }
4644
4645                found = false;
4646                for (j = 0; j < ar->wmi.num_mem_chunks; j++) {
4647                        if (ar->wmi.mem_chunks[j].req_id == req_id) {
4648                                pool_size = num_units * round_up(unit_size, 4);
4649                                if (ar->wmi.mem_chunks[j].len == pool_size) {
4650                                        found = true;
4651                                        break;
4652                                }
4653                        }
4654                }
4655                if (!found)
4656                        return false;
4657        }
4658
4659        return true;
4660}
4661
4662static int
4663ath10k_wmi_main_op_pull_svc_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
4664                                   struct wmi_svc_rdy_ev_arg *arg)
4665{
4666        struct wmi_service_ready_event *ev;
4667        size_t i, n;
4668
4669        if (skb->len < sizeof(*ev))
4670                return -EPROTO;
4671
4672        ev = (void *)skb->data;
4673        skb_pull(skb, sizeof(*ev));
4674        arg->min_tx_power = ev->hw_min_tx_power;
4675        arg->max_tx_power = ev->hw_max_tx_power;
4676        arg->ht_cap = ev->ht_cap_info;
4677        arg->vht_cap = ev->vht_cap_info;
4678        arg->sw_ver0 = ev->sw_version;
4679        arg->sw_ver1 = ev->sw_version_1;
4680        arg->phy_capab = ev->phy_capability;
4681        arg->num_rf_chains = ev->num_rf_chains;
4682        arg->eeprom_rd = ev->hal_reg_capabilities.eeprom_rd;
4683        arg->low_5ghz_chan = ev->hal_reg_capabilities.low_5ghz_chan;
4684        arg->high_5ghz_chan = ev->hal_reg_capabilities.high_5ghz_chan;
4685        arg->num_mem_reqs = ev->num_mem_reqs;
4686        arg->service_map = ev->wmi_service_bitmap;
4687        arg->service_map_len = sizeof(ev->wmi_service_bitmap);
4688
4689        n = min_t(size_t, __le32_to_cpu(arg->num_mem_reqs),
4690                  ARRAY_SIZE(arg->mem_reqs));
4691        for (i = 0; i < n; i++)
4692                arg->mem_reqs[i] = &ev->mem_reqs[i];
4693
4694        if (skb->len <
4695            __le32_to_cpu(arg->num_mem_reqs) * sizeof(arg->mem_reqs[0]))
4696                return -EPROTO;
4697
4698        return 0;
4699}
4700
4701static int
4702ath10k_wmi_10x_op_pull_svc_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
4703                                  struct wmi_svc_rdy_ev_arg *arg)
4704{
4705        struct wmi_10x_service_ready_event *ev;
4706        int i, n;
4707
4708        if (skb->len < sizeof(*ev))
4709                return -EPROTO;
4710
4711        ev = (void *)skb->data;
4712        skb_pull(skb, sizeof(*ev));
4713        arg->min_tx_power = ev->hw_min_tx_power;
4714        arg->max_tx_power = ev->hw_max_tx_power;
4715        arg->ht_cap = ev->ht_cap_info;
4716        arg->vht_cap = ev->vht_cap_info;
4717        arg->sw_ver0 = ev->sw_version;
4718        arg->phy_capab = ev->phy_capability;
4719        arg->num_rf_chains = ev->num_rf_chains;
4720        arg->eeprom_rd = ev->hal_reg_capabilities.eeprom_rd;
4721        arg->low_5ghz_chan = ev->hal_reg_capabilities.low_5ghz_chan;
4722        arg->high_5ghz_chan = ev->hal_reg_capabilities.high_5ghz_chan;
4723        arg->num_mem_reqs = ev->num_mem_reqs;
4724        arg->service_map = ev->wmi_service_bitmap;
4725        arg->service_map_len = sizeof(ev->wmi_service_bitmap);
4726
4727        n = min_t(size_t, __le32_to_cpu(arg->num_mem_reqs),
4728                  ARRAY_SIZE(arg->mem_reqs));
4729        for (i = 0; i < n; i++)
4730                arg->mem_reqs[i] = &ev->mem_reqs[i];
4731
4732        if (skb->len <
4733            __le32_to_cpu(arg->num_mem_reqs) * sizeof(arg->mem_reqs[0]))
4734                return -EPROTO;
4735
4736        return 0;
4737}
4738
4739static void ath10k_wmi_event_service_ready_work(struct work_struct *work)
4740{
4741        struct ath10k *ar = container_of(work, struct ath10k, svc_rdy_work);
4742        struct sk_buff *skb = ar->svc_rdy_skb;
4743        struct wmi_svc_rdy_ev_arg arg = {};
4744        u32 num_units, req_id, unit_size, num_mem_reqs, num_unit_info, i;
4745        int ret;
4746        bool allocated;
4747
4748        if (!skb) {
4749                ath10k_warn(ar, "invalid service ready event skb\n");
4750                return;
4751        }
4752
4753        ret = ath10k_wmi_pull_svc_rdy(ar, skb, &arg);
4754        if (ret) {
4755                ath10k_warn(ar, "failed to parse service ready: %d\n", ret);
4756                return;
4757        }
4758
4759        memset(&ar->wmi.svc_map, 0, sizeof(ar->wmi.svc_map));
4760        ath10k_wmi_map_svc(ar, arg.service_map, ar->wmi.svc_map,
4761                           arg.service_map_len);
4762
4763        ar->hw_min_tx_power = __le32_to_cpu(arg.min_tx_power);
4764        ar->hw_max_tx_power = __le32_to_cpu(arg.max_tx_power);
4765        ar->ht_cap_info = __le32_to_cpu(arg.ht_cap);
4766        ar->vht_cap_info = __le32_to_cpu(arg.vht_cap);
4767        ar->fw_version_major =
4768                (__le32_to_cpu(arg.sw_ver0) & 0xff000000) >> 24;
4769        ar->fw_version_minor = (__le32_to_cpu(arg.sw_ver0) & 0x00ffffff);
4770        ar->fw_version_release =
4771                (__le32_to_cpu(arg.sw_ver1) & 0xffff0000) >> 16;
4772        ar->fw_version_build = (__le32_to_cpu(arg.sw_ver1) & 0x0000ffff);
4773        ar->phy_capability = __le32_to_cpu(arg.phy_capab);
4774        ar->num_rf_chains = __le32_to_cpu(arg.num_rf_chains);
4775        ar->hw_eeprom_rd = __le32_to_cpu(arg.eeprom_rd);
4776        ar->low_5ghz_chan = __le32_to_cpu(arg.low_5ghz_chan);
4777        ar->high_5ghz_chan = __le32_to_cpu(arg.high_5ghz_chan);
4778
4779        ath10k_dbg_dump(ar, ATH10K_DBG_WMI, NULL, "wmi svc: ",
4780                        arg.service_map, arg.service_map_len);
4781
4782        if (ar->num_rf_chains > ar->max_spatial_stream) {
4783                ath10k_warn(ar, "hardware advertises support for more spatial streams than it should (%d > %d)\n",
4784                            ar->num_rf_chains, ar->max_spatial_stream);
4785                ar->num_rf_chains = ar->max_spatial_stream;
4786        }
4787
4788        if (!ar->cfg_tx_chainmask) {
4789                ar->cfg_tx_chainmask = (1 << ar->num_rf_chains) - 1;
4790                ar->cfg_rx_chainmask = (1 << ar->num_rf_chains) - 1;
4791        }
4792
4793        if (strlen(ar->hw->wiphy->fw_version) == 0) {
4794                snprintf(ar->hw->wiphy->fw_version,
4795                         sizeof(ar->hw->wiphy->fw_version),
4796                         "%u.%u.%u.%u",
4797                         ar->fw_version_major,
4798                         ar->fw_version_minor,
4799                         ar->fw_version_release,
4800                         ar->fw_version_build);
4801        }
4802
4803        num_mem_reqs = __le32_to_cpu(arg.num_mem_reqs);
4804        if (num_mem_reqs > WMI_MAX_MEM_REQS) {
4805                ath10k_warn(ar, "requested memory chunks number (%d) exceeds the limit\n",
4806                            num_mem_reqs);
4807                return;
4808        }
4809
4810        if (test_bit(WMI_SERVICE_PEER_CACHING, ar->wmi.svc_map)) {
4811                if (test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL,
4812                             ar->running_fw->fw_file.fw_features))
4813                        ar->num_active_peers = TARGET_10_4_QCACHE_ACTIVE_PEERS_PFC +
4814                                               ar->max_num_vdevs;
4815                else
4816                        ar->num_active_peers = TARGET_10_4_QCACHE_ACTIVE_PEERS +
4817                                               ar->max_num_vdevs;
4818
4819                ar->max_num_peers = TARGET_10_4_NUM_QCACHE_PEERS_MAX +
4820                                    ar->max_num_vdevs;
4821                ar->num_tids = ar->num_active_peers * 2;
4822                ar->max_num_stations = TARGET_10_4_NUM_QCACHE_PEERS_MAX;
4823        }
4824
4825        /* TODO: Adjust max peer count for cases like WMI_SERVICE_RATECTRL_CACHE
4826         * and WMI_SERVICE_IRAM_TIDS, etc.
4827         */
4828
4829        allocated = ath10k_wmi_is_host_mem_allocated(ar, arg.mem_reqs,
4830                                                     num_mem_reqs);
4831        if (allocated)
4832                goto skip_mem_alloc;
4833
4834        /* Either this event is received during boot time or there is a change
4835         * in memory requirement from firmware when compared to last request.
4836         * Free any old memory and do a fresh allocation based on the current
4837         * memory requirement.
4838         */
4839        ath10k_wmi_free_host_mem(ar);
4840
4841        for (i = 0; i < num_mem_reqs; ++i) {
4842                req_id = __le32_to_cpu(arg.mem_reqs[i]->req_id);
4843                num_units = __le32_to_cpu(arg.mem_reqs[i]->num_units);
4844                unit_size = __le32_to_cpu(arg.mem_reqs[i]->unit_size);
4845                num_unit_info = __le32_to_cpu(arg.mem_reqs[i]->num_unit_info);
4846
4847                if (num_unit_info & NUM_UNITS_IS_NUM_ACTIVE_PEERS) {
4848                        if (ar->num_active_peers)
4849                                num_units = ar->num_active_peers + 1;
4850                        else
4851                                num_units = ar->max_num_peers + 1;
4852                } else if (num_unit_info & NUM_UNITS_IS_NUM_PEERS) {
4853                        /* number of units to allocate is number of
4854                         * peers, 1 extra for self peer on target
4855                         * this needs to be tied, host and target
4856                         * can get out of sync
4857                         */
4858                        num_units = ar->max_num_peers + 1;
4859                } else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS) {
4860                        num_units = ar->max_num_vdevs + 1;
4861                }
4862
4863                ath10k_dbg(ar, ATH10K_DBG_WMI,
4864                           "wmi mem_req_id %d num_units %d num_unit_info %d unit size %d actual units %d\n",
4865                           req_id,
4866                           __le32_to_cpu(arg.mem_reqs[i]->num_units),
4867                           num_unit_info,
4868                           unit_size,
4869                           num_units);
4870
4871                ret = ath10k_wmi_alloc_host_mem(ar, req_id, num_units,
4872                                                unit_size);
4873                if (ret)
4874                        return;
4875        }
4876
4877skip_mem_alloc:
4878        ath10k_dbg(ar, ATH10K_DBG_WMI,
4879                   "wmi event service ready min_tx_power 0x%08x max_tx_power 0x%08x ht_cap 0x%08x vht_cap 0x%08x sw_ver0 0x%08x sw_ver1 0x%08x fw_build 0x%08x phy_capab 0x%08x num_rf_chains 0x%08x eeprom_rd 0x%08x num_mem_reqs 0x%08x\n",
4880                   __le32_to_cpu(arg.min_tx_power),
4881                   __le32_to_cpu(arg.max_tx_power),
4882                   __le32_to_cpu(arg.ht_cap),
4883                   __le32_to_cpu(arg.vht_cap),
4884                   __le32_to_cpu(arg.sw_ver0),
4885                   __le32_to_cpu(arg.sw_ver1),
4886                   __le32_to_cpu(arg.fw_build),
4887                   __le32_to_cpu(arg.phy_capab),
4888                   __le32_to_cpu(arg.num_rf_chains),
4889                   __le32_to_cpu(arg.eeprom_rd),
4890                   __le32_to_cpu(arg.num_mem_reqs));
4891
4892        dev_kfree_skb(skb);
4893        ar->svc_rdy_skb = NULL;
4894        complete(&ar->wmi.service_ready);
4895}
4896
4897void ath10k_wmi_event_service_ready(struct ath10k *ar, struct sk_buff *skb)
4898{
4899        ar->svc_rdy_skb = skb;
4900        queue_work(ar->workqueue_aux, &ar->svc_rdy_work);
4901}
4902
4903static int ath10k_wmi_op_pull_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
4904                                     struct wmi_rdy_ev_arg *arg)
4905{
4906        struct wmi_ready_event *ev = (void *)skb->data;
4907
4908        if (skb->len < sizeof(*ev))
4909                return -EPROTO;
4910
4911        skb_pull(skb, sizeof(*ev));
4912        arg->sw_version = ev->sw_version;
4913        arg->abi_version = ev->abi_version;
4914        arg->status = ev->status;
4915        arg->mac_addr = ev->mac_addr.addr;
4916
4917        return 0;
4918}
4919
4920static int ath10k_wmi_op_pull_roam_ev(struct ath10k *ar, struct sk_buff *skb,
4921                                      struct wmi_roam_ev_arg *arg)
4922{
4923        struct wmi_roam_ev *ev = (void *)skb->data;
4924
4925        if (skb->len < sizeof(*ev))
4926                return -EPROTO;
4927
4928        skb_pull(skb, sizeof(*ev));
4929        arg->vdev_id = ev->vdev_id;
4930        arg->reason = ev->reason;
4931
4932        return 0;
4933}
4934
4935static int ath10k_wmi_op_pull_echo_ev(struct ath10k *ar,
4936                                      struct sk_buff *skb,
4937                                      struct wmi_echo_ev_arg *arg)
4938{
4939        struct wmi_echo_event *ev = (void *)skb->data;
4940
4941        arg->value = ev->value;
4942
4943        return 0;
4944}
4945
4946int ath10k_wmi_event_ready(struct ath10k *ar, struct sk_buff *skb)
4947{
4948        struct wmi_rdy_ev_arg arg = {};
4949        int ret;
4950
4951        ret = ath10k_wmi_pull_rdy(ar, skb, &arg);
4952        if (ret) {
4953                ath10k_warn(ar, "failed to parse ready event: %d\n", ret);
4954                return ret;
4955        }
4956
4957        ath10k_dbg(ar, ATH10K_DBG_WMI,
4958                   "wmi event ready sw_version %u abi_version %u mac_addr %pM status %d\n",
4959                   __le32_to_cpu(arg.sw_version),
4960                   __le32_to_cpu(arg.abi_version),
4961                   arg.mac_addr,
4962                   __le32_to_cpu(arg.status));
4963
4964        ether_addr_copy(ar->mac_addr, arg.mac_addr);
4965        complete(&ar->wmi.unified_ready);
4966        return 0;
4967}
4968
4969static int ath10k_wmi_event_temperature(struct ath10k *ar, struct sk_buff *skb)
4970{
4971        const struct wmi_pdev_temperature_event *ev;
4972
4973        ev = (struct wmi_pdev_temperature_event *)skb->data;
4974        if (WARN_ON(skb->len < sizeof(*ev)))
4975                return -EPROTO;
4976
4977        ath10k_thermal_event_temperature(ar, __le32_to_cpu(ev->temperature));
4978        return 0;
4979}
4980
4981static int ath10k_wmi_event_pdev_bss_chan_info(struct ath10k *ar,
4982                                               struct sk_buff *skb)
4983{
4984        struct wmi_pdev_bss_chan_info_event *ev;
4985        struct survey_info *survey;
4986        u64 busy, total, tx, rx, rx_bss;
4987        u32 freq, noise_floor;
4988        u32 cc_freq_hz = ar->hw_params.channel_counters_freq_hz;
4989        int idx;
4990
4991        ev = (struct wmi_pdev_bss_chan_info_event *)skb->data;
4992        if (WARN_ON(skb->len < sizeof(*ev)))
4993                return -EPROTO;
4994
4995        freq        = __le32_to_cpu(ev->freq);
4996        noise_floor = __le32_to_cpu(ev->noise_floor);
4997        busy        = __le64_to_cpu(ev->cycle_busy);
4998        total       = __le64_to_cpu(ev->cycle_total);
4999        tx          = __le64_to_cpu(ev->cycle_tx);
5000        rx          = __le64_to_cpu(ev->cycle_rx);
5001        rx_bss      = __le64_to_cpu(ev->cycle_rx_bss);
5002
5003        ath10k_dbg(ar, ATH10K_DBG_WMI,
5004                   "wmi event pdev bss chan info:\n freq: %d noise: %d cycle: busy %llu total %llu tx %llu rx %llu rx_bss %llu\n",
5005                   freq, noise_floor, busy, total, tx, rx, rx_bss);
5006
5007        spin_lock_bh(&ar->data_lock);
5008        idx = freq_to_idx(ar, freq);
5009        if (idx >= ARRAY_SIZE(ar->survey)) {
5010                ath10k_warn(ar, "bss chan info: invalid frequency %d (idx %d out of bounds)\n",
5011                            freq, idx);
5012                goto exit;
5013        }
5014
5015        survey = &ar->survey[idx];
5016
5017        survey->noise     = noise_floor;
5018        survey->time      = div_u64(total, cc_freq_hz);
5019        survey->time_busy = div_u64(busy, cc_freq_hz);
5020        survey->time_rx   = div_u64(rx_bss, cc_freq_hz);
5021        survey->time_tx   = div_u64(tx, cc_freq_hz);
5022        survey->filled   |= (SURVEY_INFO_NOISE_DBM |
5023                             SURVEY_INFO_TIME |
5024                             SURVEY_INFO_TIME_BUSY |
5025                             SURVEY_INFO_TIME_RX |
5026                             SURVEY_INFO_TIME_TX);
5027exit:
5028        spin_unlock_bh(&ar->data_lock);
5029        complete(&ar->bss_survey_done);
5030        return 0;
5031}
5032
5033static inline void ath10k_wmi_queue_set_coverage_class_work(struct ath10k *ar)
5034{
5035        if (ar->hw_params.hw_ops->set_coverage_class) {
5036                spin_lock_bh(&ar->data_lock);
5037
5038                /* This call only ensures that the modified coverage class
5039                 * persists in case the firmware sets the registers back to
5040                 * their default value. So calling it is only necessary if the
5041                 * coverage class has a non-zero value.
5042                 */
5043                if (ar->fw_coverage.coverage_class)
5044                        queue_work(ar->workqueue, &ar->set_coverage_class_work);
5045
5046                spin_unlock_bh(&ar->data_lock);
5047        }
5048}
5049
5050static void ath10k_wmi_op_rx(struct ath10k *ar, struct sk_buff *skb)
5051{
5052        struct wmi_cmd_hdr *cmd_hdr;
5053        enum wmi_event_id id;
5054
5055        cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
5056        id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
5057
5058        if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
5059                goto out;
5060
5061        trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
5062
5063        switch (id) {
5064        case WMI_MGMT_RX_EVENTID:
5065                ath10k_wmi_event_mgmt_rx(ar, skb);
5066                /* mgmt_rx() owns the skb now! */
5067                return;
5068        case WMI_SCAN_EVENTID:
5069                ath10k_wmi_event_scan(ar, skb);
5070                ath10k_wmi_queue_set_coverage_class_work(ar);
5071                break;
5072        case WMI_CHAN_INFO_EVENTID:
5073                ath10k_wmi_event_chan_info(ar, skb);
5074                break;
5075        case WMI_ECHO_EVENTID:
5076                ath10k_wmi_event_echo(ar, skb);
5077                break;
5078        case WMI_DEBUG_MESG_EVENTID:
5079                ath10k_wmi_event_debug_mesg(ar, skb);
5080                ath10k_wmi_queue_set_coverage_class_work(ar);
5081                break;
5082        case WMI_UPDATE_STATS_EVENTID:
5083                ath10k_wmi_event_update_stats(ar, skb);
5084                break;
5085        case WMI_VDEV_START_RESP_EVENTID:
5086                ath10k_wmi_event_vdev_start_resp(ar, skb);
5087                ath10k_wmi_queue_set_coverage_class_work(ar);
5088                break;
5089        case WMI_VDEV_STOPPED_EVENTID:
5090                ath10k_wmi_event_vdev_stopped(ar, skb);
5091                ath10k_wmi_queue_set_coverage_class_work(ar);
5092                break;
5093        case WMI_PEER_STA_KICKOUT_EVENTID:
5094                ath10k_wmi_event_peer_sta_kickout(ar, skb);
5095                break;
5096        case WMI_HOST_SWBA_EVENTID:
5097                ath10k_wmi_event_host_swba(ar, skb);
5098                break;
5099        case WMI_TBTTOFFSET_UPDATE_EVENTID:
5100                ath10k_wmi_event_tbttoffset_update(ar, skb);
5101                break;
5102        case WMI_PHYERR_EVENTID:
5103                ath10k_wmi_event_phyerr(ar, skb);
5104                break;
5105        case WMI_ROAM_EVENTID:
5106                ath10k_wmi_event_roam(ar, skb);
5107                ath10k_wmi_queue_set_coverage_class_work(ar);
5108                break;
5109        case WMI_PROFILE_MATCH:
5110                ath10k_wmi_event_profile_match(ar, skb);
5111                break;
5112        case WMI_DEBUG_PRINT_EVENTID:
5113                ath10k_wmi_event_debug_print(ar, skb);
5114                ath10k_wmi_queue_set_coverage_class_work(ar);
5115                break;
5116        case WMI_PDEV_QVIT_EVENTID:
5117                ath10k_wmi_event_pdev_qvit(ar, skb);
5118                break;
5119        case WMI_WLAN_PROFILE_DATA_EVENTID:
5120                ath10k_wmi_event_wlan_profile_data(ar, skb);
5121                break;
5122        case WMI_RTT_MEASUREMENT_REPORT_EVENTID:
5123                ath10k_wmi_event_rtt_measurement_report(ar, skb);
5124                break;
5125        case WMI_TSF_MEASUREMENT_REPORT_EVENTID:
5126                ath10k_wmi_event_tsf_measurement_report(ar, skb);
5127                break;
5128        case WMI_RTT_ERROR_REPORT_EVENTID:
5129                ath10k_wmi_event_rtt_error_report(ar, skb);
5130                break;
5131        case WMI_WOW_WAKEUP_HOST_EVENTID:
5132                ath10k_wmi_event_wow_wakeup_host(ar, skb);
5133                break;
5134        case WMI_DCS_INTERFERENCE_EVENTID:
5135                ath10k_wmi_event_dcs_interference(ar, skb);
5136                break;
5137        case WMI_PDEV_TPC_CONFIG_EVENTID:
5138                ath10k_wmi_event_pdev_tpc_config(ar, skb);
5139                break;
5140        case WMI_PDEV_FTM_INTG_EVENTID:
5141                ath10k_wmi_event_pdev_ftm_intg(ar, skb);
5142                break;
5143        case WMI_GTK_OFFLOAD_STATUS_EVENTID:
5144                ath10k_wmi_event_gtk_offload_status(ar, skb);
5145                break;
5146        case WMI_GTK_REKEY_FAIL_EVENTID:
5147                ath10k_wmi_event_gtk_rekey_fail(ar, skb);
5148                break;
5149        case WMI_TX_DELBA_COMPLETE_EVENTID:
5150                ath10k_wmi_event_delba_complete(ar, skb);
5151                break;
5152        case WMI_TX_ADDBA_COMPLETE_EVENTID:
5153                ath10k_wmi_event_addba_complete(ar, skb);
5154                break;
5155        case WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID:
5156                ath10k_wmi_event_vdev_install_key_complete(ar, skb);
5157                break;
5158        case WMI_SERVICE_READY_EVENTID:
5159                ath10k_wmi_event_service_ready(ar, skb);
5160                return;
5161        case WMI_READY_EVENTID:
5162                ath10k_wmi_event_ready(ar, skb);
5163                ath10k_wmi_queue_set_coverage_class_work(ar);
5164                break;
5165        default:
5166                ath10k_warn(ar, "Unknown eventid: %d\n", id);
5167                break;
5168        }
5169
5170out:
5171        dev_kfree_skb(skb);
5172}
5173
5174static void ath10k_wmi_10_1_op_rx(struct ath10k *ar, struct sk_buff *skb)
5175{
5176        struct wmi_cmd_hdr *cmd_hdr;
5177        enum wmi_10x_event_id id;
5178        bool consumed;
5179
5180        cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
5181        id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
5182
5183        if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
5184                goto out;
5185
5186        trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
5187
5188        consumed = ath10k_tm_event_wmi(ar, id, skb);
5189
5190        /* Ready event must be handled normally also in UTF mode so that we
5191         * know the UTF firmware has booted, others we are just bypass WMI
5192         * events to testmode.
5193         */
5194        if (consumed && id != WMI_10X_READY_EVENTID) {
5195                ath10k_dbg(ar, ATH10K_DBG_WMI,
5196                           "wmi testmode consumed 0x%x\n", id);
5197                goto out;
5198        }
5199
5200        switch (id) {
5201        case WMI_10X_MGMT_RX_EVENTID:
5202                ath10k_wmi_event_mgmt_rx(ar, skb);
5203                /* mgmt_rx() owns the skb now! */
5204                return;
5205        case WMI_10X_SCAN_EVENTID:
5206                ath10k_wmi_event_scan(ar, skb);
5207                ath10k_wmi_queue_set_coverage_class_work(ar);
5208                break;
5209        case WMI_10X_CHAN_INFO_EVENTID:
5210                ath10k_wmi_event_chan_info(ar, skb);
5211                break;
5212        case WMI_10X_ECHO_EVENTID:
5213                ath10k_wmi_event_echo(ar, skb);
5214                break;
5215        case WMI_10X_DEBUG_MESG_EVENTID:
5216                ath10k_wmi_event_debug_mesg(ar, skb);
5217                ath10k_wmi_queue_set_coverage_class_work(ar);
5218                break;
5219        case WMI_10X_UPDATE_STATS_EVENTID:
5220                ath10k_wmi_event_update_stats(ar, skb);
5221                break;
5222        case WMI_10X_VDEV_START_RESP_EVENTID:
5223                ath10k_wmi_event_vdev_start_resp(ar, skb);
5224                ath10k_wmi_queue_set_coverage_class_work(ar);
5225                break;
5226        case WMI_10X_VDEV_STOPPED_EVENTID:
5227                ath10k_wmi_event_vdev_stopped(ar, skb);
5228                ath10k_wmi_queue_set_coverage_class_work(ar);
5229                break;
5230        case WMI_10X_PEER_STA_KICKOUT_EVENTID:
5231                ath10k_wmi_event_peer_sta_kickout(ar, skb);
5232                break;
5233        case WMI_10X_HOST_SWBA_EVENTID:
5234                ath10k_wmi_event_host_swba(ar, skb);
5235                break;
5236        case WMI_10X_TBTTOFFSET_UPDATE_EVENTID:
5237                ath10k_wmi_event_tbttoffset_update(ar, skb);
5238                break;
5239        case WMI_10X_PHYERR_EVENTID:
5240                ath10k_wmi_event_phyerr(ar, skb);
5241                break;
5242        case WMI_10X_ROAM_EVENTID:
5243                ath10k_wmi_event_roam(ar, skb);
5244                ath10k_wmi_queue_set_coverage_class_work(ar);
5245                break;
5246        case WMI_10X_PROFILE_MATCH:
5247                ath10k_wmi_event_profile_match(ar, skb);
5248                break;
5249        case WMI_10X_DEBUG_PRINT_EVENTID:
5250                ath10k_wmi_event_debug_print(ar, skb);
5251                ath10k_wmi_queue_set_coverage_class_work(ar);
5252                break;
5253        case WMI_10X_PDEV_QVIT_EVENTID:
5254                ath10k_wmi_event_pdev_qvit(ar, skb);
5255                break;
5256        case WMI_10X_WLAN_PROFILE_DATA_EVENTID:
5257                ath10k_wmi_event_wlan_profile_data(ar, skb);
5258                break;
5259        case WMI_10X_RTT_MEASUREMENT_REPORT_EVENTID:
5260                ath10k_wmi_event_rtt_measurement_report(ar, skb);
5261                break;
5262        case WMI_10X_TSF_MEASUREMENT_REPORT_EVENTID:
5263                ath10k_wmi_event_tsf_measurement_report(ar, skb);
5264                break;
5265        case WMI_10X_RTT_ERROR_REPORT_EVENTID:
5266                ath10k_wmi_event_rtt_error_report(ar, skb);
5267                break;
5268        case WMI_10X_WOW_WAKEUP_HOST_EVENTID:
5269                ath10k_wmi_event_wow_wakeup_host(ar, skb);
5270                break;
5271        case WMI_10X_DCS_INTERFERENCE_EVENTID:
5272                ath10k_wmi_event_dcs_interference(ar, skb);
5273                break;
5274        case WMI_10X_PDEV_TPC_CONFIG_EVENTID:
5275                ath10k_wmi_event_pdev_tpc_config(ar, skb);
5276                break;
5277        case WMI_10X_INST_RSSI_STATS_EVENTID:
5278                ath10k_wmi_event_inst_rssi_stats(ar, skb);
5279                break;
5280        case WMI_10X_VDEV_STANDBY_REQ_EVENTID:
5281                ath10k_wmi_event_vdev_standby_req(ar, skb);
5282                break;
5283        case WMI_10X_VDEV_RESUME_REQ_EVENTID:
5284                ath10k_wmi_event_vdev_resume_req(ar, skb);
5285                break;
5286        case WMI_10X_SERVICE_READY_EVENTID:
5287                ath10k_wmi_event_service_ready(ar, skb);
5288                return;
5289        case WMI_10X_READY_EVENTID:
5290                ath10k_wmi_event_ready(ar, skb);
5291                ath10k_wmi_queue_set_coverage_class_work(ar);
5292                break;
5293        case WMI_10X_PDEV_UTF_EVENTID:
5294                /* ignore utf events */
5295                break;
5296        default:
5297                ath10k_warn(ar, "Unknown eventid: %d\n", id);
5298                break;
5299        }
5300
5301out:
5302        dev_kfree_skb(skb);
5303}
5304
5305static void ath10k_wmi_10_2_op_rx(struct ath10k *ar, struct sk_buff *skb)
5306{
5307        struct wmi_cmd_hdr *cmd_hdr;
5308        enum wmi_10_2_event_id id;
5309        bool consumed;
5310
5311        cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
5312        id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
5313
5314        if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
5315                goto out;
5316
5317        trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
5318
5319        consumed = ath10k_tm_event_wmi(ar, id, skb);
5320
5321        /* Ready event must be handled normally also in UTF mode so that we
5322         * know the UTF firmware has booted, others we are just bypass WMI
5323         * events to testmode.
5324         */
5325        if (consumed && id != WMI_10_2_READY_EVENTID) {
5326                ath10k_dbg(ar, ATH10K_DBG_WMI,
5327                           "wmi testmode consumed 0x%x\n", id);
5328                goto out;
5329        }
5330
5331        switch (id) {
5332        case WMI_10_2_MGMT_RX_EVENTID:
5333                ath10k_wmi_event_mgmt_rx(ar, skb);
5334                /* mgmt_rx() owns the skb now! */
5335                return;
5336        case WMI_10_2_SCAN_EVENTID:
5337                ath10k_wmi_event_scan(ar, skb);
5338                ath10k_wmi_queue_set_coverage_class_work(ar);
5339                break;
5340        case WMI_10_2_CHAN_INFO_EVENTID:
5341                ath10k_wmi_event_chan_info(ar, skb);
5342                break;
5343        case WMI_10_2_ECHO_EVENTID:
5344                ath10k_wmi_event_echo(ar, skb);
5345                break;
5346        case WMI_10_2_DEBUG_MESG_EVENTID:
5347                ath10k_wmi_event_debug_mesg(ar, skb);
5348                ath10k_wmi_queue_set_coverage_class_work(ar);
5349                break;
5350        case WMI_10_2_UPDATE_STATS_EVENTID:
5351                ath10k_wmi_event_update_stats(ar, skb);
5352                break;
5353        case WMI_10_2_VDEV_START_RESP_EVENTID:
5354                ath10k_wmi_event_vdev_start_resp(ar, skb);
5355                ath10k_wmi_queue_set_coverage_class_work(ar);
5356                break;
5357        case WMI_10_2_VDEV_STOPPED_EVENTID:
5358                ath10k_wmi_event_vdev_stopped(ar, skb);
5359                ath10k_wmi_queue_set_coverage_class_work(ar);
5360                break;
5361        case WMI_10_2_PEER_STA_KICKOUT_EVENTID:
5362                ath10k_wmi_event_peer_sta_kickout(ar, skb);
5363                break;
5364        case WMI_10_2_HOST_SWBA_EVENTID:
5365                ath10k_wmi_event_host_swba(ar, skb);
5366                break;
5367        case WMI_10_2_TBTTOFFSET_UPDATE_EVENTID:
5368                ath10k_wmi_event_tbttoffset_update(ar, skb);
5369                break;
5370        case WMI_10_2_PHYERR_EVENTID:
5371                ath10k_wmi_event_phyerr(ar, skb);
5372                break;
5373        case WMI_10_2_ROAM_EVENTID:
5374                ath10k_wmi_event_roam(ar, skb);
5375                ath10k_wmi_queue_set_coverage_class_work(ar);
5376                break;
5377        case WMI_10_2_PROFILE_MATCH:
5378                ath10k_wmi_event_profile_match(ar, skb);
5379                break;
5380        case WMI_10_2_DEBUG_PRINT_EVENTID:
5381                ath10k_wmi_event_debug_print(ar, skb);
5382                ath10k_wmi_queue_set_coverage_class_work(ar);
5383                break;
5384        case WMI_10_2_PDEV_QVIT_EVENTID:
5385                ath10k_wmi_event_pdev_qvit(ar, skb);
5386                break;
5387        case WMI_10_2_WLAN_PROFILE_DATA_EVENTID:
5388                ath10k_wmi_event_wlan_profile_data(ar, skb);
5389                break;
5390        case WMI_10_2_RTT_MEASUREMENT_REPORT_EVENTID:
5391                ath10k_wmi_event_rtt_measurement_report(ar, skb);
5392                break;
5393        case WMI_10_2_TSF_MEASUREMENT_REPORT_EVENTID:
5394                ath10k_wmi_event_tsf_measurement_report(ar, skb);
5395                break;
5396        case WMI_10_2_RTT_ERROR_REPORT_EVENTID:
5397                ath10k_wmi_event_rtt_error_report(ar, skb);
5398                break;
5399        case WMI_10_2_WOW_WAKEUP_HOST_EVENTID:
5400                ath10k_wmi_event_wow_wakeup_host(ar, skb);
5401                break;
5402        case WMI_10_2_DCS_INTERFERENCE_EVENTID:
5403                ath10k_wmi_event_dcs_interference(ar, skb);
5404                break;
5405        case WMI_10_2_PDEV_TPC_CONFIG_EVENTID:
5406                ath10k_wmi_event_pdev_tpc_config(ar, skb);
5407                break;
5408        case WMI_10_2_INST_RSSI_STATS_EVENTID:
5409                ath10k_wmi_event_inst_rssi_stats(ar, skb);
5410                break;
5411        case WMI_10_2_VDEV_STANDBY_REQ_EVENTID:
5412                ath10k_wmi_event_vdev_standby_req(ar, skb);
5413                ath10k_wmi_queue_set_coverage_class_work(ar);
5414                break;
5415        case WMI_10_2_VDEV_RESUME_REQ_EVENTID:
5416                ath10k_wmi_event_vdev_resume_req(ar, skb);
5417                ath10k_wmi_queue_set_coverage_class_work(ar);
5418                break;
5419        case WMI_10_2_SERVICE_READY_EVENTID:
5420                ath10k_wmi_event_service_ready(ar, skb);
5421                return;
5422        case WMI_10_2_READY_EVENTID:
5423                ath10k_wmi_event_ready(ar, skb);
5424                ath10k_wmi_queue_set_coverage_class_work(ar);
5425                break;
5426        case WMI_10_2_PDEV_TEMPERATURE_EVENTID:
5427                ath10k_wmi_event_temperature(ar, skb);
5428                break;
5429        case WMI_10_2_PDEV_BSS_CHAN_INFO_EVENTID:
5430                ath10k_wmi_event_pdev_bss_chan_info(ar, skb);
5431                break;
5432        case WMI_10_2_RTT_KEEPALIVE_EVENTID:
5433        case WMI_10_2_GPIO_INPUT_EVENTID:
5434        case WMI_10_2_PEER_RATECODE_LIST_EVENTID:
5435        case WMI_10_2_GENERIC_BUFFER_EVENTID:
5436        case WMI_10_2_MCAST_BUF_RELEASE_EVENTID:
5437        case WMI_10_2_MCAST_LIST_AGEOUT_EVENTID:
5438        case WMI_10_2_WDS_PEER_EVENTID:
5439                ath10k_dbg(ar, ATH10K_DBG_WMI,
5440                           "received event id %d not implemented\n", id);
5441                break;
5442        default:
5443                ath10k_warn(ar, "Unknown eventid: %d\n", id);
5444                break;
5445        }
5446
5447out:
5448        dev_kfree_skb(skb);
5449}
5450
5451static void ath10k_wmi_10_4_op_rx(struct ath10k *ar, struct sk_buff *skb)
5452{
5453        struct wmi_cmd_hdr *cmd_hdr;
5454        enum wmi_10_4_event_id id;
5455        bool consumed;
5456
5457        cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
5458        id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
5459
5460        if (!skb_pull(skb, sizeof(struct wmi_cmd_hdr)))
5461                goto out;
5462
5463        trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
5464
5465        consumed = ath10k_tm_event_wmi(ar, id, skb);
5466
5467        /* Ready event must be handled normally also in UTF mode so that we
5468         * know the UTF firmware has booted, others we are just bypass WMI
5469         * events to testmode.
5470         */
5471        if (consumed && id != WMI_10_4_READY_EVENTID) {
5472                ath10k_dbg(ar, ATH10K_DBG_WMI,
5473                           "wmi testmode consumed 0x%x\n", id);
5474                goto out;
5475        }
5476
5477        switch (id) {
5478        case WMI_10_4_MGMT_RX_EVENTID:
5479                ath10k_wmi_event_mgmt_rx(ar, skb);
5480                /* mgmt_rx() owns the skb now! */
5481                return;
5482        case WMI_10_4_ECHO_EVENTID:
5483                ath10k_wmi_event_echo(ar, skb);
5484                break;
5485        case WMI_10_4_DEBUG_MESG_EVENTID:
5486                ath10k_wmi_event_debug_mesg(ar, skb);
5487                ath10k_wmi_queue_set_coverage_class_work(ar);
5488                break;
5489        case WMI_10_4_SERVICE_READY_EVENTID:
5490                ath10k_wmi_event_service_ready(ar, skb);
5491                return;
5492        case WMI_10_4_SCAN_EVENTID:
5493                ath10k_wmi_event_scan(ar, skb);
5494                ath10k_wmi_queue_set_coverage_class_work(ar);
5495                break;
5496        case WMI_10_4_CHAN_INFO_EVENTID:
5497                ath10k_wmi_event_chan_info(ar, skb);
5498                break;
5499        case WMI_10_4_PHYERR_EVENTID:
5500                ath10k_wmi_event_phyerr(ar, skb);
5501                break;
5502        case WMI_10_4_READY_EVENTID:
5503                ath10k_wmi_event_ready(ar, skb);
5504                ath10k_wmi_queue_set_coverage_class_work(ar);
5505                break;
5506        case WMI_10_4_PEER_STA_KICKOUT_EVENTID:
5507                ath10k_wmi_event_peer_sta_kickout(ar, skb);
5508                break;
5509        case WMI_10_4_ROAM_EVENTID:
5510                ath10k_wmi_event_roam(ar, skb);
5511                ath10k_wmi_queue_set_coverage_class_work(ar);
5512                break;
5513        case WMI_10_4_HOST_SWBA_EVENTID:
5514                ath10k_wmi_event_host_swba(ar, skb);
5515                break;
5516        case WMI_10_4_TBTTOFFSET_UPDATE_EVENTID:
5517                ath10k_wmi_event_tbttoffset_update(ar, skb);
5518                break;
5519        case WMI_10_4_DEBUG_PRINT_EVENTID:
5520                ath10k_wmi_event_debug_print(ar, skb);
5521                ath10k_wmi_queue_set_coverage_class_work(ar);
5522                break;
5523        case WMI_10_4_VDEV_START_RESP_EVENTID:
5524                ath10k_wmi_event_vdev_start_resp(ar, skb);
5525                ath10k_wmi_queue_set_coverage_class_work(ar);
5526                break;
5527        case WMI_10_4_VDEV_STOPPED_EVENTID:
5528                ath10k_wmi_event_vdev_stopped(ar, skb);
5529                ath10k_wmi_queue_set_coverage_class_work(ar);
5530                break;
5531        case WMI_10_4_WOW_WAKEUP_HOST_EVENTID:
5532        case WMI_10_4_PEER_RATECODE_LIST_EVENTID:
5533        case WMI_10_4_WDS_PEER_EVENTID:
5534                ath10k_dbg(ar, ATH10K_DBG_WMI,
5535                           "received event id %d not implemented\n", id);
5536                break;
5537        case WMI_10_4_UPDATE_STATS_EVENTID:
5538                ath10k_wmi_event_update_stats(ar, skb);
5539                break;
5540        case WMI_10_4_PDEV_TEMPERATURE_EVENTID:
5541                ath10k_wmi_event_temperature(ar, skb);
5542                break;
5543        case WMI_10_4_PDEV_BSS_CHAN_INFO_EVENTID:
5544                ath10k_wmi_event_pdev_bss_chan_info(ar, skb);
5545                break;
5546        case WMI_10_4_PDEV_TPC_CONFIG_EVENTID:
5547                ath10k_wmi_event_pdev_tpc_config(ar, skb);
5548                break;
5549        case WMI_10_4_TDLS_PEER_EVENTID:
5550                ath10k_wmi_handle_tdls_peer_event(ar, skb);
5551                break;
5552        default:
5553                ath10k_warn(ar, "Unknown eventid: %d\n", id);
5554                break;
5555        }
5556
5557out:
5558        dev_kfree_skb(skb);
5559}
5560
5561static void ath10k_wmi_process_rx(struct ath10k *ar, struct sk_buff *skb)
5562{
5563        int ret;
5564
5565        ret = ath10k_wmi_rx(ar, skb);
5566        if (ret)
5567                ath10k_warn(ar, "failed to process wmi rx: %d\n", ret);
5568}
5569
5570int ath10k_wmi_connect(struct ath10k *ar)
5571{
5572        int status;
5573        struct ath10k_htc_svc_conn_req conn_req;
5574        struct ath10k_htc_svc_conn_resp conn_resp;
5575
5576        memset(&conn_req, 0, sizeof(conn_req));
5577        memset(&conn_resp, 0, sizeof(conn_resp));
5578
5579        /* these fields are the same for all service endpoints */
5580        conn_req.ep_ops.ep_tx_complete = ath10k_wmi_htc_tx_complete;
5581        conn_req.ep_ops.ep_rx_complete = ath10k_wmi_process_rx;
5582        conn_req.ep_ops.ep_tx_credits = ath10k_wmi_op_ep_tx_credits;
5583
5584        /* connect to control service */
5585        conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL;
5586
5587        status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp);
5588        if (status) {
5589                ath10k_warn(ar, "failed to connect to WMI CONTROL service status: %d\n",
5590                            status);
5591                return status;
5592        }
5593
5594        ar->wmi.eid = conn_resp.eid;
5595        return 0;
5596}
5597
5598static struct sk_buff *
5599ath10k_wmi_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16 rd5g,
5600                              u16 ctl2g, u16 ctl5g,
5601                              enum wmi_dfs_region dfs_reg)
5602{
5603        struct wmi_pdev_set_regdomain_cmd *cmd;
5604        struct sk_buff *skb;
5605
5606        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5607        if (!skb)
5608                return ERR_PTR(-ENOMEM);
5609
5610        cmd = (struct wmi_pdev_set_regdomain_cmd *)skb->data;
5611        cmd->reg_domain = __cpu_to_le32(rd);
5612        cmd->reg_domain_2G = __cpu_to_le32(rd2g);
5613        cmd->reg_domain_5G = __cpu_to_le32(rd5g);
5614        cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g);
5615        cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
5616
5617        ath10k_dbg(ar, ATH10K_DBG_WMI,
5618                   "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x\n",
5619                   rd, rd2g, rd5g, ctl2g, ctl5g);
5620        return skb;
5621}
5622
5623static struct sk_buff *
5624ath10k_wmi_10x_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16
5625                                  rd5g, u16 ctl2g, u16 ctl5g,
5626                                  enum wmi_dfs_region dfs_reg)
5627{
5628        struct wmi_pdev_set_regdomain_cmd_10x *cmd;
5629        struct sk_buff *skb;
5630
5631        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5632        if (!skb)
5633                return ERR_PTR(-ENOMEM);
5634
5635        cmd = (struct wmi_pdev_set_regdomain_cmd_10x *)skb->data;
5636        cmd->reg_domain = __cpu_to_le32(rd);
5637        cmd->reg_domain_2G = __cpu_to_le32(rd2g);
5638        cmd->reg_domain_5G = __cpu_to_le32(rd5g);
5639        cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g);
5640        cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
5641        cmd->dfs_domain = __cpu_to_le32(dfs_reg);
5642
5643        ath10k_dbg(ar, ATH10K_DBG_WMI,
5644                   "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x dfs_region %x\n",
5645                   rd, rd2g, rd5g, ctl2g, ctl5g, dfs_reg);
5646        return skb;
5647}
5648
5649static struct sk_buff *
5650ath10k_wmi_op_gen_pdev_suspend(struct ath10k *ar, u32 suspend_opt)
5651{
5652        struct wmi_pdev_suspend_cmd *cmd;
5653        struct sk_buff *skb;
5654
5655        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5656        if (!skb)
5657                return ERR_PTR(-ENOMEM);
5658
5659        cmd = (struct wmi_pdev_suspend_cmd *)skb->data;
5660        cmd->suspend_opt = __cpu_to_le32(suspend_opt);
5661
5662        return skb;
5663}
5664
5665static struct sk_buff *
5666ath10k_wmi_op_gen_pdev_resume(struct ath10k *ar)
5667{
5668        struct sk_buff *skb;
5669
5670        skb = ath10k_wmi_alloc_skb(ar, 0);
5671        if (!skb)
5672                return ERR_PTR(-ENOMEM);
5673
5674        return skb;
5675}
5676
5677static struct sk_buff *
5678ath10k_wmi_op_gen_pdev_set_param(struct ath10k *ar, u32 id, u32 value)
5679{
5680        struct wmi_pdev_set_param_cmd *cmd;
5681        struct sk_buff *skb;
5682
5683        if (id == WMI_PDEV_PARAM_UNSUPPORTED) {
5684                ath10k_warn(ar, "pdev param %d not supported by firmware\n",
5685                            id);
5686                return ERR_PTR(-EOPNOTSUPP);
5687        }
5688
5689        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5690        if (!skb)
5691                return ERR_PTR(-ENOMEM);
5692
5693        cmd = (struct wmi_pdev_set_param_cmd *)skb->data;
5694        cmd->param_id    = __cpu_to_le32(id);
5695        cmd->param_value = __cpu_to_le32(value);
5696
5697        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set param %d value %d\n",
5698                   id, value);
5699        return skb;
5700}
5701
5702void ath10k_wmi_put_host_mem_chunks(struct ath10k *ar,
5703                                    struct wmi_host_mem_chunks *chunks)
5704{
5705        struct host_memory_chunk *chunk;
5706        int i;
5707
5708        chunks->count = __cpu_to_le32(ar->wmi.num_mem_chunks);
5709
5710        for (i = 0; i < ar->wmi.num_mem_chunks; i++) {
5711                chunk = &chunks->items[i];
5712                chunk->ptr = __cpu_to_le32(ar->wmi.mem_chunks[i].paddr);
5713                chunk->size = __cpu_to_le32(ar->wmi.mem_chunks[i].len);
5714                chunk->req_id = __cpu_to_le32(ar->wmi.mem_chunks[i].req_id);
5715
5716                ath10k_dbg(ar, ATH10K_DBG_WMI,
5717                           "wmi chunk %d len %d requested, addr 0x%llx\n",
5718                           i,
5719                           ar->wmi.mem_chunks[i].len,
5720                           (unsigned long long)ar->wmi.mem_chunks[i].paddr);
5721        }
5722}
5723
5724static struct sk_buff *ath10k_wmi_op_gen_init(struct ath10k *ar)
5725{
5726        struct wmi_init_cmd *cmd;
5727        struct sk_buff *buf;
5728        struct wmi_resource_config config = {};
5729        u32 len, val;
5730
5731        config.num_vdevs = __cpu_to_le32(TARGET_NUM_VDEVS);
5732        config.num_peers = __cpu_to_le32(TARGET_NUM_PEERS);
5733        config.num_offload_peers = __cpu_to_le32(TARGET_NUM_OFFLOAD_PEERS);
5734
5735        config.num_offload_reorder_bufs =
5736                __cpu_to_le32(TARGET_NUM_OFFLOAD_REORDER_BUFS);
5737
5738        config.num_peer_keys = __cpu_to_le32(TARGET_NUM_PEER_KEYS);
5739        config.num_tids = __cpu_to_le32(TARGET_NUM_TIDS);
5740        config.ast_skid_limit = __cpu_to_le32(TARGET_AST_SKID_LIMIT);
5741        config.tx_chain_mask = __cpu_to_le32(TARGET_TX_CHAIN_MASK);
5742        config.rx_chain_mask = __cpu_to_le32(TARGET_RX_CHAIN_MASK);
5743        config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
5744        config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
5745        config.rx_timeout_pri_be = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
5746        config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_RX_TIMEOUT_HI_PRI);
5747        config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
5748        config.scan_max_pending_reqs =
5749                __cpu_to_le32(TARGET_SCAN_MAX_PENDING_REQS);
5750
5751        config.bmiss_offload_max_vdev =
5752                __cpu_to_le32(TARGET_BMISS_OFFLOAD_MAX_VDEV);
5753
5754        config.roam_offload_max_vdev =
5755                __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_VDEV);
5756
5757        config.roam_offload_max_ap_profiles =
5758                __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_AP_PROFILES);
5759
5760        config.num_mcast_groups = __cpu_to_le32(TARGET_NUM_MCAST_GROUPS);
5761        config.num_mcast_table_elems =
5762                __cpu_to_le32(TARGET_NUM_MCAST_TABLE_ELEMS);
5763
5764        config.mcast2ucast_mode = __cpu_to_le32(TARGET_MCAST2UCAST_MODE);
5765        config.tx_dbg_log_size = __cpu_to_le32(TARGET_TX_DBG_LOG_SIZE);
5766        config.num_wds_entries = __cpu_to_le32(TARGET_NUM_WDS_ENTRIES);
5767        config.dma_burst_size = __cpu_to_le32(TARGET_DMA_BURST_SIZE);
5768        config.mac_aggr_delim = __cpu_to_le32(TARGET_MAC_AGGR_DELIM);
5769
5770        val = TARGET_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
5771        config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
5772
5773        config.vow_config = __cpu_to_le32(TARGET_VOW_CONFIG);
5774
5775        config.gtk_offload_max_vdev =
5776                __cpu_to_le32(TARGET_GTK_OFFLOAD_MAX_VDEV);
5777
5778        config.num_msdu_desc = __cpu_to_le32(TARGET_NUM_MSDU_DESC);
5779        config.max_frag_entries = __cpu_to_le32(TARGET_MAX_FRAG_ENTRIES);
5780
5781        len = sizeof(*cmd) +
5782              (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5783
5784        buf = ath10k_wmi_alloc_skb(ar, len);
5785        if (!buf)
5786                return ERR_PTR(-ENOMEM);
5787
5788        cmd = (struct wmi_init_cmd *)buf->data;
5789
5790        memcpy(&cmd->resource_config, &config, sizeof(config));
5791        ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
5792
5793        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init\n");
5794        return buf;
5795}
5796
5797static struct sk_buff *ath10k_wmi_10_1_op_gen_init(struct ath10k *ar)
5798{
5799        struct wmi_init_cmd_10x *cmd;
5800        struct sk_buff *buf;
5801        struct wmi_resource_config_10x config = {};
5802        u32 len, val;
5803
5804        config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS);
5805        config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS);
5806        config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS);
5807        config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS);
5808        config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT);
5809        config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK);
5810        config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK);
5811        config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5812        config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5813        config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5814        config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI);
5815        config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
5816        config.scan_max_pending_reqs =
5817                __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS);
5818
5819        config.bmiss_offload_max_vdev =
5820                __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV);
5821
5822        config.roam_offload_max_vdev =
5823                __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV);
5824
5825        config.roam_offload_max_ap_profiles =
5826                __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES);
5827
5828        config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS);
5829        config.num_mcast_table_elems =
5830                __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS);
5831
5832        config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE);
5833        config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE);
5834        config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES);
5835        config.dma_burst_size = __cpu_to_le32(TARGET_10X_DMA_BURST_SIZE);
5836        config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM);
5837
5838        val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
5839        config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
5840
5841        config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG);
5842
5843        config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC);
5844        config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES);
5845
5846        len = sizeof(*cmd) +
5847              (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5848
5849        buf = ath10k_wmi_alloc_skb(ar, len);
5850        if (!buf)
5851                return ERR_PTR(-ENOMEM);
5852
5853        cmd = (struct wmi_init_cmd_10x *)buf->data;
5854
5855        memcpy(&cmd->resource_config, &config, sizeof(config));
5856        ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
5857
5858        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10x\n");
5859        return buf;
5860}
5861
5862static struct sk_buff *ath10k_wmi_10_2_op_gen_init(struct ath10k *ar)
5863{
5864        struct wmi_init_cmd_10_2 *cmd;
5865        struct sk_buff *buf;
5866        struct wmi_resource_config_10x config = {};
5867        u32 len, val, features;
5868
5869        config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS);
5870        config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS);
5871
5872        if (ath10k_peer_stats_enabled(ar)) {
5873                config.num_peers = __cpu_to_le32(TARGET_10X_TX_STATS_NUM_PEERS);
5874                config.num_tids = __cpu_to_le32(TARGET_10X_TX_STATS_NUM_TIDS);
5875        } else {
5876                config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS);
5877                config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS);
5878        }
5879
5880        config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT);
5881        config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK);
5882        config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK);
5883        config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5884        config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5885        config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5886        config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI);
5887        config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
5888
5889        config.scan_max_pending_reqs =
5890                __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS);
5891
5892        config.bmiss_offload_max_vdev =
5893                __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV);
5894
5895        config.roam_offload_max_vdev =
5896                __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV);
5897
5898        config.roam_offload_max_ap_profiles =
5899                __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES);
5900
5901        config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS);
5902        config.num_mcast_table_elems =
5903                __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS);
5904
5905        config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE);
5906        config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE);
5907        config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES);
5908        config.dma_burst_size = __cpu_to_le32(TARGET_10_2_DMA_BURST_SIZE);
5909        config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM);
5910
5911        val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
5912        config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
5913
5914        config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG);
5915
5916        config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC);
5917        config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES);
5918
5919        len = sizeof(*cmd) +
5920              (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5921
5922        buf = ath10k_wmi_alloc_skb(ar, len);
5923        if (!buf)
5924                return ERR_PTR(-ENOMEM);
5925
5926        cmd = (struct wmi_init_cmd_10_2 *)buf->data;
5927
5928        features = WMI_10_2_RX_BATCH_MODE;
5929
5930        if (test_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags) &&
5931            test_bit(WMI_SERVICE_COEX_GPIO, ar->wmi.svc_map))
5932                features |= WMI_10_2_COEX_GPIO;
5933
5934        if (ath10k_peer_stats_enabled(ar))
5935                features |= WMI_10_2_PEER_STATS;
5936
5937        if (test_bit(WMI_SERVICE_BSS_CHANNEL_INFO_64, ar->wmi.svc_map))
5938                features |= WMI_10_2_BSS_CHAN_INFO;
5939
5940        cmd->resource_config.feature_mask = __cpu_to_le32(features);
5941
5942        memcpy(&cmd->resource_config.common, &config, sizeof(config));
5943        ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
5944
5945        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.2\n");
5946        return buf;
5947}
5948
5949static struct sk_buff *ath10k_wmi_10_4_op_gen_init(struct ath10k *ar)
5950{
5951        struct wmi_init_cmd_10_4 *cmd;
5952        struct sk_buff *buf;
5953        struct wmi_resource_config_10_4 config = {};
5954        u32 len;
5955
5956        config.num_vdevs = __cpu_to_le32(ar->max_num_vdevs);
5957        config.num_peers = __cpu_to_le32(ar->max_num_peers);
5958        config.num_active_peers = __cpu_to_le32(ar->num_active_peers);
5959        config.num_tids = __cpu_to_le32(ar->num_tids);
5960
5961        config.num_offload_peers = __cpu_to_le32(TARGET_10_4_NUM_OFFLOAD_PEERS);
5962        config.num_offload_reorder_buffs =
5963                        __cpu_to_le32(TARGET_10_4_NUM_OFFLOAD_REORDER_BUFFS);
5964        config.num_peer_keys  = __cpu_to_le32(TARGET_10_4_NUM_PEER_KEYS);
5965        config.ast_skid_limit = __cpu_to_le32(TARGET_10_4_AST_SKID_LIMIT);
5966        config.tx_chain_mask  = __cpu_to_le32(ar->hw_params.tx_chain_mask);
5967        config.rx_chain_mask  = __cpu_to_le32(ar->hw_params.rx_chain_mask);
5968
5969        config.rx_timeout_pri[0] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_LO_PRI);
5970        config.rx_timeout_pri[1] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_LO_PRI);
5971        config.rx_timeout_pri[2] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_LO_PRI);
5972        config.rx_timeout_pri[3] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_HI_PRI);
5973
5974        config.rx_decap_mode        = __cpu_to_le32(ar->wmi.rx_decap_mode);
5975        config.scan_max_pending_req = __cpu_to_le32(TARGET_10_4_SCAN_MAX_REQS);
5976        config.bmiss_offload_max_vdev =
5977                        __cpu_to_le32(TARGET_10_4_BMISS_OFFLOAD_MAX_VDEV);
5978        config.roam_offload_max_vdev  =
5979                        __cpu_to_le32(TARGET_10_4_ROAM_OFFLOAD_MAX_VDEV);
5980        config.roam_offload_max_ap_profiles =
5981                        __cpu_to_le32(TARGET_10_4_ROAM_OFFLOAD_MAX_PROFILES);
5982        config.num_mcast_groups = __cpu_to_le32(TARGET_10_4_NUM_MCAST_GROUPS);
5983        config.num_mcast_table_elems =
5984                        __cpu_to_le32(TARGET_10_4_NUM_MCAST_TABLE_ELEMS);
5985
5986        config.mcast2ucast_mode = __cpu_to_le32(TARGET_10_4_MCAST2UCAST_MODE);
5987        config.tx_dbg_log_size  = __cpu_to_le32(TARGET_10_4_TX_DBG_LOG_SIZE);
5988        config.num_wds_entries  = __cpu_to_le32(TARGET_10_4_NUM_WDS_ENTRIES);
5989        config.dma_burst_size   = __cpu_to_le32(TARGET_10_4_DMA_BURST_SIZE);
5990        config.mac_aggr_delim   = __cpu_to_le32(TARGET_10_4_MAC_AGGR_DELIM);
5991
5992        config.rx_skip_defrag_timeout_dup_detection_check =
5993          __cpu_to_le32(TARGET_10_4_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK);
5994
5995        config.vow_config = __cpu_to_le32(TARGET_10_4_VOW_CONFIG);
5996        config.gtk_offload_max_vdev =
5997                        __cpu_to_le32(TARGET_10_4_GTK_OFFLOAD_MAX_VDEV);
5998        config.num_msdu_desc = __cpu_to_le32(ar->htt.max_num_pending_tx);
5999        config.max_frag_entries = __cpu_to_le32(TARGET_10_4_11AC_TX_MAX_FRAGS);
6000        config.max_peer_ext_stats =
6001                        __cpu_to_le32(TARGET_10_4_MAX_PEER_EXT_STATS);
6002        config.smart_ant_cap = __cpu_to_le32(TARGET_10_4_SMART_ANT_CAP);
6003
6004        config.bk_minfree = __cpu_to_le32(TARGET_10_4_BK_MIN_FREE);
6005        config.be_minfree = __cpu_to_le32(TARGET_10_4_BE_MIN_FREE);
6006        config.vi_minfree = __cpu_to_le32(TARGET_10_4_VI_MIN_FREE);
6007        config.vo_minfree = __cpu_to_le32(TARGET_10_4_VO_MIN_FREE);
6008
6009        config.rx_batchmode = __cpu_to_le32(TARGET_10_4_RX_BATCH_MODE);
6010        config.tt_support =
6011                        __cpu_to_le32(TARGET_10_4_THERMAL_THROTTLING_CONFIG);
6012        config.atf_config = __cpu_to_le32(TARGET_10_4_ATF_CONFIG);
6013        config.iphdr_pad_config = __cpu_to_le32(TARGET_10_4_IPHDR_PAD_CONFIG);
6014        config.qwrap_config = __cpu_to_le32(TARGET_10_4_QWRAP_CONFIG);
6015
6016        len = sizeof(*cmd) +
6017              (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
6018
6019        buf = ath10k_wmi_alloc_skb(ar, len);
6020        if (!buf)
6021                return ERR_PTR(-ENOMEM);
6022
6023        cmd = (struct wmi_init_cmd_10_4 *)buf->data;
6024        memcpy(&cmd->resource_config, &config, sizeof(config));
6025        ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
6026
6027        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.4\n");
6028        return buf;
6029}
6030
6031int ath10k_wmi_start_scan_verify(const struct wmi_start_scan_arg *arg)
6032{
6033        if (arg->ie_len > WLAN_SCAN_PARAMS_MAX_IE_LEN)
6034                return -EINVAL;
6035        if (arg->n_channels > ARRAY_SIZE(arg->channels))
6036                return -EINVAL;
6037        if (arg->n_ssids > WLAN_SCAN_PARAMS_MAX_SSID)
6038                return -EINVAL;
6039        if (arg->n_bssids > WLAN_SCAN_PARAMS_MAX_BSSID)
6040                return -EINVAL;
6041
6042        return 0;
6043}
6044
6045static size_t
6046ath10k_wmi_start_scan_tlvs_len(const struct wmi_start_scan_arg *arg)
6047{
6048        int len = 0;
6049
6050        if (arg->ie_len) {
6051                len += sizeof(struct wmi_ie_data);
6052                len += roundup(arg->ie_len, 4);
6053        }
6054
6055        if (arg->n_channels) {
6056                len += sizeof(struct wmi_chan_list);
6057                len += sizeof(__le32) * arg->n_channels;
6058        }
6059
6060        if (arg->n_ssids) {
6061                len += sizeof(struct wmi_ssid_list);
6062                len += sizeof(struct wmi_ssid) * arg->n_ssids;
6063        }
6064
6065        if (arg->n_bssids) {
6066                len += sizeof(struct wmi_bssid_list);
6067                len += sizeof(struct wmi_mac_addr) * arg->n_bssids;
6068        }
6069
6070        return len;
6071}
6072
6073void ath10k_wmi_put_start_scan_common(struct wmi_start_scan_common *cmn,
6074                                      const struct wmi_start_scan_arg *arg)
6075{
6076        u32 scan_id;
6077        u32 scan_req_id;
6078
6079        scan_id  = WMI_HOST_SCAN_REQ_ID_PREFIX;
6080        scan_id |= arg->scan_id;
6081
6082        scan_req_id  = WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
6083        scan_req_id |= arg->scan_req_id;
6084
6085        cmn->scan_id            = __cpu_to_le32(scan_id);
6086        cmn->scan_req_id        = __cpu_to_le32(scan_req_id);
6087        cmn->vdev_id            = __cpu_to_le32(arg->vdev_id);
6088        cmn->scan_priority      = __cpu_to_le32(arg->scan_priority);
6089        cmn->notify_scan_events = __cpu_to_le32(arg->notify_scan_events);
6090        cmn->dwell_time_active  = __cpu_to_le32(arg->dwell_time_active);
6091        cmn->dwell_time_passive = __cpu_to_le32(arg->dwell_time_passive);
6092        cmn->min_rest_time      = __cpu_to_le32(arg->min_rest_time);
6093        cmn->max_rest_time      = __cpu_to_le32(arg->max_rest_time);
6094        cmn->repeat_probe_time  = __cpu_to_le32(arg->repeat_probe_time);
6095        cmn->probe_spacing_time = __cpu_to_le32(arg->probe_spacing_time);
6096        cmn->idle_time          = __cpu_to_le32(arg->idle_time);
6097        cmn->max_scan_time      = __cpu_to_le32(arg->max_scan_time);
6098        cmn->probe_delay        = __cpu_to_le32(arg->probe_delay);
6099        cmn->scan_ctrl_flags    = __cpu_to_le32(arg->scan_ctrl_flags);
6100}
6101
6102static void
6103ath10k_wmi_put_start_scan_tlvs(struct wmi_start_scan_tlvs *tlvs,
6104                               const struct wmi_start_scan_arg *arg)
6105{
6106        struct wmi_ie_data *ie;
6107        struct wmi_chan_list *channels;
6108        struct wmi_ssid_list *ssids;
6109        struct wmi_bssid_list *bssids;
6110        void *ptr = tlvs->tlvs;
6111        int i;
6112
6113        if (arg->n_channels) {
6114                channels = ptr;
6115                channels->tag = __cpu_to_le32(WMI_CHAN_LIST_TAG);
6116                channels->num_chan = __cpu_to_le32(arg->n_channels);
6117
6118                for (i = 0; i < arg->n_channels; i++)
6119                        channels->channel_list[i].freq =
6120                                __cpu_to_le16(arg->channels[i]);
6121
6122                ptr += sizeof(*channels);
6123                ptr += sizeof(__le32) * arg->n_channels;
6124        }
6125
6126        if (arg->n_ssids) {
6127                ssids = ptr;
6128                ssids->tag = __cpu_to_le32(WMI_SSID_LIST_TAG);
6129                ssids->num_ssids = __cpu_to_le32(arg->n_ssids);
6130
6131                for (i = 0; i < arg->n_ssids; i++) {
6132                        ssids->ssids[i].ssid_len =
6133                                __cpu_to_le32(arg->ssids[i].len);
6134                        memcpy(&ssids->ssids[i].ssid,
6135                               arg->ssids[i].ssid,
6136                               arg->ssids[i].len);
6137                }
6138
6139                ptr += sizeof(*ssids);
6140                ptr += sizeof(struct wmi_ssid) * arg->n_ssids;
6141        }
6142
6143        if (arg->n_bssids) {
6144                bssids = ptr;
6145                bssids->tag = __cpu_to_le32(WMI_BSSID_LIST_TAG);
6146                bssids->num_bssid = __cpu_to_le32(arg->n_bssids);
6147
6148                for (i = 0; i < arg->n_bssids; i++)
6149                        ether_addr_copy(bssids->bssid_list[i].addr,
6150                                        arg->bssids[i].bssid);
6151
6152                ptr += sizeof(*bssids);
6153                ptr += sizeof(struct wmi_mac_addr) * arg->n_bssids;
6154        }
6155
6156        if (arg->ie_len) {
6157                ie = ptr;
6158                ie->tag = __cpu_to_le32(WMI_IE_TAG);
6159                ie->ie_len = __cpu_to_le32(arg->ie_len);
6160                memcpy(ie->ie_data, arg->ie, arg->ie_len);
6161
6162                ptr += sizeof(*ie);
6163                ptr += roundup(arg->ie_len, 4);
6164        }
6165}
6166
6167static struct sk_buff *
6168ath10k_wmi_op_gen_start_scan(struct ath10k *ar,
6169                             const struct wmi_start_scan_arg *arg)
6170{
6171        struct wmi_start_scan_cmd *cmd;
6172        struct sk_buff *skb;
6173        size_t len;
6174        int ret;
6175
6176        ret = ath10k_wmi_start_scan_verify(arg);
6177        if (ret)
6178                return ERR_PTR(ret);
6179
6180        len = sizeof(*cmd) + ath10k_wmi_start_scan_tlvs_len(arg);
6181        skb = ath10k_wmi_alloc_skb(ar, len);
6182        if (!skb)
6183                return ERR_PTR(-ENOMEM);
6184
6185        cmd = (struct wmi_start_scan_cmd *)skb->data;
6186
6187        ath10k_wmi_put_start_scan_common(&cmd->common, arg);
6188        ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
6189
6190        cmd->burst_duration_ms = __cpu_to_le32(0);
6191
6192        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi start scan\n");
6193        return skb;
6194}
6195
6196static struct sk_buff *
6197ath10k_wmi_10x_op_gen_start_scan(struct ath10k *ar,
6198                                 const struct wmi_start_scan_arg *arg)
6199{
6200        struct wmi_10x_start_scan_cmd *cmd;
6201        struct sk_buff *skb;
6202        size_t len;
6203        int ret;
6204
6205        ret = ath10k_wmi_start_scan_verify(arg);
6206        if (ret)
6207                return ERR_PTR(ret);
6208
6209        len = sizeof(*cmd) + ath10k_wmi_start_scan_tlvs_len(arg);
6210        skb = ath10k_wmi_alloc_skb(ar, len);
6211        if (!skb)
6212                return ERR_PTR(-ENOMEM);
6213
6214        cmd = (struct wmi_10x_start_scan_cmd *)skb->data;
6215
6216        ath10k_wmi_put_start_scan_common(&cmd->common, arg);
6217        ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
6218
6219        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi 10x start scan\n");
6220        return skb;
6221}
6222
6223void ath10k_wmi_start_scan_init(struct ath10k *ar,
6224                                struct wmi_start_scan_arg *arg)
6225{
6226        /* setup commonly used values */
6227        arg->scan_req_id = 1;
6228        arg->scan_priority = WMI_SCAN_PRIORITY_LOW;
6229        arg->dwell_time_active = 50;
6230        arg->dwell_time_passive = 150;
6231        arg->min_rest_time = 50;
6232        arg->max_rest_time = 500;
6233        arg->repeat_probe_time = 0;
6234        arg->probe_spacing_time = 0;
6235        arg->idle_time = 0;
6236        arg->max_scan_time = 20000;
6237        arg->probe_delay = 5;
6238        arg->notify_scan_events = WMI_SCAN_EVENT_STARTED
6239                | WMI_SCAN_EVENT_COMPLETED
6240                | WMI_SCAN_EVENT_BSS_CHANNEL
6241                | WMI_SCAN_EVENT_FOREIGN_CHANNEL
6242                | WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT
6243                | WMI_SCAN_EVENT_DEQUEUED;
6244        arg->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
6245        arg->n_bssids = 1;
6246        arg->bssids[0].bssid = "\xFF\xFF\xFF\xFF\xFF\xFF";
6247}
6248
6249static struct sk_buff *
6250ath10k_wmi_op_gen_stop_scan(struct ath10k *ar,
6251                            const struct wmi_stop_scan_arg *arg)
6252{
6253        struct wmi_stop_scan_cmd *cmd;
6254        struct sk_buff *skb;
6255        u32 scan_id;
6256        u32 req_id;
6257
6258        if (arg->req_id > 0xFFF)
6259                return ERR_PTR(-EINVAL);
6260        if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF)
6261                return ERR_PTR(-EINVAL);
6262
6263        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6264        if (!skb)
6265                return ERR_PTR(-ENOMEM);
6266
6267        scan_id = arg->u.scan_id;
6268        scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX;
6269
6270        req_id = arg->req_id;
6271        req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
6272
6273        cmd = (struct wmi_stop_scan_cmd *)skb->data;
6274        cmd->req_type    = __cpu_to_le32(arg->req_type);
6275        cmd->vdev_id     = __cpu_to_le32(arg->u.vdev_id);
6276        cmd->scan_id     = __cpu_to_le32(scan_id);
6277        cmd->scan_req_id = __cpu_to_le32(req_id);
6278
6279        ath10k_dbg(ar, ATH10K_DBG_WMI,
6280                   "wmi stop scan reqid %d req_type %d vdev/scan_id %d\n",
6281                   arg->req_id, arg->req_type, arg->u.scan_id);
6282        return skb;
6283}
6284
6285static struct sk_buff *
6286ath10k_wmi_op_gen_vdev_create(struct ath10k *ar, u32 vdev_id,
6287                              enum wmi_vdev_type type,
6288                              enum wmi_vdev_subtype subtype,
6289                              const u8 macaddr[ETH_ALEN])
6290{
6291        struct wmi_vdev_create_cmd *cmd;
6292        struct sk_buff *skb;
6293
6294        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6295        if (!skb)
6296                return ERR_PTR(-ENOMEM);
6297
6298        cmd = (struct wmi_vdev_create_cmd *)skb->data;
6299        cmd->vdev_id      = __cpu_to_le32(vdev_id);
6300        cmd->vdev_type    = __cpu_to_le32(type);
6301        cmd->vdev_subtype = __cpu_to_le32(subtype);
6302        ether_addr_copy(cmd->vdev_macaddr.addr, macaddr);
6303
6304        ath10k_dbg(ar, ATH10K_DBG_WMI,
6305                   "WMI vdev create: id %d type %d subtype %d macaddr %pM\n",
6306                   vdev_id, type, subtype, macaddr);
6307        return skb;
6308}
6309
6310static struct sk_buff *
6311ath10k_wmi_op_gen_vdev_delete(struct ath10k *ar, u32 vdev_id)
6312{
6313        struct wmi_vdev_delete_cmd *cmd;
6314        struct sk_buff *skb;
6315
6316        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6317        if (!skb)
6318                return ERR_PTR(-ENOMEM);
6319
6320        cmd = (struct wmi_vdev_delete_cmd *)skb->data;
6321        cmd->vdev_id = __cpu_to_le32(vdev_id);
6322
6323        ath10k_dbg(ar, ATH10K_DBG_WMI,
6324                   "WMI vdev delete id %d\n", vdev_id);
6325        return skb;
6326}
6327
6328static struct sk_buff *
6329ath10k_wmi_op_gen_vdev_start(struct ath10k *ar,
6330                             const struct wmi_vdev_start_request_arg *arg,
6331                             bool restart)
6332{
6333        struct wmi_vdev_start_request_cmd *cmd;
6334        struct sk_buff *skb;
6335        const char *cmdname;
6336        u32 flags = 0;
6337
6338        if (WARN_ON(arg->hidden_ssid && !arg->ssid))
6339                return ERR_PTR(-EINVAL);
6340        if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid)))
6341                return ERR_PTR(-EINVAL);
6342
6343        if (restart)
6344                cmdname = "restart";
6345        else
6346                cmdname = "start";
6347
6348        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6349        if (!skb)
6350                return ERR_PTR(-ENOMEM);
6351
6352        if (arg->hidden_ssid)
6353                flags |= WMI_VDEV_START_HIDDEN_SSID;
6354        if (arg->pmf_enabled)
6355                flags |= WMI_VDEV_START_PMF_ENABLED;
6356
6357        cmd = (struct wmi_vdev_start_request_cmd *)skb->data;
6358        cmd->vdev_id         = __cpu_to_le32(arg->vdev_id);
6359        cmd->disable_hw_ack  = __cpu_to_le32(arg->disable_hw_ack);
6360        cmd->beacon_interval = __cpu_to_le32(arg->bcn_intval);
6361        cmd->dtim_period     = __cpu_to_le32(arg->dtim_period);
6362        cmd->flags           = __cpu_to_le32(flags);
6363        cmd->bcn_tx_rate     = __cpu_to_le32(arg->bcn_tx_rate);
6364        cmd->bcn_tx_power    = __cpu_to_le32(arg->bcn_tx_power);
6365
6366        if (arg->ssid) {
6367                cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len);
6368                memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len);
6369        }
6370
6371        ath10k_wmi_put_wmi_channel(&cmd->chan, &arg->channel);
6372
6373        ath10k_dbg(ar, ATH10K_DBG_WMI,
6374                   "wmi vdev %s id 0x%x flags: 0x%0X, freq %d, mode %d, ch_flags: 0x%0X, max_power: %d\n",
6375                   cmdname, arg->vdev_id,
6376                   flags, arg->channel.freq, arg->channel.mode,
6377                   cmd->chan.flags, arg->channel.max_power);
6378
6379        return skb;
6380}
6381
6382static struct sk_buff *
6383ath10k_wmi_op_gen_vdev_stop(struct ath10k *ar, u32 vdev_id)
6384{
6385        struct wmi_vdev_stop_cmd *cmd;
6386        struct sk_buff *skb;
6387
6388        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6389        if (!skb)
6390                return ERR_PTR(-ENOMEM);
6391
6392        cmd = (struct wmi_vdev_stop_cmd *)skb->data;
6393        cmd->vdev_id = __cpu_to_le32(vdev_id);
6394
6395        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi vdev stop id 0x%x\n", vdev_id);
6396        return skb;
6397}
6398
6399static struct sk_buff *
6400ath10k_wmi_op_gen_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid,
6401                          const u8 *bssid)
6402{
6403        struct wmi_vdev_up_cmd *cmd;
6404        struct sk_buff *skb;
6405
6406        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6407        if (!skb)
6408                return ERR_PTR(-ENOMEM);
6409
6410        cmd = (struct wmi_vdev_up_cmd *)skb->data;
6411        cmd->vdev_id       = __cpu_to_le32(vdev_id);
6412        cmd->vdev_assoc_id = __cpu_to_le32(aid);
6413        ether_addr_copy(cmd->vdev_bssid.addr, bssid);
6414
6415        ath10k_dbg(ar, ATH10K_DBG_WMI,
6416                   "wmi mgmt vdev up id 0x%x assoc id %d bssid %pM\n",
6417                   vdev_id, aid, bssid);
6418        return skb;
6419}
6420
6421static struct sk_buff *
6422ath10k_wmi_op_gen_vdev_down(struct ath10k *ar, u32 vdev_id)
6423{
6424        struct wmi_vdev_down_cmd *cmd;
6425        struct sk_buff *skb;
6426
6427        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6428        if (!skb)
6429                return ERR_PTR(-ENOMEM);
6430
6431        cmd = (struct wmi_vdev_down_cmd *)skb->data;
6432        cmd->vdev_id = __cpu_to_le32(vdev_id);
6433
6434        ath10k_dbg(ar, ATH10K_DBG_WMI,
6435                   "wmi mgmt vdev down id 0x%x\n", vdev_id);
6436        return skb;
6437}
6438
6439static struct sk_buff *
6440ath10k_wmi_op_gen_vdev_set_param(struct ath10k *ar, u32 vdev_id,
6441                                 u32 param_id, u32 param_value)
6442{
6443        struct wmi_vdev_set_param_cmd *cmd;
6444        struct sk_buff *skb;
6445
6446        if (param_id == WMI_VDEV_PARAM_UNSUPPORTED) {
6447                ath10k_dbg(ar, ATH10K_DBG_WMI,
6448                           "vdev param %d not supported by firmware\n",
6449                            param_id);
6450                return ERR_PTR(-EOPNOTSUPP);
6451        }
6452
6453        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6454        if (!skb)
6455                return ERR_PTR(-ENOMEM);
6456
6457        cmd = (struct wmi_vdev_set_param_cmd *)skb->data;
6458        cmd->vdev_id     = __cpu_to_le32(vdev_id);
6459        cmd->param_id    = __cpu_to_le32(param_id);
6460        cmd->param_value = __cpu_to_le32(param_value);
6461
6462        ath10k_dbg(ar, ATH10K_DBG_WMI,
6463                   "wmi vdev id 0x%x set param %d value %d\n",
6464                   vdev_id, param_id, param_value);
6465        return skb;
6466}
6467
6468static struct sk_buff *
6469ath10k_wmi_op_gen_vdev_install_key(struct ath10k *ar,
6470                                   const struct wmi_vdev_install_key_arg *arg)
6471{
6472        struct wmi_vdev_install_key_cmd *cmd;
6473        struct sk_buff *skb;
6474
6475        if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL)
6476                return ERR_PTR(-EINVAL);
6477        if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL)
6478                return ERR_PTR(-EINVAL);
6479
6480        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd) + arg->key_len);
6481        if (!skb)
6482                return ERR_PTR(-ENOMEM);
6483
6484        cmd = (struct wmi_vdev_install_key_cmd *)skb->data;
6485        cmd->vdev_id       = __cpu_to_le32(arg->vdev_id);
6486        cmd->key_idx       = __cpu_to_le32(arg->key_idx);
6487        cmd->key_flags     = __cpu_to_le32(arg->key_flags);
6488        cmd->key_cipher    = __cpu_to_le32(arg->key_cipher);
6489        cmd->key_len       = __cpu_to_le32(arg->key_len);
6490        cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len);
6491        cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len);
6492
6493        if (arg->macaddr)
6494                ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr);
6495        if (arg->key_data)
6496                memcpy(cmd->key_data, arg->key_data, arg->key_len);
6497
6498        ath10k_dbg(ar, ATH10K_DBG_WMI,
6499                   "wmi vdev install key idx %d cipher %d len %d\n",
6500                   arg->key_idx, arg->key_cipher, arg->key_len);
6501        return skb;
6502}
6503
6504static struct sk_buff *
6505ath10k_wmi_op_gen_vdev_spectral_conf(struct ath10k *ar,
6506                                     const struct wmi_vdev_spectral_conf_arg *arg)
6507{
6508        struct wmi_vdev_spectral_conf_cmd *cmd;
6509        struct sk_buff *skb;
6510
6511        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6512        if (!skb)
6513                return ERR_PTR(-ENOMEM);
6514
6515        cmd = (struct wmi_vdev_spectral_conf_cmd *)skb->data;
6516        cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
6517        cmd->scan_count = __cpu_to_le32(arg->scan_count);
6518        cmd->scan_period = __cpu_to_le32(arg->scan_period);
6519        cmd->scan_priority = __cpu_to_le32(arg->scan_priority);
6520        cmd->scan_fft_size = __cpu_to_le32(arg->scan_fft_size);
6521        cmd->scan_gc_ena = __cpu_to_le32(arg->scan_gc_ena);
6522        cmd->scan_restart_ena = __cpu_to_le32(arg->scan_restart_ena);
6523        cmd->scan_noise_floor_ref = __cpu_to_le32(arg->scan_noise_floor_ref);
6524        cmd->scan_init_delay = __cpu_to_le32(arg->scan_init_delay);
6525        cmd->scan_nb_tone_thr = __cpu_to_le32(arg->scan_nb_tone_thr);
6526        cmd->scan_str_bin_thr = __cpu_to_le32(arg->scan_str_bin_thr);
6527        cmd->scan_wb_rpt_mode = __cpu_to_le32(arg->scan_wb_rpt_mode);
6528        cmd->scan_rssi_rpt_mode = __cpu_to_le32(arg->scan_rssi_rpt_mode);
6529        cmd->scan_rssi_thr = __cpu_to_le32(arg->scan_rssi_thr);
6530        cmd->scan_pwr_format = __cpu_to_le32(arg->scan_pwr_format);
6531        cmd->scan_rpt_mode = __cpu_to_le32(arg->scan_rpt_mode);
6532        cmd->scan_bin_scale = __cpu_to_le32(arg->scan_bin_scale);
6533        cmd->scan_dbm_adj = __cpu_to_le32(arg->scan_dbm_adj);
6534        cmd->scan_chn_mask = __cpu_to_le32(arg->scan_chn_mask);
6535
6536        return skb;
6537}
6538
6539static struct sk_buff *
6540ath10k_wmi_op_gen_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id,
6541                                       u32 trigger, u32 enable)
6542{
6543        struct wmi_vdev_spectral_enable_cmd *cmd;
6544        struct sk_buff *skb;
6545
6546        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6547        if (!skb)
6548                return ERR_PTR(-ENOMEM);
6549
6550        cmd = (struct wmi_vdev_spectral_enable_cmd *)skb->data;
6551        cmd->vdev_id = __cpu_to_le32(vdev_id);
6552        cmd->trigger_cmd = __cpu_to_le32(trigger);
6553        cmd->enable_cmd = __cpu_to_le32(enable);
6554
6555        return skb;
6556}
6557
6558static struct sk_buff *
6559ath10k_wmi_op_gen_peer_create(struct ath10k *ar, u32 vdev_id,
6560                              const u8 peer_addr[ETH_ALEN],
6561                              enum wmi_peer_type peer_type)
6562{
6563        struct wmi_peer_create_cmd *cmd;
6564        struct sk_buff *skb;
6565
6566        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6567        if (!skb)
6568                return ERR_PTR(-ENOMEM);
6569
6570        cmd = (struct wmi_peer_create_cmd *)skb->data;
6571        cmd->vdev_id = __cpu_to_le32(vdev_id);
6572        ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
6573        cmd->peer_type = __cpu_to_le32(peer_type);
6574
6575        ath10k_dbg(ar, ATH10K_DBG_WMI,
6576                   "wmi peer create vdev_id %d peer_addr %pM\n",
6577                   vdev_id, peer_addr);
6578        return skb;
6579}
6580
6581static struct sk_buff *
6582ath10k_wmi_op_gen_peer_delete(struct ath10k *ar, u32 vdev_id,
6583                              const u8 peer_addr[ETH_ALEN])
6584{
6585        struct wmi_peer_delete_cmd *cmd;
6586        struct sk_buff *skb;
6587
6588        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6589        if (!skb)
6590                return ERR_PTR(-ENOMEM);
6591
6592        cmd = (struct wmi_peer_delete_cmd *)skb->data;
6593        cmd->vdev_id = __cpu_to_le32(vdev_id);
6594        ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
6595
6596        ath10k_dbg(ar, ATH10K_DBG_WMI,
6597                   "wmi peer delete vdev_id %d peer_addr %pM\n",
6598                   vdev_id, peer_addr);
6599        return skb;
6600}
6601
6602static struct sk_buff *
6603ath10k_wmi_op_gen_peer_flush(struct ath10k *ar, u32 vdev_id,
6604                             const u8 peer_addr[ETH_ALEN], u32 tid_bitmap)
6605{
6606        struct wmi_peer_flush_tids_cmd *cmd;
6607        struct sk_buff *skb;
6608
6609        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6610        if (!skb)
6611                return ERR_PTR(-ENOMEM);
6612
6613        cmd = (struct wmi_peer_flush_tids_cmd *)skb->data;
6614        cmd->vdev_id         = __cpu_to_le32(vdev_id);
6615        cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap);
6616        ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
6617
6618        ath10k_dbg(ar, ATH10K_DBG_WMI,
6619                   "wmi peer flush vdev_id %d peer_addr %pM tids %08x\n",
6620                   vdev_id, peer_addr, tid_bitmap);
6621        return skb;
6622}
6623
6624static struct sk_buff *
6625ath10k_wmi_op_gen_peer_set_param(struct ath10k *ar, u32 vdev_id,
6626                                 const u8 *peer_addr,
6627                                 enum wmi_peer_param param_id,
6628                                 u32 param_value)
6629{
6630        struct wmi_peer_set_param_cmd *cmd;
6631        struct sk_buff *skb;
6632
6633        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6634        if (!skb)
6635                return ERR_PTR(-ENOMEM);
6636
6637        cmd = (struct wmi_peer_set_param_cmd *)skb->data;
6638        cmd->vdev_id     = __cpu_to_le32(vdev_id);
6639        cmd->param_id    = __cpu_to_le32(param_id);
6640        cmd->param_value = __cpu_to_le32(param_value);
6641        ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
6642
6643        ath10k_dbg(ar, ATH10K_DBG_WMI,
6644                   "wmi vdev %d peer 0x%pM set param %d value %d\n",
6645                   vdev_id, peer_addr, param_id, param_value);
6646        return skb;
6647}
6648
6649static struct sk_buff *
6650ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
6651                             enum wmi_sta_ps_mode psmode)
6652{
6653        struct wmi_sta_powersave_mode_cmd *cmd;
6654        struct sk_buff *skb;
6655
6656        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6657        if (!skb)
6658                return ERR_PTR(-ENOMEM);
6659
6660        cmd = (struct wmi_sta_powersave_mode_cmd *)skb->data;
6661        cmd->vdev_id     = __cpu_to_le32(vdev_id);
6662        cmd->sta_ps_mode = __cpu_to_le32(psmode);
6663
6664        ath10k_dbg(ar, ATH10K_DBG_WMI,
6665                   "wmi set powersave id 0x%x mode %d\n",
6666                   vdev_id, psmode);
6667        return skb;
6668}
6669
6670static struct sk_buff *
6671ath10k_wmi_op_gen_set_sta_ps(struct ath10k *ar, u32 vdev_id,
6672                             enum wmi_sta_powersave_param param_id,
6673                             u32 value)
6674{
6675        struct wmi_sta_powersave_param_cmd *cmd;
6676        struct sk_buff *skb;
6677
6678        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6679        if (!skb)
6680                return ERR_PTR(-ENOMEM);
6681
6682        cmd = (struct wmi_sta_powersave_param_cmd *)skb->data;
6683        cmd->vdev_id     = __cpu_to_le32(vdev_id);
6684        cmd->param_id    = __cpu_to_le32(param_id);
6685        cmd->param_value = __cpu_to_le32(value);
6686
6687        ath10k_dbg(ar, ATH10K_DBG_WMI,
6688                   "wmi sta ps param vdev_id 0x%x param %d value %d\n",
6689                   vdev_id, param_id, value);
6690        return skb;
6691}
6692
6693static struct sk_buff *
6694ath10k_wmi_op_gen_set_ap_ps(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6695                            enum wmi_ap_ps_peer_param param_id, u32 value)
6696{
6697        struct wmi_ap_ps_peer_cmd *cmd;
6698        struct sk_buff *skb;
6699
6700        if (!mac)
6701                return ERR_PTR(-EINVAL);
6702
6703        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6704        if (!skb)
6705                return ERR_PTR(-ENOMEM);
6706
6707        cmd = (struct wmi_ap_ps_peer_cmd *)skb->data;
6708        cmd->vdev_id = __cpu_to_le32(vdev_id);
6709        cmd->param_id = __cpu_to_le32(param_id);
6710        cmd->param_value = __cpu_to_le32(value);
6711        ether_addr_copy(cmd->peer_macaddr.addr, mac);
6712
6713        ath10k_dbg(ar, ATH10K_DBG_WMI,
6714                   "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr %pM\n",
6715                   vdev_id, param_id, value, mac);
6716        return skb;
6717}
6718
6719static struct sk_buff *
6720ath10k_wmi_op_gen_scan_chan_list(struct ath10k *ar,
6721                                 const struct wmi_scan_chan_list_arg *arg)
6722{
6723        struct wmi_scan_chan_list_cmd *cmd;
6724        struct sk_buff *skb;
6725        struct wmi_channel_arg *ch;
6726        struct wmi_channel *ci;
6727        int len;
6728        int i;
6729
6730        len = sizeof(*cmd) + arg->n_channels * sizeof(struct wmi_channel);
6731
6732        skb = ath10k_wmi_alloc_skb(ar, len);
6733        if (!skb)
6734                return ERR_PTR(-EINVAL);
6735
6736        cmd = (struct wmi_scan_chan_list_cmd *)skb->data;
6737        cmd->num_scan_chans = __cpu_to_le32(arg->n_channels);
6738
6739        for (i = 0; i < arg->n_channels; i++) {
6740                ch = &arg->channels[i];
6741                ci = &cmd->chan_info[i];
6742
6743                ath10k_wmi_put_wmi_channel(ci, ch);
6744        }
6745
6746        return skb;
6747}
6748
6749static void
6750ath10k_wmi_peer_assoc_fill(struct ath10k *ar, void *buf,
6751                           const struct wmi_peer_assoc_complete_arg *arg)
6752{
6753        struct wmi_common_peer_assoc_complete_cmd *cmd = buf;
6754
6755        cmd->vdev_id            = __cpu_to_le32(arg->vdev_id);
6756        cmd->peer_new_assoc     = __cpu_to_le32(arg->peer_reassoc ? 0 : 1);
6757        cmd->peer_associd       = __cpu_to_le32(arg->peer_aid);
6758        cmd->peer_flags         = __cpu_to_le32(arg->peer_flags);
6759        cmd->peer_caps          = __cpu_to_le32(arg->peer_caps);
6760        cmd->peer_listen_intval = __cpu_to_le32(arg->peer_listen_intval);
6761        cmd->peer_ht_caps       = __cpu_to_le32(arg->peer_ht_caps);
6762        cmd->peer_max_mpdu      = __cpu_to_le32(arg->peer_max_mpdu);
6763        cmd->peer_mpdu_density  = __cpu_to_le32(arg->peer_mpdu_density);
6764        cmd->peer_rate_caps     = __cpu_to_le32(arg->peer_rate_caps);
6765        cmd->peer_nss           = __cpu_to_le32(arg->peer_num_spatial_streams);
6766        cmd->peer_vht_caps      = __cpu_to_le32(arg->peer_vht_caps);
6767        cmd->peer_phymode       = __cpu_to_le32(arg->peer_phymode);
6768
6769        ether_addr_copy(cmd->peer_macaddr.addr, arg->addr);
6770
6771        cmd->peer_legacy_rates.num_rates =
6772                __cpu_to_le32(arg->peer_legacy_rates.num_rates);
6773        memcpy(cmd->peer_legacy_rates.rates, arg->peer_legacy_rates.rates,
6774               arg->peer_legacy_rates.num_rates);
6775
6776        cmd->peer_ht_rates.num_rates =
6777                __cpu_to_le32(arg->peer_ht_rates.num_rates);
6778        memcpy(cmd->peer_ht_rates.rates, arg->peer_ht_rates.rates,
6779               arg->peer_ht_rates.num_rates);
6780
6781        cmd->peer_vht_rates.rx_max_rate =
6782                __cpu_to_le32(arg->peer_vht_rates.rx_max_rate);
6783        cmd->peer_vht_rates.rx_mcs_set =
6784                __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set);
6785        cmd->peer_vht_rates.tx_max_rate =
6786                __cpu_to_le32(arg->peer_vht_rates.tx_max_rate);
6787        cmd->peer_vht_rates.tx_mcs_set =
6788                __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set);
6789}
6790
6791static void
6792ath10k_wmi_peer_assoc_fill_main(struct ath10k *ar, void *buf,
6793                                const struct wmi_peer_assoc_complete_arg *arg)
6794{
6795        struct wmi_main_peer_assoc_complete_cmd *cmd = buf;
6796
6797        ath10k_wmi_peer_assoc_fill(ar, buf, arg);
6798        memset(cmd->peer_ht_info, 0, sizeof(cmd->peer_ht_info));
6799}
6800
6801static void
6802ath10k_wmi_peer_assoc_fill_10_1(struct ath10k *ar, void *buf,
6803                                const struct wmi_peer_assoc_complete_arg *arg)
6804{
6805        ath10k_wmi_peer_assoc_fill(ar, buf, arg);
6806}
6807
6808static void
6809ath10k_wmi_peer_assoc_fill_10_2(struct ath10k *ar, void *buf,
6810                                const struct wmi_peer_assoc_complete_arg *arg)
6811{
6812        struct wmi_10_2_peer_assoc_complete_cmd *cmd = buf;
6813        int max_mcs, max_nss;
6814        u32 info0;
6815
6816        /* TODO: Is using max values okay with firmware? */
6817        max_mcs = 0xf;
6818        max_nss = 0xf;
6819
6820        info0 = SM(max_mcs, WMI_PEER_ASSOC_INFO0_MAX_MCS_IDX) |
6821                SM(max_nss, WMI_PEER_ASSOC_INFO0_MAX_NSS);
6822
6823        ath10k_wmi_peer_assoc_fill(ar, buf, arg);
6824        cmd->info0 = __cpu_to_le32(info0);
6825}
6826
6827static void
6828ath10k_wmi_peer_assoc_fill_10_4(struct ath10k *ar, void *buf,
6829                                const struct wmi_peer_assoc_complete_arg *arg)
6830{
6831        struct wmi_10_4_peer_assoc_complete_cmd *cmd = buf;
6832
6833        ath10k_wmi_peer_assoc_fill_10_2(ar, buf, arg);
6834        if (arg->peer_bw_rxnss_override)
6835                cmd->peer_bw_rxnss_override =
6836                        __cpu_to_le32((arg->peer_bw_rxnss_override - 1) |
6837                                      BIT(PEER_BW_RXNSS_OVERRIDE_OFFSET));
6838        else
6839                cmd->peer_bw_rxnss_override = 0;
6840}
6841
6842static int
6843ath10k_wmi_peer_assoc_check_arg(const struct wmi_peer_assoc_complete_arg *arg)
6844{
6845        if (arg->peer_mpdu_density > 16)
6846                return -EINVAL;
6847        if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES)
6848                return -EINVAL;
6849        if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES)
6850                return -EINVAL;
6851
6852        return 0;
6853}
6854
6855static struct sk_buff *
6856ath10k_wmi_op_gen_peer_assoc(struct ath10k *ar,
6857                             const struct wmi_peer_assoc_complete_arg *arg)
6858{
6859        size_t len = sizeof(struct wmi_main_peer_assoc_complete_cmd);
6860        struct sk_buff *skb;
6861        int ret;
6862
6863        ret = ath10k_wmi_peer_assoc_check_arg(arg);
6864        if (ret)
6865                return ERR_PTR(ret);
6866
6867        skb = ath10k_wmi_alloc_skb(ar, len);
6868        if (!skb)
6869                return ERR_PTR(-ENOMEM);
6870
6871        ath10k_wmi_peer_assoc_fill_main(ar, skb->data, arg);
6872
6873        ath10k_dbg(ar, ATH10K_DBG_WMI,
6874                   "wmi peer assoc vdev %d addr %pM (%s)\n",
6875                   arg->vdev_id, arg->addr,
6876                   arg->peer_reassoc ? "reassociate" : "new");
6877        return skb;
6878}
6879
6880static struct sk_buff *
6881ath10k_wmi_10_1_op_gen_peer_assoc(struct ath10k *ar,
6882                                  const struct wmi_peer_assoc_complete_arg *arg)
6883{
6884        size_t len = sizeof(struct wmi_10_1_peer_assoc_complete_cmd);
6885        struct sk_buff *skb;
6886        int ret;
6887
6888        ret = ath10k_wmi_peer_assoc_check_arg(arg);
6889        if (ret)
6890                return ERR_PTR(ret);
6891
6892        skb = ath10k_wmi_alloc_skb(ar, len);
6893        if (!skb)
6894                return ERR_PTR(-ENOMEM);
6895
6896        ath10k_wmi_peer_assoc_fill_10_1(ar, skb->data, arg);
6897
6898        ath10k_dbg(ar, ATH10K_DBG_WMI,
6899                   "wmi peer assoc vdev %d addr %pM (%s)\n",
6900                   arg->vdev_id, arg->addr,
6901                   arg->peer_reassoc ? "reassociate" : "new");
6902        return skb;
6903}
6904
6905static struct sk_buff *
6906ath10k_wmi_10_2_op_gen_peer_assoc(struct ath10k *ar,
6907                                  const struct wmi_peer_assoc_complete_arg *arg)
6908{
6909        size_t len = sizeof(struct wmi_10_2_peer_assoc_complete_cmd);
6910        struct sk_buff *skb;
6911        int ret;
6912
6913        ret = ath10k_wmi_peer_assoc_check_arg(arg);
6914        if (ret)
6915                return ERR_PTR(ret);
6916
6917        skb = ath10k_wmi_alloc_skb(ar, len);
6918        if (!skb)
6919                return ERR_PTR(-ENOMEM);
6920
6921        ath10k_wmi_peer_assoc_fill_10_2(ar, skb->data, arg);
6922
6923        ath10k_dbg(ar, ATH10K_DBG_WMI,
6924                   "wmi peer assoc vdev %d addr %pM (%s)\n",
6925                   arg->vdev_id, arg->addr,
6926                   arg->peer_reassoc ? "reassociate" : "new");
6927        return skb;
6928}
6929
6930static struct sk_buff *
6931ath10k_wmi_10_4_op_gen_peer_assoc(struct ath10k *ar,
6932                                  const struct wmi_peer_assoc_complete_arg *arg)
6933{
6934        size_t len = sizeof(struct wmi_10_4_peer_assoc_complete_cmd);
6935        struct sk_buff *skb;
6936        int ret;
6937
6938        ret = ath10k_wmi_peer_assoc_check_arg(arg);
6939        if (ret)
6940                return ERR_PTR(ret);
6941
6942        skb = ath10k_wmi_alloc_skb(ar, len);
6943        if (!skb)
6944                return ERR_PTR(-ENOMEM);
6945
6946        ath10k_wmi_peer_assoc_fill_10_4(ar, skb->data, arg);
6947
6948        ath10k_dbg(ar, ATH10K_DBG_WMI,
6949                   "wmi peer assoc vdev %d addr %pM (%s)\n",
6950                   arg->vdev_id, arg->addr,
6951                   arg->peer_reassoc ? "reassociate" : "new");
6952        return skb;
6953}
6954
6955static struct sk_buff *
6956ath10k_wmi_10_2_op_gen_pdev_get_temperature(struct ath10k *ar)
6957{
6958        struct sk_buff *skb;
6959
6960        skb = ath10k_wmi_alloc_skb(ar, 0);
6961        if (!skb)
6962                return ERR_PTR(-ENOMEM);
6963
6964        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev get temperature\n");
6965        return skb;
6966}
6967
6968static struct sk_buff *
6969ath10k_wmi_10_2_op_gen_pdev_bss_chan_info(struct ath10k *ar,
6970                                          enum wmi_bss_survey_req_type type)
6971{
6972        struct wmi_pdev_chan_info_req_cmd *cmd;
6973        struct sk_buff *skb;
6974
6975        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6976        if (!skb)
6977                return ERR_PTR(-ENOMEM);
6978
6979        cmd = (struct wmi_pdev_chan_info_req_cmd *)skb->data;
6980        cmd->type = __cpu_to_le32(type);
6981
6982        ath10k_dbg(ar, ATH10K_DBG_WMI,
6983                   "wmi pdev bss info request type %d\n", type);
6984
6985        return skb;
6986}
6987
6988/* This function assumes the beacon is already DMA mapped */
6989static struct sk_buff *
6990ath10k_wmi_op_gen_beacon_dma(struct ath10k *ar, u32 vdev_id, const void *bcn,
6991                             size_t bcn_len, u32 bcn_paddr, bool dtim_zero,
6992                             bool deliver_cab)
6993{
6994        struct wmi_bcn_tx_ref_cmd *cmd;
6995        struct sk_buff *skb;
6996        struct ieee80211_hdr *hdr;
6997        u16 fc;
6998
6999        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7000        if (!skb)
7001                return ERR_PTR(-ENOMEM);
7002
7003        hdr = (struct ieee80211_hdr *)bcn;
7004        fc = le16_to_cpu(hdr->frame_control);
7005
7006        cmd = (struct wmi_bcn_tx_ref_cmd *)skb->data;
7007        cmd->vdev_id = __cpu_to_le32(vdev_id);
7008        cmd->data_len = __cpu_to_le32(bcn_len);
7009        cmd->data_ptr = __cpu_to_le32(bcn_paddr);
7010        cmd->msdu_id = 0;
7011        cmd->frame_control = __cpu_to_le32(fc);
7012        cmd->flags = 0;
7013        cmd->antenna_mask = __cpu_to_le32(WMI_BCN_TX_REF_DEF_ANTENNA);
7014
7015        if (dtim_zero)
7016                cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DTIM_ZERO);
7017
7018        if (deliver_cab)
7019                cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB);
7020
7021        return skb;
7022}
7023
7024void ath10k_wmi_set_wmm_param(struct wmi_wmm_params *params,
7025                              const struct wmi_wmm_params_arg *arg)
7026{
7027        params->cwmin  = __cpu_to_le32(arg->cwmin);
7028        params->cwmax  = __cpu_to_le32(arg->cwmax);
7029        params->aifs   = __cpu_to_le32(arg->aifs);
7030        params->txop   = __cpu_to_le32(arg->txop);
7031        params->acm    = __cpu_to_le32(arg->acm);
7032        params->no_ack = __cpu_to_le32(arg->no_ack);
7033}
7034
7035static struct sk_buff *
7036ath10k_wmi_op_gen_pdev_set_wmm(struct ath10k *ar,
7037                               const struct wmi_wmm_params_all_arg *arg)
7038{
7039        struct wmi_pdev_set_wmm_params *cmd;
7040        struct sk_buff *skb;
7041
7042        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7043        if (!skb)
7044                return ERR_PTR(-ENOMEM);
7045
7046        cmd = (struct wmi_pdev_set_wmm_params *)skb->data;
7047        ath10k_wmi_set_wmm_param(&cmd->ac_be, &arg->ac_be);
7048        ath10k_wmi_set_wmm_param(&cmd->ac_bk, &arg->ac_bk);
7049        ath10k_wmi_set_wmm_param(&cmd->ac_vi, &arg->ac_vi);
7050        ath10k_wmi_set_wmm_param(&cmd->ac_vo, &arg->ac_vo);
7051
7052        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set wmm params\n");
7053        return skb;
7054}
7055
7056static struct sk_buff *
7057ath10k_wmi_op_gen_request_stats(struct ath10k *ar, u32 stats_mask)
7058{
7059        struct wmi_request_stats_cmd *cmd;
7060        struct sk_buff *skb;
7061
7062        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7063        if (!skb)
7064                return ERR_PTR(-ENOMEM);
7065
7066        cmd = (struct wmi_request_stats_cmd *)skb->data;
7067        cmd->stats_id = __cpu_to_le32(stats_mask);
7068
7069        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi request stats 0x%08x\n",
7070                   stats_mask);
7071        return skb;
7072}
7073
7074static struct sk_buff *
7075ath10k_wmi_op_gen_force_fw_hang(struct ath10k *ar,
7076                                enum wmi_force_fw_hang_type type, u32 delay_ms)
7077{
7078        struct wmi_force_fw_hang_cmd *cmd;
7079        struct sk_buff *skb;
7080
7081        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7082        if (!skb)
7083                return ERR_PTR(-ENOMEM);
7084
7085        cmd = (struct wmi_force_fw_hang_cmd *)skb->data;
7086        cmd->type = __cpu_to_le32(type);
7087        cmd->delay_ms = __cpu_to_le32(delay_ms);
7088
7089        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi force fw hang %d delay %d\n",
7090                   type, delay_ms);
7091        return skb;
7092}
7093
7094static struct sk_buff *
7095ath10k_wmi_op_gen_dbglog_cfg(struct ath10k *ar, u64 module_enable,
7096                             u32 log_level)
7097{
7098        struct wmi_dbglog_cfg_cmd *cmd;
7099        struct sk_buff *skb;
7100        u32 cfg;
7101
7102        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7103        if (!skb)
7104                return ERR_PTR(-ENOMEM);
7105
7106        cmd = (struct wmi_dbglog_cfg_cmd *)skb->data;
7107
7108        if (module_enable) {
7109                cfg = SM(log_level,
7110                         ATH10K_DBGLOG_CFG_LOG_LVL);
7111        } else {
7112                /* set back defaults, all modules with WARN level */
7113                cfg = SM(ATH10K_DBGLOG_LEVEL_WARN,
7114                         ATH10K_DBGLOG_CFG_LOG_LVL);
7115                module_enable = ~0;
7116        }
7117
7118        cmd->module_enable = __cpu_to_le32(module_enable);
7119        cmd->module_valid = __cpu_to_le32(~0);
7120        cmd->config_enable = __cpu_to_le32(cfg);
7121        cmd->config_valid = __cpu_to_le32(ATH10K_DBGLOG_CFG_LOG_LVL_MASK);
7122
7123        ath10k_dbg(ar, ATH10K_DBG_WMI,
7124                   "wmi dbglog cfg modules %08x %08x config %08x %08x\n",
7125                   __le32_to_cpu(cmd->module_enable),
7126                   __le32_to_cpu(cmd->module_valid),
7127                   __le32_to_cpu(cmd->config_enable),
7128                   __le32_to_cpu(cmd->config_valid));
7129        return skb;
7130}
7131
7132static struct sk_buff *
7133ath10k_wmi_10_4_op_gen_dbglog_cfg(struct ath10k *ar, u64 module_enable,
7134                                  u32 log_level)
7135{
7136        struct wmi_10_4_dbglog_cfg_cmd *cmd;
7137        struct sk_buff *skb;
7138        u32 cfg;
7139
7140        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7141        if (!skb)
7142                return ERR_PTR(-ENOMEM);
7143
7144        cmd = (struct wmi_10_4_dbglog_cfg_cmd *)skb->data;
7145
7146        if (module_enable) {
7147                cfg = SM(log_level,
7148                         ATH10K_DBGLOG_CFG_LOG_LVL);
7149        } else {
7150                /* set back defaults, all modules with WARN level */
7151                cfg = SM(ATH10K_DBGLOG_LEVEL_WARN,
7152                         ATH10K_DBGLOG_CFG_LOG_LVL);
7153                module_enable = ~0;
7154        }
7155
7156        cmd->module_enable = __cpu_to_le64(module_enable);
7157        cmd->module_valid = __cpu_to_le64(~0);
7158        cmd->config_enable = __cpu_to_le32(cfg);
7159        cmd->config_valid = __cpu_to_le32(ATH10K_DBGLOG_CFG_LOG_LVL_MASK);
7160
7161        ath10k_dbg(ar, ATH10K_DBG_WMI,
7162                   "wmi dbglog cfg modules 0x%016llx 0x%016llx config %08x %08x\n",
7163                   __le64_to_cpu(cmd->module_enable),
7164                   __le64_to_cpu(cmd->module_valid),
7165                   __le32_to_cpu(cmd->config_enable),
7166                   __le32_to_cpu(cmd->config_valid));
7167        return skb;
7168}
7169
7170static struct sk_buff *
7171ath10k_wmi_op_gen_pktlog_enable(struct ath10k *ar, u32 ev_bitmap)
7172{
7173        struct wmi_pdev_pktlog_enable_cmd *cmd;
7174        struct sk_buff *skb;
7175
7176        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7177        if (!skb)
7178                return ERR_PTR(-ENOMEM);
7179
7180        ev_bitmap &= ATH10K_PKTLOG_ANY;
7181
7182        cmd = (struct wmi_pdev_pktlog_enable_cmd *)skb->data;
7183        cmd->ev_bitmap = __cpu_to_le32(ev_bitmap);
7184
7185        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi enable pktlog filter 0x%08x\n",
7186                   ev_bitmap);
7187        return skb;
7188}
7189
7190static struct sk_buff *
7191ath10k_wmi_op_gen_pktlog_disable(struct ath10k *ar)
7192{
7193        struct sk_buff *skb;
7194
7195        skb = ath10k_wmi_alloc_skb(ar, 0);
7196        if (!skb)
7197                return ERR_PTR(-ENOMEM);
7198
7199        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi disable pktlog\n");
7200        return skb;
7201}
7202
7203static struct sk_buff *
7204ath10k_wmi_op_gen_pdev_set_quiet_mode(struct ath10k *ar, u32 period,
7205                                      u32 duration, u32 next_offset,
7206                                      u32 enabled)
7207{
7208        struct wmi_pdev_set_quiet_cmd *cmd;
7209        struct sk_buff *skb;
7210
7211        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7212        if (!skb)
7213                return ERR_PTR(-ENOMEM);
7214
7215        cmd = (struct wmi_pdev_set_quiet_cmd *)skb->data;
7216        cmd->period = __cpu_to_le32(period);
7217        cmd->duration = __cpu_to_le32(duration);
7218        cmd->next_start = __cpu_to_le32(next_offset);
7219        cmd->enabled = __cpu_to_le32(enabled);
7220
7221        ath10k_dbg(ar, ATH10K_DBG_WMI,
7222                   "wmi quiet param: period %u duration %u enabled %d\n",
7223                   period, duration, enabled);
7224        return skb;
7225}
7226
7227static struct sk_buff *
7228ath10k_wmi_op_gen_addba_clear_resp(struct ath10k *ar, u32 vdev_id,
7229                                   const u8 *mac)
7230{
7231        struct wmi_addba_clear_resp_cmd *cmd;
7232        struct sk_buff *skb;
7233
7234        if (!mac)
7235                return ERR_PTR(-EINVAL);
7236
7237        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7238        if (!skb)
7239                return ERR_PTR(-ENOMEM);
7240
7241        cmd = (struct wmi_addba_clear_resp_cmd *)skb->data;
7242        cmd->vdev_id = __cpu_to_le32(vdev_id);
7243        ether_addr_copy(cmd->peer_macaddr.addr, mac);
7244
7245        ath10k_dbg(ar, ATH10K_DBG_WMI,
7246                   "wmi addba clear resp vdev_id 0x%X mac_addr %pM\n",
7247                   vdev_id, mac);
7248        return skb;
7249}
7250
7251static struct sk_buff *
7252ath10k_wmi_op_gen_addba_send(struct ath10k *ar, u32 vdev_id, const u8 *mac,
7253                             u32 tid, u32 buf_size)
7254{
7255        struct wmi_addba_send_cmd *cmd;
7256        struct sk_buff *skb;
7257
7258        if (!mac)
7259                return ERR_PTR(-EINVAL);
7260
7261        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7262        if (!skb)
7263                return ERR_PTR(-ENOMEM);
7264
7265        cmd = (struct wmi_addba_send_cmd *)skb->data;
7266        cmd->vdev_id = __cpu_to_le32(vdev_id);
7267        ether_addr_copy(cmd->peer_macaddr.addr, mac);
7268        cmd->tid = __cpu_to_le32(tid);
7269        cmd->buffersize = __cpu_to_le32(buf_size);
7270
7271        ath10k_dbg(ar, ATH10K_DBG_WMI,
7272                   "wmi addba send vdev_id 0x%X mac_addr %pM tid %u bufsize %u\n",
7273                   vdev_id, mac, tid, buf_size);
7274        return skb;
7275}
7276
7277static struct sk_buff *
7278ath10k_wmi_op_gen_addba_set_resp(struct ath10k *ar, u32 vdev_id, const u8 *mac,
7279                                 u32 tid, u32 status)
7280{
7281        struct wmi_addba_setresponse_cmd *cmd;
7282        struct sk_buff *skb;
7283
7284        if (!mac)
7285                return ERR_PTR(-EINVAL);
7286
7287        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7288        if (!skb)
7289                return ERR_PTR(-ENOMEM);
7290
7291        cmd = (struct wmi_addba_setresponse_cmd *)skb->data;
7292        cmd->vdev_id = __cpu_to_le32(vdev_id);
7293        ether_addr_copy(cmd->peer_macaddr.addr, mac);
7294        cmd->tid = __cpu_to_le32(tid);
7295        cmd->statuscode = __cpu_to_le32(status);
7296
7297        ath10k_dbg(ar, ATH10K_DBG_WMI,
7298                   "wmi addba set resp vdev_id 0x%X mac_addr %pM tid %u status %u\n",
7299                   vdev_id, mac, tid, status);
7300        return skb;
7301}
7302
7303static struct sk_buff *
7304ath10k_wmi_op_gen_delba_send(struct ath10k *ar, u32 vdev_id, const u8 *mac,
7305                             u32 tid, u32 initiator, u32 reason)
7306{
7307        struct wmi_delba_send_cmd *cmd;
7308        struct sk_buff *skb;
7309
7310        if (!mac)
7311                return ERR_PTR(-EINVAL);
7312
7313        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7314        if (!skb)
7315                return ERR_PTR(-ENOMEM);
7316
7317        cmd = (struct wmi_delba_send_cmd *)skb->data;
7318        cmd->vdev_id = __cpu_to_le32(vdev_id);
7319        ether_addr_copy(cmd->peer_macaddr.addr, mac);
7320        cmd->tid = __cpu_to_le32(tid);
7321        cmd->initiator = __cpu_to_le32(initiator);
7322        cmd->reasoncode = __cpu_to_le32(reason);
7323
7324        ath10k_dbg(ar, ATH10K_DBG_WMI,
7325                   "wmi delba send vdev_id 0x%X mac_addr %pM tid %u initiator %u reason %u\n",
7326                   vdev_id, mac, tid, initiator, reason);
7327        return skb;
7328}
7329
7330static struct sk_buff *
7331ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config(struct ath10k *ar, u32 param)
7332{
7333        struct wmi_pdev_get_tpc_config_cmd *cmd;
7334        struct sk_buff *skb;
7335
7336        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7337        if (!skb)
7338                return ERR_PTR(-ENOMEM);
7339
7340        cmd = (struct wmi_pdev_get_tpc_config_cmd *)skb->data;
7341        cmd->param = __cpu_to_le32(param);
7342
7343        ath10k_dbg(ar, ATH10K_DBG_WMI,
7344                   "wmi pdev get tcp config param:%d\n", param);
7345        return skb;
7346}
7347
7348size_t ath10k_wmi_fw_stats_num_peers(struct list_head *head)
7349{
7350        struct ath10k_fw_stats_peer *i;
7351        size_t num = 0;
7352
7353        list_for_each_entry(i, head, list)
7354                ++num;
7355
7356        return num;
7357}
7358
7359size_t ath10k_wmi_fw_stats_num_vdevs(struct list_head *head)
7360{
7361        struct ath10k_fw_stats_vdev *i;
7362        size_t num = 0;
7363
7364        list_for_each_entry(i, head, list)
7365                ++num;
7366
7367        return num;
7368}
7369
7370static void
7371ath10k_wmi_fw_pdev_base_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
7372                                   char *buf, u32 *length)
7373{
7374        u32 len = *length;
7375        u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7376
7377        len += scnprintf(buf + len, buf_len - len, "\n");
7378        len += scnprintf(buf + len, buf_len - len, "%30s\n",
7379                        "ath10k PDEV stats");
7380        len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7381                        "=================");
7382
7383        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7384                        "Channel noise floor", pdev->ch_noise_floor);
7385        len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7386                        "Channel TX power", pdev->chan_tx_power);
7387        len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7388                        "TX frame count", pdev->tx_frame_count);
7389        len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7390                        "RX frame count", pdev->rx_frame_count);
7391        len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7392                        "RX clear count", pdev->rx_clear_count);
7393        len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7394                        "Cycle count", pdev->cycle_count);
7395        len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7396                        "PHY error count", pdev->phy_err_count);
7397
7398        *length = len;
7399}
7400
7401static void
7402ath10k_wmi_fw_pdev_extra_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
7403                                    char *buf, u32 *length)
7404{
7405        u32 len = *length;
7406        u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7407
7408        len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7409                        "RTS bad count", pdev->rts_bad);
7410        len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7411                        "RTS good count", pdev->rts_good);
7412        len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7413                        "FCS bad count", pdev->fcs_bad);
7414        len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7415                        "No beacon count", pdev->no_beacons);
7416        len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7417                        "MIB int count", pdev->mib_int_count);
7418
7419        len += scnprintf(buf + len, buf_len - len, "\n");
7420        *length = len;
7421}
7422
7423static void
7424ath10k_wmi_fw_pdev_tx_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
7425                                 char *buf, u32 *length)
7426{
7427        u32 len = *length;
7428        u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7429
7430        len += scnprintf(buf + len, buf_len - len, "\n%30s\n",
7431                         "ath10k PDEV TX stats");
7432        len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7433                                 "=================");
7434
7435        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7436                         "HTT cookies queued", pdev->comp_queued);
7437        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7438                         "HTT cookies disp.", pdev->comp_delivered);
7439        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7440                         "MSDU queued", pdev->msdu_enqued);
7441        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7442                         "MPDU queued", pdev->mpdu_enqued);
7443        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7444                         "MSDUs dropped", pdev->wmm_drop);
7445        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7446                         "Local enqued", pdev->local_enqued);
7447        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7448                         "Local freed", pdev->local_freed);
7449        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7450                         "HW queued", pdev->hw_queued);
7451        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7452                         "PPDUs reaped", pdev->hw_reaped);
7453        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7454                         "Num underruns", pdev->underrun);
7455        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7456                         "PPDUs cleaned", pdev->tx_abort);
7457        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7458                         "MPDUs requed", pdev->mpdus_requed);
7459        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7460                         "Excessive retries", pdev->tx_ko);
7461        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7462                         "HW rate", pdev->data_rc);
7463        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7464                         "Sched self tiggers", pdev->self_triggers);
7465        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7466                         "Dropped due to SW retries",
7467                         pdev->sw_retry_failure);
7468        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7469                         "Illegal rate phy errors",
7470                         pdev->illgl_rate_phy_err);
7471        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7472                         "Pdev continuous xretry", pdev->pdev_cont_xretry);
7473        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7474                         "TX timeout", pdev->pdev_tx_timeout);
7475        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7476                         "PDEV resets", pdev->pdev_resets);
7477        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7478                         "PHY underrun", pdev->phy_underrun);
7479        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7480                         "MPDU is more than txop limit", pdev->txop_ovf);
7481        *length = len;
7482}
7483
7484static void
7485ath10k_wmi_fw_pdev_rx_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
7486                                 char *buf, u32 *length)
7487{
7488        u32 len = *length;
7489        u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7490
7491        len += scnprintf(buf + len, buf_len - len, "\n%30s\n",
7492                         "ath10k PDEV RX stats");
7493        len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7494                                 "=================");
7495
7496        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7497                         "Mid PPDU route change",
7498                         pdev->mid_ppdu_route_change);
7499        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7500                         "Tot. number of statuses", pdev->status_rcvd);
7501        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7502                         "Extra frags on rings 0", pdev->r0_frags);
7503        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7504                         "Extra frags on rings 1", pdev->r1_frags);
7505        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7506                         "Extra frags on rings 2", pdev->r2_frags);
7507        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7508                         "Extra frags on rings 3", pdev->r3_frags);
7509        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7510                         "MSDUs delivered to HTT", pdev->htt_msdus);
7511        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7512                         "MPDUs delivered to HTT", pdev->htt_mpdus);
7513        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7514                         "MSDUs delivered to stack", pdev->loc_msdus);
7515        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7516                         "MPDUs delivered to stack", pdev->loc_mpdus);
7517        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7518                         "Oversized AMSUs", pdev->oversize_amsdu);
7519        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7520                         "PHY errors", pdev->phy_errs);
7521        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7522                         "PHY errors drops", pdev->phy_err_drop);
7523        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7524                         "MPDU errors (FCS, MIC, ENC)", pdev->mpdu_errs);
7525        *length = len;
7526}
7527
7528static void
7529ath10k_wmi_fw_vdev_stats_fill(const struct ath10k_fw_stats_vdev *vdev,
7530                              char *buf, u32 *length)
7531{
7532        u32 len = *length;
7533        u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7534        int i;
7535
7536        len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7537                        "vdev id", vdev->vdev_id);
7538        len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7539                        "beacon snr", vdev->beacon_snr);
7540        len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7541                        "data snr", vdev->data_snr);
7542        len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7543                        "num rx frames", vdev->num_rx_frames);
7544        len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7545                        "num rts fail", vdev->num_rts_fail);
7546        len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7547                        "num rts success", vdev->num_rts_success);
7548        len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7549                        "num rx err", vdev->num_rx_err);
7550        len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7551                        "num rx discard", vdev->num_rx_discard);
7552        len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7553                        "num tx not acked", vdev->num_tx_not_acked);
7554
7555        for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames); i++)
7556                len += scnprintf(buf + len, buf_len - len,
7557                                "%25s [%02d] %u\n",
7558                                "num tx frames", i,
7559                                vdev->num_tx_frames[i]);
7560
7561        for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames_retries); i++)
7562                len += scnprintf(buf + len, buf_len - len,
7563                                "%25s [%02d] %u\n",
7564                                "num tx frames retries", i,
7565                                vdev->num_tx_frames_retries[i]);
7566
7567        for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames_failures); i++)
7568                len += scnprintf(buf + len, buf_len - len,
7569                                "%25s [%02d] %u\n",
7570                                "num tx frames failures", i,
7571                                vdev->num_tx_frames_failures[i]);
7572
7573        for (i = 0 ; i < ARRAY_SIZE(vdev->tx_rate_history); i++)
7574                len += scnprintf(buf + len, buf_len - len,
7575                                "%25s [%02d] 0x%08x\n",
7576                                "tx rate history", i,
7577                                vdev->tx_rate_history[i]);
7578
7579        for (i = 0 ; i < ARRAY_SIZE(vdev->beacon_rssi_history); i++)
7580                len += scnprintf(buf + len, buf_len - len,
7581                                "%25s [%02d] %u\n",
7582                                "beacon rssi history", i,
7583                                vdev->beacon_rssi_history[i]);
7584
7585        len += scnprintf(buf + len, buf_len - len, "\n");
7586        *length = len;
7587}
7588
7589static void
7590ath10k_wmi_fw_peer_stats_fill(const struct ath10k_fw_stats_peer *peer,
7591                              char *buf, u32 *length)
7592{
7593        u32 len = *length;
7594        u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7595
7596        len += scnprintf(buf + len, buf_len - len, "%30s %pM\n",
7597                        "Peer MAC address", peer->peer_macaddr);
7598        len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7599                        "Peer RSSI", peer->peer_rssi);
7600        len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7601                        "Peer TX rate", peer->peer_tx_rate);
7602        len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7603                        "Peer RX rate", peer->peer_rx_rate);
7604        len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7605                        "Peer RX duration", peer->rx_duration);
7606
7607        len += scnprintf(buf + len, buf_len - len, "\n");
7608        *length = len;
7609}
7610
7611void ath10k_wmi_main_op_fw_stats_fill(struct ath10k *ar,
7612                                      struct ath10k_fw_stats *fw_stats,
7613                                      char *buf)
7614{
7615        u32 len = 0;
7616        u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7617        const struct ath10k_fw_stats_pdev *pdev;
7618        const struct ath10k_fw_stats_vdev *vdev;
7619        const struct ath10k_fw_stats_peer *peer;
7620        size_t num_peers;
7621        size_t num_vdevs;
7622
7623        spin_lock_bh(&ar->data_lock);
7624
7625        pdev = list_first_entry_or_null(&fw_stats->pdevs,
7626                                        struct ath10k_fw_stats_pdev, list);
7627        if (!pdev) {
7628                ath10k_warn(ar, "failed to get pdev stats\n");
7629                goto unlock;
7630        }
7631
7632        num_peers = ath10k_wmi_fw_stats_num_peers(&fw_stats->peers);
7633        num_vdevs = ath10k_wmi_fw_stats_num_vdevs(&fw_stats->vdevs);
7634
7635        ath10k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len);
7636        ath10k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len);
7637        ath10k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len);
7638
7639        len += scnprintf(buf + len, buf_len - len, "\n");
7640        len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7641                         "ath10k VDEV stats", num_vdevs);
7642        len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7643                                 "=================");
7644
7645        list_for_each_entry(vdev, &fw_stats->vdevs, list) {
7646                ath10k_wmi_fw_vdev_stats_fill(vdev, buf, &len);
7647        }
7648
7649        len += scnprintf(buf + len, buf_len - len, "\n");
7650        len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7651                         "ath10k PEER stats", num_peers);
7652        len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7653                                 "=================");
7654
7655        list_for_each_entry(peer, &fw_stats->peers, list) {
7656                ath10k_wmi_fw_peer_stats_fill(peer, buf, &len);
7657        }
7658
7659unlock:
7660        spin_unlock_bh(&ar->data_lock);
7661
7662        if (len >= buf_len)
7663                buf[len - 1] = 0;
7664        else
7665                buf[len] = 0;
7666}
7667
7668void ath10k_wmi_10x_op_fw_stats_fill(struct ath10k *ar,
7669                                     struct ath10k_fw_stats *fw_stats,
7670                                     char *buf)
7671{
7672        unsigned int len = 0;
7673        unsigned int buf_len = ATH10K_FW_STATS_BUF_SIZE;
7674        const struct ath10k_fw_stats_pdev *pdev;
7675        const struct ath10k_fw_stats_vdev *vdev;
7676        const struct ath10k_fw_stats_peer *peer;
7677        size_t num_peers;
7678        size_t num_vdevs;
7679
7680        spin_lock_bh(&ar->data_lock);
7681
7682        pdev = list_first_entry_or_null(&fw_stats->pdevs,
7683                                        struct ath10k_fw_stats_pdev, list);
7684        if (!pdev) {
7685                ath10k_warn(ar, "failed to get pdev stats\n");
7686                goto unlock;
7687        }
7688
7689        num_peers = ath10k_wmi_fw_stats_num_peers(&fw_stats->peers);
7690        num_vdevs = ath10k_wmi_fw_stats_num_vdevs(&fw_stats->vdevs);
7691
7692        ath10k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len);
7693        ath10k_wmi_fw_pdev_extra_stats_fill(pdev, buf, &len);
7694        ath10k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len);
7695        ath10k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len);
7696
7697        len += scnprintf(buf + len, buf_len - len, "\n");
7698        len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7699                         "ath10k VDEV stats", num_vdevs);
7700        len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7701                                 "=================");
7702
7703        list_for_each_entry(vdev, &fw_stats->vdevs, list) {
7704                ath10k_wmi_fw_vdev_stats_fill(vdev, buf, &len);
7705        }
7706
7707        len += scnprintf(buf + len, buf_len - len, "\n");
7708        len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7709                         "ath10k PEER stats", num_peers);
7710        len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7711                                 "=================");
7712
7713        list_for_each_entry(peer, &fw_stats->peers, list) {
7714                ath10k_wmi_fw_peer_stats_fill(peer, buf, &len);
7715        }
7716
7717unlock:
7718        spin_unlock_bh(&ar->data_lock);
7719
7720        if (len >= buf_len)
7721                buf[len - 1] = 0;
7722        else
7723                buf[len] = 0;
7724}
7725
7726static struct sk_buff *
7727ath10k_wmi_op_gen_pdev_enable_adaptive_cca(struct ath10k *ar, u8 enable,
7728                                           u32 detect_level, u32 detect_margin)
7729{
7730        struct wmi_pdev_set_adaptive_cca_params *cmd;
7731        struct sk_buff *skb;
7732
7733        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7734        if (!skb)
7735                return ERR_PTR(-ENOMEM);
7736
7737        cmd = (struct wmi_pdev_set_adaptive_cca_params *)skb->data;
7738        cmd->enable = __cpu_to_le32(enable);
7739        cmd->cca_detect_level = __cpu_to_le32(detect_level);
7740        cmd->cca_detect_margin = __cpu_to_le32(detect_margin);
7741
7742        ath10k_dbg(ar, ATH10K_DBG_WMI,
7743                   "wmi pdev set adaptive cca params enable:%d detection level:%d detection margin:%d\n",
7744                   enable, detect_level, detect_margin);
7745        return skb;
7746}
7747
7748void ath10k_wmi_10_4_op_fw_stats_fill(struct ath10k *ar,
7749                                      struct ath10k_fw_stats *fw_stats,
7750                                      char *buf)
7751{
7752        u32 len = 0;
7753        u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7754        const struct ath10k_fw_stats_pdev *pdev;
7755        const struct ath10k_fw_stats_vdev *vdev;
7756        const struct ath10k_fw_stats_peer *peer;
7757        size_t num_peers;
7758        size_t num_vdevs;
7759
7760        spin_lock_bh(&ar->data_lock);
7761
7762        pdev = list_first_entry_or_null(&fw_stats->pdevs,
7763                                        struct ath10k_fw_stats_pdev, list);
7764        if (!pdev) {
7765                ath10k_warn(ar, "failed to get pdev stats\n");
7766                goto unlock;
7767        }
7768
7769        num_peers = ath10k_wmi_fw_stats_num_peers(&fw_stats->peers);
7770        num_vdevs = ath10k_wmi_fw_stats_num_vdevs(&fw_stats->vdevs);
7771
7772        ath10k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len);
7773        ath10k_wmi_fw_pdev_extra_stats_fill(pdev, buf, &len);
7774        ath10k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len);
7775
7776        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7777                        "HW paused", pdev->hw_paused);
7778        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7779                        "Seqs posted", pdev->seq_posted);
7780        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7781                        "Seqs failed queueing", pdev->seq_failed_queueing);
7782        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7783                        "Seqs completed", pdev->seq_completed);
7784        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7785                        "Seqs restarted", pdev->seq_restarted);
7786        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7787                        "MU Seqs posted", pdev->mu_seq_posted);
7788        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7789                        "MPDUs SW flushed", pdev->mpdus_sw_flush);
7790        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7791                        "MPDUs HW filtered", pdev->mpdus_hw_filter);
7792        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7793                        "MPDUs truncated", pdev->mpdus_truncated);
7794        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7795                        "MPDUs receive no ACK", pdev->mpdus_ack_failed);
7796        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7797                        "MPDUs expired", pdev->mpdus_expired);
7798
7799        ath10k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len);
7800        len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7801                        "Num Rx Overflow errors", pdev->rx_ovfl_errs);
7802
7803        len += scnprintf(buf + len, buf_len - len, "\n");
7804        len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7805                        "ath10k VDEV stats", num_vdevs);
7806        len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7807                                "=================");
7808
7809        list_for_each_entry(vdev, &fw_stats->vdevs, list) {
7810                ath10k_wmi_fw_vdev_stats_fill(vdev, buf, &len);
7811        }
7812
7813        len += scnprintf(buf + len, buf_len - len, "\n");
7814        len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7815                        "ath10k PEER stats", num_peers);
7816        len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7817                                "=================");
7818
7819        list_for_each_entry(peer, &fw_stats->peers, list) {
7820                ath10k_wmi_fw_peer_stats_fill(peer, buf, &len);
7821        }
7822
7823unlock:
7824        spin_unlock_bh(&ar->data_lock);
7825
7826        if (len >= buf_len)
7827                buf[len - 1] = 0;
7828        else
7829                buf[len] = 0;
7830}
7831
7832int ath10k_wmi_op_get_vdev_subtype(struct ath10k *ar,
7833                                   enum wmi_vdev_subtype subtype)
7834{
7835        switch (subtype) {
7836        case WMI_VDEV_SUBTYPE_NONE:
7837                return WMI_VDEV_SUBTYPE_LEGACY_NONE;
7838        case WMI_VDEV_SUBTYPE_P2P_DEVICE:
7839                return WMI_VDEV_SUBTYPE_LEGACY_P2P_DEV;
7840        case WMI_VDEV_SUBTYPE_P2P_CLIENT:
7841                return WMI_VDEV_SUBTYPE_LEGACY_P2P_CLI;
7842        case WMI_VDEV_SUBTYPE_P2P_GO:
7843                return WMI_VDEV_SUBTYPE_LEGACY_P2P_GO;
7844        case WMI_VDEV_SUBTYPE_PROXY_STA:
7845                return WMI_VDEV_SUBTYPE_LEGACY_PROXY_STA;
7846        case WMI_VDEV_SUBTYPE_MESH_11S:
7847        case WMI_VDEV_SUBTYPE_MESH_NON_11S:
7848                return -ENOTSUPP;
7849        }
7850        return -ENOTSUPP;
7851}
7852
7853static int ath10k_wmi_10_2_4_op_get_vdev_subtype(struct ath10k *ar,
7854                                                 enum wmi_vdev_subtype subtype)
7855{
7856        switch (subtype) {
7857        case WMI_VDEV_SUBTYPE_NONE:
7858                return WMI_VDEV_SUBTYPE_10_2_4_NONE;
7859        case WMI_VDEV_SUBTYPE_P2P_DEVICE:
7860                return WMI_VDEV_SUBTYPE_10_2_4_P2P_DEV;
7861        case WMI_VDEV_SUBTYPE_P2P_CLIENT:
7862                return WMI_VDEV_SUBTYPE_10_2_4_P2P_CLI;
7863        case WMI_VDEV_SUBTYPE_P2P_GO:
7864                return WMI_VDEV_SUBTYPE_10_2_4_P2P_GO;
7865        case WMI_VDEV_SUBTYPE_PROXY_STA:
7866                return WMI_VDEV_SUBTYPE_10_2_4_PROXY_STA;
7867        case WMI_VDEV_SUBTYPE_MESH_11S:
7868                return WMI_VDEV_SUBTYPE_10_2_4_MESH_11S;
7869        case WMI_VDEV_SUBTYPE_MESH_NON_11S:
7870                return -ENOTSUPP;
7871        }
7872        return -ENOTSUPP;
7873}
7874
7875static int ath10k_wmi_10_4_op_get_vdev_subtype(struct ath10k *ar,
7876                                               enum wmi_vdev_subtype subtype)
7877{
7878        switch (subtype) {
7879        case WMI_VDEV_SUBTYPE_NONE:
7880                return WMI_VDEV_SUBTYPE_10_4_NONE;
7881        case WMI_VDEV_SUBTYPE_P2P_DEVICE:
7882                return WMI_VDEV_SUBTYPE_10_4_P2P_DEV;
7883        case WMI_VDEV_SUBTYPE_P2P_CLIENT:
7884                return WMI_VDEV_SUBTYPE_10_4_P2P_CLI;
7885        case WMI_VDEV_SUBTYPE_P2P_GO:
7886                return WMI_VDEV_SUBTYPE_10_4_P2P_GO;
7887        case WMI_VDEV_SUBTYPE_PROXY_STA:
7888                return WMI_VDEV_SUBTYPE_10_4_PROXY_STA;
7889        case WMI_VDEV_SUBTYPE_MESH_11S:
7890                return WMI_VDEV_SUBTYPE_10_4_MESH_11S;
7891        case WMI_VDEV_SUBTYPE_MESH_NON_11S:
7892                return WMI_VDEV_SUBTYPE_10_4_MESH_NON_11S;
7893        }
7894        return -ENOTSUPP;
7895}
7896
7897static struct sk_buff *
7898ath10k_wmi_10_4_ext_resource_config(struct ath10k *ar,
7899                                    enum wmi_host_platform_type type,
7900                                    u32 fw_feature_bitmap)
7901{
7902        struct wmi_ext_resource_config_10_4_cmd *cmd;
7903        struct sk_buff *skb;
7904        u32 num_tdls_sleep_sta = 0;
7905
7906        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7907        if (!skb)
7908                return ERR_PTR(-ENOMEM);
7909
7910        if (test_bit(WMI_SERVICE_TDLS_UAPSD_SLEEP_STA, ar->wmi.svc_map))
7911                num_tdls_sleep_sta = TARGET_10_4_NUM_TDLS_SLEEP_STA;
7912
7913        cmd = (struct wmi_ext_resource_config_10_4_cmd *)skb->data;
7914        cmd->host_platform_config = __cpu_to_le32(type);
7915        cmd->fw_feature_bitmap = __cpu_to_le32(fw_feature_bitmap);
7916        cmd->wlan_gpio_priority = __cpu_to_le32(-1);
7917        cmd->coex_version = __cpu_to_le32(WMI_NO_COEX_VERSION_SUPPORT);
7918        cmd->coex_gpio_pin1 = __cpu_to_le32(-1);
7919        cmd->coex_gpio_pin2 = __cpu_to_le32(-1);
7920        cmd->coex_gpio_pin3 = __cpu_to_le32(-1);
7921        cmd->num_tdls_vdevs = __cpu_to_le32(TARGET_10_4_NUM_TDLS_VDEVS);
7922        cmd->num_tdls_conn_table_entries = __cpu_to_le32(20);
7923        cmd->max_tdls_concurrent_sleep_sta = __cpu_to_le32(num_tdls_sleep_sta);
7924        cmd->max_tdls_concurrent_buffer_sta =
7925                        __cpu_to_le32(TARGET_10_4_NUM_TDLS_BUFFER_STA);
7926
7927        ath10k_dbg(ar, ATH10K_DBG_WMI,
7928                   "wmi ext resource config host type %d firmware feature bitmap %08x\n",
7929                   type, fw_feature_bitmap);
7930        return skb;
7931}
7932
7933static struct sk_buff *
7934ath10k_wmi_10_4_gen_update_fw_tdls_state(struct ath10k *ar, u32 vdev_id,
7935                                         enum wmi_tdls_state state)
7936{
7937        struct wmi_10_4_tdls_set_state_cmd *cmd;
7938        struct sk_buff *skb;
7939        u32 options = 0;
7940
7941        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7942        if (!skb)
7943                return ERR_PTR(-ENOMEM);
7944
7945        if (test_bit(WMI_SERVICE_TDLS_EXPLICIT_MODE_ONLY, ar->wmi.svc_map) &&
7946            state == WMI_TDLS_ENABLE_ACTIVE)
7947                state = WMI_TDLS_ENABLE_PASSIVE;
7948
7949        if (test_bit(WMI_SERVICE_TDLS_UAPSD_BUFFER_STA, ar->wmi.svc_map))
7950                options |= WMI_TDLS_BUFFER_STA_EN;
7951
7952        cmd = (struct wmi_10_4_tdls_set_state_cmd *)skb->data;
7953        cmd->vdev_id = __cpu_to_le32(vdev_id);
7954        cmd->state = __cpu_to_le32(state);
7955        cmd->notification_interval_ms = __cpu_to_le32(5000);
7956        cmd->tx_discovery_threshold = __cpu_to_le32(100);
7957        cmd->tx_teardown_threshold = __cpu_to_le32(5);
7958        cmd->rssi_teardown_threshold = __cpu_to_le32(-75);
7959        cmd->rssi_delta = __cpu_to_le32(-20);
7960        cmd->tdls_options = __cpu_to_le32(options);
7961        cmd->tdls_peer_traffic_ind_window = __cpu_to_le32(2);
7962        cmd->tdls_peer_traffic_response_timeout_ms = __cpu_to_le32(5000);
7963        cmd->tdls_puapsd_mask = __cpu_to_le32(0xf);
7964        cmd->tdls_puapsd_inactivity_time_ms = __cpu_to_le32(0);
7965        cmd->tdls_puapsd_rx_frame_threshold = __cpu_to_le32(10);
7966        cmd->teardown_notification_ms = __cpu_to_le32(10);
7967        cmd->tdls_peer_kickout_threshold = __cpu_to_le32(96);
7968
7969        ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi update fw tdls state %d for vdev %i\n",
7970                   state, vdev_id);
7971        return skb;
7972}
7973
7974static u32 ath10k_wmi_prepare_peer_qos(u8 uapsd_queues, u8 sp)
7975{
7976        u32 peer_qos = 0;
7977
7978        if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
7979                peer_qos |= WMI_TDLS_PEER_QOS_AC_VO;
7980        if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI)
7981                peer_qos |= WMI_TDLS_PEER_QOS_AC_VI;
7982        if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK)
7983                peer_qos |= WMI_TDLS_PEER_QOS_AC_BK;
7984        if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE)
7985                peer_qos |= WMI_TDLS_PEER_QOS_AC_BE;
7986
7987        peer_qos |= SM(sp, WMI_TDLS_PEER_SP);
7988
7989        return peer_qos;
7990}
7991
7992static struct sk_buff *
7993ath10k_wmi_10_4_gen_tdls_peer_update(struct ath10k *ar,
7994                                     const struct wmi_tdls_peer_update_cmd_arg *arg,
7995                                     const struct wmi_tdls_peer_capab_arg *cap,
7996                                     const struct wmi_channel_arg *chan_arg)
7997{
7998        struct wmi_10_4_tdls_peer_update_cmd *cmd;
7999        struct wmi_tdls_peer_capabilities *peer_cap;
8000        struct wmi_channel *chan;
8001        struct sk_buff *skb;
8002        u32 peer_qos;
8003        int len, chan_len;
8004        int i;
8005
8006        /* tdls peer update cmd has place holder for one channel*/
8007        chan_len = cap->peer_chan_len ? (cap->peer_chan_len - 1) : 0;
8008
8009        len = sizeof(*cmd) + chan_len * sizeof(*chan);
8010
8011        skb = ath10k_wmi_alloc_skb(ar, len);
8012        if (!skb)
8013                return ERR_PTR(-ENOMEM);
8014
8015        memset(skb->data, 0, sizeof(*cmd));
8016
8017        cmd = (struct wmi_10_4_tdls_peer_update_cmd *)skb->data;
8018        cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
8019        ether_addr_copy(cmd->peer_macaddr.addr, arg->addr);
8020        cmd->peer_state = __cpu_to_le32(arg->peer_state);
8021
8022        peer_qos = ath10k_wmi_prepare_peer_qos(cap->peer_uapsd_queues,
8023                                               cap->peer_max_sp);
8024
8025        peer_cap = &cmd->peer_capab;
8026        peer_cap->peer_qos = __cpu_to_le32(peer_qos);
8027        peer_cap->buff_sta_support = __cpu_to_le32(cap->buff_sta_support);
8028        peer_cap->off_chan_support = __cpu_to_le32(cap->off_chan_support);
8029        peer_cap->peer_curr_operclass = __cpu_to_le32(cap->peer_curr_operclass);
8030        peer_cap->self_curr_operclass = __cpu_to_le32(cap->self_curr_operclass);
8031        peer_cap->peer_chan_len = __cpu_to_le32(cap->peer_chan_len);
8032        peer_cap->peer_operclass_len = __cpu_to_le32(cap->peer_operclass_len);
8033
8034        for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++)
8035                peer_cap->peer_operclass[i] = cap->peer_operclass[i];
8036
8037        peer_cap->is_peer_responder = __cpu_to_le32(cap->is_peer_responder);
8038        peer_cap->pref_offchan_num = __cpu_to_le32(cap->pref_offchan_num);
8039        peer_cap->pref_offchan_bw = __cpu_to_le32(cap->pref_offchan_bw);
8040
8041        for (i = 0; i < cap->peer_chan_len; i++) {
8042                chan = (struct wmi_channel *)&peer_cap->peer_chan_list[i];
8043                ath10k_wmi_put_wmi_channel(chan, &chan_arg[i]);
8044        }
8045
8046        ath10k_dbg(ar, ATH10K_DBG_WMI,
8047                   "wmi tdls peer update vdev %i state %d n_chans %u\n",
8048                   arg->vdev_id, arg->peer_state, cap->peer_chan_len);
8049        return skb;
8050}
8051
8052static struct sk_buff *
8053ath10k_wmi_op_gen_echo(struct ath10k *ar, u32 value)
8054{
8055        struct wmi_echo_cmd *cmd;
8056        struct sk_buff *skb;
8057
8058        skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
8059        if (!skb)
8060                return ERR_PTR(-ENOMEM);
8061
8062        cmd = (struct wmi_echo_cmd *)skb->data;
8063        cmd->value = cpu_to_le32(value);
8064
8065        ath10k_dbg(ar, ATH10K_DBG_WMI,
8066                   "wmi echo value 0x%08x\n", value);
8067        return skb;
8068}
8069
8070int
8071ath10k_wmi_barrier(struct ath10k *ar)
8072{
8073        int ret;
8074        int time_left;
8075
8076        spin_lock_bh(&ar->data_lock);
8077        reinit_completion(&ar->wmi.barrier);
8078        spin_unlock_bh(&ar->data_lock);
8079
8080        ret = ath10k_wmi_echo(ar, ATH10K_WMI_BARRIER_ECHO_ID);
8081        if (ret) {
8082                ath10k_warn(ar, "failed to submit wmi echo: %d\n", ret);
8083                return ret;
8084        }
8085
8086        time_left = wait_for_completion_timeout(&ar->wmi.barrier,
8087                                                ATH10K_WMI_BARRIER_TIMEOUT_HZ);
8088        if (!time_left)
8089                return -ETIMEDOUT;
8090
8091        return 0;
8092}
8093
8094static const struct wmi_ops wmi_ops = {
8095        .rx = ath10k_wmi_op_rx,
8096        .map_svc = wmi_main_svc_map,
8097
8098        .pull_scan = ath10k_wmi_op_pull_scan_ev,
8099        .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
8100        .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
8101        .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
8102        .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
8103        .pull_swba = ath10k_wmi_op_pull_swba_ev,
8104        .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
8105        .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
8106        .pull_svc_rdy = ath10k_wmi_main_op_pull_svc_rdy_ev,
8107        .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
8108        .pull_fw_stats = ath10k_wmi_main_op_pull_fw_stats,
8109        .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
8110        .pull_echo_ev = ath10k_wmi_op_pull_echo_ev,
8111
8112        .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
8113        .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
8114        .gen_pdev_set_rd = ath10k_wmi_op_gen_pdev_set_rd,
8115        .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
8116        .gen_init = ath10k_wmi_op_gen_init,
8117        .gen_start_scan = ath10k_wmi_op_gen_start_scan,
8118        .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
8119        .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
8120        .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
8121        .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
8122        .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
8123        .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
8124        .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
8125        .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
8126        .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
8127        .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
8128        .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
8129        /* .gen_vdev_wmm_conf not implemented */
8130        .gen_peer_create = ath10k_wmi_op_gen_peer_create,
8131        .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
8132        .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
8133        .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
8134        .gen_peer_assoc = ath10k_wmi_op_gen_peer_assoc,
8135        .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
8136        .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
8137        .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
8138        .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
8139        .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
8140        .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
8141        .gen_request_stats = ath10k_wmi_op_gen_request_stats,
8142        .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
8143        .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
8144        .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
8145        .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
8146        .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
8147        .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
8148        /* .gen_pdev_get_temperature not implemented */
8149        .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
8150        .gen_addba_send = ath10k_wmi_op_gen_addba_send,
8151        .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
8152        .gen_delba_send = ath10k_wmi_op_gen_delba_send,
8153        .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
8154        .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
8155        .gen_echo = ath10k_wmi_op_gen_echo,
8156        /* .gen_bcn_tmpl not implemented */
8157        /* .gen_prb_tmpl not implemented */
8158        /* .gen_p2p_go_bcn_ie not implemented */
8159        /* .gen_adaptive_qcs not implemented */
8160        /* .gen_pdev_enable_adaptive_cca not implemented */
8161};
8162
8163static const struct wmi_ops wmi_10_1_ops = {
8164        .rx = ath10k_wmi_10_1_op_rx,
8165        .map_svc = wmi_10x_svc_map,
8166        .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
8167        .pull_fw_stats = ath10k_wmi_10x_op_pull_fw_stats,
8168        .gen_init = ath10k_wmi_10_1_op_gen_init,
8169        .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
8170        .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
8171        .gen_peer_assoc = ath10k_wmi_10_1_op_gen_peer_assoc,
8172        /* .gen_pdev_get_temperature not implemented */
8173
8174        /* shared with main branch */
8175        .pull_scan = ath10k_wmi_op_pull_scan_ev,
8176        .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
8177        .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
8178        .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
8179        .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
8180        .pull_swba = ath10k_wmi_op_pull_swba_ev,
8181        .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
8182        .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
8183        .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
8184        .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
8185        .pull_echo_ev = ath10k_wmi_op_pull_echo_ev,
8186
8187        .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
8188        .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
8189        .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
8190        .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
8191        .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
8192        .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
8193        .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
8194        .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
8195        .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
8196        .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
8197        .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
8198        .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
8199        .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
8200        .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
8201        /* .gen_vdev_wmm_conf not implemented */
8202        .gen_peer_create = ath10k_wmi_op_gen_peer_create,
8203        .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
8204        .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
8205        .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
8206        .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
8207        .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
8208        .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
8209        .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
8210        .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
8211        .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
8212        .gen_request_stats = ath10k_wmi_op_gen_request_stats,
8213        .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
8214        .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
8215        .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
8216        .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
8217        .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
8218        .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
8219        .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
8220        .gen_addba_send = ath10k_wmi_op_gen_addba_send,
8221        .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
8222        .gen_delba_send = ath10k_wmi_op_gen_delba_send,
8223        .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
8224        .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
8225        .gen_echo = ath10k_wmi_op_gen_echo,
8226        /* .gen_bcn_tmpl not implemented */
8227        /* .gen_prb_tmpl not implemented */
8228        /* .gen_p2p_go_bcn_ie not implemented */
8229        /* .gen_adaptive_qcs not implemented */
8230        /* .gen_pdev_enable_adaptive_cca not implemented */
8231};
8232
8233static const struct wmi_ops wmi_10_2_ops = {
8234        .rx = ath10k_wmi_10_2_op_rx,
8235        .pull_fw_stats = ath10k_wmi_10_2_op_pull_fw_stats,
8236        .gen_init = ath10k_wmi_10_2_op_gen_init,
8237        .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
8238        /* .gen_pdev_get_temperature not implemented */
8239
8240        /* shared with 10.1 */
8241        .map_svc = wmi_10x_svc_map,
8242        .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
8243        .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
8244        .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
8245        .gen_echo = ath10k_wmi_op_gen_echo,
8246
8247        .pull_scan = ath10k_wmi_op_pull_scan_ev,
8248        .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
8249        .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
8250        .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
8251        .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
8252        .pull_swba = ath10k_wmi_op_pull_swba_ev,
8253        .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
8254        .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
8255        .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
8256        .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
8257        .pull_echo_ev = ath10k_wmi_op_pull_echo_ev,
8258
8259        .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
8260        .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
8261        .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
8262        .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
8263        .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
8264        .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
8265        .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
8266        .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
8267        .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
8268        .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
8269        .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
8270        .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
8271        .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
8272        .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
8273        /* .gen_vdev_wmm_conf not implemented */
8274        .gen_peer_create = ath10k_wmi_op_gen_peer_create,
8275        .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
8276        .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
8277        .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
8278        .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
8279        .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
8280        .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
8281        .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
8282        .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
8283        .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
8284        .gen_request_stats = ath10k_wmi_op_gen_request_stats,
8285        .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
8286        .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
8287        .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
8288        .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
8289        .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
8290        .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
8291        .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
8292        .gen_addba_send = ath10k_wmi_op_gen_addba_send,
8293        .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
8294        .gen_delba_send = ath10k_wmi_op_gen_delba_send,
8295        .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
8296        .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
8297        /* .gen_pdev_enable_adaptive_cca not implemented */
8298};
8299
8300static const struct wmi_ops wmi_10_2_4_ops = {
8301        .rx = ath10k_wmi_10_2_op_rx,
8302        .pull_fw_stats = ath10k_wmi_10_2_4_op_pull_fw_stats,
8303        .gen_init = ath10k_wmi_10_2_op_gen_init,
8304        .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
8305        .gen_pdev_get_temperature = ath10k_wmi_10_2_op_gen_pdev_get_temperature,
8306        .gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info,
8307
8308        /* shared with 10.1 */
8309        .map_svc = wmi_10x_svc_map,
8310        .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
8311        .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
8312        .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
8313        .gen_echo = ath10k_wmi_op_gen_echo,
8314
8315        .pull_scan = ath10k_wmi_op_pull_scan_ev,
8316        .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
8317        .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
8318        .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
8319        .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
8320        .pull_swba = ath10k_wmi_10_2_4_op_pull_swba_ev,
8321        .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
8322        .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
8323        .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
8324        .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
8325        .pull_echo_ev = ath10k_wmi_op_pull_echo_ev,
8326
8327        .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
8328        .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
8329        .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
8330        .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
8331        .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
8332        .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
8333        .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
8334        .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
8335        .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
8336        .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
8337        .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
8338        .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
8339        .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
8340        .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
8341        .gen_peer_create = ath10k_wmi_op_gen_peer_create,
8342        .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
8343        .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
8344        .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
8345        .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
8346        .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
8347        .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
8348        .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
8349        .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
8350        .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
8351        .gen_request_stats = ath10k_wmi_op_gen_request_stats,
8352        .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
8353        .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
8354        .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
8355        .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
8356        .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
8357        .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
8358        .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
8359        .gen_addba_send = ath10k_wmi_op_gen_addba_send,
8360        .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
8361        .gen_delba_send = ath10k_wmi_op_gen_delba_send,
8362        .gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config,
8363        .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
8364        .gen_pdev_enable_adaptive_cca =
8365                ath10k_wmi_op_gen_pdev_enable_adaptive_cca,
8366        .get_vdev_subtype = ath10k_wmi_10_2_4_op_get_vdev_subtype,
8367        /* .gen_bcn_tmpl not implemented */
8368        /* .gen_prb_tmpl not implemented */
8369        /* .gen_p2p_go_bcn_ie not implemented */
8370        /* .gen_adaptive_qcs not implemented */
8371};
8372
8373static const struct wmi_ops wmi_10_4_ops = {
8374        .rx = ath10k_wmi_10_4_op_rx,
8375        .map_svc = wmi_10_4_svc_map,
8376
8377        .pull_fw_stats = ath10k_wmi_10_4_op_pull_fw_stats,
8378        .pull_scan = ath10k_wmi_op_pull_scan_ev,
8379        .pull_mgmt_rx = ath10k_wmi_10_4_op_pull_mgmt_rx_ev,
8380        .pull_ch_info = ath10k_wmi_10_4_op_pull_ch_info_ev,
8381        .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
8382        .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
8383        .pull_swba = ath10k_wmi_10_4_op_pull_swba_ev,
8384        .pull_phyerr_hdr = ath10k_wmi_10_4_op_pull_phyerr_ev_hdr,
8385        .pull_phyerr = ath10k_wmi_10_4_op_pull_phyerr_ev,
8386        .pull_svc_rdy = ath10k_wmi_main_op_pull_svc_rdy_ev,
8387        .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
8388        .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
8389        .get_txbf_conf_scheme = ath10k_wmi_10_4_txbf_conf_scheme,
8390
8391        .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
8392        .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
8393        .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
8394        .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
8395        .gen_init = ath10k_wmi_10_4_op_gen_init,
8396        .gen_start_scan = ath10k_wmi_op_gen_start_scan,
8397        .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
8398        .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
8399        .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
8400        .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
8401        .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
8402        .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
8403        .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
8404        .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
8405        .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
8406        .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
8407        .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
8408        .gen_peer_create = ath10k_wmi_op_gen_peer_create,
8409        .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
8410        .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
8411        .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
8412        .gen_peer_assoc = ath10k_wmi_10_4_op_gen_peer_assoc,
8413        .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
8414        .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
8415        .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
8416        .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
8417        .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
8418        .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
8419        .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
8420        .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
8421        .gen_dbglog_cfg = ath10k_wmi_10_4_op_gen_dbglog_cfg,
8422        .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
8423        .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
8424        .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
8425        .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
8426        .gen_addba_send = ath10k_wmi_op_gen_addba_send,
8427        .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
8428        .gen_delba_send = ath10k_wmi_op_gen_delba_send,
8429        .fw_stats_fill = ath10k_wmi_10_4_op_fw_stats_fill,
8430        .ext_resource_config = ath10k_wmi_10_4_ext_resource_config,
8431        .gen_update_fw_tdls_state = ath10k_wmi_10_4_gen_update_fw_tdls_state,
8432        .gen_tdls_peer_update = ath10k_wmi_10_4_gen_tdls_peer_update,
8433
8434        /* shared with 10.2 */
8435        .pull_echo_ev = ath10k_wmi_op_pull_echo_ev,
8436        .gen_request_stats = ath10k_wmi_op_gen_request_stats,
8437        .gen_pdev_get_temperature = ath10k_wmi_10_2_op_gen_pdev_get_temperature,
8438        .get_vdev_subtype = ath10k_wmi_10_4_op_get_vdev_subtype,
8439        .gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info,
8440        .gen_echo = ath10k_wmi_op_gen_echo,
8441        .gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config,
8442};
8443
8444int ath10k_wmi_attach(struct ath10k *ar)
8445{
8446        switch (ar->running_fw->fw_file.wmi_op_version) {
8447        case ATH10K_FW_WMI_OP_VERSION_10_4:
8448                ar->wmi.ops = &wmi_10_4_ops;
8449                ar->wmi.cmd = &wmi_10_4_cmd_map;
8450                ar->wmi.vdev_param = &wmi_10_4_vdev_param_map;
8451                ar->wmi.pdev_param = &wmi_10_4_pdev_param_map;
8452                ar->wmi.peer_flags = &wmi_10_2_peer_flags_map;
8453                break;
8454        case ATH10K_FW_WMI_OP_VERSION_10_2_4:
8455                ar->wmi.cmd = &wmi_10_2_4_cmd_map;
8456                ar->wmi.ops = &wmi_10_2_4_ops;
8457                ar->wmi.vdev_param = &wmi_10_2_4_vdev_param_map;
8458                ar->wmi.pdev_param = &wmi_10_2_4_pdev_param_map;
8459                ar->wmi.peer_flags = &wmi_10_2_peer_flags_map;
8460                break;
8461        case ATH10K_FW_WMI_OP_VERSION_10_2:
8462                ar->wmi.cmd = &wmi_10_2_cmd_map;
8463                ar->wmi.ops = &wmi_10_2_ops;
8464                ar->wmi.vdev_param = &wmi_10x_vdev_param_map;
8465                ar->wmi.pdev_param = &wmi_10x_pdev_param_map;
8466                ar->wmi.peer_flags = &wmi_10_2_peer_flags_map;
8467                break;
8468        case ATH10K_FW_WMI_OP_VERSION_10_1:
8469                ar->wmi.cmd = &wmi_10x_cmd_map;
8470                ar->wmi.ops = &wmi_10_1_ops;
8471                ar->wmi.vdev_param = &wmi_10x_vdev_param_map;
8472                ar->wmi.pdev_param = &wmi_10x_pdev_param_map;
8473                ar->wmi.peer_flags = &wmi_10x_peer_flags_map;
8474                break;
8475        case ATH10K_FW_WMI_OP_VERSION_MAIN:
8476                ar->wmi.cmd = &wmi_cmd_map;
8477                ar->wmi.ops = &wmi_ops;
8478                ar->wmi.vdev_param = &wmi_vdev_param_map;
8479                ar->wmi.pdev_param = &wmi_pdev_param_map;
8480                ar->wmi.peer_flags = &wmi_peer_flags_map;
8481                break;
8482        case ATH10K_FW_WMI_OP_VERSION_TLV:
8483                ath10k_wmi_tlv_attach(ar);
8484                break;
8485        case ATH10K_FW_WMI_OP_VERSION_UNSET:
8486        case ATH10K_FW_WMI_OP_VERSION_MAX:
8487                ath10k_err(ar, "unsupported WMI op version: %d\n",
8488                           ar->running_fw->fw_file.wmi_op_version);
8489                return -EINVAL;
8490        }
8491
8492        init_completion(&ar->wmi.service_ready);
8493        init_completion(&ar->wmi.unified_ready);
8494        init_completion(&ar->wmi.barrier);
8495
8496        INIT_WORK(&ar->svc_rdy_work, ath10k_wmi_event_service_ready_work);
8497
8498        return 0;
8499}
8500
8501void ath10k_wmi_free_host_mem(struct ath10k *ar)
8502{
8503        int i;
8504
8505        /* free the host memory chunks requested by firmware */
8506        for (i = 0; i < ar->wmi.num_mem_chunks; i++) {
8507                dma_free_coherent(ar->dev,
8508                                  ar->wmi.mem_chunks[i].len,
8509                                  ar->wmi.mem_chunks[i].vaddr,
8510                                  ar->wmi.mem_chunks[i].paddr);
8511        }
8512
8513        ar->wmi.num_mem_chunks = 0;
8514}
8515
8516void ath10k_wmi_detach(struct ath10k *ar)
8517{
8518        cancel_work_sync(&ar->svc_rdy_work);
8519
8520        if (ar->svc_rdy_skb)
8521                dev_kfree_skb(ar->svc_rdy_skb);
8522}
8523