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 | |
| 1332 | static void ath10k_wmi_event_update_stats(struct ath10k *ar, |
| 1333 | struct sk_buff *skb) |
| 1334 | { |
| 1335 | struct wmi_stats_event *ev = (struct wmi_stats_event *)skb->data; |
| 1336 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1337 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_UPDATE_STATS_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1338 | |
| 1339 | ath10k_debug_read_target_stats(ar, ev); |
| 1340 | } |
| 1341 | |
| 1342 | static void ath10k_wmi_event_vdev_start_resp(struct ath10k *ar, |
| 1343 | struct sk_buff *skb) |
| 1344 | { |
| 1345 | struct wmi_vdev_start_response_event *ev; |
| 1346 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1347 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_START_RESP_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1348 | |
| 1349 | ev = (struct wmi_vdev_start_response_event *)skb->data; |
| 1350 | |
| 1351 | if (WARN_ON(__le32_to_cpu(ev->status))) |
| 1352 | return; |
| 1353 | |
| 1354 | complete(&ar->vdev_setup_done); |
| 1355 | } |
| 1356 | |
| 1357 | static void ath10k_wmi_event_vdev_stopped(struct ath10k *ar, |
| 1358 | struct sk_buff *skb) |
| 1359 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1360 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STOPPED_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1361 | complete(&ar->vdev_setup_done); |
| 1362 | } |
| 1363 | |
| 1364 | static void ath10k_wmi_event_peer_sta_kickout(struct ath10k *ar, |
| 1365 | struct sk_buff *skb) |
| 1366 | { |
Kalle Valo | 5a13e76 | 2014-01-20 11:01:46 +0200 | [diff] [blame] | 1367 | struct wmi_peer_sta_kickout_event *ev; |
| 1368 | struct ieee80211_sta *sta; |
| 1369 | |
| 1370 | ev = (struct wmi_peer_sta_kickout_event *)skb->data; |
| 1371 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1372 | 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] | 1373 | ev->peer_macaddr.addr); |
| 1374 | |
| 1375 | rcu_read_lock(); |
| 1376 | |
| 1377 | sta = ieee80211_find_sta_by_ifaddr(ar->hw, ev->peer_macaddr.addr, NULL); |
| 1378 | if (!sta) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1379 | ath10k_warn(ar, "Spurious quick kickout for STA %pM\n", |
Kalle Valo | 5a13e76 | 2014-01-20 11:01:46 +0200 | [diff] [blame] | 1380 | ev->peer_macaddr.addr); |
| 1381 | goto exit; |
| 1382 | } |
| 1383 | |
| 1384 | ieee80211_report_low_ack(sta, 10); |
| 1385 | |
| 1386 | exit: |
| 1387 | rcu_read_unlock(); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1388 | } |
| 1389 | |
| 1390 | /* |
| 1391 | * FIXME |
| 1392 | * |
| 1393 | * We don't report to mac80211 sleep state of connected |
| 1394 | * stations. Due to this mac80211 can't fill in TIM IE |
| 1395 | * correctly. |
| 1396 | * |
| 1397 | * I know of no way of getting nullfunc frames that contain |
| 1398 | * sleep transition from connected stations - these do not |
| 1399 | * seem to be sent from the target to the host. There also |
| 1400 | * doesn't seem to be a dedicated event for that. So the |
| 1401 | * only way left to do this would be to read tim_bitmap |
| 1402 | * during SWBA. |
| 1403 | * |
| 1404 | * We could probably try using tim_bitmap from SWBA to tell |
| 1405 | * mac80211 which stations are asleep and which are not. The |
| 1406 | * problem here is calling mac80211 functions so many times |
| 1407 | * could take too long and make us miss the time to submit |
| 1408 | * the beacon to the target. |
| 1409 | * |
| 1410 | * So as a workaround we try to extend the TIM IE if there |
| 1411 | * is unicast buffered for stations with aid > 7 and fill it |
| 1412 | * in ourselves. |
| 1413 | */ |
| 1414 | static void ath10k_wmi_update_tim(struct ath10k *ar, |
| 1415 | struct ath10k_vif *arvif, |
| 1416 | struct sk_buff *bcn, |
| 1417 | struct wmi_bcn_info *bcn_info) |
| 1418 | { |
| 1419 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)bcn->data; |
| 1420 | struct ieee80211_tim_ie *tim; |
| 1421 | u8 *ies, *ie; |
| 1422 | u8 ie_len, pvm_len; |
Kalle Valo | af762c0 | 2014-09-14 12:50:17 +0300 | [diff] [blame] | 1423 | __le32 t; |
| 1424 | u32 v; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1425 | |
| 1426 | /* if next SWBA has no tim_changed the tim_bitmap is garbage. |
| 1427 | * we must copy the bitmap upon change and reuse it later */ |
| 1428 | if (__le32_to_cpu(bcn_info->tim_info.tim_changed)) { |
| 1429 | int i; |
| 1430 | |
| 1431 | BUILD_BUG_ON(sizeof(arvif->u.ap.tim_bitmap) != |
| 1432 | sizeof(bcn_info->tim_info.tim_bitmap)); |
| 1433 | |
| 1434 | for (i = 0; i < sizeof(arvif->u.ap.tim_bitmap); i++) { |
Kalle Valo | af762c0 | 2014-09-14 12:50:17 +0300 | [diff] [blame] | 1435 | t = bcn_info->tim_info.tim_bitmap[i / 4]; |
| 1436 | v = __le32_to_cpu(t); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1437 | arvif->u.ap.tim_bitmap[i] = (v >> ((i % 4) * 8)) & 0xFF; |
| 1438 | } |
| 1439 | |
| 1440 | /* FW reports either length 0 or 16 |
| 1441 | * so we calculate this on our own */ |
| 1442 | arvif->u.ap.tim_len = 0; |
| 1443 | for (i = 0; i < sizeof(arvif->u.ap.tim_bitmap); i++) |
| 1444 | if (arvif->u.ap.tim_bitmap[i]) |
| 1445 | arvif->u.ap.tim_len = i; |
| 1446 | |
| 1447 | arvif->u.ap.tim_len++; |
| 1448 | } |
| 1449 | |
| 1450 | ies = bcn->data; |
| 1451 | ies += ieee80211_hdrlen(hdr->frame_control); |
| 1452 | ies += 12; /* fixed parameters */ |
| 1453 | |
| 1454 | ie = (u8 *)cfg80211_find_ie(WLAN_EID_TIM, ies, |
| 1455 | (u8 *)skb_tail_pointer(bcn) - ies); |
| 1456 | if (!ie) { |
Michal Kazior | 09af8f8 | 2013-07-05 16:15:08 +0300 | [diff] [blame] | 1457 | if (arvif->vdev_type != WMI_VDEV_TYPE_IBSS) |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1458 | ath10k_warn(ar, "no tim ie found;\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1459 | return; |
| 1460 | } |
| 1461 | |
| 1462 | tim = (void *)ie + 2; |
| 1463 | ie_len = ie[1]; |
| 1464 | pvm_len = ie_len - 3; /* exclude dtim count, dtim period, bmap ctl */ |
| 1465 | |
| 1466 | if (pvm_len < arvif->u.ap.tim_len) { |
| 1467 | int expand_size = sizeof(arvif->u.ap.tim_bitmap) - pvm_len; |
| 1468 | int move_size = skb_tail_pointer(bcn) - (ie + 2 + ie_len); |
| 1469 | void *next_ie = ie + 2 + ie_len; |
| 1470 | |
| 1471 | if (skb_put(bcn, expand_size)) { |
| 1472 | memmove(next_ie + expand_size, next_ie, move_size); |
| 1473 | |
| 1474 | ie[1] += expand_size; |
| 1475 | ie_len += expand_size; |
| 1476 | pvm_len += expand_size; |
| 1477 | } else { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1478 | ath10k_warn(ar, "tim expansion failed\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1479 | } |
| 1480 | } |
| 1481 | |
| 1482 | if (pvm_len > sizeof(arvif->u.ap.tim_bitmap)) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1483 | 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] | 1484 | return; |
| 1485 | } |
| 1486 | |
| 1487 | tim->bitmap_ctrl = !!__le32_to_cpu(bcn_info->tim_info.tim_mcast); |
| 1488 | memcpy(tim->virtual_map, arvif->u.ap.tim_bitmap, pvm_len); |
| 1489 | |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 1490 | if (tim->dtim_count == 0) { |
| 1491 | ATH10K_SKB_CB(bcn)->bcn.dtim_zero = true; |
| 1492 | |
| 1493 | if (__le32_to_cpu(bcn_info->tim_info.tim_mcast) == 1) |
| 1494 | ATH10K_SKB_CB(bcn)->bcn.deliver_cab = true; |
| 1495 | } |
| 1496 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1497 | 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] | 1498 | tim->dtim_count, tim->dtim_period, |
| 1499 | tim->bitmap_ctrl, pvm_len); |
| 1500 | } |
| 1501 | |
| 1502 | static void ath10k_p2p_fill_noa_ie(u8 *data, u32 len, |
| 1503 | struct wmi_p2p_noa_info *noa) |
| 1504 | { |
| 1505 | struct ieee80211_p2p_noa_attr *noa_attr; |
| 1506 | u8 ctwindow_oppps = noa->ctwindow_oppps; |
| 1507 | u8 ctwindow = ctwindow_oppps >> WMI_P2P_OPPPS_CTWINDOW_OFFSET; |
| 1508 | bool oppps = !!(ctwindow_oppps & WMI_P2P_OPPPS_ENABLE_BIT); |
| 1509 | __le16 *noa_attr_len; |
| 1510 | u16 attr_len; |
| 1511 | u8 noa_descriptors = noa->num_descriptors; |
| 1512 | int i; |
| 1513 | |
| 1514 | /* P2P IE */ |
| 1515 | data[0] = WLAN_EID_VENDOR_SPECIFIC; |
| 1516 | data[1] = len - 2; |
| 1517 | data[2] = (WLAN_OUI_WFA >> 16) & 0xff; |
| 1518 | data[3] = (WLAN_OUI_WFA >> 8) & 0xff; |
| 1519 | data[4] = (WLAN_OUI_WFA >> 0) & 0xff; |
| 1520 | data[5] = WLAN_OUI_TYPE_WFA_P2P; |
| 1521 | |
| 1522 | /* NOA ATTR */ |
| 1523 | data[6] = IEEE80211_P2P_ATTR_ABSENCE_NOTICE; |
| 1524 | noa_attr_len = (__le16 *)&data[7]; /* 2 bytes */ |
| 1525 | noa_attr = (struct ieee80211_p2p_noa_attr *)&data[9]; |
| 1526 | |
| 1527 | noa_attr->index = noa->index; |
| 1528 | noa_attr->oppps_ctwindow = ctwindow; |
| 1529 | if (oppps) |
| 1530 | noa_attr->oppps_ctwindow |= IEEE80211_P2P_OPPPS_ENABLE_BIT; |
| 1531 | |
| 1532 | for (i = 0; i < noa_descriptors; i++) { |
| 1533 | noa_attr->desc[i].count = |
| 1534 | __le32_to_cpu(noa->descriptors[i].type_count); |
| 1535 | noa_attr->desc[i].duration = noa->descriptors[i].duration; |
| 1536 | noa_attr->desc[i].interval = noa->descriptors[i].interval; |
| 1537 | noa_attr->desc[i].start_time = noa->descriptors[i].start_time; |
| 1538 | } |
| 1539 | |
| 1540 | attr_len = 2; /* index + oppps_ctwindow */ |
| 1541 | attr_len += noa_descriptors * sizeof(struct ieee80211_p2p_noa_desc); |
| 1542 | *noa_attr_len = __cpu_to_le16(attr_len); |
| 1543 | } |
| 1544 | |
| 1545 | static u32 ath10k_p2p_calc_noa_ie_len(struct wmi_p2p_noa_info *noa) |
| 1546 | { |
| 1547 | u32 len = 0; |
| 1548 | u8 noa_descriptors = noa->num_descriptors; |
| 1549 | u8 opp_ps_info = noa->ctwindow_oppps; |
| 1550 | bool opps_enabled = !!(opp_ps_info & WMI_P2P_OPPPS_ENABLE_BIT); |
| 1551 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1552 | if (!noa_descriptors && !opps_enabled) |
| 1553 | return len; |
| 1554 | |
| 1555 | len += 1 + 1 + 4; /* EID + len + OUI */ |
| 1556 | len += 1 + 2; /* noa attr + attr len */ |
| 1557 | len += 1 + 1; /* index + oppps_ctwindow */ |
| 1558 | len += noa_descriptors * sizeof(struct ieee80211_p2p_noa_desc); |
| 1559 | |
| 1560 | return len; |
| 1561 | } |
| 1562 | |
| 1563 | static void ath10k_wmi_update_noa(struct ath10k *ar, struct ath10k_vif *arvif, |
| 1564 | struct sk_buff *bcn, |
| 1565 | struct wmi_bcn_info *bcn_info) |
| 1566 | { |
| 1567 | struct wmi_p2p_noa_info *noa = &bcn_info->p2p_noa_info; |
| 1568 | u8 *new_data, *old_data = arvif->u.ap.noa_data; |
| 1569 | u32 new_len; |
| 1570 | |
| 1571 | if (arvif->vdev_subtype != WMI_VDEV_SUBTYPE_P2P_GO) |
| 1572 | return; |
| 1573 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1574 | ath10k_dbg(ar, ATH10K_DBG_MGMT, "noa changed: %d\n", noa->changed); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1575 | if (noa->changed & WMI_P2P_NOA_CHANGED_BIT) { |
| 1576 | new_len = ath10k_p2p_calc_noa_ie_len(noa); |
| 1577 | if (!new_len) |
| 1578 | goto cleanup; |
| 1579 | |
| 1580 | new_data = kmalloc(new_len, GFP_ATOMIC); |
| 1581 | if (!new_data) |
| 1582 | goto cleanup; |
| 1583 | |
| 1584 | ath10k_p2p_fill_noa_ie(new_data, new_len, noa); |
| 1585 | |
| 1586 | spin_lock_bh(&ar->data_lock); |
| 1587 | arvif->u.ap.noa_data = new_data; |
| 1588 | arvif->u.ap.noa_len = new_len; |
| 1589 | spin_unlock_bh(&ar->data_lock); |
| 1590 | kfree(old_data); |
| 1591 | } |
| 1592 | |
| 1593 | if (arvif->u.ap.noa_data) |
| 1594 | if (!pskb_expand_head(bcn, 0, arvif->u.ap.noa_len, GFP_ATOMIC)) |
| 1595 | memcpy(skb_put(bcn, arvif->u.ap.noa_len), |
| 1596 | arvif->u.ap.noa_data, |
| 1597 | arvif->u.ap.noa_len); |
| 1598 | return; |
| 1599 | |
| 1600 | cleanup: |
| 1601 | spin_lock_bh(&ar->data_lock); |
| 1602 | arvif->u.ap.noa_data = NULL; |
| 1603 | arvif->u.ap.noa_len = 0; |
| 1604 | spin_unlock_bh(&ar->data_lock); |
| 1605 | kfree(old_data); |
| 1606 | } |
| 1607 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1608 | static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb) |
| 1609 | { |
| 1610 | struct wmi_host_swba_event *ev; |
| 1611 | u32 map; |
| 1612 | int i = -1; |
| 1613 | struct wmi_bcn_info *bcn_info; |
| 1614 | struct ath10k_vif *arvif; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1615 | struct sk_buff *bcn; |
Michal Kazior | 64badcb | 2014-09-18 11:18:02 +0300 | [diff] [blame] | 1616 | dma_addr_t paddr; |
Michal Kazior | 767d34f | 2014-02-27 18:50:03 +0200 | [diff] [blame] | 1617 | int ret, vdev_id = 0; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1618 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1619 | ev = (struct wmi_host_swba_event *)skb->data; |
| 1620 | map = __le32_to_cpu(ev->vdev_map); |
| 1621 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1622 | 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] | 1623 | ev->vdev_map); |
| 1624 | |
| 1625 | for (; map; map >>= 1, vdev_id++) { |
| 1626 | if (!(map & 0x1)) |
| 1627 | continue; |
| 1628 | |
| 1629 | i++; |
| 1630 | |
| 1631 | if (i >= WMI_MAX_AP_VDEV) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1632 | ath10k_warn(ar, "swba has corrupted vdev map\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1633 | break; |
| 1634 | } |
| 1635 | |
| 1636 | bcn_info = &ev->bcn_info[i]; |
| 1637 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1638 | ath10k_dbg(ar, ATH10K_DBG_MGMT, |
Kalle Valo | 7a8a396 | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 1639 | "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] | 1640 | i, |
| 1641 | __le32_to_cpu(bcn_info->tim_info.tim_len), |
| 1642 | __le32_to_cpu(bcn_info->tim_info.tim_mcast), |
| 1643 | __le32_to_cpu(bcn_info->tim_info.tim_changed), |
| 1644 | __le32_to_cpu(bcn_info->tim_info.tim_num_ps_pending), |
| 1645 | __le32_to_cpu(bcn_info->tim_info.tim_bitmap[3]), |
| 1646 | __le32_to_cpu(bcn_info->tim_info.tim_bitmap[2]), |
| 1647 | __le32_to_cpu(bcn_info->tim_info.tim_bitmap[1]), |
| 1648 | __le32_to_cpu(bcn_info->tim_info.tim_bitmap[0])); |
| 1649 | |
| 1650 | arvif = ath10k_get_arvif(ar, vdev_id); |
| 1651 | if (arvif == NULL) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1652 | ath10k_warn(ar, "no vif for vdev_id %d found\n", |
| 1653 | vdev_id); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1654 | continue; |
| 1655 | } |
| 1656 | |
Michal Kazior | c2df44b | 2014-01-23 11:38:26 +0100 | [diff] [blame] | 1657 | /* There are no completions for beacons so wait for next SWBA |
| 1658 | * before telling mac80211 to decrement CSA counter |
| 1659 | * |
| 1660 | * Once CSA counter is completed stop sending beacons until |
| 1661 | * actual channel switch is done */ |
| 1662 | if (arvif->vif->csa_active && |
| 1663 | ieee80211_csa_is_complete(arvif->vif)) { |
| 1664 | ieee80211_csa_finish(arvif->vif); |
| 1665 | continue; |
| 1666 | } |
| 1667 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1668 | bcn = ieee80211_beacon_get(ar->hw, arvif->vif); |
| 1669 | if (!bcn) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1670 | ath10k_warn(ar, "could not get mac80211 beacon\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1671 | continue; |
| 1672 | } |
| 1673 | |
Michal Kazior | 4b60455 | 2014-07-21 21:03:09 +0300 | [diff] [blame] | 1674 | ath10k_tx_h_seq_no(arvif->vif, bcn); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1675 | ath10k_wmi_update_tim(ar, arvif, bcn, bcn_info); |
| 1676 | ath10k_wmi_update_noa(ar, arvif, bcn, bcn_info); |
| 1677 | |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 1678 | spin_lock_bh(&ar->data_lock); |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 1679 | |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 1680 | if (arvif->beacon) { |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 1681 | if (!arvif->beacon_sent) |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1682 | ath10k_warn(ar, "SWBA overrun on vdev %d\n", |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 1683 | arvif->vdev_id); |
| 1684 | |
Michal Kazior | 64badcb | 2014-09-18 11:18:02 +0300 | [diff] [blame] | 1685 | ath10k_mac_vif_beacon_free(arvif); |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 1686 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1687 | |
Michal Kazior | 64badcb | 2014-09-18 11:18:02 +0300 | [diff] [blame] | 1688 | if (!arvif->beacon_buf) { |
| 1689 | paddr = dma_map_single(arvif->ar->dev, bcn->data, |
| 1690 | bcn->len, DMA_TO_DEVICE); |
| 1691 | ret = dma_mapping_error(arvif->ar->dev, paddr); |
| 1692 | if (ret) { |
| 1693 | ath10k_warn(ar, "failed to map beacon: %d\n", |
| 1694 | ret); |
| 1695 | dev_kfree_skb_any(bcn); |
| 1696 | goto skip; |
| 1697 | } |
| 1698 | |
| 1699 | ATH10K_SKB_CB(bcn)->paddr = paddr; |
| 1700 | } else { |
| 1701 | if (bcn->len > IEEE80211_MAX_FRAME_LEN) { |
| 1702 | ath10k_warn(ar, "trimming beacon %d -> %d bytes!\n", |
| 1703 | bcn->len, IEEE80211_MAX_FRAME_LEN); |
| 1704 | skb_trim(bcn, IEEE80211_MAX_FRAME_LEN); |
| 1705 | } |
| 1706 | memcpy(arvif->beacon_buf, bcn->data, bcn->len); |
| 1707 | ATH10K_SKB_CB(bcn)->paddr = arvif->beacon_paddr; |
Michal Kazior | 767d34f | 2014-02-27 18:50:03 +0200 | [diff] [blame] | 1708 | } |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 1709 | |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 1710 | arvif->beacon = bcn; |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 1711 | arvif->beacon_sent = false; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1712 | |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 1713 | ath10k_wmi_tx_beacon_nowait(arvif); |
Michal Kazior | 767d34f | 2014-02-27 18:50:03 +0200 | [diff] [blame] | 1714 | skip: |
Michal Kazior | ed54388 | 2013-09-13 14:16:56 +0200 | [diff] [blame] | 1715 | spin_unlock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1716 | } |
| 1717 | } |
| 1718 | |
| 1719 | static void ath10k_wmi_event_tbttoffset_update(struct ath10k *ar, |
| 1720 | struct sk_buff *skb) |
| 1721 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1722 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TBTTOFFSET_UPDATE_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1723 | } |
| 1724 | |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1725 | static void ath10k_dfs_radar_report(struct ath10k *ar, |
| 1726 | struct wmi_single_phyerr_rx_event *event, |
| 1727 | struct phyerr_radar_report *rr, |
| 1728 | u64 tsf) |
| 1729 | { |
| 1730 | u32 reg0, reg1, tsf32l; |
| 1731 | struct pulse_event pe; |
| 1732 | u64 tsf64; |
| 1733 | u8 rssi, width; |
| 1734 | |
| 1735 | reg0 = __le32_to_cpu(rr->reg0); |
| 1736 | reg1 = __le32_to_cpu(rr->reg1); |
| 1737 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1738 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1739 | "wmi phyerr radar report chirp %d max_width %d agc_total_gain %d pulse_delta_diff %d\n", |
| 1740 | MS(reg0, RADAR_REPORT_REG0_PULSE_IS_CHIRP), |
| 1741 | MS(reg0, RADAR_REPORT_REG0_PULSE_IS_MAX_WIDTH), |
| 1742 | MS(reg0, RADAR_REPORT_REG0_AGC_TOTAL_GAIN), |
| 1743 | MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_DIFF)); |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1744 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1745 | "wmi phyerr radar report pulse_delta_pean %d pulse_sidx %d fft_valid %d agc_mb_gain %d subchan_mask %d\n", |
| 1746 | MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_PEAK), |
| 1747 | MS(reg0, RADAR_REPORT_REG0_PULSE_SIDX), |
| 1748 | MS(reg1, RADAR_REPORT_REG1_PULSE_SRCH_FFT_VALID), |
| 1749 | MS(reg1, RADAR_REPORT_REG1_PULSE_AGC_MB_GAIN), |
| 1750 | MS(reg1, RADAR_REPORT_REG1_PULSE_SUBCHAN_MASK)); |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1751 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1752 | "wmi phyerr radar report pulse_tsf_offset 0x%X pulse_dur: %d\n", |
| 1753 | MS(reg1, RADAR_REPORT_REG1_PULSE_TSF_OFFSET), |
| 1754 | MS(reg1, RADAR_REPORT_REG1_PULSE_DUR)); |
| 1755 | |
| 1756 | if (!ar->dfs_detector) |
| 1757 | return; |
| 1758 | |
| 1759 | /* report event to DFS pattern detector */ |
| 1760 | tsf32l = __le32_to_cpu(event->hdr.tsf_timestamp); |
| 1761 | tsf64 = tsf & (~0xFFFFFFFFULL); |
| 1762 | tsf64 |= tsf32l; |
| 1763 | |
| 1764 | width = MS(reg1, RADAR_REPORT_REG1_PULSE_DUR); |
| 1765 | rssi = event->hdr.rssi_combined; |
| 1766 | |
| 1767 | /* hardware store this as 8 bit signed value, |
| 1768 | * set to zero if negative number |
| 1769 | */ |
| 1770 | if (rssi & 0x80) |
| 1771 | rssi = 0; |
| 1772 | |
| 1773 | pe.ts = tsf64; |
| 1774 | pe.freq = ar->hw->conf.chandef.chan->center_freq; |
| 1775 | pe.width = width; |
| 1776 | pe.rssi = rssi; |
| 1777 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1778 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1779 | "dfs add pulse freq: %d, width: %d, rssi %d, tsf: %llX\n", |
| 1780 | pe.freq, pe.width, pe.rssi, pe.ts); |
| 1781 | |
| 1782 | ATH10K_DFS_STAT_INC(ar, pulses_detected); |
| 1783 | |
| 1784 | if (!ar->dfs_detector->add_pulse(ar->dfs_detector, &pe)) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1785 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1786 | "dfs no pulse pattern detected, yet\n"); |
| 1787 | return; |
| 1788 | } |
| 1789 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1790 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs radar detected\n"); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1791 | ATH10K_DFS_STAT_INC(ar, radar_detected); |
Marek Puzyniak | 7d9b40b | 2013-11-20 10:00:28 +0200 | [diff] [blame] | 1792 | |
| 1793 | /* Control radar events reporting in debugfs file |
| 1794 | dfs_block_radar_events */ |
| 1795 | if (ar->dfs_block_radar_events) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1796 | ath10k_info(ar, "DFS Radar detected, but ignored as requested\n"); |
Marek Puzyniak | 7d9b40b | 2013-11-20 10:00:28 +0200 | [diff] [blame] | 1797 | return; |
| 1798 | } |
| 1799 | |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1800 | ieee80211_radar_detected(ar->hw); |
| 1801 | } |
| 1802 | |
| 1803 | static int ath10k_dfs_fft_report(struct ath10k *ar, |
| 1804 | struct wmi_single_phyerr_rx_event *event, |
| 1805 | struct phyerr_fft_report *fftr, |
| 1806 | u64 tsf) |
| 1807 | { |
| 1808 | u32 reg0, reg1; |
| 1809 | u8 rssi, peak_mag; |
| 1810 | |
| 1811 | reg0 = __le32_to_cpu(fftr->reg0); |
| 1812 | reg1 = __le32_to_cpu(fftr->reg1); |
| 1813 | rssi = event->hdr.rssi_combined; |
| 1814 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1815 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1816 | "wmi phyerr fft report total_gain_db %d base_pwr_db %d fft_chn_idx %d peak_sidx %d\n", |
| 1817 | MS(reg0, SEARCH_FFT_REPORT_REG0_TOTAL_GAIN_DB), |
| 1818 | MS(reg0, SEARCH_FFT_REPORT_REG0_BASE_PWR_DB), |
| 1819 | MS(reg0, SEARCH_FFT_REPORT_REG0_FFT_CHN_IDX), |
| 1820 | MS(reg0, SEARCH_FFT_REPORT_REG0_PEAK_SIDX)); |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1821 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1822 | "wmi phyerr fft report rel_pwr_db %d avgpwr_db %d peak_mag %d num_store_bin %d\n", |
| 1823 | MS(reg1, SEARCH_FFT_REPORT_REG1_RELPWR_DB), |
| 1824 | MS(reg1, SEARCH_FFT_REPORT_REG1_AVGPWR_DB), |
| 1825 | MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG), |
| 1826 | MS(reg1, SEARCH_FFT_REPORT_REG1_NUM_STR_BINS_IB)); |
| 1827 | |
| 1828 | peak_mag = MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG); |
| 1829 | |
| 1830 | /* false event detection */ |
| 1831 | if (rssi == DFS_RSSI_POSSIBLY_FALSE && |
| 1832 | peak_mag < 2 * DFS_PEAK_MAG_THOLD_POSSIBLY_FALSE) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1833 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs false pulse detected\n"); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1834 | ATH10K_DFS_STAT_INC(ar, pulses_discarded); |
| 1835 | return -EINVAL; |
| 1836 | } |
| 1837 | |
| 1838 | return 0; |
| 1839 | } |
| 1840 | |
| 1841 | static void ath10k_wmi_event_dfs(struct ath10k *ar, |
| 1842 | struct wmi_single_phyerr_rx_event *event, |
| 1843 | u64 tsf) |
| 1844 | { |
| 1845 | int buf_len, tlv_len, res, i = 0; |
| 1846 | struct phyerr_tlv *tlv; |
| 1847 | struct phyerr_radar_report *rr; |
| 1848 | struct phyerr_fft_report *fftr; |
| 1849 | u8 *tlv_buf; |
| 1850 | |
| 1851 | buf_len = __le32_to_cpu(event->hdr.buf_len); |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1852 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1853 | "wmi event dfs err_code %d rssi %d tsfl 0x%X tsf64 0x%llX len %d\n", |
| 1854 | event->hdr.phy_err_code, event->hdr.rssi_combined, |
| 1855 | __le32_to_cpu(event->hdr.tsf_timestamp), tsf, buf_len); |
| 1856 | |
| 1857 | /* Skip event if DFS disabled */ |
| 1858 | if (!config_enabled(CONFIG_ATH10K_DFS_CERTIFIED)) |
| 1859 | return; |
| 1860 | |
| 1861 | ATH10K_DFS_STAT_INC(ar, pulses_total); |
| 1862 | |
| 1863 | while (i < buf_len) { |
| 1864 | if (i + sizeof(*tlv) > buf_len) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1865 | ath10k_warn(ar, "too short buf for tlv header (%d)\n", |
| 1866 | i); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1867 | return; |
| 1868 | } |
| 1869 | |
| 1870 | tlv = (struct phyerr_tlv *)&event->bufp[i]; |
| 1871 | tlv_len = __le16_to_cpu(tlv->len); |
| 1872 | tlv_buf = &event->bufp[i + sizeof(*tlv)]; |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1873 | ath10k_dbg(ar, ATH10K_DBG_REGULATORY, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1874 | "wmi event dfs tlv_len %d tlv_tag 0x%02X tlv_sig 0x%02X\n", |
| 1875 | tlv_len, tlv->tag, tlv->sig); |
| 1876 | |
| 1877 | switch (tlv->tag) { |
| 1878 | case PHYERR_TLV_TAG_RADAR_PULSE_SUMMARY: |
| 1879 | if (i + sizeof(*tlv) + sizeof(*rr) > buf_len) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1880 | ath10k_warn(ar, "too short radar pulse summary (%d)\n", |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1881 | i); |
| 1882 | return; |
| 1883 | } |
| 1884 | |
| 1885 | rr = (struct phyerr_radar_report *)tlv_buf; |
| 1886 | ath10k_dfs_radar_report(ar, event, rr, tsf); |
| 1887 | break; |
| 1888 | case PHYERR_TLV_TAG_SEARCH_FFT_REPORT: |
| 1889 | if (i + sizeof(*tlv) + sizeof(*fftr) > buf_len) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1890 | ath10k_warn(ar, "too short fft report (%d)\n", |
| 1891 | i); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1892 | return; |
| 1893 | } |
| 1894 | |
| 1895 | fftr = (struct phyerr_fft_report *)tlv_buf; |
| 1896 | res = ath10k_dfs_fft_report(ar, event, fftr, tsf); |
| 1897 | if (res) |
| 1898 | return; |
| 1899 | break; |
| 1900 | } |
| 1901 | |
| 1902 | i += sizeof(*tlv) + tlv_len; |
| 1903 | } |
| 1904 | } |
| 1905 | |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 1906 | static void |
| 1907 | ath10k_wmi_event_spectral_scan(struct ath10k *ar, |
| 1908 | struct wmi_single_phyerr_rx_event *event, |
| 1909 | u64 tsf) |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1910 | { |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 1911 | int buf_len, tlv_len, res, i = 0; |
| 1912 | struct phyerr_tlv *tlv; |
| 1913 | u8 *tlv_buf; |
| 1914 | struct phyerr_fft_report *fftr; |
| 1915 | size_t fftr_len; |
| 1916 | |
| 1917 | buf_len = __le32_to_cpu(event->hdr.buf_len); |
| 1918 | |
| 1919 | while (i < buf_len) { |
| 1920 | if (i + sizeof(*tlv) > buf_len) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1921 | 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] | 1922 | i); |
| 1923 | return; |
| 1924 | } |
| 1925 | |
| 1926 | tlv = (struct phyerr_tlv *)&event->bufp[i]; |
| 1927 | tlv_len = __le16_to_cpu(tlv->len); |
| 1928 | tlv_buf = &event->bufp[i + sizeof(*tlv)]; |
| 1929 | |
| 1930 | if (i + sizeof(*tlv) + tlv_len > buf_len) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1931 | 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] | 1932 | i); |
| 1933 | return; |
| 1934 | } |
| 1935 | |
| 1936 | switch (tlv->tag) { |
| 1937 | case PHYERR_TLV_TAG_SEARCH_FFT_REPORT: |
| 1938 | if (sizeof(*fftr) > tlv_len) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1939 | ath10k_warn(ar, "failed to parse fft report at byte %d\n", |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 1940 | i); |
| 1941 | return; |
| 1942 | } |
| 1943 | |
| 1944 | fftr_len = tlv_len - sizeof(*fftr); |
| 1945 | fftr = (struct phyerr_fft_report *)tlv_buf; |
| 1946 | res = ath10k_spectral_process_fft(ar, event, |
| 1947 | fftr, fftr_len, |
| 1948 | tsf); |
| 1949 | if (res < 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1950 | ath10k_warn(ar, "failed to process fft report: %d\n", |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 1951 | res); |
| 1952 | return; |
| 1953 | } |
| 1954 | break; |
| 1955 | } |
| 1956 | |
| 1957 | i += sizeof(*tlv) + tlv_len; |
| 1958 | } |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1959 | } |
| 1960 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1961 | static void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb) |
| 1962 | { |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1963 | struct wmi_comb_phyerr_rx_event *comb_event; |
| 1964 | struct wmi_single_phyerr_rx_event *event; |
| 1965 | u32 count, i, buf_len, phy_err_code; |
| 1966 | u64 tsf; |
| 1967 | int left_len = skb->len; |
| 1968 | |
| 1969 | ATH10K_DFS_STAT_INC(ar, phy_errors); |
| 1970 | |
| 1971 | /* Check if combined event available */ |
| 1972 | if (left_len < sizeof(*comb_event)) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1973 | ath10k_warn(ar, "wmi phyerr combined event wrong len\n"); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1974 | return; |
| 1975 | } |
| 1976 | |
| 1977 | left_len -= sizeof(*comb_event); |
| 1978 | |
| 1979 | /* Check number of included events */ |
| 1980 | comb_event = (struct wmi_comb_phyerr_rx_event *)skb->data; |
| 1981 | count = __le32_to_cpu(comb_event->hdr.num_phyerr_events); |
| 1982 | |
| 1983 | tsf = __le32_to_cpu(comb_event->hdr.tsf_u32); |
| 1984 | tsf <<= 32; |
| 1985 | tsf |= __le32_to_cpu(comb_event->hdr.tsf_l32); |
| 1986 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1987 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1988 | "wmi event phyerr count %d tsf64 0x%llX\n", |
| 1989 | count, tsf); |
| 1990 | |
| 1991 | event = (struct wmi_single_phyerr_rx_event *)comb_event->bufp; |
| 1992 | for (i = 0; i < count; i++) { |
| 1993 | /* Check if we can read event header */ |
| 1994 | if (left_len < sizeof(*event)) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1995 | ath10k_warn(ar, "single event (%d) wrong head len\n", |
| 1996 | i); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1997 | return; |
| 1998 | } |
| 1999 | |
| 2000 | left_len -= sizeof(*event); |
| 2001 | |
| 2002 | buf_len = __le32_to_cpu(event->hdr.buf_len); |
| 2003 | phy_err_code = event->hdr.phy_err_code; |
| 2004 | |
| 2005 | if (left_len < buf_len) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2006 | ath10k_warn(ar, "single event (%d) wrong buf len\n", i); |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2007 | return; |
| 2008 | } |
| 2009 | |
| 2010 | left_len -= buf_len; |
| 2011 | |
| 2012 | switch (phy_err_code) { |
| 2013 | case PHY_ERROR_RADAR: |
| 2014 | ath10k_wmi_event_dfs(ar, event, tsf); |
| 2015 | break; |
| 2016 | case PHY_ERROR_SPECTRAL_SCAN: |
| 2017 | ath10k_wmi_event_spectral_scan(ar, event, tsf); |
| 2018 | break; |
| 2019 | case PHY_ERROR_FALSE_RADAR_EXT: |
| 2020 | ath10k_wmi_event_dfs(ar, event, tsf); |
| 2021 | ath10k_wmi_event_spectral_scan(ar, event, tsf); |
| 2022 | break; |
| 2023 | default: |
| 2024 | break; |
| 2025 | } |
| 2026 | |
| 2027 | event += sizeof(*event) + buf_len; |
| 2028 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2029 | } |
| 2030 | |
| 2031 | static void ath10k_wmi_event_roam(struct ath10k *ar, struct sk_buff *skb) |
| 2032 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2033 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_ROAM_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2034 | } |
| 2035 | |
| 2036 | static void ath10k_wmi_event_profile_match(struct ath10k *ar, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 2037 | struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2038 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2039 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PROFILE_MATCH\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2040 | } |
| 2041 | |
| 2042 | static void ath10k_wmi_event_debug_print(struct ath10k *ar, |
Kalle Valo | 2fe5288 | 2014-01-03 12:59:20 +0200 | [diff] [blame] | 2043 | struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2044 | { |
Kalle Valo | 2fe5288 | 2014-01-03 12:59:20 +0200 | [diff] [blame] | 2045 | char buf[101], c; |
| 2046 | int i; |
| 2047 | |
| 2048 | for (i = 0; i < sizeof(buf) - 1; i++) { |
| 2049 | if (i >= skb->len) |
| 2050 | break; |
| 2051 | |
| 2052 | c = skb->data[i]; |
| 2053 | |
| 2054 | if (c == '\0') |
| 2055 | break; |
| 2056 | |
| 2057 | if (isascii(c) && isprint(c)) |
| 2058 | buf[i] = c; |
| 2059 | else |
| 2060 | buf[i] = '.'; |
| 2061 | } |
| 2062 | |
| 2063 | if (i == sizeof(buf) - 1) |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2064 | ath10k_warn(ar, "wmi debug print truncated: %d\n", skb->len); |
Kalle Valo | 2fe5288 | 2014-01-03 12:59:20 +0200 | [diff] [blame] | 2065 | |
| 2066 | /* for some reason the debug prints end with \n, remove that */ |
| 2067 | if (skb->data[i - 1] == '\n') |
| 2068 | i--; |
| 2069 | |
| 2070 | /* the last byte is always reserved for the null character */ |
| 2071 | buf[i] = '\0'; |
| 2072 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2073 | 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] | 2074 | } |
| 2075 | |
| 2076 | static void ath10k_wmi_event_pdev_qvit(struct ath10k *ar, struct sk_buff *skb) |
| 2077 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2078 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_QVIT_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2079 | } |
| 2080 | |
| 2081 | static void ath10k_wmi_event_wlan_profile_data(struct ath10k *ar, |
| 2082 | struct sk_buff *skb) |
| 2083 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2084 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_WLAN_PROFILE_DATA_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2085 | } |
| 2086 | |
| 2087 | static void ath10k_wmi_event_rtt_measurement_report(struct ath10k *ar, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 2088 | struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2089 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2090 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_MEASUREMENT_REPORT_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2091 | } |
| 2092 | |
| 2093 | static void ath10k_wmi_event_tsf_measurement_report(struct ath10k *ar, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 2094 | struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2095 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2096 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TSF_MEASUREMENT_REPORT_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2097 | } |
| 2098 | |
| 2099 | static void ath10k_wmi_event_rtt_error_report(struct ath10k *ar, |
| 2100 | struct sk_buff *skb) |
| 2101 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2102 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_ERROR_REPORT_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2103 | } |
| 2104 | |
| 2105 | static void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, |
| 2106 | struct sk_buff *skb) |
| 2107 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2108 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_WOW_WAKEUP_HOST_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2109 | } |
| 2110 | |
| 2111 | static void ath10k_wmi_event_dcs_interference(struct ath10k *ar, |
| 2112 | struct sk_buff *skb) |
| 2113 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2114 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_DCS_INTERFERENCE_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2115 | } |
| 2116 | |
| 2117 | static void ath10k_wmi_event_pdev_tpc_config(struct ath10k *ar, |
| 2118 | struct sk_buff *skb) |
| 2119 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2120 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_TPC_CONFIG_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2121 | } |
| 2122 | |
| 2123 | static void ath10k_wmi_event_pdev_ftm_intg(struct ath10k *ar, |
| 2124 | struct sk_buff *skb) |
| 2125 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2126 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_FTM_INTG_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2127 | } |
| 2128 | |
| 2129 | static void ath10k_wmi_event_gtk_offload_status(struct ath10k *ar, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 2130 | struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2131 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2132 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_OFFLOAD_STATUS_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2133 | } |
| 2134 | |
| 2135 | static void ath10k_wmi_event_gtk_rekey_fail(struct ath10k *ar, |
| 2136 | struct sk_buff *skb) |
| 2137 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2138 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_REKEY_FAIL_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2139 | } |
| 2140 | |
| 2141 | static void ath10k_wmi_event_delba_complete(struct ath10k *ar, |
| 2142 | struct sk_buff *skb) |
| 2143 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2144 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_DELBA_COMPLETE_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2145 | } |
| 2146 | |
| 2147 | static void ath10k_wmi_event_addba_complete(struct ath10k *ar, |
| 2148 | struct sk_buff *skb) |
| 2149 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2150 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_ADDBA_COMPLETE_EVENTID\n"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2151 | } |
| 2152 | |
| 2153 | static void ath10k_wmi_event_vdev_install_key_complete(struct ath10k *ar, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 2154 | struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2155 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2156 | 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] | 2157 | } |
| 2158 | |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2159 | static void ath10k_wmi_event_inst_rssi_stats(struct ath10k *ar, |
| 2160 | struct sk_buff *skb) |
| 2161 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2162 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_INST_RSSI_STATS_EVENTID\n"); |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2163 | } |
| 2164 | |
| 2165 | static void ath10k_wmi_event_vdev_standby_req(struct ath10k *ar, |
| 2166 | struct sk_buff *skb) |
| 2167 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2168 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STANDBY_REQ_EVENTID\n"); |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2169 | } |
| 2170 | |
| 2171 | static void ath10k_wmi_event_vdev_resume_req(struct ath10k *ar, |
| 2172 | struct sk_buff *skb) |
| 2173 | { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2174 | ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_RESUME_REQ_EVENTID\n"); |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2175 | } |
| 2176 | |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2177 | 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] | 2178 | u32 num_units, u32 unit_len) |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2179 | { |
| 2180 | dma_addr_t paddr; |
| 2181 | u32 pool_size; |
| 2182 | int idx = ar->wmi.num_mem_chunks; |
| 2183 | |
| 2184 | pool_size = num_units * round_up(unit_len, 4); |
| 2185 | |
| 2186 | if (!pool_size) |
| 2187 | return -EINVAL; |
| 2188 | |
| 2189 | ar->wmi.mem_chunks[idx].vaddr = dma_alloc_coherent(ar->dev, |
| 2190 | pool_size, |
| 2191 | &paddr, |
| 2192 | GFP_ATOMIC); |
| 2193 | if (!ar->wmi.mem_chunks[idx].vaddr) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2194 | ath10k_warn(ar, "failed to allocate memory chunk\n"); |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2195 | return -ENOMEM; |
| 2196 | } |
| 2197 | |
| 2198 | memset(ar->wmi.mem_chunks[idx].vaddr, 0, pool_size); |
| 2199 | |
| 2200 | ar->wmi.mem_chunks[idx].paddr = paddr; |
| 2201 | ar->wmi.mem_chunks[idx].len = pool_size; |
| 2202 | ar->wmi.mem_chunks[idx].req_id = req_id; |
| 2203 | ar->wmi.num_mem_chunks++; |
| 2204 | |
| 2205 | return 0; |
| 2206 | } |
| 2207 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2208 | static void ath10k_wmi_service_ready_event_rx(struct ath10k *ar, |
| 2209 | struct sk_buff *skb) |
| 2210 | { |
| 2211 | struct wmi_service_ready_event *ev = (void *)skb->data; |
Michal Kazior | c4f8c83 | 2014-09-04 10:18:32 +0200 | [diff] [blame] | 2212 | DECLARE_BITMAP(svc_bmap, WMI_SERVICE_MAX) = {}; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2213 | |
| 2214 | if (skb->len < sizeof(*ev)) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2215 | ath10k_warn(ar, "Service ready event was %d B but expected %zu B. Wrong firmware version?\n", |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2216 | skb->len, sizeof(*ev)); |
| 2217 | return; |
| 2218 | } |
| 2219 | |
| 2220 | ar->hw_min_tx_power = __le32_to_cpu(ev->hw_min_tx_power); |
| 2221 | ar->hw_max_tx_power = __le32_to_cpu(ev->hw_max_tx_power); |
| 2222 | ar->ht_cap_info = __le32_to_cpu(ev->ht_cap_info); |
| 2223 | ar->vht_cap_info = __le32_to_cpu(ev->vht_cap_info); |
| 2224 | ar->fw_version_major = |
| 2225 | (__le32_to_cpu(ev->sw_version) & 0xff000000) >> 24; |
| 2226 | ar->fw_version_minor = (__le32_to_cpu(ev->sw_version) & 0x00ffffff); |
| 2227 | ar->fw_version_release = |
| 2228 | (__le32_to_cpu(ev->sw_version_1) & 0xffff0000) >> 16; |
| 2229 | ar->fw_version_build = (__le32_to_cpu(ev->sw_version_1) & 0x0000ffff); |
| 2230 | ar->phy_capability = __le32_to_cpu(ev->phy_capability); |
Michal Kazior | 8865bee4 | 2013-07-24 12:36:46 +0200 | [diff] [blame] | 2231 | ar->num_rf_chains = __le32_to_cpu(ev->num_rf_chains); |
| 2232 | |
Kalle Valo | 1a22243 | 2013-09-27 19:55:07 +0300 | [diff] [blame] | 2233 | /* only manually set fw features when not using FW IE format */ |
| 2234 | if (ar->fw_api == 1 && ar->fw_version_build > 636) |
Michal Kazior | 0d9b043 | 2013-08-09 10:13:33 +0200 | [diff] [blame] | 2235 | set_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features); |
| 2236 | |
Michal Kazior | 8865bee4 | 2013-07-24 12:36:46 +0200 | [diff] [blame] | 2237 | if (ar->num_rf_chains > WMI_MAX_SPATIAL_STREAM) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2238 | 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] | 2239 | ar->num_rf_chains, WMI_MAX_SPATIAL_STREAM); |
| 2240 | ar->num_rf_chains = WMI_MAX_SPATIAL_STREAM; |
| 2241 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2242 | |
Michal Kazior | fdb959c | 2014-09-18 15:21:19 +0200 | [diff] [blame] | 2243 | ar->supp_tx_chainmask = (1 << ar->num_rf_chains) - 1; |
| 2244 | ar->supp_rx_chainmask = (1 << ar->num_rf_chains) - 1; |
| 2245 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2246 | ar->ath_common.regulatory.current_rd = |
| 2247 | __le32_to_cpu(ev->hal_reg_capabilities.eeprom_rd); |
| 2248 | |
Michal Kazior | 7a7b373 | 2014-08-19 13:22:32 +0200 | [diff] [blame] | 2249 | wmi_main_svc_map(ev->wmi_service_bitmap, svc_bmap); |
Michal Kazior | cff990c | 2014-08-04 09:18:33 +0300 | [diff] [blame] | 2250 | ath10k_debug_read_service_map(ar, svc_bmap, sizeof(svc_bmap)); |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2251 | ath10k_dbg_dump(ar, ATH10K_DBG_WMI, NULL, "wmi svc: ", |
Michal Kazior | cff990c | 2014-08-04 09:18:33 +0300 | [diff] [blame] | 2252 | ev->wmi_service_bitmap, sizeof(ev->wmi_service_bitmap)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2253 | |
| 2254 | if (strlen(ar->hw->wiphy->fw_version) == 0) { |
| 2255 | snprintf(ar->hw->wiphy->fw_version, |
| 2256 | sizeof(ar->hw->wiphy->fw_version), |
| 2257 | "%u.%u.%u.%u", |
| 2258 | ar->fw_version_major, |
| 2259 | ar->fw_version_minor, |
| 2260 | ar->fw_version_release, |
| 2261 | ar->fw_version_build); |
| 2262 | } |
| 2263 | |
| 2264 | /* FIXME: it probably should be better to support this */ |
| 2265 | if (__le32_to_cpu(ev->num_mem_reqs) > 0) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2266 | ath10k_warn(ar, "target requested %d memory chunks; ignoring\n", |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2267 | __le32_to_cpu(ev->num_mem_reqs)); |
| 2268 | } |
| 2269 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2270 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Michal Kazior | 8865bee4 | 2013-07-24 12:36:46 +0200 | [diff] [blame] | 2271 | "wmi event service ready sw_ver 0x%08x sw_ver1 0x%08x abi_ver %u phy_cap 0x%08x ht_cap 0x%08x vht_cap 0x%08x vht_supp_msc 0x%08x sys_cap_info 0x%08x mem_reqs %u num_rf_chains %u\n", |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2272 | __le32_to_cpu(ev->sw_version), |
| 2273 | __le32_to_cpu(ev->sw_version_1), |
| 2274 | __le32_to_cpu(ev->abi_version), |
| 2275 | __le32_to_cpu(ev->phy_capability), |
| 2276 | __le32_to_cpu(ev->ht_cap_info), |
| 2277 | __le32_to_cpu(ev->vht_cap_info), |
| 2278 | __le32_to_cpu(ev->vht_supp_mcs), |
| 2279 | __le32_to_cpu(ev->sys_cap_info), |
Michal Kazior | 8865bee4 | 2013-07-24 12:36:46 +0200 | [diff] [blame] | 2280 | __le32_to_cpu(ev->num_mem_reqs), |
| 2281 | __le32_to_cpu(ev->num_rf_chains)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2282 | |
| 2283 | complete(&ar->wmi.service_ready); |
| 2284 | } |
| 2285 | |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 2286 | static void ath10k_wmi_10x_service_ready_event_rx(struct ath10k *ar, |
| 2287 | struct sk_buff *skb) |
| 2288 | { |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2289 | u32 num_units, req_id, unit_size, num_mem_reqs, num_unit_info, i; |
| 2290 | int ret; |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 2291 | struct wmi_service_ready_event_10x *ev = (void *)skb->data; |
Michal Kazior | c4f8c83 | 2014-09-04 10:18:32 +0200 | [diff] [blame] | 2292 | DECLARE_BITMAP(svc_bmap, WMI_SERVICE_MAX) = {}; |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 2293 | |
| 2294 | if (skb->len < sizeof(*ev)) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2295 | ath10k_warn(ar, "Service ready event was %d B but expected %zu B. Wrong firmware version?\n", |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 2296 | skb->len, sizeof(*ev)); |
| 2297 | return; |
| 2298 | } |
| 2299 | |
| 2300 | ar->hw_min_tx_power = __le32_to_cpu(ev->hw_min_tx_power); |
| 2301 | ar->hw_max_tx_power = __le32_to_cpu(ev->hw_max_tx_power); |
| 2302 | ar->ht_cap_info = __le32_to_cpu(ev->ht_cap_info); |
| 2303 | ar->vht_cap_info = __le32_to_cpu(ev->vht_cap_info); |
| 2304 | ar->fw_version_major = |
| 2305 | (__le32_to_cpu(ev->sw_version) & 0xff000000) >> 24; |
| 2306 | ar->fw_version_minor = (__le32_to_cpu(ev->sw_version) & 0x00ffffff); |
| 2307 | ar->phy_capability = __le32_to_cpu(ev->phy_capability); |
| 2308 | ar->num_rf_chains = __le32_to_cpu(ev->num_rf_chains); |
| 2309 | |
| 2310 | if (ar->num_rf_chains > WMI_MAX_SPATIAL_STREAM) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2311 | ath10k_warn(ar, "hardware advertises support for more spatial streams than it should (%d > %d)\n", |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 2312 | ar->num_rf_chains, WMI_MAX_SPATIAL_STREAM); |
| 2313 | ar->num_rf_chains = WMI_MAX_SPATIAL_STREAM; |
| 2314 | } |
| 2315 | |
Michal Kazior | fdb959c | 2014-09-18 15:21:19 +0200 | [diff] [blame] | 2316 | ar->supp_tx_chainmask = (1 << ar->num_rf_chains) - 1; |
| 2317 | ar->supp_rx_chainmask = (1 << ar->num_rf_chains) - 1; |
| 2318 | |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 2319 | ar->ath_common.regulatory.current_rd = |
| 2320 | __le32_to_cpu(ev->hal_reg_capabilities.eeprom_rd); |
| 2321 | |
Michal Kazior | 7a7b373 | 2014-08-19 13:22:32 +0200 | [diff] [blame] | 2322 | wmi_10x_svc_map(ev->wmi_service_bitmap, svc_bmap); |
Michal Kazior | cff990c | 2014-08-04 09:18:33 +0300 | [diff] [blame] | 2323 | ath10k_debug_read_service_map(ar, svc_bmap, sizeof(svc_bmap)); |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2324 | ath10k_dbg_dump(ar, ATH10K_DBG_WMI, NULL, "wmi svc: ", |
Michal Kazior | cff990c | 2014-08-04 09:18:33 +0300 | [diff] [blame] | 2325 | ev->wmi_service_bitmap, sizeof(ev->wmi_service_bitmap)); |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 2326 | |
| 2327 | if (strlen(ar->hw->wiphy->fw_version) == 0) { |
| 2328 | snprintf(ar->hw->wiphy->fw_version, |
| 2329 | sizeof(ar->hw->wiphy->fw_version), |
| 2330 | "%u.%u", |
| 2331 | ar->fw_version_major, |
| 2332 | ar->fw_version_minor); |
| 2333 | } |
| 2334 | |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2335 | num_mem_reqs = __le32_to_cpu(ev->num_mem_reqs); |
| 2336 | |
| 2337 | if (num_mem_reqs > ATH10K_MAX_MEM_REQS) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2338 | ath10k_warn(ar, "requested memory chunks number (%d) exceeds the limit\n", |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2339 | num_mem_reqs); |
| 2340 | return; |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 2341 | } |
| 2342 | |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2343 | if (!num_mem_reqs) |
| 2344 | goto exit; |
| 2345 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2346 | ath10k_dbg(ar, ATH10K_DBG_WMI, "firmware has requested %d memory chunks\n", |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2347 | num_mem_reqs); |
| 2348 | |
| 2349 | for (i = 0; i < num_mem_reqs; ++i) { |
| 2350 | req_id = __le32_to_cpu(ev->mem_reqs[i].req_id); |
| 2351 | num_units = __le32_to_cpu(ev->mem_reqs[i].num_units); |
| 2352 | unit_size = __le32_to_cpu(ev->mem_reqs[i].unit_size); |
| 2353 | num_unit_info = __le32_to_cpu(ev->mem_reqs[i].num_unit_info); |
| 2354 | |
| 2355 | if (num_unit_info & NUM_UNITS_IS_NUM_PEERS) |
| 2356 | /* number of units to allocate is number of |
| 2357 | * peers, 1 extra for self peer on target */ |
| 2358 | /* this needs to be tied, host and target |
| 2359 | * can get out of sync */ |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 2360 | num_units = TARGET_10X_NUM_PEERS + 1; |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2361 | else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS) |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 2362 | num_units = TARGET_10X_NUM_VDEVS + 1; |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2363 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2364 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2365 | "wmi mem_req_id %d num_units %d num_unit_info %d unit size %d actual units %d\n", |
| 2366 | req_id, |
| 2367 | __le32_to_cpu(ev->mem_reqs[i].num_units), |
| 2368 | num_unit_info, |
| 2369 | unit_size, |
| 2370 | num_units); |
| 2371 | |
| 2372 | ret = ath10k_wmi_alloc_host_mem(ar, req_id, num_units, |
| 2373 | unit_size); |
| 2374 | if (ret) |
| 2375 | return; |
| 2376 | } |
| 2377 | |
| 2378 | exit: |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2379 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 2380 | "wmi event service ready sw_ver 0x%08x abi_ver %u phy_cap 0x%08x ht_cap 0x%08x vht_cap 0x%08x vht_supp_msc 0x%08x sys_cap_info 0x%08x mem_reqs %u num_rf_chains %u\n", |
| 2381 | __le32_to_cpu(ev->sw_version), |
| 2382 | __le32_to_cpu(ev->abi_version), |
| 2383 | __le32_to_cpu(ev->phy_capability), |
| 2384 | __le32_to_cpu(ev->ht_cap_info), |
| 2385 | __le32_to_cpu(ev->vht_cap_info), |
| 2386 | __le32_to_cpu(ev->vht_supp_mcs), |
| 2387 | __le32_to_cpu(ev->sys_cap_info), |
| 2388 | __le32_to_cpu(ev->num_mem_reqs), |
| 2389 | __le32_to_cpu(ev->num_rf_chains)); |
| 2390 | |
| 2391 | complete(&ar->wmi.service_ready); |
| 2392 | } |
| 2393 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2394 | static int ath10k_wmi_ready_event_rx(struct ath10k *ar, struct sk_buff *skb) |
| 2395 | { |
| 2396 | struct wmi_ready_event *ev = (struct wmi_ready_event *)skb->data; |
| 2397 | |
| 2398 | if (WARN_ON(skb->len < sizeof(*ev))) |
| 2399 | return -EINVAL; |
| 2400 | |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 2401 | ether_addr_copy(ar->mac_addr, ev->mac_addr.addr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2402 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2403 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Ben Greear | 2c34752 | 2014-02-05 13:58:32 -0800 | [diff] [blame] | 2404 | "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] | 2405 | __le32_to_cpu(ev->sw_version), |
| 2406 | __le32_to_cpu(ev->abi_version), |
| 2407 | ev->mac_addr.addr, |
Ben Greear | 2c34752 | 2014-02-05 13:58:32 -0800 | [diff] [blame] | 2408 | __le32_to_cpu(ev->status), skb->len, sizeof(*ev)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2409 | |
| 2410 | complete(&ar->wmi.unified_ready); |
| 2411 | return 0; |
| 2412 | } |
| 2413 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2414 | 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] | 2415 | { |
| 2416 | struct wmi_cmd_hdr *cmd_hdr; |
| 2417 | enum wmi_event_id id; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2418 | |
| 2419 | cmd_hdr = (struct wmi_cmd_hdr *)skb->data; |
| 2420 | id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID); |
| 2421 | |
| 2422 | if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL) |
| 2423 | return; |
| 2424 | |
Michal Kazior | d35a6c1 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 2425 | trace_ath10k_wmi_event(ar, id, skb->data, skb->len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2426 | |
| 2427 | switch (id) { |
| 2428 | case WMI_MGMT_RX_EVENTID: |
| 2429 | ath10k_wmi_event_mgmt_rx(ar, skb); |
| 2430 | /* mgmt_rx() owns the skb now! */ |
| 2431 | return; |
| 2432 | case WMI_SCAN_EVENTID: |
| 2433 | ath10k_wmi_event_scan(ar, skb); |
| 2434 | break; |
| 2435 | case WMI_CHAN_INFO_EVENTID: |
| 2436 | ath10k_wmi_event_chan_info(ar, skb); |
| 2437 | break; |
| 2438 | case WMI_ECHO_EVENTID: |
| 2439 | ath10k_wmi_event_echo(ar, skb); |
| 2440 | break; |
| 2441 | case WMI_DEBUG_MESG_EVENTID: |
| 2442 | ath10k_wmi_event_debug_mesg(ar, skb); |
| 2443 | break; |
| 2444 | case WMI_UPDATE_STATS_EVENTID: |
| 2445 | ath10k_wmi_event_update_stats(ar, skb); |
| 2446 | break; |
| 2447 | case WMI_VDEV_START_RESP_EVENTID: |
| 2448 | ath10k_wmi_event_vdev_start_resp(ar, skb); |
| 2449 | break; |
| 2450 | case WMI_VDEV_STOPPED_EVENTID: |
| 2451 | ath10k_wmi_event_vdev_stopped(ar, skb); |
| 2452 | break; |
| 2453 | case WMI_PEER_STA_KICKOUT_EVENTID: |
| 2454 | ath10k_wmi_event_peer_sta_kickout(ar, skb); |
| 2455 | break; |
| 2456 | case WMI_HOST_SWBA_EVENTID: |
| 2457 | ath10k_wmi_event_host_swba(ar, skb); |
| 2458 | break; |
| 2459 | case WMI_TBTTOFFSET_UPDATE_EVENTID: |
| 2460 | ath10k_wmi_event_tbttoffset_update(ar, skb); |
| 2461 | break; |
| 2462 | case WMI_PHYERR_EVENTID: |
| 2463 | ath10k_wmi_event_phyerr(ar, skb); |
| 2464 | break; |
| 2465 | case WMI_ROAM_EVENTID: |
| 2466 | ath10k_wmi_event_roam(ar, skb); |
| 2467 | break; |
| 2468 | case WMI_PROFILE_MATCH: |
| 2469 | ath10k_wmi_event_profile_match(ar, skb); |
| 2470 | break; |
| 2471 | case WMI_DEBUG_PRINT_EVENTID: |
| 2472 | ath10k_wmi_event_debug_print(ar, skb); |
| 2473 | break; |
| 2474 | case WMI_PDEV_QVIT_EVENTID: |
| 2475 | ath10k_wmi_event_pdev_qvit(ar, skb); |
| 2476 | break; |
| 2477 | case WMI_WLAN_PROFILE_DATA_EVENTID: |
| 2478 | ath10k_wmi_event_wlan_profile_data(ar, skb); |
| 2479 | break; |
| 2480 | case WMI_RTT_MEASUREMENT_REPORT_EVENTID: |
| 2481 | ath10k_wmi_event_rtt_measurement_report(ar, skb); |
| 2482 | break; |
| 2483 | case WMI_TSF_MEASUREMENT_REPORT_EVENTID: |
| 2484 | ath10k_wmi_event_tsf_measurement_report(ar, skb); |
| 2485 | break; |
| 2486 | case WMI_RTT_ERROR_REPORT_EVENTID: |
| 2487 | ath10k_wmi_event_rtt_error_report(ar, skb); |
| 2488 | break; |
| 2489 | case WMI_WOW_WAKEUP_HOST_EVENTID: |
| 2490 | ath10k_wmi_event_wow_wakeup_host(ar, skb); |
| 2491 | break; |
| 2492 | case WMI_DCS_INTERFERENCE_EVENTID: |
| 2493 | ath10k_wmi_event_dcs_interference(ar, skb); |
| 2494 | break; |
| 2495 | case WMI_PDEV_TPC_CONFIG_EVENTID: |
| 2496 | ath10k_wmi_event_pdev_tpc_config(ar, skb); |
| 2497 | break; |
| 2498 | case WMI_PDEV_FTM_INTG_EVENTID: |
| 2499 | ath10k_wmi_event_pdev_ftm_intg(ar, skb); |
| 2500 | break; |
| 2501 | case WMI_GTK_OFFLOAD_STATUS_EVENTID: |
| 2502 | ath10k_wmi_event_gtk_offload_status(ar, skb); |
| 2503 | break; |
| 2504 | case WMI_GTK_REKEY_FAIL_EVENTID: |
| 2505 | ath10k_wmi_event_gtk_rekey_fail(ar, skb); |
| 2506 | break; |
| 2507 | case WMI_TX_DELBA_COMPLETE_EVENTID: |
| 2508 | ath10k_wmi_event_delba_complete(ar, skb); |
| 2509 | break; |
| 2510 | case WMI_TX_ADDBA_COMPLETE_EVENTID: |
| 2511 | ath10k_wmi_event_addba_complete(ar, skb); |
| 2512 | break; |
| 2513 | case WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID: |
| 2514 | ath10k_wmi_event_vdev_install_key_complete(ar, skb); |
| 2515 | break; |
| 2516 | case WMI_SERVICE_READY_EVENTID: |
| 2517 | ath10k_wmi_service_ready_event_rx(ar, skb); |
| 2518 | break; |
| 2519 | case WMI_READY_EVENTID: |
| 2520 | ath10k_wmi_ready_event_rx(ar, skb); |
| 2521 | break; |
| 2522 | default: |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2523 | ath10k_warn(ar, "Unknown eventid: %d\n", id); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2524 | break; |
| 2525 | } |
| 2526 | |
| 2527 | dev_kfree_skb(skb); |
| 2528 | } |
| 2529 | |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2530 | static void ath10k_wmi_10x_process_rx(struct ath10k *ar, struct sk_buff *skb) |
| 2531 | { |
| 2532 | struct wmi_cmd_hdr *cmd_hdr; |
| 2533 | enum wmi_10x_event_id id; |
Kalle Valo | 43d2a30 | 2014-09-10 18:23:30 +0300 | [diff] [blame] | 2534 | bool consumed; |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2535 | |
| 2536 | cmd_hdr = (struct wmi_cmd_hdr *)skb->data; |
| 2537 | id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID); |
| 2538 | |
| 2539 | if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL) |
| 2540 | return; |
| 2541 | |
Michal Kazior | d35a6c1 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 2542 | trace_ath10k_wmi_event(ar, id, skb->data, skb->len); |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2543 | |
Kalle Valo | 43d2a30 | 2014-09-10 18:23:30 +0300 | [diff] [blame] | 2544 | consumed = ath10k_tm_event_wmi(ar, id, skb); |
| 2545 | |
| 2546 | /* Ready event must be handled normally also in UTF mode so that we |
| 2547 | * know the UTF firmware has booted, others we are just bypass WMI |
| 2548 | * events to testmode. |
| 2549 | */ |
| 2550 | if (consumed && id != WMI_10X_READY_EVENTID) { |
| 2551 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
| 2552 | "wmi testmode consumed 0x%x\n", id); |
| 2553 | goto out; |
| 2554 | } |
| 2555 | |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2556 | switch (id) { |
| 2557 | case WMI_10X_MGMT_RX_EVENTID: |
| 2558 | ath10k_wmi_event_mgmt_rx(ar, skb); |
| 2559 | /* mgmt_rx() owns the skb now! */ |
| 2560 | return; |
| 2561 | case WMI_10X_SCAN_EVENTID: |
| 2562 | ath10k_wmi_event_scan(ar, skb); |
| 2563 | break; |
| 2564 | case WMI_10X_CHAN_INFO_EVENTID: |
| 2565 | ath10k_wmi_event_chan_info(ar, skb); |
| 2566 | break; |
| 2567 | case WMI_10X_ECHO_EVENTID: |
| 2568 | ath10k_wmi_event_echo(ar, skb); |
| 2569 | break; |
| 2570 | case WMI_10X_DEBUG_MESG_EVENTID: |
| 2571 | ath10k_wmi_event_debug_mesg(ar, skb); |
| 2572 | break; |
| 2573 | case WMI_10X_UPDATE_STATS_EVENTID: |
| 2574 | ath10k_wmi_event_update_stats(ar, skb); |
| 2575 | break; |
| 2576 | case WMI_10X_VDEV_START_RESP_EVENTID: |
| 2577 | ath10k_wmi_event_vdev_start_resp(ar, skb); |
| 2578 | break; |
| 2579 | case WMI_10X_VDEV_STOPPED_EVENTID: |
| 2580 | ath10k_wmi_event_vdev_stopped(ar, skb); |
| 2581 | break; |
| 2582 | case WMI_10X_PEER_STA_KICKOUT_EVENTID: |
| 2583 | ath10k_wmi_event_peer_sta_kickout(ar, skb); |
| 2584 | break; |
| 2585 | case WMI_10X_HOST_SWBA_EVENTID: |
| 2586 | ath10k_wmi_event_host_swba(ar, skb); |
| 2587 | break; |
| 2588 | case WMI_10X_TBTTOFFSET_UPDATE_EVENTID: |
| 2589 | ath10k_wmi_event_tbttoffset_update(ar, skb); |
| 2590 | break; |
| 2591 | case WMI_10X_PHYERR_EVENTID: |
| 2592 | ath10k_wmi_event_phyerr(ar, skb); |
| 2593 | break; |
| 2594 | case WMI_10X_ROAM_EVENTID: |
| 2595 | ath10k_wmi_event_roam(ar, skb); |
| 2596 | break; |
| 2597 | case WMI_10X_PROFILE_MATCH: |
| 2598 | ath10k_wmi_event_profile_match(ar, skb); |
| 2599 | break; |
| 2600 | case WMI_10X_DEBUG_PRINT_EVENTID: |
| 2601 | ath10k_wmi_event_debug_print(ar, skb); |
| 2602 | break; |
| 2603 | case WMI_10X_PDEV_QVIT_EVENTID: |
| 2604 | ath10k_wmi_event_pdev_qvit(ar, skb); |
| 2605 | break; |
| 2606 | case WMI_10X_WLAN_PROFILE_DATA_EVENTID: |
| 2607 | ath10k_wmi_event_wlan_profile_data(ar, skb); |
| 2608 | break; |
| 2609 | case WMI_10X_RTT_MEASUREMENT_REPORT_EVENTID: |
| 2610 | ath10k_wmi_event_rtt_measurement_report(ar, skb); |
| 2611 | break; |
| 2612 | case WMI_10X_TSF_MEASUREMENT_REPORT_EVENTID: |
| 2613 | ath10k_wmi_event_tsf_measurement_report(ar, skb); |
| 2614 | break; |
| 2615 | case WMI_10X_RTT_ERROR_REPORT_EVENTID: |
| 2616 | ath10k_wmi_event_rtt_error_report(ar, skb); |
| 2617 | break; |
| 2618 | case WMI_10X_WOW_WAKEUP_HOST_EVENTID: |
| 2619 | ath10k_wmi_event_wow_wakeup_host(ar, skb); |
| 2620 | break; |
| 2621 | case WMI_10X_DCS_INTERFERENCE_EVENTID: |
| 2622 | ath10k_wmi_event_dcs_interference(ar, skb); |
| 2623 | break; |
| 2624 | case WMI_10X_PDEV_TPC_CONFIG_EVENTID: |
| 2625 | ath10k_wmi_event_pdev_tpc_config(ar, skb); |
| 2626 | break; |
| 2627 | case WMI_10X_INST_RSSI_STATS_EVENTID: |
| 2628 | ath10k_wmi_event_inst_rssi_stats(ar, skb); |
| 2629 | break; |
| 2630 | case WMI_10X_VDEV_STANDBY_REQ_EVENTID: |
| 2631 | ath10k_wmi_event_vdev_standby_req(ar, skb); |
| 2632 | break; |
| 2633 | case WMI_10X_VDEV_RESUME_REQ_EVENTID: |
| 2634 | ath10k_wmi_event_vdev_resume_req(ar, skb); |
| 2635 | break; |
| 2636 | case WMI_10X_SERVICE_READY_EVENTID: |
Bartosz Markowski | 6f97d25 | 2013-09-26 17:47:09 +0200 | [diff] [blame] | 2637 | ath10k_wmi_10x_service_ready_event_rx(ar, skb); |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2638 | break; |
| 2639 | case WMI_10X_READY_EVENTID: |
| 2640 | ath10k_wmi_ready_event_rx(ar, skb); |
| 2641 | break; |
Kalle Valo | 43d2a30 | 2014-09-10 18:23:30 +0300 | [diff] [blame] | 2642 | case WMI_10X_PDEV_UTF_EVENTID: |
| 2643 | /* ignore utf events */ |
| 2644 | break; |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2645 | default: |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2646 | ath10k_warn(ar, "Unknown eventid: %d\n", id); |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2647 | break; |
| 2648 | } |
| 2649 | |
Kalle Valo | 43d2a30 | 2014-09-10 18:23:30 +0300 | [diff] [blame] | 2650 | out: |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2651 | dev_kfree_skb(skb); |
| 2652 | } |
| 2653 | |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 2654 | static void ath10k_wmi_10_2_process_rx(struct ath10k *ar, struct sk_buff *skb) |
| 2655 | { |
| 2656 | struct wmi_cmd_hdr *cmd_hdr; |
| 2657 | enum wmi_10_2_event_id id; |
| 2658 | |
| 2659 | cmd_hdr = (struct wmi_cmd_hdr *)skb->data; |
| 2660 | id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID); |
| 2661 | |
| 2662 | if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL) |
| 2663 | return; |
| 2664 | |
Michal Kazior | d35a6c1 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 2665 | trace_ath10k_wmi_event(ar, id, skb->data, skb->len); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 2666 | |
| 2667 | switch (id) { |
| 2668 | case WMI_10_2_MGMT_RX_EVENTID: |
| 2669 | ath10k_wmi_event_mgmt_rx(ar, skb); |
| 2670 | /* mgmt_rx() owns the skb now! */ |
| 2671 | return; |
| 2672 | case WMI_10_2_SCAN_EVENTID: |
| 2673 | ath10k_wmi_event_scan(ar, skb); |
| 2674 | break; |
| 2675 | case WMI_10_2_CHAN_INFO_EVENTID: |
| 2676 | ath10k_wmi_event_chan_info(ar, skb); |
| 2677 | break; |
| 2678 | case WMI_10_2_ECHO_EVENTID: |
| 2679 | ath10k_wmi_event_echo(ar, skb); |
| 2680 | break; |
| 2681 | case WMI_10_2_DEBUG_MESG_EVENTID: |
| 2682 | ath10k_wmi_event_debug_mesg(ar, skb); |
| 2683 | break; |
| 2684 | case WMI_10_2_UPDATE_STATS_EVENTID: |
| 2685 | ath10k_wmi_event_update_stats(ar, skb); |
| 2686 | break; |
| 2687 | case WMI_10_2_VDEV_START_RESP_EVENTID: |
| 2688 | ath10k_wmi_event_vdev_start_resp(ar, skb); |
| 2689 | break; |
| 2690 | case WMI_10_2_VDEV_STOPPED_EVENTID: |
| 2691 | ath10k_wmi_event_vdev_stopped(ar, skb); |
| 2692 | break; |
| 2693 | case WMI_10_2_PEER_STA_KICKOUT_EVENTID: |
| 2694 | ath10k_wmi_event_peer_sta_kickout(ar, skb); |
| 2695 | break; |
| 2696 | case WMI_10_2_HOST_SWBA_EVENTID: |
| 2697 | ath10k_wmi_event_host_swba(ar, skb); |
| 2698 | break; |
| 2699 | case WMI_10_2_TBTTOFFSET_UPDATE_EVENTID: |
| 2700 | ath10k_wmi_event_tbttoffset_update(ar, skb); |
| 2701 | break; |
| 2702 | case WMI_10_2_PHYERR_EVENTID: |
| 2703 | ath10k_wmi_event_phyerr(ar, skb); |
| 2704 | break; |
| 2705 | case WMI_10_2_ROAM_EVENTID: |
| 2706 | ath10k_wmi_event_roam(ar, skb); |
| 2707 | break; |
| 2708 | case WMI_10_2_PROFILE_MATCH: |
| 2709 | ath10k_wmi_event_profile_match(ar, skb); |
| 2710 | break; |
| 2711 | case WMI_10_2_DEBUG_PRINT_EVENTID: |
| 2712 | ath10k_wmi_event_debug_print(ar, skb); |
| 2713 | break; |
| 2714 | case WMI_10_2_PDEV_QVIT_EVENTID: |
| 2715 | ath10k_wmi_event_pdev_qvit(ar, skb); |
| 2716 | break; |
| 2717 | case WMI_10_2_WLAN_PROFILE_DATA_EVENTID: |
| 2718 | ath10k_wmi_event_wlan_profile_data(ar, skb); |
| 2719 | break; |
| 2720 | case WMI_10_2_RTT_MEASUREMENT_REPORT_EVENTID: |
| 2721 | ath10k_wmi_event_rtt_measurement_report(ar, skb); |
| 2722 | break; |
| 2723 | case WMI_10_2_TSF_MEASUREMENT_REPORT_EVENTID: |
| 2724 | ath10k_wmi_event_tsf_measurement_report(ar, skb); |
| 2725 | break; |
| 2726 | case WMI_10_2_RTT_ERROR_REPORT_EVENTID: |
| 2727 | ath10k_wmi_event_rtt_error_report(ar, skb); |
| 2728 | break; |
| 2729 | case WMI_10_2_WOW_WAKEUP_HOST_EVENTID: |
| 2730 | ath10k_wmi_event_wow_wakeup_host(ar, skb); |
| 2731 | break; |
| 2732 | case WMI_10_2_DCS_INTERFERENCE_EVENTID: |
| 2733 | ath10k_wmi_event_dcs_interference(ar, skb); |
| 2734 | break; |
| 2735 | case WMI_10_2_PDEV_TPC_CONFIG_EVENTID: |
| 2736 | ath10k_wmi_event_pdev_tpc_config(ar, skb); |
| 2737 | break; |
| 2738 | case WMI_10_2_INST_RSSI_STATS_EVENTID: |
| 2739 | ath10k_wmi_event_inst_rssi_stats(ar, skb); |
| 2740 | break; |
| 2741 | case WMI_10_2_VDEV_STANDBY_REQ_EVENTID: |
| 2742 | ath10k_wmi_event_vdev_standby_req(ar, skb); |
| 2743 | break; |
| 2744 | case WMI_10_2_VDEV_RESUME_REQ_EVENTID: |
| 2745 | ath10k_wmi_event_vdev_resume_req(ar, skb); |
| 2746 | break; |
| 2747 | case WMI_10_2_SERVICE_READY_EVENTID: |
| 2748 | ath10k_wmi_10x_service_ready_event_rx(ar, skb); |
| 2749 | break; |
| 2750 | case WMI_10_2_READY_EVENTID: |
| 2751 | ath10k_wmi_ready_event_rx(ar, skb); |
| 2752 | break; |
| 2753 | case WMI_10_2_RTT_KEEPALIVE_EVENTID: |
| 2754 | case WMI_10_2_GPIO_INPUT_EVENTID: |
| 2755 | case WMI_10_2_PEER_RATECODE_LIST_EVENTID: |
| 2756 | case WMI_10_2_GENERIC_BUFFER_EVENTID: |
| 2757 | case WMI_10_2_MCAST_BUF_RELEASE_EVENTID: |
| 2758 | case WMI_10_2_MCAST_LIST_AGEOUT_EVENTID: |
| 2759 | case WMI_10_2_WDS_PEER_EVENTID: |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2760 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 2761 | "received event id %d not implemented\n", id); |
| 2762 | break; |
| 2763 | default: |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2764 | ath10k_warn(ar, "Unknown eventid: %d\n", id); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 2765 | break; |
| 2766 | } |
| 2767 | |
| 2768 | dev_kfree_skb(skb); |
| 2769 | } |
Bartosz Markowski | 8a6618b | 2013-09-26 17:47:08 +0200 | [diff] [blame] | 2770 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2771 | static void ath10k_wmi_process_rx(struct ath10k *ar, struct sk_buff *skb) |
| 2772 | { |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 2773 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { |
| 2774 | if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features)) |
| 2775 | ath10k_wmi_10_2_process_rx(ar, skb); |
| 2776 | else |
| 2777 | ath10k_wmi_10x_process_rx(ar, skb); |
| 2778 | } else { |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2779 | ath10k_wmi_main_process_rx(ar, skb); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 2780 | } |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2781 | } |
| 2782 | |
Michal Kazior | 95bf21f | 2014-05-16 17:15:39 +0300 | [diff] [blame] | 2783 | int ath10k_wmi_connect(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2784 | { |
| 2785 | int status; |
| 2786 | struct ath10k_htc_svc_conn_req conn_req; |
| 2787 | struct ath10k_htc_svc_conn_resp conn_resp; |
| 2788 | |
| 2789 | memset(&conn_req, 0, sizeof(conn_req)); |
| 2790 | memset(&conn_resp, 0, sizeof(conn_resp)); |
| 2791 | |
| 2792 | /* these fields are the same for all service endpoints */ |
| 2793 | conn_req.ep_ops.ep_tx_complete = ath10k_wmi_htc_tx_complete; |
| 2794 | conn_req.ep_ops.ep_rx_complete = ath10k_wmi_process_rx; |
Michal Kazior | be8b394 | 2013-09-13 14:16:54 +0200 | [diff] [blame] | 2795 | 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] | 2796 | |
| 2797 | /* connect to control service */ |
| 2798 | conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL; |
| 2799 | |
Michal Kazior | cd003fa | 2013-07-05 16:15:13 +0300 | [diff] [blame] | 2800 | status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2801 | if (status) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2802 | 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] | 2803 | status); |
| 2804 | return status; |
| 2805 | } |
| 2806 | |
| 2807 | ar->wmi.eid = conn_resp.eid; |
| 2808 | return 0; |
| 2809 | } |
| 2810 | |
Marek Puzyniak | 821af6a | 2014-03-21 17:46:57 +0200 | [diff] [blame] | 2811 | static int ath10k_wmi_main_pdev_set_regdomain(struct ath10k *ar, u16 rd, |
| 2812 | u16 rd2g, u16 rd5g, u16 ctl2g, |
| 2813 | u16 ctl5g) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2814 | { |
| 2815 | struct wmi_pdev_set_regdomain_cmd *cmd; |
| 2816 | struct sk_buff *skb; |
| 2817 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2818 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2819 | if (!skb) |
| 2820 | return -ENOMEM; |
| 2821 | |
| 2822 | cmd = (struct wmi_pdev_set_regdomain_cmd *)skb->data; |
| 2823 | cmd->reg_domain = __cpu_to_le32(rd); |
| 2824 | cmd->reg_domain_2G = __cpu_to_le32(rd2g); |
| 2825 | cmd->reg_domain_5G = __cpu_to_le32(rd5g); |
| 2826 | cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g); |
| 2827 | cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g); |
| 2828 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2829 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2830 | "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x\n", |
| 2831 | rd, rd2g, rd5g, ctl2g, ctl5g); |
| 2832 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2833 | return ath10k_wmi_cmd_send(ar, skb, |
| 2834 | ar->wmi.cmd->pdev_set_regdomain_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2835 | } |
| 2836 | |
Marek Puzyniak | 821af6a | 2014-03-21 17:46:57 +0200 | [diff] [blame] | 2837 | static int ath10k_wmi_10x_pdev_set_regdomain(struct ath10k *ar, u16 rd, |
| 2838 | u16 rd2g, u16 rd5g, |
| 2839 | u16 ctl2g, u16 ctl5g, |
| 2840 | enum wmi_dfs_region dfs_reg) |
| 2841 | { |
| 2842 | struct wmi_pdev_set_regdomain_cmd_10x *cmd; |
| 2843 | struct sk_buff *skb; |
| 2844 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2845 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Marek Puzyniak | 821af6a | 2014-03-21 17:46:57 +0200 | [diff] [blame] | 2846 | if (!skb) |
| 2847 | return -ENOMEM; |
| 2848 | |
| 2849 | cmd = (struct wmi_pdev_set_regdomain_cmd_10x *)skb->data; |
| 2850 | cmd->reg_domain = __cpu_to_le32(rd); |
| 2851 | cmd->reg_domain_2G = __cpu_to_le32(rd2g); |
| 2852 | cmd->reg_domain_5G = __cpu_to_le32(rd5g); |
| 2853 | cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g); |
| 2854 | cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g); |
| 2855 | cmd->dfs_domain = __cpu_to_le32(dfs_reg); |
| 2856 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2857 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Marek Puzyniak | 821af6a | 2014-03-21 17:46:57 +0200 | [diff] [blame] | 2858 | "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x dfs_region %x\n", |
| 2859 | rd, rd2g, rd5g, ctl2g, ctl5g, dfs_reg); |
| 2860 | |
| 2861 | return ath10k_wmi_cmd_send(ar, skb, |
| 2862 | ar->wmi.cmd->pdev_set_regdomain_cmdid); |
| 2863 | } |
| 2864 | |
| 2865 | int ath10k_wmi_pdev_set_regdomain(struct ath10k *ar, u16 rd, u16 rd2g, |
| 2866 | u16 rd5g, u16 ctl2g, u16 ctl5g, |
| 2867 | enum wmi_dfs_region dfs_reg) |
| 2868 | { |
| 2869 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) |
| 2870 | return ath10k_wmi_10x_pdev_set_regdomain(ar, rd, rd2g, rd5g, |
| 2871 | ctl2g, ctl5g, dfs_reg); |
| 2872 | else |
| 2873 | return ath10k_wmi_main_pdev_set_regdomain(ar, rd, rd2g, rd5g, |
| 2874 | ctl2g, ctl5g); |
| 2875 | } |
| 2876 | |
Marek Puzyniak | 00f5482 | 2014-02-10 17:14:24 +0100 | [diff] [blame] | 2877 | int ath10k_wmi_pdev_suspend_target(struct ath10k *ar, u32 suspend_opt) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2878 | { |
| 2879 | struct wmi_pdev_suspend_cmd *cmd; |
| 2880 | struct sk_buff *skb; |
| 2881 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2882 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2883 | if (!skb) |
| 2884 | return -ENOMEM; |
| 2885 | |
| 2886 | cmd = (struct wmi_pdev_suspend_cmd *)skb->data; |
Marek Puzyniak | 00f5482 | 2014-02-10 17:14:24 +0100 | [diff] [blame] | 2887 | cmd->suspend_opt = __cpu_to_le32(suspend_opt); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2888 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2889 | 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] | 2890 | } |
| 2891 | |
| 2892 | int ath10k_wmi_pdev_resume_target(struct ath10k *ar) |
| 2893 | { |
| 2894 | struct sk_buff *skb; |
| 2895 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2896 | skb = ath10k_wmi_alloc_skb(ar, 0); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2897 | if (skb == NULL) |
| 2898 | return -ENOMEM; |
| 2899 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2900 | 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] | 2901 | } |
| 2902 | |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 2903 | 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] | 2904 | { |
| 2905 | struct wmi_pdev_set_param_cmd *cmd; |
| 2906 | struct sk_buff *skb; |
| 2907 | |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 2908 | if (id == WMI_PDEV_PARAM_UNSUPPORTED) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2909 | ath10k_warn(ar, "pdev param %d not supported by firmware\n", |
| 2910 | id); |
Bartosz Markowski | d544943 | 2013-10-15 09:55:32 +0200 | [diff] [blame] | 2911 | return -EOPNOTSUPP; |
Bartosz Markowski | 226a339 | 2013-09-26 17:47:16 +0200 | [diff] [blame] | 2912 | } |
| 2913 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2914 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2915 | if (!skb) |
| 2916 | return -ENOMEM; |
| 2917 | |
| 2918 | cmd = (struct wmi_pdev_set_param_cmd *)skb->data; |
| 2919 | cmd->param_id = __cpu_to_le32(id); |
| 2920 | cmd->param_value = __cpu_to_le32(value); |
| 2921 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2922 | 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] | 2923 | id, value); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 2924 | 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] | 2925 | } |
| 2926 | |
Michal Kazior | cf9fca8 | 2014-09-18 15:21:22 +0200 | [diff] [blame] | 2927 | static void ath10k_wmi_put_host_mem_chunks(struct ath10k *ar, |
| 2928 | struct wmi_host_mem_chunks *chunks) |
| 2929 | { |
| 2930 | struct host_memory_chunk *chunk; |
| 2931 | int i; |
| 2932 | |
| 2933 | chunks->count = __cpu_to_le32(ar->wmi.num_mem_chunks); |
| 2934 | |
| 2935 | for (i = 0; i < ar->wmi.num_mem_chunks; i++) { |
| 2936 | chunk = &chunks->items[i]; |
| 2937 | chunk->ptr = __cpu_to_le32(ar->wmi.mem_chunks[i].paddr); |
| 2938 | chunk->size = __cpu_to_le32(ar->wmi.mem_chunks[i].len); |
| 2939 | chunk->req_id = __cpu_to_le32(ar->wmi.mem_chunks[i].req_id); |
| 2940 | |
| 2941 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
| 2942 | "wmi chunk %d len %d requested, addr 0x%llx\n", |
| 2943 | i, |
| 2944 | ar->wmi.mem_chunks[i].len, |
| 2945 | (unsigned long long)ar->wmi.mem_chunks[i].paddr); |
| 2946 | } |
| 2947 | } |
| 2948 | |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 2949 | static int ath10k_wmi_main_cmd_init(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2950 | { |
| 2951 | struct wmi_init_cmd *cmd; |
| 2952 | struct sk_buff *buf; |
| 2953 | struct wmi_resource_config config = {}; |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 2954 | u32 len, val; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2955 | |
| 2956 | config.num_vdevs = __cpu_to_le32(TARGET_NUM_VDEVS); |
| 2957 | config.num_peers = __cpu_to_le32(TARGET_NUM_PEERS + TARGET_NUM_VDEVS); |
| 2958 | config.num_offload_peers = __cpu_to_le32(TARGET_NUM_OFFLOAD_PEERS); |
| 2959 | |
| 2960 | config.num_offload_reorder_bufs = |
| 2961 | __cpu_to_le32(TARGET_NUM_OFFLOAD_REORDER_BUFS); |
| 2962 | |
| 2963 | config.num_peer_keys = __cpu_to_le32(TARGET_NUM_PEER_KEYS); |
| 2964 | config.num_tids = __cpu_to_le32(TARGET_NUM_TIDS); |
| 2965 | config.ast_skid_limit = __cpu_to_le32(TARGET_AST_SKID_LIMIT); |
| 2966 | config.tx_chain_mask = __cpu_to_le32(TARGET_TX_CHAIN_MASK); |
| 2967 | config.rx_chain_mask = __cpu_to_le32(TARGET_RX_CHAIN_MASK); |
| 2968 | config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI); |
| 2969 | config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI); |
| 2970 | config.rx_timeout_pri_be = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI); |
| 2971 | config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_RX_TIMEOUT_HI_PRI); |
| 2972 | config.rx_decap_mode = __cpu_to_le32(TARGET_RX_DECAP_MODE); |
| 2973 | |
| 2974 | config.scan_max_pending_reqs = |
| 2975 | __cpu_to_le32(TARGET_SCAN_MAX_PENDING_REQS); |
| 2976 | |
| 2977 | config.bmiss_offload_max_vdev = |
| 2978 | __cpu_to_le32(TARGET_BMISS_OFFLOAD_MAX_VDEV); |
| 2979 | |
| 2980 | config.roam_offload_max_vdev = |
| 2981 | __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_VDEV); |
| 2982 | |
| 2983 | config.roam_offload_max_ap_profiles = |
| 2984 | __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_AP_PROFILES); |
| 2985 | |
| 2986 | config.num_mcast_groups = __cpu_to_le32(TARGET_NUM_MCAST_GROUPS); |
| 2987 | config.num_mcast_table_elems = |
| 2988 | __cpu_to_le32(TARGET_NUM_MCAST_TABLE_ELEMS); |
| 2989 | |
| 2990 | config.mcast2ucast_mode = __cpu_to_le32(TARGET_MCAST2UCAST_MODE); |
| 2991 | config.tx_dbg_log_size = __cpu_to_le32(TARGET_TX_DBG_LOG_SIZE); |
| 2992 | config.num_wds_entries = __cpu_to_le32(TARGET_NUM_WDS_ENTRIES); |
| 2993 | config.dma_burst_size = __cpu_to_le32(TARGET_DMA_BURST_SIZE); |
| 2994 | config.mac_aggr_delim = __cpu_to_le32(TARGET_MAC_AGGR_DELIM); |
| 2995 | |
| 2996 | val = TARGET_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK; |
| 2997 | config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val); |
| 2998 | |
| 2999 | config.vow_config = __cpu_to_le32(TARGET_VOW_CONFIG); |
| 3000 | |
| 3001 | config.gtk_offload_max_vdev = |
| 3002 | __cpu_to_le32(TARGET_GTK_OFFLOAD_MAX_VDEV); |
| 3003 | |
| 3004 | config.num_msdu_desc = __cpu_to_le32(TARGET_NUM_MSDU_DESC); |
| 3005 | config.max_frag_entries = __cpu_to_le32(TARGET_MAX_FRAG_ENTRIES); |
| 3006 | |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 3007 | len = sizeof(*cmd) + |
| 3008 | (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks); |
| 3009 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3010 | buf = ath10k_wmi_alloc_skb(ar, len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3011 | if (!buf) |
| 3012 | return -ENOMEM; |
| 3013 | |
| 3014 | cmd = (struct wmi_init_cmd *)buf->data; |
Bartosz Markowski | b3effe6 | 2013-09-26 17:47:11 +0200 | [diff] [blame] | 3015 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3016 | memcpy(&cmd->resource_config, &config, sizeof(config)); |
Michal Kazior | cf9fca8 | 2014-09-18 15:21:22 +0200 | [diff] [blame] | 3017 | ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3018 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3019 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init\n"); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3020 | return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3021 | } |
| 3022 | |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3023 | static int ath10k_wmi_10x_cmd_init(struct ath10k *ar) |
| 3024 | { |
| 3025 | struct wmi_init_cmd_10x *cmd; |
| 3026 | struct sk_buff *buf; |
| 3027 | struct wmi_resource_config_10x config = {}; |
| 3028 | u32 len, val; |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3029 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3030 | config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS); |
| 3031 | config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS); |
| 3032 | config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS); |
| 3033 | config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS); |
| 3034 | config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT); |
| 3035 | config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK); |
| 3036 | config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK); |
| 3037 | config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI); |
| 3038 | config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI); |
| 3039 | config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI); |
| 3040 | config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI); |
| 3041 | config.rx_decap_mode = __cpu_to_le32(TARGET_10X_RX_DECAP_MODE); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3042 | |
| 3043 | config.scan_max_pending_reqs = |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3044 | __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3045 | |
| 3046 | config.bmiss_offload_max_vdev = |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3047 | __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3048 | |
| 3049 | config.roam_offload_max_vdev = |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3050 | __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3051 | |
| 3052 | config.roam_offload_max_ap_profiles = |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3053 | __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3054 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3055 | config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3056 | config.num_mcast_table_elems = |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3057 | __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3058 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3059 | config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE); |
| 3060 | config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE); |
| 3061 | config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES); |
| 3062 | config.dma_burst_size = __cpu_to_le32(TARGET_10X_DMA_BURST_SIZE); |
| 3063 | config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3064 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3065 | val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK; |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3066 | config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val); |
| 3067 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3068 | config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3069 | |
Bartosz Markowski | ec6a73f | 2013-09-26 17:47:14 +0200 | [diff] [blame] | 3070 | config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC); |
| 3071 | config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3072 | |
| 3073 | len = sizeof(*cmd) + |
| 3074 | (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks); |
| 3075 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3076 | buf = ath10k_wmi_alloc_skb(ar, len); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3077 | if (!buf) |
| 3078 | return -ENOMEM; |
| 3079 | |
| 3080 | cmd = (struct wmi_init_cmd_10x *)buf->data; |
| 3081 | |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3082 | memcpy(&cmd->resource_config, &config, sizeof(config)); |
Michal Kazior | cf9fca8 | 2014-09-18 15:21:22 +0200 | [diff] [blame] | 3083 | ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3084 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3085 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10x\n"); |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3086 | return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); |
| 3087 | } |
| 3088 | |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3089 | static int ath10k_wmi_10_2_cmd_init(struct ath10k *ar) |
| 3090 | { |
| 3091 | struct wmi_init_cmd_10_2 *cmd; |
| 3092 | struct sk_buff *buf; |
| 3093 | struct wmi_resource_config_10x config = {}; |
| 3094 | u32 len, val; |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3095 | |
| 3096 | config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS); |
| 3097 | config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS); |
| 3098 | config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS); |
| 3099 | config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS); |
| 3100 | config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT); |
| 3101 | config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK); |
| 3102 | config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK); |
| 3103 | config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI); |
| 3104 | config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI); |
| 3105 | config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI); |
| 3106 | config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI); |
| 3107 | config.rx_decap_mode = __cpu_to_le32(TARGET_10X_RX_DECAP_MODE); |
| 3108 | |
| 3109 | config.scan_max_pending_reqs = |
| 3110 | __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS); |
| 3111 | |
| 3112 | config.bmiss_offload_max_vdev = |
| 3113 | __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV); |
| 3114 | |
| 3115 | config.roam_offload_max_vdev = |
| 3116 | __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV); |
| 3117 | |
| 3118 | config.roam_offload_max_ap_profiles = |
| 3119 | __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES); |
| 3120 | |
| 3121 | config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS); |
| 3122 | config.num_mcast_table_elems = |
| 3123 | __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS); |
| 3124 | |
| 3125 | config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE); |
| 3126 | config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE); |
| 3127 | config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES); |
| 3128 | config.dma_burst_size = __cpu_to_le32(TARGET_10X_DMA_BURST_SIZE); |
| 3129 | config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM); |
| 3130 | |
| 3131 | val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK; |
| 3132 | config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val); |
| 3133 | |
| 3134 | config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG); |
| 3135 | |
| 3136 | config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC); |
| 3137 | config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES); |
| 3138 | |
| 3139 | len = sizeof(*cmd) + |
| 3140 | (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks); |
| 3141 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3142 | buf = ath10k_wmi_alloc_skb(ar, len); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3143 | if (!buf) |
| 3144 | return -ENOMEM; |
| 3145 | |
| 3146 | cmd = (struct wmi_init_cmd_10_2 *)buf->data; |
| 3147 | |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3148 | memcpy(&cmd->resource_config.common, &config, sizeof(config)); |
Michal Kazior | cf9fca8 | 2014-09-18 15:21:22 +0200 | [diff] [blame] | 3149 | ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3150 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3151 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.2\n"); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3152 | return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid); |
| 3153 | } |
| 3154 | |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3155 | int ath10k_wmi_cmd_init(struct ath10k *ar) |
| 3156 | { |
| 3157 | int ret; |
| 3158 | |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3159 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { |
| 3160 | if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features)) |
| 3161 | ret = ath10k_wmi_10_2_cmd_init(ar); |
| 3162 | else |
| 3163 | ret = ath10k_wmi_10x_cmd_init(ar); |
| 3164 | } else { |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3165 | ret = ath10k_wmi_main_cmd_init(ar); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3166 | } |
Bartosz Markowski | 12b2b9e | 2013-09-26 17:47:13 +0200 | [diff] [blame] | 3167 | |
| 3168 | return ret; |
| 3169 | } |
| 3170 | |
Bartosz Markowski | 89b7e76 | 2013-09-26 17:47:17 +0200 | [diff] [blame] | 3171 | static int ath10k_wmi_start_scan_calc_len(struct ath10k *ar, |
| 3172 | const struct wmi_start_scan_arg *arg) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3173 | { |
| 3174 | int len; |
| 3175 | |
Bartosz Markowski | 89b7e76 | 2013-09-26 17:47:17 +0200 | [diff] [blame] | 3176 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) |
| 3177 | len = sizeof(struct wmi_start_scan_cmd_10x); |
| 3178 | else |
| 3179 | len = sizeof(struct wmi_start_scan_cmd); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3180 | |
| 3181 | if (arg->ie_len) { |
| 3182 | if (!arg->ie) |
| 3183 | return -EINVAL; |
| 3184 | if (arg->ie_len > WLAN_SCAN_PARAMS_MAX_IE_LEN) |
| 3185 | return -EINVAL; |
| 3186 | |
| 3187 | len += sizeof(struct wmi_ie_data); |
| 3188 | len += roundup(arg->ie_len, 4); |
| 3189 | } |
| 3190 | |
| 3191 | if (arg->n_channels) { |
| 3192 | if (!arg->channels) |
| 3193 | return -EINVAL; |
| 3194 | if (arg->n_channels > ARRAY_SIZE(arg->channels)) |
| 3195 | return -EINVAL; |
| 3196 | |
| 3197 | len += sizeof(struct wmi_chan_list); |
| 3198 | len += sizeof(__le32) * arg->n_channels; |
| 3199 | } |
| 3200 | |
| 3201 | if (arg->n_ssids) { |
| 3202 | if (!arg->ssids) |
| 3203 | return -EINVAL; |
| 3204 | if (arg->n_ssids > WLAN_SCAN_PARAMS_MAX_SSID) |
| 3205 | return -EINVAL; |
| 3206 | |
| 3207 | len += sizeof(struct wmi_ssid_list); |
| 3208 | len += sizeof(struct wmi_ssid) * arg->n_ssids; |
| 3209 | } |
| 3210 | |
| 3211 | if (arg->n_bssids) { |
| 3212 | if (!arg->bssids) |
| 3213 | return -EINVAL; |
| 3214 | if (arg->n_bssids > WLAN_SCAN_PARAMS_MAX_BSSID) |
| 3215 | return -EINVAL; |
| 3216 | |
| 3217 | len += sizeof(struct wmi_bssid_list); |
| 3218 | len += sizeof(struct wmi_mac_addr) * arg->n_bssids; |
| 3219 | } |
| 3220 | |
| 3221 | return len; |
| 3222 | } |
| 3223 | |
| 3224 | int ath10k_wmi_start_scan(struct ath10k *ar, |
| 3225 | const struct wmi_start_scan_arg *arg) |
| 3226 | { |
| 3227 | struct wmi_start_scan_cmd *cmd; |
| 3228 | struct sk_buff *skb; |
| 3229 | struct wmi_ie_data *ie; |
| 3230 | struct wmi_chan_list *channels; |
| 3231 | struct wmi_ssid_list *ssids; |
| 3232 | struct wmi_bssid_list *bssids; |
| 3233 | u32 scan_id; |
| 3234 | u32 scan_req_id; |
| 3235 | int off; |
| 3236 | int len = 0; |
| 3237 | int i; |
| 3238 | |
Bartosz Markowski | 89b7e76 | 2013-09-26 17:47:17 +0200 | [diff] [blame] | 3239 | len = ath10k_wmi_start_scan_calc_len(ar, arg); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3240 | if (len < 0) |
| 3241 | return len; /* len contains error code here */ |
| 3242 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3243 | skb = ath10k_wmi_alloc_skb(ar, len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3244 | if (!skb) |
| 3245 | return -ENOMEM; |
| 3246 | |
| 3247 | scan_id = WMI_HOST_SCAN_REQ_ID_PREFIX; |
| 3248 | scan_id |= arg->scan_id; |
| 3249 | |
| 3250 | scan_req_id = WMI_HOST_SCAN_REQUESTOR_ID_PREFIX; |
| 3251 | scan_req_id |= arg->scan_req_id; |
| 3252 | |
| 3253 | cmd = (struct wmi_start_scan_cmd *)skb->data; |
| 3254 | cmd->scan_id = __cpu_to_le32(scan_id); |
| 3255 | cmd->scan_req_id = __cpu_to_le32(scan_req_id); |
| 3256 | cmd->vdev_id = __cpu_to_le32(arg->vdev_id); |
| 3257 | cmd->scan_priority = __cpu_to_le32(arg->scan_priority); |
| 3258 | cmd->notify_scan_events = __cpu_to_le32(arg->notify_scan_events); |
| 3259 | cmd->dwell_time_active = __cpu_to_le32(arg->dwell_time_active); |
| 3260 | cmd->dwell_time_passive = __cpu_to_le32(arg->dwell_time_passive); |
| 3261 | cmd->min_rest_time = __cpu_to_le32(arg->min_rest_time); |
| 3262 | cmd->max_rest_time = __cpu_to_le32(arg->max_rest_time); |
| 3263 | cmd->repeat_probe_time = __cpu_to_le32(arg->repeat_probe_time); |
| 3264 | cmd->probe_spacing_time = __cpu_to_le32(arg->probe_spacing_time); |
| 3265 | cmd->idle_time = __cpu_to_le32(arg->idle_time); |
| 3266 | cmd->max_scan_time = __cpu_to_le32(arg->max_scan_time); |
| 3267 | cmd->probe_delay = __cpu_to_le32(arg->probe_delay); |
| 3268 | cmd->scan_ctrl_flags = __cpu_to_le32(arg->scan_ctrl_flags); |
| 3269 | |
| 3270 | /* TLV list starts after fields included in the struct */ |
Bartosz Markowski | 89b7e76 | 2013-09-26 17:47:17 +0200 | [diff] [blame] | 3271 | /* There's just one filed that differes the two start_scan |
| 3272 | * structures - burst_duration, which we are not using btw, |
| 3273 | no point to make the split here, just shift the buffer to fit with |
| 3274 | given FW */ |
| 3275 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) |
| 3276 | off = sizeof(struct wmi_start_scan_cmd_10x); |
| 3277 | else |
| 3278 | off = sizeof(struct wmi_start_scan_cmd); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3279 | |
| 3280 | if (arg->n_channels) { |
| 3281 | channels = (void *)skb->data + off; |
| 3282 | channels->tag = __cpu_to_le32(WMI_CHAN_LIST_TAG); |
| 3283 | channels->num_chan = __cpu_to_le32(arg->n_channels); |
| 3284 | |
| 3285 | for (i = 0; i < arg->n_channels; i++) |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3286 | channels->channel_list[i].freq = |
| 3287 | __cpu_to_le16(arg->channels[i]); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3288 | |
| 3289 | off += sizeof(*channels); |
| 3290 | off += sizeof(__le32) * arg->n_channels; |
| 3291 | } |
| 3292 | |
| 3293 | if (arg->n_ssids) { |
| 3294 | ssids = (void *)skb->data + off; |
| 3295 | ssids->tag = __cpu_to_le32(WMI_SSID_LIST_TAG); |
| 3296 | ssids->num_ssids = __cpu_to_le32(arg->n_ssids); |
| 3297 | |
| 3298 | for (i = 0; i < arg->n_ssids; i++) { |
| 3299 | ssids->ssids[i].ssid_len = |
| 3300 | __cpu_to_le32(arg->ssids[i].len); |
| 3301 | memcpy(&ssids->ssids[i].ssid, |
| 3302 | arg->ssids[i].ssid, |
| 3303 | arg->ssids[i].len); |
| 3304 | } |
| 3305 | |
| 3306 | off += sizeof(*ssids); |
| 3307 | off += sizeof(struct wmi_ssid) * arg->n_ssids; |
| 3308 | } |
| 3309 | |
| 3310 | if (arg->n_bssids) { |
| 3311 | bssids = (void *)skb->data + off; |
| 3312 | bssids->tag = __cpu_to_le32(WMI_BSSID_LIST_TAG); |
| 3313 | bssids->num_bssid = __cpu_to_le32(arg->n_bssids); |
| 3314 | |
| 3315 | for (i = 0; i < arg->n_bssids; i++) |
| 3316 | memcpy(&bssids->bssid_list[i], |
| 3317 | arg->bssids[i].bssid, |
| 3318 | ETH_ALEN); |
| 3319 | |
| 3320 | off += sizeof(*bssids); |
| 3321 | off += sizeof(struct wmi_mac_addr) * arg->n_bssids; |
| 3322 | } |
| 3323 | |
| 3324 | if (arg->ie_len) { |
| 3325 | ie = (void *)skb->data + off; |
| 3326 | ie->tag = __cpu_to_le32(WMI_IE_TAG); |
| 3327 | ie->ie_len = __cpu_to_le32(arg->ie_len); |
| 3328 | memcpy(ie->ie_data, arg->ie, arg->ie_len); |
| 3329 | |
| 3330 | off += sizeof(*ie); |
| 3331 | off += roundup(arg->ie_len, 4); |
| 3332 | } |
| 3333 | |
| 3334 | if (off != skb->len) { |
| 3335 | dev_kfree_skb(skb); |
| 3336 | return -EINVAL; |
| 3337 | } |
| 3338 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3339 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi start scan\n"); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3340 | 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] | 3341 | } |
| 3342 | |
| 3343 | void ath10k_wmi_start_scan_init(struct ath10k *ar, |
| 3344 | struct wmi_start_scan_arg *arg) |
| 3345 | { |
| 3346 | /* setup commonly used values */ |
| 3347 | arg->scan_req_id = 1; |
| 3348 | arg->scan_priority = WMI_SCAN_PRIORITY_LOW; |
| 3349 | arg->dwell_time_active = 50; |
| 3350 | arg->dwell_time_passive = 150; |
| 3351 | arg->min_rest_time = 50; |
| 3352 | arg->max_rest_time = 500; |
| 3353 | arg->repeat_probe_time = 0; |
| 3354 | arg->probe_spacing_time = 0; |
| 3355 | arg->idle_time = 0; |
Bartosz Markowski | c322892 | 2013-10-02 08:48:52 +0200 | [diff] [blame] | 3356 | arg->max_scan_time = 20000; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3357 | arg->probe_delay = 5; |
| 3358 | arg->notify_scan_events = WMI_SCAN_EVENT_STARTED |
| 3359 | | WMI_SCAN_EVENT_COMPLETED |
| 3360 | | WMI_SCAN_EVENT_BSS_CHANNEL |
| 3361 | | WMI_SCAN_EVENT_FOREIGN_CHANNEL |
| 3362 | | WMI_SCAN_EVENT_DEQUEUED; |
| 3363 | arg->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES; |
| 3364 | arg->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT; |
| 3365 | arg->n_bssids = 1; |
| 3366 | arg->bssids[0].bssid = "\xFF\xFF\xFF\xFF\xFF\xFF"; |
| 3367 | } |
| 3368 | |
| 3369 | int ath10k_wmi_stop_scan(struct ath10k *ar, const struct wmi_stop_scan_arg *arg) |
| 3370 | { |
| 3371 | struct wmi_stop_scan_cmd *cmd; |
| 3372 | struct sk_buff *skb; |
| 3373 | u32 scan_id; |
| 3374 | u32 req_id; |
| 3375 | |
| 3376 | if (arg->req_id > 0xFFF) |
| 3377 | return -EINVAL; |
| 3378 | if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF) |
| 3379 | return -EINVAL; |
| 3380 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3381 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3382 | if (!skb) |
| 3383 | return -ENOMEM; |
| 3384 | |
| 3385 | scan_id = arg->u.scan_id; |
| 3386 | scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX; |
| 3387 | |
| 3388 | req_id = arg->req_id; |
| 3389 | req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX; |
| 3390 | |
| 3391 | cmd = (struct wmi_stop_scan_cmd *)skb->data; |
| 3392 | cmd->req_type = __cpu_to_le32(arg->req_type); |
| 3393 | cmd->vdev_id = __cpu_to_le32(arg->u.vdev_id); |
| 3394 | cmd->scan_id = __cpu_to_le32(scan_id); |
| 3395 | cmd->scan_req_id = __cpu_to_le32(req_id); |
| 3396 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3397 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3398 | "wmi stop scan reqid %d req_type %d vdev/scan_id %d\n", |
| 3399 | arg->req_id, arg->req_type, arg->u.scan_id); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3400 | 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] | 3401 | } |
| 3402 | |
| 3403 | int ath10k_wmi_vdev_create(struct ath10k *ar, u32 vdev_id, |
| 3404 | enum wmi_vdev_type type, |
| 3405 | enum wmi_vdev_subtype subtype, |
| 3406 | const u8 macaddr[ETH_ALEN]) |
| 3407 | { |
| 3408 | struct wmi_vdev_create_cmd *cmd; |
| 3409 | struct sk_buff *skb; |
| 3410 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3411 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3412 | if (!skb) |
| 3413 | return -ENOMEM; |
| 3414 | |
| 3415 | cmd = (struct wmi_vdev_create_cmd *)skb->data; |
| 3416 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3417 | cmd->vdev_type = __cpu_to_le32(type); |
| 3418 | cmd->vdev_subtype = __cpu_to_le32(subtype); |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3419 | ether_addr_copy(cmd->vdev_macaddr.addr, macaddr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3420 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3421 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3422 | "WMI vdev create: id %d type %d subtype %d macaddr %pM\n", |
| 3423 | vdev_id, type, subtype, macaddr); |
| 3424 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3425 | 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] | 3426 | } |
| 3427 | |
| 3428 | int ath10k_wmi_vdev_delete(struct ath10k *ar, u32 vdev_id) |
| 3429 | { |
| 3430 | struct wmi_vdev_delete_cmd *cmd; |
| 3431 | struct sk_buff *skb; |
| 3432 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3433 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3434 | if (!skb) |
| 3435 | return -ENOMEM; |
| 3436 | |
| 3437 | cmd = (struct wmi_vdev_delete_cmd *)skb->data; |
| 3438 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3439 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3440 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3441 | "WMI vdev delete id %d\n", vdev_id); |
| 3442 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3443 | 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] | 3444 | } |
| 3445 | |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 3446 | static int |
| 3447 | ath10k_wmi_vdev_start_restart(struct ath10k *ar, |
| 3448 | const struct wmi_vdev_start_request_arg *arg, |
| 3449 | u32 cmd_id) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3450 | { |
| 3451 | struct wmi_vdev_start_request_cmd *cmd; |
| 3452 | struct sk_buff *skb; |
| 3453 | const char *cmdname; |
| 3454 | u32 flags = 0; |
| 3455 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3456 | if (cmd_id != ar->wmi.cmd->vdev_start_request_cmdid && |
| 3457 | cmd_id != ar->wmi.cmd->vdev_restart_request_cmdid) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3458 | return -EINVAL; |
| 3459 | if (WARN_ON(arg->ssid && arg->ssid_len == 0)) |
| 3460 | return -EINVAL; |
| 3461 | if (WARN_ON(arg->hidden_ssid && !arg->ssid)) |
| 3462 | return -EINVAL; |
| 3463 | if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid))) |
| 3464 | return -EINVAL; |
| 3465 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3466 | if (cmd_id == ar->wmi.cmd->vdev_start_request_cmdid) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3467 | cmdname = "start"; |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3468 | else if (cmd_id == ar->wmi.cmd->vdev_restart_request_cmdid) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3469 | cmdname = "restart"; |
| 3470 | else |
| 3471 | return -EINVAL; /* should not happen, we already check cmd_id */ |
| 3472 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3473 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3474 | if (!skb) |
| 3475 | return -ENOMEM; |
| 3476 | |
| 3477 | if (arg->hidden_ssid) |
| 3478 | flags |= WMI_VDEV_START_HIDDEN_SSID; |
| 3479 | if (arg->pmf_enabled) |
| 3480 | flags |= WMI_VDEV_START_PMF_ENABLED; |
| 3481 | |
| 3482 | cmd = (struct wmi_vdev_start_request_cmd *)skb->data; |
| 3483 | cmd->vdev_id = __cpu_to_le32(arg->vdev_id); |
| 3484 | cmd->disable_hw_ack = __cpu_to_le32(arg->disable_hw_ack); |
| 3485 | cmd->beacon_interval = __cpu_to_le32(arg->bcn_intval); |
| 3486 | cmd->dtim_period = __cpu_to_le32(arg->dtim_period); |
| 3487 | cmd->flags = __cpu_to_le32(flags); |
| 3488 | cmd->bcn_tx_rate = __cpu_to_le32(arg->bcn_tx_rate); |
| 3489 | cmd->bcn_tx_power = __cpu_to_le32(arg->bcn_tx_power); |
| 3490 | |
| 3491 | if (arg->ssid) { |
| 3492 | cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len); |
| 3493 | memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len); |
| 3494 | } |
| 3495 | |
Michal Kazior | 2d66721 | 2014-09-18 15:21:21 +0200 | [diff] [blame] | 3496 | ath10k_wmi_put_wmi_channel(&cmd->chan, &arg->channel); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3497 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3498 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 8cc7f26 | 2014-09-14 12:50:39 +0300 | [diff] [blame] | 3499 | "wmi vdev %s id 0x%x flags: 0x%0X, freq %d, mode %d, ch_flags: 0x%0X, max_power: %d\n", |
| 3500 | cmdname, arg->vdev_id, |
Marek Puzyniak | e8a50f8 | 2013-11-20 09:59:47 +0200 | [diff] [blame] | 3501 | flags, arg->channel.freq, arg->channel.mode, |
| 3502 | cmd->chan.flags, arg->channel.max_power); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3503 | |
| 3504 | return ath10k_wmi_cmd_send(ar, skb, cmd_id); |
| 3505 | } |
| 3506 | |
| 3507 | int ath10k_wmi_vdev_start(struct ath10k *ar, |
| 3508 | const struct wmi_vdev_start_request_arg *arg) |
| 3509 | { |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3510 | u32 cmd_id = ar->wmi.cmd->vdev_start_request_cmdid; |
| 3511 | |
| 3512 | return ath10k_wmi_vdev_start_restart(ar, arg, cmd_id); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3513 | } |
| 3514 | |
| 3515 | int ath10k_wmi_vdev_restart(struct ath10k *ar, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 3516 | const struct wmi_vdev_start_request_arg *arg) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3517 | { |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3518 | u32 cmd_id = ar->wmi.cmd->vdev_restart_request_cmdid; |
| 3519 | |
| 3520 | return ath10k_wmi_vdev_start_restart(ar, arg, cmd_id); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3521 | } |
| 3522 | |
| 3523 | int ath10k_wmi_vdev_stop(struct ath10k *ar, u32 vdev_id) |
| 3524 | { |
| 3525 | struct wmi_vdev_stop_cmd *cmd; |
| 3526 | struct sk_buff *skb; |
| 3527 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3528 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3529 | if (!skb) |
| 3530 | return -ENOMEM; |
| 3531 | |
| 3532 | cmd = (struct wmi_vdev_stop_cmd *)skb->data; |
| 3533 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3534 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3535 | 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] | 3536 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3537 | 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] | 3538 | } |
| 3539 | |
| 3540 | int ath10k_wmi_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid, const u8 *bssid) |
| 3541 | { |
| 3542 | struct wmi_vdev_up_cmd *cmd; |
| 3543 | struct sk_buff *skb; |
| 3544 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3545 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3546 | if (!skb) |
| 3547 | return -ENOMEM; |
| 3548 | |
| 3549 | cmd = (struct wmi_vdev_up_cmd *)skb->data; |
| 3550 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3551 | cmd->vdev_assoc_id = __cpu_to_le32(aid); |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3552 | ether_addr_copy(cmd->vdev_bssid.addr, bssid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3553 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3554 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3555 | "wmi mgmt vdev up id 0x%x assoc id %d bssid %pM\n", |
| 3556 | vdev_id, aid, bssid); |
| 3557 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3558 | 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] | 3559 | } |
| 3560 | |
| 3561 | int ath10k_wmi_vdev_down(struct ath10k *ar, u32 vdev_id) |
| 3562 | { |
| 3563 | struct wmi_vdev_down_cmd *cmd; |
| 3564 | struct sk_buff *skb; |
| 3565 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3566 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3567 | if (!skb) |
| 3568 | return -ENOMEM; |
| 3569 | |
| 3570 | cmd = (struct wmi_vdev_down_cmd *)skb->data; |
| 3571 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3572 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3573 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3574 | "wmi mgmt vdev down id 0x%x\n", vdev_id); |
| 3575 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3576 | 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] | 3577 | } |
| 3578 | |
| 3579 | int ath10k_wmi_vdev_set_param(struct ath10k *ar, u32 vdev_id, |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 3580 | u32 param_id, u32 param_value) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3581 | { |
| 3582 | struct wmi_vdev_set_param_cmd *cmd; |
| 3583 | struct sk_buff *skb; |
| 3584 | |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 3585 | if (param_id == WMI_VDEV_PARAM_UNSUPPORTED) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3586 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 3587 | "vdev param %d not supported by firmware\n", |
| 3588 | param_id); |
Bartosz Markowski | ebc9abd | 2013-10-15 09:26:20 +0200 | [diff] [blame] | 3589 | return -EOPNOTSUPP; |
Bartosz Markowski | 6d1506e | 2013-09-26 17:47:15 +0200 | [diff] [blame] | 3590 | } |
| 3591 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3592 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3593 | if (!skb) |
| 3594 | return -ENOMEM; |
| 3595 | |
| 3596 | cmd = (struct wmi_vdev_set_param_cmd *)skb->data; |
| 3597 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3598 | cmd->param_id = __cpu_to_le32(param_id); |
| 3599 | cmd->param_value = __cpu_to_le32(param_value); |
| 3600 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3601 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3602 | "wmi vdev id 0x%x set param %d value %d\n", |
| 3603 | vdev_id, param_id, param_value); |
| 3604 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3605 | 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] | 3606 | } |
| 3607 | |
| 3608 | int ath10k_wmi_vdev_install_key(struct ath10k *ar, |
| 3609 | const struct wmi_vdev_install_key_arg *arg) |
| 3610 | { |
| 3611 | struct wmi_vdev_install_key_cmd *cmd; |
| 3612 | struct sk_buff *skb; |
| 3613 | |
| 3614 | if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL) |
| 3615 | return -EINVAL; |
| 3616 | if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL) |
| 3617 | return -EINVAL; |
| 3618 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3619 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd) + arg->key_len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3620 | if (!skb) |
| 3621 | return -ENOMEM; |
| 3622 | |
| 3623 | cmd = (struct wmi_vdev_install_key_cmd *)skb->data; |
| 3624 | cmd->vdev_id = __cpu_to_le32(arg->vdev_id); |
| 3625 | cmd->key_idx = __cpu_to_le32(arg->key_idx); |
| 3626 | cmd->key_flags = __cpu_to_le32(arg->key_flags); |
| 3627 | cmd->key_cipher = __cpu_to_le32(arg->key_cipher); |
| 3628 | cmd->key_len = __cpu_to_le32(arg->key_len); |
| 3629 | cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len); |
| 3630 | cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len); |
| 3631 | |
| 3632 | if (arg->macaddr) |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3633 | ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3634 | if (arg->key_data) |
| 3635 | memcpy(cmd->key_data, arg->key_data, arg->key_len); |
| 3636 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3637 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Michal Kazior | e0c508a | 2013-07-05 16:15:17 +0300 | [diff] [blame] | 3638 | "wmi vdev install key idx %d cipher %d len %d\n", |
| 3639 | arg->key_idx, arg->key_cipher, arg->key_len); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3640 | return ath10k_wmi_cmd_send(ar, skb, |
| 3641 | ar->wmi.cmd->vdev_install_key_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3642 | } |
| 3643 | |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 3644 | int ath10k_wmi_vdev_spectral_conf(struct ath10k *ar, |
| 3645 | const struct wmi_vdev_spectral_conf_arg *arg) |
| 3646 | { |
| 3647 | struct wmi_vdev_spectral_conf_cmd *cmd; |
| 3648 | struct sk_buff *skb; |
| 3649 | u32 cmdid; |
| 3650 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3651 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 3652 | if (!skb) |
| 3653 | return -ENOMEM; |
| 3654 | |
| 3655 | cmd = (struct wmi_vdev_spectral_conf_cmd *)skb->data; |
| 3656 | cmd->vdev_id = __cpu_to_le32(arg->vdev_id); |
| 3657 | cmd->scan_count = __cpu_to_le32(arg->scan_count); |
| 3658 | cmd->scan_period = __cpu_to_le32(arg->scan_period); |
| 3659 | cmd->scan_priority = __cpu_to_le32(arg->scan_priority); |
| 3660 | cmd->scan_fft_size = __cpu_to_le32(arg->scan_fft_size); |
| 3661 | cmd->scan_gc_ena = __cpu_to_le32(arg->scan_gc_ena); |
| 3662 | cmd->scan_restart_ena = __cpu_to_le32(arg->scan_restart_ena); |
| 3663 | cmd->scan_noise_floor_ref = __cpu_to_le32(arg->scan_noise_floor_ref); |
| 3664 | cmd->scan_init_delay = __cpu_to_le32(arg->scan_init_delay); |
| 3665 | cmd->scan_nb_tone_thr = __cpu_to_le32(arg->scan_nb_tone_thr); |
| 3666 | cmd->scan_str_bin_thr = __cpu_to_le32(arg->scan_str_bin_thr); |
| 3667 | cmd->scan_wb_rpt_mode = __cpu_to_le32(arg->scan_wb_rpt_mode); |
| 3668 | cmd->scan_rssi_rpt_mode = __cpu_to_le32(arg->scan_rssi_rpt_mode); |
| 3669 | cmd->scan_rssi_thr = __cpu_to_le32(arg->scan_rssi_thr); |
| 3670 | cmd->scan_pwr_format = __cpu_to_le32(arg->scan_pwr_format); |
| 3671 | cmd->scan_rpt_mode = __cpu_to_le32(arg->scan_rpt_mode); |
| 3672 | cmd->scan_bin_scale = __cpu_to_le32(arg->scan_bin_scale); |
| 3673 | cmd->scan_dbm_adj = __cpu_to_le32(arg->scan_dbm_adj); |
| 3674 | cmd->scan_chn_mask = __cpu_to_le32(arg->scan_chn_mask); |
| 3675 | |
| 3676 | cmdid = ar->wmi.cmd->vdev_spectral_scan_configure_cmdid; |
| 3677 | return ath10k_wmi_cmd_send(ar, skb, cmdid); |
| 3678 | } |
| 3679 | |
| 3680 | int ath10k_wmi_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id, u32 trigger, |
| 3681 | u32 enable) |
| 3682 | { |
| 3683 | struct wmi_vdev_spectral_enable_cmd *cmd; |
| 3684 | struct sk_buff *skb; |
| 3685 | u32 cmdid; |
| 3686 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3687 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Simon Wunderlich | 855aed1 | 2014-08-02 09:12:54 +0300 | [diff] [blame] | 3688 | if (!skb) |
| 3689 | return -ENOMEM; |
| 3690 | |
| 3691 | cmd = (struct wmi_vdev_spectral_enable_cmd *)skb->data; |
| 3692 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3693 | cmd->trigger_cmd = __cpu_to_le32(trigger); |
| 3694 | cmd->enable_cmd = __cpu_to_le32(enable); |
| 3695 | |
| 3696 | cmdid = ar->wmi.cmd->vdev_spectral_scan_enable_cmdid; |
| 3697 | return ath10k_wmi_cmd_send(ar, skb, cmdid); |
| 3698 | } |
| 3699 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3700 | int ath10k_wmi_peer_create(struct ath10k *ar, u32 vdev_id, |
| 3701 | const u8 peer_addr[ETH_ALEN]) |
| 3702 | { |
| 3703 | struct wmi_peer_create_cmd *cmd; |
| 3704 | struct sk_buff *skb; |
| 3705 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3706 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3707 | if (!skb) |
| 3708 | return -ENOMEM; |
| 3709 | |
| 3710 | cmd = (struct wmi_peer_create_cmd *)skb->data; |
| 3711 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3712 | ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3713 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3714 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3715 | "wmi peer create vdev_id %d peer_addr %pM\n", |
| 3716 | vdev_id, peer_addr); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3717 | 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] | 3718 | } |
| 3719 | |
| 3720 | int ath10k_wmi_peer_delete(struct ath10k *ar, u32 vdev_id, |
| 3721 | const u8 peer_addr[ETH_ALEN]) |
| 3722 | { |
| 3723 | struct wmi_peer_delete_cmd *cmd; |
| 3724 | struct sk_buff *skb; |
| 3725 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3726 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3727 | if (!skb) |
| 3728 | return -ENOMEM; |
| 3729 | |
| 3730 | cmd = (struct wmi_peer_delete_cmd *)skb->data; |
| 3731 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3732 | ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3733 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3734 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3735 | "wmi peer delete vdev_id %d peer_addr %pM\n", |
| 3736 | vdev_id, peer_addr); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3737 | 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] | 3738 | } |
| 3739 | |
| 3740 | int ath10k_wmi_peer_flush(struct ath10k *ar, u32 vdev_id, |
| 3741 | const u8 peer_addr[ETH_ALEN], u32 tid_bitmap) |
| 3742 | { |
| 3743 | struct wmi_peer_flush_tids_cmd *cmd; |
| 3744 | struct sk_buff *skb; |
| 3745 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3746 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3747 | if (!skb) |
| 3748 | return -ENOMEM; |
| 3749 | |
| 3750 | cmd = (struct wmi_peer_flush_tids_cmd *)skb->data; |
| 3751 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3752 | cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap); |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3753 | ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3754 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3755 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3756 | "wmi peer flush vdev_id %d peer_addr %pM tids %08x\n", |
| 3757 | vdev_id, peer_addr, tid_bitmap); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3758 | 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] | 3759 | } |
| 3760 | |
| 3761 | int ath10k_wmi_peer_set_param(struct ath10k *ar, u32 vdev_id, |
| 3762 | const u8 *peer_addr, enum wmi_peer_param param_id, |
| 3763 | u32 param_value) |
| 3764 | { |
| 3765 | struct wmi_peer_set_param_cmd *cmd; |
| 3766 | struct sk_buff *skb; |
| 3767 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3768 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3769 | if (!skb) |
| 3770 | return -ENOMEM; |
| 3771 | |
| 3772 | cmd = (struct wmi_peer_set_param_cmd *)skb->data; |
| 3773 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3774 | cmd->param_id = __cpu_to_le32(param_id); |
| 3775 | cmd->param_value = __cpu_to_le32(param_value); |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3776 | ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3777 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3778 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3779 | "wmi vdev %d peer 0x%pM set param %d value %d\n", |
| 3780 | vdev_id, peer_addr, param_id, param_value); |
| 3781 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3782 | 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] | 3783 | } |
| 3784 | |
| 3785 | int ath10k_wmi_set_psmode(struct ath10k *ar, u32 vdev_id, |
| 3786 | enum wmi_sta_ps_mode psmode) |
| 3787 | { |
| 3788 | struct wmi_sta_powersave_mode_cmd *cmd; |
| 3789 | struct sk_buff *skb; |
| 3790 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3791 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3792 | if (!skb) |
| 3793 | return -ENOMEM; |
| 3794 | |
| 3795 | cmd = (struct wmi_sta_powersave_mode_cmd *)skb->data; |
| 3796 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3797 | cmd->sta_ps_mode = __cpu_to_le32(psmode); |
| 3798 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3799 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3800 | "wmi set powersave id 0x%x mode %d\n", |
| 3801 | vdev_id, psmode); |
| 3802 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3803 | return ath10k_wmi_cmd_send(ar, skb, |
| 3804 | ar->wmi.cmd->sta_powersave_mode_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3805 | } |
| 3806 | |
| 3807 | int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id, |
| 3808 | enum wmi_sta_powersave_param param_id, |
| 3809 | u32 value) |
| 3810 | { |
| 3811 | struct wmi_sta_powersave_param_cmd *cmd; |
| 3812 | struct sk_buff *skb; |
| 3813 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3814 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3815 | if (!skb) |
| 3816 | return -ENOMEM; |
| 3817 | |
| 3818 | cmd = (struct wmi_sta_powersave_param_cmd *)skb->data; |
| 3819 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3820 | cmd->param_id = __cpu_to_le32(param_id); |
| 3821 | cmd->param_value = __cpu_to_le32(value); |
| 3822 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3823 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3824 | "wmi sta ps param vdev_id 0x%x param %d value %d\n", |
| 3825 | vdev_id, param_id, value); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3826 | return ath10k_wmi_cmd_send(ar, skb, |
| 3827 | ar->wmi.cmd->sta_powersave_param_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3828 | } |
| 3829 | |
| 3830 | int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac, |
| 3831 | enum wmi_ap_ps_peer_param param_id, u32 value) |
| 3832 | { |
| 3833 | struct wmi_ap_ps_peer_cmd *cmd; |
| 3834 | struct sk_buff *skb; |
| 3835 | |
| 3836 | if (!mac) |
| 3837 | return -EINVAL; |
| 3838 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3839 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3840 | if (!skb) |
| 3841 | return -ENOMEM; |
| 3842 | |
| 3843 | cmd = (struct wmi_ap_ps_peer_cmd *)skb->data; |
| 3844 | cmd->vdev_id = __cpu_to_le32(vdev_id); |
| 3845 | cmd->param_id = __cpu_to_le32(param_id); |
| 3846 | cmd->param_value = __cpu_to_le32(value); |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3847 | ether_addr_copy(cmd->peer_macaddr.addr, mac); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3848 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3849 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3850 | "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr %pM\n", |
| 3851 | vdev_id, param_id, value, mac); |
| 3852 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3853 | return ath10k_wmi_cmd_send(ar, skb, |
| 3854 | ar->wmi.cmd->ap_ps_peer_param_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3855 | } |
| 3856 | |
| 3857 | int ath10k_wmi_scan_chan_list(struct ath10k *ar, |
| 3858 | const struct wmi_scan_chan_list_arg *arg) |
| 3859 | { |
| 3860 | struct wmi_scan_chan_list_cmd *cmd; |
| 3861 | struct sk_buff *skb; |
| 3862 | struct wmi_channel_arg *ch; |
| 3863 | struct wmi_channel *ci; |
| 3864 | int len; |
| 3865 | int i; |
| 3866 | |
| 3867 | len = sizeof(*cmd) + arg->n_channels * sizeof(struct wmi_channel); |
| 3868 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3869 | skb = ath10k_wmi_alloc_skb(ar, len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3870 | if (!skb) |
| 3871 | return -EINVAL; |
| 3872 | |
| 3873 | cmd = (struct wmi_scan_chan_list_cmd *)skb->data; |
| 3874 | cmd->num_scan_chans = __cpu_to_le32(arg->n_channels); |
| 3875 | |
| 3876 | for (i = 0; i < arg->n_channels; i++) { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3877 | ch = &arg->channels[i]; |
| 3878 | ci = &cmd->chan_info[i]; |
| 3879 | |
Michal Kazior | 2d66721 | 2014-09-18 15:21:21 +0200 | [diff] [blame] | 3880 | ath10k_wmi_put_wmi_channel(ci, ch); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3881 | } |
| 3882 | |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 3883 | 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] | 3884 | } |
| 3885 | |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3886 | static void |
| 3887 | ath10k_wmi_peer_assoc_fill(struct ath10k *ar, void *buf, |
| 3888 | const struct wmi_peer_assoc_complete_arg *arg) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3889 | { |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3890 | struct wmi_common_peer_assoc_complete_cmd *cmd = buf; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3891 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3892 | cmd->vdev_id = __cpu_to_le32(arg->vdev_id); |
| 3893 | cmd->peer_new_assoc = __cpu_to_le32(arg->peer_reassoc ? 0 : 1); |
| 3894 | cmd->peer_associd = __cpu_to_le32(arg->peer_aid); |
| 3895 | cmd->peer_flags = __cpu_to_le32(arg->peer_flags); |
| 3896 | cmd->peer_caps = __cpu_to_le32(arg->peer_caps); |
| 3897 | cmd->peer_listen_intval = __cpu_to_le32(arg->peer_listen_intval); |
| 3898 | cmd->peer_ht_caps = __cpu_to_le32(arg->peer_ht_caps); |
| 3899 | cmd->peer_max_mpdu = __cpu_to_le32(arg->peer_max_mpdu); |
| 3900 | cmd->peer_mpdu_density = __cpu_to_le32(arg->peer_mpdu_density); |
| 3901 | cmd->peer_rate_caps = __cpu_to_le32(arg->peer_rate_caps); |
| 3902 | cmd->peer_nss = __cpu_to_le32(arg->peer_num_spatial_streams); |
| 3903 | cmd->peer_vht_caps = __cpu_to_le32(arg->peer_vht_caps); |
| 3904 | cmd->peer_phymode = __cpu_to_le32(arg->peer_phymode); |
| 3905 | |
Kalle Valo | b25f32c | 2014-09-14 12:50:49 +0300 | [diff] [blame] | 3906 | ether_addr_copy(cmd->peer_macaddr.addr, arg->addr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3907 | |
| 3908 | cmd->peer_legacy_rates.num_rates = |
| 3909 | __cpu_to_le32(arg->peer_legacy_rates.num_rates); |
| 3910 | memcpy(cmd->peer_legacy_rates.rates, arg->peer_legacy_rates.rates, |
| 3911 | arg->peer_legacy_rates.num_rates); |
| 3912 | |
| 3913 | cmd->peer_ht_rates.num_rates = |
| 3914 | __cpu_to_le32(arg->peer_ht_rates.num_rates); |
| 3915 | memcpy(cmd->peer_ht_rates.rates, arg->peer_ht_rates.rates, |
| 3916 | arg->peer_ht_rates.num_rates); |
| 3917 | |
| 3918 | cmd->peer_vht_rates.rx_max_rate = |
| 3919 | __cpu_to_le32(arg->peer_vht_rates.rx_max_rate); |
| 3920 | cmd->peer_vht_rates.rx_mcs_set = |
| 3921 | __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set); |
| 3922 | cmd->peer_vht_rates.tx_max_rate = |
| 3923 | __cpu_to_le32(arg->peer_vht_rates.tx_max_rate); |
| 3924 | cmd->peer_vht_rates.tx_mcs_set = |
| 3925 | __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3926 | } |
| 3927 | |
| 3928 | static void |
| 3929 | ath10k_wmi_peer_assoc_fill_main(struct ath10k *ar, void *buf, |
| 3930 | const struct wmi_peer_assoc_complete_arg *arg) |
| 3931 | { |
| 3932 | struct wmi_main_peer_assoc_complete_cmd *cmd = buf; |
| 3933 | |
| 3934 | ath10k_wmi_peer_assoc_fill(ar, buf, arg); |
| 3935 | memset(cmd->peer_ht_info, 0, sizeof(cmd->peer_ht_info)); |
| 3936 | } |
| 3937 | |
| 3938 | static void |
| 3939 | ath10k_wmi_peer_assoc_fill_10_1(struct ath10k *ar, void *buf, |
| 3940 | const struct wmi_peer_assoc_complete_arg *arg) |
| 3941 | { |
| 3942 | ath10k_wmi_peer_assoc_fill(ar, buf, arg); |
| 3943 | } |
| 3944 | |
| 3945 | static void |
| 3946 | ath10k_wmi_peer_assoc_fill_10_2(struct ath10k *ar, void *buf, |
| 3947 | const struct wmi_peer_assoc_complete_arg *arg) |
| 3948 | { |
| 3949 | struct wmi_10_2_peer_assoc_complete_cmd *cmd = buf; |
| 3950 | int max_mcs, max_nss; |
| 3951 | u32 info0; |
| 3952 | |
| 3953 | /* TODO: Is using max values okay with firmware? */ |
| 3954 | max_mcs = 0xf; |
| 3955 | max_nss = 0xf; |
| 3956 | |
| 3957 | info0 = SM(max_mcs, WMI_PEER_ASSOC_INFO0_MAX_MCS_IDX) | |
| 3958 | SM(max_nss, WMI_PEER_ASSOC_INFO0_MAX_NSS); |
| 3959 | |
| 3960 | ath10k_wmi_peer_assoc_fill(ar, buf, arg); |
| 3961 | cmd->info0 = __cpu_to_le32(info0); |
| 3962 | } |
| 3963 | |
| 3964 | int ath10k_wmi_peer_assoc(struct ath10k *ar, |
| 3965 | const struct wmi_peer_assoc_complete_arg *arg) |
| 3966 | { |
| 3967 | struct sk_buff *skb; |
| 3968 | int len; |
| 3969 | |
| 3970 | if (arg->peer_mpdu_density > 16) |
| 3971 | return -EINVAL; |
| 3972 | if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES) |
| 3973 | return -EINVAL; |
| 3974 | if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES) |
| 3975 | return -EINVAL; |
| 3976 | |
| 3977 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { |
| 3978 | if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features)) |
| 3979 | len = sizeof(struct wmi_10_2_peer_assoc_complete_cmd); |
| 3980 | else |
| 3981 | len = sizeof(struct wmi_10_1_peer_assoc_complete_cmd); |
| 3982 | } else { |
| 3983 | len = sizeof(struct wmi_main_peer_assoc_complete_cmd); |
| 3984 | } |
| 3985 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3986 | skb = ath10k_wmi_alloc_skb(ar, len); |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 3987 | if (!skb) |
| 3988 | return -ENOMEM; |
| 3989 | |
| 3990 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { |
| 3991 | if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features)) |
| 3992 | ath10k_wmi_peer_assoc_fill_10_1(ar, skb->data, arg); |
| 3993 | else |
| 3994 | ath10k_wmi_peer_assoc_fill_10_2(ar, skb->data, arg); |
| 3995 | } else { |
| 3996 | ath10k_wmi_peer_assoc_fill_main(ar, skb->data, arg); |
| 3997 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 3998 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 3999 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Chun-Yeow Yeoh | 44d6fa9 | 2014-03-07 10:19:30 +0200 | [diff] [blame] | 4000 | "wmi peer assoc vdev %d addr %pM (%s)\n", |
| 4001 | arg->vdev_id, arg->addr, |
| 4002 | arg->peer_reassoc ? "reassociate" : "new"); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 4003 | 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] | 4004 | } |
| 4005 | |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 4006 | /* This function assumes the beacon is already DMA mapped */ |
| 4007 | int ath10k_wmi_beacon_send_ref_nowait(struct ath10k_vif *arvif) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4008 | { |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 4009 | struct wmi_bcn_tx_ref_cmd *cmd; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4010 | struct sk_buff *skb; |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 4011 | struct sk_buff *beacon = arvif->beacon; |
| 4012 | struct ath10k *ar = arvif->ar; |
| 4013 | struct ieee80211_hdr *hdr; |
Michal Kazior | e204548 | 2013-10-28 07:18:14 +0100 | [diff] [blame] | 4014 | int ret; |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 4015 | u16 fc; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4016 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4017 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4018 | if (!skb) |
| 4019 | return -ENOMEM; |
| 4020 | |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 4021 | hdr = (struct ieee80211_hdr *)beacon->data; |
| 4022 | fc = le16_to_cpu(hdr->frame_control); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4023 | |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 4024 | cmd = (struct wmi_bcn_tx_ref_cmd *)skb->data; |
| 4025 | cmd->vdev_id = __cpu_to_le32(arvif->vdev_id); |
| 4026 | cmd->data_len = __cpu_to_le32(beacon->len); |
| 4027 | cmd->data_ptr = __cpu_to_le32(ATH10K_SKB_CB(beacon)->paddr); |
| 4028 | cmd->msdu_id = 0; |
| 4029 | cmd->frame_control = __cpu_to_le32(fc); |
| 4030 | cmd->flags = 0; |
Michal Kazior | 24c88f7 | 2014-07-25 13:32:17 +0200 | [diff] [blame] | 4031 | cmd->antenna_mask = __cpu_to_le32(WMI_BCN_TX_REF_DEF_ANTENNA); |
Michal Kazior | 748afc4 | 2014-01-23 12:48:21 +0100 | [diff] [blame] | 4032 | |
| 4033 | if (ATH10K_SKB_CB(beacon)->bcn.dtim_zero) |
| 4034 | cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DTIM_ZERO); |
| 4035 | |
| 4036 | if (ATH10K_SKB_CB(beacon)->bcn.deliver_cab) |
| 4037 | cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB); |
| 4038 | |
| 4039 | ret = ath10k_wmi_cmd_send_nowait(ar, skb, |
| 4040 | ar->wmi.cmd->pdev_send_bcn_cmdid); |
| 4041 | |
Michal Kazior | e204548 | 2013-10-28 07:18:14 +0100 | [diff] [blame] | 4042 | if (ret) |
| 4043 | dev_kfree_skb(skb); |
| 4044 | |
| 4045 | return ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4046 | } |
| 4047 | |
| 4048 | static void ath10k_wmi_pdev_set_wmm_param(struct wmi_wmm_params *params, |
| 4049 | const struct wmi_wmm_params_arg *arg) |
| 4050 | { |
| 4051 | params->cwmin = __cpu_to_le32(arg->cwmin); |
| 4052 | params->cwmax = __cpu_to_le32(arg->cwmax); |
| 4053 | params->aifs = __cpu_to_le32(arg->aifs); |
| 4054 | params->txop = __cpu_to_le32(arg->txop); |
| 4055 | params->acm = __cpu_to_le32(arg->acm); |
| 4056 | params->no_ack = __cpu_to_le32(arg->no_ack); |
| 4057 | } |
| 4058 | |
| 4059 | int ath10k_wmi_pdev_set_wmm_params(struct ath10k *ar, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 4060 | const struct wmi_pdev_set_wmm_params_arg *arg) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4061 | { |
| 4062 | struct wmi_pdev_set_wmm_params *cmd; |
| 4063 | struct sk_buff *skb; |
| 4064 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4065 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4066 | if (!skb) |
| 4067 | return -ENOMEM; |
| 4068 | |
| 4069 | cmd = (struct wmi_pdev_set_wmm_params *)skb->data; |
| 4070 | ath10k_wmi_pdev_set_wmm_param(&cmd->ac_be, &arg->ac_be); |
| 4071 | ath10k_wmi_pdev_set_wmm_param(&cmd->ac_bk, &arg->ac_bk); |
| 4072 | ath10k_wmi_pdev_set_wmm_param(&cmd->ac_vi, &arg->ac_vi); |
| 4073 | ath10k_wmi_pdev_set_wmm_param(&cmd->ac_vo, &arg->ac_vo); |
| 4074 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4075 | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set wmm params\n"); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 4076 | return ath10k_wmi_cmd_send(ar, skb, |
| 4077 | ar->wmi.cmd->pdev_set_wmm_params_cmdid); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4078 | } |
| 4079 | |
| 4080 | int ath10k_wmi_request_stats(struct ath10k *ar, enum wmi_stats_id stats_id) |
| 4081 | { |
| 4082 | struct wmi_request_stats_cmd *cmd; |
| 4083 | struct sk_buff *skb; |
| 4084 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4085 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 4086 | if (!skb) |
| 4087 | return -ENOMEM; |
| 4088 | |
| 4089 | cmd = (struct wmi_request_stats_cmd *)skb->data; |
| 4090 | cmd->stats_id = __cpu_to_le32(stats_id); |
| 4091 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4092 | 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] | 4093 | 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] | 4094 | } |
Michal Kazior | 9cfbce7 | 2013-07-16 09:54:36 +0200 | [diff] [blame] | 4095 | |
| 4096 | int ath10k_wmi_force_fw_hang(struct ath10k *ar, |
| 4097 | enum wmi_force_fw_hang_type type, u32 delay_ms) |
| 4098 | { |
| 4099 | struct wmi_force_fw_hang_cmd *cmd; |
| 4100 | struct sk_buff *skb; |
| 4101 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4102 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Michal Kazior | 9cfbce7 | 2013-07-16 09:54:36 +0200 | [diff] [blame] | 4103 | if (!skb) |
| 4104 | return -ENOMEM; |
| 4105 | |
| 4106 | cmd = (struct wmi_force_fw_hang_cmd *)skb->data; |
| 4107 | cmd->type = __cpu_to_le32(type); |
| 4108 | cmd->delay_ms = __cpu_to_le32(delay_ms); |
| 4109 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4110 | 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] | 4111 | type, delay_ms); |
Bartosz Markowski | ce42870 | 2013-09-26 17:47:05 +0200 | [diff] [blame] | 4112 | 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] | 4113 | } |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 4114 | |
| 4115 | int ath10k_wmi_dbglog_cfg(struct ath10k *ar, u32 module_enable) |
| 4116 | { |
| 4117 | struct wmi_dbglog_cfg_cmd *cmd; |
| 4118 | struct sk_buff *skb; |
| 4119 | u32 cfg; |
| 4120 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4121 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd)); |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 4122 | if (!skb) |
| 4123 | return -ENOMEM; |
| 4124 | |
| 4125 | cmd = (struct wmi_dbglog_cfg_cmd *)skb->data; |
| 4126 | |
| 4127 | if (module_enable) { |
| 4128 | cfg = SM(ATH10K_DBGLOG_LEVEL_VERBOSE, |
| 4129 | ATH10K_DBGLOG_CFG_LOG_LVL); |
| 4130 | } else { |
| 4131 | /* set back defaults, all modules with WARN level */ |
| 4132 | cfg = SM(ATH10K_DBGLOG_LEVEL_WARN, |
| 4133 | ATH10K_DBGLOG_CFG_LOG_LVL); |
| 4134 | module_enable = ~0; |
| 4135 | } |
| 4136 | |
| 4137 | cmd->module_enable = __cpu_to_le32(module_enable); |
| 4138 | cmd->module_valid = __cpu_to_le32(~0); |
| 4139 | cmd->config_enable = __cpu_to_le32(cfg); |
| 4140 | cmd->config_valid = __cpu_to_le32(ATH10K_DBGLOG_CFG_LOG_LVL_MASK); |
| 4141 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 4142 | ath10k_dbg(ar, ATH10K_DBG_WMI, |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 4143 | "wmi dbglog cfg modules %08x %08x config %08x %08x\n", |
| 4144 | __le32_to_cpu(cmd->module_enable), |
| 4145 | __le32_to_cpu(cmd->module_valid), |
| 4146 | __le32_to_cpu(cmd->config_enable), |
| 4147 | __le32_to_cpu(cmd->config_valid)); |
| 4148 | |
| 4149 | return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->dbglog_cfg_cmdid); |
| 4150 | } |
Michal Kazior | b79b9ba | 2014-09-18 15:21:23 +0200 | [diff] [blame^] | 4151 | |
| 4152 | int ath10k_wmi_attach(struct ath10k *ar) |
| 4153 | { |
| 4154 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { |
| 4155 | if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features)) |
| 4156 | ar->wmi.cmd = &wmi_10_2_cmd_map; |
| 4157 | else |
| 4158 | ar->wmi.cmd = &wmi_10x_cmd_map; |
| 4159 | |
| 4160 | ar->wmi.vdev_param = &wmi_10x_vdev_param_map; |
| 4161 | ar->wmi.pdev_param = &wmi_10x_pdev_param_map; |
| 4162 | } else { |
| 4163 | ar->wmi.cmd = &wmi_cmd_map; |
| 4164 | ar->wmi.vdev_param = &wmi_vdev_param_map; |
| 4165 | ar->wmi.pdev_param = &wmi_pdev_param_map; |
| 4166 | } |
| 4167 | |
| 4168 | init_completion(&ar->wmi.service_ready); |
| 4169 | init_completion(&ar->wmi.unified_ready); |
| 4170 | init_waitqueue_head(&ar->wmi.tx_credits_wq); |
| 4171 | |
| 4172 | return 0; |
| 4173 | } |
| 4174 | |
| 4175 | void ath10k_wmi_detach(struct ath10k *ar) |
| 4176 | { |
| 4177 | int i; |
| 4178 | |
| 4179 | /* free the host memory chunks requested by firmware */ |
| 4180 | for (i = 0; i < ar->wmi.num_mem_chunks; i++) { |
| 4181 | dma_free_coherent(ar->dev, |
| 4182 | ar->wmi.mem_chunks[i].len, |
| 4183 | ar->wmi.mem_chunks[i].vaddr, |
| 4184 | ar->wmi.mem_chunks[i].paddr); |
| 4185 | } |
| 4186 | |
| 4187 | ar->wmi.num_mem_chunks = 0; |
| 4188 | } |