blob: 8c223671ecc43c7c4d55d70522c82a0d6c516775 [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>
19
20#include "core.h"
21#include "htc.h"
22#include "debug.h"
23#include "wmi.h"
24#include "mac.h"
25
Bartosz Markowskice428702013-09-26 17:47:05 +020026/* MAIN WMI cmd track */
27static struct wmi_cmd_map wmi_cmd_map = {
28 .init_cmdid = WMI_INIT_CMDID,
29 .start_scan_cmdid = WMI_START_SCAN_CMDID,
30 .stop_scan_cmdid = WMI_STOP_SCAN_CMDID,
31 .scan_chan_list_cmdid = WMI_SCAN_CHAN_LIST_CMDID,
32 .scan_sch_prio_tbl_cmdid = WMI_SCAN_SCH_PRIO_TBL_CMDID,
33 .pdev_set_regdomain_cmdid = WMI_PDEV_SET_REGDOMAIN_CMDID,
34 .pdev_set_channel_cmdid = WMI_PDEV_SET_CHANNEL_CMDID,
35 .pdev_set_param_cmdid = WMI_PDEV_SET_PARAM_CMDID,
36 .pdev_pktlog_enable_cmdid = WMI_PDEV_PKTLOG_ENABLE_CMDID,
37 .pdev_pktlog_disable_cmdid = WMI_PDEV_PKTLOG_DISABLE_CMDID,
38 .pdev_set_wmm_params_cmdid = WMI_PDEV_SET_WMM_PARAMS_CMDID,
39 .pdev_set_ht_cap_ie_cmdid = WMI_PDEV_SET_HT_CAP_IE_CMDID,
40 .pdev_set_vht_cap_ie_cmdid = WMI_PDEV_SET_VHT_CAP_IE_CMDID,
41 .pdev_set_dscp_tid_map_cmdid = WMI_PDEV_SET_DSCP_TID_MAP_CMDID,
42 .pdev_set_quiet_mode_cmdid = WMI_PDEV_SET_QUIET_MODE_CMDID,
43 .pdev_green_ap_ps_enable_cmdid = WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID,
44 .pdev_get_tpc_config_cmdid = WMI_PDEV_GET_TPC_CONFIG_CMDID,
45 .pdev_set_base_macaddr_cmdid = WMI_PDEV_SET_BASE_MACADDR_CMDID,
46 .vdev_create_cmdid = WMI_VDEV_CREATE_CMDID,
47 .vdev_delete_cmdid = WMI_VDEV_DELETE_CMDID,
48 .vdev_start_request_cmdid = WMI_VDEV_START_REQUEST_CMDID,
49 .vdev_restart_request_cmdid = WMI_VDEV_RESTART_REQUEST_CMDID,
50 .vdev_up_cmdid = WMI_VDEV_UP_CMDID,
51 .vdev_stop_cmdid = WMI_VDEV_STOP_CMDID,
52 .vdev_down_cmdid = WMI_VDEV_DOWN_CMDID,
53 .vdev_set_param_cmdid = WMI_VDEV_SET_PARAM_CMDID,
54 .vdev_install_key_cmdid = WMI_VDEV_INSTALL_KEY_CMDID,
55 .peer_create_cmdid = WMI_PEER_CREATE_CMDID,
56 .peer_delete_cmdid = WMI_PEER_DELETE_CMDID,
57 .peer_flush_tids_cmdid = WMI_PEER_FLUSH_TIDS_CMDID,
58 .peer_set_param_cmdid = WMI_PEER_SET_PARAM_CMDID,
59 .peer_assoc_cmdid = WMI_PEER_ASSOC_CMDID,
60 .peer_add_wds_entry_cmdid = WMI_PEER_ADD_WDS_ENTRY_CMDID,
61 .peer_remove_wds_entry_cmdid = WMI_PEER_REMOVE_WDS_ENTRY_CMDID,
62 .peer_mcast_group_cmdid = WMI_PEER_MCAST_GROUP_CMDID,
63 .bcn_tx_cmdid = WMI_BCN_TX_CMDID,
64 .pdev_send_bcn_cmdid = WMI_PDEV_SEND_BCN_CMDID,
65 .bcn_tmpl_cmdid = WMI_BCN_TMPL_CMDID,
66 .bcn_filter_rx_cmdid = WMI_BCN_FILTER_RX_CMDID,
67 .prb_req_filter_rx_cmdid = WMI_PRB_REQ_FILTER_RX_CMDID,
68 .mgmt_tx_cmdid = WMI_MGMT_TX_CMDID,
69 .prb_tmpl_cmdid = WMI_PRB_TMPL_CMDID,
70 .addba_clear_resp_cmdid = WMI_ADDBA_CLEAR_RESP_CMDID,
71 .addba_send_cmdid = WMI_ADDBA_SEND_CMDID,
72 .addba_status_cmdid = WMI_ADDBA_STATUS_CMDID,
73 .delba_send_cmdid = WMI_DELBA_SEND_CMDID,
74 .addba_set_resp_cmdid = WMI_ADDBA_SET_RESP_CMDID,
75 .send_singleamsdu_cmdid = WMI_SEND_SINGLEAMSDU_CMDID,
76 .sta_powersave_mode_cmdid = WMI_STA_POWERSAVE_MODE_CMDID,
77 .sta_powersave_param_cmdid = WMI_STA_POWERSAVE_PARAM_CMDID,
78 .sta_mimo_ps_mode_cmdid = WMI_STA_MIMO_PS_MODE_CMDID,
79 .pdev_dfs_enable_cmdid = WMI_PDEV_DFS_ENABLE_CMDID,
80 .pdev_dfs_disable_cmdid = WMI_PDEV_DFS_DISABLE_CMDID,
81 .roam_scan_mode = WMI_ROAM_SCAN_MODE,
82 .roam_scan_rssi_threshold = WMI_ROAM_SCAN_RSSI_THRESHOLD,
83 .roam_scan_period = WMI_ROAM_SCAN_PERIOD,
84 .roam_scan_rssi_change_threshold = WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
85 .roam_ap_profile = WMI_ROAM_AP_PROFILE,
86 .ofl_scan_add_ap_profile = WMI_ROAM_AP_PROFILE,
87 .ofl_scan_remove_ap_profile = WMI_OFL_SCAN_REMOVE_AP_PROFILE,
88 .ofl_scan_period = WMI_OFL_SCAN_PERIOD,
89 .p2p_dev_set_device_info = WMI_P2P_DEV_SET_DEVICE_INFO,
90 .p2p_dev_set_discoverability = WMI_P2P_DEV_SET_DISCOVERABILITY,
91 .p2p_go_set_beacon_ie = WMI_P2P_GO_SET_BEACON_IE,
92 .p2p_go_set_probe_resp_ie = WMI_P2P_GO_SET_PROBE_RESP_IE,
93 .p2p_set_vendor_ie_data_cmdid = WMI_P2P_SET_VENDOR_IE_DATA_CMDID,
94 .ap_ps_peer_param_cmdid = WMI_AP_PS_PEER_PARAM_CMDID,
95 .ap_ps_peer_uapsd_coex_cmdid = WMI_AP_PS_PEER_UAPSD_COEX_CMDID,
96 .peer_rate_retry_sched_cmdid = WMI_PEER_RATE_RETRY_SCHED_CMDID,
97 .wlan_profile_trigger_cmdid = WMI_WLAN_PROFILE_TRIGGER_CMDID,
98 .wlan_profile_set_hist_intvl_cmdid =
99 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
100 .wlan_profile_get_profile_data_cmdid =
101 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
102 .wlan_profile_enable_profile_id_cmdid =
103 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
104 .wlan_profile_list_profile_id_cmdid =
105 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
106 .pdev_suspend_cmdid = WMI_PDEV_SUSPEND_CMDID,
107 .pdev_resume_cmdid = WMI_PDEV_RESUME_CMDID,
108 .add_bcn_filter_cmdid = WMI_ADD_BCN_FILTER_CMDID,
109 .rmv_bcn_filter_cmdid = WMI_RMV_BCN_FILTER_CMDID,
110 .wow_add_wake_pattern_cmdid = WMI_WOW_ADD_WAKE_PATTERN_CMDID,
111 .wow_del_wake_pattern_cmdid = WMI_WOW_DEL_WAKE_PATTERN_CMDID,
112 .wow_enable_disable_wake_event_cmdid =
113 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
114 .wow_enable_cmdid = WMI_WOW_ENABLE_CMDID,
115 .wow_hostwakeup_from_sleep_cmdid = WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
116 .rtt_measreq_cmdid = WMI_RTT_MEASREQ_CMDID,
117 .rtt_tsf_cmdid = WMI_RTT_TSF_CMDID,
118 .vdev_spectral_scan_configure_cmdid =
119 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
120 .vdev_spectral_scan_enable_cmdid = WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
121 .request_stats_cmdid = WMI_REQUEST_STATS_CMDID,
122 .set_arp_ns_offload_cmdid = WMI_SET_ARP_NS_OFFLOAD_CMDID,
123 .network_list_offload_config_cmdid =
124 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID,
125 .gtk_offload_cmdid = WMI_GTK_OFFLOAD_CMDID,
126 .csa_offload_enable_cmdid = WMI_CSA_OFFLOAD_ENABLE_CMDID,
127 .csa_offload_chanswitch_cmdid = WMI_CSA_OFFLOAD_CHANSWITCH_CMDID,
128 .chatter_set_mode_cmdid = WMI_CHATTER_SET_MODE_CMDID,
129 .peer_tid_addba_cmdid = WMI_PEER_TID_ADDBA_CMDID,
130 .peer_tid_delba_cmdid = WMI_PEER_TID_DELBA_CMDID,
131 .sta_dtim_ps_method_cmdid = WMI_STA_DTIM_PS_METHOD_CMDID,
132 .sta_uapsd_auto_trig_cmdid = WMI_STA_UAPSD_AUTO_TRIG_CMDID,
133 .sta_keepalive_cmd = WMI_STA_KEEPALIVE_CMD,
134 .echo_cmdid = WMI_ECHO_CMDID,
135 .pdev_utf_cmdid = WMI_PDEV_UTF_CMDID,
136 .dbglog_cfg_cmdid = WMI_DBGLOG_CFG_CMDID,
137 .pdev_qvit_cmdid = WMI_PDEV_QVIT_CMDID,
138 .pdev_ftm_intg_cmdid = WMI_PDEV_FTM_INTG_CMDID,
139 .vdev_set_keepalive_cmdid = WMI_VDEV_SET_KEEPALIVE_CMDID,
140 .vdev_get_keepalive_cmdid = WMI_VDEV_GET_KEEPALIVE_CMDID,
141 .force_fw_hang_cmdid = WMI_FORCE_FW_HANG_CMDID,
142 .gpio_config_cmdid = WMI_GPIO_CONFIG_CMDID,
143 .gpio_output_cmdid = WMI_GPIO_OUTPUT_CMDID,
144};
145
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200146/* 10.X WMI cmd track */
147static struct wmi_cmd_map wmi_10x_cmd_map = {
148 .init_cmdid = WMI_10X_INIT_CMDID,
149 .start_scan_cmdid = WMI_10X_START_SCAN_CMDID,
150 .stop_scan_cmdid = WMI_10X_STOP_SCAN_CMDID,
151 .scan_chan_list_cmdid = WMI_10X_SCAN_CHAN_LIST_CMDID,
152 .scan_sch_prio_tbl_cmdid = WMI_CMD_UNDEFINED,
153 .pdev_set_regdomain_cmdid = WMI_10X_PDEV_SET_REGDOMAIN_CMDID,
154 .pdev_set_channel_cmdid = WMI_10X_PDEV_SET_CHANNEL_CMDID,
155 .pdev_set_param_cmdid = WMI_10X_PDEV_SET_PARAM_CMDID,
156 .pdev_pktlog_enable_cmdid = WMI_10X_PDEV_PKTLOG_ENABLE_CMDID,
157 .pdev_pktlog_disable_cmdid = WMI_10X_PDEV_PKTLOG_DISABLE_CMDID,
158 .pdev_set_wmm_params_cmdid = WMI_10X_PDEV_SET_WMM_PARAMS_CMDID,
159 .pdev_set_ht_cap_ie_cmdid = WMI_10X_PDEV_SET_HT_CAP_IE_CMDID,
160 .pdev_set_vht_cap_ie_cmdid = WMI_10X_PDEV_SET_VHT_CAP_IE_CMDID,
161 .pdev_set_dscp_tid_map_cmdid = WMI_10X_PDEV_SET_DSCP_TID_MAP_CMDID,
162 .pdev_set_quiet_mode_cmdid = WMI_10X_PDEV_SET_QUIET_MODE_CMDID,
163 .pdev_green_ap_ps_enable_cmdid = WMI_10X_PDEV_GREEN_AP_PS_ENABLE_CMDID,
164 .pdev_get_tpc_config_cmdid = WMI_10X_PDEV_GET_TPC_CONFIG_CMDID,
165 .pdev_set_base_macaddr_cmdid = WMI_10X_PDEV_SET_BASE_MACADDR_CMDID,
166 .vdev_create_cmdid = WMI_10X_VDEV_CREATE_CMDID,
167 .vdev_delete_cmdid = WMI_10X_VDEV_DELETE_CMDID,
168 .vdev_start_request_cmdid = WMI_10X_VDEV_START_REQUEST_CMDID,
169 .vdev_restart_request_cmdid = WMI_10X_VDEV_RESTART_REQUEST_CMDID,
170 .vdev_up_cmdid = WMI_10X_VDEV_UP_CMDID,
171 .vdev_stop_cmdid = WMI_10X_VDEV_STOP_CMDID,
172 .vdev_down_cmdid = WMI_10X_VDEV_DOWN_CMDID,
173 .vdev_set_param_cmdid = WMI_10X_VDEV_SET_PARAM_CMDID,
174 .vdev_install_key_cmdid = WMI_10X_VDEV_INSTALL_KEY_CMDID,
175 .peer_create_cmdid = WMI_10X_PEER_CREATE_CMDID,
176 .peer_delete_cmdid = WMI_10X_PEER_DELETE_CMDID,
177 .peer_flush_tids_cmdid = WMI_10X_PEER_FLUSH_TIDS_CMDID,
178 .peer_set_param_cmdid = WMI_10X_PEER_SET_PARAM_CMDID,
179 .peer_assoc_cmdid = WMI_10X_PEER_ASSOC_CMDID,
180 .peer_add_wds_entry_cmdid = WMI_10X_PEER_ADD_WDS_ENTRY_CMDID,
181 .peer_remove_wds_entry_cmdid = WMI_10X_PEER_REMOVE_WDS_ENTRY_CMDID,
182 .peer_mcast_group_cmdid = WMI_10X_PEER_MCAST_GROUP_CMDID,
183 .bcn_tx_cmdid = WMI_10X_BCN_TX_CMDID,
184 .pdev_send_bcn_cmdid = WMI_10X_PDEV_SEND_BCN_CMDID,
185 .bcn_tmpl_cmdid = WMI_CMD_UNDEFINED,
186 .bcn_filter_rx_cmdid = WMI_10X_BCN_FILTER_RX_CMDID,
187 .prb_req_filter_rx_cmdid = WMI_10X_PRB_REQ_FILTER_RX_CMDID,
188 .mgmt_tx_cmdid = WMI_10X_MGMT_TX_CMDID,
189 .prb_tmpl_cmdid = WMI_CMD_UNDEFINED,
190 .addba_clear_resp_cmdid = WMI_10X_ADDBA_CLEAR_RESP_CMDID,
191 .addba_send_cmdid = WMI_10X_ADDBA_SEND_CMDID,
192 .addba_status_cmdid = WMI_10X_ADDBA_STATUS_CMDID,
193 .delba_send_cmdid = WMI_10X_DELBA_SEND_CMDID,
194 .addba_set_resp_cmdid = WMI_10X_ADDBA_SET_RESP_CMDID,
195 .send_singleamsdu_cmdid = WMI_10X_SEND_SINGLEAMSDU_CMDID,
196 .sta_powersave_mode_cmdid = WMI_10X_STA_POWERSAVE_MODE_CMDID,
197 .sta_powersave_param_cmdid = WMI_10X_STA_POWERSAVE_PARAM_CMDID,
198 .sta_mimo_ps_mode_cmdid = WMI_10X_STA_MIMO_PS_MODE_CMDID,
199 .pdev_dfs_enable_cmdid = WMI_10X_PDEV_DFS_ENABLE_CMDID,
200 .pdev_dfs_disable_cmdid = WMI_10X_PDEV_DFS_DISABLE_CMDID,
201 .roam_scan_mode = WMI_10X_ROAM_SCAN_MODE,
202 .roam_scan_rssi_threshold = WMI_10X_ROAM_SCAN_RSSI_THRESHOLD,
203 .roam_scan_period = WMI_10X_ROAM_SCAN_PERIOD,
204 .roam_scan_rssi_change_threshold =
205 WMI_10X_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
206 .roam_ap_profile = WMI_10X_ROAM_AP_PROFILE,
207 .ofl_scan_add_ap_profile = WMI_10X_OFL_SCAN_ADD_AP_PROFILE,
208 .ofl_scan_remove_ap_profile = WMI_10X_OFL_SCAN_REMOVE_AP_PROFILE,
209 .ofl_scan_period = WMI_10X_OFL_SCAN_PERIOD,
210 .p2p_dev_set_device_info = WMI_10X_P2P_DEV_SET_DEVICE_INFO,
211 .p2p_dev_set_discoverability = WMI_10X_P2P_DEV_SET_DISCOVERABILITY,
212 .p2p_go_set_beacon_ie = WMI_10X_P2P_GO_SET_BEACON_IE,
213 .p2p_go_set_probe_resp_ie = WMI_10X_P2P_GO_SET_PROBE_RESP_IE,
214 .p2p_set_vendor_ie_data_cmdid = WMI_CMD_UNDEFINED,
215 .ap_ps_peer_param_cmdid = WMI_CMD_UNDEFINED,
216 .ap_ps_peer_uapsd_coex_cmdid = WMI_CMD_UNDEFINED,
217 .peer_rate_retry_sched_cmdid = WMI_10X_PEER_RATE_RETRY_SCHED_CMDID,
218 .wlan_profile_trigger_cmdid = WMI_10X_WLAN_PROFILE_TRIGGER_CMDID,
219 .wlan_profile_set_hist_intvl_cmdid =
220 WMI_10X_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
221 .wlan_profile_get_profile_data_cmdid =
222 WMI_10X_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
223 .wlan_profile_enable_profile_id_cmdid =
224 WMI_10X_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
225 .wlan_profile_list_profile_id_cmdid =
226 WMI_10X_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
227 .pdev_suspend_cmdid = WMI_10X_PDEV_SUSPEND_CMDID,
228 .pdev_resume_cmdid = WMI_10X_PDEV_RESUME_CMDID,
229 .add_bcn_filter_cmdid = WMI_10X_ADD_BCN_FILTER_CMDID,
230 .rmv_bcn_filter_cmdid = WMI_10X_RMV_BCN_FILTER_CMDID,
231 .wow_add_wake_pattern_cmdid = WMI_10X_WOW_ADD_WAKE_PATTERN_CMDID,
232 .wow_del_wake_pattern_cmdid = WMI_10X_WOW_DEL_WAKE_PATTERN_CMDID,
233 .wow_enable_disable_wake_event_cmdid =
234 WMI_10X_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
235 .wow_enable_cmdid = WMI_10X_WOW_ENABLE_CMDID,
236 .wow_hostwakeup_from_sleep_cmdid =
237 WMI_10X_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
238 .rtt_measreq_cmdid = WMI_10X_RTT_MEASREQ_CMDID,
239 .rtt_tsf_cmdid = WMI_10X_RTT_TSF_CMDID,
240 .vdev_spectral_scan_configure_cmdid =
241 WMI_10X_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
242 .vdev_spectral_scan_enable_cmdid =
243 WMI_10X_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
244 .request_stats_cmdid = WMI_10X_REQUEST_STATS_CMDID,
245 .set_arp_ns_offload_cmdid = WMI_CMD_UNDEFINED,
246 .network_list_offload_config_cmdid = WMI_CMD_UNDEFINED,
247 .gtk_offload_cmdid = WMI_CMD_UNDEFINED,
248 .csa_offload_enable_cmdid = WMI_CMD_UNDEFINED,
249 .csa_offload_chanswitch_cmdid = WMI_CMD_UNDEFINED,
250 .chatter_set_mode_cmdid = WMI_CMD_UNDEFINED,
251 .peer_tid_addba_cmdid = WMI_CMD_UNDEFINED,
252 .peer_tid_delba_cmdid = WMI_CMD_UNDEFINED,
253 .sta_dtim_ps_method_cmdid = WMI_CMD_UNDEFINED,
254 .sta_uapsd_auto_trig_cmdid = WMI_CMD_UNDEFINED,
255 .sta_keepalive_cmd = WMI_CMD_UNDEFINED,
256 .echo_cmdid = WMI_10X_ECHO_CMDID,
257 .pdev_utf_cmdid = WMI_10X_PDEV_UTF_CMDID,
258 .dbglog_cfg_cmdid = WMI_10X_DBGLOG_CFG_CMDID,
259 .pdev_qvit_cmdid = WMI_10X_PDEV_QVIT_CMDID,
260 .pdev_ftm_intg_cmdid = WMI_CMD_UNDEFINED,
261 .vdev_set_keepalive_cmdid = WMI_CMD_UNDEFINED,
262 .vdev_get_keepalive_cmdid = WMI_CMD_UNDEFINED,
263 .force_fw_hang_cmdid = WMI_CMD_UNDEFINED,
264 .gpio_config_cmdid = WMI_10X_GPIO_CONFIG_CMDID,
265 .gpio_output_cmdid = WMI_10X_GPIO_OUTPUT_CMDID,
266};
Bartosz Markowskice428702013-09-26 17:47:05 +0200267
Kalle Valo5e3dd152013-06-12 20:52:10 +0300268int ath10k_wmi_wait_for_service_ready(struct ath10k *ar)
269{
270 int ret;
271 ret = wait_for_completion_timeout(&ar->wmi.service_ready,
272 WMI_SERVICE_READY_TIMEOUT_HZ);
273 return ret;
274}
275
276int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar)
277{
278 int ret;
279 ret = wait_for_completion_timeout(&ar->wmi.unified_ready,
280 WMI_UNIFIED_READY_TIMEOUT_HZ);
281 return ret;
282}
283
284static struct sk_buff *ath10k_wmi_alloc_skb(u32 len)
285{
286 struct sk_buff *skb;
287 u32 round_len = roundup(len, 4);
288
289 skb = ath10k_htc_alloc_skb(WMI_SKB_HEADROOM + round_len);
290 if (!skb)
291 return NULL;
292
293 skb_reserve(skb, WMI_SKB_HEADROOM);
294 if (!IS_ALIGNED((unsigned long)skb->data, 4))
295 ath10k_warn("Unaligned WMI skb\n");
296
297 skb_put(skb, round_len);
298 memset(skb->data, 0, round_len);
299
300 return skb;
301}
302
303static void ath10k_wmi_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb)
304{
305 dev_kfree_skb(skb);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300306}
307
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200308static int ath10k_wmi_cmd_send_nowait(struct ath10k *ar, struct sk_buff *skb,
Bartosz Markowskice428702013-09-26 17:47:05 +0200309 u32 cmd_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +0300310{
311 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb);
312 struct wmi_cmd_hdr *cmd_hdr;
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200313 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300314 u32 cmd = 0;
315
316 if (skb_push(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
317 return -ENOMEM;
318
319 cmd |= SM(cmd_id, WMI_CMD_HDR_CMD_ID);
320
321 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
322 cmd_hdr->cmd_id = __cpu_to_le32(cmd);
323
Kalle Valo5e3dd152013-06-12 20:52:10 +0300324 memset(skb_cb, 0, sizeof(*skb_cb));
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200325 ret = ath10k_htc_send(&ar->htc, ar->wmi.eid, skb);
326 trace_ath10k_wmi_cmd(cmd_id, skb->data, skb->len, ret);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300327
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200328 if (ret)
329 goto err_pull;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300330
331 return 0;
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200332
333err_pull:
334 skb_pull(skb, sizeof(struct wmi_cmd_hdr));
335 return ret;
336}
337
Michal Kaziored543882013-09-13 14:16:56 +0200338static void ath10k_wmi_tx_beacon_nowait(struct ath10k_vif *arvif)
339{
340 struct wmi_bcn_tx_arg arg = {0};
341 int ret;
342
343 lockdep_assert_held(&arvif->ar->data_lock);
344
345 if (arvif->beacon == NULL)
346 return;
347
348 arg.vdev_id = arvif->vdev_id;
349 arg.tx_rate = 0;
350 arg.tx_power = 0;
351 arg.bcn = arvif->beacon->data;
352 arg.bcn_len = arvif->beacon->len;
353
354 ret = ath10k_wmi_beacon_send_nowait(arvif->ar, &arg);
355 if (ret)
356 return;
357
358 dev_kfree_skb_any(arvif->beacon);
359 arvif->beacon = NULL;
360}
361
362static void ath10k_wmi_tx_beacons_iter(void *data, u8 *mac,
363 struct ieee80211_vif *vif)
364{
365 struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif);
366
367 ath10k_wmi_tx_beacon_nowait(arvif);
368}
369
370static void ath10k_wmi_tx_beacons_nowait(struct ath10k *ar)
371{
372 spin_lock_bh(&ar->data_lock);
373 ieee80211_iterate_active_interfaces_atomic(ar->hw,
374 IEEE80211_IFACE_ITER_NORMAL,
375 ath10k_wmi_tx_beacons_iter,
376 NULL);
377 spin_unlock_bh(&ar->data_lock);
378}
379
Michal Kazior12acbc42013-09-13 14:16:55 +0200380static void ath10k_wmi_op_ep_tx_credits(struct ath10k *ar)
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200381{
Michal Kaziored543882013-09-13 14:16:56 +0200382 /* try to send pending beacons first. they take priority */
383 ath10k_wmi_tx_beacons_nowait(ar);
384
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200385 wake_up(&ar->wmi.tx_credits_wq);
386}
387
388static int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb,
Bartosz Markowskice428702013-09-26 17:47:05 +0200389 u32 cmd_id)
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200390{
391 int ret = -EINVAL;
392
Bartosz Markowski55321552013-09-26 17:47:07 +0200393 if (cmd_id == WMI_CMD_UNDEFINED) {
394 ath10k_warn("wmi command %d is not supported by firmware\n",
395 cmd_id);
396 return ret;
397 }
398
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200399 wait_event_timeout(ar->wmi.tx_credits_wq, ({
Michal Kaziored543882013-09-13 14:16:56 +0200400 /* try to send pending beacons first. they take priority */
401 ath10k_wmi_tx_beacons_nowait(ar);
402
Michal Kaziorbe8b3942013-09-13 14:16:54 +0200403 ret = ath10k_wmi_cmd_send_nowait(ar, skb, cmd_id);
404 (ret != -EAGAIN);
405 }), 3*HZ);
406
407 if (ret)
408 dev_kfree_skb_any(skb);
409
410 return ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300411}
412
Bartosz Markowski5e00d312013-09-26 17:47:12 +0200413int ath10k_wmi_mgmt_tx(struct ath10k *ar, struct sk_buff *skb)
414{
415 int ret = 0;
416 struct wmi_mgmt_tx_cmd *cmd;
417 struct ieee80211_hdr *hdr;
418 struct sk_buff *wmi_skb;
419 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
420 int len;
421 u16 fc;
422
423 hdr = (struct ieee80211_hdr *)skb->data;
424 fc = le16_to_cpu(hdr->frame_control);
425
426 if (WARN_ON_ONCE(!ieee80211_is_mgmt(hdr->frame_control)))
427 return -EINVAL;
428
429 len = sizeof(cmd->hdr) + skb->len;
430 len = round_up(len, 4);
431
432 wmi_skb = ath10k_wmi_alloc_skb(len);
433 if (!wmi_skb)
434 return -ENOMEM;
435
436 cmd = (struct wmi_mgmt_tx_cmd *)wmi_skb->data;
437
438 cmd->hdr.vdev_id = __cpu_to_le32(ATH10K_SKB_CB(skb)->vdev_id);
439 cmd->hdr.tx_rate = 0;
440 cmd->hdr.tx_power = 0;
441 cmd->hdr.buf_len = __cpu_to_le32((u32)(skb->len));
442
443 memcpy(cmd->hdr.peer_macaddr.addr, ieee80211_get_DA(hdr), ETH_ALEN);
444 memcpy(cmd->buf, skb->data, skb->len);
445
446 ath10k_dbg(ATH10K_DBG_WMI, "wmi mgmt tx skb %p len %d ftype %02x stype %02x\n",
447 wmi_skb, wmi_skb->len, fc & IEEE80211_FCTL_FTYPE,
448 fc & IEEE80211_FCTL_STYPE);
449
450 /* Send the management frame buffer to the target */
451 ret = ath10k_wmi_cmd_send(ar, wmi_skb, ar->wmi.cmd->mgmt_tx_cmdid);
452 if (ret) {
453 dev_kfree_skb_any(skb);
454 return ret;
455 }
456
457 /* TODO: report tx status to mac80211 - temporary just ACK */
458 info->flags |= IEEE80211_TX_STAT_ACK;
459 ieee80211_tx_status_irqsafe(ar->hw, skb);
460
461 return ret;
462}
463
Kalle Valo5e3dd152013-06-12 20:52:10 +0300464static int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb)
465{
466 struct wmi_scan_event *event = (struct wmi_scan_event *)skb->data;
467 enum wmi_scan_event_type event_type;
468 enum wmi_scan_completion_reason reason;
469 u32 freq;
470 u32 req_id;
471 u32 scan_id;
472 u32 vdev_id;
473
474 event_type = __le32_to_cpu(event->event_type);
475 reason = __le32_to_cpu(event->reason);
476 freq = __le32_to_cpu(event->channel_freq);
477 req_id = __le32_to_cpu(event->scan_req_id);
478 scan_id = __le32_to_cpu(event->scan_id);
479 vdev_id = __le32_to_cpu(event->vdev_id);
480
481 ath10k_dbg(ATH10K_DBG_WMI, "WMI_SCAN_EVENTID\n");
482 ath10k_dbg(ATH10K_DBG_WMI,
483 "scan event type %d reason %d freq %d req_id %d "
484 "scan_id %d vdev_id %d\n",
485 event_type, reason, freq, req_id, scan_id, vdev_id);
486
487 spin_lock_bh(&ar->data_lock);
488
489 switch (event_type) {
490 case WMI_SCAN_EVENT_STARTED:
491 ath10k_dbg(ATH10K_DBG_WMI, "SCAN_EVENT_STARTED\n");
492 if (ar->scan.in_progress && ar->scan.is_roc)
493 ieee80211_ready_on_channel(ar->hw);
494
495 complete(&ar->scan.started);
496 break;
497 case WMI_SCAN_EVENT_COMPLETED:
498 ath10k_dbg(ATH10K_DBG_WMI, "SCAN_EVENT_COMPLETED\n");
499 switch (reason) {
500 case WMI_SCAN_REASON_COMPLETED:
501 ath10k_dbg(ATH10K_DBG_WMI, "SCAN_REASON_COMPLETED\n");
502 break;
503 case WMI_SCAN_REASON_CANCELLED:
504 ath10k_dbg(ATH10K_DBG_WMI, "SCAN_REASON_CANCELED\n");
505 break;
506 case WMI_SCAN_REASON_PREEMPTED:
507 ath10k_dbg(ATH10K_DBG_WMI, "SCAN_REASON_PREEMPTED\n");
508 break;
509 case WMI_SCAN_REASON_TIMEDOUT:
510 ath10k_dbg(ATH10K_DBG_WMI, "SCAN_REASON_TIMEDOUT\n");
511 break;
512 default:
513 break;
514 }
515
516 ar->scan_channel = NULL;
517 if (!ar->scan.in_progress) {
518 ath10k_warn("no scan requested, ignoring\n");
519 break;
520 }
521
522 if (ar->scan.is_roc) {
523 ath10k_offchan_tx_purge(ar);
524
525 if (!ar->scan.aborting)
526 ieee80211_remain_on_channel_expired(ar->hw);
527 } else {
528 ieee80211_scan_completed(ar->hw, ar->scan.aborting);
529 }
530
531 del_timer(&ar->scan.timeout);
532 complete_all(&ar->scan.completed);
533 ar->scan.in_progress = false;
534 break;
535 case WMI_SCAN_EVENT_BSS_CHANNEL:
536 ath10k_dbg(ATH10K_DBG_WMI, "SCAN_EVENT_BSS_CHANNEL\n");
537 ar->scan_channel = NULL;
538 break;
539 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
540 ath10k_dbg(ATH10K_DBG_WMI, "SCAN_EVENT_FOREIGN_CHANNEL\n");
541 ar->scan_channel = ieee80211_get_channel(ar->hw->wiphy, freq);
542 if (ar->scan.in_progress && ar->scan.is_roc &&
543 ar->scan.roc_freq == freq) {
544 complete(&ar->scan.on_channel);
545 }
546 break;
547 case WMI_SCAN_EVENT_DEQUEUED:
548 ath10k_dbg(ATH10K_DBG_WMI, "SCAN_EVENT_DEQUEUED\n");
549 break;
550 case WMI_SCAN_EVENT_PREEMPTED:
551 ath10k_dbg(ATH10K_DBG_WMI, "WMI_SCAN_EVENT_PREEMPTED\n");
552 break;
553 case WMI_SCAN_EVENT_START_FAILED:
554 ath10k_dbg(ATH10K_DBG_WMI, "WMI_SCAN_EVENT_START_FAILED\n");
555 break;
556 default:
557 break;
558 }
559
560 spin_unlock_bh(&ar->data_lock);
561 return 0;
562}
563
564static inline enum ieee80211_band phy_mode_to_band(u32 phy_mode)
565{
566 enum ieee80211_band band;
567
568 switch (phy_mode) {
569 case MODE_11A:
570 case MODE_11NA_HT20:
571 case MODE_11NA_HT40:
572 case MODE_11AC_VHT20:
573 case MODE_11AC_VHT40:
574 case MODE_11AC_VHT80:
575 band = IEEE80211_BAND_5GHZ;
576 break;
577 case MODE_11G:
578 case MODE_11B:
579 case MODE_11GONLY:
580 case MODE_11NG_HT20:
581 case MODE_11NG_HT40:
582 case MODE_11AC_VHT20_2G:
583 case MODE_11AC_VHT40_2G:
584 case MODE_11AC_VHT80_2G:
585 default:
586 band = IEEE80211_BAND_2GHZ;
587 }
588
589 return band;
590}
591
592static inline u8 get_rate_idx(u32 rate, enum ieee80211_band band)
593{
594 u8 rate_idx = 0;
595
596 /* rate in Kbps */
597 switch (rate) {
598 case 1000:
599 rate_idx = 0;
600 break;
601 case 2000:
602 rate_idx = 1;
603 break;
604 case 5500:
605 rate_idx = 2;
606 break;
607 case 11000:
608 rate_idx = 3;
609 break;
610 case 6000:
611 rate_idx = 4;
612 break;
613 case 9000:
614 rate_idx = 5;
615 break;
616 case 12000:
617 rate_idx = 6;
618 break;
619 case 18000:
620 rate_idx = 7;
621 break;
622 case 24000:
623 rate_idx = 8;
624 break;
625 case 36000:
626 rate_idx = 9;
627 break;
628 case 48000:
629 rate_idx = 10;
630 break;
631 case 54000:
632 rate_idx = 11;
633 break;
634 default:
635 break;
636 }
637
638 if (band == IEEE80211_BAND_5GHZ) {
639 if (rate_idx > 3)
640 /* Omit CCK rates */
641 rate_idx -= 4;
642 else
643 rate_idx = 0;
644 }
645
646 return rate_idx;
647}
648
649static int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
650{
Michal Kazior0d9b0432013-08-09 10:13:33 +0200651 struct wmi_mgmt_rx_event_v1 *ev_v1;
652 struct wmi_mgmt_rx_event_v2 *ev_v2;
653 struct wmi_mgmt_rx_hdr_v1 *ev_hdr;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300654 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
655 struct ieee80211_hdr *hdr;
656 u32 rx_status;
657 u32 channel;
658 u32 phy_mode;
659 u32 snr;
660 u32 rate;
661 u32 buf_len;
662 u16 fc;
Michal Kazior0d9b0432013-08-09 10:13:33 +0200663 int pull_len;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300664
Michal Kazior0d9b0432013-08-09 10:13:33 +0200665 if (test_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features)) {
666 ev_v2 = (struct wmi_mgmt_rx_event_v2 *)skb->data;
667 ev_hdr = &ev_v2->hdr.v1;
668 pull_len = sizeof(*ev_v2);
669 } else {
670 ev_v1 = (struct wmi_mgmt_rx_event_v1 *)skb->data;
671 ev_hdr = &ev_v1->hdr;
672 pull_len = sizeof(*ev_v1);
673 }
674
675 channel = __le32_to_cpu(ev_hdr->channel);
676 buf_len = __le32_to_cpu(ev_hdr->buf_len);
677 rx_status = __le32_to_cpu(ev_hdr->status);
678 snr = __le32_to_cpu(ev_hdr->snr);
679 phy_mode = __le32_to_cpu(ev_hdr->phy_mode);
680 rate = __le32_to_cpu(ev_hdr->rate);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300681
682 memset(status, 0, sizeof(*status));
683
684 ath10k_dbg(ATH10K_DBG_MGMT,
685 "event mgmt rx status %08x\n", rx_status);
686
687 if (rx_status & WMI_RX_STATUS_ERR_DECRYPT) {
688 dev_kfree_skb(skb);
689 return 0;
690 }
691
692 if (rx_status & WMI_RX_STATUS_ERR_KEY_CACHE_MISS) {
693 dev_kfree_skb(skb);
694 return 0;
695 }
696
697 if (rx_status & WMI_RX_STATUS_ERR_CRC)
698 status->flag |= RX_FLAG_FAILED_FCS_CRC;
699 if (rx_status & WMI_RX_STATUS_ERR_MIC)
700 status->flag |= RX_FLAG_MMIC_ERROR;
701
702 status->band = phy_mode_to_band(phy_mode);
703 status->freq = ieee80211_channel_to_frequency(channel, status->band);
704 status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR;
705 status->rate_idx = get_rate_idx(rate, status->band);
706
Michal Kazior0d9b0432013-08-09 10:13:33 +0200707 skb_pull(skb, pull_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300708
709 hdr = (struct ieee80211_hdr *)skb->data;
710 fc = le16_to_cpu(hdr->frame_control);
711
712 if (fc & IEEE80211_FCTL_PROTECTED) {
713 status->flag |= RX_FLAG_DECRYPTED | RX_FLAG_IV_STRIPPED |
714 RX_FLAG_MMIC_STRIPPED;
715 hdr->frame_control = __cpu_to_le16(fc &
716 ~IEEE80211_FCTL_PROTECTED);
717 }
718
719 ath10k_dbg(ATH10K_DBG_MGMT,
720 "event mgmt rx skb %p len %d ftype %02x stype %02x\n",
721 skb, skb->len,
722 fc & IEEE80211_FCTL_FTYPE, fc & IEEE80211_FCTL_STYPE);
723
724 ath10k_dbg(ATH10K_DBG_MGMT,
725 "event mgmt rx freq %d band %d snr %d, rate_idx %d\n",
726 status->freq, status->band, status->signal,
727 status->rate_idx);
728
729 /*
730 * packets from HTC come aligned to 4byte boundaries
731 * because they can originally come in along with a trailer
732 */
733 skb_trim(skb, buf_len);
734
735 ieee80211_rx(ar->hw, skb);
736 return 0;
737}
738
Michal Kazior2e1dea42013-07-31 10:32:40 +0200739static int freq_to_idx(struct ath10k *ar, int freq)
740{
741 struct ieee80211_supported_band *sband;
742 int band, ch, idx = 0;
743
744 for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) {
745 sband = ar->hw->wiphy->bands[band];
746 if (!sband)
747 continue;
748
749 for (ch = 0; ch < sband->n_channels; ch++, idx++)
750 if (sband->channels[ch].center_freq == freq)
751 goto exit;
752 }
753
754exit:
755 return idx;
756}
757
Kalle Valo5e3dd152013-06-12 20:52:10 +0300758static void ath10k_wmi_event_chan_info(struct ath10k *ar, struct sk_buff *skb)
759{
Michal Kazior2e1dea42013-07-31 10:32:40 +0200760 struct wmi_chan_info_event *ev;
761 struct survey_info *survey;
762 u32 err_code, freq, cmd_flags, noise_floor, rx_clear_count, cycle_count;
763 int idx;
764
765 ev = (struct wmi_chan_info_event *)skb->data;
766
767 err_code = __le32_to_cpu(ev->err_code);
768 freq = __le32_to_cpu(ev->freq);
769 cmd_flags = __le32_to_cpu(ev->cmd_flags);
770 noise_floor = __le32_to_cpu(ev->noise_floor);
771 rx_clear_count = __le32_to_cpu(ev->rx_clear_count);
772 cycle_count = __le32_to_cpu(ev->cycle_count);
773
774 ath10k_dbg(ATH10K_DBG_WMI,
775 "chan info err_code %d freq %d cmd_flags %d noise_floor %d rx_clear_count %d cycle_count %d\n",
776 err_code, freq, cmd_flags, noise_floor, rx_clear_count,
777 cycle_count);
778
779 spin_lock_bh(&ar->data_lock);
780
781 if (!ar->scan.in_progress) {
782 ath10k_warn("chan info event without a scan request?\n");
783 goto exit;
784 }
785
786 idx = freq_to_idx(ar, freq);
787 if (idx >= ARRAY_SIZE(ar->survey)) {
788 ath10k_warn("chan info: invalid frequency %d (idx %d out of bounds)\n",
789 freq, idx);
790 goto exit;
791 }
792
793 if (cmd_flags & WMI_CHAN_INFO_FLAG_COMPLETE) {
794 /* During scanning chan info is reported twice for each
795 * visited channel. The reported cycle count is global
796 * and per-channel cycle count must be calculated */
797
798 cycle_count -= ar->survey_last_cycle_count;
799 rx_clear_count -= ar->survey_last_rx_clear_count;
800
801 survey = &ar->survey[idx];
802 survey->channel_time = WMI_CHAN_INFO_MSEC(cycle_count);
803 survey->channel_time_rx = WMI_CHAN_INFO_MSEC(rx_clear_count);
804 survey->noise = noise_floor;
805 survey->filled = SURVEY_INFO_CHANNEL_TIME |
806 SURVEY_INFO_CHANNEL_TIME_RX |
807 SURVEY_INFO_NOISE_DBM;
808 }
809
810 ar->survey_last_rx_clear_count = rx_clear_count;
811 ar->survey_last_cycle_count = cycle_count;
812
813exit:
814 spin_unlock_bh(&ar->data_lock);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300815}
816
817static void ath10k_wmi_event_echo(struct ath10k *ar, struct sk_buff *skb)
818{
819 ath10k_dbg(ATH10K_DBG_WMI, "WMI_ECHO_EVENTID\n");
820}
821
822static void ath10k_wmi_event_debug_mesg(struct ath10k *ar, struct sk_buff *skb)
823{
824 ath10k_dbg(ATH10K_DBG_WMI, "WMI_DEBUG_MESG_EVENTID\n");
825}
826
827static void ath10k_wmi_event_update_stats(struct ath10k *ar,
828 struct sk_buff *skb)
829{
830 struct wmi_stats_event *ev = (struct wmi_stats_event *)skb->data;
831
832 ath10k_dbg(ATH10K_DBG_WMI, "WMI_UPDATE_STATS_EVENTID\n");
833
834 ath10k_debug_read_target_stats(ar, ev);
835}
836
837static void ath10k_wmi_event_vdev_start_resp(struct ath10k *ar,
838 struct sk_buff *skb)
839{
840 struct wmi_vdev_start_response_event *ev;
841
842 ath10k_dbg(ATH10K_DBG_WMI, "WMI_VDEV_START_RESP_EVENTID\n");
843
844 ev = (struct wmi_vdev_start_response_event *)skb->data;
845
846 if (WARN_ON(__le32_to_cpu(ev->status)))
847 return;
848
849 complete(&ar->vdev_setup_done);
850}
851
852static void ath10k_wmi_event_vdev_stopped(struct ath10k *ar,
853 struct sk_buff *skb)
854{
855 ath10k_dbg(ATH10K_DBG_WMI, "WMI_VDEV_STOPPED_EVENTID\n");
856 complete(&ar->vdev_setup_done);
857}
858
859static void ath10k_wmi_event_peer_sta_kickout(struct ath10k *ar,
860 struct sk_buff *skb)
861{
862 ath10k_dbg(ATH10K_DBG_WMI, "WMI_PEER_STA_KICKOUT_EVENTID\n");
863}
864
865/*
866 * FIXME
867 *
868 * We don't report to mac80211 sleep state of connected
869 * stations. Due to this mac80211 can't fill in TIM IE
870 * correctly.
871 *
872 * I know of no way of getting nullfunc frames that contain
873 * sleep transition from connected stations - these do not
874 * seem to be sent from the target to the host. There also
875 * doesn't seem to be a dedicated event for that. So the
876 * only way left to do this would be to read tim_bitmap
877 * during SWBA.
878 *
879 * We could probably try using tim_bitmap from SWBA to tell
880 * mac80211 which stations are asleep and which are not. The
881 * problem here is calling mac80211 functions so many times
882 * could take too long and make us miss the time to submit
883 * the beacon to the target.
884 *
885 * So as a workaround we try to extend the TIM IE if there
886 * is unicast buffered for stations with aid > 7 and fill it
887 * in ourselves.
888 */
889static void ath10k_wmi_update_tim(struct ath10k *ar,
890 struct ath10k_vif *arvif,
891 struct sk_buff *bcn,
892 struct wmi_bcn_info *bcn_info)
893{
894 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)bcn->data;
895 struct ieee80211_tim_ie *tim;
896 u8 *ies, *ie;
897 u8 ie_len, pvm_len;
898
899 /* if next SWBA has no tim_changed the tim_bitmap is garbage.
900 * we must copy the bitmap upon change and reuse it later */
901 if (__le32_to_cpu(bcn_info->tim_info.tim_changed)) {
902 int i;
903
904 BUILD_BUG_ON(sizeof(arvif->u.ap.tim_bitmap) !=
905 sizeof(bcn_info->tim_info.tim_bitmap));
906
907 for (i = 0; i < sizeof(arvif->u.ap.tim_bitmap); i++) {
908 __le32 t = bcn_info->tim_info.tim_bitmap[i / 4];
909 u32 v = __le32_to_cpu(t);
910 arvif->u.ap.tim_bitmap[i] = (v >> ((i % 4) * 8)) & 0xFF;
911 }
912
913 /* FW reports either length 0 or 16
914 * so we calculate this on our own */
915 arvif->u.ap.tim_len = 0;
916 for (i = 0; i < sizeof(arvif->u.ap.tim_bitmap); i++)
917 if (arvif->u.ap.tim_bitmap[i])
918 arvif->u.ap.tim_len = i;
919
920 arvif->u.ap.tim_len++;
921 }
922
923 ies = bcn->data;
924 ies += ieee80211_hdrlen(hdr->frame_control);
925 ies += 12; /* fixed parameters */
926
927 ie = (u8 *)cfg80211_find_ie(WLAN_EID_TIM, ies,
928 (u8 *)skb_tail_pointer(bcn) - ies);
929 if (!ie) {
Michal Kazior09af8f82013-07-05 16:15:08 +0300930 if (arvif->vdev_type != WMI_VDEV_TYPE_IBSS)
931 ath10k_warn("no tim ie found;\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +0300932 return;
933 }
934
935 tim = (void *)ie + 2;
936 ie_len = ie[1];
937 pvm_len = ie_len - 3; /* exclude dtim count, dtim period, bmap ctl */
938
939 if (pvm_len < arvif->u.ap.tim_len) {
940 int expand_size = sizeof(arvif->u.ap.tim_bitmap) - pvm_len;
941 int move_size = skb_tail_pointer(bcn) - (ie + 2 + ie_len);
942 void *next_ie = ie + 2 + ie_len;
943
944 if (skb_put(bcn, expand_size)) {
945 memmove(next_ie + expand_size, next_ie, move_size);
946
947 ie[1] += expand_size;
948 ie_len += expand_size;
949 pvm_len += expand_size;
950 } else {
951 ath10k_warn("tim expansion failed\n");
952 }
953 }
954
955 if (pvm_len > sizeof(arvif->u.ap.tim_bitmap)) {
956 ath10k_warn("tim pvm length is too great (%d)\n", pvm_len);
957 return;
958 }
959
960 tim->bitmap_ctrl = !!__le32_to_cpu(bcn_info->tim_info.tim_mcast);
961 memcpy(tim->virtual_map, arvif->u.ap.tim_bitmap, pvm_len);
962
963 ath10k_dbg(ATH10K_DBG_MGMT, "dtim %d/%d mcast %d pvmlen %d\n",
964 tim->dtim_count, tim->dtim_period,
965 tim->bitmap_ctrl, pvm_len);
966}
967
968static void ath10k_p2p_fill_noa_ie(u8 *data, u32 len,
969 struct wmi_p2p_noa_info *noa)
970{
971 struct ieee80211_p2p_noa_attr *noa_attr;
972 u8 ctwindow_oppps = noa->ctwindow_oppps;
973 u8 ctwindow = ctwindow_oppps >> WMI_P2P_OPPPS_CTWINDOW_OFFSET;
974 bool oppps = !!(ctwindow_oppps & WMI_P2P_OPPPS_ENABLE_BIT);
975 __le16 *noa_attr_len;
976 u16 attr_len;
977 u8 noa_descriptors = noa->num_descriptors;
978 int i;
979
980 /* P2P IE */
981 data[0] = WLAN_EID_VENDOR_SPECIFIC;
982 data[1] = len - 2;
983 data[2] = (WLAN_OUI_WFA >> 16) & 0xff;
984 data[3] = (WLAN_OUI_WFA >> 8) & 0xff;
985 data[4] = (WLAN_OUI_WFA >> 0) & 0xff;
986 data[5] = WLAN_OUI_TYPE_WFA_P2P;
987
988 /* NOA ATTR */
989 data[6] = IEEE80211_P2P_ATTR_ABSENCE_NOTICE;
990 noa_attr_len = (__le16 *)&data[7]; /* 2 bytes */
991 noa_attr = (struct ieee80211_p2p_noa_attr *)&data[9];
992
993 noa_attr->index = noa->index;
994 noa_attr->oppps_ctwindow = ctwindow;
995 if (oppps)
996 noa_attr->oppps_ctwindow |= IEEE80211_P2P_OPPPS_ENABLE_BIT;
997
998 for (i = 0; i < noa_descriptors; i++) {
999 noa_attr->desc[i].count =
1000 __le32_to_cpu(noa->descriptors[i].type_count);
1001 noa_attr->desc[i].duration = noa->descriptors[i].duration;
1002 noa_attr->desc[i].interval = noa->descriptors[i].interval;
1003 noa_attr->desc[i].start_time = noa->descriptors[i].start_time;
1004 }
1005
1006 attr_len = 2; /* index + oppps_ctwindow */
1007 attr_len += noa_descriptors * sizeof(struct ieee80211_p2p_noa_desc);
1008 *noa_attr_len = __cpu_to_le16(attr_len);
1009}
1010
1011static u32 ath10k_p2p_calc_noa_ie_len(struct wmi_p2p_noa_info *noa)
1012{
1013 u32 len = 0;
1014 u8 noa_descriptors = noa->num_descriptors;
1015 u8 opp_ps_info = noa->ctwindow_oppps;
1016 bool opps_enabled = !!(opp_ps_info & WMI_P2P_OPPPS_ENABLE_BIT);
1017
1018
1019 if (!noa_descriptors && !opps_enabled)
1020 return len;
1021
1022 len += 1 + 1 + 4; /* EID + len + OUI */
1023 len += 1 + 2; /* noa attr + attr len */
1024 len += 1 + 1; /* index + oppps_ctwindow */
1025 len += noa_descriptors * sizeof(struct ieee80211_p2p_noa_desc);
1026
1027 return len;
1028}
1029
1030static void ath10k_wmi_update_noa(struct ath10k *ar, struct ath10k_vif *arvif,
1031 struct sk_buff *bcn,
1032 struct wmi_bcn_info *bcn_info)
1033{
1034 struct wmi_p2p_noa_info *noa = &bcn_info->p2p_noa_info;
1035 u8 *new_data, *old_data = arvif->u.ap.noa_data;
1036 u32 new_len;
1037
1038 if (arvif->vdev_subtype != WMI_VDEV_SUBTYPE_P2P_GO)
1039 return;
1040
1041 ath10k_dbg(ATH10K_DBG_MGMT, "noa changed: %d\n", noa->changed);
1042 if (noa->changed & WMI_P2P_NOA_CHANGED_BIT) {
1043 new_len = ath10k_p2p_calc_noa_ie_len(noa);
1044 if (!new_len)
1045 goto cleanup;
1046
1047 new_data = kmalloc(new_len, GFP_ATOMIC);
1048 if (!new_data)
1049 goto cleanup;
1050
1051 ath10k_p2p_fill_noa_ie(new_data, new_len, noa);
1052
1053 spin_lock_bh(&ar->data_lock);
1054 arvif->u.ap.noa_data = new_data;
1055 arvif->u.ap.noa_len = new_len;
1056 spin_unlock_bh(&ar->data_lock);
1057 kfree(old_data);
1058 }
1059
1060 if (arvif->u.ap.noa_data)
1061 if (!pskb_expand_head(bcn, 0, arvif->u.ap.noa_len, GFP_ATOMIC))
1062 memcpy(skb_put(bcn, arvif->u.ap.noa_len),
1063 arvif->u.ap.noa_data,
1064 arvif->u.ap.noa_len);
1065 return;
1066
1067cleanup:
1068 spin_lock_bh(&ar->data_lock);
1069 arvif->u.ap.noa_data = NULL;
1070 arvif->u.ap.noa_len = 0;
1071 spin_unlock_bh(&ar->data_lock);
1072 kfree(old_data);
1073}
1074
1075
1076static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
1077{
1078 struct wmi_host_swba_event *ev;
1079 u32 map;
1080 int i = -1;
1081 struct wmi_bcn_info *bcn_info;
1082 struct ath10k_vif *arvif;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001083 struct sk_buff *bcn;
1084 int vdev_id = 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001085
1086 ath10k_dbg(ATH10K_DBG_MGMT, "WMI_HOST_SWBA_EVENTID\n");
1087
1088 ev = (struct wmi_host_swba_event *)skb->data;
1089 map = __le32_to_cpu(ev->vdev_map);
1090
1091 ath10k_dbg(ATH10K_DBG_MGMT, "host swba:\n"
1092 "-vdev map 0x%x\n",
1093 ev->vdev_map);
1094
1095 for (; map; map >>= 1, vdev_id++) {
1096 if (!(map & 0x1))
1097 continue;
1098
1099 i++;
1100
1101 if (i >= WMI_MAX_AP_VDEV) {
1102 ath10k_warn("swba has corrupted vdev map\n");
1103 break;
1104 }
1105
1106 bcn_info = &ev->bcn_info[i];
1107
1108 ath10k_dbg(ATH10K_DBG_MGMT,
1109 "-bcn_info[%d]:\n"
1110 "--tim_len %d\n"
1111 "--tim_mcast %d\n"
1112 "--tim_changed %d\n"
1113 "--tim_num_ps_pending %d\n"
1114 "--tim_bitmap 0x%08x%08x%08x%08x\n",
1115 i,
1116 __le32_to_cpu(bcn_info->tim_info.tim_len),
1117 __le32_to_cpu(bcn_info->tim_info.tim_mcast),
1118 __le32_to_cpu(bcn_info->tim_info.tim_changed),
1119 __le32_to_cpu(bcn_info->tim_info.tim_num_ps_pending),
1120 __le32_to_cpu(bcn_info->tim_info.tim_bitmap[3]),
1121 __le32_to_cpu(bcn_info->tim_info.tim_bitmap[2]),
1122 __le32_to_cpu(bcn_info->tim_info.tim_bitmap[1]),
1123 __le32_to_cpu(bcn_info->tim_info.tim_bitmap[0]));
1124
1125 arvif = ath10k_get_arvif(ar, vdev_id);
1126 if (arvif == NULL) {
1127 ath10k_warn("no vif for vdev_id %d found\n", vdev_id);
1128 continue;
1129 }
1130
1131 bcn = ieee80211_beacon_get(ar->hw, arvif->vif);
1132 if (!bcn) {
1133 ath10k_warn("could not get mac80211 beacon\n");
1134 continue;
1135 }
1136
1137 ath10k_tx_h_seq_no(bcn);
1138 ath10k_wmi_update_tim(ar, arvif, bcn, bcn_info);
1139 ath10k_wmi_update_noa(ar, arvif, bcn, bcn_info);
1140
Michal Kaziored543882013-09-13 14:16:56 +02001141 spin_lock_bh(&ar->data_lock);
1142 if (arvif->beacon) {
1143 ath10k_warn("SWBA overrun on vdev %d\n",
1144 arvif->vdev_id);
1145 dev_kfree_skb_any(arvif->beacon);
1146 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03001147
Michal Kaziored543882013-09-13 14:16:56 +02001148 arvif->beacon = bcn;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001149
Michal Kaziored543882013-09-13 14:16:56 +02001150 ath10k_wmi_tx_beacon_nowait(arvif);
1151 spin_unlock_bh(&ar->data_lock);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001152 }
1153}
1154
1155static void ath10k_wmi_event_tbttoffset_update(struct ath10k *ar,
1156 struct sk_buff *skb)
1157{
1158 ath10k_dbg(ATH10K_DBG_WMI, "WMI_TBTTOFFSET_UPDATE_EVENTID\n");
1159}
1160
1161static void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb)
1162{
1163 ath10k_dbg(ATH10K_DBG_WMI, "WMI_PHYERR_EVENTID\n");
1164}
1165
1166static void ath10k_wmi_event_roam(struct ath10k *ar, struct sk_buff *skb)
1167{
1168 ath10k_dbg(ATH10K_DBG_WMI, "WMI_ROAM_EVENTID\n");
1169}
1170
1171static void ath10k_wmi_event_profile_match(struct ath10k *ar,
1172 struct sk_buff *skb)
1173{
1174 ath10k_dbg(ATH10K_DBG_WMI, "WMI_PROFILE_MATCH\n");
1175}
1176
1177static void ath10k_wmi_event_debug_print(struct ath10k *ar,
1178 struct sk_buff *skb)
1179{
1180 ath10k_dbg(ATH10K_DBG_WMI, "WMI_DEBUG_PRINT_EVENTID\n");
1181}
1182
1183static void ath10k_wmi_event_pdev_qvit(struct ath10k *ar, struct sk_buff *skb)
1184{
1185 ath10k_dbg(ATH10K_DBG_WMI, "WMI_PDEV_QVIT_EVENTID\n");
1186}
1187
1188static void ath10k_wmi_event_wlan_profile_data(struct ath10k *ar,
1189 struct sk_buff *skb)
1190{
1191 ath10k_dbg(ATH10K_DBG_WMI, "WMI_WLAN_PROFILE_DATA_EVENTID\n");
1192}
1193
1194static void ath10k_wmi_event_rtt_measurement_report(struct ath10k *ar,
1195 struct sk_buff *skb)
1196{
1197 ath10k_dbg(ATH10K_DBG_WMI, "WMI_RTT_MEASUREMENT_REPORT_EVENTID\n");
1198}
1199
1200static void ath10k_wmi_event_tsf_measurement_report(struct ath10k *ar,
1201 struct sk_buff *skb)
1202{
1203 ath10k_dbg(ATH10K_DBG_WMI, "WMI_TSF_MEASUREMENT_REPORT_EVENTID\n");
1204}
1205
1206static void ath10k_wmi_event_rtt_error_report(struct ath10k *ar,
1207 struct sk_buff *skb)
1208{
1209 ath10k_dbg(ATH10K_DBG_WMI, "WMI_RTT_ERROR_REPORT_EVENTID\n");
1210}
1211
1212static void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar,
1213 struct sk_buff *skb)
1214{
1215 ath10k_dbg(ATH10K_DBG_WMI, "WMI_WOW_WAKEUP_HOST_EVENTID\n");
1216}
1217
1218static void ath10k_wmi_event_dcs_interference(struct ath10k *ar,
1219 struct sk_buff *skb)
1220{
1221 ath10k_dbg(ATH10K_DBG_WMI, "WMI_DCS_INTERFERENCE_EVENTID\n");
1222}
1223
1224static void ath10k_wmi_event_pdev_tpc_config(struct ath10k *ar,
1225 struct sk_buff *skb)
1226{
1227 ath10k_dbg(ATH10K_DBG_WMI, "WMI_PDEV_TPC_CONFIG_EVENTID\n");
1228}
1229
1230static void ath10k_wmi_event_pdev_ftm_intg(struct ath10k *ar,
1231 struct sk_buff *skb)
1232{
1233 ath10k_dbg(ATH10K_DBG_WMI, "WMI_PDEV_FTM_INTG_EVENTID\n");
1234}
1235
1236static void ath10k_wmi_event_gtk_offload_status(struct ath10k *ar,
1237 struct sk_buff *skb)
1238{
1239 ath10k_dbg(ATH10K_DBG_WMI, "WMI_GTK_OFFLOAD_STATUS_EVENTID\n");
1240}
1241
1242static void ath10k_wmi_event_gtk_rekey_fail(struct ath10k *ar,
1243 struct sk_buff *skb)
1244{
1245 ath10k_dbg(ATH10K_DBG_WMI, "WMI_GTK_REKEY_FAIL_EVENTID\n");
1246}
1247
1248static void ath10k_wmi_event_delba_complete(struct ath10k *ar,
1249 struct sk_buff *skb)
1250{
1251 ath10k_dbg(ATH10K_DBG_WMI, "WMI_TX_DELBA_COMPLETE_EVENTID\n");
1252}
1253
1254static void ath10k_wmi_event_addba_complete(struct ath10k *ar,
1255 struct sk_buff *skb)
1256{
1257 ath10k_dbg(ATH10K_DBG_WMI, "WMI_TX_ADDBA_COMPLETE_EVENTID\n");
1258}
1259
1260static void ath10k_wmi_event_vdev_install_key_complete(struct ath10k *ar,
1261 struct sk_buff *skb)
1262{
1263 ath10k_dbg(ATH10K_DBG_WMI, "WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID\n");
1264}
1265
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02001266static void ath10k_wmi_event_inst_rssi_stats(struct ath10k *ar,
1267 struct sk_buff *skb)
1268{
1269 ath10k_dbg(ATH10K_DBG_WMI, "WMI_INST_RSSI_STATS_EVENTID\n");
1270}
1271
1272static void ath10k_wmi_event_vdev_standby_req(struct ath10k *ar,
1273 struct sk_buff *skb)
1274{
1275 ath10k_dbg(ATH10K_DBG_WMI, "WMI_VDEV_STANDBY_REQ_EVENTID\n");
1276}
1277
1278static void ath10k_wmi_event_vdev_resume_req(struct ath10k *ar,
1279 struct sk_buff *skb)
1280{
1281 ath10k_dbg(ATH10K_DBG_WMI, "WMI_VDEV_RESUME_REQ_EVENTID\n");
1282}
1283
Bartosz Markowskib3effe62013-09-26 17:47:11 +02001284static int ath10k_wmi_alloc_host_mem(struct ath10k *ar, u32 req_id,
1285 u32 num_units, u32 unit_len)
1286{
1287 dma_addr_t paddr;
1288 u32 pool_size;
1289 int idx = ar->wmi.num_mem_chunks;
1290
1291 pool_size = num_units * round_up(unit_len, 4);
1292
1293 if (!pool_size)
1294 return -EINVAL;
1295
1296 ar->wmi.mem_chunks[idx].vaddr = dma_alloc_coherent(ar->dev,
1297 pool_size,
1298 &paddr,
1299 GFP_ATOMIC);
1300 if (!ar->wmi.mem_chunks[idx].vaddr) {
1301 ath10k_warn("failed to allocate memory chunk\n");
1302 return -ENOMEM;
1303 }
1304
1305 memset(ar->wmi.mem_chunks[idx].vaddr, 0, pool_size);
1306
1307 ar->wmi.mem_chunks[idx].paddr = paddr;
1308 ar->wmi.mem_chunks[idx].len = pool_size;
1309 ar->wmi.mem_chunks[idx].req_id = req_id;
1310 ar->wmi.num_mem_chunks++;
1311
1312 return 0;
1313}
1314
Kalle Valo5e3dd152013-06-12 20:52:10 +03001315static void ath10k_wmi_service_ready_event_rx(struct ath10k *ar,
1316 struct sk_buff *skb)
1317{
1318 struct wmi_service_ready_event *ev = (void *)skb->data;
1319
1320 if (skb->len < sizeof(*ev)) {
1321 ath10k_warn("Service ready event was %d B but expected %zu B. Wrong firmware version?\n",
1322 skb->len, sizeof(*ev));
1323 return;
1324 }
1325
1326 ar->hw_min_tx_power = __le32_to_cpu(ev->hw_min_tx_power);
1327 ar->hw_max_tx_power = __le32_to_cpu(ev->hw_max_tx_power);
1328 ar->ht_cap_info = __le32_to_cpu(ev->ht_cap_info);
1329 ar->vht_cap_info = __le32_to_cpu(ev->vht_cap_info);
1330 ar->fw_version_major =
1331 (__le32_to_cpu(ev->sw_version) & 0xff000000) >> 24;
1332 ar->fw_version_minor = (__le32_to_cpu(ev->sw_version) & 0x00ffffff);
1333 ar->fw_version_release =
1334 (__le32_to_cpu(ev->sw_version_1) & 0xffff0000) >> 16;
1335 ar->fw_version_build = (__le32_to_cpu(ev->sw_version_1) & 0x0000ffff);
1336 ar->phy_capability = __le32_to_cpu(ev->phy_capability);
Michal Kazior8865bee42013-07-24 12:36:46 +02001337 ar->num_rf_chains = __le32_to_cpu(ev->num_rf_chains);
1338
Michal Kazior0d9b0432013-08-09 10:13:33 +02001339 if (ar->fw_version_build > 636)
1340 set_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features);
1341
Michal Kazior8865bee42013-07-24 12:36:46 +02001342 if (ar->num_rf_chains > WMI_MAX_SPATIAL_STREAM) {
1343 ath10k_warn("hardware advertises support for more spatial streams than it should (%d > %d)\n",
1344 ar->num_rf_chains, WMI_MAX_SPATIAL_STREAM);
1345 ar->num_rf_chains = WMI_MAX_SPATIAL_STREAM;
1346 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03001347
1348 ar->ath_common.regulatory.current_rd =
1349 __le32_to_cpu(ev->hal_reg_capabilities.eeprom_rd);
1350
1351 ath10k_debug_read_service_map(ar, ev->wmi_service_bitmap,
1352 sizeof(ev->wmi_service_bitmap));
1353
1354 if (strlen(ar->hw->wiphy->fw_version) == 0) {
1355 snprintf(ar->hw->wiphy->fw_version,
1356 sizeof(ar->hw->wiphy->fw_version),
1357 "%u.%u.%u.%u",
1358 ar->fw_version_major,
1359 ar->fw_version_minor,
1360 ar->fw_version_release,
1361 ar->fw_version_build);
1362 }
1363
1364 /* FIXME: it probably should be better to support this */
1365 if (__le32_to_cpu(ev->num_mem_reqs) > 0) {
1366 ath10k_warn("target requested %d memory chunks; ignoring\n",
1367 __le32_to_cpu(ev->num_mem_reqs));
1368 }
1369
1370 ath10k_dbg(ATH10K_DBG_WMI,
Michal Kazior8865bee42013-07-24 12:36:46 +02001371 "wmi event service ready sw_ver 0x%08x sw_ver1 0x%08x abi_ver %u phy_cap 0x%08x ht_cap 0x%08x vht_cap 0x%08x vht_supp_msc 0x%08x sys_cap_info 0x%08x mem_reqs %u num_rf_chains %u\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +03001372 __le32_to_cpu(ev->sw_version),
1373 __le32_to_cpu(ev->sw_version_1),
1374 __le32_to_cpu(ev->abi_version),
1375 __le32_to_cpu(ev->phy_capability),
1376 __le32_to_cpu(ev->ht_cap_info),
1377 __le32_to_cpu(ev->vht_cap_info),
1378 __le32_to_cpu(ev->vht_supp_mcs),
1379 __le32_to_cpu(ev->sys_cap_info),
Michal Kazior8865bee42013-07-24 12:36:46 +02001380 __le32_to_cpu(ev->num_mem_reqs),
1381 __le32_to_cpu(ev->num_rf_chains));
Kalle Valo5e3dd152013-06-12 20:52:10 +03001382
1383 complete(&ar->wmi.service_ready);
1384}
1385
Bartosz Markowski6f97d252013-09-26 17:47:09 +02001386static void ath10k_wmi_10x_service_ready_event_rx(struct ath10k *ar,
1387 struct sk_buff *skb)
1388{
Bartosz Markowskib3effe62013-09-26 17:47:11 +02001389 u32 num_units, req_id, unit_size, num_mem_reqs, num_unit_info, i;
1390 int ret;
Bartosz Markowski6f97d252013-09-26 17:47:09 +02001391 struct wmi_service_ready_event_10x *ev = (void *)skb->data;
1392
1393 if (skb->len < sizeof(*ev)) {
1394 ath10k_warn("Service ready event was %d B but expected %zu B. Wrong firmware version?\n",
1395 skb->len, sizeof(*ev));
1396 return;
1397 }
1398
1399 ar->hw_min_tx_power = __le32_to_cpu(ev->hw_min_tx_power);
1400 ar->hw_max_tx_power = __le32_to_cpu(ev->hw_max_tx_power);
1401 ar->ht_cap_info = __le32_to_cpu(ev->ht_cap_info);
1402 ar->vht_cap_info = __le32_to_cpu(ev->vht_cap_info);
1403 ar->fw_version_major =
1404 (__le32_to_cpu(ev->sw_version) & 0xff000000) >> 24;
1405 ar->fw_version_minor = (__le32_to_cpu(ev->sw_version) & 0x00ffffff);
1406 ar->phy_capability = __le32_to_cpu(ev->phy_capability);
1407 ar->num_rf_chains = __le32_to_cpu(ev->num_rf_chains);
1408
1409 if (ar->num_rf_chains > WMI_MAX_SPATIAL_STREAM) {
1410 ath10k_warn("hardware advertises support for more spatial streams than it should (%d > %d)\n",
1411 ar->num_rf_chains, WMI_MAX_SPATIAL_STREAM);
1412 ar->num_rf_chains = WMI_MAX_SPATIAL_STREAM;
1413 }
1414
1415 ar->ath_common.regulatory.current_rd =
1416 __le32_to_cpu(ev->hal_reg_capabilities.eeprom_rd);
1417
1418 ath10k_debug_read_service_map(ar, ev->wmi_service_bitmap,
1419 sizeof(ev->wmi_service_bitmap));
1420
1421 if (strlen(ar->hw->wiphy->fw_version) == 0) {
1422 snprintf(ar->hw->wiphy->fw_version,
1423 sizeof(ar->hw->wiphy->fw_version),
1424 "%u.%u",
1425 ar->fw_version_major,
1426 ar->fw_version_minor);
1427 }
1428
Bartosz Markowskib3effe62013-09-26 17:47:11 +02001429 num_mem_reqs = __le32_to_cpu(ev->num_mem_reqs);
1430
1431 if (num_mem_reqs > ATH10K_MAX_MEM_REQS) {
1432 ath10k_warn("requested memory chunks number (%d) exceeds the limit\n",
1433 num_mem_reqs);
1434 return;
Bartosz Markowski6f97d252013-09-26 17:47:09 +02001435 }
1436
Bartosz Markowskib3effe62013-09-26 17:47:11 +02001437 if (!num_mem_reqs)
1438 goto exit;
1439
1440 ath10k_dbg(ATH10K_DBG_WMI, "firmware has requested %d memory chunks\n",
1441 num_mem_reqs);
1442
1443 for (i = 0; i < num_mem_reqs; ++i) {
1444 req_id = __le32_to_cpu(ev->mem_reqs[i].req_id);
1445 num_units = __le32_to_cpu(ev->mem_reqs[i].num_units);
1446 unit_size = __le32_to_cpu(ev->mem_reqs[i].unit_size);
1447 num_unit_info = __le32_to_cpu(ev->mem_reqs[i].num_unit_info);
1448
1449 if (num_unit_info & NUM_UNITS_IS_NUM_PEERS)
1450 /* number of units to allocate is number of
1451 * peers, 1 extra for self peer on target */
1452 /* this needs to be tied, host and target
1453 * can get out of sync */
1454 num_units = TARGET_NUM_PEERS + 1;
1455 else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS)
1456 num_units = TARGET_NUM_VDEVS + 1;
1457
1458 ath10k_dbg(ATH10K_DBG_WMI,
1459 "wmi mem_req_id %d num_units %d num_unit_info %d unit size %d actual units %d\n",
1460 req_id,
1461 __le32_to_cpu(ev->mem_reqs[i].num_units),
1462 num_unit_info,
1463 unit_size,
1464 num_units);
1465
1466 ret = ath10k_wmi_alloc_host_mem(ar, req_id, num_units,
1467 unit_size);
1468 if (ret)
1469 return;
1470 }
1471
1472exit:
Bartosz Markowski6f97d252013-09-26 17:47:09 +02001473 ath10k_dbg(ATH10K_DBG_WMI,
1474 "wmi event service ready sw_ver 0x%08x abi_ver %u phy_cap 0x%08x ht_cap 0x%08x vht_cap 0x%08x vht_supp_msc 0x%08x sys_cap_info 0x%08x mem_reqs %u num_rf_chains %u\n",
1475 __le32_to_cpu(ev->sw_version),
1476 __le32_to_cpu(ev->abi_version),
1477 __le32_to_cpu(ev->phy_capability),
1478 __le32_to_cpu(ev->ht_cap_info),
1479 __le32_to_cpu(ev->vht_cap_info),
1480 __le32_to_cpu(ev->vht_supp_mcs),
1481 __le32_to_cpu(ev->sys_cap_info),
1482 __le32_to_cpu(ev->num_mem_reqs),
1483 __le32_to_cpu(ev->num_rf_chains));
1484
1485 complete(&ar->wmi.service_ready);
1486}
1487
Kalle Valo5e3dd152013-06-12 20:52:10 +03001488static int ath10k_wmi_ready_event_rx(struct ath10k *ar, struct sk_buff *skb)
1489{
1490 struct wmi_ready_event *ev = (struct wmi_ready_event *)skb->data;
1491
1492 if (WARN_ON(skb->len < sizeof(*ev)))
1493 return -EINVAL;
1494
1495 memcpy(ar->mac_addr, ev->mac_addr.addr, ETH_ALEN);
1496
1497 ath10k_dbg(ATH10K_DBG_WMI,
1498 "wmi event ready sw_version %u abi_version %u mac_addr %pM status %d\n",
1499 __le32_to_cpu(ev->sw_version),
1500 __le32_to_cpu(ev->abi_version),
1501 ev->mac_addr.addr,
1502 __le32_to_cpu(ev->status));
1503
1504 complete(&ar->wmi.unified_ready);
1505 return 0;
1506}
1507
Bartosz Markowskice428702013-09-26 17:47:05 +02001508static void ath10k_wmi_main_process_rx(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03001509{
1510 struct wmi_cmd_hdr *cmd_hdr;
1511 enum wmi_event_id id;
1512 u16 len;
1513
1514 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
1515 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
1516
1517 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
1518 return;
1519
1520 len = skb->len;
1521
1522 trace_ath10k_wmi_event(id, skb->data, skb->len);
1523
1524 switch (id) {
1525 case WMI_MGMT_RX_EVENTID:
1526 ath10k_wmi_event_mgmt_rx(ar, skb);
1527 /* mgmt_rx() owns the skb now! */
1528 return;
1529 case WMI_SCAN_EVENTID:
1530 ath10k_wmi_event_scan(ar, skb);
1531 break;
1532 case WMI_CHAN_INFO_EVENTID:
1533 ath10k_wmi_event_chan_info(ar, skb);
1534 break;
1535 case WMI_ECHO_EVENTID:
1536 ath10k_wmi_event_echo(ar, skb);
1537 break;
1538 case WMI_DEBUG_MESG_EVENTID:
1539 ath10k_wmi_event_debug_mesg(ar, skb);
1540 break;
1541 case WMI_UPDATE_STATS_EVENTID:
1542 ath10k_wmi_event_update_stats(ar, skb);
1543 break;
1544 case WMI_VDEV_START_RESP_EVENTID:
1545 ath10k_wmi_event_vdev_start_resp(ar, skb);
1546 break;
1547 case WMI_VDEV_STOPPED_EVENTID:
1548 ath10k_wmi_event_vdev_stopped(ar, skb);
1549 break;
1550 case WMI_PEER_STA_KICKOUT_EVENTID:
1551 ath10k_wmi_event_peer_sta_kickout(ar, skb);
1552 break;
1553 case WMI_HOST_SWBA_EVENTID:
1554 ath10k_wmi_event_host_swba(ar, skb);
1555 break;
1556 case WMI_TBTTOFFSET_UPDATE_EVENTID:
1557 ath10k_wmi_event_tbttoffset_update(ar, skb);
1558 break;
1559 case WMI_PHYERR_EVENTID:
1560 ath10k_wmi_event_phyerr(ar, skb);
1561 break;
1562 case WMI_ROAM_EVENTID:
1563 ath10k_wmi_event_roam(ar, skb);
1564 break;
1565 case WMI_PROFILE_MATCH:
1566 ath10k_wmi_event_profile_match(ar, skb);
1567 break;
1568 case WMI_DEBUG_PRINT_EVENTID:
1569 ath10k_wmi_event_debug_print(ar, skb);
1570 break;
1571 case WMI_PDEV_QVIT_EVENTID:
1572 ath10k_wmi_event_pdev_qvit(ar, skb);
1573 break;
1574 case WMI_WLAN_PROFILE_DATA_EVENTID:
1575 ath10k_wmi_event_wlan_profile_data(ar, skb);
1576 break;
1577 case WMI_RTT_MEASUREMENT_REPORT_EVENTID:
1578 ath10k_wmi_event_rtt_measurement_report(ar, skb);
1579 break;
1580 case WMI_TSF_MEASUREMENT_REPORT_EVENTID:
1581 ath10k_wmi_event_tsf_measurement_report(ar, skb);
1582 break;
1583 case WMI_RTT_ERROR_REPORT_EVENTID:
1584 ath10k_wmi_event_rtt_error_report(ar, skb);
1585 break;
1586 case WMI_WOW_WAKEUP_HOST_EVENTID:
1587 ath10k_wmi_event_wow_wakeup_host(ar, skb);
1588 break;
1589 case WMI_DCS_INTERFERENCE_EVENTID:
1590 ath10k_wmi_event_dcs_interference(ar, skb);
1591 break;
1592 case WMI_PDEV_TPC_CONFIG_EVENTID:
1593 ath10k_wmi_event_pdev_tpc_config(ar, skb);
1594 break;
1595 case WMI_PDEV_FTM_INTG_EVENTID:
1596 ath10k_wmi_event_pdev_ftm_intg(ar, skb);
1597 break;
1598 case WMI_GTK_OFFLOAD_STATUS_EVENTID:
1599 ath10k_wmi_event_gtk_offload_status(ar, skb);
1600 break;
1601 case WMI_GTK_REKEY_FAIL_EVENTID:
1602 ath10k_wmi_event_gtk_rekey_fail(ar, skb);
1603 break;
1604 case WMI_TX_DELBA_COMPLETE_EVENTID:
1605 ath10k_wmi_event_delba_complete(ar, skb);
1606 break;
1607 case WMI_TX_ADDBA_COMPLETE_EVENTID:
1608 ath10k_wmi_event_addba_complete(ar, skb);
1609 break;
1610 case WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID:
1611 ath10k_wmi_event_vdev_install_key_complete(ar, skb);
1612 break;
1613 case WMI_SERVICE_READY_EVENTID:
1614 ath10k_wmi_service_ready_event_rx(ar, skb);
1615 break;
1616 case WMI_READY_EVENTID:
1617 ath10k_wmi_ready_event_rx(ar, skb);
1618 break;
1619 default:
1620 ath10k_warn("Unknown eventid: %d\n", id);
1621 break;
1622 }
1623
1624 dev_kfree_skb(skb);
1625}
1626
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02001627static void ath10k_wmi_10x_process_rx(struct ath10k *ar, struct sk_buff *skb)
1628{
1629 struct wmi_cmd_hdr *cmd_hdr;
1630 enum wmi_10x_event_id id;
1631 u16 len;
1632
1633 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
1634 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
1635
1636 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
1637 return;
1638
1639 len = skb->len;
1640
1641 trace_ath10k_wmi_event(id, skb->data, skb->len);
1642
1643 switch (id) {
1644 case WMI_10X_MGMT_RX_EVENTID:
1645 ath10k_wmi_event_mgmt_rx(ar, skb);
1646 /* mgmt_rx() owns the skb now! */
1647 return;
1648 case WMI_10X_SCAN_EVENTID:
1649 ath10k_wmi_event_scan(ar, skb);
1650 break;
1651 case WMI_10X_CHAN_INFO_EVENTID:
1652 ath10k_wmi_event_chan_info(ar, skb);
1653 break;
1654 case WMI_10X_ECHO_EVENTID:
1655 ath10k_wmi_event_echo(ar, skb);
1656 break;
1657 case WMI_10X_DEBUG_MESG_EVENTID:
1658 ath10k_wmi_event_debug_mesg(ar, skb);
1659 break;
1660 case WMI_10X_UPDATE_STATS_EVENTID:
1661 ath10k_wmi_event_update_stats(ar, skb);
1662 break;
1663 case WMI_10X_VDEV_START_RESP_EVENTID:
1664 ath10k_wmi_event_vdev_start_resp(ar, skb);
1665 break;
1666 case WMI_10X_VDEV_STOPPED_EVENTID:
1667 ath10k_wmi_event_vdev_stopped(ar, skb);
1668 break;
1669 case WMI_10X_PEER_STA_KICKOUT_EVENTID:
1670 ath10k_wmi_event_peer_sta_kickout(ar, skb);
1671 break;
1672 case WMI_10X_HOST_SWBA_EVENTID:
1673 ath10k_wmi_event_host_swba(ar, skb);
1674 break;
1675 case WMI_10X_TBTTOFFSET_UPDATE_EVENTID:
1676 ath10k_wmi_event_tbttoffset_update(ar, skb);
1677 break;
1678 case WMI_10X_PHYERR_EVENTID:
1679 ath10k_wmi_event_phyerr(ar, skb);
1680 break;
1681 case WMI_10X_ROAM_EVENTID:
1682 ath10k_wmi_event_roam(ar, skb);
1683 break;
1684 case WMI_10X_PROFILE_MATCH:
1685 ath10k_wmi_event_profile_match(ar, skb);
1686 break;
1687 case WMI_10X_DEBUG_PRINT_EVENTID:
1688 ath10k_wmi_event_debug_print(ar, skb);
1689 break;
1690 case WMI_10X_PDEV_QVIT_EVENTID:
1691 ath10k_wmi_event_pdev_qvit(ar, skb);
1692 break;
1693 case WMI_10X_WLAN_PROFILE_DATA_EVENTID:
1694 ath10k_wmi_event_wlan_profile_data(ar, skb);
1695 break;
1696 case WMI_10X_RTT_MEASUREMENT_REPORT_EVENTID:
1697 ath10k_wmi_event_rtt_measurement_report(ar, skb);
1698 break;
1699 case WMI_10X_TSF_MEASUREMENT_REPORT_EVENTID:
1700 ath10k_wmi_event_tsf_measurement_report(ar, skb);
1701 break;
1702 case WMI_10X_RTT_ERROR_REPORT_EVENTID:
1703 ath10k_wmi_event_rtt_error_report(ar, skb);
1704 break;
1705 case WMI_10X_WOW_WAKEUP_HOST_EVENTID:
1706 ath10k_wmi_event_wow_wakeup_host(ar, skb);
1707 break;
1708 case WMI_10X_DCS_INTERFERENCE_EVENTID:
1709 ath10k_wmi_event_dcs_interference(ar, skb);
1710 break;
1711 case WMI_10X_PDEV_TPC_CONFIG_EVENTID:
1712 ath10k_wmi_event_pdev_tpc_config(ar, skb);
1713 break;
1714 case WMI_10X_INST_RSSI_STATS_EVENTID:
1715 ath10k_wmi_event_inst_rssi_stats(ar, skb);
1716 break;
1717 case WMI_10X_VDEV_STANDBY_REQ_EVENTID:
1718 ath10k_wmi_event_vdev_standby_req(ar, skb);
1719 break;
1720 case WMI_10X_VDEV_RESUME_REQ_EVENTID:
1721 ath10k_wmi_event_vdev_resume_req(ar, skb);
1722 break;
1723 case WMI_10X_SERVICE_READY_EVENTID:
Bartosz Markowski6f97d252013-09-26 17:47:09 +02001724 ath10k_wmi_10x_service_ready_event_rx(ar, skb);
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02001725 break;
1726 case WMI_10X_READY_EVENTID:
1727 ath10k_wmi_ready_event_rx(ar, skb);
1728 break;
1729 default:
1730 ath10k_warn("Unknown eventid: %d\n", id);
1731 break;
1732 }
1733
1734 dev_kfree_skb(skb);
1735}
1736
1737
Bartosz Markowskice428702013-09-26 17:47:05 +02001738static void ath10k_wmi_process_rx(struct ath10k *ar, struct sk_buff *skb)
1739{
1740 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features))
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02001741 ath10k_wmi_10x_process_rx(ar, skb);
Bartosz Markowskice428702013-09-26 17:47:05 +02001742 else
1743 ath10k_wmi_main_process_rx(ar, skb);
1744}
1745
Kalle Valo5e3dd152013-06-12 20:52:10 +03001746/* WMI Initialization functions */
1747int ath10k_wmi_attach(struct ath10k *ar)
1748{
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +02001749 int ret;
Bartosz Markowskice428702013-09-26 17:47:05 +02001750
1751 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) {
1752 ath10k_warn("Firmware 10.X is not yet supported\n");
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +02001753 ar->wmi.cmd = &wmi_10x_cmd_map;
Bartosz Markowskice428702013-09-26 17:47:05 +02001754 ret = -ENOTSUPP;
1755 } else {
1756 ar->wmi.cmd = &wmi_cmd_map;
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +02001757 ret = 0;
Bartosz Markowskice428702013-09-26 17:47:05 +02001758 }
1759
Kalle Valo5e3dd152013-06-12 20:52:10 +03001760 init_completion(&ar->wmi.service_ready);
1761 init_completion(&ar->wmi.unified_ready);
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001762 init_waitqueue_head(&ar->wmi.tx_credits_wq);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001763
Bartosz Markowskice428702013-09-26 17:47:05 +02001764 return ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001765}
1766
1767void ath10k_wmi_detach(struct ath10k *ar)
1768{
Bartosz Markowskib3effe62013-09-26 17:47:11 +02001769 int i;
1770
1771 /* free the host memory chunks requested by firmware */
1772 for (i = 0; i < ar->wmi.num_mem_chunks; i++) {
1773 dma_free_coherent(ar->dev,
1774 ar->wmi.mem_chunks[i].len,
1775 ar->wmi.mem_chunks[i].vaddr,
1776 ar->wmi.mem_chunks[i].paddr);
1777 }
1778
1779 ar->wmi.num_mem_chunks = 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001780}
1781
1782int ath10k_wmi_connect_htc_service(struct ath10k *ar)
1783{
1784 int status;
1785 struct ath10k_htc_svc_conn_req conn_req;
1786 struct ath10k_htc_svc_conn_resp conn_resp;
1787
1788 memset(&conn_req, 0, sizeof(conn_req));
1789 memset(&conn_resp, 0, sizeof(conn_resp));
1790
1791 /* these fields are the same for all service endpoints */
1792 conn_req.ep_ops.ep_tx_complete = ath10k_wmi_htc_tx_complete;
1793 conn_req.ep_ops.ep_rx_complete = ath10k_wmi_process_rx;
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001794 conn_req.ep_ops.ep_tx_credits = ath10k_wmi_op_ep_tx_credits;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001795
1796 /* connect to control service */
1797 conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL;
1798
Michal Kaziorcd003fa2013-07-05 16:15:13 +03001799 status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001800 if (status) {
1801 ath10k_warn("failed to connect to WMI CONTROL service status: %d\n",
1802 status);
1803 return status;
1804 }
1805
1806 ar->wmi.eid = conn_resp.eid;
1807 return 0;
1808}
1809
1810int ath10k_wmi_pdev_set_regdomain(struct ath10k *ar, u16 rd, u16 rd2g,
1811 u16 rd5g, u16 ctl2g, u16 ctl5g)
1812{
1813 struct wmi_pdev_set_regdomain_cmd *cmd;
1814 struct sk_buff *skb;
1815
1816 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
1817 if (!skb)
1818 return -ENOMEM;
1819
1820 cmd = (struct wmi_pdev_set_regdomain_cmd *)skb->data;
1821 cmd->reg_domain = __cpu_to_le32(rd);
1822 cmd->reg_domain_2G = __cpu_to_le32(rd2g);
1823 cmd->reg_domain_5G = __cpu_to_le32(rd5g);
1824 cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g);
1825 cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
1826
1827 ath10k_dbg(ATH10K_DBG_WMI,
1828 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x\n",
1829 rd, rd2g, rd5g, ctl2g, ctl5g);
1830
Bartosz Markowskice428702013-09-26 17:47:05 +02001831 return ath10k_wmi_cmd_send(ar, skb,
1832 ar->wmi.cmd->pdev_set_regdomain_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001833}
1834
1835int ath10k_wmi_pdev_set_channel(struct ath10k *ar,
1836 const struct wmi_channel_arg *arg)
1837{
1838 struct wmi_set_channel_cmd *cmd;
1839 struct sk_buff *skb;
1840
1841 if (arg->passive)
1842 return -EINVAL;
1843
1844 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
1845 if (!skb)
1846 return -ENOMEM;
1847
1848 cmd = (struct wmi_set_channel_cmd *)skb->data;
1849 cmd->chan.mhz = __cpu_to_le32(arg->freq);
1850 cmd->chan.band_center_freq1 = __cpu_to_le32(arg->freq);
1851 cmd->chan.mode = arg->mode;
1852 cmd->chan.min_power = arg->min_power;
1853 cmd->chan.max_power = arg->max_power;
1854 cmd->chan.reg_power = arg->max_reg_power;
1855 cmd->chan.reg_classid = arg->reg_class_id;
1856 cmd->chan.antenna_max = arg->max_antenna_gain;
1857
1858 ath10k_dbg(ATH10K_DBG_WMI,
1859 "wmi set channel mode %d freq %d\n",
1860 arg->mode, arg->freq);
1861
Bartosz Markowskice428702013-09-26 17:47:05 +02001862 return ath10k_wmi_cmd_send(ar, skb,
1863 ar->wmi.cmd->pdev_set_channel_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001864}
1865
1866int ath10k_wmi_pdev_suspend_target(struct ath10k *ar)
1867{
1868 struct wmi_pdev_suspend_cmd *cmd;
1869 struct sk_buff *skb;
1870
1871 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
1872 if (!skb)
1873 return -ENOMEM;
1874
1875 cmd = (struct wmi_pdev_suspend_cmd *)skb->data;
1876 cmd->suspend_opt = WMI_PDEV_SUSPEND;
1877
Bartosz Markowskice428702013-09-26 17:47:05 +02001878 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_suspend_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001879}
1880
1881int ath10k_wmi_pdev_resume_target(struct ath10k *ar)
1882{
1883 struct sk_buff *skb;
1884
1885 skb = ath10k_wmi_alloc_skb(0);
1886 if (skb == NULL)
1887 return -ENOMEM;
1888
Bartosz Markowskice428702013-09-26 17:47:05 +02001889 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_resume_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001890}
1891
1892int ath10k_wmi_pdev_set_param(struct ath10k *ar, enum wmi_pdev_param id,
1893 u32 value)
1894{
1895 struct wmi_pdev_set_param_cmd *cmd;
1896 struct sk_buff *skb;
1897
1898 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
1899 if (!skb)
1900 return -ENOMEM;
1901
1902 cmd = (struct wmi_pdev_set_param_cmd *)skb->data;
1903 cmd->param_id = __cpu_to_le32(id);
1904 cmd->param_value = __cpu_to_le32(value);
1905
1906 ath10k_dbg(ATH10K_DBG_WMI, "wmi pdev set param %d value %d\n",
1907 id, value);
Bartosz Markowskice428702013-09-26 17:47:05 +02001908 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_set_param_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001909}
1910
1911int ath10k_wmi_cmd_init(struct ath10k *ar)
1912{
1913 struct wmi_init_cmd *cmd;
1914 struct sk_buff *buf;
1915 struct wmi_resource_config config = {};
Bartosz Markowskib3effe62013-09-26 17:47:11 +02001916 u32 len, val;
1917 int i;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001918
1919 config.num_vdevs = __cpu_to_le32(TARGET_NUM_VDEVS);
1920 config.num_peers = __cpu_to_le32(TARGET_NUM_PEERS + TARGET_NUM_VDEVS);
1921 config.num_offload_peers = __cpu_to_le32(TARGET_NUM_OFFLOAD_PEERS);
1922
1923 config.num_offload_reorder_bufs =
1924 __cpu_to_le32(TARGET_NUM_OFFLOAD_REORDER_BUFS);
1925
1926 config.num_peer_keys = __cpu_to_le32(TARGET_NUM_PEER_KEYS);
1927 config.num_tids = __cpu_to_le32(TARGET_NUM_TIDS);
1928 config.ast_skid_limit = __cpu_to_le32(TARGET_AST_SKID_LIMIT);
1929 config.tx_chain_mask = __cpu_to_le32(TARGET_TX_CHAIN_MASK);
1930 config.rx_chain_mask = __cpu_to_le32(TARGET_RX_CHAIN_MASK);
1931 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
1932 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
1933 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
1934 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_RX_TIMEOUT_HI_PRI);
1935 config.rx_decap_mode = __cpu_to_le32(TARGET_RX_DECAP_MODE);
1936
1937 config.scan_max_pending_reqs =
1938 __cpu_to_le32(TARGET_SCAN_MAX_PENDING_REQS);
1939
1940 config.bmiss_offload_max_vdev =
1941 __cpu_to_le32(TARGET_BMISS_OFFLOAD_MAX_VDEV);
1942
1943 config.roam_offload_max_vdev =
1944 __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_VDEV);
1945
1946 config.roam_offload_max_ap_profiles =
1947 __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_AP_PROFILES);
1948
1949 config.num_mcast_groups = __cpu_to_le32(TARGET_NUM_MCAST_GROUPS);
1950 config.num_mcast_table_elems =
1951 __cpu_to_le32(TARGET_NUM_MCAST_TABLE_ELEMS);
1952
1953 config.mcast2ucast_mode = __cpu_to_le32(TARGET_MCAST2UCAST_MODE);
1954 config.tx_dbg_log_size = __cpu_to_le32(TARGET_TX_DBG_LOG_SIZE);
1955 config.num_wds_entries = __cpu_to_le32(TARGET_NUM_WDS_ENTRIES);
1956 config.dma_burst_size = __cpu_to_le32(TARGET_DMA_BURST_SIZE);
1957 config.mac_aggr_delim = __cpu_to_le32(TARGET_MAC_AGGR_DELIM);
1958
1959 val = TARGET_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
1960 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
1961
1962 config.vow_config = __cpu_to_le32(TARGET_VOW_CONFIG);
1963
1964 config.gtk_offload_max_vdev =
1965 __cpu_to_le32(TARGET_GTK_OFFLOAD_MAX_VDEV);
1966
1967 config.num_msdu_desc = __cpu_to_le32(TARGET_NUM_MSDU_DESC);
1968 config.max_frag_entries = __cpu_to_le32(TARGET_MAX_FRAG_ENTRIES);
1969
Bartosz Markowskib3effe62013-09-26 17:47:11 +02001970 len = sizeof(*cmd) +
1971 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
1972
1973 buf = ath10k_wmi_alloc_skb(len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001974 if (!buf)
1975 return -ENOMEM;
1976
1977 cmd = (struct wmi_init_cmd *)buf->data;
Bartosz Markowskib3effe62013-09-26 17:47:11 +02001978
1979 if (ar->wmi.num_mem_chunks == 0) {
1980 cmd->num_host_mem_chunks = 0;
1981 goto out;
1982 }
1983
1984 ath10k_dbg(ATH10K_DBG_WMI, "wmi sending %d memory chunks info.\n",
1985 __cpu_to_le32(ar->wmi.num_mem_chunks));
1986
1987 cmd->num_host_mem_chunks = __cpu_to_le32(ar->wmi.num_mem_chunks);
1988
1989 for (i = 0; i < ar->wmi.num_mem_chunks; i++) {
1990 cmd->host_mem_chunks[i].ptr =
1991 __cpu_to_le32(ar->wmi.mem_chunks[i].paddr);
1992 cmd->host_mem_chunks[i].size =
1993 __cpu_to_le32(ar->wmi.mem_chunks[i].len);
1994 cmd->host_mem_chunks[i].req_id =
1995 __cpu_to_le32(ar->wmi.mem_chunks[i].req_id);
1996
1997 ath10k_dbg(ATH10K_DBG_WMI,
1998 "wmi chunk %d len %d requested, addr 0x%x\n",
1999 i,
2000 cmd->host_mem_chunks[i].size,
2001 cmd->host_mem_chunks[i].ptr);
2002 }
2003out:
Kalle Valo5e3dd152013-06-12 20:52:10 +03002004 memcpy(&cmd->resource_config, &config, sizeof(config));
2005
2006 ath10k_dbg(ATH10K_DBG_WMI, "wmi init\n");
Bartosz Markowskice428702013-09-26 17:47:05 +02002007 return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002008}
2009
2010static int ath10k_wmi_start_scan_calc_len(const struct wmi_start_scan_arg *arg)
2011{
2012 int len;
2013
2014 len = sizeof(struct wmi_start_scan_cmd);
2015
2016 if (arg->ie_len) {
2017 if (!arg->ie)
2018 return -EINVAL;
2019 if (arg->ie_len > WLAN_SCAN_PARAMS_MAX_IE_LEN)
2020 return -EINVAL;
2021
2022 len += sizeof(struct wmi_ie_data);
2023 len += roundup(arg->ie_len, 4);
2024 }
2025
2026 if (arg->n_channels) {
2027 if (!arg->channels)
2028 return -EINVAL;
2029 if (arg->n_channels > ARRAY_SIZE(arg->channels))
2030 return -EINVAL;
2031
2032 len += sizeof(struct wmi_chan_list);
2033 len += sizeof(__le32) * arg->n_channels;
2034 }
2035
2036 if (arg->n_ssids) {
2037 if (!arg->ssids)
2038 return -EINVAL;
2039 if (arg->n_ssids > WLAN_SCAN_PARAMS_MAX_SSID)
2040 return -EINVAL;
2041
2042 len += sizeof(struct wmi_ssid_list);
2043 len += sizeof(struct wmi_ssid) * arg->n_ssids;
2044 }
2045
2046 if (arg->n_bssids) {
2047 if (!arg->bssids)
2048 return -EINVAL;
2049 if (arg->n_bssids > WLAN_SCAN_PARAMS_MAX_BSSID)
2050 return -EINVAL;
2051
2052 len += sizeof(struct wmi_bssid_list);
2053 len += sizeof(struct wmi_mac_addr) * arg->n_bssids;
2054 }
2055
2056 return len;
2057}
2058
2059int ath10k_wmi_start_scan(struct ath10k *ar,
2060 const struct wmi_start_scan_arg *arg)
2061{
2062 struct wmi_start_scan_cmd *cmd;
2063 struct sk_buff *skb;
2064 struct wmi_ie_data *ie;
2065 struct wmi_chan_list *channels;
2066 struct wmi_ssid_list *ssids;
2067 struct wmi_bssid_list *bssids;
2068 u32 scan_id;
2069 u32 scan_req_id;
2070 int off;
2071 int len = 0;
2072 int i;
2073
2074 len = ath10k_wmi_start_scan_calc_len(arg);
2075 if (len < 0)
2076 return len; /* len contains error code here */
2077
2078 skb = ath10k_wmi_alloc_skb(len);
2079 if (!skb)
2080 return -ENOMEM;
2081
2082 scan_id = WMI_HOST_SCAN_REQ_ID_PREFIX;
2083 scan_id |= arg->scan_id;
2084
2085 scan_req_id = WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
2086 scan_req_id |= arg->scan_req_id;
2087
2088 cmd = (struct wmi_start_scan_cmd *)skb->data;
2089 cmd->scan_id = __cpu_to_le32(scan_id);
2090 cmd->scan_req_id = __cpu_to_le32(scan_req_id);
2091 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
2092 cmd->scan_priority = __cpu_to_le32(arg->scan_priority);
2093 cmd->notify_scan_events = __cpu_to_le32(arg->notify_scan_events);
2094 cmd->dwell_time_active = __cpu_to_le32(arg->dwell_time_active);
2095 cmd->dwell_time_passive = __cpu_to_le32(arg->dwell_time_passive);
2096 cmd->min_rest_time = __cpu_to_le32(arg->min_rest_time);
2097 cmd->max_rest_time = __cpu_to_le32(arg->max_rest_time);
2098 cmd->repeat_probe_time = __cpu_to_le32(arg->repeat_probe_time);
2099 cmd->probe_spacing_time = __cpu_to_le32(arg->probe_spacing_time);
2100 cmd->idle_time = __cpu_to_le32(arg->idle_time);
2101 cmd->max_scan_time = __cpu_to_le32(arg->max_scan_time);
2102 cmd->probe_delay = __cpu_to_le32(arg->probe_delay);
2103 cmd->scan_ctrl_flags = __cpu_to_le32(arg->scan_ctrl_flags);
2104
2105 /* TLV list starts after fields included in the struct */
2106 off = sizeof(*cmd);
2107
2108 if (arg->n_channels) {
2109 channels = (void *)skb->data + off;
2110 channels->tag = __cpu_to_le32(WMI_CHAN_LIST_TAG);
2111 channels->num_chan = __cpu_to_le32(arg->n_channels);
2112
2113 for (i = 0; i < arg->n_channels; i++)
2114 channels->channel_list[i] =
2115 __cpu_to_le32(arg->channels[i]);
2116
2117 off += sizeof(*channels);
2118 off += sizeof(__le32) * arg->n_channels;
2119 }
2120
2121 if (arg->n_ssids) {
2122 ssids = (void *)skb->data + off;
2123 ssids->tag = __cpu_to_le32(WMI_SSID_LIST_TAG);
2124 ssids->num_ssids = __cpu_to_le32(arg->n_ssids);
2125
2126 for (i = 0; i < arg->n_ssids; i++) {
2127 ssids->ssids[i].ssid_len =
2128 __cpu_to_le32(arg->ssids[i].len);
2129 memcpy(&ssids->ssids[i].ssid,
2130 arg->ssids[i].ssid,
2131 arg->ssids[i].len);
2132 }
2133
2134 off += sizeof(*ssids);
2135 off += sizeof(struct wmi_ssid) * arg->n_ssids;
2136 }
2137
2138 if (arg->n_bssids) {
2139 bssids = (void *)skb->data + off;
2140 bssids->tag = __cpu_to_le32(WMI_BSSID_LIST_TAG);
2141 bssids->num_bssid = __cpu_to_le32(arg->n_bssids);
2142
2143 for (i = 0; i < arg->n_bssids; i++)
2144 memcpy(&bssids->bssid_list[i],
2145 arg->bssids[i].bssid,
2146 ETH_ALEN);
2147
2148 off += sizeof(*bssids);
2149 off += sizeof(struct wmi_mac_addr) * arg->n_bssids;
2150 }
2151
2152 if (arg->ie_len) {
2153 ie = (void *)skb->data + off;
2154 ie->tag = __cpu_to_le32(WMI_IE_TAG);
2155 ie->ie_len = __cpu_to_le32(arg->ie_len);
2156 memcpy(ie->ie_data, arg->ie, arg->ie_len);
2157
2158 off += sizeof(*ie);
2159 off += roundup(arg->ie_len, 4);
2160 }
2161
2162 if (off != skb->len) {
2163 dev_kfree_skb(skb);
2164 return -EINVAL;
2165 }
2166
2167 ath10k_dbg(ATH10K_DBG_WMI, "wmi start scan\n");
Bartosz Markowskice428702013-09-26 17:47:05 +02002168 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->start_scan_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002169}
2170
2171void ath10k_wmi_start_scan_init(struct ath10k *ar,
2172 struct wmi_start_scan_arg *arg)
2173{
2174 /* setup commonly used values */
2175 arg->scan_req_id = 1;
2176 arg->scan_priority = WMI_SCAN_PRIORITY_LOW;
2177 arg->dwell_time_active = 50;
2178 arg->dwell_time_passive = 150;
2179 arg->min_rest_time = 50;
2180 arg->max_rest_time = 500;
2181 arg->repeat_probe_time = 0;
2182 arg->probe_spacing_time = 0;
2183 arg->idle_time = 0;
2184 arg->max_scan_time = 5000;
2185 arg->probe_delay = 5;
2186 arg->notify_scan_events = WMI_SCAN_EVENT_STARTED
2187 | WMI_SCAN_EVENT_COMPLETED
2188 | WMI_SCAN_EVENT_BSS_CHANNEL
2189 | WMI_SCAN_EVENT_FOREIGN_CHANNEL
2190 | WMI_SCAN_EVENT_DEQUEUED;
2191 arg->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2192 arg->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
2193 arg->n_bssids = 1;
2194 arg->bssids[0].bssid = "\xFF\xFF\xFF\xFF\xFF\xFF";
2195}
2196
2197int ath10k_wmi_stop_scan(struct ath10k *ar, const struct wmi_stop_scan_arg *arg)
2198{
2199 struct wmi_stop_scan_cmd *cmd;
2200 struct sk_buff *skb;
2201 u32 scan_id;
2202 u32 req_id;
2203
2204 if (arg->req_id > 0xFFF)
2205 return -EINVAL;
2206 if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF)
2207 return -EINVAL;
2208
2209 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2210 if (!skb)
2211 return -ENOMEM;
2212
2213 scan_id = arg->u.scan_id;
2214 scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX;
2215
2216 req_id = arg->req_id;
2217 req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
2218
2219 cmd = (struct wmi_stop_scan_cmd *)skb->data;
2220 cmd->req_type = __cpu_to_le32(arg->req_type);
2221 cmd->vdev_id = __cpu_to_le32(arg->u.vdev_id);
2222 cmd->scan_id = __cpu_to_le32(scan_id);
2223 cmd->scan_req_id = __cpu_to_le32(req_id);
2224
2225 ath10k_dbg(ATH10K_DBG_WMI,
2226 "wmi stop scan reqid %d req_type %d vdev/scan_id %d\n",
2227 arg->req_id, arg->req_type, arg->u.scan_id);
Bartosz Markowskice428702013-09-26 17:47:05 +02002228 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->stop_scan_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002229}
2230
2231int ath10k_wmi_vdev_create(struct ath10k *ar, u32 vdev_id,
2232 enum wmi_vdev_type type,
2233 enum wmi_vdev_subtype subtype,
2234 const u8 macaddr[ETH_ALEN])
2235{
2236 struct wmi_vdev_create_cmd *cmd;
2237 struct sk_buff *skb;
2238
2239 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2240 if (!skb)
2241 return -ENOMEM;
2242
2243 cmd = (struct wmi_vdev_create_cmd *)skb->data;
2244 cmd->vdev_id = __cpu_to_le32(vdev_id);
2245 cmd->vdev_type = __cpu_to_le32(type);
2246 cmd->vdev_subtype = __cpu_to_le32(subtype);
2247 memcpy(cmd->vdev_macaddr.addr, macaddr, ETH_ALEN);
2248
2249 ath10k_dbg(ATH10K_DBG_WMI,
2250 "WMI vdev create: id %d type %d subtype %d macaddr %pM\n",
2251 vdev_id, type, subtype, macaddr);
2252
Bartosz Markowskice428702013-09-26 17:47:05 +02002253 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_create_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002254}
2255
2256int ath10k_wmi_vdev_delete(struct ath10k *ar, u32 vdev_id)
2257{
2258 struct wmi_vdev_delete_cmd *cmd;
2259 struct sk_buff *skb;
2260
2261 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2262 if (!skb)
2263 return -ENOMEM;
2264
2265 cmd = (struct wmi_vdev_delete_cmd *)skb->data;
2266 cmd->vdev_id = __cpu_to_le32(vdev_id);
2267
2268 ath10k_dbg(ATH10K_DBG_WMI,
2269 "WMI vdev delete id %d\n", vdev_id);
2270
Bartosz Markowskice428702013-09-26 17:47:05 +02002271 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_delete_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002272}
2273
2274static int ath10k_wmi_vdev_start_restart(struct ath10k *ar,
2275 const struct wmi_vdev_start_request_arg *arg,
Bartosz Markowskice428702013-09-26 17:47:05 +02002276 u32 cmd_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002277{
2278 struct wmi_vdev_start_request_cmd *cmd;
2279 struct sk_buff *skb;
2280 const char *cmdname;
2281 u32 flags = 0;
2282
Bartosz Markowskice428702013-09-26 17:47:05 +02002283 if (cmd_id != ar->wmi.cmd->vdev_start_request_cmdid &&
2284 cmd_id != ar->wmi.cmd->vdev_restart_request_cmdid)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002285 return -EINVAL;
2286 if (WARN_ON(arg->ssid && arg->ssid_len == 0))
2287 return -EINVAL;
2288 if (WARN_ON(arg->hidden_ssid && !arg->ssid))
2289 return -EINVAL;
2290 if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid)))
2291 return -EINVAL;
2292
Bartosz Markowskice428702013-09-26 17:47:05 +02002293 if (cmd_id == ar->wmi.cmd->vdev_start_request_cmdid)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002294 cmdname = "start";
Bartosz Markowskice428702013-09-26 17:47:05 +02002295 else if (cmd_id == ar->wmi.cmd->vdev_restart_request_cmdid)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002296 cmdname = "restart";
2297 else
2298 return -EINVAL; /* should not happen, we already check cmd_id */
2299
2300 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2301 if (!skb)
2302 return -ENOMEM;
2303
2304 if (arg->hidden_ssid)
2305 flags |= WMI_VDEV_START_HIDDEN_SSID;
2306 if (arg->pmf_enabled)
2307 flags |= WMI_VDEV_START_PMF_ENABLED;
2308
2309 cmd = (struct wmi_vdev_start_request_cmd *)skb->data;
2310 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
2311 cmd->disable_hw_ack = __cpu_to_le32(arg->disable_hw_ack);
2312 cmd->beacon_interval = __cpu_to_le32(arg->bcn_intval);
2313 cmd->dtim_period = __cpu_to_le32(arg->dtim_period);
2314 cmd->flags = __cpu_to_le32(flags);
2315 cmd->bcn_tx_rate = __cpu_to_le32(arg->bcn_tx_rate);
2316 cmd->bcn_tx_power = __cpu_to_le32(arg->bcn_tx_power);
2317
2318 if (arg->ssid) {
2319 cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len);
2320 memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len);
2321 }
2322
2323 cmd->chan.mhz = __cpu_to_le32(arg->channel.freq);
2324
2325 cmd->chan.band_center_freq1 =
2326 __cpu_to_le32(arg->channel.band_center_freq1);
2327
2328 cmd->chan.mode = arg->channel.mode;
2329 cmd->chan.min_power = arg->channel.min_power;
2330 cmd->chan.max_power = arg->channel.max_power;
2331 cmd->chan.reg_power = arg->channel.max_reg_power;
2332 cmd->chan.reg_classid = arg->channel.reg_class_id;
2333 cmd->chan.antenna_max = arg->channel.max_antenna_gain;
2334
2335 ath10k_dbg(ATH10K_DBG_WMI,
2336 "wmi vdev %s id 0x%x freq %d, mode %d, ch_flags: 0x%0X,"
2337 "max_power: %d\n", cmdname, arg->vdev_id, arg->channel.freq,
2338 arg->channel.mode, flags, arg->channel.max_power);
2339
2340 return ath10k_wmi_cmd_send(ar, skb, cmd_id);
2341}
2342
2343int ath10k_wmi_vdev_start(struct ath10k *ar,
2344 const struct wmi_vdev_start_request_arg *arg)
2345{
Bartosz Markowskice428702013-09-26 17:47:05 +02002346 u32 cmd_id = ar->wmi.cmd->vdev_start_request_cmdid;
2347
2348 return ath10k_wmi_vdev_start_restart(ar, arg, cmd_id);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002349}
2350
2351int ath10k_wmi_vdev_restart(struct ath10k *ar,
2352 const struct wmi_vdev_start_request_arg *arg)
2353{
Bartosz Markowskice428702013-09-26 17:47:05 +02002354 u32 cmd_id = ar->wmi.cmd->vdev_restart_request_cmdid;
2355
2356 return ath10k_wmi_vdev_start_restart(ar, arg, cmd_id);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002357}
2358
2359int ath10k_wmi_vdev_stop(struct ath10k *ar, u32 vdev_id)
2360{
2361 struct wmi_vdev_stop_cmd *cmd;
2362 struct sk_buff *skb;
2363
2364 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2365 if (!skb)
2366 return -ENOMEM;
2367
2368 cmd = (struct wmi_vdev_stop_cmd *)skb->data;
2369 cmd->vdev_id = __cpu_to_le32(vdev_id);
2370
2371 ath10k_dbg(ATH10K_DBG_WMI, "wmi vdev stop id 0x%x\n", vdev_id);
2372
Bartosz Markowskice428702013-09-26 17:47:05 +02002373 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_stop_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002374}
2375
2376int ath10k_wmi_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid, const u8 *bssid)
2377{
2378 struct wmi_vdev_up_cmd *cmd;
2379 struct sk_buff *skb;
2380
2381 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2382 if (!skb)
2383 return -ENOMEM;
2384
2385 cmd = (struct wmi_vdev_up_cmd *)skb->data;
2386 cmd->vdev_id = __cpu_to_le32(vdev_id);
2387 cmd->vdev_assoc_id = __cpu_to_le32(aid);
2388 memcpy(&cmd->vdev_bssid.addr, bssid, 6);
2389
2390 ath10k_dbg(ATH10K_DBG_WMI,
2391 "wmi mgmt vdev up id 0x%x assoc id %d bssid %pM\n",
2392 vdev_id, aid, bssid);
2393
Bartosz Markowskice428702013-09-26 17:47:05 +02002394 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_up_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002395}
2396
2397int ath10k_wmi_vdev_down(struct ath10k *ar, u32 vdev_id)
2398{
2399 struct wmi_vdev_down_cmd *cmd;
2400 struct sk_buff *skb;
2401
2402 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2403 if (!skb)
2404 return -ENOMEM;
2405
2406 cmd = (struct wmi_vdev_down_cmd *)skb->data;
2407 cmd->vdev_id = __cpu_to_le32(vdev_id);
2408
2409 ath10k_dbg(ATH10K_DBG_WMI,
2410 "wmi mgmt vdev down id 0x%x\n", vdev_id);
2411
Bartosz Markowskice428702013-09-26 17:47:05 +02002412 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_down_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002413}
2414
2415int ath10k_wmi_vdev_set_param(struct ath10k *ar, u32 vdev_id,
2416 enum wmi_vdev_param param_id, u32 param_value)
2417{
2418 struct wmi_vdev_set_param_cmd *cmd;
2419 struct sk_buff *skb;
2420
2421 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2422 if (!skb)
2423 return -ENOMEM;
2424
2425 cmd = (struct wmi_vdev_set_param_cmd *)skb->data;
2426 cmd->vdev_id = __cpu_to_le32(vdev_id);
2427 cmd->param_id = __cpu_to_le32(param_id);
2428 cmd->param_value = __cpu_to_le32(param_value);
2429
2430 ath10k_dbg(ATH10K_DBG_WMI,
2431 "wmi vdev id 0x%x set param %d value %d\n",
2432 vdev_id, param_id, param_value);
2433
Bartosz Markowskice428702013-09-26 17:47:05 +02002434 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_set_param_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002435}
2436
2437int ath10k_wmi_vdev_install_key(struct ath10k *ar,
2438 const struct wmi_vdev_install_key_arg *arg)
2439{
2440 struct wmi_vdev_install_key_cmd *cmd;
2441 struct sk_buff *skb;
2442
2443 if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL)
2444 return -EINVAL;
2445 if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL)
2446 return -EINVAL;
2447
2448 skb = ath10k_wmi_alloc_skb(sizeof(*cmd) + arg->key_len);
2449 if (!skb)
2450 return -ENOMEM;
2451
2452 cmd = (struct wmi_vdev_install_key_cmd *)skb->data;
2453 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
2454 cmd->key_idx = __cpu_to_le32(arg->key_idx);
2455 cmd->key_flags = __cpu_to_le32(arg->key_flags);
2456 cmd->key_cipher = __cpu_to_le32(arg->key_cipher);
2457 cmd->key_len = __cpu_to_le32(arg->key_len);
2458 cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len);
2459 cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len);
2460
2461 if (arg->macaddr)
2462 memcpy(cmd->peer_macaddr.addr, arg->macaddr, ETH_ALEN);
2463 if (arg->key_data)
2464 memcpy(cmd->key_data, arg->key_data, arg->key_len);
2465
Michal Kaziore0c508a2013-07-05 16:15:17 +03002466 ath10k_dbg(ATH10K_DBG_WMI,
2467 "wmi vdev install key idx %d cipher %d len %d\n",
2468 arg->key_idx, arg->key_cipher, arg->key_len);
Bartosz Markowskice428702013-09-26 17:47:05 +02002469 return ath10k_wmi_cmd_send(ar, skb,
2470 ar->wmi.cmd->vdev_install_key_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002471}
2472
2473int ath10k_wmi_peer_create(struct ath10k *ar, u32 vdev_id,
2474 const u8 peer_addr[ETH_ALEN])
2475{
2476 struct wmi_peer_create_cmd *cmd;
2477 struct sk_buff *skb;
2478
2479 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2480 if (!skb)
2481 return -ENOMEM;
2482
2483 cmd = (struct wmi_peer_create_cmd *)skb->data;
2484 cmd->vdev_id = __cpu_to_le32(vdev_id);
2485 memcpy(cmd->peer_macaddr.addr, peer_addr, ETH_ALEN);
2486
2487 ath10k_dbg(ATH10K_DBG_WMI,
2488 "wmi peer create vdev_id %d peer_addr %pM\n",
2489 vdev_id, peer_addr);
Bartosz Markowskice428702013-09-26 17:47:05 +02002490 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_create_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002491}
2492
2493int ath10k_wmi_peer_delete(struct ath10k *ar, u32 vdev_id,
2494 const u8 peer_addr[ETH_ALEN])
2495{
2496 struct wmi_peer_delete_cmd *cmd;
2497 struct sk_buff *skb;
2498
2499 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2500 if (!skb)
2501 return -ENOMEM;
2502
2503 cmd = (struct wmi_peer_delete_cmd *)skb->data;
2504 cmd->vdev_id = __cpu_to_le32(vdev_id);
2505 memcpy(cmd->peer_macaddr.addr, peer_addr, ETH_ALEN);
2506
2507 ath10k_dbg(ATH10K_DBG_WMI,
2508 "wmi peer delete vdev_id %d peer_addr %pM\n",
2509 vdev_id, peer_addr);
Bartosz Markowskice428702013-09-26 17:47:05 +02002510 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_delete_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002511}
2512
2513int ath10k_wmi_peer_flush(struct ath10k *ar, u32 vdev_id,
2514 const u8 peer_addr[ETH_ALEN], u32 tid_bitmap)
2515{
2516 struct wmi_peer_flush_tids_cmd *cmd;
2517 struct sk_buff *skb;
2518
2519 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2520 if (!skb)
2521 return -ENOMEM;
2522
2523 cmd = (struct wmi_peer_flush_tids_cmd *)skb->data;
2524 cmd->vdev_id = __cpu_to_le32(vdev_id);
2525 cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap);
2526 memcpy(cmd->peer_macaddr.addr, peer_addr, ETH_ALEN);
2527
2528 ath10k_dbg(ATH10K_DBG_WMI,
2529 "wmi peer flush vdev_id %d peer_addr %pM tids %08x\n",
2530 vdev_id, peer_addr, tid_bitmap);
Bartosz Markowskice428702013-09-26 17:47:05 +02002531 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_flush_tids_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002532}
2533
2534int ath10k_wmi_peer_set_param(struct ath10k *ar, u32 vdev_id,
2535 const u8 *peer_addr, enum wmi_peer_param param_id,
2536 u32 param_value)
2537{
2538 struct wmi_peer_set_param_cmd *cmd;
2539 struct sk_buff *skb;
2540
2541 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2542 if (!skb)
2543 return -ENOMEM;
2544
2545 cmd = (struct wmi_peer_set_param_cmd *)skb->data;
2546 cmd->vdev_id = __cpu_to_le32(vdev_id);
2547 cmd->param_id = __cpu_to_le32(param_id);
2548 cmd->param_value = __cpu_to_le32(param_value);
2549 memcpy(&cmd->peer_macaddr.addr, peer_addr, 6);
2550
2551 ath10k_dbg(ATH10K_DBG_WMI,
2552 "wmi vdev %d peer 0x%pM set param %d value %d\n",
2553 vdev_id, peer_addr, param_id, param_value);
2554
Bartosz Markowskice428702013-09-26 17:47:05 +02002555 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_set_param_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002556}
2557
2558int ath10k_wmi_set_psmode(struct ath10k *ar, u32 vdev_id,
2559 enum wmi_sta_ps_mode psmode)
2560{
2561 struct wmi_sta_powersave_mode_cmd *cmd;
2562 struct sk_buff *skb;
2563
2564 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2565 if (!skb)
2566 return -ENOMEM;
2567
2568 cmd = (struct wmi_sta_powersave_mode_cmd *)skb->data;
2569 cmd->vdev_id = __cpu_to_le32(vdev_id);
2570 cmd->sta_ps_mode = __cpu_to_le32(psmode);
2571
2572 ath10k_dbg(ATH10K_DBG_WMI,
2573 "wmi set powersave id 0x%x mode %d\n",
2574 vdev_id, psmode);
2575
Bartosz Markowskice428702013-09-26 17:47:05 +02002576 return ath10k_wmi_cmd_send(ar, skb,
2577 ar->wmi.cmd->sta_powersave_mode_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002578}
2579
2580int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id,
2581 enum wmi_sta_powersave_param param_id,
2582 u32 value)
2583{
2584 struct wmi_sta_powersave_param_cmd *cmd;
2585 struct sk_buff *skb;
2586
2587 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2588 if (!skb)
2589 return -ENOMEM;
2590
2591 cmd = (struct wmi_sta_powersave_param_cmd *)skb->data;
2592 cmd->vdev_id = __cpu_to_le32(vdev_id);
2593 cmd->param_id = __cpu_to_le32(param_id);
2594 cmd->param_value = __cpu_to_le32(value);
2595
2596 ath10k_dbg(ATH10K_DBG_WMI,
2597 "wmi sta ps param vdev_id 0x%x param %d value %d\n",
2598 vdev_id, param_id, value);
Bartosz Markowskice428702013-09-26 17:47:05 +02002599 return ath10k_wmi_cmd_send(ar, skb,
2600 ar->wmi.cmd->sta_powersave_param_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002601}
2602
2603int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
2604 enum wmi_ap_ps_peer_param param_id, u32 value)
2605{
2606 struct wmi_ap_ps_peer_cmd *cmd;
2607 struct sk_buff *skb;
2608
2609 if (!mac)
2610 return -EINVAL;
2611
2612 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2613 if (!skb)
2614 return -ENOMEM;
2615
2616 cmd = (struct wmi_ap_ps_peer_cmd *)skb->data;
2617 cmd->vdev_id = __cpu_to_le32(vdev_id);
2618 cmd->param_id = __cpu_to_le32(param_id);
2619 cmd->param_value = __cpu_to_le32(value);
2620 memcpy(&cmd->peer_macaddr, mac, ETH_ALEN);
2621
2622 ath10k_dbg(ATH10K_DBG_WMI,
2623 "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr %pM\n",
2624 vdev_id, param_id, value, mac);
2625
Bartosz Markowskice428702013-09-26 17:47:05 +02002626 return ath10k_wmi_cmd_send(ar, skb,
2627 ar->wmi.cmd->ap_ps_peer_param_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002628}
2629
2630int ath10k_wmi_scan_chan_list(struct ath10k *ar,
2631 const struct wmi_scan_chan_list_arg *arg)
2632{
2633 struct wmi_scan_chan_list_cmd *cmd;
2634 struct sk_buff *skb;
2635 struct wmi_channel_arg *ch;
2636 struct wmi_channel *ci;
2637 int len;
2638 int i;
2639
2640 len = sizeof(*cmd) + arg->n_channels * sizeof(struct wmi_channel);
2641
2642 skb = ath10k_wmi_alloc_skb(len);
2643 if (!skb)
2644 return -EINVAL;
2645
2646 cmd = (struct wmi_scan_chan_list_cmd *)skb->data;
2647 cmd->num_scan_chans = __cpu_to_le32(arg->n_channels);
2648
2649 for (i = 0; i < arg->n_channels; i++) {
2650 u32 flags = 0;
2651
2652 ch = &arg->channels[i];
2653 ci = &cmd->chan_info[i];
2654
2655 if (ch->passive)
2656 flags |= WMI_CHAN_FLAG_PASSIVE;
2657 if (ch->allow_ibss)
2658 flags |= WMI_CHAN_FLAG_ADHOC_ALLOWED;
2659 if (ch->allow_ht)
2660 flags |= WMI_CHAN_FLAG_ALLOW_HT;
2661 if (ch->allow_vht)
2662 flags |= WMI_CHAN_FLAG_ALLOW_VHT;
2663 if (ch->ht40plus)
2664 flags |= WMI_CHAN_FLAG_HT40_PLUS;
2665
2666 ci->mhz = __cpu_to_le32(ch->freq);
2667 ci->band_center_freq1 = __cpu_to_le32(ch->freq);
2668 ci->band_center_freq2 = 0;
2669 ci->min_power = ch->min_power;
2670 ci->max_power = ch->max_power;
2671 ci->reg_power = ch->max_reg_power;
2672 ci->antenna_max = ch->max_antenna_gain;
2673 ci->antenna_max = 0;
2674
2675 /* mode & flags share storage */
2676 ci->mode = ch->mode;
2677 ci->flags |= __cpu_to_le32(flags);
2678 }
2679
Bartosz Markowskice428702013-09-26 17:47:05 +02002680 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->scan_chan_list_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002681}
2682
2683int ath10k_wmi_peer_assoc(struct ath10k *ar,
2684 const struct wmi_peer_assoc_complete_arg *arg)
2685{
2686 struct wmi_peer_assoc_complete_cmd *cmd;
2687 struct sk_buff *skb;
2688
2689 if (arg->peer_mpdu_density > 16)
2690 return -EINVAL;
2691 if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES)
2692 return -EINVAL;
2693 if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES)
2694 return -EINVAL;
2695
2696 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2697 if (!skb)
2698 return -ENOMEM;
2699
2700 cmd = (struct wmi_peer_assoc_complete_cmd *)skb->data;
2701 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
2702 cmd->peer_new_assoc = __cpu_to_le32(arg->peer_reassoc ? 0 : 1);
2703 cmd->peer_associd = __cpu_to_le32(arg->peer_aid);
2704 cmd->peer_flags = __cpu_to_le32(arg->peer_flags);
2705 cmd->peer_caps = __cpu_to_le32(arg->peer_caps);
2706 cmd->peer_listen_intval = __cpu_to_le32(arg->peer_listen_intval);
2707 cmd->peer_ht_caps = __cpu_to_le32(arg->peer_ht_caps);
2708 cmd->peer_max_mpdu = __cpu_to_le32(arg->peer_max_mpdu);
2709 cmd->peer_mpdu_density = __cpu_to_le32(arg->peer_mpdu_density);
2710 cmd->peer_rate_caps = __cpu_to_le32(arg->peer_rate_caps);
2711 cmd->peer_nss = __cpu_to_le32(arg->peer_num_spatial_streams);
2712 cmd->peer_vht_caps = __cpu_to_le32(arg->peer_vht_caps);
2713 cmd->peer_phymode = __cpu_to_le32(arg->peer_phymode);
2714
2715 memcpy(cmd->peer_macaddr.addr, arg->addr, ETH_ALEN);
2716
2717 cmd->peer_legacy_rates.num_rates =
2718 __cpu_to_le32(arg->peer_legacy_rates.num_rates);
2719 memcpy(cmd->peer_legacy_rates.rates, arg->peer_legacy_rates.rates,
2720 arg->peer_legacy_rates.num_rates);
2721
2722 cmd->peer_ht_rates.num_rates =
2723 __cpu_to_le32(arg->peer_ht_rates.num_rates);
2724 memcpy(cmd->peer_ht_rates.rates, arg->peer_ht_rates.rates,
2725 arg->peer_ht_rates.num_rates);
2726
2727 cmd->peer_vht_rates.rx_max_rate =
2728 __cpu_to_le32(arg->peer_vht_rates.rx_max_rate);
2729 cmd->peer_vht_rates.rx_mcs_set =
2730 __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set);
2731 cmd->peer_vht_rates.tx_max_rate =
2732 __cpu_to_le32(arg->peer_vht_rates.tx_max_rate);
2733 cmd->peer_vht_rates.tx_mcs_set =
2734 __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set);
2735
Michal Kaziore0c508a2013-07-05 16:15:17 +03002736 ath10k_dbg(ATH10K_DBG_WMI,
2737 "wmi peer assoc vdev %d addr %pM\n",
2738 arg->vdev_id, arg->addr);
Bartosz Markowskice428702013-09-26 17:47:05 +02002739 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_assoc_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002740}
2741
Michal Kaziored543882013-09-13 14:16:56 +02002742int ath10k_wmi_beacon_send_nowait(struct ath10k *ar,
2743 const struct wmi_bcn_tx_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002744{
2745 struct wmi_bcn_tx_cmd *cmd;
2746 struct sk_buff *skb;
2747
2748 skb = ath10k_wmi_alloc_skb(sizeof(*cmd) + arg->bcn_len);
2749 if (!skb)
2750 return -ENOMEM;
2751
2752 cmd = (struct wmi_bcn_tx_cmd *)skb->data;
2753 cmd->hdr.vdev_id = __cpu_to_le32(arg->vdev_id);
2754 cmd->hdr.tx_rate = __cpu_to_le32(arg->tx_rate);
2755 cmd->hdr.tx_power = __cpu_to_le32(arg->tx_power);
2756 cmd->hdr.bcn_len = __cpu_to_le32(arg->bcn_len);
2757 memcpy(cmd->bcn, arg->bcn, arg->bcn_len);
2758
Bartosz Markowskice428702013-09-26 17:47:05 +02002759 return ath10k_wmi_cmd_send_nowait(ar, skb, ar->wmi.cmd->bcn_tx_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002760}
2761
2762static void ath10k_wmi_pdev_set_wmm_param(struct wmi_wmm_params *params,
2763 const struct wmi_wmm_params_arg *arg)
2764{
2765 params->cwmin = __cpu_to_le32(arg->cwmin);
2766 params->cwmax = __cpu_to_le32(arg->cwmax);
2767 params->aifs = __cpu_to_le32(arg->aifs);
2768 params->txop = __cpu_to_le32(arg->txop);
2769 params->acm = __cpu_to_le32(arg->acm);
2770 params->no_ack = __cpu_to_le32(arg->no_ack);
2771}
2772
2773int ath10k_wmi_pdev_set_wmm_params(struct ath10k *ar,
2774 const struct wmi_pdev_set_wmm_params_arg *arg)
2775{
2776 struct wmi_pdev_set_wmm_params *cmd;
2777 struct sk_buff *skb;
2778
2779 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2780 if (!skb)
2781 return -ENOMEM;
2782
2783 cmd = (struct wmi_pdev_set_wmm_params *)skb->data;
2784 ath10k_wmi_pdev_set_wmm_param(&cmd->ac_be, &arg->ac_be);
2785 ath10k_wmi_pdev_set_wmm_param(&cmd->ac_bk, &arg->ac_bk);
2786 ath10k_wmi_pdev_set_wmm_param(&cmd->ac_vi, &arg->ac_vi);
2787 ath10k_wmi_pdev_set_wmm_param(&cmd->ac_vo, &arg->ac_vo);
2788
2789 ath10k_dbg(ATH10K_DBG_WMI, "wmi pdev set wmm params\n");
Bartosz Markowskice428702013-09-26 17:47:05 +02002790 return ath10k_wmi_cmd_send(ar, skb,
2791 ar->wmi.cmd->pdev_set_wmm_params_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002792}
2793
2794int ath10k_wmi_request_stats(struct ath10k *ar, enum wmi_stats_id stats_id)
2795{
2796 struct wmi_request_stats_cmd *cmd;
2797 struct sk_buff *skb;
2798
2799 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2800 if (!skb)
2801 return -ENOMEM;
2802
2803 cmd = (struct wmi_request_stats_cmd *)skb->data;
2804 cmd->stats_id = __cpu_to_le32(stats_id);
2805
2806 ath10k_dbg(ATH10K_DBG_WMI, "wmi request stats %d\n", (int)stats_id);
Bartosz Markowskice428702013-09-26 17:47:05 +02002807 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->request_stats_cmdid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002808}
Michal Kazior9cfbce72013-07-16 09:54:36 +02002809
2810int ath10k_wmi_force_fw_hang(struct ath10k *ar,
2811 enum wmi_force_fw_hang_type type, u32 delay_ms)
2812{
2813 struct wmi_force_fw_hang_cmd *cmd;
2814 struct sk_buff *skb;
2815
2816 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2817 if (!skb)
2818 return -ENOMEM;
2819
2820 cmd = (struct wmi_force_fw_hang_cmd *)skb->data;
2821 cmd->type = __cpu_to_le32(type);
2822 cmd->delay_ms = __cpu_to_le32(delay_ms);
2823
2824 ath10k_dbg(ATH10K_DBG_WMI, "wmi force fw hang %d delay %d\n",
2825 type, delay_ms);
Bartosz Markowskice428702013-09-26 17:47:05 +02002826 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->force_fw_hang_cmdid);
Michal Kazior9cfbce72013-07-16 09:54:36 +02002827}