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