blob: 651220e98c72841239072fd648f50890f1683972 [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
Tamizh chelvam3fab30f2015-10-29 14:27:37 +02001549static const struct wmi_peer_flags_map wmi_peer_flags_map = {
1550 .auth = WMI_PEER_AUTH,
1551 .qos = WMI_PEER_QOS,
1552 .need_ptk_4_way = WMI_PEER_NEED_PTK_4_WAY,
1553 .need_gtk_2_way = WMI_PEER_NEED_GTK_2_WAY,
1554 .apsd = WMI_PEER_APSD,
1555 .ht = WMI_PEER_HT,
1556 .bw40 = WMI_PEER_40MHZ,
1557 .stbc = WMI_PEER_STBC,
1558 .ldbc = WMI_PEER_LDPC,
1559 .dyn_mimops = WMI_PEER_DYN_MIMOPS,
1560 .static_mimops = WMI_PEER_STATIC_MIMOPS,
1561 .spatial_mux = WMI_PEER_SPATIAL_MUX,
1562 .vht = WMI_PEER_VHT,
1563 .bw80 = WMI_PEER_80MHZ,
1564 .vht_2g = WMI_PEER_VHT_2G,
1565 .pmf = WMI_PEER_PMF,
1566};
1567
1568static const struct wmi_peer_flags_map wmi_10x_peer_flags_map = {
1569 .auth = WMI_10X_PEER_AUTH,
1570 .qos = WMI_10X_PEER_QOS,
1571 .need_ptk_4_way = WMI_10X_PEER_NEED_PTK_4_WAY,
1572 .need_gtk_2_way = WMI_10X_PEER_NEED_GTK_2_WAY,
1573 .apsd = WMI_10X_PEER_APSD,
1574 .ht = WMI_10X_PEER_HT,
1575 .bw40 = WMI_10X_PEER_40MHZ,
1576 .stbc = WMI_10X_PEER_STBC,
1577 .ldbc = WMI_10X_PEER_LDPC,
1578 .dyn_mimops = WMI_10X_PEER_DYN_MIMOPS,
1579 .static_mimops = WMI_10X_PEER_STATIC_MIMOPS,
1580 .spatial_mux = WMI_10X_PEER_SPATIAL_MUX,
1581 .vht = WMI_10X_PEER_VHT,
1582 .bw80 = WMI_10X_PEER_80MHZ,
1583};
1584
1585static const struct wmi_peer_flags_map wmi_10_2_peer_flags_map = {
1586 .auth = WMI_10_2_PEER_AUTH,
1587 .qos = WMI_10_2_PEER_QOS,
1588 .need_ptk_4_way = WMI_10_2_PEER_NEED_PTK_4_WAY,
1589 .need_gtk_2_way = WMI_10_2_PEER_NEED_GTK_2_WAY,
1590 .apsd = WMI_10_2_PEER_APSD,
1591 .ht = WMI_10_2_PEER_HT,
1592 .bw40 = WMI_10_2_PEER_40MHZ,
1593 .stbc = WMI_10_2_PEER_STBC,
1594 .ldbc = WMI_10_2_PEER_LDPC,
1595 .dyn_mimops = WMI_10_2_PEER_DYN_MIMOPS,
1596 .static_mimops = WMI_10_2_PEER_STATIC_MIMOPS,
1597 .spatial_mux = WMI_10_2_PEER_SPATIAL_MUX,
1598 .vht = WMI_10_2_PEER_VHT,
1599 .bw80 = WMI_10_2_PEER_80MHZ,
1600 .vht_2g = WMI_10_2_PEER_VHT_2G,
1601 .pmf = WMI_10_2_PEER_PMF,
1602};
1603
Michal Kazior0226d602014-12-03 10:11:22 +02001604void ath10k_wmi_put_wmi_channel(struct wmi_channel *ch,
1605 const struct wmi_channel_arg *arg)
Michal Kazior2d667212014-09-18 15:21:21 +02001606{
1607 u32 flags = 0;
1608
1609 memset(ch, 0, sizeof(*ch));
1610
1611 if (arg->passive)
1612 flags |= WMI_CHAN_FLAG_PASSIVE;
1613 if (arg->allow_ibss)
1614 flags |= WMI_CHAN_FLAG_ADHOC_ALLOWED;
1615 if (arg->allow_ht)
1616 flags |= WMI_CHAN_FLAG_ALLOW_HT;
1617 if (arg->allow_vht)
1618 flags |= WMI_CHAN_FLAG_ALLOW_VHT;
1619 if (arg->ht40plus)
1620 flags |= WMI_CHAN_FLAG_HT40_PLUS;
1621 if (arg->chan_radar)
1622 flags |= WMI_CHAN_FLAG_DFS;
1623
1624 ch->mhz = __cpu_to_le32(arg->freq);
1625 ch->band_center_freq1 = __cpu_to_le32(arg->band_center_freq1);
1626 ch->band_center_freq2 = 0;
1627 ch->min_power = arg->min_power;
1628 ch->max_power = arg->max_power;
1629 ch->reg_power = arg->max_reg_power;
1630 ch->antenna_max = arg->max_antenna_gain;
1631
1632 /* mode & flags share storage */
1633 ch->mode = arg->mode;
1634 ch->flags |= __cpu_to_le32(flags);
1635}
1636
Kalle Valo5e3dd152013-06-12 20:52:10 +03001637int ath10k_wmi_wait_for_service_ready(struct ath10k *ar)
1638{
Nicholas Mc Guire9eea5682015-03-30 15:39:21 +03001639 unsigned long time_left;
Kalle Valoaf762c02014-09-14 12:50:17 +03001640
Nicholas Mc Guire9eea5682015-03-30 15:39:21 +03001641 time_left = wait_for_completion_timeout(&ar->wmi.service_ready,
1642 WMI_SERVICE_READY_TIMEOUT_HZ);
1643 if (!time_left)
1644 return -ETIMEDOUT;
1645 return 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001646}
1647
1648int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar)
1649{
Nicholas Mc Guire9eea5682015-03-30 15:39:21 +03001650 unsigned long time_left;
Kalle Valoaf762c02014-09-14 12:50:17 +03001651
Nicholas Mc Guire9eea5682015-03-30 15:39:21 +03001652 time_left = wait_for_completion_timeout(&ar->wmi.unified_ready,
1653 WMI_UNIFIED_READY_TIMEOUT_HZ);
1654 if (!time_left)
1655 return -ETIMEDOUT;
1656 return 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001657}
1658
Kalle Valo666a73f32014-09-10 18:23:23 +03001659struct sk_buff *ath10k_wmi_alloc_skb(struct ath10k *ar, u32 len)
Kalle Valo5e3dd152013-06-12 20:52:10 +03001660{
1661 struct sk_buff *skb;
1662 u32 round_len = roundup(len, 4);
1663
Michal Kazior7aa7a722014-08-25 12:09:38 +02001664 skb = ath10k_htc_alloc_skb(ar, WMI_SKB_HEADROOM + round_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001665 if (!skb)
1666 return NULL;
1667
1668 skb_reserve(skb, WMI_SKB_HEADROOM);
1669 if (!IS_ALIGNED((unsigned long)skb->data, 4))
Michal Kazior7aa7a722014-08-25 12:09:38 +02001670 ath10k_warn(ar, "Unaligned WMI skb\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03001671
1672 skb_put(skb, round_len);
1673 memset(skb->data, 0, round_len);
1674
1675 return skb;
1676}
1677
1678static void ath10k_wmi_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb)
1679{
1680 dev_kfree_skb(skb);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001681}
1682
Michal Kaziord7579d12014-12-03 10:10:54 +02001683int ath10k_wmi_cmd_send_nowait(struct ath10k *ar, struct sk_buff *skb,
1684 u32 cmd_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +03001685{
1686 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb);
1687 struct wmi_cmd_hdr *cmd_hdr;
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001688 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001689 u32 cmd = 0;
1690
1691 if (skb_push(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
1692 return -ENOMEM;
1693
1694 cmd |= SM(cmd_id, WMI_CMD_HDR_CMD_ID);
1695
1696 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
1697 cmd_hdr->cmd_id = __cpu_to_le32(cmd);
1698
Kalle Valo5e3dd152013-06-12 20:52:10 +03001699 memset(skb_cb, 0, sizeof(*skb_cb));
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001700 ret = ath10k_htc_send(&ar->htc, ar->wmi.eid, skb);
Michal Kaziord35a6c12014-09-02 11:00:21 +03001701 trace_ath10k_wmi_cmd(ar, cmd_id, skb->data, skb->len, ret);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001702
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001703 if (ret)
1704 goto err_pull;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001705
1706 return 0;
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001707
1708err_pull:
1709 skb_pull(skb, sizeof(struct wmi_cmd_hdr));
1710 return ret;
1711}
1712
Michal Kaziored543882013-09-13 14:16:56 +02001713static void ath10k_wmi_tx_beacon_nowait(struct ath10k_vif *arvif)
1714{
Michal Kazioraf213192015-01-29 14:29:52 +02001715 struct ath10k *ar = arvif->ar;
Michal Kazior9ad50182015-01-29 14:29:47 +02001716 struct ath10k_skb_cb *cb;
Michal Kazioraf213192015-01-29 14:29:52 +02001717 struct sk_buff *bcn;
Michal Kazior66b8a012015-11-18 06:59:20 +01001718 bool dtim_zero;
1719 bool deliver_cab;
Michal Kaziored543882013-09-13 14:16:56 +02001720 int ret;
1721
Michal Kazioraf213192015-01-29 14:29:52 +02001722 spin_lock_bh(&ar->data_lock);
Michal Kaziored543882013-09-13 14:16:56 +02001723
Michal Kazior9ad50182015-01-29 14:29:47 +02001724 bcn = arvif->beacon;
Michal Kaziored543882013-09-13 14:16:56 +02001725
Michal Kazioraf213192015-01-29 14:29:52 +02001726 if (!bcn)
1727 goto unlock;
Michal Kaziored543882013-09-13 14:16:56 +02001728
Michal Kazioraf213192015-01-29 14:29:52 +02001729 cb = ATH10K_SKB_CB(bcn);
Michal Kaziored543882013-09-13 14:16:56 +02001730
Michal Kazioraf213192015-01-29 14:29:52 +02001731 switch (arvif->beacon_state) {
1732 case ATH10K_BEACON_SENDING:
1733 case ATH10K_BEACON_SENT:
1734 break;
1735 case ATH10K_BEACON_SCHEDULED:
1736 arvif->beacon_state = ATH10K_BEACON_SENDING;
1737 spin_unlock_bh(&ar->data_lock);
1738
Michal Kazior66b8a012015-11-18 06:59:20 +01001739 dtim_zero = !!(cb->flags & ATH10K_SKB_F_DTIM_ZERO);
1740 deliver_cab = !!(cb->flags & ATH10K_SKB_F_DELIVER_CAB);
Michal Kazioraf213192015-01-29 14:29:52 +02001741 ret = ath10k_wmi_beacon_send_ref_nowait(arvif->ar,
1742 arvif->vdev_id,
1743 bcn->data, bcn->len,
1744 cb->paddr,
Michal Kazior66b8a012015-11-18 06:59:20 +01001745 dtim_zero,
1746 deliver_cab);
Michal Kazioraf213192015-01-29 14:29:52 +02001747
1748 spin_lock_bh(&ar->data_lock);
1749
1750 if (ret == 0)
1751 arvif->beacon_state = ATH10K_BEACON_SENT;
1752 else
1753 arvif->beacon_state = ATH10K_BEACON_SCHEDULED;
1754 }
1755
1756unlock:
1757 spin_unlock_bh(&ar->data_lock);
Michal Kaziored543882013-09-13 14:16:56 +02001758}
1759
1760static void ath10k_wmi_tx_beacons_iter(void *data, u8 *mac,
1761 struct ieee80211_vif *vif)
1762{
1763 struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif);
1764
1765 ath10k_wmi_tx_beacon_nowait(arvif);
1766}
1767
1768static void ath10k_wmi_tx_beacons_nowait(struct ath10k *ar)
1769{
Michal Kaziored543882013-09-13 14:16:56 +02001770 ieee80211_iterate_active_interfaces_atomic(ar->hw,
1771 IEEE80211_IFACE_ITER_NORMAL,
1772 ath10k_wmi_tx_beacons_iter,
1773 NULL);
Michal Kaziored543882013-09-13 14:16:56 +02001774}
1775
Michal Kazior12acbc42013-09-13 14:16:55 +02001776static void ath10k_wmi_op_ep_tx_credits(struct ath10k *ar)
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001777{
Michal Kaziored543882013-09-13 14:16:56 +02001778 /* try to send pending beacons first. they take priority */
1779 ath10k_wmi_tx_beacons_nowait(ar);
1780
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001781 wake_up(&ar->wmi.tx_credits_wq);
1782}
1783
Kalle Valo666a73f32014-09-10 18:23:23 +03001784int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id)
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001785{
Bartosz Markowski34957b22013-10-15 09:55:31 +02001786 int ret = -EOPNOTSUPP;
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001787
Kalle Valo56b84282013-10-16 15:44:47 +03001788 might_sleep();
1789
Bartosz Markowski34957b22013-10-15 09:55:31 +02001790 if (cmd_id == WMI_CMD_UNSUPPORTED) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02001791 ath10k_warn(ar, "wmi command %d is not supported by firmware\n",
Bartosz Markowski55321552013-09-26 17:47:07 +02001792 cmd_id);
1793 return ret;
1794 }
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001795
1796 wait_event_timeout(ar->wmi.tx_credits_wq, ({
Michal Kaziored543882013-09-13 14:16:56 +02001797 /* try to send pending beacons first. they take priority */
1798 ath10k_wmi_tx_beacons_nowait(ar);
1799
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001800 ret = ath10k_wmi_cmd_send_nowait(ar, skb, cmd_id);
Michal Kazior7962b0d2014-10-28 10:34:38 +01001801
1802 if (ret && test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags))
1803 ret = -ESHUTDOWN;
1804
Michal Kaziorbe8b3942013-09-13 14:16:54 +02001805 (ret != -EAGAIN);
1806 }), 3*HZ);
1807
1808 if (ret)
1809 dev_kfree_skb_any(skb);
1810
1811 return ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001812}
1813
Michal Kaziord7579d12014-12-03 10:10:54 +02001814static struct sk_buff *
1815ath10k_wmi_op_gen_mgmt_tx(struct ath10k *ar, struct sk_buff *msdu)
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001816{
Michal Kazior609db222015-11-18 06:59:22 +01001817 struct ath10k_skb_cb *cb = ATH10K_SKB_CB(msdu);
1818 struct ath10k_vif *arvif = (void *)cb->vif->drv_priv;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001819 struct wmi_mgmt_tx_cmd *cmd;
1820 struct ieee80211_hdr *hdr;
Michal Kaziord7579d12014-12-03 10:10:54 +02001821 struct sk_buff *skb;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001822 int len;
Michal Kazior609db222015-11-18 06:59:22 +01001823 u32 vdev_id;
Michal Kaziord7579d12014-12-03 10:10:54 +02001824 u32 buf_len = msdu->len;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001825 u16 fc;
1826
Michal Kaziord7579d12014-12-03 10:10:54 +02001827 hdr = (struct ieee80211_hdr *)msdu->data;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001828 fc = le16_to_cpu(hdr->frame_control);
1829
Michal Kazior609db222015-11-18 06:59:22 +01001830 if (cb->vif)
1831 vdev_id = arvif->vdev_id;
1832 else
1833 vdev_id = 0;
1834
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001835 if (WARN_ON_ONCE(!ieee80211_is_mgmt(hdr->frame_control)))
Michal Kaziord7579d12014-12-03 10:10:54 +02001836 return ERR_PTR(-EINVAL);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001837
Michal Kaziord7579d12014-12-03 10:10:54 +02001838 len = sizeof(cmd->hdr) + msdu->len;
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03001839
1840 if ((ieee80211_is_action(hdr->frame_control) ||
1841 ieee80211_is_deauth(hdr->frame_control) ||
1842 ieee80211_is_disassoc(hdr->frame_control)) &&
1843 ieee80211_has_protected(hdr->frame_control)) {
1844 len += IEEE80211_CCMP_MIC_LEN;
1845 buf_len += IEEE80211_CCMP_MIC_LEN;
1846 }
1847
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001848 len = round_up(len, 4);
1849
Michal Kaziord7579d12014-12-03 10:10:54 +02001850 skb = ath10k_wmi_alloc_skb(ar, len);
1851 if (!skb)
1852 return ERR_PTR(-ENOMEM);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001853
Michal Kaziord7579d12014-12-03 10:10:54 +02001854 cmd = (struct wmi_mgmt_tx_cmd *)skb->data;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001855
Michal Kazior609db222015-11-18 06:59:22 +01001856 cmd->hdr.vdev_id = __cpu_to_le32(vdev_id);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001857 cmd->hdr.tx_rate = 0;
1858 cmd->hdr.tx_power = 0;
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03001859 cmd->hdr.buf_len = __cpu_to_le32(buf_len);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001860
Kalle Valob25f32c2014-09-14 12:50:49 +03001861 ether_addr_copy(cmd->hdr.peer_macaddr.addr, ieee80211_get_DA(hdr));
Michal Kaziord7579d12014-12-03 10:10:54 +02001862 memcpy(cmd->buf, msdu->data, msdu->len);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001863
Michal Kazior7aa7a722014-08-25 12:09:38 +02001864 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 +02001865 msdu, skb->len, fc & IEEE80211_FCTL_FTYPE,
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001866 fc & IEEE80211_FCTL_STYPE);
Rajkumar Manoharan5ce8e7f2014-11-05 19:14:31 +05301867 trace_ath10k_tx_hdr(ar, skb->data, skb->len);
1868 trace_ath10k_tx_payload(ar, skb->data, skb->len);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001869
Michal Kaziord7579d12014-12-03 10:10:54 +02001870 return skb;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001871}
1872
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001873static void ath10k_wmi_event_scan_started(struct ath10k *ar)
1874{
1875 lockdep_assert_held(&ar->data_lock);
1876
1877 switch (ar->scan.state) {
1878 case ATH10K_SCAN_IDLE:
1879 case ATH10K_SCAN_RUNNING:
1880 case ATH10K_SCAN_ABORTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02001881 ath10k_warn(ar, "received scan started 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_STARTING:
1886 ar->scan.state = ATH10K_SCAN_RUNNING;
1887
1888 if (ar->scan.is_roc)
1889 ieee80211_ready_on_channel(ar->hw);
1890
1891 complete(&ar->scan.started);
1892 break;
1893 }
1894}
1895
Ben Greear2f9eec02015-02-15 16:50:38 +02001896static void ath10k_wmi_event_scan_start_failed(struct ath10k *ar)
1897{
1898 lockdep_assert_held(&ar->data_lock);
1899
1900 switch (ar->scan.state) {
1901 case ATH10K_SCAN_IDLE:
1902 case ATH10K_SCAN_RUNNING:
1903 case ATH10K_SCAN_ABORTING:
1904 ath10k_warn(ar, "received scan start failed event in an invalid scan state: %s (%d)\n",
1905 ath10k_scan_state_str(ar->scan.state),
1906 ar->scan.state);
1907 break;
1908 case ATH10K_SCAN_STARTING:
1909 complete(&ar->scan.started);
1910 __ath10k_scan_finish(ar);
1911 break;
1912 }
1913}
1914
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001915static void ath10k_wmi_event_scan_completed(struct ath10k *ar)
1916{
1917 lockdep_assert_held(&ar->data_lock);
1918
1919 switch (ar->scan.state) {
1920 case ATH10K_SCAN_IDLE:
1921 case ATH10K_SCAN_STARTING:
1922 /* One suspected reason scan can be completed while starting is
1923 * if firmware fails to deliver all scan events to the host,
1924 * e.g. when transport pipe is full. This has been observed
1925 * with spectral scan phyerr events starving wmi transport
1926 * pipe. In such case the "scan completed" event should be (and
1927 * is) ignored by the host as it may be just firmware's scan
1928 * state machine recovering.
1929 */
Michal Kazior7aa7a722014-08-25 12:09:38 +02001930 ath10k_warn(ar, "received scan completed event in an invalid scan state: %s (%d)\n",
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001931 ath10k_scan_state_str(ar->scan.state),
1932 ar->scan.state);
1933 break;
1934 case ATH10K_SCAN_RUNNING:
1935 case ATH10K_SCAN_ABORTING:
1936 __ath10k_scan_finish(ar);
1937 break;
1938 }
1939}
1940
1941static void ath10k_wmi_event_scan_bss_chan(struct ath10k *ar)
1942{
1943 lockdep_assert_held(&ar->data_lock);
1944
1945 switch (ar->scan.state) {
1946 case ATH10K_SCAN_IDLE:
1947 case ATH10K_SCAN_STARTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02001948 ath10k_warn(ar, "received scan bss chan event in an invalid scan state: %s (%d)\n",
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001949 ath10k_scan_state_str(ar->scan.state),
1950 ar->scan.state);
1951 break;
1952 case ATH10K_SCAN_RUNNING:
1953 case ATH10K_SCAN_ABORTING:
1954 ar->scan_channel = NULL;
1955 break;
1956 }
1957}
1958
1959static void ath10k_wmi_event_scan_foreign_chan(struct ath10k *ar, u32 freq)
1960{
1961 lockdep_assert_held(&ar->data_lock);
1962
1963 switch (ar->scan.state) {
1964 case ATH10K_SCAN_IDLE:
1965 case ATH10K_SCAN_STARTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02001966 ath10k_warn(ar, "received scan foreign chan event in an invalid scan state: %s (%d)\n",
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001967 ath10k_scan_state_str(ar->scan.state),
1968 ar->scan.state);
1969 break;
1970 case ATH10K_SCAN_RUNNING:
1971 case ATH10K_SCAN_ABORTING:
1972 ar->scan_channel = ieee80211_get_channel(ar->hw->wiphy, freq);
1973
1974 if (ar->scan.is_roc && ar->scan.roc_freq == freq)
1975 complete(&ar->scan.on_channel);
1976 break;
1977 }
1978}
1979
Michal Kazior9ff8b722014-08-05 14:54:43 +02001980static const char *
1981ath10k_wmi_event_scan_type_str(enum wmi_scan_event_type type,
1982 enum wmi_scan_completion_reason reason)
1983{
1984 switch (type) {
1985 case WMI_SCAN_EVENT_STARTED:
1986 return "started";
1987 case WMI_SCAN_EVENT_COMPLETED:
1988 switch (reason) {
1989 case WMI_SCAN_REASON_COMPLETED:
1990 return "completed";
1991 case WMI_SCAN_REASON_CANCELLED:
1992 return "completed [cancelled]";
1993 case WMI_SCAN_REASON_PREEMPTED:
1994 return "completed [preempted]";
1995 case WMI_SCAN_REASON_TIMEDOUT:
1996 return "completed [timedout]";
Raja Manib2297ba2015-06-22 20:22:23 +05301997 case WMI_SCAN_REASON_INTERNAL_FAILURE:
1998 return "completed [internal err]";
Michal Kazior9ff8b722014-08-05 14:54:43 +02001999 case WMI_SCAN_REASON_MAX:
2000 break;
2001 }
2002 return "completed [unknown]";
2003 case WMI_SCAN_EVENT_BSS_CHANNEL:
2004 return "bss channel";
2005 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
2006 return "foreign channel";
2007 case WMI_SCAN_EVENT_DEQUEUED:
2008 return "dequeued";
2009 case WMI_SCAN_EVENT_PREEMPTED:
2010 return "preempted";
2011 case WMI_SCAN_EVENT_START_FAILED:
2012 return "start failed";
Raja Manib2297ba2015-06-22 20:22:23 +05302013 case WMI_SCAN_EVENT_RESTARTED:
2014 return "restarted";
2015 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
2016 return "foreign channel exit";
Michal Kazior9ff8b722014-08-05 14:54:43 +02002017 default:
2018 return "unknown";
2019 }
2020}
2021
Michal Kaziord7579d12014-12-03 10:10:54 +02002022static int ath10k_wmi_op_pull_scan_ev(struct ath10k *ar, struct sk_buff *skb,
2023 struct wmi_scan_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02002024{
2025 struct wmi_scan_event *ev = (void *)skb->data;
2026
2027 if (skb->len < sizeof(*ev))
2028 return -EPROTO;
2029
2030 skb_pull(skb, sizeof(*ev));
2031 arg->event_type = ev->event_type;
2032 arg->reason = ev->reason;
2033 arg->channel_freq = ev->channel_freq;
2034 arg->scan_req_id = ev->scan_req_id;
2035 arg->scan_id = ev->scan_id;
2036 arg->vdev_id = ev->vdev_id;
2037
2038 return 0;
2039}
2040
Michal Kazior0226d602014-12-03 10:11:22 +02002041int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002042{
Michal Kazior32653cf2014-12-03 10:10:26 +02002043 struct wmi_scan_ev_arg arg = {};
Kalle Valo5e3dd152013-06-12 20:52:10 +03002044 enum wmi_scan_event_type event_type;
2045 enum wmi_scan_completion_reason reason;
2046 u32 freq;
2047 u32 req_id;
2048 u32 scan_id;
2049 u32 vdev_id;
Michal Kazior32653cf2014-12-03 10:10:26 +02002050 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002051
Michal Kaziord7579d12014-12-03 10:10:54 +02002052 ret = ath10k_wmi_pull_scan(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02002053 if (ret) {
2054 ath10k_warn(ar, "failed to parse scan event: %d\n", ret);
2055 return ret;
2056 }
2057
2058 event_type = __le32_to_cpu(arg.event_type);
2059 reason = __le32_to_cpu(arg.reason);
2060 freq = __le32_to_cpu(arg.channel_freq);
2061 req_id = __le32_to_cpu(arg.scan_req_id);
2062 scan_id = __le32_to_cpu(arg.scan_id);
2063 vdev_id = __le32_to_cpu(arg.vdev_id);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002064
Kalle Valo5e3dd152013-06-12 20:52:10 +03002065 spin_lock_bh(&ar->data_lock);
2066
Michal Kazior7aa7a722014-08-25 12:09:38 +02002067 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002068 "scan event %s type %d reason %d freq %d req_id %d scan_id %d vdev_id %d state %s (%d)\n",
2069 ath10k_wmi_event_scan_type_str(event_type, reason),
2070 event_type, reason, freq, req_id, scan_id, vdev_id,
2071 ath10k_scan_state_str(ar->scan.state), ar->scan.state);
2072
Kalle Valo5e3dd152013-06-12 20:52:10 +03002073 switch (event_type) {
2074 case WMI_SCAN_EVENT_STARTED:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002075 ath10k_wmi_event_scan_started(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002076 break;
2077 case WMI_SCAN_EVENT_COMPLETED:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002078 ath10k_wmi_event_scan_completed(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002079 break;
2080 case WMI_SCAN_EVENT_BSS_CHANNEL:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002081 ath10k_wmi_event_scan_bss_chan(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002082 break;
2083 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002084 ath10k_wmi_event_scan_foreign_chan(ar, freq);
2085 break;
2086 case WMI_SCAN_EVENT_START_FAILED:
Michal Kazior7aa7a722014-08-25 12:09:38 +02002087 ath10k_warn(ar, "received scan start failure event\n");
Ben Greear2f9eec02015-02-15 16:50:38 +02002088 ath10k_wmi_event_scan_start_failed(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002089 break;
2090 case WMI_SCAN_EVENT_DEQUEUED:
Kalle Valo5e3dd152013-06-12 20:52:10 +03002091 case WMI_SCAN_EVENT_PREEMPTED:
Raja Manib2297ba2015-06-22 20:22:23 +05302092 case WMI_SCAN_EVENT_RESTARTED:
2093 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Kalle Valo5e3dd152013-06-12 20:52:10 +03002094 default:
2095 break;
2096 }
2097
2098 spin_unlock_bh(&ar->data_lock);
2099 return 0;
2100}
2101
2102static inline enum ieee80211_band phy_mode_to_band(u32 phy_mode)
2103{
2104 enum ieee80211_band band;
2105
2106 switch (phy_mode) {
2107 case MODE_11A:
2108 case MODE_11NA_HT20:
2109 case MODE_11NA_HT40:
2110 case MODE_11AC_VHT20:
2111 case MODE_11AC_VHT40:
2112 case MODE_11AC_VHT80:
2113 band = IEEE80211_BAND_5GHZ;
2114 break;
2115 case MODE_11G:
2116 case MODE_11B:
2117 case MODE_11GONLY:
2118 case MODE_11NG_HT20:
2119 case MODE_11NG_HT40:
2120 case MODE_11AC_VHT20_2G:
2121 case MODE_11AC_VHT40_2G:
2122 case MODE_11AC_VHT80_2G:
2123 default:
2124 band = IEEE80211_BAND_2GHZ;
2125 }
2126
2127 return band;
2128}
2129
Sujith Manoharan504f6cd2014-11-25 11:46:58 +05302130/* If keys are configured, HW decrypts all frames
2131 * with protected bit set. Mark such frames as decrypted.
2132 */
2133static void ath10k_wmi_handle_wep_reauth(struct ath10k *ar,
2134 struct sk_buff *skb,
2135 struct ieee80211_rx_status *status)
2136{
2137 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2138 unsigned int hdrlen;
2139 bool peer_key;
2140 u8 *addr, keyidx;
2141
2142 if (!ieee80211_is_auth(hdr->frame_control) ||
2143 !ieee80211_has_protected(hdr->frame_control))
2144 return;
2145
2146 hdrlen = ieee80211_hdrlen(hdr->frame_control);
2147 if (skb->len < (hdrlen + IEEE80211_WEP_IV_LEN))
2148 return;
2149
2150 keyidx = skb->data[hdrlen + (IEEE80211_WEP_IV_LEN - 1)] >> WEP_KEYID_SHIFT;
2151 addr = ieee80211_get_SA(hdr);
2152
2153 spin_lock_bh(&ar->data_lock);
2154 peer_key = ath10k_mac_is_peer_wep_key_set(ar, addr, keyidx);
2155 spin_unlock_bh(&ar->data_lock);
2156
2157 if (peer_key) {
2158 ath10k_dbg(ar, ATH10K_DBG_MAC,
2159 "mac wep key present for peer %pM\n", addr);
2160 status->flag |= RX_FLAG_DECRYPTED;
2161 }
2162}
2163
Michal Kaziord7579d12014-12-03 10:10:54 +02002164static int ath10k_wmi_op_pull_mgmt_rx_ev(struct ath10k *ar, struct sk_buff *skb,
2165 struct wmi_mgmt_rx_ev_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002166{
Michal Kazior0d9b0432013-08-09 10:13:33 +02002167 struct wmi_mgmt_rx_event_v1 *ev_v1;
2168 struct wmi_mgmt_rx_event_v2 *ev_v2;
2169 struct wmi_mgmt_rx_hdr_v1 *ev_hdr;
Michal Kazior32653cf2014-12-03 10:10:26 +02002170 size_t pull_len;
2171 u32 msdu_len;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002172
Michal Kazior0d9b0432013-08-09 10:13:33 +02002173 if (test_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features)) {
2174 ev_v2 = (struct wmi_mgmt_rx_event_v2 *)skb->data;
2175 ev_hdr = &ev_v2->hdr.v1;
2176 pull_len = sizeof(*ev_v2);
2177 } else {
2178 ev_v1 = (struct wmi_mgmt_rx_event_v1 *)skb->data;
2179 ev_hdr = &ev_v1->hdr;
2180 pull_len = sizeof(*ev_v1);
2181 }
2182
Michal Kazior32653cf2014-12-03 10:10:26 +02002183 if (skb->len < pull_len)
2184 return -EPROTO;
2185
2186 skb_pull(skb, pull_len);
2187 arg->channel = ev_hdr->channel;
2188 arg->buf_len = ev_hdr->buf_len;
2189 arg->status = ev_hdr->status;
2190 arg->snr = ev_hdr->snr;
2191 arg->phy_mode = ev_hdr->phy_mode;
2192 arg->rate = ev_hdr->rate;
2193
2194 msdu_len = __le32_to_cpu(arg->buf_len);
2195 if (skb->len < msdu_len)
2196 return -EPROTO;
2197
2198 /* the WMI buffer might've ended up being padded to 4 bytes due to HTC
2199 * trailer with credit update. Trim the excess garbage.
2200 */
2201 skb_trim(skb, msdu_len);
2202
2203 return 0;
2204}
2205
Raja Mani1c092962015-06-22 20:10:16 +05302206static int ath10k_wmi_10_4_op_pull_mgmt_rx_ev(struct ath10k *ar,
2207 struct sk_buff *skb,
2208 struct wmi_mgmt_rx_ev_arg *arg)
2209{
2210 struct wmi_10_4_mgmt_rx_event *ev;
2211 struct wmi_10_4_mgmt_rx_hdr *ev_hdr;
2212 size_t pull_len;
2213 u32 msdu_len;
2214
2215 ev = (struct wmi_10_4_mgmt_rx_event *)skb->data;
2216 ev_hdr = &ev->hdr;
2217 pull_len = sizeof(*ev);
2218
2219 if (skb->len < pull_len)
2220 return -EPROTO;
2221
2222 skb_pull(skb, pull_len);
2223 arg->channel = ev_hdr->channel;
2224 arg->buf_len = ev_hdr->buf_len;
2225 arg->status = ev_hdr->status;
2226 arg->snr = ev_hdr->snr;
2227 arg->phy_mode = ev_hdr->phy_mode;
2228 arg->rate = ev_hdr->rate;
2229
2230 msdu_len = __le32_to_cpu(arg->buf_len);
2231 if (skb->len < msdu_len)
2232 return -EPROTO;
2233
2234 /* Make sure bytes added for padding are removed. */
2235 skb_trim(skb, msdu_len);
2236
2237 return 0;
2238}
2239
Michal Kazior0226d602014-12-03 10:11:22 +02002240int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
Michal Kazior32653cf2014-12-03 10:10:26 +02002241{
2242 struct wmi_mgmt_rx_ev_arg arg = {};
2243 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
2244 struct ieee80211_hdr *hdr;
Michal Kazior01cebe12015-03-30 09:51:56 +03002245 struct ieee80211_supported_band *sband;
Michal Kazior32653cf2014-12-03 10:10:26 +02002246 u32 rx_status;
2247 u32 channel;
2248 u32 phy_mode;
2249 u32 snr;
2250 u32 rate;
2251 u32 buf_len;
2252 u16 fc;
2253 int ret;
2254
Michal Kaziord7579d12014-12-03 10:10:54 +02002255 ret = ath10k_wmi_pull_mgmt_rx(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02002256 if (ret) {
2257 ath10k_warn(ar, "failed to parse mgmt rx event: %d\n", ret);
Raja Mani08603f22015-06-01 14:53:33 +05302258 dev_kfree_skb(skb);
Michal Kazior32653cf2014-12-03 10:10:26 +02002259 return ret;
2260 }
2261
2262 channel = __le32_to_cpu(arg.channel);
2263 buf_len = __le32_to_cpu(arg.buf_len);
2264 rx_status = __le32_to_cpu(arg.status);
2265 snr = __le32_to_cpu(arg.snr);
2266 phy_mode = __le32_to_cpu(arg.phy_mode);
2267 rate = __le32_to_cpu(arg.rate);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002268
2269 memset(status, 0, sizeof(*status));
2270
Michal Kazior7aa7a722014-08-25 12:09:38 +02002271 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo5e3dd152013-06-12 20:52:10 +03002272 "event mgmt rx status %08x\n", rx_status);
2273
Manikanta Pubbisetty2c9bcec2015-10-20 12:11:40 +05302274 if ((test_bit(ATH10K_CAC_RUNNING, &ar->dev_flags)) ||
2275 (rx_status & (WMI_RX_STATUS_ERR_DECRYPT |
2276 WMI_RX_STATUS_ERR_KEY_CACHE_MISS | WMI_RX_STATUS_ERR_CRC))) {
Michal Kaziord67d0a02014-11-24 15:34:08 +01002277 dev_kfree_skb(skb);
2278 return 0;
2279 }
2280
Kalle Valo5e3dd152013-06-12 20:52:10 +03002281 if (rx_status & WMI_RX_STATUS_ERR_MIC)
2282 status->flag |= RX_FLAG_MMIC_ERROR;
2283
Michal Kazior21040bf2014-10-21 10:10:30 +03002284 /* Hardware can Rx CCK rates on 5GHz. In that case phy_mode is set to
Michal Kazior453cdb62013-12-13 10:44:43 +01002285 * MODE_11B. This means phy_mode is not a reliable source for the band
Michal Kazior21040bf2014-10-21 10:10:30 +03002286 * of mgmt rx.
2287 */
2288 if (channel >= 1 && channel <= 14) {
2289 status->band = IEEE80211_BAND_2GHZ;
2290 } else if (channel >= 36 && channel <= 165) {
2291 status->band = IEEE80211_BAND_5GHZ;
Michal Kazior453cdb62013-12-13 10:44:43 +01002292 } else {
Michal Kazior21040bf2014-10-21 10:10:30 +03002293 /* Shouldn't happen unless list of advertised channels to
2294 * mac80211 has been changed.
2295 */
2296 WARN_ON_ONCE(1);
2297 dev_kfree_skb(skb);
2298 return 0;
Michal Kazior453cdb62013-12-13 10:44:43 +01002299 }
2300
Michal Kazior21040bf2014-10-21 10:10:30 +03002301 if (phy_mode == MODE_11B && status->band == IEEE80211_BAND_5GHZ)
2302 ath10k_dbg(ar, ATH10K_DBG_MGMT, "wmi mgmt rx 11b (CCK) on 5GHz\n");
2303
Michal Kazior01cebe12015-03-30 09:51:56 +03002304 sband = &ar->mac.sbands[status->band];
2305
Kalle Valo5e3dd152013-06-12 20:52:10 +03002306 status->freq = ieee80211_channel_to_frequency(channel, status->band);
2307 status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR;
Michal Kazior01cebe12015-03-30 09:51:56 +03002308 status->rate_idx = ath10k_mac_bitrate_to_idx(sband, rate / 100);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002309
Kalle Valo5e3dd152013-06-12 20:52:10 +03002310 hdr = (struct ieee80211_hdr *)skb->data;
2311 fc = le16_to_cpu(hdr->frame_control);
2312
Grzegorz Bajorski60549ca2015-11-30 13:56:59 +01002313 /* Firmware is guaranteed to report all essential management frames via
2314 * WMI while it can deliver some extra via HTT. Since there can be
2315 * duplicates split the reporting wrt monitor/sniffing.
2316 */
2317 status->flag |= RX_FLAG_SKIP_MONITOR;
2318
Sujith Manoharan504f6cd2014-11-25 11:46:58 +05302319 ath10k_wmi_handle_wep_reauth(ar, skb, status);
2320
Michal Kazior2b6a6a92013-12-05 06:53:41 +01002321 /* FW delivers WEP Shared Auth frame with Protected Bit set and
2322 * encrypted payload. However in case of PMF it delivers decrypted
2323 * frames with Protected Bit set. */
2324 if (ieee80211_has_protected(hdr->frame_control) &&
2325 !ieee80211_is_auth(hdr->frame_control)) {
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03002326 status->flag |= RX_FLAG_DECRYPTED;
2327
2328 if (!ieee80211_is_action(hdr->frame_control) &&
2329 !ieee80211_is_deauth(hdr->frame_control) &&
2330 !ieee80211_is_disassoc(hdr->frame_control)) {
2331 status->flag |= RX_FLAG_IV_STRIPPED |
2332 RX_FLAG_MMIC_STRIPPED;
2333 hdr->frame_control = __cpu_to_le16(fc &
Kalle Valo5e3dd152013-06-12 20:52:10 +03002334 ~IEEE80211_FCTL_PROTECTED);
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03002335 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03002336 }
2337
Michal Kaziorcc9904e2015-03-10 16:22:01 +02002338 if (ieee80211_is_beacon(hdr->frame_control))
2339 ath10k_mac_handle_beacon(ar, skb);
2340
Michal Kazior7aa7a722014-08-25 12:09:38 +02002341 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo5e3dd152013-06-12 20:52:10 +03002342 "event mgmt rx skb %p len %d ftype %02x stype %02x\n",
2343 skb, skb->len,
2344 fc & IEEE80211_FCTL_FTYPE, fc & IEEE80211_FCTL_STYPE);
2345
Michal Kazior7aa7a722014-08-25 12:09:38 +02002346 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo5e3dd152013-06-12 20:52:10 +03002347 "event mgmt rx freq %d band %d snr %d, rate_idx %d\n",
2348 status->freq, status->band, status->signal,
2349 status->rate_idx);
2350
Kalle Valo5e3dd152013-06-12 20:52:10 +03002351 ieee80211_rx(ar->hw, skb);
2352 return 0;
2353}
2354
Michal Kazior2e1dea42013-07-31 10:32:40 +02002355static int freq_to_idx(struct ath10k *ar, int freq)
2356{
2357 struct ieee80211_supported_band *sband;
2358 int band, ch, idx = 0;
2359
2360 for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) {
2361 sband = ar->hw->wiphy->bands[band];
2362 if (!sband)
2363 continue;
2364
2365 for (ch = 0; ch < sband->n_channels; ch++, idx++)
2366 if (sband->channels[ch].center_freq == freq)
2367 goto exit;
2368 }
2369
2370exit:
2371 return idx;
2372}
2373
Michal Kaziord7579d12014-12-03 10:10:54 +02002374static int ath10k_wmi_op_pull_ch_info_ev(struct ath10k *ar, struct sk_buff *skb,
2375 struct wmi_ch_info_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02002376{
2377 struct wmi_chan_info_event *ev = (void *)skb->data;
2378
2379 if (skb->len < sizeof(*ev))
2380 return -EPROTO;
2381
2382 skb_pull(skb, sizeof(*ev));
2383 arg->err_code = ev->err_code;
2384 arg->freq = ev->freq;
2385 arg->cmd_flags = ev->cmd_flags;
2386 arg->noise_floor = ev->noise_floor;
2387 arg->rx_clear_count = ev->rx_clear_count;
2388 arg->cycle_count = ev->cycle_count;
2389
2390 return 0;
2391}
2392
Raja Manib2297ba2015-06-22 20:22:23 +05302393static int ath10k_wmi_10_4_op_pull_ch_info_ev(struct ath10k *ar,
2394 struct sk_buff *skb,
2395 struct wmi_ch_info_ev_arg *arg)
2396{
2397 struct wmi_10_4_chan_info_event *ev = (void *)skb->data;
2398
2399 if (skb->len < sizeof(*ev))
2400 return -EPROTO;
2401
2402 skb_pull(skb, sizeof(*ev));
2403 arg->err_code = ev->err_code;
2404 arg->freq = ev->freq;
2405 arg->cmd_flags = ev->cmd_flags;
2406 arg->noise_floor = ev->noise_floor;
2407 arg->rx_clear_count = ev->rx_clear_count;
2408 arg->cycle_count = ev->cycle_count;
2409 arg->chan_tx_pwr_range = ev->chan_tx_pwr_range;
2410 arg->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
2411 arg->rx_frame_count = ev->rx_frame_count;
2412
2413 return 0;
2414}
2415
Michal Kazior0226d602014-12-03 10:11:22 +02002416void ath10k_wmi_event_chan_info(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002417{
Michal Kazior32653cf2014-12-03 10:10:26 +02002418 struct wmi_ch_info_ev_arg arg = {};
Michal Kazior2e1dea42013-07-31 10:32:40 +02002419 struct survey_info *survey;
2420 u32 err_code, freq, cmd_flags, noise_floor, rx_clear_count, cycle_count;
Michal Kazior32653cf2014-12-03 10:10:26 +02002421 int idx, ret;
Michal Kazior2e1dea42013-07-31 10:32:40 +02002422
Michal Kaziord7579d12014-12-03 10:10:54 +02002423 ret = ath10k_wmi_pull_ch_info(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02002424 if (ret) {
2425 ath10k_warn(ar, "failed to parse chan info event: %d\n", ret);
2426 return;
2427 }
Michal Kazior2e1dea42013-07-31 10:32:40 +02002428
Michal Kazior32653cf2014-12-03 10:10:26 +02002429 err_code = __le32_to_cpu(arg.err_code);
2430 freq = __le32_to_cpu(arg.freq);
2431 cmd_flags = __le32_to_cpu(arg.cmd_flags);
2432 noise_floor = __le32_to_cpu(arg.noise_floor);
2433 rx_clear_count = __le32_to_cpu(arg.rx_clear_count);
2434 cycle_count = __le32_to_cpu(arg.cycle_count);
Michal Kazior2e1dea42013-07-31 10:32:40 +02002435
Michal Kazior7aa7a722014-08-25 12:09:38 +02002436 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior2e1dea42013-07-31 10:32:40 +02002437 "chan info err_code %d freq %d cmd_flags %d noise_floor %d rx_clear_count %d cycle_count %d\n",
2438 err_code, freq, cmd_flags, noise_floor, rx_clear_count,
2439 cycle_count);
2440
2441 spin_lock_bh(&ar->data_lock);
2442
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002443 switch (ar->scan.state) {
2444 case ATH10K_SCAN_IDLE:
2445 case ATH10K_SCAN_STARTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02002446 ath10k_warn(ar, "received chan info event without a scan request, ignoring\n");
Michal Kazior2e1dea42013-07-31 10:32:40 +02002447 goto exit;
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002448 case ATH10K_SCAN_RUNNING:
2449 case ATH10K_SCAN_ABORTING:
2450 break;
Michal Kazior2e1dea42013-07-31 10:32:40 +02002451 }
2452
2453 idx = freq_to_idx(ar, freq);
2454 if (idx >= ARRAY_SIZE(ar->survey)) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002455 ath10k_warn(ar, "chan info: invalid frequency %d (idx %d out of bounds)\n",
Michal Kazior2e1dea42013-07-31 10:32:40 +02002456 freq, idx);
2457 goto exit;
2458 }
2459
2460 if (cmd_flags & WMI_CHAN_INFO_FLAG_COMPLETE) {
Michal Kazior44b7d482015-05-25 14:06:19 +02002461 if (ar->ch_info_can_report_survey) {
2462 survey = &ar->survey[idx];
2463 survey->noise = noise_floor;
2464 survey->filled = SURVEY_INFO_NOISE_DBM;
Michal Kazior2e1dea42013-07-31 10:32:40 +02002465
Michal Kazior44b7d482015-05-25 14:06:19 +02002466 ath10k_hw_fill_survey_time(ar,
2467 survey,
2468 cycle_count,
2469 rx_clear_count,
2470 ar->survey_last_cycle_count,
2471 ar->survey_last_rx_clear_count);
2472 }
Michal Kazior587f7032015-05-25 14:06:18 +02002473
Michal Kazior44b7d482015-05-25 14:06:19 +02002474 ar->ch_info_can_report_survey = false;
2475 } else {
2476 ar->ch_info_can_report_survey = true;
Michal Kazior2e1dea42013-07-31 10:32:40 +02002477 }
2478
Vasanthakumar Thiagarajan3d2a2e22015-08-12 16:24:04 +05302479 if (!(cmd_flags & WMI_CHAN_INFO_FLAG_PRE_COMPLETE)) {
2480 ar->survey_last_rx_clear_count = rx_clear_count;
2481 ar->survey_last_cycle_count = cycle_count;
2482 }
Michal Kazior2e1dea42013-07-31 10:32:40 +02002483
2484exit:
2485 spin_unlock_bh(&ar->data_lock);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002486}
2487
Michal Kazior0226d602014-12-03 10:11:22 +02002488void ath10k_wmi_event_echo(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002489{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002490 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_ECHO_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002491}
2492
Michal Kazior0226d602014-12-03 10:11:22 +02002493int ath10k_wmi_event_debug_mesg(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002494{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002495 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event debug mesg len %d\n",
Kalle Valo869526b2014-01-03 12:59:26 +02002496 skb->len);
2497
Michal Kaziord35a6c12014-09-02 11:00:21 +03002498 trace_ath10k_wmi_dbglog(ar, skb->data, skb->len);
Kalle Valo869526b2014-01-03 12:59:26 +02002499
2500 return 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002501}
2502
Michal Kaziorb91251f2015-01-24 12:14:49 +02002503void ath10k_wmi_pull_pdev_stats_base(const struct wmi_pdev_stats_base *src,
2504 struct ath10k_fw_stats_pdev *dst)
Michal Kaziord15fb522014-09-25 12:33:47 +02002505{
Michal Kaziord15fb522014-09-25 12:33:47 +02002506 dst->ch_noise_floor = __le32_to_cpu(src->chan_nf);
2507 dst->tx_frame_count = __le32_to_cpu(src->tx_frame_count);
2508 dst->rx_frame_count = __le32_to_cpu(src->rx_frame_count);
2509 dst->rx_clear_count = __le32_to_cpu(src->rx_clear_count);
2510 dst->cycle_count = __le32_to_cpu(src->cycle_count);
2511 dst->phy_err_count = __le32_to_cpu(src->phy_err_count);
2512 dst->chan_tx_power = __le32_to_cpu(src->chan_tx_pwr);
Michal Kaziorb91251f2015-01-24 12:14:49 +02002513}
Michal Kaziord15fb522014-09-25 12:33:47 +02002514
Michal Kaziorb91251f2015-01-24 12:14:49 +02002515void ath10k_wmi_pull_pdev_stats_tx(const struct wmi_pdev_stats_tx *src,
2516 struct ath10k_fw_stats_pdev *dst)
2517{
2518 dst->comp_queued = __le32_to_cpu(src->comp_queued);
2519 dst->comp_delivered = __le32_to_cpu(src->comp_delivered);
2520 dst->msdu_enqued = __le32_to_cpu(src->msdu_enqued);
2521 dst->mpdu_enqued = __le32_to_cpu(src->mpdu_enqued);
2522 dst->wmm_drop = __le32_to_cpu(src->wmm_drop);
2523 dst->local_enqued = __le32_to_cpu(src->local_enqued);
2524 dst->local_freed = __le32_to_cpu(src->local_freed);
2525 dst->hw_queued = __le32_to_cpu(src->hw_queued);
2526 dst->hw_reaped = __le32_to_cpu(src->hw_reaped);
2527 dst->underrun = __le32_to_cpu(src->underrun);
2528 dst->tx_abort = __le32_to_cpu(src->tx_abort);
2529 dst->mpdus_requed = __le32_to_cpu(src->mpdus_requed);
2530 dst->tx_ko = __le32_to_cpu(src->tx_ko);
2531 dst->data_rc = __le32_to_cpu(src->data_rc);
2532 dst->self_triggers = __le32_to_cpu(src->self_triggers);
2533 dst->sw_retry_failure = __le32_to_cpu(src->sw_retry_failure);
2534 dst->illgl_rate_phy_err = __le32_to_cpu(src->illgl_rate_phy_err);
2535 dst->pdev_cont_xretry = __le32_to_cpu(src->pdev_cont_xretry);
2536 dst->pdev_tx_timeout = __le32_to_cpu(src->pdev_tx_timeout);
2537 dst->pdev_resets = __le32_to_cpu(src->pdev_resets);
2538 dst->phy_underrun = __le32_to_cpu(src->phy_underrun);
2539 dst->txop_ovf = __le32_to_cpu(src->txop_ovf);
2540}
Michal Kaziord15fb522014-09-25 12:33:47 +02002541
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02002542static void
2543ath10k_wmi_10_4_pull_pdev_stats_tx(const struct wmi_10_4_pdev_stats_tx *src,
2544 struct ath10k_fw_stats_pdev *dst)
2545{
2546 dst->comp_queued = __le32_to_cpu(src->comp_queued);
2547 dst->comp_delivered = __le32_to_cpu(src->comp_delivered);
2548 dst->msdu_enqued = __le32_to_cpu(src->msdu_enqued);
2549 dst->mpdu_enqued = __le32_to_cpu(src->mpdu_enqued);
2550 dst->wmm_drop = __le32_to_cpu(src->wmm_drop);
2551 dst->local_enqued = __le32_to_cpu(src->local_enqued);
2552 dst->local_freed = __le32_to_cpu(src->local_freed);
2553 dst->hw_queued = __le32_to_cpu(src->hw_queued);
2554 dst->hw_reaped = __le32_to_cpu(src->hw_reaped);
2555 dst->underrun = __le32_to_cpu(src->underrun);
2556 dst->tx_abort = __le32_to_cpu(src->tx_abort);
2557 dst->mpdus_requed = __le32_to_cpu(src->mpdus_requed);
2558 dst->tx_ko = __le32_to_cpu(src->tx_ko);
2559 dst->data_rc = __le32_to_cpu(src->data_rc);
2560 dst->self_triggers = __le32_to_cpu(src->self_triggers);
2561 dst->sw_retry_failure = __le32_to_cpu(src->sw_retry_failure);
2562 dst->illgl_rate_phy_err = __le32_to_cpu(src->illgl_rate_phy_err);
2563 dst->pdev_cont_xretry = __le32_to_cpu(src->pdev_cont_xretry);
2564 dst->pdev_tx_timeout = __le32_to_cpu(src->pdev_tx_timeout);
2565 dst->pdev_resets = __le32_to_cpu(src->pdev_resets);
2566 dst->phy_underrun = __le32_to_cpu(src->phy_underrun);
2567 dst->txop_ovf = __le32_to_cpu(src->txop_ovf);
2568 dst->hw_paused = __le32_to_cpu(src->hw_paused);
2569 dst->seq_posted = __le32_to_cpu(src->seq_posted);
2570 dst->seq_failed_queueing =
2571 __le32_to_cpu(src->seq_failed_queueing);
2572 dst->seq_completed = __le32_to_cpu(src->seq_completed);
2573 dst->seq_restarted = __le32_to_cpu(src->seq_restarted);
2574 dst->mu_seq_posted = __le32_to_cpu(src->mu_seq_posted);
2575 dst->mpdus_sw_flush = __le32_to_cpu(src->mpdus_sw_flush);
2576 dst->mpdus_hw_filter = __le32_to_cpu(src->mpdus_hw_filter);
2577 dst->mpdus_truncated = __le32_to_cpu(src->mpdus_truncated);
2578 dst->mpdus_ack_failed = __le32_to_cpu(src->mpdus_ack_failed);
2579 dst->mpdus_hw_filter = __le32_to_cpu(src->mpdus_hw_filter);
2580 dst->mpdus_expired = __le32_to_cpu(src->mpdus_expired);
2581}
2582
Michal Kaziorb91251f2015-01-24 12:14:49 +02002583void ath10k_wmi_pull_pdev_stats_rx(const struct wmi_pdev_stats_rx *src,
2584 struct ath10k_fw_stats_pdev *dst)
2585{
2586 dst->mid_ppdu_route_change = __le32_to_cpu(src->mid_ppdu_route_change);
2587 dst->status_rcvd = __le32_to_cpu(src->status_rcvd);
2588 dst->r0_frags = __le32_to_cpu(src->r0_frags);
2589 dst->r1_frags = __le32_to_cpu(src->r1_frags);
2590 dst->r2_frags = __le32_to_cpu(src->r2_frags);
2591 dst->r3_frags = __le32_to_cpu(src->r3_frags);
2592 dst->htt_msdus = __le32_to_cpu(src->htt_msdus);
2593 dst->htt_mpdus = __le32_to_cpu(src->htt_mpdus);
2594 dst->loc_msdus = __le32_to_cpu(src->loc_msdus);
2595 dst->loc_mpdus = __le32_to_cpu(src->loc_mpdus);
2596 dst->oversize_amsdu = __le32_to_cpu(src->oversize_amsdu);
2597 dst->phy_errs = __le32_to_cpu(src->phy_errs);
2598 dst->phy_err_drop = __le32_to_cpu(src->phy_err_drop);
2599 dst->mpdu_errs = __le32_to_cpu(src->mpdu_errs);
2600}
2601
2602void ath10k_wmi_pull_pdev_stats_extra(const struct wmi_pdev_stats_extra *src,
2603 struct ath10k_fw_stats_pdev *dst)
2604{
2605 dst->ack_rx_bad = __le32_to_cpu(src->ack_rx_bad);
2606 dst->rts_bad = __le32_to_cpu(src->rts_bad);
2607 dst->rts_good = __le32_to_cpu(src->rts_good);
2608 dst->fcs_bad = __le32_to_cpu(src->fcs_bad);
2609 dst->no_beacons = __le32_to_cpu(src->no_beacons);
2610 dst->mib_int_count = __le32_to_cpu(src->mib_int_count);
Michal Kaziord15fb522014-09-25 12:33:47 +02002611}
2612
Michal Kazior0226d602014-12-03 10:11:22 +02002613void ath10k_wmi_pull_peer_stats(const struct wmi_peer_stats *src,
2614 struct ath10k_fw_stats_peer *dst)
Michal Kaziord15fb522014-09-25 12:33:47 +02002615{
2616 ether_addr_copy(dst->peer_macaddr, src->peer_macaddr.addr);
2617 dst->peer_rssi = __le32_to_cpu(src->peer_rssi);
2618 dst->peer_tx_rate = __le32_to_cpu(src->peer_tx_rate);
2619}
2620
Michal Kaziord7579d12014-12-03 10:10:54 +02002621static int ath10k_wmi_main_op_pull_fw_stats(struct ath10k *ar,
2622 struct sk_buff *skb,
2623 struct ath10k_fw_stats *stats)
Michal Kaziord15fb522014-09-25 12:33:47 +02002624{
2625 const struct wmi_stats_event *ev = (void *)skb->data;
2626 u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
2627 int i;
2628
2629 if (!skb_pull(skb, sizeof(*ev)))
2630 return -EPROTO;
2631
2632 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2633 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2634 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2635
Michal Kazior53268492014-09-25 12:33:50 +02002636 for (i = 0; i < num_pdev_stats; i++) {
Michal Kaziord15fb522014-09-25 12:33:47 +02002637 const struct wmi_pdev_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02002638 struct ath10k_fw_stats_pdev *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02002639
2640 src = (void *)skb->data;
2641 if (!skb_pull(skb, sizeof(*src)))
2642 return -EPROTO;
2643
Michal Kazior53268492014-09-25 12:33:50 +02002644 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2645 if (!dst)
2646 continue;
2647
Michal Kaziorb91251f2015-01-24 12:14:49 +02002648 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2649 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2650 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2651
Michal Kazior53268492014-09-25 12:33:50 +02002652 list_add_tail(&dst->list, &stats->pdevs);
Michal Kaziord15fb522014-09-25 12:33:47 +02002653 }
2654
2655 /* fw doesn't implement vdev stats */
2656
2657 for (i = 0; i < num_peer_stats; i++) {
2658 const struct wmi_peer_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02002659 struct ath10k_fw_stats_peer *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02002660
2661 src = (void *)skb->data;
2662 if (!skb_pull(skb, sizeof(*src)))
2663 return -EPROTO;
2664
Michal Kazior53268492014-09-25 12:33:50 +02002665 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2666 if (!dst)
2667 continue;
2668
2669 ath10k_wmi_pull_peer_stats(src, dst);
2670 list_add_tail(&dst->list, &stats->peers);
Michal Kaziord15fb522014-09-25 12:33:47 +02002671 }
2672
2673 return 0;
2674}
2675
Michal Kaziord7579d12014-12-03 10:10:54 +02002676static int ath10k_wmi_10x_op_pull_fw_stats(struct ath10k *ar,
2677 struct sk_buff *skb,
2678 struct ath10k_fw_stats *stats)
Michal Kaziord15fb522014-09-25 12:33:47 +02002679{
2680 const struct wmi_stats_event *ev = (void *)skb->data;
2681 u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
2682 int i;
2683
2684 if (!skb_pull(skb, sizeof(*ev)))
2685 return -EPROTO;
2686
2687 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2688 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2689 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2690
Michal Kazior53268492014-09-25 12:33:50 +02002691 for (i = 0; i < num_pdev_stats; i++) {
Michal Kaziord15fb522014-09-25 12:33:47 +02002692 const struct wmi_10x_pdev_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02002693 struct ath10k_fw_stats_pdev *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02002694
2695 src = (void *)skb->data;
2696 if (!skb_pull(skb, sizeof(*src)))
2697 return -EPROTO;
2698
Michal Kazior53268492014-09-25 12:33:50 +02002699 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2700 if (!dst)
2701 continue;
Michal Kaziord15fb522014-09-25 12:33:47 +02002702
Michal Kaziorb91251f2015-01-24 12:14:49 +02002703 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2704 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2705 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2706 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
Michal Kazior53268492014-09-25 12:33:50 +02002707
2708 list_add_tail(&dst->list, &stats->pdevs);
Michal Kaziord15fb522014-09-25 12:33:47 +02002709 }
2710
2711 /* fw doesn't implement vdev stats */
2712
2713 for (i = 0; i < num_peer_stats; i++) {
2714 const struct wmi_10x_peer_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02002715 struct ath10k_fw_stats_peer *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02002716
2717 src = (void *)skb->data;
2718 if (!skb_pull(skb, sizeof(*src)))
2719 return -EPROTO;
2720
Michal Kazior53268492014-09-25 12:33:50 +02002721 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2722 if (!dst)
2723 continue;
Michal Kaziord15fb522014-09-25 12:33:47 +02002724
Michal Kazior53268492014-09-25 12:33:50 +02002725 ath10k_wmi_pull_peer_stats(&src->old, dst);
2726
2727 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
2728
2729 list_add_tail(&dst->list, &stats->peers);
Michal Kaziord15fb522014-09-25 12:33:47 +02002730 }
2731
2732 return 0;
2733}
2734
Michal Kazior20de2222015-01-24 12:14:49 +02002735static int ath10k_wmi_10_2_op_pull_fw_stats(struct ath10k *ar,
2736 struct sk_buff *skb,
2737 struct ath10k_fw_stats *stats)
2738{
2739 const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2740 u32 num_pdev_stats;
2741 u32 num_pdev_ext_stats;
2742 u32 num_vdev_stats;
2743 u32 num_peer_stats;
2744 int i;
2745
2746 if (!skb_pull(skb, sizeof(*ev)))
2747 return -EPROTO;
2748
2749 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2750 num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
2751 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2752 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2753
2754 for (i = 0; i < num_pdev_stats; i++) {
2755 const struct wmi_10_2_pdev_stats *src;
2756 struct ath10k_fw_stats_pdev *dst;
2757
2758 src = (void *)skb->data;
2759 if (!skb_pull(skb, sizeof(*src)))
2760 return -EPROTO;
2761
2762 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2763 if (!dst)
2764 continue;
2765
2766 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2767 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2768 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2769 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2770 /* FIXME: expose 10.2 specific values */
2771
2772 list_add_tail(&dst->list, &stats->pdevs);
2773 }
2774
2775 for (i = 0; i < num_pdev_ext_stats; i++) {
2776 const struct wmi_10_2_pdev_ext_stats *src;
2777
2778 src = (void *)skb->data;
2779 if (!skb_pull(skb, sizeof(*src)))
2780 return -EPROTO;
2781
2782 /* FIXME: expose values to userspace
2783 *
2784 * Note: Even though this loop seems to do nothing it is
2785 * required to parse following sub-structures properly.
2786 */
2787 }
2788
2789 /* fw doesn't implement vdev stats */
2790
2791 for (i = 0; i < num_peer_stats; i++) {
2792 const struct wmi_10_2_peer_stats *src;
2793 struct ath10k_fw_stats_peer *dst;
2794
2795 src = (void *)skb->data;
2796 if (!skb_pull(skb, sizeof(*src)))
2797 return -EPROTO;
2798
2799 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2800 if (!dst)
2801 continue;
2802
2803 ath10k_wmi_pull_peer_stats(&src->old, dst);
2804
2805 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
2806 /* FIXME: expose 10.2 specific values */
2807
2808 list_add_tail(&dst->list, &stats->peers);
2809 }
2810
2811 return 0;
2812}
2813
2814static int ath10k_wmi_10_2_4_op_pull_fw_stats(struct ath10k *ar,
2815 struct sk_buff *skb,
2816 struct ath10k_fw_stats *stats)
2817{
2818 const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2819 u32 num_pdev_stats;
2820 u32 num_pdev_ext_stats;
2821 u32 num_vdev_stats;
2822 u32 num_peer_stats;
2823 int i;
2824
2825 if (!skb_pull(skb, sizeof(*ev)))
2826 return -EPROTO;
2827
2828 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2829 num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
2830 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2831 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2832
2833 for (i = 0; i < num_pdev_stats; i++) {
2834 const struct wmi_10_2_pdev_stats *src;
2835 struct ath10k_fw_stats_pdev *dst;
2836
2837 src = (void *)skb->data;
2838 if (!skb_pull(skb, sizeof(*src)))
2839 return -EPROTO;
2840
2841 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2842 if (!dst)
2843 continue;
2844
2845 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2846 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2847 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2848 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2849 /* FIXME: expose 10.2 specific values */
2850
2851 list_add_tail(&dst->list, &stats->pdevs);
2852 }
2853
2854 for (i = 0; i < num_pdev_ext_stats; i++) {
2855 const struct wmi_10_2_pdev_ext_stats *src;
2856
2857 src = (void *)skb->data;
2858 if (!skb_pull(skb, sizeof(*src)))
2859 return -EPROTO;
2860
2861 /* FIXME: expose values to userspace
2862 *
2863 * Note: Even though this loop seems to do nothing it is
2864 * required to parse following sub-structures properly.
2865 */
2866 }
2867
2868 /* fw doesn't implement vdev stats */
2869
2870 for (i = 0; i < num_peer_stats; i++) {
Mohammed Shafi Shajakhande46c012016-01-13 21:16:28 +05302871 const struct wmi_10_2_4_ext_peer_stats *src;
Michal Kazior20de2222015-01-24 12:14:49 +02002872 struct ath10k_fw_stats_peer *dst;
Mohammed Shafi Shajakhande46c012016-01-13 21:16:28 +05302873 int stats_len;
2874 bool ext_peer_stats_support;
2875
2876 ext_peer_stats_support = test_bit(WMI_SERVICE_PEER_STATS,
2877 ar->wmi.svc_map);
2878 if (ext_peer_stats_support)
2879 stats_len = sizeof(struct wmi_10_2_4_ext_peer_stats);
2880 else
2881 stats_len = sizeof(struct wmi_10_2_4_peer_stats);
Michal Kazior20de2222015-01-24 12:14:49 +02002882
2883 src = (void *)skb->data;
Mohammed Shafi Shajakhande46c012016-01-13 21:16:28 +05302884 if (!skb_pull(skb, stats_len))
Michal Kazior20de2222015-01-24 12:14:49 +02002885 return -EPROTO;
2886
2887 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2888 if (!dst)
2889 continue;
2890
2891 ath10k_wmi_pull_peer_stats(&src->common.old, dst);
2892
2893 dst->peer_rx_rate = __le32_to_cpu(src->common.peer_rx_rate);
Mohammed Shafi Shajakhande46c012016-01-13 21:16:28 +05302894
2895 if (ext_peer_stats_support)
2896 dst->rx_duration = __le32_to_cpu(src->rx_duration);
Michal Kazior20de2222015-01-24 12:14:49 +02002897 /* FIXME: expose 10.2 specific values */
2898
2899 list_add_tail(&dst->list, &stats->peers);
2900 }
2901
2902 return 0;
2903}
2904
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02002905static int ath10k_wmi_10_4_op_pull_fw_stats(struct ath10k *ar,
2906 struct sk_buff *skb,
2907 struct ath10k_fw_stats *stats)
2908{
2909 const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2910 u32 num_pdev_stats;
2911 u32 num_pdev_ext_stats;
2912 u32 num_vdev_stats;
2913 u32 num_peer_stats;
2914 int i;
2915
2916 if (!skb_pull(skb, sizeof(*ev)))
2917 return -EPROTO;
2918
2919 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2920 num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
2921 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2922 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2923
2924 for (i = 0; i < num_pdev_stats; i++) {
2925 const struct wmi_10_4_pdev_stats *src;
2926 struct ath10k_fw_stats_pdev *dst;
2927
2928 src = (void *)skb->data;
2929 if (!skb_pull(skb, sizeof(*src)))
2930 return -EPROTO;
2931
2932 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2933 if (!dst)
2934 continue;
2935
2936 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2937 ath10k_wmi_10_4_pull_pdev_stats_tx(&src->tx, dst);
2938 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2939 dst->rx_ovfl_errs = __le32_to_cpu(src->rx_ovfl_errs);
2940 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2941
2942 list_add_tail(&dst->list, &stats->pdevs);
2943 }
2944
2945 for (i = 0; i < num_pdev_ext_stats; i++) {
2946 const struct wmi_10_2_pdev_ext_stats *src;
2947
2948 src = (void *)skb->data;
2949 if (!skb_pull(skb, sizeof(*src)))
2950 return -EPROTO;
2951
2952 /* FIXME: expose values to userspace
2953 *
2954 * Note: Even though this loop seems to do nothing it is
2955 * required to parse following sub-structures properly.
2956 */
2957 }
2958
2959 /* fw doesn't implement vdev stats */
2960
2961 for (i = 0; i < num_peer_stats; i++) {
2962 const struct wmi_10_4_peer_stats *src;
2963 struct ath10k_fw_stats_peer *dst;
2964
2965 src = (void *)skb->data;
2966 if (!skb_pull(skb, sizeof(*src)))
2967 return -EPROTO;
2968
2969 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2970 if (!dst)
2971 continue;
2972
2973 ether_addr_copy(dst->peer_macaddr, src->peer_macaddr.addr);
2974 dst->peer_rssi = __le32_to_cpu(src->peer_rssi);
2975 dst->peer_tx_rate = __le32_to_cpu(src->peer_tx_rate);
2976 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
2977 /* FIXME: expose 10.4 specific values */
2978
2979 list_add_tail(&dst->list, &stats->peers);
2980 }
2981
2982 return 0;
2983}
2984
Michal Kazior0226d602014-12-03 10:11:22 +02002985void ath10k_wmi_event_update_stats(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002986{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002987 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_UPDATE_STATS_EVENTID\n");
Michal Kazior60ef4012014-09-25 12:33:48 +02002988 ath10k_debug_fw_stats_process(ar, skb);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002989}
2990
Michal Kaziord7579d12014-12-03 10:10:54 +02002991static int
2992ath10k_wmi_op_pull_vdev_start_ev(struct ath10k *ar, struct sk_buff *skb,
2993 struct wmi_vdev_start_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02002994{
2995 struct wmi_vdev_start_response_event *ev = (void *)skb->data;
2996
2997 if (skb->len < sizeof(*ev))
2998 return -EPROTO;
2999
3000 skb_pull(skb, sizeof(*ev));
3001 arg->vdev_id = ev->vdev_id;
3002 arg->req_id = ev->req_id;
3003 arg->resp_type = ev->resp_type;
3004 arg->status = ev->status;
3005
3006 return 0;
3007}
3008
Michal Kazior0226d602014-12-03 10:11:22 +02003009void ath10k_wmi_event_vdev_start_resp(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003010{
Michal Kazior32653cf2014-12-03 10:10:26 +02003011 struct wmi_vdev_start_ev_arg arg = {};
3012 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003013
Michal Kazior7aa7a722014-08-25 12:09:38 +02003014 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_START_RESP_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003015
Michal Kaziord7579d12014-12-03 10:10:54 +02003016 ret = ath10k_wmi_pull_vdev_start(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02003017 if (ret) {
3018 ath10k_warn(ar, "failed to parse vdev start event: %d\n", ret);
3019 return;
3020 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03003021
Michal Kazior32653cf2014-12-03 10:10:26 +02003022 if (WARN_ON(__le32_to_cpu(arg.status)))
Kalle Valo5e3dd152013-06-12 20:52:10 +03003023 return;
3024
3025 complete(&ar->vdev_setup_done);
3026}
3027
Michal Kazior0226d602014-12-03 10:11:22 +02003028void ath10k_wmi_event_vdev_stopped(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003029{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003030 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STOPPED_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003031 complete(&ar->vdev_setup_done);
3032}
3033
Michal Kaziord7579d12014-12-03 10:10:54 +02003034static int
3035ath10k_wmi_op_pull_peer_kick_ev(struct ath10k *ar, struct sk_buff *skb,
3036 struct wmi_peer_kick_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02003037{
3038 struct wmi_peer_sta_kickout_event *ev = (void *)skb->data;
3039
3040 if (skb->len < sizeof(*ev))
3041 return -EPROTO;
3042
3043 skb_pull(skb, sizeof(*ev));
3044 arg->mac_addr = ev->peer_macaddr.addr;
3045
3046 return 0;
3047}
3048
Michal Kazior0226d602014-12-03 10:11:22 +02003049void ath10k_wmi_event_peer_sta_kickout(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003050{
Michal Kazior32653cf2014-12-03 10:10:26 +02003051 struct wmi_peer_kick_ev_arg arg = {};
Kalle Valo5a13e762014-01-20 11:01:46 +02003052 struct ieee80211_sta *sta;
Michal Kazior32653cf2014-12-03 10:10:26 +02003053 int ret;
Kalle Valo5a13e762014-01-20 11:01:46 +02003054
Michal Kaziord7579d12014-12-03 10:10:54 +02003055 ret = ath10k_wmi_pull_peer_kick(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02003056 if (ret) {
3057 ath10k_warn(ar, "failed to parse peer kickout event: %d\n",
3058 ret);
3059 return;
3060 }
Kalle Valo5a13e762014-01-20 11:01:46 +02003061
Michal Kazior7aa7a722014-08-25 12:09:38 +02003062 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event peer sta kickout %pM\n",
Michal Kazior32653cf2014-12-03 10:10:26 +02003063 arg.mac_addr);
Kalle Valo5a13e762014-01-20 11:01:46 +02003064
3065 rcu_read_lock();
3066
Michal Kazior32653cf2014-12-03 10:10:26 +02003067 sta = ieee80211_find_sta_by_ifaddr(ar->hw, arg.mac_addr, NULL);
Kalle Valo5a13e762014-01-20 11:01:46 +02003068 if (!sta) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003069 ath10k_warn(ar, "Spurious quick kickout for STA %pM\n",
Michal Kazior32653cf2014-12-03 10:10:26 +02003070 arg.mac_addr);
Kalle Valo5a13e762014-01-20 11:01:46 +02003071 goto exit;
3072 }
3073
3074 ieee80211_report_low_ack(sta, 10);
3075
3076exit:
3077 rcu_read_unlock();
Kalle Valo5e3dd152013-06-12 20:52:10 +03003078}
3079
3080/*
3081 * FIXME
3082 *
3083 * We don't report to mac80211 sleep state of connected
3084 * stations. Due to this mac80211 can't fill in TIM IE
3085 * correctly.
3086 *
3087 * I know of no way of getting nullfunc frames that contain
3088 * sleep transition from connected stations - these do not
3089 * seem to be sent from the target to the host. There also
3090 * doesn't seem to be a dedicated event for that. So the
3091 * only way left to do this would be to read tim_bitmap
3092 * during SWBA.
3093 *
3094 * We could probably try using tim_bitmap from SWBA to tell
3095 * mac80211 which stations are asleep and which are not. The
3096 * problem here is calling mac80211 functions so many times
3097 * could take too long and make us miss the time to submit
3098 * the beacon to the target.
3099 *
3100 * So as a workaround we try to extend the TIM IE if there
3101 * is unicast buffered for stations with aid > 7 and fill it
3102 * in ourselves.
3103 */
3104static void ath10k_wmi_update_tim(struct ath10k *ar,
3105 struct ath10k_vif *arvif,
3106 struct sk_buff *bcn,
Raja Mania03fee32015-06-22 20:22:20 +05303107 const struct wmi_tim_info_arg *tim_info)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003108{
3109 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)bcn->data;
3110 struct ieee80211_tim_ie *tim;
3111 u8 *ies, *ie;
3112 u8 ie_len, pvm_len;
Kalle Valoaf762c02014-09-14 12:50:17 +03003113 __le32 t;
Raja Mania03fee32015-06-22 20:22:20 +05303114 u32 v, tim_len;
3115
3116 /* When FW reports 0 in tim_len, ensure atleast first byte
3117 * in tim_bitmap is considered for pvm calculation.
3118 */
3119 tim_len = tim_info->tim_len ? __le32_to_cpu(tim_info->tim_len) : 1;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003120
3121 /* if next SWBA has no tim_changed the tim_bitmap is garbage.
3122 * we must copy the bitmap upon change and reuse it later */
Michal Kazior32653cf2014-12-03 10:10:26 +02003123 if (__le32_to_cpu(tim_info->tim_changed)) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03003124 int i;
3125
Raja Mania03fee32015-06-22 20:22:20 +05303126 if (sizeof(arvif->u.ap.tim_bitmap) < tim_len) {
3127 ath10k_warn(ar, "SWBA TIM field is too big (%u), truncated it to %zu",
3128 tim_len, sizeof(arvif->u.ap.tim_bitmap));
3129 tim_len = sizeof(arvif->u.ap.tim_bitmap);
3130 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03003131
Raja Mania03fee32015-06-22 20:22:20 +05303132 for (i = 0; i < tim_len; i++) {
Michal Kazior32653cf2014-12-03 10:10:26 +02003133 t = tim_info->tim_bitmap[i / 4];
Kalle Valoaf762c02014-09-14 12:50:17 +03003134 v = __le32_to_cpu(t);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003135 arvif->u.ap.tim_bitmap[i] = (v >> ((i % 4) * 8)) & 0xFF;
3136 }
3137
Raja Mania03fee32015-06-22 20:22:20 +05303138 /* FW reports either length 0 or length based on max supported
3139 * station. so we calculate this on our own
3140 */
Kalle Valo5e3dd152013-06-12 20:52:10 +03003141 arvif->u.ap.tim_len = 0;
Raja Mania03fee32015-06-22 20:22:20 +05303142 for (i = 0; i < tim_len; i++)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003143 if (arvif->u.ap.tim_bitmap[i])
3144 arvif->u.ap.tim_len = i;
3145
3146 arvif->u.ap.tim_len++;
3147 }
3148
3149 ies = bcn->data;
3150 ies += ieee80211_hdrlen(hdr->frame_control);
3151 ies += 12; /* fixed parameters */
3152
3153 ie = (u8 *)cfg80211_find_ie(WLAN_EID_TIM, ies,
3154 (u8 *)skb_tail_pointer(bcn) - ies);
3155 if (!ie) {
Michal Kazior09af8f82013-07-05 16:15:08 +03003156 if (arvif->vdev_type != WMI_VDEV_TYPE_IBSS)
Michal Kazior7aa7a722014-08-25 12:09:38 +02003157 ath10k_warn(ar, "no tim ie found;\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003158 return;
3159 }
3160
3161 tim = (void *)ie + 2;
3162 ie_len = ie[1];
3163 pvm_len = ie_len - 3; /* exclude dtim count, dtim period, bmap ctl */
3164
3165 if (pvm_len < arvif->u.ap.tim_len) {
Raja Mania03fee32015-06-22 20:22:20 +05303166 int expand_size = tim_len - pvm_len;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003167 int move_size = skb_tail_pointer(bcn) - (ie + 2 + ie_len);
3168 void *next_ie = ie + 2 + ie_len;
3169
3170 if (skb_put(bcn, expand_size)) {
3171 memmove(next_ie + expand_size, next_ie, move_size);
3172
3173 ie[1] += expand_size;
3174 ie_len += expand_size;
3175 pvm_len += expand_size;
3176 } else {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003177 ath10k_warn(ar, "tim expansion failed\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003178 }
3179 }
3180
Raja Mania03fee32015-06-22 20:22:20 +05303181 if (pvm_len > tim_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003182 ath10k_warn(ar, "tim pvm length is too great (%d)\n", pvm_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003183 return;
3184 }
3185
Michal Kazior32653cf2014-12-03 10:10:26 +02003186 tim->bitmap_ctrl = !!__le32_to_cpu(tim_info->tim_mcast);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003187 memcpy(tim->virtual_map, arvif->u.ap.tim_bitmap, pvm_len);
3188
Michal Kazior748afc42014-01-23 12:48:21 +01003189 if (tim->dtim_count == 0) {
Michal Kazior66b8a012015-11-18 06:59:20 +01003190 ATH10K_SKB_CB(bcn)->flags |= ATH10K_SKB_F_DTIM_ZERO;
Michal Kazior748afc42014-01-23 12:48:21 +01003191
Michal Kazior32653cf2014-12-03 10:10:26 +02003192 if (__le32_to_cpu(tim_info->tim_mcast) == 1)
Michal Kazior66b8a012015-11-18 06:59:20 +01003193 ATH10K_SKB_CB(bcn)->flags |= ATH10K_SKB_F_DELIVER_CAB;
Michal Kazior748afc42014-01-23 12:48:21 +01003194 }
3195
Michal Kazior7aa7a722014-08-25 12:09:38 +02003196 ath10k_dbg(ar, ATH10K_DBG_MGMT, "dtim %d/%d mcast %d pvmlen %d\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +03003197 tim->dtim_count, tim->dtim_period,
3198 tim->bitmap_ctrl, pvm_len);
3199}
3200
Kalle Valo5e3dd152013-06-12 20:52:10 +03003201static void ath10k_wmi_update_noa(struct ath10k *ar, struct ath10k_vif *arvif,
3202 struct sk_buff *bcn,
Michal Kazior32653cf2014-12-03 10:10:26 +02003203 const struct wmi_p2p_noa_info *noa)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003204{
Peter Oh08c27be2016-01-28 13:54:09 -08003205 if (!arvif->vif->p2p)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003206 return;
3207
Michal Kazior7aa7a722014-08-25 12:09:38 +02003208 ath10k_dbg(ar, ATH10K_DBG_MGMT, "noa changed: %d\n", noa->changed);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003209
Michal Kazior6a948882015-02-26 13:23:17 +01003210 if (noa->changed & WMI_P2P_NOA_CHANGED_BIT)
3211 ath10k_p2p_noa_update(arvif, noa);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003212
3213 if (arvif->u.ap.noa_data)
3214 if (!pskb_expand_head(bcn, 0, arvif->u.ap.noa_len, GFP_ATOMIC))
3215 memcpy(skb_put(bcn, arvif->u.ap.noa_len),
3216 arvif->u.ap.noa_data,
3217 arvif->u.ap.noa_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003218}
3219
Michal Kaziord7579d12014-12-03 10:10:54 +02003220static int ath10k_wmi_op_pull_swba_ev(struct ath10k *ar, struct sk_buff *skb,
3221 struct wmi_swba_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02003222{
3223 struct wmi_host_swba_event *ev = (void *)skb->data;
3224 u32 map;
3225 size_t i;
3226
3227 if (skb->len < sizeof(*ev))
3228 return -EPROTO;
3229
3230 skb_pull(skb, sizeof(*ev));
3231 arg->vdev_map = ev->vdev_map;
3232
3233 for (i = 0, map = __le32_to_cpu(ev->vdev_map); map; map >>= 1) {
3234 if (!(map & BIT(0)))
3235 continue;
3236
3237 /* If this happens there were some changes in firmware and
3238 * ath10k should update the max size of tim_info array.
3239 */
3240 if (WARN_ON_ONCE(i == ARRAY_SIZE(arg->tim_info)))
3241 break;
3242
Raja Mania03fee32015-06-22 20:22:20 +05303243 if (__le32_to_cpu(ev->bcn_info[i].tim_info.tim_len) >
3244 sizeof(ev->bcn_info[i].tim_info.tim_bitmap)) {
3245 ath10k_warn(ar, "refusing to parse invalid swba structure\n");
3246 return -EPROTO;
3247 }
3248
3249 arg->tim_info[i].tim_len = ev->bcn_info[i].tim_info.tim_len;
3250 arg->tim_info[i].tim_mcast = ev->bcn_info[i].tim_info.tim_mcast;
3251 arg->tim_info[i].tim_bitmap =
3252 ev->bcn_info[i].tim_info.tim_bitmap;
3253 arg->tim_info[i].tim_changed =
3254 ev->bcn_info[i].tim_info.tim_changed;
3255 arg->tim_info[i].tim_num_ps_pending =
3256 ev->bcn_info[i].tim_info.tim_num_ps_pending;
3257
Michal Kazior32653cf2014-12-03 10:10:26 +02003258 arg->noa_info[i] = &ev->bcn_info[i].p2p_noa_info;
3259 i++;
3260 }
3261
3262 return 0;
3263}
3264
Yanbo Li8b019fb2016-01-14 15:39:19 -08003265static int ath10k_wmi_10_2_4_op_pull_swba_ev(struct ath10k *ar,
3266 struct sk_buff *skb,
3267 struct wmi_swba_ev_arg *arg)
3268{
3269 struct wmi_10_2_4_host_swba_event *ev = (void *)skb->data;
3270 u32 map;
3271 size_t i;
3272
3273 if (skb->len < sizeof(*ev))
3274 return -EPROTO;
3275
3276 skb_pull(skb, sizeof(*ev));
3277 arg->vdev_map = ev->vdev_map;
3278
3279 for (i = 0, map = __le32_to_cpu(ev->vdev_map); map; map >>= 1) {
3280 if (!(map & BIT(0)))
3281 continue;
3282
3283 /* If this happens there were some changes in firmware and
3284 * ath10k should update the max size of tim_info array.
3285 */
3286 if (WARN_ON_ONCE(i == ARRAY_SIZE(arg->tim_info)))
3287 break;
3288
3289 if (__le32_to_cpu(ev->bcn_info[i].tim_info.tim_len) >
3290 sizeof(ev->bcn_info[i].tim_info.tim_bitmap)) {
3291 ath10k_warn(ar, "refusing to parse invalid swba structure\n");
3292 return -EPROTO;
3293 }
3294
3295 arg->tim_info[i].tim_len = ev->bcn_info[i].tim_info.tim_len;
3296 arg->tim_info[i].tim_mcast = ev->bcn_info[i].tim_info.tim_mcast;
3297 arg->tim_info[i].tim_bitmap =
3298 ev->bcn_info[i].tim_info.tim_bitmap;
3299 arg->tim_info[i].tim_changed =
3300 ev->bcn_info[i].tim_info.tim_changed;
3301 arg->tim_info[i].tim_num_ps_pending =
3302 ev->bcn_info[i].tim_info.tim_num_ps_pending;
3303 i++;
3304 }
3305
3306 return 0;
3307}
3308
Raja Mani3cec3be2015-06-22 20:22:21 +05303309static int ath10k_wmi_10_4_op_pull_swba_ev(struct ath10k *ar,
3310 struct sk_buff *skb,
3311 struct wmi_swba_ev_arg *arg)
3312{
3313 struct wmi_10_4_host_swba_event *ev = (void *)skb->data;
3314 u32 map, tim_len;
3315 size_t i;
3316
3317 if (skb->len < sizeof(*ev))
3318 return -EPROTO;
3319
3320 skb_pull(skb, sizeof(*ev));
3321 arg->vdev_map = ev->vdev_map;
3322
3323 for (i = 0, map = __le32_to_cpu(ev->vdev_map); map; map >>= 1) {
3324 if (!(map & BIT(0)))
3325 continue;
3326
3327 /* If this happens there were some changes in firmware and
3328 * ath10k should update the max size of tim_info array.
3329 */
3330 if (WARN_ON_ONCE(i == ARRAY_SIZE(arg->tim_info)))
3331 break;
3332
3333 if (__le32_to_cpu(ev->bcn_info[i].tim_info.tim_len) >
3334 sizeof(ev->bcn_info[i].tim_info.tim_bitmap)) {
3335 ath10k_warn(ar, "refusing to parse invalid swba structure\n");
3336 return -EPROTO;
3337 }
3338
3339 tim_len = __le32_to_cpu(ev->bcn_info[i].tim_info.tim_len);
3340 if (tim_len) {
3341 /* Exclude 4 byte guard length */
3342 tim_len -= 4;
3343 arg->tim_info[i].tim_len = __cpu_to_le32(tim_len);
3344 } else {
3345 arg->tim_info[i].tim_len = 0;
3346 }
3347
3348 arg->tim_info[i].tim_mcast = ev->bcn_info[i].tim_info.tim_mcast;
3349 arg->tim_info[i].tim_bitmap =
3350 ev->bcn_info[i].tim_info.tim_bitmap;
3351 arg->tim_info[i].tim_changed =
3352 ev->bcn_info[i].tim_info.tim_changed;
3353 arg->tim_info[i].tim_num_ps_pending =
3354 ev->bcn_info[i].tim_info.tim_num_ps_pending;
3355
3356 /* 10.4 firmware doesn't have p2p support. notice of absence
3357 * info can be ignored for now.
3358 */
3359
3360 i++;
3361 }
3362
3363 return 0;
3364}
3365
Vivek Natarajan08e75ea2015-08-04 10:45:11 +05303366static enum wmi_txbf_conf ath10k_wmi_10_4_txbf_conf_scheme(struct ath10k *ar)
3367{
3368 return WMI_TXBF_CONF_BEFORE_ASSOC;
3369}
3370
Michal Kazior0226d602014-12-03 10:11:22 +02003371void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003372{
Michal Kazior32653cf2014-12-03 10:10:26 +02003373 struct wmi_swba_ev_arg arg = {};
Kalle Valo5e3dd152013-06-12 20:52:10 +03003374 u32 map;
3375 int i = -1;
Raja Mania03fee32015-06-22 20:22:20 +05303376 const struct wmi_tim_info_arg *tim_info;
Michal Kazior32653cf2014-12-03 10:10:26 +02003377 const struct wmi_p2p_noa_info *noa_info;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003378 struct ath10k_vif *arvif;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003379 struct sk_buff *bcn;
Michal Kazior64badcb2014-09-18 11:18:02 +03003380 dma_addr_t paddr;
Michal Kazior767d34f2014-02-27 18:50:03 +02003381 int ret, vdev_id = 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003382
Michal Kaziord7579d12014-12-03 10:10:54 +02003383 ret = ath10k_wmi_pull_swba(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02003384 if (ret) {
3385 ath10k_warn(ar, "failed to parse swba event: %d\n", ret);
3386 return;
3387 }
3388
3389 map = __le32_to_cpu(arg.vdev_map);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003390
Michal Kazior7aa7a722014-08-25 12:09:38 +02003391 ath10k_dbg(ar, ATH10K_DBG_MGMT, "mgmt swba vdev_map 0x%x\n",
Michal Kazior32653cf2014-12-03 10:10:26 +02003392 map);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003393
3394 for (; map; map >>= 1, vdev_id++) {
3395 if (!(map & 0x1))
3396 continue;
3397
3398 i++;
3399
3400 if (i >= WMI_MAX_AP_VDEV) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003401 ath10k_warn(ar, "swba has corrupted vdev map\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003402 break;
3403 }
3404
Raja Mania03fee32015-06-22 20:22:20 +05303405 tim_info = &arg.tim_info[i];
Michal Kazior32653cf2014-12-03 10:10:26 +02003406 noa_info = arg.noa_info[i];
Kalle Valo5e3dd152013-06-12 20:52:10 +03003407
Michal Kazior7aa7a722014-08-25 12:09:38 +02003408 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo7a8a3962014-03-28 14:35:16 +02003409 "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 +03003410 i,
Michal Kazior32653cf2014-12-03 10:10:26 +02003411 __le32_to_cpu(tim_info->tim_len),
3412 __le32_to_cpu(tim_info->tim_mcast),
3413 __le32_to_cpu(tim_info->tim_changed),
3414 __le32_to_cpu(tim_info->tim_num_ps_pending),
3415 __le32_to_cpu(tim_info->tim_bitmap[3]),
3416 __le32_to_cpu(tim_info->tim_bitmap[2]),
3417 __le32_to_cpu(tim_info->tim_bitmap[1]),
3418 __le32_to_cpu(tim_info->tim_bitmap[0]));
Kalle Valo5e3dd152013-06-12 20:52:10 +03003419
Raja Mania03fee32015-06-22 20:22:20 +05303420 /* TODO: Only first 4 word from tim_bitmap is dumped.
3421 * Extend debug code to dump full tim_bitmap.
3422 */
3423
Kalle Valo5e3dd152013-06-12 20:52:10 +03003424 arvif = ath10k_get_arvif(ar, vdev_id);
3425 if (arvif == NULL) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003426 ath10k_warn(ar, "no vif for vdev_id %d found\n",
3427 vdev_id);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003428 continue;
3429 }
3430
Michal Kaziorc2df44b2014-01-23 11:38:26 +01003431 /* There are no completions for beacons so wait for next SWBA
3432 * before telling mac80211 to decrement CSA counter
3433 *
3434 * Once CSA counter is completed stop sending beacons until
3435 * actual channel switch is done */
3436 if (arvif->vif->csa_active &&
3437 ieee80211_csa_is_complete(arvif->vif)) {
3438 ieee80211_csa_finish(arvif->vif);
3439 continue;
3440 }
3441
Kalle Valo5e3dd152013-06-12 20:52:10 +03003442 bcn = ieee80211_beacon_get(ar->hw, arvif->vif);
3443 if (!bcn) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003444 ath10k_warn(ar, "could not get mac80211 beacon\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003445 continue;
3446 }
3447
Michal Kazior4b604552014-07-21 21:03:09 +03003448 ath10k_tx_h_seq_no(arvif->vif, bcn);
Michal Kazior32653cf2014-12-03 10:10:26 +02003449 ath10k_wmi_update_tim(ar, arvif, bcn, tim_info);
3450 ath10k_wmi_update_noa(ar, arvif, bcn, noa_info);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003451
Michal Kaziored543882013-09-13 14:16:56 +02003452 spin_lock_bh(&ar->data_lock);
Michal Kazior748afc42014-01-23 12:48:21 +01003453
Michal Kaziored543882013-09-13 14:16:56 +02003454 if (arvif->beacon) {
Michal Kazioraf213192015-01-29 14:29:52 +02003455 switch (arvif->beacon_state) {
3456 case ATH10K_BEACON_SENT:
3457 break;
3458 case ATH10K_BEACON_SCHEDULED:
3459 ath10k_warn(ar, "SWBA overrun on vdev %d, skipped old beacon\n",
Michal Kazior748afc42014-01-23 12:48:21 +01003460 arvif->vdev_id);
Michal Kazioraf213192015-01-29 14:29:52 +02003461 break;
3462 case ATH10K_BEACON_SENDING:
3463 ath10k_warn(ar, "SWBA overrun on vdev %d, skipped new beacon\n",
3464 arvif->vdev_id);
3465 dev_kfree_skb(bcn);
3466 goto skip;
3467 }
Michal Kazior748afc42014-01-23 12:48:21 +01003468
Michal Kazior64badcb2014-09-18 11:18:02 +03003469 ath10k_mac_vif_beacon_free(arvif);
Michal Kaziored543882013-09-13 14:16:56 +02003470 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03003471
Michal Kazior64badcb2014-09-18 11:18:02 +03003472 if (!arvif->beacon_buf) {
3473 paddr = dma_map_single(arvif->ar->dev, bcn->data,
3474 bcn->len, DMA_TO_DEVICE);
3475 ret = dma_mapping_error(arvif->ar->dev, paddr);
3476 if (ret) {
3477 ath10k_warn(ar, "failed to map beacon: %d\n",
3478 ret);
3479 dev_kfree_skb_any(bcn);
Michal Kazior5e55e3c2015-08-19 13:10:43 +02003480 ret = -EIO;
Michal Kazior64badcb2014-09-18 11:18:02 +03003481 goto skip;
3482 }
3483
3484 ATH10K_SKB_CB(bcn)->paddr = paddr;
3485 } else {
3486 if (bcn->len > IEEE80211_MAX_FRAME_LEN) {
3487 ath10k_warn(ar, "trimming beacon %d -> %d bytes!\n",
3488 bcn->len, IEEE80211_MAX_FRAME_LEN);
3489 skb_trim(bcn, IEEE80211_MAX_FRAME_LEN);
3490 }
3491 memcpy(arvif->beacon_buf, bcn->data, bcn->len);
3492 ATH10K_SKB_CB(bcn)->paddr = arvif->beacon_paddr;
Michal Kazior767d34f2014-02-27 18:50:03 +02003493 }
Michal Kazior748afc42014-01-23 12:48:21 +01003494
Michal Kaziored543882013-09-13 14:16:56 +02003495 arvif->beacon = bcn;
Michal Kazioraf213192015-01-29 14:29:52 +02003496 arvif->beacon_state = ATH10K_BEACON_SCHEDULED;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003497
Rajkumar Manoharan5ce8e7f2014-11-05 19:14:31 +05303498 trace_ath10k_tx_hdr(ar, bcn->data, bcn->len);
3499 trace_ath10k_tx_payload(ar, bcn->data, bcn->len);
3500
Michal Kazior767d34f2014-02-27 18:50:03 +02003501skip:
Michal Kaziored543882013-09-13 14:16:56 +02003502 spin_unlock_bh(&ar->data_lock);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003503 }
Michal Kazioraf213192015-01-29 14:29:52 +02003504
3505 ath10k_wmi_tx_beacons_nowait(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003506}
3507
Michal Kazior0226d602014-12-03 10:11:22 +02003508void ath10k_wmi_event_tbttoffset_update(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003509{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003510 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TBTTOFFSET_UPDATE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003511}
3512
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003513static void ath10k_dfs_radar_report(struct ath10k *ar,
Raja Mani991adf72015-08-14 11:13:29 +03003514 struct wmi_phyerr_ev_arg *phyerr,
Michal Kazior2332d0a2014-09-18 15:21:25 +02003515 const struct phyerr_radar_report *rr,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003516 u64 tsf)
3517{
3518 u32 reg0, reg1, tsf32l;
Michal Kazior500ff9f2015-03-31 10:26:21 +00003519 struct ieee80211_channel *ch;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003520 struct pulse_event pe;
3521 u64 tsf64;
3522 u8 rssi, width;
3523
3524 reg0 = __le32_to_cpu(rr->reg0);
3525 reg1 = __le32_to_cpu(rr->reg1);
3526
Michal Kazior7aa7a722014-08-25 12:09:38 +02003527 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003528 "wmi phyerr radar report chirp %d max_width %d agc_total_gain %d pulse_delta_diff %d\n",
3529 MS(reg0, RADAR_REPORT_REG0_PULSE_IS_CHIRP),
3530 MS(reg0, RADAR_REPORT_REG0_PULSE_IS_MAX_WIDTH),
3531 MS(reg0, RADAR_REPORT_REG0_AGC_TOTAL_GAIN),
3532 MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_DIFF));
Michal Kazior7aa7a722014-08-25 12:09:38 +02003533 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003534 "wmi phyerr radar report pulse_delta_pean %d pulse_sidx %d fft_valid %d agc_mb_gain %d subchan_mask %d\n",
3535 MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_PEAK),
3536 MS(reg0, RADAR_REPORT_REG0_PULSE_SIDX),
3537 MS(reg1, RADAR_REPORT_REG1_PULSE_SRCH_FFT_VALID),
3538 MS(reg1, RADAR_REPORT_REG1_PULSE_AGC_MB_GAIN),
3539 MS(reg1, RADAR_REPORT_REG1_PULSE_SUBCHAN_MASK));
Michal Kazior7aa7a722014-08-25 12:09:38 +02003540 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003541 "wmi phyerr radar report pulse_tsf_offset 0x%X pulse_dur: %d\n",
3542 MS(reg1, RADAR_REPORT_REG1_PULSE_TSF_OFFSET),
3543 MS(reg1, RADAR_REPORT_REG1_PULSE_DUR));
3544
3545 if (!ar->dfs_detector)
3546 return;
3547
Michal Kazior500ff9f2015-03-31 10:26:21 +00003548 spin_lock_bh(&ar->data_lock);
3549 ch = ar->rx_channel;
3550 spin_unlock_bh(&ar->data_lock);
3551
3552 if (!ch) {
3553 ath10k_warn(ar, "failed to derive channel for radar pulse, treating as radar\n");
3554 goto radar_detected;
3555 }
3556
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003557 /* report event to DFS pattern detector */
Raja Mani991adf72015-08-14 11:13:29 +03003558 tsf32l = phyerr->tsf_timestamp;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003559 tsf64 = tsf & (~0xFFFFFFFFULL);
3560 tsf64 |= tsf32l;
3561
3562 width = MS(reg1, RADAR_REPORT_REG1_PULSE_DUR);
Michal Kazior2332d0a2014-09-18 15:21:25 +02003563 rssi = phyerr->rssi_combined;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003564
3565 /* hardware store this as 8 bit signed value,
3566 * set to zero if negative number
3567 */
3568 if (rssi & 0x80)
3569 rssi = 0;
3570
3571 pe.ts = tsf64;
Michal Kazior500ff9f2015-03-31 10:26:21 +00003572 pe.freq = ch->center_freq;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003573 pe.width = width;
3574 pe.rssi = rssi;
Peter Oh2c3f26a2015-03-04 15:43:46 +02003575 pe.chirp = (MS(reg0, RADAR_REPORT_REG0_PULSE_IS_CHIRP) != 0);
Michal Kazior7aa7a722014-08-25 12:09:38 +02003576 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003577 "dfs add pulse freq: %d, width: %d, rssi %d, tsf: %llX\n",
3578 pe.freq, pe.width, pe.rssi, pe.ts);
3579
3580 ATH10K_DFS_STAT_INC(ar, pulses_detected);
3581
3582 if (!ar->dfs_detector->add_pulse(ar->dfs_detector, &pe)) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003583 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003584 "dfs no pulse pattern detected, yet\n");
3585 return;
3586 }
3587
Michal Kazior500ff9f2015-03-31 10:26:21 +00003588radar_detected:
Michal Kazior7aa7a722014-08-25 12:09:38 +02003589 ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs radar detected\n");
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003590 ATH10K_DFS_STAT_INC(ar, radar_detected);
Marek Puzyniak7d9b40b2013-11-20 10:00:28 +02003591
3592 /* Control radar events reporting in debugfs file
3593 dfs_block_radar_events */
3594 if (ar->dfs_block_radar_events) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003595 ath10k_info(ar, "DFS Radar detected, but ignored as requested\n");
Marek Puzyniak7d9b40b2013-11-20 10:00:28 +02003596 return;
3597 }
3598
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003599 ieee80211_radar_detected(ar->hw);
3600}
3601
3602static int ath10k_dfs_fft_report(struct ath10k *ar,
Raja Mani991adf72015-08-14 11:13:29 +03003603 struct wmi_phyerr_ev_arg *phyerr,
Michal Kazior2332d0a2014-09-18 15:21:25 +02003604 const struct phyerr_fft_report *fftr,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003605 u64 tsf)
3606{
3607 u32 reg0, reg1;
3608 u8 rssi, peak_mag;
3609
3610 reg0 = __le32_to_cpu(fftr->reg0);
3611 reg1 = __le32_to_cpu(fftr->reg1);
Michal Kazior2332d0a2014-09-18 15:21:25 +02003612 rssi = phyerr->rssi_combined;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003613
Michal Kazior7aa7a722014-08-25 12:09:38 +02003614 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003615 "wmi phyerr fft report total_gain_db %d base_pwr_db %d fft_chn_idx %d peak_sidx %d\n",
3616 MS(reg0, SEARCH_FFT_REPORT_REG0_TOTAL_GAIN_DB),
3617 MS(reg0, SEARCH_FFT_REPORT_REG0_BASE_PWR_DB),
3618 MS(reg0, SEARCH_FFT_REPORT_REG0_FFT_CHN_IDX),
3619 MS(reg0, SEARCH_FFT_REPORT_REG0_PEAK_SIDX));
Michal Kazior7aa7a722014-08-25 12:09:38 +02003620 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003621 "wmi phyerr fft report rel_pwr_db %d avgpwr_db %d peak_mag %d num_store_bin %d\n",
3622 MS(reg1, SEARCH_FFT_REPORT_REG1_RELPWR_DB),
3623 MS(reg1, SEARCH_FFT_REPORT_REG1_AVGPWR_DB),
3624 MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG),
3625 MS(reg1, SEARCH_FFT_REPORT_REG1_NUM_STR_BINS_IB));
3626
3627 peak_mag = MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG);
3628
3629 /* false event detection */
3630 if (rssi == DFS_RSSI_POSSIBLY_FALSE &&
3631 peak_mag < 2 * DFS_PEAK_MAG_THOLD_POSSIBLY_FALSE) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003632 ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs false pulse detected\n");
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003633 ATH10K_DFS_STAT_INC(ar, pulses_discarded);
3634 return -EINVAL;
3635 }
3636
3637 return 0;
3638}
3639
Michal Kazior0226d602014-12-03 10:11:22 +02003640void ath10k_wmi_event_dfs(struct ath10k *ar,
Raja Mani991adf72015-08-14 11:13:29 +03003641 struct wmi_phyerr_ev_arg *phyerr,
Michal Kazior0226d602014-12-03 10:11:22 +02003642 u64 tsf)
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003643{
3644 int buf_len, tlv_len, res, i = 0;
Michal Kazior2332d0a2014-09-18 15:21:25 +02003645 const struct phyerr_tlv *tlv;
3646 const struct phyerr_radar_report *rr;
3647 const struct phyerr_fft_report *fftr;
3648 const u8 *tlv_buf;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003649
Raja Mani991adf72015-08-14 11:13:29 +03003650 buf_len = phyerr->buf_len;
Michal Kazior7aa7a722014-08-25 12:09:38 +02003651 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003652 "wmi event dfs err_code %d rssi %d tsfl 0x%X tsf64 0x%llX len %d\n",
Michal Kazior2332d0a2014-09-18 15:21:25 +02003653 phyerr->phy_err_code, phyerr->rssi_combined,
Raja Mani991adf72015-08-14 11:13:29 +03003654 phyerr->tsf_timestamp, tsf, buf_len);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003655
3656 /* Skip event if DFS disabled */
3657 if (!config_enabled(CONFIG_ATH10K_DFS_CERTIFIED))
3658 return;
3659
3660 ATH10K_DFS_STAT_INC(ar, pulses_total);
3661
3662 while (i < buf_len) {
3663 if (i + sizeof(*tlv) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003664 ath10k_warn(ar, "too short buf for tlv header (%d)\n",
3665 i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003666 return;
3667 }
3668
Michal Kazior2332d0a2014-09-18 15:21:25 +02003669 tlv = (struct phyerr_tlv *)&phyerr->buf[i];
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003670 tlv_len = __le16_to_cpu(tlv->len);
Michal Kazior2332d0a2014-09-18 15:21:25 +02003671 tlv_buf = &phyerr->buf[i + sizeof(*tlv)];
Michal Kazior7aa7a722014-08-25 12:09:38 +02003672 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003673 "wmi event dfs tlv_len %d tlv_tag 0x%02X tlv_sig 0x%02X\n",
3674 tlv_len, tlv->tag, tlv->sig);
3675
3676 switch (tlv->tag) {
3677 case PHYERR_TLV_TAG_RADAR_PULSE_SUMMARY:
3678 if (i + sizeof(*tlv) + sizeof(*rr) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003679 ath10k_warn(ar, "too short radar pulse summary (%d)\n",
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003680 i);
3681 return;
3682 }
3683
3684 rr = (struct phyerr_radar_report *)tlv_buf;
Michal Kazior2332d0a2014-09-18 15:21:25 +02003685 ath10k_dfs_radar_report(ar, phyerr, rr, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003686 break;
3687 case PHYERR_TLV_TAG_SEARCH_FFT_REPORT:
3688 if (i + sizeof(*tlv) + sizeof(*fftr) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003689 ath10k_warn(ar, "too short fft report (%d)\n",
3690 i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003691 return;
3692 }
3693
3694 fftr = (struct phyerr_fft_report *)tlv_buf;
Michal Kazior2332d0a2014-09-18 15:21:25 +02003695 res = ath10k_dfs_fft_report(ar, phyerr, fftr, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003696 if (res)
3697 return;
3698 break;
3699 }
3700
3701 i += sizeof(*tlv) + tlv_len;
3702 }
3703}
3704
Michal Kazior0226d602014-12-03 10:11:22 +02003705void ath10k_wmi_event_spectral_scan(struct ath10k *ar,
Raja Mani991adf72015-08-14 11:13:29 +03003706 struct wmi_phyerr_ev_arg *phyerr,
Michal Kazior0226d602014-12-03 10:11:22 +02003707 u64 tsf)
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003708{
Simon Wunderlich855aed12014-08-02 09:12:54 +03003709 int buf_len, tlv_len, res, i = 0;
3710 struct phyerr_tlv *tlv;
Michal Kazior2332d0a2014-09-18 15:21:25 +02003711 const void *tlv_buf;
3712 const struct phyerr_fft_report *fftr;
Simon Wunderlich855aed12014-08-02 09:12:54 +03003713 size_t fftr_len;
3714
Raja Mani991adf72015-08-14 11:13:29 +03003715 buf_len = phyerr->buf_len;
Simon Wunderlich855aed12014-08-02 09:12:54 +03003716
3717 while (i < buf_len) {
3718 if (i + sizeof(*tlv) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003719 ath10k_warn(ar, "failed to parse phyerr tlv header at byte %d\n",
Simon Wunderlich855aed12014-08-02 09:12:54 +03003720 i);
3721 return;
3722 }
3723
Michal Kazior2332d0a2014-09-18 15:21:25 +02003724 tlv = (struct phyerr_tlv *)&phyerr->buf[i];
Simon Wunderlich855aed12014-08-02 09:12:54 +03003725 tlv_len = __le16_to_cpu(tlv->len);
Michal Kazior2332d0a2014-09-18 15:21:25 +02003726 tlv_buf = &phyerr->buf[i + sizeof(*tlv)];
Simon Wunderlich855aed12014-08-02 09:12:54 +03003727
3728 if (i + sizeof(*tlv) + tlv_len > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003729 ath10k_warn(ar, "failed to parse phyerr tlv payload at byte %d\n",
Simon Wunderlich855aed12014-08-02 09:12:54 +03003730 i);
3731 return;
3732 }
3733
3734 switch (tlv->tag) {
3735 case PHYERR_TLV_TAG_SEARCH_FFT_REPORT:
3736 if (sizeof(*fftr) > tlv_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003737 ath10k_warn(ar, "failed to parse fft report at byte %d\n",
Simon Wunderlich855aed12014-08-02 09:12:54 +03003738 i);
3739 return;
3740 }
3741
3742 fftr_len = tlv_len - sizeof(*fftr);
Michal Kazior2332d0a2014-09-18 15:21:25 +02003743 fftr = tlv_buf;
3744 res = ath10k_spectral_process_fft(ar, phyerr,
Simon Wunderlich855aed12014-08-02 09:12:54 +03003745 fftr, fftr_len,
3746 tsf);
3747 if (res < 0) {
Kevin Darbyshire-Bryant3413e972015-07-21 15:50:15 +01003748 ath10k_dbg(ar, ATH10K_DBG_WMI, "failed to process fft report: %d\n",
Kalle Valo617b0f42015-10-05 17:56:35 +03003749 res);
Simon Wunderlich855aed12014-08-02 09:12:54 +03003750 return;
3751 }
3752 break;
3753 }
3754
3755 i += sizeof(*tlv) + tlv_len;
3756 }
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003757}
3758
Raja Mani991adf72015-08-14 11:13:29 +03003759static int ath10k_wmi_op_pull_phyerr_ev_hdr(struct ath10k *ar,
3760 struct sk_buff *skb,
3761 struct wmi_phyerr_hdr_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02003762{
3763 struct wmi_phyerr_event *ev = (void *)skb->data;
3764
3765 if (skb->len < sizeof(*ev))
3766 return -EPROTO;
3767
Raja Mani991adf72015-08-14 11:13:29 +03003768 arg->num_phyerrs = __le32_to_cpu(ev->num_phyerrs);
3769 arg->tsf_l32 = __le32_to_cpu(ev->tsf_l32);
3770 arg->tsf_u32 = __le32_to_cpu(ev->tsf_u32);
3771 arg->buf_len = skb->len - sizeof(*ev);
Michal Kazior32653cf2014-12-03 10:10:26 +02003772 arg->phyerrs = ev->phyerrs;
3773
3774 return 0;
3775}
3776
Raja Mani2b0a2e02015-08-14 11:13:34 +03003777static int ath10k_wmi_10_4_op_pull_phyerr_ev_hdr(struct ath10k *ar,
3778 struct sk_buff *skb,
3779 struct wmi_phyerr_hdr_arg *arg)
3780{
3781 struct wmi_10_4_phyerr_event *ev = (void *)skb->data;
3782
3783 if (skb->len < sizeof(*ev))
3784 return -EPROTO;
3785
3786 /* 10.4 firmware always reports only one phyerr */
3787 arg->num_phyerrs = 1;
3788
3789 arg->tsf_l32 = __le32_to_cpu(ev->tsf_l32);
3790 arg->tsf_u32 = __le32_to_cpu(ev->tsf_u32);
3791 arg->buf_len = skb->len;
3792 arg->phyerrs = skb->data;
3793
3794 return 0;
3795}
3796
Raja Mani991adf72015-08-14 11:13:29 +03003797int ath10k_wmi_op_pull_phyerr_ev(struct ath10k *ar,
3798 const void *phyerr_buf,
3799 int left_len,
3800 struct wmi_phyerr_ev_arg *arg)
3801{
3802 const struct wmi_phyerr *phyerr = phyerr_buf;
3803 int i;
3804
3805 if (left_len < sizeof(*phyerr)) {
Raja Maniee92a202015-08-21 18:42:36 +05303806 ath10k_warn(ar, "wrong phyerr event head len %d (need: >=%zd)\n",
Raja Mani991adf72015-08-14 11:13:29 +03003807 left_len, sizeof(*phyerr));
3808 return -EINVAL;
3809 }
3810
3811 arg->tsf_timestamp = __le32_to_cpu(phyerr->tsf_timestamp);
3812 arg->freq1 = __le16_to_cpu(phyerr->freq1);
3813 arg->freq2 = __le16_to_cpu(phyerr->freq2);
3814 arg->rssi_combined = phyerr->rssi_combined;
3815 arg->chan_width_mhz = phyerr->chan_width_mhz;
3816 arg->buf_len = __le32_to_cpu(phyerr->buf_len);
3817 arg->buf = phyerr->buf;
3818 arg->hdr_len = sizeof(*phyerr);
3819
3820 for (i = 0; i < 4; i++)
3821 arg->nf_chains[i] = __le16_to_cpu(phyerr->nf_chains[i]);
3822
3823 switch (phyerr->phy_err_code) {
3824 case PHY_ERROR_GEN_SPECTRAL_SCAN:
3825 arg->phy_err_code = PHY_ERROR_SPECTRAL_SCAN;
3826 break;
3827 case PHY_ERROR_GEN_FALSE_RADAR_EXT:
3828 arg->phy_err_code = PHY_ERROR_FALSE_RADAR_EXT;
3829 break;
3830 case PHY_ERROR_GEN_RADAR:
3831 arg->phy_err_code = PHY_ERROR_RADAR;
3832 break;
3833 default:
3834 arg->phy_err_code = PHY_ERROR_UNKNOWN;
3835 break;
3836 }
3837
3838 return 0;
3839}
3840
Raja Mani2b0a2e02015-08-14 11:13:34 +03003841static int ath10k_wmi_10_4_op_pull_phyerr_ev(struct ath10k *ar,
3842 const void *phyerr_buf,
3843 int left_len,
3844 struct wmi_phyerr_ev_arg *arg)
3845{
3846 const struct wmi_10_4_phyerr_event *phyerr = phyerr_buf;
3847 u32 phy_err_mask;
3848 int i;
3849
3850 if (left_len < sizeof(*phyerr)) {
Raja Maniee92a202015-08-21 18:42:36 +05303851 ath10k_warn(ar, "wrong phyerr event head len %d (need: >=%zd)\n",
Raja Mani2b0a2e02015-08-14 11:13:34 +03003852 left_len, sizeof(*phyerr));
3853 return -EINVAL;
3854 }
3855
3856 arg->tsf_timestamp = __le32_to_cpu(phyerr->tsf_timestamp);
3857 arg->freq1 = __le16_to_cpu(phyerr->freq1);
3858 arg->freq2 = __le16_to_cpu(phyerr->freq2);
3859 arg->rssi_combined = phyerr->rssi_combined;
3860 arg->chan_width_mhz = phyerr->chan_width_mhz;
3861 arg->buf_len = __le32_to_cpu(phyerr->buf_len);
3862 arg->buf = phyerr->buf;
3863 arg->hdr_len = sizeof(*phyerr);
3864
3865 for (i = 0; i < 4; i++)
3866 arg->nf_chains[i] = __le16_to_cpu(phyerr->nf_chains[i]);
3867
3868 phy_err_mask = __le32_to_cpu(phyerr->phy_err_mask[0]);
3869
3870 if (phy_err_mask & PHY_ERROR_10_4_SPECTRAL_SCAN_MASK)
3871 arg->phy_err_code = PHY_ERROR_SPECTRAL_SCAN;
3872 else if (phy_err_mask & PHY_ERROR_10_4_RADAR_MASK)
3873 arg->phy_err_code = PHY_ERROR_RADAR;
3874 else
3875 arg->phy_err_code = PHY_ERROR_UNKNOWN;
3876
3877 return 0;
3878}
3879
Michal Kazior0226d602014-12-03 10:11:22 +02003880void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003881{
Raja Mani991adf72015-08-14 11:13:29 +03003882 struct wmi_phyerr_hdr_arg hdr_arg = {};
3883 struct wmi_phyerr_ev_arg phyerr_arg = {};
3884 const void *phyerr;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003885 u32 count, i, buf_len, phy_err_code;
3886 u64 tsf;
Michal Kazior32653cf2014-12-03 10:10:26 +02003887 int left_len, ret;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003888
3889 ATH10K_DFS_STAT_INC(ar, phy_errors);
3890
Raja Mani991adf72015-08-14 11:13:29 +03003891 ret = ath10k_wmi_pull_phyerr_hdr(ar, skb, &hdr_arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02003892 if (ret) {
Raja Mani991adf72015-08-14 11:13:29 +03003893 ath10k_warn(ar, "failed to parse phyerr event hdr: %d\n", ret);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003894 return;
3895 }
3896
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003897 /* Check number of included events */
Raja Mani991adf72015-08-14 11:13:29 +03003898 count = hdr_arg.num_phyerrs;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003899
Raja Mani991adf72015-08-14 11:13:29 +03003900 left_len = hdr_arg.buf_len;
3901
3902 tsf = hdr_arg.tsf_u32;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003903 tsf <<= 32;
Raja Mani991adf72015-08-14 11:13:29 +03003904 tsf |= hdr_arg.tsf_l32;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003905
Michal Kazior7aa7a722014-08-25 12:09:38 +02003906 ath10k_dbg(ar, ATH10K_DBG_WMI,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003907 "wmi event phyerr count %d tsf64 0x%llX\n",
3908 count, tsf);
3909
Raja Mani991adf72015-08-14 11:13:29 +03003910 phyerr = hdr_arg.phyerrs;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003911 for (i = 0; i < count; i++) {
Raja Mani991adf72015-08-14 11:13:29 +03003912 ret = ath10k_wmi_pull_phyerr(ar, phyerr, left_len, &phyerr_arg);
3913 if (ret) {
3914 ath10k_warn(ar, "failed to parse phyerr event (%d)\n",
Michal Kazior7aa7a722014-08-25 12:09:38 +02003915 i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003916 return;
3917 }
3918
Raja Mani991adf72015-08-14 11:13:29 +03003919 left_len -= phyerr_arg.hdr_len;
3920 buf_len = phyerr_arg.buf_len;
3921 phy_err_code = phyerr_arg.phy_err_code;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003922
3923 if (left_len < buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003924 ath10k_warn(ar, "single event (%d) wrong buf len\n", i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003925 return;
3926 }
3927
3928 left_len -= buf_len;
3929
3930 switch (phy_err_code) {
3931 case PHY_ERROR_RADAR:
Raja Mani991adf72015-08-14 11:13:29 +03003932 ath10k_wmi_event_dfs(ar, &phyerr_arg, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003933 break;
3934 case PHY_ERROR_SPECTRAL_SCAN:
Raja Mani991adf72015-08-14 11:13:29 +03003935 ath10k_wmi_event_spectral_scan(ar, &phyerr_arg, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003936 break;
3937 case PHY_ERROR_FALSE_RADAR_EXT:
Raja Mani991adf72015-08-14 11:13:29 +03003938 ath10k_wmi_event_dfs(ar, &phyerr_arg, tsf);
3939 ath10k_wmi_event_spectral_scan(ar, &phyerr_arg, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003940 break;
3941 default:
3942 break;
3943 }
3944
Raja Mani991adf72015-08-14 11:13:29 +03003945 phyerr = phyerr + phyerr_arg.hdr_len + buf_len;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003946 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03003947}
3948
Michal Kazior0226d602014-12-03 10:11:22 +02003949void ath10k_wmi_event_roam(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003950{
Michal Kaziorc1a46542015-03-10 16:21:54 +02003951 struct wmi_roam_ev_arg arg = {};
3952 int ret;
3953 u32 vdev_id;
3954 u32 reason;
3955 s32 rssi;
3956
3957 ret = ath10k_wmi_pull_roam_ev(ar, skb, &arg);
3958 if (ret) {
3959 ath10k_warn(ar, "failed to parse roam event: %d\n", ret);
3960 return;
3961 }
3962
3963 vdev_id = __le32_to_cpu(arg.vdev_id);
3964 reason = __le32_to_cpu(arg.reason);
3965 rssi = __le32_to_cpu(arg.rssi);
3966 rssi += WMI_SPECTRAL_NOISE_FLOOR_REF_DEFAULT;
3967
3968 ath10k_dbg(ar, ATH10K_DBG_WMI,
3969 "wmi roam event vdev %u reason 0x%08x rssi %d\n",
3970 vdev_id, reason, rssi);
3971
3972 if (reason >= WMI_ROAM_REASON_MAX)
3973 ath10k_warn(ar, "ignoring unknown roam event reason %d on vdev %i\n",
3974 reason, vdev_id);
3975
3976 switch (reason) {
Michal Kaziorc1a46542015-03-10 16:21:54 +02003977 case WMI_ROAM_REASON_BEACON_MISS:
Michal Kaziorcc9904e2015-03-10 16:22:01 +02003978 ath10k_mac_handle_beacon_miss(ar, vdev_id);
3979 break;
3980 case WMI_ROAM_REASON_BETTER_AP:
Michal Kaziorc1a46542015-03-10 16:21:54 +02003981 case WMI_ROAM_REASON_LOW_RSSI:
3982 case WMI_ROAM_REASON_SUITABLE_AP_FOUND:
3983 case WMI_ROAM_REASON_HO_FAILED:
3984 ath10k_warn(ar, "ignoring not implemented roam event reason %d on vdev %i\n",
3985 reason, vdev_id);
3986 break;
3987 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03003988}
3989
Michal Kazior0226d602014-12-03 10:11:22 +02003990void ath10k_wmi_event_profile_match(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003991{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003992 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PROFILE_MATCH\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003993}
3994
Michal Kazior0226d602014-12-03 10:11:22 +02003995void ath10k_wmi_event_debug_print(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003996{
Kalle Valo2fe52882014-01-03 12:59:20 +02003997 char buf[101], c;
3998 int i;
3999
4000 for (i = 0; i < sizeof(buf) - 1; i++) {
4001 if (i >= skb->len)
4002 break;
4003
4004 c = skb->data[i];
4005
4006 if (c == '\0')
4007 break;
4008
4009 if (isascii(c) && isprint(c))
4010 buf[i] = c;
4011 else
4012 buf[i] = '.';
4013 }
4014
4015 if (i == sizeof(buf) - 1)
Michal Kazior7aa7a722014-08-25 12:09:38 +02004016 ath10k_warn(ar, "wmi debug print truncated: %d\n", skb->len);
Kalle Valo2fe52882014-01-03 12:59:20 +02004017
4018 /* for some reason the debug prints end with \n, remove that */
4019 if (skb->data[i - 1] == '\n')
4020 i--;
4021
4022 /* the last byte is always reserved for the null character */
4023 buf[i] = '\0';
4024
Ben Greear3be004c2014-09-23 14:17:19 -07004025 ath10k_dbg(ar, ATH10K_DBG_WMI_PRINT, "wmi print '%s'\n", buf);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004026}
4027
Michal Kazior0226d602014-12-03 10:11:22 +02004028void ath10k_wmi_event_pdev_qvit(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004029{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004030 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_QVIT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004031}
4032
Michal Kazior0226d602014-12-03 10:11:22 +02004033void ath10k_wmi_event_wlan_profile_data(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004034{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004035 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_WLAN_PROFILE_DATA_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004036}
4037
Michal Kazior0226d602014-12-03 10:11:22 +02004038void ath10k_wmi_event_rtt_measurement_report(struct ath10k *ar,
4039 struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004040{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004041 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_MEASUREMENT_REPORT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004042}
4043
Michal Kazior0226d602014-12-03 10:11:22 +02004044void ath10k_wmi_event_tsf_measurement_report(struct ath10k *ar,
4045 struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004046{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004047 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TSF_MEASUREMENT_REPORT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004048}
4049
Michal Kazior0226d602014-12-03 10:11:22 +02004050void ath10k_wmi_event_rtt_error_report(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004051{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004052 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_ERROR_REPORT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004053}
4054
Michal Kazior0226d602014-12-03 10:11:22 +02004055void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004056{
Janusz Dziedzic5fd3ac32015-03-23 17:32:53 +02004057 struct wmi_wow_ev_arg ev = {};
4058 int ret;
4059
4060 complete(&ar->wow.wakeup_completed);
4061
4062 ret = ath10k_wmi_pull_wow_event(ar, skb, &ev);
4063 if (ret) {
4064 ath10k_warn(ar, "failed to parse wow wakeup event: %d\n", ret);
4065 return;
4066 }
4067
4068 ath10k_dbg(ar, ATH10K_DBG_WMI, "wow wakeup host reason %s\n",
4069 wow_reason(ev.wake_reason));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004070}
4071
Michal Kazior0226d602014-12-03 10:11:22 +02004072void ath10k_wmi_event_dcs_interference(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004073{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004074 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_DCS_INTERFERENCE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004075}
4076
Maharaja Kennadyrajan29542662015-10-05 17:56:38 +03004077static u8 ath10k_tpc_config_get_rate(struct ath10k *ar,
4078 struct wmi_pdev_tpc_config_event *ev,
4079 u32 rate_idx, u32 num_chains,
4080 u32 rate_code, u8 type)
4081{
4082 u8 tpc, num_streams, preamble, ch, stm_idx;
4083
4084 num_streams = ATH10K_HW_NSS(rate_code);
4085 preamble = ATH10K_HW_PREAMBLE(rate_code);
4086 ch = num_chains - 1;
4087
4088 tpc = min_t(u8, ev->rates_array[rate_idx], ev->max_reg_allow_pow[ch]);
4089
4090 if (__le32_to_cpu(ev->num_tx_chain) <= 1)
4091 goto out;
4092
4093 if (preamble == WMI_RATE_PREAMBLE_CCK)
4094 goto out;
4095
4096 stm_idx = num_streams - 1;
4097 if (num_chains <= num_streams)
4098 goto out;
4099
4100 switch (type) {
4101 case WMI_TPC_TABLE_TYPE_STBC:
4102 tpc = min_t(u8, tpc,
4103 ev->max_reg_allow_pow_agstbc[ch - 1][stm_idx]);
4104 break;
4105 case WMI_TPC_TABLE_TYPE_TXBF:
4106 tpc = min_t(u8, tpc,
4107 ev->max_reg_allow_pow_agtxbf[ch - 1][stm_idx]);
4108 break;
4109 case WMI_TPC_TABLE_TYPE_CDD:
4110 tpc = min_t(u8, tpc,
4111 ev->max_reg_allow_pow_agcdd[ch - 1][stm_idx]);
4112 break;
4113 default:
4114 ath10k_warn(ar, "unknown wmi tpc table type: %d\n", type);
4115 tpc = 0;
4116 break;
4117 }
4118
4119out:
4120 return tpc;
4121}
4122
4123static void ath10k_tpc_config_disp_tables(struct ath10k *ar,
4124 struct wmi_pdev_tpc_config_event *ev,
4125 struct ath10k_tpc_stats *tpc_stats,
4126 u8 *rate_code, u16 *pream_table, u8 type)
4127{
4128 u32 i, j, pream_idx, flags;
4129 u8 tpc[WMI_TPC_TX_N_CHAIN];
4130 char tpc_value[WMI_TPC_TX_N_CHAIN * WMI_TPC_BUF_SIZE];
4131 char buff[WMI_TPC_BUF_SIZE];
4132
4133 flags = __le32_to_cpu(ev->flags);
4134
4135 switch (type) {
4136 case WMI_TPC_TABLE_TYPE_CDD:
4137 if (!(flags & WMI_TPC_CONFIG_EVENT_FLAG_TABLE_CDD)) {
4138 ath10k_dbg(ar, ATH10K_DBG_WMI, "CDD not supported\n");
4139 tpc_stats->flag[type] = ATH10K_TPC_TABLE_TYPE_FLAG;
4140 return;
4141 }
4142 break;
4143 case WMI_TPC_TABLE_TYPE_STBC:
4144 if (!(flags & WMI_TPC_CONFIG_EVENT_FLAG_TABLE_STBC)) {
4145 ath10k_dbg(ar, ATH10K_DBG_WMI, "STBC not supported\n");
4146 tpc_stats->flag[type] = ATH10K_TPC_TABLE_TYPE_FLAG;
4147 return;
4148 }
4149 break;
4150 case WMI_TPC_TABLE_TYPE_TXBF:
4151 if (!(flags & WMI_TPC_CONFIG_EVENT_FLAG_TABLE_TXBF)) {
4152 ath10k_dbg(ar, ATH10K_DBG_WMI, "TXBF not supported\n");
4153 tpc_stats->flag[type] = ATH10K_TPC_TABLE_TYPE_FLAG;
4154 return;
4155 }
4156 break;
4157 default:
4158 ath10k_dbg(ar, ATH10K_DBG_WMI,
4159 "invalid table type in wmi tpc event: %d\n", type);
4160 return;
4161 }
4162
4163 pream_idx = 0;
4164 for (i = 0; i < __le32_to_cpu(ev->rate_max); i++) {
4165 memset(tpc_value, 0, sizeof(tpc_value));
4166 memset(buff, 0, sizeof(buff));
4167 if (i == pream_table[pream_idx])
4168 pream_idx++;
4169
4170 for (j = 0; j < WMI_TPC_TX_N_CHAIN; j++) {
4171 if (j >= __le32_to_cpu(ev->num_tx_chain))
4172 break;
4173
4174 tpc[j] = ath10k_tpc_config_get_rate(ar, ev, i, j + 1,
4175 rate_code[i],
4176 type);
4177 snprintf(buff, sizeof(buff), "%8d ", tpc[j]);
4178 strncat(tpc_value, buff, strlen(buff));
4179 }
4180 tpc_stats->tpc_table[type].pream_idx[i] = pream_idx;
4181 tpc_stats->tpc_table[type].rate_code[i] = rate_code[i];
4182 memcpy(tpc_stats->tpc_table[type].tpc_value[i],
4183 tpc_value, sizeof(tpc_value));
4184 }
4185}
4186
Michal Kazior0226d602014-12-03 10:11:22 +02004187void ath10k_wmi_event_pdev_tpc_config(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004188{
Maharaja Kennadyrajan29542662015-10-05 17:56:38 +03004189 u32 i, j, pream_idx, num_tx_chain;
4190 u8 rate_code[WMI_TPC_RATE_MAX], rate_idx;
4191 u16 pream_table[WMI_TPC_PREAM_TABLE_MAX];
4192 struct wmi_pdev_tpc_config_event *ev;
4193 struct ath10k_tpc_stats *tpc_stats;
4194
4195 ev = (struct wmi_pdev_tpc_config_event *)skb->data;
4196
4197 tpc_stats = kzalloc(sizeof(*tpc_stats), GFP_ATOMIC);
4198 if (!tpc_stats)
4199 return;
4200
4201 /* Create the rate code table based on the chains supported */
4202 rate_idx = 0;
4203 pream_idx = 0;
4204
4205 /* Fill CCK rate code */
4206 for (i = 0; i < 4; i++) {
4207 rate_code[rate_idx] =
4208 ATH10K_HW_RATECODE(i, 0, WMI_RATE_PREAMBLE_CCK);
4209 rate_idx++;
4210 }
4211 pream_table[pream_idx] = rate_idx;
4212 pream_idx++;
4213
4214 /* Fill OFDM rate code */
4215 for (i = 0; i < 8; i++) {
4216 rate_code[rate_idx] =
4217 ATH10K_HW_RATECODE(i, 0, WMI_RATE_PREAMBLE_OFDM);
4218 rate_idx++;
4219 }
4220 pream_table[pream_idx] = rate_idx;
4221 pream_idx++;
4222
4223 num_tx_chain = __le32_to_cpu(ev->num_tx_chain);
4224
4225 /* Fill HT20 rate code */
4226 for (i = 0; i < num_tx_chain; i++) {
4227 for (j = 0; j < 8; j++) {
4228 rate_code[rate_idx] =
4229 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_HT);
4230 rate_idx++;
4231 }
4232 }
4233 pream_table[pream_idx] = rate_idx;
4234 pream_idx++;
4235
4236 /* Fill HT40 rate code */
4237 for (i = 0; i < num_tx_chain; i++) {
4238 for (j = 0; j < 8; j++) {
4239 rate_code[rate_idx] =
4240 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_HT);
4241 rate_idx++;
4242 }
4243 }
4244 pream_table[pream_idx] = rate_idx;
4245 pream_idx++;
4246
4247 /* Fill VHT20 rate code */
4248 for (i = 0; i < __le32_to_cpu(ev->num_tx_chain); i++) {
4249 for (j = 0; j < 10; j++) {
4250 rate_code[rate_idx] =
4251 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_VHT);
4252 rate_idx++;
4253 }
4254 }
4255 pream_table[pream_idx] = rate_idx;
4256 pream_idx++;
4257
4258 /* Fill VHT40 rate code */
4259 for (i = 0; i < num_tx_chain; i++) {
4260 for (j = 0; j < 10; j++) {
4261 rate_code[rate_idx] =
4262 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_VHT);
4263 rate_idx++;
4264 }
4265 }
4266 pream_table[pream_idx] = rate_idx;
4267 pream_idx++;
4268
4269 /* Fill VHT80 rate code */
4270 for (i = 0; i < num_tx_chain; i++) {
4271 for (j = 0; j < 10; j++) {
4272 rate_code[rate_idx] =
4273 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_VHT);
4274 rate_idx++;
4275 }
4276 }
4277 pream_table[pream_idx] = rate_idx;
4278 pream_idx++;
4279
4280 rate_code[rate_idx++] =
4281 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_CCK);
4282 rate_code[rate_idx++] =
4283 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_OFDM);
4284 rate_code[rate_idx++] =
4285 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_CCK);
4286 rate_code[rate_idx++] =
4287 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_OFDM);
4288 rate_code[rate_idx++] =
4289 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_OFDM);
4290
4291 pream_table[pream_idx] = ATH10K_TPC_PREAM_TABLE_END;
4292
4293 tpc_stats->chan_freq = __le32_to_cpu(ev->chan_freq);
4294 tpc_stats->phy_mode = __le32_to_cpu(ev->phy_mode);
4295 tpc_stats->ctl = __le32_to_cpu(ev->ctl);
4296 tpc_stats->reg_domain = __le32_to_cpu(ev->reg_domain);
4297 tpc_stats->twice_antenna_gain = a_sle32_to_cpu(ev->twice_antenna_gain);
4298 tpc_stats->twice_antenna_reduction =
4299 __le32_to_cpu(ev->twice_antenna_reduction);
4300 tpc_stats->power_limit = __le32_to_cpu(ev->power_limit);
4301 tpc_stats->twice_max_rd_power = __le32_to_cpu(ev->twice_max_rd_power);
4302 tpc_stats->num_tx_chain = __le32_to_cpu(ev->num_tx_chain);
4303 tpc_stats->rate_max = __le32_to_cpu(ev->rate_max);
4304
4305 ath10k_tpc_config_disp_tables(ar, ev, tpc_stats,
4306 rate_code, pream_table,
4307 WMI_TPC_TABLE_TYPE_CDD);
4308 ath10k_tpc_config_disp_tables(ar, ev, tpc_stats,
4309 rate_code, pream_table,
4310 WMI_TPC_TABLE_TYPE_STBC);
4311 ath10k_tpc_config_disp_tables(ar, ev, tpc_stats,
4312 rate_code, pream_table,
4313 WMI_TPC_TABLE_TYPE_TXBF);
4314
4315 ath10k_debug_tpc_stats_process(ar, tpc_stats);
4316
4317 ath10k_dbg(ar, ATH10K_DBG_WMI,
4318 "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",
4319 __le32_to_cpu(ev->chan_freq),
4320 __le32_to_cpu(ev->phy_mode),
4321 __le32_to_cpu(ev->ctl),
4322 __le32_to_cpu(ev->reg_domain),
4323 a_sle32_to_cpu(ev->twice_antenna_gain),
4324 __le32_to_cpu(ev->twice_antenna_reduction),
4325 __le32_to_cpu(ev->power_limit),
4326 __le32_to_cpu(ev->twice_max_rd_power) / 2,
4327 __le32_to_cpu(ev->num_tx_chain),
4328 __le32_to_cpu(ev->rate_max));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004329}
4330
Michal Kazior0226d602014-12-03 10:11:22 +02004331void ath10k_wmi_event_pdev_ftm_intg(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004332{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004333 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_FTM_INTG_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004334}
4335
Michal Kazior0226d602014-12-03 10:11:22 +02004336void ath10k_wmi_event_gtk_offload_status(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004337{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004338 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_OFFLOAD_STATUS_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004339}
4340
Michal Kazior0226d602014-12-03 10:11:22 +02004341void ath10k_wmi_event_gtk_rekey_fail(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004342{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004343 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_REKEY_FAIL_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004344}
4345
Michal Kazior0226d602014-12-03 10:11:22 +02004346void ath10k_wmi_event_delba_complete(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004347{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004348 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_DELBA_COMPLETE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004349}
4350
Michal Kazior0226d602014-12-03 10:11:22 +02004351void ath10k_wmi_event_addba_complete(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004352{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004353 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_ADDBA_COMPLETE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004354}
4355
Michal Kazior0226d602014-12-03 10:11:22 +02004356void ath10k_wmi_event_vdev_install_key_complete(struct ath10k *ar,
4357 struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004358{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004359 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004360}
4361
Michal Kazior0226d602014-12-03 10:11:22 +02004362void ath10k_wmi_event_inst_rssi_stats(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004363{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004364 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_INST_RSSI_STATS_EVENTID\n");
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004365}
4366
Michal Kazior0226d602014-12-03 10:11:22 +02004367void ath10k_wmi_event_vdev_standby_req(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004368{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004369 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STANDBY_REQ_EVENTID\n");
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004370}
4371
Michal Kazior0226d602014-12-03 10:11:22 +02004372void ath10k_wmi_event_vdev_resume_req(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004373{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004374 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_RESUME_REQ_EVENTID\n");
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004375}
4376
Felix Fietkaub0578862015-11-30 19:32:01 +01004377static int ath10k_wmi_alloc_chunk(struct ath10k *ar, u32 req_id,
4378 u32 num_units, u32 unit_len)
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004379{
4380 dma_addr_t paddr;
Felix Fietkaub0578862015-11-30 19:32:01 +01004381 u32 pool_size = 0;
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004382 int idx = ar->wmi.num_mem_chunks;
Felix Fietkaub0578862015-11-30 19:32:01 +01004383 void *vaddr = NULL;
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004384
Felix Fietkaub0578862015-11-30 19:32:01 +01004385 if (ar->wmi.num_mem_chunks == ARRAY_SIZE(ar->wmi.mem_chunks))
4386 return -ENOMEM;
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004387
Felix Fietkaub0578862015-11-30 19:32:01 +01004388 while (!vaddr && num_units) {
4389 pool_size = num_units * round_up(unit_len, 4);
4390 if (!pool_size)
4391 return -EINVAL;
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004392
Felix Fietkaub0578862015-11-30 19:32:01 +01004393 vaddr = kzalloc(pool_size, GFP_KERNEL | __GFP_NOWARN);
4394 if (!vaddr)
4395 num_units /= 2;
4396 }
4397
4398 if (!num_units)
4399 return -ENOMEM;
4400
4401 paddr = dma_map_single(ar->dev, vaddr, pool_size, DMA_TO_DEVICE);
4402 if (dma_mapping_error(ar->dev, paddr)) {
4403 kfree(vaddr);
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004404 return -ENOMEM;
4405 }
4406
Felix Fietkaub0578862015-11-30 19:32:01 +01004407 ar->wmi.mem_chunks[idx].vaddr = vaddr;
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004408 ar->wmi.mem_chunks[idx].paddr = paddr;
4409 ar->wmi.mem_chunks[idx].len = pool_size;
4410 ar->wmi.mem_chunks[idx].req_id = req_id;
4411 ar->wmi.num_mem_chunks++;
4412
Felix Fietkaub0578862015-11-30 19:32:01 +01004413 return num_units;
4414}
4415
4416static int ath10k_wmi_alloc_host_mem(struct ath10k *ar, u32 req_id,
4417 u32 num_units, u32 unit_len)
4418{
4419 int ret;
4420
4421 while (num_units) {
4422 ret = ath10k_wmi_alloc_chunk(ar, req_id, num_units, unit_len);
4423 if (ret < 0)
4424 return ret;
4425
4426 num_units -= ret;
4427 }
4428
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004429 return 0;
4430}
4431
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05304432static bool
4433ath10k_wmi_is_host_mem_allocated(struct ath10k *ar,
4434 const struct wlan_host_mem_req **mem_reqs,
4435 u32 num_mem_reqs)
4436{
4437 u32 req_id, num_units, unit_size, num_unit_info;
4438 u32 pool_size;
4439 int i, j;
4440 bool found;
4441
4442 if (ar->wmi.num_mem_chunks != num_mem_reqs)
4443 return false;
4444
4445 for (i = 0; i < num_mem_reqs; ++i) {
4446 req_id = __le32_to_cpu(mem_reqs[i]->req_id);
4447 num_units = __le32_to_cpu(mem_reqs[i]->num_units);
4448 unit_size = __le32_to_cpu(mem_reqs[i]->unit_size);
4449 num_unit_info = __le32_to_cpu(mem_reqs[i]->num_unit_info);
4450
4451 if (num_unit_info & NUM_UNITS_IS_NUM_ACTIVE_PEERS) {
4452 if (ar->num_active_peers)
4453 num_units = ar->num_active_peers + 1;
4454 else
4455 num_units = ar->max_num_peers + 1;
4456 } else if (num_unit_info & NUM_UNITS_IS_NUM_PEERS) {
4457 num_units = ar->max_num_peers + 1;
4458 } else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS) {
4459 num_units = ar->max_num_vdevs + 1;
4460 }
4461
4462 found = false;
4463 for (j = 0; j < ar->wmi.num_mem_chunks; j++) {
4464 if (ar->wmi.mem_chunks[j].req_id == req_id) {
4465 pool_size = num_units * round_up(unit_size, 4);
4466 if (ar->wmi.mem_chunks[j].len == pool_size) {
4467 found = true;
4468 break;
4469 }
4470 }
4471 }
4472 if (!found)
4473 return false;
4474 }
4475
4476 return true;
4477}
4478
Michal Kaziord7579d12014-12-03 10:10:54 +02004479static int
4480ath10k_wmi_main_op_pull_svc_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
4481 struct wmi_svc_rdy_ev_arg *arg)
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004482{
4483 struct wmi_service_ready_event *ev;
4484 size_t i, n;
4485
4486 if (skb->len < sizeof(*ev))
4487 return -EPROTO;
4488
4489 ev = (void *)skb->data;
4490 skb_pull(skb, sizeof(*ev));
4491 arg->min_tx_power = ev->hw_min_tx_power;
4492 arg->max_tx_power = ev->hw_max_tx_power;
4493 arg->ht_cap = ev->ht_cap_info;
4494 arg->vht_cap = ev->vht_cap_info;
4495 arg->sw_ver0 = ev->sw_version;
4496 arg->sw_ver1 = ev->sw_version_1;
4497 arg->phy_capab = ev->phy_capability;
4498 arg->num_rf_chains = ev->num_rf_chains;
4499 arg->eeprom_rd = ev->hal_reg_capabilities.eeprom_rd;
4500 arg->num_mem_reqs = ev->num_mem_reqs;
4501 arg->service_map = ev->wmi_service_bitmap;
Michal Kazior2a3e60d2014-11-27 10:11:15 +01004502 arg->service_map_len = sizeof(ev->wmi_service_bitmap);
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004503
4504 n = min_t(size_t, __le32_to_cpu(arg->num_mem_reqs),
4505 ARRAY_SIZE(arg->mem_reqs));
4506 for (i = 0; i < n; i++)
4507 arg->mem_reqs[i] = &ev->mem_reqs[i];
4508
4509 if (skb->len <
4510 __le32_to_cpu(arg->num_mem_reqs) * sizeof(arg->mem_reqs[0]))
4511 return -EPROTO;
4512
4513 return 0;
4514}
4515
Michal Kaziord7579d12014-12-03 10:10:54 +02004516static int
4517ath10k_wmi_10x_op_pull_svc_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
4518 struct wmi_svc_rdy_ev_arg *arg)
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004519{
4520 struct wmi_10x_service_ready_event *ev;
4521 int i, n;
4522
4523 if (skb->len < sizeof(*ev))
4524 return -EPROTO;
4525
4526 ev = (void *)skb->data;
4527 skb_pull(skb, sizeof(*ev));
4528 arg->min_tx_power = ev->hw_min_tx_power;
4529 arg->max_tx_power = ev->hw_max_tx_power;
4530 arg->ht_cap = ev->ht_cap_info;
4531 arg->vht_cap = ev->vht_cap_info;
4532 arg->sw_ver0 = ev->sw_version;
4533 arg->phy_capab = ev->phy_capability;
4534 arg->num_rf_chains = ev->num_rf_chains;
4535 arg->eeprom_rd = ev->hal_reg_capabilities.eeprom_rd;
4536 arg->num_mem_reqs = ev->num_mem_reqs;
4537 arg->service_map = ev->wmi_service_bitmap;
Michal Kazior2a3e60d2014-11-27 10:11:15 +01004538 arg->service_map_len = sizeof(ev->wmi_service_bitmap);
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004539
4540 n = min_t(size_t, __le32_to_cpu(arg->num_mem_reqs),
4541 ARRAY_SIZE(arg->mem_reqs));
4542 for (i = 0; i < n; i++)
4543 arg->mem_reqs[i] = &ev->mem_reqs[i];
4544
4545 if (skb->len <
4546 __le32_to_cpu(arg->num_mem_reqs) * sizeof(arg->mem_reqs[0]))
4547 return -EPROTO;
4548
4549 return 0;
4550}
4551
Raja Manic8ecfc12015-07-29 11:40:38 +03004552static void ath10k_wmi_event_service_ready_work(struct work_struct *work)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004553{
Raja Manic8ecfc12015-07-29 11:40:38 +03004554 struct ath10k *ar = container_of(work, struct ath10k, svc_rdy_work);
4555 struct sk_buff *skb = ar->svc_rdy_skb;
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004556 struct wmi_svc_rdy_ev_arg arg = {};
4557 u32 num_units, req_id, unit_size, num_mem_reqs, num_unit_info, i;
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004558 int ret;
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05304559 bool allocated;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004560
Raja Manic8ecfc12015-07-29 11:40:38 +03004561 if (!skb) {
4562 ath10k_warn(ar, "invalid service ready event skb\n");
4563 return;
4564 }
4565
Michal Kaziord7579d12014-12-03 10:10:54 +02004566 ret = ath10k_wmi_pull_svc_rdy(ar, skb, &arg);
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004567 if (ret) {
4568 ath10k_warn(ar, "failed to parse service ready: %d\n", ret);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004569 return;
4570 }
4571
Michal Kaziord7579d12014-12-03 10:10:54 +02004572 memset(&ar->wmi.svc_map, 0, sizeof(ar->wmi.svc_map));
4573 ath10k_wmi_map_svc(ar, arg.service_map, ar->wmi.svc_map,
4574 arg.service_map_len);
4575
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004576 ar->hw_min_tx_power = __le32_to_cpu(arg.min_tx_power);
4577 ar->hw_max_tx_power = __le32_to_cpu(arg.max_tx_power);
4578 ar->ht_cap_info = __le32_to_cpu(arg.ht_cap);
4579 ar->vht_cap_info = __le32_to_cpu(arg.vht_cap);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004580 ar->fw_version_major =
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004581 (__le32_to_cpu(arg.sw_ver0) & 0xff000000) >> 24;
4582 ar->fw_version_minor = (__le32_to_cpu(arg.sw_ver0) & 0x00ffffff);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004583 ar->fw_version_release =
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004584 (__le32_to_cpu(arg.sw_ver1) & 0xffff0000) >> 16;
4585 ar->fw_version_build = (__le32_to_cpu(arg.sw_ver1) & 0x0000ffff);
4586 ar->phy_capability = __le32_to_cpu(arg.phy_capab);
4587 ar->num_rf_chains = __le32_to_cpu(arg.num_rf_chains);
4588 ar->ath_common.regulatory.current_rd = __le32_to_cpu(arg.eeprom_rd);
4589
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004590 ath10k_dbg_dump(ar, ATH10K_DBG_WMI, NULL, "wmi svc: ",
Michal Kazior2a3e60d2014-11-27 10:11:15 +01004591 arg.service_map, arg.service_map_len);
Michal Kazior8865bee42013-07-24 12:36:46 +02004592
Kalle Valo1a222432013-09-27 19:55:07 +03004593 /* only manually set fw features when not using FW IE format */
4594 if (ar->fw_api == 1 && ar->fw_version_build > 636)
Michal Kazior0d9b0432013-08-09 10:13:33 +02004595 set_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features);
4596
Raja Mani5c8726e2015-06-22 20:22:26 +05304597 if (ar->num_rf_chains > ar->max_spatial_stream) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02004598 ath10k_warn(ar, "hardware advertises support for more spatial streams than it should (%d > %d)\n",
Raja Mani5c8726e2015-06-22 20:22:26 +05304599 ar->num_rf_chains, ar->max_spatial_stream);
4600 ar->num_rf_chains = ar->max_spatial_stream;
Michal Kazior8865bee42013-07-24 12:36:46 +02004601 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03004602
Rajkumar Manoharan166de3f2015-10-27 17:51:11 +05304603 if (!ar->cfg_tx_chainmask) {
4604 ar->cfg_tx_chainmask = (1 << ar->num_rf_chains) - 1;
4605 ar->cfg_rx_chainmask = (1 << ar->num_rf_chains) - 1;
4606 }
Michal Kaziorfdb959c2014-09-18 15:21:19 +02004607
Kalle Valo5e3dd152013-06-12 20:52:10 +03004608 if (strlen(ar->hw->wiphy->fw_version) == 0) {
4609 snprintf(ar->hw->wiphy->fw_version,
4610 sizeof(ar->hw->wiphy->fw_version),
4611 "%u.%u.%u.%u",
4612 ar->fw_version_major,
4613 ar->fw_version_minor,
4614 ar->fw_version_release,
4615 ar->fw_version_build);
4616 }
4617
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004618 num_mem_reqs = __le32_to_cpu(arg.num_mem_reqs);
4619 if (num_mem_reqs > WMI_MAX_MEM_REQS) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02004620 ath10k_warn(ar, "requested memory chunks number (%d) exceeds the limit\n",
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004621 num_mem_reqs);
4622 return;
Bartosz Markowski6f97d252013-09-26 17:47:09 +02004623 }
4624
Raja Manib0399412015-06-22 20:10:17 +05304625 if (test_bit(WMI_SERVICE_PEER_CACHING, ar->wmi.svc_map)) {
Michal Kazior99ad1cb2016-03-01 13:16:11 +01004626 if (test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL,
4627 ar->fw_features))
4628 ar->num_active_peers = TARGET_10_4_QCACHE_ACTIVE_PEERS_PFC +
4629 ar->max_num_vdevs;
4630 else
4631 ar->num_active_peers = TARGET_10_4_QCACHE_ACTIVE_PEERS +
4632 ar->max_num_vdevs;
4633
Raja Manib0399412015-06-22 20:10:17 +05304634 ar->max_num_peers = TARGET_10_4_NUM_QCACHE_PEERS_MAX +
Raja Mani5699a6f2016-01-29 16:35:12 +05304635 ar->max_num_vdevs;
Raja Manib0399412015-06-22 20:10:17 +05304636 ar->num_tids = ar->num_active_peers * 2;
4637 ar->max_num_stations = TARGET_10_4_NUM_QCACHE_PEERS_MAX;
4638 }
4639
4640 /* TODO: Adjust max peer count for cases like WMI_SERVICE_RATECTRL_CACHE
4641 * and WMI_SERVICE_IRAM_TIDS, etc.
4642 */
4643
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05304644 allocated = ath10k_wmi_is_host_mem_allocated(ar, arg.mem_reqs,
4645 num_mem_reqs);
4646 if (allocated)
4647 goto skip_mem_alloc;
4648
4649 /* Either this event is received during boot time or there is a change
4650 * in memory requirement from firmware when compared to last request.
4651 * Free any old memory and do a fresh allocation based on the current
4652 * memory requirement.
4653 */
4654 ath10k_wmi_free_host_mem(ar);
4655
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004656 for (i = 0; i < num_mem_reqs; ++i) {
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004657 req_id = __le32_to_cpu(arg.mem_reqs[i]->req_id);
4658 num_units = __le32_to_cpu(arg.mem_reqs[i]->num_units);
4659 unit_size = __le32_to_cpu(arg.mem_reqs[i]->unit_size);
4660 num_unit_info = __le32_to_cpu(arg.mem_reqs[i]->num_unit_info);
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004661
Raja Manib0399412015-06-22 20:10:17 +05304662 if (num_unit_info & NUM_UNITS_IS_NUM_ACTIVE_PEERS) {
4663 if (ar->num_active_peers)
4664 num_units = ar->num_active_peers + 1;
4665 else
4666 num_units = ar->max_num_peers + 1;
4667 } else if (num_unit_info & NUM_UNITS_IS_NUM_PEERS) {
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004668 /* number of units to allocate is number of
4669 * peers, 1 extra for self peer on target */
4670 /* this needs to be tied, host and target
4671 * can get out of sync */
Raja Manib0399412015-06-22 20:10:17 +05304672 num_units = ar->max_num_peers + 1;
4673 } else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS) {
4674 num_units = ar->max_num_vdevs + 1;
4675 }
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004676
Michal Kazior7aa7a722014-08-25 12:09:38 +02004677 ath10k_dbg(ar, ATH10K_DBG_WMI,
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004678 "wmi mem_req_id %d num_units %d num_unit_info %d unit size %d actual units %d\n",
4679 req_id,
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004680 __le32_to_cpu(arg.mem_reqs[i]->num_units),
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004681 num_unit_info,
4682 unit_size,
4683 num_units);
4684
4685 ret = ath10k_wmi_alloc_host_mem(ar, req_id, num_units,
4686 unit_size);
4687 if (ret)
4688 return;
4689 }
4690
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05304691skip_mem_alloc:
Michal Kazior7aa7a722014-08-25 12:09:38 +02004692 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kaziorca996ec2014-12-03 10:11:32 +02004693 "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 +02004694 __le32_to_cpu(arg.min_tx_power),
4695 __le32_to_cpu(arg.max_tx_power),
4696 __le32_to_cpu(arg.ht_cap),
4697 __le32_to_cpu(arg.vht_cap),
4698 __le32_to_cpu(arg.sw_ver0),
4699 __le32_to_cpu(arg.sw_ver1),
Michal Kaziorca996ec2014-12-03 10:11:32 +02004700 __le32_to_cpu(arg.fw_build),
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004701 __le32_to_cpu(arg.phy_capab),
4702 __le32_to_cpu(arg.num_rf_chains),
4703 __le32_to_cpu(arg.eeprom_rd),
4704 __le32_to_cpu(arg.num_mem_reqs));
Bartosz Markowski6f97d252013-09-26 17:47:09 +02004705
Raja Manic8ecfc12015-07-29 11:40:38 +03004706 dev_kfree_skb(skb);
4707 ar->svc_rdy_skb = NULL;
Bartosz Markowski6f97d252013-09-26 17:47:09 +02004708 complete(&ar->wmi.service_ready);
4709}
4710
Raja Manic8ecfc12015-07-29 11:40:38 +03004711void ath10k_wmi_event_service_ready(struct ath10k *ar, struct sk_buff *skb)
4712{
4713 ar->svc_rdy_skb = skb;
4714 queue_work(ar->workqueue_aux, &ar->svc_rdy_work);
4715}
4716
Michal Kaziord7579d12014-12-03 10:10:54 +02004717static int ath10k_wmi_op_pull_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
4718 struct wmi_rdy_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02004719{
4720 struct wmi_ready_event *ev = (void *)skb->data;
4721
4722 if (skb->len < sizeof(*ev))
4723 return -EPROTO;
4724
4725 skb_pull(skb, sizeof(*ev));
4726 arg->sw_version = ev->sw_version;
4727 arg->abi_version = ev->abi_version;
4728 arg->status = ev->status;
4729 arg->mac_addr = ev->mac_addr.addr;
4730
4731 return 0;
4732}
4733
Michal Kaziorc1a46542015-03-10 16:21:54 +02004734static int ath10k_wmi_op_pull_roam_ev(struct ath10k *ar, struct sk_buff *skb,
4735 struct wmi_roam_ev_arg *arg)
4736{
4737 struct wmi_roam_ev *ev = (void *)skb->data;
4738
4739 if (skb->len < sizeof(*ev))
4740 return -EPROTO;
4741
4742 skb_pull(skb, sizeof(*ev));
4743 arg->vdev_id = ev->vdev_id;
4744 arg->reason = ev->reason;
4745
4746 return 0;
4747}
4748
Michal Kazior0226d602014-12-03 10:11:22 +02004749int ath10k_wmi_event_ready(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004750{
Michal Kazior32653cf2014-12-03 10:10:26 +02004751 struct wmi_rdy_ev_arg arg = {};
4752 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004753
Michal Kaziord7579d12014-12-03 10:10:54 +02004754 ret = ath10k_wmi_pull_rdy(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02004755 if (ret) {
4756 ath10k_warn(ar, "failed to parse ready event: %d\n", ret);
4757 return ret;
4758 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03004759
Michal Kazior7aa7a722014-08-25 12:09:38 +02004760 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior32653cf2014-12-03 10:10:26 +02004761 "wmi event ready sw_version %u abi_version %u mac_addr %pM status %d\n",
4762 __le32_to_cpu(arg.sw_version),
4763 __le32_to_cpu(arg.abi_version),
4764 arg.mac_addr,
4765 __le32_to_cpu(arg.status));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004766
Michal Kazior32653cf2014-12-03 10:10:26 +02004767 ether_addr_copy(ar->mac_addr, arg.mac_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004768 complete(&ar->wmi.unified_ready);
4769 return 0;
4770}
4771
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02004772static int ath10k_wmi_event_temperature(struct ath10k *ar, struct sk_buff *skb)
4773{
4774 const struct wmi_pdev_temperature_event *ev;
4775
4776 ev = (struct wmi_pdev_temperature_event *)skb->data;
4777 if (WARN_ON(skb->len < sizeof(*ev)))
4778 return -EPROTO;
4779
Rajkumar Manoharanac2953f2014-12-17 12:22:26 +02004780 ath10k_thermal_event_temperature(ar, __le32_to_cpu(ev->temperature));
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02004781 return 0;
4782}
4783
Michal Kaziord7579d12014-12-03 10:10:54 +02004784static void ath10k_wmi_op_rx(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004785{
4786 struct wmi_cmd_hdr *cmd_hdr;
4787 enum wmi_event_id id;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004788
4789 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
4790 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
4791
4792 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
Michal Kazior469d4792015-06-08 13:23:27 +02004793 goto out;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004794
Michal Kaziord35a6c12014-09-02 11:00:21 +03004795 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004796
4797 switch (id) {
4798 case WMI_MGMT_RX_EVENTID:
4799 ath10k_wmi_event_mgmt_rx(ar, skb);
4800 /* mgmt_rx() owns the skb now! */
4801 return;
4802 case WMI_SCAN_EVENTID:
4803 ath10k_wmi_event_scan(ar, skb);
4804 break;
4805 case WMI_CHAN_INFO_EVENTID:
4806 ath10k_wmi_event_chan_info(ar, skb);
4807 break;
4808 case WMI_ECHO_EVENTID:
4809 ath10k_wmi_event_echo(ar, skb);
4810 break;
4811 case WMI_DEBUG_MESG_EVENTID:
4812 ath10k_wmi_event_debug_mesg(ar, skb);
4813 break;
4814 case WMI_UPDATE_STATS_EVENTID:
4815 ath10k_wmi_event_update_stats(ar, skb);
4816 break;
4817 case WMI_VDEV_START_RESP_EVENTID:
4818 ath10k_wmi_event_vdev_start_resp(ar, skb);
4819 break;
4820 case WMI_VDEV_STOPPED_EVENTID:
4821 ath10k_wmi_event_vdev_stopped(ar, skb);
4822 break;
4823 case WMI_PEER_STA_KICKOUT_EVENTID:
4824 ath10k_wmi_event_peer_sta_kickout(ar, skb);
4825 break;
4826 case WMI_HOST_SWBA_EVENTID:
4827 ath10k_wmi_event_host_swba(ar, skb);
4828 break;
4829 case WMI_TBTTOFFSET_UPDATE_EVENTID:
4830 ath10k_wmi_event_tbttoffset_update(ar, skb);
4831 break;
4832 case WMI_PHYERR_EVENTID:
4833 ath10k_wmi_event_phyerr(ar, skb);
4834 break;
4835 case WMI_ROAM_EVENTID:
4836 ath10k_wmi_event_roam(ar, skb);
4837 break;
4838 case WMI_PROFILE_MATCH:
4839 ath10k_wmi_event_profile_match(ar, skb);
4840 break;
4841 case WMI_DEBUG_PRINT_EVENTID:
4842 ath10k_wmi_event_debug_print(ar, skb);
4843 break;
4844 case WMI_PDEV_QVIT_EVENTID:
4845 ath10k_wmi_event_pdev_qvit(ar, skb);
4846 break;
4847 case WMI_WLAN_PROFILE_DATA_EVENTID:
4848 ath10k_wmi_event_wlan_profile_data(ar, skb);
4849 break;
4850 case WMI_RTT_MEASUREMENT_REPORT_EVENTID:
4851 ath10k_wmi_event_rtt_measurement_report(ar, skb);
4852 break;
4853 case WMI_TSF_MEASUREMENT_REPORT_EVENTID:
4854 ath10k_wmi_event_tsf_measurement_report(ar, skb);
4855 break;
4856 case WMI_RTT_ERROR_REPORT_EVENTID:
4857 ath10k_wmi_event_rtt_error_report(ar, skb);
4858 break;
4859 case WMI_WOW_WAKEUP_HOST_EVENTID:
4860 ath10k_wmi_event_wow_wakeup_host(ar, skb);
4861 break;
4862 case WMI_DCS_INTERFERENCE_EVENTID:
4863 ath10k_wmi_event_dcs_interference(ar, skb);
4864 break;
4865 case WMI_PDEV_TPC_CONFIG_EVENTID:
4866 ath10k_wmi_event_pdev_tpc_config(ar, skb);
4867 break;
4868 case WMI_PDEV_FTM_INTG_EVENTID:
4869 ath10k_wmi_event_pdev_ftm_intg(ar, skb);
4870 break;
4871 case WMI_GTK_OFFLOAD_STATUS_EVENTID:
4872 ath10k_wmi_event_gtk_offload_status(ar, skb);
4873 break;
4874 case WMI_GTK_REKEY_FAIL_EVENTID:
4875 ath10k_wmi_event_gtk_rekey_fail(ar, skb);
4876 break;
4877 case WMI_TX_DELBA_COMPLETE_EVENTID:
4878 ath10k_wmi_event_delba_complete(ar, skb);
4879 break;
4880 case WMI_TX_ADDBA_COMPLETE_EVENTID:
4881 ath10k_wmi_event_addba_complete(ar, skb);
4882 break;
4883 case WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID:
4884 ath10k_wmi_event_vdev_install_key_complete(ar, skb);
4885 break;
4886 case WMI_SERVICE_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02004887 ath10k_wmi_event_service_ready(ar, skb);
Raja Manic8ecfc12015-07-29 11:40:38 +03004888 return;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004889 case WMI_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02004890 ath10k_wmi_event_ready(ar, skb);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004891 break;
4892 default:
Michal Kazior7aa7a722014-08-25 12:09:38 +02004893 ath10k_warn(ar, "Unknown eventid: %d\n", id);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004894 break;
4895 }
4896
Michal Kazior469d4792015-06-08 13:23:27 +02004897out:
Kalle Valo5e3dd152013-06-12 20:52:10 +03004898 dev_kfree_skb(skb);
4899}
4900
Michal Kaziord7579d12014-12-03 10:10:54 +02004901static void ath10k_wmi_10_1_op_rx(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004902{
4903 struct wmi_cmd_hdr *cmd_hdr;
4904 enum wmi_10x_event_id id;
Kalle Valo43d2a302014-09-10 18:23:30 +03004905 bool consumed;
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004906
4907 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
4908 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
4909
4910 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
Michal Kazior469d4792015-06-08 13:23:27 +02004911 goto out;
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004912
Michal Kaziord35a6c12014-09-02 11:00:21 +03004913 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004914
Kalle Valo43d2a302014-09-10 18:23:30 +03004915 consumed = ath10k_tm_event_wmi(ar, id, skb);
4916
4917 /* Ready event must be handled normally also in UTF mode so that we
4918 * know the UTF firmware has booted, others we are just bypass WMI
4919 * events to testmode.
4920 */
4921 if (consumed && id != WMI_10X_READY_EVENTID) {
4922 ath10k_dbg(ar, ATH10K_DBG_WMI,
4923 "wmi testmode consumed 0x%x\n", id);
4924 goto out;
4925 }
4926
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004927 switch (id) {
4928 case WMI_10X_MGMT_RX_EVENTID:
4929 ath10k_wmi_event_mgmt_rx(ar, skb);
4930 /* mgmt_rx() owns the skb now! */
4931 return;
4932 case WMI_10X_SCAN_EVENTID:
4933 ath10k_wmi_event_scan(ar, skb);
4934 break;
4935 case WMI_10X_CHAN_INFO_EVENTID:
4936 ath10k_wmi_event_chan_info(ar, skb);
4937 break;
4938 case WMI_10X_ECHO_EVENTID:
4939 ath10k_wmi_event_echo(ar, skb);
4940 break;
4941 case WMI_10X_DEBUG_MESG_EVENTID:
4942 ath10k_wmi_event_debug_mesg(ar, skb);
4943 break;
4944 case WMI_10X_UPDATE_STATS_EVENTID:
4945 ath10k_wmi_event_update_stats(ar, skb);
4946 break;
4947 case WMI_10X_VDEV_START_RESP_EVENTID:
4948 ath10k_wmi_event_vdev_start_resp(ar, skb);
4949 break;
4950 case WMI_10X_VDEV_STOPPED_EVENTID:
4951 ath10k_wmi_event_vdev_stopped(ar, skb);
4952 break;
4953 case WMI_10X_PEER_STA_KICKOUT_EVENTID:
4954 ath10k_wmi_event_peer_sta_kickout(ar, skb);
4955 break;
4956 case WMI_10X_HOST_SWBA_EVENTID:
4957 ath10k_wmi_event_host_swba(ar, skb);
4958 break;
4959 case WMI_10X_TBTTOFFSET_UPDATE_EVENTID:
4960 ath10k_wmi_event_tbttoffset_update(ar, skb);
4961 break;
4962 case WMI_10X_PHYERR_EVENTID:
4963 ath10k_wmi_event_phyerr(ar, skb);
4964 break;
4965 case WMI_10X_ROAM_EVENTID:
4966 ath10k_wmi_event_roam(ar, skb);
4967 break;
4968 case WMI_10X_PROFILE_MATCH:
4969 ath10k_wmi_event_profile_match(ar, skb);
4970 break;
4971 case WMI_10X_DEBUG_PRINT_EVENTID:
4972 ath10k_wmi_event_debug_print(ar, skb);
4973 break;
4974 case WMI_10X_PDEV_QVIT_EVENTID:
4975 ath10k_wmi_event_pdev_qvit(ar, skb);
4976 break;
4977 case WMI_10X_WLAN_PROFILE_DATA_EVENTID:
4978 ath10k_wmi_event_wlan_profile_data(ar, skb);
4979 break;
4980 case WMI_10X_RTT_MEASUREMENT_REPORT_EVENTID:
4981 ath10k_wmi_event_rtt_measurement_report(ar, skb);
4982 break;
4983 case WMI_10X_TSF_MEASUREMENT_REPORT_EVENTID:
4984 ath10k_wmi_event_tsf_measurement_report(ar, skb);
4985 break;
4986 case WMI_10X_RTT_ERROR_REPORT_EVENTID:
4987 ath10k_wmi_event_rtt_error_report(ar, skb);
4988 break;
4989 case WMI_10X_WOW_WAKEUP_HOST_EVENTID:
4990 ath10k_wmi_event_wow_wakeup_host(ar, skb);
4991 break;
4992 case WMI_10X_DCS_INTERFERENCE_EVENTID:
4993 ath10k_wmi_event_dcs_interference(ar, skb);
4994 break;
4995 case WMI_10X_PDEV_TPC_CONFIG_EVENTID:
4996 ath10k_wmi_event_pdev_tpc_config(ar, skb);
4997 break;
4998 case WMI_10X_INST_RSSI_STATS_EVENTID:
4999 ath10k_wmi_event_inst_rssi_stats(ar, skb);
5000 break;
5001 case WMI_10X_VDEV_STANDBY_REQ_EVENTID:
5002 ath10k_wmi_event_vdev_standby_req(ar, skb);
5003 break;
5004 case WMI_10X_VDEV_RESUME_REQ_EVENTID:
5005 ath10k_wmi_event_vdev_resume_req(ar, skb);
5006 break;
5007 case WMI_10X_SERVICE_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02005008 ath10k_wmi_event_service_ready(ar, skb);
Raja Manic8ecfc12015-07-29 11:40:38 +03005009 return;
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02005010 case WMI_10X_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02005011 ath10k_wmi_event_ready(ar, skb);
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02005012 break;
Kalle Valo43d2a302014-09-10 18:23:30 +03005013 case WMI_10X_PDEV_UTF_EVENTID:
5014 /* ignore utf events */
5015 break;
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02005016 default:
Michal Kazior7aa7a722014-08-25 12:09:38 +02005017 ath10k_warn(ar, "Unknown eventid: %d\n", id);
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02005018 break;
5019 }
5020
Kalle Valo43d2a302014-09-10 18:23:30 +03005021out:
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02005022 dev_kfree_skb(skb);
5023}
5024
Michal Kaziord7579d12014-12-03 10:10:54 +02005025static void ath10k_wmi_10_2_op_rx(struct ath10k *ar, struct sk_buff *skb)
Michal Kazior24c88f72014-07-25 13:32:17 +02005026{
5027 struct wmi_cmd_hdr *cmd_hdr;
5028 enum wmi_10_2_event_id id;
5029
5030 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
5031 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
5032
5033 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
Michal Kazior469d4792015-06-08 13:23:27 +02005034 goto out;
Michal Kazior24c88f72014-07-25 13:32:17 +02005035
Michal Kaziord35a6c12014-09-02 11:00:21 +03005036 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
Michal Kazior24c88f72014-07-25 13:32:17 +02005037
5038 switch (id) {
5039 case WMI_10_2_MGMT_RX_EVENTID:
5040 ath10k_wmi_event_mgmt_rx(ar, skb);
5041 /* mgmt_rx() owns the skb now! */
5042 return;
5043 case WMI_10_2_SCAN_EVENTID:
5044 ath10k_wmi_event_scan(ar, skb);
5045 break;
5046 case WMI_10_2_CHAN_INFO_EVENTID:
5047 ath10k_wmi_event_chan_info(ar, skb);
5048 break;
5049 case WMI_10_2_ECHO_EVENTID:
5050 ath10k_wmi_event_echo(ar, skb);
5051 break;
5052 case WMI_10_2_DEBUG_MESG_EVENTID:
5053 ath10k_wmi_event_debug_mesg(ar, skb);
5054 break;
5055 case WMI_10_2_UPDATE_STATS_EVENTID:
5056 ath10k_wmi_event_update_stats(ar, skb);
5057 break;
5058 case WMI_10_2_VDEV_START_RESP_EVENTID:
5059 ath10k_wmi_event_vdev_start_resp(ar, skb);
5060 break;
5061 case WMI_10_2_VDEV_STOPPED_EVENTID:
5062 ath10k_wmi_event_vdev_stopped(ar, skb);
5063 break;
5064 case WMI_10_2_PEER_STA_KICKOUT_EVENTID:
5065 ath10k_wmi_event_peer_sta_kickout(ar, skb);
5066 break;
5067 case WMI_10_2_HOST_SWBA_EVENTID:
5068 ath10k_wmi_event_host_swba(ar, skb);
5069 break;
5070 case WMI_10_2_TBTTOFFSET_UPDATE_EVENTID:
5071 ath10k_wmi_event_tbttoffset_update(ar, skb);
5072 break;
5073 case WMI_10_2_PHYERR_EVENTID:
5074 ath10k_wmi_event_phyerr(ar, skb);
5075 break;
5076 case WMI_10_2_ROAM_EVENTID:
5077 ath10k_wmi_event_roam(ar, skb);
5078 break;
5079 case WMI_10_2_PROFILE_MATCH:
5080 ath10k_wmi_event_profile_match(ar, skb);
5081 break;
5082 case WMI_10_2_DEBUG_PRINT_EVENTID:
5083 ath10k_wmi_event_debug_print(ar, skb);
5084 break;
5085 case WMI_10_2_PDEV_QVIT_EVENTID:
5086 ath10k_wmi_event_pdev_qvit(ar, skb);
5087 break;
5088 case WMI_10_2_WLAN_PROFILE_DATA_EVENTID:
5089 ath10k_wmi_event_wlan_profile_data(ar, skb);
5090 break;
5091 case WMI_10_2_RTT_MEASUREMENT_REPORT_EVENTID:
5092 ath10k_wmi_event_rtt_measurement_report(ar, skb);
5093 break;
5094 case WMI_10_2_TSF_MEASUREMENT_REPORT_EVENTID:
5095 ath10k_wmi_event_tsf_measurement_report(ar, skb);
5096 break;
5097 case WMI_10_2_RTT_ERROR_REPORT_EVENTID:
5098 ath10k_wmi_event_rtt_error_report(ar, skb);
5099 break;
5100 case WMI_10_2_WOW_WAKEUP_HOST_EVENTID:
5101 ath10k_wmi_event_wow_wakeup_host(ar, skb);
5102 break;
5103 case WMI_10_2_DCS_INTERFERENCE_EVENTID:
5104 ath10k_wmi_event_dcs_interference(ar, skb);
5105 break;
5106 case WMI_10_2_PDEV_TPC_CONFIG_EVENTID:
5107 ath10k_wmi_event_pdev_tpc_config(ar, skb);
5108 break;
5109 case WMI_10_2_INST_RSSI_STATS_EVENTID:
5110 ath10k_wmi_event_inst_rssi_stats(ar, skb);
5111 break;
5112 case WMI_10_2_VDEV_STANDBY_REQ_EVENTID:
5113 ath10k_wmi_event_vdev_standby_req(ar, skb);
5114 break;
5115 case WMI_10_2_VDEV_RESUME_REQ_EVENTID:
5116 ath10k_wmi_event_vdev_resume_req(ar, skb);
5117 break;
5118 case WMI_10_2_SERVICE_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02005119 ath10k_wmi_event_service_ready(ar, skb);
Raja Manic8ecfc12015-07-29 11:40:38 +03005120 return;
Michal Kazior24c88f72014-07-25 13:32:17 +02005121 case WMI_10_2_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02005122 ath10k_wmi_event_ready(ar, skb);
Michal Kazior24c88f72014-07-25 13:32:17 +02005123 break;
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02005124 case WMI_10_2_PDEV_TEMPERATURE_EVENTID:
5125 ath10k_wmi_event_temperature(ar, skb);
5126 break;
Michal Kazior24c88f72014-07-25 13:32:17 +02005127 case WMI_10_2_RTT_KEEPALIVE_EVENTID:
5128 case WMI_10_2_GPIO_INPUT_EVENTID:
5129 case WMI_10_2_PEER_RATECODE_LIST_EVENTID:
5130 case WMI_10_2_GENERIC_BUFFER_EVENTID:
5131 case WMI_10_2_MCAST_BUF_RELEASE_EVENTID:
5132 case WMI_10_2_MCAST_LIST_AGEOUT_EVENTID:
5133 case WMI_10_2_WDS_PEER_EVENTID:
Michal Kazior7aa7a722014-08-25 12:09:38 +02005134 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior24c88f72014-07-25 13:32:17 +02005135 "received event id %d not implemented\n", id);
5136 break;
5137 default:
Michal Kazior7aa7a722014-08-25 12:09:38 +02005138 ath10k_warn(ar, "Unknown eventid: %d\n", id);
Michal Kazior24c88f72014-07-25 13:32:17 +02005139 break;
5140 }
5141
Michal Kazior469d4792015-06-08 13:23:27 +02005142out:
Michal Kazior24c88f72014-07-25 13:32:17 +02005143 dev_kfree_skb(skb);
5144}
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02005145
Raja Mani1c092962015-06-22 20:10:16 +05305146static void ath10k_wmi_10_4_op_rx(struct ath10k *ar, struct sk_buff *skb)
5147{
5148 struct wmi_cmd_hdr *cmd_hdr;
5149 enum wmi_10_4_event_id id;
5150
5151 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
5152 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
5153
5154 if (!skb_pull(skb, sizeof(struct wmi_cmd_hdr)))
5155 goto out;
5156
5157 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
5158
5159 switch (id) {
5160 case WMI_10_4_MGMT_RX_EVENTID:
5161 ath10k_wmi_event_mgmt_rx(ar, skb);
5162 /* mgmt_rx() owns the skb now! */
5163 return;
Raja Mani373b48c2015-06-22 20:22:22 +05305164 case WMI_10_4_ECHO_EVENTID:
5165 ath10k_wmi_event_echo(ar, skb);
5166 break;
5167 case WMI_10_4_DEBUG_MESG_EVENTID:
5168 ath10k_wmi_event_debug_mesg(ar, skb);
5169 break;
5170 case WMI_10_4_SERVICE_READY_EVENTID:
5171 ath10k_wmi_event_service_ready(ar, skb);
Raja Manic8ecfc12015-07-29 11:40:38 +03005172 return;
Raja Manib2297ba2015-06-22 20:22:23 +05305173 case WMI_10_4_SCAN_EVENTID:
5174 ath10k_wmi_event_scan(ar, skb);
5175 break;
5176 case WMI_10_4_CHAN_INFO_EVENTID:
5177 ath10k_wmi_event_chan_info(ar, skb);
5178 break;
Raja Mani2b0a2e02015-08-14 11:13:34 +03005179 case WMI_10_4_PHYERR_EVENTID:
5180 ath10k_wmi_event_phyerr(ar, skb);
5181 break;
Raja Manid02e7522015-06-22 20:10:18 +05305182 case WMI_10_4_READY_EVENTID:
5183 ath10k_wmi_event_ready(ar, skb);
5184 break;
Raja Mani373b48c2015-06-22 20:22:22 +05305185 case WMI_10_4_PEER_STA_KICKOUT_EVENTID:
5186 ath10k_wmi_event_peer_sta_kickout(ar, skb);
5187 break;
Raja Mani3cec3be2015-06-22 20:22:21 +05305188 case WMI_10_4_HOST_SWBA_EVENTID:
5189 ath10k_wmi_event_host_swba(ar, skb);
5190 break;
Raja Mani373b48c2015-06-22 20:22:22 +05305191 case WMI_10_4_TBTTOFFSET_UPDATE_EVENTID:
5192 ath10k_wmi_event_tbttoffset_update(ar, skb);
5193 break;
5194 case WMI_10_4_DEBUG_PRINT_EVENTID:
5195 ath10k_wmi_event_debug_print(ar, skb);
5196 break;
5197 case WMI_10_4_VDEV_START_RESP_EVENTID:
5198 ath10k_wmi_event_vdev_start_resp(ar, skb);
5199 break;
5200 case WMI_10_4_VDEV_STOPPED_EVENTID:
5201 ath10k_wmi_event_vdev_stopped(ar, skb);
5202 break;
5203 case WMI_10_4_WOW_WAKEUP_HOST_EVENTID:
5204 ath10k_dbg(ar, ATH10K_DBG_WMI,
5205 "received event id %d not implemented\n", id);
5206 break;
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02005207 case WMI_10_4_UPDATE_STATS_EVENTID:
5208 ath10k_wmi_event_update_stats(ar, skb);
5209 break;
Tamizh chelvam6dd46342015-10-31 11:20:32 +02005210 case WMI_10_4_PDEV_TEMPERATURE_EVENTID:
5211 ath10k_wmi_event_temperature(ar, skb);
5212 break;
Raja Mani1c092962015-06-22 20:10:16 +05305213 default:
5214 ath10k_warn(ar, "Unknown eventid: %d\n", id);
5215 break;
5216 }
5217
5218out:
5219 dev_kfree_skb(skb);
5220}
5221
Bartosz Markowskice428702013-09-26 17:47:05 +02005222static void ath10k_wmi_process_rx(struct ath10k *ar, struct sk_buff *skb)
5223{
Michal Kaziord7579d12014-12-03 10:10:54 +02005224 int ret;
5225
5226 ret = ath10k_wmi_rx(ar, skb);
5227 if (ret)
5228 ath10k_warn(ar, "failed to process wmi rx: %d\n", ret);
Bartosz Markowskice428702013-09-26 17:47:05 +02005229}
5230
Michal Kazior95bf21f2014-05-16 17:15:39 +03005231int ath10k_wmi_connect(struct ath10k *ar)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005232{
5233 int status;
5234 struct ath10k_htc_svc_conn_req conn_req;
5235 struct ath10k_htc_svc_conn_resp conn_resp;
5236
5237 memset(&conn_req, 0, sizeof(conn_req));
5238 memset(&conn_resp, 0, sizeof(conn_resp));
5239
5240 /* these fields are the same for all service endpoints */
5241 conn_req.ep_ops.ep_tx_complete = ath10k_wmi_htc_tx_complete;
5242 conn_req.ep_ops.ep_rx_complete = ath10k_wmi_process_rx;
Michal Kaziorbe8b3942013-09-13 14:16:54 +02005243 conn_req.ep_ops.ep_tx_credits = ath10k_wmi_op_ep_tx_credits;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005244
5245 /* connect to control service */
5246 conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL;
5247
Michal Kaziorcd003fa2013-07-05 16:15:13 +03005248 status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005249 if (status) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02005250 ath10k_warn(ar, "failed to connect to WMI CONTROL service status: %d\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +03005251 status);
5252 return status;
5253 }
5254
5255 ar->wmi.eid = conn_resp.eid;
5256 return 0;
5257}
5258
Michal Kaziord7579d12014-12-03 10:10:54 +02005259static struct sk_buff *
5260ath10k_wmi_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16 rd5g,
5261 u16 ctl2g, u16 ctl5g,
5262 enum wmi_dfs_region dfs_reg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005263{
5264 struct wmi_pdev_set_regdomain_cmd *cmd;
5265 struct sk_buff *skb;
5266
Michal Kazior7aa7a722014-08-25 12:09:38 +02005267 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005268 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005269 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005270
5271 cmd = (struct wmi_pdev_set_regdomain_cmd *)skb->data;
5272 cmd->reg_domain = __cpu_to_le32(rd);
5273 cmd->reg_domain_2G = __cpu_to_le32(rd2g);
5274 cmd->reg_domain_5G = __cpu_to_le32(rd5g);
5275 cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g);
5276 cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
5277
Michal Kazior7aa7a722014-08-25 12:09:38 +02005278 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005279 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x\n",
5280 rd, rd2g, rd5g, ctl2g, ctl5g);
Michal Kaziord7579d12014-12-03 10:10:54 +02005281 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005282}
5283
Michal Kaziord7579d12014-12-03 10:10:54 +02005284static struct sk_buff *
5285ath10k_wmi_10x_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16
5286 rd5g, u16 ctl2g, u16 ctl5g,
5287 enum wmi_dfs_region dfs_reg)
Marek Puzyniak821af6a2014-03-21 17:46:57 +02005288{
5289 struct wmi_pdev_set_regdomain_cmd_10x *cmd;
5290 struct sk_buff *skb;
5291
Michal Kazior7aa7a722014-08-25 12:09:38 +02005292 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Marek Puzyniak821af6a2014-03-21 17:46:57 +02005293 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005294 return ERR_PTR(-ENOMEM);
Marek Puzyniak821af6a2014-03-21 17:46:57 +02005295
5296 cmd = (struct wmi_pdev_set_regdomain_cmd_10x *)skb->data;
5297 cmd->reg_domain = __cpu_to_le32(rd);
5298 cmd->reg_domain_2G = __cpu_to_le32(rd2g);
5299 cmd->reg_domain_5G = __cpu_to_le32(rd5g);
5300 cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g);
5301 cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
5302 cmd->dfs_domain = __cpu_to_le32(dfs_reg);
5303
Michal Kazior7aa7a722014-08-25 12:09:38 +02005304 ath10k_dbg(ar, ATH10K_DBG_WMI,
Marek Puzyniak821af6a2014-03-21 17:46:57 +02005305 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x dfs_region %x\n",
5306 rd, rd2g, rd5g, ctl2g, ctl5g, dfs_reg);
Michal Kaziord7579d12014-12-03 10:10:54 +02005307 return skb;
Marek Puzyniak821af6a2014-03-21 17:46:57 +02005308}
5309
Michal Kaziord7579d12014-12-03 10:10:54 +02005310static struct sk_buff *
5311ath10k_wmi_op_gen_pdev_suspend(struct ath10k *ar, u32 suspend_opt)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005312{
5313 struct wmi_pdev_suspend_cmd *cmd;
5314 struct sk_buff *skb;
5315
Michal Kazior7aa7a722014-08-25 12:09:38 +02005316 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005317 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005318 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005319
5320 cmd = (struct wmi_pdev_suspend_cmd *)skb->data;
Marek Puzyniak00f54822014-02-10 17:14:24 +01005321 cmd->suspend_opt = __cpu_to_le32(suspend_opt);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005322
Michal Kaziord7579d12014-12-03 10:10:54 +02005323 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005324}
5325
Michal Kaziord7579d12014-12-03 10:10:54 +02005326static struct sk_buff *
5327ath10k_wmi_op_gen_pdev_resume(struct ath10k *ar)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005328{
5329 struct sk_buff *skb;
5330
Michal Kazior7aa7a722014-08-25 12:09:38 +02005331 skb = ath10k_wmi_alloc_skb(ar, 0);
Michal Kaziord7579d12014-12-03 10:10:54 +02005332 if (!skb)
5333 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005334
Michal Kaziord7579d12014-12-03 10:10:54 +02005335 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005336}
5337
Michal Kaziord7579d12014-12-03 10:10:54 +02005338static struct sk_buff *
5339ath10k_wmi_op_gen_pdev_set_param(struct ath10k *ar, u32 id, u32 value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005340{
5341 struct wmi_pdev_set_param_cmd *cmd;
5342 struct sk_buff *skb;
5343
Bartosz Markowski226a3392013-09-26 17:47:16 +02005344 if (id == WMI_PDEV_PARAM_UNSUPPORTED) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02005345 ath10k_warn(ar, "pdev param %d not supported by firmware\n",
5346 id);
Michal Kaziord7579d12014-12-03 10:10:54 +02005347 return ERR_PTR(-EOPNOTSUPP);
Bartosz Markowski226a3392013-09-26 17:47:16 +02005348 }
5349
Michal Kazior7aa7a722014-08-25 12:09:38 +02005350 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005351 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005352 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005353
5354 cmd = (struct wmi_pdev_set_param_cmd *)skb->data;
5355 cmd->param_id = __cpu_to_le32(id);
5356 cmd->param_value = __cpu_to_le32(value);
5357
Michal Kazior7aa7a722014-08-25 12:09:38 +02005358 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set param %d value %d\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +03005359 id, value);
Michal Kaziord7579d12014-12-03 10:10:54 +02005360 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005361}
5362
Michal Kazior0226d602014-12-03 10:11:22 +02005363void ath10k_wmi_put_host_mem_chunks(struct ath10k *ar,
5364 struct wmi_host_mem_chunks *chunks)
Michal Kaziorcf9fca82014-09-18 15:21:22 +02005365{
5366 struct host_memory_chunk *chunk;
5367 int i;
5368
5369 chunks->count = __cpu_to_le32(ar->wmi.num_mem_chunks);
5370
5371 for (i = 0; i < ar->wmi.num_mem_chunks; i++) {
5372 chunk = &chunks->items[i];
5373 chunk->ptr = __cpu_to_le32(ar->wmi.mem_chunks[i].paddr);
5374 chunk->size = __cpu_to_le32(ar->wmi.mem_chunks[i].len);
5375 chunk->req_id = __cpu_to_le32(ar->wmi.mem_chunks[i].req_id);
5376
5377 ath10k_dbg(ar, ATH10K_DBG_WMI,
5378 "wmi chunk %d len %d requested, addr 0x%llx\n",
5379 i,
5380 ar->wmi.mem_chunks[i].len,
5381 (unsigned long long)ar->wmi.mem_chunks[i].paddr);
5382 }
5383}
5384
Michal Kaziord7579d12014-12-03 10:10:54 +02005385static struct sk_buff *ath10k_wmi_op_gen_init(struct ath10k *ar)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005386{
5387 struct wmi_init_cmd *cmd;
5388 struct sk_buff *buf;
5389 struct wmi_resource_config config = {};
Bartosz Markowskib3effe62013-09-26 17:47:11 +02005390 u32 len, val;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005391
5392 config.num_vdevs = __cpu_to_le32(TARGET_NUM_VDEVS);
Michal Kaziorcfd10612014-11-25 15:16:05 +01005393 config.num_peers = __cpu_to_le32(TARGET_NUM_PEERS);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005394 config.num_offload_peers = __cpu_to_le32(TARGET_NUM_OFFLOAD_PEERS);
5395
5396 config.num_offload_reorder_bufs =
5397 __cpu_to_le32(TARGET_NUM_OFFLOAD_REORDER_BUFS);
5398
5399 config.num_peer_keys = __cpu_to_le32(TARGET_NUM_PEER_KEYS);
5400 config.num_tids = __cpu_to_le32(TARGET_NUM_TIDS);
5401 config.ast_skid_limit = __cpu_to_le32(TARGET_AST_SKID_LIMIT);
5402 config.tx_chain_mask = __cpu_to_le32(TARGET_TX_CHAIN_MASK);
5403 config.rx_chain_mask = __cpu_to_le32(TARGET_RX_CHAIN_MASK);
5404 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
5405 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
5406 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
5407 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_RX_TIMEOUT_HI_PRI);
David Liuccec9032015-07-24 20:25:32 +03005408 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005409 config.scan_max_pending_reqs =
5410 __cpu_to_le32(TARGET_SCAN_MAX_PENDING_REQS);
5411
5412 config.bmiss_offload_max_vdev =
5413 __cpu_to_le32(TARGET_BMISS_OFFLOAD_MAX_VDEV);
5414
5415 config.roam_offload_max_vdev =
5416 __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_VDEV);
5417
5418 config.roam_offload_max_ap_profiles =
5419 __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_AP_PROFILES);
5420
5421 config.num_mcast_groups = __cpu_to_le32(TARGET_NUM_MCAST_GROUPS);
5422 config.num_mcast_table_elems =
5423 __cpu_to_le32(TARGET_NUM_MCAST_TABLE_ELEMS);
5424
5425 config.mcast2ucast_mode = __cpu_to_le32(TARGET_MCAST2UCAST_MODE);
5426 config.tx_dbg_log_size = __cpu_to_le32(TARGET_TX_DBG_LOG_SIZE);
5427 config.num_wds_entries = __cpu_to_le32(TARGET_NUM_WDS_ENTRIES);
5428 config.dma_burst_size = __cpu_to_le32(TARGET_DMA_BURST_SIZE);
5429 config.mac_aggr_delim = __cpu_to_le32(TARGET_MAC_AGGR_DELIM);
5430
5431 val = TARGET_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
5432 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
5433
5434 config.vow_config = __cpu_to_le32(TARGET_VOW_CONFIG);
5435
5436 config.gtk_offload_max_vdev =
5437 __cpu_to_le32(TARGET_GTK_OFFLOAD_MAX_VDEV);
5438
5439 config.num_msdu_desc = __cpu_to_le32(TARGET_NUM_MSDU_DESC);
5440 config.max_frag_entries = __cpu_to_le32(TARGET_MAX_FRAG_ENTRIES);
5441
Bartosz Markowskib3effe62013-09-26 17:47:11 +02005442 len = sizeof(*cmd) +
5443 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5444
Michal Kazior7aa7a722014-08-25 12:09:38 +02005445 buf = ath10k_wmi_alloc_skb(ar, len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005446 if (!buf)
Michal Kaziord7579d12014-12-03 10:10:54 +02005447 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005448
5449 cmd = (struct wmi_init_cmd *)buf->data;
Bartosz Markowskib3effe62013-09-26 17:47:11 +02005450
Kalle Valo5e3dd152013-06-12 20:52:10 +03005451 memcpy(&cmd->resource_config, &config, sizeof(config));
Michal Kaziorcf9fca82014-09-18 15:21:22 +02005452 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005453
Michal Kazior7aa7a722014-08-25 12:09:38 +02005454 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02005455 return buf;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005456}
5457
Michal Kaziord7579d12014-12-03 10:10:54 +02005458static struct sk_buff *ath10k_wmi_10_1_op_gen_init(struct ath10k *ar)
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005459{
5460 struct wmi_init_cmd_10x *cmd;
5461 struct sk_buff *buf;
5462 struct wmi_resource_config_10x config = {};
5463 u32 len, val;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005464
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005465 config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS);
5466 config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS);
5467 config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS);
5468 config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS);
5469 config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT);
5470 config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK);
5471 config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK);
5472 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5473 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5474 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5475 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI);
David Liuccec9032015-07-24 20:25:32 +03005476 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005477 config.scan_max_pending_reqs =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005478 __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005479
5480 config.bmiss_offload_max_vdev =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005481 __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005482
5483 config.roam_offload_max_vdev =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005484 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005485
5486 config.roam_offload_max_ap_profiles =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005487 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005488
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005489 config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005490 config.num_mcast_table_elems =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005491 __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005492
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005493 config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE);
5494 config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE);
5495 config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES);
5496 config.dma_burst_size = __cpu_to_le32(TARGET_10X_DMA_BURST_SIZE);
5497 config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005498
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005499 val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005500 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
5501
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005502 config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005503
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005504 config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC);
5505 config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005506
5507 len = sizeof(*cmd) +
5508 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5509
Michal Kazior7aa7a722014-08-25 12:09:38 +02005510 buf = ath10k_wmi_alloc_skb(ar, len);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005511 if (!buf)
Michal Kaziord7579d12014-12-03 10:10:54 +02005512 return ERR_PTR(-ENOMEM);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005513
5514 cmd = (struct wmi_init_cmd_10x *)buf->data;
5515
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005516 memcpy(&cmd->resource_config, &config, sizeof(config));
Michal Kaziorcf9fca82014-09-18 15:21:22 +02005517 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005518
Michal Kazior7aa7a722014-08-25 12:09:38 +02005519 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10x\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02005520 return buf;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005521}
5522
Michal Kaziord7579d12014-12-03 10:10:54 +02005523static struct sk_buff *ath10k_wmi_10_2_op_gen_init(struct ath10k *ar)
Michal Kazior24c88f72014-07-25 13:32:17 +02005524{
5525 struct wmi_init_cmd_10_2 *cmd;
5526 struct sk_buff *buf;
5527 struct wmi_resource_config_10x config = {};
Sujith Manoharanb6c8e282015-01-12 12:30:02 +02005528 u32 len, val, features;
Michal Kazior24c88f72014-07-25 13:32:17 +02005529
5530 config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS);
Michal Kazior24c88f72014-07-25 13:32:17 +02005531 config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS);
Anilkumar Kolliaf9a6a32016-02-23 12:19:57 +05305532 if (test_bit(WMI_SERVICE_PEER_STATS, ar->wmi.svc_map)) {
5533 config.num_peers = __cpu_to_le32(TARGET_10X_TX_STATS_NUM_PEERS);
5534 config.num_tids = __cpu_to_le32(TARGET_10X_TX_STATS_NUM_TIDS);
5535 } else {
5536 config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS);
5537 config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS);
5538 }
5539
Michal Kazior24c88f72014-07-25 13:32:17 +02005540 config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT);
5541 config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK);
5542 config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK);
5543 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5544 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5545 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5546 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI);
David Liuccec9032015-07-24 20:25:32 +03005547 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
Michal Kazior24c88f72014-07-25 13:32:17 +02005548
5549 config.scan_max_pending_reqs =
5550 __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS);
5551
5552 config.bmiss_offload_max_vdev =
5553 __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV);
5554
5555 config.roam_offload_max_vdev =
5556 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV);
5557
5558 config.roam_offload_max_ap_profiles =
5559 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES);
5560
5561 config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS);
5562 config.num_mcast_table_elems =
5563 __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS);
5564
5565 config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE);
5566 config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE);
5567 config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES);
Sujith Manoharanf6603ff2015-01-12 12:30:02 +02005568 config.dma_burst_size = __cpu_to_le32(TARGET_10_2_DMA_BURST_SIZE);
Michal Kazior24c88f72014-07-25 13:32:17 +02005569 config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM);
5570
5571 val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
5572 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
5573
5574 config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG);
5575
5576 config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC);
5577 config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES);
5578
5579 len = sizeof(*cmd) +
5580 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5581
Michal Kazior7aa7a722014-08-25 12:09:38 +02005582 buf = ath10k_wmi_alloc_skb(ar, len);
Michal Kazior24c88f72014-07-25 13:32:17 +02005583 if (!buf)
Michal Kaziord7579d12014-12-03 10:10:54 +02005584 return ERR_PTR(-ENOMEM);
Michal Kazior24c88f72014-07-25 13:32:17 +02005585
5586 cmd = (struct wmi_init_cmd_10_2 *)buf->data;
5587
Sujith Manoharanb6c8e282015-01-12 12:30:02 +02005588 features = WMI_10_2_RX_BATCH_MODE;
Yanbo Li844fa572015-10-31 11:07:21 +02005589
5590 if (test_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags) &&
5591 test_bit(WMI_SERVICE_COEX_GPIO, ar->wmi.svc_map))
Yanbo Lide0c7892015-04-15 15:28:08 +03005592 features |= WMI_10_2_COEX_GPIO;
Yanbo Li844fa572015-10-31 11:07:21 +02005593
Mohammed Shafi Shajakhande46c012016-01-13 21:16:28 +05305594 if (test_bit(WMI_SERVICE_PEER_STATS, ar->wmi.svc_map))
5595 features |= WMI_10_2_PEER_STATS;
5596
Sujith Manoharanb6c8e282015-01-12 12:30:02 +02005597 cmd->resource_config.feature_mask = __cpu_to_le32(features);
5598
Michal Kazior24c88f72014-07-25 13:32:17 +02005599 memcpy(&cmd->resource_config.common, &config, sizeof(config));
Michal Kaziorcf9fca82014-09-18 15:21:22 +02005600 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
Michal Kazior24c88f72014-07-25 13:32:17 +02005601
Michal Kazior7aa7a722014-08-25 12:09:38 +02005602 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.2\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02005603 return buf;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005604}
5605
Raja Manid1e52a82015-06-22 20:10:15 +05305606static struct sk_buff *ath10k_wmi_10_4_op_gen_init(struct ath10k *ar)
5607{
5608 struct wmi_init_cmd_10_4 *cmd;
5609 struct sk_buff *buf;
5610 struct wmi_resource_config_10_4 config = {};
5611 u32 len;
5612
5613 config.num_vdevs = __cpu_to_le32(ar->max_num_vdevs);
5614 config.num_peers = __cpu_to_le32(ar->max_num_peers);
5615 config.num_active_peers = __cpu_to_le32(ar->num_active_peers);
5616 config.num_tids = __cpu_to_le32(ar->num_tids);
5617
5618 config.num_offload_peers = __cpu_to_le32(TARGET_10_4_NUM_OFFLOAD_PEERS);
5619 config.num_offload_reorder_buffs =
5620 __cpu_to_le32(TARGET_10_4_NUM_OFFLOAD_REORDER_BUFFS);
5621 config.num_peer_keys = __cpu_to_le32(TARGET_10_4_NUM_PEER_KEYS);
5622 config.ast_skid_limit = __cpu_to_le32(TARGET_10_4_AST_SKID_LIMIT);
Raja Mani5699a6f2016-01-29 16:35:12 +05305623 config.tx_chain_mask = __cpu_to_le32(ar->hw_params.tx_chain_mask);
5624 config.rx_chain_mask = __cpu_to_le32(ar->hw_params.rx_chain_mask);
Raja Manid1e52a82015-06-22 20:10:15 +05305625
5626 config.rx_timeout_pri[0] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_LO_PRI);
5627 config.rx_timeout_pri[1] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_LO_PRI);
5628 config.rx_timeout_pri[2] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_LO_PRI);
5629 config.rx_timeout_pri[3] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_HI_PRI);
5630
Peter Ohbc27e8c2015-10-05 17:56:39 +03005631 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
Raja Manid1e52a82015-06-22 20:10:15 +05305632 config.scan_max_pending_req = __cpu_to_le32(TARGET_10_4_SCAN_MAX_REQS);
5633 config.bmiss_offload_max_vdev =
5634 __cpu_to_le32(TARGET_10_4_BMISS_OFFLOAD_MAX_VDEV);
5635 config.roam_offload_max_vdev =
5636 __cpu_to_le32(TARGET_10_4_ROAM_OFFLOAD_MAX_VDEV);
5637 config.roam_offload_max_ap_profiles =
5638 __cpu_to_le32(TARGET_10_4_ROAM_OFFLOAD_MAX_PROFILES);
5639 config.num_mcast_groups = __cpu_to_le32(TARGET_10_4_NUM_MCAST_GROUPS);
5640 config.num_mcast_table_elems =
5641 __cpu_to_le32(TARGET_10_4_NUM_MCAST_TABLE_ELEMS);
5642
5643 config.mcast2ucast_mode = __cpu_to_le32(TARGET_10_4_MCAST2UCAST_MODE);
5644 config.tx_dbg_log_size = __cpu_to_le32(TARGET_10_4_TX_DBG_LOG_SIZE);
5645 config.num_wds_entries = __cpu_to_le32(TARGET_10_4_NUM_WDS_ENTRIES);
5646 config.dma_burst_size = __cpu_to_le32(TARGET_10_4_DMA_BURST_SIZE);
5647 config.mac_aggr_delim = __cpu_to_le32(TARGET_10_4_MAC_AGGR_DELIM);
5648
5649 config.rx_skip_defrag_timeout_dup_detection_check =
5650 __cpu_to_le32(TARGET_10_4_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK);
5651
5652 config.vow_config = __cpu_to_le32(TARGET_10_4_VOW_CONFIG);
5653 config.gtk_offload_max_vdev =
5654 __cpu_to_le32(TARGET_10_4_GTK_OFFLOAD_MAX_VDEV);
Raja Mani5699a6f2016-01-29 16:35:12 +05305655 config.num_msdu_desc = __cpu_to_le32(ar->htt.max_num_pending_tx);
Raja Manid1e52a82015-06-22 20:10:15 +05305656 config.max_frag_entries = __cpu_to_le32(TARGET_10_4_11AC_TX_MAX_FRAGS);
5657 config.max_peer_ext_stats =
5658 __cpu_to_le32(TARGET_10_4_MAX_PEER_EXT_STATS);
5659 config.smart_ant_cap = __cpu_to_le32(TARGET_10_4_SMART_ANT_CAP);
5660
5661 config.bk_minfree = __cpu_to_le32(TARGET_10_4_BK_MIN_FREE);
5662 config.be_minfree = __cpu_to_le32(TARGET_10_4_BE_MIN_FREE);
5663 config.vi_minfree = __cpu_to_le32(TARGET_10_4_VI_MIN_FREE);
5664 config.vo_minfree = __cpu_to_le32(TARGET_10_4_VO_MIN_FREE);
5665
5666 config.rx_batchmode = __cpu_to_le32(TARGET_10_4_RX_BATCH_MODE);
5667 config.tt_support =
5668 __cpu_to_le32(TARGET_10_4_THERMAL_THROTTLING_CONFIG);
5669 config.atf_config = __cpu_to_le32(TARGET_10_4_ATF_CONFIG);
5670 config.iphdr_pad_config = __cpu_to_le32(TARGET_10_4_IPHDR_PAD_CONFIG);
5671 config.qwrap_config = __cpu_to_le32(TARGET_10_4_QWRAP_CONFIG);
5672
5673 len = sizeof(*cmd) +
5674 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5675
5676 buf = ath10k_wmi_alloc_skb(ar, len);
5677 if (!buf)
5678 return ERR_PTR(-ENOMEM);
5679
5680 cmd = (struct wmi_init_cmd_10_4 *)buf->data;
5681 memcpy(&cmd->resource_config, &config, sizeof(config));
5682 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
5683
5684 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.4\n");
5685 return buf;
5686}
5687
Michal Kazior0226d602014-12-03 10:11:22 +02005688int ath10k_wmi_start_scan_verify(const struct wmi_start_scan_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005689{
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005690 if (arg->ie_len && !arg->ie)
5691 return -EINVAL;
5692 if (arg->n_channels && !arg->channels)
5693 return -EINVAL;
5694 if (arg->n_ssids && !arg->ssids)
5695 return -EINVAL;
5696 if (arg->n_bssids && !arg->bssids)
5697 return -EINVAL;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005698
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005699 if (arg->ie_len > WLAN_SCAN_PARAMS_MAX_IE_LEN)
5700 return -EINVAL;
5701 if (arg->n_channels > ARRAY_SIZE(arg->channels))
5702 return -EINVAL;
5703 if (arg->n_ssids > WLAN_SCAN_PARAMS_MAX_SSID)
5704 return -EINVAL;
5705 if (arg->n_bssids > WLAN_SCAN_PARAMS_MAX_BSSID)
5706 return -EINVAL;
5707
5708 return 0;
5709}
5710
5711static size_t
5712ath10k_wmi_start_scan_tlvs_len(const struct wmi_start_scan_arg *arg)
5713{
5714 int len = 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005715
5716 if (arg->ie_len) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03005717 len += sizeof(struct wmi_ie_data);
5718 len += roundup(arg->ie_len, 4);
5719 }
5720
5721 if (arg->n_channels) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03005722 len += sizeof(struct wmi_chan_list);
5723 len += sizeof(__le32) * arg->n_channels;
5724 }
5725
5726 if (arg->n_ssids) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03005727 len += sizeof(struct wmi_ssid_list);
5728 len += sizeof(struct wmi_ssid) * arg->n_ssids;
5729 }
5730
5731 if (arg->n_bssids) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03005732 len += sizeof(struct wmi_bssid_list);
5733 len += sizeof(struct wmi_mac_addr) * arg->n_bssids;
5734 }
5735
5736 return len;
5737}
5738
Michal Kazior0226d602014-12-03 10:11:22 +02005739void ath10k_wmi_put_start_scan_common(struct wmi_start_scan_common *cmn,
5740 const struct wmi_start_scan_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005741{
Kalle Valo5e3dd152013-06-12 20:52:10 +03005742 u32 scan_id;
5743 u32 scan_req_id;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005744
5745 scan_id = WMI_HOST_SCAN_REQ_ID_PREFIX;
5746 scan_id |= arg->scan_id;
5747
5748 scan_req_id = WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
5749 scan_req_id |= arg->scan_req_id;
5750
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005751 cmn->scan_id = __cpu_to_le32(scan_id);
5752 cmn->scan_req_id = __cpu_to_le32(scan_req_id);
5753 cmn->vdev_id = __cpu_to_le32(arg->vdev_id);
5754 cmn->scan_priority = __cpu_to_le32(arg->scan_priority);
5755 cmn->notify_scan_events = __cpu_to_le32(arg->notify_scan_events);
5756 cmn->dwell_time_active = __cpu_to_le32(arg->dwell_time_active);
5757 cmn->dwell_time_passive = __cpu_to_le32(arg->dwell_time_passive);
5758 cmn->min_rest_time = __cpu_to_le32(arg->min_rest_time);
5759 cmn->max_rest_time = __cpu_to_le32(arg->max_rest_time);
5760 cmn->repeat_probe_time = __cpu_to_le32(arg->repeat_probe_time);
5761 cmn->probe_spacing_time = __cpu_to_le32(arg->probe_spacing_time);
5762 cmn->idle_time = __cpu_to_le32(arg->idle_time);
5763 cmn->max_scan_time = __cpu_to_le32(arg->max_scan_time);
5764 cmn->probe_delay = __cpu_to_le32(arg->probe_delay);
5765 cmn->scan_ctrl_flags = __cpu_to_le32(arg->scan_ctrl_flags);
5766}
Kalle Valo5e3dd152013-06-12 20:52:10 +03005767
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005768static void
5769ath10k_wmi_put_start_scan_tlvs(struct wmi_start_scan_tlvs *tlvs,
5770 const struct wmi_start_scan_arg *arg)
5771{
5772 struct wmi_ie_data *ie;
5773 struct wmi_chan_list *channels;
5774 struct wmi_ssid_list *ssids;
5775 struct wmi_bssid_list *bssids;
5776 void *ptr = tlvs->tlvs;
5777 int i;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005778
5779 if (arg->n_channels) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005780 channels = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005781 channels->tag = __cpu_to_le32(WMI_CHAN_LIST_TAG);
5782 channels->num_chan = __cpu_to_le32(arg->n_channels);
5783
5784 for (i = 0; i < arg->n_channels; i++)
Michal Kazior24c88f72014-07-25 13:32:17 +02005785 channels->channel_list[i].freq =
5786 __cpu_to_le16(arg->channels[i]);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005787
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005788 ptr += sizeof(*channels);
5789 ptr += sizeof(__le32) * arg->n_channels;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005790 }
5791
5792 if (arg->n_ssids) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005793 ssids = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005794 ssids->tag = __cpu_to_le32(WMI_SSID_LIST_TAG);
5795 ssids->num_ssids = __cpu_to_le32(arg->n_ssids);
5796
5797 for (i = 0; i < arg->n_ssids; i++) {
5798 ssids->ssids[i].ssid_len =
5799 __cpu_to_le32(arg->ssids[i].len);
5800 memcpy(&ssids->ssids[i].ssid,
5801 arg->ssids[i].ssid,
5802 arg->ssids[i].len);
5803 }
5804
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005805 ptr += sizeof(*ssids);
5806 ptr += sizeof(struct wmi_ssid) * arg->n_ssids;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005807 }
5808
5809 if (arg->n_bssids) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005810 bssids = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005811 bssids->tag = __cpu_to_le32(WMI_BSSID_LIST_TAG);
5812 bssids->num_bssid = __cpu_to_le32(arg->n_bssids);
5813
5814 for (i = 0; i < arg->n_bssids; i++)
5815 memcpy(&bssids->bssid_list[i],
5816 arg->bssids[i].bssid,
5817 ETH_ALEN);
5818
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005819 ptr += sizeof(*bssids);
5820 ptr += sizeof(struct wmi_mac_addr) * arg->n_bssids;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005821 }
5822
5823 if (arg->ie_len) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005824 ie = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005825 ie->tag = __cpu_to_le32(WMI_IE_TAG);
5826 ie->ie_len = __cpu_to_le32(arg->ie_len);
5827 memcpy(ie->ie_data, arg->ie, arg->ie_len);
5828
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005829 ptr += sizeof(*ie);
5830 ptr += roundup(arg->ie_len, 4);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005831 }
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005832}
Kalle Valo5e3dd152013-06-12 20:52:10 +03005833
Michal Kaziord7579d12014-12-03 10:10:54 +02005834static struct sk_buff *
5835ath10k_wmi_op_gen_start_scan(struct ath10k *ar,
5836 const struct wmi_start_scan_arg *arg)
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005837{
Michal Kaziord7579d12014-12-03 10:10:54 +02005838 struct wmi_start_scan_cmd *cmd;
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005839 struct sk_buff *skb;
5840 size_t len;
5841 int ret;
5842
5843 ret = ath10k_wmi_start_scan_verify(arg);
5844 if (ret)
Michal Kaziord7579d12014-12-03 10:10:54 +02005845 return ERR_PTR(ret);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005846
Michal Kaziord7579d12014-12-03 10:10:54 +02005847 len = sizeof(*cmd) + ath10k_wmi_start_scan_tlvs_len(arg);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005848 skb = ath10k_wmi_alloc_skb(ar, len);
5849 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005850 return ERR_PTR(-ENOMEM);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005851
Michal Kaziord7579d12014-12-03 10:10:54 +02005852 cmd = (struct wmi_start_scan_cmd *)skb->data;
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005853
Michal Kaziord7579d12014-12-03 10:10:54 +02005854 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
5855 ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005856
Michal Kaziord7579d12014-12-03 10:10:54 +02005857 cmd->burst_duration_ms = __cpu_to_le32(0);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005858
Michal Kazior7aa7a722014-08-25 12:09:38 +02005859 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi start scan\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02005860 return skb;
5861}
5862
5863static struct sk_buff *
5864ath10k_wmi_10x_op_gen_start_scan(struct ath10k *ar,
5865 const struct wmi_start_scan_arg *arg)
5866{
5867 struct wmi_10x_start_scan_cmd *cmd;
5868 struct sk_buff *skb;
5869 size_t len;
5870 int ret;
5871
5872 ret = ath10k_wmi_start_scan_verify(arg);
5873 if (ret)
5874 return ERR_PTR(ret);
5875
5876 len = sizeof(*cmd) + ath10k_wmi_start_scan_tlvs_len(arg);
5877 skb = ath10k_wmi_alloc_skb(ar, len);
5878 if (!skb)
5879 return ERR_PTR(-ENOMEM);
5880
5881 cmd = (struct wmi_10x_start_scan_cmd *)skb->data;
5882
5883 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
5884 ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
5885
5886 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi 10x start scan\n");
5887 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005888}
5889
5890void ath10k_wmi_start_scan_init(struct ath10k *ar,
5891 struct wmi_start_scan_arg *arg)
5892{
5893 /* setup commonly used values */
5894 arg->scan_req_id = 1;
5895 arg->scan_priority = WMI_SCAN_PRIORITY_LOW;
5896 arg->dwell_time_active = 50;
5897 arg->dwell_time_passive = 150;
5898 arg->min_rest_time = 50;
5899 arg->max_rest_time = 500;
5900 arg->repeat_probe_time = 0;
5901 arg->probe_spacing_time = 0;
5902 arg->idle_time = 0;
Bartosz Markowskic3228922013-10-02 08:48:52 +02005903 arg->max_scan_time = 20000;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005904 arg->probe_delay = 5;
5905 arg->notify_scan_events = WMI_SCAN_EVENT_STARTED
5906 | WMI_SCAN_EVENT_COMPLETED
5907 | WMI_SCAN_EVENT_BSS_CHANNEL
5908 | WMI_SCAN_EVENT_FOREIGN_CHANNEL
5909 | WMI_SCAN_EVENT_DEQUEUED;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005910 arg->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
5911 arg->n_bssids = 1;
5912 arg->bssids[0].bssid = "\xFF\xFF\xFF\xFF\xFF\xFF";
5913}
5914
Michal Kaziord7579d12014-12-03 10:10:54 +02005915static struct sk_buff *
5916ath10k_wmi_op_gen_stop_scan(struct ath10k *ar,
5917 const struct wmi_stop_scan_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005918{
5919 struct wmi_stop_scan_cmd *cmd;
5920 struct sk_buff *skb;
5921 u32 scan_id;
5922 u32 req_id;
5923
5924 if (arg->req_id > 0xFFF)
Michal Kaziord7579d12014-12-03 10:10:54 +02005925 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005926 if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF)
Michal Kaziord7579d12014-12-03 10:10:54 +02005927 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005928
Michal Kazior7aa7a722014-08-25 12:09:38 +02005929 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005930 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005931 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005932
5933 scan_id = arg->u.scan_id;
5934 scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX;
5935
5936 req_id = arg->req_id;
5937 req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
5938
5939 cmd = (struct wmi_stop_scan_cmd *)skb->data;
5940 cmd->req_type = __cpu_to_le32(arg->req_type);
5941 cmd->vdev_id = __cpu_to_le32(arg->u.vdev_id);
5942 cmd->scan_id = __cpu_to_le32(scan_id);
5943 cmd->scan_req_id = __cpu_to_le32(req_id);
5944
Michal Kazior7aa7a722014-08-25 12:09:38 +02005945 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005946 "wmi stop scan reqid %d req_type %d vdev/scan_id %d\n",
5947 arg->req_id, arg->req_type, arg->u.scan_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02005948 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005949}
5950
Michal Kaziord7579d12014-12-03 10:10:54 +02005951static struct sk_buff *
5952ath10k_wmi_op_gen_vdev_create(struct ath10k *ar, u32 vdev_id,
5953 enum wmi_vdev_type type,
5954 enum wmi_vdev_subtype subtype,
5955 const u8 macaddr[ETH_ALEN])
Kalle Valo5e3dd152013-06-12 20:52:10 +03005956{
5957 struct wmi_vdev_create_cmd *cmd;
5958 struct sk_buff *skb;
5959
Michal Kazior7aa7a722014-08-25 12:09:38 +02005960 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005961 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005962 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005963
5964 cmd = (struct wmi_vdev_create_cmd *)skb->data;
5965 cmd->vdev_id = __cpu_to_le32(vdev_id);
5966 cmd->vdev_type = __cpu_to_le32(type);
5967 cmd->vdev_subtype = __cpu_to_le32(subtype);
Kalle Valob25f32c2014-09-14 12:50:49 +03005968 ether_addr_copy(cmd->vdev_macaddr.addr, macaddr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005969
Michal Kazior7aa7a722014-08-25 12:09:38 +02005970 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005971 "WMI vdev create: id %d type %d subtype %d macaddr %pM\n",
5972 vdev_id, type, subtype, macaddr);
Michal Kaziord7579d12014-12-03 10:10:54 +02005973 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005974}
5975
Michal Kaziord7579d12014-12-03 10:10:54 +02005976static struct sk_buff *
5977ath10k_wmi_op_gen_vdev_delete(struct ath10k *ar, u32 vdev_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005978{
5979 struct wmi_vdev_delete_cmd *cmd;
5980 struct sk_buff *skb;
5981
Michal Kazior7aa7a722014-08-25 12:09:38 +02005982 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005983 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005984 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005985
5986 cmd = (struct wmi_vdev_delete_cmd *)skb->data;
5987 cmd->vdev_id = __cpu_to_le32(vdev_id);
5988
Michal Kazior7aa7a722014-08-25 12:09:38 +02005989 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005990 "WMI vdev delete id %d\n", vdev_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02005991 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005992}
5993
Michal Kaziord7579d12014-12-03 10:10:54 +02005994static struct sk_buff *
5995ath10k_wmi_op_gen_vdev_start(struct ath10k *ar,
5996 const struct wmi_vdev_start_request_arg *arg,
5997 bool restart)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005998{
5999 struct wmi_vdev_start_request_cmd *cmd;
6000 struct sk_buff *skb;
6001 const char *cmdname;
6002 u32 flags = 0;
6003
Kalle Valo5e3dd152013-06-12 20:52:10 +03006004 if (WARN_ON(arg->hidden_ssid && !arg->ssid))
Michal Kaziord7579d12014-12-03 10:10:54 +02006005 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006006 if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid)))
Michal Kaziord7579d12014-12-03 10:10:54 +02006007 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006008
Michal Kaziord7579d12014-12-03 10:10:54 +02006009 if (restart)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006010 cmdname = "restart";
6011 else
Michal Kaziord7579d12014-12-03 10:10:54 +02006012 cmdname = "start";
Kalle Valo5e3dd152013-06-12 20:52:10 +03006013
Michal Kazior7aa7a722014-08-25 12:09:38 +02006014 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006015 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006016 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006017
6018 if (arg->hidden_ssid)
6019 flags |= WMI_VDEV_START_HIDDEN_SSID;
6020 if (arg->pmf_enabled)
6021 flags |= WMI_VDEV_START_PMF_ENABLED;
6022
6023 cmd = (struct wmi_vdev_start_request_cmd *)skb->data;
6024 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
6025 cmd->disable_hw_ack = __cpu_to_le32(arg->disable_hw_ack);
6026 cmd->beacon_interval = __cpu_to_le32(arg->bcn_intval);
6027 cmd->dtim_period = __cpu_to_le32(arg->dtim_period);
6028 cmd->flags = __cpu_to_le32(flags);
6029 cmd->bcn_tx_rate = __cpu_to_le32(arg->bcn_tx_rate);
6030 cmd->bcn_tx_power = __cpu_to_le32(arg->bcn_tx_power);
6031
6032 if (arg->ssid) {
6033 cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len);
6034 memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len);
6035 }
6036
Michal Kazior2d667212014-09-18 15:21:21 +02006037 ath10k_wmi_put_wmi_channel(&cmd->chan, &arg->channel);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006038
Michal Kazior7aa7a722014-08-25 12:09:38 +02006039 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo8cc7f262014-09-14 12:50:39 +03006040 "wmi vdev %s id 0x%x flags: 0x%0X, freq %d, mode %d, ch_flags: 0x%0X, max_power: %d\n",
6041 cmdname, arg->vdev_id,
Marek Puzyniake8a50f82013-11-20 09:59:47 +02006042 flags, arg->channel.freq, arg->channel.mode,
6043 cmd->chan.flags, arg->channel.max_power);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006044
Michal Kaziord7579d12014-12-03 10:10:54 +02006045 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006046}
6047
Michal Kaziord7579d12014-12-03 10:10:54 +02006048static struct sk_buff *
6049ath10k_wmi_op_gen_vdev_stop(struct ath10k *ar, u32 vdev_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006050{
6051 struct wmi_vdev_stop_cmd *cmd;
6052 struct sk_buff *skb;
6053
Michal Kazior7aa7a722014-08-25 12:09:38 +02006054 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006055 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006056 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006057
6058 cmd = (struct wmi_vdev_stop_cmd *)skb->data;
6059 cmd->vdev_id = __cpu_to_le32(vdev_id);
6060
Michal Kazior7aa7a722014-08-25 12:09:38 +02006061 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi vdev stop id 0x%x\n", vdev_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02006062 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006063}
6064
Michal Kaziord7579d12014-12-03 10:10:54 +02006065static struct sk_buff *
6066ath10k_wmi_op_gen_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid,
6067 const u8 *bssid)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006068{
6069 struct wmi_vdev_up_cmd *cmd;
6070 struct sk_buff *skb;
6071
Michal Kazior7aa7a722014-08-25 12:09:38 +02006072 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006073 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006074 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006075
6076 cmd = (struct wmi_vdev_up_cmd *)skb->data;
6077 cmd->vdev_id = __cpu_to_le32(vdev_id);
6078 cmd->vdev_assoc_id = __cpu_to_le32(aid);
Kalle Valob25f32c2014-09-14 12:50:49 +03006079 ether_addr_copy(cmd->vdev_bssid.addr, bssid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006080
Michal Kazior7aa7a722014-08-25 12:09:38 +02006081 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006082 "wmi mgmt vdev up id 0x%x assoc id %d bssid %pM\n",
6083 vdev_id, aid, bssid);
Michal Kaziord7579d12014-12-03 10:10:54 +02006084 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006085}
6086
Michal Kaziord7579d12014-12-03 10:10:54 +02006087static struct sk_buff *
6088ath10k_wmi_op_gen_vdev_down(struct ath10k *ar, u32 vdev_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006089{
6090 struct wmi_vdev_down_cmd *cmd;
6091 struct sk_buff *skb;
6092
Michal Kazior7aa7a722014-08-25 12:09:38 +02006093 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006094 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006095 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006096
6097 cmd = (struct wmi_vdev_down_cmd *)skb->data;
6098 cmd->vdev_id = __cpu_to_le32(vdev_id);
6099
Michal Kazior7aa7a722014-08-25 12:09:38 +02006100 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006101 "wmi mgmt vdev down id 0x%x\n", vdev_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02006102 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006103}
6104
Michal Kaziord7579d12014-12-03 10:10:54 +02006105static struct sk_buff *
6106ath10k_wmi_op_gen_vdev_set_param(struct ath10k *ar, u32 vdev_id,
6107 u32 param_id, u32 param_value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006108{
6109 struct wmi_vdev_set_param_cmd *cmd;
6110 struct sk_buff *skb;
6111
Bartosz Markowski6d1506e2013-09-26 17:47:15 +02006112 if (param_id == WMI_VDEV_PARAM_UNSUPPORTED) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02006113 ath10k_dbg(ar, ATH10K_DBG_WMI,
Bartosz Markowski6d1506e2013-09-26 17:47:15 +02006114 "vdev param %d not supported by firmware\n",
6115 param_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02006116 return ERR_PTR(-EOPNOTSUPP);
Bartosz Markowski6d1506e2013-09-26 17:47:15 +02006117 }
6118
Michal Kazior7aa7a722014-08-25 12:09:38 +02006119 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006120 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006121 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006122
6123 cmd = (struct wmi_vdev_set_param_cmd *)skb->data;
6124 cmd->vdev_id = __cpu_to_le32(vdev_id);
6125 cmd->param_id = __cpu_to_le32(param_id);
6126 cmd->param_value = __cpu_to_le32(param_value);
6127
Michal Kazior7aa7a722014-08-25 12:09:38 +02006128 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006129 "wmi vdev id 0x%x set param %d value %d\n",
6130 vdev_id, param_id, param_value);
Michal Kaziord7579d12014-12-03 10:10:54 +02006131 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006132}
6133
Michal Kaziord7579d12014-12-03 10:10:54 +02006134static struct sk_buff *
6135ath10k_wmi_op_gen_vdev_install_key(struct ath10k *ar,
6136 const struct wmi_vdev_install_key_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006137{
6138 struct wmi_vdev_install_key_cmd *cmd;
6139 struct sk_buff *skb;
6140
6141 if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL)
Michal Kaziord7579d12014-12-03 10:10:54 +02006142 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006143 if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL)
Michal Kaziord7579d12014-12-03 10:10:54 +02006144 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006145
Michal Kazior7aa7a722014-08-25 12:09:38 +02006146 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd) + arg->key_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006147 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006148 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006149
6150 cmd = (struct wmi_vdev_install_key_cmd *)skb->data;
6151 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
6152 cmd->key_idx = __cpu_to_le32(arg->key_idx);
6153 cmd->key_flags = __cpu_to_le32(arg->key_flags);
6154 cmd->key_cipher = __cpu_to_le32(arg->key_cipher);
6155 cmd->key_len = __cpu_to_le32(arg->key_len);
6156 cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len);
6157 cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len);
6158
6159 if (arg->macaddr)
Kalle Valob25f32c2014-09-14 12:50:49 +03006160 ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006161 if (arg->key_data)
6162 memcpy(cmd->key_data, arg->key_data, arg->key_len);
6163
Michal Kazior7aa7a722014-08-25 12:09:38 +02006164 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kaziore0c508a2013-07-05 16:15:17 +03006165 "wmi vdev install key idx %d cipher %d len %d\n",
6166 arg->key_idx, arg->key_cipher, arg->key_len);
Michal Kaziord7579d12014-12-03 10:10:54 +02006167 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006168}
6169
Michal Kaziord7579d12014-12-03 10:10:54 +02006170static struct sk_buff *
6171ath10k_wmi_op_gen_vdev_spectral_conf(struct ath10k *ar,
6172 const struct wmi_vdev_spectral_conf_arg *arg)
Simon Wunderlich855aed12014-08-02 09:12:54 +03006173{
6174 struct wmi_vdev_spectral_conf_cmd *cmd;
6175 struct sk_buff *skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03006176
Michal Kazior7aa7a722014-08-25 12:09:38 +02006177 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Simon Wunderlich855aed12014-08-02 09:12:54 +03006178 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006179 return ERR_PTR(-ENOMEM);
Simon Wunderlich855aed12014-08-02 09:12:54 +03006180
6181 cmd = (struct wmi_vdev_spectral_conf_cmd *)skb->data;
6182 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
6183 cmd->scan_count = __cpu_to_le32(arg->scan_count);
6184 cmd->scan_period = __cpu_to_le32(arg->scan_period);
6185 cmd->scan_priority = __cpu_to_le32(arg->scan_priority);
6186 cmd->scan_fft_size = __cpu_to_le32(arg->scan_fft_size);
6187 cmd->scan_gc_ena = __cpu_to_le32(arg->scan_gc_ena);
6188 cmd->scan_restart_ena = __cpu_to_le32(arg->scan_restart_ena);
6189 cmd->scan_noise_floor_ref = __cpu_to_le32(arg->scan_noise_floor_ref);
6190 cmd->scan_init_delay = __cpu_to_le32(arg->scan_init_delay);
6191 cmd->scan_nb_tone_thr = __cpu_to_le32(arg->scan_nb_tone_thr);
6192 cmd->scan_str_bin_thr = __cpu_to_le32(arg->scan_str_bin_thr);
6193 cmd->scan_wb_rpt_mode = __cpu_to_le32(arg->scan_wb_rpt_mode);
6194 cmd->scan_rssi_rpt_mode = __cpu_to_le32(arg->scan_rssi_rpt_mode);
6195 cmd->scan_rssi_thr = __cpu_to_le32(arg->scan_rssi_thr);
6196 cmd->scan_pwr_format = __cpu_to_le32(arg->scan_pwr_format);
6197 cmd->scan_rpt_mode = __cpu_to_le32(arg->scan_rpt_mode);
6198 cmd->scan_bin_scale = __cpu_to_le32(arg->scan_bin_scale);
6199 cmd->scan_dbm_adj = __cpu_to_le32(arg->scan_dbm_adj);
6200 cmd->scan_chn_mask = __cpu_to_le32(arg->scan_chn_mask);
6201
Michal Kaziord7579d12014-12-03 10:10:54 +02006202 return skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03006203}
6204
Michal Kaziord7579d12014-12-03 10:10:54 +02006205static struct sk_buff *
6206ath10k_wmi_op_gen_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id,
6207 u32 trigger, u32 enable)
Simon Wunderlich855aed12014-08-02 09:12:54 +03006208{
6209 struct wmi_vdev_spectral_enable_cmd *cmd;
6210 struct sk_buff *skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03006211
Michal Kazior7aa7a722014-08-25 12:09:38 +02006212 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Simon Wunderlich855aed12014-08-02 09:12:54 +03006213 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006214 return ERR_PTR(-ENOMEM);
Simon Wunderlich855aed12014-08-02 09:12:54 +03006215
6216 cmd = (struct wmi_vdev_spectral_enable_cmd *)skb->data;
6217 cmd->vdev_id = __cpu_to_le32(vdev_id);
6218 cmd->trigger_cmd = __cpu_to_le32(trigger);
6219 cmd->enable_cmd = __cpu_to_le32(enable);
6220
Michal Kaziord7579d12014-12-03 10:10:54 +02006221 return skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03006222}
6223
Michal Kaziord7579d12014-12-03 10:10:54 +02006224static struct sk_buff *
6225ath10k_wmi_op_gen_peer_create(struct ath10k *ar, u32 vdev_id,
Marek Puzyniak7390ed32015-03-30 09:51:52 +03006226 const u8 peer_addr[ETH_ALEN],
6227 enum wmi_peer_type peer_type)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006228{
6229 struct wmi_peer_create_cmd *cmd;
6230 struct sk_buff *skb;
6231
Michal Kazior7aa7a722014-08-25 12:09:38 +02006232 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006233 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006234 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006235
6236 cmd = (struct wmi_peer_create_cmd *)skb->data;
6237 cmd->vdev_id = __cpu_to_le32(vdev_id);
Kalle Valob25f32c2014-09-14 12:50:49 +03006238 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006239
Michal Kazior7aa7a722014-08-25 12:09:38 +02006240 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006241 "wmi peer create vdev_id %d peer_addr %pM\n",
6242 vdev_id, peer_addr);
Michal Kaziord7579d12014-12-03 10:10:54 +02006243 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006244}
6245
Michal Kaziord7579d12014-12-03 10:10:54 +02006246static struct sk_buff *
6247ath10k_wmi_op_gen_peer_delete(struct ath10k *ar, u32 vdev_id,
6248 const u8 peer_addr[ETH_ALEN])
Kalle Valo5e3dd152013-06-12 20:52:10 +03006249{
6250 struct wmi_peer_delete_cmd *cmd;
6251 struct sk_buff *skb;
6252
Michal Kazior7aa7a722014-08-25 12:09:38 +02006253 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006254 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006255 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006256
6257 cmd = (struct wmi_peer_delete_cmd *)skb->data;
6258 cmd->vdev_id = __cpu_to_le32(vdev_id);
Kalle Valob25f32c2014-09-14 12:50:49 +03006259 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006260
Michal Kazior7aa7a722014-08-25 12:09:38 +02006261 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006262 "wmi peer delete vdev_id %d peer_addr %pM\n",
6263 vdev_id, peer_addr);
Michal Kaziord7579d12014-12-03 10:10:54 +02006264 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006265}
6266
Michal Kaziord7579d12014-12-03 10:10:54 +02006267static struct sk_buff *
6268ath10k_wmi_op_gen_peer_flush(struct ath10k *ar, u32 vdev_id,
6269 const u8 peer_addr[ETH_ALEN], u32 tid_bitmap)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006270{
6271 struct wmi_peer_flush_tids_cmd *cmd;
6272 struct sk_buff *skb;
6273
Michal Kazior7aa7a722014-08-25 12:09:38 +02006274 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006275 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006276 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006277
6278 cmd = (struct wmi_peer_flush_tids_cmd *)skb->data;
6279 cmd->vdev_id = __cpu_to_le32(vdev_id);
6280 cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap);
Kalle Valob25f32c2014-09-14 12:50:49 +03006281 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006282
Michal Kazior7aa7a722014-08-25 12:09:38 +02006283 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006284 "wmi peer flush vdev_id %d peer_addr %pM tids %08x\n",
6285 vdev_id, peer_addr, tid_bitmap);
Michal Kaziord7579d12014-12-03 10:10:54 +02006286 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006287}
6288
Michal Kaziord7579d12014-12-03 10:10:54 +02006289static struct sk_buff *
6290ath10k_wmi_op_gen_peer_set_param(struct ath10k *ar, u32 vdev_id,
6291 const u8 *peer_addr,
6292 enum wmi_peer_param param_id,
6293 u32 param_value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006294{
6295 struct wmi_peer_set_param_cmd *cmd;
6296 struct sk_buff *skb;
6297
Michal Kazior7aa7a722014-08-25 12:09:38 +02006298 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006299 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006300 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006301
6302 cmd = (struct wmi_peer_set_param_cmd *)skb->data;
6303 cmd->vdev_id = __cpu_to_le32(vdev_id);
6304 cmd->param_id = __cpu_to_le32(param_id);
6305 cmd->param_value = __cpu_to_le32(param_value);
Kalle Valob25f32c2014-09-14 12:50:49 +03006306 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006307
Michal Kazior7aa7a722014-08-25 12:09:38 +02006308 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006309 "wmi vdev %d peer 0x%pM set param %d value %d\n",
6310 vdev_id, peer_addr, param_id, param_value);
Michal Kaziord7579d12014-12-03 10:10:54 +02006311 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006312}
6313
Michal Kaziord7579d12014-12-03 10:10:54 +02006314static struct sk_buff *
6315ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
6316 enum wmi_sta_ps_mode psmode)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006317{
6318 struct wmi_sta_powersave_mode_cmd *cmd;
6319 struct sk_buff *skb;
6320
Michal Kazior7aa7a722014-08-25 12:09:38 +02006321 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006322 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006323 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006324
6325 cmd = (struct wmi_sta_powersave_mode_cmd *)skb->data;
6326 cmd->vdev_id = __cpu_to_le32(vdev_id);
6327 cmd->sta_ps_mode = __cpu_to_le32(psmode);
6328
Michal Kazior7aa7a722014-08-25 12:09:38 +02006329 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006330 "wmi set powersave id 0x%x mode %d\n",
6331 vdev_id, psmode);
Michal Kaziord7579d12014-12-03 10:10:54 +02006332 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006333}
6334
Michal Kaziord7579d12014-12-03 10:10:54 +02006335static struct sk_buff *
6336ath10k_wmi_op_gen_set_sta_ps(struct ath10k *ar, u32 vdev_id,
6337 enum wmi_sta_powersave_param param_id,
6338 u32 value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006339{
6340 struct wmi_sta_powersave_param_cmd *cmd;
6341 struct sk_buff *skb;
6342
Michal Kazior7aa7a722014-08-25 12:09:38 +02006343 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006344 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006345 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006346
6347 cmd = (struct wmi_sta_powersave_param_cmd *)skb->data;
6348 cmd->vdev_id = __cpu_to_le32(vdev_id);
6349 cmd->param_id = __cpu_to_le32(param_id);
6350 cmd->param_value = __cpu_to_le32(value);
6351
Michal Kazior7aa7a722014-08-25 12:09:38 +02006352 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006353 "wmi sta ps param vdev_id 0x%x param %d value %d\n",
6354 vdev_id, param_id, value);
Michal Kaziord7579d12014-12-03 10:10:54 +02006355 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006356}
6357
Michal Kaziord7579d12014-12-03 10:10:54 +02006358static struct sk_buff *
6359ath10k_wmi_op_gen_set_ap_ps(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6360 enum wmi_ap_ps_peer_param param_id, u32 value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006361{
6362 struct wmi_ap_ps_peer_cmd *cmd;
6363 struct sk_buff *skb;
6364
6365 if (!mac)
Michal Kaziord7579d12014-12-03 10:10:54 +02006366 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006367
Michal Kazior7aa7a722014-08-25 12:09:38 +02006368 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006369 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006370 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006371
6372 cmd = (struct wmi_ap_ps_peer_cmd *)skb->data;
6373 cmd->vdev_id = __cpu_to_le32(vdev_id);
6374 cmd->param_id = __cpu_to_le32(param_id);
6375 cmd->param_value = __cpu_to_le32(value);
Kalle Valob25f32c2014-09-14 12:50:49 +03006376 ether_addr_copy(cmd->peer_macaddr.addr, mac);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006377
Michal Kazior7aa7a722014-08-25 12:09:38 +02006378 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006379 "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr %pM\n",
6380 vdev_id, param_id, value, mac);
Michal Kaziord7579d12014-12-03 10:10:54 +02006381 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006382}
6383
Michal Kaziord7579d12014-12-03 10:10:54 +02006384static struct sk_buff *
6385ath10k_wmi_op_gen_scan_chan_list(struct ath10k *ar,
6386 const struct wmi_scan_chan_list_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006387{
6388 struct wmi_scan_chan_list_cmd *cmd;
6389 struct sk_buff *skb;
6390 struct wmi_channel_arg *ch;
6391 struct wmi_channel *ci;
6392 int len;
6393 int i;
6394
6395 len = sizeof(*cmd) + arg->n_channels * sizeof(struct wmi_channel);
6396
Michal Kazior7aa7a722014-08-25 12:09:38 +02006397 skb = ath10k_wmi_alloc_skb(ar, len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006398 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006399 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006400
6401 cmd = (struct wmi_scan_chan_list_cmd *)skb->data;
6402 cmd->num_scan_chans = __cpu_to_le32(arg->n_channels);
6403
6404 for (i = 0; i < arg->n_channels; i++) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03006405 ch = &arg->channels[i];
6406 ci = &cmd->chan_info[i];
6407
Michal Kazior2d667212014-09-18 15:21:21 +02006408 ath10k_wmi_put_wmi_channel(ci, ch);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006409 }
6410
Michal Kaziord7579d12014-12-03 10:10:54 +02006411 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006412}
6413
Michal Kazior24c88f72014-07-25 13:32:17 +02006414static void
6415ath10k_wmi_peer_assoc_fill(struct ath10k *ar, void *buf,
6416 const struct wmi_peer_assoc_complete_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006417{
Michal Kazior24c88f72014-07-25 13:32:17 +02006418 struct wmi_common_peer_assoc_complete_cmd *cmd = buf;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006419
Kalle Valo5e3dd152013-06-12 20:52:10 +03006420 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
6421 cmd->peer_new_assoc = __cpu_to_le32(arg->peer_reassoc ? 0 : 1);
6422 cmd->peer_associd = __cpu_to_le32(arg->peer_aid);
6423 cmd->peer_flags = __cpu_to_le32(arg->peer_flags);
6424 cmd->peer_caps = __cpu_to_le32(arg->peer_caps);
6425 cmd->peer_listen_intval = __cpu_to_le32(arg->peer_listen_intval);
6426 cmd->peer_ht_caps = __cpu_to_le32(arg->peer_ht_caps);
6427 cmd->peer_max_mpdu = __cpu_to_le32(arg->peer_max_mpdu);
6428 cmd->peer_mpdu_density = __cpu_to_le32(arg->peer_mpdu_density);
6429 cmd->peer_rate_caps = __cpu_to_le32(arg->peer_rate_caps);
6430 cmd->peer_nss = __cpu_to_le32(arg->peer_num_spatial_streams);
6431 cmd->peer_vht_caps = __cpu_to_le32(arg->peer_vht_caps);
6432 cmd->peer_phymode = __cpu_to_le32(arg->peer_phymode);
6433
Kalle Valob25f32c2014-09-14 12:50:49 +03006434 ether_addr_copy(cmd->peer_macaddr.addr, arg->addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006435
6436 cmd->peer_legacy_rates.num_rates =
6437 __cpu_to_le32(arg->peer_legacy_rates.num_rates);
6438 memcpy(cmd->peer_legacy_rates.rates, arg->peer_legacy_rates.rates,
6439 arg->peer_legacy_rates.num_rates);
6440
6441 cmd->peer_ht_rates.num_rates =
6442 __cpu_to_le32(arg->peer_ht_rates.num_rates);
6443 memcpy(cmd->peer_ht_rates.rates, arg->peer_ht_rates.rates,
6444 arg->peer_ht_rates.num_rates);
6445
6446 cmd->peer_vht_rates.rx_max_rate =
6447 __cpu_to_le32(arg->peer_vht_rates.rx_max_rate);
6448 cmd->peer_vht_rates.rx_mcs_set =
6449 __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set);
6450 cmd->peer_vht_rates.tx_max_rate =
6451 __cpu_to_le32(arg->peer_vht_rates.tx_max_rate);
6452 cmd->peer_vht_rates.tx_mcs_set =
6453 __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set);
Michal Kazior24c88f72014-07-25 13:32:17 +02006454}
6455
6456static void
6457ath10k_wmi_peer_assoc_fill_main(struct ath10k *ar, void *buf,
6458 const struct wmi_peer_assoc_complete_arg *arg)
6459{
6460 struct wmi_main_peer_assoc_complete_cmd *cmd = buf;
6461
6462 ath10k_wmi_peer_assoc_fill(ar, buf, arg);
6463 memset(cmd->peer_ht_info, 0, sizeof(cmd->peer_ht_info));
6464}
6465
6466static void
6467ath10k_wmi_peer_assoc_fill_10_1(struct ath10k *ar, void *buf,
6468 const struct wmi_peer_assoc_complete_arg *arg)
6469{
6470 ath10k_wmi_peer_assoc_fill(ar, buf, arg);
6471}
6472
6473static void
6474ath10k_wmi_peer_assoc_fill_10_2(struct ath10k *ar, void *buf,
6475 const struct wmi_peer_assoc_complete_arg *arg)
6476{
6477 struct wmi_10_2_peer_assoc_complete_cmd *cmd = buf;
6478 int max_mcs, max_nss;
6479 u32 info0;
6480
6481 /* TODO: Is using max values okay with firmware? */
6482 max_mcs = 0xf;
6483 max_nss = 0xf;
6484
6485 info0 = SM(max_mcs, WMI_PEER_ASSOC_INFO0_MAX_MCS_IDX) |
6486 SM(max_nss, WMI_PEER_ASSOC_INFO0_MAX_NSS);
6487
6488 ath10k_wmi_peer_assoc_fill(ar, buf, arg);
6489 cmd->info0 = __cpu_to_le32(info0);
6490}
6491
Vasanthakumar Thiagarajanb54e16f2015-11-05 11:33:58 +05306492static void
6493ath10k_wmi_peer_assoc_fill_10_4(struct ath10k *ar, void *buf,
6494 const struct wmi_peer_assoc_complete_arg *arg)
6495{
6496 struct wmi_10_4_peer_assoc_complete_cmd *cmd = buf;
6497
6498 ath10k_wmi_peer_assoc_fill_10_2(ar, buf, arg);
6499 cmd->peer_bw_rxnss_override = 0;
6500}
6501
Michal Kaziord7579d12014-12-03 10:10:54 +02006502static int
6503ath10k_wmi_peer_assoc_check_arg(const struct wmi_peer_assoc_complete_arg *arg)
Michal Kazior24c88f72014-07-25 13:32:17 +02006504{
Michal Kazior24c88f72014-07-25 13:32:17 +02006505 if (arg->peer_mpdu_density > 16)
6506 return -EINVAL;
6507 if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES)
6508 return -EINVAL;
6509 if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES)
6510 return -EINVAL;
6511
Michal Kaziord7579d12014-12-03 10:10:54 +02006512 return 0;
6513}
6514
6515static struct sk_buff *
6516ath10k_wmi_op_gen_peer_assoc(struct ath10k *ar,
6517 const struct wmi_peer_assoc_complete_arg *arg)
6518{
6519 size_t len = sizeof(struct wmi_main_peer_assoc_complete_cmd);
6520 struct sk_buff *skb;
6521 int ret;
6522
6523 ret = ath10k_wmi_peer_assoc_check_arg(arg);
6524 if (ret)
6525 return ERR_PTR(ret);
Michal Kazior24c88f72014-07-25 13:32:17 +02006526
Michal Kazior7aa7a722014-08-25 12:09:38 +02006527 skb = ath10k_wmi_alloc_skb(ar, len);
Michal Kazior24c88f72014-07-25 13:32:17 +02006528 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006529 return ERR_PTR(-ENOMEM);
Michal Kazior24c88f72014-07-25 13:32:17 +02006530
Michal Kaziord7579d12014-12-03 10:10:54 +02006531 ath10k_wmi_peer_assoc_fill_main(ar, skb->data, arg);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006532
Michal Kazior7aa7a722014-08-25 12:09:38 +02006533 ath10k_dbg(ar, ATH10K_DBG_WMI,
Chun-Yeow Yeoh44d6fa92014-03-07 10:19:30 +02006534 "wmi peer assoc vdev %d addr %pM (%s)\n",
6535 arg->vdev_id, arg->addr,
6536 arg->peer_reassoc ? "reassociate" : "new");
Michal Kaziord7579d12014-12-03 10:10:54 +02006537 return skb;
6538}
6539
6540static struct sk_buff *
6541ath10k_wmi_10_1_op_gen_peer_assoc(struct ath10k *ar,
6542 const struct wmi_peer_assoc_complete_arg *arg)
6543{
6544 size_t len = sizeof(struct wmi_10_1_peer_assoc_complete_cmd);
6545 struct sk_buff *skb;
6546 int ret;
6547
6548 ret = ath10k_wmi_peer_assoc_check_arg(arg);
6549 if (ret)
6550 return ERR_PTR(ret);
6551
6552 skb = ath10k_wmi_alloc_skb(ar, len);
6553 if (!skb)
6554 return ERR_PTR(-ENOMEM);
6555
6556 ath10k_wmi_peer_assoc_fill_10_1(ar, skb->data, arg);
6557
6558 ath10k_dbg(ar, ATH10K_DBG_WMI,
6559 "wmi peer assoc vdev %d addr %pM (%s)\n",
6560 arg->vdev_id, arg->addr,
6561 arg->peer_reassoc ? "reassociate" : "new");
6562 return skb;
6563}
6564
6565static struct sk_buff *
6566ath10k_wmi_10_2_op_gen_peer_assoc(struct ath10k *ar,
6567 const struct wmi_peer_assoc_complete_arg *arg)
6568{
6569 size_t len = sizeof(struct wmi_10_2_peer_assoc_complete_cmd);
6570 struct sk_buff *skb;
6571 int ret;
6572
6573 ret = ath10k_wmi_peer_assoc_check_arg(arg);
6574 if (ret)
6575 return ERR_PTR(ret);
6576
6577 skb = ath10k_wmi_alloc_skb(ar, len);
6578 if (!skb)
6579 return ERR_PTR(-ENOMEM);
6580
6581 ath10k_wmi_peer_assoc_fill_10_2(ar, skb->data, arg);
6582
6583 ath10k_dbg(ar, ATH10K_DBG_WMI,
6584 "wmi peer assoc vdev %d addr %pM (%s)\n",
6585 arg->vdev_id, arg->addr,
6586 arg->peer_reassoc ? "reassociate" : "new");
6587 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006588}
6589
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02006590static struct sk_buff *
Vasanthakumar Thiagarajanb54e16f2015-11-05 11:33:58 +05306591ath10k_wmi_10_4_op_gen_peer_assoc(struct ath10k *ar,
6592 const struct wmi_peer_assoc_complete_arg *arg)
6593{
6594 size_t len = sizeof(struct wmi_10_4_peer_assoc_complete_cmd);
6595 struct sk_buff *skb;
6596 int ret;
6597
6598 ret = ath10k_wmi_peer_assoc_check_arg(arg);
6599 if (ret)
6600 return ERR_PTR(ret);
6601
6602 skb = ath10k_wmi_alloc_skb(ar, len);
6603 if (!skb)
6604 return ERR_PTR(-ENOMEM);
6605
6606 ath10k_wmi_peer_assoc_fill_10_4(ar, skb->data, arg);
6607
6608 ath10k_dbg(ar, ATH10K_DBG_WMI,
6609 "wmi peer assoc vdev %d addr %pM (%s)\n",
6610 arg->vdev_id, arg->addr,
6611 arg->peer_reassoc ? "reassociate" : "new");
6612 return skb;
6613}
6614
6615static struct sk_buff *
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02006616ath10k_wmi_10_2_op_gen_pdev_get_temperature(struct ath10k *ar)
6617{
6618 struct sk_buff *skb;
6619
6620 skb = ath10k_wmi_alloc_skb(ar, 0);
6621 if (!skb)
6622 return ERR_PTR(-ENOMEM);
6623
6624 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev get temperature\n");
6625 return skb;
6626}
6627
Michal Kazior748afc42014-01-23 12:48:21 +01006628/* This function assumes the beacon is already DMA mapped */
Michal Kaziord7579d12014-12-03 10:10:54 +02006629static struct sk_buff *
Michal Kazior9ad50182015-01-29 14:29:47 +02006630ath10k_wmi_op_gen_beacon_dma(struct ath10k *ar, u32 vdev_id, const void *bcn,
6631 size_t bcn_len, u32 bcn_paddr, bool dtim_zero,
6632 bool deliver_cab)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006633{
Michal Kazior748afc42014-01-23 12:48:21 +01006634 struct wmi_bcn_tx_ref_cmd *cmd;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006635 struct sk_buff *skb;
Michal Kazior748afc42014-01-23 12:48:21 +01006636 struct ieee80211_hdr *hdr;
Michal Kazior748afc42014-01-23 12:48:21 +01006637 u16 fc;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006638
Michal Kazior7aa7a722014-08-25 12:09:38 +02006639 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006640 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006641 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006642
Michal Kazior9ad50182015-01-29 14:29:47 +02006643 hdr = (struct ieee80211_hdr *)bcn;
Michal Kazior748afc42014-01-23 12:48:21 +01006644 fc = le16_to_cpu(hdr->frame_control);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006645
Michal Kazior748afc42014-01-23 12:48:21 +01006646 cmd = (struct wmi_bcn_tx_ref_cmd *)skb->data;
Michal Kazior9ad50182015-01-29 14:29:47 +02006647 cmd->vdev_id = __cpu_to_le32(vdev_id);
6648 cmd->data_len = __cpu_to_le32(bcn_len);
6649 cmd->data_ptr = __cpu_to_le32(bcn_paddr);
Michal Kazior748afc42014-01-23 12:48:21 +01006650 cmd->msdu_id = 0;
6651 cmd->frame_control = __cpu_to_le32(fc);
6652 cmd->flags = 0;
Michal Kazior24c88f72014-07-25 13:32:17 +02006653 cmd->antenna_mask = __cpu_to_le32(WMI_BCN_TX_REF_DEF_ANTENNA);
Michal Kazior748afc42014-01-23 12:48:21 +01006654
Michal Kazior9ad50182015-01-29 14:29:47 +02006655 if (dtim_zero)
Michal Kazior748afc42014-01-23 12:48:21 +01006656 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DTIM_ZERO);
6657
Michal Kazior9ad50182015-01-29 14:29:47 +02006658 if (deliver_cab)
Michal Kazior748afc42014-01-23 12:48:21 +01006659 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB);
6660
Michal Kaziord7579d12014-12-03 10:10:54 +02006661 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006662}
6663
Michal Kazior5e752e42015-01-19 09:53:41 +01006664void ath10k_wmi_set_wmm_param(struct wmi_wmm_params *params,
6665 const struct wmi_wmm_params_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006666{
6667 params->cwmin = __cpu_to_le32(arg->cwmin);
6668 params->cwmax = __cpu_to_le32(arg->cwmax);
6669 params->aifs = __cpu_to_le32(arg->aifs);
6670 params->txop = __cpu_to_le32(arg->txop);
6671 params->acm = __cpu_to_le32(arg->acm);
6672 params->no_ack = __cpu_to_le32(arg->no_ack);
6673}
6674
Michal Kaziord7579d12014-12-03 10:10:54 +02006675static struct sk_buff *
6676ath10k_wmi_op_gen_pdev_set_wmm(struct ath10k *ar,
Michal Kazior5e752e42015-01-19 09:53:41 +01006677 const struct wmi_wmm_params_all_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006678{
6679 struct wmi_pdev_set_wmm_params *cmd;
6680 struct sk_buff *skb;
6681
Michal Kazior7aa7a722014-08-25 12:09:38 +02006682 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006683 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006684 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006685
6686 cmd = (struct wmi_pdev_set_wmm_params *)skb->data;
Michal Kazior5e752e42015-01-19 09:53:41 +01006687 ath10k_wmi_set_wmm_param(&cmd->ac_be, &arg->ac_be);
6688 ath10k_wmi_set_wmm_param(&cmd->ac_bk, &arg->ac_bk);
6689 ath10k_wmi_set_wmm_param(&cmd->ac_vi, &arg->ac_vi);
6690 ath10k_wmi_set_wmm_param(&cmd->ac_vo, &arg->ac_vo);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006691
Michal Kazior7aa7a722014-08-25 12:09:38 +02006692 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set wmm params\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02006693 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006694}
6695
Michal Kaziord7579d12014-12-03 10:10:54 +02006696static struct sk_buff *
Michal Kaziorde23d3e2015-02-15 16:50:41 +02006697ath10k_wmi_op_gen_request_stats(struct ath10k *ar, u32 stats_mask)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006698{
6699 struct wmi_request_stats_cmd *cmd;
6700 struct sk_buff *skb;
6701
Michal Kazior7aa7a722014-08-25 12:09:38 +02006702 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006703 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006704 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006705
6706 cmd = (struct wmi_request_stats_cmd *)skb->data;
Michal Kaziorde23d3e2015-02-15 16:50:41 +02006707 cmd->stats_id = __cpu_to_le32(stats_mask);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006708
Michal Kaziorde23d3e2015-02-15 16:50:41 +02006709 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi request stats 0x%08x\n",
6710 stats_mask);
Michal Kaziord7579d12014-12-03 10:10:54 +02006711 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006712}
Michal Kazior9cfbce72013-07-16 09:54:36 +02006713
Michal Kaziord7579d12014-12-03 10:10:54 +02006714static struct sk_buff *
6715ath10k_wmi_op_gen_force_fw_hang(struct ath10k *ar,
6716 enum wmi_force_fw_hang_type type, u32 delay_ms)
Michal Kazior9cfbce72013-07-16 09:54:36 +02006717{
6718 struct wmi_force_fw_hang_cmd *cmd;
6719 struct sk_buff *skb;
6720
Michal Kazior7aa7a722014-08-25 12:09:38 +02006721 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Michal Kazior9cfbce72013-07-16 09:54:36 +02006722 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006723 return ERR_PTR(-ENOMEM);
Michal Kazior9cfbce72013-07-16 09:54:36 +02006724
6725 cmd = (struct wmi_force_fw_hang_cmd *)skb->data;
6726 cmd->type = __cpu_to_le32(type);
6727 cmd->delay_ms = __cpu_to_le32(delay_ms);
6728
Michal Kazior7aa7a722014-08-25 12:09:38 +02006729 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi force fw hang %d delay %d\n",
Michal Kazior9cfbce72013-07-16 09:54:36 +02006730 type, delay_ms);
Michal Kaziord7579d12014-12-03 10:10:54 +02006731 return skb;
Michal Kazior9cfbce72013-07-16 09:54:36 +02006732}
Kalle Valof118a3e2014-01-03 12:59:31 +02006733
Michal Kaziord7579d12014-12-03 10:10:54 +02006734static struct sk_buff *
SenthilKumar Jegadeesan467210a2015-01-29 14:36:52 +05306735ath10k_wmi_op_gen_dbglog_cfg(struct ath10k *ar, u32 module_enable,
6736 u32 log_level)
Kalle Valof118a3e2014-01-03 12:59:31 +02006737{
6738 struct wmi_dbglog_cfg_cmd *cmd;
6739 struct sk_buff *skb;
6740 u32 cfg;
6741
Michal Kazior7aa7a722014-08-25 12:09:38 +02006742 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valof118a3e2014-01-03 12:59:31 +02006743 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006744 return ERR_PTR(-ENOMEM);
Kalle Valof118a3e2014-01-03 12:59:31 +02006745
6746 cmd = (struct wmi_dbglog_cfg_cmd *)skb->data;
6747
6748 if (module_enable) {
SenthilKumar Jegadeesan467210a2015-01-29 14:36:52 +05306749 cfg = SM(log_level,
Kalle Valof118a3e2014-01-03 12:59:31 +02006750 ATH10K_DBGLOG_CFG_LOG_LVL);
6751 } else {
6752 /* set back defaults, all modules with WARN level */
6753 cfg = SM(ATH10K_DBGLOG_LEVEL_WARN,
6754 ATH10K_DBGLOG_CFG_LOG_LVL);
6755 module_enable = ~0;
6756 }
6757
6758 cmd->module_enable = __cpu_to_le32(module_enable);
6759 cmd->module_valid = __cpu_to_le32(~0);
6760 cmd->config_enable = __cpu_to_le32(cfg);
6761 cmd->config_valid = __cpu_to_le32(ATH10K_DBGLOG_CFG_LOG_LVL_MASK);
6762
Michal Kazior7aa7a722014-08-25 12:09:38 +02006763 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valof118a3e2014-01-03 12:59:31 +02006764 "wmi dbglog cfg modules %08x %08x config %08x %08x\n",
6765 __le32_to_cpu(cmd->module_enable),
6766 __le32_to_cpu(cmd->module_valid),
6767 __le32_to_cpu(cmd->config_enable),
6768 __le32_to_cpu(cmd->config_valid));
Michal Kaziord7579d12014-12-03 10:10:54 +02006769 return skb;
Kalle Valof118a3e2014-01-03 12:59:31 +02006770}
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02006771
Michal Kaziord7579d12014-12-03 10:10:54 +02006772static struct sk_buff *
6773ath10k_wmi_op_gen_pktlog_enable(struct ath10k *ar, u32 ev_bitmap)
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006774{
6775 struct wmi_pdev_pktlog_enable_cmd *cmd;
6776 struct sk_buff *skb;
6777
6778 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6779 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006780 return ERR_PTR(-ENOMEM);
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006781
6782 ev_bitmap &= ATH10K_PKTLOG_ANY;
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006783
6784 cmd = (struct wmi_pdev_pktlog_enable_cmd *)skb->data;
6785 cmd->ev_bitmap = __cpu_to_le32(ev_bitmap);
Michal Kaziord7579d12014-12-03 10:10:54 +02006786
6787 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi enable pktlog filter 0x%08x\n",
6788 ev_bitmap);
6789 return skb;
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006790}
6791
Michal Kaziord7579d12014-12-03 10:10:54 +02006792static struct sk_buff *
6793ath10k_wmi_op_gen_pktlog_disable(struct ath10k *ar)
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006794{
6795 struct sk_buff *skb;
6796
6797 skb = ath10k_wmi_alloc_skb(ar, 0);
6798 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006799 return ERR_PTR(-ENOMEM);
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006800
6801 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi disable pktlog\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02006802 return skb;
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006803}
6804
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02006805static struct sk_buff *
6806ath10k_wmi_op_gen_pdev_set_quiet_mode(struct ath10k *ar, u32 period,
6807 u32 duration, u32 next_offset,
6808 u32 enabled)
6809{
6810 struct wmi_pdev_set_quiet_cmd *cmd;
6811 struct sk_buff *skb;
6812
6813 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6814 if (!skb)
6815 return ERR_PTR(-ENOMEM);
6816
6817 cmd = (struct wmi_pdev_set_quiet_cmd *)skb->data;
6818 cmd->period = __cpu_to_le32(period);
6819 cmd->duration = __cpu_to_le32(duration);
6820 cmd->next_start = __cpu_to_le32(next_offset);
6821 cmd->enabled = __cpu_to_le32(enabled);
6822
6823 ath10k_dbg(ar, ATH10K_DBG_WMI,
6824 "wmi quiet param: period %u duration %u enabled %d\n",
6825 period, duration, enabled);
6826 return skb;
6827}
6828
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02006829static struct sk_buff *
6830ath10k_wmi_op_gen_addba_clear_resp(struct ath10k *ar, u32 vdev_id,
6831 const u8 *mac)
6832{
6833 struct wmi_addba_clear_resp_cmd *cmd;
6834 struct sk_buff *skb;
6835
6836 if (!mac)
6837 return ERR_PTR(-EINVAL);
6838
6839 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6840 if (!skb)
6841 return ERR_PTR(-ENOMEM);
6842
6843 cmd = (struct wmi_addba_clear_resp_cmd *)skb->data;
6844 cmd->vdev_id = __cpu_to_le32(vdev_id);
6845 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6846
6847 ath10k_dbg(ar, ATH10K_DBG_WMI,
6848 "wmi addba clear resp vdev_id 0x%X mac_addr %pM\n",
6849 vdev_id, mac);
6850 return skb;
6851}
6852
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02006853static struct sk_buff *
6854ath10k_wmi_op_gen_addba_send(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6855 u32 tid, u32 buf_size)
6856{
6857 struct wmi_addba_send_cmd *cmd;
6858 struct sk_buff *skb;
6859
6860 if (!mac)
6861 return ERR_PTR(-EINVAL);
6862
6863 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6864 if (!skb)
6865 return ERR_PTR(-ENOMEM);
6866
6867 cmd = (struct wmi_addba_send_cmd *)skb->data;
6868 cmd->vdev_id = __cpu_to_le32(vdev_id);
6869 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6870 cmd->tid = __cpu_to_le32(tid);
6871 cmd->buffersize = __cpu_to_le32(buf_size);
6872
6873 ath10k_dbg(ar, ATH10K_DBG_WMI,
6874 "wmi addba send vdev_id 0x%X mac_addr %pM tid %u bufsize %u\n",
6875 vdev_id, mac, tid, buf_size);
6876 return skb;
6877}
6878
Rajkumar Manoharan11597412015-01-12 14:07:26 +02006879static struct sk_buff *
6880ath10k_wmi_op_gen_addba_set_resp(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6881 u32 tid, u32 status)
6882{
6883 struct wmi_addba_setresponse_cmd *cmd;
6884 struct sk_buff *skb;
6885
6886 if (!mac)
6887 return ERR_PTR(-EINVAL);
6888
6889 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6890 if (!skb)
6891 return ERR_PTR(-ENOMEM);
6892
6893 cmd = (struct wmi_addba_setresponse_cmd *)skb->data;
6894 cmd->vdev_id = __cpu_to_le32(vdev_id);
6895 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6896 cmd->tid = __cpu_to_le32(tid);
6897 cmd->statuscode = __cpu_to_le32(status);
6898
6899 ath10k_dbg(ar, ATH10K_DBG_WMI,
6900 "wmi addba set resp vdev_id 0x%X mac_addr %pM tid %u status %u\n",
6901 vdev_id, mac, tid, status);
6902 return skb;
6903}
6904
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02006905static struct sk_buff *
6906ath10k_wmi_op_gen_delba_send(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6907 u32 tid, u32 initiator, u32 reason)
6908{
6909 struct wmi_delba_send_cmd *cmd;
6910 struct sk_buff *skb;
6911
6912 if (!mac)
6913 return ERR_PTR(-EINVAL);
6914
6915 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6916 if (!skb)
6917 return ERR_PTR(-ENOMEM);
6918
6919 cmd = (struct wmi_delba_send_cmd *)skb->data;
6920 cmd->vdev_id = __cpu_to_le32(vdev_id);
6921 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6922 cmd->tid = __cpu_to_le32(tid);
6923 cmd->initiator = __cpu_to_le32(initiator);
6924 cmd->reasoncode = __cpu_to_le32(reason);
6925
6926 ath10k_dbg(ar, ATH10K_DBG_WMI,
6927 "wmi delba send vdev_id 0x%X mac_addr %pM tid %u initiator %u reason %u\n",
6928 vdev_id, mac, tid, initiator, reason);
6929 return skb;
6930}
6931
Maharaja Kennadyrajan29542662015-10-05 17:56:38 +03006932static struct sk_buff *
6933ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config(struct ath10k *ar, u32 param)
6934{
6935 struct wmi_pdev_get_tpc_config_cmd *cmd;
6936 struct sk_buff *skb;
6937
6938 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6939 if (!skb)
6940 return ERR_PTR(-ENOMEM);
6941
6942 cmd = (struct wmi_pdev_get_tpc_config_cmd *)skb->data;
6943 cmd->param = __cpu_to_le32(param);
6944
6945 ath10k_dbg(ar, ATH10K_DBG_WMI,
6946 "wmi pdev get tcp config param:%d\n", param);
6947 return skb;
6948}
6949
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03006950size_t ath10k_wmi_fw_stats_num_peers(struct list_head *head)
6951{
6952 struct ath10k_fw_stats_peer *i;
6953 size_t num = 0;
6954
6955 list_for_each_entry(i, head, list)
6956 ++num;
6957
6958 return num;
6959}
6960
6961size_t ath10k_wmi_fw_stats_num_vdevs(struct list_head *head)
6962{
6963 struct ath10k_fw_stats_vdev *i;
6964 size_t num = 0;
6965
6966 list_for_each_entry(i, head, list)
6967 ++num;
6968
6969 return num;
6970}
6971
6972static void
6973ath10k_wmi_fw_pdev_base_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
6974 char *buf, u32 *length)
6975{
6976 u32 len = *length;
6977 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
6978
6979 len += scnprintf(buf + len, buf_len - len, "\n");
6980 len += scnprintf(buf + len, buf_len - len, "%30s\n",
6981 "ath10k PDEV stats");
6982 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
6983 "=================");
6984
6985 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6986 "Channel noise floor", pdev->ch_noise_floor);
6987 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6988 "Channel TX power", pdev->chan_tx_power);
6989 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6990 "TX frame count", pdev->tx_frame_count);
6991 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6992 "RX frame count", pdev->rx_frame_count);
6993 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6994 "RX clear count", pdev->rx_clear_count);
6995 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6996 "Cycle count", pdev->cycle_count);
6997 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6998 "PHY error count", pdev->phy_err_count);
6999
7000 *length = len;
7001}
7002
7003static void
7004ath10k_wmi_fw_pdev_extra_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
7005 char *buf, u32 *length)
7006{
7007 u32 len = *length;
7008 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7009
7010 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7011 "RTS bad count", pdev->rts_bad);
7012 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7013 "RTS good count", pdev->rts_good);
7014 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7015 "FCS bad count", pdev->fcs_bad);
7016 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7017 "No beacon count", pdev->no_beacons);
7018 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
7019 "MIB int count", pdev->mib_int_count);
7020
7021 len += scnprintf(buf + len, buf_len - len, "\n");
7022 *length = len;
7023}
7024
7025static void
7026ath10k_wmi_fw_pdev_tx_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
7027 char *buf, u32 *length)
7028{
7029 u32 len = *length;
7030 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7031
7032 len += scnprintf(buf + len, buf_len - len, "\n%30s\n",
7033 "ath10k PDEV TX stats");
7034 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7035 "=================");
7036
7037 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7038 "HTT cookies queued", pdev->comp_queued);
7039 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7040 "HTT cookies disp.", pdev->comp_delivered);
7041 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7042 "MSDU queued", pdev->msdu_enqued);
7043 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7044 "MPDU queued", pdev->mpdu_enqued);
7045 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7046 "MSDUs dropped", pdev->wmm_drop);
7047 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7048 "Local enqued", pdev->local_enqued);
7049 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7050 "Local freed", pdev->local_freed);
7051 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7052 "HW queued", pdev->hw_queued);
7053 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7054 "PPDUs reaped", pdev->hw_reaped);
7055 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7056 "Num underruns", pdev->underrun);
7057 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7058 "PPDUs cleaned", pdev->tx_abort);
7059 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7060 "MPDUs requed", pdev->mpdus_requed);
7061 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7062 "Excessive retries", pdev->tx_ko);
7063 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7064 "HW rate", pdev->data_rc);
7065 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7066 "Sched self tiggers", pdev->self_triggers);
7067 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7068 "Dropped due to SW retries",
7069 pdev->sw_retry_failure);
7070 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7071 "Illegal rate phy errors",
7072 pdev->illgl_rate_phy_err);
7073 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7074 "Pdev continuous xretry", pdev->pdev_cont_xretry);
7075 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7076 "TX timeout", pdev->pdev_tx_timeout);
7077 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7078 "PDEV resets", pdev->pdev_resets);
7079 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7080 "PHY underrun", pdev->phy_underrun);
7081 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7082 "MPDU is more than txop limit", pdev->txop_ovf);
7083 *length = len;
7084}
7085
7086static void
7087ath10k_wmi_fw_pdev_rx_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
7088 char *buf, u32 *length)
7089{
7090 u32 len = *length;
7091 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7092
7093 len += scnprintf(buf + len, buf_len - len, "\n%30s\n",
7094 "ath10k PDEV RX stats");
7095 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7096 "=================");
7097
7098 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7099 "Mid PPDU route change",
7100 pdev->mid_ppdu_route_change);
7101 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7102 "Tot. number of statuses", pdev->status_rcvd);
7103 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7104 "Extra frags on rings 0", pdev->r0_frags);
7105 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7106 "Extra frags on rings 1", pdev->r1_frags);
7107 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7108 "Extra frags on rings 2", pdev->r2_frags);
7109 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7110 "Extra frags on rings 3", pdev->r3_frags);
7111 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7112 "MSDUs delivered to HTT", pdev->htt_msdus);
7113 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7114 "MPDUs delivered to HTT", pdev->htt_mpdus);
7115 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7116 "MSDUs delivered to stack", pdev->loc_msdus);
7117 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7118 "MPDUs delivered to stack", pdev->loc_mpdus);
7119 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7120 "Oversized AMSUs", pdev->oversize_amsdu);
7121 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7122 "PHY errors", pdev->phy_errs);
7123 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7124 "PHY errors drops", pdev->phy_err_drop);
7125 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7126 "MPDU errors (FCS, MIC, ENC)", pdev->mpdu_errs);
7127 *length = len;
7128}
7129
7130static void
7131ath10k_wmi_fw_vdev_stats_fill(const struct ath10k_fw_stats_vdev *vdev,
7132 char *buf, u32 *length)
7133{
7134 u32 len = *length;
7135 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7136 int i;
7137
7138 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7139 "vdev id", vdev->vdev_id);
7140 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7141 "beacon snr", vdev->beacon_snr);
7142 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7143 "data snr", vdev->data_snr);
7144 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7145 "num rx frames", vdev->num_rx_frames);
7146 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7147 "num rts fail", vdev->num_rts_fail);
7148 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7149 "num rts success", vdev->num_rts_success);
7150 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7151 "num rx err", vdev->num_rx_err);
7152 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7153 "num rx discard", vdev->num_rx_discard);
7154 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7155 "num tx not acked", vdev->num_tx_not_acked);
7156
7157 for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames); i++)
7158 len += scnprintf(buf + len, buf_len - len,
7159 "%25s [%02d] %u\n",
7160 "num tx frames", i,
7161 vdev->num_tx_frames[i]);
7162
7163 for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames_retries); i++)
7164 len += scnprintf(buf + len, buf_len - len,
7165 "%25s [%02d] %u\n",
7166 "num tx frames retries", i,
7167 vdev->num_tx_frames_retries[i]);
7168
7169 for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames_failures); i++)
7170 len += scnprintf(buf + len, buf_len - len,
7171 "%25s [%02d] %u\n",
7172 "num tx frames failures", i,
7173 vdev->num_tx_frames_failures[i]);
7174
7175 for (i = 0 ; i < ARRAY_SIZE(vdev->tx_rate_history); i++)
7176 len += scnprintf(buf + len, buf_len - len,
7177 "%25s [%02d] 0x%08x\n",
7178 "tx rate history", i,
7179 vdev->tx_rate_history[i]);
7180
7181 for (i = 0 ; i < ARRAY_SIZE(vdev->beacon_rssi_history); i++)
7182 len += scnprintf(buf + len, buf_len - len,
7183 "%25s [%02d] %u\n",
7184 "beacon rssi history", i,
7185 vdev->beacon_rssi_history[i]);
7186
7187 len += scnprintf(buf + len, buf_len - len, "\n");
7188 *length = len;
7189}
7190
7191static void
7192ath10k_wmi_fw_peer_stats_fill(const struct ath10k_fw_stats_peer *peer,
7193 char *buf, u32 *length)
7194{
7195 u32 len = *length;
7196 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7197
7198 len += scnprintf(buf + len, buf_len - len, "%30s %pM\n",
7199 "Peer MAC address", peer->peer_macaddr);
7200 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7201 "Peer RSSI", peer->peer_rssi);
7202 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7203 "Peer TX rate", peer->peer_tx_rate);
7204 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7205 "Peer RX rate", peer->peer_rx_rate);
Mohammed Shafi Shajakhande46c012016-01-13 21:16:28 +05307206 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7207 "Peer RX duration", peer->rx_duration);
7208
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03007209 len += scnprintf(buf + len, buf_len - len, "\n");
7210 *length = len;
7211}
7212
7213void ath10k_wmi_main_op_fw_stats_fill(struct ath10k *ar,
7214 struct ath10k_fw_stats *fw_stats,
7215 char *buf)
7216{
7217 u32 len = 0;
7218 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7219 const struct ath10k_fw_stats_pdev *pdev;
7220 const struct ath10k_fw_stats_vdev *vdev;
7221 const struct ath10k_fw_stats_peer *peer;
7222 size_t num_peers;
7223 size_t num_vdevs;
7224
7225 spin_lock_bh(&ar->data_lock);
7226
7227 pdev = list_first_entry_or_null(&fw_stats->pdevs,
7228 struct ath10k_fw_stats_pdev, list);
7229 if (!pdev) {
7230 ath10k_warn(ar, "failed to get pdev stats\n");
7231 goto unlock;
7232 }
7233
7234 num_peers = ath10k_wmi_fw_stats_num_peers(&fw_stats->peers);
7235 num_vdevs = ath10k_wmi_fw_stats_num_vdevs(&fw_stats->vdevs);
7236
7237 ath10k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len);
7238 ath10k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len);
7239 ath10k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len);
7240
7241 len += scnprintf(buf + len, buf_len - len, "\n");
7242 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7243 "ath10k VDEV stats", num_vdevs);
7244 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7245 "=================");
7246
7247 list_for_each_entry(vdev, &fw_stats->vdevs, list) {
7248 ath10k_wmi_fw_vdev_stats_fill(vdev, buf, &len);
7249 }
7250
7251 len += scnprintf(buf + len, buf_len - len, "\n");
7252 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7253 "ath10k PEER stats", num_peers);
7254 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7255 "=================");
7256
7257 list_for_each_entry(peer, &fw_stats->peers, list) {
7258 ath10k_wmi_fw_peer_stats_fill(peer, buf, &len);
7259 }
7260
7261unlock:
7262 spin_unlock_bh(&ar->data_lock);
7263
7264 if (len >= buf_len)
7265 buf[len - 1] = 0;
7266 else
7267 buf[len] = 0;
7268}
7269
7270void ath10k_wmi_10x_op_fw_stats_fill(struct ath10k *ar,
7271 struct ath10k_fw_stats *fw_stats,
7272 char *buf)
7273{
7274 unsigned int len = 0;
7275 unsigned int buf_len = ATH10K_FW_STATS_BUF_SIZE;
7276 const struct ath10k_fw_stats_pdev *pdev;
7277 const struct ath10k_fw_stats_vdev *vdev;
7278 const struct ath10k_fw_stats_peer *peer;
7279 size_t num_peers;
7280 size_t num_vdevs;
7281
7282 spin_lock_bh(&ar->data_lock);
7283
7284 pdev = list_first_entry_or_null(&fw_stats->pdevs,
7285 struct ath10k_fw_stats_pdev, list);
7286 if (!pdev) {
7287 ath10k_warn(ar, "failed to get pdev stats\n");
7288 goto unlock;
7289 }
7290
7291 num_peers = ath10k_wmi_fw_stats_num_peers(&fw_stats->peers);
7292 num_vdevs = ath10k_wmi_fw_stats_num_vdevs(&fw_stats->vdevs);
7293
7294 ath10k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len);
7295 ath10k_wmi_fw_pdev_extra_stats_fill(pdev, buf, &len);
7296 ath10k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len);
7297 ath10k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len);
7298
7299 len += scnprintf(buf + len, buf_len - len, "\n");
7300 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7301 "ath10k VDEV stats", num_vdevs);
7302 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7303 "=================");
7304
7305 list_for_each_entry(vdev, &fw_stats->vdevs, list) {
7306 ath10k_wmi_fw_vdev_stats_fill(vdev, buf, &len);
7307 }
7308
7309 len += scnprintf(buf + len, buf_len - len, "\n");
7310 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7311 "ath10k PEER stats", num_peers);
7312 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7313 "=================");
7314
7315 list_for_each_entry(peer, &fw_stats->peers, list) {
7316 ath10k_wmi_fw_peer_stats_fill(peer, buf, &len);
7317 }
7318
7319unlock:
7320 spin_unlock_bh(&ar->data_lock);
7321
7322 if (len >= buf_len)
7323 buf[len - 1] = 0;
7324 else
7325 buf[len] = 0;
7326}
7327
Maharaja62f77f02015-10-21 11:49:18 +03007328static struct sk_buff *
7329ath10k_wmi_op_gen_pdev_enable_adaptive_cca(struct ath10k *ar, u8 enable,
7330 u32 detect_level, u32 detect_margin)
7331{
7332 struct wmi_pdev_set_adaptive_cca_params *cmd;
7333 struct sk_buff *skb;
7334
7335 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7336 if (!skb)
7337 return ERR_PTR(-ENOMEM);
7338
7339 cmd = (struct wmi_pdev_set_adaptive_cca_params *)skb->data;
7340 cmd->enable = __cpu_to_le32(enable);
7341 cmd->cca_detect_level = __cpu_to_le32(detect_level);
7342 cmd->cca_detect_margin = __cpu_to_le32(detect_margin);
7343
7344 ath10k_dbg(ar, ATH10K_DBG_WMI,
7345 "wmi pdev set adaptive cca params enable:%d detection level:%d detection margin:%d\n",
7346 enable, detect_level, detect_margin);
7347 return skb;
7348}
7349
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02007350void ath10k_wmi_10_4_op_fw_stats_fill(struct ath10k *ar,
7351 struct ath10k_fw_stats *fw_stats,
7352 char *buf)
7353{
7354 u32 len = 0;
7355 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7356 const struct ath10k_fw_stats_pdev *pdev;
7357 const struct ath10k_fw_stats_vdev *vdev;
7358 const struct ath10k_fw_stats_peer *peer;
7359 size_t num_peers;
7360 size_t num_vdevs;
7361
7362 spin_lock_bh(&ar->data_lock);
7363
7364 pdev = list_first_entry_or_null(&fw_stats->pdevs,
7365 struct ath10k_fw_stats_pdev, list);
7366 if (!pdev) {
7367 ath10k_warn(ar, "failed to get pdev stats\n");
7368 goto unlock;
7369 }
7370
7371 num_peers = ath10k_wmi_fw_stats_num_peers(&fw_stats->peers);
7372 num_vdevs = ath10k_wmi_fw_stats_num_vdevs(&fw_stats->vdevs);
7373
7374 ath10k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len);
7375 ath10k_wmi_fw_pdev_extra_stats_fill(pdev, buf, &len);
7376 ath10k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len);
7377
7378 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7379 "HW paused", pdev->hw_paused);
7380 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7381 "Seqs posted", pdev->seq_posted);
7382 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7383 "Seqs failed queueing", pdev->seq_failed_queueing);
7384 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7385 "Seqs completed", pdev->seq_completed);
7386 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7387 "Seqs restarted", pdev->seq_restarted);
7388 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7389 "MU Seqs posted", pdev->mu_seq_posted);
7390 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7391 "MPDUs SW flushed", pdev->mpdus_sw_flush);
7392 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7393 "MPDUs HW filtered", pdev->mpdus_hw_filter);
7394 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7395 "MPDUs truncated", pdev->mpdus_truncated);
7396 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7397 "MPDUs receive no ACK", pdev->mpdus_ack_failed);
7398 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7399 "MPDUs expired", pdev->mpdus_expired);
7400
7401 ath10k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len);
7402 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7403 "Num Rx Overflow errors", pdev->rx_ovfl_errs);
7404
7405 len += scnprintf(buf + len, buf_len - len, "\n");
7406 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7407 "ath10k VDEV stats", num_vdevs);
7408 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7409 "=================");
7410
7411 list_for_each_entry(vdev, &fw_stats->vdevs, list) {
7412 ath10k_wmi_fw_vdev_stats_fill(vdev, buf, &len);
7413 }
7414
7415 len += scnprintf(buf + len, buf_len - len, "\n");
7416 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7417 "ath10k PEER stats", num_peers);
7418 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7419 "=================");
7420
7421 list_for_each_entry(peer, &fw_stats->peers, list) {
7422 ath10k_wmi_fw_peer_stats_fill(peer, buf, &len);
7423 }
7424
7425unlock:
7426 spin_unlock_bh(&ar->data_lock);
7427
7428 if (len >= buf_len)
7429 buf[len - 1] = 0;
7430 else
7431 buf[len] = 0;
7432}
7433
Peter Oh6e4de1a2016-01-28 13:54:10 -08007434int ath10k_wmi_op_get_vdev_subtype(struct ath10k *ar,
7435 enum wmi_vdev_subtype subtype)
7436{
7437 switch (subtype) {
7438 case WMI_VDEV_SUBTYPE_NONE:
7439 return WMI_VDEV_SUBTYPE_LEGACY_NONE;
7440 case WMI_VDEV_SUBTYPE_P2P_DEVICE:
7441 return WMI_VDEV_SUBTYPE_LEGACY_P2P_DEV;
7442 case WMI_VDEV_SUBTYPE_P2P_CLIENT:
7443 return WMI_VDEV_SUBTYPE_LEGACY_P2P_CLI;
7444 case WMI_VDEV_SUBTYPE_P2P_GO:
7445 return WMI_VDEV_SUBTYPE_LEGACY_P2P_GO;
7446 case WMI_VDEV_SUBTYPE_PROXY_STA:
7447 return WMI_VDEV_SUBTYPE_LEGACY_PROXY_STA;
7448 case WMI_VDEV_SUBTYPE_MESH_11S:
7449 case WMI_VDEV_SUBTYPE_MESH_NON_11S:
7450 return -ENOTSUPP;
7451 }
7452 return -ENOTSUPP;
7453}
7454
7455static int ath10k_wmi_10_2_4_op_get_vdev_subtype(struct ath10k *ar,
7456 enum wmi_vdev_subtype subtype)
7457{
7458 switch (subtype) {
7459 case WMI_VDEV_SUBTYPE_NONE:
7460 return WMI_VDEV_SUBTYPE_10_2_4_NONE;
7461 case WMI_VDEV_SUBTYPE_P2P_DEVICE:
7462 return WMI_VDEV_SUBTYPE_10_2_4_P2P_DEV;
7463 case WMI_VDEV_SUBTYPE_P2P_CLIENT:
7464 return WMI_VDEV_SUBTYPE_10_2_4_P2P_CLI;
7465 case WMI_VDEV_SUBTYPE_P2P_GO:
7466 return WMI_VDEV_SUBTYPE_10_2_4_P2P_GO;
7467 case WMI_VDEV_SUBTYPE_PROXY_STA:
7468 return WMI_VDEV_SUBTYPE_10_2_4_PROXY_STA;
7469 case WMI_VDEV_SUBTYPE_MESH_11S:
7470 return WMI_VDEV_SUBTYPE_10_2_4_MESH_11S;
7471 case WMI_VDEV_SUBTYPE_MESH_NON_11S:
7472 return -ENOTSUPP;
7473 }
7474 return -ENOTSUPP;
7475}
7476
7477static int ath10k_wmi_10_4_op_get_vdev_subtype(struct ath10k *ar,
7478 enum wmi_vdev_subtype subtype)
7479{
7480 switch (subtype) {
7481 case WMI_VDEV_SUBTYPE_NONE:
7482 return WMI_VDEV_SUBTYPE_10_4_NONE;
7483 case WMI_VDEV_SUBTYPE_P2P_DEVICE:
7484 return WMI_VDEV_SUBTYPE_10_4_P2P_DEV;
7485 case WMI_VDEV_SUBTYPE_P2P_CLIENT:
7486 return WMI_VDEV_SUBTYPE_10_4_P2P_CLI;
7487 case WMI_VDEV_SUBTYPE_P2P_GO:
7488 return WMI_VDEV_SUBTYPE_10_4_P2P_GO;
7489 case WMI_VDEV_SUBTYPE_PROXY_STA:
7490 return WMI_VDEV_SUBTYPE_10_4_PROXY_STA;
7491 case WMI_VDEV_SUBTYPE_MESH_11S:
7492 return WMI_VDEV_SUBTYPE_10_4_MESH_11S;
7493 case WMI_VDEV_SUBTYPE_MESH_NON_11S:
7494 return WMI_VDEV_SUBTYPE_10_4_MESH_NON_11S;
7495 }
7496 return -ENOTSUPP;
7497}
7498
Michal Kaziord7579d12014-12-03 10:10:54 +02007499static const struct wmi_ops wmi_ops = {
7500 .rx = ath10k_wmi_op_rx,
7501 .map_svc = wmi_main_svc_map,
7502
7503 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7504 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7505 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7506 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7507 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7508 .pull_swba = ath10k_wmi_op_pull_swba_ev,
Raja Mani991adf72015-08-14 11:13:29 +03007509 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
Michal Kaziord7579d12014-12-03 10:10:54 +02007510 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7511 .pull_svc_rdy = ath10k_wmi_main_op_pull_svc_rdy_ev,
7512 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
7513 .pull_fw_stats = ath10k_wmi_main_op_pull_fw_stats,
Michal Kaziorc1a46542015-03-10 16:21:54 +02007514 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02007515
7516 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7517 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7518 .gen_pdev_set_rd = ath10k_wmi_op_gen_pdev_set_rd,
7519 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7520 .gen_init = ath10k_wmi_op_gen_init,
7521 .gen_start_scan = ath10k_wmi_op_gen_start_scan,
7522 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7523 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7524 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7525 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7526 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7527 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7528 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7529 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7530 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7531 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7532 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
Michal Kazior6d492fe2015-01-28 09:57:22 +02007533 /* .gen_vdev_wmm_conf not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007534 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7535 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7536 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7537 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7538 .gen_peer_assoc = ath10k_wmi_op_gen_peer_assoc,
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_request_stats = ath10k_wmi_op_gen_request_stats,
7546 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7547 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7548 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7549 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7550 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02007551 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02007552 /* .gen_pdev_get_temperature not implemented */
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02007553 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02007554 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02007555 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02007556 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03007557 .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
Peter Oh6e4de1a2016-01-28 13:54:10 -08007558 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
Michal Kaziorbe9ce9d2015-01-13 16:30:11 +02007559 /* .gen_bcn_tmpl not implemented */
Michal Kazior4c4955f2015-01-13 16:30:11 +02007560 /* .gen_prb_tmpl not implemented */
Michal Kazior369242b4e2015-01-13 16:30:11 +02007561 /* .gen_p2p_go_bcn_ie not implemented */
Michal Kazior5b272e32015-03-31 10:26:22 +00007562 /* .gen_adaptive_qcs not implemented */
Maharaja62f77f02015-10-21 11:49:18 +03007563 /* .gen_pdev_enable_adaptive_cca not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007564};
7565
7566static const struct wmi_ops wmi_10_1_ops = {
7567 .rx = ath10k_wmi_10_1_op_rx,
7568 .map_svc = wmi_10x_svc_map,
7569 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
7570 .pull_fw_stats = ath10k_wmi_10x_op_pull_fw_stats,
7571 .gen_init = ath10k_wmi_10_1_op_gen_init,
7572 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7573 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
7574 .gen_peer_assoc = ath10k_wmi_10_1_op_gen_peer_assoc,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02007575 /* .gen_pdev_get_temperature not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007576
7577 /* shared with main branch */
7578 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7579 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7580 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7581 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7582 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7583 .pull_swba = ath10k_wmi_op_pull_swba_ev,
Raja Mani991adf72015-08-14 11:13:29 +03007584 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
Michal Kaziord7579d12014-12-03 10:10:54 +02007585 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7586 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
Michal Kaziorc1a46542015-03-10 16:21:54 +02007587 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02007588
7589 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7590 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7591 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7592 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7593 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7594 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7595 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7596 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7597 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7598 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7599 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7600 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7601 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7602 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
Michal Kazior6d492fe2015-01-28 09:57:22 +02007603 /* .gen_vdev_wmm_conf not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007604 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7605 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7606 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7607 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7608 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7609 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7610 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7611 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7612 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7613 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7614 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7615 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7616 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7617 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7618 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7619 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02007620 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02007621 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02007622 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02007623 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02007624 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03007625 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
Peter Oh6e4de1a2016-01-28 13:54:10 -08007626 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
Michal Kaziorbe9ce9d2015-01-13 16:30:11 +02007627 /* .gen_bcn_tmpl not implemented */
Michal Kazior4c4955f2015-01-13 16:30:11 +02007628 /* .gen_prb_tmpl not implemented */
Michal Kazior369242b4e2015-01-13 16:30:11 +02007629 /* .gen_p2p_go_bcn_ie not implemented */
Michal Kazior5b272e32015-03-31 10:26:22 +00007630 /* .gen_adaptive_qcs not implemented */
Maharaja62f77f02015-10-21 11:49:18 +03007631 /* .gen_pdev_enable_adaptive_cca not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007632};
7633
7634static const struct wmi_ops wmi_10_2_ops = {
7635 .rx = ath10k_wmi_10_2_op_rx,
Michal Kazior20de2222015-01-24 12:14:49 +02007636 .pull_fw_stats = ath10k_wmi_10_2_op_pull_fw_stats,
Michal Kaziord7579d12014-12-03 10:10:54 +02007637 .gen_init = ath10k_wmi_10_2_op_gen_init,
7638 .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02007639 /* .gen_pdev_get_temperature not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007640
7641 /* shared with 10.1 */
7642 .map_svc = wmi_10x_svc_map,
7643 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02007644 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7645 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
7646
7647 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7648 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7649 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7650 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7651 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7652 .pull_swba = ath10k_wmi_op_pull_swba_ev,
Raja Mani991adf72015-08-14 11:13:29 +03007653 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
Michal Kaziord7579d12014-12-03 10:10:54 +02007654 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7655 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
Michal Kaziorc1a46542015-03-10 16:21:54 +02007656 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02007657
7658 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7659 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7660 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7661 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7662 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7663 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7664 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7665 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7666 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7667 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7668 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7669 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7670 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7671 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
Michal Kazior6d492fe2015-01-28 09:57:22 +02007672 /* .gen_vdev_wmm_conf not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007673 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7674 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7675 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7676 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7677 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7678 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7679 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7680 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7681 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7682 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7683 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7684 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7685 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7686 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7687 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7688 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02007689 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02007690 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02007691 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02007692 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02007693 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03007694 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
Peter Oh6e4de1a2016-01-28 13:54:10 -08007695 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
Maharaja62f77f02015-10-21 11:49:18 +03007696 /* .gen_pdev_enable_adaptive_cca not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007697};
7698
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007699static const struct wmi_ops wmi_10_2_4_ops = {
7700 .rx = ath10k_wmi_10_2_op_rx,
Michal Kazior20de2222015-01-24 12:14:49 +02007701 .pull_fw_stats = ath10k_wmi_10_2_4_op_pull_fw_stats,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007702 .gen_init = ath10k_wmi_10_2_op_gen_init,
7703 .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02007704 .gen_pdev_get_temperature = ath10k_wmi_10_2_op_gen_pdev_get_temperature,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007705
7706 /* shared with 10.1 */
7707 .map_svc = wmi_10x_svc_map,
7708 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007709 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7710 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
7711
7712 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7713 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7714 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7715 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7716 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
Yanbo Li8b019fb2016-01-14 15:39:19 -08007717 .pull_swba = ath10k_wmi_10_2_4_op_pull_swba_ev,
Raja Mani991adf72015-08-14 11:13:29 +03007718 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007719 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7720 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
Michal Kaziorc1a46542015-03-10 16:21:54 +02007721 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007722
7723 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7724 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7725 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7726 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7727 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7728 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7729 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7730 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7731 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7732 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7733 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7734 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7735 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7736 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
7737 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7738 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7739 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7740 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7741 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7742 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7743 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7744 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7745 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7746 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7747 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7748 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7749 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7750 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7751 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7752 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02007753 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02007754 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02007755 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02007756 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02007757 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Maharaja Kennadyrajan29542662015-10-05 17:56:38 +03007758 .gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config,
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03007759 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
Maharaja62f77f02015-10-21 11:49:18 +03007760 .gen_pdev_enable_adaptive_cca =
7761 ath10k_wmi_op_gen_pdev_enable_adaptive_cca,
Peter Oh6e4de1a2016-01-28 13:54:10 -08007762 .get_vdev_subtype = ath10k_wmi_10_2_4_op_get_vdev_subtype,
Michal Kaziorbe9ce9d2015-01-13 16:30:11 +02007763 /* .gen_bcn_tmpl not implemented */
Michal Kazior4c4955f2015-01-13 16:30:11 +02007764 /* .gen_prb_tmpl not implemented */
Michal Kazior369242b4e2015-01-13 16:30:11 +02007765 /* .gen_p2p_go_bcn_ie not implemented */
Michal Kazior5b272e32015-03-31 10:26:22 +00007766 /* .gen_adaptive_qcs not implemented */
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007767};
7768
Raja Mani840357c2015-06-22 20:10:10 +05307769static const struct wmi_ops wmi_10_4_ops = {
Raja Mani1c092962015-06-22 20:10:16 +05307770 .rx = ath10k_wmi_10_4_op_rx,
Raja Mani840357c2015-06-22 20:10:10 +05307771 .map_svc = wmi_10_4_svc_map,
Raja Manib2297ba2015-06-22 20:22:23 +05307772
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02007773 .pull_fw_stats = ath10k_wmi_10_4_op_pull_fw_stats,
Raja Manib2297ba2015-06-22 20:22:23 +05307774 .pull_scan = ath10k_wmi_op_pull_scan_ev,
Raja Mani1c092962015-06-22 20:10:16 +05307775 .pull_mgmt_rx = ath10k_wmi_10_4_op_pull_mgmt_rx_ev,
Raja Manib2297ba2015-06-22 20:22:23 +05307776 .pull_ch_info = ath10k_wmi_10_4_op_pull_ch_info_ev,
Raja Mani373b48c2015-06-22 20:22:22 +05307777 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7778 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
Raja Mani3cec3be2015-06-22 20:22:21 +05307779 .pull_swba = ath10k_wmi_10_4_op_pull_swba_ev,
Raja Mani2b0a2e02015-08-14 11:13:34 +03007780 .pull_phyerr_hdr = ath10k_wmi_10_4_op_pull_phyerr_ev_hdr,
7781 .pull_phyerr = ath10k_wmi_10_4_op_pull_phyerr_ev,
Raja Mani1c092962015-06-22 20:10:16 +05307782 .pull_svc_rdy = ath10k_wmi_main_op_pull_svc_rdy_ev,
Raja Manid02e7522015-06-22 20:10:18 +05307783 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
Vivek Natarajan08e75ea2015-08-04 10:45:11 +05307784 .get_txbf_conf_scheme = ath10k_wmi_10_4_txbf_conf_scheme,
Raja Mani373b48c2015-06-22 20:22:22 +05307785
7786 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7787 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7788 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7789 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
Raja Manid1e52a82015-06-22 20:10:15 +05307790 .gen_init = ath10k_wmi_10_4_op_gen_init,
Raja Manib2297ba2015-06-22 20:22:23 +05307791 .gen_start_scan = ath10k_wmi_op_gen_start_scan,
7792 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
Raja Mani373b48c2015-06-22 20:22:22 +05307793 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7794 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7795 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7796 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7797 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7798 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7799 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7800 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
Raja Mani4535edb2015-08-20 10:29:05 +05307801 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7802 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
Raja Mani373b48c2015-06-22 20:22:22 +05307803 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7804 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7805 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7806 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
Vasanthakumar Thiagarajanb54e16f2015-11-05 11:33:58 +05307807 .gen_peer_assoc = ath10k_wmi_10_4_op_gen_peer_assoc,
Raja Mani373b48c2015-06-22 20:22:22 +05307808 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7809 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7810 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7811 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7812 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7813 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7814 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7815 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7816 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7817 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7818 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
7819 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Vasanthakumar Thiagarajanb2887412015-08-13 21:10:54 +05307820 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
7821 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
7822 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
7823 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02007824 .fw_stats_fill = ath10k_wmi_10_4_op_fw_stats_fill,
Raja Mani373b48c2015-06-22 20:22:22 +05307825
7826 /* shared with 10.2 */
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02007827 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
Tamizh chelvam6dd46342015-10-31 11:20:32 +02007828 .gen_pdev_get_temperature = ath10k_wmi_10_2_op_gen_pdev_get_temperature,
Peter Oh6e4de1a2016-01-28 13:54:10 -08007829 .get_vdev_subtype = ath10k_wmi_10_4_op_get_vdev_subtype,
Raja Mani840357c2015-06-22 20:10:10 +05307830};
7831
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007832int ath10k_wmi_attach(struct ath10k *ar)
7833{
Michal Kaziord7579d12014-12-03 10:10:54 +02007834 switch (ar->wmi.op_version) {
Raja Mani9bd21322015-06-22 20:10:09 +05307835 case ATH10K_FW_WMI_OP_VERSION_10_4:
Raja Mani840357c2015-06-22 20:10:10 +05307836 ar->wmi.ops = &wmi_10_4_ops;
Raja Mani2d491e62015-06-22 20:10:11 +05307837 ar->wmi.cmd = &wmi_10_4_cmd_map;
Raja Mani93841a12015-06-22 20:10:13 +05307838 ar->wmi.vdev_param = &wmi_10_4_vdev_param_map;
Raja Manid86561f2015-06-22 20:10:14 +05307839 ar->wmi.pdev_param = &wmi_10_4_pdev_param_map;
Tamizh chelvam3fab30f2015-10-29 14:27:37 +02007840 ar->wmi.peer_flags = &wmi_10_2_peer_flags_map;
Raja Mani9bd21322015-06-22 20:10:09 +05307841 break;
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007842 case ATH10K_FW_WMI_OP_VERSION_10_2_4:
7843 ar->wmi.cmd = &wmi_10_2_4_cmd_map;
7844 ar->wmi.ops = &wmi_10_2_4_ops;
7845 ar->wmi.vdev_param = &wmi_10_2_4_vdev_param_map;
7846 ar->wmi.pdev_param = &wmi_10_2_4_pdev_param_map;
Tamizh chelvam3fab30f2015-10-29 14:27:37 +02007847 ar->wmi.peer_flags = &wmi_10_2_peer_flags_map;
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007848 break;
Michal Kaziord7579d12014-12-03 10:10:54 +02007849 case ATH10K_FW_WMI_OP_VERSION_10_2:
7850 ar->wmi.cmd = &wmi_10_2_cmd_map;
7851 ar->wmi.ops = &wmi_10_2_ops;
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007852 ar->wmi.vdev_param = &wmi_10x_vdev_param_map;
7853 ar->wmi.pdev_param = &wmi_10x_pdev_param_map;
Tamizh chelvam3fab30f2015-10-29 14:27:37 +02007854 ar->wmi.peer_flags = &wmi_10_2_peer_flags_map;
Michal Kaziord7579d12014-12-03 10:10:54 +02007855 break;
7856 case ATH10K_FW_WMI_OP_VERSION_10_1:
7857 ar->wmi.cmd = &wmi_10x_cmd_map;
7858 ar->wmi.ops = &wmi_10_1_ops;
7859 ar->wmi.vdev_param = &wmi_10x_vdev_param_map;
7860 ar->wmi.pdev_param = &wmi_10x_pdev_param_map;
Tamizh chelvam3fab30f2015-10-29 14:27:37 +02007861 ar->wmi.peer_flags = &wmi_10x_peer_flags_map;
Michal Kaziord7579d12014-12-03 10:10:54 +02007862 break;
7863 case ATH10K_FW_WMI_OP_VERSION_MAIN:
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007864 ar->wmi.cmd = &wmi_cmd_map;
Michal Kaziord7579d12014-12-03 10:10:54 +02007865 ar->wmi.ops = &wmi_ops;
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007866 ar->wmi.vdev_param = &wmi_vdev_param_map;
7867 ar->wmi.pdev_param = &wmi_pdev_param_map;
Tamizh chelvam3fab30f2015-10-29 14:27:37 +02007868 ar->wmi.peer_flags = &wmi_peer_flags_map;
Michal Kaziord7579d12014-12-03 10:10:54 +02007869 break;
Michal Kaziorca996ec2014-12-03 10:11:32 +02007870 case ATH10K_FW_WMI_OP_VERSION_TLV:
7871 ath10k_wmi_tlv_attach(ar);
7872 break;
Michal Kaziord7579d12014-12-03 10:10:54 +02007873 case ATH10K_FW_WMI_OP_VERSION_UNSET:
7874 case ATH10K_FW_WMI_OP_VERSION_MAX:
7875 ath10k_err(ar, "unsupported WMI op version: %d\n",
7876 ar->wmi.op_version);
7877 return -EINVAL;
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007878 }
7879
7880 init_completion(&ar->wmi.service_ready);
7881 init_completion(&ar->wmi.unified_ready);
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007882
Raja Manic8ecfc12015-07-29 11:40:38 +03007883 INIT_WORK(&ar->svc_rdy_work, ath10k_wmi_event_service_ready_work);
7884
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007885 return 0;
7886}
7887
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05307888void ath10k_wmi_free_host_mem(struct ath10k *ar)
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007889{
7890 int i;
7891
7892 /* free the host memory chunks requested by firmware */
7893 for (i = 0; i < ar->wmi.num_mem_chunks; i++) {
Felix Fietkaub0578862015-11-30 19:32:01 +01007894 dma_unmap_single(ar->dev,
7895 ar->wmi.mem_chunks[i].paddr,
7896 ar->wmi.mem_chunks[i].len,
7897 DMA_TO_DEVICE);
7898 kfree(ar->wmi.mem_chunks[i].vaddr);
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007899 }
7900
7901 ar->wmi.num_mem_chunks = 0;
7902}
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05307903
7904void ath10k_wmi_detach(struct ath10k *ar)
7905{
7906 cancel_work_sync(&ar->svc_rdy_work);
7907
7908 if (ar->svc_rdy_skb)
7909 dev_kfree_skb(ar->svc_rdy_skb);
7910}