blob: 7569db0f69b5eed8f69d65c3e881f56bf54129b4 [file] [log] [blame]
Kalle Valo5e3dd152013-06-12 20:52:10 +03001/*
2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <linux/skbuff.h>
Kalle Valo2fe52882014-01-03 12:59:20 +020019#include <linux/ctype.h>
Kalle Valo5e3dd152013-06-12 20:52:10 +030020
21#include "core.h"
22#include "htc.h"
23#include "debug.h"
24#include "wmi.h"
Michal Kaziorca996ec2014-12-03 10:11:32 +020025#include "wmi-tlv.h"
Kalle Valo5e3dd152013-06-12 20:52:10 +030026#include "mac.h"
Kalle Valo43d2a302014-09-10 18:23:30 +030027#include "testmode.h"
Michal Kaziord7579d12014-12-03 10:10:54 +020028#include "wmi-ops.h"
Michal Kazior6a948882015-02-26 13:23:17 +010029#include "p2p.h"
Michal Kazior587f7032015-05-25 14:06:18 +020030#include "hw.h"
Kalle Valo5e3dd152013-06-12 20:52:10 +030031
Bartosz Markowskice428702013-09-26 17:47:05 +020032/* MAIN WMI cmd track */
33static struct wmi_cmd_map wmi_cmd_map = {
34 .init_cmdid = WMI_INIT_CMDID,
35 .start_scan_cmdid = WMI_START_SCAN_CMDID,
36 .stop_scan_cmdid = WMI_STOP_SCAN_CMDID,
37 .scan_chan_list_cmdid = WMI_SCAN_CHAN_LIST_CMDID,
38 .scan_sch_prio_tbl_cmdid = WMI_SCAN_SCH_PRIO_TBL_CMDID,
39 .pdev_set_regdomain_cmdid = WMI_PDEV_SET_REGDOMAIN_CMDID,
40 .pdev_set_channel_cmdid = WMI_PDEV_SET_CHANNEL_CMDID,
41 .pdev_set_param_cmdid = WMI_PDEV_SET_PARAM_CMDID,
42 .pdev_pktlog_enable_cmdid = WMI_PDEV_PKTLOG_ENABLE_CMDID,
43 .pdev_pktlog_disable_cmdid = WMI_PDEV_PKTLOG_DISABLE_CMDID,
44 .pdev_set_wmm_params_cmdid = WMI_PDEV_SET_WMM_PARAMS_CMDID,
45 .pdev_set_ht_cap_ie_cmdid = WMI_PDEV_SET_HT_CAP_IE_CMDID,
46 .pdev_set_vht_cap_ie_cmdid = WMI_PDEV_SET_VHT_CAP_IE_CMDID,
47 .pdev_set_dscp_tid_map_cmdid = WMI_PDEV_SET_DSCP_TID_MAP_CMDID,
48 .pdev_set_quiet_mode_cmdid = WMI_PDEV_SET_QUIET_MODE_CMDID,
49 .pdev_green_ap_ps_enable_cmdid = WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID,
50 .pdev_get_tpc_config_cmdid = WMI_PDEV_GET_TPC_CONFIG_CMDID,
51 .pdev_set_base_macaddr_cmdid = WMI_PDEV_SET_BASE_MACADDR_CMDID,
52 .vdev_create_cmdid = WMI_VDEV_CREATE_CMDID,
53 .vdev_delete_cmdid = WMI_VDEV_DELETE_CMDID,
54 .vdev_start_request_cmdid = WMI_VDEV_START_REQUEST_CMDID,
55 .vdev_restart_request_cmdid = WMI_VDEV_RESTART_REQUEST_CMDID,
56 .vdev_up_cmdid = WMI_VDEV_UP_CMDID,
57 .vdev_stop_cmdid = WMI_VDEV_STOP_CMDID,
58 .vdev_down_cmdid = WMI_VDEV_DOWN_CMDID,
59 .vdev_set_param_cmdid = WMI_VDEV_SET_PARAM_CMDID,
60 .vdev_install_key_cmdid = WMI_VDEV_INSTALL_KEY_CMDID,
61 .peer_create_cmdid = WMI_PEER_CREATE_CMDID,
62 .peer_delete_cmdid = WMI_PEER_DELETE_CMDID,
63 .peer_flush_tids_cmdid = WMI_PEER_FLUSH_TIDS_CMDID,
64 .peer_set_param_cmdid = WMI_PEER_SET_PARAM_CMDID,
65 .peer_assoc_cmdid = WMI_PEER_ASSOC_CMDID,
66 .peer_add_wds_entry_cmdid = WMI_PEER_ADD_WDS_ENTRY_CMDID,
67 .peer_remove_wds_entry_cmdid = WMI_PEER_REMOVE_WDS_ENTRY_CMDID,
68 .peer_mcast_group_cmdid = WMI_PEER_MCAST_GROUP_CMDID,
69 .bcn_tx_cmdid = WMI_BCN_TX_CMDID,
70 .pdev_send_bcn_cmdid = WMI_PDEV_SEND_BCN_CMDID,
71 .bcn_tmpl_cmdid = WMI_BCN_TMPL_CMDID,
72 .bcn_filter_rx_cmdid = WMI_BCN_FILTER_RX_CMDID,
73 .prb_req_filter_rx_cmdid = WMI_PRB_REQ_FILTER_RX_CMDID,
74 .mgmt_tx_cmdid = WMI_MGMT_TX_CMDID,
75 .prb_tmpl_cmdid = WMI_PRB_TMPL_CMDID,
76 .addba_clear_resp_cmdid = WMI_ADDBA_CLEAR_RESP_CMDID,
77 .addba_send_cmdid = WMI_ADDBA_SEND_CMDID,
78 .addba_status_cmdid = WMI_ADDBA_STATUS_CMDID,
79 .delba_send_cmdid = WMI_DELBA_SEND_CMDID,
80 .addba_set_resp_cmdid = WMI_ADDBA_SET_RESP_CMDID,
81 .send_singleamsdu_cmdid = WMI_SEND_SINGLEAMSDU_CMDID,
82 .sta_powersave_mode_cmdid = WMI_STA_POWERSAVE_MODE_CMDID,
83 .sta_powersave_param_cmdid = WMI_STA_POWERSAVE_PARAM_CMDID,
84 .sta_mimo_ps_mode_cmdid = WMI_STA_MIMO_PS_MODE_CMDID,
85 .pdev_dfs_enable_cmdid = WMI_PDEV_DFS_ENABLE_CMDID,
86 .pdev_dfs_disable_cmdid = WMI_PDEV_DFS_DISABLE_CMDID,
87 .roam_scan_mode = WMI_ROAM_SCAN_MODE,
88 .roam_scan_rssi_threshold = WMI_ROAM_SCAN_RSSI_THRESHOLD,
89 .roam_scan_period = WMI_ROAM_SCAN_PERIOD,
90 .roam_scan_rssi_change_threshold = WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
91 .roam_ap_profile = WMI_ROAM_AP_PROFILE,
92 .ofl_scan_add_ap_profile = WMI_ROAM_AP_PROFILE,
93 .ofl_scan_remove_ap_profile = WMI_OFL_SCAN_REMOVE_AP_PROFILE,
94 .ofl_scan_period = WMI_OFL_SCAN_PERIOD,
95 .p2p_dev_set_device_info = WMI_P2P_DEV_SET_DEVICE_INFO,
96 .p2p_dev_set_discoverability = WMI_P2P_DEV_SET_DISCOVERABILITY,
97 .p2p_go_set_beacon_ie = WMI_P2P_GO_SET_BEACON_IE,
98 .p2p_go_set_probe_resp_ie = WMI_P2P_GO_SET_PROBE_RESP_IE,
99 .p2p_set_vendor_ie_data_cmdid = WMI_P2P_SET_VENDOR_IE_DATA_CMDID,
100 .ap_ps_peer_param_cmdid = WMI_AP_PS_PEER_PARAM_CMDID,
101 .ap_ps_peer_uapsd_coex_cmdid = WMI_AP_PS_PEER_UAPSD_COEX_CMDID,
102 .peer_rate_retry_sched_cmdid = WMI_PEER_RATE_RETRY_SCHED_CMDID,
103 .wlan_profile_trigger_cmdid = WMI_WLAN_PROFILE_TRIGGER_CMDID,
104 .wlan_profile_set_hist_intvl_cmdid =
105 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
106 .wlan_profile_get_profile_data_cmdid =
107 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
108 .wlan_profile_enable_profile_id_cmdid =
109 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
110 .wlan_profile_list_profile_id_cmdid =
111 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
112 .pdev_suspend_cmdid = WMI_PDEV_SUSPEND_CMDID,
113 .pdev_resume_cmdid = WMI_PDEV_RESUME_CMDID,
114 .add_bcn_filter_cmdid = WMI_ADD_BCN_FILTER_CMDID,
115 .rmv_bcn_filter_cmdid = WMI_RMV_BCN_FILTER_CMDID,
116 .wow_add_wake_pattern_cmdid = WMI_WOW_ADD_WAKE_PATTERN_CMDID,
117 .wow_del_wake_pattern_cmdid = WMI_WOW_DEL_WAKE_PATTERN_CMDID,
118 .wow_enable_disable_wake_event_cmdid =
119 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
120 .wow_enable_cmdid = WMI_WOW_ENABLE_CMDID,
121 .wow_hostwakeup_from_sleep_cmdid = WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
122 .rtt_measreq_cmdid = WMI_RTT_MEASREQ_CMDID,
123 .rtt_tsf_cmdid = WMI_RTT_TSF_CMDID,
124 .vdev_spectral_scan_configure_cmdid =
125 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
126 .vdev_spectral_scan_enable_cmdid = WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
127 .request_stats_cmdid = WMI_REQUEST_STATS_CMDID,
128 .set_arp_ns_offload_cmdid = WMI_SET_ARP_NS_OFFLOAD_CMDID,
129 .network_list_offload_config_cmdid =
130 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID,
131 .gtk_offload_cmdid = WMI_GTK_OFFLOAD_CMDID,
132 .csa_offload_enable_cmdid = WMI_CSA_OFFLOAD_ENABLE_CMDID,
133 .csa_offload_chanswitch_cmdid = WMI_CSA_OFFLOAD_CHANSWITCH_CMDID,
134 .chatter_set_mode_cmdid = WMI_CHATTER_SET_MODE_CMDID,
135 .peer_tid_addba_cmdid = WMI_PEER_TID_ADDBA_CMDID,
136 .peer_tid_delba_cmdid = WMI_PEER_TID_DELBA_CMDID,
137 .sta_dtim_ps_method_cmdid = WMI_STA_DTIM_PS_METHOD_CMDID,
138 .sta_uapsd_auto_trig_cmdid = WMI_STA_UAPSD_AUTO_TRIG_CMDID,
139 .sta_keepalive_cmd = WMI_STA_KEEPALIVE_CMD,
140 .echo_cmdid = WMI_ECHO_CMDID,
141 .pdev_utf_cmdid = WMI_PDEV_UTF_CMDID,
142 .dbglog_cfg_cmdid = WMI_DBGLOG_CFG_CMDID,
143 .pdev_qvit_cmdid = WMI_PDEV_QVIT_CMDID,
144 .pdev_ftm_intg_cmdid = WMI_PDEV_FTM_INTG_CMDID,
145 .vdev_set_keepalive_cmdid = WMI_VDEV_SET_KEEPALIVE_CMDID,
146 .vdev_get_keepalive_cmdid = WMI_VDEV_GET_KEEPALIVE_CMDID,
147 .force_fw_hang_cmdid = WMI_FORCE_FW_HANG_CMDID,
148 .gpio_config_cmdid = WMI_GPIO_CONFIG_CMDID,
149 .gpio_output_cmdid = WMI_GPIO_OUTPUT_CMDID,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +0200150 .pdev_get_temperature_cmdid = WMI_CMD_UNSUPPORTED,
Maharaja62f77f02015-10-21 11:49:18 +0300151 .pdev_enable_adaptive_cca_cmdid = WMI_CMD_UNSUPPORTED,
Raja Mani772b4ae2015-06-22 20:10:12 +0530152 .scan_update_request_cmdid = WMI_CMD_UNSUPPORTED,
153 .vdev_standby_response_cmdid = WMI_CMD_UNSUPPORTED,
154 .vdev_resume_response_cmdid = WMI_CMD_UNSUPPORTED,
155 .wlan_peer_caching_add_peer_cmdid = WMI_CMD_UNSUPPORTED,
156 .wlan_peer_caching_evict_peer_cmdid = WMI_CMD_UNSUPPORTED,
157 .wlan_peer_caching_restore_peer_cmdid = WMI_CMD_UNSUPPORTED,
158 .wlan_peer_caching_print_all_peers_info_cmdid = WMI_CMD_UNSUPPORTED,
159 .peer_update_wds_entry_cmdid = WMI_CMD_UNSUPPORTED,
160 .peer_add_proxy_sta_entry_cmdid = WMI_CMD_UNSUPPORTED,
161 .rtt_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
162 .oem_req_cmdid = WMI_CMD_UNSUPPORTED,
163 .nan_cmdid = WMI_CMD_UNSUPPORTED,
164 .vdev_ratemask_cmdid = WMI_CMD_UNSUPPORTED,
165 .qboost_cfg_cmdid = WMI_CMD_UNSUPPORTED,
166 .pdev_smart_ant_enable_cmdid = WMI_CMD_UNSUPPORTED,
167 .pdev_smart_ant_set_rx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
168 .peer_smart_ant_set_tx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
169 .peer_smart_ant_set_train_info_cmdid = WMI_CMD_UNSUPPORTED,
170 .peer_smart_ant_set_node_config_ops_cmdid = WMI_CMD_UNSUPPORTED,
171 .pdev_set_antenna_switch_table_cmdid = WMI_CMD_UNSUPPORTED,
172 .pdev_set_ctl_table_cmdid = WMI_CMD_UNSUPPORTED,
173 .pdev_set_mimogain_table_cmdid = WMI_CMD_UNSUPPORTED,
174 .pdev_ratepwr_table_cmdid = WMI_CMD_UNSUPPORTED,
175 .pdev_ratepwr_chainmsk_table_cmdid = WMI_CMD_UNSUPPORTED,
176 .pdev_fips_cmdid = WMI_CMD_UNSUPPORTED,
177 .tt_set_conf_cmdid = WMI_CMD_UNSUPPORTED,
178 .fwtest_cmdid = WMI_CMD_UNSUPPORTED,
179 .vdev_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
180 .peer_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
181 .pdev_get_ani_cck_config_cmdid = WMI_CMD_UNSUPPORTED,
182 .pdev_get_ani_ofdm_config_cmdid = WMI_CMD_UNSUPPORTED,
183 .pdev_reserve_ast_entry_cmdid = WMI_CMD_UNSUPPORTED,
184 .pdev_get_nfcal_power_cmdid = WMI_CMD_UNSUPPORTED,
185 .pdev_get_tpc_cmdid = WMI_CMD_UNSUPPORTED,
186 .pdev_get_ast_info_cmdid = WMI_CMD_UNSUPPORTED,
187 .vdev_set_dscp_tid_map_cmdid = WMI_CMD_UNSUPPORTED,
188 .pdev_get_info_cmdid = WMI_CMD_UNSUPPORTED,
189 .vdev_get_info_cmdid = WMI_CMD_UNSUPPORTED,
190 .vdev_filter_neighbor_rx_packets_cmdid = WMI_CMD_UNSUPPORTED,
191 .mu_cal_start_cmdid = WMI_CMD_UNSUPPORTED,
192 .set_cca_params_cmdid = WMI_CMD_UNSUPPORTED,
193 .pdev_bss_chan_info_request_cmdid = WMI_CMD_UNSUPPORTED,
Bartosz Markowskice428702013-09-26 17:47:05 +0200194};
195
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200196/* 10.X WMI cmd track */
197static struct wmi_cmd_map wmi_10x_cmd_map = {
198 .init_cmdid = WMI_10X_INIT_CMDID,
199 .start_scan_cmdid = WMI_10X_START_SCAN_CMDID,
200 .stop_scan_cmdid = WMI_10X_STOP_SCAN_CMDID,
201 .scan_chan_list_cmdid = WMI_10X_SCAN_CHAN_LIST_CMDID,
Bartosz Markowski34957b22013-10-15 09:55:31 +0200202 .scan_sch_prio_tbl_cmdid = WMI_CMD_UNSUPPORTED,
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200203 .pdev_set_regdomain_cmdid = WMI_10X_PDEV_SET_REGDOMAIN_CMDID,
204 .pdev_set_channel_cmdid = WMI_10X_PDEV_SET_CHANNEL_CMDID,
205 .pdev_set_param_cmdid = WMI_10X_PDEV_SET_PARAM_CMDID,
206 .pdev_pktlog_enable_cmdid = WMI_10X_PDEV_PKTLOG_ENABLE_CMDID,
207 .pdev_pktlog_disable_cmdid = WMI_10X_PDEV_PKTLOG_DISABLE_CMDID,
208 .pdev_set_wmm_params_cmdid = WMI_10X_PDEV_SET_WMM_PARAMS_CMDID,
209 .pdev_set_ht_cap_ie_cmdid = WMI_10X_PDEV_SET_HT_CAP_IE_CMDID,
210 .pdev_set_vht_cap_ie_cmdid = WMI_10X_PDEV_SET_VHT_CAP_IE_CMDID,
211 .pdev_set_dscp_tid_map_cmdid = WMI_10X_PDEV_SET_DSCP_TID_MAP_CMDID,
212 .pdev_set_quiet_mode_cmdid = WMI_10X_PDEV_SET_QUIET_MODE_CMDID,
213 .pdev_green_ap_ps_enable_cmdid = WMI_10X_PDEV_GREEN_AP_PS_ENABLE_CMDID,
214 .pdev_get_tpc_config_cmdid = WMI_10X_PDEV_GET_TPC_CONFIG_CMDID,
215 .pdev_set_base_macaddr_cmdid = WMI_10X_PDEV_SET_BASE_MACADDR_CMDID,
216 .vdev_create_cmdid = WMI_10X_VDEV_CREATE_CMDID,
217 .vdev_delete_cmdid = WMI_10X_VDEV_DELETE_CMDID,
218 .vdev_start_request_cmdid = WMI_10X_VDEV_START_REQUEST_CMDID,
219 .vdev_restart_request_cmdid = WMI_10X_VDEV_RESTART_REQUEST_CMDID,
220 .vdev_up_cmdid = WMI_10X_VDEV_UP_CMDID,
221 .vdev_stop_cmdid = WMI_10X_VDEV_STOP_CMDID,
222 .vdev_down_cmdid = WMI_10X_VDEV_DOWN_CMDID,
223 .vdev_set_param_cmdid = WMI_10X_VDEV_SET_PARAM_CMDID,
224 .vdev_install_key_cmdid = WMI_10X_VDEV_INSTALL_KEY_CMDID,
225 .peer_create_cmdid = WMI_10X_PEER_CREATE_CMDID,
226 .peer_delete_cmdid = WMI_10X_PEER_DELETE_CMDID,
227 .peer_flush_tids_cmdid = WMI_10X_PEER_FLUSH_TIDS_CMDID,
228 .peer_set_param_cmdid = WMI_10X_PEER_SET_PARAM_CMDID,
229 .peer_assoc_cmdid = WMI_10X_PEER_ASSOC_CMDID,
230 .peer_add_wds_entry_cmdid = WMI_10X_PEER_ADD_WDS_ENTRY_CMDID,
231 .peer_remove_wds_entry_cmdid = WMI_10X_PEER_REMOVE_WDS_ENTRY_CMDID,
232 .peer_mcast_group_cmdid = WMI_10X_PEER_MCAST_GROUP_CMDID,
233 .bcn_tx_cmdid = WMI_10X_BCN_TX_CMDID,
234 .pdev_send_bcn_cmdid = WMI_10X_PDEV_SEND_BCN_CMDID,
Bartosz Markowski34957b22013-10-15 09:55:31 +0200235 .bcn_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200236 .bcn_filter_rx_cmdid = WMI_10X_BCN_FILTER_RX_CMDID,
237 .prb_req_filter_rx_cmdid = WMI_10X_PRB_REQ_FILTER_RX_CMDID,
238 .mgmt_tx_cmdid = WMI_10X_MGMT_TX_CMDID,
Bartosz Markowski34957b22013-10-15 09:55:31 +0200239 .prb_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200240 .addba_clear_resp_cmdid = WMI_10X_ADDBA_CLEAR_RESP_CMDID,
241 .addba_send_cmdid = WMI_10X_ADDBA_SEND_CMDID,
242 .addba_status_cmdid = WMI_10X_ADDBA_STATUS_CMDID,
243 .delba_send_cmdid = WMI_10X_DELBA_SEND_CMDID,
244 .addba_set_resp_cmdid = WMI_10X_ADDBA_SET_RESP_CMDID,
245 .send_singleamsdu_cmdid = WMI_10X_SEND_SINGLEAMSDU_CMDID,
246 .sta_powersave_mode_cmdid = WMI_10X_STA_POWERSAVE_MODE_CMDID,
247 .sta_powersave_param_cmdid = WMI_10X_STA_POWERSAVE_PARAM_CMDID,
248 .sta_mimo_ps_mode_cmdid = WMI_10X_STA_MIMO_PS_MODE_CMDID,
249 .pdev_dfs_enable_cmdid = WMI_10X_PDEV_DFS_ENABLE_CMDID,
250 .pdev_dfs_disable_cmdid = WMI_10X_PDEV_DFS_DISABLE_CMDID,
251 .roam_scan_mode = WMI_10X_ROAM_SCAN_MODE,
252 .roam_scan_rssi_threshold = WMI_10X_ROAM_SCAN_RSSI_THRESHOLD,
253 .roam_scan_period = WMI_10X_ROAM_SCAN_PERIOD,
254 .roam_scan_rssi_change_threshold =
255 WMI_10X_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
256 .roam_ap_profile = WMI_10X_ROAM_AP_PROFILE,
257 .ofl_scan_add_ap_profile = WMI_10X_OFL_SCAN_ADD_AP_PROFILE,
258 .ofl_scan_remove_ap_profile = WMI_10X_OFL_SCAN_REMOVE_AP_PROFILE,
259 .ofl_scan_period = WMI_10X_OFL_SCAN_PERIOD,
260 .p2p_dev_set_device_info = WMI_10X_P2P_DEV_SET_DEVICE_INFO,
261 .p2p_dev_set_discoverability = WMI_10X_P2P_DEV_SET_DISCOVERABILITY,
262 .p2p_go_set_beacon_ie = WMI_10X_P2P_GO_SET_BEACON_IE,
263 .p2p_go_set_probe_resp_ie = WMI_10X_P2P_GO_SET_PROBE_RESP_IE,
Bartosz Markowski34957b22013-10-15 09:55:31 +0200264 .p2p_set_vendor_ie_data_cmdid = WMI_CMD_UNSUPPORTED,
Janusz Dziedzic542fb172014-01-17 14:08:08 +0100265 .ap_ps_peer_param_cmdid = WMI_10X_AP_PS_PEER_PARAM_CMDID,
Bartosz Markowski34957b22013-10-15 09:55:31 +0200266 .ap_ps_peer_uapsd_coex_cmdid = WMI_CMD_UNSUPPORTED,
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200267 .peer_rate_retry_sched_cmdid = WMI_10X_PEER_RATE_RETRY_SCHED_CMDID,
268 .wlan_profile_trigger_cmdid = WMI_10X_WLAN_PROFILE_TRIGGER_CMDID,
269 .wlan_profile_set_hist_intvl_cmdid =
270 WMI_10X_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
271 .wlan_profile_get_profile_data_cmdid =
272 WMI_10X_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
273 .wlan_profile_enable_profile_id_cmdid =
274 WMI_10X_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
275 .wlan_profile_list_profile_id_cmdid =
276 WMI_10X_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
277 .pdev_suspend_cmdid = WMI_10X_PDEV_SUSPEND_CMDID,
278 .pdev_resume_cmdid = WMI_10X_PDEV_RESUME_CMDID,
279 .add_bcn_filter_cmdid = WMI_10X_ADD_BCN_FILTER_CMDID,
280 .rmv_bcn_filter_cmdid = WMI_10X_RMV_BCN_FILTER_CMDID,
281 .wow_add_wake_pattern_cmdid = WMI_10X_WOW_ADD_WAKE_PATTERN_CMDID,
282 .wow_del_wake_pattern_cmdid = WMI_10X_WOW_DEL_WAKE_PATTERN_CMDID,
283 .wow_enable_disable_wake_event_cmdid =
284 WMI_10X_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
285 .wow_enable_cmdid = WMI_10X_WOW_ENABLE_CMDID,
286 .wow_hostwakeup_from_sleep_cmdid =
287 WMI_10X_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
288 .rtt_measreq_cmdid = WMI_10X_RTT_MEASREQ_CMDID,
289 .rtt_tsf_cmdid = WMI_10X_RTT_TSF_CMDID,
290 .vdev_spectral_scan_configure_cmdid =
291 WMI_10X_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
292 .vdev_spectral_scan_enable_cmdid =
293 WMI_10X_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
294 .request_stats_cmdid = WMI_10X_REQUEST_STATS_CMDID,
Bartosz Markowski34957b22013-10-15 09:55:31 +0200295 .set_arp_ns_offload_cmdid = WMI_CMD_UNSUPPORTED,
296 .network_list_offload_config_cmdid = WMI_CMD_UNSUPPORTED,
297 .gtk_offload_cmdid = WMI_CMD_UNSUPPORTED,
298 .csa_offload_enable_cmdid = WMI_CMD_UNSUPPORTED,
299 .csa_offload_chanswitch_cmdid = WMI_CMD_UNSUPPORTED,
300 .chatter_set_mode_cmdid = WMI_CMD_UNSUPPORTED,
301 .peer_tid_addba_cmdid = WMI_CMD_UNSUPPORTED,
302 .peer_tid_delba_cmdid = WMI_CMD_UNSUPPORTED,
303 .sta_dtim_ps_method_cmdid = WMI_CMD_UNSUPPORTED,
304 .sta_uapsd_auto_trig_cmdid = WMI_CMD_UNSUPPORTED,
305 .sta_keepalive_cmd = WMI_CMD_UNSUPPORTED,
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200306 .echo_cmdid = WMI_10X_ECHO_CMDID,
307 .pdev_utf_cmdid = WMI_10X_PDEV_UTF_CMDID,
308 .dbglog_cfg_cmdid = WMI_10X_DBGLOG_CFG_CMDID,
309 .pdev_qvit_cmdid = WMI_10X_PDEV_QVIT_CMDID,
Bartosz Markowski34957b22013-10-15 09:55:31 +0200310 .pdev_ftm_intg_cmdid = WMI_CMD_UNSUPPORTED,
311 .vdev_set_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
312 .vdev_get_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
313 .force_fw_hang_cmdid = WMI_CMD_UNSUPPORTED,
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200314 .gpio_config_cmdid = WMI_10X_GPIO_CONFIG_CMDID,
315 .gpio_output_cmdid = WMI_10X_GPIO_OUTPUT_CMDID,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +0200316 .pdev_get_temperature_cmdid = WMI_CMD_UNSUPPORTED,
Maharaja62f77f02015-10-21 11:49:18 +0300317 .pdev_enable_adaptive_cca_cmdid = WMI_CMD_UNSUPPORTED,
Raja Mani772b4ae2015-06-22 20:10:12 +0530318 .scan_update_request_cmdid = WMI_CMD_UNSUPPORTED,
319 .vdev_standby_response_cmdid = WMI_CMD_UNSUPPORTED,
320 .vdev_resume_response_cmdid = WMI_CMD_UNSUPPORTED,
321 .wlan_peer_caching_add_peer_cmdid = WMI_CMD_UNSUPPORTED,
322 .wlan_peer_caching_evict_peer_cmdid = WMI_CMD_UNSUPPORTED,
323 .wlan_peer_caching_restore_peer_cmdid = WMI_CMD_UNSUPPORTED,
324 .wlan_peer_caching_print_all_peers_info_cmdid = WMI_CMD_UNSUPPORTED,
325 .peer_update_wds_entry_cmdid = WMI_CMD_UNSUPPORTED,
326 .peer_add_proxy_sta_entry_cmdid = WMI_CMD_UNSUPPORTED,
327 .rtt_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
328 .oem_req_cmdid = WMI_CMD_UNSUPPORTED,
329 .nan_cmdid = WMI_CMD_UNSUPPORTED,
330 .vdev_ratemask_cmdid = WMI_CMD_UNSUPPORTED,
331 .qboost_cfg_cmdid = WMI_CMD_UNSUPPORTED,
332 .pdev_smart_ant_enable_cmdid = WMI_CMD_UNSUPPORTED,
333 .pdev_smart_ant_set_rx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
334 .peer_smart_ant_set_tx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
335 .peer_smart_ant_set_train_info_cmdid = WMI_CMD_UNSUPPORTED,
336 .peer_smart_ant_set_node_config_ops_cmdid = WMI_CMD_UNSUPPORTED,
337 .pdev_set_antenna_switch_table_cmdid = WMI_CMD_UNSUPPORTED,
338 .pdev_set_ctl_table_cmdid = WMI_CMD_UNSUPPORTED,
339 .pdev_set_mimogain_table_cmdid = WMI_CMD_UNSUPPORTED,
340 .pdev_ratepwr_table_cmdid = WMI_CMD_UNSUPPORTED,
341 .pdev_ratepwr_chainmsk_table_cmdid = WMI_CMD_UNSUPPORTED,
342 .pdev_fips_cmdid = WMI_CMD_UNSUPPORTED,
343 .tt_set_conf_cmdid = WMI_CMD_UNSUPPORTED,
344 .fwtest_cmdid = WMI_CMD_UNSUPPORTED,
345 .vdev_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
346 .peer_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
347 .pdev_get_ani_cck_config_cmdid = WMI_CMD_UNSUPPORTED,
348 .pdev_get_ani_ofdm_config_cmdid = WMI_CMD_UNSUPPORTED,
349 .pdev_reserve_ast_entry_cmdid = WMI_CMD_UNSUPPORTED,
350 .pdev_get_nfcal_power_cmdid = WMI_CMD_UNSUPPORTED,
351 .pdev_get_tpc_cmdid = WMI_CMD_UNSUPPORTED,
352 .pdev_get_ast_info_cmdid = WMI_CMD_UNSUPPORTED,
353 .vdev_set_dscp_tid_map_cmdid = WMI_CMD_UNSUPPORTED,
354 .pdev_get_info_cmdid = WMI_CMD_UNSUPPORTED,
355 .vdev_get_info_cmdid = WMI_CMD_UNSUPPORTED,
356 .vdev_filter_neighbor_rx_packets_cmdid = WMI_CMD_UNSUPPORTED,
357 .mu_cal_start_cmdid = WMI_CMD_UNSUPPORTED,
358 .set_cca_params_cmdid = WMI_CMD_UNSUPPORTED,
359 .pdev_bss_chan_info_request_cmdid = WMI_CMD_UNSUPPORTED,
Bartosz Markowskib7e3adf2013-09-26 17:47:06 +0200360};
Bartosz Markowskice428702013-09-26 17:47:05 +0200361
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +0200362/* 10.2.4 WMI cmd track */
363static struct wmi_cmd_map wmi_10_2_4_cmd_map = {
364 .init_cmdid = WMI_10_2_INIT_CMDID,
365 .start_scan_cmdid = WMI_10_2_START_SCAN_CMDID,
366 .stop_scan_cmdid = WMI_10_2_STOP_SCAN_CMDID,
367 .scan_chan_list_cmdid = WMI_10_2_SCAN_CHAN_LIST_CMDID,
368 .scan_sch_prio_tbl_cmdid = WMI_CMD_UNSUPPORTED,
369 .pdev_set_regdomain_cmdid = WMI_10_2_PDEV_SET_REGDOMAIN_CMDID,
370 .pdev_set_channel_cmdid = WMI_10_2_PDEV_SET_CHANNEL_CMDID,
371 .pdev_set_param_cmdid = WMI_10_2_PDEV_SET_PARAM_CMDID,
372 .pdev_pktlog_enable_cmdid = WMI_10_2_PDEV_PKTLOG_ENABLE_CMDID,
373 .pdev_pktlog_disable_cmdid = WMI_10_2_PDEV_PKTLOG_DISABLE_CMDID,
374 .pdev_set_wmm_params_cmdid = WMI_10_2_PDEV_SET_WMM_PARAMS_CMDID,
375 .pdev_set_ht_cap_ie_cmdid = WMI_10_2_PDEV_SET_HT_CAP_IE_CMDID,
376 .pdev_set_vht_cap_ie_cmdid = WMI_10_2_PDEV_SET_VHT_CAP_IE_CMDID,
377 .pdev_set_quiet_mode_cmdid = WMI_10_2_PDEV_SET_QUIET_MODE_CMDID,
378 .pdev_green_ap_ps_enable_cmdid = WMI_10_2_PDEV_GREEN_AP_PS_ENABLE_CMDID,
379 .pdev_get_tpc_config_cmdid = WMI_10_2_PDEV_GET_TPC_CONFIG_CMDID,
380 .pdev_set_base_macaddr_cmdid = WMI_10_2_PDEV_SET_BASE_MACADDR_CMDID,
381 .vdev_create_cmdid = WMI_10_2_VDEV_CREATE_CMDID,
382 .vdev_delete_cmdid = WMI_10_2_VDEV_DELETE_CMDID,
383 .vdev_start_request_cmdid = WMI_10_2_VDEV_START_REQUEST_CMDID,
384 .vdev_restart_request_cmdid = WMI_10_2_VDEV_RESTART_REQUEST_CMDID,
385 .vdev_up_cmdid = WMI_10_2_VDEV_UP_CMDID,
386 .vdev_stop_cmdid = WMI_10_2_VDEV_STOP_CMDID,
387 .vdev_down_cmdid = WMI_10_2_VDEV_DOWN_CMDID,
388 .vdev_set_param_cmdid = WMI_10_2_VDEV_SET_PARAM_CMDID,
389 .vdev_install_key_cmdid = WMI_10_2_VDEV_INSTALL_KEY_CMDID,
390 .peer_create_cmdid = WMI_10_2_PEER_CREATE_CMDID,
391 .peer_delete_cmdid = WMI_10_2_PEER_DELETE_CMDID,
392 .peer_flush_tids_cmdid = WMI_10_2_PEER_FLUSH_TIDS_CMDID,
393 .peer_set_param_cmdid = WMI_10_2_PEER_SET_PARAM_CMDID,
394 .peer_assoc_cmdid = WMI_10_2_PEER_ASSOC_CMDID,
395 .peer_add_wds_entry_cmdid = WMI_10_2_PEER_ADD_WDS_ENTRY_CMDID,
396 .peer_remove_wds_entry_cmdid = WMI_10_2_PEER_REMOVE_WDS_ENTRY_CMDID,
397 .peer_mcast_group_cmdid = WMI_10_2_PEER_MCAST_GROUP_CMDID,
398 .bcn_tx_cmdid = WMI_10_2_BCN_TX_CMDID,
399 .pdev_send_bcn_cmdid = WMI_10_2_PDEV_SEND_BCN_CMDID,
400 .bcn_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
401 .bcn_filter_rx_cmdid = WMI_10_2_BCN_FILTER_RX_CMDID,
402 .prb_req_filter_rx_cmdid = WMI_10_2_PRB_REQ_FILTER_RX_CMDID,
403 .mgmt_tx_cmdid = WMI_10_2_MGMT_TX_CMDID,
404 .prb_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
405 .addba_clear_resp_cmdid = WMI_10_2_ADDBA_CLEAR_RESP_CMDID,
406 .addba_send_cmdid = WMI_10_2_ADDBA_SEND_CMDID,
407 .addba_status_cmdid = WMI_10_2_ADDBA_STATUS_CMDID,
408 .delba_send_cmdid = WMI_10_2_DELBA_SEND_CMDID,
409 .addba_set_resp_cmdid = WMI_10_2_ADDBA_SET_RESP_CMDID,
410 .send_singleamsdu_cmdid = WMI_10_2_SEND_SINGLEAMSDU_CMDID,
411 .sta_powersave_mode_cmdid = WMI_10_2_STA_POWERSAVE_MODE_CMDID,
412 .sta_powersave_param_cmdid = WMI_10_2_STA_POWERSAVE_PARAM_CMDID,
413 .sta_mimo_ps_mode_cmdid = WMI_10_2_STA_MIMO_PS_MODE_CMDID,
414 .pdev_dfs_enable_cmdid = WMI_10_2_PDEV_DFS_ENABLE_CMDID,
415 .pdev_dfs_disable_cmdid = WMI_10_2_PDEV_DFS_DISABLE_CMDID,
416 .roam_scan_mode = WMI_10_2_ROAM_SCAN_MODE,
417 .roam_scan_rssi_threshold = WMI_10_2_ROAM_SCAN_RSSI_THRESHOLD,
418 .roam_scan_period = WMI_10_2_ROAM_SCAN_PERIOD,
419 .roam_scan_rssi_change_threshold =
420 WMI_10_2_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
421 .roam_ap_profile = WMI_10_2_ROAM_AP_PROFILE,
422 .ofl_scan_add_ap_profile = WMI_10_2_OFL_SCAN_ADD_AP_PROFILE,
423 .ofl_scan_remove_ap_profile = WMI_10_2_OFL_SCAN_REMOVE_AP_PROFILE,
424 .ofl_scan_period = WMI_10_2_OFL_SCAN_PERIOD,
425 .p2p_dev_set_device_info = WMI_10_2_P2P_DEV_SET_DEVICE_INFO,
426 .p2p_dev_set_discoverability = WMI_10_2_P2P_DEV_SET_DISCOVERABILITY,
427 .p2p_go_set_beacon_ie = WMI_10_2_P2P_GO_SET_BEACON_IE,
428 .p2p_go_set_probe_resp_ie = WMI_10_2_P2P_GO_SET_PROBE_RESP_IE,
429 .p2p_set_vendor_ie_data_cmdid = WMI_CMD_UNSUPPORTED,
430 .ap_ps_peer_param_cmdid = WMI_10_2_AP_PS_PEER_PARAM_CMDID,
431 .ap_ps_peer_uapsd_coex_cmdid = WMI_CMD_UNSUPPORTED,
432 .peer_rate_retry_sched_cmdid = WMI_10_2_PEER_RATE_RETRY_SCHED_CMDID,
433 .wlan_profile_trigger_cmdid = WMI_10_2_WLAN_PROFILE_TRIGGER_CMDID,
434 .wlan_profile_set_hist_intvl_cmdid =
435 WMI_10_2_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
436 .wlan_profile_get_profile_data_cmdid =
437 WMI_10_2_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
438 .wlan_profile_enable_profile_id_cmdid =
439 WMI_10_2_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
440 .wlan_profile_list_profile_id_cmdid =
441 WMI_10_2_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
442 .pdev_suspend_cmdid = WMI_10_2_PDEV_SUSPEND_CMDID,
443 .pdev_resume_cmdid = WMI_10_2_PDEV_RESUME_CMDID,
444 .add_bcn_filter_cmdid = WMI_10_2_ADD_BCN_FILTER_CMDID,
445 .rmv_bcn_filter_cmdid = WMI_10_2_RMV_BCN_FILTER_CMDID,
446 .wow_add_wake_pattern_cmdid = WMI_10_2_WOW_ADD_WAKE_PATTERN_CMDID,
447 .wow_del_wake_pattern_cmdid = WMI_10_2_WOW_DEL_WAKE_PATTERN_CMDID,
448 .wow_enable_disable_wake_event_cmdid =
449 WMI_10_2_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
450 .wow_enable_cmdid = WMI_10_2_WOW_ENABLE_CMDID,
451 .wow_hostwakeup_from_sleep_cmdid =
452 WMI_10_2_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
453 .rtt_measreq_cmdid = WMI_10_2_RTT_MEASREQ_CMDID,
454 .rtt_tsf_cmdid = WMI_10_2_RTT_TSF_CMDID,
455 .vdev_spectral_scan_configure_cmdid =
456 WMI_10_2_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
457 .vdev_spectral_scan_enable_cmdid =
458 WMI_10_2_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
459 .request_stats_cmdid = WMI_10_2_REQUEST_STATS_CMDID,
460 .set_arp_ns_offload_cmdid = WMI_CMD_UNSUPPORTED,
461 .network_list_offload_config_cmdid = WMI_CMD_UNSUPPORTED,
462 .gtk_offload_cmdid = WMI_CMD_UNSUPPORTED,
463 .csa_offload_enable_cmdid = WMI_CMD_UNSUPPORTED,
464 .csa_offload_chanswitch_cmdid = WMI_CMD_UNSUPPORTED,
465 .chatter_set_mode_cmdid = WMI_CMD_UNSUPPORTED,
466 .peer_tid_addba_cmdid = WMI_CMD_UNSUPPORTED,
467 .peer_tid_delba_cmdid = WMI_CMD_UNSUPPORTED,
468 .sta_dtim_ps_method_cmdid = WMI_CMD_UNSUPPORTED,
469 .sta_uapsd_auto_trig_cmdid = WMI_CMD_UNSUPPORTED,
470 .sta_keepalive_cmd = WMI_CMD_UNSUPPORTED,
471 .echo_cmdid = WMI_10_2_ECHO_CMDID,
472 .pdev_utf_cmdid = WMI_10_2_PDEV_UTF_CMDID,
473 .dbglog_cfg_cmdid = WMI_10_2_DBGLOG_CFG_CMDID,
474 .pdev_qvit_cmdid = WMI_10_2_PDEV_QVIT_CMDID,
475 .pdev_ftm_intg_cmdid = WMI_CMD_UNSUPPORTED,
476 .vdev_set_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
477 .vdev_get_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
478 .force_fw_hang_cmdid = WMI_CMD_UNSUPPORTED,
479 .gpio_config_cmdid = WMI_10_2_GPIO_CONFIG_CMDID,
480 .gpio_output_cmdid = WMI_10_2_GPIO_OUTPUT_CMDID,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +0200481 .pdev_get_temperature_cmdid = WMI_10_2_PDEV_GET_TEMPERATURE_CMDID,
Maharaja62f77f02015-10-21 11:49:18 +0300482 .pdev_enable_adaptive_cca_cmdid = WMI_10_2_SET_CCA_PARAMS,
Raja Mani772b4ae2015-06-22 20:10:12 +0530483 .scan_update_request_cmdid = WMI_CMD_UNSUPPORTED,
484 .vdev_standby_response_cmdid = WMI_CMD_UNSUPPORTED,
485 .vdev_resume_response_cmdid = WMI_CMD_UNSUPPORTED,
486 .wlan_peer_caching_add_peer_cmdid = WMI_CMD_UNSUPPORTED,
487 .wlan_peer_caching_evict_peer_cmdid = WMI_CMD_UNSUPPORTED,
488 .wlan_peer_caching_restore_peer_cmdid = WMI_CMD_UNSUPPORTED,
489 .wlan_peer_caching_print_all_peers_info_cmdid = WMI_CMD_UNSUPPORTED,
490 .peer_update_wds_entry_cmdid = WMI_CMD_UNSUPPORTED,
491 .peer_add_proxy_sta_entry_cmdid = WMI_CMD_UNSUPPORTED,
492 .rtt_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
493 .oem_req_cmdid = WMI_CMD_UNSUPPORTED,
494 .nan_cmdid = WMI_CMD_UNSUPPORTED,
495 .vdev_ratemask_cmdid = WMI_CMD_UNSUPPORTED,
496 .qboost_cfg_cmdid = WMI_CMD_UNSUPPORTED,
497 .pdev_smart_ant_enable_cmdid = WMI_CMD_UNSUPPORTED,
498 .pdev_smart_ant_set_rx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
499 .peer_smart_ant_set_tx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
500 .peer_smart_ant_set_train_info_cmdid = WMI_CMD_UNSUPPORTED,
501 .peer_smart_ant_set_node_config_ops_cmdid = WMI_CMD_UNSUPPORTED,
502 .pdev_set_antenna_switch_table_cmdid = WMI_CMD_UNSUPPORTED,
503 .pdev_set_ctl_table_cmdid = WMI_CMD_UNSUPPORTED,
504 .pdev_set_mimogain_table_cmdid = WMI_CMD_UNSUPPORTED,
505 .pdev_ratepwr_table_cmdid = WMI_CMD_UNSUPPORTED,
506 .pdev_ratepwr_chainmsk_table_cmdid = WMI_CMD_UNSUPPORTED,
507 .pdev_fips_cmdid = WMI_CMD_UNSUPPORTED,
508 .tt_set_conf_cmdid = WMI_CMD_UNSUPPORTED,
509 .fwtest_cmdid = WMI_CMD_UNSUPPORTED,
510 .vdev_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
511 .peer_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
512 .pdev_get_ani_cck_config_cmdid = WMI_CMD_UNSUPPORTED,
513 .pdev_get_ani_ofdm_config_cmdid = WMI_CMD_UNSUPPORTED,
514 .pdev_reserve_ast_entry_cmdid = WMI_CMD_UNSUPPORTED,
515 .pdev_get_nfcal_power_cmdid = WMI_CMD_UNSUPPORTED,
516 .pdev_get_tpc_cmdid = WMI_CMD_UNSUPPORTED,
517 .pdev_get_ast_info_cmdid = WMI_CMD_UNSUPPORTED,
518 .vdev_set_dscp_tid_map_cmdid = WMI_CMD_UNSUPPORTED,
519 .pdev_get_info_cmdid = WMI_CMD_UNSUPPORTED,
520 .vdev_get_info_cmdid = WMI_CMD_UNSUPPORTED,
521 .vdev_filter_neighbor_rx_packets_cmdid = WMI_CMD_UNSUPPORTED,
522 .mu_cal_start_cmdid = WMI_CMD_UNSUPPORTED,
523 .set_cca_params_cmdid = WMI_CMD_UNSUPPORTED,
524 .pdev_bss_chan_info_request_cmdid = WMI_CMD_UNSUPPORTED,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +0200525};
526
Raja Mani2d491e62015-06-22 20:10:11 +0530527/* 10.4 WMI cmd track */
528static struct wmi_cmd_map wmi_10_4_cmd_map = {
529 .init_cmdid = WMI_10_4_INIT_CMDID,
530 .start_scan_cmdid = WMI_10_4_START_SCAN_CMDID,
531 .stop_scan_cmdid = WMI_10_4_STOP_SCAN_CMDID,
532 .scan_chan_list_cmdid = WMI_10_4_SCAN_CHAN_LIST_CMDID,
533 .scan_sch_prio_tbl_cmdid = WMI_10_4_SCAN_SCH_PRIO_TBL_CMDID,
534 .pdev_set_regdomain_cmdid = WMI_10_4_PDEV_SET_REGDOMAIN_CMDID,
535 .pdev_set_channel_cmdid = WMI_10_4_PDEV_SET_CHANNEL_CMDID,
536 .pdev_set_param_cmdid = WMI_10_4_PDEV_SET_PARAM_CMDID,
537 .pdev_pktlog_enable_cmdid = WMI_10_4_PDEV_PKTLOG_ENABLE_CMDID,
538 .pdev_pktlog_disable_cmdid = WMI_10_4_PDEV_PKTLOG_DISABLE_CMDID,
539 .pdev_set_wmm_params_cmdid = WMI_10_4_PDEV_SET_WMM_PARAMS_CMDID,
540 .pdev_set_ht_cap_ie_cmdid = WMI_10_4_PDEV_SET_HT_CAP_IE_CMDID,
541 .pdev_set_vht_cap_ie_cmdid = WMI_10_4_PDEV_SET_VHT_CAP_IE_CMDID,
542 .pdev_set_dscp_tid_map_cmdid = WMI_10_4_PDEV_SET_DSCP_TID_MAP_CMDID,
543 .pdev_set_quiet_mode_cmdid = WMI_10_4_PDEV_SET_QUIET_MODE_CMDID,
544 .pdev_green_ap_ps_enable_cmdid = WMI_10_4_PDEV_GREEN_AP_PS_ENABLE_CMDID,
545 .pdev_get_tpc_config_cmdid = WMI_10_4_PDEV_GET_TPC_CONFIG_CMDID,
546 .pdev_set_base_macaddr_cmdid = WMI_10_4_PDEV_SET_BASE_MACADDR_CMDID,
547 .vdev_create_cmdid = WMI_10_4_VDEV_CREATE_CMDID,
548 .vdev_delete_cmdid = WMI_10_4_VDEV_DELETE_CMDID,
549 .vdev_start_request_cmdid = WMI_10_4_VDEV_START_REQUEST_CMDID,
550 .vdev_restart_request_cmdid = WMI_10_4_VDEV_RESTART_REQUEST_CMDID,
551 .vdev_up_cmdid = WMI_10_4_VDEV_UP_CMDID,
552 .vdev_stop_cmdid = WMI_10_4_VDEV_STOP_CMDID,
553 .vdev_down_cmdid = WMI_10_4_VDEV_DOWN_CMDID,
554 .vdev_set_param_cmdid = WMI_10_4_VDEV_SET_PARAM_CMDID,
555 .vdev_install_key_cmdid = WMI_10_4_VDEV_INSTALL_KEY_CMDID,
556 .peer_create_cmdid = WMI_10_4_PEER_CREATE_CMDID,
557 .peer_delete_cmdid = WMI_10_4_PEER_DELETE_CMDID,
558 .peer_flush_tids_cmdid = WMI_10_4_PEER_FLUSH_TIDS_CMDID,
559 .peer_set_param_cmdid = WMI_10_4_PEER_SET_PARAM_CMDID,
560 .peer_assoc_cmdid = WMI_10_4_PEER_ASSOC_CMDID,
561 .peer_add_wds_entry_cmdid = WMI_10_4_PEER_ADD_WDS_ENTRY_CMDID,
562 .peer_remove_wds_entry_cmdid = WMI_10_4_PEER_REMOVE_WDS_ENTRY_CMDID,
563 .peer_mcast_group_cmdid = WMI_10_4_PEER_MCAST_GROUP_CMDID,
564 .bcn_tx_cmdid = WMI_10_4_BCN_TX_CMDID,
565 .pdev_send_bcn_cmdid = WMI_10_4_PDEV_SEND_BCN_CMDID,
566 .bcn_tmpl_cmdid = WMI_10_4_BCN_PRB_TMPL_CMDID,
567 .bcn_filter_rx_cmdid = WMI_10_4_BCN_FILTER_RX_CMDID,
568 .prb_req_filter_rx_cmdid = WMI_10_4_PRB_REQ_FILTER_RX_CMDID,
569 .mgmt_tx_cmdid = WMI_10_4_MGMT_TX_CMDID,
570 .prb_tmpl_cmdid = WMI_10_4_PRB_TMPL_CMDID,
571 .addba_clear_resp_cmdid = WMI_10_4_ADDBA_CLEAR_RESP_CMDID,
572 .addba_send_cmdid = WMI_10_4_ADDBA_SEND_CMDID,
573 .addba_status_cmdid = WMI_10_4_ADDBA_STATUS_CMDID,
574 .delba_send_cmdid = WMI_10_4_DELBA_SEND_CMDID,
575 .addba_set_resp_cmdid = WMI_10_4_ADDBA_SET_RESP_CMDID,
576 .send_singleamsdu_cmdid = WMI_10_4_SEND_SINGLEAMSDU_CMDID,
577 .sta_powersave_mode_cmdid = WMI_10_4_STA_POWERSAVE_MODE_CMDID,
578 .sta_powersave_param_cmdid = WMI_10_4_STA_POWERSAVE_PARAM_CMDID,
579 .sta_mimo_ps_mode_cmdid = WMI_10_4_STA_MIMO_PS_MODE_CMDID,
580 .pdev_dfs_enable_cmdid = WMI_10_4_PDEV_DFS_ENABLE_CMDID,
581 .pdev_dfs_disable_cmdid = WMI_10_4_PDEV_DFS_DISABLE_CMDID,
582 .roam_scan_mode = WMI_10_4_ROAM_SCAN_MODE,
583 .roam_scan_rssi_threshold = WMI_10_4_ROAM_SCAN_RSSI_THRESHOLD,
584 .roam_scan_period = WMI_10_4_ROAM_SCAN_PERIOD,
585 .roam_scan_rssi_change_threshold =
586 WMI_10_4_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
587 .roam_ap_profile = WMI_10_4_ROAM_AP_PROFILE,
588 .ofl_scan_add_ap_profile = WMI_10_4_OFL_SCAN_ADD_AP_PROFILE,
589 .ofl_scan_remove_ap_profile = WMI_10_4_OFL_SCAN_REMOVE_AP_PROFILE,
590 .ofl_scan_period = WMI_10_4_OFL_SCAN_PERIOD,
591 .p2p_dev_set_device_info = WMI_10_4_P2P_DEV_SET_DEVICE_INFO,
592 .p2p_dev_set_discoverability = WMI_10_4_P2P_DEV_SET_DISCOVERABILITY,
593 .p2p_go_set_beacon_ie = WMI_10_4_P2P_GO_SET_BEACON_IE,
594 .p2p_go_set_probe_resp_ie = WMI_10_4_P2P_GO_SET_PROBE_RESP_IE,
595 .p2p_set_vendor_ie_data_cmdid = WMI_10_4_P2P_SET_VENDOR_IE_DATA_CMDID,
596 .ap_ps_peer_param_cmdid = WMI_10_4_AP_PS_PEER_PARAM_CMDID,
597 .ap_ps_peer_uapsd_coex_cmdid = WMI_10_4_AP_PS_PEER_UAPSD_COEX_CMDID,
598 .peer_rate_retry_sched_cmdid = WMI_10_4_PEER_RATE_RETRY_SCHED_CMDID,
599 .wlan_profile_trigger_cmdid = WMI_10_4_WLAN_PROFILE_TRIGGER_CMDID,
600 .wlan_profile_set_hist_intvl_cmdid =
601 WMI_10_4_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
602 .wlan_profile_get_profile_data_cmdid =
603 WMI_10_4_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
604 .wlan_profile_enable_profile_id_cmdid =
605 WMI_10_4_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
606 .wlan_profile_list_profile_id_cmdid =
607 WMI_10_4_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
608 .pdev_suspend_cmdid = WMI_10_4_PDEV_SUSPEND_CMDID,
609 .pdev_resume_cmdid = WMI_10_4_PDEV_RESUME_CMDID,
610 .add_bcn_filter_cmdid = WMI_10_4_ADD_BCN_FILTER_CMDID,
611 .rmv_bcn_filter_cmdid = WMI_10_4_RMV_BCN_FILTER_CMDID,
612 .wow_add_wake_pattern_cmdid = WMI_10_4_WOW_ADD_WAKE_PATTERN_CMDID,
613 .wow_del_wake_pattern_cmdid = WMI_10_4_WOW_DEL_WAKE_PATTERN_CMDID,
614 .wow_enable_disable_wake_event_cmdid =
615 WMI_10_4_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
616 .wow_enable_cmdid = WMI_10_4_WOW_ENABLE_CMDID,
617 .wow_hostwakeup_from_sleep_cmdid =
618 WMI_10_4_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
619 .rtt_measreq_cmdid = WMI_10_4_RTT_MEASREQ_CMDID,
620 .rtt_tsf_cmdid = WMI_10_4_RTT_TSF_CMDID,
621 .vdev_spectral_scan_configure_cmdid =
622 WMI_10_4_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
623 .vdev_spectral_scan_enable_cmdid =
624 WMI_10_4_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
625 .request_stats_cmdid = WMI_10_4_REQUEST_STATS_CMDID,
626 .set_arp_ns_offload_cmdid = WMI_CMD_UNSUPPORTED,
627 .network_list_offload_config_cmdid = WMI_CMD_UNSUPPORTED,
628 .gtk_offload_cmdid = WMI_10_4_GTK_OFFLOAD_CMDID,
629 .csa_offload_enable_cmdid = WMI_10_4_CSA_OFFLOAD_ENABLE_CMDID,
630 .csa_offload_chanswitch_cmdid = WMI_10_4_CSA_OFFLOAD_CHANSWITCH_CMDID,
631 .chatter_set_mode_cmdid = WMI_CMD_UNSUPPORTED,
632 .peer_tid_addba_cmdid = WMI_CMD_UNSUPPORTED,
633 .peer_tid_delba_cmdid = WMI_CMD_UNSUPPORTED,
634 .sta_dtim_ps_method_cmdid = WMI_CMD_UNSUPPORTED,
635 .sta_uapsd_auto_trig_cmdid = WMI_CMD_UNSUPPORTED,
636 .sta_keepalive_cmd = WMI_CMD_UNSUPPORTED,
637 .echo_cmdid = WMI_10_4_ECHO_CMDID,
638 .pdev_utf_cmdid = WMI_10_4_PDEV_UTF_CMDID,
639 .dbglog_cfg_cmdid = WMI_10_4_DBGLOG_CFG_CMDID,
640 .pdev_qvit_cmdid = WMI_10_4_PDEV_QVIT_CMDID,
641 .pdev_ftm_intg_cmdid = WMI_CMD_UNSUPPORTED,
642 .vdev_set_keepalive_cmdid = WMI_10_4_VDEV_SET_KEEPALIVE_CMDID,
643 .vdev_get_keepalive_cmdid = WMI_10_4_VDEV_GET_KEEPALIVE_CMDID,
644 .force_fw_hang_cmdid = WMI_10_4_FORCE_FW_HANG_CMDID,
645 .gpio_config_cmdid = WMI_10_4_GPIO_CONFIG_CMDID,
646 .gpio_output_cmdid = WMI_10_4_GPIO_OUTPUT_CMDID,
647 .pdev_get_temperature_cmdid = WMI_10_4_PDEV_GET_TEMPERATURE_CMDID,
648 .vdev_set_wmm_params_cmdid = WMI_CMD_UNSUPPORTED,
649 .tdls_set_state_cmdid = WMI_CMD_UNSUPPORTED,
650 .tdls_peer_update_cmdid = WMI_CMD_UNSUPPORTED,
651 .adaptive_qcs_cmdid = WMI_CMD_UNSUPPORTED,
652 .scan_update_request_cmdid = WMI_10_4_SCAN_UPDATE_REQUEST_CMDID,
653 .vdev_standby_response_cmdid = WMI_10_4_VDEV_STANDBY_RESPONSE_CMDID,
654 .vdev_resume_response_cmdid = WMI_10_4_VDEV_RESUME_RESPONSE_CMDID,
655 .wlan_peer_caching_add_peer_cmdid =
656 WMI_10_4_WLAN_PEER_CACHING_ADD_PEER_CMDID,
657 .wlan_peer_caching_evict_peer_cmdid =
658 WMI_10_4_WLAN_PEER_CACHING_EVICT_PEER_CMDID,
659 .wlan_peer_caching_restore_peer_cmdid =
660 WMI_10_4_WLAN_PEER_CACHING_RESTORE_PEER_CMDID,
661 .wlan_peer_caching_print_all_peers_info_cmdid =
662 WMI_10_4_WLAN_PEER_CACHING_PRINT_ALL_PEERS_INFO_CMDID,
663 .peer_update_wds_entry_cmdid = WMI_10_4_PEER_UPDATE_WDS_ENTRY_CMDID,
664 .peer_add_proxy_sta_entry_cmdid =
665 WMI_10_4_PEER_ADD_PROXY_STA_ENTRY_CMDID,
666 .rtt_keepalive_cmdid = WMI_10_4_RTT_KEEPALIVE_CMDID,
667 .oem_req_cmdid = WMI_10_4_OEM_REQ_CMDID,
668 .nan_cmdid = WMI_10_4_NAN_CMDID,
669 .vdev_ratemask_cmdid = WMI_10_4_VDEV_RATEMASK_CMDID,
670 .qboost_cfg_cmdid = WMI_10_4_QBOOST_CFG_CMDID,
671 .pdev_smart_ant_enable_cmdid = WMI_10_4_PDEV_SMART_ANT_ENABLE_CMDID,
672 .pdev_smart_ant_set_rx_antenna_cmdid =
673 WMI_10_4_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID,
674 .peer_smart_ant_set_tx_antenna_cmdid =
675 WMI_10_4_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID,
676 .peer_smart_ant_set_train_info_cmdid =
677 WMI_10_4_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID,
678 .peer_smart_ant_set_node_config_ops_cmdid =
679 WMI_10_4_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID,
680 .pdev_set_antenna_switch_table_cmdid =
681 WMI_10_4_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID,
682 .pdev_set_ctl_table_cmdid = WMI_10_4_PDEV_SET_CTL_TABLE_CMDID,
683 .pdev_set_mimogain_table_cmdid = WMI_10_4_PDEV_SET_MIMOGAIN_TABLE_CMDID,
684 .pdev_ratepwr_table_cmdid = WMI_10_4_PDEV_RATEPWR_TABLE_CMDID,
685 .pdev_ratepwr_chainmsk_table_cmdid =
686 WMI_10_4_PDEV_RATEPWR_CHAINMSK_TABLE_CMDID,
687 .pdev_fips_cmdid = WMI_10_4_PDEV_FIPS_CMDID,
688 .tt_set_conf_cmdid = WMI_10_4_TT_SET_CONF_CMDID,
689 .fwtest_cmdid = WMI_10_4_FWTEST_CMDID,
690 .vdev_atf_request_cmdid = WMI_10_4_VDEV_ATF_REQUEST_CMDID,
691 .peer_atf_request_cmdid = WMI_10_4_PEER_ATF_REQUEST_CMDID,
692 .pdev_get_ani_cck_config_cmdid = WMI_10_4_PDEV_GET_ANI_CCK_CONFIG_CMDID,
693 .pdev_get_ani_ofdm_config_cmdid =
694 WMI_10_4_PDEV_GET_ANI_OFDM_CONFIG_CMDID,
695 .pdev_reserve_ast_entry_cmdid = WMI_10_4_PDEV_RESERVE_AST_ENTRY_CMDID,
696 .pdev_get_nfcal_power_cmdid = WMI_10_4_PDEV_GET_NFCAL_POWER_CMDID,
697 .pdev_get_tpc_cmdid = WMI_10_4_PDEV_GET_TPC_CMDID,
698 .pdev_get_ast_info_cmdid = WMI_10_4_PDEV_GET_AST_INFO_CMDID,
699 .vdev_set_dscp_tid_map_cmdid = WMI_10_4_VDEV_SET_DSCP_TID_MAP_CMDID,
700 .pdev_get_info_cmdid = WMI_10_4_PDEV_GET_INFO_CMDID,
701 .vdev_get_info_cmdid = WMI_10_4_VDEV_GET_INFO_CMDID,
702 .vdev_filter_neighbor_rx_packets_cmdid =
703 WMI_10_4_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID,
704 .mu_cal_start_cmdid = WMI_10_4_MU_CAL_START_CMDID,
705 .set_cca_params_cmdid = WMI_10_4_SET_CCA_PARAMS_CMDID,
706 .pdev_bss_chan_info_request_cmdid =
707 WMI_10_4_PDEV_BSS_CHAN_INFO_REQUEST_CMDID,
708};
709
Bartosz Markowski6d1506e2013-09-26 17:47:15 +0200710/* MAIN WMI VDEV param map */
711static struct wmi_vdev_param_map wmi_vdev_param_map = {
712 .rts_threshold = WMI_VDEV_PARAM_RTS_THRESHOLD,
713 .fragmentation_threshold = WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
714 .beacon_interval = WMI_VDEV_PARAM_BEACON_INTERVAL,
715 .listen_interval = WMI_VDEV_PARAM_LISTEN_INTERVAL,
716 .multicast_rate = WMI_VDEV_PARAM_MULTICAST_RATE,
717 .mgmt_tx_rate = WMI_VDEV_PARAM_MGMT_TX_RATE,
718 .slot_time = WMI_VDEV_PARAM_SLOT_TIME,
719 .preamble = WMI_VDEV_PARAM_PREAMBLE,
720 .swba_time = WMI_VDEV_PARAM_SWBA_TIME,
721 .wmi_vdev_stats_update_period = WMI_VDEV_STATS_UPDATE_PERIOD,
722 .wmi_vdev_pwrsave_ageout_time = WMI_VDEV_PWRSAVE_AGEOUT_TIME,
723 .wmi_vdev_host_swba_interval = WMI_VDEV_HOST_SWBA_INTERVAL,
724 .dtim_period = WMI_VDEV_PARAM_DTIM_PERIOD,
725 .wmi_vdev_oc_scheduler_air_time_limit =
726 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
727 .wds = WMI_VDEV_PARAM_WDS,
728 .atim_window = WMI_VDEV_PARAM_ATIM_WINDOW,
729 .bmiss_count_max = WMI_VDEV_PARAM_BMISS_COUNT_MAX,
730 .bmiss_first_bcnt = WMI_VDEV_PARAM_BMISS_FIRST_BCNT,
731 .bmiss_final_bcnt = WMI_VDEV_PARAM_BMISS_FINAL_BCNT,
732 .feature_wmm = WMI_VDEV_PARAM_FEATURE_WMM,
733 .chwidth = WMI_VDEV_PARAM_CHWIDTH,
734 .chextoffset = WMI_VDEV_PARAM_CHEXTOFFSET,
735 .disable_htprotection = WMI_VDEV_PARAM_DISABLE_HTPROTECTION,
736 .sta_quickkickout = WMI_VDEV_PARAM_STA_QUICKKICKOUT,
737 .mgmt_rate = WMI_VDEV_PARAM_MGMT_RATE,
738 .protection_mode = WMI_VDEV_PARAM_PROTECTION_MODE,
739 .fixed_rate = WMI_VDEV_PARAM_FIXED_RATE,
740 .sgi = WMI_VDEV_PARAM_SGI,
741 .ldpc = WMI_VDEV_PARAM_LDPC,
742 .tx_stbc = WMI_VDEV_PARAM_TX_STBC,
743 .rx_stbc = WMI_VDEV_PARAM_RX_STBC,
744 .intra_bss_fwd = WMI_VDEV_PARAM_INTRA_BSS_FWD,
745 .def_keyid = WMI_VDEV_PARAM_DEF_KEYID,
746 .nss = WMI_VDEV_PARAM_NSS,
747 .bcast_data_rate = WMI_VDEV_PARAM_BCAST_DATA_RATE,
748 .mcast_data_rate = WMI_VDEV_PARAM_MCAST_DATA_RATE,
749 .mcast_indicate = WMI_VDEV_PARAM_MCAST_INDICATE,
750 .dhcp_indicate = WMI_VDEV_PARAM_DHCP_INDICATE,
751 .unknown_dest_indicate = WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
752 .ap_keepalive_min_idle_inactive_time_secs =
753 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
754 .ap_keepalive_max_idle_inactive_time_secs =
755 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
756 .ap_keepalive_max_unresponsive_time_secs =
757 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
758 .ap_enable_nawds = WMI_VDEV_PARAM_AP_ENABLE_NAWDS,
759 .mcast2ucast_set = WMI_VDEV_PARAM_UNSUPPORTED,
760 .enable_rtscts = WMI_VDEV_PARAM_ENABLE_RTSCTS,
761 .txbf = WMI_VDEV_PARAM_TXBF,
762 .packet_powersave = WMI_VDEV_PARAM_PACKET_POWERSAVE,
763 .drop_unencry = WMI_VDEV_PARAM_DROP_UNENCRY,
764 .tx_encap_type = WMI_VDEV_PARAM_TX_ENCAP_TYPE,
765 .ap_detect_out_of_sync_sleeping_sta_time_secs =
766 WMI_VDEV_PARAM_UNSUPPORTED,
Raja Mani93841a12015-06-22 20:10:13 +0530767 .rc_num_retries = WMI_VDEV_PARAM_UNSUPPORTED,
768 .cabq_maxdur = WMI_VDEV_PARAM_UNSUPPORTED,
769 .mfptest_set = WMI_VDEV_PARAM_UNSUPPORTED,
770 .rts_fixed_rate = WMI_VDEV_PARAM_UNSUPPORTED,
771 .vht_sgimask = WMI_VDEV_PARAM_UNSUPPORTED,
772 .vht80_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
773 .early_rx_adjust_enable = WMI_VDEV_PARAM_UNSUPPORTED,
774 .early_rx_tgt_bmiss_num = WMI_VDEV_PARAM_UNSUPPORTED,
775 .early_rx_bmiss_sample_cycle = WMI_VDEV_PARAM_UNSUPPORTED,
776 .early_rx_slop_step = WMI_VDEV_PARAM_UNSUPPORTED,
777 .early_rx_init_slop = WMI_VDEV_PARAM_UNSUPPORTED,
778 .early_rx_adjust_pause = WMI_VDEV_PARAM_UNSUPPORTED,
779 .proxy_sta = WMI_VDEV_PARAM_UNSUPPORTED,
780 .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED,
781 .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED,
782 .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
Bartosz Markowski6d1506e2013-09-26 17:47:15 +0200783};
784
785/* 10.X WMI VDEV param map */
786static struct wmi_vdev_param_map wmi_10x_vdev_param_map = {
787 .rts_threshold = WMI_10X_VDEV_PARAM_RTS_THRESHOLD,
788 .fragmentation_threshold = WMI_10X_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
789 .beacon_interval = WMI_10X_VDEV_PARAM_BEACON_INTERVAL,
790 .listen_interval = WMI_10X_VDEV_PARAM_LISTEN_INTERVAL,
791 .multicast_rate = WMI_10X_VDEV_PARAM_MULTICAST_RATE,
792 .mgmt_tx_rate = WMI_10X_VDEV_PARAM_MGMT_TX_RATE,
793 .slot_time = WMI_10X_VDEV_PARAM_SLOT_TIME,
794 .preamble = WMI_10X_VDEV_PARAM_PREAMBLE,
795 .swba_time = WMI_10X_VDEV_PARAM_SWBA_TIME,
796 .wmi_vdev_stats_update_period = WMI_10X_VDEV_STATS_UPDATE_PERIOD,
797 .wmi_vdev_pwrsave_ageout_time = WMI_10X_VDEV_PWRSAVE_AGEOUT_TIME,
798 .wmi_vdev_host_swba_interval = WMI_10X_VDEV_HOST_SWBA_INTERVAL,
799 .dtim_period = WMI_10X_VDEV_PARAM_DTIM_PERIOD,
800 .wmi_vdev_oc_scheduler_air_time_limit =
801 WMI_10X_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
802 .wds = WMI_10X_VDEV_PARAM_WDS,
803 .atim_window = WMI_10X_VDEV_PARAM_ATIM_WINDOW,
804 .bmiss_count_max = WMI_10X_VDEV_PARAM_BMISS_COUNT_MAX,
805 .bmiss_first_bcnt = WMI_VDEV_PARAM_UNSUPPORTED,
806 .bmiss_final_bcnt = WMI_VDEV_PARAM_UNSUPPORTED,
807 .feature_wmm = WMI_10X_VDEV_PARAM_FEATURE_WMM,
808 .chwidth = WMI_10X_VDEV_PARAM_CHWIDTH,
809 .chextoffset = WMI_10X_VDEV_PARAM_CHEXTOFFSET,
810 .disable_htprotection = WMI_10X_VDEV_PARAM_DISABLE_HTPROTECTION,
811 .sta_quickkickout = WMI_10X_VDEV_PARAM_STA_QUICKKICKOUT,
812 .mgmt_rate = WMI_10X_VDEV_PARAM_MGMT_RATE,
813 .protection_mode = WMI_10X_VDEV_PARAM_PROTECTION_MODE,
814 .fixed_rate = WMI_10X_VDEV_PARAM_FIXED_RATE,
815 .sgi = WMI_10X_VDEV_PARAM_SGI,
816 .ldpc = WMI_10X_VDEV_PARAM_LDPC,
817 .tx_stbc = WMI_10X_VDEV_PARAM_TX_STBC,
818 .rx_stbc = WMI_10X_VDEV_PARAM_RX_STBC,
819 .intra_bss_fwd = WMI_10X_VDEV_PARAM_INTRA_BSS_FWD,
820 .def_keyid = WMI_10X_VDEV_PARAM_DEF_KEYID,
821 .nss = WMI_10X_VDEV_PARAM_NSS,
822 .bcast_data_rate = WMI_10X_VDEV_PARAM_BCAST_DATA_RATE,
823 .mcast_data_rate = WMI_10X_VDEV_PARAM_MCAST_DATA_RATE,
824 .mcast_indicate = WMI_10X_VDEV_PARAM_MCAST_INDICATE,
825 .dhcp_indicate = WMI_10X_VDEV_PARAM_DHCP_INDICATE,
826 .unknown_dest_indicate = WMI_10X_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
827 .ap_keepalive_min_idle_inactive_time_secs =
828 WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
829 .ap_keepalive_max_idle_inactive_time_secs =
830 WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
831 .ap_keepalive_max_unresponsive_time_secs =
832 WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
833 .ap_enable_nawds = WMI_10X_VDEV_PARAM_AP_ENABLE_NAWDS,
834 .mcast2ucast_set = WMI_10X_VDEV_PARAM_MCAST2UCAST_SET,
835 .enable_rtscts = WMI_10X_VDEV_PARAM_ENABLE_RTSCTS,
836 .txbf = WMI_VDEV_PARAM_UNSUPPORTED,
837 .packet_powersave = WMI_VDEV_PARAM_UNSUPPORTED,
838 .drop_unencry = WMI_VDEV_PARAM_UNSUPPORTED,
839 .tx_encap_type = WMI_VDEV_PARAM_UNSUPPORTED,
840 .ap_detect_out_of_sync_sleeping_sta_time_secs =
841 WMI_10X_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS,
Raja Mani93841a12015-06-22 20:10:13 +0530842 .rc_num_retries = WMI_VDEV_PARAM_UNSUPPORTED,
843 .cabq_maxdur = WMI_VDEV_PARAM_UNSUPPORTED,
844 .mfptest_set = WMI_VDEV_PARAM_UNSUPPORTED,
845 .rts_fixed_rate = WMI_VDEV_PARAM_UNSUPPORTED,
846 .vht_sgimask = WMI_VDEV_PARAM_UNSUPPORTED,
847 .vht80_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
848 .early_rx_adjust_enable = WMI_VDEV_PARAM_UNSUPPORTED,
849 .early_rx_tgt_bmiss_num = WMI_VDEV_PARAM_UNSUPPORTED,
850 .early_rx_bmiss_sample_cycle = WMI_VDEV_PARAM_UNSUPPORTED,
851 .early_rx_slop_step = WMI_VDEV_PARAM_UNSUPPORTED,
852 .early_rx_init_slop = WMI_VDEV_PARAM_UNSUPPORTED,
853 .early_rx_adjust_pause = WMI_VDEV_PARAM_UNSUPPORTED,
854 .proxy_sta = WMI_VDEV_PARAM_UNSUPPORTED,
855 .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED,
856 .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED,
857 .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
Bartosz Markowski6d1506e2013-09-26 17:47:15 +0200858};
859
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +0200860static struct wmi_vdev_param_map wmi_10_2_4_vdev_param_map = {
861 .rts_threshold = WMI_10X_VDEV_PARAM_RTS_THRESHOLD,
862 .fragmentation_threshold = WMI_10X_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
863 .beacon_interval = WMI_10X_VDEV_PARAM_BEACON_INTERVAL,
864 .listen_interval = WMI_10X_VDEV_PARAM_LISTEN_INTERVAL,
865 .multicast_rate = WMI_10X_VDEV_PARAM_MULTICAST_RATE,
866 .mgmt_tx_rate = WMI_10X_VDEV_PARAM_MGMT_TX_RATE,
867 .slot_time = WMI_10X_VDEV_PARAM_SLOT_TIME,
868 .preamble = WMI_10X_VDEV_PARAM_PREAMBLE,
869 .swba_time = WMI_10X_VDEV_PARAM_SWBA_TIME,
870 .wmi_vdev_stats_update_period = WMI_10X_VDEV_STATS_UPDATE_PERIOD,
871 .wmi_vdev_pwrsave_ageout_time = WMI_10X_VDEV_PWRSAVE_AGEOUT_TIME,
872 .wmi_vdev_host_swba_interval = WMI_10X_VDEV_HOST_SWBA_INTERVAL,
873 .dtim_period = WMI_10X_VDEV_PARAM_DTIM_PERIOD,
874 .wmi_vdev_oc_scheduler_air_time_limit =
875 WMI_10X_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
876 .wds = WMI_10X_VDEV_PARAM_WDS,
877 .atim_window = WMI_10X_VDEV_PARAM_ATIM_WINDOW,
878 .bmiss_count_max = WMI_10X_VDEV_PARAM_BMISS_COUNT_MAX,
879 .bmiss_first_bcnt = WMI_VDEV_PARAM_UNSUPPORTED,
880 .bmiss_final_bcnt = WMI_VDEV_PARAM_UNSUPPORTED,
881 .feature_wmm = WMI_10X_VDEV_PARAM_FEATURE_WMM,
882 .chwidth = WMI_10X_VDEV_PARAM_CHWIDTH,
883 .chextoffset = WMI_10X_VDEV_PARAM_CHEXTOFFSET,
884 .disable_htprotection = WMI_10X_VDEV_PARAM_DISABLE_HTPROTECTION,
885 .sta_quickkickout = WMI_10X_VDEV_PARAM_STA_QUICKKICKOUT,
886 .mgmt_rate = WMI_10X_VDEV_PARAM_MGMT_RATE,
887 .protection_mode = WMI_10X_VDEV_PARAM_PROTECTION_MODE,
888 .fixed_rate = WMI_10X_VDEV_PARAM_FIXED_RATE,
889 .sgi = WMI_10X_VDEV_PARAM_SGI,
890 .ldpc = WMI_10X_VDEV_PARAM_LDPC,
891 .tx_stbc = WMI_10X_VDEV_PARAM_TX_STBC,
892 .rx_stbc = WMI_10X_VDEV_PARAM_RX_STBC,
893 .intra_bss_fwd = WMI_10X_VDEV_PARAM_INTRA_BSS_FWD,
894 .def_keyid = WMI_10X_VDEV_PARAM_DEF_KEYID,
895 .nss = WMI_10X_VDEV_PARAM_NSS,
896 .bcast_data_rate = WMI_10X_VDEV_PARAM_BCAST_DATA_RATE,
897 .mcast_data_rate = WMI_10X_VDEV_PARAM_MCAST_DATA_RATE,
898 .mcast_indicate = WMI_10X_VDEV_PARAM_MCAST_INDICATE,
899 .dhcp_indicate = WMI_10X_VDEV_PARAM_DHCP_INDICATE,
900 .unknown_dest_indicate = WMI_10X_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
901 .ap_keepalive_min_idle_inactive_time_secs =
902 WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
903 .ap_keepalive_max_idle_inactive_time_secs =
904 WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
905 .ap_keepalive_max_unresponsive_time_secs =
906 WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
907 .ap_enable_nawds = WMI_10X_VDEV_PARAM_AP_ENABLE_NAWDS,
908 .mcast2ucast_set = WMI_10X_VDEV_PARAM_MCAST2UCAST_SET,
909 .enable_rtscts = WMI_10X_VDEV_PARAM_ENABLE_RTSCTS,
910 .txbf = WMI_VDEV_PARAM_UNSUPPORTED,
911 .packet_powersave = WMI_VDEV_PARAM_UNSUPPORTED,
912 .drop_unencry = WMI_VDEV_PARAM_UNSUPPORTED,
913 .tx_encap_type = WMI_VDEV_PARAM_UNSUPPORTED,
914 .ap_detect_out_of_sync_sleeping_sta_time_secs =
915 WMI_10X_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS,
Raja Mani93841a12015-06-22 20:10:13 +0530916 .rc_num_retries = WMI_VDEV_PARAM_UNSUPPORTED,
917 .cabq_maxdur = WMI_VDEV_PARAM_UNSUPPORTED,
918 .mfptest_set = WMI_VDEV_PARAM_UNSUPPORTED,
919 .rts_fixed_rate = WMI_VDEV_PARAM_UNSUPPORTED,
920 .vht_sgimask = WMI_VDEV_PARAM_UNSUPPORTED,
921 .vht80_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
922 .early_rx_adjust_enable = WMI_VDEV_PARAM_UNSUPPORTED,
923 .early_rx_tgt_bmiss_num = WMI_VDEV_PARAM_UNSUPPORTED,
924 .early_rx_bmiss_sample_cycle = WMI_VDEV_PARAM_UNSUPPORTED,
925 .early_rx_slop_step = WMI_VDEV_PARAM_UNSUPPORTED,
926 .early_rx_init_slop = WMI_VDEV_PARAM_UNSUPPORTED,
927 .early_rx_adjust_pause = WMI_VDEV_PARAM_UNSUPPORTED,
928 .proxy_sta = WMI_VDEV_PARAM_UNSUPPORTED,
929 .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED,
930 .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED,
931 .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
932};
933
934static struct wmi_vdev_param_map wmi_10_4_vdev_param_map = {
935 .rts_threshold = WMI_10_4_VDEV_PARAM_RTS_THRESHOLD,
936 .fragmentation_threshold = WMI_10_4_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
937 .beacon_interval = WMI_10_4_VDEV_PARAM_BEACON_INTERVAL,
938 .listen_interval = WMI_10_4_VDEV_PARAM_LISTEN_INTERVAL,
939 .multicast_rate = WMI_10_4_VDEV_PARAM_MULTICAST_RATE,
940 .mgmt_tx_rate = WMI_10_4_VDEV_PARAM_MGMT_TX_RATE,
941 .slot_time = WMI_10_4_VDEV_PARAM_SLOT_TIME,
942 .preamble = WMI_10_4_VDEV_PARAM_PREAMBLE,
943 .swba_time = WMI_10_4_VDEV_PARAM_SWBA_TIME,
944 .wmi_vdev_stats_update_period = WMI_10_4_VDEV_STATS_UPDATE_PERIOD,
945 .wmi_vdev_pwrsave_ageout_time = WMI_10_4_VDEV_PWRSAVE_AGEOUT_TIME,
946 .wmi_vdev_host_swba_interval = WMI_10_4_VDEV_HOST_SWBA_INTERVAL,
947 .dtim_period = WMI_10_4_VDEV_PARAM_DTIM_PERIOD,
948 .wmi_vdev_oc_scheduler_air_time_limit =
949 WMI_10_4_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
950 .wds = WMI_10_4_VDEV_PARAM_WDS,
951 .atim_window = WMI_10_4_VDEV_PARAM_ATIM_WINDOW,
952 .bmiss_count_max = WMI_10_4_VDEV_PARAM_BMISS_COUNT_MAX,
953 .bmiss_first_bcnt = WMI_10_4_VDEV_PARAM_BMISS_FIRST_BCNT,
954 .bmiss_final_bcnt = WMI_10_4_VDEV_PARAM_BMISS_FINAL_BCNT,
955 .feature_wmm = WMI_10_4_VDEV_PARAM_FEATURE_WMM,
956 .chwidth = WMI_10_4_VDEV_PARAM_CHWIDTH,
957 .chextoffset = WMI_10_4_VDEV_PARAM_CHEXTOFFSET,
958 .disable_htprotection = WMI_10_4_VDEV_PARAM_DISABLE_HTPROTECTION,
959 .sta_quickkickout = WMI_10_4_VDEV_PARAM_STA_QUICKKICKOUT,
960 .mgmt_rate = WMI_10_4_VDEV_PARAM_MGMT_RATE,
961 .protection_mode = WMI_10_4_VDEV_PARAM_PROTECTION_MODE,
962 .fixed_rate = WMI_10_4_VDEV_PARAM_FIXED_RATE,
963 .sgi = WMI_10_4_VDEV_PARAM_SGI,
964 .ldpc = WMI_10_4_VDEV_PARAM_LDPC,
965 .tx_stbc = WMI_10_4_VDEV_PARAM_TX_STBC,
966 .rx_stbc = WMI_10_4_VDEV_PARAM_RX_STBC,
967 .intra_bss_fwd = WMI_10_4_VDEV_PARAM_INTRA_BSS_FWD,
968 .def_keyid = WMI_10_4_VDEV_PARAM_DEF_KEYID,
969 .nss = WMI_10_4_VDEV_PARAM_NSS,
970 .bcast_data_rate = WMI_10_4_VDEV_PARAM_BCAST_DATA_RATE,
971 .mcast_data_rate = WMI_10_4_VDEV_PARAM_MCAST_DATA_RATE,
972 .mcast_indicate = WMI_10_4_VDEV_PARAM_MCAST_INDICATE,
973 .dhcp_indicate = WMI_10_4_VDEV_PARAM_DHCP_INDICATE,
974 .unknown_dest_indicate = WMI_10_4_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
975 .ap_keepalive_min_idle_inactive_time_secs =
976 WMI_10_4_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
977 .ap_keepalive_max_idle_inactive_time_secs =
978 WMI_10_4_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
979 .ap_keepalive_max_unresponsive_time_secs =
980 WMI_10_4_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
981 .ap_enable_nawds = WMI_10_4_VDEV_PARAM_AP_ENABLE_NAWDS,
982 .mcast2ucast_set = WMI_10_4_VDEV_PARAM_MCAST2UCAST_SET,
983 .enable_rtscts = WMI_10_4_VDEV_PARAM_ENABLE_RTSCTS,
984 .txbf = WMI_10_4_VDEV_PARAM_TXBF,
985 .packet_powersave = WMI_10_4_VDEV_PARAM_PACKET_POWERSAVE,
986 .drop_unencry = WMI_10_4_VDEV_PARAM_DROP_UNENCRY,
987 .tx_encap_type = WMI_10_4_VDEV_PARAM_TX_ENCAP_TYPE,
988 .ap_detect_out_of_sync_sleeping_sta_time_secs =
989 WMI_10_4_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS,
990 .rc_num_retries = WMI_10_4_VDEV_PARAM_RC_NUM_RETRIES,
991 .cabq_maxdur = WMI_10_4_VDEV_PARAM_CABQ_MAXDUR,
992 .mfptest_set = WMI_10_4_VDEV_PARAM_MFPTEST_SET,
993 .rts_fixed_rate = WMI_10_4_VDEV_PARAM_RTS_FIXED_RATE,
994 .vht_sgimask = WMI_10_4_VDEV_PARAM_VHT_SGIMASK,
995 .vht80_ratemask = WMI_10_4_VDEV_PARAM_VHT80_RATEMASK,
996 .early_rx_adjust_enable = WMI_10_4_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
997 .early_rx_tgt_bmiss_num = WMI_10_4_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
998 .early_rx_bmiss_sample_cycle =
999 WMI_10_4_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
1000 .early_rx_slop_step = WMI_10_4_VDEV_PARAM_EARLY_RX_SLOP_STEP,
1001 .early_rx_init_slop = WMI_10_4_VDEV_PARAM_EARLY_RX_INIT_SLOP,
1002 .early_rx_adjust_pause = WMI_10_4_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
1003 .proxy_sta = WMI_10_4_VDEV_PARAM_PROXY_STA,
1004 .meru_vc = WMI_10_4_VDEV_PARAM_MERU_VC,
1005 .rx_decap_type = WMI_10_4_VDEV_PARAM_RX_DECAP_TYPE,
1006 .bw_nss_ratemask = WMI_10_4_VDEV_PARAM_BW_NSS_RATEMASK,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02001007};
1008
Bartosz Markowski226a3392013-09-26 17:47:16 +02001009static struct wmi_pdev_param_map wmi_pdev_param_map = {
1010 .tx_chain_mask = WMI_PDEV_PARAM_TX_CHAIN_MASK,
1011 .rx_chain_mask = WMI_PDEV_PARAM_RX_CHAIN_MASK,
1012 .txpower_limit2g = WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
1013 .txpower_limit5g = WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
1014 .txpower_scale = WMI_PDEV_PARAM_TXPOWER_SCALE,
1015 .beacon_gen_mode = WMI_PDEV_PARAM_BEACON_GEN_MODE,
1016 .beacon_tx_mode = WMI_PDEV_PARAM_BEACON_TX_MODE,
1017 .resmgr_offchan_mode = WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
1018 .protection_mode = WMI_PDEV_PARAM_PROTECTION_MODE,
1019 .dynamic_bw = WMI_PDEV_PARAM_DYNAMIC_BW,
1020 .non_agg_sw_retry_th = WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
1021 .agg_sw_retry_th = WMI_PDEV_PARAM_AGG_SW_RETRY_TH,
1022 .sta_kickout_th = WMI_PDEV_PARAM_STA_KICKOUT_TH,
1023 .ac_aggrsize_scaling = WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING,
1024 .ltr_enable = WMI_PDEV_PARAM_LTR_ENABLE,
1025 .ltr_ac_latency_be = WMI_PDEV_PARAM_LTR_AC_LATENCY_BE,
1026 .ltr_ac_latency_bk = WMI_PDEV_PARAM_LTR_AC_LATENCY_BK,
1027 .ltr_ac_latency_vi = WMI_PDEV_PARAM_LTR_AC_LATENCY_VI,
1028 .ltr_ac_latency_vo = WMI_PDEV_PARAM_LTR_AC_LATENCY_VO,
1029 .ltr_ac_latency_timeout = WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
1030 .ltr_sleep_override = WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
1031 .ltr_rx_override = WMI_PDEV_PARAM_LTR_RX_OVERRIDE,
1032 .ltr_tx_activity_timeout = WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
1033 .l1ss_enable = WMI_PDEV_PARAM_L1SS_ENABLE,
1034 .dsleep_enable = WMI_PDEV_PARAM_DSLEEP_ENABLE,
1035 .pcielp_txbuf_flush = WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH,
1036 .pcielp_txbuf_watermark = WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
1037 .pcielp_txbuf_tmo_en = WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
1038 .pcielp_txbuf_tmo_value = WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE,
1039 .pdev_stats_update_period = WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
1040 .vdev_stats_update_period = WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
1041 .peer_stats_update_period = WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
1042 .bcnflt_stats_update_period = WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
1043 .pmf_qos = WMI_PDEV_PARAM_PMF_QOS,
1044 .arp_ac_override = WMI_PDEV_PARAM_ARP_AC_OVERRIDE,
Bartosz Markowski226a3392013-09-26 17:47:16 +02001045 .dcs = WMI_PDEV_PARAM_DCS,
1046 .ani_enable = WMI_PDEV_PARAM_ANI_ENABLE,
1047 .ani_poll_period = WMI_PDEV_PARAM_ANI_POLL_PERIOD,
1048 .ani_listen_period = WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
1049 .ani_ofdm_level = WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
1050 .ani_cck_level = WMI_PDEV_PARAM_ANI_CCK_LEVEL,
1051 .dyntxchain = WMI_PDEV_PARAM_DYNTXCHAIN,
1052 .proxy_sta = WMI_PDEV_PARAM_PROXY_STA,
1053 .idle_ps_config = WMI_PDEV_PARAM_IDLE_PS_CONFIG,
1054 .power_gating_sleep = WMI_PDEV_PARAM_POWER_GATING_SLEEP,
1055 .fast_channel_reset = WMI_PDEV_PARAM_UNSUPPORTED,
1056 .burst_dur = WMI_PDEV_PARAM_UNSUPPORTED,
1057 .burst_enable = WMI_PDEV_PARAM_UNSUPPORTED,
Peter Oha7bd3e92014-12-02 13:07:14 +02001058 .cal_period = WMI_PDEV_PARAM_UNSUPPORTED,
Raja Manid86561f2015-06-22 20:10:14 +05301059 .aggr_burst = WMI_PDEV_PARAM_UNSUPPORTED,
1060 .rx_decap_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1061 .smart_antenna_default_antenna = WMI_PDEV_PARAM_UNSUPPORTED,
1062 .igmpmld_override = WMI_PDEV_PARAM_UNSUPPORTED,
1063 .igmpmld_tid = WMI_PDEV_PARAM_UNSUPPORTED,
1064 .antenna_gain = WMI_PDEV_PARAM_UNSUPPORTED,
1065 .rx_filter = WMI_PDEV_PARAM_UNSUPPORTED,
1066 .set_mcast_to_ucast_tid = WMI_PDEV_PARAM_UNSUPPORTED,
1067 .proxy_sta_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1068 .set_mcast2ucast_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1069 .set_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
1070 .remove_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
1071 .peer_sta_ps_statechg_enable = WMI_PDEV_PARAM_UNSUPPORTED,
1072 .igmpmld_ac_override = WMI_PDEV_PARAM_UNSUPPORTED,
1073 .block_interbss = WMI_PDEV_PARAM_UNSUPPORTED,
1074 .set_disable_reset_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1075 .set_msdu_ttl_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1076 .set_ppdu_duration_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1077 .txbf_sound_period_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1078 .set_promisc_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1079 .set_burst_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1080 .en_stats = WMI_PDEV_PARAM_UNSUPPORTED,
1081 .mu_group_policy = WMI_PDEV_PARAM_UNSUPPORTED,
1082 .noise_detection = WMI_PDEV_PARAM_UNSUPPORTED,
1083 .noise_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
1084 .dpd_enable = WMI_PDEV_PARAM_UNSUPPORTED,
1085 .set_mcast_bcast_echo = WMI_PDEV_PARAM_UNSUPPORTED,
1086 .atf_strict_sch = WMI_PDEV_PARAM_UNSUPPORTED,
1087 .atf_sched_duration = WMI_PDEV_PARAM_UNSUPPORTED,
1088 .ant_plzn = WMI_PDEV_PARAM_UNSUPPORTED,
1089 .mgmt_retry_limit = WMI_PDEV_PARAM_UNSUPPORTED,
1090 .sensitivity_level = WMI_PDEV_PARAM_UNSUPPORTED,
1091 .signed_txpower_2g = WMI_PDEV_PARAM_UNSUPPORTED,
1092 .signed_txpower_5g = WMI_PDEV_PARAM_UNSUPPORTED,
1093 .enable_per_tid_amsdu = WMI_PDEV_PARAM_UNSUPPORTED,
1094 .enable_per_tid_ampdu = WMI_PDEV_PARAM_UNSUPPORTED,
1095 .cca_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
1096 .rts_fixed_rate = WMI_PDEV_PARAM_UNSUPPORTED,
1097 .pdev_reset = WMI_PDEV_PARAM_UNSUPPORTED,
1098 .wapi_mbssid_offset = WMI_PDEV_PARAM_UNSUPPORTED,
1099 .arp_srcaddr = WMI_PDEV_PARAM_UNSUPPORTED,
1100 .arp_dstaddr = WMI_PDEV_PARAM_UNSUPPORTED,
Bartosz Markowski226a3392013-09-26 17:47:16 +02001101};
1102
1103static struct wmi_pdev_param_map wmi_10x_pdev_param_map = {
1104 .tx_chain_mask = WMI_10X_PDEV_PARAM_TX_CHAIN_MASK,
1105 .rx_chain_mask = WMI_10X_PDEV_PARAM_RX_CHAIN_MASK,
1106 .txpower_limit2g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT2G,
1107 .txpower_limit5g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT5G,
1108 .txpower_scale = WMI_10X_PDEV_PARAM_TXPOWER_SCALE,
1109 .beacon_gen_mode = WMI_10X_PDEV_PARAM_BEACON_GEN_MODE,
1110 .beacon_tx_mode = WMI_10X_PDEV_PARAM_BEACON_TX_MODE,
1111 .resmgr_offchan_mode = WMI_10X_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
1112 .protection_mode = WMI_10X_PDEV_PARAM_PROTECTION_MODE,
1113 .dynamic_bw = WMI_10X_PDEV_PARAM_DYNAMIC_BW,
1114 .non_agg_sw_retry_th = WMI_10X_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
1115 .agg_sw_retry_th = WMI_10X_PDEV_PARAM_AGG_SW_RETRY_TH,
1116 .sta_kickout_th = WMI_10X_PDEV_PARAM_STA_KICKOUT_TH,
1117 .ac_aggrsize_scaling = WMI_10X_PDEV_PARAM_AC_AGGRSIZE_SCALING,
1118 .ltr_enable = WMI_10X_PDEV_PARAM_LTR_ENABLE,
1119 .ltr_ac_latency_be = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BE,
1120 .ltr_ac_latency_bk = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BK,
1121 .ltr_ac_latency_vi = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VI,
1122 .ltr_ac_latency_vo = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VO,
1123 .ltr_ac_latency_timeout = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
1124 .ltr_sleep_override = WMI_10X_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
1125 .ltr_rx_override = WMI_10X_PDEV_PARAM_LTR_RX_OVERRIDE,
1126 .ltr_tx_activity_timeout = WMI_10X_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
1127 .l1ss_enable = WMI_10X_PDEV_PARAM_L1SS_ENABLE,
1128 .dsleep_enable = WMI_10X_PDEV_PARAM_DSLEEP_ENABLE,
1129 .pcielp_txbuf_flush = WMI_PDEV_PARAM_UNSUPPORTED,
1130 .pcielp_txbuf_watermark = WMI_PDEV_PARAM_UNSUPPORTED,
1131 .pcielp_txbuf_tmo_en = WMI_PDEV_PARAM_UNSUPPORTED,
1132 .pcielp_txbuf_tmo_value = WMI_PDEV_PARAM_UNSUPPORTED,
1133 .pdev_stats_update_period = WMI_10X_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
1134 .vdev_stats_update_period = WMI_10X_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
1135 .peer_stats_update_period = WMI_10X_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
1136 .bcnflt_stats_update_period =
1137 WMI_10X_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
1138 .pmf_qos = WMI_10X_PDEV_PARAM_PMF_QOS,
Marek Puzyniakab6258e2014-01-29 15:03:31 +02001139 .arp_ac_override = WMI_10X_PDEV_PARAM_ARPDHCP_AC_OVERRIDE,
Bartosz Markowski226a3392013-09-26 17:47:16 +02001140 .dcs = WMI_10X_PDEV_PARAM_DCS,
1141 .ani_enable = WMI_10X_PDEV_PARAM_ANI_ENABLE,
1142 .ani_poll_period = WMI_10X_PDEV_PARAM_ANI_POLL_PERIOD,
1143 .ani_listen_period = WMI_10X_PDEV_PARAM_ANI_LISTEN_PERIOD,
1144 .ani_ofdm_level = WMI_10X_PDEV_PARAM_ANI_OFDM_LEVEL,
1145 .ani_cck_level = WMI_10X_PDEV_PARAM_ANI_CCK_LEVEL,
1146 .dyntxchain = WMI_10X_PDEV_PARAM_DYNTXCHAIN,
1147 .proxy_sta = WMI_PDEV_PARAM_UNSUPPORTED,
1148 .idle_ps_config = WMI_PDEV_PARAM_UNSUPPORTED,
1149 .power_gating_sleep = WMI_PDEV_PARAM_UNSUPPORTED,
1150 .fast_channel_reset = WMI_10X_PDEV_PARAM_FAST_CHANNEL_RESET,
1151 .burst_dur = WMI_10X_PDEV_PARAM_BURST_DUR,
1152 .burst_enable = WMI_10X_PDEV_PARAM_BURST_ENABLE,
Peter Oha7bd3e92014-12-02 13:07:14 +02001153 .cal_period = WMI_10X_PDEV_PARAM_CAL_PERIOD,
Raja Manid86561f2015-06-22 20:10:14 +05301154 .aggr_burst = WMI_PDEV_PARAM_UNSUPPORTED,
1155 .rx_decap_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1156 .smart_antenna_default_antenna = WMI_PDEV_PARAM_UNSUPPORTED,
1157 .igmpmld_override = WMI_PDEV_PARAM_UNSUPPORTED,
1158 .igmpmld_tid = WMI_PDEV_PARAM_UNSUPPORTED,
1159 .antenna_gain = WMI_PDEV_PARAM_UNSUPPORTED,
1160 .rx_filter = WMI_PDEV_PARAM_UNSUPPORTED,
1161 .set_mcast_to_ucast_tid = WMI_PDEV_PARAM_UNSUPPORTED,
1162 .proxy_sta_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1163 .set_mcast2ucast_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1164 .set_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
1165 .remove_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
1166 .peer_sta_ps_statechg_enable = WMI_PDEV_PARAM_UNSUPPORTED,
1167 .igmpmld_ac_override = WMI_PDEV_PARAM_UNSUPPORTED,
1168 .block_interbss = WMI_PDEV_PARAM_UNSUPPORTED,
1169 .set_disable_reset_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1170 .set_msdu_ttl_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1171 .set_ppdu_duration_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1172 .txbf_sound_period_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1173 .set_promisc_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1174 .set_burst_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1175 .en_stats = WMI_PDEV_PARAM_UNSUPPORTED,
1176 .mu_group_policy = WMI_PDEV_PARAM_UNSUPPORTED,
1177 .noise_detection = WMI_PDEV_PARAM_UNSUPPORTED,
1178 .noise_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
1179 .dpd_enable = WMI_PDEV_PARAM_UNSUPPORTED,
1180 .set_mcast_bcast_echo = WMI_PDEV_PARAM_UNSUPPORTED,
1181 .atf_strict_sch = WMI_PDEV_PARAM_UNSUPPORTED,
1182 .atf_sched_duration = WMI_PDEV_PARAM_UNSUPPORTED,
1183 .ant_plzn = WMI_PDEV_PARAM_UNSUPPORTED,
1184 .mgmt_retry_limit = WMI_PDEV_PARAM_UNSUPPORTED,
1185 .sensitivity_level = WMI_PDEV_PARAM_UNSUPPORTED,
1186 .signed_txpower_2g = WMI_PDEV_PARAM_UNSUPPORTED,
1187 .signed_txpower_5g = WMI_PDEV_PARAM_UNSUPPORTED,
1188 .enable_per_tid_amsdu = WMI_PDEV_PARAM_UNSUPPORTED,
1189 .enable_per_tid_ampdu = WMI_PDEV_PARAM_UNSUPPORTED,
1190 .cca_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
1191 .rts_fixed_rate = WMI_PDEV_PARAM_UNSUPPORTED,
1192 .pdev_reset = WMI_PDEV_PARAM_UNSUPPORTED,
1193 .wapi_mbssid_offset = WMI_PDEV_PARAM_UNSUPPORTED,
1194 .arp_srcaddr = WMI_PDEV_PARAM_UNSUPPORTED,
1195 .arp_dstaddr = WMI_PDEV_PARAM_UNSUPPORTED,
Bartosz Markowski226a3392013-09-26 17:47:16 +02001196};
1197
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02001198static struct wmi_pdev_param_map wmi_10_2_4_pdev_param_map = {
1199 .tx_chain_mask = WMI_10X_PDEV_PARAM_TX_CHAIN_MASK,
1200 .rx_chain_mask = WMI_10X_PDEV_PARAM_RX_CHAIN_MASK,
1201 .txpower_limit2g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT2G,
1202 .txpower_limit5g = WMI_10X_PDEV_PARAM_TXPOWER_LIMIT5G,
1203 .txpower_scale = WMI_10X_PDEV_PARAM_TXPOWER_SCALE,
1204 .beacon_gen_mode = WMI_10X_PDEV_PARAM_BEACON_GEN_MODE,
1205 .beacon_tx_mode = WMI_10X_PDEV_PARAM_BEACON_TX_MODE,
1206 .resmgr_offchan_mode = WMI_10X_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
1207 .protection_mode = WMI_10X_PDEV_PARAM_PROTECTION_MODE,
1208 .dynamic_bw = WMI_10X_PDEV_PARAM_DYNAMIC_BW,
1209 .non_agg_sw_retry_th = WMI_10X_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
1210 .agg_sw_retry_th = WMI_10X_PDEV_PARAM_AGG_SW_RETRY_TH,
1211 .sta_kickout_th = WMI_10X_PDEV_PARAM_STA_KICKOUT_TH,
1212 .ac_aggrsize_scaling = WMI_10X_PDEV_PARAM_AC_AGGRSIZE_SCALING,
1213 .ltr_enable = WMI_10X_PDEV_PARAM_LTR_ENABLE,
1214 .ltr_ac_latency_be = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BE,
1215 .ltr_ac_latency_bk = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BK,
1216 .ltr_ac_latency_vi = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VI,
1217 .ltr_ac_latency_vo = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VO,
1218 .ltr_ac_latency_timeout = WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
1219 .ltr_sleep_override = WMI_10X_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
1220 .ltr_rx_override = WMI_10X_PDEV_PARAM_LTR_RX_OVERRIDE,
1221 .ltr_tx_activity_timeout = WMI_10X_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
1222 .l1ss_enable = WMI_10X_PDEV_PARAM_L1SS_ENABLE,
1223 .dsleep_enable = WMI_10X_PDEV_PARAM_DSLEEP_ENABLE,
1224 .pcielp_txbuf_flush = WMI_PDEV_PARAM_UNSUPPORTED,
1225 .pcielp_txbuf_watermark = WMI_PDEV_PARAM_UNSUPPORTED,
1226 .pcielp_txbuf_tmo_en = WMI_PDEV_PARAM_UNSUPPORTED,
1227 .pcielp_txbuf_tmo_value = WMI_PDEV_PARAM_UNSUPPORTED,
1228 .pdev_stats_update_period = WMI_10X_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
1229 .vdev_stats_update_period = WMI_10X_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
1230 .peer_stats_update_period = WMI_10X_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
1231 .bcnflt_stats_update_period =
1232 WMI_10X_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
1233 .pmf_qos = WMI_10X_PDEV_PARAM_PMF_QOS,
1234 .arp_ac_override = WMI_10X_PDEV_PARAM_ARPDHCP_AC_OVERRIDE,
1235 .dcs = WMI_10X_PDEV_PARAM_DCS,
1236 .ani_enable = WMI_10X_PDEV_PARAM_ANI_ENABLE,
1237 .ani_poll_period = WMI_10X_PDEV_PARAM_ANI_POLL_PERIOD,
1238 .ani_listen_period = WMI_10X_PDEV_PARAM_ANI_LISTEN_PERIOD,
1239 .ani_ofdm_level = WMI_10X_PDEV_PARAM_ANI_OFDM_LEVEL,
1240 .ani_cck_level = WMI_10X_PDEV_PARAM_ANI_CCK_LEVEL,
1241 .dyntxchain = WMI_10X_PDEV_PARAM_DYNTXCHAIN,
1242 .proxy_sta = WMI_PDEV_PARAM_UNSUPPORTED,
1243 .idle_ps_config = WMI_PDEV_PARAM_UNSUPPORTED,
1244 .power_gating_sleep = WMI_PDEV_PARAM_UNSUPPORTED,
1245 .fast_channel_reset = WMI_10X_PDEV_PARAM_FAST_CHANNEL_RESET,
1246 .burst_dur = WMI_10X_PDEV_PARAM_BURST_DUR,
1247 .burst_enable = WMI_10X_PDEV_PARAM_BURST_ENABLE,
1248 .cal_period = WMI_10X_PDEV_PARAM_CAL_PERIOD,
Raja Manid86561f2015-06-22 20:10:14 +05301249 .aggr_burst = WMI_PDEV_PARAM_UNSUPPORTED,
1250 .rx_decap_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1251 .smart_antenna_default_antenna = WMI_PDEV_PARAM_UNSUPPORTED,
1252 .igmpmld_override = WMI_PDEV_PARAM_UNSUPPORTED,
1253 .igmpmld_tid = WMI_PDEV_PARAM_UNSUPPORTED,
1254 .antenna_gain = WMI_PDEV_PARAM_UNSUPPORTED,
1255 .rx_filter = WMI_PDEV_PARAM_UNSUPPORTED,
1256 .set_mcast_to_ucast_tid = WMI_PDEV_PARAM_UNSUPPORTED,
1257 .proxy_sta_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1258 .set_mcast2ucast_mode = WMI_PDEV_PARAM_UNSUPPORTED,
1259 .set_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
1260 .remove_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
1261 .peer_sta_ps_statechg_enable = WMI_PDEV_PARAM_UNSUPPORTED,
1262 .igmpmld_ac_override = WMI_PDEV_PARAM_UNSUPPORTED,
1263 .block_interbss = WMI_PDEV_PARAM_UNSUPPORTED,
1264 .set_disable_reset_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1265 .set_msdu_ttl_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1266 .set_ppdu_duration_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1267 .txbf_sound_period_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1268 .set_promisc_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1269 .set_burst_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
1270 .en_stats = WMI_PDEV_PARAM_UNSUPPORTED,
1271 .mu_group_policy = WMI_PDEV_PARAM_UNSUPPORTED,
1272 .noise_detection = WMI_PDEV_PARAM_UNSUPPORTED,
1273 .noise_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
1274 .dpd_enable = WMI_PDEV_PARAM_UNSUPPORTED,
1275 .set_mcast_bcast_echo = WMI_PDEV_PARAM_UNSUPPORTED,
1276 .atf_strict_sch = WMI_PDEV_PARAM_UNSUPPORTED,
1277 .atf_sched_duration = WMI_PDEV_PARAM_UNSUPPORTED,
1278 .ant_plzn = WMI_PDEV_PARAM_UNSUPPORTED,
1279 .mgmt_retry_limit = WMI_PDEV_PARAM_UNSUPPORTED,
1280 .sensitivity_level = WMI_PDEV_PARAM_UNSUPPORTED,
1281 .signed_txpower_2g = WMI_PDEV_PARAM_UNSUPPORTED,
1282 .signed_txpower_5g = WMI_PDEV_PARAM_UNSUPPORTED,
1283 .enable_per_tid_amsdu = WMI_PDEV_PARAM_UNSUPPORTED,
1284 .enable_per_tid_ampdu = WMI_PDEV_PARAM_UNSUPPORTED,
1285 .cca_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
1286 .rts_fixed_rate = WMI_PDEV_PARAM_UNSUPPORTED,
1287 .pdev_reset = WMI_PDEV_PARAM_UNSUPPORTED,
1288 .wapi_mbssid_offset = WMI_PDEV_PARAM_UNSUPPORTED,
1289 .arp_srcaddr = WMI_PDEV_PARAM_UNSUPPORTED,
1290 .arp_dstaddr = WMI_PDEV_PARAM_UNSUPPORTED,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02001291};
1292
Michal Kazior24c88f72014-07-25 13:32:17 +02001293/* firmware 10.2 specific mappings */
1294static struct wmi_cmd_map wmi_10_2_cmd_map = {
1295 .init_cmdid = WMI_10_2_INIT_CMDID,
1296 .start_scan_cmdid = WMI_10_2_START_SCAN_CMDID,
1297 .stop_scan_cmdid = WMI_10_2_STOP_SCAN_CMDID,
1298 .scan_chan_list_cmdid = WMI_10_2_SCAN_CHAN_LIST_CMDID,
1299 .scan_sch_prio_tbl_cmdid = WMI_CMD_UNSUPPORTED,
1300 .pdev_set_regdomain_cmdid = WMI_10_2_PDEV_SET_REGDOMAIN_CMDID,
1301 .pdev_set_channel_cmdid = WMI_10_2_PDEV_SET_CHANNEL_CMDID,
1302 .pdev_set_param_cmdid = WMI_10_2_PDEV_SET_PARAM_CMDID,
1303 .pdev_pktlog_enable_cmdid = WMI_10_2_PDEV_PKTLOG_ENABLE_CMDID,
1304 .pdev_pktlog_disable_cmdid = WMI_10_2_PDEV_PKTLOG_DISABLE_CMDID,
1305 .pdev_set_wmm_params_cmdid = WMI_10_2_PDEV_SET_WMM_PARAMS_CMDID,
1306 .pdev_set_ht_cap_ie_cmdid = WMI_10_2_PDEV_SET_HT_CAP_IE_CMDID,
1307 .pdev_set_vht_cap_ie_cmdid = WMI_10_2_PDEV_SET_VHT_CAP_IE_CMDID,
1308 .pdev_set_quiet_mode_cmdid = WMI_10_2_PDEV_SET_QUIET_MODE_CMDID,
1309 .pdev_green_ap_ps_enable_cmdid = WMI_10_2_PDEV_GREEN_AP_PS_ENABLE_CMDID,
1310 .pdev_get_tpc_config_cmdid = WMI_10_2_PDEV_GET_TPC_CONFIG_CMDID,
1311 .pdev_set_base_macaddr_cmdid = WMI_10_2_PDEV_SET_BASE_MACADDR_CMDID,
1312 .vdev_create_cmdid = WMI_10_2_VDEV_CREATE_CMDID,
1313 .vdev_delete_cmdid = WMI_10_2_VDEV_DELETE_CMDID,
1314 .vdev_start_request_cmdid = WMI_10_2_VDEV_START_REQUEST_CMDID,
1315 .vdev_restart_request_cmdid = WMI_10_2_VDEV_RESTART_REQUEST_CMDID,
1316 .vdev_up_cmdid = WMI_10_2_VDEV_UP_CMDID,
1317 .vdev_stop_cmdid = WMI_10_2_VDEV_STOP_CMDID,
1318 .vdev_down_cmdid = WMI_10_2_VDEV_DOWN_CMDID,
1319 .vdev_set_param_cmdid = WMI_10_2_VDEV_SET_PARAM_CMDID,
1320 .vdev_install_key_cmdid = WMI_10_2_VDEV_INSTALL_KEY_CMDID,
1321 .peer_create_cmdid = WMI_10_2_PEER_CREATE_CMDID,
1322 .peer_delete_cmdid = WMI_10_2_PEER_DELETE_CMDID,
1323 .peer_flush_tids_cmdid = WMI_10_2_PEER_FLUSH_TIDS_CMDID,
1324 .peer_set_param_cmdid = WMI_10_2_PEER_SET_PARAM_CMDID,
1325 .peer_assoc_cmdid = WMI_10_2_PEER_ASSOC_CMDID,
1326 .peer_add_wds_entry_cmdid = WMI_10_2_PEER_ADD_WDS_ENTRY_CMDID,
1327 .peer_remove_wds_entry_cmdid = WMI_10_2_PEER_REMOVE_WDS_ENTRY_CMDID,
1328 .peer_mcast_group_cmdid = WMI_10_2_PEER_MCAST_GROUP_CMDID,
1329 .bcn_tx_cmdid = WMI_10_2_BCN_TX_CMDID,
1330 .pdev_send_bcn_cmdid = WMI_10_2_PDEV_SEND_BCN_CMDID,
1331 .bcn_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
1332 .bcn_filter_rx_cmdid = WMI_10_2_BCN_FILTER_RX_CMDID,
1333 .prb_req_filter_rx_cmdid = WMI_10_2_PRB_REQ_FILTER_RX_CMDID,
1334 .mgmt_tx_cmdid = WMI_10_2_MGMT_TX_CMDID,
1335 .prb_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
1336 .addba_clear_resp_cmdid = WMI_10_2_ADDBA_CLEAR_RESP_CMDID,
1337 .addba_send_cmdid = WMI_10_2_ADDBA_SEND_CMDID,
1338 .addba_status_cmdid = WMI_10_2_ADDBA_STATUS_CMDID,
1339 .delba_send_cmdid = WMI_10_2_DELBA_SEND_CMDID,
1340 .addba_set_resp_cmdid = WMI_10_2_ADDBA_SET_RESP_CMDID,
1341 .send_singleamsdu_cmdid = WMI_10_2_SEND_SINGLEAMSDU_CMDID,
1342 .sta_powersave_mode_cmdid = WMI_10_2_STA_POWERSAVE_MODE_CMDID,
1343 .sta_powersave_param_cmdid = WMI_10_2_STA_POWERSAVE_PARAM_CMDID,
1344 .sta_mimo_ps_mode_cmdid = WMI_10_2_STA_MIMO_PS_MODE_CMDID,
1345 .pdev_dfs_enable_cmdid = WMI_10_2_PDEV_DFS_ENABLE_CMDID,
1346 .pdev_dfs_disable_cmdid = WMI_10_2_PDEV_DFS_DISABLE_CMDID,
1347 .roam_scan_mode = WMI_10_2_ROAM_SCAN_MODE,
1348 .roam_scan_rssi_threshold = WMI_10_2_ROAM_SCAN_RSSI_THRESHOLD,
1349 .roam_scan_period = WMI_10_2_ROAM_SCAN_PERIOD,
1350 .roam_scan_rssi_change_threshold =
1351 WMI_10_2_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
1352 .roam_ap_profile = WMI_10_2_ROAM_AP_PROFILE,
1353 .ofl_scan_add_ap_profile = WMI_10_2_OFL_SCAN_ADD_AP_PROFILE,
1354 .ofl_scan_remove_ap_profile = WMI_10_2_OFL_SCAN_REMOVE_AP_PROFILE,
1355 .ofl_scan_period = WMI_10_2_OFL_SCAN_PERIOD,
1356 .p2p_dev_set_device_info = WMI_10_2_P2P_DEV_SET_DEVICE_INFO,
1357 .p2p_dev_set_discoverability = WMI_10_2_P2P_DEV_SET_DISCOVERABILITY,
1358 .p2p_go_set_beacon_ie = WMI_10_2_P2P_GO_SET_BEACON_IE,
1359 .p2p_go_set_probe_resp_ie = WMI_10_2_P2P_GO_SET_PROBE_RESP_IE,
1360 .p2p_set_vendor_ie_data_cmdid = WMI_CMD_UNSUPPORTED,
1361 .ap_ps_peer_param_cmdid = WMI_10_2_AP_PS_PEER_PARAM_CMDID,
1362 .ap_ps_peer_uapsd_coex_cmdid = WMI_CMD_UNSUPPORTED,
1363 .peer_rate_retry_sched_cmdid = WMI_10_2_PEER_RATE_RETRY_SCHED_CMDID,
1364 .wlan_profile_trigger_cmdid = WMI_10_2_WLAN_PROFILE_TRIGGER_CMDID,
1365 .wlan_profile_set_hist_intvl_cmdid =
1366 WMI_10_2_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
1367 .wlan_profile_get_profile_data_cmdid =
1368 WMI_10_2_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
1369 .wlan_profile_enable_profile_id_cmdid =
1370 WMI_10_2_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
1371 .wlan_profile_list_profile_id_cmdid =
1372 WMI_10_2_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
1373 .pdev_suspend_cmdid = WMI_10_2_PDEV_SUSPEND_CMDID,
1374 .pdev_resume_cmdid = WMI_10_2_PDEV_RESUME_CMDID,
1375 .add_bcn_filter_cmdid = WMI_10_2_ADD_BCN_FILTER_CMDID,
1376 .rmv_bcn_filter_cmdid = WMI_10_2_RMV_BCN_FILTER_CMDID,
1377 .wow_add_wake_pattern_cmdid = WMI_10_2_WOW_ADD_WAKE_PATTERN_CMDID,
1378 .wow_del_wake_pattern_cmdid = WMI_10_2_WOW_DEL_WAKE_PATTERN_CMDID,
1379 .wow_enable_disable_wake_event_cmdid =
1380 WMI_10_2_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
1381 .wow_enable_cmdid = WMI_10_2_WOW_ENABLE_CMDID,
1382 .wow_hostwakeup_from_sleep_cmdid =
1383 WMI_10_2_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
1384 .rtt_measreq_cmdid = WMI_10_2_RTT_MEASREQ_CMDID,
1385 .rtt_tsf_cmdid = WMI_10_2_RTT_TSF_CMDID,
1386 .vdev_spectral_scan_configure_cmdid =
1387 WMI_10_2_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID,
1388 .vdev_spectral_scan_enable_cmdid =
1389 WMI_10_2_VDEV_SPECTRAL_SCAN_ENABLE_CMDID,
1390 .request_stats_cmdid = WMI_10_2_REQUEST_STATS_CMDID,
1391 .set_arp_ns_offload_cmdid = WMI_CMD_UNSUPPORTED,
1392 .network_list_offload_config_cmdid = WMI_CMD_UNSUPPORTED,
1393 .gtk_offload_cmdid = WMI_CMD_UNSUPPORTED,
1394 .csa_offload_enable_cmdid = WMI_CMD_UNSUPPORTED,
1395 .csa_offload_chanswitch_cmdid = WMI_CMD_UNSUPPORTED,
1396 .chatter_set_mode_cmdid = WMI_CMD_UNSUPPORTED,
1397 .peer_tid_addba_cmdid = WMI_CMD_UNSUPPORTED,
1398 .peer_tid_delba_cmdid = WMI_CMD_UNSUPPORTED,
1399 .sta_dtim_ps_method_cmdid = WMI_CMD_UNSUPPORTED,
1400 .sta_uapsd_auto_trig_cmdid = WMI_CMD_UNSUPPORTED,
1401 .sta_keepalive_cmd = WMI_CMD_UNSUPPORTED,
1402 .echo_cmdid = WMI_10_2_ECHO_CMDID,
1403 .pdev_utf_cmdid = WMI_10_2_PDEV_UTF_CMDID,
1404 .dbglog_cfg_cmdid = WMI_10_2_DBGLOG_CFG_CMDID,
1405 .pdev_qvit_cmdid = WMI_10_2_PDEV_QVIT_CMDID,
1406 .pdev_ftm_intg_cmdid = WMI_CMD_UNSUPPORTED,
1407 .vdev_set_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
1408 .vdev_get_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
1409 .force_fw_hang_cmdid = WMI_CMD_UNSUPPORTED,
1410 .gpio_config_cmdid = WMI_10_2_GPIO_CONFIG_CMDID,
1411 .gpio_output_cmdid = WMI_10_2_GPIO_OUTPUT_CMDID,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02001412 .pdev_get_temperature_cmdid = WMI_CMD_UNSUPPORTED,
Maharaja62f77f02015-10-21 11:49:18 +03001413 .pdev_enable_adaptive_cca_cmdid = WMI_CMD_UNSUPPORTED,
Raja Mani772b4ae2015-06-22 20:10:12 +05301414 .scan_update_request_cmdid = WMI_CMD_UNSUPPORTED,
1415 .vdev_standby_response_cmdid = WMI_CMD_UNSUPPORTED,
1416 .vdev_resume_response_cmdid = WMI_CMD_UNSUPPORTED,
1417 .wlan_peer_caching_add_peer_cmdid = WMI_CMD_UNSUPPORTED,
1418 .wlan_peer_caching_evict_peer_cmdid = WMI_CMD_UNSUPPORTED,
1419 .wlan_peer_caching_restore_peer_cmdid = WMI_CMD_UNSUPPORTED,
1420 .wlan_peer_caching_print_all_peers_info_cmdid = WMI_CMD_UNSUPPORTED,
1421 .peer_update_wds_entry_cmdid = WMI_CMD_UNSUPPORTED,
1422 .peer_add_proxy_sta_entry_cmdid = WMI_CMD_UNSUPPORTED,
1423 .rtt_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
1424 .oem_req_cmdid = WMI_CMD_UNSUPPORTED,
1425 .nan_cmdid = WMI_CMD_UNSUPPORTED,
1426 .vdev_ratemask_cmdid = WMI_CMD_UNSUPPORTED,
1427 .qboost_cfg_cmdid = WMI_CMD_UNSUPPORTED,
1428 .pdev_smart_ant_enable_cmdid = WMI_CMD_UNSUPPORTED,
1429 .pdev_smart_ant_set_rx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
1430 .peer_smart_ant_set_tx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
1431 .peer_smart_ant_set_train_info_cmdid = WMI_CMD_UNSUPPORTED,
1432 .peer_smart_ant_set_node_config_ops_cmdid = WMI_CMD_UNSUPPORTED,
1433 .pdev_set_antenna_switch_table_cmdid = WMI_CMD_UNSUPPORTED,
1434 .pdev_set_ctl_table_cmdid = WMI_CMD_UNSUPPORTED,
1435 .pdev_set_mimogain_table_cmdid = WMI_CMD_UNSUPPORTED,
1436 .pdev_ratepwr_table_cmdid = WMI_CMD_UNSUPPORTED,
1437 .pdev_ratepwr_chainmsk_table_cmdid = WMI_CMD_UNSUPPORTED,
1438 .pdev_fips_cmdid = WMI_CMD_UNSUPPORTED,
1439 .tt_set_conf_cmdid = WMI_CMD_UNSUPPORTED,
1440 .fwtest_cmdid = WMI_CMD_UNSUPPORTED,
1441 .vdev_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
1442 .peer_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
1443 .pdev_get_ani_cck_config_cmdid = WMI_CMD_UNSUPPORTED,
1444 .pdev_get_ani_ofdm_config_cmdid = WMI_CMD_UNSUPPORTED,
1445 .pdev_reserve_ast_entry_cmdid = WMI_CMD_UNSUPPORTED,
Michal Kazior24c88f72014-07-25 13:32:17 +02001446};
1447
Raja Manid86561f2015-06-22 20:10:14 +05301448static struct wmi_pdev_param_map wmi_10_4_pdev_param_map = {
1449 .tx_chain_mask = WMI_10_4_PDEV_PARAM_TX_CHAIN_MASK,
1450 .rx_chain_mask = WMI_10_4_PDEV_PARAM_RX_CHAIN_MASK,
1451 .txpower_limit2g = WMI_10_4_PDEV_PARAM_TXPOWER_LIMIT2G,
1452 .txpower_limit5g = WMI_10_4_PDEV_PARAM_TXPOWER_LIMIT5G,
1453 .txpower_scale = WMI_10_4_PDEV_PARAM_TXPOWER_SCALE,
1454 .beacon_gen_mode = WMI_10_4_PDEV_PARAM_BEACON_GEN_MODE,
1455 .beacon_tx_mode = WMI_10_4_PDEV_PARAM_BEACON_TX_MODE,
1456 .resmgr_offchan_mode = WMI_10_4_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
1457 .protection_mode = WMI_10_4_PDEV_PARAM_PROTECTION_MODE,
1458 .dynamic_bw = WMI_10_4_PDEV_PARAM_DYNAMIC_BW,
1459 .non_agg_sw_retry_th = WMI_10_4_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
1460 .agg_sw_retry_th = WMI_10_4_PDEV_PARAM_AGG_SW_RETRY_TH,
1461 .sta_kickout_th = WMI_10_4_PDEV_PARAM_STA_KICKOUT_TH,
1462 .ac_aggrsize_scaling = WMI_10_4_PDEV_PARAM_AC_AGGRSIZE_SCALING,
1463 .ltr_enable = WMI_10_4_PDEV_PARAM_LTR_ENABLE,
1464 .ltr_ac_latency_be = WMI_10_4_PDEV_PARAM_LTR_AC_LATENCY_BE,
1465 .ltr_ac_latency_bk = WMI_10_4_PDEV_PARAM_LTR_AC_LATENCY_BK,
1466 .ltr_ac_latency_vi = WMI_10_4_PDEV_PARAM_LTR_AC_LATENCY_VI,
1467 .ltr_ac_latency_vo = WMI_10_4_PDEV_PARAM_LTR_AC_LATENCY_VO,
1468 .ltr_ac_latency_timeout = WMI_10_4_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
1469 .ltr_sleep_override = WMI_10_4_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
1470 .ltr_rx_override = WMI_10_4_PDEV_PARAM_LTR_RX_OVERRIDE,
1471 .ltr_tx_activity_timeout = WMI_10_4_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
1472 .l1ss_enable = WMI_10_4_PDEV_PARAM_L1SS_ENABLE,
1473 .dsleep_enable = WMI_10_4_PDEV_PARAM_DSLEEP_ENABLE,
1474 .pcielp_txbuf_flush = WMI_10_4_PDEV_PARAM_PCIELP_TXBUF_FLUSH,
1475 .pcielp_txbuf_watermark = WMI_10_4_PDEV_PARAM_PCIELP_TXBUF_WATERMARK,
1476 .pcielp_txbuf_tmo_en = WMI_10_4_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
1477 .pcielp_txbuf_tmo_value = WMI_10_4_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE,
1478 .pdev_stats_update_period =
1479 WMI_10_4_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
1480 .vdev_stats_update_period =
1481 WMI_10_4_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
1482 .peer_stats_update_period =
1483 WMI_10_4_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
1484 .bcnflt_stats_update_period =
1485 WMI_10_4_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
1486 .pmf_qos = WMI_10_4_PDEV_PARAM_PMF_QOS,
1487 .arp_ac_override = WMI_10_4_PDEV_PARAM_ARP_AC_OVERRIDE,
1488 .dcs = WMI_10_4_PDEV_PARAM_DCS,
1489 .ani_enable = WMI_10_4_PDEV_PARAM_ANI_ENABLE,
1490 .ani_poll_period = WMI_10_4_PDEV_PARAM_ANI_POLL_PERIOD,
1491 .ani_listen_period = WMI_10_4_PDEV_PARAM_ANI_LISTEN_PERIOD,
1492 .ani_ofdm_level = WMI_10_4_PDEV_PARAM_ANI_OFDM_LEVEL,
1493 .ani_cck_level = WMI_10_4_PDEV_PARAM_ANI_CCK_LEVEL,
1494 .dyntxchain = WMI_10_4_PDEV_PARAM_DYNTXCHAIN,
1495 .proxy_sta = WMI_10_4_PDEV_PARAM_PROXY_STA,
1496 .idle_ps_config = WMI_10_4_PDEV_PARAM_IDLE_PS_CONFIG,
1497 .power_gating_sleep = WMI_10_4_PDEV_PARAM_POWER_GATING_SLEEP,
1498 .fast_channel_reset = WMI_10_4_PDEV_PARAM_FAST_CHANNEL_RESET,
1499 .burst_dur = WMI_10_4_PDEV_PARAM_BURST_DUR,
1500 .burst_enable = WMI_10_4_PDEV_PARAM_BURST_ENABLE,
1501 .cal_period = WMI_10_4_PDEV_PARAM_CAL_PERIOD,
1502 .aggr_burst = WMI_10_4_PDEV_PARAM_AGGR_BURST,
1503 .rx_decap_mode = WMI_10_4_PDEV_PARAM_RX_DECAP_MODE,
1504 .smart_antenna_default_antenna =
1505 WMI_10_4_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA,
1506 .igmpmld_override = WMI_10_4_PDEV_PARAM_IGMPMLD_OVERRIDE,
1507 .igmpmld_tid = WMI_10_4_PDEV_PARAM_IGMPMLD_TID,
1508 .antenna_gain = WMI_10_4_PDEV_PARAM_ANTENNA_GAIN,
1509 .rx_filter = WMI_10_4_PDEV_PARAM_RX_FILTER,
1510 .set_mcast_to_ucast_tid = WMI_10_4_PDEV_SET_MCAST_TO_UCAST_TID,
1511 .proxy_sta_mode = WMI_10_4_PDEV_PARAM_PROXY_STA_MODE,
1512 .set_mcast2ucast_mode = WMI_10_4_PDEV_PARAM_SET_MCAST2UCAST_MODE,
1513 .set_mcast2ucast_buffer = WMI_10_4_PDEV_PARAM_SET_MCAST2UCAST_BUFFER,
1514 .remove_mcast2ucast_buffer =
1515 WMI_10_4_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER,
1516 .peer_sta_ps_statechg_enable =
1517 WMI_10_4_PDEV_PEER_STA_PS_STATECHG_ENABLE,
1518 .igmpmld_ac_override = WMI_10_4_PDEV_PARAM_IGMPMLD_AC_OVERRIDE,
1519 .block_interbss = WMI_10_4_PDEV_PARAM_BLOCK_INTERBSS,
1520 .set_disable_reset_cmdid = WMI_10_4_PDEV_PARAM_SET_DISABLE_RESET_CMDID,
1521 .set_msdu_ttl_cmdid = WMI_10_4_PDEV_PARAM_SET_MSDU_TTL_CMDID,
1522 .set_ppdu_duration_cmdid = WMI_10_4_PDEV_PARAM_SET_PPDU_DURATION_CMDID,
1523 .txbf_sound_period_cmdid = WMI_10_4_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID,
1524 .set_promisc_mode_cmdid = WMI_10_4_PDEV_PARAM_SET_PROMISC_MODE_CMDID,
1525 .set_burst_mode_cmdid = WMI_10_4_PDEV_PARAM_SET_BURST_MODE_CMDID,
1526 .en_stats = WMI_10_4_PDEV_PARAM_EN_STATS,
1527 .mu_group_policy = WMI_10_4_PDEV_PARAM_MU_GROUP_POLICY,
1528 .noise_detection = WMI_10_4_PDEV_PARAM_NOISE_DETECTION,
1529 .noise_threshold = WMI_10_4_PDEV_PARAM_NOISE_THRESHOLD,
1530 .dpd_enable = WMI_10_4_PDEV_PARAM_DPD_ENABLE,
1531 .set_mcast_bcast_echo = WMI_10_4_PDEV_PARAM_SET_MCAST_BCAST_ECHO,
1532 .atf_strict_sch = WMI_10_4_PDEV_PARAM_ATF_STRICT_SCH,
1533 .atf_sched_duration = WMI_10_4_PDEV_PARAM_ATF_SCHED_DURATION,
1534 .ant_plzn = WMI_10_4_PDEV_PARAM_ANT_PLZN,
1535 .mgmt_retry_limit = WMI_10_4_PDEV_PARAM_MGMT_RETRY_LIMIT,
1536 .sensitivity_level = WMI_10_4_PDEV_PARAM_SENSITIVITY_LEVEL,
1537 .signed_txpower_2g = WMI_10_4_PDEV_PARAM_SIGNED_TXPOWER_2G,
1538 .signed_txpower_5g = WMI_10_4_PDEV_PARAM_SIGNED_TXPOWER_5G,
1539 .enable_per_tid_amsdu = WMI_10_4_PDEV_PARAM_ENABLE_PER_TID_AMSDU,
1540 .enable_per_tid_ampdu = WMI_10_4_PDEV_PARAM_ENABLE_PER_TID_AMPDU,
1541 .cca_threshold = WMI_10_4_PDEV_PARAM_CCA_THRESHOLD,
1542 .rts_fixed_rate = WMI_10_4_PDEV_PARAM_RTS_FIXED_RATE,
1543 .pdev_reset = WMI_10_4_PDEV_PARAM_PDEV_RESET,
1544 .wapi_mbssid_offset = WMI_10_4_PDEV_PARAM_WAPI_MBSSID_OFFSET,
1545 .arp_srcaddr = WMI_10_4_PDEV_PARAM_ARP_SRCADDR,
1546 .arp_dstaddr = WMI_10_4_PDEV_PARAM_ARP_DSTADDR,
1547};
1548
Michal Kazior0226d602014-12-03 10:11:22 +02001549void ath10k_wmi_put_wmi_channel(struct wmi_channel *ch,
1550 const struct wmi_channel_arg *arg)
Michal Kazior2d667212014-09-18 15:21:21 +02001551{
1552 u32 flags = 0;
1553
1554 memset(ch, 0, sizeof(*ch));
1555
1556 if (arg->passive)
1557 flags |= WMI_CHAN_FLAG_PASSIVE;
1558 if (arg->allow_ibss)
1559 flags |= WMI_CHAN_FLAG_ADHOC_ALLOWED;
1560 if (arg->allow_ht)
1561 flags |= WMI_CHAN_FLAG_ALLOW_HT;
1562 if (arg->allow_vht)
1563 flags |= WMI_CHAN_FLAG_ALLOW_VHT;
1564 if (arg->ht40plus)
1565 flags |= WMI_CHAN_FLAG_HT40_PLUS;
1566 if (arg->chan_radar)
1567 flags |= WMI_CHAN_FLAG_DFS;
1568
1569 ch->mhz = __cpu_to_le32(arg->freq);
1570 ch->band_center_freq1 = __cpu_to_le32(arg->band_center_freq1);
1571 ch->band_center_freq2 = 0;
1572 ch->min_power = arg->min_power;
1573 ch->max_power = arg->max_power;
1574 ch->reg_power = arg->max_reg_power;
1575 ch->antenna_max = arg->max_antenna_gain;
1576
1577 /* mode & flags share storage */
1578 ch->mode = arg->mode;
1579 ch->flags |= __cpu_to_le32(flags);
1580}
1581
Kalle Valo5e3dd152013-06-12 20:52:10 +03001582int ath10k_wmi_wait_for_service_ready(struct ath10k *ar)
1583{
Nicholas Mc Guire9eea5682015-03-30 15:39:21 +03001584 unsigned long time_left;
Kalle Valoaf762c02014-09-14 12:50:17 +03001585
Nicholas Mc Guire9eea5682015-03-30 15:39:21 +03001586 time_left = wait_for_completion_timeout(&ar->wmi.service_ready,
1587 WMI_SERVICE_READY_TIMEOUT_HZ);
1588 if (!time_left)
1589 return -ETIMEDOUT;
1590 return 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001591}
1592
1593int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar)
1594{
Nicholas Mc Guire9eea5682015-03-30 15:39:21 +03001595 unsigned long time_left;
Kalle Valoaf762c02014-09-14 12:50:17 +03001596
Nicholas Mc Guire9eea5682015-03-30 15:39:21 +03001597 time_left = wait_for_completion_timeout(&ar->wmi.unified_ready,
1598 WMI_UNIFIED_READY_TIMEOUT_HZ);
1599 if (!time_left)
1600 return -ETIMEDOUT;
1601 return 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001602}
1603
Kalle Valo666a73f32014-09-10 18:23:23 +03001604struct sk_buff *ath10k_wmi_alloc_skb(struct ath10k *ar, u32 len)
Kalle Valo5e3dd152013-06-12 20:52:10 +03001605{
1606 struct sk_buff *skb;
1607 u32 round_len = roundup(len, 4);
1608
Michal Kazior7aa7a722014-08-25 12:09:38 +02001609 skb = ath10k_htc_alloc_skb(ar, WMI_SKB_HEADROOM + round_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001610 if (!skb)
1611 return NULL;
1612
1613 skb_reserve(skb, WMI_SKB_HEADROOM);
1614 if (!IS_ALIGNED((unsigned long)skb->data, 4))
Michal Kazior7aa7a722014-08-25 12:09:38 +02001615 ath10k_warn(ar, "Unaligned WMI skb\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03001616
1617 skb_put(skb, round_len);
1618 memset(skb->data, 0, round_len);
1619
1620 return skb;
1621}
1622
1623static void ath10k_wmi_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb)
1624{
1625 dev_kfree_skb(skb);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001626}
1627
Michal Kaziord7579d12014-12-03 10:10:54 +02001628int ath10k_wmi_cmd_send_nowait(struct ath10k *ar, struct sk_buff *skb,
1629 u32 cmd_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +03001630{
1631 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb);
1632 struct wmi_cmd_hdr *cmd_hdr;
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001633 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001634 u32 cmd = 0;
1635
1636 if (skb_push(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
1637 return -ENOMEM;
1638
1639 cmd |= SM(cmd_id, WMI_CMD_HDR_CMD_ID);
1640
1641 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
1642 cmd_hdr->cmd_id = __cpu_to_le32(cmd);
1643
Kalle Valo5e3dd152013-06-12 20:52:10 +03001644 memset(skb_cb, 0, sizeof(*skb_cb));
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001645 ret = ath10k_htc_send(&ar->htc, ar->wmi.eid, skb);
Michal Kaziord35a6c12014-09-02 11:00:21 +03001646 trace_ath10k_wmi_cmd(ar, cmd_id, skb->data, skb->len, ret);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001647
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001648 if (ret)
1649 goto err_pull;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001650
1651 return 0;
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001652
1653err_pull:
1654 skb_pull(skb, sizeof(struct wmi_cmd_hdr));
1655 return ret;
1656}
1657
Michal Kaziored543882013-09-13 14:16:56 +02001658static void ath10k_wmi_tx_beacon_nowait(struct ath10k_vif *arvif)
1659{
Michal Kazioraf213192015-01-29 14:29:52 +02001660 struct ath10k *ar = arvif->ar;
Michal Kazior9ad50182015-01-29 14:29:47 +02001661 struct ath10k_skb_cb *cb;
Michal Kazioraf213192015-01-29 14:29:52 +02001662 struct sk_buff *bcn;
Michal Kaziored543882013-09-13 14:16:56 +02001663 int ret;
1664
Michal Kazioraf213192015-01-29 14:29:52 +02001665 spin_lock_bh(&ar->data_lock);
Michal Kaziored543882013-09-13 14:16:56 +02001666
Michal Kazior9ad50182015-01-29 14:29:47 +02001667 bcn = arvif->beacon;
Michal Kaziored543882013-09-13 14:16:56 +02001668
Michal Kazioraf213192015-01-29 14:29:52 +02001669 if (!bcn)
1670 goto unlock;
Michal Kaziored543882013-09-13 14:16:56 +02001671
Michal Kazioraf213192015-01-29 14:29:52 +02001672 cb = ATH10K_SKB_CB(bcn);
Michal Kaziored543882013-09-13 14:16:56 +02001673
Michal Kazioraf213192015-01-29 14:29:52 +02001674 switch (arvif->beacon_state) {
1675 case ATH10K_BEACON_SENDING:
1676 case ATH10K_BEACON_SENT:
1677 break;
1678 case ATH10K_BEACON_SCHEDULED:
1679 arvif->beacon_state = ATH10K_BEACON_SENDING;
1680 spin_unlock_bh(&ar->data_lock);
1681
1682 ret = ath10k_wmi_beacon_send_ref_nowait(arvif->ar,
1683 arvif->vdev_id,
1684 bcn->data, bcn->len,
1685 cb->paddr,
1686 cb->bcn.dtim_zero,
1687 cb->bcn.deliver_cab);
1688
1689 spin_lock_bh(&ar->data_lock);
1690
1691 if (ret == 0)
1692 arvif->beacon_state = ATH10K_BEACON_SENT;
1693 else
1694 arvif->beacon_state = ATH10K_BEACON_SCHEDULED;
1695 }
1696
1697unlock:
1698 spin_unlock_bh(&ar->data_lock);
Michal Kaziored543882013-09-13 14:16:56 +02001699}
1700
1701static void ath10k_wmi_tx_beacons_iter(void *data, u8 *mac,
1702 struct ieee80211_vif *vif)
1703{
1704 struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif);
1705
1706 ath10k_wmi_tx_beacon_nowait(arvif);
1707}
1708
1709static void ath10k_wmi_tx_beacons_nowait(struct ath10k *ar)
1710{
Michal Kaziored543882013-09-13 14:16:56 +02001711 ieee80211_iterate_active_interfaces_atomic(ar->hw,
1712 IEEE80211_IFACE_ITER_NORMAL,
1713 ath10k_wmi_tx_beacons_iter,
1714 NULL);
Michal Kaziored543882013-09-13 14:16:56 +02001715}
1716
Michal Kazior12acbc42013-09-13 14:16:55 +02001717static void ath10k_wmi_op_ep_tx_credits(struct ath10k *ar)
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001718{
Michal Kaziored543882013-09-13 14:16:56 +02001719 /* try to send pending beacons first. they take priority */
1720 ath10k_wmi_tx_beacons_nowait(ar);
1721
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001722 wake_up(&ar->wmi.tx_credits_wq);
1723}
1724
Kalle Valo666a73f32014-09-10 18:23:23 +03001725int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id)
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001726{
Bartosz Markowski34957b22013-10-15 09:55:31 +02001727 int ret = -EOPNOTSUPP;
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001728
Kalle Valo56b84282013-10-16 15:44:47 +03001729 might_sleep();
1730
Bartosz Markowski34957b22013-10-15 09:55:31 +02001731 if (cmd_id == WMI_CMD_UNSUPPORTED) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02001732 ath10k_warn(ar, "wmi command %d is not supported by firmware\n",
Bartosz Markowski55321552013-09-26 17:47:07 +02001733 cmd_id);
1734 return ret;
1735 }
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001736
1737 wait_event_timeout(ar->wmi.tx_credits_wq, ({
Michal Kaziored543882013-09-13 14:16:56 +02001738 /* try to send pending beacons first. they take priority */
1739 ath10k_wmi_tx_beacons_nowait(ar);
1740
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001741 ret = ath10k_wmi_cmd_send_nowait(ar, skb, cmd_id);
Michal Kazior7962b0d2014-10-28 10:34:38 +01001742
1743 if (ret && test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags))
1744 ret = -ESHUTDOWN;
1745
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001746 (ret != -EAGAIN);
1747 }), 3*HZ);
1748
1749 if (ret)
1750 dev_kfree_skb_any(skb);
1751
1752 return ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001753}
1754
Michal Kaziord7579d12014-12-03 10:10:54 +02001755static struct sk_buff *
1756ath10k_wmi_op_gen_mgmt_tx(struct ath10k *ar, struct sk_buff *msdu)
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001757{
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001758 struct wmi_mgmt_tx_cmd *cmd;
1759 struct ieee80211_hdr *hdr;
Michal Kaziord7579d12014-12-03 10:10:54 +02001760 struct sk_buff *skb;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001761 int len;
Michal Kaziord7579d12014-12-03 10:10:54 +02001762 u32 buf_len = msdu->len;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001763 u16 fc;
1764
Michal Kaziord7579d12014-12-03 10:10:54 +02001765 hdr = (struct ieee80211_hdr *)msdu->data;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001766 fc = le16_to_cpu(hdr->frame_control);
1767
1768 if (WARN_ON_ONCE(!ieee80211_is_mgmt(hdr->frame_control)))
Michal Kaziord7579d12014-12-03 10:10:54 +02001769 return ERR_PTR(-EINVAL);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001770
Michal Kaziord7579d12014-12-03 10:10:54 +02001771 len = sizeof(cmd->hdr) + msdu->len;
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03001772
1773 if ((ieee80211_is_action(hdr->frame_control) ||
1774 ieee80211_is_deauth(hdr->frame_control) ||
1775 ieee80211_is_disassoc(hdr->frame_control)) &&
1776 ieee80211_has_protected(hdr->frame_control)) {
1777 len += IEEE80211_CCMP_MIC_LEN;
1778 buf_len += IEEE80211_CCMP_MIC_LEN;
1779 }
1780
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001781 len = round_up(len, 4);
1782
Michal Kaziord7579d12014-12-03 10:10:54 +02001783 skb = ath10k_wmi_alloc_skb(ar, len);
1784 if (!skb)
1785 return ERR_PTR(-ENOMEM);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001786
Michal Kaziord7579d12014-12-03 10:10:54 +02001787 cmd = (struct wmi_mgmt_tx_cmd *)skb->data;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001788
Michal Kaziord7579d12014-12-03 10:10:54 +02001789 cmd->hdr.vdev_id = __cpu_to_le32(ATH10K_SKB_CB(msdu)->vdev_id);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001790 cmd->hdr.tx_rate = 0;
1791 cmd->hdr.tx_power = 0;
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03001792 cmd->hdr.buf_len = __cpu_to_le32(buf_len);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001793
Kalle Valob25f32c2014-09-14 12:50:49 +03001794 ether_addr_copy(cmd->hdr.peer_macaddr.addr, ieee80211_get_DA(hdr));
Michal Kaziord7579d12014-12-03 10:10:54 +02001795 memcpy(cmd->buf, msdu->data, msdu->len);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001796
Michal Kazior7aa7a722014-08-25 12:09:38 +02001797 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi mgmt tx skb %p len %d ftype %02x stype %02x\n",
Michal Kaziord7579d12014-12-03 10:10:54 +02001798 msdu, skb->len, fc & IEEE80211_FCTL_FTYPE,
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001799 fc & IEEE80211_FCTL_STYPE);
Rajkumar Manoharan5ce8e7f2014-11-05 19:14:31 +05301800 trace_ath10k_tx_hdr(ar, skb->data, skb->len);
1801 trace_ath10k_tx_payload(ar, skb->data, skb->len);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001802
Michal Kaziord7579d12014-12-03 10:10:54 +02001803 return skb;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001804}
1805
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001806static void ath10k_wmi_event_scan_started(struct ath10k *ar)
1807{
1808 lockdep_assert_held(&ar->data_lock);
1809
1810 switch (ar->scan.state) {
1811 case ATH10K_SCAN_IDLE:
1812 case ATH10K_SCAN_RUNNING:
1813 case ATH10K_SCAN_ABORTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02001814 ath10k_warn(ar, "received scan started event in an invalid scan state: %s (%d)\n",
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001815 ath10k_scan_state_str(ar->scan.state),
1816 ar->scan.state);
1817 break;
1818 case ATH10K_SCAN_STARTING:
1819 ar->scan.state = ATH10K_SCAN_RUNNING;
1820
1821 if (ar->scan.is_roc)
1822 ieee80211_ready_on_channel(ar->hw);
1823
1824 complete(&ar->scan.started);
1825 break;
1826 }
1827}
1828
Ben Greear2f9eec02015-02-15 16:50:38 +02001829static void ath10k_wmi_event_scan_start_failed(struct ath10k *ar)
1830{
1831 lockdep_assert_held(&ar->data_lock);
1832
1833 switch (ar->scan.state) {
1834 case ATH10K_SCAN_IDLE:
1835 case ATH10K_SCAN_RUNNING:
1836 case ATH10K_SCAN_ABORTING:
1837 ath10k_warn(ar, "received scan start failed event in an invalid scan state: %s (%d)\n",
1838 ath10k_scan_state_str(ar->scan.state),
1839 ar->scan.state);
1840 break;
1841 case ATH10K_SCAN_STARTING:
1842 complete(&ar->scan.started);
1843 __ath10k_scan_finish(ar);
1844 break;
1845 }
1846}
1847
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001848static void ath10k_wmi_event_scan_completed(struct ath10k *ar)
1849{
1850 lockdep_assert_held(&ar->data_lock);
1851
1852 switch (ar->scan.state) {
1853 case ATH10K_SCAN_IDLE:
1854 case ATH10K_SCAN_STARTING:
1855 /* One suspected reason scan can be completed while starting is
1856 * if firmware fails to deliver all scan events to the host,
1857 * e.g. when transport pipe is full. This has been observed
1858 * with spectral scan phyerr events starving wmi transport
1859 * pipe. In such case the "scan completed" event should be (and
1860 * is) ignored by the host as it may be just firmware's scan
1861 * state machine recovering.
1862 */
Michal Kazior7aa7a722014-08-25 12:09:38 +02001863 ath10k_warn(ar, "received scan completed event in an invalid scan state: %s (%d)\n",
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001864 ath10k_scan_state_str(ar->scan.state),
1865 ar->scan.state);
1866 break;
1867 case ATH10K_SCAN_RUNNING:
1868 case ATH10K_SCAN_ABORTING:
1869 __ath10k_scan_finish(ar);
1870 break;
1871 }
1872}
1873
1874static void ath10k_wmi_event_scan_bss_chan(struct ath10k *ar)
1875{
1876 lockdep_assert_held(&ar->data_lock);
1877
1878 switch (ar->scan.state) {
1879 case ATH10K_SCAN_IDLE:
1880 case ATH10K_SCAN_STARTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02001881 ath10k_warn(ar, "received scan bss chan event in an invalid scan state: %s (%d)\n",
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001882 ath10k_scan_state_str(ar->scan.state),
1883 ar->scan.state);
1884 break;
1885 case ATH10K_SCAN_RUNNING:
1886 case ATH10K_SCAN_ABORTING:
1887 ar->scan_channel = NULL;
1888 break;
1889 }
1890}
1891
1892static void ath10k_wmi_event_scan_foreign_chan(struct ath10k *ar, u32 freq)
1893{
1894 lockdep_assert_held(&ar->data_lock);
1895
1896 switch (ar->scan.state) {
1897 case ATH10K_SCAN_IDLE:
1898 case ATH10K_SCAN_STARTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02001899 ath10k_warn(ar, "received scan foreign chan event in an invalid scan state: %s (%d)\n",
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001900 ath10k_scan_state_str(ar->scan.state),
1901 ar->scan.state);
1902 break;
1903 case ATH10K_SCAN_RUNNING:
1904 case ATH10K_SCAN_ABORTING:
1905 ar->scan_channel = ieee80211_get_channel(ar->hw->wiphy, freq);
1906
1907 if (ar->scan.is_roc && ar->scan.roc_freq == freq)
1908 complete(&ar->scan.on_channel);
1909 break;
1910 }
1911}
1912
Michal Kazior9ff8b722014-08-05 14:54:43 +02001913static const char *
1914ath10k_wmi_event_scan_type_str(enum wmi_scan_event_type type,
1915 enum wmi_scan_completion_reason reason)
1916{
1917 switch (type) {
1918 case WMI_SCAN_EVENT_STARTED:
1919 return "started";
1920 case WMI_SCAN_EVENT_COMPLETED:
1921 switch (reason) {
1922 case WMI_SCAN_REASON_COMPLETED:
1923 return "completed";
1924 case WMI_SCAN_REASON_CANCELLED:
1925 return "completed [cancelled]";
1926 case WMI_SCAN_REASON_PREEMPTED:
1927 return "completed [preempted]";
1928 case WMI_SCAN_REASON_TIMEDOUT:
1929 return "completed [timedout]";
Raja Manib2297ba2015-06-22 20:22:23 +05301930 case WMI_SCAN_REASON_INTERNAL_FAILURE:
1931 return "completed [internal err]";
Michal Kazior9ff8b722014-08-05 14:54:43 +02001932 case WMI_SCAN_REASON_MAX:
1933 break;
1934 }
1935 return "completed [unknown]";
1936 case WMI_SCAN_EVENT_BSS_CHANNEL:
1937 return "bss channel";
1938 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
1939 return "foreign channel";
1940 case WMI_SCAN_EVENT_DEQUEUED:
1941 return "dequeued";
1942 case WMI_SCAN_EVENT_PREEMPTED:
1943 return "preempted";
1944 case WMI_SCAN_EVENT_START_FAILED:
1945 return "start failed";
Raja Manib2297ba2015-06-22 20:22:23 +05301946 case WMI_SCAN_EVENT_RESTARTED:
1947 return "restarted";
1948 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
1949 return "foreign channel exit";
Michal Kazior9ff8b722014-08-05 14:54:43 +02001950 default:
1951 return "unknown";
1952 }
1953}
1954
Michal Kaziord7579d12014-12-03 10:10:54 +02001955static int ath10k_wmi_op_pull_scan_ev(struct ath10k *ar, struct sk_buff *skb,
1956 struct wmi_scan_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02001957{
1958 struct wmi_scan_event *ev = (void *)skb->data;
1959
1960 if (skb->len < sizeof(*ev))
1961 return -EPROTO;
1962
1963 skb_pull(skb, sizeof(*ev));
1964 arg->event_type = ev->event_type;
1965 arg->reason = ev->reason;
1966 arg->channel_freq = ev->channel_freq;
1967 arg->scan_req_id = ev->scan_req_id;
1968 arg->scan_id = ev->scan_id;
1969 arg->vdev_id = ev->vdev_id;
1970
1971 return 0;
1972}
1973
Michal Kazior0226d602014-12-03 10:11:22 +02001974int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03001975{
Michal Kazior32653cf2014-12-03 10:10:26 +02001976 struct wmi_scan_ev_arg arg = {};
Kalle Valo5e3dd152013-06-12 20:52:10 +03001977 enum wmi_scan_event_type event_type;
1978 enum wmi_scan_completion_reason reason;
1979 u32 freq;
1980 u32 req_id;
1981 u32 scan_id;
1982 u32 vdev_id;
Michal Kazior32653cf2014-12-03 10:10:26 +02001983 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001984
Michal Kaziord7579d12014-12-03 10:10:54 +02001985 ret = ath10k_wmi_pull_scan(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02001986 if (ret) {
1987 ath10k_warn(ar, "failed to parse scan event: %d\n", ret);
1988 return ret;
1989 }
1990
1991 event_type = __le32_to_cpu(arg.event_type);
1992 reason = __le32_to_cpu(arg.reason);
1993 freq = __le32_to_cpu(arg.channel_freq);
1994 req_id = __le32_to_cpu(arg.scan_req_id);
1995 scan_id = __le32_to_cpu(arg.scan_id);
1996 vdev_id = __le32_to_cpu(arg.vdev_id);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001997
Kalle Valo5e3dd152013-06-12 20:52:10 +03001998 spin_lock_bh(&ar->data_lock);
1999
Michal Kazior7aa7a722014-08-25 12:09:38 +02002000 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002001 "scan event %s type %d reason %d freq %d req_id %d scan_id %d vdev_id %d state %s (%d)\n",
2002 ath10k_wmi_event_scan_type_str(event_type, reason),
2003 event_type, reason, freq, req_id, scan_id, vdev_id,
2004 ath10k_scan_state_str(ar->scan.state), ar->scan.state);
2005
Kalle Valo5e3dd152013-06-12 20:52:10 +03002006 switch (event_type) {
2007 case WMI_SCAN_EVENT_STARTED:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002008 ath10k_wmi_event_scan_started(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002009 break;
2010 case WMI_SCAN_EVENT_COMPLETED:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002011 ath10k_wmi_event_scan_completed(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002012 break;
2013 case WMI_SCAN_EVENT_BSS_CHANNEL:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002014 ath10k_wmi_event_scan_bss_chan(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002015 break;
2016 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002017 ath10k_wmi_event_scan_foreign_chan(ar, freq);
2018 break;
2019 case WMI_SCAN_EVENT_START_FAILED:
Michal Kazior7aa7a722014-08-25 12:09:38 +02002020 ath10k_warn(ar, "received scan start failure event\n");
Ben Greear2f9eec02015-02-15 16:50:38 +02002021 ath10k_wmi_event_scan_start_failed(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002022 break;
2023 case WMI_SCAN_EVENT_DEQUEUED:
Kalle Valo5e3dd152013-06-12 20:52:10 +03002024 case WMI_SCAN_EVENT_PREEMPTED:
Raja Manib2297ba2015-06-22 20:22:23 +05302025 case WMI_SCAN_EVENT_RESTARTED:
2026 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Kalle Valo5e3dd152013-06-12 20:52:10 +03002027 default:
2028 break;
2029 }
2030
2031 spin_unlock_bh(&ar->data_lock);
2032 return 0;
2033}
2034
2035static inline enum ieee80211_band phy_mode_to_band(u32 phy_mode)
2036{
2037 enum ieee80211_band band;
2038
2039 switch (phy_mode) {
2040 case MODE_11A:
2041 case MODE_11NA_HT20:
2042 case MODE_11NA_HT40:
2043 case MODE_11AC_VHT20:
2044 case MODE_11AC_VHT40:
2045 case MODE_11AC_VHT80:
2046 band = IEEE80211_BAND_5GHZ;
2047 break;
2048 case MODE_11G:
2049 case MODE_11B:
2050 case MODE_11GONLY:
2051 case MODE_11NG_HT20:
2052 case MODE_11NG_HT40:
2053 case MODE_11AC_VHT20_2G:
2054 case MODE_11AC_VHT40_2G:
2055 case MODE_11AC_VHT80_2G:
2056 default:
2057 band = IEEE80211_BAND_2GHZ;
2058 }
2059
2060 return band;
2061}
2062
Sujith Manoharan504f6cd2014-11-25 11:46:58 +05302063/* If keys are configured, HW decrypts all frames
2064 * with protected bit set. Mark such frames as decrypted.
2065 */
2066static void ath10k_wmi_handle_wep_reauth(struct ath10k *ar,
2067 struct sk_buff *skb,
2068 struct ieee80211_rx_status *status)
2069{
2070 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2071 unsigned int hdrlen;
2072 bool peer_key;
2073 u8 *addr, keyidx;
2074
2075 if (!ieee80211_is_auth(hdr->frame_control) ||
2076 !ieee80211_has_protected(hdr->frame_control))
2077 return;
2078
2079 hdrlen = ieee80211_hdrlen(hdr->frame_control);
2080 if (skb->len < (hdrlen + IEEE80211_WEP_IV_LEN))
2081 return;
2082
2083 keyidx = skb->data[hdrlen + (IEEE80211_WEP_IV_LEN - 1)] >> WEP_KEYID_SHIFT;
2084 addr = ieee80211_get_SA(hdr);
2085
2086 spin_lock_bh(&ar->data_lock);
2087 peer_key = ath10k_mac_is_peer_wep_key_set(ar, addr, keyidx);
2088 spin_unlock_bh(&ar->data_lock);
2089
2090 if (peer_key) {
2091 ath10k_dbg(ar, ATH10K_DBG_MAC,
2092 "mac wep key present for peer %pM\n", addr);
2093 status->flag |= RX_FLAG_DECRYPTED;
2094 }
2095}
2096
Michal Kaziord7579d12014-12-03 10:10:54 +02002097static int ath10k_wmi_op_pull_mgmt_rx_ev(struct ath10k *ar, struct sk_buff *skb,
2098 struct wmi_mgmt_rx_ev_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002099{
Michal Kazior0d9b0432013-08-09 10:13:33 +02002100 struct wmi_mgmt_rx_event_v1 *ev_v1;
2101 struct wmi_mgmt_rx_event_v2 *ev_v2;
2102 struct wmi_mgmt_rx_hdr_v1 *ev_hdr;
Michal Kazior32653cf2014-12-03 10:10:26 +02002103 size_t pull_len;
2104 u32 msdu_len;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002105
Michal Kazior0d9b0432013-08-09 10:13:33 +02002106 if (test_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features)) {
2107 ev_v2 = (struct wmi_mgmt_rx_event_v2 *)skb->data;
2108 ev_hdr = &ev_v2->hdr.v1;
2109 pull_len = sizeof(*ev_v2);
2110 } else {
2111 ev_v1 = (struct wmi_mgmt_rx_event_v1 *)skb->data;
2112 ev_hdr = &ev_v1->hdr;
2113 pull_len = sizeof(*ev_v1);
2114 }
2115
Michal Kazior32653cf2014-12-03 10:10:26 +02002116 if (skb->len < pull_len)
2117 return -EPROTO;
2118
2119 skb_pull(skb, pull_len);
2120 arg->channel = ev_hdr->channel;
2121 arg->buf_len = ev_hdr->buf_len;
2122 arg->status = ev_hdr->status;
2123 arg->snr = ev_hdr->snr;
2124 arg->phy_mode = ev_hdr->phy_mode;
2125 arg->rate = ev_hdr->rate;
2126
2127 msdu_len = __le32_to_cpu(arg->buf_len);
2128 if (skb->len < msdu_len)
2129 return -EPROTO;
2130
2131 /* the WMI buffer might've ended up being padded to 4 bytes due to HTC
2132 * trailer with credit update. Trim the excess garbage.
2133 */
2134 skb_trim(skb, msdu_len);
2135
2136 return 0;
2137}
2138
Raja Mani1c092962015-06-22 20:10:16 +05302139static int ath10k_wmi_10_4_op_pull_mgmt_rx_ev(struct ath10k *ar,
2140 struct sk_buff *skb,
2141 struct wmi_mgmt_rx_ev_arg *arg)
2142{
2143 struct wmi_10_4_mgmt_rx_event *ev;
2144 struct wmi_10_4_mgmt_rx_hdr *ev_hdr;
2145 size_t pull_len;
2146 u32 msdu_len;
2147
2148 ev = (struct wmi_10_4_mgmt_rx_event *)skb->data;
2149 ev_hdr = &ev->hdr;
2150 pull_len = sizeof(*ev);
2151
2152 if (skb->len < pull_len)
2153 return -EPROTO;
2154
2155 skb_pull(skb, pull_len);
2156 arg->channel = ev_hdr->channel;
2157 arg->buf_len = ev_hdr->buf_len;
2158 arg->status = ev_hdr->status;
2159 arg->snr = ev_hdr->snr;
2160 arg->phy_mode = ev_hdr->phy_mode;
2161 arg->rate = ev_hdr->rate;
2162
2163 msdu_len = __le32_to_cpu(arg->buf_len);
2164 if (skb->len < msdu_len)
2165 return -EPROTO;
2166
2167 /* Make sure bytes added for padding are removed. */
2168 skb_trim(skb, msdu_len);
2169
2170 return 0;
2171}
2172
Michal Kazior0226d602014-12-03 10:11:22 +02002173int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
Michal Kazior32653cf2014-12-03 10:10:26 +02002174{
2175 struct wmi_mgmt_rx_ev_arg arg = {};
2176 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
2177 struct ieee80211_hdr *hdr;
Michal Kazior01cebe12015-03-30 09:51:56 +03002178 struct ieee80211_supported_band *sband;
Michal Kazior32653cf2014-12-03 10:10:26 +02002179 u32 rx_status;
2180 u32 channel;
2181 u32 phy_mode;
2182 u32 snr;
2183 u32 rate;
2184 u32 buf_len;
2185 u16 fc;
2186 int ret;
2187
Michal Kaziord7579d12014-12-03 10:10:54 +02002188 ret = ath10k_wmi_pull_mgmt_rx(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02002189 if (ret) {
2190 ath10k_warn(ar, "failed to parse mgmt rx event: %d\n", ret);
Raja Mani08603f22015-06-01 14:53:33 +05302191 dev_kfree_skb(skb);
Michal Kazior32653cf2014-12-03 10:10:26 +02002192 return ret;
2193 }
2194
2195 channel = __le32_to_cpu(arg.channel);
2196 buf_len = __le32_to_cpu(arg.buf_len);
2197 rx_status = __le32_to_cpu(arg.status);
2198 snr = __le32_to_cpu(arg.snr);
2199 phy_mode = __le32_to_cpu(arg.phy_mode);
2200 rate = __le32_to_cpu(arg.rate);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002201
2202 memset(status, 0, sizeof(*status));
2203
Michal Kazior7aa7a722014-08-25 12:09:38 +02002204 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo5e3dd152013-06-12 20:52:10 +03002205 "event mgmt rx status %08x\n", rx_status);
2206
Marek Puzyniake8a50f82013-11-20 09:59:47 +02002207 if (test_bit(ATH10K_CAC_RUNNING, &ar->dev_flags)) {
2208 dev_kfree_skb(skb);
2209 return 0;
2210 }
2211
Kalle Valo5e3dd152013-06-12 20:52:10 +03002212 if (rx_status & WMI_RX_STATUS_ERR_DECRYPT) {
2213 dev_kfree_skb(skb);
2214 return 0;
2215 }
2216
2217 if (rx_status & WMI_RX_STATUS_ERR_KEY_CACHE_MISS) {
2218 dev_kfree_skb(skb);
2219 return 0;
2220 }
2221
Michal Kaziord67d0a02014-11-24 15:34:08 +01002222 if (rx_status & WMI_RX_STATUS_ERR_CRC) {
2223 dev_kfree_skb(skb);
2224 return 0;
2225 }
2226
Kalle Valo5e3dd152013-06-12 20:52:10 +03002227 if (rx_status & WMI_RX_STATUS_ERR_MIC)
2228 status->flag |= RX_FLAG_MMIC_ERROR;
2229
Michal Kazior21040bf2014-10-21 10:10:30 +03002230 /* Hardware can Rx CCK rates on 5GHz. In that case phy_mode is set to
Michal Kazior453cdb62013-12-13 10:44:43 +01002231 * MODE_11B. This means phy_mode is not a reliable source for the band
Michal Kazior21040bf2014-10-21 10:10:30 +03002232 * of mgmt rx.
2233 */
2234 if (channel >= 1 && channel <= 14) {
2235 status->band = IEEE80211_BAND_2GHZ;
2236 } else if (channel >= 36 && channel <= 165) {
2237 status->band = IEEE80211_BAND_5GHZ;
Michal Kazior453cdb62013-12-13 10:44:43 +01002238 } else {
Michal Kazior21040bf2014-10-21 10:10:30 +03002239 /* Shouldn't happen unless list of advertised channels to
2240 * mac80211 has been changed.
2241 */
2242 WARN_ON_ONCE(1);
2243 dev_kfree_skb(skb);
2244 return 0;
Michal Kazior453cdb62013-12-13 10:44:43 +01002245 }
2246
Michal Kazior21040bf2014-10-21 10:10:30 +03002247 if (phy_mode == MODE_11B && status->band == IEEE80211_BAND_5GHZ)
2248 ath10k_dbg(ar, ATH10K_DBG_MGMT, "wmi mgmt rx 11b (CCK) on 5GHz\n");
2249
Michal Kazior01cebe12015-03-30 09:51:56 +03002250 sband = &ar->mac.sbands[status->band];
2251
Kalle Valo5e3dd152013-06-12 20:52:10 +03002252 status->freq = ieee80211_channel_to_frequency(channel, status->band);
2253 status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR;
Michal Kazior01cebe12015-03-30 09:51:56 +03002254 status->rate_idx = ath10k_mac_bitrate_to_idx(sband, rate / 100);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002255
Kalle Valo5e3dd152013-06-12 20:52:10 +03002256 hdr = (struct ieee80211_hdr *)skb->data;
2257 fc = le16_to_cpu(hdr->frame_control);
2258
Sujith Manoharan504f6cd2014-11-25 11:46:58 +05302259 ath10k_wmi_handle_wep_reauth(ar, skb, status);
2260
Michal Kazior2b6a6a92013-12-05 06:53:41 +01002261 /* FW delivers WEP Shared Auth frame with Protected Bit set and
2262 * encrypted payload. However in case of PMF it delivers decrypted
2263 * frames with Protected Bit set. */
2264 if (ieee80211_has_protected(hdr->frame_control) &&
2265 !ieee80211_is_auth(hdr->frame_control)) {
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03002266 status->flag |= RX_FLAG_DECRYPTED;
2267
2268 if (!ieee80211_is_action(hdr->frame_control) &&
2269 !ieee80211_is_deauth(hdr->frame_control) &&
2270 !ieee80211_is_disassoc(hdr->frame_control)) {
2271 status->flag |= RX_FLAG_IV_STRIPPED |
2272 RX_FLAG_MMIC_STRIPPED;
2273 hdr->frame_control = __cpu_to_le16(fc &
Kalle Valo5e3dd152013-06-12 20:52:10 +03002274 ~IEEE80211_FCTL_PROTECTED);
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03002275 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03002276 }
2277
Michal Kaziorcc9904e2015-03-10 16:22:01 +02002278 if (ieee80211_is_beacon(hdr->frame_control))
2279 ath10k_mac_handle_beacon(ar, skb);
2280
Michal Kazior7aa7a722014-08-25 12:09:38 +02002281 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo5e3dd152013-06-12 20:52:10 +03002282 "event mgmt rx skb %p len %d ftype %02x stype %02x\n",
2283 skb, skb->len,
2284 fc & IEEE80211_FCTL_FTYPE, fc & IEEE80211_FCTL_STYPE);
2285
Michal Kazior7aa7a722014-08-25 12:09:38 +02002286 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo5e3dd152013-06-12 20:52:10 +03002287 "event mgmt rx freq %d band %d snr %d, rate_idx %d\n",
2288 status->freq, status->band, status->signal,
2289 status->rate_idx);
2290
Kalle Valo5e3dd152013-06-12 20:52:10 +03002291 ieee80211_rx(ar->hw, skb);
2292 return 0;
2293}
2294
Michal Kazior2e1dea42013-07-31 10:32:40 +02002295static int freq_to_idx(struct ath10k *ar, int freq)
2296{
2297 struct ieee80211_supported_band *sband;
2298 int band, ch, idx = 0;
2299
2300 for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) {
2301 sband = ar->hw->wiphy->bands[band];
2302 if (!sband)
2303 continue;
2304
2305 for (ch = 0; ch < sband->n_channels; ch++, idx++)
2306 if (sband->channels[ch].center_freq == freq)
2307 goto exit;
2308 }
2309
2310exit:
2311 return idx;
2312}
2313
Michal Kaziord7579d12014-12-03 10:10:54 +02002314static int ath10k_wmi_op_pull_ch_info_ev(struct ath10k *ar, struct sk_buff *skb,
2315 struct wmi_ch_info_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02002316{
2317 struct wmi_chan_info_event *ev = (void *)skb->data;
2318
2319 if (skb->len < sizeof(*ev))
2320 return -EPROTO;
2321
2322 skb_pull(skb, sizeof(*ev));
2323 arg->err_code = ev->err_code;
2324 arg->freq = ev->freq;
2325 arg->cmd_flags = ev->cmd_flags;
2326 arg->noise_floor = ev->noise_floor;
2327 arg->rx_clear_count = ev->rx_clear_count;
2328 arg->cycle_count = ev->cycle_count;
2329
2330 return 0;
2331}
2332
Raja Manib2297ba2015-06-22 20:22:23 +05302333static int ath10k_wmi_10_4_op_pull_ch_info_ev(struct ath10k *ar,
2334 struct sk_buff *skb,
2335 struct wmi_ch_info_ev_arg *arg)
2336{
2337 struct wmi_10_4_chan_info_event *ev = (void *)skb->data;
2338
2339 if (skb->len < sizeof(*ev))
2340 return -EPROTO;
2341
2342 skb_pull(skb, sizeof(*ev));
2343 arg->err_code = ev->err_code;
2344 arg->freq = ev->freq;
2345 arg->cmd_flags = ev->cmd_flags;
2346 arg->noise_floor = ev->noise_floor;
2347 arg->rx_clear_count = ev->rx_clear_count;
2348 arg->cycle_count = ev->cycle_count;
2349 arg->chan_tx_pwr_range = ev->chan_tx_pwr_range;
2350 arg->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
2351 arg->rx_frame_count = ev->rx_frame_count;
2352
2353 return 0;
2354}
2355
Michal Kazior0226d602014-12-03 10:11:22 +02002356void ath10k_wmi_event_chan_info(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002357{
Michal Kazior32653cf2014-12-03 10:10:26 +02002358 struct wmi_ch_info_ev_arg arg = {};
Michal Kazior2e1dea42013-07-31 10:32:40 +02002359 struct survey_info *survey;
2360 u32 err_code, freq, cmd_flags, noise_floor, rx_clear_count, cycle_count;
Michal Kazior32653cf2014-12-03 10:10:26 +02002361 int idx, ret;
Michal Kazior2e1dea42013-07-31 10:32:40 +02002362
Michal Kaziord7579d12014-12-03 10:10:54 +02002363 ret = ath10k_wmi_pull_ch_info(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02002364 if (ret) {
2365 ath10k_warn(ar, "failed to parse chan info event: %d\n", ret);
2366 return;
2367 }
Michal Kazior2e1dea42013-07-31 10:32:40 +02002368
Michal Kazior32653cf2014-12-03 10:10:26 +02002369 err_code = __le32_to_cpu(arg.err_code);
2370 freq = __le32_to_cpu(arg.freq);
2371 cmd_flags = __le32_to_cpu(arg.cmd_flags);
2372 noise_floor = __le32_to_cpu(arg.noise_floor);
2373 rx_clear_count = __le32_to_cpu(arg.rx_clear_count);
2374 cycle_count = __le32_to_cpu(arg.cycle_count);
Michal Kazior2e1dea42013-07-31 10:32:40 +02002375
Michal Kazior7aa7a722014-08-25 12:09:38 +02002376 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior2e1dea42013-07-31 10:32:40 +02002377 "chan info err_code %d freq %d cmd_flags %d noise_floor %d rx_clear_count %d cycle_count %d\n",
2378 err_code, freq, cmd_flags, noise_floor, rx_clear_count,
2379 cycle_count);
2380
2381 spin_lock_bh(&ar->data_lock);
2382
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002383 switch (ar->scan.state) {
2384 case ATH10K_SCAN_IDLE:
2385 case ATH10K_SCAN_STARTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02002386 ath10k_warn(ar, "received chan info event without a scan request, ignoring\n");
Michal Kazior2e1dea42013-07-31 10:32:40 +02002387 goto exit;
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002388 case ATH10K_SCAN_RUNNING:
2389 case ATH10K_SCAN_ABORTING:
2390 break;
Michal Kazior2e1dea42013-07-31 10:32:40 +02002391 }
2392
2393 idx = freq_to_idx(ar, freq);
2394 if (idx >= ARRAY_SIZE(ar->survey)) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002395 ath10k_warn(ar, "chan info: invalid frequency %d (idx %d out of bounds)\n",
Michal Kazior2e1dea42013-07-31 10:32:40 +02002396 freq, idx);
2397 goto exit;
2398 }
2399
2400 if (cmd_flags & WMI_CHAN_INFO_FLAG_COMPLETE) {
Michal Kazior44b7d482015-05-25 14:06:19 +02002401 if (ar->ch_info_can_report_survey) {
2402 survey = &ar->survey[idx];
2403 survey->noise = noise_floor;
2404 survey->filled = SURVEY_INFO_NOISE_DBM;
Michal Kazior2e1dea42013-07-31 10:32:40 +02002405
Michal Kazior44b7d482015-05-25 14:06:19 +02002406 ath10k_hw_fill_survey_time(ar,
2407 survey,
2408 cycle_count,
2409 rx_clear_count,
2410 ar->survey_last_cycle_count,
2411 ar->survey_last_rx_clear_count);
2412 }
Michal Kazior587f7032015-05-25 14:06:18 +02002413
Michal Kazior44b7d482015-05-25 14:06:19 +02002414 ar->ch_info_can_report_survey = false;
2415 } else {
2416 ar->ch_info_can_report_survey = true;
Michal Kazior2e1dea42013-07-31 10:32:40 +02002417 }
2418
Vasanthakumar Thiagarajan3d2a2e22015-08-12 16:24:04 +05302419 if (!(cmd_flags & WMI_CHAN_INFO_FLAG_PRE_COMPLETE)) {
2420 ar->survey_last_rx_clear_count = rx_clear_count;
2421 ar->survey_last_cycle_count = cycle_count;
2422 }
Michal Kazior2e1dea42013-07-31 10:32:40 +02002423
2424exit:
2425 spin_unlock_bh(&ar->data_lock);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002426}
2427
Michal Kazior0226d602014-12-03 10:11:22 +02002428void ath10k_wmi_event_echo(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002429{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002430 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_ECHO_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002431}
2432
Michal Kazior0226d602014-12-03 10:11:22 +02002433int ath10k_wmi_event_debug_mesg(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002434{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002435 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event debug mesg len %d\n",
Kalle Valo869526b2014-01-03 12:59:26 +02002436 skb->len);
2437
Michal Kaziord35a6c12014-09-02 11:00:21 +03002438 trace_ath10k_wmi_dbglog(ar, skb->data, skb->len);
Kalle Valo869526b2014-01-03 12:59:26 +02002439
2440 return 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002441}
2442
Michal Kaziorb91251f2015-01-24 12:14:49 +02002443void ath10k_wmi_pull_pdev_stats_base(const struct wmi_pdev_stats_base *src,
2444 struct ath10k_fw_stats_pdev *dst)
Michal Kaziord15fb522014-09-25 12:33:47 +02002445{
Michal Kaziord15fb522014-09-25 12:33:47 +02002446 dst->ch_noise_floor = __le32_to_cpu(src->chan_nf);
2447 dst->tx_frame_count = __le32_to_cpu(src->tx_frame_count);
2448 dst->rx_frame_count = __le32_to_cpu(src->rx_frame_count);
2449 dst->rx_clear_count = __le32_to_cpu(src->rx_clear_count);
2450 dst->cycle_count = __le32_to_cpu(src->cycle_count);
2451 dst->phy_err_count = __le32_to_cpu(src->phy_err_count);
2452 dst->chan_tx_power = __le32_to_cpu(src->chan_tx_pwr);
Michal Kaziorb91251f2015-01-24 12:14:49 +02002453}
Michal Kaziord15fb522014-09-25 12:33:47 +02002454
Michal Kaziorb91251f2015-01-24 12:14:49 +02002455void ath10k_wmi_pull_pdev_stats_tx(const struct wmi_pdev_stats_tx *src,
2456 struct ath10k_fw_stats_pdev *dst)
2457{
2458 dst->comp_queued = __le32_to_cpu(src->comp_queued);
2459 dst->comp_delivered = __le32_to_cpu(src->comp_delivered);
2460 dst->msdu_enqued = __le32_to_cpu(src->msdu_enqued);
2461 dst->mpdu_enqued = __le32_to_cpu(src->mpdu_enqued);
2462 dst->wmm_drop = __le32_to_cpu(src->wmm_drop);
2463 dst->local_enqued = __le32_to_cpu(src->local_enqued);
2464 dst->local_freed = __le32_to_cpu(src->local_freed);
2465 dst->hw_queued = __le32_to_cpu(src->hw_queued);
2466 dst->hw_reaped = __le32_to_cpu(src->hw_reaped);
2467 dst->underrun = __le32_to_cpu(src->underrun);
2468 dst->tx_abort = __le32_to_cpu(src->tx_abort);
2469 dst->mpdus_requed = __le32_to_cpu(src->mpdus_requed);
2470 dst->tx_ko = __le32_to_cpu(src->tx_ko);
2471 dst->data_rc = __le32_to_cpu(src->data_rc);
2472 dst->self_triggers = __le32_to_cpu(src->self_triggers);
2473 dst->sw_retry_failure = __le32_to_cpu(src->sw_retry_failure);
2474 dst->illgl_rate_phy_err = __le32_to_cpu(src->illgl_rate_phy_err);
2475 dst->pdev_cont_xretry = __le32_to_cpu(src->pdev_cont_xretry);
2476 dst->pdev_tx_timeout = __le32_to_cpu(src->pdev_tx_timeout);
2477 dst->pdev_resets = __le32_to_cpu(src->pdev_resets);
2478 dst->phy_underrun = __le32_to_cpu(src->phy_underrun);
2479 dst->txop_ovf = __le32_to_cpu(src->txop_ovf);
2480}
Michal Kaziord15fb522014-09-25 12:33:47 +02002481
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02002482static void
2483ath10k_wmi_10_4_pull_pdev_stats_tx(const struct wmi_10_4_pdev_stats_tx *src,
2484 struct ath10k_fw_stats_pdev *dst)
2485{
2486 dst->comp_queued = __le32_to_cpu(src->comp_queued);
2487 dst->comp_delivered = __le32_to_cpu(src->comp_delivered);
2488 dst->msdu_enqued = __le32_to_cpu(src->msdu_enqued);
2489 dst->mpdu_enqued = __le32_to_cpu(src->mpdu_enqued);
2490 dst->wmm_drop = __le32_to_cpu(src->wmm_drop);
2491 dst->local_enqued = __le32_to_cpu(src->local_enqued);
2492 dst->local_freed = __le32_to_cpu(src->local_freed);
2493 dst->hw_queued = __le32_to_cpu(src->hw_queued);
2494 dst->hw_reaped = __le32_to_cpu(src->hw_reaped);
2495 dst->underrun = __le32_to_cpu(src->underrun);
2496 dst->tx_abort = __le32_to_cpu(src->tx_abort);
2497 dst->mpdus_requed = __le32_to_cpu(src->mpdus_requed);
2498 dst->tx_ko = __le32_to_cpu(src->tx_ko);
2499 dst->data_rc = __le32_to_cpu(src->data_rc);
2500 dst->self_triggers = __le32_to_cpu(src->self_triggers);
2501 dst->sw_retry_failure = __le32_to_cpu(src->sw_retry_failure);
2502 dst->illgl_rate_phy_err = __le32_to_cpu(src->illgl_rate_phy_err);
2503 dst->pdev_cont_xretry = __le32_to_cpu(src->pdev_cont_xretry);
2504 dst->pdev_tx_timeout = __le32_to_cpu(src->pdev_tx_timeout);
2505 dst->pdev_resets = __le32_to_cpu(src->pdev_resets);
2506 dst->phy_underrun = __le32_to_cpu(src->phy_underrun);
2507 dst->txop_ovf = __le32_to_cpu(src->txop_ovf);
2508 dst->hw_paused = __le32_to_cpu(src->hw_paused);
2509 dst->seq_posted = __le32_to_cpu(src->seq_posted);
2510 dst->seq_failed_queueing =
2511 __le32_to_cpu(src->seq_failed_queueing);
2512 dst->seq_completed = __le32_to_cpu(src->seq_completed);
2513 dst->seq_restarted = __le32_to_cpu(src->seq_restarted);
2514 dst->mu_seq_posted = __le32_to_cpu(src->mu_seq_posted);
2515 dst->mpdus_sw_flush = __le32_to_cpu(src->mpdus_sw_flush);
2516 dst->mpdus_hw_filter = __le32_to_cpu(src->mpdus_hw_filter);
2517 dst->mpdus_truncated = __le32_to_cpu(src->mpdus_truncated);
2518 dst->mpdus_ack_failed = __le32_to_cpu(src->mpdus_ack_failed);
2519 dst->mpdus_hw_filter = __le32_to_cpu(src->mpdus_hw_filter);
2520 dst->mpdus_expired = __le32_to_cpu(src->mpdus_expired);
2521}
2522
Michal Kaziorb91251f2015-01-24 12:14:49 +02002523void ath10k_wmi_pull_pdev_stats_rx(const struct wmi_pdev_stats_rx *src,
2524 struct ath10k_fw_stats_pdev *dst)
2525{
2526 dst->mid_ppdu_route_change = __le32_to_cpu(src->mid_ppdu_route_change);
2527 dst->status_rcvd = __le32_to_cpu(src->status_rcvd);
2528 dst->r0_frags = __le32_to_cpu(src->r0_frags);
2529 dst->r1_frags = __le32_to_cpu(src->r1_frags);
2530 dst->r2_frags = __le32_to_cpu(src->r2_frags);
2531 dst->r3_frags = __le32_to_cpu(src->r3_frags);
2532 dst->htt_msdus = __le32_to_cpu(src->htt_msdus);
2533 dst->htt_mpdus = __le32_to_cpu(src->htt_mpdus);
2534 dst->loc_msdus = __le32_to_cpu(src->loc_msdus);
2535 dst->loc_mpdus = __le32_to_cpu(src->loc_mpdus);
2536 dst->oversize_amsdu = __le32_to_cpu(src->oversize_amsdu);
2537 dst->phy_errs = __le32_to_cpu(src->phy_errs);
2538 dst->phy_err_drop = __le32_to_cpu(src->phy_err_drop);
2539 dst->mpdu_errs = __le32_to_cpu(src->mpdu_errs);
2540}
2541
2542void ath10k_wmi_pull_pdev_stats_extra(const struct wmi_pdev_stats_extra *src,
2543 struct ath10k_fw_stats_pdev *dst)
2544{
2545 dst->ack_rx_bad = __le32_to_cpu(src->ack_rx_bad);
2546 dst->rts_bad = __le32_to_cpu(src->rts_bad);
2547 dst->rts_good = __le32_to_cpu(src->rts_good);
2548 dst->fcs_bad = __le32_to_cpu(src->fcs_bad);
2549 dst->no_beacons = __le32_to_cpu(src->no_beacons);
2550 dst->mib_int_count = __le32_to_cpu(src->mib_int_count);
Michal Kaziord15fb522014-09-25 12:33:47 +02002551}
2552
Michal Kazior0226d602014-12-03 10:11:22 +02002553void ath10k_wmi_pull_peer_stats(const struct wmi_peer_stats *src,
2554 struct ath10k_fw_stats_peer *dst)
Michal Kaziord15fb522014-09-25 12:33:47 +02002555{
2556 ether_addr_copy(dst->peer_macaddr, src->peer_macaddr.addr);
2557 dst->peer_rssi = __le32_to_cpu(src->peer_rssi);
2558 dst->peer_tx_rate = __le32_to_cpu(src->peer_tx_rate);
2559}
2560
Michal Kaziord7579d12014-12-03 10:10:54 +02002561static int ath10k_wmi_main_op_pull_fw_stats(struct ath10k *ar,
2562 struct sk_buff *skb,
2563 struct ath10k_fw_stats *stats)
Michal Kaziord15fb522014-09-25 12:33:47 +02002564{
2565 const struct wmi_stats_event *ev = (void *)skb->data;
2566 u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
2567 int i;
2568
2569 if (!skb_pull(skb, sizeof(*ev)))
2570 return -EPROTO;
2571
2572 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2573 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2574 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2575
Michal Kazior53268492014-09-25 12:33:50 +02002576 for (i = 0; i < num_pdev_stats; i++) {
Michal Kaziord15fb522014-09-25 12:33:47 +02002577 const struct wmi_pdev_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02002578 struct ath10k_fw_stats_pdev *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02002579
2580 src = (void *)skb->data;
2581 if (!skb_pull(skb, sizeof(*src)))
2582 return -EPROTO;
2583
Michal Kazior53268492014-09-25 12:33:50 +02002584 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2585 if (!dst)
2586 continue;
2587
Michal Kaziorb91251f2015-01-24 12:14:49 +02002588 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2589 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2590 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2591
Michal Kazior53268492014-09-25 12:33:50 +02002592 list_add_tail(&dst->list, &stats->pdevs);
Michal Kaziord15fb522014-09-25 12:33:47 +02002593 }
2594
2595 /* fw doesn't implement vdev stats */
2596
2597 for (i = 0; i < num_peer_stats; i++) {
2598 const struct wmi_peer_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02002599 struct ath10k_fw_stats_peer *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02002600
2601 src = (void *)skb->data;
2602 if (!skb_pull(skb, sizeof(*src)))
2603 return -EPROTO;
2604
Michal Kazior53268492014-09-25 12:33:50 +02002605 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2606 if (!dst)
2607 continue;
2608
2609 ath10k_wmi_pull_peer_stats(src, dst);
2610 list_add_tail(&dst->list, &stats->peers);
Michal Kaziord15fb522014-09-25 12:33:47 +02002611 }
2612
2613 return 0;
2614}
2615
Michal Kaziord7579d12014-12-03 10:10:54 +02002616static int ath10k_wmi_10x_op_pull_fw_stats(struct ath10k *ar,
2617 struct sk_buff *skb,
2618 struct ath10k_fw_stats *stats)
Michal Kaziord15fb522014-09-25 12:33:47 +02002619{
2620 const struct wmi_stats_event *ev = (void *)skb->data;
2621 u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
2622 int i;
2623
2624 if (!skb_pull(skb, sizeof(*ev)))
2625 return -EPROTO;
2626
2627 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2628 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2629 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2630
Michal Kazior53268492014-09-25 12:33:50 +02002631 for (i = 0; i < num_pdev_stats; i++) {
Michal Kaziord15fb522014-09-25 12:33:47 +02002632 const struct wmi_10x_pdev_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02002633 struct ath10k_fw_stats_pdev *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02002634
2635 src = (void *)skb->data;
2636 if (!skb_pull(skb, sizeof(*src)))
2637 return -EPROTO;
2638
Michal Kazior53268492014-09-25 12:33:50 +02002639 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2640 if (!dst)
2641 continue;
Michal Kaziord15fb522014-09-25 12:33:47 +02002642
Michal Kaziorb91251f2015-01-24 12:14:49 +02002643 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2644 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2645 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2646 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
Michal Kazior53268492014-09-25 12:33:50 +02002647
2648 list_add_tail(&dst->list, &stats->pdevs);
Michal Kaziord15fb522014-09-25 12:33:47 +02002649 }
2650
2651 /* fw doesn't implement vdev stats */
2652
2653 for (i = 0; i < num_peer_stats; i++) {
2654 const struct wmi_10x_peer_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02002655 struct ath10k_fw_stats_peer *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02002656
2657 src = (void *)skb->data;
2658 if (!skb_pull(skb, sizeof(*src)))
2659 return -EPROTO;
2660
Michal Kazior53268492014-09-25 12:33:50 +02002661 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2662 if (!dst)
2663 continue;
Michal Kaziord15fb522014-09-25 12:33:47 +02002664
Michal Kazior53268492014-09-25 12:33:50 +02002665 ath10k_wmi_pull_peer_stats(&src->old, dst);
2666
2667 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
2668
2669 list_add_tail(&dst->list, &stats->peers);
Michal Kaziord15fb522014-09-25 12:33:47 +02002670 }
2671
2672 return 0;
2673}
2674
Michal Kazior20de2222015-01-24 12:14:49 +02002675static int ath10k_wmi_10_2_op_pull_fw_stats(struct ath10k *ar,
2676 struct sk_buff *skb,
2677 struct ath10k_fw_stats *stats)
2678{
2679 const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2680 u32 num_pdev_stats;
2681 u32 num_pdev_ext_stats;
2682 u32 num_vdev_stats;
2683 u32 num_peer_stats;
2684 int i;
2685
2686 if (!skb_pull(skb, sizeof(*ev)))
2687 return -EPROTO;
2688
2689 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2690 num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
2691 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2692 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2693
2694 for (i = 0; i < num_pdev_stats; i++) {
2695 const struct wmi_10_2_pdev_stats *src;
2696 struct ath10k_fw_stats_pdev *dst;
2697
2698 src = (void *)skb->data;
2699 if (!skb_pull(skb, sizeof(*src)))
2700 return -EPROTO;
2701
2702 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2703 if (!dst)
2704 continue;
2705
2706 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2707 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2708 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2709 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2710 /* FIXME: expose 10.2 specific values */
2711
2712 list_add_tail(&dst->list, &stats->pdevs);
2713 }
2714
2715 for (i = 0; i < num_pdev_ext_stats; i++) {
2716 const struct wmi_10_2_pdev_ext_stats *src;
2717
2718 src = (void *)skb->data;
2719 if (!skb_pull(skb, sizeof(*src)))
2720 return -EPROTO;
2721
2722 /* FIXME: expose values to userspace
2723 *
2724 * Note: Even though this loop seems to do nothing it is
2725 * required to parse following sub-structures properly.
2726 */
2727 }
2728
2729 /* fw doesn't implement vdev stats */
2730
2731 for (i = 0; i < num_peer_stats; i++) {
2732 const struct wmi_10_2_peer_stats *src;
2733 struct ath10k_fw_stats_peer *dst;
2734
2735 src = (void *)skb->data;
2736 if (!skb_pull(skb, sizeof(*src)))
2737 return -EPROTO;
2738
2739 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2740 if (!dst)
2741 continue;
2742
2743 ath10k_wmi_pull_peer_stats(&src->old, dst);
2744
2745 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
2746 /* FIXME: expose 10.2 specific values */
2747
2748 list_add_tail(&dst->list, &stats->peers);
2749 }
2750
2751 return 0;
2752}
2753
2754static int ath10k_wmi_10_2_4_op_pull_fw_stats(struct ath10k *ar,
2755 struct sk_buff *skb,
2756 struct ath10k_fw_stats *stats)
2757{
2758 const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2759 u32 num_pdev_stats;
2760 u32 num_pdev_ext_stats;
2761 u32 num_vdev_stats;
2762 u32 num_peer_stats;
2763 int i;
2764
2765 if (!skb_pull(skb, sizeof(*ev)))
2766 return -EPROTO;
2767
2768 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2769 num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
2770 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2771 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2772
2773 for (i = 0; i < num_pdev_stats; i++) {
2774 const struct wmi_10_2_pdev_stats *src;
2775 struct ath10k_fw_stats_pdev *dst;
2776
2777 src = (void *)skb->data;
2778 if (!skb_pull(skb, sizeof(*src)))
2779 return -EPROTO;
2780
2781 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2782 if (!dst)
2783 continue;
2784
2785 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2786 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2787 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2788 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2789 /* FIXME: expose 10.2 specific values */
2790
2791 list_add_tail(&dst->list, &stats->pdevs);
2792 }
2793
2794 for (i = 0; i < num_pdev_ext_stats; i++) {
2795 const struct wmi_10_2_pdev_ext_stats *src;
2796
2797 src = (void *)skb->data;
2798 if (!skb_pull(skb, sizeof(*src)))
2799 return -EPROTO;
2800
2801 /* FIXME: expose values to userspace
2802 *
2803 * Note: Even though this loop seems to do nothing it is
2804 * required to parse following sub-structures properly.
2805 */
2806 }
2807
2808 /* fw doesn't implement vdev stats */
2809
2810 for (i = 0; i < num_peer_stats; i++) {
2811 const struct wmi_10_2_4_peer_stats *src;
2812 struct ath10k_fw_stats_peer *dst;
2813
2814 src = (void *)skb->data;
2815 if (!skb_pull(skb, sizeof(*src)))
2816 return -EPROTO;
2817
2818 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2819 if (!dst)
2820 continue;
2821
2822 ath10k_wmi_pull_peer_stats(&src->common.old, dst);
2823
2824 dst->peer_rx_rate = __le32_to_cpu(src->common.peer_rx_rate);
2825 /* FIXME: expose 10.2 specific values */
2826
2827 list_add_tail(&dst->list, &stats->peers);
2828 }
2829
2830 return 0;
2831}
2832
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02002833static int ath10k_wmi_10_4_op_pull_fw_stats(struct ath10k *ar,
2834 struct sk_buff *skb,
2835 struct ath10k_fw_stats *stats)
2836{
2837 const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2838 u32 num_pdev_stats;
2839 u32 num_pdev_ext_stats;
2840 u32 num_vdev_stats;
2841 u32 num_peer_stats;
2842 int i;
2843
2844 if (!skb_pull(skb, sizeof(*ev)))
2845 return -EPROTO;
2846
2847 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2848 num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
2849 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2850 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2851
2852 for (i = 0; i < num_pdev_stats; i++) {
2853 const struct wmi_10_4_pdev_stats *src;
2854 struct ath10k_fw_stats_pdev *dst;
2855
2856 src = (void *)skb->data;
2857 if (!skb_pull(skb, sizeof(*src)))
2858 return -EPROTO;
2859
2860 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2861 if (!dst)
2862 continue;
2863
2864 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2865 ath10k_wmi_10_4_pull_pdev_stats_tx(&src->tx, dst);
2866 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2867 dst->rx_ovfl_errs = __le32_to_cpu(src->rx_ovfl_errs);
2868 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2869
2870 list_add_tail(&dst->list, &stats->pdevs);
2871 }
2872
2873 for (i = 0; i < num_pdev_ext_stats; i++) {
2874 const struct wmi_10_2_pdev_ext_stats *src;
2875
2876 src = (void *)skb->data;
2877 if (!skb_pull(skb, sizeof(*src)))
2878 return -EPROTO;
2879
2880 /* FIXME: expose values to userspace
2881 *
2882 * Note: Even though this loop seems to do nothing it is
2883 * required to parse following sub-structures properly.
2884 */
2885 }
2886
2887 /* fw doesn't implement vdev stats */
2888
2889 for (i = 0; i < num_peer_stats; i++) {
2890 const struct wmi_10_4_peer_stats *src;
2891 struct ath10k_fw_stats_peer *dst;
2892
2893 src = (void *)skb->data;
2894 if (!skb_pull(skb, sizeof(*src)))
2895 return -EPROTO;
2896
2897 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2898 if (!dst)
2899 continue;
2900
2901 ether_addr_copy(dst->peer_macaddr, src->peer_macaddr.addr);
2902 dst->peer_rssi = __le32_to_cpu(src->peer_rssi);
2903 dst->peer_tx_rate = __le32_to_cpu(src->peer_tx_rate);
2904 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
2905 /* FIXME: expose 10.4 specific values */
2906
2907 list_add_tail(&dst->list, &stats->peers);
2908 }
2909
2910 return 0;
2911}
2912
Michal Kazior0226d602014-12-03 10:11:22 +02002913void ath10k_wmi_event_update_stats(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002914{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002915 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_UPDATE_STATS_EVENTID\n");
Michal Kazior60ef4012014-09-25 12:33:48 +02002916 ath10k_debug_fw_stats_process(ar, skb);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002917}
2918
Michal Kaziord7579d12014-12-03 10:10:54 +02002919static int
2920ath10k_wmi_op_pull_vdev_start_ev(struct ath10k *ar, struct sk_buff *skb,
2921 struct wmi_vdev_start_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02002922{
2923 struct wmi_vdev_start_response_event *ev = (void *)skb->data;
2924
2925 if (skb->len < sizeof(*ev))
2926 return -EPROTO;
2927
2928 skb_pull(skb, sizeof(*ev));
2929 arg->vdev_id = ev->vdev_id;
2930 arg->req_id = ev->req_id;
2931 arg->resp_type = ev->resp_type;
2932 arg->status = ev->status;
2933
2934 return 0;
2935}
2936
Michal Kazior0226d602014-12-03 10:11:22 +02002937void ath10k_wmi_event_vdev_start_resp(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002938{
Michal Kazior32653cf2014-12-03 10:10:26 +02002939 struct wmi_vdev_start_ev_arg arg = {};
2940 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002941
Michal Kazior7aa7a722014-08-25 12:09:38 +02002942 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_START_RESP_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002943
Michal Kaziord7579d12014-12-03 10:10:54 +02002944 ret = ath10k_wmi_pull_vdev_start(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02002945 if (ret) {
2946 ath10k_warn(ar, "failed to parse vdev start event: %d\n", ret);
2947 return;
2948 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03002949
Michal Kazior32653cf2014-12-03 10:10:26 +02002950 if (WARN_ON(__le32_to_cpu(arg.status)))
Kalle Valo5e3dd152013-06-12 20:52:10 +03002951 return;
2952
2953 complete(&ar->vdev_setup_done);
2954}
2955
Michal Kazior0226d602014-12-03 10:11:22 +02002956void ath10k_wmi_event_vdev_stopped(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002957{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002958 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STOPPED_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002959 complete(&ar->vdev_setup_done);
2960}
2961
Michal Kaziord7579d12014-12-03 10:10:54 +02002962static int
2963ath10k_wmi_op_pull_peer_kick_ev(struct ath10k *ar, struct sk_buff *skb,
2964 struct wmi_peer_kick_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02002965{
2966 struct wmi_peer_sta_kickout_event *ev = (void *)skb->data;
2967
2968 if (skb->len < sizeof(*ev))
2969 return -EPROTO;
2970
2971 skb_pull(skb, sizeof(*ev));
2972 arg->mac_addr = ev->peer_macaddr.addr;
2973
2974 return 0;
2975}
2976
Michal Kazior0226d602014-12-03 10:11:22 +02002977void ath10k_wmi_event_peer_sta_kickout(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002978{
Michal Kazior32653cf2014-12-03 10:10:26 +02002979 struct wmi_peer_kick_ev_arg arg = {};
Kalle Valo5a13e762014-01-20 11:01:46 +02002980 struct ieee80211_sta *sta;
Michal Kazior32653cf2014-12-03 10:10:26 +02002981 int ret;
Kalle Valo5a13e762014-01-20 11:01:46 +02002982
Michal Kaziord7579d12014-12-03 10:10:54 +02002983 ret = ath10k_wmi_pull_peer_kick(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02002984 if (ret) {
2985 ath10k_warn(ar, "failed to parse peer kickout event: %d\n",
2986 ret);
2987 return;
2988 }
Kalle Valo5a13e762014-01-20 11:01:46 +02002989
Michal Kazior7aa7a722014-08-25 12:09:38 +02002990 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event peer sta kickout %pM\n",
Michal Kazior32653cf2014-12-03 10:10:26 +02002991 arg.mac_addr);
Kalle Valo5a13e762014-01-20 11:01:46 +02002992
2993 rcu_read_lock();
2994
Michal Kazior32653cf2014-12-03 10:10:26 +02002995 sta = ieee80211_find_sta_by_ifaddr(ar->hw, arg.mac_addr, NULL);
Kalle Valo5a13e762014-01-20 11:01:46 +02002996 if (!sta) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002997 ath10k_warn(ar, "Spurious quick kickout for STA %pM\n",
Michal Kazior32653cf2014-12-03 10:10:26 +02002998 arg.mac_addr);
Kalle Valo5a13e762014-01-20 11:01:46 +02002999 goto exit;
3000 }
3001
3002 ieee80211_report_low_ack(sta, 10);
3003
3004exit:
3005 rcu_read_unlock();
Kalle Valo5e3dd152013-06-12 20:52:10 +03003006}
3007
3008/*
3009 * FIXME
3010 *
3011 * We don't report to mac80211 sleep state of connected
3012 * stations. Due to this mac80211 can't fill in TIM IE
3013 * correctly.
3014 *
3015 * I know of no way of getting nullfunc frames that contain
3016 * sleep transition from connected stations - these do not
3017 * seem to be sent from the target to the host. There also
3018 * doesn't seem to be a dedicated event for that. So the
3019 * only way left to do this would be to read tim_bitmap
3020 * during SWBA.
3021 *
3022 * We could probably try using tim_bitmap from SWBA to tell
3023 * mac80211 which stations are asleep and which are not. The
3024 * problem here is calling mac80211 functions so many times
3025 * could take too long and make us miss the time to submit
3026 * the beacon to the target.
3027 *
3028 * So as a workaround we try to extend the TIM IE if there
3029 * is unicast buffered for stations with aid > 7 and fill it
3030 * in ourselves.
3031 */
3032static void ath10k_wmi_update_tim(struct ath10k *ar,
3033 struct ath10k_vif *arvif,
3034 struct sk_buff *bcn,
Raja Mania03fee32015-06-22 20:22:20 +05303035 const struct wmi_tim_info_arg *tim_info)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003036{
3037 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)bcn->data;
3038 struct ieee80211_tim_ie *tim;
3039 u8 *ies, *ie;
3040 u8 ie_len, pvm_len;
Kalle Valoaf762c02014-09-14 12:50:17 +03003041 __le32 t;
Raja Mania03fee32015-06-22 20:22:20 +05303042 u32 v, tim_len;
3043
3044 /* When FW reports 0 in tim_len, ensure atleast first byte
3045 * in tim_bitmap is considered for pvm calculation.
3046 */
3047 tim_len = tim_info->tim_len ? __le32_to_cpu(tim_info->tim_len) : 1;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003048
3049 /* if next SWBA has no tim_changed the tim_bitmap is garbage.
3050 * we must copy the bitmap upon change and reuse it later */
Michal Kazior32653cf2014-12-03 10:10:26 +02003051 if (__le32_to_cpu(tim_info->tim_changed)) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03003052 int i;
3053
Raja Mania03fee32015-06-22 20:22:20 +05303054 if (sizeof(arvif->u.ap.tim_bitmap) < tim_len) {
3055 ath10k_warn(ar, "SWBA TIM field is too big (%u), truncated it to %zu",
3056 tim_len, sizeof(arvif->u.ap.tim_bitmap));
3057 tim_len = sizeof(arvif->u.ap.tim_bitmap);
3058 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03003059
Raja Mania03fee32015-06-22 20:22:20 +05303060 for (i = 0; i < tim_len; i++) {
Michal Kazior32653cf2014-12-03 10:10:26 +02003061 t = tim_info->tim_bitmap[i / 4];
Kalle Valoaf762c02014-09-14 12:50:17 +03003062 v = __le32_to_cpu(t);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003063 arvif->u.ap.tim_bitmap[i] = (v >> ((i % 4) * 8)) & 0xFF;
3064 }
3065
Raja Mania03fee32015-06-22 20:22:20 +05303066 /* FW reports either length 0 or length based on max supported
3067 * station. so we calculate this on our own
3068 */
Kalle Valo5e3dd152013-06-12 20:52:10 +03003069 arvif->u.ap.tim_len = 0;
Raja Mania03fee32015-06-22 20:22:20 +05303070 for (i = 0; i < tim_len; i++)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003071 if (arvif->u.ap.tim_bitmap[i])
3072 arvif->u.ap.tim_len = i;
3073
3074 arvif->u.ap.tim_len++;
3075 }
3076
3077 ies = bcn->data;
3078 ies += ieee80211_hdrlen(hdr->frame_control);
3079 ies += 12; /* fixed parameters */
3080
3081 ie = (u8 *)cfg80211_find_ie(WLAN_EID_TIM, ies,
3082 (u8 *)skb_tail_pointer(bcn) - ies);
3083 if (!ie) {
Michal Kazior09af8f82013-07-05 16:15:08 +03003084 if (arvif->vdev_type != WMI_VDEV_TYPE_IBSS)
Michal Kazior7aa7a722014-08-25 12:09:38 +02003085 ath10k_warn(ar, "no tim ie found;\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003086 return;
3087 }
3088
3089 tim = (void *)ie + 2;
3090 ie_len = ie[1];
3091 pvm_len = ie_len - 3; /* exclude dtim count, dtim period, bmap ctl */
3092
3093 if (pvm_len < arvif->u.ap.tim_len) {
Raja Mania03fee32015-06-22 20:22:20 +05303094 int expand_size = tim_len - pvm_len;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003095 int move_size = skb_tail_pointer(bcn) - (ie + 2 + ie_len);
3096 void *next_ie = ie + 2 + ie_len;
3097
3098 if (skb_put(bcn, expand_size)) {
3099 memmove(next_ie + expand_size, next_ie, move_size);
3100
3101 ie[1] += expand_size;
3102 ie_len += expand_size;
3103 pvm_len += expand_size;
3104 } else {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003105 ath10k_warn(ar, "tim expansion failed\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003106 }
3107 }
3108
Raja Mania03fee32015-06-22 20:22:20 +05303109 if (pvm_len > tim_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003110 ath10k_warn(ar, "tim pvm length is too great (%d)\n", pvm_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003111 return;
3112 }
3113
Michal Kazior32653cf2014-12-03 10:10:26 +02003114 tim->bitmap_ctrl = !!__le32_to_cpu(tim_info->tim_mcast);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003115 memcpy(tim->virtual_map, arvif->u.ap.tim_bitmap, pvm_len);
3116
Michal Kazior748afc42014-01-23 12:48:21 +01003117 if (tim->dtim_count == 0) {
3118 ATH10K_SKB_CB(bcn)->bcn.dtim_zero = true;
3119
Michal Kazior32653cf2014-12-03 10:10:26 +02003120 if (__le32_to_cpu(tim_info->tim_mcast) == 1)
Michal Kazior748afc42014-01-23 12:48:21 +01003121 ATH10K_SKB_CB(bcn)->bcn.deliver_cab = true;
3122 }
3123
Michal Kazior7aa7a722014-08-25 12:09:38 +02003124 ath10k_dbg(ar, ATH10K_DBG_MGMT, "dtim %d/%d mcast %d pvmlen %d\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +03003125 tim->dtim_count, tim->dtim_period,
3126 tim->bitmap_ctrl, pvm_len);
3127}
3128
Kalle Valo5e3dd152013-06-12 20:52:10 +03003129static void ath10k_wmi_update_noa(struct ath10k *ar, struct ath10k_vif *arvif,
3130 struct sk_buff *bcn,
Michal Kazior32653cf2014-12-03 10:10:26 +02003131 const struct wmi_p2p_noa_info *noa)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003132{
Kalle Valo5e3dd152013-06-12 20:52:10 +03003133 if (arvif->vdev_subtype != WMI_VDEV_SUBTYPE_P2P_GO)
3134 return;
3135
Michal Kazior7aa7a722014-08-25 12:09:38 +02003136 ath10k_dbg(ar, ATH10K_DBG_MGMT, "noa changed: %d\n", noa->changed);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003137
Michal Kazior6a948882015-02-26 13:23:17 +01003138 if (noa->changed & WMI_P2P_NOA_CHANGED_BIT)
3139 ath10k_p2p_noa_update(arvif, noa);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003140
3141 if (arvif->u.ap.noa_data)
3142 if (!pskb_expand_head(bcn, 0, arvif->u.ap.noa_len, GFP_ATOMIC))
3143 memcpy(skb_put(bcn, arvif->u.ap.noa_len),
3144 arvif->u.ap.noa_data,
3145 arvif->u.ap.noa_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003146}
3147
Michal Kaziord7579d12014-12-03 10:10:54 +02003148static int ath10k_wmi_op_pull_swba_ev(struct ath10k *ar, struct sk_buff *skb,
3149 struct wmi_swba_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02003150{
3151 struct wmi_host_swba_event *ev = (void *)skb->data;
3152 u32 map;
3153 size_t i;
3154
3155 if (skb->len < sizeof(*ev))
3156 return -EPROTO;
3157
3158 skb_pull(skb, sizeof(*ev));
3159 arg->vdev_map = ev->vdev_map;
3160
3161 for (i = 0, map = __le32_to_cpu(ev->vdev_map); map; map >>= 1) {
3162 if (!(map & BIT(0)))
3163 continue;
3164
3165 /* If this happens there were some changes in firmware and
3166 * ath10k should update the max size of tim_info array.
3167 */
3168 if (WARN_ON_ONCE(i == ARRAY_SIZE(arg->tim_info)))
3169 break;
3170
Raja Mania03fee32015-06-22 20:22:20 +05303171 if (__le32_to_cpu(ev->bcn_info[i].tim_info.tim_len) >
3172 sizeof(ev->bcn_info[i].tim_info.tim_bitmap)) {
3173 ath10k_warn(ar, "refusing to parse invalid swba structure\n");
3174 return -EPROTO;
3175 }
3176
3177 arg->tim_info[i].tim_len = ev->bcn_info[i].tim_info.tim_len;
3178 arg->tim_info[i].tim_mcast = ev->bcn_info[i].tim_info.tim_mcast;
3179 arg->tim_info[i].tim_bitmap =
3180 ev->bcn_info[i].tim_info.tim_bitmap;
3181 arg->tim_info[i].tim_changed =
3182 ev->bcn_info[i].tim_info.tim_changed;
3183 arg->tim_info[i].tim_num_ps_pending =
3184 ev->bcn_info[i].tim_info.tim_num_ps_pending;
3185
Michal Kazior32653cf2014-12-03 10:10:26 +02003186 arg->noa_info[i] = &ev->bcn_info[i].p2p_noa_info;
3187 i++;
3188 }
3189
3190 return 0;
3191}
3192
Raja Mani3cec3be2015-06-22 20:22:21 +05303193static int ath10k_wmi_10_4_op_pull_swba_ev(struct ath10k *ar,
3194 struct sk_buff *skb,
3195 struct wmi_swba_ev_arg *arg)
3196{
3197 struct wmi_10_4_host_swba_event *ev = (void *)skb->data;
3198 u32 map, tim_len;
3199 size_t i;
3200
3201 if (skb->len < sizeof(*ev))
3202 return -EPROTO;
3203
3204 skb_pull(skb, sizeof(*ev));
3205 arg->vdev_map = ev->vdev_map;
3206
3207 for (i = 0, map = __le32_to_cpu(ev->vdev_map); map; map >>= 1) {
3208 if (!(map & BIT(0)))
3209 continue;
3210
3211 /* If this happens there were some changes in firmware and
3212 * ath10k should update the max size of tim_info array.
3213 */
3214 if (WARN_ON_ONCE(i == ARRAY_SIZE(arg->tim_info)))
3215 break;
3216
3217 if (__le32_to_cpu(ev->bcn_info[i].tim_info.tim_len) >
3218 sizeof(ev->bcn_info[i].tim_info.tim_bitmap)) {
3219 ath10k_warn(ar, "refusing to parse invalid swba structure\n");
3220 return -EPROTO;
3221 }
3222
3223 tim_len = __le32_to_cpu(ev->bcn_info[i].tim_info.tim_len);
3224 if (tim_len) {
3225 /* Exclude 4 byte guard length */
3226 tim_len -= 4;
3227 arg->tim_info[i].tim_len = __cpu_to_le32(tim_len);
3228 } else {
3229 arg->tim_info[i].tim_len = 0;
3230 }
3231
3232 arg->tim_info[i].tim_mcast = ev->bcn_info[i].tim_info.tim_mcast;
3233 arg->tim_info[i].tim_bitmap =
3234 ev->bcn_info[i].tim_info.tim_bitmap;
3235 arg->tim_info[i].tim_changed =
3236 ev->bcn_info[i].tim_info.tim_changed;
3237 arg->tim_info[i].tim_num_ps_pending =
3238 ev->bcn_info[i].tim_info.tim_num_ps_pending;
3239
3240 /* 10.4 firmware doesn't have p2p support. notice of absence
3241 * info can be ignored for now.
3242 */
3243
3244 i++;
3245 }
3246
3247 return 0;
3248}
3249
Vivek Natarajan08e75ea2015-08-04 10:45:11 +05303250static enum wmi_txbf_conf ath10k_wmi_10_4_txbf_conf_scheme(struct ath10k *ar)
3251{
3252 return WMI_TXBF_CONF_BEFORE_ASSOC;
3253}
3254
Michal Kazior0226d602014-12-03 10:11:22 +02003255void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003256{
Michal Kazior32653cf2014-12-03 10:10:26 +02003257 struct wmi_swba_ev_arg arg = {};
Kalle Valo5e3dd152013-06-12 20:52:10 +03003258 u32 map;
3259 int i = -1;
Raja Mania03fee32015-06-22 20:22:20 +05303260 const struct wmi_tim_info_arg *tim_info;
Michal Kazior32653cf2014-12-03 10:10:26 +02003261 const struct wmi_p2p_noa_info *noa_info;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003262 struct ath10k_vif *arvif;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003263 struct sk_buff *bcn;
Michal Kazior64badcb2014-09-18 11:18:02 +03003264 dma_addr_t paddr;
Michal Kazior767d34f2014-02-27 18:50:03 +02003265 int ret, vdev_id = 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003266
Michal Kaziord7579d12014-12-03 10:10:54 +02003267 ret = ath10k_wmi_pull_swba(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02003268 if (ret) {
3269 ath10k_warn(ar, "failed to parse swba event: %d\n", ret);
3270 return;
3271 }
3272
3273 map = __le32_to_cpu(arg.vdev_map);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003274
Michal Kazior7aa7a722014-08-25 12:09:38 +02003275 ath10k_dbg(ar, ATH10K_DBG_MGMT, "mgmt swba vdev_map 0x%x\n",
Michal Kazior32653cf2014-12-03 10:10:26 +02003276 map);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003277
3278 for (; map; map >>= 1, vdev_id++) {
3279 if (!(map & 0x1))
3280 continue;
3281
3282 i++;
3283
3284 if (i >= WMI_MAX_AP_VDEV) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003285 ath10k_warn(ar, "swba has corrupted vdev map\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003286 break;
3287 }
3288
Raja Mania03fee32015-06-22 20:22:20 +05303289 tim_info = &arg.tim_info[i];
Michal Kazior32653cf2014-12-03 10:10:26 +02003290 noa_info = arg.noa_info[i];
Kalle Valo5e3dd152013-06-12 20:52:10 +03003291
Michal Kazior7aa7a722014-08-25 12:09:38 +02003292 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo7a8a3962014-03-28 14:35:16 +02003293 "mgmt event bcn_info %d tim_len %d mcast %d changed %d num_ps_pending %d bitmap 0x%08x%08x%08x%08x\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +03003294 i,
Michal Kazior32653cf2014-12-03 10:10:26 +02003295 __le32_to_cpu(tim_info->tim_len),
3296 __le32_to_cpu(tim_info->tim_mcast),
3297 __le32_to_cpu(tim_info->tim_changed),
3298 __le32_to_cpu(tim_info->tim_num_ps_pending),
3299 __le32_to_cpu(tim_info->tim_bitmap[3]),
3300 __le32_to_cpu(tim_info->tim_bitmap[2]),
3301 __le32_to_cpu(tim_info->tim_bitmap[1]),
3302 __le32_to_cpu(tim_info->tim_bitmap[0]));
Kalle Valo5e3dd152013-06-12 20:52:10 +03003303
Raja Mania03fee32015-06-22 20:22:20 +05303304 /* TODO: Only first 4 word from tim_bitmap is dumped.
3305 * Extend debug code to dump full tim_bitmap.
3306 */
3307
Kalle Valo5e3dd152013-06-12 20:52:10 +03003308 arvif = ath10k_get_arvif(ar, vdev_id);
3309 if (arvif == NULL) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003310 ath10k_warn(ar, "no vif for vdev_id %d found\n",
3311 vdev_id);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003312 continue;
3313 }
3314
Michal Kaziorc2df44b2014-01-23 11:38:26 +01003315 /* There are no completions for beacons so wait for next SWBA
3316 * before telling mac80211 to decrement CSA counter
3317 *
3318 * Once CSA counter is completed stop sending beacons until
3319 * actual channel switch is done */
3320 if (arvif->vif->csa_active &&
3321 ieee80211_csa_is_complete(arvif->vif)) {
3322 ieee80211_csa_finish(arvif->vif);
3323 continue;
3324 }
3325
Kalle Valo5e3dd152013-06-12 20:52:10 +03003326 bcn = ieee80211_beacon_get(ar->hw, arvif->vif);
3327 if (!bcn) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003328 ath10k_warn(ar, "could not get mac80211 beacon\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003329 continue;
3330 }
3331
Michal Kazior4b604552014-07-21 21:03:09 +03003332 ath10k_tx_h_seq_no(arvif->vif, bcn);
Michal Kazior32653cf2014-12-03 10:10:26 +02003333 ath10k_wmi_update_tim(ar, arvif, bcn, tim_info);
3334 ath10k_wmi_update_noa(ar, arvif, bcn, noa_info);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003335
Michal Kaziored543882013-09-13 14:16:56 +02003336 spin_lock_bh(&ar->data_lock);
Michal Kazior748afc42014-01-23 12:48:21 +01003337
Michal Kaziored543882013-09-13 14:16:56 +02003338 if (arvif->beacon) {
Michal Kazioraf213192015-01-29 14:29:52 +02003339 switch (arvif->beacon_state) {
3340 case ATH10K_BEACON_SENT:
3341 break;
3342 case ATH10K_BEACON_SCHEDULED:
3343 ath10k_warn(ar, "SWBA overrun on vdev %d, skipped old beacon\n",
Michal Kazior748afc42014-01-23 12:48:21 +01003344 arvif->vdev_id);
Michal Kazioraf213192015-01-29 14:29:52 +02003345 break;
3346 case ATH10K_BEACON_SENDING:
3347 ath10k_warn(ar, "SWBA overrun on vdev %d, skipped new beacon\n",
3348 arvif->vdev_id);
3349 dev_kfree_skb(bcn);
3350 goto skip;
3351 }
Michal Kazior748afc42014-01-23 12:48:21 +01003352
Michal Kazior64badcb2014-09-18 11:18:02 +03003353 ath10k_mac_vif_beacon_free(arvif);
Michal Kaziored543882013-09-13 14:16:56 +02003354 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03003355
Michal Kazior64badcb2014-09-18 11:18:02 +03003356 if (!arvif->beacon_buf) {
3357 paddr = dma_map_single(arvif->ar->dev, bcn->data,
3358 bcn->len, DMA_TO_DEVICE);
3359 ret = dma_mapping_error(arvif->ar->dev, paddr);
3360 if (ret) {
3361 ath10k_warn(ar, "failed to map beacon: %d\n",
3362 ret);
3363 dev_kfree_skb_any(bcn);
Michal Kazior5e55e3c2015-08-19 13:10:43 +02003364 ret = -EIO;
Michal Kazior64badcb2014-09-18 11:18:02 +03003365 goto skip;
3366 }
3367
3368 ATH10K_SKB_CB(bcn)->paddr = paddr;
3369 } else {
3370 if (bcn->len > IEEE80211_MAX_FRAME_LEN) {
3371 ath10k_warn(ar, "trimming beacon %d -> %d bytes!\n",
3372 bcn->len, IEEE80211_MAX_FRAME_LEN);
3373 skb_trim(bcn, IEEE80211_MAX_FRAME_LEN);
3374 }
3375 memcpy(arvif->beacon_buf, bcn->data, bcn->len);
3376 ATH10K_SKB_CB(bcn)->paddr = arvif->beacon_paddr;
Michal Kazior767d34f2014-02-27 18:50:03 +02003377 }
Michal Kazior748afc42014-01-23 12:48:21 +01003378
Michal Kaziored543882013-09-13 14:16:56 +02003379 arvif->beacon = bcn;
Michal Kazioraf213192015-01-29 14:29:52 +02003380 arvif->beacon_state = ATH10K_BEACON_SCHEDULED;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003381
Rajkumar Manoharan5ce8e7f2014-11-05 19:14:31 +05303382 trace_ath10k_tx_hdr(ar, bcn->data, bcn->len);
3383 trace_ath10k_tx_payload(ar, bcn->data, bcn->len);
3384
Michal Kazior767d34f2014-02-27 18:50:03 +02003385skip:
Michal Kaziored543882013-09-13 14:16:56 +02003386 spin_unlock_bh(&ar->data_lock);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003387 }
Michal Kazioraf213192015-01-29 14:29:52 +02003388
3389 ath10k_wmi_tx_beacons_nowait(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003390}
3391
Michal Kazior0226d602014-12-03 10:11:22 +02003392void ath10k_wmi_event_tbttoffset_update(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003393{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003394 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TBTTOFFSET_UPDATE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003395}
3396
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003397static void ath10k_dfs_radar_report(struct ath10k *ar,
Raja Mani991adf72015-08-14 11:13:29 +03003398 struct wmi_phyerr_ev_arg *phyerr,
Michal Kazior2332d0a2014-09-18 15:21:25 +02003399 const struct phyerr_radar_report *rr,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003400 u64 tsf)
3401{
3402 u32 reg0, reg1, tsf32l;
Michal Kazior500ff9f2015-03-31 10:26:21 +00003403 struct ieee80211_channel *ch;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003404 struct pulse_event pe;
3405 u64 tsf64;
3406 u8 rssi, width;
3407
3408 reg0 = __le32_to_cpu(rr->reg0);
3409 reg1 = __le32_to_cpu(rr->reg1);
3410
Michal Kazior7aa7a722014-08-25 12:09:38 +02003411 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003412 "wmi phyerr radar report chirp %d max_width %d agc_total_gain %d pulse_delta_diff %d\n",
3413 MS(reg0, RADAR_REPORT_REG0_PULSE_IS_CHIRP),
3414 MS(reg0, RADAR_REPORT_REG0_PULSE_IS_MAX_WIDTH),
3415 MS(reg0, RADAR_REPORT_REG0_AGC_TOTAL_GAIN),
3416 MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_DIFF));
Michal Kazior7aa7a722014-08-25 12:09:38 +02003417 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003418 "wmi phyerr radar report pulse_delta_pean %d pulse_sidx %d fft_valid %d agc_mb_gain %d subchan_mask %d\n",
3419 MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_PEAK),
3420 MS(reg0, RADAR_REPORT_REG0_PULSE_SIDX),
3421 MS(reg1, RADAR_REPORT_REG1_PULSE_SRCH_FFT_VALID),
3422 MS(reg1, RADAR_REPORT_REG1_PULSE_AGC_MB_GAIN),
3423 MS(reg1, RADAR_REPORT_REG1_PULSE_SUBCHAN_MASK));
Michal Kazior7aa7a722014-08-25 12:09:38 +02003424 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003425 "wmi phyerr radar report pulse_tsf_offset 0x%X pulse_dur: %d\n",
3426 MS(reg1, RADAR_REPORT_REG1_PULSE_TSF_OFFSET),
3427 MS(reg1, RADAR_REPORT_REG1_PULSE_DUR));
3428
3429 if (!ar->dfs_detector)
3430 return;
3431
Michal Kazior500ff9f2015-03-31 10:26:21 +00003432 spin_lock_bh(&ar->data_lock);
3433 ch = ar->rx_channel;
3434 spin_unlock_bh(&ar->data_lock);
3435
3436 if (!ch) {
3437 ath10k_warn(ar, "failed to derive channel for radar pulse, treating as radar\n");
3438 goto radar_detected;
3439 }
3440
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003441 /* report event to DFS pattern detector */
Raja Mani991adf72015-08-14 11:13:29 +03003442 tsf32l = phyerr->tsf_timestamp;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003443 tsf64 = tsf & (~0xFFFFFFFFULL);
3444 tsf64 |= tsf32l;
3445
3446 width = MS(reg1, RADAR_REPORT_REG1_PULSE_DUR);
Michal Kazior2332d0a2014-09-18 15:21:25 +02003447 rssi = phyerr->rssi_combined;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003448
3449 /* hardware store this as 8 bit signed value,
3450 * set to zero if negative number
3451 */
3452 if (rssi & 0x80)
3453 rssi = 0;
3454
3455 pe.ts = tsf64;
Michal Kazior500ff9f2015-03-31 10:26:21 +00003456 pe.freq = ch->center_freq;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003457 pe.width = width;
3458 pe.rssi = rssi;
Peter Oh2c3f26a2015-03-04 15:43:46 +02003459 pe.chirp = (MS(reg0, RADAR_REPORT_REG0_PULSE_IS_CHIRP) != 0);
Michal Kazior7aa7a722014-08-25 12:09:38 +02003460 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003461 "dfs add pulse freq: %d, width: %d, rssi %d, tsf: %llX\n",
3462 pe.freq, pe.width, pe.rssi, pe.ts);
3463
3464 ATH10K_DFS_STAT_INC(ar, pulses_detected);
3465
3466 if (!ar->dfs_detector->add_pulse(ar->dfs_detector, &pe)) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003467 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003468 "dfs no pulse pattern detected, yet\n");
3469 return;
3470 }
3471
Michal Kazior500ff9f2015-03-31 10:26:21 +00003472radar_detected:
Michal Kazior7aa7a722014-08-25 12:09:38 +02003473 ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs radar detected\n");
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003474 ATH10K_DFS_STAT_INC(ar, radar_detected);
Marek Puzyniak7d9b40b2013-11-20 10:00:28 +02003475
3476 /* Control radar events reporting in debugfs file
3477 dfs_block_radar_events */
3478 if (ar->dfs_block_radar_events) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003479 ath10k_info(ar, "DFS Radar detected, but ignored as requested\n");
Marek Puzyniak7d9b40b2013-11-20 10:00:28 +02003480 return;
3481 }
3482
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003483 ieee80211_radar_detected(ar->hw);
3484}
3485
3486static int ath10k_dfs_fft_report(struct ath10k *ar,
Raja Mani991adf72015-08-14 11:13:29 +03003487 struct wmi_phyerr_ev_arg *phyerr,
Michal Kazior2332d0a2014-09-18 15:21:25 +02003488 const struct phyerr_fft_report *fftr,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003489 u64 tsf)
3490{
3491 u32 reg0, reg1;
3492 u8 rssi, peak_mag;
3493
3494 reg0 = __le32_to_cpu(fftr->reg0);
3495 reg1 = __le32_to_cpu(fftr->reg1);
Michal Kazior2332d0a2014-09-18 15:21:25 +02003496 rssi = phyerr->rssi_combined;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003497
Michal Kazior7aa7a722014-08-25 12:09:38 +02003498 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003499 "wmi phyerr fft report total_gain_db %d base_pwr_db %d fft_chn_idx %d peak_sidx %d\n",
3500 MS(reg0, SEARCH_FFT_REPORT_REG0_TOTAL_GAIN_DB),
3501 MS(reg0, SEARCH_FFT_REPORT_REG0_BASE_PWR_DB),
3502 MS(reg0, SEARCH_FFT_REPORT_REG0_FFT_CHN_IDX),
3503 MS(reg0, SEARCH_FFT_REPORT_REG0_PEAK_SIDX));
Michal Kazior7aa7a722014-08-25 12:09:38 +02003504 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003505 "wmi phyerr fft report rel_pwr_db %d avgpwr_db %d peak_mag %d num_store_bin %d\n",
3506 MS(reg1, SEARCH_FFT_REPORT_REG1_RELPWR_DB),
3507 MS(reg1, SEARCH_FFT_REPORT_REG1_AVGPWR_DB),
3508 MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG),
3509 MS(reg1, SEARCH_FFT_REPORT_REG1_NUM_STR_BINS_IB));
3510
3511 peak_mag = MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG);
3512
3513 /* false event detection */
3514 if (rssi == DFS_RSSI_POSSIBLY_FALSE &&
3515 peak_mag < 2 * DFS_PEAK_MAG_THOLD_POSSIBLY_FALSE) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003516 ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs false pulse detected\n");
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003517 ATH10K_DFS_STAT_INC(ar, pulses_discarded);
3518 return -EINVAL;
3519 }
3520
3521 return 0;
3522}
3523
Michal Kazior0226d602014-12-03 10:11:22 +02003524void ath10k_wmi_event_dfs(struct ath10k *ar,
Raja Mani991adf72015-08-14 11:13:29 +03003525 struct wmi_phyerr_ev_arg *phyerr,
Michal Kazior0226d602014-12-03 10:11:22 +02003526 u64 tsf)
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003527{
3528 int buf_len, tlv_len, res, i = 0;
Michal Kazior2332d0a2014-09-18 15:21:25 +02003529 const struct phyerr_tlv *tlv;
3530 const struct phyerr_radar_report *rr;
3531 const struct phyerr_fft_report *fftr;
3532 const u8 *tlv_buf;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003533
Raja Mani991adf72015-08-14 11:13:29 +03003534 buf_len = phyerr->buf_len;
Michal Kazior7aa7a722014-08-25 12:09:38 +02003535 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003536 "wmi event dfs err_code %d rssi %d tsfl 0x%X tsf64 0x%llX len %d\n",
Michal Kazior2332d0a2014-09-18 15:21:25 +02003537 phyerr->phy_err_code, phyerr->rssi_combined,
Raja Mani991adf72015-08-14 11:13:29 +03003538 phyerr->tsf_timestamp, tsf, buf_len);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003539
3540 /* Skip event if DFS disabled */
3541 if (!config_enabled(CONFIG_ATH10K_DFS_CERTIFIED))
3542 return;
3543
3544 ATH10K_DFS_STAT_INC(ar, pulses_total);
3545
3546 while (i < buf_len) {
3547 if (i + sizeof(*tlv) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003548 ath10k_warn(ar, "too short buf for tlv header (%d)\n",
3549 i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003550 return;
3551 }
3552
Michal Kazior2332d0a2014-09-18 15:21:25 +02003553 tlv = (struct phyerr_tlv *)&phyerr->buf[i];
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003554 tlv_len = __le16_to_cpu(tlv->len);
Michal Kazior2332d0a2014-09-18 15:21:25 +02003555 tlv_buf = &phyerr->buf[i + sizeof(*tlv)];
Michal Kazior7aa7a722014-08-25 12:09:38 +02003556 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003557 "wmi event dfs tlv_len %d tlv_tag 0x%02X tlv_sig 0x%02X\n",
3558 tlv_len, tlv->tag, tlv->sig);
3559
3560 switch (tlv->tag) {
3561 case PHYERR_TLV_TAG_RADAR_PULSE_SUMMARY:
3562 if (i + sizeof(*tlv) + sizeof(*rr) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003563 ath10k_warn(ar, "too short radar pulse summary (%d)\n",
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003564 i);
3565 return;
3566 }
3567
3568 rr = (struct phyerr_radar_report *)tlv_buf;
Michal Kazior2332d0a2014-09-18 15:21:25 +02003569 ath10k_dfs_radar_report(ar, phyerr, rr, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003570 break;
3571 case PHYERR_TLV_TAG_SEARCH_FFT_REPORT:
3572 if (i + sizeof(*tlv) + sizeof(*fftr) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003573 ath10k_warn(ar, "too short fft report (%d)\n",
3574 i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003575 return;
3576 }
3577
3578 fftr = (struct phyerr_fft_report *)tlv_buf;
Michal Kazior2332d0a2014-09-18 15:21:25 +02003579 res = ath10k_dfs_fft_report(ar, phyerr, fftr, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003580 if (res)
3581 return;
3582 break;
3583 }
3584
3585 i += sizeof(*tlv) + tlv_len;
3586 }
3587}
3588
Michal Kazior0226d602014-12-03 10:11:22 +02003589void ath10k_wmi_event_spectral_scan(struct ath10k *ar,
Raja Mani991adf72015-08-14 11:13:29 +03003590 struct wmi_phyerr_ev_arg *phyerr,
Michal Kazior0226d602014-12-03 10:11:22 +02003591 u64 tsf)
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003592{
Simon Wunderlich855aed12014-08-02 09:12:54 +03003593 int buf_len, tlv_len, res, i = 0;
3594 struct phyerr_tlv *tlv;
Michal Kazior2332d0a2014-09-18 15:21:25 +02003595 const void *tlv_buf;
3596 const struct phyerr_fft_report *fftr;
Simon Wunderlich855aed12014-08-02 09:12:54 +03003597 size_t fftr_len;
3598
Raja Mani991adf72015-08-14 11:13:29 +03003599 buf_len = phyerr->buf_len;
Simon Wunderlich855aed12014-08-02 09:12:54 +03003600
3601 while (i < buf_len) {
3602 if (i + sizeof(*tlv) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003603 ath10k_warn(ar, "failed to parse phyerr tlv header at byte %d\n",
Simon Wunderlich855aed12014-08-02 09:12:54 +03003604 i);
3605 return;
3606 }
3607
Michal Kazior2332d0a2014-09-18 15:21:25 +02003608 tlv = (struct phyerr_tlv *)&phyerr->buf[i];
Simon Wunderlich855aed12014-08-02 09:12:54 +03003609 tlv_len = __le16_to_cpu(tlv->len);
Michal Kazior2332d0a2014-09-18 15:21:25 +02003610 tlv_buf = &phyerr->buf[i + sizeof(*tlv)];
Simon Wunderlich855aed12014-08-02 09:12:54 +03003611
3612 if (i + sizeof(*tlv) + tlv_len > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003613 ath10k_warn(ar, "failed to parse phyerr tlv payload at byte %d\n",
Simon Wunderlich855aed12014-08-02 09:12:54 +03003614 i);
3615 return;
3616 }
3617
3618 switch (tlv->tag) {
3619 case PHYERR_TLV_TAG_SEARCH_FFT_REPORT:
3620 if (sizeof(*fftr) > tlv_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003621 ath10k_warn(ar, "failed to parse fft report at byte %d\n",
Simon Wunderlich855aed12014-08-02 09:12:54 +03003622 i);
3623 return;
3624 }
3625
3626 fftr_len = tlv_len - sizeof(*fftr);
Michal Kazior2332d0a2014-09-18 15:21:25 +02003627 fftr = tlv_buf;
3628 res = ath10k_spectral_process_fft(ar, phyerr,
Simon Wunderlich855aed12014-08-02 09:12:54 +03003629 fftr, fftr_len,
3630 tsf);
3631 if (res < 0) {
Kevin Darbyshire-Bryant3413e972015-07-21 15:50:15 +01003632 ath10k_dbg(ar, ATH10K_DBG_WMI, "failed to process fft report: %d\n",
Kalle Valo617b0f42015-10-05 17:56:35 +03003633 res);
Simon Wunderlich855aed12014-08-02 09:12:54 +03003634 return;
3635 }
3636 break;
3637 }
3638
3639 i += sizeof(*tlv) + tlv_len;
3640 }
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003641}
3642
Raja Mani991adf72015-08-14 11:13:29 +03003643static int ath10k_wmi_op_pull_phyerr_ev_hdr(struct ath10k *ar,
3644 struct sk_buff *skb,
3645 struct wmi_phyerr_hdr_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02003646{
3647 struct wmi_phyerr_event *ev = (void *)skb->data;
3648
3649 if (skb->len < sizeof(*ev))
3650 return -EPROTO;
3651
Raja Mani991adf72015-08-14 11:13:29 +03003652 arg->num_phyerrs = __le32_to_cpu(ev->num_phyerrs);
3653 arg->tsf_l32 = __le32_to_cpu(ev->tsf_l32);
3654 arg->tsf_u32 = __le32_to_cpu(ev->tsf_u32);
3655 arg->buf_len = skb->len - sizeof(*ev);
Michal Kazior32653cf2014-12-03 10:10:26 +02003656 arg->phyerrs = ev->phyerrs;
3657
3658 return 0;
3659}
3660
Raja Mani2b0a2e02015-08-14 11:13:34 +03003661static int ath10k_wmi_10_4_op_pull_phyerr_ev_hdr(struct ath10k *ar,
3662 struct sk_buff *skb,
3663 struct wmi_phyerr_hdr_arg *arg)
3664{
3665 struct wmi_10_4_phyerr_event *ev = (void *)skb->data;
3666
3667 if (skb->len < sizeof(*ev))
3668 return -EPROTO;
3669
3670 /* 10.4 firmware always reports only one phyerr */
3671 arg->num_phyerrs = 1;
3672
3673 arg->tsf_l32 = __le32_to_cpu(ev->tsf_l32);
3674 arg->tsf_u32 = __le32_to_cpu(ev->tsf_u32);
3675 arg->buf_len = skb->len;
3676 arg->phyerrs = skb->data;
3677
3678 return 0;
3679}
3680
Raja Mani991adf72015-08-14 11:13:29 +03003681int ath10k_wmi_op_pull_phyerr_ev(struct ath10k *ar,
3682 const void *phyerr_buf,
3683 int left_len,
3684 struct wmi_phyerr_ev_arg *arg)
3685{
3686 const struct wmi_phyerr *phyerr = phyerr_buf;
3687 int i;
3688
3689 if (left_len < sizeof(*phyerr)) {
Raja Maniee92a202015-08-21 18:42:36 +05303690 ath10k_warn(ar, "wrong phyerr event head len %d (need: >=%zd)\n",
Raja Mani991adf72015-08-14 11:13:29 +03003691 left_len, sizeof(*phyerr));
3692 return -EINVAL;
3693 }
3694
3695 arg->tsf_timestamp = __le32_to_cpu(phyerr->tsf_timestamp);
3696 arg->freq1 = __le16_to_cpu(phyerr->freq1);
3697 arg->freq2 = __le16_to_cpu(phyerr->freq2);
3698 arg->rssi_combined = phyerr->rssi_combined;
3699 arg->chan_width_mhz = phyerr->chan_width_mhz;
3700 arg->buf_len = __le32_to_cpu(phyerr->buf_len);
3701 arg->buf = phyerr->buf;
3702 arg->hdr_len = sizeof(*phyerr);
3703
3704 for (i = 0; i < 4; i++)
3705 arg->nf_chains[i] = __le16_to_cpu(phyerr->nf_chains[i]);
3706
3707 switch (phyerr->phy_err_code) {
3708 case PHY_ERROR_GEN_SPECTRAL_SCAN:
3709 arg->phy_err_code = PHY_ERROR_SPECTRAL_SCAN;
3710 break;
3711 case PHY_ERROR_GEN_FALSE_RADAR_EXT:
3712 arg->phy_err_code = PHY_ERROR_FALSE_RADAR_EXT;
3713 break;
3714 case PHY_ERROR_GEN_RADAR:
3715 arg->phy_err_code = PHY_ERROR_RADAR;
3716 break;
3717 default:
3718 arg->phy_err_code = PHY_ERROR_UNKNOWN;
3719 break;
3720 }
3721
3722 return 0;
3723}
3724
Raja Mani2b0a2e02015-08-14 11:13:34 +03003725static int ath10k_wmi_10_4_op_pull_phyerr_ev(struct ath10k *ar,
3726 const void *phyerr_buf,
3727 int left_len,
3728 struct wmi_phyerr_ev_arg *arg)
3729{
3730 const struct wmi_10_4_phyerr_event *phyerr = phyerr_buf;
3731 u32 phy_err_mask;
3732 int i;
3733
3734 if (left_len < sizeof(*phyerr)) {
Raja Maniee92a202015-08-21 18:42:36 +05303735 ath10k_warn(ar, "wrong phyerr event head len %d (need: >=%zd)\n",
Raja Mani2b0a2e02015-08-14 11:13:34 +03003736 left_len, sizeof(*phyerr));
3737 return -EINVAL;
3738 }
3739
3740 arg->tsf_timestamp = __le32_to_cpu(phyerr->tsf_timestamp);
3741 arg->freq1 = __le16_to_cpu(phyerr->freq1);
3742 arg->freq2 = __le16_to_cpu(phyerr->freq2);
3743 arg->rssi_combined = phyerr->rssi_combined;
3744 arg->chan_width_mhz = phyerr->chan_width_mhz;
3745 arg->buf_len = __le32_to_cpu(phyerr->buf_len);
3746 arg->buf = phyerr->buf;
3747 arg->hdr_len = sizeof(*phyerr);
3748
3749 for (i = 0; i < 4; i++)
3750 arg->nf_chains[i] = __le16_to_cpu(phyerr->nf_chains[i]);
3751
3752 phy_err_mask = __le32_to_cpu(phyerr->phy_err_mask[0]);
3753
3754 if (phy_err_mask & PHY_ERROR_10_4_SPECTRAL_SCAN_MASK)
3755 arg->phy_err_code = PHY_ERROR_SPECTRAL_SCAN;
3756 else if (phy_err_mask & PHY_ERROR_10_4_RADAR_MASK)
3757 arg->phy_err_code = PHY_ERROR_RADAR;
3758 else
3759 arg->phy_err_code = PHY_ERROR_UNKNOWN;
3760
3761 return 0;
3762}
3763
Michal Kazior0226d602014-12-03 10:11:22 +02003764void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003765{
Raja Mani991adf72015-08-14 11:13:29 +03003766 struct wmi_phyerr_hdr_arg hdr_arg = {};
3767 struct wmi_phyerr_ev_arg phyerr_arg = {};
3768 const void *phyerr;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003769 u32 count, i, buf_len, phy_err_code;
3770 u64 tsf;
Michal Kazior32653cf2014-12-03 10:10:26 +02003771 int left_len, ret;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003772
3773 ATH10K_DFS_STAT_INC(ar, phy_errors);
3774
Raja Mani991adf72015-08-14 11:13:29 +03003775 ret = ath10k_wmi_pull_phyerr_hdr(ar, skb, &hdr_arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02003776 if (ret) {
Raja Mani991adf72015-08-14 11:13:29 +03003777 ath10k_warn(ar, "failed to parse phyerr event hdr: %d\n", ret);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003778 return;
3779 }
3780
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003781 /* Check number of included events */
Raja Mani991adf72015-08-14 11:13:29 +03003782 count = hdr_arg.num_phyerrs;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003783
Raja Mani991adf72015-08-14 11:13:29 +03003784 left_len = hdr_arg.buf_len;
3785
3786 tsf = hdr_arg.tsf_u32;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003787 tsf <<= 32;
Raja Mani991adf72015-08-14 11:13:29 +03003788 tsf |= hdr_arg.tsf_l32;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003789
Michal Kazior7aa7a722014-08-25 12:09:38 +02003790 ath10k_dbg(ar, ATH10K_DBG_WMI,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003791 "wmi event phyerr count %d tsf64 0x%llX\n",
3792 count, tsf);
3793
Raja Mani991adf72015-08-14 11:13:29 +03003794 phyerr = hdr_arg.phyerrs;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003795 for (i = 0; i < count; i++) {
Raja Mani991adf72015-08-14 11:13:29 +03003796 ret = ath10k_wmi_pull_phyerr(ar, phyerr, left_len, &phyerr_arg);
3797 if (ret) {
3798 ath10k_warn(ar, "failed to parse phyerr event (%d)\n",
Michal Kazior7aa7a722014-08-25 12:09:38 +02003799 i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003800 return;
3801 }
3802
Raja Mani991adf72015-08-14 11:13:29 +03003803 left_len -= phyerr_arg.hdr_len;
3804 buf_len = phyerr_arg.buf_len;
3805 phy_err_code = phyerr_arg.phy_err_code;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003806
3807 if (left_len < buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003808 ath10k_warn(ar, "single event (%d) wrong buf len\n", i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003809 return;
3810 }
3811
3812 left_len -= buf_len;
3813
3814 switch (phy_err_code) {
3815 case PHY_ERROR_RADAR:
Raja Mani991adf72015-08-14 11:13:29 +03003816 ath10k_wmi_event_dfs(ar, &phyerr_arg, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003817 break;
3818 case PHY_ERROR_SPECTRAL_SCAN:
Raja Mani991adf72015-08-14 11:13:29 +03003819 ath10k_wmi_event_spectral_scan(ar, &phyerr_arg, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003820 break;
3821 case PHY_ERROR_FALSE_RADAR_EXT:
Raja Mani991adf72015-08-14 11:13:29 +03003822 ath10k_wmi_event_dfs(ar, &phyerr_arg, tsf);
3823 ath10k_wmi_event_spectral_scan(ar, &phyerr_arg, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003824 break;
3825 default:
3826 break;
3827 }
3828
Raja Mani991adf72015-08-14 11:13:29 +03003829 phyerr = phyerr + phyerr_arg.hdr_len + buf_len;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003830 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03003831}
3832
Michal Kazior0226d602014-12-03 10:11:22 +02003833void ath10k_wmi_event_roam(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003834{
Michal Kaziorc1a46542015-03-10 16:21:54 +02003835 struct wmi_roam_ev_arg arg = {};
3836 int ret;
3837 u32 vdev_id;
3838 u32 reason;
3839 s32 rssi;
3840
3841 ret = ath10k_wmi_pull_roam_ev(ar, skb, &arg);
3842 if (ret) {
3843 ath10k_warn(ar, "failed to parse roam event: %d\n", ret);
3844 return;
3845 }
3846
3847 vdev_id = __le32_to_cpu(arg.vdev_id);
3848 reason = __le32_to_cpu(arg.reason);
3849 rssi = __le32_to_cpu(arg.rssi);
3850 rssi += WMI_SPECTRAL_NOISE_FLOOR_REF_DEFAULT;
3851
3852 ath10k_dbg(ar, ATH10K_DBG_WMI,
3853 "wmi roam event vdev %u reason 0x%08x rssi %d\n",
3854 vdev_id, reason, rssi);
3855
3856 if (reason >= WMI_ROAM_REASON_MAX)
3857 ath10k_warn(ar, "ignoring unknown roam event reason %d on vdev %i\n",
3858 reason, vdev_id);
3859
3860 switch (reason) {
Michal Kaziorc1a46542015-03-10 16:21:54 +02003861 case WMI_ROAM_REASON_BEACON_MISS:
Michal Kaziorcc9904e2015-03-10 16:22:01 +02003862 ath10k_mac_handle_beacon_miss(ar, vdev_id);
3863 break;
3864 case WMI_ROAM_REASON_BETTER_AP:
Michal Kaziorc1a46542015-03-10 16:21:54 +02003865 case WMI_ROAM_REASON_LOW_RSSI:
3866 case WMI_ROAM_REASON_SUITABLE_AP_FOUND:
3867 case WMI_ROAM_REASON_HO_FAILED:
3868 ath10k_warn(ar, "ignoring not implemented roam event reason %d on vdev %i\n",
3869 reason, vdev_id);
3870 break;
3871 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03003872}
3873
Michal Kazior0226d602014-12-03 10:11:22 +02003874void ath10k_wmi_event_profile_match(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003875{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003876 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PROFILE_MATCH\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003877}
3878
Michal Kazior0226d602014-12-03 10:11:22 +02003879void ath10k_wmi_event_debug_print(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003880{
Kalle Valo2fe52882014-01-03 12:59:20 +02003881 char buf[101], c;
3882 int i;
3883
3884 for (i = 0; i < sizeof(buf) - 1; i++) {
3885 if (i >= skb->len)
3886 break;
3887
3888 c = skb->data[i];
3889
3890 if (c == '\0')
3891 break;
3892
3893 if (isascii(c) && isprint(c))
3894 buf[i] = c;
3895 else
3896 buf[i] = '.';
3897 }
3898
3899 if (i == sizeof(buf) - 1)
Michal Kazior7aa7a722014-08-25 12:09:38 +02003900 ath10k_warn(ar, "wmi debug print truncated: %d\n", skb->len);
Kalle Valo2fe52882014-01-03 12:59:20 +02003901
3902 /* for some reason the debug prints end with \n, remove that */
3903 if (skb->data[i - 1] == '\n')
3904 i--;
3905
3906 /* the last byte is always reserved for the null character */
3907 buf[i] = '\0';
3908
Ben Greear3be004c2014-09-23 14:17:19 -07003909 ath10k_dbg(ar, ATH10K_DBG_WMI_PRINT, "wmi print '%s'\n", buf);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003910}
3911
Michal Kazior0226d602014-12-03 10:11:22 +02003912void ath10k_wmi_event_pdev_qvit(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003913{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003914 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_QVIT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003915}
3916
Michal Kazior0226d602014-12-03 10:11:22 +02003917void ath10k_wmi_event_wlan_profile_data(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003918{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003919 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_WLAN_PROFILE_DATA_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003920}
3921
Michal Kazior0226d602014-12-03 10:11:22 +02003922void ath10k_wmi_event_rtt_measurement_report(struct ath10k *ar,
3923 struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003924{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003925 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_MEASUREMENT_REPORT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003926}
3927
Michal Kazior0226d602014-12-03 10:11:22 +02003928void ath10k_wmi_event_tsf_measurement_report(struct ath10k *ar,
3929 struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003930{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003931 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TSF_MEASUREMENT_REPORT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003932}
3933
Michal Kazior0226d602014-12-03 10:11:22 +02003934void ath10k_wmi_event_rtt_error_report(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003935{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003936 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_ERROR_REPORT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003937}
3938
Michal Kazior0226d602014-12-03 10:11:22 +02003939void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003940{
Janusz Dziedzic5fd3ac32015-03-23 17:32:53 +02003941 struct wmi_wow_ev_arg ev = {};
3942 int ret;
3943
3944 complete(&ar->wow.wakeup_completed);
3945
3946 ret = ath10k_wmi_pull_wow_event(ar, skb, &ev);
3947 if (ret) {
3948 ath10k_warn(ar, "failed to parse wow wakeup event: %d\n", ret);
3949 return;
3950 }
3951
3952 ath10k_dbg(ar, ATH10K_DBG_WMI, "wow wakeup host reason %s\n",
3953 wow_reason(ev.wake_reason));
Kalle Valo5e3dd152013-06-12 20:52:10 +03003954}
3955
Michal Kazior0226d602014-12-03 10:11:22 +02003956void ath10k_wmi_event_dcs_interference(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003957{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003958 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_DCS_INTERFERENCE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003959}
3960
Maharaja Kennadyrajan29542662015-10-05 17:56:38 +03003961static u8 ath10k_tpc_config_get_rate(struct ath10k *ar,
3962 struct wmi_pdev_tpc_config_event *ev,
3963 u32 rate_idx, u32 num_chains,
3964 u32 rate_code, u8 type)
3965{
3966 u8 tpc, num_streams, preamble, ch, stm_idx;
3967
3968 num_streams = ATH10K_HW_NSS(rate_code);
3969 preamble = ATH10K_HW_PREAMBLE(rate_code);
3970 ch = num_chains - 1;
3971
3972 tpc = min_t(u8, ev->rates_array[rate_idx], ev->max_reg_allow_pow[ch]);
3973
3974 if (__le32_to_cpu(ev->num_tx_chain) <= 1)
3975 goto out;
3976
3977 if (preamble == WMI_RATE_PREAMBLE_CCK)
3978 goto out;
3979
3980 stm_idx = num_streams - 1;
3981 if (num_chains <= num_streams)
3982 goto out;
3983
3984 switch (type) {
3985 case WMI_TPC_TABLE_TYPE_STBC:
3986 tpc = min_t(u8, tpc,
3987 ev->max_reg_allow_pow_agstbc[ch - 1][stm_idx]);
3988 break;
3989 case WMI_TPC_TABLE_TYPE_TXBF:
3990 tpc = min_t(u8, tpc,
3991 ev->max_reg_allow_pow_agtxbf[ch - 1][stm_idx]);
3992 break;
3993 case WMI_TPC_TABLE_TYPE_CDD:
3994 tpc = min_t(u8, tpc,
3995 ev->max_reg_allow_pow_agcdd[ch - 1][stm_idx]);
3996 break;
3997 default:
3998 ath10k_warn(ar, "unknown wmi tpc table type: %d\n", type);
3999 tpc = 0;
4000 break;
4001 }
4002
4003out:
4004 return tpc;
4005}
4006
4007static void ath10k_tpc_config_disp_tables(struct ath10k *ar,
4008 struct wmi_pdev_tpc_config_event *ev,
4009 struct ath10k_tpc_stats *tpc_stats,
4010 u8 *rate_code, u16 *pream_table, u8 type)
4011{
4012 u32 i, j, pream_idx, flags;
4013 u8 tpc[WMI_TPC_TX_N_CHAIN];
4014 char tpc_value[WMI_TPC_TX_N_CHAIN * WMI_TPC_BUF_SIZE];
4015 char buff[WMI_TPC_BUF_SIZE];
4016
4017 flags = __le32_to_cpu(ev->flags);
4018
4019 switch (type) {
4020 case WMI_TPC_TABLE_TYPE_CDD:
4021 if (!(flags & WMI_TPC_CONFIG_EVENT_FLAG_TABLE_CDD)) {
4022 ath10k_dbg(ar, ATH10K_DBG_WMI, "CDD not supported\n");
4023 tpc_stats->flag[type] = ATH10K_TPC_TABLE_TYPE_FLAG;
4024 return;
4025 }
4026 break;
4027 case WMI_TPC_TABLE_TYPE_STBC:
4028 if (!(flags & WMI_TPC_CONFIG_EVENT_FLAG_TABLE_STBC)) {
4029 ath10k_dbg(ar, ATH10K_DBG_WMI, "STBC not supported\n");
4030 tpc_stats->flag[type] = ATH10K_TPC_TABLE_TYPE_FLAG;
4031 return;
4032 }
4033 break;
4034 case WMI_TPC_TABLE_TYPE_TXBF:
4035 if (!(flags & WMI_TPC_CONFIG_EVENT_FLAG_TABLE_TXBF)) {
4036 ath10k_dbg(ar, ATH10K_DBG_WMI, "TXBF not supported\n");
4037 tpc_stats->flag[type] = ATH10K_TPC_TABLE_TYPE_FLAG;
4038 return;
4039 }
4040 break;
4041 default:
4042 ath10k_dbg(ar, ATH10K_DBG_WMI,
4043 "invalid table type in wmi tpc event: %d\n", type);
4044 return;
4045 }
4046
4047 pream_idx = 0;
4048 for (i = 0; i < __le32_to_cpu(ev->rate_max); i++) {
4049 memset(tpc_value, 0, sizeof(tpc_value));
4050 memset(buff, 0, sizeof(buff));
4051 if (i == pream_table[pream_idx])
4052 pream_idx++;
4053
4054 for (j = 0; j < WMI_TPC_TX_N_CHAIN; j++) {
4055 if (j >= __le32_to_cpu(ev->num_tx_chain))
4056 break;
4057
4058 tpc[j] = ath10k_tpc_config_get_rate(ar, ev, i, j + 1,
4059 rate_code[i],
4060 type);
4061 snprintf(buff, sizeof(buff), "%8d ", tpc[j]);
4062 strncat(tpc_value, buff, strlen(buff));
4063 }
4064 tpc_stats->tpc_table[type].pream_idx[i] = pream_idx;
4065 tpc_stats->tpc_table[type].rate_code[i] = rate_code[i];
4066 memcpy(tpc_stats->tpc_table[type].tpc_value[i],
4067 tpc_value, sizeof(tpc_value));
4068 }
4069}
4070
Michal Kazior0226d602014-12-03 10:11:22 +02004071void ath10k_wmi_event_pdev_tpc_config(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004072{
Maharaja Kennadyrajan29542662015-10-05 17:56:38 +03004073 u32 i, j, pream_idx, num_tx_chain;
4074 u8 rate_code[WMI_TPC_RATE_MAX], rate_idx;
4075 u16 pream_table[WMI_TPC_PREAM_TABLE_MAX];
4076 struct wmi_pdev_tpc_config_event *ev;
4077 struct ath10k_tpc_stats *tpc_stats;
4078
4079 ev = (struct wmi_pdev_tpc_config_event *)skb->data;
4080
4081 tpc_stats = kzalloc(sizeof(*tpc_stats), GFP_ATOMIC);
4082 if (!tpc_stats)
4083 return;
4084
4085 /* Create the rate code table based on the chains supported */
4086 rate_idx = 0;
4087 pream_idx = 0;
4088
4089 /* Fill CCK rate code */
4090 for (i = 0; i < 4; i++) {
4091 rate_code[rate_idx] =
4092 ATH10K_HW_RATECODE(i, 0, WMI_RATE_PREAMBLE_CCK);
4093 rate_idx++;
4094 }
4095 pream_table[pream_idx] = rate_idx;
4096 pream_idx++;
4097
4098 /* Fill OFDM rate code */
4099 for (i = 0; i < 8; i++) {
4100 rate_code[rate_idx] =
4101 ATH10K_HW_RATECODE(i, 0, WMI_RATE_PREAMBLE_OFDM);
4102 rate_idx++;
4103 }
4104 pream_table[pream_idx] = rate_idx;
4105 pream_idx++;
4106
4107 num_tx_chain = __le32_to_cpu(ev->num_tx_chain);
4108
4109 /* Fill HT20 rate code */
4110 for (i = 0; i < num_tx_chain; i++) {
4111 for (j = 0; j < 8; j++) {
4112 rate_code[rate_idx] =
4113 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_HT);
4114 rate_idx++;
4115 }
4116 }
4117 pream_table[pream_idx] = rate_idx;
4118 pream_idx++;
4119
4120 /* Fill HT40 rate code */
4121 for (i = 0; i < num_tx_chain; i++) {
4122 for (j = 0; j < 8; j++) {
4123 rate_code[rate_idx] =
4124 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_HT);
4125 rate_idx++;
4126 }
4127 }
4128 pream_table[pream_idx] = rate_idx;
4129 pream_idx++;
4130
4131 /* Fill VHT20 rate code */
4132 for (i = 0; i < __le32_to_cpu(ev->num_tx_chain); i++) {
4133 for (j = 0; j < 10; j++) {
4134 rate_code[rate_idx] =
4135 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_VHT);
4136 rate_idx++;
4137 }
4138 }
4139 pream_table[pream_idx] = rate_idx;
4140 pream_idx++;
4141
4142 /* Fill VHT40 rate code */
4143 for (i = 0; i < num_tx_chain; i++) {
4144 for (j = 0; j < 10; j++) {
4145 rate_code[rate_idx] =
4146 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_VHT);
4147 rate_idx++;
4148 }
4149 }
4150 pream_table[pream_idx] = rate_idx;
4151 pream_idx++;
4152
4153 /* Fill VHT80 rate code */
4154 for (i = 0; i < num_tx_chain; i++) {
4155 for (j = 0; j < 10; j++) {
4156 rate_code[rate_idx] =
4157 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_VHT);
4158 rate_idx++;
4159 }
4160 }
4161 pream_table[pream_idx] = rate_idx;
4162 pream_idx++;
4163
4164 rate_code[rate_idx++] =
4165 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_CCK);
4166 rate_code[rate_idx++] =
4167 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_OFDM);
4168 rate_code[rate_idx++] =
4169 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_CCK);
4170 rate_code[rate_idx++] =
4171 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_OFDM);
4172 rate_code[rate_idx++] =
4173 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_OFDM);
4174
4175 pream_table[pream_idx] = ATH10K_TPC_PREAM_TABLE_END;
4176
4177 tpc_stats->chan_freq = __le32_to_cpu(ev->chan_freq);
4178 tpc_stats->phy_mode = __le32_to_cpu(ev->phy_mode);
4179 tpc_stats->ctl = __le32_to_cpu(ev->ctl);
4180 tpc_stats->reg_domain = __le32_to_cpu(ev->reg_domain);
4181 tpc_stats->twice_antenna_gain = a_sle32_to_cpu(ev->twice_antenna_gain);
4182 tpc_stats->twice_antenna_reduction =
4183 __le32_to_cpu(ev->twice_antenna_reduction);
4184 tpc_stats->power_limit = __le32_to_cpu(ev->power_limit);
4185 tpc_stats->twice_max_rd_power = __le32_to_cpu(ev->twice_max_rd_power);
4186 tpc_stats->num_tx_chain = __le32_to_cpu(ev->num_tx_chain);
4187 tpc_stats->rate_max = __le32_to_cpu(ev->rate_max);
4188
4189 ath10k_tpc_config_disp_tables(ar, ev, tpc_stats,
4190 rate_code, pream_table,
4191 WMI_TPC_TABLE_TYPE_CDD);
4192 ath10k_tpc_config_disp_tables(ar, ev, tpc_stats,
4193 rate_code, pream_table,
4194 WMI_TPC_TABLE_TYPE_STBC);
4195 ath10k_tpc_config_disp_tables(ar, ev, tpc_stats,
4196 rate_code, pream_table,
4197 WMI_TPC_TABLE_TYPE_TXBF);
4198
4199 ath10k_debug_tpc_stats_process(ar, tpc_stats);
4200
4201 ath10k_dbg(ar, ATH10K_DBG_WMI,
4202 "wmi event tpc config channel %d mode %d ctl %d regd %d gain %d %d limit %d max_power %d tx_chanins %d rates %d\n",
4203 __le32_to_cpu(ev->chan_freq),
4204 __le32_to_cpu(ev->phy_mode),
4205 __le32_to_cpu(ev->ctl),
4206 __le32_to_cpu(ev->reg_domain),
4207 a_sle32_to_cpu(ev->twice_antenna_gain),
4208 __le32_to_cpu(ev->twice_antenna_reduction),
4209 __le32_to_cpu(ev->power_limit),
4210 __le32_to_cpu(ev->twice_max_rd_power) / 2,
4211 __le32_to_cpu(ev->num_tx_chain),
4212 __le32_to_cpu(ev->rate_max));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004213}
4214
Michal Kazior0226d602014-12-03 10:11:22 +02004215void ath10k_wmi_event_pdev_ftm_intg(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004216{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004217 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_FTM_INTG_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004218}
4219
Michal Kazior0226d602014-12-03 10:11:22 +02004220void ath10k_wmi_event_gtk_offload_status(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004221{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004222 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_OFFLOAD_STATUS_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004223}
4224
Michal Kazior0226d602014-12-03 10:11:22 +02004225void ath10k_wmi_event_gtk_rekey_fail(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004226{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004227 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_REKEY_FAIL_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004228}
4229
Michal Kazior0226d602014-12-03 10:11:22 +02004230void ath10k_wmi_event_delba_complete(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004231{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004232 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_DELBA_COMPLETE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004233}
4234
Michal Kazior0226d602014-12-03 10:11:22 +02004235void ath10k_wmi_event_addba_complete(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004236{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004237 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_ADDBA_COMPLETE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004238}
4239
Michal Kazior0226d602014-12-03 10:11:22 +02004240void ath10k_wmi_event_vdev_install_key_complete(struct ath10k *ar,
4241 struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004242{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004243 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004244}
4245
Michal Kazior0226d602014-12-03 10:11:22 +02004246void ath10k_wmi_event_inst_rssi_stats(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004247{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004248 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_INST_RSSI_STATS_EVENTID\n");
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004249}
4250
Michal Kazior0226d602014-12-03 10:11:22 +02004251void ath10k_wmi_event_vdev_standby_req(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004252{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004253 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STANDBY_REQ_EVENTID\n");
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004254}
4255
Michal Kazior0226d602014-12-03 10:11:22 +02004256void ath10k_wmi_event_vdev_resume_req(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004257{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004258 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_RESUME_REQ_EVENTID\n");
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004259}
4260
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004261static int ath10k_wmi_alloc_host_mem(struct ath10k *ar, u32 req_id,
Kalle Valo5b07e072014-09-14 12:50:06 +03004262 u32 num_units, u32 unit_len)
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004263{
4264 dma_addr_t paddr;
4265 u32 pool_size;
4266 int idx = ar->wmi.num_mem_chunks;
4267
4268 pool_size = num_units * round_up(unit_len, 4);
4269
4270 if (!pool_size)
4271 return -EINVAL;
4272
4273 ar->wmi.mem_chunks[idx].vaddr = dma_alloc_coherent(ar->dev,
4274 pool_size,
4275 &paddr,
Raja Manic8ecfc12015-07-29 11:40:38 +03004276 GFP_KERNEL);
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004277 if (!ar->wmi.mem_chunks[idx].vaddr) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02004278 ath10k_warn(ar, "failed to allocate memory chunk\n");
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004279 return -ENOMEM;
4280 }
4281
4282 memset(ar->wmi.mem_chunks[idx].vaddr, 0, pool_size);
4283
4284 ar->wmi.mem_chunks[idx].paddr = paddr;
4285 ar->wmi.mem_chunks[idx].len = pool_size;
4286 ar->wmi.mem_chunks[idx].req_id = req_id;
4287 ar->wmi.num_mem_chunks++;
4288
4289 return 0;
4290}
4291
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05304292static bool
4293ath10k_wmi_is_host_mem_allocated(struct ath10k *ar,
4294 const struct wlan_host_mem_req **mem_reqs,
4295 u32 num_mem_reqs)
4296{
4297 u32 req_id, num_units, unit_size, num_unit_info;
4298 u32 pool_size;
4299 int i, j;
4300 bool found;
4301
4302 if (ar->wmi.num_mem_chunks != num_mem_reqs)
4303 return false;
4304
4305 for (i = 0; i < num_mem_reqs; ++i) {
4306 req_id = __le32_to_cpu(mem_reqs[i]->req_id);
4307 num_units = __le32_to_cpu(mem_reqs[i]->num_units);
4308 unit_size = __le32_to_cpu(mem_reqs[i]->unit_size);
4309 num_unit_info = __le32_to_cpu(mem_reqs[i]->num_unit_info);
4310
4311 if (num_unit_info & NUM_UNITS_IS_NUM_ACTIVE_PEERS) {
4312 if (ar->num_active_peers)
4313 num_units = ar->num_active_peers + 1;
4314 else
4315 num_units = ar->max_num_peers + 1;
4316 } else if (num_unit_info & NUM_UNITS_IS_NUM_PEERS) {
4317 num_units = ar->max_num_peers + 1;
4318 } else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS) {
4319 num_units = ar->max_num_vdevs + 1;
4320 }
4321
4322 found = false;
4323 for (j = 0; j < ar->wmi.num_mem_chunks; j++) {
4324 if (ar->wmi.mem_chunks[j].req_id == req_id) {
4325 pool_size = num_units * round_up(unit_size, 4);
4326 if (ar->wmi.mem_chunks[j].len == pool_size) {
4327 found = true;
4328 break;
4329 }
4330 }
4331 }
4332 if (!found)
4333 return false;
4334 }
4335
4336 return true;
4337}
4338
Michal Kaziord7579d12014-12-03 10:10:54 +02004339static int
4340ath10k_wmi_main_op_pull_svc_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
4341 struct wmi_svc_rdy_ev_arg *arg)
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004342{
4343 struct wmi_service_ready_event *ev;
4344 size_t i, n;
4345
4346 if (skb->len < sizeof(*ev))
4347 return -EPROTO;
4348
4349 ev = (void *)skb->data;
4350 skb_pull(skb, sizeof(*ev));
4351 arg->min_tx_power = ev->hw_min_tx_power;
4352 arg->max_tx_power = ev->hw_max_tx_power;
4353 arg->ht_cap = ev->ht_cap_info;
4354 arg->vht_cap = ev->vht_cap_info;
4355 arg->sw_ver0 = ev->sw_version;
4356 arg->sw_ver1 = ev->sw_version_1;
4357 arg->phy_capab = ev->phy_capability;
4358 arg->num_rf_chains = ev->num_rf_chains;
4359 arg->eeprom_rd = ev->hal_reg_capabilities.eeprom_rd;
4360 arg->num_mem_reqs = ev->num_mem_reqs;
4361 arg->service_map = ev->wmi_service_bitmap;
Michal Kazior2a3e60d2014-11-27 10:11:15 +01004362 arg->service_map_len = sizeof(ev->wmi_service_bitmap);
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004363
4364 n = min_t(size_t, __le32_to_cpu(arg->num_mem_reqs),
4365 ARRAY_SIZE(arg->mem_reqs));
4366 for (i = 0; i < n; i++)
4367 arg->mem_reqs[i] = &ev->mem_reqs[i];
4368
4369 if (skb->len <
4370 __le32_to_cpu(arg->num_mem_reqs) * sizeof(arg->mem_reqs[0]))
4371 return -EPROTO;
4372
4373 return 0;
4374}
4375
Michal Kaziord7579d12014-12-03 10:10:54 +02004376static int
4377ath10k_wmi_10x_op_pull_svc_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
4378 struct wmi_svc_rdy_ev_arg *arg)
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004379{
4380 struct wmi_10x_service_ready_event *ev;
4381 int i, n;
4382
4383 if (skb->len < sizeof(*ev))
4384 return -EPROTO;
4385
4386 ev = (void *)skb->data;
4387 skb_pull(skb, sizeof(*ev));
4388 arg->min_tx_power = ev->hw_min_tx_power;
4389 arg->max_tx_power = ev->hw_max_tx_power;
4390 arg->ht_cap = ev->ht_cap_info;
4391 arg->vht_cap = ev->vht_cap_info;
4392 arg->sw_ver0 = ev->sw_version;
4393 arg->phy_capab = ev->phy_capability;
4394 arg->num_rf_chains = ev->num_rf_chains;
4395 arg->eeprom_rd = ev->hal_reg_capabilities.eeprom_rd;
4396 arg->num_mem_reqs = ev->num_mem_reqs;
4397 arg->service_map = ev->wmi_service_bitmap;
Michal Kazior2a3e60d2014-11-27 10:11:15 +01004398 arg->service_map_len = sizeof(ev->wmi_service_bitmap);
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004399
4400 n = min_t(size_t, __le32_to_cpu(arg->num_mem_reqs),
4401 ARRAY_SIZE(arg->mem_reqs));
4402 for (i = 0; i < n; i++)
4403 arg->mem_reqs[i] = &ev->mem_reqs[i];
4404
4405 if (skb->len <
4406 __le32_to_cpu(arg->num_mem_reqs) * sizeof(arg->mem_reqs[0]))
4407 return -EPROTO;
4408
4409 return 0;
4410}
4411
Raja Manic8ecfc12015-07-29 11:40:38 +03004412static void ath10k_wmi_event_service_ready_work(struct work_struct *work)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004413{
Raja Manic8ecfc12015-07-29 11:40:38 +03004414 struct ath10k *ar = container_of(work, struct ath10k, svc_rdy_work);
4415 struct sk_buff *skb = ar->svc_rdy_skb;
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004416 struct wmi_svc_rdy_ev_arg arg = {};
4417 u32 num_units, req_id, unit_size, num_mem_reqs, num_unit_info, i;
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004418 int ret;
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05304419 bool allocated;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004420
Raja Manic8ecfc12015-07-29 11:40:38 +03004421 if (!skb) {
4422 ath10k_warn(ar, "invalid service ready event skb\n");
4423 return;
4424 }
4425
Michal Kaziord7579d12014-12-03 10:10:54 +02004426 ret = ath10k_wmi_pull_svc_rdy(ar, skb, &arg);
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004427 if (ret) {
4428 ath10k_warn(ar, "failed to parse service ready: %d\n", ret);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004429 return;
4430 }
4431
Michal Kaziord7579d12014-12-03 10:10:54 +02004432 memset(&ar->wmi.svc_map, 0, sizeof(ar->wmi.svc_map));
4433 ath10k_wmi_map_svc(ar, arg.service_map, ar->wmi.svc_map,
4434 arg.service_map_len);
4435
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004436 ar->hw_min_tx_power = __le32_to_cpu(arg.min_tx_power);
4437 ar->hw_max_tx_power = __le32_to_cpu(arg.max_tx_power);
4438 ar->ht_cap_info = __le32_to_cpu(arg.ht_cap);
4439 ar->vht_cap_info = __le32_to_cpu(arg.vht_cap);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004440 ar->fw_version_major =
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004441 (__le32_to_cpu(arg.sw_ver0) & 0xff000000) >> 24;
4442 ar->fw_version_minor = (__le32_to_cpu(arg.sw_ver0) & 0x00ffffff);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004443 ar->fw_version_release =
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004444 (__le32_to_cpu(arg.sw_ver1) & 0xffff0000) >> 16;
4445 ar->fw_version_build = (__le32_to_cpu(arg.sw_ver1) & 0x0000ffff);
4446 ar->phy_capability = __le32_to_cpu(arg.phy_capab);
4447 ar->num_rf_chains = __le32_to_cpu(arg.num_rf_chains);
4448 ar->ath_common.regulatory.current_rd = __le32_to_cpu(arg.eeprom_rd);
4449
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004450 ath10k_dbg_dump(ar, ATH10K_DBG_WMI, NULL, "wmi svc: ",
Michal Kazior2a3e60d2014-11-27 10:11:15 +01004451 arg.service_map, arg.service_map_len);
Michal Kazior8865bee42013-07-24 12:36:46 +02004452
Kalle Valo1a222432013-09-27 19:55:07 +03004453 /* only manually set fw features when not using FW IE format */
4454 if (ar->fw_api == 1 && ar->fw_version_build > 636)
Michal Kazior0d9b0432013-08-09 10:13:33 +02004455 set_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features);
4456
Raja Mani5c8726e2015-06-22 20:22:26 +05304457 if (ar->num_rf_chains > ar->max_spatial_stream) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02004458 ath10k_warn(ar, "hardware advertises support for more spatial streams than it should (%d > %d)\n",
Raja Mani5c8726e2015-06-22 20:22:26 +05304459 ar->num_rf_chains, ar->max_spatial_stream);
4460 ar->num_rf_chains = ar->max_spatial_stream;
Michal Kazior8865bee42013-07-24 12:36:46 +02004461 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03004462
Rajkumar Manoharan166de3f2015-10-27 17:51:11 +05304463 if (!ar->cfg_tx_chainmask) {
4464 ar->cfg_tx_chainmask = (1 << ar->num_rf_chains) - 1;
4465 ar->cfg_rx_chainmask = (1 << ar->num_rf_chains) - 1;
4466 }
Michal Kaziorfdb959c2014-09-18 15:21:19 +02004467
Kalle Valo5e3dd152013-06-12 20:52:10 +03004468 if (strlen(ar->hw->wiphy->fw_version) == 0) {
4469 snprintf(ar->hw->wiphy->fw_version,
4470 sizeof(ar->hw->wiphy->fw_version),
4471 "%u.%u.%u.%u",
4472 ar->fw_version_major,
4473 ar->fw_version_minor,
4474 ar->fw_version_release,
4475 ar->fw_version_build);
4476 }
4477
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004478 num_mem_reqs = __le32_to_cpu(arg.num_mem_reqs);
4479 if (num_mem_reqs > WMI_MAX_MEM_REQS) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02004480 ath10k_warn(ar, "requested memory chunks number (%d) exceeds the limit\n",
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004481 num_mem_reqs);
4482 return;
Bartosz Markowski6f97d252013-09-26 17:47:09 +02004483 }
4484
Raja Manib0399412015-06-22 20:10:17 +05304485 if (test_bit(WMI_SERVICE_PEER_CACHING, ar->wmi.svc_map)) {
4486 ar->max_num_peers = TARGET_10_4_NUM_QCACHE_PEERS_MAX +
4487 TARGET_10_4_NUM_VDEVS;
4488 ar->num_active_peers = TARGET_10_4_QCACHE_ACTIVE_PEERS +
4489 TARGET_10_4_NUM_VDEVS;
4490 ar->num_tids = ar->num_active_peers * 2;
4491 ar->max_num_stations = TARGET_10_4_NUM_QCACHE_PEERS_MAX;
4492 }
4493
4494 /* TODO: Adjust max peer count for cases like WMI_SERVICE_RATECTRL_CACHE
4495 * and WMI_SERVICE_IRAM_TIDS, etc.
4496 */
4497
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05304498 allocated = ath10k_wmi_is_host_mem_allocated(ar, arg.mem_reqs,
4499 num_mem_reqs);
4500 if (allocated)
4501 goto skip_mem_alloc;
4502
4503 /* Either this event is received during boot time or there is a change
4504 * in memory requirement from firmware when compared to last request.
4505 * Free any old memory and do a fresh allocation based on the current
4506 * memory requirement.
4507 */
4508 ath10k_wmi_free_host_mem(ar);
4509
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004510 for (i = 0; i < num_mem_reqs; ++i) {
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004511 req_id = __le32_to_cpu(arg.mem_reqs[i]->req_id);
4512 num_units = __le32_to_cpu(arg.mem_reqs[i]->num_units);
4513 unit_size = __le32_to_cpu(arg.mem_reqs[i]->unit_size);
4514 num_unit_info = __le32_to_cpu(arg.mem_reqs[i]->num_unit_info);
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004515
Raja Manib0399412015-06-22 20:10:17 +05304516 if (num_unit_info & NUM_UNITS_IS_NUM_ACTIVE_PEERS) {
4517 if (ar->num_active_peers)
4518 num_units = ar->num_active_peers + 1;
4519 else
4520 num_units = ar->max_num_peers + 1;
4521 } else if (num_unit_info & NUM_UNITS_IS_NUM_PEERS) {
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004522 /* number of units to allocate is number of
4523 * peers, 1 extra for self peer on target */
4524 /* this needs to be tied, host and target
4525 * can get out of sync */
Raja Manib0399412015-06-22 20:10:17 +05304526 num_units = ar->max_num_peers + 1;
4527 } else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS) {
4528 num_units = ar->max_num_vdevs + 1;
4529 }
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004530
Michal Kazior7aa7a722014-08-25 12:09:38 +02004531 ath10k_dbg(ar, ATH10K_DBG_WMI,
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004532 "wmi mem_req_id %d num_units %d num_unit_info %d unit size %d actual units %d\n",
4533 req_id,
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004534 __le32_to_cpu(arg.mem_reqs[i]->num_units),
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004535 num_unit_info,
4536 unit_size,
4537 num_units);
4538
4539 ret = ath10k_wmi_alloc_host_mem(ar, req_id, num_units,
4540 unit_size);
4541 if (ret)
4542 return;
4543 }
4544
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05304545skip_mem_alloc:
Michal Kazior7aa7a722014-08-25 12:09:38 +02004546 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kaziorca996ec2014-12-03 10:11:32 +02004547 "wmi event service ready min_tx_power 0x%08x max_tx_power 0x%08x ht_cap 0x%08x vht_cap 0x%08x sw_ver0 0x%08x sw_ver1 0x%08x fw_build 0x%08x phy_capab 0x%08x num_rf_chains 0x%08x eeprom_rd 0x%08x num_mem_reqs 0x%08x\n",
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004548 __le32_to_cpu(arg.min_tx_power),
4549 __le32_to_cpu(arg.max_tx_power),
4550 __le32_to_cpu(arg.ht_cap),
4551 __le32_to_cpu(arg.vht_cap),
4552 __le32_to_cpu(arg.sw_ver0),
4553 __le32_to_cpu(arg.sw_ver1),
Michal Kaziorca996ec2014-12-03 10:11:32 +02004554 __le32_to_cpu(arg.fw_build),
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004555 __le32_to_cpu(arg.phy_capab),
4556 __le32_to_cpu(arg.num_rf_chains),
4557 __le32_to_cpu(arg.eeprom_rd),
4558 __le32_to_cpu(arg.num_mem_reqs));
Bartosz Markowski6f97d252013-09-26 17:47:09 +02004559
Raja Manic8ecfc12015-07-29 11:40:38 +03004560 dev_kfree_skb(skb);
4561 ar->svc_rdy_skb = NULL;
Bartosz Markowski6f97d252013-09-26 17:47:09 +02004562 complete(&ar->wmi.service_ready);
4563}
4564
Raja Manic8ecfc12015-07-29 11:40:38 +03004565void ath10k_wmi_event_service_ready(struct ath10k *ar, struct sk_buff *skb)
4566{
4567 ar->svc_rdy_skb = skb;
4568 queue_work(ar->workqueue_aux, &ar->svc_rdy_work);
4569}
4570
Michal Kaziord7579d12014-12-03 10:10:54 +02004571static int ath10k_wmi_op_pull_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
4572 struct wmi_rdy_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02004573{
4574 struct wmi_ready_event *ev = (void *)skb->data;
4575
4576 if (skb->len < sizeof(*ev))
4577 return -EPROTO;
4578
4579 skb_pull(skb, sizeof(*ev));
4580 arg->sw_version = ev->sw_version;
4581 arg->abi_version = ev->abi_version;
4582 arg->status = ev->status;
4583 arg->mac_addr = ev->mac_addr.addr;
4584
4585 return 0;
4586}
4587
Michal Kaziorc1a46542015-03-10 16:21:54 +02004588static int ath10k_wmi_op_pull_roam_ev(struct ath10k *ar, struct sk_buff *skb,
4589 struct wmi_roam_ev_arg *arg)
4590{
4591 struct wmi_roam_ev *ev = (void *)skb->data;
4592
4593 if (skb->len < sizeof(*ev))
4594 return -EPROTO;
4595
4596 skb_pull(skb, sizeof(*ev));
4597 arg->vdev_id = ev->vdev_id;
4598 arg->reason = ev->reason;
4599
4600 return 0;
4601}
4602
Michal Kazior0226d602014-12-03 10:11:22 +02004603int ath10k_wmi_event_ready(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004604{
Michal Kazior32653cf2014-12-03 10:10:26 +02004605 struct wmi_rdy_ev_arg arg = {};
4606 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004607
Michal Kaziord7579d12014-12-03 10:10:54 +02004608 ret = ath10k_wmi_pull_rdy(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02004609 if (ret) {
4610 ath10k_warn(ar, "failed to parse ready event: %d\n", ret);
4611 return ret;
4612 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03004613
Michal Kazior7aa7a722014-08-25 12:09:38 +02004614 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior32653cf2014-12-03 10:10:26 +02004615 "wmi event ready sw_version %u abi_version %u mac_addr %pM status %d\n",
4616 __le32_to_cpu(arg.sw_version),
4617 __le32_to_cpu(arg.abi_version),
4618 arg.mac_addr,
4619 __le32_to_cpu(arg.status));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004620
Michal Kazior32653cf2014-12-03 10:10:26 +02004621 ether_addr_copy(ar->mac_addr, arg.mac_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004622 complete(&ar->wmi.unified_ready);
4623 return 0;
4624}
4625
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02004626static int ath10k_wmi_event_temperature(struct ath10k *ar, struct sk_buff *skb)
4627{
4628 const struct wmi_pdev_temperature_event *ev;
4629
4630 ev = (struct wmi_pdev_temperature_event *)skb->data;
4631 if (WARN_ON(skb->len < sizeof(*ev)))
4632 return -EPROTO;
4633
Rajkumar Manoharanac2953f2014-12-17 12:22:26 +02004634 ath10k_thermal_event_temperature(ar, __le32_to_cpu(ev->temperature));
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02004635 return 0;
4636}
4637
Michal Kaziord7579d12014-12-03 10:10:54 +02004638static void ath10k_wmi_op_rx(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004639{
4640 struct wmi_cmd_hdr *cmd_hdr;
4641 enum wmi_event_id id;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004642
4643 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
4644 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
4645
4646 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
Michal Kazior469d4792015-06-08 13:23:27 +02004647 goto out;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004648
Michal Kaziord35a6c12014-09-02 11:00:21 +03004649 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004650
4651 switch (id) {
4652 case WMI_MGMT_RX_EVENTID:
4653 ath10k_wmi_event_mgmt_rx(ar, skb);
4654 /* mgmt_rx() owns the skb now! */
4655 return;
4656 case WMI_SCAN_EVENTID:
4657 ath10k_wmi_event_scan(ar, skb);
4658 break;
4659 case WMI_CHAN_INFO_EVENTID:
4660 ath10k_wmi_event_chan_info(ar, skb);
4661 break;
4662 case WMI_ECHO_EVENTID:
4663 ath10k_wmi_event_echo(ar, skb);
4664 break;
4665 case WMI_DEBUG_MESG_EVENTID:
4666 ath10k_wmi_event_debug_mesg(ar, skb);
4667 break;
4668 case WMI_UPDATE_STATS_EVENTID:
4669 ath10k_wmi_event_update_stats(ar, skb);
4670 break;
4671 case WMI_VDEV_START_RESP_EVENTID:
4672 ath10k_wmi_event_vdev_start_resp(ar, skb);
4673 break;
4674 case WMI_VDEV_STOPPED_EVENTID:
4675 ath10k_wmi_event_vdev_stopped(ar, skb);
4676 break;
4677 case WMI_PEER_STA_KICKOUT_EVENTID:
4678 ath10k_wmi_event_peer_sta_kickout(ar, skb);
4679 break;
4680 case WMI_HOST_SWBA_EVENTID:
4681 ath10k_wmi_event_host_swba(ar, skb);
4682 break;
4683 case WMI_TBTTOFFSET_UPDATE_EVENTID:
4684 ath10k_wmi_event_tbttoffset_update(ar, skb);
4685 break;
4686 case WMI_PHYERR_EVENTID:
4687 ath10k_wmi_event_phyerr(ar, skb);
4688 break;
4689 case WMI_ROAM_EVENTID:
4690 ath10k_wmi_event_roam(ar, skb);
4691 break;
4692 case WMI_PROFILE_MATCH:
4693 ath10k_wmi_event_profile_match(ar, skb);
4694 break;
4695 case WMI_DEBUG_PRINT_EVENTID:
4696 ath10k_wmi_event_debug_print(ar, skb);
4697 break;
4698 case WMI_PDEV_QVIT_EVENTID:
4699 ath10k_wmi_event_pdev_qvit(ar, skb);
4700 break;
4701 case WMI_WLAN_PROFILE_DATA_EVENTID:
4702 ath10k_wmi_event_wlan_profile_data(ar, skb);
4703 break;
4704 case WMI_RTT_MEASUREMENT_REPORT_EVENTID:
4705 ath10k_wmi_event_rtt_measurement_report(ar, skb);
4706 break;
4707 case WMI_TSF_MEASUREMENT_REPORT_EVENTID:
4708 ath10k_wmi_event_tsf_measurement_report(ar, skb);
4709 break;
4710 case WMI_RTT_ERROR_REPORT_EVENTID:
4711 ath10k_wmi_event_rtt_error_report(ar, skb);
4712 break;
4713 case WMI_WOW_WAKEUP_HOST_EVENTID:
4714 ath10k_wmi_event_wow_wakeup_host(ar, skb);
4715 break;
4716 case WMI_DCS_INTERFERENCE_EVENTID:
4717 ath10k_wmi_event_dcs_interference(ar, skb);
4718 break;
4719 case WMI_PDEV_TPC_CONFIG_EVENTID:
4720 ath10k_wmi_event_pdev_tpc_config(ar, skb);
4721 break;
4722 case WMI_PDEV_FTM_INTG_EVENTID:
4723 ath10k_wmi_event_pdev_ftm_intg(ar, skb);
4724 break;
4725 case WMI_GTK_OFFLOAD_STATUS_EVENTID:
4726 ath10k_wmi_event_gtk_offload_status(ar, skb);
4727 break;
4728 case WMI_GTK_REKEY_FAIL_EVENTID:
4729 ath10k_wmi_event_gtk_rekey_fail(ar, skb);
4730 break;
4731 case WMI_TX_DELBA_COMPLETE_EVENTID:
4732 ath10k_wmi_event_delba_complete(ar, skb);
4733 break;
4734 case WMI_TX_ADDBA_COMPLETE_EVENTID:
4735 ath10k_wmi_event_addba_complete(ar, skb);
4736 break;
4737 case WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID:
4738 ath10k_wmi_event_vdev_install_key_complete(ar, skb);
4739 break;
4740 case WMI_SERVICE_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02004741 ath10k_wmi_event_service_ready(ar, skb);
Raja Manic8ecfc12015-07-29 11:40:38 +03004742 return;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004743 case WMI_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02004744 ath10k_wmi_event_ready(ar, skb);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004745 break;
4746 default:
Michal Kazior7aa7a722014-08-25 12:09:38 +02004747 ath10k_warn(ar, "Unknown eventid: %d\n", id);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004748 break;
4749 }
4750
Michal Kazior469d4792015-06-08 13:23:27 +02004751out:
Kalle Valo5e3dd152013-06-12 20:52:10 +03004752 dev_kfree_skb(skb);
4753}
4754
Michal Kaziord7579d12014-12-03 10:10:54 +02004755static void ath10k_wmi_10_1_op_rx(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004756{
4757 struct wmi_cmd_hdr *cmd_hdr;
4758 enum wmi_10x_event_id id;
Kalle Valo43d2a302014-09-10 18:23:30 +03004759 bool consumed;
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004760
4761 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
4762 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
4763
4764 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
Michal Kazior469d4792015-06-08 13:23:27 +02004765 goto out;
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004766
Michal Kaziord35a6c12014-09-02 11:00:21 +03004767 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004768
Kalle Valo43d2a302014-09-10 18:23:30 +03004769 consumed = ath10k_tm_event_wmi(ar, id, skb);
4770
4771 /* Ready event must be handled normally also in UTF mode so that we
4772 * know the UTF firmware has booted, others we are just bypass WMI
4773 * events to testmode.
4774 */
4775 if (consumed && id != WMI_10X_READY_EVENTID) {
4776 ath10k_dbg(ar, ATH10K_DBG_WMI,
4777 "wmi testmode consumed 0x%x\n", id);
4778 goto out;
4779 }
4780
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004781 switch (id) {
4782 case WMI_10X_MGMT_RX_EVENTID:
4783 ath10k_wmi_event_mgmt_rx(ar, skb);
4784 /* mgmt_rx() owns the skb now! */
4785 return;
4786 case WMI_10X_SCAN_EVENTID:
4787 ath10k_wmi_event_scan(ar, skb);
4788 break;
4789 case WMI_10X_CHAN_INFO_EVENTID:
4790 ath10k_wmi_event_chan_info(ar, skb);
4791 break;
4792 case WMI_10X_ECHO_EVENTID:
4793 ath10k_wmi_event_echo(ar, skb);
4794 break;
4795 case WMI_10X_DEBUG_MESG_EVENTID:
4796 ath10k_wmi_event_debug_mesg(ar, skb);
4797 break;
4798 case WMI_10X_UPDATE_STATS_EVENTID:
4799 ath10k_wmi_event_update_stats(ar, skb);
4800 break;
4801 case WMI_10X_VDEV_START_RESP_EVENTID:
4802 ath10k_wmi_event_vdev_start_resp(ar, skb);
4803 break;
4804 case WMI_10X_VDEV_STOPPED_EVENTID:
4805 ath10k_wmi_event_vdev_stopped(ar, skb);
4806 break;
4807 case WMI_10X_PEER_STA_KICKOUT_EVENTID:
4808 ath10k_wmi_event_peer_sta_kickout(ar, skb);
4809 break;
4810 case WMI_10X_HOST_SWBA_EVENTID:
4811 ath10k_wmi_event_host_swba(ar, skb);
4812 break;
4813 case WMI_10X_TBTTOFFSET_UPDATE_EVENTID:
4814 ath10k_wmi_event_tbttoffset_update(ar, skb);
4815 break;
4816 case WMI_10X_PHYERR_EVENTID:
4817 ath10k_wmi_event_phyerr(ar, skb);
4818 break;
4819 case WMI_10X_ROAM_EVENTID:
4820 ath10k_wmi_event_roam(ar, skb);
4821 break;
4822 case WMI_10X_PROFILE_MATCH:
4823 ath10k_wmi_event_profile_match(ar, skb);
4824 break;
4825 case WMI_10X_DEBUG_PRINT_EVENTID:
4826 ath10k_wmi_event_debug_print(ar, skb);
4827 break;
4828 case WMI_10X_PDEV_QVIT_EVENTID:
4829 ath10k_wmi_event_pdev_qvit(ar, skb);
4830 break;
4831 case WMI_10X_WLAN_PROFILE_DATA_EVENTID:
4832 ath10k_wmi_event_wlan_profile_data(ar, skb);
4833 break;
4834 case WMI_10X_RTT_MEASUREMENT_REPORT_EVENTID:
4835 ath10k_wmi_event_rtt_measurement_report(ar, skb);
4836 break;
4837 case WMI_10X_TSF_MEASUREMENT_REPORT_EVENTID:
4838 ath10k_wmi_event_tsf_measurement_report(ar, skb);
4839 break;
4840 case WMI_10X_RTT_ERROR_REPORT_EVENTID:
4841 ath10k_wmi_event_rtt_error_report(ar, skb);
4842 break;
4843 case WMI_10X_WOW_WAKEUP_HOST_EVENTID:
4844 ath10k_wmi_event_wow_wakeup_host(ar, skb);
4845 break;
4846 case WMI_10X_DCS_INTERFERENCE_EVENTID:
4847 ath10k_wmi_event_dcs_interference(ar, skb);
4848 break;
4849 case WMI_10X_PDEV_TPC_CONFIG_EVENTID:
4850 ath10k_wmi_event_pdev_tpc_config(ar, skb);
4851 break;
4852 case WMI_10X_INST_RSSI_STATS_EVENTID:
4853 ath10k_wmi_event_inst_rssi_stats(ar, skb);
4854 break;
4855 case WMI_10X_VDEV_STANDBY_REQ_EVENTID:
4856 ath10k_wmi_event_vdev_standby_req(ar, skb);
4857 break;
4858 case WMI_10X_VDEV_RESUME_REQ_EVENTID:
4859 ath10k_wmi_event_vdev_resume_req(ar, skb);
4860 break;
4861 case WMI_10X_SERVICE_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02004862 ath10k_wmi_event_service_ready(ar, skb);
Raja Manic8ecfc12015-07-29 11:40:38 +03004863 return;
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004864 case WMI_10X_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02004865 ath10k_wmi_event_ready(ar, skb);
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004866 break;
Kalle Valo43d2a302014-09-10 18:23:30 +03004867 case WMI_10X_PDEV_UTF_EVENTID:
4868 /* ignore utf events */
4869 break;
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004870 default:
Michal Kazior7aa7a722014-08-25 12:09:38 +02004871 ath10k_warn(ar, "Unknown eventid: %d\n", id);
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004872 break;
4873 }
4874
Kalle Valo43d2a302014-09-10 18:23:30 +03004875out:
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004876 dev_kfree_skb(skb);
4877}
4878
Michal Kaziord7579d12014-12-03 10:10:54 +02004879static void ath10k_wmi_10_2_op_rx(struct ath10k *ar, struct sk_buff *skb)
Michal Kazior24c88f72014-07-25 13:32:17 +02004880{
4881 struct wmi_cmd_hdr *cmd_hdr;
4882 enum wmi_10_2_event_id id;
4883
4884 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
4885 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
4886
4887 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
Michal Kazior469d4792015-06-08 13:23:27 +02004888 goto out;
Michal Kazior24c88f72014-07-25 13:32:17 +02004889
Michal Kaziord35a6c12014-09-02 11:00:21 +03004890 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
Michal Kazior24c88f72014-07-25 13:32:17 +02004891
4892 switch (id) {
4893 case WMI_10_2_MGMT_RX_EVENTID:
4894 ath10k_wmi_event_mgmt_rx(ar, skb);
4895 /* mgmt_rx() owns the skb now! */
4896 return;
4897 case WMI_10_2_SCAN_EVENTID:
4898 ath10k_wmi_event_scan(ar, skb);
4899 break;
4900 case WMI_10_2_CHAN_INFO_EVENTID:
4901 ath10k_wmi_event_chan_info(ar, skb);
4902 break;
4903 case WMI_10_2_ECHO_EVENTID:
4904 ath10k_wmi_event_echo(ar, skb);
4905 break;
4906 case WMI_10_2_DEBUG_MESG_EVENTID:
4907 ath10k_wmi_event_debug_mesg(ar, skb);
4908 break;
4909 case WMI_10_2_UPDATE_STATS_EVENTID:
4910 ath10k_wmi_event_update_stats(ar, skb);
4911 break;
4912 case WMI_10_2_VDEV_START_RESP_EVENTID:
4913 ath10k_wmi_event_vdev_start_resp(ar, skb);
4914 break;
4915 case WMI_10_2_VDEV_STOPPED_EVENTID:
4916 ath10k_wmi_event_vdev_stopped(ar, skb);
4917 break;
4918 case WMI_10_2_PEER_STA_KICKOUT_EVENTID:
4919 ath10k_wmi_event_peer_sta_kickout(ar, skb);
4920 break;
4921 case WMI_10_2_HOST_SWBA_EVENTID:
4922 ath10k_wmi_event_host_swba(ar, skb);
4923 break;
4924 case WMI_10_2_TBTTOFFSET_UPDATE_EVENTID:
4925 ath10k_wmi_event_tbttoffset_update(ar, skb);
4926 break;
4927 case WMI_10_2_PHYERR_EVENTID:
4928 ath10k_wmi_event_phyerr(ar, skb);
4929 break;
4930 case WMI_10_2_ROAM_EVENTID:
4931 ath10k_wmi_event_roam(ar, skb);
4932 break;
4933 case WMI_10_2_PROFILE_MATCH:
4934 ath10k_wmi_event_profile_match(ar, skb);
4935 break;
4936 case WMI_10_2_DEBUG_PRINT_EVENTID:
4937 ath10k_wmi_event_debug_print(ar, skb);
4938 break;
4939 case WMI_10_2_PDEV_QVIT_EVENTID:
4940 ath10k_wmi_event_pdev_qvit(ar, skb);
4941 break;
4942 case WMI_10_2_WLAN_PROFILE_DATA_EVENTID:
4943 ath10k_wmi_event_wlan_profile_data(ar, skb);
4944 break;
4945 case WMI_10_2_RTT_MEASUREMENT_REPORT_EVENTID:
4946 ath10k_wmi_event_rtt_measurement_report(ar, skb);
4947 break;
4948 case WMI_10_2_TSF_MEASUREMENT_REPORT_EVENTID:
4949 ath10k_wmi_event_tsf_measurement_report(ar, skb);
4950 break;
4951 case WMI_10_2_RTT_ERROR_REPORT_EVENTID:
4952 ath10k_wmi_event_rtt_error_report(ar, skb);
4953 break;
4954 case WMI_10_2_WOW_WAKEUP_HOST_EVENTID:
4955 ath10k_wmi_event_wow_wakeup_host(ar, skb);
4956 break;
4957 case WMI_10_2_DCS_INTERFERENCE_EVENTID:
4958 ath10k_wmi_event_dcs_interference(ar, skb);
4959 break;
4960 case WMI_10_2_PDEV_TPC_CONFIG_EVENTID:
4961 ath10k_wmi_event_pdev_tpc_config(ar, skb);
4962 break;
4963 case WMI_10_2_INST_RSSI_STATS_EVENTID:
4964 ath10k_wmi_event_inst_rssi_stats(ar, skb);
4965 break;
4966 case WMI_10_2_VDEV_STANDBY_REQ_EVENTID:
4967 ath10k_wmi_event_vdev_standby_req(ar, skb);
4968 break;
4969 case WMI_10_2_VDEV_RESUME_REQ_EVENTID:
4970 ath10k_wmi_event_vdev_resume_req(ar, skb);
4971 break;
4972 case WMI_10_2_SERVICE_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02004973 ath10k_wmi_event_service_ready(ar, skb);
Raja Manic8ecfc12015-07-29 11:40:38 +03004974 return;
Michal Kazior24c88f72014-07-25 13:32:17 +02004975 case WMI_10_2_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02004976 ath10k_wmi_event_ready(ar, skb);
Michal Kazior24c88f72014-07-25 13:32:17 +02004977 break;
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02004978 case WMI_10_2_PDEV_TEMPERATURE_EVENTID:
4979 ath10k_wmi_event_temperature(ar, skb);
4980 break;
Michal Kazior24c88f72014-07-25 13:32:17 +02004981 case WMI_10_2_RTT_KEEPALIVE_EVENTID:
4982 case WMI_10_2_GPIO_INPUT_EVENTID:
4983 case WMI_10_2_PEER_RATECODE_LIST_EVENTID:
4984 case WMI_10_2_GENERIC_BUFFER_EVENTID:
4985 case WMI_10_2_MCAST_BUF_RELEASE_EVENTID:
4986 case WMI_10_2_MCAST_LIST_AGEOUT_EVENTID:
4987 case WMI_10_2_WDS_PEER_EVENTID:
Michal Kazior7aa7a722014-08-25 12:09:38 +02004988 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior24c88f72014-07-25 13:32:17 +02004989 "received event id %d not implemented\n", id);
4990 break;
4991 default:
Michal Kazior7aa7a722014-08-25 12:09:38 +02004992 ath10k_warn(ar, "Unknown eventid: %d\n", id);
Michal Kazior24c88f72014-07-25 13:32:17 +02004993 break;
4994 }
4995
Michal Kazior469d4792015-06-08 13:23:27 +02004996out:
Michal Kazior24c88f72014-07-25 13:32:17 +02004997 dev_kfree_skb(skb);
4998}
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004999
Raja Mani1c092962015-06-22 20:10:16 +05305000static void ath10k_wmi_10_4_op_rx(struct ath10k *ar, struct sk_buff *skb)
5001{
5002 struct wmi_cmd_hdr *cmd_hdr;
5003 enum wmi_10_4_event_id id;
5004
5005 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
5006 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
5007
5008 if (!skb_pull(skb, sizeof(struct wmi_cmd_hdr)))
5009 goto out;
5010
5011 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
5012
5013 switch (id) {
5014 case WMI_10_4_MGMT_RX_EVENTID:
5015 ath10k_wmi_event_mgmt_rx(ar, skb);
5016 /* mgmt_rx() owns the skb now! */
5017 return;
Raja Mani373b48c2015-06-22 20:22:22 +05305018 case WMI_10_4_ECHO_EVENTID:
5019 ath10k_wmi_event_echo(ar, skb);
5020 break;
5021 case WMI_10_4_DEBUG_MESG_EVENTID:
5022 ath10k_wmi_event_debug_mesg(ar, skb);
5023 break;
5024 case WMI_10_4_SERVICE_READY_EVENTID:
5025 ath10k_wmi_event_service_ready(ar, skb);
Raja Manic8ecfc12015-07-29 11:40:38 +03005026 return;
Raja Manib2297ba2015-06-22 20:22:23 +05305027 case WMI_10_4_SCAN_EVENTID:
5028 ath10k_wmi_event_scan(ar, skb);
5029 break;
5030 case WMI_10_4_CHAN_INFO_EVENTID:
5031 ath10k_wmi_event_chan_info(ar, skb);
5032 break;
Raja Mani2b0a2e02015-08-14 11:13:34 +03005033 case WMI_10_4_PHYERR_EVENTID:
5034 ath10k_wmi_event_phyerr(ar, skb);
5035 break;
Raja Manid02e7522015-06-22 20:10:18 +05305036 case WMI_10_4_READY_EVENTID:
5037 ath10k_wmi_event_ready(ar, skb);
5038 break;
Raja Mani373b48c2015-06-22 20:22:22 +05305039 case WMI_10_4_PEER_STA_KICKOUT_EVENTID:
5040 ath10k_wmi_event_peer_sta_kickout(ar, skb);
5041 break;
Raja Mani3cec3be2015-06-22 20:22:21 +05305042 case WMI_10_4_HOST_SWBA_EVENTID:
5043 ath10k_wmi_event_host_swba(ar, skb);
5044 break;
Raja Mani373b48c2015-06-22 20:22:22 +05305045 case WMI_10_4_TBTTOFFSET_UPDATE_EVENTID:
5046 ath10k_wmi_event_tbttoffset_update(ar, skb);
5047 break;
5048 case WMI_10_4_DEBUG_PRINT_EVENTID:
5049 ath10k_wmi_event_debug_print(ar, skb);
5050 break;
5051 case WMI_10_4_VDEV_START_RESP_EVENTID:
5052 ath10k_wmi_event_vdev_start_resp(ar, skb);
5053 break;
5054 case WMI_10_4_VDEV_STOPPED_EVENTID:
5055 ath10k_wmi_event_vdev_stopped(ar, skb);
5056 break;
5057 case WMI_10_4_WOW_WAKEUP_HOST_EVENTID:
5058 ath10k_dbg(ar, ATH10K_DBG_WMI,
5059 "received event id %d not implemented\n", id);
5060 break;
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02005061 case WMI_10_4_UPDATE_STATS_EVENTID:
5062 ath10k_wmi_event_update_stats(ar, skb);
5063 break;
Raja Mani1c092962015-06-22 20:10:16 +05305064 default:
5065 ath10k_warn(ar, "Unknown eventid: %d\n", id);
5066 break;
5067 }
5068
5069out:
5070 dev_kfree_skb(skb);
5071}
5072
Bartosz Markowskice428702013-09-26 17:47:05 +02005073static void ath10k_wmi_process_rx(struct ath10k *ar, struct sk_buff *skb)
5074{
Michal Kaziord7579d12014-12-03 10:10:54 +02005075 int ret;
5076
5077 ret = ath10k_wmi_rx(ar, skb);
5078 if (ret)
5079 ath10k_warn(ar, "failed to process wmi rx: %d\n", ret);
Bartosz Markowskice428702013-09-26 17:47:05 +02005080}
5081
Michal Kazior95bf21f2014-05-16 17:15:39 +03005082int ath10k_wmi_connect(struct ath10k *ar)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005083{
5084 int status;
5085 struct ath10k_htc_svc_conn_req conn_req;
5086 struct ath10k_htc_svc_conn_resp conn_resp;
5087
5088 memset(&conn_req, 0, sizeof(conn_req));
5089 memset(&conn_resp, 0, sizeof(conn_resp));
5090
5091 /* these fields are the same for all service endpoints */
5092 conn_req.ep_ops.ep_tx_complete = ath10k_wmi_htc_tx_complete;
5093 conn_req.ep_ops.ep_rx_complete = ath10k_wmi_process_rx;
Michal Kaziorbe8b3942013-09-13 14:16:54 +02005094 conn_req.ep_ops.ep_tx_credits = ath10k_wmi_op_ep_tx_credits;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005095
5096 /* connect to control service */
5097 conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL;
5098
Michal Kaziorcd003fa2013-07-05 16:15:13 +03005099 status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005100 if (status) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02005101 ath10k_warn(ar, "failed to connect to WMI CONTROL service status: %d\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +03005102 status);
5103 return status;
5104 }
5105
5106 ar->wmi.eid = conn_resp.eid;
5107 return 0;
5108}
5109
Michal Kaziord7579d12014-12-03 10:10:54 +02005110static struct sk_buff *
5111ath10k_wmi_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16 rd5g,
5112 u16 ctl2g, u16 ctl5g,
5113 enum wmi_dfs_region dfs_reg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005114{
5115 struct wmi_pdev_set_regdomain_cmd *cmd;
5116 struct sk_buff *skb;
5117
Michal Kazior7aa7a722014-08-25 12:09:38 +02005118 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005119 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005120 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005121
5122 cmd = (struct wmi_pdev_set_regdomain_cmd *)skb->data;
5123 cmd->reg_domain = __cpu_to_le32(rd);
5124 cmd->reg_domain_2G = __cpu_to_le32(rd2g);
5125 cmd->reg_domain_5G = __cpu_to_le32(rd5g);
5126 cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g);
5127 cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
5128
Michal Kazior7aa7a722014-08-25 12:09:38 +02005129 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005130 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x\n",
5131 rd, rd2g, rd5g, ctl2g, ctl5g);
Michal Kaziord7579d12014-12-03 10:10:54 +02005132 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005133}
5134
Michal Kaziord7579d12014-12-03 10:10:54 +02005135static struct sk_buff *
5136ath10k_wmi_10x_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16
5137 rd5g, u16 ctl2g, u16 ctl5g,
5138 enum wmi_dfs_region dfs_reg)
Marek Puzyniak821af6a2014-03-21 17:46:57 +02005139{
5140 struct wmi_pdev_set_regdomain_cmd_10x *cmd;
5141 struct sk_buff *skb;
5142
Michal Kazior7aa7a722014-08-25 12:09:38 +02005143 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Marek Puzyniak821af6a2014-03-21 17:46:57 +02005144 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005145 return ERR_PTR(-ENOMEM);
Marek Puzyniak821af6a2014-03-21 17:46:57 +02005146
5147 cmd = (struct wmi_pdev_set_regdomain_cmd_10x *)skb->data;
5148 cmd->reg_domain = __cpu_to_le32(rd);
5149 cmd->reg_domain_2G = __cpu_to_le32(rd2g);
5150 cmd->reg_domain_5G = __cpu_to_le32(rd5g);
5151 cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g);
5152 cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
5153 cmd->dfs_domain = __cpu_to_le32(dfs_reg);
5154
Michal Kazior7aa7a722014-08-25 12:09:38 +02005155 ath10k_dbg(ar, ATH10K_DBG_WMI,
Marek Puzyniak821af6a2014-03-21 17:46:57 +02005156 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x dfs_region %x\n",
5157 rd, rd2g, rd5g, ctl2g, ctl5g, dfs_reg);
Michal Kaziord7579d12014-12-03 10:10:54 +02005158 return skb;
Marek Puzyniak821af6a2014-03-21 17:46:57 +02005159}
5160
Michal Kaziord7579d12014-12-03 10:10:54 +02005161static struct sk_buff *
5162ath10k_wmi_op_gen_pdev_suspend(struct ath10k *ar, u32 suspend_opt)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005163{
5164 struct wmi_pdev_suspend_cmd *cmd;
5165 struct sk_buff *skb;
5166
Michal Kazior7aa7a722014-08-25 12:09:38 +02005167 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005168 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005169 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005170
5171 cmd = (struct wmi_pdev_suspend_cmd *)skb->data;
Marek Puzyniak00f54822014-02-10 17:14:24 +01005172 cmd->suspend_opt = __cpu_to_le32(suspend_opt);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005173
Michal Kaziord7579d12014-12-03 10:10:54 +02005174 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005175}
5176
Michal Kaziord7579d12014-12-03 10:10:54 +02005177static struct sk_buff *
5178ath10k_wmi_op_gen_pdev_resume(struct ath10k *ar)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005179{
5180 struct sk_buff *skb;
5181
Michal Kazior7aa7a722014-08-25 12:09:38 +02005182 skb = ath10k_wmi_alloc_skb(ar, 0);
Michal Kaziord7579d12014-12-03 10:10:54 +02005183 if (!skb)
5184 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005185
Michal Kaziord7579d12014-12-03 10:10:54 +02005186 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005187}
5188
Michal Kaziord7579d12014-12-03 10:10:54 +02005189static struct sk_buff *
5190ath10k_wmi_op_gen_pdev_set_param(struct ath10k *ar, u32 id, u32 value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005191{
5192 struct wmi_pdev_set_param_cmd *cmd;
5193 struct sk_buff *skb;
5194
Bartosz Markowski226a3392013-09-26 17:47:16 +02005195 if (id == WMI_PDEV_PARAM_UNSUPPORTED) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02005196 ath10k_warn(ar, "pdev param %d not supported by firmware\n",
5197 id);
Michal Kaziord7579d12014-12-03 10:10:54 +02005198 return ERR_PTR(-EOPNOTSUPP);
Bartosz Markowski226a3392013-09-26 17:47:16 +02005199 }
5200
Michal Kazior7aa7a722014-08-25 12:09:38 +02005201 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005202 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005203 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005204
5205 cmd = (struct wmi_pdev_set_param_cmd *)skb->data;
5206 cmd->param_id = __cpu_to_le32(id);
5207 cmd->param_value = __cpu_to_le32(value);
5208
Michal Kazior7aa7a722014-08-25 12:09:38 +02005209 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set param %d value %d\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +03005210 id, value);
Michal Kaziord7579d12014-12-03 10:10:54 +02005211 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005212}
5213
Michal Kazior0226d602014-12-03 10:11:22 +02005214void ath10k_wmi_put_host_mem_chunks(struct ath10k *ar,
5215 struct wmi_host_mem_chunks *chunks)
Michal Kaziorcf9fca82014-09-18 15:21:22 +02005216{
5217 struct host_memory_chunk *chunk;
5218 int i;
5219
5220 chunks->count = __cpu_to_le32(ar->wmi.num_mem_chunks);
5221
5222 for (i = 0; i < ar->wmi.num_mem_chunks; i++) {
5223 chunk = &chunks->items[i];
5224 chunk->ptr = __cpu_to_le32(ar->wmi.mem_chunks[i].paddr);
5225 chunk->size = __cpu_to_le32(ar->wmi.mem_chunks[i].len);
5226 chunk->req_id = __cpu_to_le32(ar->wmi.mem_chunks[i].req_id);
5227
5228 ath10k_dbg(ar, ATH10K_DBG_WMI,
5229 "wmi chunk %d len %d requested, addr 0x%llx\n",
5230 i,
5231 ar->wmi.mem_chunks[i].len,
5232 (unsigned long long)ar->wmi.mem_chunks[i].paddr);
5233 }
5234}
5235
Michal Kaziord7579d12014-12-03 10:10:54 +02005236static struct sk_buff *ath10k_wmi_op_gen_init(struct ath10k *ar)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005237{
5238 struct wmi_init_cmd *cmd;
5239 struct sk_buff *buf;
5240 struct wmi_resource_config config = {};
Bartosz Markowskib3effe62013-09-26 17:47:11 +02005241 u32 len, val;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005242
5243 config.num_vdevs = __cpu_to_le32(TARGET_NUM_VDEVS);
Michal Kaziorcfd10612014-11-25 15:16:05 +01005244 config.num_peers = __cpu_to_le32(TARGET_NUM_PEERS);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005245 config.num_offload_peers = __cpu_to_le32(TARGET_NUM_OFFLOAD_PEERS);
5246
5247 config.num_offload_reorder_bufs =
5248 __cpu_to_le32(TARGET_NUM_OFFLOAD_REORDER_BUFS);
5249
5250 config.num_peer_keys = __cpu_to_le32(TARGET_NUM_PEER_KEYS);
5251 config.num_tids = __cpu_to_le32(TARGET_NUM_TIDS);
5252 config.ast_skid_limit = __cpu_to_le32(TARGET_AST_SKID_LIMIT);
5253 config.tx_chain_mask = __cpu_to_le32(TARGET_TX_CHAIN_MASK);
5254 config.rx_chain_mask = __cpu_to_le32(TARGET_RX_CHAIN_MASK);
5255 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
5256 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
5257 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
5258 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_RX_TIMEOUT_HI_PRI);
David Liuccec9032015-07-24 20:25:32 +03005259 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005260 config.scan_max_pending_reqs =
5261 __cpu_to_le32(TARGET_SCAN_MAX_PENDING_REQS);
5262
5263 config.bmiss_offload_max_vdev =
5264 __cpu_to_le32(TARGET_BMISS_OFFLOAD_MAX_VDEV);
5265
5266 config.roam_offload_max_vdev =
5267 __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_VDEV);
5268
5269 config.roam_offload_max_ap_profiles =
5270 __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_AP_PROFILES);
5271
5272 config.num_mcast_groups = __cpu_to_le32(TARGET_NUM_MCAST_GROUPS);
5273 config.num_mcast_table_elems =
5274 __cpu_to_le32(TARGET_NUM_MCAST_TABLE_ELEMS);
5275
5276 config.mcast2ucast_mode = __cpu_to_le32(TARGET_MCAST2UCAST_MODE);
5277 config.tx_dbg_log_size = __cpu_to_le32(TARGET_TX_DBG_LOG_SIZE);
5278 config.num_wds_entries = __cpu_to_le32(TARGET_NUM_WDS_ENTRIES);
5279 config.dma_burst_size = __cpu_to_le32(TARGET_DMA_BURST_SIZE);
5280 config.mac_aggr_delim = __cpu_to_le32(TARGET_MAC_AGGR_DELIM);
5281
5282 val = TARGET_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
5283 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
5284
5285 config.vow_config = __cpu_to_le32(TARGET_VOW_CONFIG);
5286
5287 config.gtk_offload_max_vdev =
5288 __cpu_to_le32(TARGET_GTK_OFFLOAD_MAX_VDEV);
5289
5290 config.num_msdu_desc = __cpu_to_le32(TARGET_NUM_MSDU_DESC);
5291 config.max_frag_entries = __cpu_to_le32(TARGET_MAX_FRAG_ENTRIES);
5292
Bartosz Markowskib3effe62013-09-26 17:47:11 +02005293 len = sizeof(*cmd) +
5294 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5295
Michal Kazior7aa7a722014-08-25 12:09:38 +02005296 buf = ath10k_wmi_alloc_skb(ar, len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005297 if (!buf)
Michal Kaziord7579d12014-12-03 10:10:54 +02005298 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005299
5300 cmd = (struct wmi_init_cmd *)buf->data;
Bartosz Markowskib3effe62013-09-26 17:47:11 +02005301
Kalle Valo5e3dd152013-06-12 20:52:10 +03005302 memcpy(&cmd->resource_config, &config, sizeof(config));
Michal Kaziorcf9fca82014-09-18 15:21:22 +02005303 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005304
Michal Kazior7aa7a722014-08-25 12:09:38 +02005305 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02005306 return buf;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005307}
5308
Michal Kaziord7579d12014-12-03 10:10:54 +02005309static struct sk_buff *ath10k_wmi_10_1_op_gen_init(struct ath10k *ar)
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005310{
5311 struct wmi_init_cmd_10x *cmd;
5312 struct sk_buff *buf;
5313 struct wmi_resource_config_10x config = {};
5314 u32 len, val;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005315
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005316 config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS);
5317 config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS);
5318 config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS);
5319 config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS);
5320 config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT);
5321 config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK);
5322 config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK);
5323 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5324 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5325 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5326 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI);
David Liuccec9032015-07-24 20:25:32 +03005327 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005328 config.scan_max_pending_reqs =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005329 __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005330
5331 config.bmiss_offload_max_vdev =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005332 __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005333
5334 config.roam_offload_max_vdev =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005335 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005336
5337 config.roam_offload_max_ap_profiles =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005338 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005339
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005340 config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005341 config.num_mcast_table_elems =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005342 __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005343
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005344 config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE);
5345 config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE);
5346 config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES);
5347 config.dma_burst_size = __cpu_to_le32(TARGET_10X_DMA_BURST_SIZE);
5348 config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005349
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005350 val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005351 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
5352
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005353 config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005354
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005355 config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC);
5356 config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005357
5358 len = sizeof(*cmd) +
5359 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5360
Michal Kazior7aa7a722014-08-25 12:09:38 +02005361 buf = ath10k_wmi_alloc_skb(ar, len);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005362 if (!buf)
Michal Kaziord7579d12014-12-03 10:10:54 +02005363 return ERR_PTR(-ENOMEM);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005364
5365 cmd = (struct wmi_init_cmd_10x *)buf->data;
5366
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005367 memcpy(&cmd->resource_config, &config, sizeof(config));
Michal Kaziorcf9fca82014-09-18 15:21:22 +02005368 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005369
Michal Kazior7aa7a722014-08-25 12:09:38 +02005370 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10x\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02005371 return buf;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005372}
5373
Michal Kaziord7579d12014-12-03 10:10:54 +02005374static struct sk_buff *ath10k_wmi_10_2_op_gen_init(struct ath10k *ar)
Michal Kazior24c88f72014-07-25 13:32:17 +02005375{
5376 struct wmi_init_cmd_10_2 *cmd;
5377 struct sk_buff *buf;
5378 struct wmi_resource_config_10x config = {};
Sujith Manoharanb6c8e282015-01-12 12:30:02 +02005379 u32 len, val, features;
Michal Kazior24c88f72014-07-25 13:32:17 +02005380
5381 config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS);
5382 config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS);
5383 config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS);
5384 config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS);
5385 config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT);
5386 config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK);
5387 config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK);
5388 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5389 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5390 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5391 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI);
David Liuccec9032015-07-24 20:25:32 +03005392 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
Michal Kazior24c88f72014-07-25 13:32:17 +02005393
5394 config.scan_max_pending_reqs =
5395 __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS);
5396
5397 config.bmiss_offload_max_vdev =
5398 __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV);
5399
5400 config.roam_offload_max_vdev =
5401 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV);
5402
5403 config.roam_offload_max_ap_profiles =
5404 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES);
5405
5406 config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS);
5407 config.num_mcast_table_elems =
5408 __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS);
5409
5410 config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE);
5411 config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE);
5412 config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES);
Sujith Manoharanf6603ff2015-01-12 12:30:02 +02005413 config.dma_burst_size = __cpu_to_le32(TARGET_10_2_DMA_BURST_SIZE);
Michal Kazior24c88f72014-07-25 13:32:17 +02005414 config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM);
5415
5416 val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
5417 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
5418
5419 config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG);
5420
5421 config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC);
5422 config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES);
5423
5424 len = sizeof(*cmd) +
5425 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5426
Michal Kazior7aa7a722014-08-25 12:09:38 +02005427 buf = ath10k_wmi_alloc_skb(ar, len);
Michal Kazior24c88f72014-07-25 13:32:17 +02005428 if (!buf)
Michal Kaziord7579d12014-12-03 10:10:54 +02005429 return ERR_PTR(-ENOMEM);
Michal Kazior24c88f72014-07-25 13:32:17 +02005430
5431 cmd = (struct wmi_init_cmd_10_2 *)buf->data;
5432
Sujith Manoharanb6c8e282015-01-12 12:30:02 +02005433 features = WMI_10_2_RX_BATCH_MODE;
Yanbo Lide0c7892015-04-15 15:28:08 +03005434 if (test_bit(WMI_SERVICE_COEX_GPIO, ar->wmi.svc_map))
5435 features |= WMI_10_2_COEX_GPIO;
Sujith Manoharanb6c8e282015-01-12 12:30:02 +02005436 cmd->resource_config.feature_mask = __cpu_to_le32(features);
5437
Michal Kazior24c88f72014-07-25 13:32:17 +02005438 memcpy(&cmd->resource_config.common, &config, sizeof(config));
Michal Kaziorcf9fca82014-09-18 15:21:22 +02005439 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
Michal Kazior24c88f72014-07-25 13:32:17 +02005440
Michal Kazior7aa7a722014-08-25 12:09:38 +02005441 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.2\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02005442 return buf;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005443}
5444
Raja Manid1e52a82015-06-22 20:10:15 +05305445static struct sk_buff *ath10k_wmi_10_4_op_gen_init(struct ath10k *ar)
5446{
5447 struct wmi_init_cmd_10_4 *cmd;
5448 struct sk_buff *buf;
5449 struct wmi_resource_config_10_4 config = {};
5450 u32 len;
5451
5452 config.num_vdevs = __cpu_to_le32(ar->max_num_vdevs);
5453 config.num_peers = __cpu_to_le32(ar->max_num_peers);
5454 config.num_active_peers = __cpu_to_le32(ar->num_active_peers);
5455 config.num_tids = __cpu_to_le32(ar->num_tids);
5456
5457 config.num_offload_peers = __cpu_to_le32(TARGET_10_4_NUM_OFFLOAD_PEERS);
5458 config.num_offload_reorder_buffs =
5459 __cpu_to_le32(TARGET_10_4_NUM_OFFLOAD_REORDER_BUFFS);
5460 config.num_peer_keys = __cpu_to_le32(TARGET_10_4_NUM_PEER_KEYS);
5461 config.ast_skid_limit = __cpu_to_le32(TARGET_10_4_AST_SKID_LIMIT);
5462 config.tx_chain_mask = __cpu_to_le32(TARGET_10_4_TX_CHAIN_MASK);
5463 config.rx_chain_mask = __cpu_to_le32(TARGET_10_4_RX_CHAIN_MASK);
5464
5465 config.rx_timeout_pri[0] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_LO_PRI);
5466 config.rx_timeout_pri[1] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_LO_PRI);
5467 config.rx_timeout_pri[2] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_LO_PRI);
5468 config.rx_timeout_pri[3] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_HI_PRI);
5469
Peter Ohbc27e8c2015-10-05 17:56:39 +03005470 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
Raja Manid1e52a82015-06-22 20:10:15 +05305471 config.scan_max_pending_req = __cpu_to_le32(TARGET_10_4_SCAN_MAX_REQS);
5472 config.bmiss_offload_max_vdev =
5473 __cpu_to_le32(TARGET_10_4_BMISS_OFFLOAD_MAX_VDEV);
5474 config.roam_offload_max_vdev =
5475 __cpu_to_le32(TARGET_10_4_ROAM_OFFLOAD_MAX_VDEV);
5476 config.roam_offload_max_ap_profiles =
5477 __cpu_to_le32(TARGET_10_4_ROAM_OFFLOAD_MAX_PROFILES);
5478 config.num_mcast_groups = __cpu_to_le32(TARGET_10_4_NUM_MCAST_GROUPS);
5479 config.num_mcast_table_elems =
5480 __cpu_to_le32(TARGET_10_4_NUM_MCAST_TABLE_ELEMS);
5481
5482 config.mcast2ucast_mode = __cpu_to_le32(TARGET_10_4_MCAST2UCAST_MODE);
5483 config.tx_dbg_log_size = __cpu_to_le32(TARGET_10_4_TX_DBG_LOG_SIZE);
5484 config.num_wds_entries = __cpu_to_le32(TARGET_10_4_NUM_WDS_ENTRIES);
5485 config.dma_burst_size = __cpu_to_le32(TARGET_10_4_DMA_BURST_SIZE);
5486 config.mac_aggr_delim = __cpu_to_le32(TARGET_10_4_MAC_AGGR_DELIM);
5487
5488 config.rx_skip_defrag_timeout_dup_detection_check =
5489 __cpu_to_le32(TARGET_10_4_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK);
5490
5491 config.vow_config = __cpu_to_le32(TARGET_10_4_VOW_CONFIG);
5492 config.gtk_offload_max_vdev =
5493 __cpu_to_le32(TARGET_10_4_GTK_OFFLOAD_MAX_VDEV);
5494 config.num_msdu_desc = __cpu_to_le32(TARGET_10_4_NUM_MSDU_DESC);
5495 config.max_frag_entries = __cpu_to_le32(TARGET_10_4_11AC_TX_MAX_FRAGS);
5496 config.max_peer_ext_stats =
5497 __cpu_to_le32(TARGET_10_4_MAX_PEER_EXT_STATS);
5498 config.smart_ant_cap = __cpu_to_le32(TARGET_10_4_SMART_ANT_CAP);
5499
5500 config.bk_minfree = __cpu_to_le32(TARGET_10_4_BK_MIN_FREE);
5501 config.be_minfree = __cpu_to_le32(TARGET_10_4_BE_MIN_FREE);
5502 config.vi_minfree = __cpu_to_le32(TARGET_10_4_VI_MIN_FREE);
5503 config.vo_minfree = __cpu_to_le32(TARGET_10_4_VO_MIN_FREE);
5504
5505 config.rx_batchmode = __cpu_to_le32(TARGET_10_4_RX_BATCH_MODE);
5506 config.tt_support =
5507 __cpu_to_le32(TARGET_10_4_THERMAL_THROTTLING_CONFIG);
5508 config.atf_config = __cpu_to_le32(TARGET_10_4_ATF_CONFIG);
5509 config.iphdr_pad_config = __cpu_to_le32(TARGET_10_4_IPHDR_PAD_CONFIG);
5510 config.qwrap_config = __cpu_to_le32(TARGET_10_4_QWRAP_CONFIG);
5511
5512 len = sizeof(*cmd) +
5513 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5514
5515 buf = ath10k_wmi_alloc_skb(ar, len);
5516 if (!buf)
5517 return ERR_PTR(-ENOMEM);
5518
5519 cmd = (struct wmi_init_cmd_10_4 *)buf->data;
5520 memcpy(&cmd->resource_config, &config, sizeof(config));
5521 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
5522
5523 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.4\n");
5524 return buf;
5525}
5526
Michal Kazior0226d602014-12-03 10:11:22 +02005527int ath10k_wmi_start_scan_verify(const struct wmi_start_scan_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005528{
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005529 if (arg->ie_len && !arg->ie)
5530 return -EINVAL;
5531 if (arg->n_channels && !arg->channels)
5532 return -EINVAL;
5533 if (arg->n_ssids && !arg->ssids)
5534 return -EINVAL;
5535 if (arg->n_bssids && !arg->bssids)
5536 return -EINVAL;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005537
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005538 if (arg->ie_len > WLAN_SCAN_PARAMS_MAX_IE_LEN)
5539 return -EINVAL;
5540 if (arg->n_channels > ARRAY_SIZE(arg->channels))
5541 return -EINVAL;
5542 if (arg->n_ssids > WLAN_SCAN_PARAMS_MAX_SSID)
5543 return -EINVAL;
5544 if (arg->n_bssids > WLAN_SCAN_PARAMS_MAX_BSSID)
5545 return -EINVAL;
5546
5547 return 0;
5548}
5549
5550static size_t
5551ath10k_wmi_start_scan_tlvs_len(const struct wmi_start_scan_arg *arg)
5552{
5553 int len = 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005554
5555 if (arg->ie_len) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03005556 len += sizeof(struct wmi_ie_data);
5557 len += roundup(arg->ie_len, 4);
5558 }
5559
5560 if (arg->n_channels) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03005561 len += sizeof(struct wmi_chan_list);
5562 len += sizeof(__le32) * arg->n_channels;
5563 }
5564
5565 if (arg->n_ssids) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03005566 len += sizeof(struct wmi_ssid_list);
5567 len += sizeof(struct wmi_ssid) * arg->n_ssids;
5568 }
5569
5570 if (arg->n_bssids) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03005571 len += sizeof(struct wmi_bssid_list);
5572 len += sizeof(struct wmi_mac_addr) * arg->n_bssids;
5573 }
5574
5575 return len;
5576}
5577
Michal Kazior0226d602014-12-03 10:11:22 +02005578void ath10k_wmi_put_start_scan_common(struct wmi_start_scan_common *cmn,
5579 const struct wmi_start_scan_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005580{
Kalle Valo5e3dd152013-06-12 20:52:10 +03005581 u32 scan_id;
5582 u32 scan_req_id;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005583
5584 scan_id = WMI_HOST_SCAN_REQ_ID_PREFIX;
5585 scan_id |= arg->scan_id;
5586
5587 scan_req_id = WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
5588 scan_req_id |= arg->scan_req_id;
5589
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005590 cmn->scan_id = __cpu_to_le32(scan_id);
5591 cmn->scan_req_id = __cpu_to_le32(scan_req_id);
5592 cmn->vdev_id = __cpu_to_le32(arg->vdev_id);
5593 cmn->scan_priority = __cpu_to_le32(arg->scan_priority);
5594 cmn->notify_scan_events = __cpu_to_le32(arg->notify_scan_events);
5595 cmn->dwell_time_active = __cpu_to_le32(arg->dwell_time_active);
5596 cmn->dwell_time_passive = __cpu_to_le32(arg->dwell_time_passive);
5597 cmn->min_rest_time = __cpu_to_le32(arg->min_rest_time);
5598 cmn->max_rest_time = __cpu_to_le32(arg->max_rest_time);
5599 cmn->repeat_probe_time = __cpu_to_le32(arg->repeat_probe_time);
5600 cmn->probe_spacing_time = __cpu_to_le32(arg->probe_spacing_time);
5601 cmn->idle_time = __cpu_to_le32(arg->idle_time);
5602 cmn->max_scan_time = __cpu_to_le32(arg->max_scan_time);
5603 cmn->probe_delay = __cpu_to_le32(arg->probe_delay);
5604 cmn->scan_ctrl_flags = __cpu_to_le32(arg->scan_ctrl_flags);
5605}
Kalle Valo5e3dd152013-06-12 20:52:10 +03005606
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005607static void
5608ath10k_wmi_put_start_scan_tlvs(struct wmi_start_scan_tlvs *tlvs,
5609 const struct wmi_start_scan_arg *arg)
5610{
5611 struct wmi_ie_data *ie;
5612 struct wmi_chan_list *channels;
5613 struct wmi_ssid_list *ssids;
5614 struct wmi_bssid_list *bssids;
5615 void *ptr = tlvs->tlvs;
5616 int i;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005617
5618 if (arg->n_channels) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005619 channels = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005620 channels->tag = __cpu_to_le32(WMI_CHAN_LIST_TAG);
5621 channels->num_chan = __cpu_to_le32(arg->n_channels);
5622
5623 for (i = 0; i < arg->n_channels; i++)
Michal Kazior24c88f72014-07-25 13:32:17 +02005624 channels->channel_list[i].freq =
5625 __cpu_to_le16(arg->channels[i]);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005626
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005627 ptr += sizeof(*channels);
5628 ptr += sizeof(__le32) * arg->n_channels;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005629 }
5630
5631 if (arg->n_ssids) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005632 ssids = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005633 ssids->tag = __cpu_to_le32(WMI_SSID_LIST_TAG);
5634 ssids->num_ssids = __cpu_to_le32(arg->n_ssids);
5635
5636 for (i = 0; i < arg->n_ssids; i++) {
5637 ssids->ssids[i].ssid_len =
5638 __cpu_to_le32(arg->ssids[i].len);
5639 memcpy(&ssids->ssids[i].ssid,
5640 arg->ssids[i].ssid,
5641 arg->ssids[i].len);
5642 }
5643
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005644 ptr += sizeof(*ssids);
5645 ptr += sizeof(struct wmi_ssid) * arg->n_ssids;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005646 }
5647
5648 if (arg->n_bssids) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005649 bssids = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005650 bssids->tag = __cpu_to_le32(WMI_BSSID_LIST_TAG);
5651 bssids->num_bssid = __cpu_to_le32(arg->n_bssids);
5652
5653 for (i = 0; i < arg->n_bssids; i++)
5654 memcpy(&bssids->bssid_list[i],
5655 arg->bssids[i].bssid,
5656 ETH_ALEN);
5657
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005658 ptr += sizeof(*bssids);
5659 ptr += sizeof(struct wmi_mac_addr) * arg->n_bssids;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005660 }
5661
5662 if (arg->ie_len) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005663 ie = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005664 ie->tag = __cpu_to_le32(WMI_IE_TAG);
5665 ie->ie_len = __cpu_to_le32(arg->ie_len);
5666 memcpy(ie->ie_data, arg->ie, arg->ie_len);
5667
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005668 ptr += sizeof(*ie);
5669 ptr += roundup(arg->ie_len, 4);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005670 }
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005671}
Kalle Valo5e3dd152013-06-12 20:52:10 +03005672
Michal Kaziord7579d12014-12-03 10:10:54 +02005673static struct sk_buff *
5674ath10k_wmi_op_gen_start_scan(struct ath10k *ar,
5675 const struct wmi_start_scan_arg *arg)
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005676{
Michal Kaziord7579d12014-12-03 10:10:54 +02005677 struct wmi_start_scan_cmd *cmd;
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005678 struct sk_buff *skb;
5679 size_t len;
5680 int ret;
5681
5682 ret = ath10k_wmi_start_scan_verify(arg);
5683 if (ret)
Michal Kaziord7579d12014-12-03 10:10:54 +02005684 return ERR_PTR(ret);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005685
Michal Kaziord7579d12014-12-03 10:10:54 +02005686 len = sizeof(*cmd) + ath10k_wmi_start_scan_tlvs_len(arg);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005687 skb = ath10k_wmi_alloc_skb(ar, len);
5688 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005689 return ERR_PTR(-ENOMEM);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005690
Michal Kaziord7579d12014-12-03 10:10:54 +02005691 cmd = (struct wmi_start_scan_cmd *)skb->data;
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005692
Michal Kaziord7579d12014-12-03 10:10:54 +02005693 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
5694 ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005695
Michal Kaziord7579d12014-12-03 10:10:54 +02005696 cmd->burst_duration_ms = __cpu_to_le32(0);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005697
Michal Kazior7aa7a722014-08-25 12:09:38 +02005698 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi start scan\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02005699 return skb;
5700}
5701
5702static struct sk_buff *
5703ath10k_wmi_10x_op_gen_start_scan(struct ath10k *ar,
5704 const struct wmi_start_scan_arg *arg)
5705{
5706 struct wmi_10x_start_scan_cmd *cmd;
5707 struct sk_buff *skb;
5708 size_t len;
5709 int ret;
5710
5711 ret = ath10k_wmi_start_scan_verify(arg);
5712 if (ret)
5713 return ERR_PTR(ret);
5714
5715 len = sizeof(*cmd) + ath10k_wmi_start_scan_tlvs_len(arg);
5716 skb = ath10k_wmi_alloc_skb(ar, len);
5717 if (!skb)
5718 return ERR_PTR(-ENOMEM);
5719
5720 cmd = (struct wmi_10x_start_scan_cmd *)skb->data;
5721
5722 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
5723 ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
5724
5725 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi 10x start scan\n");
5726 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005727}
5728
5729void ath10k_wmi_start_scan_init(struct ath10k *ar,
5730 struct wmi_start_scan_arg *arg)
5731{
5732 /* setup commonly used values */
5733 arg->scan_req_id = 1;
5734 arg->scan_priority = WMI_SCAN_PRIORITY_LOW;
5735 arg->dwell_time_active = 50;
5736 arg->dwell_time_passive = 150;
5737 arg->min_rest_time = 50;
5738 arg->max_rest_time = 500;
5739 arg->repeat_probe_time = 0;
5740 arg->probe_spacing_time = 0;
5741 arg->idle_time = 0;
Bartosz Markowskic3228922013-10-02 08:48:52 +02005742 arg->max_scan_time = 20000;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005743 arg->probe_delay = 5;
5744 arg->notify_scan_events = WMI_SCAN_EVENT_STARTED
5745 | WMI_SCAN_EVENT_COMPLETED
5746 | WMI_SCAN_EVENT_BSS_CHANNEL
5747 | WMI_SCAN_EVENT_FOREIGN_CHANNEL
5748 | WMI_SCAN_EVENT_DEQUEUED;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005749 arg->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
5750 arg->n_bssids = 1;
5751 arg->bssids[0].bssid = "\xFF\xFF\xFF\xFF\xFF\xFF";
5752}
5753
Michal Kaziord7579d12014-12-03 10:10:54 +02005754static struct sk_buff *
5755ath10k_wmi_op_gen_stop_scan(struct ath10k *ar,
5756 const struct wmi_stop_scan_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005757{
5758 struct wmi_stop_scan_cmd *cmd;
5759 struct sk_buff *skb;
5760 u32 scan_id;
5761 u32 req_id;
5762
5763 if (arg->req_id > 0xFFF)
Michal Kaziord7579d12014-12-03 10:10:54 +02005764 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005765 if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF)
Michal Kaziord7579d12014-12-03 10:10:54 +02005766 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005767
Michal Kazior7aa7a722014-08-25 12:09:38 +02005768 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005769 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005770 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005771
5772 scan_id = arg->u.scan_id;
5773 scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX;
5774
5775 req_id = arg->req_id;
5776 req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
5777
5778 cmd = (struct wmi_stop_scan_cmd *)skb->data;
5779 cmd->req_type = __cpu_to_le32(arg->req_type);
5780 cmd->vdev_id = __cpu_to_le32(arg->u.vdev_id);
5781 cmd->scan_id = __cpu_to_le32(scan_id);
5782 cmd->scan_req_id = __cpu_to_le32(req_id);
5783
Michal Kazior7aa7a722014-08-25 12:09:38 +02005784 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005785 "wmi stop scan reqid %d req_type %d vdev/scan_id %d\n",
5786 arg->req_id, arg->req_type, arg->u.scan_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02005787 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005788}
5789
Michal Kaziord7579d12014-12-03 10:10:54 +02005790static struct sk_buff *
5791ath10k_wmi_op_gen_vdev_create(struct ath10k *ar, u32 vdev_id,
5792 enum wmi_vdev_type type,
5793 enum wmi_vdev_subtype subtype,
5794 const u8 macaddr[ETH_ALEN])
Kalle Valo5e3dd152013-06-12 20:52:10 +03005795{
5796 struct wmi_vdev_create_cmd *cmd;
5797 struct sk_buff *skb;
5798
Michal Kazior7aa7a722014-08-25 12:09:38 +02005799 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005800 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005801 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005802
5803 cmd = (struct wmi_vdev_create_cmd *)skb->data;
5804 cmd->vdev_id = __cpu_to_le32(vdev_id);
5805 cmd->vdev_type = __cpu_to_le32(type);
5806 cmd->vdev_subtype = __cpu_to_le32(subtype);
Kalle Valob25f32c2014-09-14 12:50:49 +03005807 ether_addr_copy(cmd->vdev_macaddr.addr, macaddr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005808
Michal Kazior7aa7a722014-08-25 12:09:38 +02005809 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005810 "WMI vdev create: id %d type %d subtype %d macaddr %pM\n",
5811 vdev_id, type, subtype, macaddr);
Michal Kaziord7579d12014-12-03 10:10:54 +02005812 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005813}
5814
Michal Kaziord7579d12014-12-03 10:10:54 +02005815static struct sk_buff *
5816ath10k_wmi_op_gen_vdev_delete(struct ath10k *ar, u32 vdev_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005817{
5818 struct wmi_vdev_delete_cmd *cmd;
5819 struct sk_buff *skb;
5820
Michal Kazior7aa7a722014-08-25 12:09:38 +02005821 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005822 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005823 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005824
5825 cmd = (struct wmi_vdev_delete_cmd *)skb->data;
5826 cmd->vdev_id = __cpu_to_le32(vdev_id);
5827
Michal Kazior7aa7a722014-08-25 12:09:38 +02005828 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005829 "WMI vdev delete id %d\n", vdev_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02005830 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005831}
5832
Michal Kaziord7579d12014-12-03 10:10:54 +02005833static struct sk_buff *
5834ath10k_wmi_op_gen_vdev_start(struct ath10k *ar,
5835 const struct wmi_vdev_start_request_arg *arg,
5836 bool restart)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005837{
5838 struct wmi_vdev_start_request_cmd *cmd;
5839 struct sk_buff *skb;
5840 const char *cmdname;
5841 u32 flags = 0;
5842
Kalle Valo5e3dd152013-06-12 20:52:10 +03005843 if (WARN_ON(arg->hidden_ssid && !arg->ssid))
Michal Kaziord7579d12014-12-03 10:10:54 +02005844 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005845 if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid)))
Michal Kaziord7579d12014-12-03 10:10:54 +02005846 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005847
Michal Kaziord7579d12014-12-03 10:10:54 +02005848 if (restart)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005849 cmdname = "restart";
5850 else
Michal Kaziord7579d12014-12-03 10:10:54 +02005851 cmdname = "start";
Kalle Valo5e3dd152013-06-12 20:52:10 +03005852
Michal Kazior7aa7a722014-08-25 12:09:38 +02005853 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005854 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005855 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005856
5857 if (arg->hidden_ssid)
5858 flags |= WMI_VDEV_START_HIDDEN_SSID;
5859 if (arg->pmf_enabled)
5860 flags |= WMI_VDEV_START_PMF_ENABLED;
5861
5862 cmd = (struct wmi_vdev_start_request_cmd *)skb->data;
5863 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
5864 cmd->disable_hw_ack = __cpu_to_le32(arg->disable_hw_ack);
5865 cmd->beacon_interval = __cpu_to_le32(arg->bcn_intval);
5866 cmd->dtim_period = __cpu_to_le32(arg->dtim_period);
5867 cmd->flags = __cpu_to_le32(flags);
5868 cmd->bcn_tx_rate = __cpu_to_le32(arg->bcn_tx_rate);
5869 cmd->bcn_tx_power = __cpu_to_le32(arg->bcn_tx_power);
5870
5871 if (arg->ssid) {
5872 cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len);
5873 memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len);
5874 }
5875
Michal Kazior2d667212014-09-18 15:21:21 +02005876 ath10k_wmi_put_wmi_channel(&cmd->chan, &arg->channel);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005877
Michal Kazior7aa7a722014-08-25 12:09:38 +02005878 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo8cc7f262014-09-14 12:50:39 +03005879 "wmi vdev %s id 0x%x flags: 0x%0X, freq %d, mode %d, ch_flags: 0x%0X, max_power: %d\n",
5880 cmdname, arg->vdev_id,
Marek Puzyniake8a50f82013-11-20 09:59:47 +02005881 flags, arg->channel.freq, arg->channel.mode,
5882 cmd->chan.flags, arg->channel.max_power);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005883
Michal Kaziord7579d12014-12-03 10:10:54 +02005884 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005885}
5886
Michal Kaziord7579d12014-12-03 10:10:54 +02005887static struct sk_buff *
5888ath10k_wmi_op_gen_vdev_stop(struct ath10k *ar, u32 vdev_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005889{
5890 struct wmi_vdev_stop_cmd *cmd;
5891 struct sk_buff *skb;
5892
Michal Kazior7aa7a722014-08-25 12:09:38 +02005893 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005894 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005895 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005896
5897 cmd = (struct wmi_vdev_stop_cmd *)skb->data;
5898 cmd->vdev_id = __cpu_to_le32(vdev_id);
5899
Michal Kazior7aa7a722014-08-25 12:09:38 +02005900 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi vdev stop id 0x%x\n", vdev_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02005901 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005902}
5903
Michal Kaziord7579d12014-12-03 10:10:54 +02005904static struct sk_buff *
5905ath10k_wmi_op_gen_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid,
5906 const u8 *bssid)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005907{
5908 struct wmi_vdev_up_cmd *cmd;
5909 struct sk_buff *skb;
5910
Michal Kazior7aa7a722014-08-25 12:09:38 +02005911 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005912 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005913 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005914
5915 cmd = (struct wmi_vdev_up_cmd *)skb->data;
5916 cmd->vdev_id = __cpu_to_le32(vdev_id);
5917 cmd->vdev_assoc_id = __cpu_to_le32(aid);
Kalle Valob25f32c2014-09-14 12:50:49 +03005918 ether_addr_copy(cmd->vdev_bssid.addr, bssid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005919
Michal Kazior7aa7a722014-08-25 12:09:38 +02005920 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005921 "wmi mgmt vdev up id 0x%x assoc id %d bssid %pM\n",
5922 vdev_id, aid, bssid);
Michal Kaziord7579d12014-12-03 10:10:54 +02005923 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005924}
5925
Michal Kaziord7579d12014-12-03 10:10:54 +02005926static struct sk_buff *
5927ath10k_wmi_op_gen_vdev_down(struct ath10k *ar, u32 vdev_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005928{
5929 struct wmi_vdev_down_cmd *cmd;
5930 struct sk_buff *skb;
5931
Michal Kazior7aa7a722014-08-25 12:09:38 +02005932 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005933 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005934 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005935
5936 cmd = (struct wmi_vdev_down_cmd *)skb->data;
5937 cmd->vdev_id = __cpu_to_le32(vdev_id);
5938
Michal Kazior7aa7a722014-08-25 12:09:38 +02005939 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005940 "wmi mgmt vdev down id 0x%x\n", vdev_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02005941 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005942}
5943
Michal Kaziord7579d12014-12-03 10:10:54 +02005944static struct sk_buff *
5945ath10k_wmi_op_gen_vdev_set_param(struct ath10k *ar, u32 vdev_id,
5946 u32 param_id, u32 param_value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005947{
5948 struct wmi_vdev_set_param_cmd *cmd;
5949 struct sk_buff *skb;
5950
Bartosz Markowski6d1506e2013-09-26 17:47:15 +02005951 if (param_id == WMI_VDEV_PARAM_UNSUPPORTED) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02005952 ath10k_dbg(ar, ATH10K_DBG_WMI,
Bartosz Markowski6d1506e2013-09-26 17:47:15 +02005953 "vdev param %d not supported by firmware\n",
5954 param_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02005955 return ERR_PTR(-EOPNOTSUPP);
Bartosz Markowski6d1506e2013-09-26 17:47:15 +02005956 }
5957
Michal Kazior7aa7a722014-08-25 12:09:38 +02005958 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005959 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005960 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005961
5962 cmd = (struct wmi_vdev_set_param_cmd *)skb->data;
5963 cmd->vdev_id = __cpu_to_le32(vdev_id);
5964 cmd->param_id = __cpu_to_le32(param_id);
5965 cmd->param_value = __cpu_to_le32(param_value);
5966
Michal Kazior7aa7a722014-08-25 12:09:38 +02005967 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005968 "wmi vdev id 0x%x set param %d value %d\n",
5969 vdev_id, param_id, param_value);
Michal Kaziord7579d12014-12-03 10:10:54 +02005970 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005971}
5972
Michal Kaziord7579d12014-12-03 10:10:54 +02005973static struct sk_buff *
5974ath10k_wmi_op_gen_vdev_install_key(struct ath10k *ar,
5975 const struct wmi_vdev_install_key_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005976{
5977 struct wmi_vdev_install_key_cmd *cmd;
5978 struct sk_buff *skb;
5979
5980 if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL)
Michal Kaziord7579d12014-12-03 10:10:54 +02005981 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005982 if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL)
Michal Kaziord7579d12014-12-03 10:10:54 +02005983 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005984
Michal Kazior7aa7a722014-08-25 12:09:38 +02005985 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd) + arg->key_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005986 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005987 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005988
5989 cmd = (struct wmi_vdev_install_key_cmd *)skb->data;
5990 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
5991 cmd->key_idx = __cpu_to_le32(arg->key_idx);
5992 cmd->key_flags = __cpu_to_le32(arg->key_flags);
5993 cmd->key_cipher = __cpu_to_le32(arg->key_cipher);
5994 cmd->key_len = __cpu_to_le32(arg->key_len);
5995 cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len);
5996 cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len);
5997
5998 if (arg->macaddr)
Kalle Valob25f32c2014-09-14 12:50:49 +03005999 ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006000 if (arg->key_data)
6001 memcpy(cmd->key_data, arg->key_data, arg->key_len);
6002
Michal Kazior7aa7a722014-08-25 12:09:38 +02006003 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kaziore0c508a2013-07-05 16:15:17 +03006004 "wmi vdev install key idx %d cipher %d len %d\n",
6005 arg->key_idx, arg->key_cipher, arg->key_len);
Michal Kaziord7579d12014-12-03 10:10:54 +02006006 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006007}
6008
Michal Kaziord7579d12014-12-03 10:10:54 +02006009static struct sk_buff *
6010ath10k_wmi_op_gen_vdev_spectral_conf(struct ath10k *ar,
6011 const struct wmi_vdev_spectral_conf_arg *arg)
Simon Wunderlich855aed12014-08-02 09:12:54 +03006012{
6013 struct wmi_vdev_spectral_conf_cmd *cmd;
6014 struct sk_buff *skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03006015
Michal Kazior7aa7a722014-08-25 12:09:38 +02006016 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Simon Wunderlich855aed12014-08-02 09:12:54 +03006017 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006018 return ERR_PTR(-ENOMEM);
Simon Wunderlich855aed12014-08-02 09:12:54 +03006019
6020 cmd = (struct wmi_vdev_spectral_conf_cmd *)skb->data;
6021 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
6022 cmd->scan_count = __cpu_to_le32(arg->scan_count);
6023 cmd->scan_period = __cpu_to_le32(arg->scan_period);
6024 cmd->scan_priority = __cpu_to_le32(arg->scan_priority);
6025 cmd->scan_fft_size = __cpu_to_le32(arg->scan_fft_size);
6026 cmd->scan_gc_ena = __cpu_to_le32(arg->scan_gc_ena);
6027 cmd->scan_restart_ena = __cpu_to_le32(arg->scan_restart_ena);
6028 cmd->scan_noise_floor_ref = __cpu_to_le32(arg->scan_noise_floor_ref);
6029 cmd->scan_init_delay = __cpu_to_le32(arg->scan_init_delay);
6030 cmd->scan_nb_tone_thr = __cpu_to_le32(arg->scan_nb_tone_thr);
6031 cmd->scan_str_bin_thr = __cpu_to_le32(arg->scan_str_bin_thr);
6032 cmd->scan_wb_rpt_mode = __cpu_to_le32(arg->scan_wb_rpt_mode);
6033 cmd->scan_rssi_rpt_mode = __cpu_to_le32(arg->scan_rssi_rpt_mode);
6034 cmd->scan_rssi_thr = __cpu_to_le32(arg->scan_rssi_thr);
6035 cmd->scan_pwr_format = __cpu_to_le32(arg->scan_pwr_format);
6036 cmd->scan_rpt_mode = __cpu_to_le32(arg->scan_rpt_mode);
6037 cmd->scan_bin_scale = __cpu_to_le32(arg->scan_bin_scale);
6038 cmd->scan_dbm_adj = __cpu_to_le32(arg->scan_dbm_adj);
6039 cmd->scan_chn_mask = __cpu_to_le32(arg->scan_chn_mask);
6040
Michal Kaziord7579d12014-12-03 10:10:54 +02006041 return skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03006042}
6043
Michal Kaziord7579d12014-12-03 10:10:54 +02006044static struct sk_buff *
6045ath10k_wmi_op_gen_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id,
6046 u32 trigger, u32 enable)
Simon Wunderlich855aed12014-08-02 09:12:54 +03006047{
6048 struct wmi_vdev_spectral_enable_cmd *cmd;
6049 struct sk_buff *skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03006050
Michal Kazior7aa7a722014-08-25 12:09:38 +02006051 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Simon Wunderlich855aed12014-08-02 09:12:54 +03006052 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006053 return ERR_PTR(-ENOMEM);
Simon Wunderlich855aed12014-08-02 09:12:54 +03006054
6055 cmd = (struct wmi_vdev_spectral_enable_cmd *)skb->data;
6056 cmd->vdev_id = __cpu_to_le32(vdev_id);
6057 cmd->trigger_cmd = __cpu_to_le32(trigger);
6058 cmd->enable_cmd = __cpu_to_le32(enable);
6059
Michal Kaziord7579d12014-12-03 10:10:54 +02006060 return skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03006061}
6062
Michal Kaziord7579d12014-12-03 10:10:54 +02006063static struct sk_buff *
6064ath10k_wmi_op_gen_peer_create(struct ath10k *ar, u32 vdev_id,
Marek Puzyniak7390ed32015-03-30 09:51:52 +03006065 const u8 peer_addr[ETH_ALEN],
6066 enum wmi_peer_type peer_type)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006067{
6068 struct wmi_peer_create_cmd *cmd;
6069 struct sk_buff *skb;
6070
Michal Kazior7aa7a722014-08-25 12:09:38 +02006071 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006072 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006073 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006074
6075 cmd = (struct wmi_peer_create_cmd *)skb->data;
6076 cmd->vdev_id = __cpu_to_le32(vdev_id);
Kalle Valob25f32c2014-09-14 12:50:49 +03006077 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006078
Michal Kazior7aa7a722014-08-25 12:09:38 +02006079 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006080 "wmi peer create vdev_id %d peer_addr %pM\n",
6081 vdev_id, peer_addr);
Michal Kaziord7579d12014-12-03 10:10:54 +02006082 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006083}
6084
Michal Kaziord7579d12014-12-03 10:10:54 +02006085static struct sk_buff *
6086ath10k_wmi_op_gen_peer_delete(struct ath10k *ar, u32 vdev_id,
6087 const u8 peer_addr[ETH_ALEN])
Kalle Valo5e3dd152013-06-12 20:52:10 +03006088{
6089 struct wmi_peer_delete_cmd *cmd;
6090 struct sk_buff *skb;
6091
Michal Kazior7aa7a722014-08-25 12:09:38 +02006092 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006093 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006094 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006095
6096 cmd = (struct wmi_peer_delete_cmd *)skb->data;
6097 cmd->vdev_id = __cpu_to_le32(vdev_id);
Kalle Valob25f32c2014-09-14 12:50:49 +03006098 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006099
Michal Kazior7aa7a722014-08-25 12:09:38 +02006100 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006101 "wmi peer delete vdev_id %d peer_addr %pM\n",
6102 vdev_id, peer_addr);
Michal Kaziord7579d12014-12-03 10:10:54 +02006103 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006104}
6105
Michal Kaziord7579d12014-12-03 10:10:54 +02006106static struct sk_buff *
6107ath10k_wmi_op_gen_peer_flush(struct ath10k *ar, u32 vdev_id,
6108 const u8 peer_addr[ETH_ALEN], u32 tid_bitmap)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006109{
6110 struct wmi_peer_flush_tids_cmd *cmd;
6111 struct sk_buff *skb;
6112
Michal Kazior7aa7a722014-08-25 12:09:38 +02006113 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006114 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006115 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006116
6117 cmd = (struct wmi_peer_flush_tids_cmd *)skb->data;
6118 cmd->vdev_id = __cpu_to_le32(vdev_id);
6119 cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap);
Kalle Valob25f32c2014-09-14 12:50:49 +03006120 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006121
Michal Kazior7aa7a722014-08-25 12:09:38 +02006122 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006123 "wmi peer flush vdev_id %d peer_addr %pM tids %08x\n",
6124 vdev_id, peer_addr, tid_bitmap);
Michal Kaziord7579d12014-12-03 10:10:54 +02006125 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006126}
6127
Michal Kaziord7579d12014-12-03 10:10:54 +02006128static struct sk_buff *
6129ath10k_wmi_op_gen_peer_set_param(struct ath10k *ar, u32 vdev_id,
6130 const u8 *peer_addr,
6131 enum wmi_peer_param param_id,
6132 u32 param_value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006133{
6134 struct wmi_peer_set_param_cmd *cmd;
6135 struct sk_buff *skb;
6136
Michal Kazior7aa7a722014-08-25 12:09:38 +02006137 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006138 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006139 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006140
6141 cmd = (struct wmi_peer_set_param_cmd *)skb->data;
6142 cmd->vdev_id = __cpu_to_le32(vdev_id);
6143 cmd->param_id = __cpu_to_le32(param_id);
6144 cmd->param_value = __cpu_to_le32(param_value);
Kalle Valob25f32c2014-09-14 12:50:49 +03006145 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006146
Michal Kazior7aa7a722014-08-25 12:09:38 +02006147 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006148 "wmi vdev %d peer 0x%pM set param %d value %d\n",
6149 vdev_id, peer_addr, param_id, param_value);
Michal Kaziord7579d12014-12-03 10:10:54 +02006150 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006151}
6152
Michal Kaziord7579d12014-12-03 10:10:54 +02006153static struct sk_buff *
6154ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
6155 enum wmi_sta_ps_mode psmode)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006156{
6157 struct wmi_sta_powersave_mode_cmd *cmd;
6158 struct sk_buff *skb;
6159
Michal Kazior7aa7a722014-08-25 12:09:38 +02006160 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006161 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006162 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006163
6164 cmd = (struct wmi_sta_powersave_mode_cmd *)skb->data;
6165 cmd->vdev_id = __cpu_to_le32(vdev_id);
6166 cmd->sta_ps_mode = __cpu_to_le32(psmode);
6167
Michal Kazior7aa7a722014-08-25 12:09:38 +02006168 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006169 "wmi set powersave id 0x%x mode %d\n",
6170 vdev_id, psmode);
Michal Kaziord7579d12014-12-03 10:10:54 +02006171 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006172}
6173
Michal Kaziord7579d12014-12-03 10:10:54 +02006174static struct sk_buff *
6175ath10k_wmi_op_gen_set_sta_ps(struct ath10k *ar, u32 vdev_id,
6176 enum wmi_sta_powersave_param param_id,
6177 u32 value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006178{
6179 struct wmi_sta_powersave_param_cmd *cmd;
6180 struct sk_buff *skb;
6181
Michal Kazior7aa7a722014-08-25 12:09:38 +02006182 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006183 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006184 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006185
6186 cmd = (struct wmi_sta_powersave_param_cmd *)skb->data;
6187 cmd->vdev_id = __cpu_to_le32(vdev_id);
6188 cmd->param_id = __cpu_to_le32(param_id);
6189 cmd->param_value = __cpu_to_le32(value);
6190
Michal Kazior7aa7a722014-08-25 12:09:38 +02006191 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006192 "wmi sta ps param vdev_id 0x%x param %d value %d\n",
6193 vdev_id, param_id, value);
Michal Kaziord7579d12014-12-03 10:10:54 +02006194 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006195}
6196
Michal Kaziord7579d12014-12-03 10:10:54 +02006197static struct sk_buff *
6198ath10k_wmi_op_gen_set_ap_ps(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6199 enum wmi_ap_ps_peer_param param_id, u32 value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006200{
6201 struct wmi_ap_ps_peer_cmd *cmd;
6202 struct sk_buff *skb;
6203
6204 if (!mac)
Michal Kaziord7579d12014-12-03 10:10:54 +02006205 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006206
Michal Kazior7aa7a722014-08-25 12:09:38 +02006207 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006208 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006209 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006210
6211 cmd = (struct wmi_ap_ps_peer_cmd *)skb->data;
6212 cmd->vdev_id = __cpu_to_le32(vdev_id);
6213 cmd->param_id = __cpu_to_le32(param_id);
6214 cmd->param_value = __cpu_to_le32(value);
Kalle Valob25f32c2014-09-14 12:50:49 +03006215 ether_addr_copy(cmd->peer_macaddr.addr, mac);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006216
Michal Kazior7aa7a722014-08-25 12:09:38 +02006217 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006218 "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr %pM\n",
6219 vdev_id, param_id, value, mac);
Michal Kaziord7579d12014-12-03 10:10:54 +02006220 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006221}
6222
Michal Kaziord7579d12014-12-03 10:10:54 +02006223static struct sk_buff *
6224ath10k_wmi_op_gen_scan_chan_list(struct ath10k *ar,
6225 const struct wmi_scan_chan_list_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006226{
6227 struct wmi_scan_chan_list_cmd *cmd;
6228 struct sk_buff *skb;
6229 struct wmi_channel_arg *ch;
6230 struct wmi_channel *ci;
6231 int len;
6232 int i;
6233
6234 len = sizeof(*cmd) + arg->n_channels * sizeof(struct wmi_channel);
6235
Michal Kazior7aa7a722014-08-25 12:09:38 +02006236 skb = ath10k_wmi_alloc_skb(ar, len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006237 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006238 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006239
6240 cmd = (struct wmi_scan_chan_list_cmd *)skb->data;
6241 cmd->num_scan_chans = __cpu_to_le32(arg->n_channels);
6242
6243 for (i = 0; i < arg->n_channels; i++) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03006244 ch = &arg->channels[i];
6245 ci = &cmd->chan_info[i];
6246
Michal Kazior2d667212014-09-18 15:21:21 +02006247 ath10k_wmi_put_wmi_channel(ci, ch);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006248 }
6249
Michal Kaziord7579d12014-12-03 10:10:54 +02006250 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006251}
6252
Michal Kazior24c88f72014-07-25 13:32:17 +02006253static void
6254ath10k_wmi_peer_assoc_fill(struct ath10k *ar, void *buf,
6255 const struct wmi_peer_assoc_complete_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006256{
Michal Kazior24c88f72014-07-25 13:32:17 +02006257 struct wmi_common_peer_assoc_complete_cmd *cmd = buf;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006258
Kalle Valo5e3dd152013-06-12 20:52:10 +03006259 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
6260 cmd->peer_new_assoc = __cpu_to_le32(arg->peer_reassoc ? 0 : 1);
6261 cmd->peer_associd = __cpu_to_le32(arg->peer_aid);
6262 cmd->peer_flags = __cpu_to_le32(arg->peer_flags);
6263 cmd->peer_caps = __cpu_to_le32(arg->peer_caps);
6264 cmd->peer_listen_intval = __cpu_to_le32(arg->peer_listen_intval);
6265 cmd->peer_ht_caps = __cpu_to_le32(arg->peer_ht_caps);
6266 cmd->peer_max_mpdu = __cpu_to_le32(arg->peer_max_mpdu);
6267 cmd->peer_mpdu_density = __cpu_to_le32(arg->peer_mpdu_density);
6268 cmd->peer_rate_caps = __cpu_to_le32(arg->peer_rate_caps);
6269 cmd->peer_nss = __cpu_to_le32(arg->peer_num_spatial_streams);
6270 cmd->peer_vht_caps = __cpu_to_le32(arg->peer_vht_caps);
6271 cmd->peer_phymode = __cpu_to_le32(arg->peer_phymode);
6272
Kalle Valob25f32c2014-09-14 12:50:49 +03006273 ether_addr_copy(cmd->peer_macaddr.addr, arg->addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006274
6275 cmd->peer_legacy_rates.num_rates =
6276 __cpu_to_le32(arg->peer_legacy_rates.num_rates);
6277 memcpy(cmd->peer_legacy_rates.rates, arg->peer_legacy_rates.rates,
6278 arg->peer_legacy_rates.num_rates);
6279
6280 cmd->peer_ht_rates.num_rates =
6281 __cpu_to_le32(arg->peer_ht_rates.num_rates);
6282 memcpy(cmd->peer_ht_rates.rates, arg->peer_ht_rates.rates,
6283 arg->peer_ht_rates.num_rates);
6284
6285 cmd->peer_vht_rates.rx_max_rate =
6286 __cpu_to_le32(arg->peer_vht_rates.rx_max_rate);
6287 cmd->peer_vht_rates.rx_mcs_set =
6288 __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set);
6289 cmd->peer_vht_rates.tx_max_rate =
6290 __cpu_to_le32(arg->peer_vht_rates.tx_max_rate);
6291 cmd->peer_vht_rates.tx_mcs_set =
6292 __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set);
Michal Kazior24c88f72014-07-25 13:32:17 +02006293}
6294
6295static void
6296ath10k_wmi_peer_assoc_fill_main(struct ath10k *ar, void *buf,
6297 const struct wmi_peer_assoc_complete_arg *arg)
6298{
6299 struct wmi_main_peer_assoc_complete_cmd *cmd = buf;
6300
6301 ath10k_wmi_peer_assoc_fill(ar, buf, arg);
6302 memset(cmd->peer_ht_info, 0, sizeof(cmd->peer_ht_info));
6303}
6304
6305static void
6306ath10k_wmi_peer_assoc_fill_10_1(struct ath10k *ar, void *buf,
6307 const struct wmi_peer_assoc_complete_arg *arg)
6308{
6309 ath10k_wmi_peer_assoc_fill(ar, buf, arg);
6310}
6311
6312static void
6313ath10k_wmi_peer_assoc_fill_10_2(struct ath10k *ar, void *buf,
6314 const struct wmi_peer_assoc_complete_arg *arg)
6315{
6316 struct wmi_10_2_peer_assoc_complete_cmd *cmd = buf;
6317 int max_mcs, max_nss;
6318 u32 info0;
6319
6320 /* TODO: Is using max values okay with firmware? */
6321 max_mcs = 0xf;
6322 max_nss = 0xf;
6323
6324 info0 = SM(max_mcs, WMI_PEER_ASSOC_INFO0_MAX_MCS_IDX) |
6325 SM(max_nss, WMI_PEER_ASSOC_INFO0_MAX_NSS);
6326
6327 ath10k_wmi_peer_assoc_fill(ar, buf, arg);
6328 cmd->info0 = __cpu_to_le32(info0);
6329}
6330
Michal Kaziord7579d12014-12-03 10:10:54 +02006331static int
6332ath10k_wmi_peer_assoc_check_arg(const struct wmi_peer_assoc_complete_arg *arg)
Michal Kazior24c88f72014-07-25 13:32:17 +02006333{
Michal Kazior24c88f72014-07-25 13:32:17 +02006334 if (arg->peer_mpdu_density > 16)
6335 return -EINVAL;
6336 if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES)
6337 return -EINVAL;
6338 if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES)
6339 return -EINVAL;
6340
Michal Kaziord7579d12014-12-03 10:10:54 +02006341 return 0;
6342}
6343
6344static struct sk_buff *
6345ath10k_wmi_op_gen_peer_assoc(struct ath10k *ar,
6346 const struct wmi_peer_assoc_complete_arg *arg)
6347{
6348 size_t len = sizeof(struct wmi_main_peer_assoc_complete_cmd);
6349 struct sk_buff *skb;
6350 int ret;
6351
6352 ret = ath10k_wmi_peer_assoc_check_arg(arg);
6353 if (ret)
6354 return ERR_PTR(ret);
Michal Kazior24c88f72014-07-25 13:32:17 +02006355
Michal Kazior7aa7a722014-08-25 12:09:38 +02006356 skb = ath10k_wmi_alloc_skb(ar, len);
Michal Kazior24c88f72014-07-25 13:32:17 +02006357 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006358 return ERR_PTR(-ENOMEM);
Michal Kazior24c88f72014-07-25 13:32:17 +02006359
Michal Kaziord7579d12014-12-03 10:10:54 +02006360 ath10k_wmi_peer_assoc_fill_main(ar, skb->data, arg);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006361
Michal Kazior7aa7a722014-08-25 12:09:38 +02006362 ath10k_dbg(ar, ATH10K_DBG_WMI,
Chun-Yeow Yeoh44d6fa92014-03-07 10:19:30 +02006363 "wmi peer assoc vdev %d addr %pM (%s)\n",
6364 arg->vdev_id, arg->addr,
6365 arg->peer_reassoc ? "reassociate" : "new");
Michal Kaziord7579d12014-12-03 10:10:54 +02006366 return skb;
6367}
6368
6369static struct sk_buff *
6370ath10k_wmi_10_1_op_gen_peer_assoc(struct ath10k *ar,
6371 const struct wmi_peer_assoc_complete_arg *arg)
6372{
6373 size_t len = sizeof(struct wmi_10_1_peer_assoc_complete_cmd);
6374 struct sk_buff *skb;
6375 int ret;
6376
6377 ret = ath10k_wmi_peer_assoc_check_arg(arg);
6378 if (ret)
6379 return ERR_PTR(ret);
6380
6381 skb = ath10k_wmi_alloc_skb(ar, len);
6382 if (!skb)
6383 return ERR_PTR(-ENOMEM);
6384
6385 ath10k_wmi_peer_assoc_fill_10_1(ar, skb->data, arg);
6386
6387 ath10k_dbg(ar, ATH10K_DBG_WMI,
6388 "wmi peer assoc vdev %d addr %pM (%s)\n",
6389 arg->vdev_id, arg->addr,
6390 arg->peer_reassoc ? "reassociate" : "new");
6391 return skb;
6392}
6393
6394static struct sk_buff *
6395ath10k_wmi_10_2_op_gen_peer_assoc(struct ath10k *ar,
6396 const struct wmi_peer_assoc_complete_arg *arg)
6397{
6398 size_t len = sizeof(struct wmi_10_2_peer_assoc_complete_cmd);
6399 struct sk_buff *skb;
6400 int ret;
6401
6402 ret = ath10k_wmi_peer_assoc_check_arg(arg);
6403 if (ret)
6404 return ERR_PTR(ret);
6405
6406 skb = ath10k_wmi_alloc_skb(ar, len);
6407 if (!skb)
6408 return ERR_PTR(-ENOMEM);
6409
6410 ath10k_wmi_peer_assoc_fill_10_2(ar, skb->data, arg);
6411
6412 ath10k_dbg(ar, ATH10K_DBG_WMI,
6413 "wmi peer assoc vdev %d addr %pM (%s)\n",
6414 arg->vdev_id, arg->addr,
6415 arg->peer_reassoc ? "reassociate" : "new");
6416 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006417}
6418
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02006419static struct sk_buff *
6420ath10k_wmi_10_2_op_gen_pdev_get_temperature(struct ath10k *ar)
6421{
6422 struct sk_buff *skb;
6423
6424 skb = ath10k_wmi_alloc_skb(ar, 0);
6425 if (!skb)
6426 return ERR_PTR(-ENOMEM);
6427
6428 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev get temperature\n");
6429 return skb;
6430}
6431
Michal Kazior748afc42014-01-23 12:48:21 +01006432/* This function assumes the beacon is already DMA mapped */
Michal Kaziord7579d12014-12-03 10:10:54 +02006433static struct sk_buff *
Michal Kazior9ad50182015-01-29 14:29:47 +02006434ath10k_wmi_op_gen_beacon_dma(struct ath10k *ar, u32 vdev_id, const void *bcn,
6435 size_t bcn_len, u32 bcn_paddr, bool dtim_zero,
6436 bool deliver_cab)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006437{
Michal Kazior748afc42014-01-23 12:48:21 +01006438 struct wmi_bcn_tx_ref_cmd *cmd;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006439 struct sk_buff *skb;
Michal Kazior748afc42014-01-23 12:48:21 +01006440 struct ieee80211_hdr *hdr;
Michal Kazior748afc42014-01-23 12:48:21 +01006441 u16 fc;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006442
Michal Kazior7aa7a722014-08-25 12:09:38 +02006443 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006444 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006445 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006446
Michal Kazior9ad50182015-01-29 14:29:47 +02006447 hdr = (struct ieee80211_hdr *)bcn;
Michal Kazior748afc42014-01-23 12:48:21 +01006448 fc = le16_to_cpu(hdr->frame_control);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006449
Michal Kazior748afc42014-01-23 12:48:21 +01006450 cmd = (struct wmi_bcn_tx_ref_cmd *)skb->data;
Michal Kazior9ad50182015-01-29 14:29:47 +02006451 cmd->vdev_id = __cpu_to_le32(vdev_id);
6452 cmd->data_len = __cpu_to_le32(bcn_len);
6453 cmd->data_ptr = __cpu_to_le32(bcn_paddr);
Michal Kazior748afc42014-01-23 12:48:21 +01006454 cmd->msdu_id = 0;
6455 cmd->frame_control = __cpu_to_le32(fc);
6456 cmd->flags = 0;
Michal Kazior24c88f72014-07-25 13:32:17 +02006457 cmd->antenna_mask = __cpu_to_le32(WMI_BCN_TX_REF_DEF_ANTENNA);
Michal Kazior748afc42014-01-23 12:48:21 +01006458
Michal Kazior9ad50182015-01-29 14:29:47 +02006459 if (dtim_zero)
Michal Kazior748afc42014-01-23 12:48:21 +01006460 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DTIM_ZERO);
6461
Michal Kazior9ad50182015-01-29 14:29:47 +02006462 if (deliver_cab)
Michal Kazior748afc42014-01-23 12:48:21 +01006463 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB);
6464
Michal Kaziord7579d12014-12-03 10:10:54 +02006465 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006466}
6467
Michal Kazior5e752e42015-01-19 09:53:41 +01006468void ath10k_wmi_set_wmm_param(struct wmi_wmm_params *params,
6469 const struct wmi_wmm_params_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006470{
6471 params->cwmin = __cpu_to_le32(arg->cwmin);
6472 params->cwmax = __cpu_to_le32(arg->cwmax);
6473 params->aifs = __cpu_to_le32(arg->aifs);
6474 params->txop = __cpu_to_le32(arg->txop);
6475 params->acm = __cpu_to_le32(arg->acm);
6476 params->no_ack = __cpu_to_le32(arg->no_ack);
6477}
6478
Michal Kaziord7579d12014-12-03 10:10:54 +02006479static struct sk_buff *
6480ath10k_wmi_op_gen_pdev_set_wmm(struct ath10k *ar,
Michal Kazior5e752e42015-01-19 09:53:41 +01006481 const struct wmi_wmm_params_all_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006482{
6483 struct wmi_pdev_set_wmm_params *cmd;
6484 struct sk_buff *skb;
6485
Michal Kazior7aa7a722014-08-25 12:09:38 +02006486 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006487 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006488 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006489
6490 cmd = (struct wmi_pdev_set_wmm_params *)skb->data;
Michal Kazior5e752e42015-01-19 09:53:41 +01006491 ath10k_wmi_set_wmm_param(&cmd->ac_be, &arg->ac_be);
6492 ath10k_wmi_set_wmm_param(&cmd->ac_bk, &arg->ac_bk);
6493 ath10k_wmi_set_wmm_param(&cmd->ac_vi, &arg->ac_vi);
6494 ath10k_wmi_set_wmm_param(&cmd->ac_vo, &arg->ac_vo);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006495
Michal Kazior7aa7a722014-08-25 12:09:38 +02006496 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set wmm params\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02006497 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006498}
6499
Michal Kaziord7579d12014-12-03 10:10:54 +02006500static struct sk_buff *
Michal Kaziorde23d3e2015-02-15 16:50:41 +02006501ath10k_wmi_op_gen_request_stats(struct ath10k *ar, u32 stats_mask)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006502{
6503 struct wmi_request_stats_cmd *cmd;
6504 struct sk_buff *skb;
6505
Michal Kazior7aa7a722014-08-25 12:09:38 +02006506 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006507 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006508 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006509
6510 cmd = (struct wmi_request_stats_cmd *)skb->data;
Michal Kaziorde23d3e2015-02-15 16:50:41 +02006511 cmd->stats_id = __cpu_to_le32(stats_mask);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006512
Michal Kaziorde23d3e2015-02-15 16:50:41 +02006513 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi request stats 0x%08x\n",
6514 stats_mask);
Michal Kaziord7579d12014-12-03 10:10:54 +02006515 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006516}
Michal Kazior9cfbce72013-07-16 09:54:36 +02006517
Michal Kaziord7579d12014-12-03 10:10:54 +02006518static struct sk_buff *
6519ath10k_wmi_op_gen_force_fw_hang(struct ath10k *ar,
6520 enum wmi_force_fw_hang_type type, u32 delay_ms)
Michal Kazior9cfbce72013-07-16 09:54:36 +02006521{
6522 struct wmi_force_fw_hang_cmd *cmd;
6523 struct sk_buff *skb;
6524
Michal Kazior7aa7a722014-08-25 12:09:38 +02006525 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Michal Kazior9cfbce72013-07-16 09:54:36 +02006526 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006527 return ERR_PTR(-ENOMEM);
Michal Kazior9cfbce72013-07-16 09:54:36 +02006528
6529 cmd = (struct wmi_force_fw_hang_cmd *)skb->data;
6530 cmd->type = __cpu_to_le32(type);
6531 cmd->delay_ms = __cpu_to_le32(delay_ms);
6532
Michal Kazior7aa7a722014-08-25 12:09:38 +02006533 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi force fw hang %d delay %d\n",
Michal Kazior9cfbce72013-07-16 09:54:36 +02006534 type, delay_ms);
Michal Kaziord7579d12014-12-03 10:10:54 +02006535 return skb;
Michal Kazior9cfbce72013-07-16 09:54:36 +02006536}
Kalle Valof118a3e2014-01-03 12:59:31 +02006537
Michal Kaziord7579d12014-12-03 10:10:54 +02006538static struct sk_buff *
SenthilKumar Jegadeesan467210a2015-01-29 14:36:52 +05306539ath10k_wmi_op_gen_dbglog_cfg(struct ath10k *ar, u32 module_enable,
6540 u32 log_level)
Kalle Valof118a3e2014-01-03 12:59:31 +02006541{
6542 struct wmi_dbglog_cfg_cmd *cmd;
6543 struct sk_buff *skb;
6544 u32 cfg;
6545
Michal Kazior7aa7a722014-08-25 12:09:38 +02006546 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valof118a3e2014-01-03 12:59:31 +02006547 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006548 return ERR_PTR(-ENOMEM);
Kalle Valof118a3e2014-01-03 12:59:31 +02006549
6550 cmd = (struct wmi_dbglog_cfg_cmd *)skb->data;
6551
6552 if (module_enable) {
SenthilKumar Jegadeesan467210a2015-01-29 14:36:52 +05306553 cfg = SM(log_level,
Kalle Valof118a3e2014-01-03 12:59:31 +02006554 ATH10K_DBGLOG_CFG_LOG_LVL);
6555 } else {
6556 /* set back defaults, all modules with WARN level */
6557 cfg = SM(ATH10K_DBGLOG_LEVEL_WARN,
6558 ATH10K_DBGLOG_CFG_LOG_LVL);
6559 module_enable = ~0;
6560 }
6561
6562 cmd->module_enable = __cpu_to_le32(module_enable);
6563 cmd->module_valid = __cpu_to_le32(~0);
6564 cmd->config_enable = __cpu_to_le32(cfg);
6565 cmd->config_valid = __cpu_to_le32(ATH10K_DBGLOG_CFG_LOG_LVL_MASK);
6566
Michal Kazior7aa7a722014-08-25 12:09:38 +02006567 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valof118a3e2014-01-03 12:59:31 +02006568 "wmi dbglog cfg modules %08x %08x config %08x %08x\n",
6569 __le32_to_cpu(cmd->module_enable),
6570 __le32_to_cpu(cmd->module_valid),
6571 __le32_to_cpu(cmd->config_enable),
6572 __le32_to_cpu(cmd->config_valid));
Michal Kaziord7579d12014-12-03 10:10:54 +02006573 return skb;
Kalle Valof118a3e2014-01-03 12:59:31 +02006574}
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02006575
Michal Kaziord7579d12014-12-03 10:10:54 +02006576static struct sk_buff *
6577ath10k_wmi_op_gen_pktlog_enable(struct ath10k *ar, u32 ev_bitmap)
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006578{
6579 struct wmi_pdev_pktlog_enable_cmd *cmd;
6580 struct sk_buff *skb;
6581
6582 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6583 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006584 return ERR_PTR(-ENOMEM);
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006585
6586 ev_bitmap &= ATH10K_PKTLOG_ANY;
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006587
6588 cmd = (struct wmi_pdev_pktlog_enable_cmd *)skb->data;
6589 cmd->ev_bitmap = __cpu_to_le32(ev_bitmap);
Michal Kaziord7579d12014-12-03 10:10:54 +02006590
6591 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi enable pktlog filter 0x%08x\n",
6592 ev_bitmap);
6593 return skb;
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006594}
6595
Michal Kaziord7579d12014-12-03 10:10:54 +02006596static struct sk_buff *
6597ath10k_wmi_op_gen_pktlog_disable(struct ath10k *ar)
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006598{
6599 struct sk_buff *skb;
6600
6601 skb = ath10k_wmi_alloc_skb(ar, 0);
6602 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006603 return ERR_PTR(-ENOMEM);
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006604
6605 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi disable pktlog\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02006606 return skb;
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006607}
6608
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02006609static struct sk_buff *
6610ath10k_wmi_op_gen_pdev_set_quiet_mode(struct ath10k *ar, u32 period,
6611 u32 duration, u32 next_offset,
6612 u32 enabled)
6613{
6614 struct wmi_pdev_set_quiet_cmd *cmd;
6615 struct sk_buff *skb;
6616
6617 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6618 if (!skb)
6619 return ERR_PTR(-ENOMEM);
6620
6621 cmd = (struct wmi_pdev_set_quiet_cmd *)skb->data;
6622 cmd->period = __cpu_to_le32(period);
6623 cmd->duration = __cpu_to_le32(duration);
6624 cmd->next_start = __cpu_to_le32(next_offset);
6625 cmd->enabled = __cpu_to_le32(enabled);
6626
6627 ath10k_dbg(ar, ATH10K_DBG_WMI,
6628 "wmi quiet param: period %u duration %u enabled %d\n",
6629 period, duration, enabled);
6630 return skb;
6631}
6632
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02006633static struct sk_buff *
6634ath10k_wmi_op_gen_addba_clear_resp(struct ath10k *ar, u32 vdev_id,
6635 const u8 *mac)
6636{
6637 struct wmi_addba_clear_resp_cmd *cmd;
6638 struct sk_buff *skb;
6639
6640 if (!mac)
6641 return ERR_PTR(-EINVAL);
6642
6643 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6644 if (!skb)
6645 return ERR_PTR(-ENOMEM);
6646
6647 cmd = (struct wmi_addba_clear_resp_cmd *)skb->data;
6648 cmd->vdev_id = __cpu_to_le32(vdev_id);
6649 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6650
6651 ath10k_dbg(ar, ATH10K_DBG_WMI,
6652 "wmi addba clear resp vdev_id 0x%X mac_addr %pM\n",
6653 vdev_id, mac);
6654 return skb;
6655}
6656
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02006657static struct sk_buff *
6658ath10k_wmi_op_gen_addba_send(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6659 u32 tid, u32 buf_size)
6660{
6661 struct wmi_addba_send_cmd *cmd;
6662 struct sk_buff *skb;
6663
6664 if (!mac)
6665 return ERR_PTR(-EINVAL);
6666
6667 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6668 if (!skb)
6669 return ERR_PTR(-ENOMEM);
6670
6671 cmd = (struct wmi_addba_send_cmd *)skb->data;
6672 cmd->vdev_id = __cpu_to_le32(vdev_id);
6673 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6674 cmd->tid = __cpu_to_le32(tid);
6675 cmd->buffersize = __cpu_to_le32(buf_size);
6676
6677 ath10k_dbg(ar, ATH10K_DBG_WMI,
6678 "wmi addba send vdev_id 0x%X mac_addr %pM tid %u bufsize %u\n",
6679 vdev_id, mac, tid, buf_size);
6680 return skb;
6681}
6682
Rajkumar Manoharan11597412015-01-12 14:07:26 +02006683static struct sk_buff *
6684ath10k_wmi_op_gen_addba_set_resp(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6685 u32 tid, u32 status)
6686{
6687 struct wmi_addba_setresponse_cmd *cmd;
6688 struct sk_buff *skb;
6689
6690 if (!mac)
6691 return ERR_PTR(-EINVAL);
6692
6693 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6694 if (!skb)
6695 return ERR_PTR(-ENOMEM);
6696
6697 cmd = (struct wmi_addba_setresponse_cmd *)skb->data;
6698 cmd->vdev_id = __cpu_to_le32(vdev_id);
6699 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6700 cmd->tid = __cpu_to_le32(tid);
6701 cmd->statuscode = __cpu_to_le32(status);
6702
6703 ath10k_dbg(ar, ATH10K_DBG_WMI,
6704 "wmi addba set resp vdev_id 0x%X mac_addr %pM tid %u status %u\n",
6705 vdev_id, mac, tid, status);
6706 return skb;
6707}
6708
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02006709static struct sk_buff *
6710ath10k_wmi_op_gen_delba_send(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6711 u32 tid, u32 initiator, u32 reason)
6712{
6713 struct wmi_delba_send_cmd *cmd;
6714 struct sk_buff *skb;
6715
6716 if (!mac)
6717 return ERR_PTR(-EINVAL);
6718
6719 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6720 if (!skb)
6721 return ERR_PTR(-ENOMEM);
6722
6723 cmd = (struct wmi_delba_send_cmd *)skb->data;
6724 cmd->vdev_id = __cpu_to_le32(vdev_id);
6725 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6726 cmd->tid = __cpu_to_le32(tid);
6727 cmd->initiator = __cpu_to_le32(initiator);
6728 cmd->reasoncode = __cpu_to_le32(reason);
6729
6730 ath10k_dbg(ar, ATH10K_DBG_WMI,
6731 "wmi delba send vdev_id 0x%X mac_addr %pM tid %u initiator %u reason %u\n",
6732 vdev_id, mac, tid, initiator, reason);
6733 return skb;
6734}
6735
Maharaja Kennadyrajan29542662015-10-05 17:56:38 +03006736static struct sk_buff *
6737ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config(struct ath10k *ar, u32 param)
6738{
6739 struct wmi_pdev_get_tpc_config_cmd *cmd;
6740 struct sk_buff *skb;
6741
6742 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6743 if (!skb)
6744 return ERR_PTR(-ENOMEM);
6745
6746 cmd = (struct wmi_pdev_get_tpc_config_cmd *)skb->data;
6747 cmd->param = __cpu_to_le32(param);
6748
6749 ath10k_dbg(ar, ATH10K_DBG_WMI,
6750 "wmi pdev get tcp config param:%d\n", param);
6751 return skb;
6752}
6753
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03006754size_t ath10k_wmi_fw_stats_num_peers(struct list_head *head)
6755{
6756 struct ath10k_fw_stats_peer *i;
6757 size_t num = 0;
6758
6759 list_for_each_entry(i, head, list)
6760 ++num;
6761
6762 return num;
6763}
6764
6765size_t ath10k_wmi_fw_stats_num_vdevs(struct list_head *head)
6766{
6767 struct ath10k_fw_stats_vdev *i;
6768 size_t num = 0;
6769
6770 list_for_each_entry(i, head, list)
6771 ++num;
6772
6773 return num;
6774}
6775
6776static void
6777ath10k_wmi_fw_pdev_base_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
6778 char *buf, u32 *length)
6779{
6780 u32 len = *length;
6781 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
6782
6783 len += scnprintf(buf + len, buf_len - len, "\n");
6784 len += scnprintf(buf + len, buf_len - len, "%30s\n",
6785 "ath10k PDEV stats");
6786 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
6787 "=================");
6788
6789 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6790 "Channel noise floor", pdev->ch_noise_floor);
6791 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6792 "Channel TX power", pdev->chan_tx_power);
6793 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6794 "TX frame count", pdev->tx_frame_count);
6795 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6796 "RX frame count", pdev->rx_frame_count);
6797 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6798 "RX clear count", pdev->rx_clear_count);
6799 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6800 "Cycle count", pdev->cycle_count);
6801 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6802 "PHY error count", pdev->phy_err_count);
6803
6804 *length = len;
6805}
6806
6807static void
6808ath10k_wmi_fw_pdev_extra_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
6809 char *buf, u32 *length)
6810{
6811 u32 len = *length;
6812 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
6813
6814 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6815 "RTS bad count", pdev->rts_bad);
6816 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6817 "RTS good count", pdev->rts_good);
6818 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6819 "FCS bad count", pdev->fcs_bad);
6820 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6821 "No beacon count", pdev->no_beacons);
6822 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6823 "MIB int count", pdev->mib_int_count);
6824
6825 len += scnprintf(buf + len, buf_len - len, "\n");
6826 *length = len;
6827}
6828
6829static void
6830ath10k_wmi_fw_pdev_tx_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
6831 char *buf, u32 *length)
6832{
6833 u32 len = *length;
6834 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
6835
6836 len += scnprintf(buf + len, buf_len - len, "\n%30s\n",
6837 "ath10k PDEV TX stats");
6838 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
6839 "=================");
6840
6841 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6842 "HTT cookies queued", pdev->comp_queued);
6843 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6844 "HTT cookies disp.", pdev->comp_delivered);
6845 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6846 "MSDU queued", pdev->msdu_enqued);
6847 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6848 "MPDU queued", pdev->mpdu_enqued);
6849 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6850 "MSDUs dropped", pdev->wmm_drop);
6851 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6852 "Local enqued", pdev->local_enqued);
6853 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6854 "Local freed", pdev->local_freed);
6855 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6856 "HW queued", pdev->hw_queued);
6857 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6858 "PPDUs reaped", pdev->hw_reaped);
6859 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6860 "Num underruns", pdev->underrun);
6861 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6862 "PPDUs cleaned", pdev->tx_abort);
6863 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6864 "MPDUs requed", pdev->mpdus_requed);
6865 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6866 "Excessive retries", pdev->tx_ko);
6867 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6868 "HW rate", pdev->data_rc);
6869 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6870 "Sched self tiggers", pdev->self_triggers);
6871 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6872 "Dropped due to SW retries",
6873 pdev->sw_retry_failure);
6874 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6875 "Illegal rate phy errors",
6876 pdev->illgl_rate_phy_err);
6877 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6878 "Pdev continuous xretry", pdev->pdev_cont_xretry);
6879 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6880 "TX timeout", pdev->pdev_tx_timeout);
6881 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6882 "PDEV resets", pdev->pdev_resets);
6883 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6884 "PHY underrun", pdev->phy_underrun);
6885 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6886 "MPDU is more than txop limit", pdev->txop_ovf);
6887 *length = len;
6888}
6889
6890static void
6891ath10k_wmi_fw_pdev_rx_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
6892 char *buf, u32 *length)
6893{
6894 u32 len = *length;
6895 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
6896
6897 len += scnprintf(buf + len, buf_len - len, "\n%30s\n",
6898 "ath10k PDEV RX stats");
6899 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
6900 "=================");
6901
6902 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6903 "Mid PPDU route change",
6904 pdev->mid_ppdu_route_change);
6905 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6906 "Tot. number of statuses", pdev->status_rcvd);
6907 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6908 "Extra frags on rings 0", pdev->r0_frags);
6909 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6910 "Extra frags on rings 1", pdev->r1_frags);
6911 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6912 "Extra frags on rings 2", pdev->r2_frags);
6913 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6914 "Extra frags on rings 3", pdev->r3_frags);
6915 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6916 "MSDUs delivered to HTT", pdev->htt_msdus);
6917 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6918 "MPDUs delivered to HTT", pdev->htt_mpdus);
6919 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6920 "MSDUs delivered to stack", pdev->loc_msdus);
6921 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6922 "MPDUs delivered to stack", pdev->loc_mpdus);
6923 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6924 "Oversized AMSUs", pdev->oversize_amsdu);
6925 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6926 "PHY errors", pdev->phy_errs);
6927 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6928 "PHY errors drops", pdev->phy_err_drop);
6929 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6930 "MPDU errors (FCS, MIC, ENC)", pdev->mpdu_errs);
6931 *length = len;
6932}
6933
6934static void
6935ath10k_wmi_fw_vdev_stats_fill(const struct ath10k_fw_stats_vdev *vdev,
6936 char *buf, u32 *length)
6937{
6938 u32 len = *length;
6939 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
6940 int i;
6941
6942 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6943 "vdev id", vdev->vdev_id);
6944 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6945 "beacon snr", vdev->beacon_snr);
6946 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6947 "data snr", vdev->data_snr);
6948 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6949 "num rx frames", vdev->num_rx_frames);
6950 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6951 "num rts fail", vdev->num_rts_fail);
6952 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6953 "num rts success", vdev->num_rts_success);
6954 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6955 "num rx err", vdev->num_rx_err);
6956 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6957 "num rx discard", vdev->num_rx_discard);
6958 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6959 "num tx not acked", vdev->num_tx_not_acked);
6960
6961 for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames); i++)
6962 len += scnprintf(buf + len, buf_len - len,
6963 "%25s [%02d] %u\n",
6964 "num tx frames", i,
6965 vdev->num_tx_frames[i]);
6966
6967 for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames_retries); i++)
6968 len += scnprintf(buf + len, buf_len - len,
6969 "%25s [%02d] %u\n",
6970 "num tx frames retries", i,
6971 vdev->num_tx_frames_retries[i]);
6972
6973 for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames_failures); i++)
6974 len += scnprintf(buf + len, buf_len - len,
6975 "%25s [%02d] %u\n",
6976 "num tx frames failures", i,
6977 vdev->num_tx_frames_failures[i]);
6978
6979 for (i = 0 ; i < ARRAY_SIZE(vdev->tx_rate_history); i++)
6980 len += scnprintf(buf + len, buf_len - len,
6981 "%25s [%02d] 0x%08x\n",
6982 "tx rate history", i,
6983 vdev->tx_rate_history[i]);
6984
6985 for (i = 0 ; i < ARRAY_SIZE(vdev->beacon_rssi_history); i++)
6986 len += scnprintf(buf + len, buf_len - len,
6987 "%25s [%02d] %u\n",
6988 "beacon rssi history", i,
6989 vdev->beacon_rssi_history[i]);
6990
6991 len += scnprintf(buf + len, buf_len - len, "\n");
6992 *length = len;
6993}
6994
6995static void
6996ath10k_wmi_fw_peer_stats_fill(const struct ath10k_fw_stats_peer *peer,
6997 char *buf, u32 *length)
6998{
6999 u32 len = *length;
7000 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7001
7002 len += scnprintf(buf + len, buf_len - len, "%30s %pM\n",
7003 "Peer MAC address", peer->peer_macaddr);
7004 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7005 "Peer RSSI", peer->peer_rssi);
7006 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7007 "Peer TX rate", peer->peer_tx_rate);
7008 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7009 "Peer RX rate", peer->peer_rx_rate);
7010 len += scnprintf(buf + len, buf_len - len, "\n");
7011 *length = len;
7012}
7013
7014void ath10k_wmi_main_op_fw_stats_fill(struct ath10k *ar,
7015 struct ath10k_fw_stats *fw_stats,
7016 char *buf)
7017{
7018 u32 len = 0;
7019 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7020 const struct ath10k_fw_stats_pdev *pdev;
7021 const struct ath10k_fw_stats_vdev *vdev;
7022 const struct ath10k_fw_stats_peer *peer;
7023 size_t num_peers;
7024 size_t num_vdevs;
7025
7026 spin_lock_bh(&ar->data_lock);
7027
7028 pdev = list_first_entry_or_null(&fw_stats->pdevs,
7029 struct ath10k_fw_stats_pdev, list);
7030 if (!pdev) {
7031 ath10k_warn(ar, "failed to get pdev stats\n");
7032 goto unlock;
7033 }
7034
7035 num_peers = ath10k_wmi_fw_stats_num_peers(&fw_stats->peers);
7036 num_vdevs = ath10k_wmi_fw_stats_num_vdevs(&fw_stats->vdevs);
7037
7038 ath10k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len);
7039 ath10k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len);
7040 ath10k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len);
7041
7042 len += scnprintf(buf + len, buf_len - len, "\n");
7043 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7044 "ath10k VDEV stats", num_vdevs);
7045 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7046 "=================");
7047
7048 list_for_each_entry(vdev, &fw_stats->vdevs, list) {
7049 ath10k_wmi_fw_vdev_stats_fill(vdev, buf, &len);
7050 }
7051
7052 len += scnprintf(buf + len, buf_len - len, "\n");
7053 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7054 "ath10k PEER stats", num_peers);
7055 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7056 "=================");
7057
7058 list_for_each_entry(peer, &fw_stats->peers, list) {
7059 ath10k_wmi_fw_peer_stats_fill(peer, buf, &len);
7060 }
7061
7062unlock:
7063 spin_unlock_bh(&ar->data_lock);
7064
7065 if (len >= buf_len)
7066 buf[len - 1] = 0;
7067 else
7068 buf[len] = 0;
7069}
7070
7071void ath10k_wmi_10x_op_fw_stats_fill(struct ath10k *ar,
7072 struct ath10k_fw_stats *fw_stats,
7073 char *buf)
7074{
7075 unsigned int len = 0;
7076 unsigned int buf_len = ATH10K_FW_STATS_BUF_SIZE;
7077 const struct ath10k_fw_stats_pdev *pdev;
7078 const struct ath10k_fw_stats_vdev *vdev;
7079 const struct ath10k_fw_stats_peer *peer;
7080 size_t num_peers;
7081 size_t num_vdevs;
7082
7083 spin_lock_bh(&ar->data_lock);
7084
7085 pdev = list_first_entry_or_null(&fw_stats->pdevs,
7086 struct ath10k_fw_stats_pdev, list);
7087 if (!pdev) {
7088 ath10k_warn(ar, "failed to get pdev stats\n");
7089 goto unlock;
7090 }
7091
7092 num_peers = ath10k_wmi_fw_stats_num_peers(&fw_stats->peers);
7093 num_vdevs = ath10k_wmi_fw_stats_num_vdevs(&fw_stats->vdevs);
7094
7095 ath10k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len);
7096 ath10k_wmi_fw_pdev_extra_stats_fill(pdev, buf, &len);
7097 ath10k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len);
7098 ath10k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len);
7099
7100 len += scnprintf(buf + len, buf_len - len, "\n");
7101 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7102 "ath10k VDEV stats", num_vdevs);
7103 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7104 "=================");
7105
7106 list_for_each_entry(vdev, &fw_stats->vdevs, list) {
7107 ath10k_wmi_fw_vdev_stats_fill(vdev, buf, &len);
7108 }
7109
7110 len += scnprintf(buf + len, buf_len - len, "\n");
7111 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7112 "ath10k PEER stats", num_peers);
7113 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7114 "=================");
7115
7116 list_for_each_entry(peer, &fw_stats->peers, list) {
7117 ath10k_wmi_fw_peer_stats_fill(peer, buf, &len);
7118 }
7119
7120unlock:
7121 spin_unlock_bh(&ar->data_lock);
7122
7123 if (len >= buf_len)
7124 buf[len - 1] = 0;
7125 else
7126 buf[len] = 0;
7127}
7128
Maharaja62f77f02015-10-21 11:49:18 +03007129static struct sk_buff *
7130ath10k_wmi_op_gen_pdev_enable_adaptive_cca(struct ath10k *ar, u8 enable,
7131 u32 detect_level, u32 detect_margin)
7132{
7133 struct wmi_pdev_set_adaptive_cca_params *cmd;
7134 struct sk_buff *skb;
7135
7136 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7137 if (!skb)
7138 return ERR_PTR(-ENOMEM);
7139
7140 cmd = (struct wmi_pdev_set_adaptive_cca_params *)skb->data;
7141 cmd->enable = __cpu_to_le32(enable);
7142 cmd->cca_detect_level = __cpu_to_le32(detect_level);
7143 cmd->cca_detect_margin = __cpu_to_le32(detect_margin);
7144
7145 ath10k_dbg(ar, ATH10K_DBG_WMI,
7146 "wmi pdev set adaptive cca params enable:%d detection level:%d detection margin:%d\n",
7147 enable, detect_level, detect_margin);
7148 return skb;
7149}
7150
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02007151void ath10k_wmi_10_4_op_fw_stats_fill(struct ath10k *ar,
7152 struct ath10k_fw_stats *fw_stats,
7153 char *buf)
7154{
7155 u32 len = 0;
7156 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7157 const struct ath10k_fw_stats_pdev *pdev;
7158 const struct ath10k_fw_stats_vdev *vdev;
7159 const struct ath10k_fw_stats_peer *peer;
7160 size_t num_peers;
7161 size_t num_vdevs;
7162
7163 spin_lock_bh(&ar->data_lock);
7164
7165 pdev = list_first_entry_or_null(&fw_stats->pdevs,
7166 struct ath10k_fw_stats_pdev, list);
7167 if (!pdev) {
7168 ath10k_warn(ar, "failed to get pdev stats\n");
7169 goto unlock;
7170 }
7171
7172 num_peers = ath10k_wmi_fw_stats_num_peers(&fw_stats->peers);
7173 num_vdevs = ath10k_wmi_fw_stats_num_vdevs(&fw_stats->vdevs);
7174
7175 ath10k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len);
7176 ath10k_wmi_fw_pdev_extra_stats_fill(pdev, buf, &len);
7177 ath10k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len);
7178
7179 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7180 "HW paused", pdev->hw_paused);
7181 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7182 "Seqs posted", pdev->seq_posted);
7183 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7184 "Seqs failed queueing", pdev->seq_failed_queueing);
7185 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7186 "Seqs completed", pdev->seq_completed);
7187 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7188 "Seqs restarted", pdev->seq_restarted);
7189 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7190 "MU Seqs posted", pdev->mu_seq_posted);
7191 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7192 "MPDUs SW flushed", pdev->mpdus_sw_flush);
7193 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7194 "MPDUs HW filtered", pdev->mpdus_hw_filter);
7195 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7196 "MPDUs truncated", pdev->mpdus_truncated);
7197 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7198 "MPDUs receive no ACK", pdev->mpdus_ack_failed);
7199 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7200 "MPDUs expired", pdev->mpdus_expired);
7201
7202 ath10k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len);
7203 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7204 "Num Rx Overflow errors", pdev->rx_ovfl_errs);
7205
7206 len += scnprintf(buf + len, buf_len - len, "\n");
7207 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7208 "ath10k VDEV stats", num_vdevs);
7209 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7210 "=================");
7211
7212 list_for_each_entry(vdev, &fw_stats->vdevs, list) {
7213 ath10k_wmi_fw_vdev_stats_fill(vdev, buf, &len);
7214 }
7215
7216 len += scnprintf(buf + len, buf_len - len, "\n");
7217 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7218 "ath10k PEER stats", num_peers);
7219 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7220 "=================");
7221
7222 list_for_each_entry(peer, &fw_stats->peers, list) {
7223 ath10k_wmi_fw_peer_stats_fill(peer, buf, &len);
7224 }
7225
7226unlock:
7227 spin_unlock_bh(&ar->data_lock);
7228
7229 if (len >= buf_len)
7230 buf[len - 1] = 0;
7231 else
7232 buf[len] = 0;
7233}
7234
Michal Kaziord7579d12014-12-03 10:10:54 +02007235static const struct wmi_ops wmi_ops = {
7236 .rx = ath10k_wmi_op_rx,
7237 .map_svc = wmi_main_svc_map,
7238
7239 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7240 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7241 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7242 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7243 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7244 .pull_swba = ath10k_wmi_op_pull_swba_ev,
Raja Mani991adf72015-08-14 11:13:29 +03007245 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
Michal Kaziord7579d12014-12-03 10:10:54 +02007246 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7247 .pull_svc_rdy = ath10k_wmi_main_op_pull_svc_rdy_ev,
7248 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
7249 .pull_fw_stats = ath10k_wmi_main_op_pull_fw_stats,
Michal Kaziorc1a46542015-03-10 16:21:54 +02007250 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02007251
7252 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7253 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7254 .gen_pdev_set_rd = ath10k_wmi_op_gen_pdev_set_rd,
7255 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7256 .gen_init = ath10k_wmi_op_gen_init,
7257 .gen_start_scan = ath10k_wmi_op_gen_start_scan,
7258 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7259 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7260 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7261 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7262 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7263 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7264 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7265 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7266 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7267 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7268 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
Michal Kazior6d492fe2015-01-28 09:57:22 +02007269 /* .gen_vdev_wmm_conf not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007270 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7271 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7272 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7273 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7274 .gen_peer_assoc = ath10k_wmi_op_gen_peer_assoc,
7275 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7276 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7277 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7278 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7279 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7280 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7281 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7282 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7283 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7284 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7285 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7286 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02007287 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02007288 /* .gen_pdev_get_temperature not implemented */
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02007289 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02007290 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02007291 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02007292 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03007293 .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
Michal Kaziorbe9ce9d2015-01-13 16:30:11 +02007294 /* .gen_bcn_tmpl not implemented */
Michal Kazior4c4955f2015-01-13 16:30:11 +02007295 /* .gen_prb_tmpl not implemented */
Michal Kazior369242b4e2015-01-13 16:30:11 +02007296 /* .gen_p2p_go_bcn_ie not implemented */
Michal Kazior5b272e32015-03-31 10:26:22 +00007297 /* .gen_adaptive_qcs not implemented */
Maharaja62f77f02015-10-21 11:49:18 +03007298 /* .gen_pdev_enable_adaptive_cca not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007299};
7300
7301static const struct wmi_ops wmi_10_1_ops = {
7302 .rx = ath10k_wmi_10_1_op_rx,
7303 .map_svc = wmi_10x_svc_map,
7304 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
7305 .pull_fw_stats = ath10k_wmi_10x_op_pull_fw_stats,
7306 .gen_init = ath10k_wmi_10_1_op_gen_init,
7307 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7308 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
7309 .gen_peer_assoc = ath10k_wmi_10_1_op_gen_peer_assoc,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02007310 /* .gen_pdev_get_temperature not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007311
7312 /* shared with main branch */
7313 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7314 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7315 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7316 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7317 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7318 .pull_swba = ath10k_wmi_op_pull_swba_ev,
Raja Mani991adf72015-08-14 11:13:29 +03007319 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
Michal Kaziord7579d12014-12-03 10:10:54 +02007320 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7321 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
Michal Kaziorc1a46542015-03-10 16:21:54 +02007322 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02007323
7324 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7325 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7326 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7327 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7328 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7329 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7330 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7331 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7332 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7333 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7334 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7335 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7336 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7337 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
Michal Kazior6d492fe2015-01-28 09:57:22 +02007338 /* .gen_vdev_wmm_conf not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007339 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7340 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7341 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7342 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7343 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7344 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7345 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7346 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7347 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7348 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7349 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7350 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7351 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7352 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7353 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7354 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02007355 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02007356 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02007357 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02007358 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02007359 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03007360 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
Michal Kaziorbe9ce9d2015-01-13 16:30:11 +02007361 /* .gen_bcn_tmpl not implemented */
Michal Kazior4c4955f2015-01-13 16:30:11 +02007362 /* .gen_prb_tmpl not implemented */
Michal Kazior369242b4e2015-01-13 16:30:11 +02007363 /* .gen_p2p_go_bcn_ie not implemented */
Michal Kazior5b272e32015-03-31 10:26:22 +00007364 /* .gen_adaptive_qcs not implemented */
Maharaja62f77f02015-10-21 11:49:18 +03007365 /* .gen_pdev_enable_adaptive_cca not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007366};
7367
7368static const struct wmi_ops wmi_10_2_ops = {
7369 .rx = ath10k_wmi_10_2_op_rx,
Michal Kazior20de2222015-01-24 12:14:49 +02007370 .pull_fw_stats = ath10k_wmi_10_2_op_pull_fw_stats,
Michal Kaziord7579d12014-12-03 10:10:54 +02007371 .gen_init = ath10k_wmi_10_2_op_gen_init,
7372 .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02007373 /* .gen_pdev_get_temperature not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007374
7375 /* shared with 10.1 */
7376 .map_svc = wmi_10x_svc_map,
7377 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02007378 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7379 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
7380
7381 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7382 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7383 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7384 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7385 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7386 .pull_swba = ath10k_wmi_op_pull_swba_ev,
Raja Mani991adf72015-08-14 11:13:29 +03007387 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
Michal Kaziord7579d12014-12-03 10:10:54 +02007388 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7389 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
Michal Kaziorc1a46542015-03-10 16:21:54 +02007390 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02007391
7392 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7393 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7394 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7395 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7396 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7397 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7398 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7399 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7400 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7401 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7402 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7403 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7404 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7405 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
Michal Kazior6d492fe2015-01-28 09:57:22 +02007406 /* .gen_vdev_wmm_conf not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007407 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7408 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7409 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7410 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7411 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7412 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7413 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7414 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7415 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7416 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7417 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7418 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7419 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7420 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7421 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7422 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02007423 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02007424 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02007425 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02007426 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02007427 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03007428 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
Maharaja62f77f02015-10-21 11:49:18 +03007429 /* .gen_pdev_enable_adaptive_cca not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007430};
7431
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007432static const struct wmi_ops wmi_10_2_4_ops = {
7433 .rx = ath10k_wmi_10_2_op_rx,
Michal Kazior20de2222015-01-24 12:14:49 +02007434 .pull_fw_stats = ath10k_wmi_10_2_4_op_pull_fw_stats,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007435 .gen_init = ath10k_wmi_10_2_op_gen_init,
7436 .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02007437 .gen_pdev_get_temperature = ath10k_wmi_10_2_op_gen_pdev_get_temperature,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007438
7439 /* shared with 10.1 */
7440 .map_svc = wmi_10x_svc_map,
7441 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007442 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7443 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
7444
7445 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7446 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7447 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7448 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7449 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7450 .pull_swba = ath10k_wmi_op_pull_swba_ev,
Raja Mani991adf72015-08-14 11:13:29 +03007451 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007452 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7453 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
Michal Kaziorc1a46542015-03-10 16:21:54 +02007454 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007455
7456 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7457 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7458 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7459 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7460 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7461 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7462 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7463 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7464 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7465 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7466 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7467 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7468 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7469 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
7470 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7471 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7472 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7473 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7474 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7475 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7476 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7477 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7478 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7479 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7480 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7481 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7482 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7483 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7484 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7485 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02007486 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02007487 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02007488 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02007489 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02007490 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Maharaja Kennadyrajan29542662015-10-05 17:56:38 +03007491 .gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config,
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03007492 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
Maharaja62f77f02015-10-21 11:49:18 +03007493 .gen_pdev_enable_adaptive_cca =
7494 ath10k_wmi_op_gen_pdev_enable_adaptive_cca,
Michal Kaziorbe9ce9d2015-01-13 16:30:11 +02007495 /* .gen_bcn_tmpl not implemented */
Michal Kazior4c4955f2015-01-13 16:30:11 +02007496 /* .gen_prb_tmpl not implemented */
Michal Kazior369242b4e2015-01-13 16:30:11 +02007497 /* .gen_p2p_go_bcn_ie not implemented */
Michal Kazior5b272e32015-03-31 10:26:22 +00007498 /* .gen_adaptive_qcs not implemented */
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007499};
7500
Raja Mani840357c2015-06-22 20:10:10 +05307501static const struct wmi_ops wmi_10_4_ops = {
Raja Mani1c092962015-06-22 20:10:16 +05307502 .rx = ath10k_wmi_10_4_op_rx,
Raja Mani840357c2015-06-22 20:10:10 +05307503 .map_svc = wmi_10_4_svc_map,
Raja Manib2297ba2015-06-22 20:22:23 +05307504
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02007505 .pull_fw_stats = ath10k_wmi_10_4_op_pull_fw_stats,
Raja Manib2297ba2015-06-22 20:22:23 +05307506 .pull_scan = ath10k_wmi_op_pull_scan_ev,
Raja Mani1c092962015-06-22 20:10:16 +05307507 .pull_mgmt_rx = ath10k_wmi_10_4_op_pull_mgmt_rx_ev,
Raja Manib2297ba2015-06-22 20:22:23 +05307508 .pull_ch_info = ath10k_wmi_10_4_op_pull_ch_info_ev,
Raja Mani373b48c2015-06-22 20:22:22 +05307509 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7510 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
Raja Mani3cec3be2015-06-22 20:22:21 +05307511 .pull_swba = ath10k_wmi_10_4_op_pull_swba_ev,
Raja Mani2b0a2e02015-08-14 11:13:34 +03007512 .pull_phyerr_hdr = ath10k_wmi_10_4_op_pull_phyerr_ev_hdr,
7513 .pull_phyerr = ath10k_wmi_10_4_op_pull_phyerr_ev,
Raja Mani1c092962015-06-22 20:10:16 +05307514 .pull_svc_rdy = ath10k_wmi_main_op_pull_svc_rdy_ev,
Raja Manid02e7522015-06-22 20:10:18 +05307515 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
Vivek Natarajan08e75ea2015-08-04 10:45:11 +05307516 .get_txbf_conf_scheme = ath10k_wmi_10_4_txbf_conf_scheme,
Raja Mani373b48c2015-06-22 20:22:22 +05307517
7518 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7519 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7520 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7521 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
Raja Manid1e52a82015-06-22 20:10:15 +05307522 .gen_init = ath10k_wmi_10_4_op_gen_init,
Raja Manib2297ba2015-06-22 20:22:23 +05307523 .gen_start_scan = ath10k_wmi_op_gen_start_scan,
7524 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
Raja Mani373b48c2015-06-22 20:22:22 +05307525 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7526 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7527 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7528 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7529 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7530 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7531 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7532 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
Raja Mani4535edb2015-08-20 10:29:05 +05307533 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7534 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
Raja Mani373b48c2015-06-22 20:22:22 +05307535 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7536 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7537 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7538 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7539 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7540 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7541 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7542 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7543 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7544 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7545 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7546 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7547 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7548 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7549 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
7550 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Vasanthakumar Thiagarajanb2887412015-08-13 21:10:54 +05307551 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
7552 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
7553 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
7554 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02007555 .fw_stats_fill = ath10k_wmi_10_4_op_fw_stats_fill,
Raja Mani373b48c2015-06-22 20:22:22 +05307556
7557 /* shared with 10.2 */
7558 .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02007559 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
Raja Mani840357c2015-06-22 20:10:10 +05307560};
7561
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007562int ath10k_wmi_attach(struct ath10k *ar)
7563{
Michal Kaziord7579d12014-12-03 10:10:54 +02007564 switch (ar->wmi.op_version) {
Raja Mani9bd21322015-06-22 20:10:09 +05307565 case ATH10K_FW_WMI_OP_VERSION_10_4:
Raja Mani840357c2015-06-22 20:10:10 +05307566 ar->wmi.ops = &wmi_10_4_ops;
Raja Mani2d491e62015-06-22 20:10:11 +05307567 ar->wmi.cmd = &wmi_10_4_cmd_map;
Raja Mani93841a12015-06-22 20:10:13 +05307568 ar->wmi.vdev_param = &wmi_10_4_vdev_param_map;
Raja Manid86561f2015-06-22 20:10:14 +05307569 ar->wmi.pdev_param = &wmi_10_4_pdev_param_map;
Raja Mani9bd21322015-06-22 20:10:09 +05307570 break;
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007571 case ATH10K_FW_WMI_OP_VERSION_10_2_4:
7572 ar->wmi.cmd = &wmi_10_2_4_cmd_map;
7573 ar->wmi.ops = &wmi_10_2_4_ops;
7574 ar->wmi.vdev_param = &wmi_10_2_4_vdev_param_map;
7575 ar->wmi.pdev_param = &wmi_10_2_4_pdev_param_map;
7576 break;
Michal Kaziord7579d12014-12-03 10:10:54 +02007577 case ATH10K_FW_WMI_OP_VERSION_10_2:
7578 ar->wmi.cmd = &wmi_10_2_cmd_map;
7579 ar->wmi.ops = &wmi_10_2_ops;
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007580 ar->wmi.vdev_param = &wmi_10x_vdev_param_map;
7581 ar->wmi.pdev_param = &wmi_10x_pdev_param_map;
Michal Kaziord7579d12014-12-03 10:10:54 +02007582 break;
7583 case ATH10K_FW_WMI_OP_VERSION_10_1:
7584 ar->wmi.cmd = &wmi_10x_cmd_map;
7585 ar->wmi.ops = &wmi_10_1_ops;
7586 ar->wmi.vdev_param = &wmi_10x_vdev_param_map;
7587 ar->wmi.pdev_param = &wmi_10x_pdev_param_map;
7588 break;
7589 case ATH10K_FW_WMI_OP_VERSION_MAIN:
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007590 ar->wmi.cmd = &wmi_cmd_map;
Michal Kaziord7579d12014-12-03 10:10:54 +02007591 ar->wmi.ops = &wmi_ops;
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007592 ar->wmi.vdev_param = &wmi_vdev_param_map;
7593 ar->wmi.pdev_param = &wmi_pdev_param_map;
Michal Kaziord7579d12014-12-03 10:10:54 +02007594 break;
Michal Kaziorca996ec2014-12-03 10:11:32 +02007595 case ATH10K_FW_WMI_OP_VERSION_TLV:
7596 ath10k_wmi_tlv_attach(ar);
7597 break;
Michal Kaziord7579d12014-12-03 10:10:54 +02007598 case ATH10K_FW_WMI_OP_VERSION_UNSET:
7599 case ATH10K_FW_WMI_OP_VERSION_MAX:
7600 ath10k_err(ar, "unsupported WMI op version: %d\n",
7601 ar->wmi.op_version);
7602 return -EINVAL;
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007603 }
7604
7605 init_completion(&ar->wmi.service_ready);
7606 init_completion(&ar->wmi.unified_ready);
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007607
Raja Manic8ecfc12015-07-29 11:40:38 +03007608 INIT_WORK(&ar->svc_rdy_work, ath10k_wmi_event_service_ready_work);
7609
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007610 return 0;
7611}
7612
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05307613void ath10k_wmi_free_host_mem(struct ath10k *ar)
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007614{
7615 int i;
7616
7617 /* free the host memory chunks requested by firmware */
7618 for (i = 0; i < ar->wmi.num_mem_chunks; i++) {
7619 dma_free_coherent(ar->dev,
7620 ar->wmi.mem_chunks[i].len,
7621 ar->wmi.mem_chunks[i].vaddr,
7622 ar->wmi.mem_chunks[i].paddr);
7623 }
7624
7625 ar->wmi.num_mem_chunks = 0;
7626}
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05307627
7628void ath10k_wmi_detach(struct ath10k *ar)
7629{
7630 cancel_work_sync(&ar->svc_rdy_work);
7631
7632 if (ar->svc_rdy_skb)
7633 dev_kfree_skb(ar->svc_rdy_skb);
7634}