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