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