Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2005-2011 Atheros Communications Inc. |
| 3 | * Copyright (c) 2011-2013 Qualcomm Atheros, Inc. |
| 4 | * |
| 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 6 | * purpose with or without fee is hereby granted, provided that the above |
| 7 | * copyright notice and this permission notice appear in all copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | */ |
| 17 | |
| 18 | #include <linux/skbuff.h> |
Kalle Valo | 2fe5288 | 2014-01-03 12:59:20 +0200 | [diff] [blame] | 19 | #include <linux/ctype.h> |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 20 | |
| 21 | #include "core.h" |
| 22 | #include "htc.h" |
| 23 | #include "debug.h" |
| 24 | #include "wmi.h" |
| 25 | #include "mac.h" |
Kalle Valo | 43d2a30 | 2014-09-10 18:23:30 +0300 | [diff] [blame] | 26 | #include "testmode.h" |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 27 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 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 | .pdev_set_regdomain_cmdid = WMI_PDEV_SET_REGDOMAIN_CMDID, |
| 36 | .pdev_set_channel_cmdid = WMI_PDEV_SET_CHANNEL_CMDID, |
| 37 | .pdev_set_param_cmdid = WMI_PDEV_SET_PARAM_CMDID, |
| 38 | .pdev_pktlog_enable_cmdid = WMI_PDEV_PKTLOG_ENABLE_CMDID, |
| 39 | .pdev_pktlog_disable_cmdid = WMI_PDEV_PKTLOG_DISABLE_CMDID, |
| 40 | .pdev_set_wmm_params_cmdid = WMI_PDEV_SET_WMM_PARAMS_CMDID, |
| 41 | .pdev_set_ht_cap_ie_cmdid = WMI_PDEV_SET_HT_CAP_IE_CMDID, |
| 42 | .pdev_set_vht_cap_ie_cmdid = WMI_PDEV_SET_VHT_CAP_IE_CMDID, |
| 43 | .pdev_set_dscp_tid_map_cmdid = WMI_PDEV_SET_DSCP_TID_MAP_CMDID, |
| 44 | .pdev_set_quiet_mode_cmdid = WMI_PDEV_SET_QUIET_MODE_CMDID, |
| 45 | .pdev_green_ap_ps_enable_cmdid = WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID, |
| 46 | .pdev_get_tpc_config_cmdid = WMI_PDEV_GET_TPC_CONFIG_CMDID, |
| 47 | .pdev_set_base_macaddr_cmdid = WMI_PDEV_SET_BASE_MACADDR_CMDID, |
| 48 | .vdev_create_cmdid = WMI_VDEV_CREATE_CMDID, |
| 49 | .vdev_delete_cmdid = WMI_VDEV_DELETE_CMDID, |
| 50 | .vdev_start_request_cmdid = WMI_VDEV_START_REQUEST_CMDID, |
| 51 | .vdev_restart_request_cmdid = WMI_VDEV_RESTART_REQUEST_CMDID, |
| 52 | .vdev_up_cmdid = WMI_VDEV_UP_CMDID, |
| 53 | .vdev_stop_cmdid = WMI_VDEV_STOP_CMDID, |
| 54 | .vdev_down_cmdid = WMI_VDEV_DOWN_CMDID, |
| 55 | .vdev_set_param_cmdid = WMI_VDEV_SET_PARAM_CMDID, |
| 56 | .vdev_install_key_cmdid = WMI_VDEV_INSTALL_KEY_CMDID, |
| 57 | .peer_create_cmdid = WMI_PEER_CREATE_CMDID, |
| 58 | .peer_delete_cmdid = WMI_PEER_DELETE_CMDID, |
| 59 | .peer_flush_tids_cmdid = WMI_PEER_FLUSH_TIDS_CMDID, |
| 60 | .peer_set_param_cmdid = WMI_PEER_SET_PARAM_CMDID, |
| 61 | .peer_assoc_cmdid = WMI_PEER_ASSOC_CMDID, |
| 62 | .peer_add_wds_entry_cmdid = WMI_PEER_ADD_WDS_ENTRY_CMDID, |
| 63 | .peer_remove_wds_entry_cmdid = WMI_PEER_REMOVE_WDS_ENTRY_CMDID, |
| 64 | .peer_mcast_group_cmdid = WMI_PEER_MCAST_GROUP_CMDID, |
| 65 | .bcn_tx_cmdid = WMI_BCN_TX_CMDID, |
| 66 | .pdev_send_bcn_cmdid = WMI_PDEV_SEND_BCN_CMDID, |
| 67 | .bcn_tmpl_cmdid = WMI_BCN_TMPL_CMDID, |
| 68 | .bcn_filter_rx_cmdid = WMI_BCN_FILTER_RX_CMDID, |
| 69 | .prb_req_filter_rx_cmdid = WMI_PRB_REQ_FILTER_RX_CMDID, |
| 70 | .mgmt_tx_cmdid = WMI_MGMT_TX_CMDID, |
| 71 | .prb_tmpl_cmdid = WMI_PRB_TMPL_CMDID, |
| 72 | .addba_clear_resp_cmdid = WMI_ADDBA_CLEAR_RESP_CMDID, |
| 73 | .addba_send_cmdid = WMI_ADDBA_SEND_CMDID, |
| 74 | .addba_status_cmdid = WMI_ADDBA_STATUS_CMDID, |
| 75 | .delba_send_cmdid = WMI_DELBA_SEND_CMDID, |
| 76 | .addba_set_resp_cmdid = WMI_ADDBA_SET_RESP_CMDID, |
| 77 | .send_singleamsdu_cmdid = WMI_SEND_SINGLEAMSDU_CMDID, |
| 78 | .sta_powersave_mode_cmdid = WMI_STA_POWERSAVE_MODE_CMDID, |
| 79 | .sta_powersave_param_cmdid = WMI_STA_POWERSAVE_PARAM_CMDID, |
| 80 | .sta_mimo_ps_mode_cmdid = WMI_STA_MIMO_PS_MODE_CMDID, |
| 81 | .pdev_dfs_enable_cmdid = WMI_PDEV_DFS_ENABLE_CMDID, |
| 82 | .pdev_dfs_disable_cmdid = WMI_PDEV_DFS_DISABLE_CMDID, |
| 83 | .roam_scan_mode = WMI_ROAM_SCAN_MODE, |
| 84 | .roam_scan_rssi_threshold = WMI_ROAM_SCAN_RSSI_THRESHOLD, |
| 85 | .roam_scan_period = WMI_ROAM_SCAN_PERIOD, |
| 86 | .roam_scan_rssi_change_threshold = WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD, |
| 87 | .roam_ap_profile = WMI_ROAM_AP_PROFILE, |
| 88 | .ofl_scan_add_ap_profile = WMI_ROAM_AP_PROFILE, |
| 89 | .ofl_scan_remove_ap_profile = WMI_OFL_SCAN_REMOVE_AP_PROFILE, |
| 90 | .ofl_scan_period = WMI_OFL_SCAN_PERIOD, |
| 91 | .p2p_dev_set_device_info = WMI_P2P_DEV_SET_DEVICE_INFO, |
| 92 | .p2p_dev_set_discoverability = WMI_P2P_DEV_SET_DISCOVERABILITY, |
| 93 | .p2p_go_set_beacon_ie = WMI_P2P_GO_SET_BEACON_IE, |
| 94 | .p2p_go_set_probe_resp_ie = WMI_P2P_GO_SET_PROBE_RESP_IE, |
| 95 | .p2p_set_vendor_ie_data_cmdid = WMI_P2P_SET_VENDOR_IE_DATA_CMDID, |
| 96 | .ap_ps_peer_param_cmdid = WMI_AP_PS_PEER_PARAM_CMDID, |
| 97 | .ap_ps_peer_uapsd_coex_cmdid = WMI_AP_PS_PEER_UAPSD_COEX_CMDID, |
| 98 | .peer_rate_retry_sched_cmdid = WMI_PEER_RATE_RETRY_SCHED_CMDID, |
| 99 | .wlan_profile_trigger_cmdid = WMI_WLAN_PROFILE_TRIGGER_CMDID, |
| 100 | .wlan_profile_set_hist_intvl_cmdid = |
| 101 | WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID, |
| 102 | .wlan_profile_get_profile_data_cmdid = |
| 103 | WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID, |
| 104 | .wlan_profile_enable_profile_id_cmdid = |
| 105 | WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID, |
| 106 | .wlan_profile_list_profile_id_cmdid = |
| 107 | WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID, |
| 108 | .pdev_suspend_cmdid = WMI_PDEV_SUSPEND_CMDID, |
| 109 | .pdev_resume_cmdid = WMI_PDEV_RESUME_CMDID, |
| 110 | .add_bcn_filter_cmdid = WMI_ADD_BCN_FILTER_CMDID, |
| 111 | .rmv_bcn_filter_cmdid = WMI_RMV_BCN_FILTER_CMDID, |
| 112 | .wow_add_wake_pattern_cmdid = WMI_WOW_ADD_WAKE_PATTERN_CMDID, |
| 113 | .wow_del_wake_pattern_cmdid = WMI_WOW_DEL_WAKE_PATTERN_CMDID, |
| 114 | .wow_enable_disable_wake_event_cmdid = |
| 115 | WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID, |
| 116 | .wow_enable_cmdid = WMI_WOW_ENABLE_CMDID, |
| 117 | .wow_hostwakeup_from_sleep_cmdid = WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID, |
| 118 | .rtt_measreq_cmdid = WMI_RTT_MEASREQ_CMDID, |
| 119 | .rtt_tsf_cmdid = WMI_RTT_TSF_CMDID, |
| 120 | .vdev_spectral_scan_configure_cmdid = |
| 121 | WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID, |
| 122 | .vdev_spectral_scan_enable_cmdid = WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID, |
| 123 | .request_stats_cmdid = WMI_REQUEST_STATS_CMDID, |
| 124 | .set_arp_ns_offload_cmdid = WMI_SET_ARP_NS_OFFLOAD_CMDID, |
| 125 | .network_list_offload_config_cmdid = |
| 126 | WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID, |
| 127 | .gtk_offload_cmdid = WMI_GTK_OFFLOAD_CMDID, |
| 128 | .csa_offload_enable_cmdid = WMI_CSA_OFFLOAD_ENABLE_CMDID, |
| 129 | .csa_offload_chanswitch_cmdid = WMI_CSA_OFFLOAD_CHANSWITCH_CMDID, |
| 130 | .chatter_set_mode_cmdid = WMI_CHATTER_SET_MODE_CMDID, |
| 131 | .peer_tid_addba_cmdid = WMI_PEER_TID_ADDBA_CMDID, |
| 132 | .peer_tid_delba_cmdid = WMI_PEER_TID_DELBA_CMDID, |
| 133 | .sta_dtim_ps_method_cmdid = WMI_STA_DTIM_PS_METHOD_CMDID, |
| 134 | .sta_uapsd_auto_trig_cmdid = WMI_STA_UAPSD_AUTO_TRIG_CMDID, |
| 135 | .sta_keepalive_cmd = WMI_STA_KEEPALIVE_CMD, |
| 136 | .echo_cmdid = WMI_ECHO_CMDID, |
| 137 | .pdev_utf_cmdid = WMI_PDEV_UTF_CMDID, |
| 138 | .dbglog_cfg_cmdid = WMI_DBGLOG_CFG_CMDID, |
| 139 | .pdev_qvit_cmdid = WMI_PDEV_QVIT_CMDID, |
| 140 | .pdev_ftm_intg_cmdid = WMI_PDEV_FTM_INTG_CMDID, |
| 141 | .vdev_set_keepalive_cmdid = WMI_VDEV_SET_KEEPALIVE_CMDID, |
| 142 | .vdev_get_keepalive_cmdid = WMI_VDEV_GET_KEEPALIVE_CMDID, |
| 143 | .force_fw_hang_cmdid = WMI_FORCE_FW_HANG_CMDID, |
| 144 | .gpio_config_cmdid = WMI_GPIO_CONFIG_CMDID, |
| 145 | .gpio_output_cmdid = WMI_GPIO_OUTPUT_CMDID, |
| 146 | }; |
| 147 | |
Bartosz Markowski | b7e3adf | 2013-09-26 17:47:06 +0200 | [diff] [blame] | 148 | /* 10.X WMI cmd track */ |
| 149 | static struct wmi_cmd_map wmi_10x_cmd_map = { |
| 150 | .init_cmdid = WMI_10X_INIT_CMDID, |
| 151 | .start_scan_cmdid = WMI_10X_START_SCAN_CMDID, |
| 152 | .stop_scan_cmdid = WMI_10X_STOP_SCAN_CMDID, |
| 153 | .scan_chan_list_cmdid = WMI_10X_SCAN_CHAN_LIST_CMDID, |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 154 | .scan_sch_prio_tbl_cmdid = WMI_CMD_UNSUPPORTED, |
Bartosz Markowski | b7e3adf | 2013-09-26 17:47:06 +0200 | [diff] [blame] | 155 | .pdev_set_regdomain_cmdid = WMI_10X_PDEV_SET_REGDOMAIN_CMDID, |
| 156 | .pdev_set_channel_cmdid = WMI_10X_PDEV_SET_CHANNEL_CMDID, |
| 157 | .pdev_set_param_cmdid = WMI_10X_PDEV_SET_PARAM_CMDID, |
| 158 | .pdev_pktlog_enable_cmdid = WMI_10X_PDEV_PKTLOG_ENABLE_CMDID, |
| 159 | .pdev_pktlog_disable_cmdid = WMI_10X_PDEV_PKTLOG_DISABLE_CMDID, |
| 160 | .pdev_set_wmm_params_cmdid = WMI_10X_PDEV_SET_WMM_PARAMS_CMDID, |
| 161 | .pdev_set_ht_cap_ie_cmdid = WMI_10X_PDEV_SET_HT_CAP_IE_CMDID, |
| 162 | .pdev_set_vht_cap_ie_cmdid = WMI_10X_PDEV_SET_VHT_CAP_IE_CMDID, |
| 163 | .pdev_set_dscp_tid_map_cmdid = WMI_10X_PDEV_SET_DSCP_TID_MAP_CMDID, |
| 164 | .pdev_set_quiet_mode_cmdid = WMI_10X_PDEV_SET_QUIET_MODE_CMDID, |
| 165 | .pdev_green_ap_ps_enable_cmdid = WMI_10X_PDEV_GREEN_AP_PS_ENABLE_CMDID, |
| 166 | .pdev_get_tpc_config_cmdid = WMI_10X_PDEV_GET_TPC_CONFIG_CMDID, |
| 167 | .pdev_set_base_macaddr_cmdid = WMI_10X_PDEV_SET_BASE_MACADDR_CMDID, |
| 168 | .vdev_create_cmdid = WMI_10X_VDEV_CREATE_CMDID, |
| 169 | .vdev_delete_cmdid = WMI_10X_VDEV_DELETE_CMDID, |
| 170 | .vdev_start_request_cmdid = WMI_10X_VDEV_START_REQUEST_CMDID, |
| 171 | .vdev_restart_request_cmdid = WMI_10X_VDEV_RESTART_REQUEST_CMDID, |
| 172 | .vdev_up_cmdid = WMI_10X_VDEV_UP_CMDID, |
| 173 | .vdev_stop_cmdid = WMI_10X_VDEV_STOP_CMDID, |
| 174 | .vdev_down_cmdid = WMI_10X_VDEV_DOWN_CMDID, |
| 175 | .vdev_set_param_cmdid = WMI_10X_VDEV_SET_PARAM_CMDID, |
| 176 | .vdev_install_key_cmdid = WMI_10X_VDEV_INSTALL_KEY_CMDID, |
| 177 | .peer_create_cmdid = WMI_10X_PEER_CREATE_CMDID, |
| 178 | .peer_delete_cmdid = WMI_10X_PEER_DELETE_CMDID, |
| 179 | .peer_flush_tids_cmdid = WMI_10X_PEER_FLUSH_TIDS_CMDID, |
| 180 | .peer_set_param_cmdid = WMI_10X_PEER_SET_PARAM_CMDID, |
| 181 | .peer_assoc_cmdid = WMI_10X_PEER_ASSOC_CMDID, |
| 182 | .peer_add_wds_entry_cmdid = WMI_10X_PEER_ADD_WDS_ENTRY_CMDID, |
| 183 | .peer_remove_wds_entry_cmdid = WMI_10X_PEER_REMOVE_WDS_ENTRY_CMDID, |
| 184 | .peer_mcast_group_cmdid = WMI_10X_PEER_MCAST_GROUP_CMDID, |
| 185 | .bcn_tx_cmdid = WMI_10X_BCN_TX_CMDID, |
| 186 | .pdev_send_bcn_cmdid = WMI_10X_PDEV_SEND_BCN_CMDID, |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 187 | .bcn_tmpl_cmdid = WMI_CMD_UNSUPPORTED, |
Bartosz Markowski | b7e3adf | 2013-09-26 17:47:06 +0200 | [diff] [blame] | 188 | .bcn_filter_rx_cmdid = WMI_10X_BCN_FILTER_RX_CMDID, |
| 189 | .prb_req_filter_rx_cmdid = WMI_10X_PRB_REQ_FILTER_RX_CMDID, |
| 190 | .mgmt_tx_cmdid = WMI_10X_MGMT_TX_CMDID, |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 191 | .prb_tmpl_cmdid = WMI_CMD_UNSUPPORTED, |
Bartosz Markowski | b7e3adf | 2013-09-26 17:47:06 +0200 | [diff] [blame] | 192 | .addba_clear_resp_cmdid = WMI_10X_ADDBA_CLEAR_RESP_CMDID, |
| 193 | .addba_send_cmdid = WMI_10X_ADDBA_SEND_CMDID, |
| 194 | .addba_status_cmdid = WMI_10X_ADDBA_STATUS_CMDID, |
| 195 | .delba_send_cmdid = WMI_10X_DELBA_SEND_CMDID, |
| 196 | .addba_set_resp_cmdid = WMI_10X_ADDBA_SET_RESP_CMDID, |
| 197 | .send_singleamsdu_cmdid = WMI_10X_SEND_SINGLEAMSDU_CMDID, |
| 198 | .sta_powersave_mode_cmdid = WMI_10X_STA_POWERSAVE_MODE_CMDID, |
| 199 | .sta_powersave_param_cmdid = WMI_10X_STA_POWERSAVE_PARAM_CMDID, |
| 200 | .sta_mimo_ps_mode_cmdid = WMI_10X_STA_MIMO_PS_MODE_CMDID, |
| 201 | .pdev_dfs_enable_cmdid = WMI_10X_PDEV_DFS_ENABLE_CMDID, |
| 202 | .pdev_dfs_disable_cmdid = WMI_10X_PDEV_DFS_DISABLE_CMDID, |
| 203 | .roam_scan_mode = WMI_10X_ROAM_SCAN_MODE, |
| 204 | .roam_scan_rssi_threshold = WMI_10X_ROAM_SCAN_RSSI_THRESHOLD, |
| 205 | .roam_scan_period = WMI_10X_ROAM_SCAN_PERIOD, |
| 206 | .roam_scan_rssi_change_threshold = |
| 207 | WMI_10X_ROAM_SCAN_RSSI_CHANGE_THRESHOLD, |
| 208 | .roam_ap_profile = WMI_10X_ROAM_AP_PROFILE, |
| 209 | .ofl_scan_add_ap_profile = WMI_10X_OFL_SCAN_ADD_AP_PROFILE, |
| 210 | .ofl_scan_remove_ap_profile = WMI_10X_OFL_SCAN_REMOVE_AP_PROFILE, |
| 211 | .ofl_scan_period = WMI_10X_OFL_SCAN_PERIOD, |
| 212 | .p2p_dev_set_device_info = WMI_10X_P2P_DEV_SET_DEVICE_INFO, |
| 213 | .p2p_dev_set_discoverability = WMI_10X_P2P_DEV_SET_DISCOVERABILITY, |
| 214 | .p2p_go_set_beacon_ie = WMI_10X_P2P_GO_SET_BEACON_IE, |
| 215 | .p2p_go_set_probe_resp_ie = WMI_10X_P2P_GO_SET_PROBE_RESP_IE, |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 216 | .p2p_set_vendor_ie_data_cmdid = WMI_CMD_UNSUPPORTED, |
Janusz Dziedzic | 542fb17 | 2014-01-17 14:08:08 +0100 | [diff] [blame] | 217 | .ap_ps_peer_param_cmdid = WMI_10X_AP_PS_PEER_PARAM_CMDID, |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 218 | .ap_ps_peer_uapsd_coex_cmdid = WMI_CMD_UNSUPPORTED, |
Bartosz Markowski | b7e3adf | 2013-09-26 17:47:06 +0200 | [diff] [blame] | 219 | .peer_rate_retry_sched_cmdid = WMI_10X_PEER_RATE_RETRY_SCHED_CMDID, |
| 220 | .wlan_profile_trigger_cmdid = WMI_10X_WLAN_PROFILE_TRIGGER_CMDID, |
| 221 | .wlan_profile_set_hist_intvl_cmdid = |
| 222 | WMI_10X_WLAN_PROFILE_SET_HIST_INTVL_CMDID, |
| 223 | .wlan_profile_get_profile_data_cmdid = |
| 224 | WMI_10X_WLAN_PROFILE_GET_PROFILE_DATA_CMDID, |
| 225 | .wlan_profile_enable_profile_id_cmdid = |
| 226 | WMI_10X_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID, |
| 227 | .wlan_profile_list_profile_id_cmdid = |
| 228 | WMI_10X_WLAN_PROFILE_LIST_PROFILE_ID_CMDID, |
| 229 | .pdev_suspend_cmdid = WMI_10X_PDEV_SUSPEND_CMDID, |
| 230 | .pdev_resume_cmdid = WMI_10X_PDEV_RESUME_CMDID, |
| 231 | .add_bcn_filter_cmdid = WMI_10X_ADD_BCN_FILTER_CMDID, |
| 232 | .rmv_bcn_filter_cmdid = WMI_10X_RMV_BCN_FILTER_CMDID, |
| 233 | .wow_add_wake_pattern_cmdid = WMI_10X_WOW_ADD_WAKE_PATTERN_CMDID, |
| 234 | .wow_del_wake_pattern_cmdid = WMI_10X_WOW_DEL_WAKE_PATTERN_CMDID, |
| 235 | .wow_enable_disable_wake_event_cmdid = |
| 236 | WMI_10X_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID, |
| 237 | .wow_enable_cmdid = WMI_10X_WOW_ENABLE_CMDID, |
| 238 | .wow_hostwakeup_from_sleep_cmdid = |
| 239 | WMI_10X_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID, |
| 240 | .rtt_measreq_cmdid = WMI_10X_RTT_MEASREQ_CMDID, |
| 241 | .rtt_tsf_cmdid = WMI_10X_RTT_TSF_CMDID, |
| 242 | .vdev_spectral_scan_configure_cmdid = |
| 243 | WMI_10X_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID, |
| 244 | .vdev_spectral_scan_enable_cmdid = |
| 245 | WMI_10X_VDEV_SPECTRAL_SCAN_ENABLE_CMDID, |
| 246 | .request_stats_cmdid = WMI_10X_REQUEST_STATS_CMDID, |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 247 | .set_arp_ns_offload_cmdid = WMI_CMD_UNSUPPORTED, |
| 248 | .network_list_offload_config_cmdid = WMI_CMD_UNSUPPORTED, |
| 249 | .gtk_offload_cmdid = WMI_CMD_UNSUPPORTED, |
| 250 | .csa_offload_enable_cmdid = WMI_CMD_UNSUPPORTED, |
| 251 | .csa_offload_chanswitch_cmdid = WMI_CMD_UNSUPPORTED, |
| 252 | .chatter_set_mode_cmdid = WMI_CMD_UNSUPPORTED, |
| 253 | .peer_tid_addba_cmdid = WMI_CMD_UNSUPPORTED, |
| 254 | .peer_tid_delba_cmdid = WMI_CMD_UNSUPPORTED, |
| 255 | .sta_dtim_ps_method_cmdid = WMI_CMD_UNSUPPORTED, |
| 256 | .sta_uapsd_auto_trig_cmdid = WMI_CMD_UNSUPPORTED, |
| 257 | .sta_keepalive_cmd = WMI_CMD_UNSUPPORTED, |
Bartosz Markowski | b7e3adf | 2013-09-26 17:47:06 +0200 | [diff] [blame] | 258 | .echo_cmdid = WMI_10X_ECHO_CMDID, |
| 259 | .pdev_utf_cmdid = WMI_10X_PDEV_UTF_CMDID, |
| 260 | .dbglog_cfg_cmdid = WMI_10X_DBGLOG_CFG_CMDID, |
| 261 | .pdev_qvit_cmdid = WMI_10X_PDEV_QVIT_CMDID, |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 262 | .pdev_ftm_intg_cmdid = WMI_CMD_UNSUPPORTED, |
| 263 | .vdev_set_keepalive_cmdid = WMI_CMD_UNSUPPORTED, |
| 264 | .vdev_get_keepalive_cmdid = WMI_CMD_UNSUPPORTED, |
| 265 | .force_fw_hang_cmdid = WMI_CMD_UNSUPPORTED, |
Bartosz Markowski | b7e3adf | 2013-09-26 17:47:06 +0200 | [diff] [blame] | 266 | .gpio_config_cmdid = WMI_10X_GPIO_CONFIG_CMDID, |
| 267 | .gpio_output_cmdid = WMI_10X_GPIO_OUTPUT_CMDID, |
| 268 | }; |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 269 | |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 270 | /* MAIN WMI VDEV param map */ |
| 271 | static struct wmi_vdev_param_map wmi_vdev_param_map = { |
| 272 | .rts_threshold = WMI_VDEV_PARAM_RTS_THRESHOLD, |
| 273 | .fragmentation_threshold = WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD, |
| 274 | .beacon_interval = WMI_VDEV_PARAM_BEACON_INTERVAL, |
| 275 | .listen_interval = WMI_VDEV_PARAM_LISTEN_INTERVAL, |
| 276 | .multicast_rate = WMI_VDEV_PARAM_MULTICAST_RATE, |
| 277 | .mgmt_tx_rate = WMI_VDEV_PARAM_MGMT_TX_RATE, |
| 278 | .slot_time = WMI_VDEV_PARAM_SLOT_TIME, |
| 279 | .preamble = WMI_VDEV_PARAM_PREAMBLE, |
| 280 | .swba_time = WMI_VDEV_PARAM_SWBA_TIME, |
| 281 | .wmi_vdev_stats_update_period = WMI_VDEV_STATS_UPDATE_PERIOD, |
| 282 | .wmi_vdev_pwrsave_ageout_time = WMI_VDEV_PWRSAVE_AGEOUT_TIME, |
| 283 | .wmi_vdev_host_swba_interval = WMI_VDEV_HOST_SWBA_INTERVAL, |
| 284 | .dtim_period = WMI_VDEV_PARAM_DTIM_PERIOD, |
| 285 | .wmi_vdev_oc_scheduler_air_time_limit = |
| 286 | WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT, |
| 287 | .wds = WMI_VDEV_PARAM_WDS, |
| 288 | .atim_window = WMI_VDEV_PARAM_ATIM_WINDOW, |
| 289 | .bmiss_count_max = WMI_VDEV_PARAM_BMISS_COUNT_MAX, |
| 290 | .bmiss_first_bcnt = WMI_VDEV_PARAM_BMISS_FIRST_BCNT, |
| 291 | .bmiss_final_bcnt = WMI_VDEV_PARAM_BMISS_FINAL_BCNT, |
| 292 | .feature_wmm = WMI_VDEV_PARAM_FEATURE_WMM, |
| 293 | .chwidth = WMI_VDEV_PARAM_CHWIDTH, |
| 294 | .chextoffset = WMI_VDEV_PARAM_CHEXTOFFSET, |
| 295 | .disable_htprotection = WMI_VDEV_PARAM_DISABLE_HTPROTECTION, |
| 296 | .sta_quickkickout = WMI_VDEV_PARAM_STA_QUICKKICKOUT, |
| 297 | .mgmt_rate = WMI_VDEV_PARAM_MGMT_RATE, |
| 298 | .protection_mode = WMI_VDEV_PARAM_PROTECTION_MODE, |
| 299 | .fixed_rate = WMI_VDEV_PARAM_FIXED_RATE, |
| 300 | .sgi = WMI_VDEV_PARAM_SGI, |
| 301 | .ldpc = WMI_VDEV_PARAM_LDPC, |
| 302 | .tx_stbc = WMI_VDEV_PARAM_TX_STBC, |
| 303 | .rx_stbc = WMI_VDEV_PARAM_RX_STBC, |
| 304 | .intra_bss_fwd = WMI_VDEV_PARAM_INTRA_BSS_FWD, |
| 305 | .def_keyid = WMI_VDEV_PARAM_DEF_KEYID, |
| 306 | .nss = WMI_VDEV_PARAM_NSS, |
| 307 | .bcast_data_rate = WMI_VDEV_PARAM_BCAST_DATA_RATE, |
| 308 | .mcast_data_rate = WMI_VDEV_PARAM_MCAST_DATA_RATE, |
| 309 | .mcast_indicate = WMI_VDEV_PARAM_MCAST_INDICATE, |
| 310 | .dhcp_indicate = WMI_VDEV_PARAM_DHCP_INDICATE, |
| 311 | .unknown_dest_indicate = WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE, |
| 312 | .ap_keepalive_min_idle_inactive_time_secs = |
| 313 | WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS, |
| 314 | .ap_keepalive_max_idle_inactive_time_secs = |
| 315 | WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS, |
| 316 | .ap_keepalive_max_unresponsive_time_secs = |
| 317 | WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS, |
| 318 | .ap_enable_nawds = WMI_VDEV_PARAM_AP_ENABLE_NAWDS, |
| 319 | .mcast2ucast_set = WMI_VDEV_PARAM_UNSUPPORTED, |
| 320 | .enable_rtscts = WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 321 | .txbf = WMI_VDEV_PARAM_TXBF, |
| 322 | .packet_powersave = WMI_VDEV_PARAM_PACKET_POWERSAVE, |
| 323 | .drop_unencry = WMI_VDEV_PARAM_DROP_UNENCRY, |
| 324 | .tx_encap_type = WMI_VDEV_PARAM_TX_ENCAP_TYPE, |
| 325 | .ap_detect_out_of_sync_sleeping_sta_time_secs = |
| 326 | WMI_VDEV_PARAM_UNSUPPORTED, |
| 327 | }; |
| 328 | |
| 329 | /* 10.X WMI VDEV param map */ |
| 330 | static struct wmi_vdev_param_map wmi_10x_vdev_param_map = { |
| 331 | .rts_threshold = WMI_10X_VDEV_PARAM_RTS_THRESHOLD, |
| 332 | .fragmentation_threshold = WMI_10X_VDEV_PARAM_FRAGMENTATION_THRESHOLD, |
| 333 | .beacon_interval = WMI_10X_VDEV_PARAM_BEACON_INTERVAL, |
| 334 | .listen_interval = WMI_10X_VDEV_PARAM_LISTEN_INTERVAL, |
| 335 | .multicast_rate = WMI_10X_VDEV_PARAM_MULTICAST_RATE, |
| 336 | .mgmt_tx_rate = WMI_10X_VDEV_PARAM_MGMT_TX_RATE, |
| 337 | .slot_time = WMI_10X_VDEV_PARAM_SLOT_TIME, |
| 338 | .preamble = WMI_10X_VDEV_PARAM_PREAMBLE, |
| 339 | .swba_time = WMI_10X_VDEV_PARAM_SWBA_TIME, |
| 340 | .wmi_vdev_stats_update_period = WMI_10X_VDEV_STATS_UPDATE_PERIOD, |
| 341 | .wmi_vdev_pwrsave_ageout_time = WMI_10X_VDEV_PWRSAVE_AGEOUT_TIME, |
| 342 | .wmi_vdev_host_swba_interval = WMI_10X_VDEV_HOST_SWBA_INTERVAL, |
| 343 | .dtim_period = WMI_10X_VDEV_PARAM_DTIM_PERIOD, |
| 344 | .wmi_vdev_oc_scheduler_air_time_limit = |
| 345 | WMI_10X_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT, |
| 346 | .wds = WMI_10X_VDEV_PARAM_WDS, |
| 347 | .atim_window = WMI_10X_VDEV_PARAM_ATIM_WINDOW, |
| 348 | .bmiss_count_max = WMI_10X_VDEV_PARAM_BMISS_COUNT_MAX, |
| 349 | .bmiss_first_bcnt = WMI_VDEV_PARAM_UNSUPPORTED, |
| 350 | .bmiss_final_bcnt = WMI_VDEV_PARAM_UNSUPPORTED, |
| 351 | .feature_wmm = WMI_10X_VDEV_PARAM_FEATURE_WMM, |
| 352 | .chwidth = WMI_10X_VDEV_PARAM_CHWIDTH, |
| 353 | .chextoffset = WMI_10X_VDEV_PARAM_CHEXTOFFSET, |
| 354 | .disable_htprotection = WMI_10X_VDEV_PARAM_DISABLE_HTPROTECTION, |
| 355 | .sta_quickkickout = WMI_10X_VDEV_PARAM_STA_QUICKKICKOUT, |
| 356 | .mgmt_rate = WMI_10X_VDEV_PARAM_MGMT_RATE, |
| 357 | .protection_mode = WMI_10X_VDEV_PARAM_PROTECTION_MODE, |
| 358 | .fixed_rate = WMI_10X_VDEV_PARAM_FIXED_RATE, |
| 359 | .sgi = WMI_10X_VDEV_PARAM_SGI, |
| 360 | .ldpc = WMI_10X_VDEV_PARAM_LDPC, |
| 361 | .tx_stbc = WMI_10X_VDEV_PARAM_TX_STBC, |
| 362 | .rx_stbc = WMI_10X_VDEV_PARAM_RX_STBC, |
| 363 | .intra_bss_fwd = WMI_10X_VDEV_PARAM_INTRA_BSS_FWD, |
| 364 | .def_keyid = WMI_10X_VDEV_PARAM_DEF_KEYID, |
| 365 | .nss = WMI_10X_VDEV_PARAM_NSS, |
| 366 | .bcast_data_rate = WMI_10X_VDEV_PARAM_BCAST_DATA_RATE, |
| 367 | .mcast_data_rate = WMI_10X_VDEV_PARAM_MCAST_DATA_RATE, |
| 368 | .mcast_indicate = WMI_10X_VDEV_PARAM_MCAST_INDICATE, |
| 369 | .dhcp_indicate = WMI_10X_VDEV_PARAM_DHCP_INDICATE, |
| 370 | .unknown_dest_indicate = WMI_10X_VDEV_PARAM_UNKNOWN_DEST_INDICATE, |
| 371 | .ap_keepalive_min_idle_inactive_time_secs = |
| 372 | WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS, |
| 373 | .ap_keepalive_max_idle_inactive_time_secs = |
| 374 | WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS, |
| 375 | .ap_keepalive_max_unresponsive_time_secs = |
| 376 | WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS, |
| 377 | .ap_enable_nawds = WMI_10X_VDEV_PARAM_AP_ENABLE_NAWDS, |
| 378 | .mcast2ucast_set = WMI_10X_VDEV_PARAM_MCAST2UCAST_SET, |
| 379 | .enable_rtscts = WMI_10X_VDEV_PARAM_ENABLE_RTSCTS, |
| 380 | .txbf = WMI_VDEV_PARAM_UNSUPPORTED, |
| 381 | .packet_powersave = WMI_VDEV_PARAM_UNSUPPORTED, |
| 382 | .drop_unencry = WMI_VDEV_PARAM_UNSUPPORTED, |
| 383 | .tx_encap_type = WMI_VDEV_PARAM_UNSUPPORTED, |
| 384 | .ap_detect_out_of_sync_sleeping_sta_time_secs = |
| 385 | WMI_10X_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS, |
| 386 | }; |
| 387 | |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 388 | static struct wmi_pdev_param_map wmi_pdev_param_map = { |
| 389 | .tx_chain_mask = WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 390 | .rx_chain_mask = WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 391 | .txpower_limit2g = WMI_PDEV_PARAM_TXPOWER_LIMIT2G, |
| 392 | .txpower_limit5g = WMI_PDEV_PARAM_TXPOWER_LIMIT5G, |
| 393 | .txpower_scale = WMI_PDEV_PARAM_TXPOWER_SCALE, |
| 394 | .beacon_gen_mode = WMI_PDEV_PARAM_BEACON_GEN_MODE, |
| 395 | .beacon_tx_mode = WMI_PDEV_PARAM_BEACON_TX_MODE, |
| 396 | .resmgr_offchan_mode = WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE, |
| 397 | .protection_mode = WMI_PDEV_PARAM_PROTECTION_MODE, |
| 398 | .dynamic_bw = WMI_PDEV_PARAM_DYNAMIC_BW, |
| 399 | .non_agg_sw_retry_th = WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH, |
| 400 | .agg_sw_retry_th = WMI_PDEV_PARAM_AGG_SW_RETRY_TH, |
| 401 | .sta_kickout_th = WMI_PDEV_PARAM_STA_KICKOUT_TH, |
| 402 | .ac_aggrsize_scaling = WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING, |
| 403 | .ltr_enable = WMI_PDEV_PARAM_LTR_ENABLE, |
| 404 | .ltr_ac_latency_be = WMI_PDEV_PARAM_LTR_AC_LATENCY_BE, |
| 405 | .ltr_ac_latency_bk = WMI_PDEV_PARAM_LTR_AC_LATENCY_BK, |
| 406 | .ltr_ac_latency_vi = WMI_PDEV_PARAM_LTR_AC_LATENCY_VI, |
| 407 | .ltr_ac_latency_vo = WMI_PDEV_PARAM_LTR_AC_LATENCY_VO, |
| 408 | .ltr_ac_latency_timeout = WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT, |
| 409 | .ltr_sleep_override = WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE, |
| 410 | .ltr_rx_override = WMI_PDEV_PARAM_LTR_RX_OVERRIDE, |
| 411 | .ltr_tx_activity_timeout = WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT, |
| 412 | .l1ss_enable = WMI_PDEV_PARAM_L1SS_ENABLE, |
| 413 | .dsleep_enable = WMI_PDEV_PARAM_DSLEEP_ENABLE, |
| 414 | .pcielp_txbuf_flush = WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH, |
| 415 | .pcielp_txbuf_watermark = WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN, |
| 416 | .pcielp_txbuf_tmo_en = WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN, |
| 417 | .pcielp_txbuf_tmo_value = WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE, |
| 418 | .pdev_stats_update_period = WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD, |
| 419 | .vdev_stats_update_period = WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD, |
| 420 | .peer_stats_update_period = WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD, |
| 421 | .bcnflt_stats_update_period = WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD, |
| 422 | .pmf_qos = WMI_PDEV_PARAM_PMF_QOS, |
| 423 | .arp_ac_override = WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 424 | .dcs = WMI_PDEV_PARAM_DCS, |
| 425 | .ani_enable = WMI_PDEV_PARAM_ANI_ENABLE, |
| 426 | .ani_poll_period = WMI_PDEV_PARAM_ANI_POLL_PERIOD, |
| 427 | .ani_listen_period = WMI_PDEV_PARAM_ANI_LISTEN_PERIOD, |
| 428 | .ani_ofdm_level = WMI_PDEV_PARAM_ANI_OFDM_LEVEL, |
| 429 | .ani_cck_level = WMI_PDEV_PARAM_ANI_CCK_LEVEL, |
| 430 | .dyntxchain = WMI_PDEV_PARAM_DYNTXCHAIN, |
| 431 | .proxy_sta = WMI_PDEV_PARAM_PROXY_STA, |
| 432 | .idle_ps_config = WMI_PDEV_PARAM_IDLE_PS_CONFIG, |
| 433 | .power_gating_sleep = WMI_PDEV_PARAM_POWER_GATING_SLEEP, |
| 434 | .fast_channel_reset = WMI_PDEV_PARAM_UNSUPPORTED, |
| 435 | .burst_dur = WMI_PDEV_PARAM_UNSUPPORTED, |
| 436 | .burst_enable = WMI_PDEV_PARAM_UNSUPPORTED, |
| 437 | }; |
| 438 | |
| 439 | static struct wmi_pdev_param_map wmi_10x_pdev_param_map = { |
| 440 | .tx_chain_mask = WMI_10X_PDEV_PARAM_TX_CHAIN_MASK, |
| 441 | .rx_chain_mask = WMI_10X_PDEV_PARAM_RX_CHAIN_MASK, |
| 442 | .txpower_limit2g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT2G, |
| 443 | .txpower_limit5g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT5G, |
| 444 | .txpower_scale = WMI_10X_PDEV_PARAM_TXPOWER_SCALE, |
| 445 | .beacon_gen_mode = WMI_10X_PDEV_PARAM_BEACON_GEN_MODE, |
| 446 | .beacon_tx_mode = WMI_10X_PDEV_PARAM_BEACON_TX_MODE, |
| 447 | .resmgr_offchan_mode = WMI_10X_PDEV_PARAM_RESMGR_OFFCHAN_MODE, |
| 448 | .protection_mode = WMI_10X_PDEV_PARAM_PROTECTION_MODE, |
| 449 | .dynamic_bw = WMI_10X_PDEV_PARAM_DYNAMIC_BW, |
| 450 | .non_agg_sw_retry_th = WMI_10X_PDEV_PARAM_NON_AGG_SW_RETRY_TH, |
| 451 | .agg_sw_retry_th = WMI_10X_PDEV_PARAM_AGG_SW_RETRY_TH, |
| 452 | .sta_kickout_th = WMI_10X_PDEV_PARAM_STA_KICKOUT_TH, |
| 453 | .ac_aggrsize_scaling = WMI_10X_PDEV_PARAM_AC_AGGRSIZE_SCALING, |
| 454 | .ltr_enable = WMI_10X_PDEV_PARAM_LTR_ENABLE, |
| 455 | .ltr_ac_latency_be = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BE, |
| 456 | .ltr_ac_latency_bk = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BK, |
| 457 | .ltr_ac_latency_vi = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VI, |
| 458 | .ltr_ac_latency_vo = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VO, |
| 459 | .ltr_ac_latency_timeout = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT, |
| 460 | .ltr_sleep_override = WMI_10X_PDEV_PARAM_LTR_SLEEP_OVERRIDE, |
| 461 | .ltr_rx_override = WMI_10X_PDEV_PARAM_LTR_RX_OVERRIDE, |
| 462 | .ltr_tx_activity_timeout = WMI_10X_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT, |
| 463 | .l1ss_enable = WMI_10X_PDEV_PARAM_L1SS_ENABLE, |
| 464 | .dsleep_enable = WMI_10X_PDEV_PARAM_DSLEEP_ENABLE, |
| 465 | .pcielp_txbuf_flush = WMI_PDEV_PARAM_UNSUPPORTED, |
| 466 | .pcielp_txbuf_watermark = WMI_PDEV_PARAM_UNSUPPORTED, |
| 467 | .pcielp_txbuf_tmo_en = WMI_PDEV_PARAM_UNSUPPORTED, |
| 468 | .pcielp_txbuf_tmo_value = WMI_PDEV_PARAM_UNSUPPORTED, |
| 469 | .pdev_stats_update_period = WMI_10X_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD, |
| 470 | .vdev_stats_update_period = WMI_10X_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD, |
| 471 | .peer_stats_update_period = WMI_10X_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD, |
| 472 | .bcnflt_stats_update_period = |
| 473 | WMI_10X_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD, |
| 474 | .pmf_qos = WMI_10X_PDEV_PARAM_PMF_QOS, |
Marek Puzyniak | ab6258e | 2014-01-29 15:03:31 +0200 | [diff] [blame] | 475 | .arp_ac_override = WMI_10X_PDEV_PARAM_ARPDHCP_AC_OVERRIDE, |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 476 | .dcs = WMI_10X_PDEV_PARAM_DCS, |
| 477 | .ani_enable = WMI_10X_PDEV_PARAM_ANI_ENABLE, |
| 478 | .ani_poll_period = WMI_10X_PDEV_PARAM_ANI_POLL_PERIOD, |
| 479 | .ani_listen_period = WMI_10X_PDEV_PARAM_ANI_LISTEN_PERIOD, |
| 480 | .ani_ofdm_level = WMI_10X_PDEV_PARAM_ANI_OFDM_LEVEL, |
| 481 | .ani_cck_level = WMI_10X_PDEV_PARAM_ANI_CCK_LEVEL, |
| 482 | .dyntxchain = WMI_10X_PDEV_PARAM_DYNTXCHAIN, |
| 483 | .proxy_sta = WMI_PDEV_PARAM_UNSUPPORTED, |
| 484 | .idle_ps_config = WMI_PDEV_PARAM_UNSUPPORTED, |
| 485 | .power_gating_sleep = WMI_PDEV_PARAM_UNSUPPORTED, |
| 486 | .fast_channel_reset = WMI_10X_PDEV_PARAM_FAST_CHANNEL_RESET, |
| 487 | .burst_dur = WMI_10X_PDEV_PARAM_BURST_DUR, |
| 488 | .burst_enable = WMI_10X_PDEV_PARAM_BURST_ENABLE, |
| 489 | }; |
| 490 | |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 491 | /* firmware 10.2 specific mappings */ |
| 492 | static struct wmi_cmd_map wmi_10_2_cmd_map = { |
| 493 | .init_cmdid = WMI_10_2_INIT_CMDID, |
| 494 | .start_scan_cmdid = WMI_10_2_START_SCAN_CMDID, |
| 495 | .stop_scan_cmdid = WMI_10_2_STOP_SCAN_CMDID, |
| 496 | .scan_chan_list_cmdid = WMI_10_2_SCAN_CHAN_LIST_CMDID, |
| 497 | .scan_sch_prio_tbl_cmdid = WMI_CMD_UNSUPPORTED, |
| 498 | .pdev_set_regdomain_cmdid = WMI_10_2_PDEV_SET_REGDOMAIN_CMDID, |
| 499 | .pdev_set_channel_cmdid = WMI_10_2_PDEV_SET_CHANNEL_CMDID, |
| 500 | .pdev_set_param_cmdid = WMI_10_2_PDEV_SET_PARAM_CMDID, |
| 501 | .pdev_pktlog_enable_cmdid = WMI_10_2_PDEV_PKTLOG_ENABLE_CMDID, |
| 502 | .pdev_pktlog_disable_cmdid = WMI_10_2_PDEV_PKTLOG_DISABLE_CMDID, |
| 503 | .pdev_set_wmm_params_cmdid = WMI_10_2_PDEV_SET_WMM_PARAMS_CMDID, |
| 504 | .pdev_set_ht_cap_ie_cmdid = WMI_10_2_PDEV_SET_HT_CAP_IE_CMDID, |
| 505 | .pdev_set_vht_cap_ie_cmdid = WMI_10_2_PDEV_SET_VHT_CAP_IE_CMDID, |
| 506 | .pdev_set_quiet_mode_cmdid = WMI_10_2_PDEV_SET_QUIET_MODE_CMDID, |
| 507 | .pdev_green_ap_ps_enable_cmdid = WMI_10_2_PDEV_GREEN_AP_PS_ENABLE_CMDID, |
| 508 | .pdev_get_tpc_config_cmdid = WMI_10_2_PDEV_GET_TPC_CONFIG_CMDID, |
| 509 | .pdev_set_base_macaddr_cmdid = WMI_10_2_PDEV_SET_BASE_MACADDR_CMDID, |
| 510 | .vdev_create_cmdid = WMI_10_2_VDEV_CREATE_CMDID, |
| 511 | .vdev_delete_cmdid = WMI_10_2_VDEV_DELETE_CMDID, |
| 512 | .vdev_start_request_cmdid = WMI_10_2_VDEV_START_REQUEST_CMDID, |
| 513 | .vdev_restart_request_cmdid = WMI_10_2_VDEV_RESTART_REQUEST_CMDID, |
| 514 | .vdev_up_cmdid = WMI_10_2_VDEV_UP_CMDID, |
| 515 | .vdev_stop_cmdid = WMI_10_2_VDEV_STOP_CMDID, |
| 516 | .vdev_down_cmdid = WMI_10_2_VDEV_DOWN_CMDID, |
| 517 | .vdev_set_param_cmdid = WMI_10_2_VDEV_SET_PARAM_CMDID, |
| 518 | .vdev_install_key_cmdid = WMI_10_2_VDEV_INSTALL_KEY_CMDID, |
| 519 | .peer_create_cmdid = WMI_10_2_PEER_CREATE_CMDID, |
| 520 | .peer_delete_cmdid = WMI_10_2_PEER_DELETE_CMDID, |
| 521 | .peer_flush_tids_cmdid = WMI_10_2_PEER_FLUSH_TIDS_CMDID, |
| 522 | .peer_set_param_cmdid = WMI_10_2_PEER_SET_PARAM_CMDID, |
| 523 | .peer_assoc_cmdid = WMI_10_2_PEER_ASSOC_CMDID, |
| 524 | .peer_add_wds_entry_cmdid = WMI_10_2_PEER_ADD_WDS_ENTRY_CMDID, |
| 525 | .peer_remove_wds_entry_cmdid = WMI_10_2_PEER_REMOVE_WDS_ENTRY_CMDID, |
| 526 | .peer_mcast_group_cmdid = WMI_10_2_PEER_MCAST_GROUP_CMDID, |
| 527 | .bcn_tx_cmdid = WMI_10_2_BCN_TX_CMDID, |
| 528 | .pdev_send_bcn_cmdid = WMI_10_2_PDEV_SEND_BCN_CMDID, |
| 529 | .bcn_tmpl_cmdid = WMI_CMD_UNSUPPORTED, |
| 530 | .bcn_filter_rx_cmdid = WMI_10_2_BCN_FILTER_RX_CMDID, |
| 531 | .prb_req_filter_rx_cmdid = WMI_10_2_PRB_REQ_FILTER_RX_CMDID, |
| 532 | .mgmt_tx_cmdid = WMI_10_2_MGMT_TX_CMDID, |
| 533 | .prb_tmpl_cmdid = WMI_CMD_UNSUPPORTED, |
| 534 | .addba_clear_resp_cmdid = WMI_10_2_ADDBA_CLEAR_RESP_CMDID, |
| 535 | .addba_send_cmdid = WMI_10_2_ADDBA_SEND_CMDID, |
| 536 | .addba_status_cmdid = WMI_10_2_ADDBA_STATUS_CMDID, |
| 537 | .delba_send_cmdid = WMI_10_2_DELBA_SEND_CMDID, |
| 538 | .addba_set_resp_cmdid = WMI_10_2_ADDBA_SET_RESP_CMDID, |
| 539 | .send_singleamsdu_cmdid = WMI_10_2_SEND_SINGLEAMSDU_CMDID, |
| 540 | .sta_powersave_mode_cmdid = WMI_10_2_STA_POWERSAVE_MODE_CMDID, |
| 541 | .sta_powersave_param_cmdid = WMI_10_2_STA_POWERSAVE_PARAM_CMDID, |
| 542 | .sta_mimo_ps_mode_cmdid = WMI_10_2_STA_MIMO_PS_MODE_CMDID, |
| 543 | .pdev_dfs_enable_cmdid = WMI_10_2_PDEV_DFS_ENABLE_CMDID, |
| 544 | .pdev_dfs_disable_cmdid = WMI_10_2_PDEV_DFS_DISABLE_CMDID, |
| 545 | .roam_scan_mode = WMI_10_2_ROAM_SCAN_MODE, |
| 546 | .roam_scan_rssi_threshold = WMI_10_2_ROAM_SCAN_RSSI_THRESHOLD, |
| 547 | .roam_scan_period = WMI_10_2_ROAM_SCAN_PERIOD, |
| 548 | .roam_scan_rssi_change_threshold = |
| 549 | WMI_10_2_ROAM_SCAN_RSSI_CHANGE_THRESHOLD, |
| 550 | .roam_ap_profile = WMI_10_2_ROAM_AP_PROFILE, |
| 551 | .ofl_scan_add_ap_profile = WMI_10_2_OFL_SCAN_ADD_AP_PROFILE, |
| 552 | .ofl_scan_remove_ap_profile = WMI_10_2_OFL_SCAN_REMOVE_AP_PROFILE, |
| 553 | .ofl_scan_period = WMI_10_2_OFL_SCAN_PERIOD, |
| 554 | .p2p_dev_set_device_info = WMI_10_2_P2P_DEV_SET_DEVICE_INFO, |
| 555 | .p2p_dev_set_discoverability = WMI_10_2_P2P_DEV_SET_DISCOVERABILITY, |
| 556 | .p2p_go_set_beacon_ie = WMI_10_2_P2P_GO_SET_BEACON_IE, |
| 557 | .p2p_go_set_probe_resp_ie = WMI_10_2_P2P_GO_SET_PROBE_RESP_IE, |
| 558 | .p2p_set_vendor_ie_data_cmdid = WMI_CMD_UNSUPPORTED, |
| 559 | .ap_ps_peer_param_cmdid = WMI_10_2_AP_PS_PEER_PARAM_CMDID, |
| 560 | .ap_ps_peer_uapsd_coex_cmdid = WMI_CMD_UNSUPPORTED, |
| 561 | .peer_rate_retry_sched_cmdid = WMI_10_2_PEER_RATE_RETRY_SCHED_CMDID, |
| 562 | .wlan_profile_trigger_cmdid = WMI_10_2_WLAN_PROFILE_TRIGGER_CMDID, |
| 563 | .wlan_profile_set_hist_intvl_cmdid = |
| 564 | WMI_10_2_WLAN_PROFILE_SET_HIST_INTVL_CMDID, |
| 565 | .wlan_profile_get_profile_data_cmdid = |
| 566 | WMI_10_2_WLAN_PROFILE_GET_PROFILE_DATA_CMDID, |
| 567 | .wlan_profile_enable_profile_id_cmdid = |
| 568 | WMI_10_2_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID, |
| 569 | .wlan_profile_list_profile_id_cmdid = |
| 570 | WMI_10_2_WLAN_PROFILE_LIST_PROFILE_ID_CMDID, |
| 571 | .pdev_suspend_cmdid = WMI_10_2_PDEV_SUSPEND_CMDID, |
| 572 | .pdev_resume_cmdid = WMI_10_2_PDEV_RESUME_CMDID, |
| 573 | .add_bcn_filter_cmdid = WMI_10_2_ADD_BCN_FILTER_CMDID, |
| 574 | .rmv_bcn_filter_cmdid = WMI_10_2_RMV_BCN_FILTER_CMDID, |
| 575 | .wow_add_wake_pattern_cmdid = WMI_10_2_WOW_ADD_WAKE_PATTERN_CMDID, |
| 576 | .wow_del_wake_pattern_cmdid = WMI_10_2_WOW_DEL_WAKE_PATTERN_CMDID, |
| 577 | .wow_enable_disable_wake_event_cmdid = |
| 578 | WMI_10_2_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID, |
| 579 | .wow_enable_cmdid = WMI_10_2_WOW_ENABLE_CMDID, |
| 580 | .wow_hostwakeup_from_sleep_cmdid = |
| 581 | WMI_10_2_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID, |
| 582 | .rtt_measreq_cmdid = WMI_10_2_RTT_MEASREQ_CMDID, |
| 583 | .rtt_tsf_cmdid = WMI_10_2_RTT_TSF_CMDID, |
| 584 | .vdev_spectral_scan_configure_cmdid = |
| 585 | WMI_10_2_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID, |
| 586 | .vdev_spectral_scan_enable_cmdid = |
| 587 | WMI_10_2_VDEV_SPECTRAL_SCAN_ENABLE_CMDID, |
| 588 | .request_stats_cmdid = WMI_10_2_REQUEST_STATS_CMDID, |
| 589 | .set_arp_ns_offload_cmdid = WMI_CMD_UNSUPPORTED, |
| 590 | .network_list_offload_config_cmdid = WMI_CMD_UNSUPPORTED, |
| 591 | .gtk_offload_cmdid = WMI_CMD_UNSUPPORTED, |
| 592 | .csa_offload_enable_cmdid = WMI_CMD_UNSUPPORTED, |
| 593 | .csa_offload_chanswitch_cmdid = WMI_CMD_UNSUPPORTED, |
| 594 | .chatter_set_mode_cmdid = WMI_CMD_UNSUPPORTED, |
| 595 | .peer_tid_addba_cmdid = WMI_CMD_UNSUPPORTED, |
| 596 | .peer_tid_delba_cmdid = WMI_CMD_UNSUPPORTED, |
| 597 | .sta_dtim_ps_method_cmdid = WMI_CMD_UNSUPPORTED, |
| 598 | .sta_uapsd_auto_trig_cmdid = WMI_CMD_UNSUPPORTED, |
| 599 | .sta_keepalive_cmd = WMI_CMD_UNSUPPORTED, |
| 600 | .echo_cmdid = WMI_10_2_ECHO_CMDID, |
| 601 | .pdev_utf_cmdid = WMI_10_2_PDEV_UTF_CMDID, |
| 602 | .dbglog_cfg_cmdid = WMI_10_2_DBGLOG_CFG_CMDID, |
| 603 | .pdev_qvit_cmdid = WMI_10_2_PDEV_QVIT_CMDID, |
| 604 | .pdev_ftm_intg_cmdid = WMI_CMD_UNSUPPORTED, |
| 605 | .vdev_set_keepalive_cmdid = WMI_CMD_UNSUPPORTED, |
| 606 | .vdev_get_keepalive_cmdid = WMI_CMD_UNSUPPORTED, |
| 607 | .force_fw_hang_cmdid = WMI_CMD_UNSUPPORTED, |
| 608 | .gpio_config_cmdid = WMI_10_2_GPIO_CONFIG_CMDID, |
| 609 | .gpio_output_cmdid = WMI_10_2_GPIO_OUTPUT_CMDID, |
| 610 | }; |
| 611 | |
Michal Kazior | 2d66721 | 2014-09-18 15:21:21 +0200 | [diff] [blame] | 612 | static void |
| 613 | ath10k_wmi_put_wmi_channel(struct wmi_channel *ch, |
| 614 | const struct wmi_channel_arg *arg) |
| 615 | { |
| 616 | u32 flags = 0; |
| 617 | |
| 618 | memset(ch, 0, sizeof(*ch)); |
| 619 | |
| 620 | if (arg->passive) |
| 621 | flags |= WMI_CHAN_FLAG_PASSIVE; |
| 622 | if (arg->allow_ibss) |
| 623 | flags |= WMI_CHAN_FLAG_ADHOC_ALLOWED; |
| 624 | if (arg->allow_ht) |
| 625 | flags |= WMI_CHAN_FLAG_ALLOW_HT; |
| 626 | if (arg->allow_vht) |
| 627 | flags |= WMI_CHAN_FLAG_ALLOW_VHT; |
| 628 | if (arg->ht40plus) |
| 629 | flags |= WMI_CHAN_FLAG_HT40_PLUS; |
| 630 | if (arg->chan_radar) |
| 631 | flags |= WMI_CHAN_FLAG_DFS; |
| 632 | |
| 633 | ch->mhz = __cpu_to_le32(arg->freq); |
| 634 | ch->band_center_freq1 = __cpu_to_le32(arg->band_center_freq1); |
| 635 | ch->band_center_freq2 = 0; |
| 636 | ch->min_power = arg->min_power; |
| 637 | ch->max_power = arg->max_power; |
| 638 | ch->reg_power = arg->max_reg_power; |
| 639 | ch->antenna_max = arg->max_antenna_gain; |
| 640 | |
| 641 | /* mode & flags share storage */ |
| 642 | ch->mode = arg->mode; |
| 643 | ch->flags |= __cpu_to_le32(flags); |
| 644 | } |
| 645 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 646 | int ath10k_wmi_wait_for_service_ready(struct ath10k *ar) |
| 647 | { |
| 648 | int ret; |
Kalle Valo | af762c0 | 2014-09-14 12:50:17 +0300 | [diff] [blame] | 649 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 650 | ret = wait_for_completion_timeout(&ar->wmi.service_ready, |
| 651 | WMI_SERVICE_READY_TIMEOUT_HZ); |
| 652 | return ret; |
| 653 | } |
| 654 | |
| 655 | int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar) |
| 656 | { |
| 657 | int ret; |
Kalle Valo | af762c0 | 2014-09-14 12:50:17 +0300 | [diff] [blame] | 658 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 659 | ret = wait_for_completion_timeout(&ar->wmi.unified_ready, |
| 660 | WMI_UNIFIED_READY_TIMEOUT_HZ); |
| 661 | return ret; |
| 662 | } |
| 663 | |
Kalle Valo | 666a73f3 | 2014-09-10 18:23:23 +0300 | [diff] [blame] | 664 | struct sk_buff *ath10k_wmi_alloc_skb(struct ath10k *ar, u32 len) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 665 | { |
| 666 | struct sk_buff *skb; |
| 667 | u32 round_len = roundup(len, 4); |
| 668 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 669 | skb = ath10k_htc_alloc_skb(ar, WMI_SKB_HEADROOM + round_len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 670 | if (!skb) |
| 671 | return NULL; |
| 672 | |
| 673 | skb_reserve(skb, WMI_SKB_HEADROOM); |
| 674 | if (!IS_ALIGNED((unsigned long)skb->data, 4)) |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 675 | ath10k_warn(ar, "Unaligned WMI skb\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 676 | |
| 677 | skb_put(skb, round_len); |
| 678 | memset(skb->data, 0, round_len); |
| 679 | |
| 680 | return skb; |
| 681 | } |
| 682 | |
| 683 | static void ath10k_wmi_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb) |
| 684 | { |
| 685 | dev_kfree_skb(skb); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 686 | } |
| 687 | |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 688 | static int ath10k_wmi_cmd_send_nowait(struct ath10k *ar, struct sk_buff *skb, |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 689 | u32 cmd_id) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 690 | { |
| 691 | struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb); |
| 692 | struct wmi_cmd_hdr *cmd_hdr; |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 693 | int ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 694 | u32 cmd = 0; |
| 695 | |
| 696 | if (skb_push(skb, sizeof(struct wmi_cmd_hdr)) == NULL) |
| 697 | return -ENOMEM; |
| 698 | |
| 699 | cmd |= SM(cmd_id, WMI_CMD_HDR_CMD_ID); |
| 700 | |
| 701 | cmd_hdr = (struct wmi_cmd_hdr *)skb->data; |
| 702 | cmd_hdr->cmd_id = __cpu_to_le32(cmd); |
| 703 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 704 | memset(skb_cb, 0, sizeof(*skb_cb)); |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 705 | ret = ath10k_htc_send(&ar->htc, ar->wmi.eid, skb); |
Michal Kazior | d35a6c1 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 706 | trace_ath10k_wmi_cmd(ar, cmd_id, skb->data, skb->len, ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 707 | |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 708 | if (ret) |
| 709 | goto err_pull; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 710 | |
| 711 | return 0; |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 712 | |
| 713 | err_pull: |
| 714 | skb_pull(skb, sizeof(struct wmi_cmd_hdr)); |
| 715 | return ret; |
| 716 | } |
| 717 | |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 718 | static void ath10k_wmi_tx_beacon_nowait(struct ath10k_vif *arvif) |
| 719 | { |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 720 | int ret; |
| 721 | |
| 722 | lockdep_assert_held(&arvif->ar->data_lock); |
| 723 | |
| 724 | if (arvif->beacon == NULL) |
| 725 | return; |
| 726 | |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 727 | if (arvif->beacon_sent) |
| 728 | return; |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 729 | |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 730 | ret = ath10k_wmi_beacon_send_ref_nowait(arvif); |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 731 | if (ret) |
| 732 | return; |
| 733 | |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 734 | /* We need to retain the arvif->beacon reference for DMA unmapping and |
| 735 | * freeing the skbuff later. */ |
| 736 | arvif->beacon_sent = true; |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | static void ath10k_wmi_tx_beacons_iter(void *data, u8 *mac, |
| 740 | struct ieee80211_vif *vif) |
| 741 | { |
| 742 | struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif); |
| 743 | |
| 744 | ath10k_wmi_tx_beacon_nowait(arvif); |
| 745 | } |
| 746 | |
| 747 | static void ath10k_wmi_tx_beacons_nowait(struct ath10k *ar) |
| 748 | { |
| 749 | spin_lock_bh(&ar->data_lock); |
| 750 | ieee80211_iterate_active_interfaces_atomic(ar->hw, |
| 751 | IEEE80211_IFACE_ITER_NORMAL, |
| 752 | ath10k_wmi_tx_beacons_iter, |
| 753 | NULL); |
| 754 | spin_unlock_bh(&ar->data_lock); |
| 755 | } |
| 756 | |
Michal Kazior | 12acbc4 | 2013-09-13 14:16:55 +0200 | [diff] [blame] | 757 | static void ath10k_wmi_op_ep_tx_credits(struct ath10k *ar) |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 758 | { |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 759 | /* try to send pending beacons first. they take priority */ |
| 760 | ath10k_wmi_tx_beacons_nowait(ar); |
| 761 | |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 762 | wake_up(&ar->wmi.tx_credits_wq); |
| 763 | } |
| 764 | |
Kalle Valo | 666a73f3 | 2014-09-10 18:23:23 +0300 | [diff] [blame] | 765 | int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id) |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 766 | { |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 767 | int ret = -EOPNOTSUPP; |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 768 | |
Kalle Valo | 56b8428 | 2013-10-16 15:44:47 +0300 | [diff] [blame] | 769 | might_sleep(); |
| 770 | |
Bartosz Markowski | 34957b2 | 2013-10-15 09:55:31 +0200 | [diff] [blame] | 771 | if (cmd_id == WMI_CMD_UNSUPPORTED) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 772 | ath10k_warn(ar, "wmi command %d is not supported by firmware\n", |
Bartosz Markowski | 5532155 | 2013-09-26 17:47:07 +0200 | [diff] [blame] | 773 | cmd_id); |
| 774 | return ret; |
| 775 | } |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 776 | |
| 777 | wait_event_timeout(ar->wmi.tx_credits_wq, ({ |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 778 | /* try to send pending beacons first. they take priority */ |
| 779 | ath10k_wmi_tx_beacons_nowait(ar); |
| 780 | |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 781 | ret = ath10k_wmi_cmd_send_nowait(ar, skb, cmd_id); |
| 782 | (ret != -EAGAIN); |
| 783 | }), 3*HZ); |
| 784 | |
| 785 | if (ret) |
| 786 | dev_kfree_skb_any(skb); |
| 787 | |
| 788 | return ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 789 | } |
| 790 | |
Bartosz Markowski | 5e00d31 | 2013-09-26 17:47:12 +0200 | [diff] [blame] | 791 | int ath10k_wmi_mgmt_tx(struct ath10k *ar, struct sk_buff *skb) |
| 792 | { |
| 793 | int ret = 0; |
| 794 | struct wmi_mgmt_tx_cmd *cmd; |
| 795 | struct ieee80211_hdr *hdr; |
| 796 | struct sk_buff *wmi_skb; |
| 797 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
| 798 | int len; |
Marek Kwaczynski | eeab266 | 2014-05-14 16:56:17 +0300 | [diff] [blame] | 799 | u32 buf_len = skb->len; |
Bartosz Markowski | 5e00d31 | 2013-09-26 17:47:12 +0200 | [diff] [blame] | 800 | u16 fc; |
| 801 | |
| 802 | hdr = (struct ieee80211_hdr *)skb->data; |
| 803 | fc = le16_to_cpu(hdr->frame_control); |
| 804 | |
| 805 | if (WARN_ON_ONCE(!ieee80211_is_mgmt(hdr->frame_control))) |
| 806 | return -EINVAL; |
| 807 | |
| 808 | len = sizeof(cmd->hdr) + skb->len; |
Marek Kwaczynski | eeab266 | 2014-05-14 16:56:17 +0300 | [diff] [blame] | 809 | |
| 810 | if ((ieee80211_is_action(hdr->frame_control) || |
| 811 | ieee80211_is_deauth(hdr->frame_control) || |
| 812 | ieee80211_is_disassoc(hdr->frame_control)) && |
| 813 | ieee80211_has_protected(hdr->frame_control)) { |
| 814 | len += IEEE80211_CCMP_MIC_LEN; |
| 815 | buf_len += IEEE80211_CCMP_MIC_LEN; |
| 816 | } |
| 817 | |
Bartosz Markowski | 5e00d31 | 2013-09-26 17:47:12 +0200 | [diff] [blame] | 818 | len = round_up(len, 4); |
| 819 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 820 | wmi_skb = ath10k_wmi_alloc_skb(ar, len); |
Bartosz Markowski | 5e00d31 | 2013-09-26 17:47:12 +0200 | [diff] [blame] | 821 | if (!wmi_skb) |
| 822 | return -ENOMEM; |
| 823 | |
| 824 | cmd = (struct wmi_mgmt_tx_cmd *)wmi_skb->data; |
| 825 | |
| 826 | cmd->hdr.vdev_id = __cpu_to_le32(ATH10K_SKB_CB(skb)->vdev_id); |
| 827 | cmd->hdr.tx_rate = 0; |
| 828 | cmd->hdr.tx_power = 0; |
Marek Kwaczynski | eeab266 | 2014-05-14 16:56:17 +0300 | [diff] [blame] | 829 | cmd->hdr.buf_len = __cpu_to_le32(buf_len); |
Bartosz Markowski | 5e00d31 | 2013-09-26 17:47:12 +0200 | [diff] [blame] | 830 | |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 831 | ether_addr_copy(cmd->hdr.peer_macaddr.addr, ieee80211_get_DA(hdr)); |
Bartosz Markowski | 5e00d31 | 2013-09-26 17:47:12 +0200 | [diff] [blame] | 832 | memcpy(cmd->buf, skb->data, skb->len); |
| 833 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 834 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi mgmt tx skb %p len %d ftype %02x stype %02x\n", |
Bartosz Markowski | 5e00d31 | 2013-09-26 17:47:12 +0200 | [diff] [blame] | 835 | wmi_skb, wmi_skb->len, fc & IEEE80211_FCTL_FTYPE, |
| 836 | fc & IEEE80211_FCTL_STYPE); |
| 837 | |
| 838 | /* Send the management frame buffer to the target */ |
| 839 | ret = ath10k_wmi_cmd_send(ar, wmi_skb, ar->wmi.cmd->mgmt_tx_cmdid); |
Michal Kazior | 5fb5e41 | 2013-10-28 07:18:13 +0100 | [diff] [blame] | 840 | if (ret) |
Bartosz Markowski | 5e00d31 | 2013-09-26 17:47:12 +0200 | [diff] [blame] | 841 | return ret; |
Bartosz Markowski | 5e00d31 | 2013-09-26 17:47:12 +0200 | [diff] [blame] | 842 | |
| 843 | /* TODO: report tx status to mac80211 - temporary just ACK */ |
| 844 | info->flags |= IEEE80211_TX_STAT_ACK; |
| 845 | ieee80211_tx_status_irqsafe(ar->hw, skb); |
| 846 | |
| 847 | return ret; |
| 848 | } |
| 849 | |
Michal Kazior | 5c81c7f | 2014-08-05 14:54:44 +0200 | [diff] [blame] | 850 | static void ath10k_wmi_event_scan_started(struct ath10k *ar) |
| 851 | { |
| 852 | lockdep_assert_held(&ar->data_lock); |
| 853 | |
| 854 | switch (ar->scan.state) { |
| 855 | case ATH10K_SCAN_IDLE: |
| 856 | case ATH10K_SCAN_RUNNING: |
| 857 | case ATH10K_SCAN_ABORTING: |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 858 | ath10k_warn(ar, "received scan started event in an invalid scan state: %s (%d)\n", |
Michal Kazior | 5c81c7f | 2014-08-05 14:54:44 +0200 | [diff] [blame] | 859 | ath10k_scan_state_str(ar->scan.state), |
| 860 | ar->scan.state); |
| 861 | break; |
| 862 | case ATH10K_SCAN_STARTING: |
| 863 | ar->scan.state = ATH10K_SCAN_RUNNING; |
| 864 | |
| 865 | if (ar->scan.is_roc) |
| 866 | ieee80211_ready_on_channel(ar->hw); |
| 867 | |
| 868 | complete(&ar->scan.started); |
| 869 | break; |
| 870 | } |
| 871 | } |
| 872 | |
| 873 | static void ath10k_wmi_event_scan_completed(struct ath10k *ar) |
| 874 | { |
| 875 | lockdep_assert_held(&ar->data_lock); |
| 876 | |
| 877 | switch (ar->scan.state) { |
| 878 | case ATH10K_SCAN_IDLE: |
| 879 | case ATH10K_SCAN_STARTING: |
| 880 | /* One suspected reason scan can be completed while starting is |
| 881 | * if firmware fails to deliver all scan events to the host, |
| 882 | * e.g. when transport pipe is full. This has been observed |
| 883 | * with spectral scan phyerr events starving wmi transport |
| 884 | * pipe. In such case the "scan completed" event should be (and |
| 885 | * is) ignored by the host as it may be just firmware's scan |
| 886 | * state machine recovering. |
| 887 | */ |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 888 | ath10k_warn(ar, "received scan completed event in an invalid scan state: %s (%d)\n", |
Michal Kazior | 5c81c7f | 2014-08-05 14:54:44 +0200 | [diff] [blame] | 889 | ath10k_scan_state_str(ar->scan.state), |
| 890 | ar->scan.state); |
| 891 | break; |
| 892 | case ATH10K_SCAN_RUNNING: |
| 893 | case ATH10K_SCAN_ABORTING: |
| 894 | __ath10k_scan_finish(ar); |
| 895 | break; |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | static void ath10k_wmi_event_scan_bss_chan(struct ath10k *ar) |
| 900 | { |
| 901 | lockdep_assert_held(&ar->data_lock); |
| 902 | |
| 903 | switch (ar->scan.state) { |
| 904 | case ATH10K_SCAN_IDLE: |
| 905 | case ATH10K_SCAN_STARTING: |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 906 | ath10k_warn(ar, "received scan bss chan event in an invalid scan state: %s (%d)\n", |
Michal Kazior | 5c81c7f | 2014-08-05 14:54:44 +0200 | [diff] [blame] | 907 | ath10k_scan_state_str(ar->scan.state), |
| 908 | ar->scan.state); |
| 909 | break; |
| 910 | case ATH10K_SCAN_RUNNING: |
| 911 | case ATH10K_SCAN_ABORTING: |
| 912 | ar->scan_channel = NULL; |
| 913 | break; |
| 914 | } |
| 915 | } |
| 916 | |
| 917 | static void ath10k_wmi_event_scan_foreign_chan(struct ath10k *ar, u32 freq) |
| 918 | { |
| 919 | lockdep_assert_held(&ar->data_lock); |
| 920 | |
| 921 | switch (ar->scan.state) { |
| 922 | case ATH10K_SCAN_IDLE: |
| 923 | case ATH10K_SCAN_STARTING: |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 924 | ath10k_warn(ar, "received scan foreign chan event in an invalid scan state: %s (%d)\n", |
Michal Kazior | 5c81c7f | 2014-08-05 14:54:44 +0200 | [diff] [blame] | 925 | ath10k_scan_state_str(ar->scan.state), |
| 926 | ar->scan.state); |
| 927 | break; |
| 928 | case ATH10K_SCAN_RUNNING: |
| 929 | case ATH10K_SCAN_ABORTING: |
| 930 | ar->scan_channel = ieee80211_get_channel(ar->hw->wiphy, freq); |
| 931 | |
| 932 | if (ar->scan.is_roc && ar->scan.roc_freq == freq) |
| 933 | complete(&ar->scan.on_channel); |
| 934 | break; |
| 935 | } |
| 936 | } |
| 937 | |
Michal Kazior | 9ff8b72 | 2014-08-05 14:54:43 +0200 | [diff] [blame] | 938 | static const char * |
| 939 | ath10k_wmi_event_scan_type_str(enum wmi_scan_event_type type, |
| 940 | enum wmi_scan_completion_reason reason) |
| 941 | { |
| 942 | switch (type) { |
| 943 | case WMI_SCAN_EVENT_STARTED: |
| 944 | return "started"; |
| 945 | case WMI_SCAN_EVENT_COMPLETED: |
| 946 | switch (reason) { |
| 947 | case WMI_SCAN_REASON_COMPLETED: |
| 948 | return "completed"; |
| 949 | case WMI_SCAN_REASON_CANCELLED: |
| 950 | return "completed [cancelled]"; |
| 951 | case WMI_SCAN_REASON_PREEMPTED: |
| 952 | return "completed [preempted]"; |
| 953 | case WMI_SCAN_REASON_TIMEDOUT: |
| 954 | return "completed [timedout]"; |
| 955 | case WMI_SCAN_REASON_MAX: |
| 956 | break; |
| 957 | } |
| 958 | return "completed [unknown]"; |
| 959 | case WMI_SCAN_EVENT_BSS_CHANNEL: |
| 960 | return "bss channel"; |
| 961 | case WMI_SCAN_EVENT_FOREIGN_CHANNEL: |
| 962 | return "foreign channel"; |
| 963 | case WMI_SCAN_EVENT_DEQUEUED: |
| 964 | return "dequeued"; |
| 965 | case WMI_SCAN_EVENT_PREEMPTED: |
| 966 | return "preempted"; |
| 967 | case WMI_SCAN_EVENT_START_FAILED: |
| 968 | return "start failed"; |
| 969 | default: |
| 970 | return "unknown"; |
| 971 | } |
| 972 | } |
| 973 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 974 | static int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb) |
| 975 | { |
| 976 | struct wmi_scan_event *event = (struct wmi_scan_event *)skb->data; |
| 977 | enum wmi_scan_event_type event_type; |
| 978 | enum wmi_scan_completion_reason reason; |
| 979 | u32 freq; |
| 980 | u32 req_id; |
| 981 | u32 scan_id; |
| 982 | u32 vdev_id; |
| 983 | |
| 984 | event_type = __le32_to_cpu(event->event_type); |
| 985 | reason = __le32_to_cpu(event->reason); |
| 986 | freq = __le32_to_cpu(event->channel_freq); |
| 987 | req_id = __le32_to_cpu(event->scan_req_id); |
| 988 | scan_id = __le32_to_cpu(event->scan_id); |
| 989 | vdev_id = __le32_to_cpu(event->vdev_id); |
| 990 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 991 | spin_lock_bh(&ar->data_lock); |
| 992 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 993 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Michal Kazior | 5c81c7f | 2014-08-05 14:54:44 +0200 | [diff] [blame] | 994 | "scan event %s type %d reason %d freq %d req_id %d scan_id %d vdev_id %d state %s (%d)\n", |
| 995 | ath10k_wmi_event_scan_type_str(event_type, reason), |
| 996 | event_type, reason, freq, req_id, scan_id, vdev_id, |
| 997 | ath10k_scan_state_str(ar->scan.state), ar->scan.state); |
| 998 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 999 | switch (event_type) { |
| 1000 | case WMI_SCAN_EVENT_STARTED: |
Michal Kazior | 5c81c7f | 2014-08-05 14:54:44 +0200 | [diff] [blame] | 1001 | ath10k_wmi_event_scan_started(ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1002 | break; |
| 1003 | case WMI_SCAN_EVENT_COMPLETED: |
Michal Kazior | 5c81c7f | 2014-08-05 14:54:44 +0200 | [diff] [blame] | 1004 | ath10k_wmi_event_scan_completed(ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1005 | break; |
| 1006 | case WMI_SCAN_EVENT_BSS_CHANNEL: |
Michal Kazior | 5c81c7f | 2014-08-05 14:54:44 +0200 | [diff] [blame] | 1007 | ath10k_wmi_event_scan_bss_chan(ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1008 | break; |
| 1009 | case WMI_SCAN_EVENT_FOREIGN_CHANNEL: |
Michal Kazior | 5c81c7f | 2014-08-05 14:54:44 +0200 | [diff] [blame] | 1010 | ath10k_wmi_event_scan_foreign_chan(ar, freq); |
| 1011 | break; |
| 1012 | case WMI_SCAN_EVENT_START_FAILED: |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1013 | ath10k_warn(ar, "received scan start failure event\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1014 | break; |
| 1015 | case WMI_SCAN_EVENT_DEQUEUED: |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1016 | case WMI_SCAN_EVENT_PREEMPTED: |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1017 | default: |
| 1018 | break; |
| 1019 | } |
| 1020 | |
| 1021 | spin_unlock_bh(&ar->data_lock); |
| 1022 | return 0; |
| 1023 | } |
| 1024 | |
| 1025 | static inline enum ieee80211_band phy_mode_to_band(u32 phy_mode) |
| 1026 | { |
| 1027 | enum ieee80211_band band; |
| 1028 | |
| 1029 | switch (phy_mode) { |
| 1030 | case MODE_11A: |
| 1031 | case MODE_11NA_HT20: |
| 1032 | case MODE_11NA_HT40: |
| 1033 | case MODE_11AC_VHT20: |
| 1034 | case MODE_11AC_VHT40: |
| 1035 | case MODE_11AC_VHT80: |
| 1036 | band = IEEE80211_BAND_5GHZ; |
| 1037 | break; |
| 1038 | case MODE_11G: |
| 1039 | case MODE_11B: |
| 1040 | case MODE_11GONLY: |
| 1041 | case MODE_11NG_HT20: |
| 1042 | case MODE_11NG_HT40: |
| 1043 | case MODE_11AC_VHT20_2G: |
| 1044 | case MODE_11AC_VHT40_2G: |
| 1045 | case MODE_11AC_VHT80_2G: |
| 1046 | default: |
| 1047 | band = IEEE80211_BAND_2GHZ; |
| 1048 | } |
| 1049 | |
| 1050 | return band; |
| 1051 | } |
| 1052 | |
| 1053 | static inline u8 get_rate_idx(u32 rate, enum ieee80211_band band) |
| 1054 | { |
| 1055 | u8 rate_idx = 0; |
| 1056 | |
| 1057 | /* rate in Kbps */ |
| 1058 | switch (rate) { |
| 1059 | case 1000: |
| 1060 | rate_idx = 0; |
| 1061 | break; |
| 1062 | case 2000: |
| 1063 | rate_idx = 1; |
| 1064 | break; |
| 1065 | case 5500: |
| 1066 | rate_idx = 2; |
| 1067 | break; |
| 1068 | case 11000: |
| 1069 | rate_idx = 3; |
| 1070 | break; |
| 1071 | case 6000: |
| 1072 | rate_idx = 4; |
| 1073 | break; |
| 1074 | case 9000: |
| 1075 | rate_idx = 5; |
| 1076 | break; |
| 1077 | case 12000: |
| 1078 | rate_idx = 6; |
| 1079 | break; |
| 1080 | case 18000: |
| 1081 | rate_idx = 7; |
| 1082 | break; |
| 1083 | case 24000: |
| 1084 | rate_idx = 8; |
| 1085 | break; |
| 1086 | case 36000: |
| 1087 | rate_idx = 9; |
| 1088 | break; |
| 1089 | case 48000: |
| 1090 | rate_idx = 10; |
| 1091 | break; |
| 1092 | case 54000: |
| 1093 | rate_idx = 11; |
| 1094 | break; |
| 1095 | default: |
| 1096 | break; |
| 1097 | } |
| 1098 | |
| 1099 | if (band == IEEE80211_BAND_5GHZ) { |
| 1100 | if (rate_idx > 3) |
| 1101 | /* Omit CCK rates */ |
| 1102 | rate_idx -= 4; |
| 1103 | else |
| 1104 | rate_idx = 0; |
| 1105 | } |
| 1106 | |
| 1107 | return rate_idx; |
| 1108 | } |
| 1109 | |
| 1110 | static int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb) |
| 1111 | { |
Michal Kazior | 0d9b043 | 2013-08-09 10:13:33 +0200 | [diff] [blame] | 1112 | struct wmi_mgmt_rx_event_v1 *ev_v1; |
| 1113 | struct wmi_mgmt_rx_event_v2 *ev_v2; |
| 1114 | struct wmi_mgmt_rx_hdr_v1 *ev_hdr; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1115 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); |
Michal Kazior | 453cdb6 | 2013-12-13 10:44:43 +0100 | [diff] [blame] | 1116 | struct ieee80211_channel *ch; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1117 | struct ieee80211_hdr *hdr; |
| 1118 | u32 rx_status; |
| 1119 | u32 channel; |
| 1120 | u32 phy_mode; |
| 1121 | u32 snr; |
| 1122 | u32 rate; |
| 1123 | u32 buf_len; |
| 1124 | u16 fc; |
Michal Kazior | 0d9b043 | 2013-08-09 10:13:33 +0200 | [diff] [blame] | 1125 | int pull_len; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1126 | |
Michal Kazior | 0d9b043 | 2013-08-09 10:13:33 +0200 | [diff] [blame] | 1127 | if (test_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features)) { |
| 1128 | ev_v2 = (struct wmi_mgmt_rx_event_v2 *)skb->data; |
| 1129 | ev_hdr = &ev_v2->hdr.v1; |
| 1130 | pull_len = sizeof(*ev_v2); |
| 1131 | } else { |
| 1132 | ev_v1 = (struct wmi_mgmt_rx_event_v1 *)skb->data; |
| 1133 | ev_hdr = &ev_v1->hdr; |
| 1134 | pull_len = sizeof(*ev_v1); |
| 1135 | } |
| 1136 | |
| 1137 | channel = __le32_to_cpu(ev_hdr->channel); |
| 1138 | buf_len = __le32_to_cpu(ev_hdr->buf_len); |
| 1139 | rx_status = __le32_to_cpu(ev_hdr->status); |
| 1140 | snr = __le32_to_cpu(ev_hdr->snr); |
| 1141 | phy_mode = __le32_to_cpu(ev_hdr->phy_mode); |
| 1142 | rate = __le32_to_cpu(ev_hdr->rate); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1143 | |
| 1144 | memset(status, 0, sizeof(*status)); |
| 1145 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1146 | ath10k_dbg(ar, ATH10K_DBG_MGMT, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1147 | "event mgmt rx status %08x\n", rx_status); |
| 1148 | |
Marek Puzyniak | e8a50f8 | 2013-11-20 09:59:47 +0200 | [diff] [blame] | 1149 | if (test_bit(ATH10K_CAC_RUNNING, &ar->dev_flags)) { |
| 1150 | dev_kfree_skb(skb); |
| 1151 | return 0; |
| 1152 | } |
| 1153 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1154 | if (rx_status & WMI_RX_STATUS_ERR_DECRYPT) { |
| 1155 | dev_kfree_skb(skb); |
| 1156 | return 0; |
| 1157 | } |
| 1158 | |
| 1159 | if (rx_status & WMI_RX_STATUS_ERR_KEY_CACHE_MISS) { |
| 1160 | dev_kfree_skb(skb); |
| 1161 | return 0; |
| 1162 | } |
| 1163 | |
| 1164 | if (rx_status & WMI_RX_STATUS_ERR_CRC) |
| 1165 | status->flag |= RX_FLAG_FAILED_FCS_CRC; |
| 1166 | if (rx_status & WMI_RX_STATUS_ERR_MIC) |
| 1167 | status->flag |= RX_FLAG_MMIC_ERROR; |
| 1168 | |
Michal Kazior | 453cdb6 | 2013-12-13 10:44:43 +0100 | [diff] [blame] | 1169 | /* HW can Rx CCK rates on 5GHz. In that case phy_mode is set to |
| 1170 | * MODE_11B. This means phy_mode is not a reliable source for the band |
| 1171 | * of mgmt rx. */ |
| 1172 | |
| 1173 | ch = ar->scan_channel; |
| 1174 | if (!ch) |
| 1175 | ch = ar->rx_channel; |
| 1176 | |
| 1177 | if (ch) { |
| 1178 | status->band = ch->band; |
| 1179 | |
| 1180 | if (phy_mode == MODE_11B && |
| 1181 | status->band == IEEE80211_BAND_5GHZ) |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1182 | ath10k_dbg(ar, ATH10K_DBG_MGMT, "wmi mgmt rx 11b (CCK) on 5GHz\n"); |
Michal Kazior | 453cdb6 | 2013-12-13 10:44:43 +0100 | [diff] [blame] | 1183 | } else { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1184 | ath10k_warn(ar, "using (unreliable) phy_mode to extract band for mgmt rx\n"); |
Michal Kazior | 453cdb6 | 2013-12-13 10:44:43 +0100 | [diff] [blame] | 1185 | status->band = phy_mode_to_band(phy_mode); |
| 1186 | } |
| 1187 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1188 | status->freq = ieee80211_channel_to_frequency(channel, status->band); |
| 1189 | status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR; |
| 1190 | status->rate_idx = get_rate_idx(rate, status->band); |
| 1191 | |
Michal Kazior | 0d9b043 | 2013-08-09 10:13:33 +0200 | [diff] [blame] | 1192 | skb_pull(skb, pull_len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1193 | |
| 1194 | hdr = (struct ieee80211_hdr *)skb->data; |
| 1195 | fc = le16_to_cpu(hdr->frame_control); |
| 1196 | |
Michal Kazior | 2b6a6a9 | 2013-12-05 06:53:41 +0100 | [diff] [blame] | 1197 | /* FW delivers WEP Shared Auth frame with Protected Bit set and |
| 1198 | * encrypted payload. However in case of PMF it delivers decrypted |
| 1199 | * frames with Protected Bit set. */ |
| 1200 | if (ieee80211_has_protected(hdr->frame_control) && |
| 1201 | !ieee80211_is_auth(hdr->frame_control)) { |
Marek Kwaczynski | eeab266 | 2014-05-14 16:56:17 +0300 | [diff] [blame] | 1202 | status->flag |= RX_FLAG_DECRYPTED; |
| 1203 | |
| 1204 | if (!ieee80211_is_action(hdr->frame_control) && |
| 1205 | !ieee80211_is_deauth(hdr->frame_control) && |
| 1206 | !ieee80211_is_disassoc(hdr->frame_control)) { |
| 1207 | status->flag |= RX_FLAG_IV_STRIPPED | |
| 1208 | RX_FLAG_MMIC_STRIPPED; |
| 1209 | hdr->frame_control = __cpu_to_le16(fc & |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1210 | ~IEEE80211_FCTL_PROTECTED); |
Marek Kwaczynski | eeab266 | 2014-05-14 16:56:17 +0300 | [diff] [blame] | 1211 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1212 | } |
| 1213 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1214 | ath10k_dbg(ar, ATH10K_DBG_MGMT, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1215 | "event mgmt rx skb %p len %d ftype %02x stype %02x\n", |
| 1216 | skb, skb->len, |
| 1217 | fc & IEEE80211_FCTL_FTYPE, fc & IEEE80211_FCTL_STYPE); |
| 1218 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1219 | ath10k_dbg(ar, ATH10K_DBG_MGMT, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1220 | "event mgmt rx freq %d band %d snr %d, rate_idx %d\n", |
| 1221 | status->freq, status->band, status->signal, |
| 1222 | status->rate_idx); |
| 1223 | |
| 1224 | /* |
| 1225 | * packets from HTC come aligned to 4byte boundaries |
| 1226 | * because they can originally come in along with a trailer |
| 1227 | */ |
| 1228 | skb_trim(skb, buf_len); |
| 1229 | |
| 1230 | ieee80211_rx(ar->hw, skb); |
| 1231 | return 0; |
| 1232 | } |
| 1233 | |
Michal Kazior | 2e1dea4 | 2013-07-31 10:32:40 +0200 | [diff] [blame] | 1234 | static int freq_to_idx(struct ath10k *ar, int freq) |
| 1235 | { |
| 1236 | struct ieee80211_supported_band *sband; |
| 1237 | int band, ch, idx = 0; |
| 1238 | |
| 1239 | for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) { |
| 1240 | sband = ar->hw->wiphy->bands[band]; |
| 1241 | if (!sband) |
| 1242 | continue; |
| 1243 | |
| 1244 | for (ch = 0; ch < sband->n_channels; ch++, idx++) |
| 1245 | if (sband->channels[ch].center_freq == freq) |
| 1246 | goto exit; |
| 1247 | } |
| 1248 | |
| 1249 | exit: |
| 1250 | return idx; |
| 1251 | } |
| 1252 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1253 | static void ath10k_wmi_event_chan_info(struct ath10k *ar, struct sk_buff *skb) |
| 1254 | { |
Michal Kazior | 2e1dea4 | 2013-07-31 10:32:40 +0200 | [diff] [blame] | 1255 | struct wmi_chan_info_event *ev; |
| 1256 | struct survey_info *survey; |
| 1257 | u32 err_code, freq, cmd_flags, noise_floor, rx_clear_count, cycle_count; |
| 1258 | int idx; |
| 1259 | |
| 1260 | ev = (struct wmi_chan_info_event *)skb->data; |
| 1261 | |
| 1262 | err_code = __le32_to_cpu(ev->err_code); |
| 1263 | freq = __le32_to_cpu(ev->freq); |
| 1264 | cmd_flags = __le32_to_cpu(ev->cmd_flags); |
| 1265 | noise_floor = __le32_to_cpu(ev->noise_floor); |
| 1266 | rx_clear_count = __le32_to_cpu(ev->rx_clear_count); |
| 1267 | cycle_count = __le32_to_cpu(ev->cycle_count); |
| 1268 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1269 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Michal Kazior | 2e1dea4 | 2013-07-31 10:32:40 +0200 | [diff] [blame] | 1270 | "chan info err_code %d freq %d cmd_flags %d noise_floor %d rx_clear_count %d cycle_count %d\n", |
| 1271 | err_code, freq, cmd_flags, noise_floor, rx_clear_count, |
| 1272 | cycle_count); |
| 1273 | |
| 1274 | spin_lock_bh(&ar->data_lock); |
| 1275 | |
Michal Kazior | 5c81c7f | 2014-08-05 14:54:44 +0200 | [diff] [blame] | 1276 | switch (ar->scan.state) { |
| 1277 | case ATH10K_SCAN_IDLE: |
| 1278 | case ATH10K_SCAN_STARTING: |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1279 | ath10k_warn(ar, "received chan info event without a scan request, ignoring\n"); |
Michal Kazior | 2e1dea4 | 2013-07-31 10:32:40 +0200 | [diff] [blame] | 1280 | goto exit; |
Michal Kazior | 5c81c7f | 2014-08-05 14:54:44 +0200 | [diff] [blame] | 1281 | case ATH10K_SCAN_RUNNING: |
| 1282 | case ATH10K_SCAN_ABORTING: |
| 1283 | break; |
Michal Kazior | 2e1dea4 | 2013-07-31 10:32:40 +0200 | [diff] [blame] | 1284 | } |
| 1285 | |
| 1286 | idx = freq_to_idx(ar, freq); |
| 1287 | if (idx >= ARRAY_SIZE(ar->survey)) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1288 | ath10k_warn(ar, "chan info: invalid frequency %d (idx %d out of bounds)\n", |
Michal Kazior | 2e1dea4 | 2013-07-31 10:32:40 +0200 | [diff] [blame] | 1289 | freq, idx); |
| 1290 | goto exit; |
| 1291 | } |
| 1292 | |
| 1293 | if (cmd_flags & WMI_CHAN_INFO_FLAG_COMPLETE) { |
| 1294 | /* During scanning chan info is reported twice for each |
| 1295 | * visited channel. The reported cycle count is global |
| 1296 | * and per-channel cycle count must be calculated */ |
| 1297 | |
| 1298 | cycle_count -= ar->survey_last_cycle_count; |
| 1299 | rx_clear_count -= ar->survey_last_rx_clear_count; |
| 1300 | |
| 1301 | survey = &ar->survey[idx]; |
| 1302 | survey->channel_time = WMI_CHAN_INFO_MSEC(cycle_count); |
| 1303 | survey->channel_time_rx = WMI_CHAN_INFO_MSEC(rx_clear_count); |
| 1304 | survey->noise = noise_floor; |
| 1305 | survey->filled = SURVEY_INFO_CHANNEL_TIME | |
| 1306 | SURVEY_INFO_CHANNEL_TIME_RX | |
| 1307 | SURVEY_INFO_NOISE_DBM; |
| 1308 | } |
| 1309 | |
| 1310 | ar->survey_last_rx_clear_count = rx_clear_count; |
| 1311 | ar->survey_last_cycle_count = cycle_count; |
| 1312 | |
| 1313 | exit: |
| 1314 | spin_unlock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1315 | } |
| 1316 | |
| 1317 | static void ath10k_wmi_event_echo(struct ath10k *ar, struct sk_buff *skb) |
| 1318 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1319 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_ECHO_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1320 | } |
| 1321 | |
Kalle Valo | 869526b | 2014-01-03 12:59:26 +0200 | [diff] [blame] | 1322 | static int ath10k_wmi_event_debug_mesg(struct ath10k *ar, struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1323 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1324 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event debug mesg len %d\n", |
Kalle Valo | 869526b | 2014-01-03 12:59:26 +0200 | [diff] [blame] | 1325 | skb->len); |
| 1326 | |
Michal Kazior | d35a6c1 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 1327 | trace_ath10k_wmi_dbglog(ar, skb->data, skb->len); |
Kalle Valo | 869526b | 2014-01-03 12:59:26 +0200 | [diff] [blame] | 1328 | |
| 1329 | return 0; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1330 | } |
| 1331 | |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1332 | static void ath10k_wmi_pull_pdev_stats(const struct wmi_pdev_stats *src, |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 1333 | struct ath10k_fw_stats_pdev *dst) |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1334 | { |
| 1335 | const struct wal_dbg_tx_stats *tx = &src->wal.tx; |
| 1336 | const struct wal_dbg_rx_stats *rx = &src->wal.rx; |
| 1337 | |
| 1338 | dst->ch_noise_floor = __le32_to_cpu(src->chan_nf); |
| 1339 | dst->tx_frame_count = __le32_to_cpu(src->tx_frame_count); |
| 1340 | dst->rx_frame_count = __le32_to_cpu(src->rx_frame_count); |
| 1341 | dst->rx_clear_count = __le32_to_cpu(src->rx_clear_count); |
| 1342 | dst->cycle_count = __le32_to_cpu(src->cycle_count); |
| 1343 | dst->phy_err_count = __le32_to_cpu(src->phy_err_count); |
| 1344 | dst->chan_tx_power = __le32_to_cpu(src->chan_tx_pwr); |
| 1345 | |
| 1346 | dst->comp_queued = __le32_to_cpu(tx->comp_queued); |
| 1347 | dst->comp_delivered = __le32_to_cpu(tx->comp_delivered); |
| 1348 | dst->msdu_enqued = __le32_to_cpu(tx->msdu_enqued); |
| 1349 | dst->mpdu_enqued = __le32_to_cpu(tx->mpdu_enqued); |
| 1350 | dst->wmm_drop = __le32_to_cpu(tx->wmm_drop); |
| 1351 | dst->local_enqued = __le32_to_cpu(tx->local_enqued); |
| 1352 | dst->local_freed = __le32_to_cpu(tx->local_freed); |
| 1353 | dst->hw_queued = __le32_to_cpu(tx->hw_queued); |
| 1354 | dst->hw_reaped = __le32_to_cpu(tx->hw_reaped); |
| 1355 | dst->underrun = __le32_to_cpu(tx->underrun); |
| 1356 | dst->tx_abort = __le32_to_cpu(tx->tx_abort); |
| 1357 | dst->mpdus_requed = __le32_to_cpu(tx->mpdus_requed); |
| 1358 | dst->tx_ko = __le32_to_cpu(tx->tx_ko); |
| 1359 | dst->data_rc = __le32_to_cpu(tx->data_rc); |
| 1360 | dst->self_triggers = __le32_to_cpu(tx->self_triggers); |
| 1361 | dst->sw_retry_failure = __le32_to_cpu(tx->sw_retry_failure); |
| 1362 | dst->illgl_rate_phy_err = __le32_to_cpu(tx->illgl_rate_phy_err); |
| 1363 | dst->pdev_cont_xretry = __le32_to_cpu(tx->pdev_cont_xretry); |
| 1364 | dst->pdev_tx_timeout = __le32_to_cpu(tx->pdev_tx_timeout); |
| 1365 | dst->pdev_resets = __le32_to_cpu(tx->pdev_resets); |
| 1366 | dst->phy_underrun = __le32_to_cpu(tx->phy_underrun); |
| 1367 | dst->txop_ovf = __le32_to_cpu(tx->txop_ovf); |
| 1368 | |
| 1369 | dst->mid_ppdu_route_change = __le32_to_cpu(rx->mid_ppdu_route_change); |
| 1370 | dst->status_rcvd = __le32_to_cpu(rx->status_rcvd); |
| 1371 | dst->r0_frags = __le32_to_cpu(rx->r0_frags); |
| 1372 | dst->r1_frags = __le32_to_cpu(rx->r1_frags); |
| 1373 | dst->r2_frags = __le32_to_cpu(rx->r2_frags); |
| 1374 | dst->r3_frags = __le32_to_cpu(rx->r3_frags); |
| 1375 | dst->htt_msdus = __le32_to_cpu(rx->htt_msdus); |
| 1376 | dst->htt_mpdus = __le32_to_cpu(rx->htt_mpdus); |
| 1377 | dst->loc_msdus = __le32_to_cpu(rx->loc_msdus); |
| 1378 | dst->loc_mpdus = __le32_to_cpu(rx->loc_mpdus); |
| 1379 | dst->oversize_amsdu = __le32_to_cpu(rx->oversize_amsdu); |
| 1380 | dst->phy_errs = __le32_to_cpu(rx->phy_errs); |
| 1381 | dst->phy_err_drop = __le32_to_cpu(rx->phy_err_drop); |
| 1382 | dst->mpdu_errs = __le32_to_cpu(rx->mpdu_errs); |
| 1383 | } |
| 1384 | |
| 1385 | static void ath10k_wmi_pull_peer_stats(const struct wmi_peer_stats *src, |
Michal Kazior | 60ef401 | 2014-09-25 12:33:48 +0200 | [diff] [blame] | 1386 | struct ath10k_fw_stats_peer *dst) |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1387 | { |
| 1388 | ether_addr_copy(dst->peer_macaddr, src->peer_macaddr.addr); |
| 1389 | dst->peer_rssi = __le32_to_cpu(src->peer_rssi); |
| 1390 | dst->peer_tx_rate = __le32_to_cpu(src->peer_tx_rate); |
| 1391 | } |
| 1392 | |
| 1393 | static int ath10k_wmi_main_pull_fw_stats(struct ath10k *ar, |
| 1394 | struct sk_buff *skb, |
Michal Kazior | 60ef401 | 2014-09-25 12:33:48 +0200 | [diff] [blame] | 1395 | struct ath10k_fw_stats *stats) |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1396 | { |
| 1397 | const struct wmi_stats_event *ev = (void *)skb->data; |
| 1398 | u32 num_pdev_stats, num_vdev_stats, num_peer_stats; |
| 1399 | int i; |
| 1400 | |
| 1401 | if (!skb_pull(skb, sizeof(*ev))) |
| 1402 | return -EPROTO; |
| 1403 | |
| 1404 | num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats); |
| 1405 | num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats); |
| 1406 | num_peer_stats = __le32_to_cpu(ev->num_peer_stats); |
| 1407 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 1408 | for (i = 0; i < num_pdev_stats; i++) { |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1409 | const struct wmi_pdev_stats *src; |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 1410 | struct ath10k_fw_stats_pdev *dst; |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1411 | |
| 1412 | src = (void *)skb->data; |
| 1413 | if (!skb_pull(skb, sizeof(*src))) |
| 1414 | return -EPROTO; |
| 1415 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 1416 | dst = kzalloc(sizeof(*dst), GFP_ATOMIC); |
| 1417 | if (!dst) |
| 1418 | continue; |
| 1419 | |
| 1420 | ath10k_wmi_pull_pdev_stats(src, dst); |
| 1421 | list_add_tail(&dst->list, &stats->pdevs); |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1422 | } |
| 1423 | |
| 1424 | /* fw doesn't implement vdev stats */ |
| 1425 | |
| 1426 | for (i = 0; i < num_peer_stats; i++) { |
| 1427 | const struct wmi_peer_stats *src; |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 1428 | struct ath10k_fw_stats_peer *dst; |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1429 | |
| 1430 | src = (void *)skb->data; |
| 1431 | if (!skb_pull(skb, sizeof(*src))) |
| 1432 | return -EPROTO; |
| 1433 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 1434 | dst = kzalloc(sizeof(*dst), GFP_ATOMIC); |
| 1435 | if (!dst) |
| 1436 | continue; |
| 1437 | |
| 1438 | ath10k_wmi_pull_peer_stats(src, dst); |
| 1439 | list_add_tail(&dst->list, &stats->peers); |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1440 | } |
| 1441 | |
| 1442 | return 0; |
| 1443 | } |
| 1444 | |
| 1445 | static int ath10k_wmi_10x_pull_fw_stats(struct ath10k *ar, |
| 1446 | struct sk_buff *skb, |
Michal Kazior | 60ef401 | 2014-09-25 12:33:48 +0200 | [diff] [blame] | 1447 | struct ath10k_fw_stats *stats) |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1448 | { |
| 1449 | const struct wmi_stats_event *ev = (void *)skb->data; |
| 1450 | u32 num_pdev_stats, num_vdev_stats, num_peer_stats; |
| 1451 | int i; |
| 1452 | |
| 1453 | if (!skb_pull(skb, sizeof(*ev))) |
| 1454 | return -EPROTO; |
| 1455 | |
| 1456 | num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats); |
| 1457 | num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats); |
| 1458 | num_peer_stats = __le32_to_cpu(ev->num_peer_stats); |
| 1459 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 1460 | for (i = 0; i < num_pdev_stats; i++) { |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1461 | const struct wmi_10x_pdev_stats *src; |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 1462 | struct ath10k_fw_stats_pdev *dst; |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1463 | |
| 1464 | src = (void *)skb->data; |
| 1465 | if (!skb_pull(skb, sizeof(*src))) |
| 1466 | return -EPROTO; |
| 1467 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 1468 | dst = kzalloc(sizeof(*dst), GFP_ATOMIC); |
| 1469 | if (!dst) |
| 1470 | continue; |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1471 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 1472 | ath10k_wmi_pull_pdev_stats(&src->old, dst); |
| 1473 | |
| 1474 | dst->ack_rx_bad = __le32_to_cpu(src->ack_rx_bad); |
| 1475 | dst->rts_bad = __le32_to_cpu(src->rts_bad); |
| 1476 | dst->rts_good = __le32_to_cpu(src->rts_good); |
| 1477 | dst->fcs_bad = __le32_to_cpu(src->fcs_bad); |
| 1478 | dst->no_beacons = __le32_to_cpu(src->no_beacons); |
| 1479 | dst->mib_int_count = __le32_to_cpu(src->mib_int_count); |
| 1480 | |
| 1481 | list_add_tail(&dst->list, &stats->pdevs); |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1482 | } |
| 1483 | |
| 1484 | /* fw doesn't implement vdev stats */ |
| 1485 | |
| 1486 | for (i = 0; i < num_peer_stats; i++) { |
| 1487 | const struct wmi_10x_peer_stats *src; |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 1488 | struct ath10k_fw_stats_peer *dst; |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1489 | |
| 1490 | src = (void *)skb->data; |
| 1491 | if (!skb_pull(skb, sizeof(*src))) |
| 1492 | return -EPROTO; |
| 1493 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 1494 | dst = kzalloc(sizeof(*dst), GFP_ATOMIC); |
| 1495 | if (!dst) |
| 1496 | continue; |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1497 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 1498 | ath10k_wmi_pull_peer_stats(&src->old, dst); |
| 1499 | |
| 1500 | dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate); |
| 1501 | |
| 1502 | list_add_tail(&dst->list, &stats->peers); |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1503 | } |
| 1504 | |
| 1505 | return 0; |
| 1506 | } |
| 1507 | |
| 1508 | int ath10k_wmi_pull_fw_stats(struct ath10k *ar, struct sk_buff *skb, |
Michal Kazior | 60ef401 | 2014-09-25 12:33:48 +0200 | [diff] [blame] | 1509 | struct ath10k_fw_stats *stats) |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 1510 | { |
| 1511 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) |
| 1512 | return ath10k_wmi_10x_pull_fw_stats(ar, skb, stats); |
| 1513 | else |
| 1514 | return ath10k_wmi_main_pull_fw_stats(ar, skb, stats); |
| 1515 | } |
| 1516 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1517 | static void ath10k_wmi_event_update_stats(struct ath10k *ar, |
| 1518 | struct sk_buff *skb) |
| 1519 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1520 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_UPDATE_STATS_EVENTID\n"); |
Michal Kazior | 60ef401 | 2014-09-25 12:33:48 +0200 | [diff] [blame] | 1521 | ath10k_debug_fw_stats_process(ar, skb); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1522 | } |
| 1523 | |
| 1524 | static void ath10k_wmi_event_vdev_start_resp(struct ath10k *ar, |
| 1525 | struct sk_buff *skb) |
| 1526 | { |
| 1527 | struct wmi_vdev_start_response_event *ev; |
| 1528 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1529 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_START_RESP_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1530 | |
| 1531 | ev = (struct wmi_vdev_start_response_event *)skb->data; |
| 1532 | |
| 1533 | if (WARN_ON(__le32_to_cpu(ev->status))) |
| 1534 | return; |
| 1535 | |
| 1536 | complete(&ar->vdev_setup_done); |
| 1537 | } |
| 1538 | |
| 1539 | static void ath10k_wmi_event_vdev_stopped(struct ath10k *ar, |
| 1540 | struct sk_buff *skb) |
| 1541 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1542 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STOPPED_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1543 | complete(&ar->vdev_setup_done); |
| 1544 | } |
| 1545 | |
| 1546 | static void ath10k_wmi_event_peer_sta_kickout(struct ath10k *ar, |
| 1547 | struct sk_buff *skb) |
| 1548 | { |
Kalle Valo | 5a13e76 | 2014-01-20 11:01:46 +0200 | [diff] [blame] | 1549 | struct wmi_peer_sta_kickout_event *ev; |
| 1550 | struct ieee80211_sta *sta; |
| 1551 | |
| 1552 | ev = (struct wmi_peer_sta_kickout_event *)skb->data; |
| 1553 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1554 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event peer sta kickout %pM\n", |
Kalle Valo | 5a13e76 | 2014-01-20 11:01:46 +0200 | [diff] [blame] | 1555 | ev->peer_macaddr.addr); |
| 1556 | |
| 1557 | rcu_read_lock(); |
| 1558 | |
| 1559 | sta = ieee80211_find_sta_by_ifaddr(ar->hw, ev->peer_macaddr.addr, NULL); |
| 1560 | if (!sta) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1561 | ath10k_warn(ar, "Spurious quick kickout for STA %pM\n", |
Kalle Valo | 5a13e76 | 2014-01-20 11:01:46 +0200 | [diff] [blame] | 1562 | ev->peer_macaddr.addr); |
| 1563 | goto exit; |
| 1564 | } |
| 1565 | |
| 1566 | ieee80211_report_low_ack(sta, 10); |
| 1567 | |
| 1568 | exit: |
| 1569 | rcu_read_unlock(); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1570 | } |
| 1571 | |
| 1572 | /* |
| 1573 | * FIXME |
| 1574 | * |
| 1575 | * We don't report to mac80211 sleep state of connected |
| 1576 | * stations. Due to this mac80211 can't fill in TIM IE |
| 1577 | * correctly. |
| 1578 | * |
| 1579 | * I know of no way of getting nullfunc frames that contain |
| 1580 | * sleep transition from connected stations - these do not |
| 1581 | * seem to be sent from the target to the host. There also |
| 1582 | * doesn't seem to be a dedicated event for that. So the |
| 1583 | * only way left to do this would be to read tim_bitmap |
| 1584 | * during SWBA. |
| 1585 | * |
| 1586 | * We could probably try using tim_bitmap from SWBA to tell |
| 1587 | * mac80211 which stations are asleep and which are not. The |
| 1588 | * problem here is calling mac80211 functions so many times |
| 1589 | * could take too long and make us miss the time to submit |
| 1590 | * the beacon to the target. |
| 1591 | * |
| 1592 | * So as a workaround we try to extend the TIM IE if there |
| 1593 | * is unicast buffered for stations with aid > 7 and fill it |
| 1594 | * in ourselves. |
| 1595 | */ |
| 1596 | static void ath10k_wmi_update_tim(struct ath10k *ar, |
| 1597 | struct ath10k_vif *arvif, |
| 1598 | struct sk_buff *bcn, |
| 1599 | struct wmi_bcn_info *bcn_info) |
| 1600 | { |
| 1601 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)bcn->data; |
| 1602 | struct ieee80211_tim_ie *tim; |
| 1603 | u8 *ies, *ie; |
| 1604 | u8 ie_len, pvm_len; |
Kalle Valo | af762c0 | 2014-09-14 12:50:17 +0300 | [diff] [blame] | 1605 | __le32 t; |
| 1606 | u32 v; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1607 | |
| 1608 | /* if next SWBA has no tim_changed the tim_bitmap is garbage. |
| 1609 | * we must copy the bitmap upon change and reuse it later */ |
| 1610 | if (__le32_to_cpu(bcn_info->tim_info.tim_changed)) { |
| 1611 | int i; |
| 1612 | |
| 1613 | BUILD_BUG_ON(sizeof(arvif->u.ap.tim_bitmap) != |
| 1614 | sizeof(bcn_info->tim_info.tim_bitmap)); |
| 1615 | |
| 1616 | for (i = 0; i < sizeof(arvif->u.ap.tim_bitmap); i++) { |
Kalle Valo | af762c0 | 2014-09-14 12:50:17 +0300 | [diff] [blame] | 1617 | t = bcn_info->tim_info.tim_bitmap[i / 4]; |
| 1618 | v = __le32_to_cpu(t); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1619 | arvif->u.ap.tim_bitmap[i] = (v >> ((i % 4) * 8)) & 0xFF; |
| 1620 | } |
| 1621 | |
| 1622 | /* FW reports either length 0 or 16 |
| 1623 | * so we calculate this on our own */ |
| 1624 | arvif->u.ap.tim_len = 0; |
| 1625 | for (i = 0; i < sizeof(arvif->u.ap.tim_bitmap); i++) |
| 1626 | if (arvif->u.ap.tim_bitmap[i]) |
| 1627 | arvif->u.ap.tim_len = i; |
| 1628 | |
| 1629 | arvif->u.ap.tim_len++; |
| 1630 | } |
| 1631 | |
| 1632 | ies = bcn->data; |
| 1633 | ies += ieee80211_hdrlen(hdr->frame_control); |
| 1634 | ies += 12; /* fixed parameters */ |
| 1635 | |
| 1636 | ie = (u8 *)cfg80211_find_ie(WLAN_EID_TIM, ies, |
| 1637 | (u8 *)skb_tail_pointer(bcn) - ies); |
| 1638 | if (!ie) { |
Michal Kazior | 09af8f8 | 2013-07-05 16:15:08 +0300 | [diff] [blame] | 1639 | if (arvif->vdev_type != WMI_VDEV_TYPE_IBSS) |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1640 | ath10k_warn(ar, "no tim ie found;\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1641 | return; |
| 1642 | } |
| 1643 | |
| 1644 | tim = (void *)ie + 2; |
| 1645 | ie_len = ie[1]; |
| 1646 | pvm_len = ie_len - 3; /* exclude dtim count, dtim period, bmap ctl */ |
| 1647 | |
| 1648 | if (pvm_len < arvif->u.ap.tim_len) { |
| 1649 | int expand_size = sizeof(arvif->u.ap.tim_bitmap) - pvm_len; |
| 1650 | int move_size = skb_tail_pointer(bcn) - (ie + 2 + ie_len); |
| 1651 | void *next_ie = ie + 2 + ie_len; |
| 1652 | |
| 1653 | if (skb_put(bcn, expand_size)) { |
| 1654 | memmove(next_ie + expand_size, next_ie, move_size); |
| 1655 | |
| 1656 | ie[1] += expand_size; |
| 1657 | ie_len += expand_size; |
| 1658 | pvm_len += expand_size; |
| 1659 | } else { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1660 | ath10k_warn(ar, "tim expansion failed\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1661 | } |
| 1662 | } |
| 1663 | |
| 1664 | if (pvm_len > sizeof(arvif->u.ap.tim_bitmap)) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1665 | ath10k_warn(ar, "tim pvm length is too great (%d)\n", pvm_len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1666 | return; |
| 1667 | } |
| 1668 | |
| 1669 | tim->bitmap_ctrl = !!__le32_to_cpu(bcn_info->tim_info.tim_mcast); |
| 1670 | memcpy(tim->virtual_map, arvif->u.ap.tim_bitmap, pvm_len); |
| 1671 | |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 1672 | if (tim->dtim_count == 0) { |
| 1673 | ATH10K_SKB_CB(bcn)->bcn.dtim_zero = true; |
| 1674 | |
| 1675 | if (__le32_to_cpu(bcn_info->tim_info.tim_mcast) == 1) |
| 1676 | ATH10K_SKB_CB(bcn)->bcn.deliver_cab = true; |
| 1677 | } |
| 1678 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1679 | ath10k_dbg(ar, ATH10K_DBG_MGMT, "dtim %d/%d mcast %d pvmlen %d\n", |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1680 | tim->dtim_count, tim->dtim_period, |
| 1681 | tim->bitmap_ctrl, pvm_len); |
| 1682 | } |
| 1683 | |
| 1684 | static void ath10k_p2p_fill_noa_ie(u8 *data, u32 len, |
| 1685 | struct wmi_p2p_noa_info *noa) |
| 1686 | { |
| 1687 | struct ieee80211_p2p_noa_attr *noa_attr; |
| 1688 | u8 ctwindow_oppps = noa->ctwindow_oppps; |
| 1689 | u8 ctwindow = ctwindow_oppps >> WMI_P2P_OPPPS_CTWINDOW_OFFSET; |
| 1690 | bool oppps = !!(ctwindow_oppps & WMI_P2P_OPPPS_ENABLE_BIT); |
| 1691 | __le16 *noa_attr_len; |
| 1692 | u16 attr_len; |
| 1693 | u8 noa_descriptors = noa->num_descriptors; |
| 1694 | int i; |
| 1695 | |
| 1696 | /* P2P IE */ |
| 1697 | data[0] = WLAN_EID_VENDOR_SPECIFIC; |
| 1698 | data[1] = len - 2; |
| 1699 | data[2] = (WLAN_OUI_WFA >> 16) & 0xff; |
| 1700 | data[3] = (WLAN_OUI_WFA >> 8) & 0xff; |
| 1701 | data[4] = (WLAN_OUI_WFA >> 0) & 0xff; |
| 1702 | data[5] = WLAN_OUI_TYPE_WFA_P2P; |
| 1703 | |
| 1704 | /* NOA ATTR */ |
| 1705 | data[6] = IEEE80211_P2P_ATTR_ABSENCE_NOTICE; |
| 1706 | noa_attr_len = (__le16 *)&data[7]; /* 2 bytes */ |
| 1707 | noa_attr = (struct ieee80211_p2p_noa_attr *)&data[9]; |
| 1708 | |
| 1709 | noa_attr->index = noa->index; |
| 1710 | noa_attr->oppps_ctwindow = ctwindow; |
| 1711 | if (oppps) |
| 1712 | noa_attr->oppps_ctwindow |= IEEE80211_P2P_OPPPS_ENABLE_BIT; |
| 1713 | |
| 1714 | for (i = 0; i < noa_descriptors; i++) { |
| 1715 | noa_attr->desc[i].count = |
| 1716 | __le32_to_cpu(noa->descriptors[i].type_count); |
| 1717 | noa_attr->desc[i].duration = noa->descriptors[i].duration; |
| 1718 | noa_attr->desc[i].interval = noa->descriptors[i].interval; |
| 1719 | noa_attr->desc[i].start_time = noa->descriptors[i].start_time; |
| 1720 | } |
| 1721 | |
| 1722 | attr_len = 2; /* index + oppps_ctwindow */ |
| 1723 | attr_len += noa_descriptors * sizeof(struct ieee80211_p2p_noa_desc); |
| 1724 | *noa_attr_len = __cpu_to_le16(attr_len); |
| 1725 | } |
| 1726 | |
| 1727 | static u32 ath10k_p2p_calc_noa_ie_len(struct wmi_p2p_noa_info *noa) |
| 1728 | { |
| 1729 | u32 len = 0; |
| 1730 | u8 noa_descriptors = noa->num_descriptors; |
| 1731 | u8 opp_ps_info = noa->ctwindow_oppps; |
| 1732 | bool opps_enabled = !!(opp_ps_info & WMI_P2P_OPPPS_ENABLE_BIT); |
| 1733 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1734 | if (!noa_descriptors && !opps_enabled) |
| 1735 | return len; |
| 1736 | |
| 1737 | len += 1 + 1 + 4; /* EID + len + OUI */ |
| 1738 | len += 1 + 2; /* noa attr + attr len */ |
| 1739 | len += 1 + 1; /* index + oppps_ctwindow */ |
| 1740 | len += noa_descriptors * sizeof(struct ieee80211_p2p_noa_desc); |
| 1741 | |
| 1742 | return len; |
| 1743 | } |
| 1744 | |
| 1745 | static void ath10k_wmi_update_noa(struct ath10k *ar, struct ath10k_vif *arvif, |
| 1746 | struct sk_buff *bcn, |
| 1747 | struct wmi_bcn_info *bcn_info) |
| 1748 | { |
| 1749 | struct wmi_p2p_noa_info *noa = &bcn_info->p2p_noa_info; |
| 1750 | u8 *new_data, *old_data = arvif->u.ap.noa_data; |
| 1751 | u32 new_len; |
| 1752 | |
| 1753 | if (arvif->vdev_subtype != WMI_VDEV_SUBTYPE_P2P_GO) |
| 1754 | return; |
| 1755 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1756 | ath10k_dbg(ar, ATH10K_DBG_MGMT, "noa changed: %d\n", noa->changed); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1757 | if (noa->changed & WMI_P2P_NOA_CHANGED_BIT) { |
| 1758 | new_len = ath10k_p2p_calc_noa_ie_len(noa); |
| 1759 | if (!new_len) |
| 1760 | goto cleanup; |
| 1761 | |
| 1762 | new_data = kmalloc(new_len, GFP_ATOMIC); |
| 1763 | if (!new_data) |
| 1764 | goto cleanup; |
| 1765 | |
| 1766 | ath10k_p2p_fill_noa_ie(new_data, new_len, noa); |
| 1767 | |
| 1768 | spin_lock_bh(&ar->data_lock); |
| 1769 | arvif->u.ap.noa_data = new_data; |
| 1770 | arvif->u.ap.noa_len = new_len; |
| 1771 | spin_unlock_bh(&ar->data_lock); |
| 1772 | kfree(old_data); |
| 1773 | } |
| 1774 | |
| 1775 | if (arvif->u.ap.noa_data) |
| 1776 | if (!pskb_expand_head(bcn, 0, arvif->u.ap.noa_len, GFP_ATOMIC)) |
| 1777 | memcpy(skb_put(bcn, arvif->u.ap.noa_len), |
| 1778 | arvif->u.ap.noa_data, |
| 1779 | arvif->u.ap.noa_len); |
| 1780 | return; |
| 1781 | |
| 1782 | cleanup: |
| 1783 | spin_lock_bh(&ar->data_lock); |
| 1784 | arvif->u.ap.noa_data = NULL; |
| 1785 | arvif->u.ap.noa_len = 0; |
| 1786 | spin_unlock_bh(&ar->data_lock); |
| 1787 | kfree(old_data); |
| 1788 | } |
| 1789 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1790 | static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb) |
| 1791 | { |
| 1792 | struct wmi_host_swba_event *ev; |
| 1793 | u32 map; |
| 1794 | int i = -1; |
| 1795 | struct wmi_bcn_info *bcn_info; |
| 1796 | struct ath10k_vif *arvif; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1797 | struct sk_buff *bcn; |
Michal Kazior | 64badcb | 2014-09-18 11:18:02 +0300 | [diff] [blame] | 1798 | dma_addr_t paddr; |
Michal Kazior | 767d34f | 2014-02-27 18:50:03 +0200 | [diff] [blame] | 1799 | int ret, vdev_id = 0; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1800 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1801 | ev = (struct wmi_host_swba_event *)skb->data; |
| 1802 | map = __le32_to_cpu(ev->vdev_map); |
| 1803 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1804 | ath10k_dbg(ar, ATH10K_DBG_MGMT, "mgmt swba vdev_map 0x%x\n", |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1805 | ev->vdev_map); |
| 1806 | |
| 1807 | for (; map; map >>= 1, vdev_id++) { |
| 1808 | if (!(map & 0x1)) |
| 1809 | continue; |
| 1810 | |
| 1811 | i++; |
| 1812 | |
| 1813 | if (i >= WMI_MAX_AP_VDEV) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1814 | ath10k_warn(ar, "swba has corrupted vdev map\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1815 | break; |
| 1816 | } |
| 1817 | |
| 1818 | bcn_info = &ev->bcn_info[i]; |
| 1819 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1820 | ath10k_dbg(ar, ATH10K_DBG_MGMT, |
Kalle Valo | 7a8a396 | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 1821 | "mgmt event bcn_info %d tim_len %d mcast %d changed %d num_ps_pending %d bitmap 0x%08x%08x%08x%08x\n", |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1822 | i, |
| 1823 | __le32_to_cpu(bcn_info->tim_info.tim_len), |
| 1824 | __le32_to_cpu(bcn_info->tim_info.tim_mcast), |
| 1825 | __le32_to_cpu(bcn_info->tim_info.tim_changed), |
| 1826 | __le32_to_cpu(bcn_info->tim_info.tim_num_ps_pending), |
| 1827 | __le32_to_cpu(bcn_info->tim_info.tim_bitmap[3]), |
| 1828 | __le32_to_cpu(bcn_info->tim_info.tim_bitmap[2]), |
| 1829 | __le32_to_cpu(bcn_info->tim_info.tim_bitmap[1]), |
| 1830 | __le32_to_cpu(bcn_info->tim_info.tim_bitmap[0])); |
| 1831 | |
| 1832 | arvif = ath10k_get_arvif(ar, vdev_id); |
| 1833 | if (arvif == NULL) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1834 | ath10k_warn(ar, "no vif for vdev_id %d found\n", |
| 1835 | vdev_id); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1836 | continue; |
| 1837 | } |
| 1838 | |
Michal Kazior | c2df44b | 2014-01-23 11:38:26 +0100 | [diff] [blame] | 1839 | /* There are no completions for beacons so wait for next SWBA |
| 1840 | * before telling mac80211 to decrement CSA counter |
| 1841 | * |
| 1842 | * Once CSA counter is completed stop sending beacons until |
| 1843 | * actual channel switch is done */ |
| 1844 | if (arvif->vif->csa_active && |
| 1845 | ieee80211_csa_is_complete(arvif->vif)) { |
| 1846 | ieee80211_csa_finish(arvif->vif); |
| 1847 | continue; |
| 1848 | } |
| 1849 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1850 | bcn = ieee80211_beacon_get(ar->hw, arvif->vif); |
| 1851 | if (!bcn) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1852 | ath10k_warn(ar, "could not get mac80211 beacon\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1853 | continue; |
| 1854 | } |
| 1855 | |
Michal Kazior | 4b60455 | 2014-07-21 21:03:09 +0300 | [diff] [blame] | 1856 | ath10k_tx_h_seq_no(arvif->vif, bcn); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1857 | ath10k_wmi_update_tim(ar, arvif, bcn, bcn_info); |
| 1858 | ath10k_wmi_update_noa(ar, arvif, bcn, bcn_info); |
| 1859 | |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 1860 | spin_lock_bh(&ar->data_lock); |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 1861 | |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 1862 | if (arvif->beacon) { |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 1863 | if (!arvif->beacon_sent) |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1864 | ath10k_warn(ar, "SWBA overrun on vdev %d\n", |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 1865 | arvif->vdev_id); |
| 1866 | |
Michal Kazior | 64badcb | 2014-09-18 11:18:02 +0300 | [diff] [blame] | 1867 | ath10k_mac_vif_beacon_free(arvif); |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 1868 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1869 | |
Michal Kazior | 64badcb | 2014-09-18 11:18:02 +0300 | [diff] [blame] | 1870 | if (!arvif->beacon_buf) { |
| 1871 | paddr = dma_map_single(arvif->ar->dev, bcn->data, |
| 1872 | bcn->len, DMA_TO_DEVICE); |
| 1873 | ret = dma_mapping_error(arvif->ar->dev, paddr); |
| 1874 | if (ret) { |
| 1875 | ath10k_warn(ar, "failed to map beacon: %d\n", |
| 1876 | ret); |
| 1877 | dev_kfree_skb_any(bcn); |
| 1878 | goto skip; |
| 1879 | } |
| 1880 | |
| 1881 | ATH10K_SKB_CB(bcn)->paddr = paddr; |
| 1882 | } else { |
| 1883 | if (bcn->len > IEEE80211_MAX_FRAME_LEN) { |
| 1884 | ath10k_warn(ar, "trimming beacon %d -> %d bytes!\n", |
| 1885 | bcn->len, IEEE80211_MAX_FRAME_LEN); |
| 1886 | skb_trim(bcn, IEEE80211_MAX_FRAME_LEN); |
| 1887 | } |
| 1888 | memcpy(arvif->beacon_buf, bcn->data, bcn->len); |
| 1889 | ATH10K_SKB_CB(bcn)->paddr = arvif->beacon_paddr; |
Michal Kazior | 767d34f | 2014-02-27 18:50:03 +0200 | [diff] [blame] | 1890 | } |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 1891 | |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 1892 | arvif->beacon = bcn; |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 1893 | arvif->beacon_sent = false; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1894 | |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 1895 | ath10k_wmi_tx_beacon_nowait(arvif); |
Michal Kazior | 767d34f | 2014-02-27 18:50:03 +0200 | [diff] [blame] | 1896 | skip: |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 1897 | spin_unlock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1898 | } |
| 1899 | } |
| 1900 | |
| 1901 | static void ath10k_wmi_event_tbttoffset_update(struct ath10k *ar, |
| 1902 | struct sk_buff *skb) |
| 1903 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1904 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TBTTOFFSET_UPDATE_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1905 | } |
| 1906 | |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1907 | static void ath10k_dfs_radar_report(struct ath10k *ar, |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 1908 | const struct wmi_phyerr *phyerr, |
| 1909 | const struct phyerr_radar_report *rr, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1910 | u64 tsf) |
| 1911 | { |
| 1912 | u32 reg0, reg1, tsf32l; |
| 1913 | struct pulse_event pe; |
| 1914 | u64 tsf64; |
| 1915 | u8 rssi, width; |
| 1916 | |
| 1917 | reg0 = __le32_to_cpu(rr->reg0); |
| 1918 | reg1 = __le32_to_cpu(rr->reg1); |
| 1919 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1920 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1921 | "wmi phyerr radar report chirp %d max_width %d agc_total_gain %d pulse_delta_diff %d\n", |
| 1922 | MS(reg0, RADAR_REPORT_REG0_PULSE_IS_CHIRP), |
| 1923 | MS(reg0, RADAR_REPORT_REG0_PULSE_IS_MAX_WIDTH), |
| 1924 | MS(reg0, RADAR_REPORT_REG0_AGC_TOTAL_GAIN), |
| 1925 | MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_DIFF)); |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1926 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1927 | "wmi phyerr radar report pulse_delta_pean %d pulse_sidx %d fft_valid %d agc_mb_gain %d subchan_mask %d\n", |
| 1928 | MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_PEAK), |
| 1929 | MS(reg0, RADAR_REPORT_REG0_PULSE_SIDX), |
| 1930 | MS(reg1, RADAR_REPORT_REG1_PULSE_SRCH_FFT_VALID), |
| 1931 | MS(reg1, RADAR_REPORT_REG1_PULSE_AGC_MB_GAIN), |
| 1932 | MS(reg1, RADAR_REPORT_REG1_PULSE_SUBCHAN_MASK)); |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1933 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1934 | "wmi phyerr radar report pulse_tsf_offset 0x%X pulse_dur: %d\n", |
| 1935 | MS(reg1, RADAR_REPORT_REG1_PULSE_TSF_OFFSET), |
| 1936 | MS(reg1, RADAR_REPORT_REG1_PULSE_DUR)); |
| 1937 | |
| 1938 | if (!ar->dfs_detector) |
| 1939 | return; |
| 1940 | |
| 1941 | /* report event to DFS pattern detector */ |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 1942 | tsf32l = __le32_to_cpu(phyerr->tsf_timestamp); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1943 | tsf64 = tsf & (~0xFFFFFFFFULL); |
| 1944 | tsf64 |= tsf32l; |
| 1945 | |
| 1946 | width = MS(reg1, RADAR_REPORT_REG1_PULSE_DUR); |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 1947 | rssi = phyerr->rssi_combined; |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1948 | |
| 1949 | /* hardware store this as 8 bit signed value, |
| 1950 | * set to zero if negative number |
| 1951 | */ |
| 1952 | if (rssi & 0x80) |
| 1953 | rssi = 0; |
| 1954 | |
| 1955 | pe.ts = tsf64; |
| 1956 | pe.freq = ar->hw->conf.chandef.chan->center_freq; |
| 1957 | pe.width = width; |
| 1958 | pe.rssi = rssi; |
| 1959 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1960 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1961 | "dfs add pulse freq: %d, width: %d, rssi %d, tsf: %llX\n", |
| 1962 | pe.freq, pe.width, pe.rssi, pe.ts); |
| 1963 | |
| 1964 | ATH10K_DFS_STAT_INC(ar, pulses_detected); |
| 1965 | |
| 1966 | if (!ar->dfs_detector->add_pulse(ar->dfs_detector, &pe)) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1967 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1968 | "dfs no pulse pattern detected, yet\n"); |
| 1969 | return; |
| 1970 | } |
| 1971 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1972 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs radar detected\n"); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1973 | ATH10K_DFS_STAT_INC(ar, radar_detected); |
Marek Puzyniak | 7d9b40b | 2013-11-20 10:00:28 +0200 | [diff] [blame] | 1974 | |
| 1975 | /* Control radar events reporting in debugfs file |
| 1976 | dfs_block_radar_events */ |
| 1977 | if (ar->dfs_block_radar_events) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1978 | ath10k_info(ar, "DFS Radar detected, but ignored as requested\n"); |
Marek Puzyniak | 7d9b40b | 2013-11-20 10:00:28 +0200 | [diff] [blame] | 1979 | return; |
| 1980 | } |
| 1981 | |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1982 | ieee80211_radar_detected(ar->hw); |
| 1983 | } |
| 1984 | |
| 1985 | static int ath10k_dfs_fft_report(struct ath10k *ar, |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 1986 | const struct wmi_phyerr *phyerr, |
| 1987 | const struct phyerr_fft_report *fftr, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1988 | u64 tsf) |
| 1989 | { |
| 1990 | u32 reg0, reg1; |
| 1991 | u8 rssi, peak_mag; |
| 1992 | |
| 1993 | reg0 = __le32_to_cpu(fftr->reg0); |
| 1994 | reg1 = __le32_to_cpu(fftr->reg1); |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 1995 | rssi = phyerr->rssi_combined; |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1996 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1997 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1998 | "wmi phyerr fft report total_gain_db %d base_pwr_db %d fft_chn_idx %d peak_sidx %d\n", |
| 1999 | MS(reg0, SEARCH_FFT_REPORT_REG0_TOTAL_GAIN_DB), |
| 2000 | MS(reg0, SEARCH_FFT_REPORT_REG0_BASE_PWR_DB), |
| 2001 | MS(reg0, SEARCH_FFT_REPORT_REG0_FFT_CHN_IDX), |
| 2002 | MS(reg0, SEARCH_FFT_REPORT_REG0_PEAK_SIDX)); |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2003 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2004 | "wmi phyerr fft report rel_pwr_db %d avgpwr_db %d peak_mag %d num_store_bin %d\n", |
| 2005 | MS(reg1, SEARCH_FFT_REPORT_REG1_RELPWR_DB), |
| 2006 | MS(reg1, SEARCH_FFT_REPORT_REG1_AVGPWR_DB), |
| 2007 | MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG), |
| 2008 | MS(reg1, SEARCH_FFT_REPORT_REG1_NUM_STR_BINS_IB)); |
| 2009 | |
| 2010 | peak_mag = MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG); |
| 2011 | |
| 2012 | /* false event detection */ |
| 2013 | if (rssi == DFS_RSSI_POSSIBLY_FALSE && |
| 2014 | peak_mag < 2 * DFS_PEAK_MAG_THOLD_POSSIBLY_FALSE) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2015 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs false pulse detected\n"); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2016 | ATH10K_DFS_STAT_INC(ar, pulses_discarded); |
| 2017 | return -EINVAL; |
| 2018 | } |
| 2019 | |
| 2020 | return 0; |
| 2021 | } |
| 2022 | |
| 2023 | static void ath10k_wmi_event_dfs(struct ath10k *ar, |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2024 | const struct wmi_phyerr *phyerr, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2025 | u64 tsf) |
| 2026 | { |
| 2027 | int buf_len, tlv_len, res, i = 0; |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2028 | const struct phyerr_tlv *tlv; |
| 2029 | const struct phyerr_radar_report *rr; |
| 2030 | const struct phyerr_fft_report *fftr; |
| 2031 | const u8 *tlv_buf; |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2032 | |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2033 | buf_len = __le32_to_cpu(phyerr->buf_len); |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2034 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2035 | "wmi event dfs err_code %d rssi %d tsfl 0x%X tsf64 0x%llX len %d\n", |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2036 | phyerr->phy_err_code, phyerr->rssi_combined, |
| 2037 | __le32_to_cpu(phyerr->tsf_timestamp), tsf, buf_len); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2038 | |
| 2039 | /* Skip event if DFS disabled */ |
| 2040 | if (!config_enabled(CONFIG_ATH10K_DFS_CERTIFIED)) |
| 2041 | return; |
| 2042 | |
| 2043 | ATH10K_DFS_STAT_INC(ar, pulses_total); |
| 2044 | |
| 2045 | while (i < buf_len) { |
| 2046 | if (i + sizeof(*tlv) > buf_len) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2047 | ath10k_warn(ar, "too short buf for tlv header (%d)\n", |
| 2048 | i); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2049 | return; |
| 2050 | } |
| 2051 | |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2052 | tlv = (struct phyerr_tlv *)&phyerr->buf[i]; |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2053 | tlv_len = __le16_to_cpu(tlv->len); |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2054 | tlv_buf = &phyerr->buf[i + sizeof(*tlv)]; |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2055 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2056 | "wmi event dfs tlv_len %d tlv_tag 0x%02X tlv_sig 0x%02X\n", |
| 2057 | tlv_len, tlv->tag, tlv->sig); |
| 2058 | |
| 2059 | switch (tlv->tag) { |
| 2060 | case PHYERR_TLV_TAG_RADAR_PULSE_SUMMARY: |
| 2061 | if (i + sizeof(*tlv) + sizeof(*rr) > buf_len) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2062 | ath10k_warn(ar, "too short radar pulse summary (%d)\n", |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2063 | i); |
| 2064 | return; |
| 2065 | } |
| 2066 | |
| 2067 | rr = (struct phyerr_radar_report *)tlv_buf; |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2068 | ath10k_dfs_radar_report(ar, phyerr, rr, tsf); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2069 | break; |
| 2070 | case PHYERR_TLV_TAG_SEARCH_FFT_REPORT: |
| 2071 | if (i + sizeof(*tlv) + sizeof(*fftr) > buf_len) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2072 | ath10k_warn(ar, "too short fft report (%d)\n", |
| 2073 | i); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2074 | return; |
| 2075 | } |
| 2076 | |
| 2077 | fftr = (struct phyerr_fft_report *)tlv_buf; |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2078 | res = ath10k_dfs_fft_report(ar, phyerr, fftr, tsf); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2079 | if (res) |
| 2080 | return; |
| 2081 | break; |
| 2082 | } |
| 2083 | |
| 2084 | i += sizeof(*tlv) + tlv_len; |
| 2085 | } |
| 2086 | } |
| 2087 | |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 2088 | static void |
| 2089 | ath10k_wmi_event_spectral_scan(struct ath10k *ar, |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2090 | const struct wmi_phyerr *phyerr, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 2091 | u64 tsf) |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2092 | { |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 2093 | int buf_len, tlv_len, res, i = 0; |
| 2094 | struct phyerr_tlv *tlv; |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2095 | const void *tlv_buf; |
| 2096 | const struct phyerr_fft_report *fftr; |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 2097 | size_t fftr_len; |
| 2098 | |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2099 | buf_len = __le32_to_cpu(phyerr->buf_len); |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 2100 | |
| 2101 | while (i < buf_len) { |
| 2102 | if (i + sizeof(*tlv) > buf_len) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2103 | ath10k_warn(ar, "failed to parse phyerr tlv header at byte %d\n", |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 2104 | i); |
| 2105 | return; |
| 2106 | } |
| 2107 | |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2108 | tlv = (struct phyerr_tlv *)&phyerr->buf[i]; |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 2109 | tlv_len = __le16_to_cpu(tlv->len); |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2110 | tlv_buf = &phyerr->buf[i + sizeof(*tlv)]; |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 2111 | |
| 2112 | if (i + sizeof(*tlv) + tlv_len > buf_len) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2113 | ath10k_warn(ar, "failed to parse phyerr tlv payload at byte %d\n", |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 2114 | i); |
| 2115 | return; |
| 2116 | } |
| 2117 | |
| 2118 | switch (tlv->tag) { |
| 2119 | case PHYERR_TLV_TAG_SEARCH_FFT_REPORT: |
| 2120 | if (sizeof(*fftr) > tlv_len) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2121 | ath10k_warn(ar, "failed to parse fft report at byte %d\n", |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 2122 | i); |
| 2123 | return; |
| 2124 | } |
| 2125 | |
| 2126 | fftr_len = tlv_len - sizeof(*fftr); |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2127 | fftr = tlv_buf; |
| 2128 | res = ath10k_spectral_process_fft(ar, phyerr, |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 2129 | fftr, fftr_len, |
| 2130 | tsf); |
| 2131 | if (res < 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2132 | ath10k_warn(ar, "failed to process fft report: %d\n", |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 2133 | res); |
| 2134 | return; |
| 2135 | } |
| 2136 | break; |
| 2137 | } |
| 2138 | |
| 2139 | i += sizeof(*tlv) + tlv_len; |
| 2140 | } |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2141 | } |
| 2142 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2143 | static void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb) |
| 2144 | { |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2145 | const struct wmi_phyerr_event *ev; |
| 2146 | const struct wmi_phyerr *phyerr; |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2147 | u32 count, i, buf_len, phy_err_code; |
| 2148 | u64 tsf; |
| 2149 | int left_len = skb->len; |
| 2150 | |
| 2151 | ATH10K_DFS_STAT_INC(ar, phy_errors); |
| 2152 | |
| 2153 | /* Check if combined event available */ |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2154 | if (left_len < sizeof(*ev)) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2155 | ath10k_warn(ar, "wmi phyerr combined event wrong len\n"); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2156 | return; |
| 2157 | } |
| 2158 | |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2159 | left_len -= sizeof(*ev); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2160 | |
| 2161 | /* Check number of included events */ |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2162 | ev = (const struct wmi_phyerr_event *)skb->data; |
| 2163 | count = __le32_to_cpu(ev->num_phyerrs); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2164 | |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2165 | tsf = __le32_to_cpu(ev->tsf_u32); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2166 | tsf <<= 32; |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2167 | tsf |= __le32_to_cpu(ev->tsf_l32); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2168 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2169 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2170 | "wmi event phyerr count %d tsf64 0x%llX\n", |
| 2171 | count, tsf); |
| 2172 | |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2173 | phyerr = ev->phyerrs; |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2174 | for (i = 0; i < count; i++) { |
| 2175 | /* Check if we can read event header */ |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2176 | if (left_len < sizeof(*phyerr)) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2177 | ath10k_warn(ar, "single event (%d) wrong head len\n", |
| 2178 | i); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2179 | return; |
| 2180 | } |
| 2181 | |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2182 | left_len -= sizeof(*phyerr); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2183 | |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2184 | buf_len = __le32_to_cpu(phyerr->buf_len); |
| 2185 | phy_err_code = phyerr->phy_err_code; |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2186 | |
| 2187 | if (left_len < buf_len) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2188 | ath10k_warn(ar, "single event (%d) wrong buf len\n", i); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2189 | return; |
| 2190 | } |
| 2191 | |
| 2192 | left_len -= buf_len; |
| 2193 | |
| 2194 | switch (phy_err_code) { |
| 2195 | case PHY_ERROR_RADAR: |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2196 | ath10k_wmi_event_dfs(ar, phyerr, tsf); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2197 | break; |
| 2198 | case PHY_ERROR_SPECTRAL_SCAN: |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2199 | ath10k_wmi_event_spectral_scan(ar, phyerr, tsf); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2200 | break; |
| 2201 | case PHY_ERROR_FALSE_RADAR_EXT: |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2202 | ath10k_wmi_event_dfs(ar, phyerr, tsf); |
| 2203 | ath10k_wmi_event_spectral_scan(ar, phyerr, tsf); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2204 | break; |
| 2205 | default: |
| 2206 | break; |
| 2207 | } |
| 2208 | |
Michal Kazior | 2332d0a | 2014-09-18 15:21:25 +0200 | [diff] [blame] | 2209 | phyerr = (void *)phyerr + sizeof(*phyerr) + buf_len; |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2210 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2211 | } |
| 2212 | |
| 2213 | static void ath10k_wmi_event_roam(struct ath10k *ar, struct sk_buff *skb) |
| 2214 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2215 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_ROAM_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2216 | } |
| 2217 | |
| 2218 | static void ath10k_wmi_event_profile_match(struct ath10k *ar, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 2219 | struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2220 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2221 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PROFILE_MATCH\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2222 | } |
| 2223 | |
| 2224 | static void ath10k_wmi_event_debug_print(struct ath10k *ar, |
Kalle Valo | 2fe5288 | 2014-01-03 12:59:20 +0200 | [diff] [blame] | 2225 | struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2226 | { |
Kalle Valo | 2fe5288 | 2014-01-03 12:59:20 +0200 | [diff] [blame] | 2227 | char buf[101], c; |
| 2228 | int i; |
| 2229 | |
| 2230 | for (i = 0; i < sizeof(buf) - 1; i++) { |
| 2231 | if (i >= skb->len) |
| 2232 | break; |
| 2233 | |
| 2234 | c = skb->data[i]; |
| 2235 | |
| 2236 | if (c == '\0') |
| 2237 | break; |
| 2238 | |
| 2239 | if (isascii(c) && isprint(c)) |
| 2240 | buf[i] = c; |
| 2241 | else |
| 2242 | buf[i] = '.'; |
| 2243 | } |
| 2244 | |
| 2245 | if (i == sizeof(buf) - 1) |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2246 | ath10k_warn(ar, "wmi debug print truncated: %d\n", skb->len); |
Kalle Valo | 2fe5288 | 2014-01-03 12:59:20 +0200 | [diff] [blame] | 2247 | |
| 2248 | /* for some reason the debug prints end with \n, remove that */ |
| 2249 | if (skb->data[i - 1] == '\n') |
| 2250 | i--; |
| 2251 | |
| 2252 | /* the last byte is always reserved for the null character */ |
| 2253 | buf[i] = '\0'; |
| 2254 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2255 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event debug print '%s'\n", buf); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2256 | } |
| 2257 | |
| 2258 | static void ath10k_wmi_event_pdev_qvit(struct ath10k *ar, struct sk_buff *skb) |
| 2259 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2260 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_QVIT_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2261 | } |
| 2262 | |
| 2263 | static void ath10k_wmi_event_wlan_profile_data(struct ath10k *ar, |
| 2264 | struct sk_buff *skb) |
| 2265 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2266 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_WLAN_PROFILE_DATA_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2267 | } |
| 2268 | |
| 2269 | static void ath10k_wmi_event_rtt_measurement_report(struct ath10k *ar, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 2270 | struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2271 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2272 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_MEASUREMENT_REPORT_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2273 | } |
| 2274 | |
| 2275 | static void ath10k_wmi_event_tsf_measurement_report(struct ath10k *ar, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 2276 | struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2277 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2278 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TSF_MEASUREMENT_REPORT_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2279 | } |
| 2280 | |
| 2281 | static void ath10k_wmi_event_rtt_error_report(struct ath10k *ar, |
| 2282 | struct sk_buff *skb) |
| 2283 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2284 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_ERROR_REPORT_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2285 | } |
| 2286 | |
| 2287 | static void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, |
| 2288 | struct sk_buff *skb) |
| 2289 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2290 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_WOW_WAKEUP_HOST_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2291 | } |
| 2292 | |
| 2293 | static void ath10k_wmi_event_dcs_interference(struct ath10k *ar, |
| 2294 | struct sk_buff *skb) |
| 2295 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2296 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_DCS_INTERFERENCE_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2297 | } |
| 2298 | |
| 2299 | static void ath10k_wmi_event_pdev_tpc_config(struct ath10k *ar, |
| 2300 | struct sk_buff *skb) |
| 2301 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2302 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_TPC_CONFIG_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2303 | } |
| 2304 | |
| 2305 | static void ath10k_wmi_event_pdev_ftm_intg(struct ath10k *ar, |
| 2306 | struct sk_buff *skb) |
| 2307 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2308 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_FTM_INTG_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2309 | } |
| 2310 | |
| 2311 | static void ath10k_wmi_event_gtk_offload_status(struct ath10k *ar, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 2312 | struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2313 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2314 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_OFFLOAD_STATUS_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2315 | } |
| 2316 | |
| 2317 | static void ath10k_wmi_event_gtk_rekey_fail(struct ath10k *ar, |
| 2318 | struct sk_buff *skb) |
| 2319 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2320 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_REKEY_FAIL_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2321 | } |
| 2322 | |
| 2323 | static void ath10k_wmi_event_delba_complete(struct ath10k *ar, |
| 2324 | struct sk_buff *skb) |
| 2325 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2326 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_DELBA_COMPLETE_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2327 | } |
| 2328 | |
| 2329 | static void ath10k_wmi_event_addba_complete(struct ath10k *ar, |
| 2330 | struct sk_buff *skb) |
| 2331 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2332 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_ADDBA_COMPLETE_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2333 | } |
| 2334 | |
| 2335 | static void ath10k_wmi_event_vdev_install_key_complete(struct ath10k *ar, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 2336 | struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2337 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2338 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2339 | } |
| 2340 | |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2341 | static void ath10k_wmi_event_inst_rssi_stats(struct ath10k *ar, |
| 2342 | struct sk_buff *skb) |
| 2343 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2344 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_INST_RSSI_STATS_EVENTID\n"); |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2345 | } |
| 2346 | |
| 2347 | static void ath10k_wmi_event_vdev_standby_req(struct ath10k *ar, |
| 2348 | struct sk_buff *skb) |
| 2349 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2350 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STANDBY_REQ_EVENTID\n"); |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2351 | } |
| 2352 | |
| 2353 | static void ath10k_wmi_event_vdev_resume_req(struct ath10k *ar, |
| 2354 | struct sk_buff *skb) |
| 2355 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2356 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_RESUME_REQ_EVENTID\n"); |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2357 | } |
| 2358 | |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2359 | static int ath10k_wmi_alloc_host_mem(struct ath10k *ar, u32 req_id, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 2360 | u32 num_units, u32 unit_len) |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2361 | { |
| 2362 | dma_addr_t paddr; |
| 2363 | u32 pool_size; |
| 2364 | int idx = ar->wmi.num_mem_chunks; |
| 2365 | |
| 2366 | pool_size = num_units * round_up(unit_len, 4); |
| 2367 | |
| 2368 | if (!pool_size) |
| 2369 | return -EINVAL; |
| 2370 | |
| 2371 | ar->wmi.mem_chunks[idx].vaddr = dma_alloc_coherent(ar->dev, |
| 2372 | pool_size, |
| 2373 | &paddr, |
| 2374 | GFP_ATOMIC); |
| 2375 | if (!ar->wmi.mem_chunks[idx].vaddr) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2376 | ath10k_warn(ar, "failed to allocate memory chunk\n"); |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2377 | return -ENOMEM; |
| 2378 | } |
| 2379 | |
| 2380 | memset(ar->wmi.mem_chunks[idx].vaddr, 0, pool_size); |
| 2381 | |
| 2382 | ar->wmi.mem_chunks[idx].paddr = paddr; |
| 2383 | ar->wmi.mem_chunks[idx].len = pool_size; |
| 2384 | ar->wmi.mem_chunks[idx].req_id = req_id; |
| 2385 | ar->wmi.num_mem_chunks++; |
| 2386 | |
| 2387 | return 0; |
| 2388 | } |
| 2389 | |
Michal Kazior | 5c01aa3d | 2014-09-18 15:21:24 +0200 | [diff] [blame] | 2390 | static int ath10k_wmi_main_pull_svc_rdy_ev(struct sk_buff *skb, |
| 2391 | struct wmi_svc_rdy_ev_arg *arg) |
| 2392 | { |
| 2393 | struct wmi_service_ready_event *ev; |
| 2394 | size_t i, n; |
| 2395 | |
| 2396 | if (skb->len < sizeof(*ev)) |
| 2397 | return -EPROTO; |
| 2398 | |
| 2399 | ev = (void *)skb->data; |
| 2400 | skb_pull(skb, sizeof(*ev)); |
| 2401 | arg->min_tx_power = ev->hw_min_tx_power; |
| 2402 | arg->max_tx_power = ev->hw_max_tx_power; |
| 2403 | arg->ht_cap = ev->ht_cap_info; |
| 2404 | arg->vht_cap = ev->vht_cap_info; |
| 2405 | arg->sw_ver0 = ev->sw_version; |
| 2406 | arg->sw_ver1 = ev->sw_version_1; |
| 2407 | arg->phy_capab = ev->phy_capability; |
| 2408 | arg->num_rf_chains = ev->num_rf_chains; |
| 2409 | arg->eeprom_rd = ev->hal_reg_capabilities.eeprom_rd; |
| 2410 | arg->num_mem_reqs = ev->num_mem_reqs; |
| 2411 | arg->service_map = ev->wmi_service_bitmap; |
| 2412 | |
| 2413 | n = min_t(size_t, __le32_to_cpu(arg->num_mem_reqs), |
| 2414 | ARRAY_SIZE(arg->mem_reqs)); |
| 2415 | for (i = 0; i < n; i++) |
| 2416 | arg->mem_reqs[i] = &ev->mem_reqs[i]; |
| 2417 | |
| 2418 | if (skb->len < |
| 2419 | __le32_to_cpu(arg->num_mem_reqs) * sizeof(arg->mem_reqs[0])) |
| 2420 | return -EPROTO; |
| 2421 | |
| 2422 | return 0; |
| 2423 | } |
| 2424 | |
| 2425 | static int ath10k_wmi_10x_pull_svc_rdy_ev(struct sk_buff *skb, |
| 2426 | struct wmi_svc_rdy_ev_arg *arg) |
| 2427 | { |
| 2428 | struct wmi_10x_service_ready_event *ev; |
| 2429 | int i, n; |
| 2430 | |
| 2431 | if (skb->len < sizeof(*ev)) |
| 2432 | return -EPROTO; |
| 2433 | |
| 2434 | ev = (void *)skb->data; |
| 2435 | skb_pull(skb, sizeof(*ev)); |
| 2436 | arg->min_tx_power = ev->hw_min_tx_power; |
| 2437 | arg->max_tx_power = ev->hw_max_tx_power; |
| 2438 | arg->ht_cap = ev->ht_cap_info; |
| 2439 | arg->vht_cap = ev->vht_cap_info; |
| 2440 | arg->sw_ver0 = ev->sw_version; |
| 2441 | arg->phy_capab = ev->phy_capability; |
| 2442 | arg->num_rf_chains = ev->num_rf_chains; |
| 2443 | arg->eeprom_rd = ev->hal_reg_capabilities.eeprom_rd; |
| 2444 | arg->num_mem_reqs = ev->num_mem_reqs; |
| 2445 | arg->service_map = ev->wmi_service_bitmap; |
| 2446 | |
| 2447 | n = min_t(size_t, __le32_to_cpu(arg->num_mem_reqs), |
| 2448 | ARRAY_SIZE(arg->mem_reqs)); |
| 2449 | for (i = 0; i < n; i++) |
| 2450 | arg->mem_reqs[i] = &ev->mem_reqs[i]; |
| 2451 | |
| 2452 | if (skb->len < |
| 2453 | __le32_to_cpu(arg->num_mem_reqs) * sizeof(arg->mem_reqs[0])) |
| 2454 | return -EPROTO; |
| 2455 | |
| 2456 | return 0; |
| 2457 | } |
| 2458 | |
Michal Kazior | b34d2b3 | 2014-09-18 15:21:26 +0200 | [diff] [blame] | 2459 | static void ath10k_wmi_event_service_ready(struct ath10k *ar, |
| 2460 | struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2461 | { |
Michal Kazior | 5c01aa3d | 2014-09-18 15:21:24 +0200 | [diff] [blame] | 2462 | struct wmi_svc_rdy_ev_arg arg = {}; |
| 2463 | u32 num_units, req_id, unit_size, num_mem_reqs, num_unit_info, i; |
Michal Kazior | c4f8c83 | 2014-09-04 10:18:32 +0200 | [diff] [blame] | 2464 | DECLARE_BITMAP(svc_bmap, WMI_SERVICE_MAX) = {}; |
Michal Kazior | 5c01aa3d | 2014-09-18 15:21:24 +0200 | [diff] [blame] | 2465 | int ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2466 | |
Michal Kazior | 5c01aa3d | 2014-09-18 15:21:24 +0200 | [diff] [blame] | 2467 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { |
| 2468 | ret = ath10k_wmi_10x_pull_svc_rdy_ev(skb, &arg); |
| 2469 | wmi_10x_svc_map(arg.service_map, svc_bmap); |
| 2470 | } else { |
| 2471 | ret = ath10k_wmi_main_pull_svc_rdy_ev(skb, &arg); |
| 2472 | wmi_main_svc_map(arg.service_map, svc_bmap); |
| 2473 | } |
| 2474 | |
| 2475 | if (ret) { |
| 2476 | ath10k_warn(ar, "failed to parse service ready: %d\n", ret); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2477 | return; |
| 2478 | } |
| 2479 | |
Michal Kazior | 5c01aa3d | 2014-09-18 15:21:24 +0200 | [diff] [blame] | 2480 | ar->hw_min_tx_power = __le32_to_cpu(arg.min_tx_power); |
| 2481 | ar->hw_max_tx_power = __le32_to_cpu(arg.max_tx_power); |
| 2482 | ar->ht_cap_info = __le32_to_cpu(arg.ht_cap); |
| 2483 | ar->vht_cap_info = __le32_to_cpu(arg.vht_cap); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2484 | ar->fw_version_major = |
Michal Kazior | 5c01aa3d | 2014-09-18 15:21:24 +0200 | [diff] [blame] | 2485 | (__le32_to_cpu(arg.sw_ver0) & 0xff000000) >> 24; |
| 2486 | ar->fw_version_minor = (__le32_to_cpu(arg.sw_ver0) & 0x00ffffff); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2487 | ar->fw_version_release = |
Michal Kazior | 5c01aa3d | 2014-09-18 15:21:24 +0200 | [diff] [blame] | 2488 | (__le32_to_cpu(arg.sw_ver1) & 0xffff0000) >> 16; |
| 2489 | ar->fw_version_build = (__le32_to_cpu(arg.sw_ver1) & 0x0000ffff); |
| 2490 | ar->phy_capability = __le32_to_cpu(arg.phy_capab); |
| 2491 | ar->num_rf_chains = __le32_to_cpu(arg.num_rf_chains); |
| 2492 | ar->ath_common.regulatory.current_rd = __le32_to_cpu(arg.eeprom_rd); |
| 2493 | |
| 2494 | ath10k_debug_read_service_map(ar, svc_bmap, sizeof(svc_bmap)); |
| 2495 | ath10k_dbg_dump(ar, ATH10K_DBG_WMI, NULL, "wmi svc: ", |
| 2496 | arg.service_map, sizeof(arg.service_map)); |
Michal Kazior | 8865bee4 | 2013-07-24 12:36:46 +0200 | [diff] [blame] | 2497 | |
Kalle Valo | 1a22243 | 2013-09-27 19:55:07 +0300 | [diff] [blame] | 2498 | /* only manually set fw features when not using FW IE format */ |
| 2499 | if (ar->fw_api == 1 && ar->fw_version_build > 636) |
Michal Kazior | 0d9b043 | 2013-08-09 10:13:33 +0200 | [diff] [blame] | 2500 | set_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features); |
| 2501 | |
Michal Kazior | 8865bee4 | 2013-07-24 12:36:46 +0200 | [diff] [blame] | 2502 | if (ar->num_rf_chains > WMI_MAX_SPATIAL_STREAM) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2503 | ath10k_warn(ar, "hardware advertises support for more spatial streams than it should (%d > %d)\n", |
Michal Kazior | 8865bee4 | 2013-07-24 12:36:46 +0200 | [diff] [blame] | 2504 | ar->num_rf_chains, WMI_MAX_SPATIAL_STREAM); |
| 2505 | ar->num_rf_chains = WMI_MAX_SPATIAL_STREAM; |
| 2506 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2507 | |
Michal Kazior | fdb959c | 2014-09-18 15:21:19 +0200 | [diff] [blame] | 2508 | ar->supp_tx_chainmask = (1 << ar->num_rf_chains) - 1; |
| 2509 | ar->supp_rx_chainmask = (1 << ar->num_rf_chains) - 1; |
| 2510 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2511 | if (strlen(ar->hw->wiphy->fw_version) == 0) { |
| 2512 | snprintf(ar->hw->wiphy->fw_version, |
| 2513 | sizeof(ar->hw->wiphy->fw_version), |
| 2514 | "%u.%u.%u.%u", |
| 2515 | ar->fw_version_major, |
| 2516 | ar->fw_version_minor, |
| 2517 | ar->fw_version_release, |
| 2518 | ar->fw_version_build); |
| 2519 | } |
| 2520 | |
Michal Kazior | 5c01aa3d | 2014-09-18 15:21:24 +0200 | [diff] [blame] | 2521 | num_mem_reqs = __le32_to_cpu(arg.num_mem_reqs); |
| 2522 | if (num_mem_reqs > WMI_MAX_MEM_REQS) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2523 | ath10k_warn(ar, "requested memory chunks number (%d) exceeds the limit\n", |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2524 | num_mem_reqs); |
| 2525 | return; |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 2526 | } |
| 2527 | |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2528 | for (i = 0; i < num_mem_reqs; ++i) { |
Michal Kazior | 5c01aa3d | 2014-09-18 15:21:24 +0200 | [diff] [blame] | 2529 | req_id = __le32_to_cpu(arg.mem_reqs[i]->req_id); |
| 2530 | num_units = __le32_to_cpu(arg.mem_reqs[i]->num_units); |
| 2531 | unit_size = __le32_to_cpu(arg.mem_reqs[i]->unit_size); |
| 2532 | num_unit_info = __le32_to_cpu(arg.mem_reqs[i]->num_unit_info); |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2533 | |
| 2534 | if (num_unit_info & NUM_UNITS_IS_NUM_PEERS) |
| 2535 | /* number of units to allocate is number of |
| 2536 | * peers, 1 extra for self peer on target */ |
| 2537 | /* this needs to be tied, host and target |
| 2538 | * can get out of sync */ |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 2539 | num_units = TARGET_10X_NUM_PEERS + 1; |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2540 | else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS) |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 2541 | num_units = TARGET_10X_NUM_VDEVS + 1; |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2542 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2543 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2544 | "wmi mem_req_id %d num_units %d num_unit_info %d unit size %d actual units %d\n", |
| 2545 | req_id, |
Michal Kazior | 5c01aa3d | 2014-09-18 15:21:24 +0200 | [diff] [blame] | 2546 | __le32_to_cpu(arg.mem_reqs[i]->num_units), |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2547 | num_unit_info, |
| 2548 | unit_size, |
| 2549 | num_units); |
| 2550 | |
| 2551 | ret = ath10k_wmi_alloc_host_mem(ar, req_id, num_units, |
| 2552 | unit_size); |
| 2553 | if (ret) |
| 2554 | return; |
| 2555 | } |
| 2556 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2557 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Michal Kazior | 5c01aa3d | 2014-09-18 15:21:24 +0200 | [diff] [blame] | 2558 | "wmi event service ready min_tx_power 0x%08x max_tx_power 0x%08x ht_cap 0x%08x vht_cap 0x%08x sw_ver0 0x%08x sw_ver1 0x%08x phy_capab 0x%08x num_rf_chains 0x%08x eeprom_rd 0x%08x num_mem_reqs 0x%08x\n", |
| 2559 | __le32_to_cpu(arg.min_tx_power), |
| 2560 | __le32_to_cpu(arg.max_tx_power), |
| 2561 | __le32_to_cpu(arg.ht_cap), |
| 2562 | __le32_to_cpu(arg.vht_cap), |
| 2563 | __le32_to_cpu(arg.sw_ver0), |
| 2564 | __le32_to_cpu(arg.sw_ver1), |
| 2565 | __le32_to_cpu(arg.phy_capab), |
| 2566 | __le32_to_cpu(arg.num_rf_chains), |
| 2567 | __le32_to_cpu(arg.eeprom_rd), |
| 2568 | __le32_to_cpu(arg.num_mem_reqs)); |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 2569 | |
| 2570 | complete(&ar->wmi.service_ready); |
| 2571 | } |
| 2572 | |
Michal Kazior | b34d2b3 | 2014-09-18 15:21:26 +0200 | [diff] [blame] | 2573 | static int ath10k_wmi_event_ready(struct ath10k *ar, struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2574 | { |
| 2575 | struct wmi_ready_event *ev = (struct wmi_ready_event *)skb->data; |
| 2576 | |
| 2577 | if (WARN_ON(skb->len < sizeof(*ev))) |
| 2578 | return -EINVAL; |
| 2579 | |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 2580 | ether_addr_copy(ar->mac_addr, ev->mac_addr.addr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2581 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2582 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Ben Greear | 2c34752 | 2014-02-05 13:58:32 -0800 | [diff] [blame] | 2583 | "wmi event ready sw_version %u abi_version %u mac_addr %pM status %d skb->len %i ev-sz %zu\n", |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2584 | __le32_to_cpu(ev->sw_version), |
| 2585 | __le32_to_cpu(ev->abi_version), |
| 2586 | ev->mac_addr.addr, |
Ben Greear | 2c34752 | 2014-02-05 13:58:32 -0800 | [diff] [blame] | 2587 | __le32_to_cpu(ev->status), skb->len, sizeof(*ev)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2588 | |
| 2589 | complete(&ar->wmi.unified_ready); |
| 2590 | return 0; |
| 2591 | } |
| 2592 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2593 | static void ath10k_wmi_main_process_rx(struct ath10k *ar, struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2594 | { |
| 2595 | struct wmi_cmd_hdr *cmd_hdr; |
| 2596 | enum wmi_event_id id; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2597 | |
| 2598 | cmd_hdr = (struct wmi_cmd_hdr *)skb->data; |
| 2599 | id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID); |
| 2600 | |
| 2601 | if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL) |
| 2602 | return; |
| 2603 | |
Michal Kazior | d35a6c1 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 2604 | trace_ath10k_wmi_event(ar, id, skb->data, skb->len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2605 | |
| 2606 | switch (id) { |
| 2607 | case WMI_MGMT_RX_EVENTID: |
| 2608 | ath10k_wmi_event_mgmt_rx(ar, skb); |
| 2609 | /* mgmt_rx() owns the skb now! */ |
| 2610 | return; |
| 2611 | case WMI_SCAN_EVENTID: |
| 2612 | ath10k_wmi_event_scan(ar, skb); |
| 2613 | break; |
| 2614 | case WMI_CHAN_INFO_EVENTID: |
| 2615 | ath10k_wmi_event_chan_info(ar, skb); |
| 2616 | break; |
| 2617 | case WMI_ECHO_EVENTID: |
| 2618 | ath10k_wmi_event_echo(ar, skb); |
| 2619 | break; |
| 2620 | case WMI_DEBUG_MESG_EVENTID: |
| 2621 | ath10k_wmi_event_debug_mesg(ar, skb); |
| 2622 | break; |
| 2623 | case WMI_UPDATE_STATS_EVENTID: |
| 2624 | ath10k_wmi_event_update_stats(ar, skb); |
| 2625 | break; |
| 2626 | case WMI_VDEV_START_RESP_EVENTID: |
| 2627 | ath10k_wmi_event_vdev_start_resp(ar, skb); |
| 2628 | break; |
| 2629 | case WMI_VDEV_STOPPED_EVENTID: |
| 2630 | ath10k_wmi_event_vdev_stopped(ar, skb); |
| 2631 | break; |
| 2632 | case WMI_PEER_STA_KICKOUT_EVENTID: |
| 2633 | ath10k_wmi_event_peer_sta_kickout(ar, skb); |
| 2634 | break; |
| 2635 | case WMI_HOST_SWBA_EVENTID: |
| 2636 | ath10k_wmi_event_host_swba(ar, skb); |
| 2637 | break; |
| 2638 | case WMI_TBTTOFFSET_UPDATE_EVENTID: |
| 2639 | ath10k_wmi_event_tbttoffset_update(ar, skb); |
| 2640 | break; |
| 2641 | case WMI_PHYERR_EVENTID: |
| 2642 | ath10k_wmi_event_phyerr(ar, skb); |
| 2643 | break; |
| 2644 | case WMI_ROAM_EVENTID: |
| 2645 | ath10k_wmi_event_roam(ar, skb); |
| 2646 | break; |
| 2647 | case WMI_PROFILE_MATCH: |
| 2648 | ath10k_wmi_event_profile_match(ar, skb); |
| 2649 | break; |
| 2650 | case WMI_DEBUG_PRINT_EVENTID: |
| 2651 | ath10k_wmi_event_debug_print(ar, skb); |
| 2652 | break; |
| 2653 | case WMI_PDEV_QVIT_EVENTID: |
| 2654 | ath10k_wmi_event_pdev_qvit(ar, skb); |
| 2655 | break; |
| 2656 | case WMI_WLAN_PROFILE_DATA_EVENTID: |
| 2657 | ath10k_wmi_event_wlan_profile_data(ar, skb); |
| 2658 | break; |
| 2659 | case WMI_RTT_MEASUREMENT_REPORT_EVENTID: |
| 2660 | ath10k_wmi_event_rtt_measurement_report(ar, skb); |
| 2661 | break; |
| 2662 | case WMI_TSF_MEASUREMENT_REPORT_EVENTID: |
| 2663 | ath10k_wmi_event_tsf_measurement_report(ar, skb); |
| 2664 | break; |
| 2665 | case WMI_RTT_ERROR_REPORT_EVENTID: |
| 2666 | ath10k_wmi_event_rtt_error_report(ar, skb); |
| 2667 | break; |
| 2668 | case WMI_WOW_WAKEUP_HOST_EVENTID: |
| 2669 | ath10k_wmi_event_wow_wakeup_host(ar, skb); |
| 2670 | break; |
| 2671 | case WMI_DCS_INTERFERENCE_EVENTID: |
| 2672 | ath10k_wmi_event_dcs_interference(ar, skb); |
| 2673 | break; |
| 2674 | case WMI_PDEV_TPC_CONFIG_EVENTID: |
| 2675 | ath10k_wmi_event_pdev_tpc_config(ar, skb); |
| 2676 | break; |
| 2677 | case WMI_PDEV_FTM_INTG_EVENTID: |
| 2678 | ath10k_wmi_event_pdev_ftm_intg(ar, skb); |
| 2679 | break; |
| 2680 | case WMI_GTK_OFFLOAD_STATUS_EVENTID: |
| 2681 | ath10k_wmi_event_gtk_offload_status(ar, skb); |
| 2682 | break; |
| 2683 | case WMI_GTK_REKEY_FAIL_EVENTID: |
| 2684 | ath10k_wmi_event_gtk_rekey_fail(ar, skb); |
| 2685 | break; |
| 2686 | case WMI_TX_DELBA_COMPLETE_EVENTID: |
| 2687 | ath10k_wmi_event_delba_complete(ar, skb); |
| 2688 | break; |
| 2689 | case WMI_TX_ADDBA_COMPLETE_EVENTID: |
| 2690 | ath10k_wmi_event_addba_complete(ar, skb); |
| 2691 | break; |
| 2692 | case WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID: |
| 2693 | ath10k_wmi_event_vdev_install_key_complete(ar, skb); |
| 2694 | break; |
| 2695 | case WMI_SERVICE_READY_EVENTID: |
Michal Kazior | b34d2b3 | 2014-09-18 15:21:26 +0200 | [diff] [blame] | 2696 | ath10k_wmi_event_service_ready(ar, skb); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2697 | break; |
| 2698 | case WMI_READY_EVENTID: |
Michal Kazior | b34d2b3 | 2014-09-18 15:21:26 +0200 | [diff] [blame] | 2699 | ath10k_wmi_event_ready(ar, skb); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2700 | break; |
| 2701 | default: |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2702 | ath10k_warn(ar, "Unknown eventid: %d\n", id); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2703 | break; |
| 2704 | } |
| 2705 | |
| 2706 | dev_kfree_skb(skb); |
| 2707 | } |
| 2708 | |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2709 | static void ath10k_wmi_10x_process_rx(struct ath10k *ar, struct sk_buff *skb) |
| 2710 | { |
| 2711 | struct wmi_cmd_hdr *cmd_hdr; |
| 2712 | enum wmi_10x_event_id id; |
Kalle Valo | 43d2a30 | 2014-09-10 18:23:30 +0300 | [diff] [blame] | 2713 | bool consumed; |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2714 | |
| 2715 | cmd_hdr = (struct wmi_cmd_hdr *)skb->data; |
| 2716 | id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID); |
| 2717 | |
| 2718 | if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL) |
| 2719 | return; |
| 2720 | |
Michal Kazior | d35a6c1 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 2721 | trace_ath10k_wmi_event(ar, id, skb->data, skb->len); |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2722 | |
Kalle Valo | 43d2a30 | 2014-09-10 18:23:30 +0300 | [diff] [blame] | 2723 | consumed = ath10k_tm_event_wmi(ar, id, skb); |
| 2724 | |
| 2725 | /* Ready event must be handled normally also in UTF mode so that we |
| 2726 | * know the UTF firmware has booted, others we are just bypass WMI |
| 2727 | * events to testmode. |
| 2728 | */ |
| 2729 | if (consumed && id != WMI_10X_READY_EVENTID) { |
| 2730 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
| 2731 | "wmi testmode consumed 0x%x\n", id); |
| 2732 | goto out; |
| 2733 | } |
| 2734 | |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2735 | switch (id) { |
| 2736 | case WMI_10X_MGMT_RX_EVENTID: |
| 2737 | ath10k_wmi_event_mgmt_rx(ar, skb); |
| 2738 | /* mgmt_rx() owns the skb now! */ |
| 2739 | return; |
| 2740 | case WMI_10X_SCAN_EVENTID: |
| 2741 | ath10k_wmi_event_scan(ar, skb); |
| 2742 | break; |
| 2743 | case WMI_10X_CHAN_INFO_EVENTID: |
| 2744 | ath10k_wmi_event_chan_info(ar, skb); |
| 2745 | break; |
| 2746 | case WMI_10X_ECHO_EVENTID: |
| 2747 | ath10k_wmi_event_echo(ar, skb); |
| 2748 | break; |
| 2749 | case WMI_10X_DEBUG_MESG_EVENTID: |
| 2750 | ath10k_wmi_event_debug_mesg(ar, skb); |
| 2751 | break; |
| 2752 | case WMI_10X_UPDATE_STATS_EVENTID: |
| 2753 | ath10k_wmi_event_update_stats(ar, skb); |
| 2754 | break; |
| 2755 | case WMI_10X_VDEV_START_RESP_EVENTID: |
| 2756 | ath10k_wmi_event_vdev_start_resp(ar, skb); |
| 2757 | break; |
| 2758 | case WMI_10X_VDEV_STOPPED_EVENTID: |
| 2759 | ath10k_wmi_event_vdev_stopped(ar, skb); |
| 2760 | break; |
| 2761 | case WMI_10X_PEER_STA_KICKOUT_EVENTID: |
| 2762 | ath10k_wmi_event_peer_sta_kickout(ar, skb); |
| 2763 | break; |
| 2764 | case WMI_10X_HOST_SWBA_EVENTID: |
| 2765 | ath10k_wmi_event_host_swba(ar, skb); |
| 2766 | break; |
| 2767 | case WMI_10X_TBTTOFFSET_UPDATE_EVENTID: |
| 2768 | ath10k_wmi_event_tbttoffset_update(ar, skb); |
| 2769 | break; |
| 2770 | case WMI_10X_PHYERR_EVENTID: |
| 2771 | ath10k_wmi_event_phyerr(ar, skb); |
| 2772 | break; |
| 2773 | case WMI_10X_ROAM_EVENTID: |
| 2774 | ath10k_wmi_event_roam(ar, skb); |
| 2775 | break; |
| 2776 | case WMI_10X_PROFILE_MATCH: |
| 2777 | ath10k_wmi_event_profile_match(ar, skb); |
| 2778 | break; |
| 2779 | case WMI_10X_DEBUG_PRINT_EVENTID: |
| 2780 | ath10k_wmi_event_debug_print(ar, skb); |
| 2781 | break; |
| 2782 | case WMI_10X_PDEV_QVIT_EVENTID: |
| 2783 | ath10k_wmi_event_pdev_qvit(ar, skb); |
| 2784 | break; |
| 2785 | case WMI_10X_WLAN_PROFILE_DATA_EVENTID: |
| 2786 | ath10k_wmi_event_wlan_profile_data(ar, skb); |
| 2787 | break; |
| 2788 | case WMI_10X_RTT_MEASUREMENT_REPORT_EVENTID: |
| 2789 | ath10k_wmi_event_rtt_measurement_report(ar, skb); |
| 2790 | break; |
| 2791 | case WMI_10X_TSF_MEASUREMENT_REPORT_EVENTID: |
| 2792 | ath10k_wmi_event_tsf_measurement_report(ar, skb); |
| 2793 | break; |
| 2794 | case WMI_10X_RTT_ERROR_REPORT_EVENTID: |
| 2795 | ath10k_wmi_event_rtt_error_report(ar, skb); |
| 2796 | break; |
| 2797 | case WMI_10X_WOW_WAKEUP_HOST_EVENTID: |
| 2798 | ath10k_wmi_event_wow_wakeup_host(ar, skb); |
| 2799 | break; |
| 2800 | case WMI_10X_DCS_INTERFERENCE_EVENTID: |
| 2801 | ath10k_wmi_event_dcs_interference(ar, skb); |
| 2802 | break; |
| 2803 | case WMI_10X_PDEV_TPC_CONFIG_EVENTID: |
| 2804 | ath10k_wmi_event_pdev_tpc_config(ar, skb); |
| 2805 | break; |
| 2806 | case WMI_10X_INST_RSSI_STATS_EVENTID: |
| 2807 | ath10k_wmi_event_inst_rssi_stats(ar, skb); |
| 2808 | break; |
| 2809 | case WMI_10X_VDEV_STANDBY_REQ_EVENTID: |
| 2810 | ath10k_wmi_event_vdev_standby_req(ar, skb); |
| 2811 | break; |
| 2812 | case WMI_10X_VDEV_RESUME_REQ_EVENTID: |
| 2813 | ath10k_wmi_event_vdev_resume_req(ar, skb); |
| 2814 | break; |
| 2815 | case WMI_10X_SERVICE_READY_EVENTID: |
Michal Kazior | b34d2b3 | 2014-09-18 15:21:26 +0200 | [diff] [blame] | 2816 | ath10k_wmi_event_service_ready(ar, skb); |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2817 | break; |
| 2818 | case WMI_10X_READY_EVENTID: |
Michal Kazior | b34d2b3 | 2014-09-18 15:21:26 +0200 | [diff] [blame] | 2819 | ath10k_wmi_event_ready(ar, skb); |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2820 | break; |
Kalle Valo | 43d2a30 | 2014-09-10 18:23:30 +0300 | [diff] [blame] | 2821 | case WMI_10X_PDEV_UTF_EVENTID: |
| 2822 | /* ignore utf events */ |
| 2823 | break; |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2824 | default: |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2825 | ath10k_warn(ar, "Unknown eventid: %d\n", id); |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2826 | break; |
| 2827 | } |
| 2828 | |
Kalle Valo | 43d2a30 | 2014-09-10 18:23:30 +0300 | [diff] [blame] | 2829 | out: |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2830 | dev_kfree_skb(skb); |
| 2831 | } |
| 2832 | |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 2833 | static void ath10k_wmi_10_2_process_rx(struct ath10k *ar, struct sk_buff *skb) |
| 2834 | { |
| 2835 | struct wmi_cmd_hdr *cmd_hdr; |
| 2836 | enum wmi_10_2_event_id id; |
| 2837 | |
| 2838 | cmd_hdr = (struct wmi_cmd_hdr *)skb->data; |
| 2839 | id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID); |
| 2840 | |
| 2841 | if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL) |
| 2842 | return; |
| 2843 | |
Michal Kazior | d35a6c1 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 2844 | trace_ath10k_wmi_event(ar, id, skb->data, skb->len); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 2845 | |
| 2846 | switch (id) { |
| 2847 | case WMI_10_2_MGMT_RX_EVENTID: |
| 2848 | ath10k_wmi_event_mgmt_rx(ar, skb); |
| 2849 | /* mgmt_rx() owns the skb now! */ |
| 2850 | return; |
| 2851 | case WMI_10_2_SCAN_EVENTID: |
| 2852 | ath10k_wmi_event_scan(ar, skb); |
| 2853 | break; |
| 2854 | case WMI_10_2_CHAN_INFO_EVENTID: |
| 2855 | ath10k_wmi_event_chan_info(ar, skb); |
| 2856 | break; |
| 2857 | case WMI_10_2_ECHO_EVENTID: |
| 2858 | ath10k_wmi_event_echo(ar, skb); |
| 2859 | break; |
| 2860 | case WMI_10_2_DEBUG_MESG_EVENTID: |
| 2861 | ath10k_wmi_event_debug_mesg(ar, skb); |
| 2862 | break; |
| 2863 | case WMI_10_2_UPDATE_STATS_EVENTID: |
| 2864 | ath10k_wmi_event_update_stats(ar, skb); |
| 2865 | break; |
| 2866 | case WMI_10_2_VDEV_START_RESP_EVENTID: |
| 2867 | ath10k_wmi_event_vdev_start_resp(ar, skb); |
| 2868 | break; |
| 2869 | case WMI_10_2_VDEV_STOPPED_EVENTID: |
| 2870 | ath10k_wmi_event_vdev_stopped(ar, skb); |
| 2871 | break; |
| 2872 | case WMI_10_2_PEER_STA_KICKOUT_EVENTID: |
| 2873 | ath10k_wmi_event_peer_sta_kickout(ar, skb); |
| 2874 | break; |
| 2875 | case WMI_10_2_HOST_SWBA_EVENTID: |
| 2876 | ath10k_wmi_event_host_swba(ar, skb); |
| 2877 | break; |
| 2878 | case WMI_10_2_TBTTOFFSET_UPDATE_EVENTID: |
| 2879 | ath10k_wmi_event_tbttoffset_update(ar, skb); |
| 2880 | break; |
| 2881 | case WMI_10_2_PHYERR_EVENTID: |
| 2882 | ath10k_wmi_event_phyerr(ar, skb); |
| 2883 | break; |
| 2884 | case WMI_10_2_ROAM_EVENTID: |
| 2885 | ath10k_wmi_event_roam(ar, skb); |
| 2886 | break; |
| 2887 | case WMI_10_2_PROFILE_MATCH: |
| 2888 | ath10k_wmi_event_profile_match(ar, skb); |
| 2889 | break; |
| 2890 | case WMI_10_2_DEBUG_PRINT_EVENTID: |
| 2891 | ath10k_wmi_event_debug_print(ar, skb); |
| 2892 | break; |
| 2893 | case WMI_10_2_PDEV_QVIT_EVENTID: |
| 2894 | ath10k_wmi_event_pdev_qvit(ar, skb); |
| 2895 | break; |
| 2896 | case WMI_10_2_WLAN_PROFILE_DATA_EVENTID: |
| 2897 | ath10k_wmi_event_wlan_profile_data(ar, skb); |
| 2898 | break; |
| 2899 | case WMI_10_2_RTT_MEASUREMENT_REPORT_EVENTID: |
| 2900 | ath10k_wmi_event_rtt_measurement_report(ar, skb); |
| 2901 | break; |
| 2902 | case WMI_10_2_TSF_MEASUREMENT_REPORT_EVENTID: |
| 2903 | ath10k_wmi_event_tsf_measurement_report(ar, skb); |
| 2904 | break; |
| 2905 | case WMI_10_2_RTT_ERROR_REPORT_EVENTID: |
| 2906 | ath10k_wmi_event_rtt_error_report(ar, skb); |
| 2907 | break; |
| 2908 | case WMI_10_2_WOW_WAKEUP_HOST_EVENTID: |
| 2909 | ath10k_wmi_event_wow_wakeup_host(ar, skb); |
| 2910 | break; |
| 2911 | case WMI_10_2_DCS_INTERFERENCE_EVENTID: |
| 2912 | ath10k_wmi_event_dcs_interference(ar, skb); |
| 2913 | break; |
| 2914 | case WMI_10_2_PDEV_TPC_CONFIG_EVENTID: |
| 2915 | ath10k_wmi_event_pdev_tpc_config(ar, skb); |
| 2916 | break; |
| 2917 | case WMI_10_2_INST_RSSI_STATS_EVENTID: |
| 2918 | ath10k_wmi_event_inst_rssi_stats(ar, skb); |
| 2919 | break; |
| 2920 | case WMI_10_2_VDEV_STANDBY_REQ_EVENTID: |
| 2921 | ath10k_wmi_event_vdev_standby_req(ar, skb); |
| 2922 | break; |
| 2923 | case WMI_10_2_VDEV_RESUME_REQ_EVENTID: |
| 2924 | ath10k_wmi_event_vdev_resume_req(ar, skb); |
| 2925 | break; |
| 2926 | case WMI_10_2_SERVICE_READY_EVENTID: |
Michal Kazior | b34d2b3 | 2014-09-18 15:21:26 +0200 | [diff] [blame] | 2927 | ath10k_wmi_event_service_ready(ar, skb); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 2928 | break; |
| 2929 | case WMI_10_2_READY_EVENTID: |
Michal Kazior | b34d2b3 | 2014-09-18 15:21:26 +0200 | [diff] [blame] | 2930 | ath10k_wmi_event_ready(ar, skb); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 2931 | break; |
| 2932 | case WMI_10_2_RTT_KEEPALIVE_EVENTID: |
| 2933 | case WMI_10_2_GPIO_INPUT_EVENTID: |
| 2934 | case WMI_10_2_PEER_RATECODE_LIST_EVENTID: |
| 2935 | case WMI_10_2_GENERIC_BUFFER_EVENTID: |
| 2936 | case WMI_10_2_MCAST_BUF_RELEASE_EVENTID: |
| 2937 | case WMI_10_2_MCAST_LIST_AGEOUT_EVENTID: |
| 2938 | case WMI_10_2_WDS_PEER_EVENTID: |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2939 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 2940 | "received event id %d not implemented\n", id); |
| 2941 | break; |
| 2942 | default: |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2943 | ath10k_warn(ar, "Unknown eventid: %d\n", id); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 2944 | break; |
| 2945 | } |
| 2946 | |
| 2947 | dev_kfree_skb(skb); |
| 2948 | } |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2949 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2950 | static void ath10k_wmi_process_rx(struct ath10k *ar, struct sk_buff *skb) |
| 2951 | { |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 2952 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { |
| 2953 | if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features)) |
| 2954 | ath10k_wmi_10_2_process_rx(ar, skb); |
| 2955 | else |
| 2956 | ath10k_wmi_10x_process_rx(ar, skb); |
| 2957 | } else { |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2958 | ath10k_wmi_main_process_rx(ar, skb); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 2959 | } |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2960 | } |
| 2961 | |
Michal Kazior | 95bf21f | 2014-05-16 17:15:39 +0300 | [diff] [blame] | 2962 | int ath10k_wmi_connect(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2963 | { |
| 2964 | int status; |
| 2965 | struct ath10k_htc_svc_conn_req conn_req; |
| 2966 | struct ath10k_htc_svc_conn_resp conn_resp; |
| 2967 | |
| 2968 | memset(&conn_req, 0, sizeof(conn_req)); |
| 2969 | memset(&conn_resp, 0, sizeof(conn_resp)); |
| 2970 | |
| 2971 | /* these fields are the same for all service endpoints */ |
| 2972 | conn_req.ep_ops.ep_tx_complete = ath10k_wmi_htc_tx_complete; |
| 2973 | conn_req.ep_ops.ep_rx_complete = ath10k_wmi_process_rx; |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 2974 | conn_req.ep_ops.ep_tx_credits = ath10k_wmi_op_ep_tx_credits; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2975 | |
| 2976 | /* connect to control service */ |
| 2977 | conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL; |
| 2978 | |
Michal Kazior | cd003fa | 2013-07-05 16:15:13 +0300 | [diff] [blame] | 2979 | status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2980 | if (status) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2981 | ath10k_warn(ar, "failed to connect to WMI CONTROL service status: %d\n", |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2982 | status); |
| 2983 | return status; |
| 2984 | } |
| 2985 | |
| 2986 | ar->wmi.eid = conn_resp.eid; |
| 2987 | return 0; |
| 2988 | } |
| 2989 | |
Marek Puzyniak | 821af6a | 2014-03-21 17:46:57 +0200 | [diff] [blame] | 2990 | static int ath10k_wmi_main_pdev_set_regdomain(struct ath10k *ar, u16 rd, |
| 2991 | u16 rd2g, u16 rd5g, u16 ctl2g, |
| 2992 | u16 ctl5g) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2993 | { |
| 2994 | struct wmi_pdev_set_regdomain_cmd *cmd; |
| 2995 | struct sk_buff *skb; |
| 2996 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2997 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2998 | if (!skb) |
| 2999 | return -ENOMEM; |
| 3000 | |
| 3001 | cmd = (struct wmi_pdev_set_regdomain_cmd *)skb->data; |
| 3002 | cmd->reg_domain = __cpu_to_le32(rd); |
| 3003 | cmd->reg_domain_2G = __cpu_to_le32(rd2g); |
| 3004 | cmd->reg_domain_5G = __cpu_to_le32(rd5g); |
| 3005 | cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g); |
| 3006 | cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g); |
| 3007 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3008 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3009 | "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x\n", |
| 3010 | rd, rd2g, rd5g, ctl2g, ctl5g); |
| 3011 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3012 | return ath10k_wmi_cmd_send(ar, skb, |
| 3013 | ar->wmi.cmd->pdev_set_regdomain_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3014 | } |
| 3015 | |
Marek Puzyniak | 821af6a | 2014-03-21 17:46:57 +0200 | [diff] [blame] | 3016 | static int ath10k_wmi_10x_pdev_set_regdomain(struct ath10k *ar, u16 rd, |
| 3017 | u16 rd2g, u16 rd5g, |
| 3018 | u16 ctl2g, u16 ctl5g, |
| 3019 | enum wmi_dfs_region dfs_reg) |
| 3020 | { |
| 3021 | struct wmi_pdev_set_regdomain_cmd_10x *cmd; |
| 3022 | struct sk_buff *skb; |
| 3023 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3024 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Marek Puzyniak | 821af6a | 2014-03-21 17:46:57 +0200 | [diff] [blame] | 3025 | if (!skb) |
| 3026 | return -ENOMEM; |
| 3027 | |
| 3028 | cmd = (struct wmi_pdev_set_regdomain_cmd_10x *)skb->data; |
| 3029 | cmd->reg_domain = __cpu_to_le32(rd); |
| 3030 | cmd->reg_domain_2G = __cpu_to_le32(rd2g); |
| 3031 | cmd->reg_domain_5G = __cpu_to_le32(rd5g); |
| 3032 | cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g); |
| 3033 | cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g); |
| 3034 | cmd->dfs_domain = __cpu_to_le32(dfs_reg); |
| 3035 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3036 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Marek Puzyniak | 821af6a | 2014-03-21 17:46:57 +0200 | [diff] [blame] | 3037 | "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x dfs_region %x\n", |
| 3038 | rd, rd2g, rd5g, ctl2g, ctl5g, dfs_reg); |
| 3039 | |
| 3040 | return ath10k_wmi_cmd_send(ar, skb, |
| 3041 | ar->wmi.cmd->pdev_set_regdomain_cmdid); |
| 3042 | } |
| 3043 | |
| 3044 | int ath10k_wmi_pdev_set_regdomain(struct ath10k *ar, u16 rd, u16 rd2g, |
| 3045 | u16 rd5g, u16 ctl2g, u16 ctl5g, |
| 3046 | enum wmi_dfs_region dfs_reg) |
| 3047 | { |
| 3048 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) |
| 3049 | return ath10k_wmi_10x_pdev_set_regdomain(ar, rd, rd2g, rd5g, |
| 3050 | ctl2g, ctl5g, dfs_reg); |
| 3051 | else |
| 3052 | return ath10k_wmi_main_pdev_set_regdomain(ar, rd, rd2g, rd5g, |
| 3053 | ctl2g, ctl5g); |
| 3054 | } |
| 3055 | |
Marek Puzyniak | 00f5482 | 2014-02-10 17:14:24 +0100 | [diff] [blame] | 3056 | int ath10k_wmi_pdev_suspend_target(struct ath10k *ar, u32 suspend_opt) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3057 | { |
| 3058 | struct wmi_pdev_suspend_cmd *cmd; |
| 3059 | struct sk_buff *skb; |
| 3060 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3061 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3062 | if (!skb) |
| 3063 | return -ENOMEM; |
| 3064 | |
| 3065 | cmd = (struct wmi_pdev_suspend_cmd *)skb->data; |
Marek Puzyniak | 00f5482 | 2014-02-10 17:14:24 +0100 | [diff] [blame] | 3066 | cmd->suspend_opt = __cpu_to_le32(suspend_opt); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3067 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3068 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_suspend_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3069 | } |
| 3070 | |
| 3071 | int ath10k_wmi_pdev_resume_target(struct ath10k *ar) |
| 3072 | { |
| 3073 | struct sk_buff *skb; |
| 3074 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3075 | skb = ath10k_wmi_alloc_skb(ar, 0); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3076 | if (skb == NULL) |
| 3077 | return -ENOMEM; |
| 3078 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3079 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_resume_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3080 | } |
| 3081 | |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 3082 | int ath10k_wmi_pdev_set_param(struct ath10k *ar, u32 id, u32 value) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3083 | { |
| 3084 | struct wmi_pdev_set_param_cmd *cmd; |
| 3085 | struct sk_buff *skb; |
| 3086 | |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 3087 | if (id == WMI_PDEV_PARAM_UNSUPPORTED) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3088 | ath10k_warn(ar, "pdev param %d not supported by firmware\n", |
| 3089 | id); |
Bartosz Markowski | d544943 | 2013-10-15 09:55:32 +0200 | [diff] [blame] | 3090 | return -EOPNOTSUPP; |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 3091 | } |
| 3092 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3093 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3094 | if (!skb) |
| 3095 | return -ENOMEM; |
| 3096 | |
| 3097 | cmd = (struct wmi_pdev_set_param_cmd *)skb->data; |
| 3098 | cmd->param_id = __cpu_to_le32(id); |
| 3099 | cmd->param_value = __cpu_to_le32(value); |
| 3100 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3101 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set param %d value %d\n", |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3102 | id, value); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3103 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_set_param_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3104 | } |
| 3105 | |
Michal Kazior | cf9fca8 | 2014-09-18 15:21:22 +0200 | [diff] [blame] | 3106 | static void ath10k_wmi_put_host_mem_chunks(struct ath10k *ar, |
| 3107 | struct wmi_host_mem_chunks *chunks) |
| 3108 | { |
| 3109 | struct host_memory_chunk *chunk; |
| 3110 | int i; |
| 3111 | |
| 3112 | chunks->count = __cpu_to_le32(ar->wmi.num_mem_chunks); |
| 3113 | |
| 3114 | for (i = 0; i < ar->wmi.num_mem_chunks; i++) { |
| 3115 | chunk = &chunks->items[i]; |
| 3116 | chunk->ptr = __cpu_to_le32(ar->wmi.mem_chunks[i].paddr); |
| 3117 | chunk->size = __cpu_to_le32(ar->wmi.mem_chunks[i].len); |
| 3118 | chunk->req_id = __cpu_to_le32(ar->wmi.mem_chunks[i].req_id); |
| 3119 | |
| 3120 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
| 3121 | "wmi chunk %d len %d requested, addr 0x%llx\n", |
| 3122 | i, |
| 3123 | ar->wmi.mem_chunks[i].len, |
| 3124 | (unsigned long long)ar->wmi.mem_chunks[i].paddr); |
| 3125 | } |
| 3126 | } |
| 3127 | |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3128 | static int ath10k_wmi_main_cmd_init(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3129 | { |
| 3130 | struct wmi_init_cmd *cmd; |
| 3131 | struct sk_buff *buf; |
| 3132 | struct wmi_resource_config config = {}; |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 3133 | u32 len, val; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3134 | |
| 3135 | config.num_vdevs = __cpu_to_le32(TARGET_NUM_VDEVS); |
| 3136 | config.num_peers = __cpu_to_le32(TARGET_NUM_PEERS + TARGET_NUM_VDEVS); |
| 3137 | config.num_offload_peers = __cpu_to_le32(TARGET_NUM_OFFLOAD_PEERS); |
| 3138 | |
| 3139 | config.num_offload_reorder_bufs = |
| 3140 | __cpu_to_le32(TARGET_NUM_OFFLOAD_REORDER_BUFS); |
| 3141 | |
| 3142 | config.num_peer_keys = __cpu_to_le32(TARGET_NUM_PEER_KEYS); |
| 3143 | config.num_tids = __cpu_to_le32(TARGET_NUM_TIDS); |
| 3144 | config.ast_skid_limit = __cpu_to_le32(TARGET_AST_SKID_LIMIT); |
| 3145 | config.tx_chain_mask = __cpu_to_le32(TARGET_TX_CHAIN_MASK); |
| 3146 | config.rx_chain_mask = __cpu_to_le32(TARGET_RX_CHAIN_MASK); |
| 3147 | config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI); |
| 3148 | config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI); |
| 3149 | config.rx_timeout_pri_be = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI); |
| 3150 | config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_RX_TIMEOUT_HI_PRI); |
| 3151 | config.rx_decap_mode = __cpu_to_le32(TARGET_RX_DECAP_MODE); |
| 3152 | |
| 3153 | config.scan_max_pending_reqs = |
| 3154 | __cpu_to_le32(TARGET_SCAN_MAX_PENDING_REQS); |
| 3155 | |
| 3156 | config.bmiss_offload_max_vdev = |
| 3157 | __cpu_to_le32(TARGET_BMISS_OFFLOAD_MAX_VDEV); |
| 3158 | |
| 3159 | config.roam_offload_max_vdev = |
| 3160 | __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_VDEV); |
| 3161 | |
| 3162 | config.roam_offload_max_ap_profiles = |
| 3163 | __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_AP_PROFILES); |
| 3164 | |
| 3165 | config.num_mcast_groups = __cpu_to_le32(TARGET_NUM_MCAST_GROUPS); |
| 3166 | config.num_mcast_table_elems = |
| 3167 | __cpu_to_le32(TARGET_NUM_MCAST_TABLE_ELEMS); |
| 3168 | |
| 3169 | config.mcast2ucast_mode = __cpu_to_le32(TARGET_MCAST2UCAST_MODE); |
| 3170 | config.tx_dbg_log_size = __cpu_to_le32(TARGET_TX_DBG_LOG_SIZE); |
| 3171 | config.num_wds_entries = __cpu_to_le32(TARGET_NUM_WDS_ENTRIES); |
| 3172 | config.dma_burst_size = __cpu_to_le32(TARGET_DMA_BURST_SIZE); |
| 3173 | config.mac_aggr_delim = __cpu_to_le32(TARGET_MAC_AGGR_DELIM); |
| 3174 | |
| 3175 | val = TARGET_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK; |
| 3176 | config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val); |
| 3177 | |
| 3178 | config.vow_config = __cpu_to_le32(TARGET_VOW_CONFIG); |
| 3179 | |
| 3180 | config.gtk_offload_max_vdev = |
| 3181 | __cpu_to_le32(TARGET_GTK_OFFLOAD_MAX_VDEV); |
| 3182 | |
| 3183 | config.num_msdu_desc = __cpu_to_le32(TARGET_NUM_MSDU_DESC); |
| 3184 | config.max_frag_entries = __cpu_to_le32(TARGET_MAX_FRAG_ENTRIES); |
| 3185 | |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 3186 | len = sizeof(*cmd) + |
| 3187 | (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks); |
| 3188 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3189 | buf = ath10k_wmi_alloc_skb(ar, len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3190 | if (!buf) |
| 3191 | return -ENOMEM; |
| 3192 | |
| 3193 | cmd = (struct wmi_init_cmd *)buf->data; |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 3194 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3195 | memcpy(&cmd->resource_config, &config, sizeof(config)); |
Michal Kazior | cf9fca8 | 2014-09-18 15:21:22 +0200 | [diff] [blame] | 3196 | ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3197 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3198 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init\n"); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3199 | return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3200 | } |
| 3201 | |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3202 | static int ath10k_wmi_10x_cmd_init(struct ath10k *ar) |
| 3203 | { |
| 3204 | struct wmi_init_cmd_10x *cmd; |
| 3205 | struct sk_buff *buf; |
| 3206 | struct wmi_resource_config_10x config = {}; |
| 3207 | u32 len, val; |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3208 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3209 | config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS); |
| 3210 | config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS); |
| 3211 | config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS); |
| 3212 | config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS); |
| 3213 | config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT); |
| 3214 | config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK); |
| 3215 | config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK); |
| 3216 | config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI); |
| 3217 | config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI); |
| 3218 | config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI); |
| 3219 | config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI); |
| 3220 | config.rx_decap_mode = __cpu_to_le32(TARGET_10X_RX_DECAP_MODE); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3221 | |
| 3222 | config.scan_max_pending_reqs = |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3223 | __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3224 | |
| 3225 | config.bmiss_offload_max_vdev = |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3226 | __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3227 | |
| 3228 | config.roam_offload_max_vdev = |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3229 | __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3230 | |
| 3231 | config.roam_offload_max_ap_profiles = |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3232 | __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3233 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3234 | config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3235 | config.num_mcast_table_elems = |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3236 | __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3237 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3238 | config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE); |
| 3239 | config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE); |
| 3240 | config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES); |
| 3241 | config.dma_burst_size = __cpu_to_le32(TARGET_10X_DMA_BURST_SIZE); |
| 3242 | config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3243 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3244 | val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK; |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3245 | config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val); |
| 3246 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3247 | config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3248 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3249 | config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC); |
| 3250 | config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3251 | |
| 3252 | len = sizeof(*cmd) + |
| 3253 | (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks); |
| 3254 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3255 | buf = ath10k_wmi_alloc_skb(ar, len); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3256 | if (!buf) |
| 3257 | return -ENOMEM; |
| 3258 | |
| 3259 | cmd = (struct wmi_init_cmd_10x *)buf->data; |
| 3260 | |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3261 | memcpy(&cmd->resource_config, &config, sizeof(config)); |
Michal Kazior | cf9fca8 | 2014-09-18 15:21:22 +0200 | [diff] [blame] | 3262 | ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3263 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3264 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10x\n"); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3265 | return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); |
| 3266 | } |
| 3267 | |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3268 | static int ath10k_wmi_10_2_cmd_init(struct ath10k *ar) |
| 3269 | { |
| 3270 | struct wmi_init_cmd_10_2 *cmd; |
| 3271 | struct sk_buff *buf; |
| 3272 | struct wmi_resource_config_10x config = {}; |
| 3273 | u32 len, val; |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3274 | |
| 3275 | config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS); |
| 3276 | config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS); |
| 3277 | config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS); |
| 3278 | config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS); |
| 3279 | config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT); |
| 3280 | config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK); |
| 3281 | config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK); |
| 3282 | config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI); |
| 3283 | config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI); |
| 3284 | config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI); |
| 3285 | config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI); |
| 3286 | config.rx_decap_mode = __cpu_to_le32(TARGET_10X_RX_DECAP_MODE); |
| 3287 | |
| 3288 | config.scan_max_pending_reqs = |
| 3289 | __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS); |
| 3290 | |
| 3291 | config.bmiss_offload_max_vdev = |
| 3292 | __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV); |
| 3293 | |
| 3294 | config.roam_offload_max_vdev = |
| 3295 | __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV); |
| 3296 | |
| 3297 | config.roam_offload_max_ap_profiles = |
| 3298 | __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES); |
| 3299 | |
| 3300 | config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS); |
| 3301 | config.num_mcast_table_elems = |
| 3302 | __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS); |
| 3303 | |
| 3304 | config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE); |
| 3305 | config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE); |
| 3306 | config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES); |
| 3307 | config.dma_burst_size = __cpu_to_le32(TARGET_10X_DMA_BURST_SIZE); |
| 3308 | config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM); |
| 3309 | |
| 3310 | val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK; |
| 3311 | config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val); |
| 3312 | |
| 3313 | config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG); |
| 3314 | |
| 3315 | config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC); |
| 3316 | config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES); |
| 3317 | |
| 3318 | len = sizeof(*cmd) + |
| 3319 | (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks); |
| 3320 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3321 | buf = ath10k_wmi_alloc_skb(ar, len); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3322 | if (!buf) |
| 3323 | return -ENOMEM; |
| 3324 | |
| 3325 | cmd = (struct wmi_init_cmd_10_2 *)buf->data; |
| 3326 | |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3327 | memcpy(&cmd->resource_config.common, &config, sizeof(config)); |
Michal Kazior | cf9fca8 | 2014-09-18 15:21:22 +0200 | [diff] [blame] | 3328 | ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3329 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3330 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.2\n"); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3331 | return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); |
| 3332 | } |
| 3333 | |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3334 | int ath10k_wmi_cmd_init(struct ath10k *ar) |
| 3335 | { |
| 3336 | int ret; |
| 3337 | |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3338 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { |
| 3339 | if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features)) |
| 3340 | ret = ath10k_wmi_10_2_cmd_init(ar); |
| 3341 | else |
| 3342 | ret = ath10k_wmi_10x_cmd_init(ar); |
| 3343 | } else { |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3344 | ret = ath10k_wmi_main_cmd_init(ar); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3345 | } |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3346 | |
| 3347 | return ret; |
| 3348 | } |
| 3349 | |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3350 | static int ath10k_wmi_start_scan_verify(const struct wmi_start_scan_arg *arg) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3351 | { |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3352 | if (arg->ie_len && !arg->ie) |
| 3353 | return -EINVAL; |
| 3354 | if (arg->n_channels && !arg->channels) |
| 3355 | return -EINVAL; |
| 3356 | if (arg->n_ssids && !arg->ssids) |
| 3357 | return -EINVAL; |
| 3358 | if (arg->n_bssids && !arg->bssids) |
| 3359 | return -EINVAL; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3360 | |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3361 | if (arg->ie_len > WLAN_SCAN_PARAMS_MAX_IE_LEN) |
| 3362 | return -EINVAL; |
| 3363 | if (arg->n_channels > ARRAY_SIZE(arg->channels)) |
| 3364 | return -EINVAL; |
| 3365 | if (arg->n_ssids > WLAN_SCAN_PARAMS_MAX_SSID) |
| 3366 | return -EINVAL; |
| 3367 | if (arg->n_bssids > WLAN_SCAN_PARAMS_MAX_BSSID) |
| 3368 | return -EINVAL; |
| 3369 | |
| 3370 | return 0; |
| 3371 | } |
| 3372 | |
| 3373 | static size_t |
| 3374 | ath10k_wmi_start_scan_tlvs_len(const struct wmi_start_scan_arg *arg) |
| 3375 | { |
| 3376 | int len = 0; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3377 | |
| 3378 | if (arg->ie_len) { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3379 | len += sizeof(struct wmi_ie_data); |
| 3380 | len += roundup(arg->ie_len, 4); |
| 3381 | } |
| 3382 | |
| 3383 | if (arg->n_channels) { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3384 | len += sizeof(struct wmi_chan_list); |
| 3385 | len += sizeof(__le32) * arg->n_channels; |
| 3386 | } |
| 3387 | |
| 3388 | if (arg->n_ssids) { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3389 | len += sizeof(struct wmi_ssid_list); |
| 3390 | len += sizeof(struct wmi_ssid) * arg->n_ssids; |
| 3391 | } |
| 3392 | |
| 3393 | if (arg->n_bssids) { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3394 | len += sizeof(struct wmi_bssid_list); |
| 3395 | len += sizeof(struct wmi_mac_addr) * arg->n_bssids; |
| 3396 | } |
| 3397 | |
| 3398 | return len; |
| 3399 | } |
| 3400 | |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3401 | static void |
| 3402 | ath10k_wmi_put_start_scan_common(struct wmi_start_scan_common *cmn, |
| 3403 | const struct wmi_start_scan_arg *arg) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3404 | { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3405 | u32 scan_id; |
| 3406 | u32 scan_req_id; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3407 | |
| 3408 | scan_id = WMI_HOST_SCAN_REQ_ID_PREFIX; |
| 3409 | scan_id |= arg->scan_id; |
| 3410 | |
| 3411 | scan_req_id = WMI_HOST_SCAN_REQUESTOR_ID_PREFIX; |
| 3412 | scan_req_id |= arg->scan_req_id; |
| 3413 | |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3414 | cmn->scan_id = __cpu_to_le32(scan_id); |
| 3415 | cmn->scan_req_id = __cpu_to_le32(scan_req_id); |
| 3416 | cmn->vdev_id = __cpu_to_le32(arg->vdev_id); |
| 3417 | cmn->scan_priority = __cpu_to_le32(arg->scan_priority); |
| 3418 | cmn->notify_scan_events = __cpu_to_le32(arg->notify_scan_events); |
| 3419 | cmn->dwell_time_active = __cpu_to_le32(arg->dwell_time_active); |
| 3420 | cmn->dwell_time_passive = __cpu_to_le32(arg->dwell_time_passive); |
| 3421 | cmn->min_rest_time = __cpu_to_le32(arg->min_rest_time); |
| 3422 | cmn->max_rest_time = __cpu_to_le32(arg->max_rest_time); |
| 3423 | cmn->repeat_probe_time = __cpu_to_le32(arg->repeat_probe_time); |
| 3424 | cmn->probe_spacing_time = __cpu_to_le32(arg->probe_spacing_time); |
| 3425 | cmn->idle_time = __cpu_to_le32(arg->idle_time); |
| 3426 | cmn->max_scan_time = __cpu_to_le32(arg->max_scan_time); |
| 3427 | cmn->probe_delay = __cpu_to_le32(arg->probe_delay); |
| 3428 | cmn->scan_ctrl_flags = __cpu_to_le32(arg->scan_ctrl_flags); |
| 3429 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3430 | |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3431 | static void |
| 3432 | ath10k_wmi_put_start_scan_tlvs(struct wmi_start_scan_tlvs *tlvs, |
| 3433 | const struct wmi_start_scan_arg *arg) |
| 3434 | { |
| 3435 | struct wmi_ie_data *ie; |
| 3436 | struct wmi_chan_list *channels; |
| 3437 | struct wmi_ssid_list *ssids; |
| 3438 | struct wmi_bssid_list *bssids; |
| 3439 | void *ptr = tlvs->tlvs; |
| 3440 | int i; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3441 | |
| 3442 | if (arg->n_channels) { |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3443 | channels = ptr; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3444 | channels->tag = __cpu_to_le32(WMI_CHAN_LIST_TAG); |
| 3445 | channels->num_chan = __cpu_to_le32(arg->n_channels); |
| 3446 | |
| 3447 | for (i = 0; i < arg->n_channels; i++) |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3448 | channels->channel_list[i].freq = |
| 3449 | __cpu_to_le16(arg->channels[i]); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3450 | |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3451 | ptr += sizeof(*channels); |
| 3452 | ptr += sizeof(__le32) * arg->n_channels; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3453 | } |
| 3454 | |
| 3455 | if (arg->n_ssids) { |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3456 | ssids = ptr; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3457 | ssids->tag = __cpu_to_le32(WMI_SSID_LIST_TAG); |
| 3458 | ssids->num_ssids = __cpu_to_le32(arg->n_ssids); |
| 3459 | |
| 3460 | for (i = 0; i < arg->n_ssids; i++) { |
| 3461 | ssids->ssids[i].ssid_len = |
| 3462 | __cpu_to_le32(arg->ssids[i].len); |
| 3463 | memcpy(&ssids->ssids[i].ssid, |
| 3464 | arg->ssids[i].ssid, |
| 3465 | arg->ssids[i].len); |
| 3466 | } |
| 3467 | |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3468 | ptr += sizeof(*ssids); |
| 3469 | ptr += sizeof(struct wmi_ssid) * arg->n_ssids; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3470 | } |
| 3471 | |
| 3472 | if (arg->n_bssids) { |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3473 | bssids = ptr; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3474 | bssids->tag = __cpu_to_le32(WMI_BSSID_LIST_TAG); |
| 3475 | bssids->num_bssid = __cpu_to_le32(arg->n_bssids); |
| 3476 | |
| 3477 | for (i = 0; i < arg->n_bssids; i++) |
| 3478 | memcpy(&bssids->bssid_list[i], |
| 3479 | arg->bssids[i].bssid, |
| 3480 | ETH_ALEN); |
| 3481 | |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3482 | ptr += sizeof(*bssids); |
| 3483 | ptr += sizeof(struct wmi_mac_addr) * arg->n_bssids; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3484 | } |
| 3485 | |
| 3486 | if (arg->ie_len) { |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3487 | ie = ptr; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3488 | ie->tag = __cpu_to_le32(WMI_IE_TAG); |
| 3489 | ie->ie_len = __cpu_to_le32(arg->ie_len); |
| 3490 | memcpy(ie->ie_data, arg->ie, arg->ie_len); |
| 3491 | |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3492 | ptr += sizeof(*ie); |
| 3493 | ptr += roundup(arg->ie_len, 4); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3494 | } |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3495 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3496 | |
Michal Kazior | a6aa5da | 2014-09-18 15:21:27 +0200 | [diff] [blame] | 3497 | int ath10k_wmi_start_scan(struct ath10k *ar, |
| 3498 | const struct wmi_start_scan_arg *arg) |
| 3499 | { |
| 3500 | struct sk_buff *skb; |
| 3501 | size_t len; |
| 3502 | int ret; |
| 3503 | |
| 3504 | ret = ath10k_wmi_start_scan_verify(arg); |
| 3505 | if (ret) |
| 3506 | return ret; |
| 3507 | |
| 3508 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) |
| 3509 | len = sizeof(struct wmi_start_scan_cmd) + |
| 3510 | ath10k_wmi_start_scan_tlvs_len(arg); |
| 3511 | else |
| 3512 | len = sizeof(struct wmi_10x_start_scan_cmd) + |
| 3513 | ath10k_wmi_start_scan_tlvs_len(arg); |
| 3514 | |
| 3515 | skb = ath10k_wmi_alloc_skb(ar, len); |
| 3516 | if (!skb) |
| 3517 | return -ENOMEM; |
| 3518 | |
| 3519 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { |
| 3520 | struct wmi_10x_start_scan_cmd *cmd; |
| 3521 | |
| 3522 | cmd = (struct wmi_10x_start_scan_cmd *)skb->data; |
| 3523 | ath10k_wmi_put_start_scan_common(&cmd->common, arg); |
| 3524 | ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg); |
| 3525 | } else { |
| 3526 | struct wmi_start_scan_cmd *cmd; |
| 3527 | |
| 3528 | cmd = (struct wmi_start_scan_cmd *)skb->data; |
| 3529 | cmd->burst_duration_ms = __cpu_to_le32(0); |
| 3530 | |
| 3531 | ath10k_wmi_put_start_scan_common(&cmd->common, arg); |
| 3532 | ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3533 | } |
| 3534 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3535 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi start scan\n"); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3536 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->start_scan_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3537 | } |
| 3538 | |
| 3539 | void ath10k_wmi_start_scan_init(struct ath10k *ar, |
| 3540 | struct wmi_start_scan_arg *arg) |
| 3541 | { |
| 3542 | /* setup commonly used values */ |
| 3543 | arg->scan_req_id = 1; |
| 3544 | arg->scan_priority = WMI_SCAN_PRIORITY_LOW; |
| 3545 | arg->dwell_time_active = 50; |
| 3546 | arg->dwell_time_passive = 150; |
| 3547 | arg->min_rest_time = 50; |
| 3548 | arg->max_rest_time = 500; |
| 3549 | arg->repeat_probe_time = 0; |
| 3550 | arg->probe_spacing_time = 0; |
| 3551 | arg->idle_time = 0; |
Bartosz Markowski | c322892 | 2013-10-02 08:48:52 +0200 | [diff] [blame] | 3552 | arg->max_scan_time = 20000; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3553 | arg->probe_delay = 5; |
| 3554 | arg->notify_scan_events = WMI_SCAN_EVENT_STARTED |
| 3555 | | WMI_SCAN_EVENT_COMPLETED |
| 3556 | | WMI_SCAN_EVENT_BSS_CHANNEL |
| 3557 | | WMI_SCAN_EVENT_FOREIGN_CHANNEL |
| 3558 | | WMI_SCAN_EVENT_DEQUEUED; |
| 3559 | arg->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES; |
| 3560 | arg->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT; |
| 3561 | arg->n_bssids = 1; |
| 3562 | arg->bssids[0].bssid = "\xFF\xFF\xFF\xFF\xFF\xFF"; |
| 3563 | } |
| 3564 | |
| 3565 | int ath10k_wmi_stop_scan(struct ath10k *ar, const struct wmi_stop_scan_arg *arg) |
| 3566 | { |
| 3567 | struct wmi_stop_scan_cmd *cmd; |
| 3568 | struct sk_buff *skb; |
| 3569 | u32 scan_id; |
| 3570 | u32 req_id; |
| 3571 | |
| 3572 | if (arg->req_id > 0xFFF) |
| 3573 | return -EINVAL; |
| 3574 | if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF) |
| 3575 | return -EINVAL; |
| 3576 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3577 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3578 | if (!skb) |
| 3579 | return -ENOMEM; |
| 3580 | |
| 3581 | scan_id = arg->u.scan_id; |
| 3582 | scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX; |
| 3583 | |
| 3584 | req_id = arg->req_id; |
| 3585 | req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX; |
| 3586 | |
| 3587 | cmd = (struct wmi_stop_scan_cmd *)skb->data; |
| 3588 | cmd->req_type = __cpu_to_le32(arg->req_type); |
| 3589 | cmd->vdev_id = __cpu_to_le32(arg->u.vdev_id); |
| 3590 | cmd->scan_id = __cpu_to_le32(scan_id); |
| 3591 | cmd->scan_req_id = __cpu_to_le32(req_id); |
| 3592 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3593 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3594 | "wmi stop scan reqid %d req_type %d vdev/scan_id %d\n", |
| 3595 | arg->req_id, arg->req_type, arg->u.scan_id); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3596 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->stop_scan_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3597 | } |
| 3598 | |
| 3599 | int ath10k_wmi_vdev_create(struct ath10k *ar, u32 vdev_id, |
| 3600 | enum wmi_vdev_type type, |
| 3601 | enum wmi_vdev_subtype subtype, |
| 3602 | const u8 macaddr[ETH_ALEN]) |
| 3603 | { |
| 3604 | struct wmi_vdev_create_cmd *cmd; |
| 3605 | struct sk_buff *skb; |
| 3606 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3607 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3608 | if (!skb) |
| 3609 | return -ENOMEM; |
| 3610 | |
| 3611 | cmd = (struct wmi_vdev_create_cmd *)skb->data; |
| 3612 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3613 | cmd->vdev_type = __cpu_to_le32(type); |
| 3614 | cmd->vdev_subtype = __cpu_to_le32(subtype); |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3615 | ether_addr_copy(cmd->vdev_macaddr.addr, macaddr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3616 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3617 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3618 | "WMI vdev create: id %d type %d subtype %d macaddr %pM\n", |
| 3619 | vdev_id, type, subtype, macaddr); |
| 3620 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3621 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_create_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3622 | } |
| 3623 | |
| 3624 | int ath10k_wmi_vdev_delete(struct ath10k *ar, u32 vdev_id) |
| 3625 | { |
| 3626 | struct wmi_vdev_delete_cmd *cmd; |
| 3627 | struct sk_buff *skb; |
| 3628 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3629 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3630 | if (!skb) |
| 3631 | return -ENOMEM; |
| 3632 | |
| 3633 | cmd = (struct wmi_vdev_delete_cmd *)skb->data; |
| 3634 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3635 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3636 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3637 | "WMI vdev delete id %d\n", vdev_id); |
| 3638 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3639 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_delete_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3640 | } |
| 3641 | |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 3642 | static int |
| 3643 | ath10k_wmi_vdev_start_restart(struct ath10k *ar, |
| 3644 | const struct wmi_vdev_start_request_arg *arg, |
| 3645 | u32 cmd_id) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3646 | { |
| 3647 | struct wmi_vdev_start_request_cmd *cmd; |
| 3648 | struct sk_buff *skb; |
| 3649 | const char *cmdname; |
| 3650 | u32 flags = 0; |
| 3651 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3652 | if (cmd_id != ar->wmi.cmd->vdev_start_request_cmdid && |
| 3653 | cmd_id != ar->wmi.cmd->vdev_restart_request_cmdid) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3654 | return -EINVAL; |
| 3655 | if (WARN_ON(arg->ssid && arg->ssid_len == 0)) |
| 3656 | return -EINVAL; |
| 3657 | if (WARN_ON(arg->hidden_ssid && !arg->ssid)) |
| 3658 | return -EINVAL; |
| 3659 | if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid))) |
| 3660 | return -EINVAL; |
| 3661 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3662 | if (cmd_id == ar->wmi.cmd->vdev_start_request_cmdid) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3663 | cmdname = "start"; |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3664 | else if (cmd_id == ar->wmi.cmd->vdev_restart_request_cmdid) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3665 | cmdname = "restart"; |
| 3666 | else |
| 3667 | return -EINVAL; /* should not happen, we already check cmd_id */ |
| 3668 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3669 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3670 | if (!skb) |
| 3671 | return -ENOMEM; |
| 3672 | |
| 3673 | if (arg->hidden_ssid) |
| 3674 | flags |= WMI_VDEV_START_HIDDEN_SSID; |
| 3675 | if (arg->pmf_enabled) |
| 3676 | flags |= WMI_VDEV_START_PMF_ENABLED; |
| 3677 | |
| 3678 | cmd = (struct wmi_vdev_start_request_cmd *)skb->data; |
| 3679 | cmd->vdev_id = __cpu_to_le32(arg->vdev_id); |
| 3680 | cmd->disable_hw_ack = __cpu_to_le32(arg->disable_hw_ack); |
| 3681 | cmd->beacon_interval = __cpu_to_le32(arg->bcn_intval); |
| 3682 | cmd->dtim_period = __cpu_to_le32(arg->dtim_period); |
| 3683 | cmd->flags = __cpu_to_le32(flags); |
| 3684 | cmd->bcn_tx_rate = __cpu_to_le32(arg->bcn_tx_rate); |
| 3685 | cmd->bcn_tx_power = __cpu_to_le32(arg->bcn_tx_power); |
| 3686 | |
| 3687 | if (arg->ssid) { |
| 3688 | cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len); |
| 3689 | memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len); |
| 3690 | } |
| 3691 | |
Michal Kazior | 2d66721 | 2014-09-18 15:21:21 +0200 | [diff] [blame] | 3692 | ath10k_wmi_put_wmi_channel(&cmd->chan, &arg->channel); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3693 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3694 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 8cc7f26 | 2014-09-14 12:50:39 +0300 | [diff] [blame] | 3695 | "wmi vdev %s id 0x%x flags: 0x%0X, freq %d, mode %d, ch_flags: 0x%0X, max_power: %d\n", |
| 3696 | cmdname, arg->vdev_id, |
Marek Puzyniak | e8a50f8 | 2013-11-20 09:59:47 +0200 | [diff] [blame] | 3697 | flags, arg->channel.freq, arg->channel.mode, |
| 3698 | cmd->chan.flags, arg->channel.max_power); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3699 | |
| 3700 | return ath10k_wmi_cmd_send(ar, skb, cmd_id); |
| 3701 | } |
| 3702 | |
| 3703 | int ath10k_wmi_vdev_start(struct ath10k *ar, |
| 3704 | const struct wmi_vdev_start_request_arg *arg) |
| 3705 | { |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3706 | u32 cmd_id = ar->wmi.cmd->vdev_start_request_cmdid; |
| 3707 | |
| 3708 | return ath10k_wmi_vdev_start_restart(ar, arg, cmd_id); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3709 | } |
| 3710 | |
| 3711 | int ath10k_wmi_vdev_restart(struct ath10k *ar, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 3712 | const struct wmi_vdev_start_request_arg *arg) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3713 | { |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3714 | u32 cmd_id = ar->wmi.cmd->vdev_restart_request_cmdid; |
| 3715 | |
| 3716 | return ath10k_wmi_vdev_start_restart(ar, arg, cmd_id); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3717 | } |
| 3718 | |
| 3719 | int ath10k_wmi_vdev_stop(struct ath10k *ar, u32 vdev_id) |
| 3720 | { |
| 3721 | struct wmi_vdev_stop_cmd *cmd; |
| 3722 | struct sk_buff *skb; |
| 3723 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3724 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3725 | if (!skb) |
| 3726 | return -ENOMEM; |
| 3727 | |
| 3728 | cmd = (struct wmi_vdev_stop_cmd *)skb->data; |
| 3729 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3730 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3731 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi vdev stop id 0x%x\n", vdev_id); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3732 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3733 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_stop_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3734 | } |
| 3735 | |
| 3736 | int ath10k_wmi_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid, const u8 *bssid) |
| 3737 | { |
| 3738 | struct wmi_vdev_up_cmd *cmd; |
| 3739 | struct sk_buff *skb; |
| 3740 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3741 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3742 | if (!skb) |
| 3743 | return -ENOMEM; |
| 3744 | |
| 3745 | cmd = (struct wmi_vdev_up_cmd *)skb->data; |
| 3746 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3747 | cmd->vdev_assoc_id = __cpu_to_le32(aid); |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3748 | ether_addr_copy(cmd->vdev_bssid.addr, bssid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3749 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3750 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3751 | "wmi mgmt vdev up id 0x%x assoc id %d bssid %pM\n", |
| 3752 | vdev_id, aid, bssid); |
| 3753 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3754 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_up_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3755 | } |
| 3756 | |
| 3757 | int ath10k_wmi_vdev_down(struct ath10k *ar, u32 vdev_id) |
| 3758 | { |
| 3759 | struct wmi_vdev_down_cmd *cmd; |
| 3760 | struct sk_buff *skb; |
| 3761 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3762 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3763 | if (!skb) |
| 3764 | return -ENOMEM; |
| 3765 | |
| 3766 | cmd = (struct wmi_vdev_down_cmd *)skb->data; |
| 3767 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3768 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3769 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3770 | "wmi mgmt vdev down id 0x%x\n", vdev_id); |
| 3771 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3772 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_down_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3773 | } |
| 3774 | |
| 3775 | int ath10k_wmi_vdev_set_param(struct ath10k *ar, u32 vdev_id, |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 3776 | u32 param_id, u32 param_value) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3777 | { |
| 3778 | struct wmi_vdev_set_param_cmd *cmd; |
| 3779 | struct sk_buff *skb; |
| 3780 | |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 3781 | if (param_id == WMI_VDEV_PARAM_UNSUPPORTED) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3782 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 3783 | "vdev param %d not supported by firmware\n", |
| 3784 | param_id); |
Bartosz Markowski | ebc9abd | 2013-10-15 09:26:20 +0200 | [diff] [blame] | 3785 | return -EOPNOTSUPP; |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 3786 | } |
| 3787 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3788 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3789 | if (!skb) |
| 3790 | return -ENOMEM; |
| 3791 | |
| 3792 | cmd = (struct wmi_vdev_set_param_cmd *)skb->data; |
| 3793 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3794 | cmd->param_id = __cpu_to_le32(param_id); |
| 3795 | cmd->param_value = __cpu_to_le32(param_value); |
| 3796 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3797 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3798 | "wmi vdev id 0x%x set param %d value %d\n", |
| 3799 | vdev_id, param_id, param_value); |
| 3800 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3801 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_set_param_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3802 | } |
| 3803 | |
| 3804 | int ath10k_wmi_vdev_install_key(struct ath10k *ar, |
| 3805 | const struct wmi_vdev_install_key_arg *arg) |
| 3806 | { |
| 3807 | struct wmi_vdev_install_key_cmd *cmd; |
| 3808 | struct sk_buff *skb; |
| 3809 | |
| 3810 | if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL) |
| 3811 | return -EINVAL; |
| 3812 | if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL) |
| 3813 | return -EINVAL; |
| 3814 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3815 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd) + arg->key_len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3816 | if (!skb) |
| 3817 | return -ENOMEM; |
| 3818 | |
| 3819 | cmd = (struct wmi_vdev_install_key_cmd *)skb->data; |
| 3820 | cmd->vdev_id = __cpu_to_le32(arg->vdev_id); |
| 3821 | cmd->key_idx = __cpu_to_le32(arg->key_idx); |
| 3822 | cmd->key_flags = __cpu_to_le32(arg->key_flags); |
| 3823 | cmd->key_cipher = __cpu_to_le32(arg->key_cipher); |
| 3824 | cmd->key_len = __cpu_to_le32(arg->key_len); |
| 3825 | cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len); |
| 3826 | cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len); |
| 3827 | |
| 3828 | if (arg->macaddr) |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3829 | ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3830 | if (arg->key_data) |
| 3831 | memcpy(cmd->key_data, arg->key_data, arg->key_len); |
| 3832 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3833 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Michal Kazior | e0c508a | 2013-07-05 16:15:17 +0300 | [diff] [blame] | 3834 | "wmi vdev install key idx %d cipher %d len %d\n", |
| 3835 | arg->key_idx, arg->key_cipher, arg->key_len); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3836 | return ath10k_wmi_cmd_send(ar, skb, |
| 3837 | ar->wmi.cmd->vdev_install_key_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3838 | } |
| 3839 | |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 3840 | int ath10k_wmi_vdev_spectral_conf(struct ath10k *ar, |
| 3841 | const struct wmi_vdev_spectral_conf_arg *arg) |
| 3842 | { |
| 3843 | struct wmi_vdev_spectral_conf_cmd *cmd; |
| 3844 | struct sk_buff *skb; |
| 3845 | u32 cmdid; |
| 3846 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3847 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 3848 | if (!skb) |
| 3849 | return -ENOMEM; |
| 3850 | |
| 3851 | cmd = (struct wmi_vdev_spectral_conf_cmd *)skb->data; |
| 3852 | cmd->vdev_id = __cpu_to_le32(arg->vdev_id); |
| 3853 | cmd->scan_count = __cpu_to_le32(arg->scan_count); |
| 3854 | cmd->scan_period = __cpu_to_le32(arg->scan_period); |
| 3855 | cmd->scan_priority = __cpu_to_le32(arg->scan_priority); |
| 3856 | cmd->scan_fft_size = __cpu_to_le32(arg->scan_fft_size); |
| 3857 | cmd->scan_gc_ena = __cpu_to_le32(arg->scan_gc_ena); |
| 3858 | cmd->scan_restart_ena = __cpu_to_le32(arg->scan_restart_ena); |
| 3859 | cmd->scan_noise_floor_ref = __cpu_to_le32(arg->scan_noise_floor_ref); |
| 3860 | cmd->scan_init_delay = __cpu_to_le32(arg->scan_init_delay); |
| 3861 | cmd->scan_nb_tone_thr = __cpu_to_le32(arg->scan_nb_tone_thr); |
| 3862 | cmd->scan_str_bin_thr = __cpu_to_le32(arg->scan_str_bin_thr); |
| 3863 | cmd->scan_wb_rpt_mode = __cpu_to_le32(arg->scan_wb_rpt_mode); |
| 3864 | cmd->scan_rssi_rpt_mode = __cpu_to_le32(arg->scan_rssi_rpt_mode); |
| 3865 | cmd->scan_rssi_thr = __cpu_to_le32(arg->scan_rssi_thr); |
| 3866 | cmd->scan_pwr_format = __cpu_to_le32(arg->scan_pwr_format); |
| 3867 | cmd->scan_rpt_mode = __cpu_to_le32(arg->scan_rpt_mode); |
| 3868 | cmd->scan_bin_scale = __cpu_to_le32(arg->scan_bin_scale); |
| 3869 | cmd->scan_dbm_adj = __cpu_to_le32(arg->scan_dbm_adj); |
| 3870 | cmd->scan_chn_mask = __cpu_to_le32(arg->scan_chn_mask); |
| 3871 | |
| 3872 | cmdid = ar->wmi.cmd->vdev_spectral_scan_configure_cmdid; |
| 3873 | return ath10k_wmi_cmd_send(ar, skb, cmdid); |
| 3874 | } |
| 3875 | |
| 3876 | int ath10k_wmi_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id, u32 trigger, |
| 3877 | u32 enable) |
| 3878 | { |
| 3879 | struct wmi_vdev_spectral_enable_cmd *cmd; |
| 3880 | struct sk_buff *skb; |
| 3881 | u32 cmdid; |
| 3882 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3883 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 3884 | if (!skb) |
| 3885 | return -ENOMEM; |
| 3886 | |
| 3887 | cmd = (struct wmi_vdev_spectral_enable_cmd *)skb->data; |
| 3888 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3889 | cmd->trigger_cmd = __cpu_to_le32(trigger); |
| 3890 | cmd->enable_cmd = __cpu_to_le32(enable); |
| 3891 | |
| 3892 | cmdid = ar->wmi.cmd->vdev_spectral_scan_enable_cmdid; |
| 3893 | return ath10k_wmi_cmd_send(ar, skb, cmdid); |
| 3894 | } |
| 3895 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3896 | int ath10k_wmi_peer_create(struct ath10k *ar, u32 vdev_id, |
| 3897 | const u8 peer_addr[ETH_ALEN]) |
| 3898 | { |
| 3899 | struct wmi_peer_create_cmd *cmd; |
| 3900 | struct sk_buff *skb; |
| 3901 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3902 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3903 | if (!skb) |
| 3904 | return -ENOMEM; |
| 3905 | |
| 3906 | cmd = (struct wmi_peer_create_cmd *)skb->data; |
| 3907 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3908 | ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3909 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3910 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3911 | "wmi peer create vdev_id %d peer_addr %pM\n", |
| 3912 | vdev_id, peer_addr); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3913 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_create_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3914 | } |
| 3915 | |
| 3916 | int ath10k_wmi_peer_delete(struct ath10k *ar, u32 vdev_id, |
| 3917 | const u8 peer_addr[ETH_ALEN]) |
| 3918 | { |
| 3919 | struct wmi_peer_delete_cmd *cmd; |
| 3920 | struct sk_buff *skb; |
| 3921 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3922 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3923 | if (!skb) |
| 3924 | return -ENOMEM; |
| 3925 | |
| 3926 | cmd = (struct wmi_peer_delete_cmd *)skb->data; |
| 3927 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3928 | ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3929 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3930 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3931 | "wmi peer delete vdev_id %d peer_addr %pM\n", |
| 3932 | vdev_id, peer_addr); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3933 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_delete_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3934 | } |
| 3935 | |
| 3936 | int ath10k_wmi_peer_flush(struct ath10k *ar, u32 vdev_id, |
| 3937 | const u8 peer_addr[ETH_ALEN], u32 tid_bitmap) |
| 3938 | { |
| 3939 | struct wmi_peer_flush_tids_cmd *cmd; |
| 3940 | struct sk_buff *skb; |
| 3941 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3942 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3943 | if (!skb) |
| 3944 | return -ENOMEM; |
| 3945 | |
| 3946 | cmd = (struct wmi_peer_flush_tids_cmd *)skb->data; |
| 3947 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3948 | cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap); |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3949 | ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3950 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3951 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3952 | "wmi peer flush vdev_id %d peer_addr %pM tids %08x\n", |
| 3953 | vdev_id, peer_addr, tid_bitmap); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3954 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_flush_tids_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3955 | } |
| 3956 | |
| 3957 | int ath10k_wmi_peer_set_param(struct ath10k *ar, u32 vdev_id, |
| 3958 | const u8 *peer_addr, enum wmi_peer_param param_id, |
| 3959 | u32 param_value) |
| 3960 | { |
| 3961 | struct wmi_peer_set_param_cmd *cmd; |
| 3962 | struct sk_buff *skb; |
| 3963 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3964 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3965 | if (!skb) |
| 3966 | return -ENOMEM; |
| 3967 | |
| 3968 | cmd = (struct wmi_peer_set_param_cmd *)skb->data; |
| 3969 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3970 | cmd->param_id = __cpu_to_le32(param_id); |
| 3971 | cmd->param_value = __cpu_to_le32(param_value); |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3972 | ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3973 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3974 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3975 | "wmi vdev %d peer 0x%pM set param %d value %d\n", |
| 3976 | vdev_id, peer_addr, param_id, param_value); |
| 3977 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3978 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_set_param_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3979 | } |
| 3980 | |
| 3981 | int ath10k_wmi_set_psmode(struct ath10k *ar, u32 vdev_id, |
| 3982 | enum wmi_sta_ps_mode psmode) |
| 3983 | { |
| 3984 | struct wmi_sta_powersave_mode_cmd *cmd; |
| 3985 | struct sk_buff *skb; |
| 3986 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3987 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3988 | if (!skb) |
| 3989 | return -ENOMEM; |
| 3990 | |
| 3991 | cmd = (struct wmi_sta_powersave_mode_cmd *)skb->data; |
| 3992 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3993 | cmd->sta_ps_mode = __cpu_to_le32(psmode); |
| 3994 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3995 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3996 | "wmi set powersave id 0x%x mode %d\n", |
| 3997 | vdev_id, psmode); |
| 3998 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3999 | return ath10k_wmi_cmd_send(ar, skb, |
| 4000 | ar->wmi.cmd->sta_powersave_mode_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4001 | } |
| 4002 | |
| 4003 | int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id, |
| 4004 | enum wmi_sta_powersave_param param_id, |
| 4005 | u32 value) |
| 4006 | { |
| 4007 | struct wmi_sta_powersave_param_cmd *cmd; |
| 4008 | struct sk_buff *skb; |
| 4009 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4010 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4011 | if (!skb) |
| 4012 | return -ENOMEM; |
| 4013 | |
| 4014 | cmd = (struct wmi_sta_powersave_param_cmd *)skb->data; |
| 4015 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 4016 | cmd->param_id = __cpu_to_le32(param_id); |
| 4017 | cmd->param_value = __cpu_to_le32(value); |
| 4018 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4019 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4020 | "wmi sta ps param vdev_id 0x%x param %d value %d\n", |
| 4021 | vdev_id, param_id, value); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 4022 | return ath10k_wmi_cmd_send(ar, skb, |
| 4023 | ar->wmi.cmd->sta_powersave_param_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4024 | } |
| 4025 | |
| 4026 | int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac, |
| 4027 | enum wmi_ap_ps_peer_param param_id, u32 value) |
| 4028 | { |
| 4029 | struct wmi_ap_ps_peer_cmd *cmd; |
| 4030 | struct sk_buff *skb; |
| 4031 | |
| 4032 | if (!mac) |
| 4033 | return -EINVAL; |
| 4034 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4035 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4036 | if (!skb) |
| 4037 | return -ENOMEM; |
| 4038 | |
| 4039 | cmd = (struct wmi_ap_ps_peer_cmd *)skb->data; |
| 4040 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 4041 | cmd->param_id = __cpu_to_le32(param_id); |
| 4042 | cmd->param_value = __cpu_to_le32(value); |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 4043 | ether_addr_copy(cmd->peer_macaddr.addr, mac); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4044 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4045 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4046 | "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr %pM\n", |
| 4047 | vdev_id, param_id, value, mac); |
| 4048 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 4049 | return ath10k_wmi_cmd_send(ar, skb, |
| 4050 | ar->wmi.cmd->ap_ps_peer_param_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4051 | } |
| 4052 | |
| 4053 | int ath10k_wmi_scan_chan_list(struct ath10k *ar, |
| 4054 | const struct wmi_scan_chan_list_arg *arg) |
| 4055 | { |
| 4056 | struct wmi_scan_chan_list_cmd *cmd; |
| 4057 | struct sk_buff *skb; |
| 4058 | struct wmi_channel_arg *ch; |
| 4059 | struct wmi_channel *ci; |
| 4060 | int len; |
| 4061 | int i; |
| 4062 | |
| 4063 | len = sizeof(*cmd) + arg->n_channels * sizeof(struct wmi_channel); |
| 4064 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4065 | skb = ath10k_wmi_alloc_skb(ar, len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4066 | if (!skb) |
| 4067 | return -EINVAL; |
| 4068 | |
| 4069 | cmd = (struct wmi_scan_chan_list_cmd *)skb->data; |
| 4070 | cmd->num_scan_chans = __cpu_to_le32(arg->n_channels); |
| 4071 | |
| 4072 | for (i = 0; i < arg->n_channels; i++) { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4073 | ch = &arg->channels[i]; |
| 4074 | ci = &cmd->chan_info[i]; |
| 4075 | |
Michal Kazior | 2d66721 | 2014-09-18 15:21:21 +0200 | [diff] [blame] | 4076 | ath10k_wmi_put_wmi_channel(ci, ch); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4077 | } |
| 4078 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 4079 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->scan_chan_list_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4080 | } |
| 4081 | |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 4082 | static void |
| 4083 | ath10k_wmi_peer_assoc_fill(struct ath10k *ar, void *buf, |
| 4084 | const struct wmi_peer_assoc_complete_arg *arg) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4085 | { |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 4086 | struct wmi_common_peer_assoc_complete_cmd *cmd = buf; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4087 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4088 | cmd->vdev_id = __cpu_to_le32(arg->vdev_id); |
| 4089 | cmd->peer_new_assoc = __cpu_to_le32(arg->peer_reassoc ? 0 : 1); |
| 4090 | cmd->peer_associd = __cpu_to_le32(arg->peer_aid); |
| 4091 | cmd->peer_flags = __cpu_to_le32(arg->peer_flags); |
| 4092 | cmd->peer_caps = __cpu_to_le32(arg->peer_caps); |
| 4093 | cmd->peer_listen_intval = __cpu_to_le32(arg->peer_listen_intval); |
| 4094 | cmd->peer_ht_caps = __cpu_to_le32(arg->peer_ht_caps); |
| 4095 | cmd->peer_max_mpdu = __cpu_to_le32(arg->peer_max_mpdu); |
| 4096 | cmd->peer_mpdu_density = __cpu_to_le32(arg->peer_mpdu_density); |
| 4097 | cmd->peer_rate_caps = __cpu_to_le32(arg->peer_rate_caps); |
| 4098 | cmd->peer_nss = __cpu_to_le32(arg->peer_num_spatial_streams); |
| 4099 | cmd->peer_vht_caps = __cpu_to_le32(arg->peer_vht_caps); |
| 4100 | cmd->peer_phymode = __cpu_to_le32(arg->peer_phymode); |
| 4101 | |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 4102 | ether_addr_copy(cmd->peer_macaddr.addr, arg->addr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4103 | |
| 4104 | cmd->peer_legacy_rates.num_rates = |
| 4105 | __cpu_to_le32(arg->peer_legacy_rates.num_rates); |
| 4106 | memcpy(cmd->peer_legacy_rates.rates, arg->peer_legacy_rates.rates, |
| 4107 | arg->peer_legacy_rates.num_rates); |
| 4108 | |
| 4109 | cmd->peer_ht_rates.num_rates = |
| 4110 | __cpu_to_le32(arg->peer_ht_rates.num_rates); |
| 4111 | memcpy(cmd->peer_ht_rates.rates, arg->peer_ht_rates.rates, |
| 4112 | arg->peer_ht_rates.num_rates); |
| 4113 | |
| 4114 | cmd->peer_vht_rates.rx_max_rate = |
| 4115 | __cpu_to_le32(arg->peer_vht_rates.rx_max_rate); |
| 4116 | cmd->peer_vht_rates.rx_mcs_set = |
| 4117 | __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set); |
| 4118 | cmd->peer_vht_rates.tx_max_rate = |
| 4119 | __cpu_to_le32(arg->peer_vht_rates.tx_max_rate); |
| 4120 | cmd->peer_vht_rates.tx_mcs_set = |
| 4121 | __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 4122 | } |
| 4123 | |
| 4124 | static void |
| 4125 | ath10k_wmi_peer_assoc_fill_main(struct ath10k *ar, void *buf, |
| 4126 | const struct wmi_peer_assoc_complete_arg *arg) |
| 4127 | { |
| 4128 | struct wmi_main_peer_assoc_complete_cmd *cmd = buf; |
| 4129 | |
| 4130 | ath10k_wmi_peer_assoc_fill(ar, buf, arg); |
| 4131 | memset(cmd->peer_ht_info, 0, sizeof(cmd->peer_ht_info)); |
| 4132 | } |
| 4133 | |
| 4134 | static void |
| 4135 | ath10k_wmi_peer_assoc_fill_10_1(struct ath10k *ar, void *buf, |
| 4136 | const struct wmi_peer_assoc_complete_arg *arg) |
| 4137 | { |
| 4138 | ath10k_wmi_peer_assoc_fill(ar, buf, arg); |
| 4139 | } |
| 4140 | |
| 4141 | static void |
| 4142 | ath10k_wmi_peer_assoc_fill_10_2(struct ath10k *ar, void *buf, |
| 4143 | const struct wmi_peer_assoc_complete_arg *arg) |
| 4144 | { |
| 4145 | struct wmi_10_2_peer_assoc_complete_cmd *cmd = buf; |
| 4146 | int max_mcs, max_nss; |
| 4147 | u32 info0; |
| 4148 | |
| 4149 | /* TODO: Is using max values okay with firmware? */ |
| 4150 | max_mcs = 0xf; |
| 4151 | max_nss = 0xf; |
| 4152 | |
| 4153 | info0 = SM(max_mcs, WMI_PEER_ASSOC_INFO0_MAX_MCS_IDX) | |
| 4154 | SM(max_nss, WMI_PEER_ASSOC_INFO0_MAX_NSS); |
| 4155 | |
| 4156 | ath10k_wmi_peer_assoc_fill(ar, buf, arg); |
| 4157 | cmd->info0 = __cpu_to_le32(info0); |
| 4158 | } |
| 4159 | |
| 4160 | int ath10k_wmi_peer_assoc(struct ath10k *ar, |
| 4161 | const struct wmi_peer_assoc_complete_arg *arg) |
| 4162 | { |
| 4163 | struct sk_buff *skb; |
| 4164 | int len; |
| 4165 | |
| 4166 | if (arg->peer_mpdu_density > 16) |
| 4167 | return -EINVAL; |
| 4168 | if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES) |
| 4169 | return -EINVAL; |
| 4170 | if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES) |
| 4171 | return -EINVAL; |
| 4172 | |
| 4173 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { |
| 4174 | if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features)) |
| 4175 | len = sizeof(struct wmi_10_2_peer_assoc_complete_cmd); |
| 4176 | else |
| 4177 | len = sizeof(struct wmi_10_1_peer_assoc_complete_cmd); |
| 4178 | } else { |
| 4179 | len = sizeof(struct wmi_main_peer_assoc_complete_cmd); |
| 4180 | } |
| 4181 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4182 | skb = ath10k_wmi_alloc_skb(ar, len); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 4183 | if (!skb) |
| 4184 | return -ENOMEM; |
| 4185 | |
| 4186 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { |
| 4187 | if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features)) |
| 4188 | ath10k_wmi_peer_assoc_fill_10_1(ar, skb->data, arg); |
| 4189 | else |
| 4190 | ath10k_wmi_peer_assoc_fill_10_2(ar, skb->data, arg); |
| 4191 | } else { |
| 4192 | ath10k_wmi_peer_assoc_fill_main(ar, skb->data, arg); |
| 4193 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4194 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4195 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Chun-Yeow Yeoh | 44d6fa9 | 2014-03-07 10:19:30 +0200 | [diff] [blame] | 4196 | "wmi peer assoc vdev %d addr %pM (%s)\n", |
| 4197 | arg->vdev_id, arg->addr, |
| 4198 | arg->peer_reassoc ? "reassociate" : "new"); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 4199 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_assoc_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4200 | } |
| 4201 | |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 4202 | /* This function assumes the beacon is already DMA mapped */ |
| 4203 | int ath10k_wmi_beacon_send_ref_nowait(struct ath10k_vif *arvif) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4204 | { |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 4205 | struct wmi_bcn_tx_ref_cmd *cmd; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4206 | struct sk_buff *skb; |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 4207 | struct sk_buff *beacon = arvif->beacon; |
| 4208 | struct ath10k *ar = arvif->ar; |
| 4209 | struct ieee80211_hdr *hdr; |
Michal Kazior | e204548 | 2013-10-28 07:18:14 +0100 | [diff] [blame] | 4210 | int ret; |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 4211 | u16 fc; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4212 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4213 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4214 | if (!skb) |
| 4215 | return -ENOMEM; |
| 4216 | |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 4217 | hdr = (struct ieee80211_hdr *)beacon->data; |
| 4218 | fc = le16_to_cpu(hdr->frame_control); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4219 | |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 4220 | cmd = (struct wmi_bcn_tx_ref_cmd *)skb->data; |
| 4221 | cmd->vdev_id = __cpu_to_le32(arvif->vdev_id); |
| 4222 | cmd->data_len = __cpu_to_le32(beacon->len); |
| 4223 | cmd->data_ptr = __cpu_to_le32(ATH10K_SKB_CB(beacon)->paddr); |
| 4224 | cmd->msdu_id = 0; |
| 4225 | cmd->frame_control = __cpu_to_le32(fc); |
| 4226 | cmd->flags = 0; |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 4227 | cmd->antenna_mask = __cpu_to_le32(WMI_BCN_TX_REF_DEF_ANTENNA); |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 4228 | |
| 4229 | if (ATH10K_SKB_CB(beacon)->bcn.dtim_zero) |
| 4230 | cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DTIM_ZERO); |
| 4231 | |
| 4232 | if (ATH10K_SKB_CB(beacon)->bcn.deliver_cab) |
| 4233 | cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB); |
| 4234 | |
| 4235 | ret = ath10k_wmi_cmd_send_nowait(ar, skb, |
| 4236 | ar->wmi.cmd->pdev_send_bcn_cmdid); |
| 4237 | |
Michal Kazior | e204548 | 2013-10-28 07:18:14 +0100 | [diff] [blame] | 4238 | if (ret) |
| 4239 | dev_kfree_skb(skb); |
| 4240 | |
| 4241 | return ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4242 | } |
| 4243 | |
| 4244 | static void ath10k_wmi_pdev_set_wmm_param(struct wmi_wmm_params *params, |
| 4245 | const struct wmi_wmm_params_arg *arg) |
| 4246 | { |
| 4247 | params->cwmin = __cpu_to_le32(arg->cwmin); |
| 4248 | params->cwmax = __cpu_to_le32(arg->cwmax); |
| 4249 | params->aifs = __cpu_to_le32(arg->aifs); |
| 4250 | params->txop = __cpu_to_le32(arg->txop); |
| 4251 | params->acm = __cpu_to_le32(arg->acm); |
| 4252 | params->no_ack = __cpu_to_le32(arg->no_ack); |
| 4253 | } |
| 4254 | |
| 4255 | int ath10k_wmi_pdev_set_wmm_params(struct ath10k *ar, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 4256 | const struct wmi_pdev_set_wmm_params_arg *arg) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4257 | { |
| 4258 | struct wmi_pdev_set_wmm_params *cmd; |
| 4259 | struct sk_buff *skb; |
| 4260 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4261 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4262 | if (!skb) |
| 4263 | return -ENOMEM; |
| 4264 | |
| 4265 | cmd = (struct wmi_pdev_set_wmm_params *)skb->data; |
| 4266 | ath10k_wmi_pdev_set_wmm_param(&cmd->ac_be, &arg->ac_be); |
| 4267 | ath10k_wmi_pdev_set_wmm_param(&cmd->ac_bk, &arg->ac_bk); |
| 4268 | ath10k_wmi_pdev_set_wmm_param(&cmd->ac_vi, &arg->ac_vi); |
| 4269 | ath10k_wmi_pdev_set_wmm_param(&cmd->ac_vo, &arg->ac_vo); |
| 4270 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4271 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set wmm params\n"); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 4272 | return ath10k_wmi_cmd_send(ar, skb, |
| 4273 | ar->wmi.cmd->pdev_set_wmm_params_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4274 | } |
| 4275 | |
| 4276 | int ath10k_wmi_request_stats(struct ath10k *ar, enum wmi_stats_id stats_id) |
| 4277 | { |
| 4278 | struct wmi_request_stats_cmd *cmd; |
| 4279 | struct sk_buff *skb; |
| 4280 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4281 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4282 | if (!skb) |
| 4283 | return -ENOMEM; |
| 4284 | |
| 4285 | cmd = (struct wmi_request_stats_cmd *)skb->data; |
| 4286 | cmd->stats_id = __cpu_to_le32(stats_id); |
| 4287 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4288 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi request stats %d\n", (int)stats_id); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 4289 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->request_stats_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4290 | } |
Michal Kazior | 9cfbce7 | 2013-07-16 09:54:36 +0200 | [diff] [blame] | 4291 | |
| 4292 | int ath10k_wmi_force_fw_hang(struct ath10k *ar, |
| 4293 | enum wmi_force_fw_hang_type type, u32 delay_ms) |
| 4294 | { |
| 4295 | struct wmi_force_fw_hang_cmd *cmd; |
| 4296 | struct sk_buff *skb; |
| 4297 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4298 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Michal Kazior | 9cfbce7 | 2013-07-16 09:54:36 +0200 | [diff] [blame] | 4299 | if (!skb) |
| 4300 | return -ENOMEM; |
| 4301 | |
| 4302 | cmd = (struct wmi_force_fw_hang_cmd *)skb->data; |
| 4303 | cmd->type = __cpu_to_le32(type); |
| 4304 | cmd->delay_ms = __cpu_to_le32(delay_ms); |
| 4305 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4306 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi force fw hang %d delay %d\n", |
Michal Kazior | 9cfbce7 | 2013-07-16 09:54:36 +0200 | [diff] [blame] | 4307 | type, delay_ms); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 4308 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->force_fw_hang_cmdid); |
Michal Kazior | 9cfbce7 | 2013-07-16 09:54:36 +0200 | [diff] [blame] | 4309 | } |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 4310 | |
| 4311 | int ath10k_wmi_dbglog_cfg(struct ath10k *ar, u32 module_enable) |
| 4312 | { |
| 4313 | struct wmi_dbglog_cfg_cmd *cmd; |
| 4314 | struct sk_buff *skb; |
| 4315 | u32 cfg; |
| 4316 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4317 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 4318 | if (!skb) |
| 4319 | return -ENOMEM; |
| 4320 | |
| 4321 | cmd = (struct wmi_dbglog_cfg_cmd *)skb->data; |
| 4322 | |
| 4323 | if (module_enable) { |
| 4324 | cfg = SM(ATH10K_DBGLOG_LEVEL_VERBOSE, |
| 4325 | ATH10K_DBGLOG_CFG_LOG_LVL); |
| 4326 | } else { |
| 4327 | /* set back defaults, all modules with WARN level */ |
| 4328 | cfg = SM(ATH10K_DBGLOG_LEVEL_WARN, |
| 4329 | ATH10K_DBGLOG_CFG_LOG_LVL); |
| 4330 | module_enable = ~0; |
| 4331 | } |
| 4332 | |
| 4333 | cmd->module_enable = __cpu_to_le32(module_enable); |
| 4334 | cmd->module_valid = __cpu_to_le32(~0); |
| 4335 | cmd->config_enable = __cpu_to_le32(cfg); |
| 4336 | cmd->config_valid = __cpu_to_le32(ATH10K_DBGLOG_CFG_LOG_LVL_MASK); |
| 4337 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4338 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 4339 | "wmi dbglog cfg modules %08x %08x config %08x %08x\n", |
| 4340 | __le32_to_cpu(cmd->module_enable), |
| 4341 | __le32_to_cpu(cmd->module_valid), |
| 4342 | __le32_to_cpu(cmd->config_enable), |
| 4343 | __le32_to_cpu(cmd->config_valid)); |
| 4344 | |
| 4345 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->dbglog_cfg_cmdid); |
| 4346 | } |
Michal Kazior | b79b9ba | 2014-09-18 15:21:23 +0200 | [diff] [blame] | 4347 | |
Rajkumar Manoharan | 9017445 | 2014-10-03 08:02:33 +0300 | [diff] [blame^] | 4348 | int ath10k_wmi_pdev_pktlog_enable(struct ath10k *ar, u32 ev_bitmap) |
| 4349 | { |
| 4350 | struct wmi_pdev_pktlog_enable_cmd *cmd; |
| 4351 | struct sk_buff *skb; |
| 4352 | |
| 4353 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
| 4354 | if (!skb) |
| 4355 | return -ENOMEM; |
| 4356 | |
| 4357 | ev_bitmap &= ATH10K_PKTLOG_ANY; |
| 4358 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
| 4359 | "wmi enable pktlog filter:%x\n", ev_bitmap); |
| 4360 | |
| 4361 | cmd = (struct wmi_pdev_pktlog_enable_cmd *)skb->data; |
| 4362 | cmd->ev_bitmap = __cpu_to_le32(ev_bitmap); |
| 4363 | return ath10k_wmi_cmd_send(ar, skb, |
| 4364 | ar->wmi.cmd->pdev_pktlog_enable_cmdid); |
| 4365 | } |
| 4366 | |
| 4367 | int ath10k_wmi_pdev_pktlog_disable(struct ath10k *ar) |
| 4368 | { |
| 4369 | struct sk_buff *skb; |
| 4370 | |
| 4371 | skb = ath10k_wmi_alloc_skb(ar, 0); |
| 4372 | if (!skb) |
| 4373 | return -ENOMEM; |
| 4374 | |
| 4375 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi disable pktlog\n"); |
| 4376 | |
| 4377 | return ath10k_wmi_cmd_send(ar, skb, |
| 4378 | ar->wmi.cmd->pdev_pktlog_disable_cmdid); |
| 4379 | } |
| 4380 | |
Michal Kazior | b79b9ba | 2014-09-18 15:21:23 +0200 | [diff] [blame] | 4381 | int ath10k_wmi_attach(struct ath10k *ar) |
| 4382 | { |
| 4383 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { |
| 4384 | if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features)) |
| 4385 | ar->wmi.cmd = &wmi_10_2_cmd_map; |
| 4386 | else |
| 4387 | ar->wmi.cmd = &wmi_10x_cmd_map; |
| 4388 | |
| 4389 | ar->wmi.vdev_param = &wmi_10x_vdev_param_map; |
| 4390 | ar->wmi.pdev_param = &wmi_10x_pdev_param_map; |
| 4391 | } else { |
| 4392 | ar->wmi.cmd = &wmi_cmd_map; |
| 4393 | ar->wmi.vdev_param = &wmi_vdev_param_map; |
| 4394 | ar->wmi.pdev_param = &wmi_pdev_param_map; |
| 4395 | } |
| 4396 | |
| 4397 | init_completion(&ar->wmi.service_ready); |
| 4398 | init_completion(&ar->wmi.unified_ready); |
| 4399 | init_waitqueue_head(&ar->wmi.tx_credits_wq); |
| 4400 | |
| 4401 | return 0; |
| 4402 | } |
| 4403 | |
| 4404 | void ath10k_wmi_detach(struct ath10k *ar) |
| 4405 | { |
| 4406 | int i; |
| 4407 | |
| 4408 | /* free the host memory chunks requested by firmware */ |
| 4409 | for (i = 0; i < ar->wmi.num_mem_chunks; i++) { |
| 4410 | dma_free_coherent(ar->dev, |
| 4411 | ar->wmi.mem_chunks[i].len, |
| 4412 | ar->wmi.mem_chunks[i].vaddr, |
| 4413 | ar->wmi.mem_chunks[i].paddr); |
| 4414 | } |
| 4415 | |
| 4416 | ar->wmi.num_mem_chunks = 0; |
| 4417 | } |