blob: ae6a038f04abd474b1de629db1eb8fd3fada4a14 [file] [log] [blame]
Kalle Valo5e3dd152013-06-12 20:52:10 +03001/*
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 Valo2fe52882014-01-03 12:59:20 +020019#include <linux/ctype.h>
Kalle Valo5e3dd152013-06-12 20:52:10 +030020
21#include "core.h"
22#include "htc.h"
23#include "debug.h"
24#include "wmi.h"
Michal Kaziorca996ec2014-12-03 10:11:32 +020025#include "wmi-tlv.h"
Kalle Valo5e3dd152013-06-12 20:52:10 +030026#include "mac.h"
Kalle Valo43d2a302014-09-10 18:23:30 +030027#include "testmode.h"
Michal Kaziord7579d12014-12-03 10:10:54 +020028#include "wmi-ops.h"
Michal Kazior6a948882015-02-26 13:23:17 +010029#include "p2p.h"
Kalle Valo5e3dd152013-06-12 20:52:10 +030030
Bartosz Markowskice428702013-09-26 17:47:05 +020031/* MAIN WMI cmd track */
32static struct wmi_cmd_map wmi_cmd_map = {
33 .init_cmdid = WMI_INIT_CMDID,
34 .start_scan_cmdid = WMI_START_SCAN_CMDID,
35 .stop_scan_cmdid = WMI_STOP_SCAN_CMDID,
36 .scan_chan_list_cmdid = WMI_SCAN_CHAN_LIST_CMDID,
37 .scan_sch_prio_tbl_cmdid = WMI_SCAN_SCH_PRIO_TBL_CMDID,
38 .pdev_set_regdomain_cmdid = WMI_PDEV_SET_REGDOMAIN_CMDID,
39 .pdev_set_channel_cmdid = WMI_PDEV_SET_CHANNEL_CMDID,
40 .pdev_set_param_cmdid = WMI_PDEV_SET_PARAM_CMDID,
41 .pdev_pktlog_enable_cmdid = WMI_PDEV_PKTLOG_ENABLE_CMDID,
42 .pdev_pktlog_disable_cmdid = WMI_PDEV_PKTLOG_DISABLE_CMDID,
43 .pdev_set_wmm_params_cmdid = WMI_PDEV_SET_WMM_PARAMS_CMDID,
44 .pdev_set_ht_cap_ie_cmdid = WMI_PDEV_SET_HT_CAP_IE_CMDID,
45 .pdev_set_vht_cap_ie_cmdid = WMI_PDEV_SET_VHT_CAP_IE_CMDID,
46 .pdev_set_dscp_tid_map_cmdid = WMI_PDEV_SET_DSCP_TID_MAP_CMDID,
47 .pdev_set_quiet_mode_cmdid = WMI_PDEV_SET_QUIET_MODE_CMDID,
48 .pdev_green_ap_ps_enable_cmdid = WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID,
49 .pdev_get_tpc_config_cmdid = WMI_PDEV_GET_TPC_CONFIG_CMDID,
50 .pdev_set_base_macaddr_cmdid = WMI_PDEV_SET_BASE_MACADDR_CMDID,
51 .vdev_create_cmdid = WMI_VDEV_CREATE_CMDID,
52 .vdev_delete_cmdid = WMI_VDEV_DELETE_CMDID,
53 .vdev_start_request_cmdid = WMI_VDEV_START_REQUEST_CMDID,
54 .vdev_restart_request_cmdid = WMI_VDEV_RESTART_REQUEST_CMDID,
55 .vdev_up_cmdid = WMI_VDEV_UP_CMDID,
56 .vdev_stop_cmdid = WMI_VDEV_STOP_CMDID,
57 .vdev_down_cmdid = WMI_VDEV_DOWN_CMDID,
58 .vdev_set_param_cmdid = WMI_VDEV_SET_PARAM_CMDID,
59 .vdev_install_key_cmdid = WMI_VDEV_INSTALL_KEY_CMDID,
60 .peer_create_cmdid = WMI_PEER_CREATE_CMDID,
61 .peer_delete_cmdid = WMI_PEER_DELETE_CMDID,
62 .peer_flush_tids_cmdid = WMI_PEER_FLUSH_TIDS_CMDID,
63 .peer_set_param_cmdid = WMI_PEER_SET_PARAM_CMDID,
64 .peer_assoc_cmdid = WMI_PEER_ASSOC_CMDID,
65 .peer_add_wds_entry_cmdid = WMI_PEER_ADD_WDS_ENTRY_CMDID,
66 .peer_remove_wds_entry_cmdid = WMI_PEER_REMOVE_WDS_ENTRY_CMDID,
67 .peer_mcast_group_cmdid = WMI_PEER_MCAST_GROUP_CMDID,
68 .bcn_tx_cmdid = WMI_BCN_TX_CMDID,
69 .pdev_send_bcn_cmdid = WMI_PDEV_SEND_BCN_CMDID,
70 .bcn_tmpl_cmdid = WMI_BCN_TMPL_CMDID,
71 .bcn_filter_rx_cmdid = WMI_BCN_FILTER_RX_CMDID,
72 .prb_req_filter_rx_cmdid = WMI_PRB_REQ_FILTER_RX_CMDID,
73 .mgmt_tx_cmdid = WMI_MGMT_TX_CMDID,
74 .prb_tmpl_cmdid = WMI_PRB_TMPL_CMDID,
75 .addba_clear_resp_cmdid = WMI_ADDBA_CLEAR_RESP_CMDID,
76 .addba_send_cmdid = WMI_ADDBA_SEND_CMDID,
77 .addba_status_cmdid = WMI_ADDBA_STATUS_CMDID,
78 .delba_send_cmdid = WMI_DELBA_SEND_CMDID,
79 .addba_set_resp_cmdid = WMI_ADDBA_SET_RESP_CMDID,
80 .send_singleamsdu_cmdid = WMI_SEND_SINGLEAMSDU_CMDID,
81 .sta_powersave_mode_cmdid = WMI_STA_POWERSAVE_MODE_CMDID,
82 .sta_powersave_param_cmdid = WMI_STA_POWERSAVE_PARAM_CMDID,
83 .sta_mimo_ps_mode_cmdid = WMI_STA_MIMO_PS_MODE_CMDID,
84 .pdev_dfs_enable_cmdid = WMI_PDEV_DFS_ENABLE_CMDID,
85 .pdev_dfs_disable_cmdid = WMI_PDEV_DFS_DISABLE_CMDID,
86 .roam_scan_mode = WMI_ROAM_SCAN_MODE,
87 .roam_scan_rssi_threshold = WMI_ROAM_SCAN_RSSI_THRESHOLD,
88 .roam_scan_period = WMI_ROAM_SCAN_PERIOD,
89 .roam_scan_rssi_change_threshold = WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
90 .roam_ap_profile = WMI_ROAM_AP_PROFILE,
91 .ofl_scan_add_ap_profile = WMI_ROAM_AP_PROFILE,
92 .ofl_scan_remove_ap_profile = WMI_OFL_SCAN_REMOVE_AP_PROFILE,
93 .ofl_scan_period = WMI_OFL_SCAN_PERIOD,
94 .p2p_dev_set_device_info = WMI_P2P_DEV_SET_DEVICE_INFO,
95 .p2p_dev_set_discoverability = WMI_P2P_DEV_SET_DISCOVERABILITY,
96 .p2p_go_set_beacon_ie = WMI_P2P_GO_SET_BEACON_IE,
97 .p2p_go_set_probe_resp_ie = WMI_P2P_GO_SET_PROBE_RESP_IE,
98 .p2p_set_vendor_ie_data_cmdid = WMI_P2P_SET_VENDOR_IE_DATA_CMDID,
99 .ap_ps_peer_param_cmdid = WMI_AP_PS_PEER_PARAM_CMDID,
100 .ap_ps_peer_uapsd_coex_cmdid = WMI_AP_PS_PEER_UAPSD_COEX_CMDID,
101 .peer_rate_retry_sched_cmdid = WMI_PEER_RATE_RETRY_SCHED_CMDID,
102 .wlan_profile_trigger_cmdid = WMI_WLAN_PROFILE_TRIGGER_CMDID,
103 .wlan_profile_set_hist_intvl_cmdid =
104 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
105 .wlan_profile_get_profile_data_cmdid =
106 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
107 .wlan_profile_enable_profile_id_cmdid =
108 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
109 .wlan_profile_list_profile_id_cmdid =
110 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
111 .pdev_suspend_cmdid = WMI_PDEV_SUSPEND_CMDID,
112 .pdev_resume_cmdid = WMI_PDEV_RESUME_CMDID,
113 .add_bcn_filter_cmdid = WMI_ADD_BCN_FILTER_CMDID,
114 .rmv_bcn_filter_cmdid = WMI_RMV_BCN_FILTER_CMDID,
115 .wow_add_wake_pattern_cmdid = WMI_WOW_ADD_WAKE_PATTERN_CMDID,
116 .wow_del_wake_pattern_cmdid = WMI_WOW_DEL_WAKE_PATTERN_CMDID,
117 .wow_enable_disable_wake_event_cmdid =
118 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
119 .wow_enable_cmdid = WMI_WOW_ENABLE_CMDID,
120 .wow_hostwakeup_from_sleep_cmdid = WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
121 .rtt_measreq_cmdid = WMI_RTT_MEASREQ_CMDID,
122 .rtt_tsf_cmdid = WMI_RTT_TSF_CMDID,
123 .vdev_spectral_scan_configure_cmdid =
124 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
125 .vdev_spectral_scan_enable_cmdid = WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
126 .request_stats_cmdid = WMI_REQUEST_STATS_CMDID,
127 .set_arp_ns_offload_cmdid = WMI_SET_ARP_NS_OFFLOAD_CMDID,
128 .network_list_offload_config_cmdid =
129 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID,
130 .gtk_offload_cmdid = WMI_GTK_OFFLOAD_CMDID,
131 .csa_offload_enable_cmdid = WMI_CSA_OFFLOAD_ENABLE_CMDID,
132 .csa_offload_chanswitch_cmdid = WMI_CSA_OFFLOAD_CHANSWITCH_CMDID,
133 .chatter_set_mode_cmdid = WMI_CHATTER_SET_MODE_CMDID,
134 .peer_tid_addba_cmdid = WMI_PEER_TID_ADDBA_CMDID,
135 .peer_tid_delba_cmdid = WMI_PEER_TID_DELBA_CMDID,
136 .sta_dtim_ps_method_cmdid = WMI_STA_DTIM_PS_METHOD_CMDID,
137 .sta_uapsd_auto_trig_cmdid = WMI_STA_UAPSD_AUTO_TRIG_CMDID,
138 .sta_keepalive_cmd = WMI_STA_KEEPALIVE_CMD,
139 .echo_cmdid = WMI_ECHO_CMDID,
140 .pdev_utf_cmdid = WMI_PDEV_UTF_CMDID,
141 .dbglog_cfg_cmdid = WMI_DBGLOG_CFG_CMDID,
142 .pdev_qvit_cmdid = WMI_PDEV_QVIT_CMDID,
143 .pdev_ftm_intg_cmdid = WMI_PDEV_FTM_INTG_CMDID,
144 .vdev_set_keepalive_cmdid = WMI_VDEV_SET_KEEPALIVE_CMDID,
145 .vdev_get_keepalive_cmdid = WMI_VDEV_GET_KEEPALIVE_CMDID,
146 .force_fw_hang_cmdid = WMI_FORCE_FW_HANG_CMDID,
147 .gpio_config_cmdid = WMI_GPIO_CONFIG_CMDID,
148 .gpio_output_cmdid = WMI_GPIO_OUTPUT_CMDID,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +0200149 .pdev_get_temperature_cmdid = WMI_CMD_UNSUPPORTED,
Bartosz Markowskice428702013-09-26 17:47:05 +0200150};
151
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200152/* 10.X WMI cmd track */
153static struct wmi_cmd_map wmi_10x_cmd_map = {
154 .init_cmdid = WMI_10X_INIT_CMDID,
155 .start_scan_cmdid = WMI_10X_START_SCAN_CMDID,
156 .stop_scan_cmdid = WMI_10X_STOP_SCAN_CMDID,
157 .scan_chan_list_cmdid = WMI_10X_SCAN_CHAN_LIST_CMDID,
Bartosz Markowski34957b22013-10-15 09:55:31 +0200158 .scan_sch_prio_tbl_cmdid = WMI_CMD_UNSUPPORTED,
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200159 .pdev_set_regdomain_cmdid = WMI_10X_PDEV_SET_REGDOMAIN_CMDID,
160 .pdev_set_channel_cmdid = WMI_10X_PDEV_SET_CHANNEL_CMDID,
161 .pdev_set_param_cmdid = WMI_10X_PDEV_SET_PARAM_CMDID,
162 .pdev_pktlog_enable_cmdid = WMI_10X_PDEV_PKTLOG_ENABLE_CMDID,
163 .pdev_pktlog_disable_cmdid = WMI_10X_PDEV_PKTLOG_DISABLE_CMDID,
164 .pdev_set_wmm_params_cmdid = WMI_10X_PDEV_SET_WMM_PARAMS_CMDID,
165 .pdev_set_ht_cap_ie_cmdid = WMI_10X_PDEV_SET_HT_CAP_IE_CMDID,
166 .pdev_set_vht_cap_ie_cmdid = WMI_10X_PDEV_SET_VHT_CAP_IE_CMDID,
167 .pdev_set_dscp_tid_map_cmdid = WMI_10X_PDEV_SET_DSCP_TID_MAP_CMDID,
168 .pdev_set_quiet_mode_cmdid = WMI_10X_PDEV_SET_QUIET_MODE_CMDID,
169 .pdev_green_ap_ps_enable_cmdid = WMI_10X_PDEV_GREEN_AP_PS_ENABLE_CMDID,
170 .pdev_get_tpc_config_cmdid = WMI_10X_PDEV_GET_TPC_CONFIG_CMDID,
171 .pdev_set_base_macaddr_cmdid = WMI_10X_PDEV_SET_BASE_MACADDR_CMDID,
172 .vdev_create_cmdid = WMI_10X_VDEV_CREATE_CMDID,
173 .vdev_delete_cmdid = WMI_10X_VDEV_DELETE_CMDID,
174 .vdev_start_request_cmdid = WMI_10X_VDEV_START_REQUEST_CMDID,
175 .vdev_restart_request_cmdid = WMI_10X_VDEV_RESTART_REQUEST_CMDID,
176 .vdev_up_cmdid = WMI_10X_VDEV_UP_CMDID,
177 .vdev_stop_cmdid = WMI_10X_VDEV_STOP_CMDID,
178 .vdev_down_cmdid = WMI_10X_VDEV_DOWN_CMDID,
179 .vdev_set_param_cmdid = WMI_10X_VDEV_SET_PARAM_CMDID,
180 .vdev_install_key_cmdid = WMI_10X_VDEV_INSTALL_KEY_CMDID,
181 .peer_create_cmdid = WMI_10X_PEER_CREATE_CMDID,
182 .peer_delete_cmdid = WMI_10X_PEER_DELETE_CMDID,
183 .peer_flush_tids_cmdid = WMI_10X_PEER_FLUSH_TIDS_CMDID,
184 .peer_set_param_cmdid = WMI_10X_PEER_SET_PARAM_CMDID,
185 .peer_assoc_cmdid = WMI_10X_PEER_ASSOC_CMDID,
186 .peer_add_wds_entry_cmdid = WMI_10X_PEER_ADD_WDS_ENTRY_CMDID,
187 .peer_remove_wds_entry_cmdid = WMI_10X_PEER_REMOVE_WDS_ENTRY_CMDID,
188 .peer_mcast_group_cmdid = WMI_10X_PEER_MCAST_GROUP_CMDID,
189 .bcn_tx_cmdid = WMI_10X_BCN_TX_CMDID,
190 .pdev_send_bcn_cmdid = WMI_10X_PDEV_SEND_BCN_CMDID,
Bartosz Markowski34957b22013-10-15 09:55:31 +0200191 .bcn_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200192 .bcn_filter_rx_cmdid = WMI_10X_BCN_FILTER_RX_CMDID,
193 .prb_req_filter_rx_cmdid = WMI_10X_PRB_REQ_FILTER_RX_CMDID,
194 .mgmt_tx_cmdid = WMI_10X_MGMT_TX_CMDID,
Bartosz Markowski34957b22013-10-15 09:55:31 +0200195 .prb_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200196 .addba_clear_resp_cmdid = WMI_10X_ADDBA_CLEAR_RESP_CMDID,
197 .addba_send_cmdid = WMI_10X_ADDBA_SEND_CMDID,
198 .addba_status_cmdid = WMI_10X_ADDBA_STATUS_CMDID,
199 .delba_send_cmdid = WMI_10X_DELBA_SEND_CMDID,
200 .addba_set_resp_cmdid = WMI_10X_ADDBA_SET_RESP_CMDID,
201 .send_singleamsdu_cmdid = WMI_10X_SEND_SINGLEAMSDU_CMDID,
202 .sta_powersave_mode_cmdid = WMI_10X_STA_POWERSAVE_MODE_CMDID,
203 .sta_powersave_param_cmdid = WMI_10X_STA_POWERSAVE_PARAM_CMDID,
204 .sta_mimo_ps_mode_cmdid = WMI_10X_STA_MIMO_PS_MODE_CMDID,
205 .pdev_dfs_enable_cmdid = WMI_10X_PDEV_DFS_ENABLE_CMDID,
206 .pdev_dfs_disable_cmdid = WMI_10X_PDEV_DFS_DISABLE_CMDID,
207 .roam_scan_mode = WMI_10X_ROAM_SCAN_MODE,
208 .roam_scan_rssi_threshold = WMI_10X_ROAM_SCAN_RSSI_THRESHOLD,
209 .roam_scan_period = WMI_10X_ROAM_SCAN_PERIOD,
210 .roam_scan_rssi_change_threshold =
211 WMI_10X_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
212 .roam_ap_profile = WMI_10X_ROAM_AP_PROFILE,
213 .ofl_scan_add_ap_profile = WMI_10X_OFL_SCAN_ADD_AP_PROFILE,
214 .ofl_scan_remove_ap_profile = WMI_10X_OFL_SCAN_REMOVE_AP_PROFILE,
215 .ofl_scan_period = WMI_10X_OFL_SCAN_PERIOD,
216 .p2p_dev_set_device_info = WMI_10X_P2P_DEV_SET_DEVICE_INFO,
217 .p2p_dev_set_discoverability = WMI_10X_P2P_DEV_SET_DISCOVERABILITY,
218 .p2p_go_set_beacon_ie = WMI_10X_P2P_GO_SET_BEACON_IE,
219 .p2p_go_set_probe_resp_ie = WMI_10X_P2P_GO_SET_PROBE_RESP_IE,
Bartosz Markowski34957b22013-10-15 09:55:31 +0200220 .p2p_set_vendor_ie_data_cmdid = WMI_CMD_UNSUPPORTED,
Janusz Dziedzic542fb172014-01-17 14:08:08 +0100221 .ap_ps_peer_param_cmdid = WMI_10X_AP_PS_PEER_PARAM_CMDID,
Bartosz Markowski34957b22013-10-15 09:55:31 +0200222 .ap_ps_peer_uapsd_coex_cmdid = WMI_CMD_UNSUPPORTED,
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200223 .peer_rate_retry_sched_cmdid = WMI_10X_PEER_RATE_RETRY_SCHED_CMDID,
224 .wlan_profile_trigger_cmdid = WMI_10X_WLAN_PROFILE_TRIGGER_CMDID,
225 .wlan_profile_set_hist_intvl_cmdid =
226 WMI_10X_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
227 .wlan_profile_get_profile_data_cmdid =
228 WMI_10X_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
229 .wlan_profile_enable_profile_id_cmdid =
230 WMI_10X_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
231 .wlan_profile_list_profile_id_cmdid =
232 WMI_10X_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
233 .pdev_suspend_cmdid = WMI_10X_PDEV_SUSPEND_CMDID,
234 .pdev_resume_cmdid = WMI_10X_PDEV_RESUME_CMDID,
235 .add_bcn_filter_cmdid = WMI_10X_ADD_BCN_FILTER_CMDID,
236 .rmv_bcn_filter_cmdid = WMI_10X_RMV_BCN_FILTER_CMDID,
237 .wow_add_wake_pattern_cmdid = WMI_10X_WOW_ADD_WAKE_PATTERN_CMDID,
238 .wow_del_wake_pattern_cmdid = WMI_10X_WOW_DEL_WAKE_PATTERN_CMDID,
239 .wow_enable_disable_wake_event_cmdid =
240 WMI_10X_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
241 .wow_enable_cmdid = WMI_10X_WOW_ENABLE_CMDID,
242 .wow_hostwakeup_from_sleep_cmdid =
243 WMI_10X_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
244 .rtt_measreq_cmdid = WMI_10X_RTT_MEASREQ_CMDID,
245 .rtt_tsf_cmdid = WMI_10X_RTT_TSF_CMDID,
246 .vdev_spectral_scan_configure_cmdid =
247 WMI_10X_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
248 .vdev_spectral_scan_enable_cmdid =
249 WMI_10X_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
250 .request_stats_cmdid = WMI_10X_REQUEST_STATS_CMDID,
Bartosz Markowski34957b22013-10-15 09:55:31 +0200251 .set_arp_ns_offload_cmdid = WMI_CMD_UNSUPPORTED,
252 .network_list_offload_config_cmdid = WMI_CMD_UNSUPPORTED,
253 .gtk_offload_cmdid = WMI_CMD_UNSUPPORTED,
254 .csa_offload_enable_cmdid = WMI_CMD_UNSUPPORTED,
255 .csa_offload_chanswitch_cmdid = WMI_CMD_UNSUPPORTED,
256 .chatter_set_mode_cmdid = WMI_CMD_UNSUPPORTED,
257 .peer_tid_addba_cmdid = WMI_CMD_UNSUPPORTED,
258 .peer_tid_delba_cmdid = WMI_CMD_UNSUPPORTED,
259 .sta_dtim_ps_method_cmdid = WMI_CMD_UNSUPPORTED,
260 .sta_uapsd_auto_trig_cmdid = WMI_CMD_UNSUPPORTED,
261 .sta_keepalive_cmd = WMI_CMD_UNSUPPORTED,
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200262 .echo_cmdid = WMI_10X_ECHO_CMDID,
263 .pdev_utf_cmdid = WMI_10X_PDEV_UTF_CMDID,
264 .dbglog_cfg_cmdid = WMI_10X_DBGLOG_CFG_CMDID,
265 .pdev_qvit_cmdid = WMI_10X_PDEV_QVIT_CMDID,
Bartosz Markowski34957b22013-10-15 09:55:31 +0200266 .pdev_ftm_intg_cmdid = WMI_CMD_UNSUPPORTED,
267 .vdev_set_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
268 .vdev_get_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
269 .force_fw_hang_cmdid = WMI_CMD_UNSUPPORTED,
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200270 .gpio_config_cmdid = WMI_10X_GPIO_CONFIG_CMDID,
271 .gpio_output_cmdid = WMI_10X_GPIO_OUTPUT_CMDID,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +0200272 .pdev_get_temperature_cmdid = WMI_CMD_UNSUPPORTED,
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200273};
Bartosz Markowskice428702013-09-26 17:47:05 +0200274
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +0200275/* 10.2.4 WMI cmd track */
276static struct wmi_cmd_map wmi_10_2_4_cmd_map = {
277 .init_cmdid = WMI_10_2_INIT_CMDID,
278 .start_scan_cmdid = WMI_10_2_START_SCAN_CMDID,
279 .stop_scan_cmdid = WMI_10_2_STOP_SCAN_CMDID,
280 .scan_chan_list_cmdid = WMI_10_2_SCAN_CHAN_LIST_CMDID,
281 .scan_sch_prio_tbl_cmdid = WMI_CMD_UNSUPPORTED,
282 .pdev_set_regdomain_cmdid = WMI_10_2_PDEV_SET_REGDOMAIN_CMDID,
283 .pdev_set_channel_cmdid = WMI_10_2_PDEV_SET_CHANNEL_CMDID,
284 .pdev_set_param_cmdid = WMI_10_2_PDEV_SET_PARAM_CMDID,
285 .pdev_pktlog_enable_cmdid = WMI_10_2_PDEV_PKTLOG_ENABLE_CMDID,
286 .pdev_pktlog_disable_cmdid = WMI_10_2_PDEV_PKTLOG_DISABLE_CMDID,
287 .pdev_set_wmm_params_cmdid = WMI_10_2_PDEV_SET_WMM_PARAMS_CMDID,
288 .pdev_set_ht_cap_ie_cmdid = WMI_10_2_PDEV_SET_HT_CAP_IE_CMDID,
289 .pdev_set_vht_cap_ie_cmdid = WMI_10_2_PDEV_SET_VHT_CAP_IE_CMDID,
290 .pdev_set_quiet_mode_cmdid = WMI_10_2_PDEV_SET_QUIET_MODE_CMDID,
291 .pdev_green_ap_ps_enable_cmdid = WMI_10_2_PDEV_GREEN_AP_PS_ENABLE_CMDID,
292 .pdev_get_tpc_config_cmdid = WMI_10_2_PDEV_GET_TPC_CONFIG_CMDID,
293 .pdev_set_base_macaddr_cmdid = WMI_10_2_PDEV_SET_BASE_MACADDR_CMDID,
294 .vdev_create_cmdid = WMI_10_2_VDEV_CREATE_CMDID,
295 .vdev_delete_cmdid = WMI_10_2_VDEV_DELETE_CMDID,
296 .vdev_start_request_cmdid = WMI_10_2_VDEV_START_REQUEST_CMDID,
297 .vdev_restart_request_cmdid = WMI_10_2_VDEV_RESTART_REQUEST_CMDID,
298 .vdev_up_cmdid = WMI_10_2_VDEV_UP_CMDID,
299 .vdev_stop_cmdid = WMI_10_2_VDEV_STOP_CMDID,
300 .vdev_down_cmdid = WMI_10_2_VDEV_DOWN_CMDID,
301 .vdev_set_param_cmdid = WMI_10_2_VDEV_SET_PARAM_CMDID,
302 .vdev_install_key_cmdid = WMI_10_2_VDEV_INSTALL_KEY_CMDID,
303 .peer_create_cmdid = WMI_10_2_PEER_CREATE_CMDID,
304 .peer_delete_cmdid = WMI_10_2_PEER_DELETE_CMDID,
305 .peer_flush_tids_cmdid = WMI_10_2_PEER_FLUSH_TIDS_CMDID,
306 .peer_set_param_cmdid = WMI_10_2_PEER_SET_PARAM_CMDID,
307 .peer_assoc_cmdid = WMI_10_2_PEER_ASSOC_CMDID,
308 .peer_add_wds_entry_cmdid = WMI_10_2_PEER_ADD_WDS_ENTRY_CMDID,
309 .peer_remove_wds_entry_cmdid = WMI_10_2_PEER_REMOVE_WDS_ENTRY_CMDID,
310 .peer_mcast_group_cmdid = WMI_10_2_PEER_MCAST_GROUP_CMDID,
311 .bcn_tx_cmdid = WMI_10_2_BCN_TX_CMDID,
312 .pdev_send_bcn_cmdid = WMI_10_2_PDEV_SEND_BCN_CMDID,
313 .bcn_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
314 .bcn_filter_rx_cmdid = WMI_10_2_BCN_FILTER_RX_CMDID,
315 .prb_req_filter_rx_cmdid = WMI_10_2_PRB_REQ_FILTER_RX_CMDID,
316 .mgmt_tx_cmdid = WMI_10_2_MGMT_TX_CMDID,
317 .prb_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
318 .addba_clear_resp_cmdid = WMI_10_2_ADDBA_CLEAR_RESP_CMDID,
319 .addba_send_cmdid = WMI_10_2_ADDBA_SEND_CMDID,
320 .addba_status_cmdid = WMI_10_2_ADDBA_STATUS_CMDID,
321 .delba_send_cmdid = WMI_10_2_DELBA_SEND_CMDID,
322 .addba_set_resp_cmdid = WMI_10_2_ADDBA_SET_RESP_CMDID,
323 .send_singleamsdu_cmdid = WMI_10_2_SEND_SINGLEAMSDU_CMDID,
324 .sta_powersave_mode_cmdid = WMI_10_2_STA_POWERSAVE_MODE_CMDID,
325 .sta_powersave_param_cmdid = WMI_10_2_STA_POWERSAVE_PARAM_CMDID,
326 .sta_mimo_ps_mode_cmdid = WMI_10_2_STA_MIMO_PS_MODE_CMDID,
327 .pdev_dfs_enable_cmdid = WMI_10_2_PDEV_DFS_ENABLE_CMDID,
328 .pdev_dfs_disable_cmdid = WMI_10_2_PDEV_DFS_DISABLE_CMDID,
329 .roam_scan_mode = WMI_10_2_ROAM_SCAN_MODE,
330 .roam_scan_rssi_threshold = WMI_10_2_ROAM_SCAN_RSSI_THRESHOLD,
331 .roam_scan_period = WMI_10_2_ROAM_SCAN_PERIOD,
332 .roam_scan_rssi_change_threshold =
333 WMI_10_2_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
334 .roam_ap_profile = WMI_10_2_ROAM_AP_PROFILE,
335 .ofl_scan_add_ap_profile = WMI_10_2_OFL_SCAN_ADD_AP_PROFILE,
336 .ofl_scan_remove_ap_profile = WMI_10_2_OFL_SCAN_REMOVE_AP_PROFILE,
337 .ofl_scan_period = WMI_10_2_OFL_SCAN_PERIOD,
338 .p2p_dev_set_device_info = WMI_10_2_P2P_DEV_SET_DEVICE_INFO,
339 .p2p_dev_set_discoverability = WMI_10_2_P2P_DEV_SET_DISCOVERABILITY,
340 .p2p_go_set_beacon_ie = WMI_10_2_P2P_GO_SET_BEACON_IE,
341 .p2p_go_set_probe_resp_ie = WMI_10_2_P2P_GO_SET_PROBE_RESP_IE,
342 .p2p_set_vendor_ie_data_cmdid = WMI_CMD_UNSUPPORTED,
343 .ap_ps_peer_param_cmdid = WMI_10_2_AP_PS_PEER_PARAM_CMDID,
344 .ap_ps_peer_uapsd_coex_cmdid = WMI_CMD_UNSUPPORTED,
345 .peer_rate_retry_sched_cmdid = WMI_10_2_PEER_RATE_RETRY_SCHED_CMDID,
346 .wlan_profile_trigger_cmdid = WMI_10_2_WLAN_PROFILE_TRIGGER_CMDID,
347 .wlan_profile_set_hist_intvl_cmdid =
348 WMI_10_2_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
349 .wlan_profile_get_profile_data_cmdid =
350 WMI_10_2_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
351 .wlan_profile_enable_profile_id_cmdid =
352 WMI_10_2_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
353 .wlan_profile_list_profile_id_cmdid =
354 WMI_10_2_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
355 .pdev_suspend_cmdid = WMI_10_2_PDEV_SUSPEND_CMDID,
356 .pdev_resume_cmdid = WMI_10_2_PDEV_RESUME_CMDID,
357 .add_bcn_filter_cmdid = WMI_10_2_ADD_BCN_FILTER_CMDID,
358 .rmv_bcn_filter_cmdid = WMI_10_2_RMV_BCN_FILTER_CMDID,
359 .wow_add_wake_pattern_cmdid = WMI_10_2_WOW_ADD_WAKE_PATTERN_CMDID,
360 .wow_del_wake_pattern_cmdid = WMI_10_2_WOW_DEL_WAKE_PATTERN_CMDID,
361 .wow_enable_disable_wake_event_cmdid =
362 WMI_10_2_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
363 .wow_enable_cmdid = WMI_10_2_WOW_ENABLE_CMDID,
364 .wow_hostwakeup_from_sleep_cmdid =
365 WMI_10_2_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
366 .rtt_measreq_cmdid = WMI_10_2_RTT_MEASREQ_CMDID,
367 .rtt_tsf_cmdid = WMI_10_2_RTT_TSF_CMDID,
368 .vdev_spectral_scan_configure_cmdid =
369 WMI_10_2_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
370 .vdev_spectral_scan_enable_cmdid =
371 WMI_10_2_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
372 .request_stats_cmdid = WMI_10_2_REQUEST_STATS_CMDID,
373 .set_arp_ns_offload_cmdid = WMI_CMD_UNSUPPORTED,
374 .network_list_offload_config_cmdid = WMI_CMD_UNSUPPORTED,
375 .gtk_offload_cmdid = WMI_CMD_UNSUPPORTED,
376 .csa_offload_enable_cmdid = WMI_CMD_UNSUPPORTED,
377 .csa_offload_chanswitch_cmdid = WMI_CMD_UNSUPPORTED,
378 .chatter_set_mode_cmdid = WMI_CMD_UNSUPPORTED,
379 .peer_tid_addba_cmdid = WMI_CMD_UNSUPPORTED,
380 .peer_tid_delba_cmdid = WMI_CMD_UNSUPPORTED,
381 .sta_dtim_ps_method_cmdid = WMI_CMD_UNSUPPORTED,
382 .sta_uapsd_auto_trig_cmdid = WMI_CMD_UNSUPPORTED,
383 .sta_keepalive_cmd = WMI_CMD_UNSUPPORTED,
384 .echo_cmdid = WMI_10_2_ECHO_CMDID,
385 .pdev_utf_cmdid = WMI_10_2_PDEV_UTF_CMDID,
386 .dbglog_cfg_cmdid = WMI_10_2_DBGLOG_CFG_CMDID,
387 .pdev_qvit_cmdid = WMI_10_2_PDEV_QVIT_CMDID,
388 .pdev_ftm_intg_cmdid = WMI_CMD_UNSUPPORTED,
389 .vdev_set_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
390 .vdev_get_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
391 .force_fw_hang_cmdid = WMI_CMD_UNSUPPORTED,
392 .gpio_config_cmdid = WMI_10_2_GPIO_CONFIG_CMDID,
393 .gpio_output_cmdid = WMI_10_2_GPIO_OUTPUT_CMDID,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +0200394 .pdev_get_temperature_cmdid = WMI_10_2_PDEV_GET_TEMPERATURE_CMDID,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +0200395};
396
Bartosz Markowski6d1506e2013-09-26 17:47:15 +0200397/* MAIN WMI VDEV param map */
398static struct wmi_vdev_param_map wmi_vdev_param_map = {
399 .rts_threshold = WMI_VDEV_PARAM_RTS_THRESHOLD,
400 .fragmentation_threshold = WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
401 .beacon_interval = WMI_VDEV_PARAM_BEACON_INTERVAL,
402 .listen_interval = WMI_VDEV_PARAM_LISTEN_INTERVAL,
403 .multicast_rate = WMI_VDEV_PARAM_MULTICAST_RATE,
404 .mgmt_tx_rate = WMI_VDEV_PARAM_MGMT_TX_RATE,
405 .slot_time = WMI_VDEV_PARAM_SLOT_TIME,
406 .preamble = WMI_VDEV_PARAM_PREAMBLE,
407 .swba_time = WMI_VDEV_PARAM_SWBA_TIME,
408 .wmi_vdev_stats_update_period = WMI_VDEV_STATS_UPDATE_PERIOD,
409 .wmi_vdev_pwrsave_ageout_time = WMI_VDEV_PWRSAVE_AGEOUT_TIME,
410 .wmi_vdev_host_swba_interval = WMI_VDEV_HOST_SWBA_INTERVAL,
411 .dtim_period = WMI_VDEV_PARAM_DTIM_PERIOD,
412 .wmi_vdev_oc_scheduler_air_time_limit =
413 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
414 .wds = WMI_VDEV_PARAM_WDS,
415 .atim_window = WMI_VDEV_PARAM_ATIM_WINDOW,
416 .bmiss_count_max = WMI_VDEV_PARAM_BMISS_COUNT_MAX,
417 .bmiss_first_bcnt = WMI_VDEV_PARAM_BMISS_FIRST_BCNT,
418 .bmiss_final_bcnt = WMI_VDEV_PARAM_BMISS_FINAL_BCNT,
419 .feature_wmm = WMI_VDEV_PARAM_FEATURE_WMM,
420 .chwidth = WMI_VDEV_PARAM_CHWIDTH,
421 .chextoffset = WMI_VDEV_PARAM_CHEXTOFFSET,
422 .disable_htprotection = WMI_VDEV_PARAM_DISABLE_HTPROTECTION,
423 .sta_quickkickout = WMI_VDEV_PARAM_STA_QUICKKICKOUT,
424 .mgmt_rate = WMI_VDEV_PARAM_MGMT_RATE,
425 .protection_mode = WMI_VDEV_PARAM_PROTECTION_MODE,
426 .fixed_rate = WMI_VDEV_PARAM_FIXED_RATE,
427 .sgi = WMI_VDEV_PARAM_SGI,
428 .ldpc = WMI_VDEV_PARAM_LDPC,
429 .tx_stbc = WMI_VDEV_PARAM_TX_STBC,
430 .rx_stbc = WMI_VDEV_PARAM_RX_STBC,
431 .intra_bss_fwd = WMI_VDEV_PARAM_INTRA_BSS_FWD,
432 .def_keyid = WMI_VDEV_PARAM_DEF_KEYID,
433 .nss = WMI_VDEV_PARAM_NSS,
434 .bcast_data_rate = WMI_VDEV_PARAM_BCAST_DATA_RATE,
435 .mcast_data_rate = WMI_VDEV_PARAM_MCAST_DATA_RATE,
436 .mcast_indicate = WMI_VDEV_PARAM_MCAST_INDICATE,
437 .dhcp_indicate = WMI_VDEV_PARAM_DHCP_INDICATE,
438 .unknown_dest_indicate = WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
439 .ap_keepalive_min_idle_inactive_time_secs =
440 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
441 .ap_keepalive_max_idle_inactive_time_secs =
442 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
443 .ap_keepalive_max_unresponsive_time_secs =
444 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
445 .ap_enable_nawds = WMI_VDEV_PARAM_AP_ENABLE_NAWDS,
446 .mcast2ucast_set = WMI_VDEV_PARAM_UNSUPPORTED,
447 .enable_rtscts = WMI_VDEV_PARAM_ENABLE_RTSCTS,
448 .txbf = WMI_VDEV_PARAM_TXBF,
449 .packet_powersave = WMI_VDEV_PARAM_PACKET_POWERSAVE,
450 .drop_unencry = WMI_VDEV_PARAM_DROP_UNENCRY,
451 .tx_encap_type = WMI_VDEV_PARAM_TX_ENCAP_TYPE,
452 .ap_detect_out_of_sync_sleeping_sta_time_secs =
453 WMI_VDEV_PARAM_UNSUPPORTED,
454};
455
456/* 10.X WMI VDEV param map */
457static struct wmi_vdev_param_map wmi_10x_vdev_param_map = {
458 .rts_threshold = WMI_10X_VDEV_PARAM_RTS_THRESHOLD,
459 .fragmentation_threshold = WMI_10X_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
460 .beacon_interval = WMI_10X_VDEV_PARAM_BEACON_INTERVAL,
461 .listen_interval = WMI_10X_VDEV_PARAM_LISTEN_INTERVAL,
462 .multicast_rate = WMI_10X_VDEV_PARAM_MULTICAST_RATE,
463 .mgmt_tx_rate = WMI_10X_VDEV_PARAM_MGMT_TX_RATE,
464 .slot_time = WMI_10X_VDEV_PARAM_SLOT_TIME,
465 .preamble = WMI_10X_VDEV_PARAM_PREAMBLE,
466 .swba_time = WMI_10X_VDEV_PARAM_SWBA_TIME,
467 .wmi_vdev_stats_update_period = WMI_10X_VDEV_STATS_UPDATE_PERIOD,
468 .wmi_vdev_pwrsave_ageout_time = WMI_10X_VDEV_PWRSAVE_AGEOUT_TIME,
469 .wmi_vdev_host_swba_interval = WMI_10X_VDEV_HOST_SWBA_INTERVAL,
470 .dtim_period = WMI_10X_VDEV_PARAM_DTIM_PERIOD,
471 .wmi_vdev_oc_scheduler_air_time_limit =
472 WMI_10X_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
473 .wds = WMI_10X_VDEV_PARAM_WDS,
474 .atim_window = WMI_10X_VDEV_PARAM_ATIM_WINDOW,
475 .bmiss_count_max = WMI_10X_VDEV_PARAM_BMISS_COUNT_MAX,
476 .bmiss_first_bcnt = WMI_VDEV_PARAM_UNSUPPORTED,
477 .bmiss_final_bcnt = WMI_VDEV_PARAM_UNSUPPORTED,
478 .feature_wmm = WMI_10X_VDEV_PARAM_FEATURE_WMM,
479 .chwidth = WMI_10X_VDEV_PARAM_CHWIDTH,
480 .chextoffset = WMI_10X_VDEV_PARAM_CHEXTOFFSET,
481 .disable_htprotection = WMI_10X_VDEV_PARAM_DISABLE_HTPROTECTION,
482 .sta_quickkickout = WMI_10X_VDEV_PARAM_STA_QUICKKICKOUT,
483 .mgmt_rate = WMI_10X_VDEV_PARAM_MGMT_RATE,
484 .protection_mode = WMI_10X_VDEV_PARAM_PROTECTION_MODE,
485 .fixed_rate = WMI_10X_VDEV_PARAM_FIXED_RATE,
486 .sgi = WMI_10X_VDEV_PARAM_SGI,
487 .ldpc = WMI_10X_VDEV_PARAM_LDPC,
488 .tx_stbc = WMI_10X_VDEV_PARAM_TX_STBC,
489 .rx_stbc = WMI_10X_VDEV_PARAM_RX_STBC,
490 .intra_bss_fwd = WMI_10X_VDEV_PARAM_INTRA_BSS_FWD,
491 .def_keyid = WMI_10X_VDEV_PARAM_DEF_KEYID,
492 .nss = WMI_10X_VDEV_PARAM_NSS,
493 .bcast_data_rate = WMI_10X_VDEV_PARAM_BCAST_DATA_RATE,
494 .mcast_data_rate = WMI_10X_VDEV_PARAM_MCAST_DATA_RATE,
495 .mcast_indicate = WMI_10X_VDEV_PARAM_MCAST_INDICATE,
496 .dhcp_indicate = WMI_10X_VDEV_PARAM_DHCP_INDICATE,
497 .unknown_dest_indicate = WMI_10X_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
498 .ap_keepalive_min_idle_inactive_time_secs =
499 WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
500 .ap_keepalive_max_idle_inactive_time_secs =
501 WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
502 .ap_keepalive_max_unresponsive_time_secs =
503 WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
504 .ap_enable_nawds = WMI_10X_VDEV_PARAM_AP_ENABLE_NAWDS,
505 .mcast2ucast_set = WMI_10X_VDEV_PARAM_MCAST2UCAST_SET,
506 .enable_rtscts = WMI_10X_VDEV_PARAM_ENABLE_RTSCTS,
507 .txbf = WMI_VDEV_PARAM_UNSUPPORTED,
508 .packet_powersave = WMI_VDEV_PARAM_UNSUPPORTED,
509 .drop_unencry = WMI_VDEV_PARAM_UNSUPPORTED,
510 .tx_encap_type = WMI_VDEV_PARAM_UNSUPPORTED,
511 .ap_detect_out_of_sync_sleeping_sta_time_secs =
512 WMI_10X_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS,
513};
514
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +0200515static struct wmi_vdev_param_map wmi_10_2_4_vdev_param_map = {
516 .rts_threshold = WMI_10X_VDEV_PARAM_RTS_THRESHOLD,
517 .fragmentation_threshold = WMI_10X_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
518 .beacon_interval = WMI_10X_VDEV_PARAM_BEACON_INTERVAL,
519 .listen_interval = WMI_10X_VDEV_PARAM_LISTEN_INTERVAL,
520 .multicast_rate = WMI_10X_VDEV_PARAM_MULTICAST_RATE,
521 .mgmt_tx_rate = WMI_10X_VDEV_PARAM_MGMT_TX_RATE,
522 .slot_time = WMI_10X_VDEV_PARAM_SLOT_TIME,
523 .preamble = WMI_10X_VDEV_PARAM_PREAMBLE,
524 .swba_time = WMI_10X_VDEV_PARAM_SWBA_TIME,
525 .wmi_vdev_stats_update_period = WMI_10X_VDEV_STATS_UPDATE_PERIOD,
526 .wmi_vdev_pwrsave_ageout_time = WMI_10X_VDEV_PWRSAVE_AGEOUT_TIME,
527 .wmi_vdev_host_swba_interval = WMI_10X_VDEV_HOST_SWBA_INTERVAL,
528 .dtim_period = WMI_10X_VDEV_PARAM_DTIM_PERIOD,
529 .wmi_vdev_oc_scheduler_air_time_limit =
530 WMI_10X_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
531 .wds = WMI_10X_VDEV_PARAM_WDS,
532 .atim_window = WMI_10X_VDEV_PARAM_ATIM_WINDOW,
533 .bmiss_count_max = WMI_10X_VDEV_PARAM_BMISS_COUNT_MAX,
534 .bmiss_first_bcnt = WMI_VDEV_PARAM_UNSUPPORTED,
535 .bmiss_final_bcnt = WMI_VDEV_PARAM_UNSUPPORTED,
536 .feature_wmm = WMI_10X_VDEV_PARAM_FEATURE_WMM,
537 .chwidth = WMI_10X_VDEV_PARAM_CHWIDTH,
538 .chextoffset = WMI_10X_VDEV_PARAM_CHEXTOFFSET,
539 .disable_htprotection = WMI_10X_VDEV_PARAM_DISABLE_HTPROTECTION,
540 .sta_quickkickout = WMI_10X_VDEV_PARAM_STA_QUICKKICKOUT,
541 .mgmt_rate = WMI_10X_VDEV_PARAM_MGMT_RATE,
542 .protection_mode = WMI_10X_VDEV_PARAM_PROTECTION_MODE,
543 .fixed_rate = WMI_10X_VDEV_PARAM_FIXED_RATE,
544 .sgi = WMI_10X_VDEV_PARAM_SGI,
545 .ldpc = WMI_10X_VDEV_PARAM_LDPC,
546 .tx_stbc = WMI_10X_VDEV_PARAM_TX_STBC,
547 .rx_stbc = WMI_10X_VDEV_PARAM_RX_STBC,
548 .intra_bss_fwd = WMI_10X_VDEV_PARAM_INTRA_BSS_FWD,
549 .def_keyid = WMI_10X_VDEV_PARAM_DEF_KEYID,
550 .nss = WMI_10X_VDEV_PARAM_NSS,
551 .bcast_data_rate = WMI_10X_VDEV_PARAM_BCAST_DATA_RATE,
552 .mcast_data_rate = WMI_10X_VDEV_PARAM_MCAST_DATA_RATE,
553 .mcast_indicate = WMI_10X_VDEV_PARAM_MCAST_INDICATE,
554 .dhcp_indicate = WMI_10X_VDEV_PARAM_DHCP_INDICATE,
555 .unknown_dest_indicate = WMI_10X_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
556 .ap_keepalive_min_idle_inactive_time_secs =
557 WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
558 .ap_keepalive_max_idle_inactive_time_secs =
559 WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
560 .ap_keepalive_max_unresponsive_time_secs =
561 WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
562 .ap_enable_nawds = WMI_10X_VDEV_PARAM_AP_ENABLE_NAWDS,
563 .mcast2ucast_set = WMI_10X_VDEV_PARAM_MCAST2UCAST_SET,
564 .enable_rtscts = WMI_10X_VDEV_PARAM_ENABLE_RTSCTS,
565 .txbf = WMI_VDEV_PARAM_UNSUPPORTED,
566 .packet_powersave = WMI_VDEV_PARAM_UNSUPPORTED,
567 .drop_unencry = WMI_VDEV_PARAM_UNSUPPORTED,
568 .tx_encap_type = WMI_VDEV_PARAM_UNSUPPORTED,
569 .ap_detect_out_of_sync_sleeping_sta_time_secs =
570 WMI_10X_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS,
571};
572
Bartosz Markowski226a3392013-09-26 17:47:16 +0200573static struct wmi_pdev_param_map wmi_pdev_param_map = {
574 .tx_chain_mask = WMI_PDEV_PARAM_TX_CHAIN_MASK,
575 .rx_chain_mask = WMI_PDEV_PARAM_RX_CHAIN_MASK,
576 .txpower_limit2g = WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
577 .txpower_limit5g = WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
578 .txpower_scale = WMI_PDEV_PARAM_TXPOWER_SCALE,
579 .beacon_gen_mode = WMI_PDEV_PARAM_BEACON_GEN_MODE,
580 .beacon_tx_mode = WMI_PDEV_PARAM_BEACON_TX_MODE,
581 .resmgr_offchan_mode = WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
582 .protection_mode = WMI_PDEV_PARAM_PROTECTION_MODE,
583 .dynamic_bw = WMI_PDEV_PARAM_DYNAMIC_BW,
584 .non_agg_sw_retry_th = WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
585 .agg_sw_retry_th = WMI_PDEV_PARAM_AGG_SW_RETRY_TH,
586 .sta_kickout_th = WMI_PDEV_PARAM_STA_KICKOUT_TH,
587 .ac_aggrsize_scaling = WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING,
588 .ltr_enable = WMI_PDEV_PARAM_LTR_ENABLE,
589 .ltr_ac_latency_be = WMI_PDEV_PARAM_LTR_AC_LATENCY_BE,
590 .ltr_ac_latency_bk = WMI_PDEV_PARAM_LTR_AC_LATENCY_BK,
591 .ltr_ac_latency_vi = WMI_PDEV_PARAM_LTR_AC_LATENCY_VI,
592 .ltr_ac_latency_vo = WMI_PDEV_PARAM_LTR_AC_LATENCY_VO,
593 .ltr_ac_latency_timeout = WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
594 .ltr_sleep_override = WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
595 .ltr_rx_override = WMI_PDEV_PARAM_LTR_RX_OVERRIDE,
596 .ltr_tx_activity_timeout = WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
597 .l1ss_enable = WMI_PDEV_PARAM_L1SS_ENABLE,
598 .dsleep_enable = WMI_PDEV_PARAM_DSLEEP_ENABLE,
599 .pcielp_txbuf_flush = WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH,
600 .pcielp_txbuf_watermark = WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
601 .pcielp_txbuf_tmo_en = WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
602 .pcielp_txbuf_tmo_value = WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE,
603 .pdev_stats_update_period = WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
604 .vdev_stats_update_period = WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
605 .peer_stats_update_period = WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
606 .bcnflt_stats_update_period = WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
607 .pmf_qos = WMI_PDEV_PARAM_PMF_QOS,
608 .arp_ac_override = WMI_PDEV_PARAM_ARP_AC_OVERRIDE,
Bartosz Markowski226a3392013-09-26 17:47:16 +0200609 .dcs = WMI_PDEV_PARAM_DCS,
610 .ani_enable = WMI_PDEV_PARAM_ANI_ENABLE,
611 .ani_poll_period = WMI_PDEV_PARAM_ANI_POLL_PERIOD,
612 .ani_listen_period = WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
613 .ani_ofdm_level = WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
614 .ani_cck_level = WMI_PDEV_PARAM_ANI_CCK_LEVEL,
615 .dyntxchain = WMI_PDEV_PARAM_DYNTXCHAIN,
616 .proxy_sta = WMI_PDEV_PARAM_PROXY_STA,
617 .idle_ps_config = WMI_PDEV_PARAM_IDLE_PS_CONFIG,
618 .power_gating_sleep = WMI_PDEV_PARAM_POWER_GATING_SLEEP,
619 .fast_channel_reset = WMI_PDEV_PARAM_UNSUPPORTED,
620 .burst_dur = WMI_PDEV_PARAM_UNSUPPORTED,
621 .burst_enable = WMI_PDEV_PARAM_UNSUPPORTED,
Peter Oha7bd3e92014-12-02 13:07:14 +0200622 .cal_period = WMI_PDEV_PARAM_UNSUPPORTED,
Bartosz Markowski226a3392013-09-26 17:47:16 +0200623};
624
625static struct wmi_pdev_param_map wmi_10x_pdev_param_map = {
626 .tx_chain_mask = WMI_10X_PDEV_PARAM_TX_CHAIN_MASK,
627 .rx_chain_mask = WMI_10X_PDEV_PARAM_RX_CHAIN_MASK,
628 .txpower_limit2g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT2G,
629 .txpower_limit5g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT5G,
630 .txpower_scale = WMI_10X_PDEV_PARAM_TXPOWER_SCALE,
631 .beacon_gen_mode = WMI_10X_PDEV_PARAM_BEACON_GEN_MODE,
632 .beacon_tx_mode = WMI_10X_PDEV_PARAM_BEACON_TX_MODE,
633 .resmgr_offchan_mode = WMI_10X_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
634 .protection_mode = WMI_10X_PDEV_PARAM_PROTECTION_MODE,
635 .dynamic_bw = WMI_10X_PDEV_PARAM_DYNAMIC_BW,
636 .non_agg_sw_retry_th = WMI_10X_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
637 .agg_sw_retry_th = WMI_10X_PDEV_PARAM_AGG_SW_RETRY_TH,
638 .sta_kickout_th = WMI_10X_PDEV_PARAM_STA_KICKOUT_TH,
639 .ac_aggrsize_scaling = WMI_10X_PDEV_PARAM_AC_AGGRSIZE_SCALING,
640 .ltr_enable = WMI_10X_PDEV_PARAM_LTR_ENABLE,
641 .ltr_ac_latency_be = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BE,
642 .ltr_ac_latency_bk = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BK,
643 .ltr_ac_latency_vi = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VI,
644 .ltr_ac_latency_vo = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VO,
645 .ltr_ac_latency_timeout = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
646 .ltr_sleep_override = WMI_10X_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
647 .ltr_rx_override = WMI_10X_PDEV_PARAM_LTR_RX_OVERRIDE,
648 .ltr_tx_activity_timeout = WMI_10X_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
649 .l1ss_enable = WMI_10X_PDEV_PARAM_L1SS_ENABLE,
650 .dsleep_enable = WMI_10X_PDEV_PARAM_DSLEEP_ENABLE,
651 .pcielp_txbuf_flush = WMI_PDEV_PARAM_UNSUPPORTED,
652 .pcielp_txbuf_watermark = WMI_PDEV_PARAM_UNSUPPORTED,
653 .pcielp_txbuf_tmo_en = WMI_PDEV_PARAM_UNSUPPORTED,
654 .pcielp_txbuf_tmo_value = WMI_PDEV_PARAM_UNSUPPORTED,
655 .pdev_stats_update_period = WMI_10X_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
656 .vdev_stats_update_period = WMI_10X_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
657 .peer_stats_update_period = WMI_10X_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
658 .bcnflt_stats_update_period =
659 WMI_10X_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
660 .pmf_qos = WMI_10X_PDEV_PARAM_PMF_QOS,
Marek Puzyniakab6258e2014-01-29 15:03:31 +0200661 .arp_ac_override = WMI_10X_PDEV_PARAM_ARPDHCP_AC_OVERRIDE,
Bartosz Markowski226a3392013-09-26 17:47:16 +0200662 .dcs = WMI_10X_PDEV_PARAM_DCS,
663 .ani_enable = WMI_10X_PDEV_PARAM_ANI_ENABLE,
664 .ani_poll_period = WMI_10X_PDEV_PARAM_ANI_POLL_PERIOD,
665 .ani_listen_period = WMI_10X_PDEV_PARAM_ANI_LISTEN_PERIOD,
666 .ani_ofdm_level = WMI_10X_PDEV_PARAM_ANI_OFDM_LEVEL,
667 .ani_cck_level = WMI_10X_PDEV_PARAM_ANI_CCK_LEVEL,
668 .dyntxchain = WMI_10X_PDEV_PARAM_DYNTXCHAIN,
669 .proxy_sta = WMI_PDEV_PARAM_UNSUPPORTED,
670 .idle_ps_config = WMI_PDEV_PARAM_UNSUPPORTED,
671 .power_gating_sleep = WMI_PDEV_PARAM_UNSUPPORTED,
672 .fast_channel_reset = WMI_10X_PDEV_PARAM_FAST_CHANNEL_RESET,
673 .burst_dur = WMI_10X_PDEV_PARAM_BURST_DUR,
674 .burst_enable = WMI_10X_PDEV_PARAM_BURST_ENABLE,
Peter Oha7bd3e92014-12-02 13:07:14 +0200675 .cal_period = WMI_10X_PDEV_PARAM_CAL_PERIOD,
Bartosz Markowski226a3392013-09-26 17:47:16 +0200676};
677
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +0200678static struct wmi_pdev_param_map wmi_10_2_4_pdev_param_map = {
679 .tx_chain_mask = WMI_10X_PDEV_PARAM_TX_CHAIN_MASK,
680 .rx_chain_mask = WMI_10X_PDEV_PARAM_RX_CHAIN_MASK,
681 .txpower_limit2g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT2G,
682 .txpower_limit5g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT5G,
683 .txpower_scale = WMI_10X_PDEV_PARAM_TXPOWER_SCALE,
684 .beacon_gen_mode = WMI_10X_PDEV_PARAM_BEACON_GEN_MODE,
685 .beacon_tx_mode = WMI_10X_PDEV_PARAM_BEACON_TX_MODE,
686 .resmgr_offchan_mode = WMI_10X_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
687 .protection_mode = WMI_10X_PDEV_PARAM_PROTECTION_MODE,
688 .dynamic_bw = WMI_10X_PDEV_PARAM_DYNAMIC_BW,
689 .non_agg_sw_retry_th = WMI_10X_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
690 .agg_sw_retry_th = WMI_10X_PDEV_PARAM_AGG_SW_RETRY_TH,
691 .sta_kickout_th = WMI_10X_PDEV_PARAM_STA_KICKOUT_TH,
692 .ac_aggrsize_scaling = WMI_10X_PDEV_PARAM_AC_AGGRSIZE_SCALING,
693 .ltr_enable = WMI_10X_PDEV_PARAM_LTR_ENABLE,
694 .ltr_ac_latency_be = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BE,
695 .ltr_ac_latency_bk = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BK,
696 .ltr_ac_latency_vi = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VI,
697 .ltr_ac_latency_vo = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VO,
698 .ltr_ac_latency_timeout = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
699 .ltr_sleep_override = WMI_10X_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
700 .ltr_rx_override = WMI_10X_PDEV_PARAM_LTR_RX_OVERRIDE,
701 .ltr_tx_activity_timeout = WMI_10X_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
702 .l1ss_enable = WMI_10X_PDEV_PARAM_L1SS_ENABLE,
703 .dsleep_enable = WMI_10X_PDEV_PARAM_DSLEEP_ENABLE,
704 .pcielp_txbuf_flush = WMI_PDEV_PARAM_UNSUPPORTED,
705 .pcielp_txbuf_watermark = WMI_PDEV_PARAM_UNSUPPORTED,
706 .pcielp_txbuf_tmo_en = WMI_PDEV_PARAM_UNSUPPORTED,
707 .pcielp_txbuf_tmo_value = WMI_PDEV_PARAM_UNSUPPORTED,
708 .pdev_stats_update_period = WMI_10X_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
709 .vdev_stats_update_period = WMI_10X_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
710 .peer_stats_update_period = WMI_10X_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
711 .bcnflt_stats_update_period =
712 WMI_10X_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
713 .pmf_qos = WMI_10X_PDEV_PARAM_PMF_QOS,
714 .arp_ac_override = WMI_10X_PDEV_PARAM_ARPDHCP_AC_OVERRIDE,
715 .dcs = WMI_10X_PDEV_PARAM_DCS,
716 .ani_enable = WMI_10X_PDEV_PARAM_ANI_ENABLE,
717 .ani_poll_period = WMI_10X_PDEV_PARAM_ANI_POLL_PERIOD,
718 .ani_listen_period = WMI_10X_PDEV_PARAM_ANI_LISTEN_PERIOD,
719 .ani_ofdm_level = WMI_10X_PDEV_PARAM_ANI_OFDM_LEVEL,
720 .ani_cck_level = WMI_10X_PDEV_PARAM_ANI_CCK_LEVEL,
721 .dyntxchain = WMI_10X_PDEV_PARAM_DYNTXCHAIN,
722 .proxy_sta = WMI_PDEV_PARAM_UNSUPPORTED,
723 .idle_ps_config = WMI_PDEV_PARAM_UNSUPPORTED,
724 .power_gating_sleep = WMI_PDEV_PARAM_UNSUPPORTED,
725 .fast_channel_reset = WMI_10X_PDEV_PARAM_FAST_CHANNEL_RESET,
726 .burst_dur = WMI_10X_PDEV_PARAM_BURST_DUR,
727 .burst_enable = WMI_10X_PDEV_PARAM_BURST_ENABLE,
728 .cal_period = WMI_10X_PDEV_PARAM_CAL_PERIOD,
729};
730
Michal Kazior24c88f72014-07-25 13:32:17 +0200731/* firmware 10.2 specific mappings */
732static struct wmi_cmd_map wmi_10_2_cmd_map = {
733 .init_cmdid = WMI_10_2_INIT_CMDID,
734 .start_scan_cmdid = WMI_10_2_START_SCAN_CMDID,
735 .stop_scan_cmdid = WMI_10_2_STOP_SCAN_CMDID,
736 .scan_chan_list_cmdid = WMI_10_2_SCAN_CHAN_LIST_CMDID,
737 .scan_sch_prio_tbl_cmdid = WMI_CMD_UNSUPPORTED,
738 .pdev_set_regdomain_cmdid = WMI_10_2_PDEV_SET_REGDOMAIN_CMDID,
739 .pdev_set_channel_cmdid = WMI_10_2_PDEV_SET_CHANNEL_CMDID,
740 .pdev_set_param_cmdid = WMI_10_2_PDEV_SET_PARAM_CMDID,
741 .pdev_pktlog_enable_cmdid = WMI_10_2_PDEV_PKTLOG_ENABLE_CMDID,
742 .pdev_pktlog_disable_cmdid = WMI_10_2_PDEV_PKTLOG_DISABLE_CMDID,
743 .pdev_set_wmm_params_cmdid = WMI_10_2_PDEV_SET_WMM_PARAMS_CMDID,
744 .pdev_set_ht_cap_ie_cmdid = WMI_10_2_PDEV_SET_HT_CAP_IE_CMDID,
745 .pdev_set_vht_cap_ie_cmdid = WMI_10_2_PDEV_SET_VHT_CAP_IE_CMDID,
746 .pdev_set_quiet_mode_cmdid = WMI_10_2_PDEV_SET_QUIET_MODE_CMDID,
747 .pdev_green_ap_ps_enable_cmdid = WMI_10_2_PDEV_GREEN_AP_PS_ENABLE_CMDID,
748 .pdev_get_tpc_config_cmdid = WMI_10_2_PDEV_GET_TPC_CONFIG_CMDID,
749 .pdev_set_base_macaddr_cmdid = WMI_10_2_PDEV_SET_BASE_MACADDR_CMDID,
750 .vdev_create_cmdid = WMI_10_2_VDEV_CREATE_CMDID,
751 .vdev_delete_cmdid = WMI_10_2_VDEV_DELETE_CMDID,
752 .vdev_start_request_cmdid = WMI_10_2_VDEV_START_REQUEST_CMDID,
753 .vdev_restart_request_cmdid = WMI_10_2_VDEV_RESTART_REQUEST_CMDID,
754 .vdev_up_cmdid = WMI_10_2_VDEV_UP_CMDID,
755 .vdev_stop_cmdid = WMI_10_2_VDEV_STOP_CMDID,
756 .vdev_down_cmdid = WMI_10_2_VDEV_DOWN_CMDID,
757 .vdev_set_param_cmdid = WMI_10_2_VDEV_SET_PARAM_CMDID,
758 .vdev_install_key_cmdid = WMI_10_2_VDEV_INSTALL_KEY_CMDID,
759 .peer_create_cmdid = WMI_10_2_PEER_CREATE_CMDID,
760 .peer_delete_cmdid = WMI_10_2_PEER_DELETE_CMDID,
761 .peer_flush_tids_cmdid = WMI_10_2_PEER_FLUSH_TIDS_CMDID,
762 .peer_set_param_cmdid = WMI_10_2_PEER_SET_PARAM_CMDID,
763 .peer_assoc_cmdid = WMI_10_2_PEER_ASSOC_CMDID,
764 .peer_add_wds_entry_cmdid = WMI_10_2_PEER_ADD_WDS_ENTRY_CMDID,
765 .peer_remove_wds_entry_cmdid = WMI_10_2_PEER_REMOVE_WDS_ENTRY_CMDID,
766 .peer_mcast_group_cmdid = WMI_10_2_PEER_MCAST_GROUP_CMDID,
767 .bcn_tx_cmdid = WMI_10_2_BCN_TX_CMDID,
768 .pdev_send_bcn_cmdid = WMI_10_2_PDEV_SEND_BCN_CMDID,
769 .bcn_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
770 .bcn_filter_rx_cmdid = WMI_10_2_BCN_FILTER_RX_CMDID,
771 .prb_req_filter_rx_cmdid = WMI_10_2_PRB_REQ_FILTER_RX_CMDID,
772 .mgmt_tx_cmdid = WMI_10_2_MGMT_TX_CMDID,
773 .prb_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
774 .addba_clear_resp_cmdid = WMI_10_2_ADDBA_CLEAR_RESP_CMDID,
775 .addba_send_cmdid = WMI_10_2_ADDBA_SEND_CMDID,
776 .addba_status_cmdid = WMI_10_2_ADDBA_STATUS_CMDID,
777 .delba_send_cmdid = WMI_10_2_DELBA_SEND_CMDID,
778 .addba_set_resp_cmdid = WMI_10_2_ADDBA_SET_RESP_CMDID,
779 .send_singleamsdu_cmdid = WMI_10_2_SEND_SINGLEAMSDU_CMDID,
780 .sta_powersave_mode_cmdid = WMI_10_2_STA_POWERSAVE_MODE_CMDID,
781 .sta_powersave_param_cmdid = WMI_10_2_STA_POWERSAVE_PARAM_CMDID,
782 .sta_mimo_ps_mode_cmdid = WMI_10_2_STA_MIMO_PS_MODE_CMDID,
783 .pdev_dfs_enable_cmdid = WMI_10_2_PDEV_DFS_ENABLE_CMDID,
784 .pdev_dfs_disable_cmdid = WMI_10_2_PDEV_DFS_DISABLE_CMDID,
785 .roam_scan_mode = WMI_10_2_ROAM_SCAN_MODE,
786 .roam_scan_rssi_threshold = WMI_10_2_ROAM_SCAN_RSSI_THRESHOLD,
787 .roam_scan_period = WMI_10_2_ROAM_SCAN_PERIOD,
788 .roam_scan_rssi_change_threshold =
789 WMI_10_2_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
790 .roam_ap_profile = WMI_10_2_ROAM_AP_PROFILE,
791 .ofl_scan_add_ap_profile = WMI_10_2_OFL_SCAN_ADD_AP_PROFILE,
792 .ofl_scan_remove_ap_profile = WMI_10_2_OFL_SCAN_REMOVE_AP_PROFILE,
793 .ofl_scan_period = WMI_10_2_OFL_SCAN_PERIOD,
794 .p2p_dev_set_device_info = WMI_10_2_P2P_DEV_SET_DEVICE_INFO,
795 .p2p_dev_set_discoverability = WMI_10_2_P2P_DEV_SET_DISCOVERABILITY,
796 .p2p_go_set_beacon_ie = WMI_10_2_P2P_GO_SET_BEACON_IE,
797 .p2p_go_set_probe_resp_ie = WMI_10_2_P2P_GO_SET_PROBE_RESP_IE,
798 .p2p_set_vendor_ie_data_cmdid = WMI_CMD_UNSUPPORTED,
799 .ap_ps_peer_param_cmdid = WMI_10_2_AP_PS_PEER_PARAM_CMDID,
800 .ap_ps_peer_uapsd_coex_cmdid = WMI_CMD_UNSUPPORTED,
801 .peer_rate_retry_sched_cmdid = WMI_10_2_PEER_RATE_RETRY_SCHED_CMDID,
802 .wlan_profile_trigger_cmdid = WMI_10_2_WLAN_PROFILE_TRIGGER_CMDID,
803 .wlan_profile_set_hist_intvl_cmdid =
804 WMI_10_2_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
805 .wlan_profile_get_profile_data_cmdid =
806 WMI_10_2_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
807 .wlan_profile_enable_profile_id_cmdid =
808 WMI_10_2_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
809 .wlan_profile_list_profile_id_cmdid =
810 WMI_10_2_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
811 .pdev_suspend_cmdid = WMI_10_2_PDEV_SUSPEND_CMDID,
812 .pdev_resume_cmdid = WMI_10_2_PDEV_RESUME_CMDID,
813 .add_bcn_filter_cmdid = WMI_10_2_ADD_BCN_FILTER_CMDID,
814 .rmv_bcn_filter_cmdid = WMI_10_2_RMV_BCN_FILTER_CMDID,
815 .wow_add_wake_pattern_cmdid = WMI_10_2_WOW_ADD_WAKE_PATTERN_CMDID,
816 .wow_del_wake_pattern_cmdid = WMI_10_2_WOW_DEL_WAKE_PATTERN_CMDID,
817 .wow_enable_disable_wake_event_cmdid =
818 WMI_10_2_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
819 .wow_enable_cmdid = WMI_10_2_WOW_ENABLE_CMDID,
820 .wow_hostwakeup_from_sleep_cmdid =
821 WMI_10_2_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
822 .rtt_measreq_cmdid = WMI_10_2_RTT_MEASREQ_CMDID,
823 .rtt_tsf_cmdid = WMI_10_2_RTT_TSF_CMDID,
824 .vdev_spectral_scan_configure_cmdid =
825 WMI_10_2_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
826 .vdev_spectral_scan_enable_cmdid =
827 WMI_10_2_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
828 .request_stats_cmdid = WMI_10_2_REQUEST_STATS_CMDID,
829 .set_arp_ns_offload_cmdid = WMI_CMD_UNSUPPORTED,
830 .network_list_offload_config_cmdid = WMI_CMD_UNSUPPORTED,
831 .gtk_offload_cmdid = WMI_CMD_UNSUPPORTED,
832 .csa_offload_enable_cmdid = WMI_CMD_UNSUPPORTED,
833 .csa_offload_chanswitch_cmdid = WMI_CMD_UNSUPPORTED,
834 .chatter_set_mode_cmdid = WMI_CMD_UNSUPPORTED,
835 .peer_tid_addba_cmdid = WMI_CMD_UNSUPPORTED,
836 .peer_tid_delba_cmdid = WMI_CMD_UNSUPPORTED,
837 .sta_dtim_ps_method_cmdid = WMI_CMD_UNSUPPORTED,
838 .sta_uapsd_auto_trig_cmdid = WMI_CMD_UNSUPPORTED,
839 .sta_keepalive_cmd = WMI_CMD_UNSUPPORTED,
840 .echo_cmdid = WMI_10_2_ECHO_CMDID,
841 .pdev_utf_cmdid = WMI_10_2_PDEV_UTF_CMDID,
842 .dbglog_cfg_cmdid = WMI_10_2_DBGLOG_CFG_CMDID,
843 .pdev_qvit_cmdid = WMI_10_2_PDEV_QVIT_CMDID,
844 .pdev_ftm_intg_cmdid = WMI_CMD_UNSUPPORTED,
845 .vdev_set_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
846 .vdev_get_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
847 .force_fw_hang_cmdid = WMI_CMD_UNSUPPORTED,
848 .gpio_config_cmdid = WMI_10_2_GPIO_CONFIG_CMDID,
849 .gpio_output_cmdid = WMI_10_2_GPIO_OUTPUT_CMDID,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +0200850 .pdev_get_temperature_cmdid = WMI_CMD_UNSUPPORTED,
Michal Kazior24c88f72014-07-25 13:32:17 +0200851};
852
Michal Kazior0226d602014-12-03 10:11:22 +0200853void ath10k_wmi_put_wmi_channel(struct wmi_channel *ch,
854 const struct wmi_channel_arg *arg)
Michal Kazior2d667212014-09-18 15:21:21 +0200855{
856 u32 flags = 0;
857
858 memset(ch, 0, sizeof(*ch));
859
860 if (arg->passive)
861 flags |= WMI_CHAN_FLAG_PASSIVE;
862 if (arg->allow_ibss)
863 flags |= WMI_CHAN_FLAG_ADHOC_ALLOWED;
864 if (arg->allow_ht)
865 flags |= WMI_CHAN_FLAG_ALLOW_HT;
866 if (arg->allow_vht)
867 flags |= WMI_CHAN_FLAG_ALLOW_VHT;
868 if (arg->ht40plus)
869 flags |= WMI_CHAN_FLAG_HT40_PLUS;
870 if (arg->chan_radar)
871 flags |= WMI_CHAN_FLAG_DFS;
872
873 ch->mhz = __cpu_to_le32(arg->freq);
874 ch->band_center_freq1 = __cpu_to_le32(arg->band_center_freq1);
875 ch->band_center_freq2 = 0;
876 ch->min_power = arg->min_power;
877 ch->max_power = arg->max_power;
878 ch->reg_power = arg->max_reg_power;
879 ch->antenna_max = arg->max_antenna_gain;
880
881 /* mode & flags share storage */
882 ch->mode = arg->mode;
883 ch->flags |= __cpu_to_le32(flags);
884}
885
Kalle Valo5e3dd152013-06-12 20:52:10 +0300886int ath10k_wmi_wait_for_service_ready(struct ath10k *ar)
887{
888 int ret;
Kalle Valoaf762c02014-09-14 12:50:17 +0300889
Kalle Valo5e3dd152013-06-12 20:52:10 +0300890 ret = wait_for_completion_timeout(&ar->wmi.service_ready,
891 WMI_SERVICE_READY_TIMEOUT_HZ);
892 return ret;
893}
894
895int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar)
896{
897 int ret;
Kalle Valoaf762c02014-09-14 12:50:17 +0300898
Kalle Valo5e3dd152013-06-12 20:52:10 +0300899 ret = wait_for_completion_timeout(&ar->wmi.unified_ready,
900 WMI_UNIFIED_READY_TIMEOUT_HZ);
901 return ret;
902}
903
Kalle Valo666a73f32014-09-10 18:23:23 +0300904struct sk_buff *ath10k_wmi_alloc_skb(struct ath10k *ar, u32 len)
Kalle Valo5e3dd152013-06-12 20:52:10 +0300905{
906 struct sk_buff *skb;
907 u32 round_len = roundup(len, 4);
908
Michal Kazior7aa7a722014-08-25 12:09:38 +0200909 skb = ath10k_htc_alloc_skb(ar, WMI_SKB_HEADROOM + round_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300910 if (!skb)
911 return NULL;
912
913 skb_reserve(skb, WMI_SKB_HEADROOM);
914 if (!IS_ALIGNED((unsigned long)skb->data, 4))
Michal Kazior7aa7a722014-08-25 12:09:38 +0200915 ath10k_warn(ar, "Unaligned WMI skb\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +0300916
917 skb_put(skb, round_len);
918 memset(skb->data, 0, round_len);
919
920 return skb;
921}
922
923static void ath10k_wmi_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb)
924{
925 dev_kfree_skb(skb);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300926}
927
Michal Kaziord7579d12014-12-03 10:10:54 +0200928int ath10k_wmi_cmd_send_nowait(struct ath10k *ar, struct sk_buff *skb,
929 u32 cmd_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +0300930{
931 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb);
932 struct wmi_cmd_hdr *cmd_hdr;
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200933 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300934 u32 cmd = 0;
935
936 if (skb_push(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
937 return -ENOMEM;
938
939 cmd |= SM(cmd_id, WMI_CMD_HDR_CMD_ID);
940
941 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
942 cmd_hdr->cmd_id = __cpu_to_le32(cmd);
943
Kalle Valo5e3dd152013-06-12 20:52:10 +0300944 memset(skb_cb, 0, sizeof(*skb_cb));
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200945 ret = ath10k_htc_send(&ar->htc, ar->wmi.eid, skb);
Michal Kaziord35a6c12014-09-02 11:00:21 +0300946 trace_ath10k_wmi_cmd(ar, cmd_id, skb->data, skb->len, ret);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300947
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200948 if (ret)
949 goto err_pull;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300950
951 return 0;
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200952
953err_pull:
954 skb_pull(skb, sizeof(struct wmi_cmd_hdr));
955 return ret;
956}
957
Michal Kaziored543882013-09-13 14:16:56 +0200958static void ath10k_wmi_tx_beacon_nowait(struct ath10k_vif *arvif)
959{
Michal Kazioraf213192015-01-29 14:29:52 +0200960 struct ath10k *ar = arvif->ar;
Michal Kazior9ad50182015-01-29 14:29:47 +0200961 struct ath10k_skb_cb *cb;
Michal Kazioraf213192015-01-29 14:29:52 +0200962 struct sk_buff *bcn;
Michal Kaziored543882013-09-13 14:16:56 +0200963 int ret;
964
Michal Kazioraf213192015-01-29 14:29:52 +0200965 spin_lock_bh(&ar->data_lock);
Michal Kaziored543882013-09-13 14:16:56 +0200966
Michal Kazior9ad50182015-01-29 14:29:47 +0200967 bcn = arvif->beacon;
Michal Kaziored543882013-09-13 14:16:56 +0200968
Michal Kazioraf213192015-01-29 14:29:52 +0200969 if (!bcn)
970 goto unlock;
Michal Kaziored543882013-09-13 14:16:56 +0200971
Michal Kazioraf213192015-01-29 14:29:52 +0200972 cb = ATH10K_SKB_CB(bcn);
Michal Kaziored543882013-09-13 14:16:56 +0200973
Michal Kazioraf213192015-01-29 14:29:52 +0200974 switch (arvif->beacon_state) {
975 case ATH10K_BEACON_SENDING:
976 case ATH10K_BEACON_SENT:
977 break;
978 case ATH10K_BEACON_SCHEDULED:
979 arvif->beacon_state = ATH10K_BEACON_SENDING;
980 spin_unlock_bh(&ar->data_lock);
981
982 ret = ath10k_wmi_beacon_send_ref_nowait(arvif->ar,
983 arvif->vdev_id,
984 bcn->data, bcn->len,
985 cb->paddr,
986 cb->bcn.dtim_zero,
987 cb->bcn.deliver_cab);
988
989 spin_lock_bh(&ar->data_lock);
990
991 if (ret == 0)
992 arvif->beacon_state = ATH10K_BEACON_SENT;
993 else
994 arvif->beacon_state = ATH10K_BEACON_SCHEDULED;
995 }
996
997unlock:
998 spin_unlock_bh(&ar->data_lock);
Michal Kaziored543882013-09-13 14:16:56 +0200999}
1000
1001static void ath10k_wmi_tx_beacons_iter(void *data, u8 *mac,
1002 struct ieee80211_vif *vif)
1003{
1004 struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif);
1005
1006 ath10k_wmi_tx_beacon_nowait(arvif);
1007}
1008
1009static void ath10k_wmi_tx_beacons_nowait(struct ath10k *ar)
1010{
Michal Kaziored543882013-09-13 14:16:56 +02001011 ieee80211_iterate_active_interfaces_atomic(ar->hw,
1012 IEEE80211_IFACE_ITER_NORMAL,
1013 ath10k_wmi_tx_beacons_iter,
1014 NULL);
Michal Kaziored543882013-09-13 14:16:56 +02001015}
1016
Michal Kazior12acbc42013-09-13 14:16:55 +02001017static void ath10k_wmi_op_ep_tx_credits(struct ath10k *ar)
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001018{
Michal Kaziored543882013-09-13 14:16:56 +02001019 /* try to send pending beacons first. they take priority */
1020 ath10k_wmi_tx_beacons_nowait(ar);
1021
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001022 wake_up(&ar->wmi.tx_credits_wq);
1023}
1024
Kalle Valo666a73f32014-09-10 18:23:23 +03001025int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id)
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001026{
Bartosz Markowski34957b22013-10-15 09:55:31 +02001027 int ret = -EOPNOTSUPP;
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001028
Kalle Valo56b84282013-10-16 15:44:47 +03001029 might_sleep();
1030
Bartosz Markowski34957b22013-10-15 09:55:31 +02001031 if (cmd_id == WMI_CMD_UNSUPPORTED) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02001032 ath10k_warn(ar, "wmi command %d is not supported by firmware\n",
Bartosz Markowski55321552013-09-26 17:47:07 +02001033 cmd_id);
1034 return ret;
1035 }
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001036
1037 wait_event_timeout(ar->wmi.tx_credits_wq, ({
Michal Kaziored543882013-09-13 14:16:56 +02001038 /* try to send pending beacons first. they take priority */
1039 ath10k_wmi_tx_beacons_nowait(ar);
1040
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001041 ret = ath10k_wmi_cmd_send_nowait(ar, skb, cmd_id);
Michal Kazior7962b0d2014-10-28 10:34:38 +01001042
1043 if (ret && test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags))
1044 ret = -ESHUTDOWN;
1045
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001046 (ret != -EAGAIN);
1047 }), 3*HZ);
1048
1049 if (ret)
1050 dev_kfree_skb_any(skb);
1051
1052 return ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001053}
1054
Michal Kaziord7579d12014-12-03 10:10:54 +02001055static struct sk_buff *
1056ath10k_wmi_op_gen_mgmt_tx(struct ath10k *ar, struct sk_buff *msdu)
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001057{
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001058 struct wmi_mgmt_tx_cmd *cmd;
1059 struct ieee80211_hdr *hdr;
Michal Kaziord7579d12014-12-03 10:10:54 +02001060 struct sk_buff *skb;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001061 int len;
Michal Kaziord7579d12014-12-03 10:10:54 +02001062 u32 buf_len = msdu->len;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001063 u16 fc;
1064
Michal Kaziord7579d12014-12-03 10:10:54 +02001065 hdr = (struct ieee80211_hdr *)msdu->data;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001066 fc = le16_to_cpu(hdr->frame_control);
1067
1068 if (WARN_ON_ONCE(!ieee80211_is_mgmt(hdr->frame_control)))
Michal Kaziord7579d12014-12-03 10:10:54 +02001069 return ERR_PTR(-EINVAL);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001070
Michal Kaziord7579d12014-12-03 10:10:54 +02001071 len = sizeof(cmd->hdr) + msdu->len;
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03001072
1073 if ((ieee80211_is_action(hdr->frame_control) ||
1074 ieee80211_is_deauth(hdr->frame_control) ||
1075 ieee80211_is_disassoc(hdr->frame_control)) &&
1076 ieee80211_has_protected(hdr->frame_control)) {
1077 len += IEEE80211_CCMP_MIC_LEN;
1078 buf_len += IEEE80211_CCMP_MIC_LEN;
1079 }
1080
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001081 len = round_up(len, 4);
1082
Michal Kaziord7579d12014-12-03 10:10:54 +02001083 skb = ath10k_wmi_alloc_skb(ar, len);
1084 if (!skb)
1085 return ERR_PTR(-ENOMEM);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001086
Michal Kaziord7579d12014-12-03 10:10:54 +02001087 cmd = (struct wmi_mgmt_tx_cmd *)skb->data;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001088
Michal Kaziord7579d12014-12-03 10:10:54 +02001089 cmd->hdr.vdev_id = __cpu_to_le32(ATH10K_SKB_CB(msdu)->vdev_id);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001090 cmd->hdr.tx_rate = 0;
1091 cmd->hdr.tx_power = 0;
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03001092 cmd->hdr.buf_len = __cpu_to_le32(buf_len);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001093
Kalle Valob25f32c2014-09-14 12:50:49 +03001094 ether_addr_copy(cmd->hdr.peer_macaddr.addr, ieee80211_get_DA(hdr));
Michal Kaziord7579d12014-12-03 10:10:54 +02001095 memcpy(cmd->buf, msdu->data, msdu->len);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001096
Michal Kazior7aa7a722014-08-25 12:09:38 +02001097 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi mgmt tx skb %p len %d ftype %02x stype %02x\n",
Michal Kaziord7579d12014-12-03 10:10:54 +02001098 msdu, skb->len, fc & IEEE80211_FCTL_FTYPE,
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001099 fc & IEEE80211_FCTL_STYPE);
Rajkumar Manoharan5ce8e7f2014-11-05 19:14:31 +05301100 trace_ath10k_tx_hdr(ar, skb->data, skb->len);
1101 trace_ath10k_tx_payload(ar, skb->data, skb->len);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001102
Michal Kaziord7579d12014-12-03 10:10:54 +02001103 return skb;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001104}
1105
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001106static void ath10k_wmi_event_scan_started(struct ath10k *ar)
1107{
1108 lockdep_assert_held(&ar->data_lock);
1109
1110 switch (ar->scan.state) {
1111 case ATH10K_SCAN_IDLE:
1112 case ATH10K_SCAN_RUNNING:
1113 case ATH10K_SCAN_ABORTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02001114 ath10k_warn(ar, "received scan started event in an invalid scan state: %s (%d)\n",
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001115 ath10k_scan_state_str(ar->scan.state),
1116 ar->scan.state);
1117 break;
1118 case ATH10K_SCAN_STARTING:
1119 ar->scan.state = ATH10K_SCAN_RUNNING;
1120
1121 if (ar->scan.is_roc)
1122 ieee80211_ready_on_channel(ar->hw);
1123
1124 complete(&ar->scan.started);
1125 break;
1126 }
1127}
1128
Ben Greear2f9eec02015-02-15 16:50:38 +02001129static void ath10k_wmi_event_scan_start_failed(struct ath10k *ar)
1130{
1131 lockdep_assert_held(&ar->data_lock);
1132
1133 switch (ar->scan.state) {
1134 case ATH10K_SCAN_IDLE:
1135 case ATH10K_SCAN_RUNNING:
1136 case ATH10K_SCAN_ABORTING:
1137 ath10k_warn(ar, "received scan start failed event in an invalid scan state: %s (%d)\n",
1138 ath10k_scan_state_str(ar->scan.state),
1139 ar->scan.state);
1140 break;
1141 case ATH10K_SCAN_STARTING:
1142 complete(&ar->scan.started);
1143 __ath10k_scan_finish(ar);
1144 break;
1145 }
1146}
1147
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001148static void ath10k_wmi_event_scan_completed(struct ath10k *ar)
1149{
1150 lockdep_assert_held(&ar->data_lock);
1151
1152 switch (ar->scan.state) {
1153 case ATH10K_SCAN_IDLE:
1154 case ATH10K_SCAN_STARTING:
1155 /* One suspected reason scan can be completed while starting is
1156 * if firmware fails to deliver all scan events to the host,
1157 * e.g. when transport pipe is full. This has been observed
1158 * with spectral scan phyerr events starving wmi transport
1159 * pipe. In such case the "scan completed" event should be (and
1160 * is) ignored by the host as it may be just firmware's scan
1161 * state machine recovering.
1162 */
Michal Kazior7aa7a722014-08-25 12:09:38 +02001163 ath10k_warn(ar, "received scan completed event in an invalid scan state: %s (%d)\n",
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001164 ath10k_scan_state_str(ar->scan.state),
1165 ar->scan.state);
1166 break;
1167 case ATH10K_SCAN_RUNNING:
1168 case ATH10K_SCAN_ABORTING:
1169 __ath10k_scan_finish(ar);
1170 break;
1171 }
1172}
1173
1174static void ath10k_wmi_event_scan_bss_chan(struct ath10k *ar)
1175{
1176 lockdep_assert_held(&ar->data_lock);
1177
1178 switch (ar->scan.state) {
1179 case ATH10K_SCAN_IDLE:
1180 case ATH10K_SCAN_STARTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02001181 ath10k_warn(ar, "received scan bss chan event in an invalid scan state: %s (%d)\n",
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001182 ath10k_scan_state_str(ar->scan.state),
1183 ar->scan.state);
1184 break;
1185 case ATH10K_SCAN_RUNNING:
1186 case ATH10K_SCAN_ABORTING:
1187 ar->scan_channel = NULL;
1188 break;
1189 }
1190}
1191
1192static void ath10k_wmi_event_scan_foreign_chan(struct ath10k *ar, u32 freq)
1193{
1194 lockdep_assert_held(&ar->data_lock);
1195
1196 switch (ar->scan.state) {
1197 case ATH10K_SCAN_IDLE:
1198 case ATH10K_SCAN_STARTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02001199 ath10k_warn(ar, "received scan foreign chan event in an invalid scan state: %s (%d)\n",
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001200 ath10k_scan_state_str(ar->scan.state),
1201 ar->scan.state);
1202 break;
1203 case ATH10K_SCAN_RUNNING:
1204 case ATH10K_SCAN_ABORTING:
1205 ar->scan_channel = ieee80211_get_channel(ar->hw->wiphy, freq);
1206
1207 if (ar->scan.is_roc && ar->scan.roc_freq == freq)
1208 complete(&ar->scan.on_channel);
1209 break;
1210 }
1211}
1212
Michal Kazior9ff8b722014-08-05 14:54:43 +02001213static const char *
1214ath10k_wmi_event_scan_type_str(enum wmi_scan_event_type type,
1215 enum wmi_scan_completion_reason reason)
1216{
1217 switch (type) {
1218 case WMI_SCAN_EVENT_STARTED:
1219 return "started";
1220 case WMI_SCAN_EVENT_COMPLETED:
1221 switch (reason) {
1222 case WMI_SCAN_REASON_COMPLETED:
1223 return "completed";
1224 case WMI_SCAN_REASON_CANCELLED:
1225 return "completed [cancelled]";
1226 case WMI_SCAN_REASON_PREEMPTED:
1227 return "completed [preempted]";
1228 case WMI_SCAN_REASON_TIMEDOUT:
1229 return "completed [timedout]";
1230 case WMI_SCAN_REASON_MAX:
1231 break;
1232 }
1233 return "completed [unknown]";
1234 case WMI_SCAN_EVENT_BSS_CHANNEL:
1235 return "bss channel";
1236 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
1237 return "foreign channel";
1238 case WMI_SCAN_EVENT_DEQUEUED:
1239 return "dequeued";
1240 case WMI_SCAN_EVENT_PREEMPTED:
1241 return "preempted";
1242 case WMI_SCAN_EVENT_START_FAILED:
1243 return "start failed";
1244 default:
1245 return "unknown";
1246 }
1247}
1248
Michal Kaziord7579d12014-12-03 10:10:54 +02001249static int ath10k_wmi_op_pull_scan_ev(struct ath10k *ar, struct sk_buff *skb,
1250 struct wmi_scan_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02001251{
1252 struct wmi_scan_event *ev = (void *)skb->data;
1253
1254 if (skb->len < sizeof(*ev))
1255 return -EPROTO;
1256
1257 skb_pull(skb, sizeof(*ev));
1258 arg->event_type = ev->event_type;
1259 arg->reason = ev->reason;
1260 arg->channel_freq = ev->channel_freq;
1261 arg->scan_req_id = ev->scan_req_id;
1262 arg->scan_id = ev->scan_id;
1263 arg->vdev_id = ev->vdev_id;
1264
1265 return 0;
1266}
1267
Michal Kazior0226d602014-12-03 10:11:22 +02001268int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03001269{
Michal Kazior32653cf2014-12-03 10:10:26 +02001270 struct wmi_scan_ev_arg arg = {};
Kalle Valo5e3dd152013-06-12 20:52:10 +03001271 enum wmi_scan_event_type event_type;
1272 enum wmi_scan_completion_reason reason;
1273 u32 freq;
1274 u32 req_id;
1275 u32 scan_id;
1276 u32 vdev_id;
Michal Kazior32653cf2014-12-03 10:10:26 +02001277 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001278
Michal Kaziord7579d12014-12-03 10:10:54 +02001279 ret = ath10k_wmi_pull_scan(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02001280 if (ret) {
1281 ath10k_warn(ar, "failed to parse scan event: %d\n", ret);
1282 return ret;
1283 }
1284
1285 event_type = __le32_to_cpu(arg.event_type);
1286 reason = __le32_to_cpu(arg.reason);
1287 freq = __le32_to_cpu(arg.channel_freq);
1288 req_id = __le32_to_cpu(arg.scan_req_id);
1289 scan_id = __le32_to_cpu(arg.scan_id);
1290 vdev_id = __le32_to_cpu(arg.vdev_id);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001291
Kalle Valo5e3dd152013-06-12 20:52:10 +03001292 spin_lock_bh(&ar->data_lock);
1293
Michal Kazior7aa7a722014-08-25 12:09:38 +02001294 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001295 "scan event %s type %d reason %d freq %d req_id %d scan_id %d vdev_id %d state %s (%d)\n",
1296 ath10k_wmi_event_scan_type_str(event_type, reason),
1297 event_type, reason, freq, req_id, scan_id, vdev_id,
1298 ath10k_scan_state_str(ar->scan.state), ar->scan.state);
1299
Kalle Valo5e3dd152013-06-12 20:52:10 +03001300 switch (event_type) {
1301 case WMI_SCAN_EVENT_STARTED:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001302 ath10k_wmi_event_scan_started(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001303 break;
1304 case WMI_SCAN_EVENT_COMPLETED:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001305 ath10k_wmi_event_scan_completed(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001306 break;
1307 case WMI_SCAN_EVENT_BSS_CHANNEL:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001308 ath10k_wmi_event_scan_bss_chan(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001309 break;
1310 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001311 ath10k_wmi_event_scan_foreign_chan(ar, freq);
1312 break;
1313 case WMI_SCAN_EVENT_START_FAILED:
Michal Kazior7aa7a722014-08-25 12:09:38 +02001314 ath10k_warn(ar, "received scan start failure event\n");
Ben Greear2f9eec02015-02-15 16:50:38 +02001315 ath10k_wmi_event_scan_start_failed(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001316 break;
1317 case WMI_SCAN_EVENT_DEQUEUED:
Kalle Valo5e3dd152013-06-12 20:52:10 +03001318 case WMI_SCAN_EVENT_PREEMPTED:
Kalle Valo5e3dd152013-06-12 20:52:10 +03001319 default:
1320 break;
1321 }
1322
1323 spin_unlock_bh(&ar->data_lock);
1324 return 0;
1325}
1326
1327static inline enum ieee80211_band phy_mode_to_band(u32 phy_mode)
1328{
1329 enum ieee80211_band band;
1330
1331 switch (phy_mode) {
1332 case MODE_11A:
1333 case MODE_11NA_HT20:
1334 case MODE_11NA_HT40:
1335 case MODE_11AC_VHT20:
1336 case MODE_11AC_VHT40:
1337 case MODE_11AC_VHT80:
1338 band = IEEE80211_BAND_5GHZ;
1339 break;
1340 case MODE_11G:
1341 case MODE_11B:
1342 case MODE_11GONLY:
1343 case MODE_11NG_HT20:
1344 case MODE_11NG_HT40:
1345 case MODE_11AC_VHT20_2G:
1346 case MODE_11AC_VHT40_2G:
1347 case MODE_11AC_VHT80_2G:
1348 default:
1349 band = IEEE80211_BAND_2GHZ;
1350 }
1351
1352 return band;
1353}
1354
1355static inline u8 get_rate_idx(u32 rate, enum ieee80211_band band)
1356{
1357 u8 rate_idx = 0;
1358
1359 /* rate in Kbps */
1360 switch (rate) {
1361 case 1000:
1362 rate_idx = 0;
1363 break;
1364 case 2000:
1365 rate_idx = 1;
1366 break;
1367 case 5500:
1368 rate_idx = 2;
1369 break;
1370 case 11000:
1371 rate_idx = 3;
1372 break;
1373 case 6000:
1374 rate_idx = 4;
1375 break;
1376 case 9000:
1377 rate_idx = 5;
1378 break;
1379 case 12000:
1380 rate_idx = 6;
1381 break;
1382 case 18000:
1383 rate_idx = 7;
1384 break;
1385 case 24000:
1386 rate_idx = 8;
1387 break;
1388 case 36000:
1389 rate_idx = 9;
1390 break;
1391 case 48000:
1392 rate_idx = 10;
1393 break;
1394 case 54000:
1395 rate_idx = 11;
1396 break;
1397 default:
1398 break;
1399 }
1400
1401 if (band == IEEE80211_BAND_5GHZ) {
1402 if (rate_idx > 3)
1403 /* Omit CCK rates */
1404 rate_idx -= 4;
1405 else
1406 rate_idx = 0;
1407 }
1408
1409 return rate_idx;
1410}
1411
Sujith Manoharan504f6cd2014-11-25 11:46:58 +05301412/* If keys are configured, HW decrypts all frames
1413 * with protected bit set. Mark such frames as decrypted.
1414 */
1415static void ath10k_wmi_handle_wep_reauth(struct ath10k *ar,
1416 struct sk_buff *skb,
1417 struct ieee80211_rx_status *status)
1418{
1419 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1420 unsigned int hdrlen;
1421 bool peer_key;
1422 u8 *addr, keyidx;
1423
1424 if (!ieee80211_is_auth(hdr->frame_control) ||
1425 !ieee80211_has_protected(hdr->frame_control))
1426 return;
1427
1428 hdrlen = ieee80211_hdrlen(hdr->frame_control);
1429 if (skb->len < (hdrlen + IEEE80211_WEP_IV_LEN))
1430 return;
1431
1432 keyidx = skb->data[hdrlen + (IEEE80211_WEP_IV_LEN - 1)] >> WEP_KEYID_SHIFT;
1433 addr = ieee80211_get_SA(hdr);
1434
1435 spin_lock_bh(&ar->data_lock);
1436 peer_key = ath10k_mac_is_peer_wep_key_set(ar, addr, keyidx);
1437 spin_unlock_bh(&ar->data_lock);
1438
1439 if (peer_key) {
1440 ath10k_dbg(ar, ATH10K_DBG_MAC,
1441 "mac wep key present for peer %pM\n", addr);
1442 status->flag |= RX_FLAG_DECRYPTED;
1443 }
1444}
1445
Michal Kaziord7579d12014-12-03 10:10:54 +02001446static int ath10k_wmi_op_pull_mgmt_rx_ev(struct ath10k *ar, struct sk_buff *skb,
1447 struct wmi_mgmt_rx_ev_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03001448{
Michal Kazior0d9b0432013-08-09 10:13:33 +02001449 struct wmi_mgmt_rx_event_v1 *ev_v1;
1450 struct wmi_mgmt_rx_event_v2 *ev_v2;
1451 struct wmi_mgmt_rx_hdr_v1 *ev_hdr;
Michal Kazior32653cf2014-12-03 10:10:26 +02001452 size_t pull_len;
1453 u32 msdu_len;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001454
Michal Kazior0d9b0432013-08-09 10:13:33 +02001455 if (test_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features)) {
1456 ev_v2 = (struct wmi_mgmt_rx_event_v2 *)skb->data;
1457 ev_hdr = &ev_v2->hdr.v1;
1458 pull_len = sizeof(*ev_v2);
1459 } else {
1460 ev_v1 = (struct wmi_mgmt_rx_event_v1 *)skb->data;
1461 ev_hdr = &ev_v1->hdr;
1462 pull_len = sizeof(*ev_v1);
1463 }
1464
Michal Kazior32653cf2014-12-03 10:10:26 +02001465 if (skb->len < pull_len)
1466 return -EPROTO;
1467
1468 skb_pull(skb, pull_len);
1469 arg->channel = ev_hdr->channel;
1470 arg->buf_len = ev_hdr->buf_len;
1471 arg->status = ev_hdr->status;
1472 arg->snr = ev_hdr->snr;
1473 arg->phy_mode = ev_hdr->phy_mode;
1474 arg->rate = ev_hdr->rate;
1475
1476 msdu_len = __le32_to_cpu(arg->buf_len);
1477 if (skb->len < msdu_len)
1478 return -EPROTO;
1479
1480 /* the WMI buffer might've ended up being padded to 4 bytes due to HTC
1481 * trailer with credit update. Trim the excess garbage.
1482 */
1483 skb_trim(skb, msdu_len);
1484
1485 return 0;
1486}
1487
Michal Kazior0226d602014-12-03 10:11:22 +02001488int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
Michal Kazior32653cf2014-12-03 10:10:26 +02001489{
1490 struct wmi_mgmt_rx_ev_arg arg = {};
1491 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
1492 struct ieee80211_hdr *hdr;
1493 u32 rx_status;
1494 u32 channel;
1495 u32 phy_mode;
1496 u32 snr;
1497 u32 rate;
1498 u32 buf_len;
1499 u16 fc;
1500 int ret;
1501
Michal Kaziord7579d12014-12-03 10:10:54 +02001502 ret = ath10k_wmi_pull_mgmt_rx(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02001503 if (ret) {
1504 ath10k_warn(ar, "failed to parse mgmt rx event: %d\n", ret);
1505 return ret;
1506 }
1507
1508 channel = __le32_to_cpu(arg.channel);
1509 buf_len = __le32_to_cpu(arg.buf_len);
1510 rx_status = __le32_to_cpu(arg.status);
1511 snr = __le32_to_cpu(arg.snr);
1512 phy_mode = __le32_to_cpu(arg.phy_mode);
1513 rate = __le32_to_cpu(arg.rate);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001514
1515 memset(status, 0, sizeof(*status));
1516
Michal Kazior7aa7a722014-08-25 12:09:38 +02001517 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo5e3dd152013-06-12 20:52:10 +03001518 "event mgmt rx status %08x\n", rx_status);
1519
Marek Puzyniake8a50f82013-11-20 09:59:47 +02001520 if (test_bit(ATH10K_CAC_RUNNING, &ar->dev_flags)) {
1521 dev_kfree_skb(skb);
1522 return 0;
1523 }
1524
Kalle Valo5e3dd152013-06-12 20:52:10 +03001525 if (rx_status & WMI_RX_STATUS_ERR_DECRYPT) {
1526 dev_kfree_skb(skb);
1527 return 0;
1528 }
1529
1530 if (rx_status & WMI_RX_STATUS_ERR_KEY_CACHE_MISS) {
1531 dev_kfree_skb(skb);
1532 return 0;
1533 }
1534
Michal Kaziord67d0a02014-11-24 15:34:08 +01001535 if (rx_status & WMI_RX_STATUS_ERR_CRC) {
1536 dev_kfree_skb(skb);
1537 return 0;
1538 }
1539
Kalle Valo5e3dd152013-06-12 20:52:10 +03001540 if (rx_status & WMI_RX_STATUS_ERR_MIC)
1541 status->flag |= RX_FLAG_MMIC_ERROR;
1542
Michal Kazior21040bf2014-10-21 10:10:30 +03001543 /* Hardware can Rx CCK rates on 5GHz. In that case phy_mode is set to
Michal Kazior453cdb62013-12-13 10:44:43 +01001544 * MODE_11B. This means phy_mode is not a reliable source for the band
Michal Kazior21040bf2014-10-21 10:10:30 +03001545 * of mgmt rx.
1546 */
1547 if (channel >= 1 && channel <= 14) {
1548 status->band = IEEE80211_BAND_2GHZ;
1549 } else if (channel >= 36 && channel <= 165) {
1550 status->band = IEEE80211_BAND_5GHZ;
Michal Kazior453cdb62013-12-13 10:44:43 +01001551 } else {
Michal Kazior21040bf2014-10-21 10:10:30 +03001552 /* Shouldn't happen unless list of advertised channels to
1553 * mac80211 has been changed.
1554 */
1555 WARN_ON_ONCE(1);
1556 dev_kfree_skb(skb);
1557 return 0;
Michal Kazior453cdb62013-12-13 10:44:43 +01001558 }
1559
Michal Kazior21040bf2014-10-21 10:10:30 +03001560 if (phy_mode == MODE_11B && status->band == IEEE80211_BAND_5GHZ)
1561 ath10k_dbg(ar, ATH10K_DBG_MGMT, "wmi mgmt rx 11b (CCK) on 5GHz\n");
1562
Kalle Valo5e3dd152013-06-12 20:52:10 +03001563 status->freq = ieee80211_channel_to_frequency(channel, status->band);
1564 status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR;
1565 status->rate_idx = get_rate_idx(rate, status->band);
1566
Kalle Valo5e3dd152013-06-12 20:52:10 +03001567 hdr = (struct ieee80211_hdr *)skb->data;
1568 fc = le16_to_cpu(hdr->frame_control);
1569
Sujith Manoharan504f6cd2014-11-25 11:46:58 +05301570 ath10k_wmi_handle_wep_reauth(ar, skb, status);
1571
Michal Kazior2b6a6a92013-12-05 06:53:41 +01001572 /* FW delivers WEP Shared Auth frame with Protected Bit set and
1573 * encrypted payload. However in case of PMF it delivers decrypted
1574 * frames with Protected Bit set. */
1575 if (ieee80211_has_protected(hdr->frame_control) &&
1576 !ieee80211_is_auth(hdr->frame_control)) {
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03001577 status->flag |= RX_FLAG_DECRYPTED;
1578
1579 if (!ieee80211_is_action(hdr->frame_control) &&
1580 !ieee80211_is_deauth(hdr->frame_control) &&
1581 !ieee80211_is_disassoc(hdr->frame_control)) {
1582 status->flag |= RX_FLAG_IV_STRIPPED |
1583 RX_FLAG_MMIC_STRIPPED;
1584 hdr->frame_control = __cpu_to_le16(fc &
Kalle Valo5e3dd152013-06-12 20:52:10 +03001585 ~IEEE80211_FCTL_PROTECTED);
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03001586 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03001587 }
1588
Michal Kaziorcc9904e2015-03-10 16:22:01 +02001589 if (ieee80211_is_beacon(hdr->frame_control))
1590 ath10k_mac_handle_beacon(ar, skb);
1591
Michal Kazior7aa7a722014-08-25 12:09:38 +02001592 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo5e3dd152013-06-12 20:52:10 +03001593 "event mgmt rx skb %p len %d ftype %02x stype %02x\n",
1594 skb, skb->len,
1595 fc & IEEE80211_FCTL_FTYPE, fc & IEEE80211_FCTL_STYPE);
1596
Michal Kazior7aa7a722014-08-25 12:09:38 +02001597 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo5e3dd152013-06-12 20:52:10 +03001598 "event mgmt rx freq %d band %d snr %d, rate_idx %d\n",
1599 status->freq, status->band, status->signal,
1600 status->rate_idx);
1601
Kalle Valo5e3dd152013-06-12 20:52:10 +03001602 ieee80211_rx(ar->hw, skb);
1603 return 0;
1604}
1605
Michal Kazior2e1dea42013-07-31 10:32:40 +02001606static int freq_to_idx(struct ath10k *ar, int freq)
1607{
1608 struct ieee80211_supported_band *sband;
1609 int band, ch, idx = 0;
1610
1611 for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) {
1612 sband = ar->hw->wiphy->bands[band];
1613 if (!sband)
1614 continue;
1615
1616 for (ch = 0; ch < sband->n_channels; ch++, idx++)
1617 if (sband->channels[ch].center_freq == freq)
1618 goto exit;
1619 }
1620
1621exit:
1622 return idx;
1623}
1624
Michal Kaziord7579d12014-12-03 10:10:54 +02001625static int ath10k_wmi_op_pull_ch_info_ev(struct ath10k *ar, struct sk_buff *skb,
1626 struct wmi_ch_info_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02001627{
1628 struct wmi_chan_info_event *ev = (void *)skb->data;
1629
1630 if (skb->len < sizeof(*ev))
1631 return -EPROTO;
1632
1633 skb_pull(skb, sizeof(*ev));
1634 arg->err_code = ev->err_code;
1635 arg->freq = ev->freq;
1636 arg->cmd_flags = ev->cmd_flags;
1637 arg->noise_floor = ev->noise_floor;
1638 arg->rx_clear_count = ev->rx_clear_count;
1639 arg->cycle_count = ev->cycle_count;
1640
1641 return 0;
1642}
1643
Michal Kazior0226d602014-12-03 10:11:22 +02001644void ath10k_wmi_event_chan_info(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03001645{
Michal Kazior32653cf2014-12-03 10:10:26 +02001646 struct wmi_ch_info_ev_arg arg = {};
Michal Kazior2e1dea42013-07-31 10:32:40 +02001647 struct survey_info *survey;
1648 u32 err_code, freq, cmd_flags, noise_floor, rx_clear_count, cycle_count;
Michal Kazior32653cf2014-12-03 10:10:26 +02001649 int idx, ret;
Michal Kazior2e1dea42013-07-31 10:32:40 +02001650
Michal Kaziord7579d12014-12-03 10:10:54 +02001651 ret = ath10k_wmi_pull_ch_info(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02001652 if (ret) {
1653 ath10k_warn(ar, "failed to parse chan info event: %d\n", ret);
1654 return;
1655 }
Michal Kazior2e1dea42013-07-31 10:32:40 +02001656
Michal Kazior32653cf2014-12-03 10:10:26 +02001657 err_code = __le32_to_cpu(arg.err_code);
1658 freq = __le32_to_cpu(arg.freq);
1659 cmd_flags = __le32_to_cpu(arg.cmd_flags);
1660 noise_floor = __le32_to_cpu(arg.noise_floor);
1661 rx_clear_count = __le32_to_cpu(arg.rx_clear_count);
1662 cycle_count = __le32_to_cpu(arg.cycle_count);
Michal Kazior2e1dea42013-07-31 10:32:40 +02001663
Michal Kazior7aa7a722014-08-25 12:09:38 +02001664 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior2e1dea42013-07-31 10:32:40 +02001665 "chan info err_code %d freq %d cmd_flags %d noise_floor %d rx_clear_count %d cycle_count %d\n",
1666 err_code, freq, cmd_flags, noise_floor, rx_clear_count,
1667 cycle_count);
1668
1669 spin_lock_bh(&ar->data_lock);
1670
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001671 switch (ar->scan.state) {
1672 case ATH10K_SCAN_IDLE:
1673 case ATH10K_SCAN_STARTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02001674 ath10k_warn(ar, "received chan info event without a scan request, ignoring\n");
Michal Kazior2e1dea42013-07-31 10:32:40 +02001675 goto exit;
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001676 case ATH10K_SCAN_RUNNING:
1677 case ATH10K_SCAN_ABORTING:
1678 break;
Michal Kazior2e1dea42013-07-31 10:32:40 +02001679 }
1680
1681 idx = freq_to_idx(ar, freq);
1682 if (idx >= ARRAY_SIZE(ar->survey)) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02001683 ath10k_warn(ar, "chan info: invalid frequency %d (idx %d out of bounds)\n",
Michal Kazior2e1dea42013-07-31 10:32:40 +02001684 freq, idx);
1685 goto exit;
1686 }
1687
1688 if (cmd_flags & WMI_CHAN_INFO_FLAG_COMPLETE) {
1689 /* During scanning chan info is reported twice for each
1690 * visited channel. The reported cycle count is global
1691 * and per-channel cycle count must be calculated */
1692
1693 cycle_count -= ar->survey_last_cycle_count;
1694 rx_clear_count -= ar->survey_last_rx_clear_count;
1695
1696 survey = &ar->survey[idx];
Johannes Berg4ed20be2014-11-14 16:35:34 +01001697 survey->time = WMI_CHAN_INFO_MSEC(cycle_count);
1698 survey->time_rx = WMI_CHAN_INFO_MSEC(rx_clear_count);
Michal Kazior2e1dea42013-07-31 10:32:40 +02001699 survey->noise = noise_floor;
Johannes Berg4ed20be2014-11-14 16:35:34 +01001700 survey->filled = SURVEY_INFO_TIME |
1701 SURVEY_INFO_TIME_RX |
Michal Kazior2e1dea42013-07-31 10:32:40 +02001702 SURVEY_INFO_NOISE_DBM;
1703 }
1704
1705 ar->survey_last_rx_clear_count = rx_clear_count;
1706 ar->survey_last_cycle_count = cycle_count;
1707
1708exit:
1709 spin_unlock_bh(&ar->data_lock);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001710}
1711
Michal Kazior0226d602014-12-03 10:11:22 +02001712void ath10k_wmi_event_echo(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03001713{
Michal Kazior7aa7a722014-08-25 12:09:38 +02001714 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_ECHO_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03001715}
1716
Michal Kazior0226d602014-12-03 10:11:22 +02001717int ath10k_wmi_event_debug_mesg(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03001718{
Michal Kazior7aa7a722014-08-25 12:09:38 +02001719 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event debug mesg len %d\n",
Kalle Valo869526b2014-01-03 12:59:26 +02001720 skb->len);
1721
Michal Kaziord35a6c12014-09-02 11:00:21 +03001722 trace_ath10k_wmi_dbglog(ar, skb->data, skb->len);
Kalle Valo869526b2014-01-03 12:59:26 +02001723
1724 return 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001725}
1726
Michal Kaziorb91251f2015-01-24 12:14:49 +02001727void ath10k_wmi_pull_pdev_stats_base(const struct wmi_pdev_stats_base *src,
1728 struct ath10k_fw_stats_pdev *dst)
Michal Kaziord15fb522014-09-25 12:33:47 +02001729{
Michal Kaziord15fb522014-09-25 12:33:47 +02001730 dst->ch_noise_floor = __le32_to_cpu(src->chan_nf);
1731 dst->tx_frame_count = __le32_to_cpu(src->tx_frame_count);
1732 dst->rx_frame_count = __le32_to_cpu(src->rx_frame_count);
1733 dst->rx_clear_count = __le32_to_cpu(src->rx_clear_count);
1734 dst->cycle_count = __le32_to_cpu(src->cycle_count);
1735 dst->phy_err_count = __le32_to_cpu(src->phy_err_count);
1736 dst->chan_tx_power = __le32_to_cpu(src->chan_tx_pwr);
Michal Kaziorb91251f2015-01-24 12:14:49 +02001737}
Michal Kaziord15fb522014-09-25 12:33:47 +02001738
Michal Kaziorb91251f2015-01-24 12:14:49 +02001739void ath10k_wmi_pull_pdev_stats_tx(const struct wmi_pdev_stats_tx *src,
1740 struct ath10k_fw_stats_pdev *dst)
1741{
1742 dst->comp_queued = __le32_to_cpu(src->comp_queued);
1743 dst->comp_delivered = __le32_to_cpu(src->comp_delivered);
1744 dst->msdu_enqued = __le32_to_cpu(src->msdu_enqued);
1745 dst->mpdu_enqued = __le32_to_cpu(src->mpdu_enqued);
1746 dst->wmm_drop = __le32_to_cpu(src->wmm_drop);
1747 dst->local_enqued = __le32_to_cpu(src->local_enqued);
1748 dst->local_freed = __le32_to_cpu(src->local_freed);
1749 dst->hw_queued = __le32_to_cpu(src->hw_queued);
1750 dst->hw_reaped = __le32_to_cpu(src->hw_reaped);
1751 dst->underrun = __le32_to_cpu(src->underrun);
1752 dst->tx_abort = __le32_to_cpu(src->tx_abort);
1753 dst->mpdus_requed = __le32_to_cpu(src->mpdus_requed);
1754 dst->tx_ko = __le32_to_cpu(src->tx_ko);
1755 dst->data_rc = __le32_to_cpu(src->data_rc);
1756 dst->self_triggers = __le32_to_cpu(src->self_triggers);
1757 dst->sw_retry_failure = __le32_to_cpu(src->sw_retry_failure);
1758 dst->illgl_rate_phy_err = __le32_to_cpu(src->illgl_rate_phy_err);
1759 dst->pdev_cont_xretry = __le32_to_cpu(src->pdev_cont_xretry);
1760 dst->pdev_tx_timeout = __le32_to_cpu(src->pdev_tx_timeout);
1761 dst->pdev_resets = __le32_to_cpu(src->pdev_resets);
1762 dst->phy_underrun = __le32_to_cpu(src->phy_underrun);
1763 dst->txop_ovf = __le32_to_cpu(src->txop_ovf);
1764}
Michal Kaziord15fb522014-09-25 12:33:47 +02001765
Michal Kaziorb91251f2015-01-24 12:14:49 +02001766void ath10k_wmi_pull_pdev_stats_rx(const struct wmi_pdev_stats_rx *src,
1767 struct ath10k_fw_stats_pdev *dst)
1768{
1769 dst->mid_ppdu_route_change = __le32_to_cpu(src->mid_ppdu_route_change);
1770 dst->status_rcvd = __le32_to_cpu(src->status_rcvd);
1771 dst->r0_frags = __le32_to_cpu(src->r0_frags);
1772 dst->r1_frags = __le32_to_cpu(src->r1_frags);
1773 dst->r2_frags = __le32_to_cpu(src->r2_frags);
1774 dst->r3_frags = __le32_to_cpu(src->r3_frags);
1775 dst->htt_msdus = __le32_to_cpu(src->htt_msdus);
1776 dst->htt_mpdus = __le32_to_cpu(src->htt_mpdus);
1777 dst->loc_msdus = __le32_to_cpu(src->loc_msdus);
1778 dst->loc_mpdus = __le32_to_cpu(src->loc_mpdus);
1779 dst->oversize_amsdu = __le32_to_cpu(src->oversize_amsdu);
1780 dst->phy_errs = __le32_to_cpu(src->phy_errs);
1781 dst->phy_err_drop = __le32_to_cpu(src->phy_err_drop);
1782 dst->mpdu_errs = __le32_to_cpu(src->mpdu_errs);
1783}
1784
1785void ath10k_wmi_pull_pdev_stats_extra(const struct wmi_pdev_stats_extra *src,
1786 struct ath10k_fw_stats_pdev *dst)
1787{
1788 dst->ack_rx_bad = __le32_to_cpu(src->ack_rx_bad);
1789 dst->rts_bad = __le32_to_cpu(src->rts_bad);
1790 dst->rts_good = __le32_to_cpu(src->rts_good);
1791 dst->fcs_bad = __le32_to_cpu(src->fcs_bad);
1792 dst->no_beacons = __le32_to_cpu(src->no_beacons);
1793 dst->mib_int_count = __le32_to_cpu(src->mib_int_count);
Michal Kaziord15fb522014-09-25 12:33:47 +02001794}
1795
Michal Kazior0226d602014-12-03 10:11:22 +02001796void ath10k_wmi_pull_peer_stats(const struct wmi_peer_stats *src,
1797 struct ath10k_fw_stats_peer *dst)
Michal Kaziord15fb522014-09-25 12:33:47 +02001798{
1799 ether_addr_copy(dst->peer_macaddr, src->peer_macaddr.addr);
1800 dst->peer_rssi = __le32_to_cpu(src->peer_rssi);
1801 dst->peer_tx_rate = __le32_to_cpu(src->peer_tx_rate);
1802}
1803
Michal Kaziord7579d12014-12-03 10:10:54 +02001804static int ath10k_wmi_main_op_pull_fw_stats(struct ath10k *ar,
1805 struct sk_buff *skb,
1806 struct ath10k_fw_stats *stats)
Michal Kaziord15fb522014-09-25 12:33:47 +02001807{
1808 const struct wmi_stats_event *ev = (void *)skb->data;
1809 u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
1810 int i;
1811
1812 if (!skb_pull(skb, sizeof(*ev)))
1813 return -EPROTO;
1814
1815 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
1816 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
1817 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
1818
Michal Kazior53268492014-09-25 12:33:50 +02001819 for (i = 0; i < num_pdev_stats; i++) {
Michal Kaziord15fb522014-09-25 12:33:47 +02001820 const struct wmi_pdev_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02001821 struct ath10k_fw_stats_pdev *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02001822
1823 src = (void *)skb->data;
1824 if (!skb_pull(skb, sizeof(*src)))
1825 return -EPROTO;
1826
Michal Kazior53268492014-09-25 12:33:50 +02001827 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1828 if (!dst)
1829 continue;
1830
Michal Kaziorb91251f2015-01-24 12:14:49 +02001831 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
1832 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
1833 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
1834
Michal Kazior53268492014-09-25 12:33:50 +02001835 list_add_tail(&dst->list, &stats->pdevs);
Michal Kaziord15fb522014-09-25 12:33:47 +02001836 }
1837
1838 /* fw doesn't implement vdev stats */
1839
1840 for (i = 0; i < num_peer_stats; i++) {
1841 const struct wmi_peer_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02001842 struct ath10k_fw_stats_peer *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02001843
1844 src = (void *)skb->data;
1845 if (!skb_pull(skb, sizeof(*src)))
1846 return -EPROTO;
1847
Michal Kazior53268492014-09-25 12:33:50 +02001848 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1849 if (!dst)
1850 continue;
1851
1852 ath10k_wmi_pull_peer_stats(src, dst);
1853 list_add_tail(&dst->list, &stats->peers);
Michal Kaziord15fb522014-09-25 12:33:47 +02001854 }
1855
1856 return 0;
1857}
1858
Michal Kaziord7579d12014-12-03 10:10:54 +02001859static int ath10k_wmi_10x_op_pull_fw_stats(struct ath10k *ar,
1860 struct sk_buff *skb,
1861 struct ath10k_fw_stats *stats)
Michal Kaziord15fb522014-09-25 12:33:47 +02001862{
1863 const struct wmi_stats_event *ev = (void *)skb->data;
1864 u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
1865 int i;
1866
1867 if (!skb_pull(skb, sizeof(*ev)))
1868 return -EPROTO;
1869
1870 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
1871 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
1872 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
1873
Michal Kazior53268492014-09-25 12:33:50 +02001874 for (i = 0; i < num_pdev_stats; i++) {
Michal Kaziord15fb522014-09-25 12:33:47 +02001875 const struct wmi_10x_pdev_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02001876 struct ath10k_fw_stats_pdev *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02001877
1878 src = (void *)skb->data;
1879 if (!skb_pull(skb, sizeof(*src)))
1880 return -EPROTO;
1881
Michal Kazior53268492014-09-25 12:33:50 +02001882 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1883 if (!dst)
1884 continue;
Michal Kaziord15fb522014-09-25 12:33:47 +02001885
Michal Kaziorb91251f2015-01-24 12:14:49 +02001886 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
1887 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
1888 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
1889 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
Michal Kazior53268492014-09-25 12:33:50 +02001890
1891 list_add_tail(&dst->list, &stats->pdevs);
Michal Kaziord15fb522014-09-25 12:33:47 +02001892 }
1893
1894 /* fw doesn't implement vdev stats */
1895
1896 for (i = 0; i < num_peer_stats; i++) {
1897 const struct wmi_10x_peer_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02001898 struct ath10k_fw_stats_peer *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02001899
1900 src = (void *)skb->data;
1901 if (!skb_pull(skb, sizeof(*src)))
1902 return -EPROTO;
1903
Michal Kazior53268492014-09-25 12:33:50 +02001904 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1905 if (!dst)
1906 continue;
Michal Kaziord15fb522014-09-25 12:33:47 +02001907
Michal Kazior53268492014-09-25 12:33:50 +02001908 ath10k_wmi_pull_peer_stats(&src->old, dst);
1909
1910 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
1911
1912 list_add_tail(&dst->list, &stats->peers);
Michal Kaziord15fb522014-09-25 12:33:47 +02001913 }
1914
1915 return 0;
1916}
1917
Michal Kazior20de2222015-01-24 12:14:49 +02001918static int ath10k_wmi_10_2_op_pull_fw_stats(struct ath10k *ar,
1919 struct sk_buff *skb,
1920 struct ath10k_fw_stats *stats)
1921{
1922 const struct wmi_10_2_stats_event *ev = (void *)skb->data;
1923 u32 num_pdev_stats;
1924 u32 num_pdev_ext_stats;
1925 u32 num_vdev_stats;
1926 u32 num_peer_stats;
1927 int i;
1928
1929 if (!skb_pull(skb, sizeof(*ev)))
1930 return -EPROTO;
1931
1932 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
1933 num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
1934 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
1935 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
1936
1937 for (i = 0; i < num_pdev_stats; i++) {
1938 const struct wmi_10_2_pdev_stats *src;
1939 struct ath10k_fw_stats_pdev *dst;
1940
1941 src = (void *)skb->data;
1942 if (!skb_pull(skb, sizeof(*src)))
1943 return -EPROTO;
1944
1945 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1946 if (!dst)
1947 continue;
1948
1949 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
1950 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
1951 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
1952 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
1953 /* FIXME: expose 10.2 specific values */
1954
1955 list_add_tail(&dst->list, &stats->pdevs);
1956 }
1957
1958 for (i = 0; i < num_pdev_ext_stats; i++) {
1959 const struct wmi_10_2_pdev_ext_stats *src;
1960
1961 src = (void *)skb->data;
1962 if (!skb_pull(skb, sizeof(*src)))
1963 return -EPROTO;
1964
1965 /* FIXME: expose values to userspace
1966 *
1967 * Note: Even though this loop seems to do nothing it is
1968 * required to parse following sub-structures properly.
1969 */
1970 }
1971
1972 /* fw doesn't implement vdev stats */
1973
1974 for (i = 0; i < num_peer_stats; i++) {
1975 const struct wmi_10_2_peer_stats *src;
1976 struct ath10k_fw_stats_peer *dst;
1977
1978 src = (void *)skb->data;
1979 if (!skb_pull(skb, sizeof(*src)))
1980 return -EPROTO;
1981
1982 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1983 if (!dst)
1984 continue;
1985
1986 ath10k_wmi_pull_peer_stats(&src->old, dst);
1987
1988 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
1989 /* FIXME: expose 10.2 specific values */
1990
1991 list_add_tail(&dst->list, &stats->peers);
1992 }
1993
1994 return 0;
1995}
1996
1997static int ath10k_wmi_10_2_4_op_pull_fw_stats(struct ath10k *ar,
1998 struct sk_buff *skb,
1999 struct ath10k_fw_stats *stats)
2000{
2001 const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2002 u32 num_pdev_stats;
2003 u32 num_pdev_ext_stats;
2004 u32 num_vdev_stats;
2005 u32 num_peer_stats;
2006 int i;
2007
2008 if (!skb_pull(skb, sizeof(*ev)))
2009 return -EPROTO;
2010
2011 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2012 num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
2013 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2014 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2015
2016 for (i = 0; i < num_pdev_stats; i++) {
2017 const struct wmi_10_2_pdev_stats *src;
2018 struct ath10k_fw_stats_pdev *dst;
2019
2020 src = (void *)skb->data;
2021 if (!skb_pull(skb, sizeof(*src)))
2022 return -EPROTO;
2023
2024 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2025 if (!dst)
2026 continue;
2027
2028 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2029 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2030 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2031 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2032 /* FIXME: expose 10.2 specific values */
2033
2034 list_add_tail(&dst->list, &stats->pdevs);
2035 }
2036
2037 for (i = 0; i < num_pdev_ext_stats; i++) {
2038 const struct wmi_10_2_pdev_ext_stats *src;
2039
2040 src = (void *)skb->data;
2041 if (!skb_pull(skb, sizeof(*src)))
2042 return -EPROTO;
2043
2044 /* FIXME: expose values to userspace
2045 *
2046 * Note: Even though this loop seems to do nothing it is
2047 * required to parse following sub-structures properly.
2048 */
2049 }
2050
2051 /* fw doesn't implement vdev stats */
2052
2053 for (i = 0; i < num_peer_stats; i++) {
2054 const struct wmi_10_2_4_peer_stats *src;
2055 struct ath10k_fw_stats_peer *dst;
2056
2057 src = (void *)skb->data;
2058 if (!skb_pull(skb, sizeof(*src)))
2059 return -EPROTO;
2060
2061 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2062 if (!dst)
2063 continue;
2064
2065 ath10k_wmi_pull_peer_stats(&src->common.old, dst);
2066
2067 dst->peer_rx_rate = __le32_to_cpu(src->common.peer_rx_rate);
2068 /* FIXME: expose 10.2 specific values */
2069
2070 list_add_tail(&dst->list, &stats->peers);
2071 }
2072
2073 return 0;
2074}
2075
Michal Kazior0226d602014-12-03 10:11:22 +02002076void ath10k_wmi_event_update_stats(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002077{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002078 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_UPDATE_STATS_EVENTID\n");
Michal Kazior60ef4012014-09-25 12:33:48 +02002079 ath10k_debug_fw_stats_process(ar, skb);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002080}
2081
Michal Kaziord7579d12014-12-03 10:10:54 +02002082static int
2083ath10k_wmi_op_pull_vdev_start_ev(struct ath10k *ar, struct sk_buff *skb,
2084 struct wmi_vdev_start_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02002085{
2086 struct wmi_vdev_start_response_event *ev = (void *)skb->data;
2087
2088 if (skb->len < sizeof(*ev))
2089 return -EPROTO;
2090
2091 skb_pull(skb, sizeof(*ev));
2092 arg->vdev_id = ev->vdev_id;
2093 arg->req_id = ev->req_id;
2094 arg->resp_type = ev->resp_type;
2095 arg->status = ev->status;
2096
2097 return 0;
2098}
2099
Michal Kazior0226d602014-12-03 10:11:22 +02002100void ath10k_wmi_event_vdev_start_resp(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002101{
Michal Kazior32653cf2014-12-03 10:10:26 +02002102 struct wmi_vdev_start_ev_arg arg = {};
2103 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002104
Michal Kazior7aa7a722014-08-25 12:09:38 +02002105 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_START_RESP_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002106
Michal Kaziord7579d12014-12-03 10:10:54 +02002107 ret = ath10k_wmi_pull_vdev_start(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02002108 if (ret) {
2109 ath10k_warn(ar, "failed to parse vdev start event: %d\n", ret);
2110 return;
2111 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03002112
Michal Kazior32653cf2014-12-03 10:10:26 +02002113 if (WARN_ON(__le32_to_cpu(arg.status)))
Kalle Valo5e3dd152013-06-12 20:52:10 +03002114 return;
2115
2116 complete(&ar->vdev_setup_done);
2117}
2118
Michal Kazior0226d602014-12-03 10:11:22 +02002119void ath10k_wmi_event_vdev_stopped(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002120{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002121 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STOPPED_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002122 complete(&ar->vdev_setup_done);
2123}
2124
Michal Kaziord7579d12014-12-03 10:10:54 +02002125static int
2126ath10k_wmi_op_pull_peer_kick_ev(struct ath10k *ar, struct sk_buff *skb,
2127 struct wmi_peer_kick_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02002128{
2129 struct wmi_peer_sta_kickout_event *ev = (void *)skb->data;
2130
2131 if (skb->len < sizeof(*ev))
2132 return -EPROTO;
2133
2134 skb_pull(skb, sizeof(*ev));
2135 arg->mac_addr = ev->peer_macaddr.addr;
2136
2137 return 0;
2138}
2139
Michal Kazior0226d602014-12-03 10:11:22 +02002140void ath10k_wmi_event_peer_sta_kickout(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002141{
Michal Kazior32653cf2014-12-03 10:10:26 +02002142 struct wmi_peer_kick_ev_arg arg = {};
Kalle Valo5a13e762014-01-20 11:01:46 +02002143 struct ieee80211_sta *sta;
Michal Kazior32653cf2014-12-03 10:10:26 +02002144 int ret;
Kalle Valo5a13e762014-01-20 11:01:46 +02002145
Michal Kaziord7579d12014-12-03 10:10:54 +02002146 ret = ath10k_wmi_pull_peer_kick(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02002147 if (ret) {
2148 ath10k_warn(ar, "failed to parse peer kickout event: %d\n",
2149 ret);
2150 return;
2151 }
Kalle Valo5a13e762014-01-20 11:01:46 +02002152
Michal Kazior7aa7a722014-08-25 12:09:38 +02002153 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event peer sta kickout %pM\n",
Michal Kazior32653cf2014-12-03 10:10:26 +02002154 arg.mac_addr);
Kalle Valo5a13e762014-01-20 11:01:46 +02002155
2156 rcu_read_lock();
2157
Michal Kazior32653cf2014-12-03 10:10:26 +02002158 sta = ieee80211_find_sta_by_ifaddr(ar->hw, arg.mac_addr, NULL);
Kalle Valo5a13e762014-01-20 11:01:46 +02002159 if (!sta) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002160 ath10k_warn(ar, "Spurious quick kickout for STA %pM\n",
Michal Kazior32653cf2014-12-03 10:10:26 +02002161 arg.mac_addr);
Kalle Valo5a13e762014-01-20 11:01:46 +02002162 goto exit;
2163 }
2164
2165 ieee80211_report_low_ack(sta, 10);
2166
2167exit:
2168 rcu_read_unlock();
Kalle Valo5e3dd152013-06-12 20:52:10 +03002169}
2170
2171/*
2172 * FIXME
2173 *
2174 * We don't report to mac80211 sleep state of connected
2175 * stations. Due to this mac80211 can't fill in TIM IE
2176 * correctly.
2177 *
2178 * I know of no way of getting nullfunc frames that contain
2179 * sleep transition from connected stations - these do not
2180 * seem to be sent from the target to the host. There also
2181 * doesn't seem to be a dedicated event for that. So the
2182 * only way left to do this would be to read tim_bitmap
2183 * during SWBA.
2184 *
2185 * We could probably try using tim_bitmap from SWBA to tell
2186 * mac80211 which stations are asleep and which are not. The
2187 * problem here is calling mac80211 functions so many times
2188 * could take too long and make us miss the time to submit
2189 * the beacon to the target.
2190 *
2191 * So as a workaround we try to extend the TIM IE if there
2192 * is unicast buffered for stations with aid > 7 and fill it
2193 * in ourselves.
2194 */
2195static void ath10k_wmi_update_tim(struct ath10k *ar,
2196 struct ath10k_vif *arvif,
2197 struct sk_buff *bcn,
Michal Kazior32653cf2014-12-03 10:10:26 +02002198 const struct wmi_tim_info *tim_info)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002199{
2200 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)bcn->data;
2201 struct ieee80211_tim_ie *tim;
2202 u8 *ies, *ie;
2203 u8 ie_len, pvm_len;
Kalle Valoaf762c02014-09-14 12:50:17 +03002204 __le32 t;
2205 u32 v;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002206
2207 /* if next SWBA has no tim_changed the tim_bitmap is garbage.
2208 * we must copy the bitmap upon change and reuse it later */
Michal Kazior32653cf2014-12-03 10:10:26 +02002209 if (__le32_to_cpu(tim_info->tim_changed)) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03002210 int i;
2211
2212 BUILD_BUG_ON(sizeof(arvif->u.ap.tim_bitmap) !=
Michal Kazior32653cf2014-12-03 10:10:26 +02002213 sizeof(tim_info->tim_bitmap));
Kalle Valo5e3dd152013-06-12 20:52:10 +03002214
2215 for (i = 0; i < sizeof(arvif->u.ap.tim_bitmap); i++) {
Michal Kazior32653cf2014-12-03 10:10:26 +02002216 t = tim_info->tim_bitmap[i / 4];
Kalle Valoaf762c02014-09-14 12:50:17 +03002217 v = __le32_to_cpu(t);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002218 arvif->u.ap.tim_bitmap[i] = (v >> ((i % 4) * 8)) & 0xFF;
2219 }
2220
2221 /* FW reports either length 0 or 16
2222 * so we calculate this on our own */
2223 arvif->u.ap.tim_len = 0;
2224 for (i = 0; i < sizeof(arvif->u.ap.tim_bitmap); i++)
2225 if (arvif->u.ap.tim_bitmap[i])
2226 arvif->u.ap.tim_len = i;
2227
2228 arvif->u.ap.tim_len++;
2229 }
2230
2231 ies = bcn->data;
2232 ies += ieee80211_hdrlen(hdr->frame_control);
2233 ies += 12; /* fixed parameters */
2234
2235 ie = (u8 *)cfg80211_find_ie(WLAN_EID_TIM, ies,
2236 (u8 *)skb_tail_pointer(bcn) - ies);
2237 if (!ie) {
Michal Kazior09af8f82013-07-05 16:15:08 +03002238 if (arvif->vdev_type != WMI_VDEV_TYPE_IBSS)
Michal Kazior7aa7a722014-08-25 12:09:38 +02002239 ath10k_warn(ar, "no tim ie found;\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002240 return;
2241 }
2242
2243 tim = (void *)ie + 2;
2244 ie_len = ie[1];
2245 pvm_len = ie_len - 3; /* exclude dtim count, dtim period, bmap ctl */
2246
2247 if (pvm_len < arvif->u.ap.tim_len) {
2248 int expand_size = sizeof(arvif->u.ap.tim_bitmap) - pvm_len;
2249 int move_size = skb_tail_pointer(bcn) - (ie + 2 + ie_len);
2250 void *next_ie = ie + 2 + ie_len;
2251
2252 if (skb_put(bcn, expand_size)) {
2253 memmove(next_ie + expand_size, next_ie, move_size);
2254
2255 ie[1] += expand_size;
2256 ie_len += expand_size;
2257 pvm_len += expand_size;
2258 } else {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002259 ath10k_warn(ar, "tim expansion failed\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002260 }
2261 }
2262
2263 if (pvm_len > sizeof(arvif->u.ap.tim_bitmap)) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002264 ath10k_warn(ar, "tim pvm length is too great (%d)\n", pvm_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002265 return;
2266 }
2267
Michal Kazior32653cf2014-12-03 10:10:26 +02002268 tim->bitmap_ctrl = !!__le32_to_cpu(tim_info->tim_mcast);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002269 memcpy(tim->virtual_map, arvif->u.ap.tim_bitmap, pvm_len);
2270
Michal Kazior748afc42014-01-23 12:48:21 +01002271 if (tim->dtim_count == 0) {
2272 ATH10K_SKB_CB(bcn)->bcn.dtim_zero = true;
2273
Michal Kazior32653cf2014-12-03 10:10:26 +02002274 if (__le32_to_cpu(tim_info->tim_mcast) == 1)
Michal Kazior748afc42014-01-23 12:48:21 +01002275 ATH10K_SKB_CB(bcn)->bcn.deliver_cab = true;
2276 }
2277
Michal Kazior7aa7a722014-08-25 12:09:38 +02002278 ath10k_dbg(ar, ATH10K_DBG_MGMT, "dtim %d/%d mcast %d pvmlen %d\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +03002279 tim->dtim_count, tim->dtim_period,
2280 tim->bitmap_ctrl, pvm_len);
2281}
2282
Kalle Valo5e3dd152013-06-12 20:52:10 +03002283static void ath10k_wmi_update_noa(struct ath10k *ar, struct ath10k_vif *arvif,
2284 struct sk_buff *bcn,
Michal Kazior32653cf2014-12-03 10:10:26 +02002285 const struct wmi_p2p_noa_info *noa)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002286{
Kalle Valo5e3dd152013-06-12 20:52:10 +03002287 if (arvif->vdev_subtype != WMI_VDEV_SUBTYPE_P2P_GO)
2288 return;
2289
Michal Kazior7aa7a722014-08-25 12:09:38 +02002290 ath10k_dbg(ar, ATH10K_DBG_MGMT, "noa changed: %d\n", noa->changed);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002291
Michal Kazior6a948882015-02-26 13:23:17 +01002292 if (noa->changed & WMI_P2P_NOA_CHANGED_BIT)
2293 ath10k_p2p_noa_update(arvif, noa);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002294
2295 if (arvif->u.ap.noa_data)
2296 if (!pskb_expand_head(bcn, 0, arvif->u.ap.noa_len, GFP_ATOMIC))
2297 memcpy(skb_put(bcn, arvif->u.ap.noa_len),
2298 arvif->u.ap.noa_data,
2299 arvif->u.ap.noa_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002300
Michal Kazior6a948882015-02-26 13:23:17 +01002301 return;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002302}
2303
Michal Kaziord7579d12014-12-03 10:10:54 +02002304static int ath10k_wmi_op_pull_swba_ev(struct ath10k *ar, struct sk_buff *skb,
2305 struct wmi_swba_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02002306{
2307 struct wmi_host_swba_event *ev = (void *)skb->data;
2308 u32 map;
2309 size_t i;
2310
2311 if (skb->len < sizeof(*ev))
2312 return -EPROTO;
2313
2314 skb_pull(skb, sizeof(*ev));
2315 arg->vdev_map = ev->vdev_map;
2316
2317 for (i = 0, map = __le32_to_cpu(ev->vdev_map); map; map >>= 1) {
2318 if (!(map & BIT(0)))
2319 continue;
2320
2321 /* If this happens there were some changes in firmware and
2322 * ath10k should update the max size of tim_info array.
2323 */
2324 if (WARN_ON_ONCE(i == ARRAY_SIZE(arg->tim_info)))
2325 break;
2326
2327 arg->tim_info[i] = &ev->bcn_info[i].tim_info;
2328 arg->noa_info[i] = &ev->bcn_info[i].p2p_noa_info;
2329 i++;
2330 }
2331
2332 return 0;
2333}
2334
Michal Kazior0226d602014-12-03 10:11:22 +02002335void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002336{
Michal Kazior32653cf2014-12-03 10:10:26 +02002337 struct wmi_swba_ev_arg arg = {};
Kalle Valo5e3dd152013-06-12 20:52:10 +03002338 u32 map;
2339 int i = -1;
Michal Kazior32653cf2014-12-03 10:10:26 +02002340 const struct wmi_tim_info *tim_info;
2341 const struct wmi_p2p_noa_info *noa_info;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002342 struct ath10k_vif *arvif;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002343 struct sk_buff *bcn;
Michal Kazior64badcb2014-09-18 11:18:02 +03002344 dma_addr_t paddr;
Michal Kazior767d34f2014-02-27 18:50:03 +02002345 int ret, vdev_id = 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002346
Michal Kaziord7579d12014-12-03 10:10:54 +02002347 ret = ath10k_wmi_pull_swba(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02002348 if (ret) {
2349 ath10k_warn(ar, "failed to parse swba event: %d\n", ret);
2350 return;
2351 }
2352
2353 map = __le32_to_cpu(arg.vdev_map);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002354
Michal Kazior7aa7a722014-08-25 12:09:38 +02002355 ath10k_dbg(ar, ATH10K_DBG_MGMT, "mgmt swba vdev_map 0x%x\n",
Michal Kazior32653cf2014-12-03 10:10:26 +02002356 map);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002357
2358 for (; map; map >>= 1, vdev_id++) {
2359 if (!(map & 0x1))
2360 continue;
2361
2362 i++;
2363
2364 if (i >= WMI_MAX_AP_VDEV) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002365 ath10k_warn(ar, "swba has corrupted vdev map\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002366 break;
2367 }
2368
Michal Kazior32653cf2014-12-03 10:10:26 +02002369 tim_info = arg.tim_info[i];
2370 noa_info = arg.noa_info[i];
Kalle Valo5e3dd152013-06-12 20:52:10 +03002371
Michal Kazior7aa7a722014-08-25 12:09:38 +02002372 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo7a8a3962014-03-28 14:35:16 +02002373 "mgmt event bcn_info %d tim_len %d mcast %d changed %d num_ps_pending %d bitmap 0x%08x%08x%08x%08x\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +03002374 i,
Michal Kazior32653cf2014-12-03 10:10:26 +02002375 __le32_to_cpu(tim_info->tim_len),
2376 __le32_to_cpu(tim_info->tim_mcast),
2377 __le32_to_cpu(tim_info->tim_changed),
2378 __le32_to_cpu(tim_info->tim_num_ps_pending),
2379 __le32_to_cpu(tim_info->tim_bitmap[3]),
2380 __le32_to_cpu(tim_info->tim_bitmap[2]),
2381 __le32_to_cpu(tim_info->tim_bitmap[1]),
2382 __le32_to_cpu(tim_info->tim_bitmap[0]));
Kalle Valo5e3dd152013-06-12 20:52:10 +03002383
2384 arvif = ath10k_get_arvif(ar, vdev_id);
2385 if (arvif == NULL) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002386 ath10k_warn(ar, "no vif for vdev_id %d found\n",
2387 vdev_id);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002388 continue;
2389 }
2390
Michal Kaziorc2df44b2014-01-23 11:38:26 +01002391 /* There are no completions for beacons so wait for next SWBA
2392 * before telling mac80211 to decrement CSA counter
2393 *
2394 * Once CSA counter is completed stop sending beacons until
2395 * actual channel switch is done */
2396 if (arvif->vif->csa_active &&
2397 ieee80211_csa_is_complete(arvif->vif)) {
2398 ieee80211_csa_finish(arvif->vif);
2399 continue;
2400 }
2401
Kalle Valo5e3dd152013-06-12 20:52:10 +03002402 bcn = ieee80211_beacon_get(ar->hw, arvif->vif);
2403 if (!bcn) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002404 ath10k_warn(ar, "could not get mac80211 beacon\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002405 continue;
2406 }
2407
Michal Kazior4b604552014-07-21 21:03:09 +03002408 ath10k_tx_h_seq_no(arvif->vif, bcn);
Michal Kazior32653cf2014-12-03 10:10:26 +02002409 ath10k_wmi_update_tim(ar, arvif, bcn, tim_info);
2410 ath10k_wmi_update_noa(ar, arvif, bcn, noa_info);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002411
Michal Kaziored543882013-09-13 14:16:56 +02002412 spin_lock_bh(&ar->data_lock);
Michal Kazior748afc42014-01-23 12:48:21 +01002413
Michal Kaziored543882013-09-13 14:16:56 +02002414 if (arvif->beacon) {
Michal Kazioraf213192015-01-29 14:29:52 +02002415 switch (arvif->beacon_state) {
2416 case ATH10K_BEACON_SENT:
2417 break;
2418 case ATH10K_BEACON_SCHEDULED:
2419 ath10k_warn(ar, "SWBA overrun on vdev %d, skipped old beacon\n",
Michal Kazior748afc42014-01-23 12:48:21 +01002420 arvif->vdev_id);
Michal Kazioraf213192015-01-29 14:29:52 +02002421 break;
2422 case ATH10K_BEACON_SENDING:
2423 ath10k_warn(ar, "SWBA overrun on vdev %d, skipped new beacon\n",
2424 arvif->vdev_id);
2425 dev_kfree_skb(bcn);
2426 goto skip;
2427 }
Michal Kazior748afc42014-01-23 12:48:21 +01002428
Michal Kazior64badcb2014-09-18 11:18:02 +03002429 ath10k_mac_vif_beacon_free(arvif);
Michal Kaziored543882013-09-13 14:16:56 +02002430 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03002431
Michal Kazior64badcb2014-09-18 11:18:02 +03002432 if (!arvif->beacon_buf) {
2433 paddr = dma_map_single(arvif->ar->dev, bcn->data,
2434 bcn->len, DMA_TO_DEVICE);
2435 ret = dma_mapping_error(arvif->ar->dev, paddr);
2436 if (ret) {
2437 ath10k_warn(ar, "failed to map beacon: %d\n",
2438 ret);
2439 dev_kfree_skb_any(bcn);
2440 goto skip;
2441 }
2442
2443 ATH10K_SKB_CB(bcn)->paddr = paddr;
2444 } else {
2445 if (bcn->len > IEEE80211_MAX_FRAME_LEN) {
2446 ath10k_warn(ar, "trimming beacon %d -> %d bytes!\n",
2447 bcn->len, IEEE80211_MAX_FRAME_LEN);
2448 skb_trim(bcn, IEEE80211_MAX_FRAME_LEN);
2449 }
2450 memcpy(arvif->beacon_buf, bcn->data, bcn->len);
2451 ATH10K_SKB_CB(bcn)->paddr = arvif->beacon_paddr;
Michal Kazior767d34f2014-02-27 18:50:03 +02002452 }
Michal Kazior748afc42014-01-23 12:48:21 +01002453
Michal Kaziored543882013-09-13 14:16:56 +02002454 arvif->beacon = bcn;
Michal Kazioraf213192015-01-29 14:29:52 +02002455 arvif->beacon_state = ATH10K_BEACON_SCHEDULED;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002456
Rajkumar Manoharan5ce8e7f2014-11-05 19:14:31 +05302457 trace_ath10k_tx_hdr(ar, bcn->data, bcn->len);
2458 trace_ath10k_tx_payload(ar, bcn->data, bcn->len);
2459
Michal Kazior767d34f2014-02-27 18:50:03 +02002460skip:
Michal Kaziored543882013-09-13 14:16:56 +02002461 spin_unlock_bh(&ar->data_lock);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002462 }
Michal Kazioraf213192015-01-29 14:29:52 +02002463
2464 ath10k_wmi_tx_beacons_nowait(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002465}
2466
Michal Kazior0226d602014-12-03 10:11:22 +02002467void ath10k_wmi_event_tbttoffset_update(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002468{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002469 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TBTTOFFSET_UPDATE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002470}
2471
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002472static void ath10k_dfs_radar_report(struct ath10k *ar,
Michal Kazior2332d0a2014-09-18 15:21:25 +02002473 const struct wmi_phyerr *phyerr,
2474 const struct phyerr_radar_report *rr,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002475 u64 tsf)
2476{
2477 u32 reg0, reg1, tsf32l;
2478 struct pulse_event pe;
2479 u64 tsf64;
2480 u8 rssi, width;
2481
2482 reg0 = __le32_to_cpu(rr->reg0);
2483 reg1 = __le32_to_cpu(rr->reg1);
2484
Michal Kazior7aa7a722014-08-25 12:09:38 +02002485 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002486 "wmi phyerr radar report chirp %d max_width %d agc_total_gain %d pulse_delta_diff %d\n",
2487 MS(reg0, RADAR_REPORT_REG0_PULSE_IS_CHIRP),
2488 MS(reg0, RADAR_REPORT_REG0_PULSE_IS_MAX_WIDTH),
2489 MS(reg0, RADAR_REPORT_REG0_AGC_TOTAL_GAIN),
2490 MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_DIFF));
Michal Kazior7aa7a722014-08-25 12:09:38 +02002491 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002492 "wmi phyerr radar report pulse_delta_pean %d pulse_sidx %d fft_valid %d agc_mb_gain %d subchan_mask %d\n",
2493 MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_PEAK),
2494 MS(reg0, RADAR_REPORT_REG0_PULSE_SIDX),
2495 MS(reg1, RADAR_REPORT_REG1_PULSE_SRCH_FFT_VALID),
2496 MS(reg1, RADAR_REPORT_REG1_PULSE_AGC_MB_GAIN),
2497 MS(reg1, RADAR_REPORT_REG1_PULSE_SUBCHAN_MASK));
Michal Kazior7aa7a722014-08-25 12:09:38 +02002498 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002499 "wmi phyerr radar report pulse_tsf_offset 0x%X pulse_dur: %d\n",
2500 MS(reg1, RADAR_REPORT_REG1_PULSE_TSF_OFFSET),
2501 MS(reg1, RADAR_REPORT_REG1_PULSE_DUR));
2502
2503 if (!ar->dfs_detector)
2504 return;
2505
2506 /* report event to DFS pattern detector */
Michal Kazior2332d0a2014-09-18 15:21:25 +02002507 tsf32l = __le32_to_cpu(phyerr->tsf_timestamp);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002508 tsf64 = tsf & (~0xFFFFFFFFULL);
2509 tsf64 |= tsf32l;
2510
2511 width = MS(reg1, RADAR_REPORT_REG1_PULSE_DUR);
Michal Kazior2332d0a2014-09-18 15:21:25 +02002512 rssi = phyerr->rssi_combined;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002513
2514 /* hardware store this as 8 bit signed value,
2515 * set to zero if negative number
2516 */
2517 if (rssi & 0x80)
2518 rssi = 0;
2519
2520 pe.ts = tsf64;
2521 pe.freq = ar->hw->conf.chandef.chan->center_freq;
2522 pe.width = width;
2523 pe.rssi = rssi;
Peter Oh2c3f26a2015-03-04 15:43:46 +02002524 pe.chirp = (MS(reg0, RADAR_REPORT_REG0_PULSE_IS_CHIRP) != 0);
Michal Kazior7aa7a722014-08-25 12:09:38 +02002525 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002526 "dfs add pulse freq: %d, width: %d, rssi %d, tsf: %llX\n",
2527 pe.freq, pe.width, pe.rssi, pe.ts);
2528
2529 ATH10K_DFS_STAT_INC(ar, pulses_detected);
2530
2531 if (!ar->dfs_detector->add_pulse(ar->dfs_detector, &pe)) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002532 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002533 "dfs no pulse pattern detected, yet\n");
2534 return;
2535 }
2536
Michal Kazior7aa7a722014-08-25 12:09:38 +02002537 ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs radar detected\n");
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002538 ATH10K_DFS_STAT_INC(ar, radar_detected);
Marek Puzyniak7d9b40b2013-11-20 10:00:28 +02002539
2540 /* Control radar events reporting in debugfs file
2541 dfs_block_radar_events */
2542 if (ar->dfs_block_radar_events) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002543 ath10k_info(ar, "DFS Radar detected, but ignored as requested\n");
Marek Puzyniak7d9b40b2013-11-20 10:00:28 +02002544 return;
2545 }
2546
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002547 ieee80211_radar_detected(ar->hw);
2548}
2549
2550static int ath10k_dfs_fft_report(struct ath10k *ar,
Michal Kazior2332d0a2014-09-18 15:21:25 +02002551 const struct wmi_phyerr *phyerr,
2552 const struct phyerr_fft_report *fftr,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002553 u64 tsf)
2554{
2555 u32 reg0, reg1;
2556 u8 rssi, peak_mag;
2557
2558 reg0 = __le32_to_cpu(fftr->reg0);
2559 reg1 = __le32_to_cpu(fftr->reg1);
Michal Kazior2332d0a2014-09-18 15:21:25 +02002560 rssi = phyerr->rssi_combined;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002561
Michal Kazior7aa7a722014-08-25 12:09:38 +02002562 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002563 "wmi phyerr fft report total_gain_db %d base_pwr_db %d fft_chn_idx %d peak_sidx %d\n",
2564 MS(reg0, SEARCH_FFT_REPORT_REG0_TOTAL_GAIN_DB),
2565 MS(reg0, SEARCH_FFT_REPORT_REG0_BASE_PWR_DB),
2566 MS(reg0, SEARCH_FFT_REPORT_REG0_FFT_CHN_IDX),
2567 MS(reg0, SEARCH_FFT_REPORT_REG0_PEAK_SIDX));
Michal Kazior7aa7a722014-08-25 12:09:38 +02002568 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002569 "wmi phyerr fft report rel_pwr_db %d avgpwr_db %d peak_mag %d num_store_bin %d\n",
2570 MS(reg1, SEARCH_FFT_REPORT_REG1_RELPWR_DB),
2571 MS(reg1, SEARCH_FFT_REPORT_REG1_AVGPWR_DB),
2572 MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG),
2573 MS(reg1, SEARCH_FFT_REPORT_REG1_NUM_STR_BINS_IB));
2574
2575 peak_mag = MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG);
2576
2577 /* false event detection */
2578 if (rssi == DFS_RSSI_POSSIBLY_FALSE &&
2579 peak_mag < 2 * DFS_PEAK_MAG_THOLD_POSSIBLY_FALSE) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002580 ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs false pulse detected\n");
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002581 ATH10K_DFS_STAT_INC(ar, pulses_discarded);
2582 return -EINVAL;
2583 }
2584
2585 return 0;
2586}
2587
Michal Kazior0226d602014-12-03 10:11:22 +02002588void ath10k_wmi_event_dfs(struct ath10k *ar,
2589 const struct wmi_phyerr *phyerr,
2590 u64 tsf)
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002591{
2592 int buf_len, tlv_len, res, i = 0;
Michal Kazior2332d0a2014-09-18 15:21:25 +02002593 const struct phyerr_tlv *tlv;
2594 const struct phyerr_radar_report *rr;
2595 const struct phyerr_fft_report *fftr;
2596 const u8 *tlv_buf;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002597
Michal Kazior2332d0a2014-09-18 15:21:25 +02002598 buf_len = __le32_to_cpu(phyerr->buf_len);
Michal Kazior7aa7a722014-08-25 12:09:38 +02002599 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002600 "wmi event dfs err_code %d rssi %d tsfl 0x%X tsf64 0x%llX len %d\n",
Michal Kazior2332d0a2014-09-18 15:21:25 +02002601 phyerr->phy_err_code, phyerr->rssi_combined,
2602 __le32_to_cpu(phyerr->tsf_timestamp), tsf, buf_len);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002603
2604 /* Skip event if DFS disabled */
2605 if (!config_enabled(CONFIG_ATH10K_DFS_CERTIFIED))
2606 return;
2607
2608 ATH10K_DFS_STAT_INC(ar, pulses_total);
2609
2610 while (i < buf_len) {
2611 if (i + sizeof(*tlv) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002612 ath10k_warn(ar, "too short buf for tlv header (%d)\n",
2613 i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002614 return;
2615 }
2616
Michal Kazior2332d0a2014-09-18 15:21:25 +02002617 tlv = (struct phyerr_tlv *)&phyerr->buf[i];
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002618 tlv_len = __le16_to_cpu(tlv->len);
Michal Kazior2332d0a2014-09-18 15:21:25 +02002619 tlv_buf = &phyerr->buf[i + sizeof(*tlv)];
Michal Kazior7aa7a722014-08-25 12:09:38 +02002620 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002621 "wmi event dfs tlv_len %d tlv_tag 0x%02X tlv_sig 0x%02X\n",
2622 tlv_len, tlv->tag, tlv->sig);
2623
2624 switch (tlv->tag) {
2625 case PHYERR_TLV_TAG_RADAR_PULSE_SUMMARY:
2626 if (i + sizeof(*tlv) + sizeof(*rr) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002627 ath10k_warn(ar, "too short radar pulse summary (%d)\n",
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002628 i);
2629 return;
2630 }
2631
2632 rr = (struct phyerr_radar_report *)tlv_buf;
Michal Kazior2332d0a2014-09-18 15:21:25 +02002633 ath10k_dfs_radar_report(ar, phyerr, rr, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002634 break;
2635 case PHYERR_TLV_TAG_SEARCH_FFT_REPORT:
2636 if (i + sizeof(*tlv) + sizeof(*fftr) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002637 ath10k_warn(ar, "too short fft report (%d)\n",
2638 i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002639 return;
2640 }
2641
2642 fftr = (struct phyerr_fft_report *)tlv_buf;
Michal Kazior2332d0a2014-09-18 15:21:25 +02002643 res = ath10k_dfs_fft_report(ar, phyerr, fftr, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002644 if (res)
2645 return;
2646 break;
2647 }
2648
2649 i += sizeof(*tlv) + tlv_len;
2650 }
2651}
2652
Michal Kazior0226d602014-12-03 10:11:22 +02002653void ath10k_wmi_event_spectral_scan(struct ath10k *ar,
2654 const struct wmi_phyerr *phyerr,
2655 u64 tsf)
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002656{
Simon Wunderlich855aed12014-08-02 09:12:54 +03002657 int buf_len, tlv_len, res, i = 0;
2658 struct phyerr_tlv *tlv;
Michal Kazior2332d0a2014-09-18 15:21:25 +02002659 const void *tlv_buf;
2660 const struct phyerr_fft_report *fftr;
Simon Wunderlich855aed12014-08-02 09:12:54 +03002661 size_t fftr_len;
2662
Michal Kazior2332d0a2014-09-18 15:21:25 +02002663 buf_len = __le32_to_cpu(phyerr->buf_len);
Simon Wunderlich855aed12014-08-02 09:12:54 +03002664
2665 while (i < buf_len) {
2666 if (i + sizeof(*tlv) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002667 ath10k_warn(ar, "failed to parse phyerr tlv header at byte %d\n",
Simon Wunderlich855aed12014-08-02 09:12:54 +03002668 i);
2669 return;
2670 }
2671
Michal Kazior2332d0a2014-09-18 15:21:25 +02002672 tlv = (struct phyerr_tlv *)&phyerr->buf[i];
Simon Wunderlich855aed12014-08-02 09:12:54 +03002673 tlv_len = __le16_to_cpu(tlv->len);
Michal Kazior2332d0a2014-09-18 15:21:25 +02002674 tlv_buf = &phyerr->buf[i + sizeof(*tlv)];
Simon Wunderlich855aed12014-08-02 09:12:54 +03002675
2676 if (i + sizeof(*tlv) + tlv_len > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002677 ath10k_warn(ar, "failed to parse phyerr tlv payload at byte %d\n",
Simon Wunderlich855aed12014-08-02 09:12:54 +03002678 i);
2679 return;
2680 }
2681
2682 switch (tlv->tag) {
2683 case PHYERR_TLV_TAG_SEARCH_FFT_REPORT:
2684 if (sizeof(*fftr) > tlv_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002685 ath10k_warn(ar, "failed to parse fft report at byte %d\n",
Simon Wunderlich855aed12014-08-02 09:12:54 +03002686 i);
2687 return;
2688 }
2689
2690 fftr_len = tlv_len - sizeof(*fftr);
Michal Kazior2332d0a2014-09-18 15:21:25 +02002691 fftr = tlv_buf;
2692 res = ath10k_spectral_process_fft(ar, phyerr,
Simon Wunderlich855aed12014-08-02 09:12:54 +03002693 fftr, fftr_len,
2694 tsf);
2695 if (res < 0) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002696 ath10k_warn(ar, "failed to process fft report: %d\n",
Simon Wunderlich855aed12014-08-02 09:12:54 +03002697 res);
2698 return;
2699 }
2700 break;
2701 }
2702
2703 i += sizeof(*tlv) + tlv_len;
2704 }
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002705}
2706
Michal Kaziord7579d12014-12-03 10:10:54 +02002707static int ath10k_wmi_op_pull_phyerr_ev(struct ath10k *ar, struct sk_buff *skb,
2708 struct wmi_phyerr_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02002709{
2710 struct wmi_phyerr_event *ev = (void *)skb->data;
2711
2712 if (skb->len < sizeof(*ev))
2713 return -EPROTO;
2714
2715 arg->num_phyerrs = ev->num_phyerrs;
2716 arg->tsf_l32 = ev->tsf_l32;
2717 arg->tsf_u32 = ev->tsf_u32;
2718 arg->buf_len = __cpu_to_le32(skb->len - sizeof(*ev));
2719 arg->phyerrs = ev->phyerrs;
2720
2721 return 0;
2722}
2723
Michal Kazior0226d602014-12-03 10:11:22 +02002724void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002725{
Michal Kazior32653cf2014-12-03 10:10:26 +02002726 struct wmi_phyerr_ev_arg arg = {};
Michal Kazior2332d0a2014-09-18 15:21:25 +02002727 const struct wmi_phyerr *phyerr;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002728 u32 count, i, buf_len, phy_err_code;
2729 u64 tsf;
Michal Kazior32653cf2014-12-03 10:10:26 +02002730 int left_len, ret;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002731
2732 ATH10K_DFS_STAT_INC(ar, phy_errors);
2733
Michal Kaziord7579d12014-12-03 10:10:54 +02002734 ret = ath10k_wmi_pull_phyerr(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02002735 if (ret) {
2736 ath10k_warn(ar, "failed to parse phyerr event: %d\n", ret);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002737 return;
2738 }
2739
Michal Kazior32653cf2014-12-03 10:10:26 +02002740 left_len = __le32_to_cpu(arg.buf_len);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002741
2742 /* Check number of included events */
Michal Kazior32653cf2014-12-03 10:10:26 +02002743 count = __le32_to_cpu(arg.num_phyerrs);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002744
Michal Kazior32653cf2014-12-03 10:10:26 +02002745 tsf = __le32_to_cpu(arg.tsf_u32);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002746 tsf <<= 32;
Michal Kazior32653cf2014-12-03 10:10:26 +02002747 tsf |= __le32_to_cpu(arg.tsf_l32);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002748
Michal Kazior7aa7a722014-08-25 12:09:38 +02002749 ath10k_dbg(ar, ATH10K_DBG_WMI,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002750 "wmi event phyerr count %d tsf64 0x%llX\n",
2751 count, tsf);
2752
Michal Kazior32653cf2014-12-03 10:10:26 +02002753 phyerr = arg.phyerrs;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002754 for (i = 0; i < count; i++) {
2755 /* Check if we can read event header */
Michal Kazior2332d0a2014-09-18 15:21:25 +02002756 if (left_len < sizeof(*phyerr)) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002757 ath10k_warn(ar, "single event (%d) wrong head len\n",
2758 i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002759 return;
2760 }
2761
Michal Kazior2332d0a2014-09-18 15:21:25 +02002762 left_len -= sizeof(*phyerr);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002763
Michal Kazior2332d0a2014-09-18 15:21:25 +02002764 buf_len = __le32_to_cpu(phyerr->buf_len);
2765 phy_err_code = phyerr->phy_err_code;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002766
2767 if (left_len < buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002768 ath10k_warn(ar, "single event (%d) wrong buf len\n", i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002769 return;
2770 }
2771
2772 left_len -= buf_len;
2773
2774 switch (phy_err_code) {
2775 case PHY_ERROR_RADAR:
Michal Kazior2332d0a2014-09-18 15:21:25 +02002776 ath10k_wmi_event_dfs(ar, phyerr, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002777 break;
2778 case PHY_ERROR_SPECTRAL_SCAN:
Michal Kazior2332d0a2014-09-18 15:21:25 +02002779 ath10k_wmi_event_spectral_scan(ar, phyerr, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002780 break;
2781 case PHY_ERROR_FALSE_RADAR_EXT:
Michal Kazior2332d0a2014-09-18 15:21:25 +02002782 ath10k_wmi_event_dfs(ar, phyerr, tsf);
2783 ath10k_wmi_event_spectral_scan(ar, phyerr, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002784 break;
2785 default:
2786 break;
2787 }
2788
Michal Kazior2332d0a2014-09-18 15:21:25 +02002789 phyerr = (void *)phyerr + sizeof(*phyerr) + buf_len;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02002790 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03002791}
2792
Michal Kazior0226d602014-12-03 10:11:22 +02002793void ath10k_wmi_event_roam(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002794{
Michal Kaziorc1a46542015-03-10 16:21:54 +02002795 struct wmi_roam_ev_arg arg = {};
2796 int ret;
2797 u32 vdev_id;
2798 u32 reason;
2799 s32 rssi;
2800
2801 ret = ath10k_wmi_pull_roam_ev(ar, skb, &arg);
2802 if (ret) {
2803 ath10k_warn(ar, "failed to parse roam event: %d\n", ret);
2804 return;
2805 }
2806
2807 vdev_id = __le32_to_cpu(arg.vdev_id);
2808 reason = __le32_to_cpu(arg.reason);
2809 rssi = __le32_to_cpu(arg.rssi);
2810 rssi += WMI_SPECTRAL_NOISE_FLOOR_REF_DEFAULT;
2811
2812 ath10k_dbg(ar, ATH10K_DBG_WMI,
2813 "wmi roam event vdev %u reason 0x%08x rssi %d\n",
2814 vdev_id, reason, rssi);
2815
2816 if (reason >= WMI_ROAM_REASON_MAX)
2817 ath10k_warn(ar, "ignoring unknown roam event reason %d on vdev %i\n",
2818 reason, vdev_id);
2819
2820 switch (reason) {
Michal Kaziorc1a46542015-03-10 16:21:54 +02002821 case WMI_ROAM_REASON_BEACON_MISS:
Michal Kaziorcc9904e2015-03-10 16:22:01 +02002822 ath10k_mac_handle_beacon_miss(ar, vdev_id);
2823 break;
2824 case WMI_ROAM_REASON_BETTER_AP:
Michal Kaziorc1a46542015-03-10 16:21:54 +02002825 case WMI_ROAM_REASON_LOW_RSSI:
2826 case WMI_ROAM_REASON_SUITABLE_AP_FOUND:
2827 case WMI_ROAM_REASON_HO_FAILED:
2828 ath10k_warn(ar, "ignoring not implemented roam event reason %d on vdev %i\n",
2829 reason, vdev_id);
2830 break;
2831 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03002832}
2833
Michal Kazior0226d602014-12-03 10:11:22 +02002834void ath10k_wmi_event_profile_match(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002835{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002836 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PROFILE_MATCH\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002837}
2838
Michal Kazior0226d602014-12-03 10:11:22 +02002839void ath10k_wmi_event_debug_print(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002840{
Kalle Valo2fe52882014-01-03 12:59:20 +02002841 char buf[101], c;
2842 int i;
2843
2844 for (i = 0; i < sizeof(buf) - 1; i++) {
2845 if (i >= skb->len)
2846 break;
2847
2848 c = skb->data[i];
2849
2850 if (c == '\0')
2851 break;
2852
2853 if (isascii(c) && isprint(c))
2854 buf[i] = c;
2855 else
2856 buf[i] = '.';
2857 }
2858
2859 if (i == sizeof(buf) - 1)
Michal Kazior7aa7a722014-08-25 12:09:38 +02002860 ath10k_warn(ar, "wmi debug print truncated: %d\n", skb->len);
Kalle Valo2fe52882014-01-03 12:59:20 +02002861
2862 /* for some reason the debug prints end with \n, remove that */
2863 if (skb->data[i - 1] == '\n')
2864 i--;
2865
2866 /* the last byte is always reserved for the null character */
2867 buf[i] = '\0';
2868
Ben Greear3be004c2014-09-23 14:17:19 -07002869 ath10k_dbg(ar, ATH10K_DBG_WMI_PRINT, "wmi print '%s'\n", buf);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002870}
2871
Michal Kazior0226d602014-12-03 10:11:22 +02002872void ath10k_wmi_event_pdev_qvit(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002873{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002874 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_QVIT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002875}
2876
Michal Kazior0226d602014-12-03 10:11:22 +02002877void ath10k_wmi_event_wlan_profile_data(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002878{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002879 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_WLAN_PROFILE_DATA_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002880}
2881
Michal Kazior0226d602014-12-03 10:11:22 +02002882void ath10k_wmi_event_rtt_measurement_report(struct ath10k *ar,
2883 struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002884{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002885 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_MEASUREMENT_REPORT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002886}
2887
Michal Kazior0226d602014-12-03 10:11:22 +02002888void ath10k_wmi_event_tsf_measurement_report(struct ath10k *ar,
2889 struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002890{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002891 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TSF_MEASUREMENT_REPORT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002892}
2893
Michal Kazior0226d602014-12-03 10:11:22 +02002894void ath10k_wmi_event_rtt_error_report(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002895{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002896 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_ERROR_REPORT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002897}
2898
Michal Kazior0226d602014-12-03 10:11:22 +02002899void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002900{
Janusz Dziedzic5fd3ac32015-03-23 17:32:53 +02002901 struct wmi_wow_ev_arg ev = {};
2902 int ret;
2903
2904 complete(&ar->wow.wakeup_completed);
2905
2906 ret = ath10k_wmi_pull_wow_event(ar, skb, &ev);
2907 if (ret) {
2908 ath10k_warn(ar, "failed to parse wow wakeup event: %d\n", ret);
2909 return;
2910 }
2911
2912 ath10k_dbg(ar, ATH10K_DBG_WMI, "wow wakeup host reason %s\n",
2913 wow_reason(ev.wake_reason));
Kalle Valo5e3dd152013-06-12 20:52:10 +03002914}
2915
Michal Kazior0226d602014-12-03 10:11:22 +02002916void ath10k_wmi_event_dcs_interference(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002917{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002918 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_DCS_INTERFERENCE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002919}
2920
Michal Kazior0226d602014-12-03 10:11:22 +02002921void ath10k_wmi_event_pdev_tpc_config(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002922{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002923 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_TPC_CONFIG_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002924}
2925
Michal Kazior0226d602014-12-03 10:11:22 +02002926void ath10k_wmi_event_pdev_ftm_intg(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002927{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002928 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_FTM_INTG_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002929}
2930
Michal Kazior0226d602014-12-03 10:11:22 +02002931void ath10k_wmi_event_gtk_offload_status(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002932{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002933 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_OFFLOAD_STATUS_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002934}
2935
Michal Kazior0226d602014-12-03 10:11:22 +02002936void ath10k_wmi_event_gtk_rekey_fail(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002937{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002938 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_REKEY_FAIL_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002939}
2940
Michal Kazior0226d602014-12-03 10:11:22 +02002941void ath10k_wmi_event_delba_complete(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002942{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002943 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_DELBA_COMPLETE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002944}
2945
Michal Kazior0226d602014-12-03 10:11:22 +02002946void ath10k_wmi_event_addba_complete(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002947{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002948 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_ADDBA_COMPLETE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002949}
2950
Michal Kazior0226d602014-12-03 10:11:22 +02002951void ath10k_wmi_event_vdev_install_key_complete(struct ath10k *ar,
2952 struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002953{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002954 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002955}
2956
Michal Kazior0226d602014-12-03 10:11:22 +02002957void ath10k_wmi_event_inst_rssi_stats(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02002958{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002959 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_INST_RSSI_STATS_EVENTID\n");
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02002960}
2961
Michal Kazior0226d602014-12-03 10:11:22 +02002962void ath10k_wmi_event_vdev_standby_req(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02002963{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002964 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STANDBY_REQ_EVENTID\n");
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02002965}
2966
Michal Kazior0226d602014-12-03 10:11:22 +02002967void ath10k_wmi_event_vdev_resume_req(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02002968{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002969 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_RESUME_REQ_EVENTID\n");
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02002970}
2971
Bartosz Markowskib3effe62013-09-26 17:47:11 +02002972static int ath10k_wmi_alloc_host_mem(struct ath10k *ar, u32 req_id,
Kalle Valo5b07e072014-09-14 12:50:06 +03002973 u32 num_units, u32 unit_len)
Bartosz Markowskib3effe62013-09-26 17:47:11 +02002974{
2975 dma_addr_t paddr;
2976 u32 pool_size;
2977 int idx = ar->wmi.num_mem_chunks;
2978
2979 pool_size = num_units * round_up(unit_len, 4);
2980
2981 if (!pool_size)
2982 return -EINVAL;
2983
2984 ar->wmi.mem_chunks[idx].vaddr = dma_alloc_coherent(ar->dev,
2985 pool_size,
2986 &paddr,
2987 GFP_ATOMIC);
2988 if (!ar->wmi.mem_chunks[idx].vaddr) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002989 ath10k_warn(ar, "failed to allocate memory chunk\n");
Bartosz Markowskib3effe62013-09-26 17:47:11 +02002990 return -ENOMEM;
2991 }
2992
2993 memset(ar->wmi.mem_chunks[idx].vaddr, 0, pool_size);
2994
2995 ar->wmi.mem_chunks[idx].paddr = paddr;
2996 ar->wmi.mem_chunks[idx].len = pool_size;
2997 ar->wmi.mem_chunks[idx].req_id = req_id;
2998 ar->wmi.num_mem_chunks++;
2999
3000 return 0;
3001}
3002
Michal Kaziord7579d12014-12-03 10:10:54 +02003003static int
3004ath10k_wmi_main_op_pull_svc_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
3005 struct wmi_svc_rdy_ev_arg *arg)
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003006{
3007 struct wmi_service_ready_event *ev;
3008 size_t i, n;
3009
3010 if (skb->len < sizeof(*ev))
3011 return -EPROTO;
3012
3013 ev = (void *)skb->data;
3014 skb_pull(skb, sizeof(*ev));
3015 arg->min_tx_power = ev->hw_min_tx_power;
3016 arg->max_tx_power = ev->hw_max_tx_power;
3017 arg->ht_cap = ev->ht_cap_info;
3018 arg->vht_cap = ev->vht_cap_info;
3019 arg->sw_ver0 = ev->sw_version;
3020 arg->sw_ver1 = ev->sw_version_1;
3021 arg->phy_capab = ev->phy_capability;
3022 arg->num_rf_chains = ev->num_rf_chains;
3023 arg->eeprom_rd = ev->hal_reg_capabilities.eeprom_rd;
3024 arg->num_mem_reqs = ev->num_mem_reqs;
3025 arg->service_map = ev->wmi_service_bitmap;
Michal Kazior2a3e60d2014-11-27 10:11:15 +01003026 arg->service_map_len = sizeof(ev->wmi_service_bitmap);
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003027
3028 n = min_t(size_t, __le32_to_cpu(arg->num_mem_reqs),
3029 ARRAY_SIZE(arg->mem_reqs));
3030 for (i = 0; i < n; i++)
3031 arg->mem_reqs[i] = &ev->mem_reqs[i];
3032
3033 if (skb->len <
3034 __le32_to_cpu(arg->num_mem_reqs) * sizeof(arg->mem_reqs[0]))
3035 return -EPROTO;
3036
3037 return 0;
3038}
3039
Michal Kaziord7579d12014-12-03 10:10:54 +02003040static int
3041ath10k_wmi_10x_op_pull_svc_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
3042 struct wmi_svc_rdy_ev_arg *arg)
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003043{
3044 struct wmi_10x_service_ready_event *ev;
3045 int i, n;
3046
3047 if (skb->len < sizeof(*ev))
3048 return -EPROTO;
3049
3050 ev = (void *)skb->data;
3051 skb_pull(skb, sizeof(*ev));
3052 arg->min_tx_power = ev->hw_min_tx_power;
3053 arg->max_tx_power = ev->hw_max_tx_power;
3054 arg->ht_cap = ev->ht_cap_info;
3055 arg->vht_cap = ev->vht_cap_info;
3056 arg->sw_ver0 = ev->sw_version;
3057 arg->phy_capab = ev->phy_capability;
3058 arg->num_rf_chains = ev->num_rf_chains;
3059 arg->eeprom_rd = ev->hal_reg_capabilities.eeprom_rd;
3060 arg->num_mem_reqs = ev->num_mem_reqs;
3061 arg->service_map = ev->wmi_service_bitmap;
Michal Kazior2a3e60d2014-11-27 10:11:15 +01003062 arg->service_map_len = sizeof(ev->wmi_service_bitmap);
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003063
3064 n = min_t(size_t, __le32_to_cpu(arg->num_mem_reqs),
3065 ARRAY_SIZE(arg->mem_reqs));
3066 for (i = 0; i < n; i++)
3067 arg->mem_reqs[i] = &ev->mem_reqs[i];
3068
3069 if (skb->len <
3070 __le32_to_cpu(arg->num_mem_reqs) * sizeof(arg->mem_reqs[0]))
3071 return -EPROTO;
3072
3073 return 0;
3074}
3075
Michal Kazior0226d602014-12-03 10:11:22 +02003076void ath10k_wmi_event_service_ready(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003077{
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003078 struct wmi_svc_rdy_ev_arg arg = {};
3079 u32 num_units, req_id, unit_size, num_mem_reqs, num_unit_info, i;
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003080 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003081
Michal Kaziord7579d12014-12-03 10:10:54 +02003082 ret = ath10k_wmi_pull_svc_rdy(ar, skb, &arg);
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003083 if (ret) {
3084 ath10k_warn(ar, "failed to parse service ready: %d\n", ret);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003085 return;
3086 }
3087
Michal Kaziord7579d12014-12-03 10:10:54 +02003088 memset(&ar->wmi.svc_map, 0, sizeof(ar->wmi.svc_map));
3089 ath10k_wmi_map_svc(ar, arg.service_map, ar->wmi.svc_map,
3090 arg.service_map_len);
3091
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003092 ar->hw_min_tx_power = __le32_to_cpu(arg.min_tx_power);
3093 ar->hw_max_tx_power = __le32_to_cpu(arg.max_tx_power);
3094 ar->ht_cap_info = __le32_to_cpu(arg.ht_cap);
3095 ar->vht_cap_info = __le32_to_cpu(arg.vht_cap);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003096 ar->fw_version_major =
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003097 (__le32_to_cpu(arg.sw_ver0) & 0xff000000) >> 24;
3098 ar->fw_version_minor = (__le32_to_cpu(arg.sw_ver0) & 0x00ffffff);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003099 ar->fw_version_release =
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003100 (__le32_to_cpu(arg.sw_ver1) & 0xffff0000) >> 16;
3101 ar->fw_version_build = (__le32_to_cpu(arg.sw_ver1) & 0x0000ffff);
3102 ar->phy_capability = __le32_to_cpu(arg.phy_capab);
3103 ar->num_rf_chains = __le32_to_cpu(arg.num_rf_chains);
3104 ar->ath_common.regulatory.current_rd = __le32_to_cpu(arg.eeprom_rd);
3105
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003106 ath10k_dbg_dump(ar, ATH10K_DBG_WMI, NULL, "wmi svc: ",
Michal Kazior2a3e60d2014-11-27 10:11:15 +01003107 arg.service_map, arg.service_map_len);
Michal Kazior8865bee42013-07-24 12:36:46 +02003108
Kalle Valo1a222432013-09-27 19:55:07 +03003109 /* only manually set fw features when not using FW IE format */
3110 if (ar->fw_api == 1 && ar->fw_version_build > 636)
Michal Kazior0d9b0432013-08-09 10:13:33 +02003111 set_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features);
3112
Michal Kazior8865bee42013-07-24 12:36:46 +02003113 if (ar->num_rf_chains > WMI_MAX_SPATIAL_STREAM) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003114 ath10k_warn(ar, "hardware advertises support for more spatial streams than it should (%d > %d)\n",
Michal Kazior8865bee42013-07-24 12:36:46 +02003115 ar->num_rf_chains, WMI_MAX_SPATIAL_STREAM);
3116 ar->num_rf_chains = WMI_MAX_SPATIAL_STREAM;
3117 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03003118
Michal Kaziorfdb959c2014-09-18 15:21:19 +02003119 ar->supp_tx_chainmask = (1 << ar->num_rf_chains) - 1;
3120 ar->supp_rx_chainmask = (1 << ar->num_rf_chains) - 1;
3121
Kalle Valo5e3dd152013-06-12 20:52:10 +03003122 if (strlen(ar->hw->wiphy->fw_version) == 0) {
3123 snprintf(ar->hw->wiphy->fw_version,
3124 sizeof(ar->hw->wiphy->fw_version),
3125 "%u.%u.%u.%u",
3126 ar->fw_version_major,
3127 ar->fw_version_minor,
3128 ar->fw_version_release,
3129 ar->fw_version_build);
3130 }
3131
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003132 num_mem_reqs = __le32_to_cpu(arg.num_mem_reqs);
3133 if (num_mem_reqs > WMI_MAX_MEM_REQS) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003134 ath10k_warn(ar, "requested memory chunks number (%d) exceeds the limit\n",
Bartosz Markowskib3effe62013-09-26 17:47:11 +02003135 num_mem_reqs);
3136 return;
Bartosz Markowski6f97d252013-09-26 17:47:09 +02003137 }
3138
Bartosz Markowskib3effe62013-09-26 17:47:11 +02003139 for (i = 0; i < num_mem_reqs; ++i) {
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003140 req_id = __le32_to_cpu(arg.mem_reqs[i]->req_id);
3141 num_units = __le32_to_cpu(arg.mem_reqs[i]->num_units);
3142 unit_size = __le32_to_cpu(arg.mem_reqs[i]->unit_size);
3143 num_unit_info = __le32_to_cpu(arg.mem_reqs[i]->num_unit_info);
Bartosz Markowskib3effe62013-09-26 17:47:11 +02003144
3145 if (num_unit_info & NUM_UNITS_IS_NUM_PEERS)
3146 /* number of units to allocate is number of
3147 * peers, 1 extra for self peer on target */
3148 /* this needs to be tied, host and target
3149 * can get out of sync */
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02003150 num_units = TARGET_10X_NUM_PEERS + 1;
Bartosz Markowskib3effe62013-09-26 17:47:11 +02003151 else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS)
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02003152 num_units = TARGET_10X_NUM_VDEVS + 1;
Bartosz Markowskib3effe62013-09-26 17:47:11 +02003153
Michal Kazior7aa7a722014-08-25 12:09:38 +02003154 ath10k_dbg(ar, ATH10K_DBG_WMI,
Bartosz Markowskib3effe62013-09-26 17:47:11 +02003155 "wmi mem_req_id %d num_units %d num_unit_info %d unit size %d actual units %d\n",
3156 req_id,
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003157 __le32_to_cpu(arg.mem_reqs[i]->num_units),
Bartosz Markowskib3effe62013-09-26 17:47:11 +02003158 num_unit_info,
3159 unit_size,
3160 num_units);
3161
3162 ret = ath10k_wmi_alloc_host_mem(ar, req_id, num_units,
3163 unit_size);
3164 if (ret)
3165 return;
3166 }
3167
Michal Kazior7aa7a722014-08-25 12:09:38 +02003168 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kaziorca996ec2014-12-03 10:11:32 +02003169 "wmi event service ready min_tx_power 0x%08x max_tx_power 0x%08x ht_cap 0x%08x vht_cap 0x%08x sw_ver0 0x%08x sw_ver1 0x%08x fw_build 0x%08x phy_capab 0x%08x num_rf_chains 0x%08x eeprom_rd 0x%08x num_mem_reqs 0x%08x\n",
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003170 __le32_to_cpu(arg.min_tx_power),
3171 __le32_to_cpu(arg.max_tx_power),
3172 __le32_to_cpu(arg.ht_cap),
3173 __le32_to_cpu(arg.vht_cap),
3174 __le32_to_cpu(arg.sw_ver0),
3175 __le32_to_cpu(arg.sw_ver1),
Michal Kaziorca996ec2014-12-03 10:11:32 +02003176 __le32_to_cpu(arg.fw_build),
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02003177 __le32_to_cpu(arg.phy_capab),
3178 __le32_to_cpu(arg.num_rf_chains),
3179 __le32_to_cpu(arg.eeprom_rd),
3180 __le32_to_cpu(arg.num_mem_reqs));
Bartosz Markowski6f97d252013-09-26 17:47:09 +02003181
3182 complete(&ar->wmi.service_ready);
3183}
3184
Michal Kaziord7579d12014-12-03 10:10:54 +02003185static int ath10k_wmi_op_pull_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
3186 struct wmi_rdy_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02003187{
3188 struct wmi_ready_event *ev = (void *)skb->data;
3189
3190 if (skb->len < sizeof(*ev))
3191 return -EPROTO;
3192
3193 skb_pull(skb, sizeof(*ev));
3194 arg->sw_version = ev->sw_version;
3195 arg->abi_version = ev->abi_version;
3196 arg->status = ev->status;
3197 arg->mac_addr = ev->mac_addr.addr;
3198
3199 return 0;
3200}
3201
Michal Kaziorc1a46542015-03-10 16:21:54 +02003202static int ath10k_wmi_op_pull_roam_ev(struct ath10k *ar, struct sk_buff *skb,
3203 struct wmi_roam_ev_arg *arg)
3204{
3205 struct wmi_roam_ev *ev = (void *)skb->data;
3206
3207 if (skb->len < sizeof(*ev))
3208 return -EPROTO;
3209
3210 skb_pull(skb, sizeof(*ev));
3211 arg->vdev_id = ev->vdev_id;
3212 arg->reason = ev->reason;
3213
3214 return 0;
3215}
3216
Michal Kazior0226d602014-12-03 10:11:22 +02003217int ath10k_wmi_event_ready(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003218{
Michal Kazior32653cf2014-12-03 10:10:26 +02003219 struct wmi_rdy_ev_arg arg = {};
3220 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003221
Michal Kaziord7579d12014-12-03 10:10:54 +02003222 ret = ath10k_wmi_pull_rdy(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02003223 if (ret) {
3224 ath10k_warn(ar, "failed to parse ready event: %d\n", ret);
3225 return ret;
3226 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03003227
Michal Kazior7aa7a722014-08-25 12:09:38 +02003228 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior32653cf2014-12-03 10:10:26 +02003229 "wmi event ready sw_version %u abi_version %u mac_addr %pM status %d\n",
3230 __le32_to_cpu(arg.sw_version),
3231 __le32_to_cpu(arg.abi_version),
3232 arg.mac_addr,
3233 __le32_to_cpu(arg.status));
Kalle Valo5e3dd152013-06-12 20:52:10 +03003234
Michal Kazior32653cf2014-12-03 10:10:26 +02003235 ether_addr_copy(ar->mac_addr, arg.mac_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003236 complete(&ar->wmi.unified_ready);
3237 return 0;
3238}
3239
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02003240static int ath10k_wmi_event_temperature(struct ath10k *ar, struct sk_buff *skb)
3241{
3242 const struct wmi_pdev_temperature_event *ev;
3243
3244 ev = (struct wmi_pdev_temperature_event *)skb->data;
3245 if (WARN_ON(skb->len < sizeof(*ev)))
3246 return -EPROTO;
3247
Rajkumar Manoharanac2953f2014-12-17 12:22:26 +02003248 ath10k_thermal_event_temperature(ar, __le32_to_cpu(ev->temperature));
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02003249 return 0;
3250}
3251
Michal Kaziord7579d12014-12-03 10:10:54 +02003252static void ath10k_wmi_op_rx(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003253{
3254 struct wmi_cmd_hdr *cmd_hdr;
3255 enum wmi_event_id id;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003256
3257 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
3258 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
3259
3260 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
3261 return;
3262
Michal Kaziord35a6c12014-09-02 11:00:21 +03003263 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003264
3265 switch (id) {
3266 case WMI_MGMT_RX_EVENTID:
3267 ath10k_wmi_event_mgmt_rx(ar, skb);
3268 /* mgmt_rx() owns the skb now! */
3269 return;
3270 case WMI_SCAN_EVENTID:
3271 ath10k_wmi_event_scan(ar, skb);
3272 break;
3273 case WMI_CHAN_INFO_EVENTID:
3274 ath10k_wmi_event_chan_info(ar, skb);
3275 break;
3276 case WMI_ECHO_EVENTID:
3277 ath10k_wmi_event_echo(ar, skb);
3278 break;
3279 case WMI_DEBUG_MESG_EVENTID:
3280 ath10k_wmi_event_debug_mesg(ar, skb);
3281 break;
3282 case WMI_UPDATE_STATS_EVENTID:
3283 ath10k_wmi_event_update_stats(ar, skb);
3284 break;
3285 case WMI_VDEV_START_RESP_EVENTID:
3286 ath10k_wmi_event_vdev_start_resp(ar, skb);
3287 break;
3288 case WMI_VDEV_STOPPED_EVENTID:
3289 ath10k_wmi_event_vdev_stopped(ar, skb);
3290 break;
3291 case WMI_PEER_STA_KICKOUT_EVENTID:
3292 ath10k_wmi_event_peer_sta_kickout(ar, skb);
3293 break;
3294 case WMI_HOST_SWBA_EVENTID:
3295 ath10k_wmi_event_host_swba(ar, skb);
3296 break;
3297 case WMI_TBTTOFFSET_UPDATE_EVENTID:
3298 ath10k_wmi_event_tbttoffset_update(ar, skb);
3299 break;
3300 case WMI_PHYERR_EVENTID:
3301 ath10k_wmi_event_phyerr(ar, skb);
3302 break;
3303 case WMI_ROAM_EVENTID:
3304 ath10k_wmi_event_roam(ar, skb);
3305 break;
3306 case WMI_PROFILE_MATCH:
3307 ath10k_wmi_event_profile_match(ar, skb);
3308 break;
3309 case WMI_DEBUG_PRINT_EVENTID:
3310 ath10k_wmi_event_debug_print(ar, skb);
3311 break;
3312 case WMI_PDEV_QVIT_EVENTID:
3313 ath10k_wmi_event_pdev_qvit(ar, skb);
3314 break;
3315 case WMI_WLAN_PROFILE_DATA_EVENTID:
3316 ath10k_wmi_event_wlan_profile_data(ar, skb);
3317 break;
3318 case WMI_RTT_MEASUREMENT_REPORT_EVENTID:
3319 ath10k_wmi_event_rtt_measurement_report(ar, skb);
3320 break;
3321 case WMI_TSF_MEASUREMENT_REPORT_EVENTID:
3322 ath10k_wmi_event_tsf_measurement_report(ar, skb);
3323 break;
3324 case WMI_RTT_ERROR_REPORT_EVENTID:
3325 ath10k_wmi_event_rtt_error_report(ar, skb);
3326 break;
3327 case WMI_WOW_WAKEUP_HOST_EVENTID:
3328 ath10k_wmi_event_wow_wakeup_host(ar, skb);
3329 break;
3330 case WMI_DCS_INTERFERENCE_EVENTID:
3331 ath10k_wmi_event_dcs_interference(ar, skb);
3332 break;
3333 case WMI_PDEV_TPC_CONFIG_EVENTID:
3334 ath10k_wmi_event_pdev_tpc_config(ar, skb);
3335 break;
3336 case WMI_PDEV_FTM_INTG_EVENTID:
3337 ath10k_wmi_event_pdev_ftm_intg(ar, skb);
3338 break;
3339 case WMI_GTK_OFFLOAD_STATUS_EVENTID:
3340 ath10k_wmi_event_gtk_offload_status(ar, skb);
3341 break;
3342 case WMI_GTK_REKEY_FAIL_EVENTID:
3343 ath10k_wmi_event_gtk_rekey_fail(ar, skb);
3344 break;
3345 case WMI_TX_DELBA_COMPLETE_EVENTID:
3346 ath10k_wmi_event_delba_complete(ar, skb);
3347 break;
3348 case WMI_TX_ADDBA_COMPLETE_EVENTID:
3349 ath10k_wmi_event_addba_complete(ar, skb);
3350 break;
3351 case WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID:
3352 ath10k_wmi_event_vdev_install_key_complete(ar, skb);
3353 break;
3354 case WMI_SERVICE_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02003355 ath10k_wmi_event_service_ready(ar, skb);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003356 break;
3357 case WMI_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02003358 ath10k_wmi_event_ready(ar, skb);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003359 break;
3360 default:
Michal Kazior7aa7a722014-08-25 12:09:38 +02003361 ath10k_warn(ar, "Unknown eventid: %d\n", id);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003362 break;
3363 }
3364
3365 dev_kfree_skb(skb);
3366}
3367
Michal Kaziord7579d12014-12-03 10:10:54 +02003368static void ath10k_wmi_10_1_op_rx(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02003369{
3370 struct wmi_cmd_hdr *cmd_hdr;
3371 enum wmi_10x_event_id id;
Kalle Valo43d2a302014-09-10 18:23:30 +03003372 bool consumed;
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02003373
3374 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
3375 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
3376
3377 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
3378 return;
3379
Michal Kaziord35a6c12014-09-02 11:00:21 +03003380 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02003381
Kalle Valo43d2a302014-09-10 18:23:30 +03003382 consumed = ath10k_tm_event_wmi(ar, id, skb);
3383
3384 /* Ready event must be handled normally also in UTF mode so that we
3385 * know the UTF firmware has booted, others we are just bypass WMI
3386 * events to testmode.
3387 */
3388 if (consumed && id != WMI_10X_READY_EVENTID) {
3389 ath10k_dbg(ar, ATH10K_DBG_WMI,
3390 "wmi testmode consumed 0x%x\n", id);
3391 goto out;
3392 }
3393
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02003394 switch (id) {
3395 case WMI_10X_MGMT_RX_EVENTID:
3396 ath10k_wmi_event_mgmt_rx(ar, skb);
3397 /* mgmt_rx() owns the skb now! */
3398 return;
3399 case WMI_10X_SCAN_EVENTID:
3400 ath10k_wmi_event_scan(ar, skb);
3401 break;
3402 case WMI_10X_CHAN_INFO_EVENTID:
3403 ath10k_wmi_event_chan_info(ar, skb);
3404 break;
3405 case WMI_10X_ECHO_EVENTID:
3406 ath10k_wmi_event_echo(ar, skb);
3407 break;
3408 case WMI_10X_DEBUG_MESG_EVENTID:
3409 ath10k_wmi_event_debug_mesg(ar, skb);
3410 break;
3411 case WMI_10X_UPDATE_STATS_EVENTID:
3412 ath10k_wmi_event_update_stats(ar, skb);
3413 break;
3414 case WMI_10X_VDEV_START_RESP_EVENTID:
3415 ath10k_wmi_event_vdev_start_resp(ar, skb);
3416 break;
3417 case WMI_10X_VDEV_STOPPED_EVENTID:
3418 ath10k_wmi_event_vdev_stopped(ar, skb);
3419 break;
3420 case WMI_10X_PEER_STA_KICKOUT_EVENTID:
3421 ath10k_wmi_event_peer_sta_kickout(ar, skb);
3422 break;
3423 case WMI_10X_HOST_SWBA_EVENTID:
3424 ath10k_wmi_event_host_swba(ar, skb);
3425 break;
3426 case WMI_10X_TBTTOFFSET_UPDATE_EVENTID:
3427 ath10k_wmi_event_tbttoffset_update(ar, skb);
3428 break;
3429 case WMI_10X_PHYERR_EVENTID:
3430 ath10k_wmi_event_phyerr(ar, skb);
3431 break;
3432 case WMI_10X_ROAM_EVENTID:
3433 ath10k_wmi_event_roam(ar, skb);
3434 break;
3435 case WMI_10X_PROFILE_MATCH:
3436 ath10k_wmi_event_profile_match(ar, skb);
3437 break;
3438 case WMI_10X_DEBUG_PRINT_EVENTID:
3439 ath10k_wmi_event_debug_print(ar, skb);
3440 break;
3441 case WMI_10X_PDEV_QVIT_EVENTID:
3442 ath10k_wmi_event_pdev_qvit(ar, skb);
3443 break;
3444 case WMI_10X_WLAN_PROFILE_DATA_EVENTID:
3445 ath10k_wmi_event_wlan_profile_data(ar, skb);
3446 break;
3447 case WMI_10X_RTT_MEASUREMENT_REPORT_EVENTID:
3448 ath10k_wmi_event_rtt_measurement_report(ar, skb);
3449 break;
3450 case WMI_10X_TSF_MEASUREMENT_REPORT_EVENTID:
3451 ath10k_wmi_event_tsf_measurement_report(ar, skb);
3452 break;
3453 case WMI_10X_RTT_ERROR_REPORT_EVENTID:
3454 ath10k_wmi_event_rtt_error_report(ar, skb);
3455 break;
3456 case WMI_10X_WOW_WAKEUP_HOST_EVENTID:
3457 ath10k_wmi_event_wow_wakeup_host(ar, skb);
3458 break;
3459 case WMI_10X_DCS_INTERFERENCE_EVENTID:
3460 ath10k_wmi_event_dcs_interference(ar, skb);
3461 break;
3462 case WMI_10X_PDEV_TPC_CONFIG_EVENTID:
3463 ath10k_wmi_event_pdev_tpc_config(ar, skb);
3464 break;
3465 case WMI_10X_INST_RSSI_STATS_EVENTID:
3466 ath10k_wmi_event_inst_rssi_stats(ar, skb);
3467 break;
3468 case WMI_10X_VDEV_STANDBY_REQ_EVENTID:
3469 ath10k_wmi_event_vdev_standby_req(ar, skb);
3470 break;
3471 case WMI_10X_VDEV_RESUME_REQ_EVENTID:
3472 ath10k_wmi_event_vdev_resume_req(ar, skb);
3473 break;
3474 case WMI_10X_SERVICE_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02003475 ath10k_wmi_event_service_ready(ar, skb);
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02003476 break;
3477 case WMI_10X_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02003478 ath10k_wmi_event_ready(ar, skb);
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02003479 break;
Kalle Valo43d2a302014-09-10 18:23:30 +03003480 case WMI_10X_PDEV_UTF_EVENTID:
3481 /* ignore utf events */
3482 break;
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02003483 default:
Michal Kazior7aa7a722014-08-25 12:09:38 +02003484 ath10k_warn(ar, "Unknown eventid: %d\n", id);
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02003485 break;
3486 }
3487
Kalle Valo43d2a302014-09-10 18:23:30 +03003488out:
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02003489 dev_kfree_skb(skb);
3490}
3491
Michal Kaziord7579d12014-12-03 10:10:54 +02003492static void ath10k_wmi_10_2_op_rx(struct ath10k *ar, struct sk_buff *skb)
Michal Kazior24c88f72014-07-25 13:32:17 +02003493{
3494 struct wmi_cmd_hdr *cmd_hdr;
3495 enum wmi_10_2_event_id id;
3496
3497 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
3498 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
3499
3500 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
3501 return;
3502
Michal Kaziord35a6c12014-09-02 11:00:21 +03003503 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
Michal Kazior24c88f72014-07-25 13:32:17 +02003504
3505 switch (id) {
3506 case WMI_10_2_MGMT_RX_EVENTID:
3507 ath10k_wmi_event_mgmt_rx(ar, skb);
3508 /* mgmt_rx() owns the skb now! */
3509 return;
3510 case WMI_10_2_SCAN_EVENTID:
3511 ath10k_wmi_event_scan(ar, skb);
3512 break;
3513 case WMI_10_2_CHAN_INFO_EVENTID:
3514 ath10k_wmi_event_chan_info(ar, skb);
3515 break;
3516 case WMI_10_2_ECHO_EVENTID:
3517 ath10k_wmi_event_echo(ar, skb);
3518 break;
3519 case WMI_10_2_DEBUG_MESG_EVENTID:
3520 ath10k_wmi_event_debug_mesg(ar, skb);
3521 break;
3522 case WMI_10_2_UPDATE_STATS_EVENTID:
3523 ath10k_wmi_event_update_stats(ar, skb);
3524 break;
3525 case WMI_10_2_VDEV_START_RESP_EVENTID:
3526 ath10k_wmi_event_vdev_start_resp(ar, skb);
3527 break;
3528 case WMI_10_2_VDEV_STOPPED_EVENTID:
3529 ath10k_wmi_event_vdev_stopped(ar, skb);
3530 break;
3531 case WMI_10_2_PEER_STA_KICKOUT_EVENTID:
3532 ath10k_wmi_event_peer_sta_kickout(ar, skb);
3533 break;
3534 case WMI_10_2_HOST_SWBA_EVENTID:
3535 ath10k_wmi_event_host_swba(ar, skb);
3536 break;
3537 case WMI_10_2_TBTTOFFSET_UPDATE_EVENTID:
3538 ath10k_wmi_event_tbttoffset_update(ar, skb);
3539 break;
3540 case WMI_10_2_PHYERR_EVENTID:
3541 ath10k_wmi_event_phyerr(ar, skb);
3542 break;
3543 case WMI_10_2_ROAM_EVENTID:
3544 ath10k_wmi_event_roam(ar, skb);
3545 break;
3546 case WMI_10_2_PROFILE_MATCH:
3547 ath10k_wmi_event_profile_match(ar, skb);
3548 break;
3549 case WMI_10_2_DEBUG_PRINT_EVENTID:
3550 ath10k_wmi_event_debug_print(ar, skb);
3551 break;
3552 case WMI_10_2_PDEV_QVIT_EVENTID:
3553 ath10k_wmi_event_pdev_qvit(ar, skb);
3554 break;
3555 case WMI_10_2_WLAN_PROFILE_DATA_EVENTID:
3556 ath10k_wmi_event_wlan_profile_data(ar, skb);
3557 break;
3558 case WMI_10_2_RTT_MEASUREMENT_REPORT_EVENTID:
3559 ath10k_wmi_event_rtt_measurement_report(ar, skb);
3560 break;
3561 case WMI_10_2_TSF_MEASUREMENT_REPORT_EVENTID:
3562 ath10k_wmi_event_tsf_measurement_report(ar, skb);
3563 break;
3564 case WMI_10_2_RTT_ERROR_REPORT_EVENTID:
3565 ath10k_wmi_event_rtt_error_report(ar, skb);
3566 break;
3567 case WMI_10_2_WOW_WAKEUP_HOST_EVENTID:
3568 ath10k_wmi_event_wow_wakeup_host(ar, skb);
3569 break;
3570 case WMI_10_2_DCS_INTERFERENCE_EVENTID:
3571 ath10k_wmi_event_dcs_interference(ar, skb);
3572 break;
3573 case WMI_10_2_PDEV_TPC_CONFIG_EVENTID:
3574 ath10k_wmi_event_pdev_tpc_config(ar, skb);
3575 break;
3576 case WMI_10_2_INST_RSSI_STATS_EVENTID:
3577 ath10k_wmi_event_inst_rssi_stats(ar, skb);
3578 break;
3579 case WMI_10_2_VDEV_STANDBY_REQ_EVENTID:
3580 ath10k_wmi_event_vdev_standby_req(ar, skb);
3581 break;
3582 case WMI_10_2_VDEV_RESUME_REQ_EVENTID:
3583 ath10k_wmi_event_vdev_resume_req(ar, skb);
3584 break;
3585 case WMI_10_2_SERVICE_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02003586 ath10k_wmi_event_service_ready(ar, skb);
Michal Kazior24c88f72014-07-25 13:32:17 +02003587 break;
3588 case WMI_10_2_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02003589 ath10k_wmi_event_ready(ar, skb);
Michal Kazior24c88f72014-07-25 13:32:17 +02003590 break;
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02003591 case WMI_10_2_PDEV_TEMPERATURE_EVENTID:
3592 ath10k_wmi_event_temperature(ar, skb);
3593 break;
Michal Kazior24c88f72014-07-25 13:32:17 +02003594 case WMI_10_2_RTT_KEEPALIVE_EVENTID:
3595 case WMI_10_2_GPIO_INPUT_EVENTID:
3596 case WMI_10_2_PEER_RATECODE_LIST_EVENTID:
3597 case WMI_10_2_GENERIC_BUFFER_EVENTID:
3598 case WMI_10_2_MCAST_BUF_RELEASE_EVENTID:
3599 case WMI_10_2_MCAST_LIST_AGEOUT_EVENTID:
3600 case WMI_10_2_WDS_PEER_EVENTID:
Michal Kazior7aa7a722014-08-25 12:09:38 +02003601 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior24c88f72014-07-25 13:32:17 +02003602 "received event id %d not implemented\n", id);
3603 break;
3604 default:
Michal Kazior7aa7a722014-08-25 12:09:38 +02003605 ath10k_warn(ar, "Unknown eventid: %d\n", id);
Michal Kazior24c88f72014-07-25 13:32:17 +02003606 break;
3607 }
3608
3609 dev_kfree_skb(skb);
3610}
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02003611
Bartosz Markowskice428702013-09-26 17:47:05 +02003612static void ath10k_wmi_process_rx(struct ath10k *ar, struct sk_buff *skb)
3613{
Michal Kaziord7579d12014-12-03 10:10:54 +02003614 int ret;
3615
3616 ret = ath10k_wmi_rx(ar, skb);
3617 if (ret)
3618 ath10k_warn(ar, "failed to process wmi rx: %d\n", ret);
Bartosz Markowskice428702013-09-26 17:47:05 +02003619}
3620
Michal Kazior95bf21f2014-05-16 17:15:39 +03003621int ath10k_wmi_connect(struct ath10k *ar)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003622{
3623 int status;
3624 struct ath10k_htc_svc_conn_req conn_req;
3625 struct ath10k_htc_svc_conn_resp conn_resp;
3626
3627 memset(&conn_req, 0, sizeof(conn_req));
3628 memset(&conn_resp, 0, sizeof(conn_resp));
3629
3630 /* these fields are the same for all service endpoints */
3631 conn_req.ep_ops.ep_tx_complete = ath10k_wmi_htc_tx_complete;
3632 conn_req.ep_ops.ep_rx_complete = ath10k_wmi_process_rx;
Michal Kaziorbe8b3942013-09-13 14:16:54 +02003633 conn_req.ep_ops.ep_tx_credits = ath10k_wmi_op_ep_tx_credits;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003634
3635 /* connect to control service */
3636 conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL;
3637
Michal Kaziorcd003fa2013-07-05 16:15:13 +03003638 status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003639 if (status) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003640 ath10k_warn(ar, "failed to connect to WMI CONTROL service status: %d\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +03003641 status);
3642 return status;
3643 }
3644
3645 ar->wmi.eid = conn_resp.eid;
3646 return 0;
3647}
3648
Michal Kaziord7579d12014-12-03 10:10:54 +02003649static struct sk_buff *
3650ath10k_wmi_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16 rd5g,
3651 u16 ctl2g, u16 ctl5g,
3652 enum wmi_dfs_region dfs_reg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003653{
3654 struct wmi_pdev_set_regdomain_cmd *cmd;
3655 struct sk_buff *skb;
3656
Michal Kazior7aa7a722014-08-25 12:09:38 +02003657 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03003658 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02003659 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003660
3661 cmd = (struct wmi_pdev_set_regdomain_cmd *)skb->data;
3662 cmd->reg_domain = __cpu_to_le32(rd);
3663 cmd->reg_domain_2G = __cpu_to_le32(rd2g);
3664 cmd->reg_domain_5G = __cpu_to_le32(rd5g);
3665 cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g);
3666 cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
3667
Michal Kazior7aa7a722014-08-25 12:09:38 +02003668 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03003669 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x\n",
3670 rd, rd2g, rd5g, ctl2g, ctl5g);
Michal Kaziord7579d12014-12-03 10:10:54 +02003671 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003672}
3673
Michal Kaziord7579d12014-12-03 10:10:54 +02003674static struct sk_buff *
3675ath10k_wmi_10x_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16
3676 rd5g, u16 ctl2g, u16 ctl5g,
3677 enum wmi_dfs_region dfs_reg)
Marek Puzyniak821af6a2014-03-21 17:46:57 +02003678{
3679 struct wmi_pdev_set_regdomain_cmd_10x *cmd;
3680 struct sk_buff *skb;
3681
Michal Kazior7aa7a722014-08-25 12:09:38 +02003682 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Marek Puzyniak821af6a2014-03-21 17:46:57 +02003683 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02003684 return ERR_PTR(-ENOMEM);
Marek Puzyniak821af6a2014-03-21 17:46:57 +02003685
3686 cmd = (struct wmi_pdev_set_regdomain_cmd_10x *)skb->data;
3687 cmd->reg_domain = __cpu_to_le32(rd);
3688 cmd->reg_domain_2G = __cpu_to_le32(rd2g);
3689 cmd->reg_domain_5G = __cpu_to_le32(rd5g);
3690 cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g);
3691 cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
3692 cmd->dfs_domain = __cpu_to_le32(dfs_reg);
3693
Michal Kazior7aa7a722014-08-25 12:09:38 +02003694 ath10k_dbg(ar, ATH10K_DBG_WMI,
Marek Puzyniak821af6a2014-03-21 17:46:57 +02003695 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x dfs_region %x\n",
3696 rd, rd2g, rd5g, ctl2g, ctl5g, dfs_reg);
Michal Kaziord7579d12014-12-03 10:10:54 +02003697 return skb;
Marek Puzyniak821af6a2014-03-21 17:46:57 +02003698}
3699
Michal Kaziord7579d12014-12-03 10:10:54 +02003700static struct sk_buff *
3701ath10k_wmi_op_gen_pdev_suspend(struct ath10k *ar, u32 suspend_opt)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003702{
3703 struct wmi_pdev_suspend_cmd *cmd;
3704 struct sk_buff *skb;
3705
Michal Kazior7aa7a722014-08-25 12:09:38 +02003706 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03003707 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02003708 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003709
3710 cmd = (struct wmi_pdev_suspend_cmd *)skb->data;
Marek Puzyniak00f54822014-02-10 17:14:24 +01003711 cmd->suspend_opt = __cpu_to_le32(suspend_opt);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003712
Michal Kaziord7579d12014-12-03 10:10:54 +02003713 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003714}
3715
Michal Kaziord7579d12014-12-03 10:10:54 +02003716static struct sk_buff *
3717ath10k_wmi_op_gen_pdev_resume(struct ath10k *ar)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003718{
3719 struct sk_buff *skb;
3720
Michal Kazior7aa7a722014-08-25 12:09:38 +02003721 skb = ath10k_wmi_alloc_skb(ar, 0);
Michal Kaziord7579d12014-12-03 10:10:54 +02003722 if (!skb)
3723 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003724
Michal Kaziord7579d12014-12-03 10:10:54 +02003725 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003726}
3727
Michal Kaziord7579d12014-12-03 10:10:54 +02003728static struct sk_buff *
3729ath10k_wmi_op_gen_pdev_set_param(struct ath10k *ar, u32 id, u32 value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003730{
3731 struct wmi_pdev_set_param_cmd *cmd;
3732 struct sk_buff *skb;
3733
Bartosz Markowski226a3392013-09-26 17:47:16 +02003734 if (id == WMI_PDEV_PARAM_UNSUPPORTED) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003735 ath10k_warn(ar, "pdev param %d not supported by firmware\n",
3736 id);
Michal Kaziord7579d12014-12-03 10:10:54 +02003737 return ERR_PTR(-EOPNOTSUPP);
Bartosz Markowski226a3392013-09-26 17:47:16 +02003738 }
3739
Michal Kazior7aa7a722014-08-25 12:09:38 +02003740 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03003741 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02003742 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003743
3744 cmd = (struct wmi_pdev_set_param_cmd *)skb->data;
3745 cmd->param_id = __cpu_to_le32(id);
3746 cmd->param_value = __cpu_to_le32(value);
3747
Michal Kazior7aa7a722014-08-25 12:09:38 +02003748 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set param %d value %d\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +03003749 id, value);
Michal Kaziord7579d12014-12-03 10:10:54 +02003750 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003751}
3752
Michal Kazior0226d602014-12-03 10:11:22 +02003753void ath10k_wmi_put_host_mem_chunks(struct ath10k *ar,
3754 struct wmi_host_mem_chunks *chunks)
Michal Kaziorcf9fca82014-09-18 15:21:22 +02003755{
3756 struct host_memory_chunk *chunk;
3757 int i;
3758
3759 chunks->count = __cpu_to_le32(ar->wmi.num_mem_chunks);
3760
3761 for (i = 0; i < ar->wmi.num_mem_chunks; i++) {
3762 chunk = &chunks->items[i];
3763 chunk->ptr = __cpu_to_le32(ar->wmi.mem_chunks[i].paddr);
3764 chunk->size = __cpu_to_le32(ar->wmi.mem_chunks[i].len);
3765 chunk->req_id = __cpu_to_le32(ar->wmi.mem_chunks[i].req_id);
3766
3767 ath10k_dbg(ar, ATH10K_DBG_WMI,
3768 "wmi chunk %d len %d requested, addr 0x%llx\n",
3769 i,
3770 ar->wmi.mem_chunks[i].len,
3771 (unsigned long long)ar->wmi.mem_chunks[i].paddr);
3772 }
3773}
3774
Michal Kaziord7579d12014-12-03 10:10:54 +02003775static struct sk_buff *ath10k_wmi_op_gen_init(struct ath10k *ar)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003776{
3777 struct wmi_init_cmd *cmd;
3778 struct sk_buff *buf;
3779 struct wmi_resource_config config = {};
Bartosz Markowskib3effe62013-09-26 17:47:11 +02003780 u32 len, val;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003781
3782 config.num_vdevs = __cpu_to_le32(TARGET_NUM_VDEVS);
Michal Kaziorcfd10612014-11-25 15:16:05 +01003783 config.num_peers = __cpu_to_le32(TARGET_NUM_PEERS);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003784 config.num_offload_peers = __cpu_to_le32(TARGET_NUM_OFFLOAD_PEERS);
3785
3786 config.num_offload_reorder_bufs =
3787 __cpu_to_le32(TARGET_NUM_OFFLOAD_REORDER_BUFS);
3788
3789 config.num_peer_keys = __cpu_to_le32(TARGET_NUM_PEER_KEYS);
3790 config.num_tids = __cpu_to_le32(TARGET_NUM_TIDS);
3791 config.ast_skid_limit = __cpu_to_le32(TARGET_AST_SKID_LIMIT);
3792 config.tx_chain_mask = __cpu_to_le32(TARGET_TX_CHAIN_MASK);
3793 config.rx_chain_mask = __cpu_to_le32(TARGET_RX_CHAIN_MASK);
3794 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
3795 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
3796 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
3797 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_RX_TIMEOUT_HI_PRI);
3798 config.rx_decap_mode = __cpu_to_le32(TARGET_RX_DECAP_MODE);
3799
3800 config.scan_max_pending_reqs =
3801 __cpu_to_le32(TARGET_SCAN_MAX_PENDING_REQS);
3802
3803 config.bmiss_offload_max_vdev =
3804 __cpu_to_le32(TARGET_BMISS_OFFLOAD_MAX_VDEV);
3805
3806 config.roam_offload_max_vdev =
3807 __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_VDEV);
3808
3809 config.roam_offload_max_ap_profiles =
3810 __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_AP_PROFILES);
3811
3812 config.num_mcast_groups = __cpu_to_le32(TARGET_NUM_MCAST_GROUPS);
3813 config.num_mcast_table_elems =
3814 __cpu_to_le32(TARGET_NUM_MCAST_TABLE_ELEMS);
3815
3816 config.mcast2ucast_mode = __cpu_to_le32(TARGET_MCAST2UCAST_MODE);
3817 config.tx_dbg_log_size = __cpu_to_le32(TARGET_TX_DBG_LOG_SIZE);
3818 config.num_wds_entries = __cpu_to_le32(TARGET_NUM_WDS_ENTRIES);
3819 config.dma_burst_size = __cpu_to_le32(TARGET_DMA_BURST_SIZE);
3820 config.mac_aggr_delim = __cpu_to_le32(TARGET_MAC_AGGR_DELIM);
3821
3822 val = TARGET_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
3823 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
3824
3825 config.vow_config = __cpu_to_le32(TARGET_VOW_CONFIG);
3826
3827 config.gtk_offload_max_vdev =
3828 __cpu_to_le32(TARGET_GTK_OFFLOAD_MAX_VDEV);
3829
3830 config.num_msdu_desc = __cpu_to_le32(TARGET_NUM_MSDU_DESC);
3831 config.max_frag_entries = __cpu_to_le32(TARGET_MAX_FRAG_ENTRIES);
3832
Bartosz Markowskib3effe62013-09-26 17:47:11 +02003833 len = sizeof(*cmd) +
3834 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
3835
Michal Kazior7aa7a722014-08-25 12:09:38 +02003836 buf = ath10k_wmi_alloc_skb(ar, len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003837 if (!buf)
Michal Kaziord7579d12014-12-03 10:10:54 +02003838 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003839
3840 cmd = (struct wmi_init_cmd *)buf->data;
Bartosz Markowskib3effe62013-09-26 17:47:11 +02003841
Kalle Valo5e3dd152013-06-12 20:52:10 +03003842 memcpy(&cmd->resource_config, &config, sizeof(config));
Michal Kaziorcf9fca82014-09-18 15:21:22 +02003843 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003844
Michal Kazior7aa7a722014-08-25 12:09:38 +02003845 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02003846 return buf;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003847}
3848
Michal Kaziord7579d12014-12-03 10:10:54 +02003849static struct sk_buff *ath10k_wmi_10_1_op_gen_init(struct ath10k *ar)
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003850{
3851 struct wmi_init_cmd_10x *cmd;
3852 struct sk_buff *buf;
3853 struct wmi_resource_config_10x config = {};
3854 u32 len, val;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003855
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02003856 config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS);
3857 config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS);
3858 config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS);
3859 config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS);
3860 config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT);
3861 config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK);
3862 config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK);
3863 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
3864 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
3865 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
3866 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI);
3867 config.rx_decap_mode = __cpu_to_le32(TARGET_10X_RX_DECAP_MODE);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003868
3869 config.scan_max_pending_reqs =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02003870 __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003871
3872 config.bmiss_offload_max_vdev =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02003873 __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003874
3875 config.roam_offload_max_vdev =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02003876 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003877
3878 config.roam_offload_max_ap_profiles =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02003879 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003880
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02003881 config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003882 config.num_mcast_table_elems =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02003883 __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003884
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02003885 config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE);
3886 config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE);
3887 config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES);
3888 config.dma_burst_size = __cpu_to_le32(TARGET_10X_DMA_BURST_SIZE);
3889 config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003890
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02003891 val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003892 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
3893
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02003894 config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003895
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02003896 config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC);
3897 config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003898
3899 len = sizeof(*cmd) +
3900 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
3901
Michal Kazior7aa7a722014-08-25 12:09:38 +02003902 buf = ath10k_wmi_alloc_skb(ar, len);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003903 if (!buf)
Michal Kaziord7579d12014-12-03 10:10:54 +02003904 return ERR_PTR(-ENOMEM);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003905
3906 cmd = (struct wmi_init_cmd_10x *)buf->data;
3907
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003908 memcpy(&cmd->resource_config, &config, sizeof(config));
Michal Kaziorcf9fca82014-09-18 15:21:22 +02003909 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003910
Michal Kazior7aa7a722014-08-25 12:09:38 +02003911 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10x\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02003912 return buf;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003913}
3914
Michal Kaziord7579d12014-12-03 10:10:54 +02003915static struct sk_buff *ath10k_wmi_10_2_op_gen_init(struct ath10k *ar)
Michal Kazior24c88f72014-07-25 13:32:17 +02003916{
3917 struct wmi_init_cmd_10_2 *cmd;
3918 struct sk_buff *buf;
3919 struct wmi_resource_config_10x config = {};
Sujith Manoharanb6c8e282015-01-12 12:30:02 +02003920 u32 len, val, features;
Michal Kazior24c88f72014-07-25 13:32:17 +02003921
3922 config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS);
3923 config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS);
3924 config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS);
3925 config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS);
3926 config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT);
3927 config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK);
3928 config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK);
3929 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
3930 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
3931 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
3932 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI);
3933 config.rx_decap_mode = __cpu_to_le32(TARGET_10X_RX_DECAP_MODE);
3934
3935 config.scan_max_pending_reqs =
3936 __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS);
3937
3938 config.bmiss_offload_max_vdev =
3939 __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV);
3940
3941 config.roam_offload_max_vdev =
3942 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV);
3943
3944 config.roam_offload_max_ap_profiles =
3945 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES);
3946
3947 config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS);
3948 config.num_mcast_table_elems =
3949 __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS);
3950
3951 config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE);
3952 config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE);
3953 config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES);
Sujith Manoharanf6603ff2015-01-12 12:30:02 +02003954 config.dma_burst_size = __cpu_to_le32(TARGET_10_2_DMA_BURST_SIZE);
Michal Kazior24c88f72014-07-25 13:32:17 +02003955 config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM);
3956
3957 val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
3958 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
3959
3960 config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG);
3961
3962 config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC);
3963 config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES);
3964
3965 len = sizeof(*cmd) +
3966 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
3967
Michal Kazior7aa7a722014-08-25 12:09:38 +02003968 buf = ath10k_wmi_alloc_skb(ar, len);
Michal Kazior24c88f72014-07-25 13:32:17 +02003969 if (!buf)
Michal Kaziord7579d12014-12-03 10:10:54 +02003970 return ERR_PTR(-ENOMEM);
Michal Kazior24c88f72014-07-25 13:32:17 +02003971
3972 cmd = (struct wmi_init_cmd_10_2 *)buf->data;
3973
Sujith Manoharanb6c8e282015-01-12 12:30:02 +02003974 features = WMI_10_2_RX_BATCH_MODE;
3975 cmd->resource_config.feature_mask = __cpu_to_le32(features);
3976
Michal Kazior24c88f72014-07-25 13:32:17 +02003977 memcpy(&cmd->resource_config.common, &config, sizeof(config));
Michal Kaziorcf9fca82014-09-18 15:21:22 +02003978 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
Michal Kazior24c88f72014-07-25 13:32:17 +02003979
Michal Kazior7aa7a722014-08-25 12:09:38 +02003980 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.2\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02003981 return buf;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02003982}
3983
Michal Kazior0226d602014-12-03 10:11:22 +02003984int ath10k_wmi_start_scan_verify(const struct wmi_start_scan_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003985{
Michal Kaziora6aa5da2014-09-18 15:21:27 +02003986 if (arg->ie_len && !arg->ie)
3987 return -EINVAL;
3988 if (arg->n_channels && !arg->channels)
3989 return -EINVAL;
3990 if (arg->n_ssids && !arg->ssids)
3991 return -EINVAL;
3992 if (arg->n_bssids && !arg->bssids)
3993 return -EINVAL;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003994
Michal Kaziora6aa5da2014-09-18 15:21:27 +02003995 if (arg->ie_len > WLAN_SCAN_PARAMS_MAX_IE_LEN)
3996 return -EINVAL;
3997 if (arg->n_channels > ARRAY_SIZE(arg->channels))
3998 return -EINVAL;
3999 if (arg->n_ssids > WLAN_SCAN_PARAMS_MAX_SSID)
4000 return -EINVAL;
4001 if (arg->n_bssids > WLAN_SCAN_PARAMS_MAX_BSSID)
4002 return -EINVAL;
4003
4004 return 0;
4005}
4006
4007static size_t
4008ath10k_wmi_start_scan_tlvs_len(const struct wmi_start_scan_arg *arg)
4009{
4010 int len = 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004011
4012 if (arg->ie_len) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03004013 len += sizeof(struct wmi_ie_data);
4014 len += roundup(arg->ie_len, 4);
4015 }
4016
4017 if (arg->n_channels) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03004018 len += sizeof(struct wmi_chan_list);
4019 len += sizeof(__le32) * arg->n_channels;
4020 }
4021
4022 if (arg->n_ssids) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03004023 len += sizeof(struct wmi_ssid_list);
4024 len += sizeof(struct wmi_ssid) * arg->n_ssids;
4025 }
4026
4027 if (arg->n_bssids) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03004028 len += sizeof(struct wmi_bssid_list);
4029 len += sizeof(struct wmi_mac_addr) * arg->n_bssids;
4030 }
4031
4032 return len;
4033}
4034
Michal Kazior0226d602014-12-03 10:11:22 +02004035void ath10k_wmi_put_start_scan_common(struct wmi_start_scan_common *cmn,
4036 const struct wmi_start_scan_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004037{
Kalle Valo5e3dd152013-06-12 20:52:10 +03004038 u32 scan_id;
4039 u32 scan_req_id;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004040
4041 scan_id = WMI_HOST_SCAN_REQ_ID_PREFIX;
4042 scan_id |= arg->scan_id;
4043
4044 scan_req_id = WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
4045 scan_req_id |= arg->scan_req_id;
4046
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004047 cmn->scan_id = __cpu_to_le32(scan_id);
4048 cmn->scan_req_id = __cpu_to_le32(scan_req_id);
4049 cmn->vdev_id = __cpu_to_le32(arg->vdev_id);
4050 cmn->scan_priority = __cpu_to_le32(arg->scan_priority);
4051 cmn->notify_scan_events = __cpu_to_le32(arg->notify_scan_events);
4052 cmn->dwell_time_active = __cpu_to_le32(arg->dwell_time_active);
4053 cmn->dwell_time_passive = __cpu_to_le32(arg->dwell_time_passive);
4054 cmn->min_rest_time = __cpu_to_le32(arg->min_rest_time);
4055 cmn->max_rest_time = __cpu_to_le32(arg->max_rest_time);
4056 cmn->repeat_probe_time = __cpu_to_le32(arg->repeat_probe_time);
4057 cmn->probe_spacing_time = __cpu_to_le32(arg->probe_spacing_time);
4058 cmn->idle_time = __cpu_to_le32(arg->idle_time);
4059 cmn->max_scan_time = __cpu_to_le32(arg->max_scan_time);
4060 cmn->probe_delay = __cpu_to_le32(arg->probe_delay);
4061 cmn->scan_ctrl_flags = __cpu_to_le32(arg->scan_ctrl_flags);
4062}
Kalle Valo5e3dd152013-06-12 20:52:10 +03004063
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004064static void
4065ath10k_wmi_put_start_scan_tlvs(struct wmi_start_scan_tlvs *tlvs,
4066 const struct wmi_start_scan_arg *arg)
4067{
4068 struct wmi_ie_data *ie;
4069 struct wmi_chan_list *channels;
4070 struct wmi_ssid_list *ssids;
4071 struct wmi_bssid_list *bssids;
4072 void *ptr = tlvs->tlvs;
4073 int i;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004074
4075 if (arg->n_channels) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004076 channels = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004077 channels->tag = __cpu_to_le32(WMI_CHAN_LIST_TAG);
4078 channels->num_chan = __cpu_to_le32(arg->n_channels);
4079
4080 for (i = 0; i < arg->n_channels; i++)
Michal Kazior24c88f72014-07-25 13:32:17 +02004081 channels->channel_list[i].freq =
4082 __cpu_to_le16(arg->channels[i]);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004083
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004084 ptr += sizeof(*channels);
4085 ptr += sizeof(__le32) * arg->n_channels;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004086 }
4087
4088 if (arg->n_ssids) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004089 ssids = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004090 ssids->tag = __cpu_to_le32(WMI_SSID_LIST_TAG);
4091 ssids->num_ssids = __cpu_to_le32(arg->n_ssids);
4092
4093 for (i = 0; i < arg->n_ssids; i++) {
4094 ssids->ssids[i].ssid_len =
4095 __cpu_to_le32(arg->ssids[i].len);
4096 memcpy(&ssids->ssids[i].ssid,
4097 arg->ssids[i].ssid,
4098 arg->ssids[i].len);
4099 }
4100
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004101 ptr += sizeof(*ssids);
4102 ptr += sizeof(struct wmi_ssid) * arg->n_ssids;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004103 }
4104
4105 if (arg->n_bssids) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004106 bssids = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004107 bssids->tag = __cpu_to_le32(WMI_BSSID_LIST_TAG);
4108 bssids->num_bssid = __cpu_to_le32(arg->n_bssids);
4109
4110 for (i = 0; i < arg->n_bssids; i++)
4111 memcpy(&bssids->bssid_list[i],
4112 arg->bssids[i].bssid,
4113 ETH_ALEN);
4114
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004115 ptr += sizeof(*bssids);
4116 ptr += sizeof(struct wmi_mac_addr) * arg->n_bssids;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004117 }
4118
4119 if (arg->ie_len) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004120 ie = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004121 ie->tag = __cpu_to_le32(WMI_IE_TAG);
4122 ie->ie_len = __cpu_to_le32(arg->ie_len);
4123 memcpy(ie->ie_data, arg->ie, arg->ie_len);
4124
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004125 ptr += sizeof(*ie);
4126 ptr += roundup(arg->ie_len, 4);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004127 }
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004128}
Kalle Valo5e3dd152013-06-12 20:52:10 +03004129
Michal Kaziord7579d12014-12-03 10:10:54 +02004130static struct sk_buff *
4131ath10k_wmi_op_gen_start_scan(struct ath10k *ar,
4132 const struct wmi_start_scan_arg *arg)
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004133{
Michal Kaziord7579d12014-12-03 10:10:54 +02004134 struct wmi_start_scan_cmd *cmd;
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004135 struct sk_buff *skb;
4136 size_t len;
4137 int ret;
4138
4139 ret = ath10k_wmi_start_scan_verify(arg);
4140 if (ret)
Michal Kaziord7579d12014-12-03 10:10:54 +02004141 return ERR_PTR(ret);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004142
Michal Kaziord7579d12014-12-03 10:10:54 +02004143 len = sizeof(*cmd) + ath10k_wmi_start_scan_tlvs_len(arg);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004144 skb = ath10k_wmi_alloc_skb(ar, len);
4145 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004146 return ERR_PTR(-ENOMEM);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004147
Michal Kaziord7579d12014-12-03 10:10:54 +02004148 cmd = (struct wmi_start_scan_cmd *)skb->data;
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004149
Michal Kaziord7579d12014-12-03 10:10:54 +02004150 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
4151 ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02004152
Michal Kaziord7579d12014-12-03 10:10:54 +02004153 cmd->burst_duration_ms = __cpu_to_le32(0);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004154
Michal Kazior7aa7a722014-08-25 12:09:38 +02004155 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi start scan\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02004156 return skb;
4157}
4158
4159static struct sk_buff *
4160ath10k_wmi_10x_op_gen_start_scan(struct ath10k *ar,
4161 const struct wmi_start_scan_arg *arg)
4162{
4163 struct wmi_10x_start_scan_cmd *cmd;
4164 struct sk_buff *skb;
4165 size_t len;
4166 int ret;
4167
4168 ret = ath10k_wmi_start_scan_verify(arg);
4169 if (ret)
4170 return ERR_PTR(ret);
4171
4172 len = sizeof(*cmd) + ath10k_wmi_start_scan_tlvs_len(arg);
4173 skb = ath10k_wmi_alloc_skb(ar, len);
4174 if (!skb)
4175 return ERR_PTR(-ENOMEM);
4176
4177 cmd = (struct wmi_10x_start_scan_cmd *)skb->data;
4178
4179 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
4180 ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
4181
4182 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi 10x start scan\n");
4183 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004184}
4185
4186void ath10k_wmi_start_scan_init(struct ath10k *ar,
4187 struct wmi_start_scan_arg *arg)
4188{
4189 /* setup commonly used values */
4190 arg->scan_req_id = 1;
4191 arg->scan_priority = WMI_SCAN_PRIORITY_LOW;
4192 arg->dwell_time_active = 50;
4193 arg->dwell_time_passive = 150;
4194 arg->min_rest_time = 50;
4195 arg->max_rest_time = 500;
4196 arg->repeat_probe_time = 0;
4197 arg->probe_spacing_time = 0;
4198 arg->idle_time = 0;
Bartosz Markowskic3228922013-10-02 08:48:52 +02004199 arg->max_scan_time = 20000;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004200 arg->probe_delay = 5;
4201 arg->notify_scan_events = WMI_SCAN_EVENT_STARTED
4202 | WMI_SCAN_EVENT_COMPLETED
4203 | WMI_SCAN_EVENT_BSS_CHANNEL
4204 | WMI_SCAN_EVENT_FOREIGN_CHANNEL
4205 | WMI_SCAN_EVENT_DEQUEUED;
4206 arg->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
4207 arg->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
4208 arg->n_bssids = 1;
4209 arg->bssids[0].bssid = "\xFF\xFF\xFF\xFF\xFF\xFF";
4210}
4211
Michal Kaziord7579d12014-12-03 10:10:54 +02004212static struct sk_buff *
4213ath10k_wmi_op_gen_stop_scan(struct ath10k *ar,
4214 const struct wmi_stop_scan_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004215{
4216 struct wmi_stop_scan_cmd *cmd;
4217 struct sk_buff *skb;
4218 u32 scan_id;
4219 u32 req_id;
4220
4221 if (arg->req_id > 0xFFF)
Michal Kaziord7579d12014-12-03 10:10:54 +02004222 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004223 if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF)
Michal Kaziord7579d12014-12-03 10:10:54 +02004224 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004225
Michal Kazior7aa7a722014-08-25 12:09:38 +02004226 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004227 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004228 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004229
4230 scan_id = arg->u.scan_id;
4231 scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX;
4232
4233 req_id = arg->req_id;
4234 req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
4235
4236 cmd = (struct wmi_stop_scan_cmd *)skb->data;
4237 cmd->req_type = __cpu_to_le32(arg->req_type);
4238 cmd->vdev_id = __cpu_to_le32(arg->u.vdev_id);
4239 cmd->scan_id = __cpu_to_le32(scan_id);
4240 cmd->scan_req_id = __cpu_to_le32(req_id);
4241
Michal Kazior7aa7a722014-08-25 12:09:38 +02004242 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03004243 "wmi stop scan reqid %d req_type %d vdev/scan_id %d\n",
4244 arg->req_id, arg->req_type, arg->u.scan_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02004245 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004246}
4247
Michal Kaziord7579d12014-12-03 10:10:54 +02004248static struct sk_buff *
4249ath10k_wmi_op_gen_vdev_create(struct ath10k *ar, u32 vdev_id,
4250 enum wmi_vdev_type type,
4251 enum wmi_vdev_subtype subtype,
4252 const u8 macaddr[ETH_ALEN])
Kalle Valo5e3dd152013-06-12 20:52:10 +03004253{
4254 struct wmi_vdev_create_cmd *cmd;
4255 struct sk_buff *skb;
4256
Michal Kazior7aa7a722014-08-25 12:09:38 +02004257 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004258 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004259 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004260
4261 cmd = (struct wmi_vdev_create_cmd *)skb->data;
4262 cmd->vdev_id = __cpu_to_le32(vdev_id);
4263 cmd->vdev_type = __cpu_to_le32(type);
4264 cmd->vdev_subtype = __cpu_to_le32(subtype);
Kalle Valob25f32c2014-09-14 12:50:49 +03004265 ether_addr_copy(cmd->vdev_macaddr.addr, macaddr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004266
Michal Kazior7aa7a722014-08-25 12:09:38 +02004267 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03004268 "WMI vdev create: id %d type %d subtype %d macaddr %pM\n",
4269 vdev_id, type, subtype, macaddr);
Michal Kaziord7579d12014-12-03 10:10:54 +02004270 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004271}
4272
Michal Kaziord7579d12014-12-03 10:10:54 +02004273static struct sk_buff *
4274ath10k_wmi_op_gen_vdev_delete(struct ath10k *ar, u32 vdev_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004275{
4276 struct wmi_vdev_delete_cmd *cmd;
4277 struct sk_buff *skb;
4278
Michal Kazior7aa7a722014-08-25 12:09:38 +02004279 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004280 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004281 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004282
4283 cmd = (struct wmi_vdev_delete_cmd *)skb->data;
4284 cmd->vdev_id = __cpu_to_le32(vdev_id);
4285
Michal Kazior7aa7a722014-08-25 12:09:38 +02004286 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03004287 "WMI vdev delete id %d\n", vdev_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02004288 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004289}
4290
Michal Kaziord7579d12014-12-03 10:10:54 +02004291static struct sk_buff *
4292ath10k_wmi_op_gen_vdev_start(struct ath10k *ar,
4293 const struct wmi_vdev_start_request_arg *arg,
4294 bool restart)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004295{
4296 struct wmi_vdev_start_request_cmd *cmd;
4297 struct sk_buff *skb;
4298 const char *cmdname;
4299 u32 flags = 0;
4300
Kalle Valo5e3dd152013-06-12 20:52:10 +03004301 if (WARN_ON(arg->ssid && arg->ssid_len == 0))
Michal Kaziord7579d12014-12-03 10:10:54 +02004302 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004303 if (WARN_ON(arg->hidden_ssid && !arg->ssid))
Michal Kaziord7579d12014-12-03 10:10:54 +02004304 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004305 if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid)))
Michal Kaziord7579d12014-12-03 10:10:54 +02004306 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004307
Michal Kaziord7579d12014-12-03 10:10:54 +02004308 if (restart)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004309 cmdname = "restart";
4310 else
Michal Kaziord7579d12014-12-03 10:10:54 +02004311 cmdname = "start";
Kalle Valo5e3dd152013-06-12 20:52:10 +03004312
Michal Kazior7aa7a722014-08-25 12:09:38 +02004313 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004314 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004315 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004316
4317 if (arg->hidden_ssid)
4318 flags |= WMI_VDEV_START_HIDDEN_SSID;
4319 if (arg->pmf_enabled)
4320 flags |= WMI_VDEV_START_PMF_ENABLED;
4321
4322 cmd = (struct wmi_vdev_start_request_cmd *)skb->data;
4323 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
4324 cmd->disable_hw_ack = __cpu_to_le32(arg->disable_hw_ack);
4325 cmd->beacon_interval = __cpu_to_le32(arg->bcn_intval);
4326 cmd->dtim_period = __cpu_to_le32(arg->dtim_period);
4327 cmd->flags = __cpu_to_le32(flags);
4328 cmd->bcn_tx_rate = __cpu_to_le32(arg->bcn_tx_rate);
4329 cmd->bcn_tx_power = __cpu_to_le32(arg->bcn_tx_power);
4330
4331 if (arg->ssid) {
4332 cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len);
4333 memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len);
4334 }
4335
Michal Kazior2d667212014-09-18 15:21:21 +02004336 ath10k_wmi_put_wmi_channel(&cmd->chan, &arg->channel);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004337
Michal Kazior7aa7a722014-08-25 12:09:38 +02004338 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo8cc7f262014-09-14 12:50:39 +03004339 "wmi vdev %s id 0x%x flags: 0x%0X, freq %d, mode %d, ch_flags: 0x%0X, max_power: %d\n",
4340 cmdname, arg->vdev_id,
Marek Puzyniake8a50f82013-11-20 09:59:47 +02004341 flags, arg->channel.freq, arg->channel.mode,
4342 cmd->chan.flags, arg->channel.max_power);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004343
Michal Kaziord7579d12014-12-03 10:10:54 +02004344 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004345}
4346
Michal Kaziord7579d12014-12-03 10:10:54 +02004347static struct sk_buff *
4348ath10k_wmi_op_gen_vdev_stop(struct ath10k *ar, u32 vdev_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004349{
4350 struct wmi_vdev_stop_cmd *cmd;
4351 struct sk_buff *skb;
4352
Michal Kazior7aa7a722014-08-25 12:09:38 +02004353 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004354 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004355 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004356
4357 cmd = (struct wmi_vdev_stop_cmd *)skb->data;
4358 cmd->vdev_id = __cpu_to_le32(vdev_id);
4359
Michal Kazior7aa7a722014-08-25 12:09:38 +02004360 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi vdev stop id 0x%x\n", vdev_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02004361 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004362}
4363
Michal Kaziord7579d12014-12-03 10:10:54 +02004364static struct sk_buff *
4365ath10k_wmi_op_gen_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid,
4366 const u8 *bssid)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004367{
4368 struct wmi_vdev_up_cmd *cmd;
4369 struct sk_buff *skb;
4370
Michal Kazior7aa7a722014-08-25 12:09:38 +02004371 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004372 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004373 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004374
4375 cmd = (struct wmi_vdev_up_cmd *)skb->data;
4376 cmd->vdev_id = __cpu_to_le32(vdev_id);
4377 cmd->vdev_assoc_id = __cpu_to_le32(aid);
Kalle Valob25f32c2014-09-14 12:50:49 +03004378 ether_addr_copy(cmd->vdev_bssid.addr, bssid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004379
Michal Kazior7aa7a722014-08-25 12:09:38 +02004380 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03004381 "wmi mgmt vdev up id 0x%x assoc id %d bssid %pM\n",
4382 vdev_id, aid, bssid);
Michal Kaziord7579d12014-12-03 10:10:54 +02004383 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004384}
4385
Michal Kaziord7579d12014-12-03 10:10:54 +02004386static struct sk_buff *
4387ath10k_wmi_op_gen_vdev_down(struct ath10k *ar, u32 vdev_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004388{
4389 struct wmi_vdev_down_cmd *cmd;
4390 struct sk_buff *skb;
4391
Michal Kazior7aa7a722014-08-25 12:09:38 +02004392 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004393 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004394 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004395
4396 cmd = (struct wmi_vdev_down_cmd *)skb->data;
4397 cmd->vdev_id = __cpu_to_le32(vdev_id);
4398
Michal Kazior7aa7a722014-08-25 12:09:38 +02004399 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03004400 "wmi mgmt vdev down id 0x%x\n", vdev_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02004401 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004402}
4403
Michal Kaziord7579d12014-12-03 10:10:54 +02004404static struct sk_buff *
4405ath10k_wmi_op_gen_vdev_set_param(struct ath10k *ar, u32 vdev_id,
4406 u32 param_id, u32 param_value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004407{
4408 struct wmi_vdev_set_param_cmd *cmd;
4409 struct sk_buff *skb;
4410
Bartosz Markowski6d1506e2013-09-26 17:47:15 +02004411 if (param_id == WMI_VDEV_PARAM_UNSUPPORTED) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02004412 ath10k_dbg(ar, ATH10K_DBG_WMI,
Bartosz Markowski6d1506e2013-09-26 17:47:15 +02004413 "vdev param %d not supported by firmware\n",
4414 param_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02004415 return ERR_PTR(-EOPNOTSUPP);
Bartosz Markowski6d1506e2013-09-26 17:47:15 +02004416 }
4417
Michal Kazior7aa7a722014-08-25 12:09:38 +02004418 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004419 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004420 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004421
4422 cmd = (struct wmi_vdev_set_param_cmd *)skb->data;
4423 cmd->vdev_id = __cpu_to_le32(vdev_id);
4424 cmd->param_id = __cpu_to_le32(param_id);
4425 cmd->param_value = __cpu_to_le32(param_value);
4426
Michal Kazior7aa7a722014-08-25 12:09:38 +02004427 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03004428 "wmi vdev id 0x%x set param %d value %d\n",
4429 vdev_id, param_id, param_value);
Michal Kaziord7579d12014-12-03 10:10:54 +02004430 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004431}
4432
Michal Kaziord7579d12014-12-03 10:10:54 +02004433static struct sk_buff *
4434ath10k_wmi_op_gen_vdev_install_key(struct ath10k *ar,
4435 const struct wmi_vdev_install_key_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004436{
4437 struct wmi_vdev_install_key_cmd *cmd;
4438 struct sk_buff *skb;
4439
4440 if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL)
Michal Kaziord7579d12014-12-03 10:10:54 +02004441 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004442 if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL)
Michal Kaziord7579d12014-12-03 10:10:54 +02004443 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004444
Michal Kazior7aa7a722014-08-25 12:09:38 +02004445 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd) + arg->key_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004446 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004447 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004448
4449 cmd = (struct wmi_vdev_install_key_cmd *)skb->data;
4450 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
4451 cmd->key_idx = __cpu_to_le32(arg->key_idx);
4452 cmd->key_flags = __cpu_to_le32(arg->key_flags);
4453 cmd->key_cipher = __cpu_to_le32(arg->key_cipher);
4454 cmd->key_len = __cpu_to_le32(arg->key_len);
4455 cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len);
4456 cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len);
4457
4458 if (arg->macaddr)
Kalle Valob25f32c2014-09-14 12:50:49 +03004459 ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004460 if (arg->key_data)
4461 memcpy(cmd->key_data, arg->key_data, arg->key_len);
4462
Michal Kazior7aa7a722014-08-25 12:09:38 +02004463 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kaziore0c508a2013-07-05 16:15:17 +03004464 "wmi vdev install key idx %d cipher %d len %d\n",
4465 arg->key_idx, arg->key_cipher, arg->key_len);
Michal Kaziord7579d12014-12-03 10:10:54 +02004466 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004467}
4468
Michal Kaziord7579d12014-12-03 10:10:54 +02004469static struct sk_buff *
4470ath10k_wmi_op_gen_vdev_spectral_conf(struct ath10k *ar,
4471 const struct wmi_vdev_spectral_conf_arg *arg)
Simon Wunderlich855aed12014-08-02 09:12:54 +03004472{
4473 struct wmi_vdev_spectral_conf_cmd *cmd;
4474 struct sk_buff *skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03004475
Michal Kazior7aa7a722014-08-25 12:09:38 +02004476 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Simon Wunderlich855aed12014-08-02 09:12:54 +03004477 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004478 return ERR_PTR(-ENOMEM);
Simon Wunderlich855aed12014-08-02 09:12:54 +03004479
4480 cmd = (struct wmi_vdev_spectral_conf_cmd *)skb->data;
4481 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
4482 cmd->scan_count = __cpu_to_le32(arg->scan_count);
4483 cmd->scan_period = __cpu_to_le32(arg->scan_period);
4484 cmd->scan_priority = __cpu_to_le32(arg->scan_priority);
4485 cmd->scan_fft_size = __cpu_to_le32(arg->scan_fft_size);
4486 cmd->scan_gc_ena = __cpu_to_le32(arg->scan_gc_ena);
4487 cmd->scan_restart_ena = __cpu_to_le32(arg->scan_restart_ena);
4488 cmd->scan_noise_floor_ref = __cpu_to_le32(arg->scan_noise_floor_ref);
4489 cmd->scan_init_delay = __cpu_to_le32(arg->scan_init_delay);
4490 cmd->scan_nb_tone_thr = __cpu_to_le32(arg->scan_nb_tone_thr);
4491 cmd->scan_str_bin_thr = __cpu_to_le32(arg->scan_str_bin_thr);
4492 cmd->scan_wb_rpt_mode = __cpu_to_le32(arg->scan_wb_rpt_mode);
4493 cmd->scan_rssi_rpt_mode = __cpu_to_le32(arg->scan_rssi_rpt_mode);
4494 cmd->scan_rssi_thr = __cpu_to_le32(arg->scan_rssi_thr);
4495 cmd->scan_pwr_format = __cpu_to_le32(arg->scan_pwr_format);
4496 cmd->scan_rpt_mode = __cpu_to_le32(arg->scan_rpt_mode);
4497 cmd->scan_bin_scale = __cpu_to_le32(arg->scan_bin_scale);
4498 cmd->scan_dbm_adj = __cpu_to_le32(arg->scan_dbm_adj);
4499 cmd->scan_chn_mask = __cpu_to_le32(arg->scan_chn_mask);
4500
Michal Kaziord7579d12014-12-03 10:10:54 +02004501 return skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03004502}
4503
Michal Kaziord7579d12014-12-03 10:10:54 +02004504static struct sk_buff *
4505ath10k_wmi_op_gen_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id,
4506 u32 trigger, u32 enable)
Simon Wunderlich855aed12014-08-02 09:12:54 +03004507{
4508 struct wmi_vdev_spectral_enable_cmd *cmd;
4509 struct sk_buff *skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03004510
Michal Kazior7aa7a722014-08-25 12:09:38 +02004511 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Simon Wunderlich855aed12014-08-02 09:12:54 +03004512 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004513 return ERR_PTR(-ENOMEM);
Simon Wunderlich855aed12014-08-02 09:12:54 +03004514
4515 cmd = (struct wmi_vdev_spectral_enable_cmd *)skb->data;
4516 cmd->vdev_id = __cpu_to_le32(vdev_id);
4517 cmd->trigger_cmd = __cpu_to_le32(trigger);
4518 cmd->enable_cmd = __cpu_to_le32(enable);
4519
Michal Kaziord7579d12014-12-03 10:10:54 +02004520 return skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03004521}
4522
Michal Kaziord7579d12014-12-03 10:10:54 +02004523static struct sk_buff *
4524ath10k_wmi_op_gen_peer_create(struct ath10k *ar, u32 vdev_id,
Marek Puzyniak7390ed32015-03-30 09:51:52 +03004525 const u8 peer_addr[ETH_ALEN],
4526 enum wmi_peer_type peer_type)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004527{
4528 struct wmi_peer_create_cmd *cmd;
4529 struct sk_buff *skb;
4530
Michal Kazior7aa7a722014-08-25 12:09:38 +02004531 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004532 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004533 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004534
4535 cmd = (struct wmi_peer_create_cmd *)skb->data;
4536 cmd->vdev_id = __cpu_to_le32(vdev_id);
Kalle Valob25f32c2014-09-14 12:50:49 +03004537 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004538
Michal Kazior7aa7a722014-08-25 12:09:38 +02004539 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03004540 "wmi peer create vdev_id %d peer_addr %pM\n",
4541 vdev_id, peer_addr);
Michal Kaziord7579d12014-12-03 10:10:54 +02004542 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004543}
4544
Michal Kaziord7579d12014-12-03 10:10:54 +02004545static struct sk_buff *
4546ath10k_wmi_op_gen_peer_delete(struct ath10k *ar, u32 vdev_id,
4547 const u8 peer_addr[ETH_ALEN])
Kalle Valo5e3dd152013-06-12 20:52:10 +03004548{
4549 struct wmi_peer_delete_cmd *cmd;
4550 struct sk_buff *skb;
4551
Michal Kazior7aa7a722014-08-25 12:09:38 +02004552 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004553 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004554 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004555
4556 cmd = (struct wmi_peer_delete_cmd *)skb->data;
4557 cmd->vdev_id = __cpu_to_le32(vdev_id);
Kalle Valob25f32c2014-09-14 12:50:49 +03004558 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004559
Michal Kazior7aa7a722014-08-25 12:09:38 +02004560 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03004561 "wmi peer delete vdev_id %d peer_addr %pM\n",
4562 vdev_id, peer_addr);
Michal Kaziord7579d12014-12-03 10:10:54 +02004563 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004564}
4565
Michal Kaziord7579d12014-12-03 10:10:54 +02004566static struct sk_buff *
4567ath10k_wmi_op_gen_peer_flush(struct ath10k *ar, u32 vdev_id,
4568 const u8 peer_addr[ETH_ALEN], u32 tid_bitmap)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004569{
4570 struct wmi_peer_flush_tids_cmd *cmd;
4571 struct sk_buff *skb;
4572
Michal Kazior7aa7a722014-08-25 12:09:38 +02004573 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004574 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004575 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004576
4577 cmd = (struct wmi_peer_flush_tids_cmd *)skb->data;
4578 cmd->vdev_id = __cpu_to_le32(vdev_id);
4579 cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap);
Kalle Valob25f32c2014-09-14 12:50:49 +03004580 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004581
Michal Kazior7aa7a722014-08-25 12:09:38 +02004582 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03004583 "wmi peer flush vdev_id %d peer_addr %pM tids %08x\n",
4584 vdev_id, peer_addr, tid_bitmap);
Michal Kaziord7579d12014-12-03 10:10:54 +02004585 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004586}
4587
Michal Kaziord7579d12014-12-03 10:10:54 +02004588static struct sk_buff *
4589ath10k_wmi_op_gen_peer_set_param(struct ath10k *ar, u32 vdev_id,
4590 const u8 *peer_addr,
4591 enum wmi_peer_param param_id,
4592 u32 param_value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004593{
4594 struct wmi_peer_set_param_cmd *cmd;
4595 struct sk_buff *skb;
4596
Michal Kazior7aa7a722014-08-25 12:09:38 +02004597 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004598 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004599 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004600
4601 cmd = (struct wmi_peer_set_param_cmd *)skb->data;
4602 cmd->vdev_id = __cpu_to_le32(vdev_id);
4603 cmd->param_id = __cpu_to_le32(param_id);
4604 cmd->param_value = __cpu_to_le32(param_value);
Kalle Valob25f32c2014-09-14 12:50:49 +03004605 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004606
Michal Kazior7aa7a722014-08-25 12:09:38 +02004607 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03004608 "wmi vdev %d peer 0x%pM set param %d value %d\n",
4609 vdev_id, peer_addr, param_id, param_value);
Michal Kaziord7579d12014-12-03 10:10:54 +02004610 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004611}
4612
Michal Kaziord7579d12014-12-03 10:10:54 +02004613static struct sk_buff *
4614ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
4615 enum wmi_sta_ps_mode psmode)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004616{
4617 struct wmi_sta_powersave_mode_cmd *cmd;
4618 struct sk_buff *skb;
4619
Michal Kazior7aa7a722014-08-25 12:09:38 +02004620 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004621 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004622 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004623
4624 cmd = (struct wmi_sta_powersave_mode_cmd *)skb->data;
4625 cmd->vdev_id = __cpu_to_le32(vdev_id);
4626 cmd->sta_ps_mode = __cpu_to_le32(psmode);
4627
Michal Kazior7aa7a722014-08-25 12:09:38 +02004628 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03004629 "wmi set powersave id 0x%x mode %d\n",
4630 vdev_id, psmode);
Michal Kaziord7579d12014-12-03 10:10:54 +02004631 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004632}
4633
Michal Kaziord7579d12014-12-03 10:10:54 +02004634static struct sk_buff *
4635ath10k_wmi_op_gen_set_sta_ps(struct ath10k *ar, u32 vdev_id,
4636 enum wmi_sta_powersave_param param_id,
4637 u32 value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004638{
4639 struct wmi_sta_powersave_param_cmd *cmd;
4640 struct sk_buff *skb;
4641
Michal Kazior7aa7a722014-08-25 12:09:38 +02004642 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004643 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004644 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004645
4646 cmd = (struct wmi_sta_powersave_param_cmd *)skb->data;
4647 cmd->vdev_id = __cpu_to_le32(vdev_id);
4648 cmd->param_id = __cpu_to_le32(param_id);
4649 cmd->param_value = __cpu_to_le32(value);
4650
Michal Kazior7aa7a722014-08-25 12:09:38 +02004651 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03004652 "wmi sta ps param vdev_id 0x%x param %d value %d\n",
4653 vdev_id, param_id, value);
Michal Kaziord7579d12014-12-03 10:10:54 +02004654 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004655}
4656
Michal Kaziord7579d12014-12-03 10:10:54 +02004657static struct sk_buff *
4658ath10k_wmi_op_gen_set_ap_ps(struct ath10k *ar, u32 vdev_id, const u8 *mac,
4659 enum wmi_ap_ps_peer_param param_id, u32 value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004660{
4661 struct wmi_ap_ps_peer_cmd *cmd;
4662 struct sk_buff *skb;
4663
4664 if (!mac)
Michal Kaziord7579d12014-12-03 10:10:54 +02004665 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004666
Michal Kazior7aa7a722014-08-25 12:09:38 +02004667 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004668 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004669 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004670
4671 cmd = (struct wmi_ap_ps_peer_cmd *)skb->data;
4672 cmd->vdev_id = __cpu_to_le32(vdev_id);
4673 cmd->param_id = __cpu_to_le32(param_id);
4674 cmd->param_value = __cpu_to_le32(value);
Kalle Valob25f32c2014-09-14 12:50:49 +03004675 ether_addr_copy(cmd->peer_macaddr.addr, mac);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004676
Michal Kazior7aa7a722014-08-25 12:09:38 +02004677 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03004678 "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr %pM\n",
4679 vdev_id, param_id, value, mac);
Michal Kaziord7579d12014-12-03 10:10:54 +02004680 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004681}
4682
Michal Kaziord7579d12014-12-03 10:10:54 +02004683static struct sk_buff *
4684ath10k_wmi_op_gen_scan_chan_list(struct ath10k *ar,
4685 const struct wmi_scan_chan_list_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004686{
4687 struct wmi_scan_chan_list_cmd *cmd;
4688 struct sk_buff *skb;
4689 struct wmi_channel_arg *ch;
4690 struct wmi_channel *ci;
4691 int len;
4692 int i;
4693
4694 len = sizeof(*cmd) + arg->n_channels * sizeof(struct wmi_channel);
4695
Michal Kazior7aa7a722014-08-25 12:09:38 +02004696 skb = ath10k_wmi_alloc_skb(ar, len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004697 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004698 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004699
4700 cmd = (struct wmi_scan_chan_list_cmd *)skb->data;
4701 cmd->num_scan_chans = __cpu_to_le32(arg->n_channels);
4702
4703 for (i = 0; i < arg->n_channels; i++) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03004704 ch = &arg->channels[i];
4705 ci = &cmd->chan_info[i];
4706
Michal Kazior2d667212014-09-18 15:21:21 +02004707 ath10k_wmi_put_wmi_channel(ci, ch);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004708 }
4709
Michal Kaziord7579d12014-12-03 10:10:54 +02004710 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004711}
4712
Michal Kazior24c88f72014-07-25 13:32:17 +02004713static void
4714ath10k_wmi_peer_assoc_fill(struct ath10k *ar, void *buf,
4715 const struct wmi_peer_assoc_complete_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004716{
Michal Kazior24c88f72014-07-25 13:32:17 +02004717 struct wmi_common_peer_assoc_complete_cmd *cmd = buf;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004718
Kalle Valo5e3dd152013-06-12 20:52:10 +03004719 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
4720 cmd->peer_new_assoc = __cpu_to_le32(arg->peer_reassoc ? 0 : 1);
4721 cmd->peer_associd = __cpu_to_le32(arg->peer_aid);
4722 cmd->peer_flags = __cpu_to_le32(arg->peer_flags);
4723 cmd->peer_caps = __cpu_to_le32(arg->peer_caps);
4724 cmd->peer_listen_intval = __cpu_to_le32(arg->peer_listen_intval);
4725 cmd->peer_ht_caps = __cpu_to_le32(arg->peer_ht_caps);
4726 cmd->peer_max_mpdu = __cpu_to_le32(arg->peer_max_mpdu);
4727 cmd->peer_mpdu_density = __cpu_to_le32(arg->peer_mpdu_density);
4728 cmd->peer_rate_caps = __cpu_to_le32(arg->peer_rate_caps);
4729 cmd->peer_nss = __cpu_to_le32(arg->peer_num_spatial_streams);
4730 cmd->peer_vht_caps = __cpu_to_le32(arg->peer_vht_caps);
4731 cmd->peer_phymode = __cpu_to_le32(arg->peer_phymode);
4732
Kalle Valob25f32c2014-09-14 12:50:49 +03004733 ether_addr_copy(cmd->peer_macaddr.addr, arg->addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004734
4735 cmd->peer_legacy_rates.num_rates =
4736 __cpu_to_le32(arg->peer_legacy_rates.num_rates);
4737 memcpy(cmd->peer_legacy_rates.rates, arg->peer_legacy_rates.rates,
4738 arg->peer_legacy_rates.num_rates);
4739
4740 cmd->peer_ht_rates.num_rates =
4741 __cpu_to_le32(arg->peer_ht_rates.num_rates);
4742 memcpy(cmd->peer_ht_rates.rates, arg->peer_ht_rates.rates,
4743 arg->peer_ht_rates.num_rates);
4744
4745 cmd->peer_vht_rates.rx_max_rate =
4746 __cpu_to_le32(arg->peer_vht_rates.rx_max_rate);
4747 cmd->peer_vht_rates.rx_mcs_set =
4748 __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set);
4749 cmd->peer_vht_rates.tx_max_rate =
4750 __cpu_to_le32(arg->peer_vht_rates.tx_max_rate);
4751 cmd->peer_vht_rates.tx_mcs_set =
4752 __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set);
Michal Kazior24c88f72014-07-25 13:32:17 +02004753}
4754
4755static void
4756ath10k_wmi_peer_assoc_fill_main(struct ath10k *ar, void *buf,
4757 const struct wmi_peer_assoc_complete_arg *arg)
4758{
4759 struct wmi_main_peer_assoc_complete_cmd *cmd = buf;
4760
4761 ath10k_wmi_peer_assoc_fill(ar, buf, arg);
4762 memset(cmd->peer_ht_info, 0, sizeof(cmd->peer_ht_info));
4763}
4764
4765static void
4766ath10k_wmi_peer_assoc_fill_10_1(struct ath10k *ar, void *buf,
4767 const struct wmi_peer_assoc_complete_arg *arg)
4768{
4769 ath10k_wmi_peer_assoc_fill(ar, buf, arg);
4770}
4771
4772static void
4773ath10k_wmi_peer_assoc_fill_10_2(struct ath10k *ar, void *buf,
4774 const struct wmi_peer_assoc_complete_arg *arg)
4775{
4776 struct wmi_10_2_peer_assoc_complete_cmd *cmd = buf;
4777 int max_mcs, max_nss;
4778 u32 info0;
4779
4780 /* TODO: Is using max values okay with firmware? */
4781 max_mcs = 0xf;
4782 max_nss = 0xf;
4783
4784 info0 = SM(max_mcs, WMI_PEER_ASSOC_INFO0_MAX_MCS_IDX) |
4785 SM(max_nss, WMI_PEER_ASSOC_INFO0_MAX_NSS);
4786
4787 ath10k_wmi_peer_assoc_fill(ar, buf, arg);
4788 cmd->info0 = __cpu_to_le32(info0);
4789}
4790
Michal Kaziord7579d12014-12-03 10:10:54 +02004791static int
4792ath10k_wmi_peer_assoc_check_arg(const struct wmi_peer_assoc_complete_arg *arg)
Michal Kazior24c88f72014-07-25 13:32:17 +02004793{
Michal Kazior24c88f72014-07-25 13:32:17 +02004794 if (arg->peer_mpdu_density > 16)
4795 return -EINVAL;
4796 if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES)
4797 return -EINVAL;
4798 if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES)
4799 return -EINVAL;
4800
Michal Kaziord7579d12014-12-03 10:10:54 +02004801 return 0;
4802}
4803
4804static struct sk_buff *
4805ath10k_wmi_op_gen_peer_assoc(struct ath10k *ar,
4806 const struct wmi_peer_assoc_complete_arg *arg)
4807{
4808 size_t len = sizeof(struct wmi_main_peer_assoc_complete_cmd);
4809 struct sk_buff *skb;
4810 int ret;
4811
4812 ret = ath10k_wmi_peer_assoc_check_arg(arg);
4813 if (ret)
4814 return ERR_PTR(ret);
Michal Kazior24c88f72014-07-25 13:32:17 +02004815
Michal Kazior7aa7a722014-08-25 12:09:38 +02004816 skb = ath10k_wmi_alloc_skb(ar, len);
Michal Kazior24c88f72014-07-25 13:32:17 +02004817 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004818 return ERR_PTR(-ENOMEM);
Michal Kazior24c88f72014-07-25 13:32:17 +02004819
Michal Kaziord7579d12014-12-03 10:10:54 +02004820 ath10k_wmi_peer_assoc_fill_main(ar, skb->data, arg);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004821
Michal Kazior7aa7a722014-08-25 12:09:38 +02004822 ath10k_dbg(ar, ATH10K_DBG_WMI,
Chun-Yeow Yeoh44d6fa92014-03-07 10:19:30 +02004823 "wmi peer assoc vdev %d addr %pM (%s)\n",
4824 arg->vdev_id, arg->addr,
4825 arg->peer_reassoc ? "reassociate" : "new");
Michal Kaziord7579d12014-12-03 10:10:54 +02004826 return skb;
4827}
4828
4829static struct sk_buff *
4830ath10k_wmi_10_1_op_gen_peer_assoc(struct ath10k *ar,
4831 const struct wmi_peer_assoc_complete_arg *arg)
4832{
4833 size_t len = sizeof(struct wmi_10_1_peer_assoc_complete_cmd);
4834 struct sk_buff *skb;
4835 int ret;
4836
4837 ret = ath10k_wmi_peer_assoc_check_arg(arg);
4838 if (ret)
4839 return ERR_PTR(ret);
4840
4841 skb = ath10k_wmi_alloc_skb(ar, len);
4842 if (!skb)
4843 return ERR_PTR(-ENOMEM);
4844
4845 ath10k_wmi_peer_assoc_fill_10_1(ar, skb->data, arg);
4846
4847 ath10k_dbg(ar, ATH10K_DBG_WMI,
4848 "wmi peer assoc vdev %d addr %pM (%s)\n",
4849 arg->vdev_id, arg->addr,
4850 arg->peer_reassoc ? "reassociate" : "new");
4851 return skb;
4852}
4853
4854static struct sk_buff *
4855ath10k_wmi_10_2_op_gen_peer_assoc(struct ath10k *ar,
4856 const struct wmi_peer_assoc_complete_arg *arg)
4857{
4858 size_t len = sizeof(struct wmi_10_2_peer_assoc_complete_cmd);
4859 struct sk_buff *skb;
4860 int ret;
4861
4862 ret = ath10k_wmi_peer_assoc_check_arg(arg);
4863 if (ret)
4864 return ERR_PTR(ret);
4865
4866 skb = ath10k_wmi_alloc_skb(ar, len);
4867 if (!skb)
4868 return ERR_PTR(-ENOMEM);
4869
4870 ath10k_wmi_peer_assoc_fill_10_2(ar, skb->data, arg);
4871
4872 ath10k_dbg(ar, ATH10K_DBG_WMI,
4873 "wmi peer assoc vdev %d addr %pM (%s)\n",
4874 arg->vdev_id, arg->addr,
4875 arg->peer_reassoc ? "reassociate" : "new");
4876 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004877}
4878
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02004879static struct sk_buff *
4880ath10k_wmi_10_2_op_gen_pdev_get_temperature(struct ath10k *ar)
4881{
4882 struct sk_buff *skb;
4883
4884 skb = ath10k_wmi_alloc_skb(ar, 0);
4885 if (!skb)
4886 return ERR_PTR(-ENOMEM);
4887
4888 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev get temperature\n");
4889 return skb;
4890}
4891
Michal Kazior748afc42014-01-23 12:48:21 +01004892/* This function assumes the beacon is already DMA mapped */
Michal Kaziord7579d12014-12-03 10:10:54 +02004893static struct sk_buff *
Michal Kazior9ad50182015-01-29 14:29:47 +02004894ath10k_wmi_op_gen_beacon_dma(struct ath10k *ar, u32 vdev_id, const void *bcn,
4895 size_t bcn_len, u32 bcn_paddr, bool dtim_zero,
4896 bool deliver_cab)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004897{
Michal Kazior748afc42014-01-23 12:48:21 +01004898 struct wmi_bcn_tx_ref_cmd *cmd;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004899 struct sk_buff *skb;
Michal Kazior748afc42014-01-23 12:48:21 +01004900 struct ieee80211_hdr *hdr;
Michal Kazior748afc42014-01-23 12:48:21 +01004901 u16 fc;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004902
Michal Kazior7aa7a722014-08-25 12:09:38 +02004903 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004904 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004905 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004906
Michal Kazior9ad50182015-01-29 14:29:47 +02004907 hdr = (struct ieee80211_hdr *)bcn;
Michal Kazior748afc42014-01-23 12:48:21 +01004908 fc = le16_to_cpu(hdr->frame_control);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004909
Michal Kazior748afc42014-01-23 12:48:21 +01004910 cmd = (struct wmi_bcn_tx_ref_cmd *)skb->data;
Michal Kazior9ad50182015-01-29 14:29:47 +02004911 cmd->vdev_id = __cpu_to_le32(vdev_id);
4912 cmd->data_len = __cpu_to_le32(bcn_len);
4913 cmd->data_ptr = __cpu_to_le32(bcn_paddr);
Michal Kazior748afc42014-01-23 12:48:21 +01004914 cmd->msdu_id = 0;
4915 cmd->frame_control = __cpu_to_le32(fc);
4916 cmd->flags = 0;
Michal Kazior24c88f72014-07-25 13:32:17 +02004917 cmd->antenna_mask = __cpu_to_le32(WMI_BCN_TX_REF_DEF_ANTENNA);
Michal Kazior748afc42014-01-23 12:48:21 +01004918
Michal Kazior9ad50182015-01-29 14:29:47 +02004919 if (dtim_zero)
Michal Kazior748afc42014-01-23 12:48:21 +01004920 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DTIM_ZERO);
4921
Michal Kazior9ad50182015-01-29 14:29:47 +02004922 if (deliver_cab)
Michal Kazior748afc42014-01-23 12:48:21 +01004923 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB);
4924
Michal Kaziord7579d12014-12-03 10:10:54 +02004925 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004926}
4927
Michal Kazior5e752e42015-01-19 09:53:41 +01004928void ath10k_wmi_set_wmm_param(struct wmi_wmm_params *params,
4929 const struct wmi_wmm_params_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004930{
4931 params->cwmin = __cpu_to_le32(arg->cwmin);
4932 params->cwmax = __cpu_to_le32(arg->cwmax);
4933 params->aifs = __cpu_to_le32(arg->aifs);
4934 params->txop = __cpu_to_le32(arg->txop);
4935 params->acm = __cpu_to_le32(arg->acm);
4936 params->no_ack = __cpu_to_le32(arg->no_ack);
4937}
4938
Michal Kaziord7579d12014-12-03 10:10:54 +02004939static struct sk_buff *
4940ath10k_wmi_op_gen_pdev_set_wmm(struct ath10k *ar,
Michal Kazior5e752e42015-01-19 09:53:41 +01004941 const struct wmi_wmm_params_all_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004942{
4943 struct wmi_pdev_set_wmm_params *cmd;
4944 struct sk_buff *skb;
4945
Michal Kazior7aa7a722014-08-25 12:09:38 +02004946 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004947 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004948 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004949
4950 cmd = (struct wmi_pdev_set_wmm_params *)skb->data;
Michal Kazior5e752e42015-01-19 09:53:41 +01004951 ath10k_wmi_set_wmm_param(&cmd->ac_be, &arg->ac_be);
4952 ath10k_wmi_set_wmm_param(&cmd->ac_bk, &arg->ac_bk);
4953 ath10k_wmi_set_wmm_param(&cmd->ac_vi, &arg->ac_vi);
4954 ath10k_wmi_set_wmm_param(&cmd->ac_vo, &arg->ac_vo);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004955
Michal Kazior7aa7a722014-08-25 12:09:38 +02004956 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set wmm params\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02004957 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004958}
4959
Michal Kaziord7579d12014-12-03 10:10:54 +02004960static struct sk_buff *
Michal Kaziorde23d3e2015-02-15 16:50:41 +02004961ath10k_wmi_op_gen_request_stats(struct ath10k *ar, u32 stats_mask)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004962{
4963 struct wmi_request_stats_cmd *cmd;
4964 struct sk_buff *skb;
4965
Michal Kazior7aa7a722014-08-25 12:09:38 +02004966 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004967 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004968 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004969
4970 cmd = (struct wmi_request_stats_cmd *)skb->data;
Michal Kaziorde23d3e2015-02-15 16:50:41 +02004971 cmd->stats_id = __cpu_to_le32(stats_mask);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004972
Michal Kaziorde23d3e2015-02-15 16:50:41 +02004973 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi request stats 0x%08x\n",
4974 stats_mask);
Michal Kaziord7579d12014-12-03 10:10:54 +02004975 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004976}
Michal Kazior9cfbce72013-07-16 09:54:36 +02004977
Michal Kaziord7579d12014-12-03 10:10:54 +02004978static struct sk_buff *
4979ath10k_wmi_op_gen_force_fw_hang(struct ath10k *ar,
4980 enum wmi_force_fw_hang_type type, u32 delay_ms)
Michal Kazior9cfbce72013-07-16 09:54:36 +02004981{
4982 struct wmi_force_fw_hang_cmd *cmd;
4983 struct sk_buff *skb;
4984
Michal Kazior7aa7a722014-08-25 12:09:38 +02004985 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Michal Kazior9cfbce72013-07-16 09:54:36 +02004986 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02004987 return ERR_PTR(-ENOMEM);
Michal Kazior9cfbce72013-07-16 09:54:36 +02004988
4989 cmd = (struct wmi_force_fw_hang_cmd *)skb->data;
4990 cmd->type = __cpu_to_le32(type);
4991 cmd->delay_ms = __cpu_to_le32(delay_ms);
4992
Michal Kazior7aa7a722014-08-25 12:09:38 +02004993 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi force fw hang %d delay %d\n",
Michal Kazior9cfbce72013-07-16 09:54:36 +02004994 type, delay_ms);
Michal Kaziord7579d12014-12-03 10:10:54 +02004995 return skb;
Michal Kazior9cfbce72013-07-16 09:54:36 +02004996}
Kalle Valof118a3e2014-01-03 12:59:31 +02004997
Michal Kaziord7579d12014-12-03 10:10:54 +02004998static struct sk_buff *
SenthilKumar Jegadeesan467210a2015-01-29 14:36:52 +05304999ath10k_wmi_op_gen_dbglog_cfg(struct ath10k *ar, u32 module_enable,
5000 u32 log_level)
Kalle Valof118a3e2014-01-03 12:59:31 +02005001{
5002 struct wmi_dbglog_cfg_cmd *cmd;
5003 struct sk_buff *skb;
5004 u32 cfg;
5005
Michal Kazior7aa7a722014-08-25 12:09:38 +02005006 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valof118a3e2014-01-03 12:59:31 +02005007 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005008 return ERR_PTR(-ENOMEM);
Kalle Valof118a3e2014-01-03 12:59:31 +02005009
5010 cmd = (struct wmi_dbglog_cfg_cmd *)skb->data;
5011
5012 if (module_enable) {
SenthilKumar Jegadeesan467210a2015-01-29 14:36:52 +05305013 cfg = SM(log_level,
Kalle Valof118a3e2014-01-03 12:59:31 +02005014 ATH10K_DBGLOG_CFG_LOG_LVL);
5015 } else {
5016 /* set back defaults, all modules with WARN level */
5017 cfg = SM(ATH10K_DBGLOG_LEVEL_WARN,
5018 ATH10K_DBGLOG_CFG_LOG_LVL);
5019 module_enable = ~0;
5020 }
5021
5022 cmd->module_enable = __cpu_to_le32(module_enable);
5023 cmd->module_valid = __cpu_to_le32(~0);
5024 cmd->config_enable = __cpu_to_le32(cfg);
5025 cmd->config_valid = __cpu_to_le32(ATH10K_DBGLOG_CFG_LOG_LVL_MASK);
5026
Michal Kazior7aa7a722014-08-25 12:09:38 +02005027 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valof118a3e2014-01-03 12:59:31 +02005028 "wmi dbglog cfg modules %08x %08x config %08x %08x\n",
5029 __le32_to_cpu(cmd->module_enable),
5030 __le32_to_cpu(cmd->module_valid),
5031 __le32_to_cpu(cmd->config_enable),
5032 __le32_to_cpu(cmd->config_valid));
Michal Kaziord7579d12014-12-03 10:10:54 +02005033 return skb;
Kalle Valof118a3e2014-01-03 12:59:31 +02005034}
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02005035
Michal Kaziord7579d12014-12-03 10:10:54 +02005036static struct sk_buff *
5037ath10k_wmi_op_gen_pktlog_enable(struct ath10k *ar, u32 ev_bitmap)
Rajkumar Manoharan90174452014-10-03 08:02:33 +03005038{
5039 struct wmi_pdev_pktlog_enable_cmd *cmd;
5040 struct sk_buff *skb;
5041
5042 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5043 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005044 return ERR_PTR(-ENOMEM);
Rajkumar Manoharan90174452014-10-03 08:02:33 +03005045
5046 ev_bitmap &= ATH10K_PKTLOG_ANY;
Rajkumar Manoharan90174452014-10-03 08:02:33 +03005047
5048 cmd = (struct wmi_pdev_pktlog_enable_cmd *)skb->data;
5049 cmd->ev_bitmap = __cpu_to_le32(ev_bitmap);
Michal Kaziord7579d12014-12-03 10:10:54 +02005050
5051 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi enable pktlog filter 0x%08x\n",
5052 ev_bitmap);
5053 return skb;
Rajkumar Manoharan90174452014-10-03 08:02:33 +03005054}
5055
Michal Kaziord7579d12014-12-03 10:10:54 +02005056static struct sk_buff *
5057ath10k_wmi_op_gen_pktlog_disable(struct ath10k *ar)
Rajkumar Manoharan90174452014-10-03 08:02:33 +03005058{
5059 struct sk_buff *skb;
5060
5061 skb = ath10k_wmi_alloc_skb(ar, 0);
5062 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005063 return ERR_PTR(-ENOMEM);
Rajkumar Manoharan90174452014-10-03 08:02:33 +03005064
5065 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi disable pktlog\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02005066 return skb;
Rajkumar Manoharan90174452014-10-03 08:02:33 +03005067}
5068
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02005069static struct sk_buff *
5070ath10k_wmi_op_gen_pdev_set_quiet_mode(struct ath10k *ar, u32 period,
5071 u32 duration, u32 next_offset,
5072 u32 enabled)
5073{
5074 struct wmi_pdev_set_quiet_cmd *cmd;
5075 struct sk_buff *skb;
5076
5077 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5078 if (!skb)
5079 return ERR_PTR(-ENOMEM);
5080
5081 cmd = (struct wmi_pdev_set_quiet_cmd *)skb->data;
5082 cmd->period = __cpu_to_le32(period);
5083 cmd->duration = __cpu_to_le32(duration);
5084 cmd->next_start = __cpu_to_le32(next_offset);
5085 cmd->enabled = __cpu_to_le32(enabled);
5086
5087 ath10k_dbg(ar, ATH10K_DBG_WMI,
5088 "wmi quiet param: period %u duration %u enabled %d\n",
5089 period, duration, enabled);
5090 return skb;
5091}
5092
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02005093static struct sk_buff *
5094ath10k_wmi_op_gen_addba_clear_resp(struct ath10k *ar, u32 vdev_id,
5095 const u8 *mac)
5096{
5097 struct wmi_addba_clear_resp_cmd *cmd;
5098 struct sk_buff *skb;
5099
5100 if (!mac)
5101 return ERR_PTR(-EINVAL);
5102
5103 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5104 if (!skb)
5105 return ERR_PTR(-ENOMEM);
5106
5107 cmd = (struct wmi_addba_clear_resp_cmd *)skb->data;
5108 cmd->vdev_id = __cpu_to_le32(vdev_id);
5109 ether_addr_copy(cmd->peer_macaddr.addr, mac);
5110
5111 ath10k_dbg(ar, ATH10K_DBG_WMI,
5112 "wmi addba clear resp vdev_id 0x%X mac_addr %pM\n",
5113 vdev_id, mac);
5114 return skb;
5115}
5116
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02005117static struct sk_buff *
5118ath10k_wmi_op_gen_addba_send(struct ath10k *ar, u32 vdev_id, const u8 *mac,
5119 u32 tid, u32 buf_size)
5120{
5121 struct wmi_addba_send_cmd *cmd;
5122 struct sk_buff *skb;
5123
5124 if (!mac)
5125 return ERR_PTR(-EINVAL);
5126
5127 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5128 if (!skb)
5129 return ERR_PTR(-ENOMEM);
5130
5131 cmd = (struct wmi_addba_send_cmd *)skb->data;
5132 cmd->vdev_id = __cpu_to_le32(vdev_id);
5133 ether_addr_copy(cmd->peer_macaddr.addr, mac);
5134 cmd->tid = __cpu_to_le32(tid);
5135 cmd->buffersize = __cpu_to_le32(buf_size);
5136
5137 ath10k_dbg(ar, ATH10K_DBG_WMI,
5138 "wmi addba send vdev_id 0x%X mac_addr %pM tid %u bufsize %u\n",
5139 vdev_id, mac, tid, buf_size);
5140 return skb;
5141}
5142
Rajkumar Manoharan11597412015-01-12 14:07:26 +02005143static struct sk_buff *
5144ath10k_wmi_op_gen_addba_set_resp(struct ath10k *ar, u32 vdev_id, const u8 *mac,
5145 u32 tid, u32 status)
5146{
5147 struct wmi_addba_setresponse_cmd *cmd;
5148 struct sk_buff *skb;
5149
5150 if (!mac)
5151 return ERR_PTR(-EINVAL);
5152
5153 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5154 if (!skb)
5155 return ERR_PTR(-ENOMEM);
5156
5157 cmd = (struct wmi_addba_setresponse_cmd *)skb->data;
5158 cmd->vdev_id = __cpu_to_le32(vdev_id);
5159 ether_addr_copy(cmd->peer_macaddr.addr, mac);
5160 cmd->tid = __cpu_to_le32(tid);
5161 cmd->statuscode = __cpu_to_le32(status);
5162
5163 ath10k_dbg(ar, ATH10K_DBG_WMI,
5164 "wmi addba set resp vdev_id 0x%X mac_addr %pM tid %u status %u\n",
5165 vdev_id, mac, tid, status);
5166 return skb;
5167}
5168
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02005169static struct sk_buff *
5170ath10k_wmi_op_gen_delba_send(struct ath10k *ar, u32 vdev_id, const u8 *mac,
5171 u32 tid, u32 initiator, u32 reason)
5172{
5173 struct wmi_delba_send_cmd *cmd;
5174 struct sk_buff *skb;
5175
5176 if (!mac)
5177 return ERR_PTR(-EINVAL);
5178
5179 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5180 if (!skb)
5181 return ERR_PTR(-ENOMEM);
5182
5183 cmd = (struct wmi_delba_send_cmd *)skb->data;
5184 cmd->vdev_id = __cpu_to_le32(vdev_id);
5185 ether_addr_copy(cmd->peer_macaddr.addr, mac);
5186 cmd->tid = __cpu_to_le32(tid);
5187 cmd->initiator = __cpu_to_le32(initiator);
5188 cmd->reasoncode = __cpu_to_le32(reason);
5189
5190 ath10k_dbg(ar, ATH10K_DBG_WMI,
5191 "wmi delba send vdev_id 0x%X mac_addr %pM tid %u initiator %u reason %u\n",
5192 vdev_id, mac, tid, initiator, reason);
5193 return skb;
5194}
5195
Michal Kaziord7579d12014-12-03 10:10:54 +02005196static const struct wmi_ops wmi_ops = {
5197 .rx = ath10k_wmi_op_rx,
5198 .map_svc = wmi_main_svc_map,
5199
5200 .pull_scan = ath10k_wmi_op_pull_scan_ev,
5201 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
5202 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
5203 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
5204 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
5205 .pull_swba = ath10k_wmi_op_pull_swba_ev,
5206 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
5207 .pull_svc_rdy = ath10k_wmi_main_op_pull_svc_rdy_ev,
5208 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
5209 .pull_fw_stats = ath10k_wmi_main_op_pull_fw_stats,
Michal Kaziorc1a46542015-03-10 16:21:54 +02005210 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02005211
5212 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
5213 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
5214 .gen_pdev_set_rd = ath10k_wmi_op_gen_pdev_set_rd,
5215 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
5216 .gen_init = ath10k_wmi_op_gen_init,
5217 .gen_start_scan = ath10k_wmi_op_gen_start_scan,
5218 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
5219 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
5220 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
5221 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
5222 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
5223 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
5224 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
5225 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
5226 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
5227 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
5228 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
Michal Kazior6d492fe2015-01-28 09:57:22 +02005229 /* .gen_vdev_wmm_conf not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02005230 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
5231 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
5232 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
5233 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
5234 .gen_peer_assoc = ath10k_wmi_op_gen_peer_assoc,
5235 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
5236 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
5237 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
5238 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
5239 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
5240 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
5241 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
5242 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
5243 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
5244 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
5245 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
5246 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02005247 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02005248 /* .gen_pdev_get_temperature not implemented */
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02005249 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02005250 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02005251 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02005252 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Michal Kaziorbe9ce9d2015-01-13 16:30:11 +02005253 /* .gen_bcn_tmpl not implemented */
Michal Kazior4c4955f2015-01-13 16:30:11 +02005254 /* .gen_prb_tmpl not implemented */
Michal Kazior369242b4e2015-01-13 16:30:11 +02005255 /* .gen_p2p_go_bcn_ie not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02005256};
5257
5258static const struct wmi_ops wmi_10_1_ops = {
5259 .rx = ath10k_wmi_10_1_op_rx,
5260 .map_svc = wmi_10x_svc_map,
5261 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
5262 .pull_fw_stats = ath10k_wmi_10x_op_pull_fw_stats,
5263 .gen_init = ath10k_wmi_10_1_op_gen_init,
5264 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
5265 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
5266 .gen_peer_assoc = ath10k_wmi_10_1_op_gen_peer_assoc,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02005267 /* .gen_pdev_get_temperature not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02005268
5269 /* shared with main branch */
5270 .pull_scan = ath10k_wmi_op_pull_scan_ev,
5271 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
5272 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
5273 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
5274 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
5275 .pull_swba = ath10k_wmi_op_pull_swba_ev,
5276 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
5277 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
Michal Kaziorc1a46542015-03-10 16:21:54 +02005278 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02005279
5280 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
5281 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
5282 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
5283 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
5284 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
5285 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
5286 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
5287 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
5288 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
5289 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
5290 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
5291 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
5292 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
5293 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
Michal Kazior6d492fe2015-01-28 09:57:22 +02005294 /* .gen_vdev_wmm_conf not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02005295 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
5296 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
5297 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
5298 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
5299 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
5300 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
5301 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
5302 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
5303 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
5304 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
5305 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
5306 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
5307 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
5308 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
5309 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
5310 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02005311 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02005312 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02005313 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02005314 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02005315 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Michal Kaziorbe9ce9d2015-01-13 16:30:11 +02005316 /* .gen_bcn_tmpl not implemented */
Michal Kazior4c4955f2015-01-13 16:30:11 +02005317 /* .gen_prb_tmpl not implemented */
Michal Kazior369242b4e2015-01-13 16:30:11 +02005318 /* .gen_p2p_go_bcn_ie not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02005319};
5320
5321static const struct wmi_ops wmi_10_2_ops = {
5322 .rx = ath10k_wmi_10_2_op_rx,
Michal Kazior20de2222015-01-24 12:14:49 +02005323 .pull_fw_stats = ath10k_wmi_10_2_op_pull_fw_stats,
Michal Kaziord7579d12014-12-03 10:10:54 +02005324 .gen_init = ath10k_wmi_10_2_op_gen_init,
5325 .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02005326 /* .gen_pdev_get_temperature not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02005327
5328 /* shared with 10.1 */
5329 .map_svc = wmi_10x_svc_map,
5330 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02005331 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
5332 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
5333
5334 .pull_scan = ath10k_wmi_op_pull_scan_ev,
5335 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
5336 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
5337 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
5338 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
5339 .pull_swba = ath10k_wmi_op_pull_swba_ev,
5340 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
5341 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
Michal Kaziorc1a46542015-03-10 16:21:54 +02005342 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02005343
5344 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
5345 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
5346 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
5347 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
5348 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
5349 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
5350 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
5351 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
5352 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
5353 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
5354 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
5355 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
5356 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
5357 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
Michal Kazior6d492fe2015-01-28 09:57:22 +02005358 /* .gen_vdev_wmm_conf not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02005359 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
5360 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
5361 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
5362 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
5363 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
5364 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
5365 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
5366 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
5367 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
5368 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
5369 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
5370 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
5371 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
5372 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
5373 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
5374 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02005375 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02005376 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02005377 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02005378 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02005379 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Michal Kaziord7579d12014-12-03 10:10:54 +02005380};
5381
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02005382static const struct wmi_ops wmi_10_2_4_ops = {
5383 .rx = ath10k_wmi_10_2_op_rx,
Michal Kazior20de2222015-01-24 12:14:49 +02005384 .pull_fw_stats = ath10k_wmi_10_2_4_op_pull_fw_stats,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02005385 .gen_init = ath10k_wmi_10_2_op_gen_init,
5386 .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02005387 .gen_pdev_get_temperature = ath10k_wmi_10_2_op_gen_pdev_get_temperature,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02005388
5389 /* shared with 10.1 */
5390 .map_svc = wmi_10x_svc_map,
5391 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02005392 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
5393 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
5394
5395 .pull_scan = ath10k_wmi_op_pull_scan_ev,
5396 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
5397 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
5398 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
5399 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
5400 .pull_swba = ath10k_wmi_op_pull_swba_ev,
5401 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
5402 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
Michal Kaziorc1a46542015-03-10 16:21:54 +02005403 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02005404
5405 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
5406 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
5407 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
5408 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
5409 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
5410 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
5411 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
5412 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
5413 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
5414 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
5415 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
5416 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
5417 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
5418 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
5419 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
5420 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
5421 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
5422 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
5423 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
5424 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
5425 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
5426 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
5427 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
5428 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
5429 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
5430 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
5431 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
5432 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
5433 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
5434 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02005435 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02005436 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02005437 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02005438 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02005439 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Michal Kaziorbe9ce9d2015-01-13 16:30:11 +02005440 /* .gen_bcn_tmpl not implemented */
Michal Kazior4c4955f2015-01-13 16:30:11 +02005441 /* .gen_prb_tmpl not implemented */
Michal Kazior369242b4e2015-01-13 16:30:11 +02005442 /* .gen_p2p_go_bcn_ie not implemented */
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02005443};
5444
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02005445int ath10k_wmi_attach(struct ath10k *ar)
5446{
Michal Kaziord7579d12014-12-03 10:10:54 +02005447 switch (ar->wmi.op_version) {
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02005448 case ATH10K_FW_WMI_OP_VERSION_10_2_4:
5449 ar->wmi.cmd = &wmi_10_2_4_cmd_map;
5450 ar->wmi.ops = &wmi_10_2_4_ops;
5451 ar->wmi.vdev_param = &wmi_10_2_4_vdev_param_map;
5452 ar->wmi.pdev_param = &wmi_10_2_4_pdev_param_map;
5453 break;
Michal Kaziord7579d12014-12-03 10:10:54 +02005454 case ATH10K_FW_WMI_OP_VERSION_10_2:
5455 ar->wmi.cmd = &wmi_10_2_cmd_map;
5456 ar->wmi.ops = &wmi_10_2_ops;
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02005457 ar->wmi.vdev_param = &wmi_10x_vdev_param_map;
5458 ar->wmi.pdev_param = &wmi_10x_pdev_param_map;
Michal Kaziord7579d12014-12-03 10:10:54 +02005459 break;
5460 case ATH10K_FW_WMI_OP_VERSION_10_1:
5461 ar->wmi.cmd = &wmi_10x_cmd_map;
5462 ar->wmi.ops = &wmi_10_1_ops;
5463 ar->wmi.vdev_param = &wmi_10x_vdev_param_map;
5464 ar->wmi.pdev_param = &wmi_10x_pdev_param_map;
5465 break;
5466 case ATH10K_FW_WMI_OP_VERSION_MAIN:
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02005467 ar->wmi.cmd = &wmi_cmd_map;
Michal Kaziord7579d12014-12-03 10:10:54 +02005468 ar->wmi.ops = &wmi_ops;
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02005469 ar->wmi.vdev_param = &wmi_vdev_param_map;
5470 ar->wmi.pdev_param = &wmi_pdev_param_map;
Michal Kaziord7579d12014-12-03 10:10:54 +02005471 break;
Michal Kaziorca996ec2014-12-03 10:11:32 +02005472 case ATH10K_FW_WMI_OP_VERSION_TLV:
5473 ath10k_wmi_tlv_attach(ar);
5474 break;
Michal Kaziord7579d12014-12-03 10:10:54 +02005475 case ATH10K_FW_WMI_OP_VERSION_UNSET:
5476 case ATH10K_FW_WMI_OP_VERSION_MAX:
5477 ath10k_err(ar, "unsupported WMI op version: %d\n",
5478 ar->wmi.op_version);
5479 return -EINVAL;
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02005480 }
5481
5482 init_completion(&ar->wmi.service_ready);
5483 init_completion(&ar->wmi.unified_ready);
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02005484
5485 return 0;
5486}
5487
5488void ath10k_wmi_detach(struct ath10k *ar)
5489{
5490 int i;
5491
5492 /* free the host memory chunks requested by firmware */
5493 for (i = 0; i < ar->wmi.num_mem_chunks; i++) {
5494 dma_free_coherent(ar->dev,
5495 ar->wmi.mem_chunks[i].len,
5496 ar->wmi.mem_chunks[i].vaddr,
5497 ar->wmi.mem_chunks[i].paddr);
5498 }
5499
5500 ar->wmi.num_mem_chunks = 0;
5501}