blob: 6028a598c199f75318d4a24565bc9adbde3cc40d [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{
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001817 struct wmi_mgmt_tx_cmd *cmd;
1818 struct ieee80211_hdr *hdr;
Michal Kaziord7579d12014-12-03 10:10:54 +02001819 struct sk_buff *skb;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001820 int len;
Michal Kaziord7579d12014-12-03 10:10:54 +02001821 u32 buf_len = msdu->len;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001822 u16 fc;
1823
Michal Kaziord7579d12014-12-03 10:10:54 +02001824 hdr = (struct ieee80211_hdr *)msdu->data;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001825 fc = le16_to_cpu(hdr->frame_control);
1826
1827 if (WARN_ON_ONCE(!ieee80211_is_mgmt(hdr->frame_control)))
Michal Kaziord7579d12014-12-03 10:10:54 +02001828 return ERR_PTR(-EINVAL);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001829
Michal Kaziord7579d12014-12-03 10:10:54 +02001830 len = sizeof(cmd->hdr) + msdu->len;
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03001831
1832 if ((ieee80211_is_action(hdr->frame_control) ||
1833 ieee80211_is_deauth(hdr->frame_control) ||
1834 ieee80211_is_disassoc(hdr->frame_control)) &&
1835 ieee80211_has_protected(hdr->frame_control)) {
1836 len += IEEE80211_CCMP_MIC_LEN;
1837 buf_len += IEEE80211_CCMP_MIC_LEN;
1838 }
1839
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001840 len = round_up(len, 4);
1841
Michal Kaziord7579d12014-12-03 10:10:54 +02001842 skb = ath10k_wmi_alloc_skb(ar, len);
1843 if (!skb)
1844 return ERR_PTR(-ENOMEM);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001845
Michal Kaziord7579d12014-12-03 10:10:54 +02001846 cmd = (struct wmi_mgmt_tx_cmd *)skb->data;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001847
Michal Kaziord7579d12014-12-03 10:10:54 +02001848 cmd->hdr.vdev_id = __cpu_to_le32(ATH10K_SKB_CB(msdu)->vdev_id);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001849 cmd->hdr.tx_rate = 0;
1850 cmd->hdr.tx_power = 0;
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03001851 cmd->hdr.buf_len = __cpu_to_le32(buf_len);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001852
Kalle Valob25f32c2014-09-14 12:50:49 +03001853 ether_addr_copy(cmd->hdr.peer_macaddr.addr, ieee80211_get_DA(hdr));
Michal Kaziord7579d12014-12-03 10:10:54 +02001854 memcpy(cmd->buf, msdu->data, msdu->len);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001855
Michal Kazior7aa7a722014-08-25 12:09:38 +02001856 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 +02001857 msdu, skb->len, fc & IEEE80211_FCTL_FTYPE,
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001858 fc & IEEE80211_FCTL_STYPE);
Rajkumar Manoharan5ce8e7f2014-11-05 19:14:31 +05301859 trace_ath10k_tx_hdr(ar, skb->data, skb->len);
1860 trace_ath10k_tx_payload(ar, skb->data, skb->len);
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001861
Michal Kaziord7579d12014-12-03 10:10:54 +02001862 return skb;
Bartosz Markowski5e00d312013-09-26 17:47:12 +02001863}
1864
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001865static void ath10k_wmi_event_scan_started(struct ath10k *ar)
1866{
1867 lockdep_assert_held(&ar->data_lock);
1868
1869 switch (ar->scan.state) {
1870 case ATH10K_SCAN_IDLE:
1871 case ATH10K_SCAN_RUNNING:
1872 case ATH10K_SCAN_ABORTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02001873 ath10k_warn(ar, "received scan started event in an invalid scan state: %s (%d)\n",
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001874 ath10k_scan_state_str(ar->scan.state),
1875 ar->scan.state);
1876 break;
1877 case ATH10K_SCAN_STARTING:
1878 ar->scan.state = ATH10K_SCAN_RUNNING;
1879
1880 if (ar->scan.is_roc)
1881 ieee80211_ready_on_channel(ar->hw);
1882
1883 complete(&ar->scan.started);
1884 break;
1885 }
1886}
1887
Ben Greear2f9eec02015-02-15 16:50:38 +02001888static void ath10k_wmi_event_scan_start_failed(struct ath10k *ar)
1889{
1890 lockdep_assert_held(&ar->data_lock);
1891
1892 switch (ar->scan.state) {
1893 case ATH10K_SCAN_IDLE:
1894 case ATH10K_SCAN_RUNNING:
1895 case ATH10K_SCAN_ABORTING:
1896 ath10k_warn(ar, "received scan start failed event in an invalid scan state: %s (%d)\n",
1897 ath10k_scan_state_str(ar->scan.state),
1898 ar->scan.state);
1899 break;
1900 case ATH10K_SCAN_STARTING:
1901 complete(&ar->scan.started);
1902 __ath10k_scan_finish(ar);
1903 break;
1904 }
1905}
1906
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001907static void ath10k_wmi_event_scan_completed(struct ath10k *ar)
1908{
1909 lockdep_assert_held(&ar->data_lock);
1910
1911 switch (ar->scan.state) {
1912 case ATH10K_SCAN_IDLE:
1913 case ATH10K_SCAN_STARTING:
1914 /* One suspected reason scan can be completed while starting is
1915 * if firmware fails to deliver all scan events to the host,
1916 * e.g. when transport pipe is full. This has been observed
1917 * with spectral scan phyerr events starving wmi transport
1918 * pipe. In such case the "scan completed" event should be (and
1919 * is) ignored by the host as it may be just firmware's scan
1920 * state machine recovering.
1921 */
Michal Kazior7aa7a722014-08-25 12:09:38 +02001922 ath10k_warn(ar, "received scan completed event in an invalid scan state: %s (%d)\n",
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001923 ath10k_scan_state_str(ar->scan.state),
1924 ar->scan.state);
1925 break;
1926 case ATH10K_SCAN_RUNNING:
1927 case ATH10K_SCAN_ABORTING:
1928 __ath10k_scan_finish(ar);
1929 break;
1930 }
1931}
1932
1933static void ath10k_wmi_event_scan_bss_chan(struct ath10k *ar)
1934{
1935 lockdep_assert_held(&ar->data_lock);
1936
1937 switch (ar->scan.state) {
1938 case ATH10K_SCAN_IDLE:
1939 case ATH10K_SCAN_STARTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02001940 ath10k_warn(ar, "received scan bss chan event in an invalid scan state: %s (%d)\n",
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001941 ath10k_scan_state_str(ar->scan.state),
1942 ar->scan.state);
1943 break;
1944 case ATH10K_SCAN_RUNNING:
1945 case ATH10K_SCAN_ABORTING:
1946 ar->scan_channel = NULL;
1947 break;
1948 }
1949}
1950
1951static void ath10k_wmi_event_scan_foreign_chan(struct ath10k *ar, u32 freq)
1952{
1953 lockdep_assert_held(&ar->data_lock);
1954
1955 switch (ar->scan.state) {
1956 case ATH10K_SCAN_IDLE:
1957 case ATH10K_SCAN_STARTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02001958 ath10k_warn(ar, "received scan foreign chan event in an invalid scan state: %s (%d)\n",
Michal Kazior5c81c7f2014-08-05 14:54:44 +02001959 ath10k_scan_state_str(ar->scan.state),
1960 ar->scan.state);
1961 break;
1962 case ATH10K_SCAN_RUNNING:
1963 case ATH10K_SCAN_ABORTING:
1964 ar->scan_channel = ieee80211_get_channel(ar->hw->wiphy, freq);
1965
1966 if (ar->scan.is_roc && ar->scan.roc_freq == freq)
1967 complete(&ar->scan.on_channel);
1968 break;
1969 }
1970}
1971
Michal Kazior9ff8b722014-08-05 14:54:43 +02001972static const char *
1973ath10k_wmi_event_scan_type_str(enum wmi_scan_event_type type,
1974 enum wmi_scan_completion_reason reason)
1975{
1976 switch (type) {
1977 case WMI_SCAN_EVENT_STARTED:
1978 return "started";
1979 case WMI_SCAN_EVENT_COMPLETED:
1980 switch (reason) {
1981 case WMI_SCAN_REASON_COMPLETED:
1982 return "completed";
1983 case WMI_SCAN_REASON_CANCELLED:
1984 return "completed [cancelled]";
1985 case WMI_SCAN_REASON_PREEMPTED:
1986 return "completed [preempted]";
1987 case WMI_SCAN_REASON_TIMEDOUT:
1988 return "completed [timedout]";
Raja Manib2297ba2015-06-22 20:22:23 +05301989 case WMI_SCAN_REASON_INTERNAL_FAILURE:
1990 return "completed [internal err]";
Michal Kazior9ff8b722014-08-05 14:54:43 +02001991 case WMI_SCAN_REASON_MAX:
1992 break;
1993 }
1994 return "completed [unknown]";
1995 case WMI_SCAN_EVENT_BSS_CHANNEL:
1996 return "bss channel";
1997 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
1998 return "foreign channel";
1999 case WMI_SCAN_EVENT_DEQUEUED:
2000 return "dequeued";
2001 case WMI_SCAN_EVENT_PREEMPTED:
2002 return "preempted";
2003 case WMI_SCAN_EVENT_START_FAILED:
2004 return "start failed";
Raja Manib2297ba2015-06-22 20:22:23 +05302005 case WMI_SCAN_EVENT_RESTARTED:
2006 return "restarted";
2007 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
2008 return "foreign channel exit";
Michal Kazior9ff8b722014-08-05 14:54:43 +02002009 default:
2010 return "unknown";
2011 }
2012}
2013
Michal Kaziord7579d12014-12-03 10:10:54 +02002014static int ath10k_wmi_op_pull_scan_ev(struct ath10k *ar, struct sk_buff *skb,
2015 struct wmi_scan_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02002016{
2017 struct wmi_scan_event *ev = (void *)skb->data;
2018
2019 if (skb->len < sizeof(*ev))
2020 return -EPROTO;
2021
2022 skb_pull(skb, sizeof(*ev));
2023 arg->event_type = ev->event_type;
2024 arg->reason = ev->reason;
2025 arg->channel_freq = ev->channel_freq;
2026 arg->scan_req_id = ev->scan_req_id;
2027 arg->scan_id = ev->scan_id;
2028 arg->vdev_id = ev->vdev_id;
2029
2030 return 0;
2031}
2032
Michal Kazior0226d602014-12-03 10:11:22 +02002033int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002034{
Michal Kazior32653cf2014-12-03 10:10:26 +02002035 struct wmi_scan_ev_arg arg = {};
Kalle Valo5e3dd152013-06-12 20:52:10 +03002036 enum wmi_scan_event_type event_type;
2037 enum wmi_scan_completion_reason reason;
2038 u32 freq;
2039 u32 req_id;
2040 u32 scan_id;
2041 u32 vdev_id;
Michal Kazior32653cf2014-12-03 10:10:26 +02002042 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002043
Michal Kaziord7579d12014-12-03 10:10:54 +02002044 ret = ath10k_wmi_pull_scan(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02002045 if (ret) {
2046 ath10k_warn(ar, "failed to parse scan event: %d\n", ret);
2047 return ret;
2048 }
2049
2050 event_type = __le32_to_cpu(arg.event_type);
2051 reason = __le32_to_cpu(arg.reason);
2052 freq = __le32_to_cpu(arg.channel_freq);
2053 req_id = __le32_to_cpu(arg.scan_req_id);
2054 scan_id = __le32_to_cpu(arg.scan_id);
2055 vdev_id = __le32_to_cpu(arg.vdev_id);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002056
Kalle Valo5e3dd152013-06-12 20:52:10 +03002057 spin_lock_bh(&ar->data_lock);
2058
Michal Kazior7aa7a722014-08-25 12:09:38 +02002059 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002060 "scan event %s type %d reason %d freq %d req_id %d scan_id %d vdev_id %d state %s (%d)\n",
2061 ath10k_wmi_event_scan_type_str(event_type, reason),
2062 event_type, reason, freq, req_id, scan_id, vdev_id,
2063 ath10k_scan_state_str(ar->scan.state), ar->scan.state);
2064
Kalle Valo5e3dd152013-06-12 20:52:10 +03002065 switch (event_type) {
2066 case WMI_SCAN_EVENT_STARTED:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002067 ath10k_wmi_event_scan_started(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002068 break;
2069 case WMI_SCAN_EVENT_COMPLETED:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002070 ath10k_wmi_event_scan_completed(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002071 break;
2072 case WMI_SCAN_EVENT_BSS_CHANNEL:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002073 ath10k_wmi_event_scan_bss_chan(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002074 break;
2075 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002076 ath10k_wmi_event_scan_foreign_chan(ar, freq);
2077 break;
2078 case WMI_SCAN_EVENT_START_FAILED:
Michal Kazior7aa7a722014-08-25 12:09:38 +02002079 ath10k_warn(ar, "received scan start failure event\n");
Ben Greear2f9eec02015-02-15 16:50:38 +02002080 ath10k_wmi_event_scan_start_failed(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002081 break;
2082 case WMI_SCAN_EVENT_DEQUEUED:
Kalle Valo5e3dd152013-06-12 20:52:10 +03002083 case WMI_SCAN_EVENT_PREEMPTED:
Raja Manib2297ba2015-06-22 20:22:23 +05302084 case WMI_SCAN_EVENT_RESTARTED:
2085 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Kalle Valo5e3dd152013-06-12 20:52:10 +03002086 default:
2087 break;
2088 }
2089
2090 spin_unlock_bh(&ar->data_lock);
2091 return 0;
2092}
2093
2094static inline enum ieee80211_band phy_mode_to_band(u32 phy_mode)
2095{
2096 enum ieee80211_band band;
2097
2098 switch (phy_mode) {
2099 case MODE_11A:
2100 case MODE_11NA_HT20:
2101 case MODE_11NA_HT40:
2102 case MODE_11AC_VHT20:
2103 case MODE_11AC_VHT40:
2104 case MODE_11AC_VHT80:
2105 band = IEEE80211_BAND_5GHZ;
2106 break;
2107 case MODE_11G:
2108 case MODE_11B:
2109 case MODE_11GONLY:
2110 case MODE_11NG_HT20:
2111 case MODE_11NG_HT40:
2112 case MODE_11AC_VHT20_2G:
2113 case MODE_11AC_VHT40_2G:
2114 case MODE_11AC_VHT80_2G:
2115 default:
2116 band = IEEE80211_BAND_2GHZ;
2117 }
2118
2119 return band;
2120}
2121
Sujith Manoharan504f6cd2014-11-25 11:46:58 +05302122/* If keys are configured, HW decrypts all frames
2123 * with protected bit set. Mark such frames as decrypted.
2124 */
2125static void ath10k_wmi_handle_wep_reauth(struct ath10k *ar,
2126 struct sk_buff *skb,
2127 struct ieee80211_rx_status *status)
2128{
2129 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2130 unsigned int hdrlen;
2131 bool peer_key;
2132 u8 *addr, keyidx;
2133
2134 if (!ieee80211_is_auth(hdr->frame_control) ||
2135 !ieee80211_has_protected(hdr->frame_control))
2136 return;
2137
2138 hdrlen = ieee80211_hdrlen(hdr->frame_control);
2139 if (skb->len < (hdrlen + IEEE80211_WEP_IV_LEN))
2140 return;
2141
2142 keyidx = skb->data[hdrlen + (IEEE80211_WEP_IV_LEN - 1)] >> WEP_KEYID_SHIFT;
2143 addr = ieee80211_get_SA(hdr);
2144
2145 spin_lock_bh(&ar->data_lock);
2146 peer_key = ath10k_mac_is_peer_wep_key_set(ar, addr, keyidx);
2147 spin_unlock_bh(&ar->data_lock);
2148
2149 if (peer_key) {
2150 ath10k_dbg(ar, ATH10K_DBG_MAC,
2151 "mac wep key present for peer %pM\n", addr);
2152 status->flag |= RX_FLAG_DECRYPTED;
2153 }
2154}
2155
Michal Kaziord7579d12014-12-03 10:10:54 +02002156static int ath10k_wmi_op_pull_mgmt_rx_ev(struct ath10k *ar, struct sk_buff *skb,
2157 struct wmi_mgmt_rx_ev_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002158{
Michal Kazior0d9b0432013-08-09 10:13:33 +02002159 struct wmi_mgmt_rx_event_v1 *ev_v1;
2160 struct wmi_mgmt_rx_event_v2 *ev_v2;
2161 struct wmi_mgmt_rx_hdr_v1 *ev_hdr;
Michal Kazior32653cf2014-12-03 10:10:26 +02002162 size_t pull_len;
2163 u32 msdu_len;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002164
Michal Kazior0d9b0432013-08-09 10:13:33 +02002165 if (test_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features)) {
2166 ev_v2 = (struct wmi_mgmt_rx_event_v2 *)skb->data;
2167 ev_hdr = &ev_v2->hdr.v1;
2168 pull_len = sizeof(*ev_v2);
2169 } else {
2170 ev_v1 = (struct wmi_mgmt_rx_event_v1 *)skb->data;
2171 ev_hdr = &ev_v1->hdr;
2172 pull_len = sizeof(*ev_v1);
2173 }
2174
Michal Kazior32653cf2014-12-03 10:10:26 +02002175 if (skb->len < pull_len)
2176 return -EPROTO;
2177
2178 skb_pull(skb, pull_len);
2179 arg->channel = ev_hdr->channel;
2180 arg->buf_len = ev_hdr->buf_len;
2181 arg->status = ev_hdr->status;
2182 arg->snr = ev_hdr->snr;
2183 arg->phy_mode = ev_hdr->phy_mode;
2184 arg->rate = ev_hdr->rate;
2185
2186 msdu_len = __le32_to_cpu(arg->buf_len);
2187 if (skb->len < msdu_len)
2188 return -EPROTO;
2189
2190 /* the WMI buffer might've ended up being padded to 4 bytes due to HTC
2191 * trailer with credit update. Trim the excess garbage.
2192 */
2193 skb_trim(skb, msdu_len);
2194
2195 return 0;
2196}
2197
Raja Mani1c092962015-06-22 20:10:16 +05302198static int ath10k_wmi_10_4_op_pull_mgmt_rx_ev(struct ath10k *ar,
2199 struct sk_buff *skb,
2200 struct wmi_mgmt_rx_ev_arg *arg)
2201{
2202 struct wmi_10_4_mgmt_rx_event *ev;
2203 struct wmi_10_4_mgmt_rx_hdr *ev_hdr;
2204 size_t pull_len;
2205 u32 msdu_len;
2206
2207 ev = (struct wmi_10_4_mgmt_rx_event *)skb->data;
2208 ev_hdr = &ev->hdr;
2209 pull_len = sizeof(*ev);
2210
2211 if (skb->len < pull_len)
2212 return -EPROTO;
2213
2214 skb_pull(skb, pull_len);
2215 arg->channel = ev_hdr->channel;
2216 arg->buf_len = ev_hdr->buf_len;
2217 arg->status = ev_hdr->status;
2218 arg->snr = ev_hdr->snr;
2219 arg->phy_mode = ev_hdr->phy_mode;
2220 arg->rate = ev_hdr->rate;
2221
2222 msdu_len = __le32_to_cpu(arg->buf_len);
2223 if (skb->len < msdu_len)
2224 return -EPROTO;
2225
2226 /* Make sure bytes added for padding are removed. */
2227 skb_trim(skb, msdu_len);
2228
2229 return 0;
2230}
2231
Michal Kazior0226d602014-12-03 10:11:22 +02002232int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
Michal Kazior32653cf2014-12-03 10:10:26 +02002233{
2234 struct wmi_mgmt_rx_ev_arg arg = {};
2235 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
2236 struct ieee80211_hdr *hdr;
Michal Kazior01cebe12015-03-30 09:51:56 +03002237 struct ieee80211_supported_band *sband;
Michal Kazior32653cf2014-12-03 10:10:26 +02002238 u32 rx_status;
2239 u32 channel;
2240 u32 phy_mode;
2241 u32 snr;
2242 u32 rate;
2243 u32 buf_len;
2244 u16 fc;
2245 int ret;
2246
Michal Kaziord7579d12014-12-03 10:10:54 +02002247 ret = ath10k_wmi_pull_mgmt_rx(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02002248 if (ret) {
2249 ath10k_warn(ar, "failed to parse mgmt rx event: %d\n", ret);
Raja Mani08603f22015-06-01 14:53:33 +05302250 dev_kfree_skb(skb);
Michal Kazior32653cf2014-12-03 10:10:26 +02002251 return ret;
2252 }
2253
2254 channel = __le32_to_cpu(arg.channel);
2255 buf_len = __le32_to_cpu(arg.buf_len);
2256 rx_status = __le32_to_cpu(arg.status);
2257 snr = __le32_to_cpu(arg.snr);
2258 phy_mode = __le32_to_cpu(arg.phy_mode);
2259 rate = __le32_to_cpu(arg.rate);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002260
2261 memset(status, 0, sizeof(*status));
2262
Michal Kazior7aa7a722014-08-25 12:09:38 +02002263 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo5e3dd152013-06-12 20:52:10 +03002264 "event mgmt rx status %08x\n", rx_status);
2265
Manikanta Pubbisetty2c9bcec2015-10-20 12:11:40 +05302266 if ((test_bit(ATH10K_CAC_RUNNING, &ar->dev_flags)) ||
2267 (rx_status & (WMI_RX_STATUS_ERR_DECRYPT |
2268 WMI_RX_STATUS_ERR_KEY_CACHE_MISS | WMI_RX_STATUS_ERR_CRC))) {
Michal Kaziord67d0a02014-11-24 15:34:08 +01002269 dev_kfree_skb(skb);
2270 return 0;
2271 }
2272
Kalle Valo5e3dd152013-06-12 20:52:10 +03002273 if (rx_status & WMI_RX_STATUS_ERR_MIC)
2274 status->flag |= RX_FLAG_MMIC_ERROR;
2275
Michal Kazior21040bf2014-10-21 10:10:30 +03002276 /* Hardware can Rx CCK rates on 5GHz. In that case phy_mode is set to
Michal Kazior453cdb62013-12-13 10:44:43 +01002277 * MODE_11B. This means phy_mode is not a reliable source for the band
Michal Kazior21040bf2014-10-21 10:10:30 +03002278 * of mgmt rx.
2279 */
2280 if (channel >= 1 && channel <= 14) {
2281 status->band = IEEE80211_BAND_2GHZ;
2282 } else if (channel >= 36 && channel <= 165) {
2283 status->band = IEEE80211_BAND_5GHZ;
Michal Kazior453cdb62013-12-13 10:44:43 +01002284 } else {
Michal Kazior21040bf2014-10-21 10:10:30 +03002285 /* Shouldn't happen unless list of advertised channels to
2286 * mac80211 has been changed.
2287 */
2288 WARN_ON_ONCE(1);
2289 dev_kfree_skb(skb);
2290 return 0;
Michal Kazior453cdb62013-12-13 10:44:43 +01002291 }
2292
Michal Kazior21040bf2014-10-21 10:10:30 +03002293 if (phy_mode == MODE_11B && status->band == IEEE80211_BAND_5GHZ)
2294 ath10k_dbg(ar, ATH10K_DBG_MGMT, "wmi mgmt rx 11b (CCK) on 5GHz\n");
2295
Michal Kazior01cebe12015-03-30 09:51:56 +03002296 sband = &ar->mac.sbands[status->band];
2297
Kalle Valo5e3dd152013-06-12 20:52:10 +03002298 status->freq = ieee80211_channel_to_frequency(channel, status->band);
2299 status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR;
Michal Kazior01cebe12015-03-30 09:51:56 +03002300 status->rate_idx = ath10k_mac_bitrate_to_idx(sband, rate / 100);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002301
Kalle Valo5e3dd152013-06-12 20:52:10 +03002302 hdr = (struct ieee80211_hdr *)skb->data;
2303 fc = le16_to_cpu(hdr->frame_control);
2304
Sujith Manoharan504f6cd2014-11-25 11:46:58 +05302305 ath10k_wmi_handle_wep_reauth(ar, skb, status);
2306
Michal Kazior2b6a6a92013-12-05 06:53:41 +01002307 /* FW delivers WEP Shared Auth frame with Protected Bit set and
2308 * encrypted payload. However in case of PMF it delivers decrypted
2309 * frames with Protected Bit set. */
2310 if (ieee80211_has_protected(hdr->frame_control) &&
2311 !ieee80211_is_auth(hdr->frame_control)) {
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03002312 status->flag |= RX_FLAG_DECRYPTED;
2313
2314 if (!ieee80211_is_action(hdr->frame_control) &&
2315 !ieee80211_is_deauth(hdr->frame_control) &&
2316 !ieee80211_is_disassoc(hdr->frame_control)) {
2317 status->flag |= RX_FLAG_IV_STRIPPED |
2318 RX_FLAG_MMIC_STRIPPED;
2319 hdr->frame_control = __cpu_to_le16(fc &
Kalle Valo5e3dd152013-06-12 20:52:10 +03002320 ~IEEE80211_FCTL_PROTECTED);
Marek Kwaczynskieeab2662014-05-14 16:56:17 +03002321 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03002322 }
2323
Michal Kaziorcc9904e2015-03-10 16:22:01 +02002324 if (ieee80211_is_beacon(hdr->frame_control))
2325 ath10k_mac_handle_beacon(ar, skb);
2326
Michal Kazior7aa7a722014-08-25 12:09:38 +02002327 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo5e3dd152013-06-12 20:52:10 +03002328 "event mgmt rx skb %p len %d ftype %02x stype %02x\n",
2329 skb, skb->len,
2330 fc & IEEE80211_FCTL_FTYPE, fc & IEEE80211_FCTL_STYPE);
2331
Michal Kazior7aa7a722014-08-25 12:09:38 +02002332 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo5e3dd152013-06-12 20:52:10 +03002333 "event mgmt rx freq %d band %d snr %d, rate_idx %d\n",
2334 status->freq, status->band, status->signal,
2335 status->rate_idx);
2336
Kalle Valo5e3dd152013-06-12 20:52:10 +03002337 ieee80211_rx(ar->hw, skb);
2338 return 0;
2339}
2340
Michal Kazior2e1dea42013-07-31 10:32:40 +02002341static int freq_to_idx(struct ath10k *ar, int freq)
2342{
2343 struct ieee80211_supported_band *sband;
2344 int band, ch, idx = 0;
2345
2346 for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) {
2347 sband = ar->hw->wiphy->bands[band];
2348 if (!sband)
2349 continue;
2350
2351 for (ch = 0; ch < sband->n_channels; ch++, idx++)
2352 if (sband->channels[ch].center_freq == freq)
2353 goto exit;
2354 }
2355
2356exit:
2357 return idx;
2358}
2359
Michal Kaziord7579d12014-12-03 10:10:54 +02002360static int ath10k_wmi_op_pull_ch_info_ev(struct ath10k *ar, struct sk_buff *skb,
2361 struct wmi_ch_info_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02002362{
2363 struct wmi_chan_info_event *ev = (void *)skb->data;
2364
2365 if (skb->len < sizeof(*ev))
2366 return -EPROTO;
2367
2368 skb_pull(skb, sizeof(*ev));
2369 arg->err_code = ev->err_code;
2370 arg->freq = ev->freq;
2371 arg->cmd_flags = ev->cmd_flags;
2372 arg->noise_floor = ev->noise_floor;
2373 arg->rx_clear_count = ev->rx_clear_count;
2374 arg->cycle_count = ev->cycle_count;
2375
2376 return 0;
2377}
2378
Raja Manib2297ba2015-06-22 20:22:23 +05302379static int ath10k_wmi_10_4_op_pull_ch_info_ev(struct ath10k *ar,
2380 struct sk_buff *skb,
2381 struct wmi_ch_info_ev_arg *arg)
2382{
2383 struct wmi_10_4_chan_info_event *ev = (void *)skb->data;
2384
2385 if (skb->len < sizeof(*ev))
2386 return -EPROTO;
2387
2388 skb_pull(skb, sizeof(*ev));
2389 arg->err_code = ev->err_code;
2390 arg->freq = ev->freq;
2391 arg->cmd_flags = ev->cmd_flags;
2392 arg->noise_floor = ev->noise_floor;
2393 arg->rx_clear_count = ev->rx_clear_count;
2394 arg->cycle_count = ev->cycle_count;
2395 arg->chan_tx_pwr_range = ev->chan_tx_pwr_range;
2396 arg->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
2397 arg->rx_frame_count = ev->rx_frame_count;
2398
2399 return 0;
2400}
2401
Michal Kazior0226d602014-12-03 10:11:22 +02002402void ath10k_wmi_event_chan_info(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002403{
Michal Kazior32653cf2014-12-03 10:10:26 +02002404 struct wmi_ch_info_ev_arg arg = {};
Michal Kazior2e1dea42013-07-31 10:32:40 +02002405 struct survey_info *survey;
2406 u32 err_code, freq, cmd_flags, noise_floor, rx_clear_count, cycle_count;
Michal Kazior32653cf2014-12-03 10:10:26 +02002407 int idx, ret;
Michal Kazior2e1dea42013-07-31 10:32:40 +02002408
Michal Kaziord7579d12014-12-03 10:10:54 +02002409 ret = ath10k_wmi_pull_ch_info(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02002410 if (ret) {
2411 ath10k_warn(ar, "failed to parse chan info event: %d\n", ret);
2412 return;
2413 }
Michal Kazior2e1dea42013-07-31 10:32:40 +02002414
Michal Kazior32653cf2014-12-03 10:10:26 +02002415 err_code = __le32_to_cpu(arg.err_code);
2416 freq = __le32_to_cpu(arg.freq);
2417 cmd_flags = __le32_to_cpu(arg.cmd_flags);
2418 noise_floor = __le32_to_cpu(arg.noise_floor);
2419 rx_clear_count = __le32_to_cpu(arg.rx_clear_count);
2420 cycle_count = __le32_to_cpu(arg.cycle_count);
Michal Kazior2e1dea42013-07-31 10:32:40 +02002421
Michal Kazior7aa7a722014-08-25 12:09:38 +02002422 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior2e1dea42013-07-31 10:32:40 +02002423 "chan info err_code %d freq %d cmd_flags %d noise_floor %d rx_clear_count %d cycle_count %d\n",
2424 err_code, freq, cmd_flags, noise_floor, rx_clear_count,
2425 cycle_count);
2426
2427 spin_lock_bh(&ar->data_lock);
2428
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002429 switch (ar->scan.state) {
2430 case ATH10K_SCAN_IDLE:
2431 case ATH10K_SCAN_STARTING:
Michal Kazior7aa7a722014-08-25 12:09:38 +02002432 ath10k_warn(ar, "received chan info event without a scan request, ignoring\n");
Michal Kazior2e1dea42013-07-31 10:32:40 +02002433 goto exit;
Michal Kazior5c81c7f2014-08-05 14:54:44 +02002434 case ATH10K_SCAN_RUNNING:
2435 case ATH10K_SCAN_ABORTING:
2436 break;
Michal Kazior2e1dea42013-07-31 10:32:40 +02002437 }
2438
2439 idx = freq_to_idx(ar, freq);
2440 if (idx >= ARRAY_SIZE(ar->survey)) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02002441 ath10k_warn(ar, "chan info: invalid frequency %d (idx %d out of bounds)\n",
Michal Kazior2e1dea42013-07-31 10:32:40 +02002442 freq, idx);
2443 goto exit;
2444 }
2445
2446 if (cmd_flags & WMI_CHAN_INFO_FLAG_COMPLETE) {
Michal Kazior44b7d482015-05-25 14:06:19 +02002447 if (ar->ch_info_can_report_survey) {
2448 survey = &ar->survey[idx];
2449 survey->noise = noise_floor;
2450 survey->filled = SURVEY_INFO_NOISE_DBM;
Michal Kazior2e1dea42013-07-31 10:32:40 +02002451
Michal Kazior44b7d482015-05-25 14:06:19 +02002452 ath10k_hw_fill_survey_time(ar,
2453 survey,
2454 cycle_count,
2455 rx_clear_count,
2456 ar->survey_last_cycle_count,
2457 ar->survey_last_rx_clear_count);
2458 }
Michal Kazior587f7032015-05-25 14:06:18 +02002459
Michal Kazior44b7d482015-05-25 14:06:19 +02002460 ar->ch_info_can_report_survey = false;
2461 } else {
2462 ar->ch_info_can_report_survey = true;
Michal Kazior2e1dea42013-07-31 10:32:40 +02002463 }
2464
Vasanthakumar Thiagarajan3d2a2e22015-08-12 16:24:04 +05302465 if (!(cmd_flags & WMI_CHAN_INFO_FLAG_PRE_COMPLETE)) {
2466 ar->survey_last_rx_clear_count = rx_clear_count;
2467 ar->survey_last_cycle_count = cycle_count;
2468 }
Michal Kazior2e1dea42013-07-31 10:32:40 +02002469
2470exit:
2471 spin_unlock_bh(&ar->data_lock);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002472}
2473
Michal Kazior0226d602014-12-03 10:11:22 +02002474void ath10k_wmi_event_echo(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002475{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002476 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_ECHO_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002477}
2478
Michal Kazior0226d602014-12-03 10:11:22 +02002479int ath10k_wmi_event_debug_mesg(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002480{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002481 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event debug mesg len %d\n",
Kalle Valo869526b2014-01-03 12:59:26 +02002482 skb->len);
2483
Michal Kaziord35a6c12014-09-02 11:00:21 +03002484 trace_ath10k_wmi_dbglog(ar, skb->data, skb->len);
Kalle Valo869526b2014-01-03 12:59:26 +02002485
2486 return 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002487}
2488
Michal Kaziorb91251f2015-01-24 12:14:49 +02002489void ath10k_wmi_pull_pdev_stats_base(const struct wmi_pdev_stats_base *src,
2490 struct ath10k_fw_stats_pdev *dst)
Michal Kaziord15fb522014-09-25 12:33:47 +02002491{
Michal Kaziord15fb522014-09-25 12:33:47 +02002492 dst->ch_noise_floor = __le32_to_cpu(src->chan_nf);
2493 dst->tx_frame_count = __le32_to_cpu(src->tx_frame_count);
2494 dst->rx_frame_count = __le32_to_cpu(src->rx_frame_count);
2495 dst->rx_clear_count = __le32_to_cpu(src->rx_clear_count);
2496 dst->cycle_count = __le32_to_cpu(src->cycle_count);
2497 dst->phy_err_count = __le32_to_cpu(src->phy_err_count);
2498 dst->chan_tx_power = __le32_to_cpu(src->chan_tx_pwr);
Michal Kaziorb91251f2015-01-24 12:14:49 +02002499}
Michal Kaziord15fb522014-09-25 12:33:47 +02002500
Michal Kaziorb91251f2015-01-24 12:14:49 +02002501void ath10k_wmi_pull_pdev_stats_tx(const struct wmi_pdev_stats_tx *src,
2502 struct ath10k_fw_stats_pdev *dst)
2503{
2504 dst->comp_queued = __le32_to_cpu(src->comp_queued);
2505 dst->comp_delivered = __le32_to_cpu(src->comp_delivered);
2506 dst->msdu_enqued = __le32_to_cpu(src->msdu_enqued);
2507 dst->mpdu_enqued = __le32_to_cpu(src->mpdu_enqued);
2508 dst->wmm_drop = __le32_to_cpu(src->wmm_drop);
2509 dst->local_enqued = __le32_to_cpu(src->local_enqued);
2510 dst->local_freed = __le32_to_cpu(src->local_freed);
2511 dst->hw_queued = __le32_to_cpu(src->hw_queued);
2512 dst->hw_reaped = __le32_to_cpu(src->hw_reaped);
2513 dst->underrun = __le32_to_cpu(src->underrun);
2514 dst->tx_abort = __le32_to_cpu(src->tx_abort);
2515 dst->mpdus_requed = __le32_to_cpu(src->mpdus_requed);
2516 dst->tx_ko = __le32_to_cpu(src->tx_ko);
2517 dst->data_rc = __le32_to_cpu(src->data_rc);
2518 dst->self_triggers = __le32_to_cpu(src->self_triggers);
2519 dst->sw_retry_failure = __le32_to_cpu(src->sw_retry_failure);
2520 dst->illgl_rate_phy_err = __le32_to_cpu(src->illgl_rate_phy_err);
2521 dst->pdev_cont_xretry = __le32_to_cpu(src->pdev_cont_xretry);
2522 dst->pdev_tx_timeout = __le32_to_cpu(src->pdev_tx_timeout);
2523 dst->pdev_resets = __le32_to_cpu(src->pdev_resets);
2524 dst->phy_underrun = __le32_to_cpu(src->phy_underrun);
2525 dst->txop_ovf = __le32_to_cpu(src->txop_ovf);
2526}
Michal Kaziord15fb522014-09-25 12:33:47 +02002527
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02002528static void
2529ath10k_wmi_10_4_pull_pdev_stats_tx(const struct wmi_10_4_pdev_stats_tx *src,
2530 struct ath10k_fw_stats_pdev *dst)
2531{
2532 dst->comp_queued = __le32_to_cpu(src->comp_queued);
2533 dst->comp_delivered = __le32_to_cpu(src->comp_delivered);
2534 dst->msdu_enqued = __le32_to_cpu(src->msdu_enqued);
2535 dst->mpdu_enqued = __le32_to_cpu(src->mpdu_enqued);
2536 dst->wmm_drop = __le32_to_cpu(src->wmm_drop);
2537 dst->local_enqued = __le32_to_cpu(src->local_enqued);
2538 dst->local_freed = __le32_to_cpu(src->local_freed);
2539 dst->hw_queued = __le32_to_cpu(src->hw_queued);
2540 dst->hw_reaped = __le32_to_cpu(src->hw_reaped);
2541 dst->underrun = __le32_to_cpu(src->underrun);
2542 dst->tx_abort = __le32_to_cpu(src->tx_abort);
2543 dst->mpdus_requed = __le32_to_cpu(src->mpdus_requed);
2544 dst->tx_ko = __le32_to_cpu(src->tx_ko);
2545 dst->data_rc = __le32_to_cpu(src->data_rc);
2546 dst->self_triggers = __le32_to_cpu(src->self_triggers);
2547 dst->sw_retry_failure = __le32_to_cpu(src->sw_retry_failure);
2548 dst->illgl_rate_phy_err = __le32_to_cpu(src->illgl_rate_phy_err);
2549 dst->pdev_cont_xretry = __le32_to_cpu(src->pdev_cont_xretry);
2550 dst->pdev_tx_timeout = __le32_to_cpu(src->pdev_tx_timeout);
2551 dst->pdev_resets = __le32_to_cpu(src->pdev_resets);
2552 dst->phy_underrun = __le32_to_cpu(src->phy_underrun);
2553 dst->txop_ovf = __le32_to_cpu(src->txop_ovf);
2554 dst->hw_paused = __le32_to_cpu(src->hw_paused);
2555 dst->seq_posted = __le32_to_cpu(src->seq_posted);
2556 dst->seq_failed_queueing =
2557 __le32_to_cpu(src->seq_failed_queueing);
2558 dst->seq_completed = __le32_to_cpu(src->seq_completed);
2559 dst->seq_restarted = __le32_to_cpu(src->seq_restarted);
2560 dst->mu_seq_posted = __le32_to_cpu(src->mu_seq_posted);
2561 dst->mpdus_sw_flush = __le32_to_cpu(src->mpdus_sw_flush);
2562 dst->mpdus_hw_filter = __le32_to_cpu(src->mpdus_hw_filter);
2563 dst->mpdus_truncated = __le32_to_cpu(src->mpdus_truncated);
2564 dst->mpdus_ack_failed = __le32_to_cpu(src->mpdus_ack_failed);
2565 dst->mpdus_hw_filter = __le32_to_cpu(src->mpdus_hw_filter);
2566 dst->mpdus_expired = __le32_to_cpu(src->mpdus_expired);
2567}
2568
Michal Kaziorb91251f2015-01-24 12:14:49 +02002569void ath10k_wmi_pull_pdev_stats_rx(const struct wmi_pdev_stats_rx *src,
2570 struct ath10k_fw_stats_pdev *dst)
2571{
2572 dst->mid_ppdu_route_change = __le32_to_cpu(src->mid_ppdu_route_change);
2573 dst->status_rcvd = __le32_to_cpu(src->status_rcvd);
2574 dst->r0_frags = __le32_to_cpu(src->r0_frags);
2575 dst->r1_frags = __le32_to_cpu(src->r1_frags);
2576 dst->r2_frags = __le32_to_cpu(src->r2_frags);
2577 dst->r3_frags = __le32_to_cpu(src->r3_frags);
2578 dst->htt_msdus = __le32_to_cpu(src->htt_msdus);
2579 dst->htt_mpdus = __le32_to_cpu(src->htt_mpdus);
2580 dst->loc_msdus = __le32_to_cpu(src->loc_msdus);
2581 dst->loc_mpdus = __le32_to_cpu(src->loc_mpdus);
2582 dst->oversize_amsdu = __le32_to_cpu(src->oversize_amsdu);
2583 dst->phy_errs = __le32_to_cpu(src->phy_errs);
2584 dst->phy_err_drop = __le32_to_cpu(src->phy_err_drop);
2585 dst->mpdu_errs = __le32_to_cpu(src->mpdu_errs);
2586}
2587
2588void ath10k_wmi_pull_pdev_stats_extra(const struct wmi_pdev_stats_extra *src,
2589 struct ath10k_fw_stats_pdev *dst)
2590{
2591 dst->ack_rx_bad = __le32_to_cpu(src->ack_rx_bad);
2592 dst->rts_bad = __le32_to_cpu(src->rts_bad);
2593 dst->rts_good = __le32_to_cpu(src->rts_good);
2594 dst->fcs_bad = __le32_to_cpu(src->fcs_bad);
2595 dst->no_beacons = __le32_to_cpu(src->no_beacons);
2596 dst->mib_int_count = __le32_to_cpu(src->mib_int_count);
Michal Kaziord15fb522014-09-25 12:33:47 +02002597}
2598
Michal Kazior0226d602014-12-03 10:11:22 +02002599void ath10k_wmi_pull_peer_stats(const struct wmi_peer_stats *src,
2600 struct ath10k_fw_stats_peer *dst)
Michal Kaziord15fb522014-09-25 12:33:47 +02002601{
2602 ether_addr_copy(dst->peer_macaddr, src->peer_macaddr.addr);
2603 dst->peer_rssi = __le32_to_cpu(src->peer_rssi);
2604 dst->peer_tx_rate = __le32_to_cpu(src->peer_tx_rate);
2605}
2606
Michal Kaziord7579d12014-12-03 10:10:54 +02002607static int ath10k_wmi_main_op_pull_fw_stats(struct ath10k *ar,
2608 struct sk_buff *skb,
2609 struct ath10k_fw_stats *stats)
Michal Kaziord15fb522014-09-25 12:33:47 +02002610{
2611 const struct wmi_stats_event *ev = (void *)skb->data;
2612 u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
2613 int i;
2614
2615 if (!skb_pull(skb, sizeof(*ev)))
2616 return -EPROTO;
2617
2618 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2619 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2620 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2621
Michal Kazior53268492014-09-25 12:33:50 +02002622 for (i = 0; i < num_pdev_stats; i++) {
Michal Kaziord15fb522014-09-25 12:33:47 +02002623 const struct wmi_pdev_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02002624 struct ath10k_fw_stats_pdev *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02002625
2626 src = (void *)skb->data;
2627 if (!skb_pull(skb, sizeof(*src)))
2628 return -EPROTO;
2629
Michal Kazior53268492014-09-25 12:33:50 +02002630 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2631 if (!dst)
2632 continue;
2633
Michal Kaziorb91251f2015-01-24 12:14:49 +02002634 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2635 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2636 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2637
Michal Kazior53268492014-09-25 12:33:50 +02002638 list_add_tail(&dst->list, &stats->pdevs);
Michal Kaziord15fb522014-09-25 12:33:47 +02002639 }
2640
2641 /* fw doesn't implement vdev stats */
2642
2643 for (i = 0; i < num_peer_stats; i++) {
2644 const struct wmi_peer_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02002645 struct ath10k_fw_stats_peer *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02002646
2647 src = (void *)skb->data;
2648 if (!skb_pull(skb, sizeof(*src)))
2649 return -EPROTO;
2650
Michal Kazior53268492014-09-25 12:33:50 +02002651 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2652 if (!dst)
2653 continue;
2654
2655 ath10k_wmi_pull_peer_stats(src, dst);
2656 list_add_tail(&dst->list, &stats->peers);
Michal Kaziord15fb522014-09-25 12:33:47 +02002657 }
2658
2659 return 0;
2660}
2661
Michal Kaziord7579d12014-12-03 10:10:54 +02002662static int ath10k_wmi_10x_op_pull_fw_stats(struct ath10k *ar,
2663 struct sk_buff *skb,
2664 struct ath10k_fw_stats *stats)
Michal Kaziord15fb522014-09-25 12:33:47 +02002665{
2666 const struct wmi_stats_event *ev = (void *)skb->data;
2667 u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
2668 int i;
2669
2670 if (!skb_pull(skb, sizeof(*ev)))
2671 return -EPROTO;
2672
2673 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2674 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2675 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2676
Michal Kazior53268492014-09-25 12:33:50 +02002677 for (i = 0; i < num_pdev_stats; i++) {
Michal Kaziord15fb522014-09-25 12:33:47 +02002678 const struct wmi_10x_pdev_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02002679 struct ath10k_fw_stats_pdev *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02002680
2681 src = (void *)skb->data;
2682 if (!skb_pull(skb, sizeof(*src)))
2683 return -EPROTO;
2684
Michal Kazior53268492014-09-25 12:33:50 +02002685 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2686 if (!dst)
2687 continue;
Michal Kaziord15fb522014-09-25 12:33:47 +02002688
Michal Kaziorb91251f2015-01-24 12:14:49 +02002689 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2690 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2691 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2692 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
Michal Kazior53268492014-09-25 12:33:50 +02002693
2694 list_add_tail(&dst->list, &stats->pdevs);
Michal Kaziord15fb522014-09-25 12:33:47 +02002695 }
2696
2697 /* fw doesn't implement vdev stats */
2698
2699 for (i = 0; i < num_peer_stats; i++) {
2700 const struct wmi_10x_peer_stats *src;
Michal Kazior53268492014-09-25 12:33:50 +02002701 struct ath10k_fw_stats_peer *dst;
Michal Kaziord15fb522014-09-25 12:33:47 +02002702
2703 src = (void *)skb->data;
2704 if (!skb_pull(skb, sizeof(*src)))
2705 return -EPROTO;
2706
Michal Kazior53268492014-09-25 12:33:50 +02002707 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2708 if (!dst)
2709 continue;
Michal Kaziord15fb522014-09-25 12:33:47 +02002710
Michal Kazior53268492014-09-25 12:33:50 +02002711 ath10k_wmi_pull_peer_stats(&src->old, dst);
2712
2713 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
2714
2715 list_add_tail(&dst->list, &stats->peers);
Michal Kaziord15fb522014-09-25 12:33:47 +02002716 }
2717
2718 return 0;
2719}
2720
Michal Kazior20de2222015-01-24 12:14:49 +02002721static int ath10k_wmi_10_2_op_pull_fw_stats(struct ath10k *ar,
2722 struct sk_buff *skb,
2723 struct ath10k_fw_stats *stats)
2724{
2725 const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2726 u32 num_pdev_stats;
2727 u32 num_pdev_ext_stats;
2728 u32 num_vdev_stats;
2729 u32 num_peer_stats;
2730 int i;
2731
2732 if (!skb_pull(skb, sizeof(*ev)))
2733 return -EPROTO;
2734
2735 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2736 num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
2737 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2738 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2739
2740 for (i = 0; i < num_pdev_stats; i++) {
2741 const struct wmi_10_2_pdev_stats *src;
2742 struct ath10k_fw_stats_pdev *dst;
2743
2744 src = (void *)skb->data;
2745 if (!skb_pull(skb, sizeof(*src)))
2746 return -EPROTO;
2747
2748 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2749 if (!dst)
2750 continue;
2751
2752 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2753 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2754 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2755 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2756 /* FIXME: expose 10.2 specific values */
2757
2758 list_add_tail(&dst->list, &stats->pdevs);
2759 }
2760
2761 for (i = 0; i < num_pdev_ext_stats; i++) {
2762 const struct wmi_10_2_pdev_ext_stats *src;
2763
2764 src = (void *)skb->data;
2765 if (!skb_pull(skb, sizeof(*src)))
2766 return -EPROTO;
2767
2768 /* FIXME: expose values to userspace
2769 *
2770 * Note: Even though this loop seems to do nothing it is
2771 * required to parse following sub-structures properly.
2772 */
2773 }
2774
2775 /* fw doesn't implement vdev stats */
2776
2777 for (i = 0; i < num_peer_stats; i++) {
2778 const struct wmi_10_2_peer_stats *src;
2779 struct ath10k_fw_stats_peer *dst;
2780
2781 src = (void *)skb->data;
2782 if (!skb_pull(skb, sizeof(*src)))
2783 return -EPROTO;
2784
2785 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2786 if (!dst)
2787 continue;
2788
2789 ath10k_wmi_pull_peer_stats(&src->old, dst);
2790
2791 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
2792 /* FIXME: expose 10.2 specific values */
2793
2794 list_add_tail(&dst->list, &stats->peers);
2795 }
2796
2797 return 0;
2798}
2799
2800static int ath10k_wmi_10_2_4_op_pull_fw_stats(struct ath10k *ar,
2801 struct sk_buff *skb,
2802 struct ath10k_fw_stats *stats)
2803{
2804 const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2805 u32 num_pdev_stats;
2806 u32 num_pdev_ext_stats;
2807 u32 num_vdev_stats;
2808 u32 num_peer_stats;
2809 int i;
2810
2811 if (!skb_pull(skb, sizeof(*ev)))
2812 return -EPROTO;
2813
2814 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2815 num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
2816 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2817 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2818
2819 for (i = 0; i < num_pdev_stats; i++) {
2820 const struct wmi_10_2_pdev_stats *src;
2821 struct ath10k_fw_stats_pdev *dst;
2822
2823 src = (void *)skb->data;
2824 if (!skb_pull(skb, sizeof(*src)))
2825 return -EPROTO;
2826
2827 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2828 if (!dst)
2829 continue;
2830
2831 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2832 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2833 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2834 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2835 /* FIXME: expose 10.2 specific values */
2836
2837 list_add_tail(&dst->list, &stats->pdevs);
2838 }
2839
2840 for (i = 0; i < num_pdev_ext_stats; i++) {
2841 const struct wmi_10_2_pdev_ext_stats *src;
2842
2843 src = (void *)skb->data;
2844 if (!skb_pull(skb, sizeof(*src)))
2845 return -EPROTO;
2846
2847 /* FIXME: expose values to userspace
2848 *
2849 * Note: Even though this loop seems to do nothing it is
2850 * required to parse following sub-structures properly.
2851 */
2852 }
2853
2854 /* fw doesn't implement vdev stats */
2855
2856 for (i = 0; i < num_peer_stats; i++) {
2857 const struct wmi_10_2_4_peer_stats *src;
2858 struct ath10k_fw_stats_peer *dst;
2859
2860 src = (void *)skb->data;
2861 if (!skb_pull(skb, sizeof(*src)))
2862 return -EPROTO;
2863
2864 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2865 if (!dst)
2866 continue;
2867
2868 ath10k_wmi_pull_peer_stats(&src->common.old, dst);
2869
2870 dst->peer_rx_rate = __le32_to_cpu(src->common.peer_rx_rate);
2871 /* FIXME: expose 10.2 specific values */
2872
2873 list_add_tail(&dst->list, &stats->peers);
2874 }
2875
2876 return 0;
2877}
2878
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02002879static int ath10k_wmi_10_4_op_pull_fw_stats(struct ath10k *ar,
2880 struct sk_buff *skb,
2881 struct ath10k_fw_stats *stats)
2882{
2883 const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2884 u32 num_pdev_stats;
2885 u32 num_pdev_ext_stats;
2886 u32 num_vdev_stats;
2887 u32 num_peer_stats;
2888 int i;
2889
2890 if (!skb_pull(skb, sizeof(*ev)))
2891 return -EPROTO;
2892
2893 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2894 num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
2895 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2896 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2897
2898 for (i = 0; i < num_pdev_stats; i++) {
2899 const struct wmi_10_4_pdev_stats *src;
2900 struct ath10k_fw_stats_pdev *dst;
2901
2902 src = (void *)skb->data;
2903 if (!skb_pull(skb, sizeof(*src)))
2904 return -EPROTO;
2905
2906 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2907 if (!dst)
2908 continue;
2909
2910 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2911 ath10k_wmi_10_4_pull_pdev_stats_tx(&src->tx, dst);
2912 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2913 dst->rx_ovfl_errs = __le32_to_cpu(src->rx_ovfl_errs);
2914 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2915
2916 list_add_tail(&dst->list, &stats->pdevs);
2917 }
2918
2919 for (i = 0; i < num_pdev_ext_stats; i++) {
2920 const struct wmi_10_2_pdev_ext_stats *src;
2921
2922 src = (void *)skb->data;
2923 if (!skb_pull(skb, sizeof(*src)))
2924 return -EPROTO;
2925
2926 /* FIXME: expose values to userspace
2927 *
2928 * Note: Even though this loop seems to do nothing it is
2929 * required to parse following sub-structures properly.
2930 */
2931 }
2932
2933 /* fw doesn't implement vdev stats */
2934
2935 for (i = 0; i < num_peer_stats; i++) {
2936 const struct wmi_10_4_peer_stats *src;
2937 struct ath10k_fw_stats_peer *dst;
2938
2939 src = (void *)skb->data;
2940 if (!skb_pull(skb, sizeof(*src)))
2941 return -EPROTO;
2942
2943 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2944 if (!dst)
2945 continue;
2946
2947 ether_addr_copy(dst->peer_macaddr, src->peer_macaddr.addr);
2948 dst->peer_rssi = __le32_to_cpu(src->peer_rssi);
2949 dst->peer_tx_rate = __le32_to_cpu(src->peer_tx_rate);
2950 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
2951 /* FIXME: expose 10.4 specific values */
2952
2953 list_add_tail(&dst->list, &stats->peers);
2954 }
2955
2956 return 0;
2957}
2958
Michal Kazior0226d602014-12-03 10:11:22 +02002959void ath10k_wmi_event_update_stats(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002960{
Michal Kazior7aa7a722014-08-25 12:09:38 +02002961 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_UPDATE_STATS_EVENTID\n");
Michal Kazior60ef4012014-09-25 12:33:48 +02002962 ath10k_debug_fw_stats_process(ar, skb);
Kalle Valo5e3dd152013-06-12 20:52:10 +03002963}
2964
Michal Kaziord7579d12014-12-03 10:10:54 +02002965static int
2966ath10k_wmi_op_pull_vdev_start_ev(struct ath10k *ar, struct sk_buff *skb,
2967 struct wmi_vdev_start_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02002968{
2969 struct wmi_vdev_start_response_event *ev = (void *)skb->data;
2970
2971 if (skb->len < sizeof(*ev))
2972 return -EPROTO;
2973
2974 skb_pull(skb, sizeof(*ev));
2975 arg->vdev_id = ev->vdev_id;
2976 arg->req_id = ev->req_id;
2977 arg->resp_type = ev->resp_type;
2978 arg->status = ev->status;
2979
2980 return 0;
2981}
2982
Michal Kazior0226d602014-12-03 10:11:22 +02002983void ath10k_wmi_event_vdev_start_resp(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03002984{
Michal Kazior32653cf2014-12-03 10:10:26 +02002985 struct wmi_vdev_start_ev_arg arg = {};
2986 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03002987
Michal Kazior7aa7a722014-08-25 12:09:38 +02002988 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_START_RESP_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03002989
Michal Kaziord7579d12014-12-03 10:10:54 +02002990 ret = ath10k_wmi_pull_vdev_start(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02002991 if (ret) {
2992 ath10k_warn(ar, "failed to parse vdev start event: %d\n", ret);
2993 return;
2994 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03002995
Michal Kazior32653cf2014-12-03 10:10:26 +02002996 if (WARN_ON(__le32_to_cpu(arg.status)))
Kalle Valo5e3dd152013-06-12 20:52:10 +03002997 return;
2998
2999 complete(&ar->vdev_setup_done);
3000}
3001
Michal Kazior0226d602014-12-03 10:11:22 +02003002void ath10k_wmi_event_vdev_stopped(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003003{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003004 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STOPPED_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003005 complete(&ar->vdev_setup_done);
3006}
3007
Michal Kaziord7579d12014-12-03 10:10:54 +02003008static int
3009ath10k_wmi_op_pull_peer_kick_ev(struct ath10k *ar, struct sk_buff *skb,
3010 struct wmi_peer_kick_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02003011{
3012 struct wmi_peer_sta_kickout_event *ev = (void *)skb->data;
3013
3014 if (skb->len < sizeof(*ev))
3015 return -EPROTO;
3016
3017 skb_pull(skb, sizeof(*ev));
3018 arg->mac_addr = ev->peer_macaddr.addr;
3019
3020 return 0;
3021}
3022
Michal Kazior0226d602014-12-03 10:11:22 +02003023void ath10k_wmi_event_peer_sta_kickout(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003024{
Michal Kazior32653cf2014-12-03 10:10:26 +02003025 struct wmi_peer_kick_ev_arg arg = {};
Kalle Valo5a13e762014-01-20 11:01:46 +02003026 struct ieee80211_sta *sta;
Michal Kazior32653cf2014-12-03 10:10:26 +02003027 int ret;
Kalle Valo5a13e762014-01-20 11:01:46 +02003028
Michal Kaziord7579d12014-12-03 10:10:54 +02003029 ret = ath10k_wmi_pull_peer_kick(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02003030 if (ret) {
3031 ath10k_warn(ar, "failed to parse peer kickout event: %d\n",
3032 ret);
3033 return;
3034 }
Kalle Valo5a13e762014-01-20 11:01:46 +02003035
Michal Kazior7aa7a722014-08-25 12:09:38 +02003036 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event peer sta kickout %pM\n",
Michal Kazior32653cf2014-12-03 10:10:26 +02003037 arg.mac_addr);
Kalle Valo5a13e762014-01-20 11:01:46 +02003038
3039 rcu_read_lock();
3040
Michal Kazior32653cf2014-12-03 10:10:26 +02003041 sta = ieee80211_find_sta_by_ifaddr(ar->hw, arg.mac_addr, NULL);
Kalle Valo5a13e762014-01-20 11:01:46 +02003042 if (!sta) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003043 ath10k_warn(ar, "Spurious quick kickout for STA %pM\n",
Michal Kazior32653cf2014-12-03 10:10:26 +02003044 arg.mac_addr);
Kalle Valo5a13e762014-01-20 11:01:46 +02003045 goto exit;
3046 }
3047
3048 ieee80211_report_low_ack(sta, 10);
3049
3050exit:
3051 rcu_read_unlock();
Kalle Valo5e3dd152013-06-12 20:52:10 +03003052}
3053
3054/*
3055 * FIXME
3056 *
3057 * We don't report to mac80211 sleep state of connected
3058 * stations. Due to this mac80211 can't fill in TIM IE
3059 * correctly.
3060 *
3061 * I know of no way of getting nullfunc frames that contain
3062 * sleep transition from connected stations - these do not
3063 * seem to be sent from the target to the host. There also
3064 * doesn't seem to be a dedicated event for that. So the
3065 * only way left to do this would be to read tim_bitmap
3066 * during SWBA.
3067 *
3068 * We could probably try using tim_bitmap from SWBA to tell
3069 * mac80211 which stations are asleep and which are not. The
3070 * problem here is calling mac80211 functions so many times
3071 * could take too long and make us miss the time to submit
3072 * the beacon to the target.
3073 *
3074 * So as a workaround we try to extend the TIM IE if there
3075 * is unicast buffered for stations with aid > 7 and fill it
3076 * in ourselves.
3077 */
3078static void ath10k_wmi_update_tim(struct ath10k *ar,
3079 struct ath10k_vif *arvif,
3080 struct sk_buff *bcn,
Raja Mania03fee32015-06-22 20:22:20 +05303081 const struct wmi_tim_info_arg *tim_info)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003082{
3083 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)bcn->data;
3084 struct ieee80211_tim_ie *tim;
3085 u8 *ies, *ie;
3086 u8 ie_len, pvm_len;
Kalle Valoaf762c02014-09-14 12:50:17 +03003087 __le32 t;
Raja Mania03fee32015-06-22 20:22:20 +05303088 u32 v, tim_len;
3089
3090 /* When FW reports 0 in tim_len, ensure atleast first byte
3091 * in tim_bitmap is considered for pvm calculation.
3092 */
3093 tim_len = tim_info->tim_len ? __le32_to_cpu(tim_info->tim_len) : 1;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003094
3095 /* if next SWBA has no tim_changed the tim_bitmap is garbage.
3096 * we must copy the bitmap upon change and reuse it later */
Michal Kazior32653cf2014-12-03 10:10:26 +02003097 if (__le32_to_cpu(tim_info->tim_changed)) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03003098 int i;
3099
Raja Mania03fee32015-06-22 20:22:20 +05303100 if (sizeof(arvif->u.ap.tim_bitmap) < tim_len) {
3101 ath10k_warn(ar, "SWBA TIM field is too big (%u), truncated it to %zu",
3102 tim_len, sizeof(arvif->u.ap.tim_bitmap));
3103 tim_len = sizeof(arvif->u.ap.tim_bitmap);
3104 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03003105
Raja Mania03fee32015-06-22 20:22:20 +05303106 for (i = 0; i < tim_len; i++) {
Michal Kazior32653cf2014-12-03 10:10:26 +02003107 t = tim_info->tim_bitmap[i / 4];
Kalle Valoaf762c02014-09-14 12:50:17 +03003108 v = __le32_to_cpu(t);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003109 arvif->u.ap.tim_bitmap[i] = (v >> ((i % 4) * 8)) & 0xFF;
3110 }
3111
Raja Mania03fee32015-06-22 20:22:20 +05303112 /* FW reports either length 0 or length based on max supported
3113 * station. so we calculate this on our own
3114 */
Kalle Valo5e3dd152013-06-12 20:52:10 +03003115 arvif->u.ap.tim_len = 0;
Raja Mania03fee32015-06-22 20:22:20 +05303116 for (i = 0; i < tim_len; i++)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003117 if (arvif->u.ap.tim_bitmap[i])
3118 arvif->u.ap.tim_len = i;
3119
3120 arvif->u.ap.tim_len++;
3121 }
3122
3123 ies = bcn->data;
3124 ies += ieee80211_hdrlen(hdr->frame_control);
3125 ies += 12; /* fixed parameters */
3126
3127 ie = (u8 *)cfg80211_find_ie(WLAN_EID_TIM, ies,
3128 (u8 *)skb_tail_pointer(bcn) - ies);
3129 if (!ie) {
Michal Kazior09af8f82013-07-05 16:15:08 +03003130 if (arvif->vdev_type != WMI_VDEV_TYPE_IBSS)
Michal Kazior7aa7a722014-08-25 12:09:38 +02003131 ath10k_warn(ar, "no tim ie found;\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003132 return;
3133 }
3134
3135 tim = (void *)ie + 2;
3136 ie_len = ie[1];
3137 pvm_len = ie_len - 3; /* exclude dtim count, dtim period, bmap ctl */
3138
3139 if (pvm_len < arvif->u.ap.tim_len) {
Raja Mania03fee32015-06-22 20:22:20 +05303140 int expand_size = tim_len - pvm_len;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003141 int move_size = skb_tail_pointer(bcn) - (ie + 2 + ie_len);
3142 void *next_ie = ie + 2 + ie_len;
3143
3144 if (skb_put(bcn, expand_size)) {
3145 memmove(next_ie + expand_size, next_ie, move_size);
3146
3147 ie[1] += expand_size;
3148 ie_len += expand_size;
3149 pvm_len += expand_size;
3150 } else {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003151 ath10k_warn(ar, "tim expansion failed\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003152 }
3153 }
3154
Raja Mania03fee32015-06-22 20:22:20 +05303155 if (pvm_len > tim_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003156 ath10k_warn(ar, "tim pvm length is too great (%d)\n", pvm_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003157 return;
3158 }
3159
Michal Kazior32653cf2014-12-03 10:10:26 +02003160 tim->bitmap_ctrl = !!__le32_to_cpu(tim_info->tim_mcast);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003161 memcpy(tim->virtual_map, arvif->u.ap.tim_bitmap, pvm_len);
3162
Michal Kazior748afc42014-01-23 12:48:21 +01003163 if (tim->dtim_count == 0) {
Michal Kazior66b8a012015-11-18 06:59:20 +01003164 ATH10K_SKB_CB(bcn)->flags |= ATH10K_SKB_F_DTIM_ZERO;
Michal Kazior748afc42014-01-23 12:48:21 +01003165
Michal Kazior32653cf2014-12-03 10:10:26 +02003166 if (__le32_to_cpu(tim_info->tim_mcast) == 1)
Michal Kazior66b8a012015-11-18 06:59:20 +01003167 ATH10K_SKB_CB(bcn)->flags |= ATH10K_SKB_F_DELIVER_CAB;
Michal Kazior748afc42014-01-23 12:48:21 +01003168 }
3169
Michal Kazior7aa7a722014-08-25 12:09:38 +02003170 ath10k_dbg(ar, ATH10K_DBG_MGMT, "dtim %d/%d mcast %d pvmlen %d\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +03003171 tim->dtim_count, tim->dtim_period,
3172 tim->bitmap_ctrl, pvm_len);
3173}
3174
Kalle Valo5e3dd152013-06-12 20:52:10 +03003175static void ath10k_wmi_update_noa(struct ath10k *ar, struct ath10k_vif *arvif,
3176 struct sk_buff *bcn,
Michal Kazior32653cf2014-12-03 10:10:26 +02003177 const struct wmi_p2p_noa_info *noa)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003178{
Kalle Valo5e3dd152013-06-12 20:52:10 +03003179 if (arvif->vdev_subtype != WMI_VDEV_SUBTYPE_P2P_GO)
3180 return;
3181
Michal Kazior7aa7a722014-08-25 12:09:38 +02003182 ath10k_dbg(ar, ATH10K_DBG_MGMT, "noa changed: %d\n", noa->changed);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003183
Michal Kazior6a948882015-02-26 13:23:17 +01003184 if (noa->changed & WMI_P2P_NOA_CHANGED_BIT)
3185 ath10k_p2p_noa_update(arvif, noa);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003186
3187 if (arvif->u.ap.noa_data)
3188 if (!pskb_expand_head(bcn, 0, arvif->u.ap.noa_len, GFP_ATOMIC))
3189 memcpy(skb_put(bcn, arvif->u.ap.noa_len),
3190 arvif->u.ap.noa_data,
3191 arvif->u.ap.noa_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003192}
3193
Michal Kaziord7579d12014-12-03 10:10:54 +02003194static int ath10k_wmi_op_pull_swba_ev(struct ath10k *ar, struct sk_buff *skb,
3195 struct wmi_swba_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02003196{
3197 struct wmi_host_swba_event *ev = (void *)skb->data;
3198 u32 map;
3199 size_t i;
3200
3201 if (skb->len < sizeof(*ev))
3202 return -EPROTO;
3203
3204 skb_pull(skb, sizeof(*ev));
3205 arg->vdev_map = ev->vdev_map;
3206
3207 for (i = 0, map = __le32_to_cpu(ev->vdev_map); map; map >>= 1) {
3208 if (!(map & BIT(0)))
3209 continue;
3210
3211 /* If this happens there were some changes in firmware and
3212 * ath10k should update the max size of tim_info array.
3213 */
3214 if (WARN_ON_ONCE(i == ARRAY_SIZE(arg->tim_info)))
3215 break;
3216
Raja Mania03fee32015-06-22 20:22:20 +05303217 if (__le32_to_cpu(ev->bcn_info[i].tim_info.tim_len) >
3218 sizeof(ev->bcn_info[i].tim_info.tim_bitmap)) {
3219 ath10k_warn(ar, "refusing to parse invalid swba structure\n");
3220 return -EPROTO;
3221 }
3222
3223 arg->tim_info[i].tim_len = ev->bcn_info[i].tim_info.tim_len;
3224 arg->tim_info[i].tim_mcast = ev->bcn_info[i].tim_info.tim_mcast;
3225 arg->tim_info[i].tim_bitmap =
3226 ev->bcn_info[i].tim_info.tim_bitmap;
3227 arg->tim_info[i].tim_changed =
3228 ev->bcn_info[i].tim_info.tim_changed;
3229 arg->tim_info[i].tim_num_ps_pending =
3230 ev->bcn_info[i].tim_info.tim_num_ps_pending;
3231
Michal Kazior32653cf2014-12-03 10:10:26 +02003232 arg->noa_info[i] = &ev->bcn_info[i].p2p_noa_info;
3233 i++;
3234 }
3235
3236 return 0;
3237}
3238
Raja Mani3cec3be2015-06-22 20:22:21 +05303239static int ath10k_wmi_10_4_op_pull_swba_ev(struct ath10k *ar,
3240 struct sk_buff *skb,
3241 struct wmi_swba_ev_arg *arg)
3242{
3243 struct wmi_10_4_host_swba_event *ev = (void *)skb->data;
3244 u32 map, tim_len;
3245 size_t i;
3246
3247 if (skb->len < sizeof(*ev))
3248 return -EPROTO;
3249
3250 skb_pull(skb, sizeof(*ev));
3251 arg->vdev_map = ev->vdev_map;
3252
3253 for (i = 0, map = __le32_to_cpu(ev->vdev_map); map; map >>= 1) {
3254 if (!(map & BIT(0)))
3255 continue;
3256
3257 /* If this happens there were some changes in firmware and
3258 * ath10k should update the max size of tim_info array.
3259 */
3260 if (WARN_ON_ONCE(i == ARRAY_SIZE(arg->tim_info)))
3261 break;
3262
3263 if (__le32_to_cpu(ev->bcn_info[i].tim_info.tim_len) >
3264 sizeof(ev->bcn_info[i].tim_info.tim_bitmap)) {
3265 ath10k_warn(ar, "refusing to parse invalid swba structure\n");
3266 return -EPROTO;
3267 }
3268
3269 tim_len = __le32_to_cpu(ev->bcn_info[i].tim_info.tim_len);
3270 if (tim_len) {
3271 /* Exclude 4 byte guard length */
3272 tim_len -= 4;
3273 arg->tim_info[i].tim_len = __cpu_to_le32(tim_len);
3274 } else {
3275 arg->tim_info[i].tim_len = 0;
3276 }
3277
3278 arg->tim_info[i].tim_mcast = ev->bcn_info[i].tim_info.tim_mcast;
3279 arg->tim_info[i].tim_bitmap =
3280 ev->bcn_info[i].tim_info.tim_bitmap;
3281 arg->tim_info[i].tim_changed =
3282 ev->bcn_info[i].tim_info.tim_changed;
3283 arg->tim_info[i].tim_num_ps_pending =
3284 ev->bcn_info[i].tim_info.tim_num_ps_pending;
3285
3286 /* 10.4 firmware doesn't have p2p support. notice of absence
3287 * info can be ignored for now.
3288 */
3289
3290 i++;
3291 }
3292
3293 return 0;
3294}
3295
Vivek Natarajan08e75ea2015-08-04 10:45:11 +05303296static enum wmi_txbf_conf ath10k_wmi_10_4_txbf_conf_scheme(struct ath10k *ar)
3297{
3298 return WMI_TXBF_CONF_BEFORE_ASSOC;
3299}
3300
Michal Kazior0226d602014-12-03 10:11:22 +02003301void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003302{
Michal Kazior32653cf2014-12-03 10:10:26 +02003303 struct wmi_swba_ev_arg arg = {};
Kalle Valo5e3dd152013-06-12 20:52:10 +03003304 u32 map;
3305 int i = -1;
Raja Mania03fee32015-06-22 20:22:20 +05303306 const struct wmi_tim_info_arg *tim_info;
Michal Kazior32653cf2014-12-03 10:10:26 +02003307 const struct wmi_p2p_noa_info *noa_info;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003308 struct ath10k_vif *arvif;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003309 struct sk_buff *bcn;
Michal Kazior64badcb2014-09-18 11:18:02 +03003310 dma_addr_t paddr;
Michal Kazior767d34f2014-02-27 18:50:03 +02003311 int ret, vdev_id = 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003312
Michal Kaziord7579d12014-12-03 10:10:54 +02003313 ret = ath10k_wmi_pull_swba(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02003314 if (ret) {
3315 ath10k_warn(ar, "failed to parse swba event: %d\n", ret);
3316 return;
3317 }
3318
3319 map = __le32_to_cpu(arg.vdev_map);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003320
Michal Kazior7aa7a722014-08-25 12:09:38 +02003321 ath10k_dbg(ar, ATH10K_DBG_MGMT, "mgmt swba vdev_map 0x%x\n",
Michal Kazior32653cf2014-12-03 10:10:26 +02003322 map);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003323
3324 for (; map; map >>= 1, vdev_id++) {
3325 if (!(map & 0x1))
3326 continue;
3327
3328 i++;
3329
3330 if (i >= WMI_MAX_AP_VDEV) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003331 ath10k_warn(ar, "swba has corrupted vdev map\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003332 break;
3333 }
3334
Raja Mania03fee32015-06-22 20:22:20 +05303335 tim_info = &arg.tim_info[i];
Michal Kazior32653cf2014-12-03 10:10:26 +02003336 noa_info = arg.noa_info[i];
Kalle Valo5e3dd152013-06-12 20:52:10 +03003337
Michal Kazior7aa7a722014-08-25 12:09:38 +02003338 ath10k_dbg(ar, ATH10K_DBG_MGMT,
Kalle Valo7a8a3962014-03-28 14:35:16 +02003339 "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 +03003340 i,
Michal Kazior32653cf2014-12-03 10:10:26 +02003341 __le32_to_cpu(tim_info->tim_len),
3342 __le32_to_cpu(tim_info->tim_mcast),
3343 __le32_to_cpu(tim_info->tim_changed),
3344 __le32_to_cpu(tim_info->tim_num_ps_pending),
3345 __le32_to_cpu(tim_info->tim_bitmap[3]),
3346 __le32_to_cpu(tim_info->tim_bitmap[2]),
3347 __le32_to_cpu(tim_info->tim_bitmap[1]),
3348 __le32_to_cpu(tim_info->tim_bitmap[0]));
Kalle Valo5e3dd152013-06-12 20:52:10 +03003349
Raja Mania03fee32015-06-22 20:22:20 +05303350 /* TODO: Only first 4 word from tim_bitmap is dumped.
3351 * Extend debug code to dump full tim_bitmap.
3352 */
3353
Kalle Valo5e3dd152013-06-12 20:52:10 +03003354 arvif = ath10k_get_arvif(ar, vdev_id);
3355 if (arvif == NULL) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003356 ath10k_warn(ar, "no vif for vdev_id %d found\n",
3357 vdev_id);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003358 continue;
3359 }
3360
Michal Kaziorc2df44b2014-01-23 11:38:26 +01003361 /* There are no completions for beacons so wait for next SWBA
3362 * before telling mac80211 to decrement CSA counter
3363 *
3364 * Once CSA counter is completed stop sending beacons until
3365 * actual channel switch is done */
3366 if (arvif->vif->csa_active &&
3367 ieee80211_csa_is_complete(arvif->vif)) {
3368 ieee80211_csa_finish(arvif->vif);
3369 continue;
3370 }
3371
Kalle Valo5e3dd152013-06-12 20:52:10 +03003372 bcn = ieee80211_beacon_get(ar->hw, arvif->vif);
3373 if (!bcn) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003374 ath10k_warn(ar, "could not get mac80211 beacon\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003375 continue;
3376 }
3377
Michal Kazior4b604552014-07-21 21:03:09 +03003378 ath10k_tx_h_seq_no(arvif->vif, bcn);
Michal Kazior32653cf2014-12-03 10:10:26 +02003379 ath10k_wmi_update_tim(ar, arvif, bcn, tim_info);
3380 ath10k_wmi_update_noa(ar, arvif, bcn, noa_info);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003381
Michal Kaziored543882013-09-13 14:16:56 +02003382 spin_lock_bh(&ar->data_lock);
Michal Kazior748afc42014-01-23 12:48:21 +01003383
Michal Kaziored543882013-09-13 14:16:56 +02003384 if (arvif->beacon) {
Michal Kazioraf213192015-01-29 14:29:52 +02003385 switch (arvif->beacon_state) {
3386 case ATH10K_BEACON_SENT:
3387 break;
3388 case ATH10K_BEACON_SCHEDULED:
3389 ath10k_warn(ar, "SWBA overrun on vdev %d, skipped old beacon\n",
Michal Kazior748afc42014-01-23 12:48:21 +01003390 arvif->vdev_id);
Michal Kazioraf213192015-01-29 14:29:52 +02003391 break;
3392 case ATH10K_BEACON_SENDING:
3393 ath10k_warn(ar, "SWBA overrun on vdev %d, skipped new beacon\n",
3394 arvif->vdev_id);
3395 dev_kfree_skb(bcn);
3396 goto skip;
3397 }
Michal Kazior748afc42014-01-23 12:48:21 +01003398
Michal Kazior64badcb2014-09-18 11:18:02 +03003399 ath10k_mac_vif_beacon_free(arvif);
Michal Kaziored543882013-09-13 14:16:56 +02003400 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03003401
Michal Kazior64badcb2014-09-18 11:18:02 +03003402 if (!arvif->beacon_buf) {
3403 paddr = dma_map_single(arvif->ar->dev, bcn->data,
3404 bcn->len, DMA_TO_DEVICE);
3405 ret = dma_mapping_error(arvif->ar->dev, paddr);
3406 if (ret) {
3407 ath10k_warn(ar, "failed to map beacon: %d\n",
3408 ret);
3409 dev_kfree_skb_any(bcn);
Michal Kazior5e55e3c2015-08-19 13:10:43 +02003410 ret = -EIO;
Michal Kazior64badcb2014-09-18 11:18:02 +03003411 goto skip;
3412 }
3413
3414 ATH10K_SKB_CB(bcn)->paddr = paddr;
3415 } else {
3416 if (bcn->len > IEEE80211_MAX_FRAME_LEN) {
3417 ath10k_warn(ar, "trimming beacon %d -> %d bytes!\n",
3418 bcn->len, IEEE80211_MAX_FRAME_LEN);
3419 skb_trim(bcn, IEEE80211_MAX_FRAME_LEN);
3420 }
3421 memcpy(arvif->beacon_buf, bcn->data, bcn->len);
3422 ATH10K_SKB_CB(bcn)->paddr = arvif->beacon_paddr;
Michal Kazior767d34f2014-02-27 18:50:03 +02003423 }
Michal Kazior748afc42014-01-23 12:48:21 +01003424
Michal Kaziored543882013-09-13 14:16:56 +02003425 arvif->beacon = bcn;
Michal Kazioraf213192015-01-29 14:29:52 +02003426 arvif->beacon_state = ATH10K_BEACON_SCHEDULED;
Kalle Valo5e3dd152013-06-12 20:52:10 +03003427
Rajkumar Manoharan5ce8e7f2014-11-05 19:14:31 +05303428 trace_ath10k_tx_hdr(ar, bcn->data, bcn->len);
3429 trace_ath10k_tx_payload(ar, bcn->data, bcn->len);
3430
Michal Kazior767d34f2014-02-27 18:50:03 +02003431skip:
Michal Kaziored543882013-09-13 14:16:56 +02003432 spin_unlock_bh(&ar->data_lock);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003433 }
Michal Kazioraf213192015-01-29 14:29:52 +02003434
3435 ath10k_wmi_tx_beacons_nowait(ar);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003436}
3437
Michal Kazior0226d602014-12-03 10:11:22 +02003438void ath10k_wmi_event_tbttoffset_update(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003439{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003440 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TBTTOFFSET_UPDATE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003441}
3442
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003443static void ath10k_dfs_radar_report(struct ath10k *ar,
Raja Mani991adf72015-08-14 11:13:29 +03003444 struct wmi_phyerr_ev_arg *phyerr,
Michal Kazior2332d0a2014-09-18 15:21:25 +02003445 const struct phyerr_radar_report *rr,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003446 u64 tsf)
3447{
3448 u32 reg0, reg1, tsf32l;
Michal Kazior500ff9f2015-03-31 10:26:21 +00003449 struct ieee80211_channel *ch;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003450 struct pulse_event pe;
3451 u64 tsf64;
3452 u8 rssi, width;
3453
3454 reg0 = __le32_to_cpu(rr->reg0);
3455 reg1 = __le32_to_cpu(rr->reg1);
3456
Michal Kazior7aa7a722014-08-25 12:09:38 +02003457 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003458 "wmi phyerr radar report chirp %d max_width %d agc_total_gain %d pulse_delta_diff %d\n",
3459 MS(reg0, RADAR_REPORT_REG0_PULSE_IS_CHIRP),
3460 MS(reg0, RADAR_REPORT_REG0_PULSE_IS_MAX_WIDTH),
3461 MS(reg0, RADAR_REPORT_REG0_AGC_TOTAL_GAIN),
3462 MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_DIFF));
Michal Kazior7aa7a722014-08-25 12:09:38 +02003463 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003464 "wmi phyerr radar report pulse_delta_pean %d pulse_sidx %d fft_valid %d agc_mb_gain %d subchan_mask %d\n",
3465 MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_PEAK),
3466 MS(reg0, RADAR_REPORT_REG0_PULSE_SIDX),
3467 MS(reg1, RADAR_REPORT_REG1_PULSE_SRCH_FFT_VALID),
3468 MS(reg1, RADAR_REPORT_REG1_PULSE_AGC_MB_GAIN),
3469 MS(reg1, RADAR_REPORT_REG1_PULSE_SUBCHAN_MASK));
Michal Kazior7aa7a722014-08-25 12:09:38 +02003470 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003471 "wmi phyerr radar report pulse_tsf_offset 0x%X pulse_dur: %d\n",
3472 MS(reg1, RADAR_REPORT_REG1_PULSE_TSF_OFFSET),
3473 MS(reg1, RADAR_REPORT_REG1_PULSE_DUR));
3474
3475 if (!ar->dfs_detector)
3476 return;
3477
Michal Kazior500ff9f2015-03-31 10:26:21 +00003478 spin_lock_bh(&ar->data_lock);
3479 ch = ar->rx_channel;
3480 spin_unlock_bh(&ar->data_lock);
3481
3482 if (!ch) {
3483 ath10k_warn(ar, "failed to derive channel for radar pulse, treating as radar\n");
3484 goto radar_detected;
3485 }
3486
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003487 /* report event to DFS pattern detector */
Raja Mani991adf72015-08-14 11:13:29 +03003488 tsf32l = phyerr->tsf_timestamp;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003489 tsf64 = tsf & (~0xFFFFFFFFULL);
3490 tsf64 |= tsf32l;
3491
3492 width = MS(reg1, RADAR_REPORT_REG1_PULSE_DUR);
Michal Kazior2332d0a2014-09-18 15:21:25 +02003493 rssi = phyerr->rssi_combined;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003494
3495 /* hardware store this as 8 bit signed value,
3496 * set to zero if negative number
3497 */
3498 if (rssi & 0x80)
3499 rssi = 0;
3500
3501 pe.ts = tsf64;
Michal Kazior500ff9f2015-03-31 10:26:21 +00003502 pe.freq = ch->center_freq;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003503 pe.width = width;
3504 pe.rssi = rssi;
Peter Oh2c3f26a2015-03-04 15:43:46 +02003505 pe.chirp = (MS(reg0, RADAR_REPORT_REG0_PULSE_IS_CHIRP) != 0);
Michal Kazior7aa7a722014-08-25 12:09:38 +02003506 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003507 "dfs add pulse freq: %d, width: %d, rssi %d, tsf: %llX\n",
3508 pe.freq, pe.width, pe.rssi, pe.ts);
3509
3510 ATH10K_DFS_STAT_INC(ar, pulses_detected);
3511
3512 if (!ar->dfs_detector->add_pulse(ar->dfs_detector, &pe)) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003513 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003514 "dfs no pulse pattern detected, yet\n");
3515 return;
3516 }
3517
Michal Kazior500ff9f2015-03-31 10:26:21 +00003518radar_detected:
Michal Kazior7aa7a722014-08-25 12:09:38 +02003519 ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs radar detected\n");
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003520 ATH10K_DFS_STAT_INC(ar, radar_detected);
Marek Puzyniak7d9b40b2013-11-20 10:00:28 +02003521
3522 /* Control radar events reporting in debugfs file
3523 dfs_block_radar_events */
3524 if (ar->dfs_block_radar_events) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003525 ath10k_info(ar, "DFS Radar detected, but ignored as requested\n");
Marek Puzyniak7d9b40b2013-11-20 10:00:28 +02003526 return;
3527 }
3528
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003529 ieee80211_radar_detected(ar->hw);
3530}
3531
3532static int ath10k_dfs_fft_report(struct ath10k *ar,
Raja Mani991adf72015-08-14 11:13:29 +03003533 struct wmi_phyerr_ev_arg *phyerr,
Michal Kazior2332d0a2014-09-18 15:21:25 +02003534 const struct phyerr_fft_report *fftr,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003535 u64 tsf)
3536{
3537 u32 reg0, reg1;
3538 u8 rssi, peak_mag;
3539
3540 reg0 = __le32_to_cpu(fftr->reg0);
3541 reg1 = __le32_to_cpu(fftr->reg1);
Michal Kazior2332d0a2014-09-18 15:21:25 +02003542 rssi = phyerr->rssi_combined;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003543
Michal Kazior7aa7a722014-08-25 12:09:38 +02003544 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003545 "wmi phyerr fft report total_gain_db %d base_pwr_db %d fft_chn_idx %d peak_sidx %d\n",
3546 MS(reg0, SEARCH_FFT_REPORT_REG0_TOTAL_GAIN_DB),
3547 MS(reg0, SEARCH_FFT_REPORT_REG0_BASE_PWR_DB),
3548 MS(reg0, SEARCH_FFT_REPORT_REG0_FFT_CHN_IDX),
3549 MS(reg0, SEARCH_FFT_REPORT_REG0_PEAK_SIDX));
Michal Kazior7aa7a722014-08-25 12:09:38 +02003550 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003551 "wmi phyerr fft report rel_pwr_db %d avgpwr_db %d peak_mag %d num_store_bin %d\n",
3552 MS(reg1, SEARCH_FFT_REPORT_REG1_RELPWR_DB),
3553 MS(reg1, SEARCH_FFT_REPORT_REG1_AVGPWR_DB),
3554 MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG),
3555 MS(reg1, SEARCH_FFT_REPORT_REG1_NUM_STR_BINS_IB));
3556
3557 peak_mag = MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG);
3558
3559 /* false event detection */
3560 if (rssi == DFS_RSSI_POSSIBLY_FALSE &&
3561 peak_mag < 2 * DFS_PEAK_MAG_THOLD_POSSIBLY_FALSE) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003562 ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs false pulse detected\n");
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003563 ATH10K_DFS_STAT_INC(ar, pulses_discarded);
3564 return -EINVAL;
3565 }
3566
3567 return 0;
3568}
3569
Michal Kazior0226d602014-12-03 10:11:22 +02003570void ath10k_wmi_event_dfs(struct ath10k *ar,
Raja Mani991adf72015-08-14 11:13:29 +03003571 struct wmi_phyerr_ev_arg *phyerr,
Michal Kazior0226d602014-12-03 10:11:22 +02003572 u64 tsf)
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003573{
3574 int buf_len, tlv_len, res, i = 0;
Michal Kazior2332d0a2014-09-18 15:21:25 +02003575 const struct phyerr_tlv *tlv;
3576 const struct phyerr_radar_report *rr;
3577 const struct phyerr_fft_report *fftr;
3578 const u8 *tlv_buf;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003579
Raja Mani991adf72015-08-14 11:13:29 +03003580 buf_len = phyerr->buf_len;
Michal Kazior7aa7a722014-08-25 12:09:38 +02003581 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003582 "wmi event dfs err_code %d rssi %d tsfl 0x%X tsf64 0x%llX len %d\n",
Michal Kazior2332d0a2014-09-18 15:21:25 +02003583 phyerr->phy_err_code, phyerr->rssi_combined,
Raja Mani991adf72015-08-14 11:13:29 +03003584 phyerr->tsf_timestamp, tsf, buf_len);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003585
3586 /* Skip event if DFS disabled */
3587 if (!config_enabled(CONFIG_ATH10K_DFS_CERTIFIED))
3588 return;
3589
3590 ATH10K_DFS_STAT_INC(ar, pulses_total);
3591
3592 while (i < buf_len) {
3593 if (i + sizeof(*tlv) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003594 ath10k_warn(ar, "too short buf for tlv header (%d)\n",
3595 i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003596 return;
3597 }
3598
Michal Kazior2332d0a2014-09-18 15:21:25 +02003599 tlv = (struct phyerr_tlv *)&phyerr->buf[i];
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003600 tlv_len = __le16_to_cpu(tlv->len);
Michal Kazior2332d0a2014-09-18 15:21:25 +02003601 tlv_buf = &phyerr->buf[i + sizeof(*tlv)];
Michal Kazior7aa7a722014-08-25 12:09:38 +02003602 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003603 "wmi event dfs tlv_len %d tlv_tag 0x%02X tlv_sig 0x%02X\n",
3604 tlv_len, tlv->tag, tlv->sig);
3605
3606 switch (tlv->tag) {
3607 case PHYERR_TLV_TAG_RADAR_PULSE_SUMMARY:
3608 if (i + sizeof(*tlv) + sizeof(*rr) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003609 ath10k_warn(ar, "too short radar pulse summary (%d)\n",
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003610 i);
3611 return;
3612 }
3613
3614 rr = (struct phyerr_radar_report *)tlv_buf;
Michal Kazior2332d0a2014-09-18 15:21:25 +02003615 ath10k_dfs_radar_report(ar, phyerr, rr, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003616 break;
3617 case PHYERR_TLV_TAG_SEARCH_FFT_REPORT:
3618 if (i + sizeof(*tlv) + sizeof(*fftr) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003619 ath10k_warn(ar, "too short fft report (%d)\n",
3620 i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003621 return;
3622 }
3623
3624 fftr = (struct phyerr_fft_report *)tlv_buf;
Michal Kazior2332d0a2014-09-18 15:21:25 +02003625 res = ath10k_dfs_fft_report(ar, phyerr, fftr, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003626 if (res)
3627 return;
3628 break;
3629 }
3630
3631 i += sizeof(*tlv) + tlv_len;
3632 }
3633}
3634
Michal Kazior0226d602014-12-03 10:11:22 +02003635void ath10k_wmi_event_spectral_scan(struct ath10k *ar,
Raja Mani991adf72015-08-14 11:13:29 +03003636 struct wmi_phyerr_ev_arg *phyerr,
Michal Kazior0226d602014-12-03 10:11:22 +02003637 u64 tsf)
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003638{
Simon Wunderlich855aed12014-08-02 09:12:54 +03003639 int buf_len, tlv_len, res, i = 0;
3640 struct phyerr_tlv *tlv;
Michal Kazior2332d0a2014-09-18 15:21:25 +02003641 const void *tlv_buf;
3642 const struct phyerr_fft_report *fftr;
Simon Wunderlich855aed12014-08-02 09:12:54 +03003643 size_t fftr_len;
3644
Raja Mani991adf72015-08-14 11:13:29 +03003645 buf_len = phyerr->buf_len;
Simon Wunderlich855aed12014-08-02 09:12:54 +03003646
3647 while (i < buf_len) {
3648 if (i + sizeof(*tlv) > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003649 ath10k_warn(ar, "failed to parse phyerr tlv header at byte %d\n",
Simon Wunderlich855aed12014-08-02 09:12:54 +03003650 i);
3651 return;
3652 }
3653
Michal Kazior2332d0a2014-09-18 15:21:25 +02003654 tlv = (struct phyerr_tlv *)&phyerr->buf[i];
Simon Wunderlich855aed12014-08-02 09:12:54 +03003655 tlv_len = __le16_to_cpu(tlv->len);
Michal Kazior2332d0a2014-09-18 15:21:25 +02003656 tlv_buf = &phyerr->buf[i + sizeof(*tlv)];
Simon Wunderlich855aed12014-08-02 09:12:54 +03003657
3658 if (i + sizeof(*tlv) + tlv_len > buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003659 ath10k_warn(ar, "failed to parse phyerr tlv payload at byte %d\n",
Simon Wunderlich855aed12014-08-02 09:12:54 +03003660 i);
3661 return;
3662 }
3663
3664 switch (tlv->tag) {
3665 case PHYERR_TLV_TAG_SEARCH_FFT_REPORT:
3666 if (sizeof(*fftr) > tlv_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003667 ath10k_warn(ar, "failed to parse fft report at byte %d\n",
Simon Wunderlich855aed12014-08-02 09:12:54 +03003668 i);
3669 return;
3670 }
3671
3672 fftr_len = tlv_len - sizeof(*fftr);
Michal Kazior2332d0a2014-09-18 15:21:25 +02003673 fftr = tlv_buf;
3674 res = ath10k_spectral_process_fft(ar, phyerr,
Simon Wunderlich855aed12014-08-02 09:12:54 +03003675 fftr, fftr_len,
3676 tsf);
3677 if (res < 0) {
Kevin Darbyshire-Bryant3413e972015-07-21 15:50:15 +01003678 ath10k_dbg(ar, ATH10K_DBG_WMI, "failed to process fft report: %d\n",
Kalle Valo617b0f42015-10-05 17:56:35 +03003679 res);
Simon Wunderlich855aed12014-08-02 09:12:54 +03003680 return;
3681 }
3682 break;
3683 }
3684
3685 i += sizeof(*tlv) + tlv_len;
3686 }
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003687}
3688
Raja Mani991adf72015-08-14 11:13:29 +03003689static int ath10k_wmi_op_pull_phyerr_ev_hdr(struct ath10k *ar,
3690 struct sk_buff *skb,
3691 struct wmi_phyerr_hdr_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02003692{
3693 struct wmi_phyerr_event *ev = (void *)skb->data;
3694
3695 if (skb->len < sizeof(*ev))
3696 return -EPROTO;
3697
Raja Mani991adf72015-08-14 11:13:29 +03003698 arg->num_phyerrs = __le32_to_cpu(ev->num_phyerrs);
3699 arg->tsf_l32 = __le32_to_cpu(ev->tsf_l32);
3700 arg->tsf_u32 = __le32_to_cpu(ev->tsf_u32);
3701 arg->buf_len = skb->len - sizeof(*ev);
Michal Kazior32653cf2014-12-03 10:10:26 +02003702 arg->phyerrs = ev->phyerrs;
3703
3704 return 0;
3705}
3706
Raja Mani2b0a2e02015-08-14 11:13:34 +03003707static int ath10k_wmi_10_4_op_pull_phyerr_ev_hdr(struct ath10k *ar,
3708 struct sk_buff *skb,
3709 struct wmi_phyerr_hdr_arg *arg)
3710{
3711 struct wmi_10_4_phyerr_event *ev = (void *)skb->data;
3712
3713 if (skb->len < sizeof(*ev))
3714 return -EPROTO;
3715
3716 /* 10.4 firmware always reports only one phyerr */
3717 arg->num_phyerrs = 1;
3718
3719 arg->tsf_l32 = __le32_to_cpu(ev->tsf_l32);
3720 arg->tsf_u32 = __le32_to_cpu(ev->tsf_u32);
3721 arg->buf_len = skb->len;
3722 arg->phyerrs = skb->data;
3723
3724 return 0;
3725}
3726
Raja Mani991adf72015-08-14 11:13:29 +03003727int ath10k_wmi_op_pull_phyerr_ev(struct ath10k *ar,
3728 const void *phyerr_buf,
3729 int left_len,
3730 struct wmi_phyerr_ev_arg *arg)
3731{
3732 const struct wmi_phyerr *phyerr = phyerr_buf;
3733 int i;
3734
3735 if (left_len < sizeof(*phyerr)) {
Raja Maniee92a202015-08-21 18:42:36 +05303736 ath10k_warn(ar, "wrong phyerr event head len %d (need: >=%zd)\n",
Raja Mani991adf72015-08-14 11:13:29 +03003737 left_len, sizeof(*phyerr));
3738 return -EINVAL;
3739 }
3740
3741 arg->tsf_timestamp = __le32_to_cpu(phyerr->tsf_timestamp);
3742 arg->freq1 = __le16_to_cpu(phyerr->freq1);
3743 arg->freq2 = __le16_to_cpu(phyerr->freq2);
3744 arg->rssi_combined = phyerr->rssi_combined;
3745 arg->chan_width_mhz = phyerr->chan_width_mhz;
3746 arg->buf_len = __le32_to_cpu(phyerr->buf_len);
3747 arg->buf = phyerr->buf;
3748 arg->hdr_len = sizeof(*phyerr);
3749
3750 for (i = 0; i < 4; i++)
3751 arg->nf_chains[i] = __le16_to_cpu(phyerr->nf_chains[i]);
3752
3753 switch (phyerr->phy_err_code) {
3754 case PHY_ERROR_GEN_SPECTRAL_SCAN:
3755 arg->phy_err_code = PHY_ERROR_SPECTRAL_SCAN;
3756 break;
3757 case PHY_ERROR_GEN_FALSE_RADAR_EXT:
3758 arg->phy_err_code = PHY_ERROR_FALSE_RADAR_EXT;
3759 break;
3760 case PHY_ERROR_GEN_RADAR:
3761 arg->phy_err_code = PHY_ERROR_RADAR;
3762 break;
3763 default:
3764 arg->phy_err_code = PHY_ERROR_UNKNOWN;
3765 break;
3766 }
3767
3768 return 0;
3769}
3770
Raja Mani2b0a2e02015-08-14 11:13:34 +03003771static int ath10k_wmi_10_4_op_pull_phyerr_ev(struct ath10k *ar,
3772 const void *phyerr_buf,
3773 int left_len,
3774 struct wmi_phyerr_ev_arg *arg)
3775{
3776 const struct wmi_10_4_phyerr_event *phyerr = phyerr_buf;
3777 u32 phy_err_mask;
3778 int i;
3779
3780 if (left_len < sizeof(*phyerr)) {
Raja Maniee92a202015-08-21 18:42:36 +05303781 ath10k_warn(ar, "wrong phyerr event head len %d (need: >=%zd)\n",
Raja Mani2b0a2e02015-08-14 11:13:34 +03003782 left_len, sizeof(*phyerr));
3783 return -EINVAL;
3784 }
3785
3786 arg->tsf_timestamp = __le32_to_cpu(phyerr->tsf_timestamp);
3787 arg->freq1 = __le16_to_cpu(phyerr->freq1);
3788 arg->freq2 = __le16_to_cpu(phyerr->freq2);
3789 arg->rssi_combined = phyerr->rssi_combined;
3790 arg->chan_width_mhz = phyerr->chan_width_mhz;
3791 arg->buf_len = __le32_to_cpu(phyerr->buf_len);
3792 arg->buf = phyerr->buf;
3793 arg->hdr_len = sizeof(*phyerr);
3794
3795 for (i = 0; i < 4; i++)
3796 arg->nf_chains[i] = __le16_to_cpu(phyerr->nf_chains[i]);
3797
3798 phy_err_mask = __le32_to_cpu(phyerr->phy_err_mask[0]);
3799
3800 if (phy_err_mask & PHY_ERROR_10_4_SPECTRAL_SCAN_MASK)
3801 arg->phy_err_code = PHY_ERROR_SPECTRAL_SCAN;
3802 else if (phy_err_mask & PHY_ERROR_10_4_RADAR_MASK)
3803 arg->phy_err_code = PHY_ERROR_RADAR;
3804 else
3805 arg->phy_err_code = PHY_ERROR_UNKNOWN;
3806
3807 return 0;
3808}
3809
Michal Kazior0226d602014-12-03 10:11:22 +02003810void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003811{
Raja Mani991adf72015-08-14 11:13:29 +03003812 struct wmi_phyerr_hdr_arg hdr_arg = {};
3813 struct wmi_phyerr_ev_arg phyerr_arg = {};
3814 const void *phyerr;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003815 u32 count, i, buf_len, phy_err_code;
3816 u64 tsf;
Michal Kazior32653cf2014-12-03 10:10:26 +02003817 int left_len, ret;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003818
3819 ATH10K_DFS_STAT_INC(ar, phy_errors);
3820
Raja Mani991adf72015-08-14 11:13:29 +03003821 ret = ath10k_wmi_pull_phyerr_hdr(ar, skb, &hdr_arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02003822 if (ret) {
Raja Mani991adf72015-08-14 11:13:29 +03003823 ath10k_warn(ar, "failed to parse phyerr event hdr: %d\n", ret);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003824 return;
3825 }
3826
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003827 /* Check number of included events */
Raja Mani991adf72015-08-14 11:13:29 +03003828 count = hdr_arg.num_phyerrs;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003829
Raja Mani991adf72015-08-14 11:13:29 +03003830 left_len = hdr_arg.buf_len;
3831
3832 tsf = hdr_arg.tsf_u32;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003833 tsf <<= 32;
Raja Mani991adf72015-08-14 11:13:29 +03003834 tsf |= hdr_arg.tsf_l32;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003835
Michal Kazior7aa7a722014-08-25 12:09:38 +02003836 ath10k_dbg(ar, ATH10K_DBG_WMI,
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003837 "wmi event phyerr count %d tsf64 0x%llX\n",
3838 count, tsf);
3839
Raja Mani991adf72015-08-14 11:13:29 +03003840 phyerr = hdr_arg.phyerrs;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003841 for (i = 0; i < count; i++) {
Raja Mani991adf72015-08-14 11:13:29 +03003842 ret = ath10k_wmi_pull_phyerr(ar, phyerr, left_len, &phyerr_arg);
3843 if (ret) {
3844 ath10k_warn(ar, "failed to parse phyerr event (%d)\n",
Michal Kazior7aa7a722014-08-25 12:09:38 +02003845 i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003846 return;
3847 }
3848
Raja Mani991adf72015-08-14 11:13:29 +03003849 left_len -= phyerr_arg.hdr_len;
3850 buf_len = phyerr_arg.buf_len;
3851 phy_err_code = phyerr_arg.phy_err_code;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003852
3853 if (left_len < buf_len) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02003854 ath10k_warn(ar, "single event (%d) wrong buf len\n", i);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003855 return;
3856 }
3857
3858 left_len -= buf_len;
3859
3860 switch (phy_err_code) {
3861 case PHY_ERROR_RADAR:
Raja Mani991adf72015-08-14 11:13:29 +03003862 ath10k_wmi_event_dfs(ar, &phyerr_arg, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003863 break;
3864 case PHY_ERROR_SPECTRAL_SCAN:
Raja Mani991adf72015-08-14 11:13:29 +03003865 ath10k_wmi_event_spectral_scan(ar, &phyerr_arg, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003866 break;
3867 case PHY_ERROR_FALSE_RADAR_EXT:
Raja Mani991adf72015-08-14 11:13:29 +03003868 ath10k_wmi_event_dfs(ar, &phyerr_arg, tsf);
3869 ath10k_wmi_event_spectral_scan(ar, &phyerr_arg, tsf);
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003870 break;
3871 default:
3872 break;
3873 }
3874
Raja Mani991adf72015-08-14 11:13:29 +03003875 phyerr = phyerr + phyerr_arg.hdr_len + buf_len;
Janusz Dziedzic9702c682013-11-20 09:59:41 +02003876 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03003877}
3878
Michal Kazior0226d602014-12-03 10:11:22 +02003879void ath10k_wmi_event_roam(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003880{
Michal Kaziorc1a46542015-03-10 16:21:54 +02003881 struct wmi_roam_ev_arg arg = {};
3882 int ret;
3883 u32 vdev_id;
3884 u32 reason;
3885 s32 rssi;
3886
3887 ret = ath10k_wmi_pull_roam_ev(ar, skb, &arg);
3888 if (ret) {
3889 ath10k_warn(ar, "failed to parse roam event: %d\n", ret);
3890 return;
3891 }
3892
3893 vdev_id = __le32_to_cpu(arg.vdev_id);
3894 reason = __le32_to_cpu(arg.reason);
3895 rssi = __le32_to_cpu(arg.rssi);
3896 rssi += WMI_SPECTRAL_NOISE_FLOOR_REF_DEFAULT;
3897
3898 ath10k_dbg(ar, ATH10K_DBG_WMI,
3899 "wmi roam event vdev %u reason 0x%08x rssi %d\n",
3900 vdev_id, reason, rssi);
3901
3902 if (reason >= WMI_ROAM_REASON_MAX)
3903 ath10k_warn(ar, "ignoring unknown roam event reason %d on vdev %i\n",
3904 reason, vdev_id);
3905
3906 switch (reason) {
Michal Kaziorc1a46542015-03-10 16:21:54 +02003907 case WMI_ROAM_REASON_BEACON_MISS:
Michal Kaziorcc9904e2015-03-10 16:22:01 +02003908 ath10k_mac_handle_beacon_miss(ar, vdev_id);
3909 break;
3910 case WMI_ROAM_REASON_BETTER_AP:
Michal Kaziorc1a46542015-03-10 16:21:54 +02003911 case WMI_ROAM_REASON_LOW_RSSI:
3912 case WMI_ROAM_REASON_SUITABLE_AP_FOUND:
3913 case WMI_ROAM_REASON_HO_FAILED:
3914 ath10k_warn(ar, "ignoring not implemented roam event reason %d on vdev %i\n",
3915 reason, vdev_id);
3916 break;
3917 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03003918}
3919
Michal Kazior0226d602014-12-03 10:11:22 +02003920void ath10k_wmi_event_profile_match(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003921{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003922 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PROFILE_MATCH\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003923}
3924
Michal Kazior0226d602014-12-03 10:11:22 +02003925void ath10k_wmi_event_debug_print(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003926{
Kalle Valo2fe52882014-01-03 12:59:20 +02003927 char buf[101], c;
3928 int i;
3929
3930 for (i = 0; i < sizeof(buf) - 1; i++) {
3931 if (i >= skb->len)
3932 break;
3933
3934 c = skb->data[i];
3935
3936 if (c == '\0')
3937 break;
3938
3939 if (isascii(c) && isprint(c))
3940 buf[i] = c;
3941 else
3942 buf[i] = '.';
3943 }
3944
3945 if (i == sizeof(buf) - 1)
Michal Kazior7aa7a722014-08-25 12:09:38 +02003946 ath10k_warn(ar, "wmi debug print truncated: %d\n", skb->len);
Kalle Valo2fe52882014-01-03 12:59:20 +02003947
3948 /* for some reason the debug prints end with \n, remove that */
3949 if (skb->data[i - 1] == '\n')
3950 i--;
3951
3952 /* the last byte is always reserved for the null character */
3953 buf[i] = '\0';
3954
Ben Greear3be004c2014-09-23 14:17:19 -07003955 ath10k_dbg(ar, ATH10K_DBG_WMI_PRINT, "wmi print '%s'\n", buf);
Kalle Valo5e3dd152013-06-12 20:52:10 +03003956}
3957
Michal Kazior0226d602014-12-03 10:11:22 +02003958void ath10k_wmi_event_pdev_qvit(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003959{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003960 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_QVIT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003961}
3962
Michal Kazior0226d602014-12-03 10:11:22 +02003963void ath10k_wmi_event_wlan_profile_data(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003964{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003965 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_WLAN_PROFILE_DATA_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003966}
3967
Michal Kazior0226d602014-12-03 10:11:22 +02003968void ath10k_wmi_event_rtt_measurement_report(struct ath10k *ar,
3969 struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003970{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003971 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_MEASUREMENT_REPORT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003972}
3973
Michal Kazior0226d602014-12-03 10:11:22 +02003974void ath10k_wmi_event_tsf_measurement_report(struct ath10k *ar,
3975 struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003976{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003977 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TSF_MEASUREMENT_REPORT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003978}
3979
Michal Kazior0226d602014-12-03 10:11:22 +02003980void ath10k_wmi_event_rtt_error_report(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003981{
Michal Kazior7aa7a722014-08-25 12:09:38 +02003982 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_ERROR_REPORT_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03003983}
3984
Michal Kazior0226d602014-12-03 10:11:22 +02003985void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03003986{
Janusz Dziedzic5fd3ac32015-03-23 17:32:53 +02003987 struct wmi_wow_ev_arg ev = {};
3988 int ret;
3989
3990 complete(&ar->wow.wakeup_completed);
3991
3992 ret = ath10k_wmi_pull_wow_event(ar, skb, &ev);
3993 if (ret) {
3994 ath10k_warn(ar, "failed to parse wow wakeup event: %d\n", ret);
3995 return;
3996 }
3997
3998 ath10k_dbg(ar, ATH10K_DBG_WMI, "wow wakeup host reason %s\n",
3999 wow_reason(ev.wake_reason));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004000}
4001
Michal Kazior0226d602014-12-03 10:11:22 +02004002void ath10k_wmi_event_dcs_interference(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004003{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004004 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_DCS_INTERFERENCE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004005}
4006
Maharaja Kennadyrajan29542662015-10-05 17:56:38 +03004007static u8 ath10k_tpc_config_get_rate(struct ath10k *ar,
4008 struct wmi_pdev_tpc_config_event *ev,
4009 u32 rate_idx, u32 num_chains,
4010 u32 rate_code, u8 type)
4011{
4012 u8 tpc, num_streams, preamble, ch, stm_idx;
4013
4014 num_streams = ATH10K_HW_NSS(rate_code);
4015 preamble = ATH10K_HW_PREAMBLE(rate_code);
4016 ch = num_chains - 1;
4017
4018 tpc = min_t(u8, ev->rates_array[rate_idx], ev->max_reg_allow_pow[ch]);
4019
4020 if (__le32_to_cpu(ev->num_tx_chain) <= 1)
4021 goto out;
4022
4023 if (preamble == WMI_RATE_PREAMBLE_CCK)
4024 goto out;
4025
4026 stm_idx = num_streams - 1;
4027 if (num_chains <= num_streams)
4028 goto out;
4029
4030 switch (type) {
4031 case WMI_TPC_TABLE_TYPE_STBC:
4032 tpc = min_t(u8, tpc,
4033 ev->max_reg_allow_pow_agstbc[ch - 1][stm_idx]);
4034 break;
4035 case WMI_TPC_TABLE_TYPE_TXBF:
4036 tpc = min_t(u8, tpc,
4037 ev->max_reg_allow_pow_agtxbf[ch - 1][stm_idx]);
4038 break;
4039 case WMI_TPC_TABLE_TYPE_CDD:
4040 tpc = min_t(u8, tpc,
4041 ev->max_reg_allow_pow_agcdd[ch - 1][stm_idx]);
4042 break;
4043 default:
4044 ath10k_warn(ar, "unknown wmi tpc table type: %d\n", type);
4045 tpc = 0;
4046 break;
4047 }
4048
4049out:
4050 return tpc;
4051}
4052
4053static void ath10k_tpc_config_disp_tables(struct ath10k *ar,
4054 struct wmi_pdev_tpc_config_event *ev,
4055 struct ath10k_tpc_stats *tpc_stats,
4056 u8 *rate_code, u16 *pream_table, u8 type)
4057{
4058 u32 i, j, pream_idx, flags;
4059 u8 tpc[WMI_TPC_TX_N_CHAIN];
4060 char tpc_value[WMI_TPC_TX_N_CHAIN * WMI_TPC_BUF_SIZE];
4061 char buff[WMI_TPC_BUF_SIZE];
4062
4063 flags = __le32_to_cpu(ev->flags);
4064
4065 switch (type) {
4066 case WMI_TPC_TABLE_TYPE_CDD:
4067 if (!(flags & WMI_TPC_CONFIG_EVENT_FLAG_TABLE_CDD)) {
4068 ath10k_dbg(ar, ATH10K_DBG_WMI, "CDD not supported\n");
4069 tpc_stats->flag[type] = ATH10K_TPC_TABLE_TYPE_FLAG;
4070 return;
4071 }
4072 break;
4073 case WMI_TPC_TABLE_TYPE_STBC:
4074 if (!(flags & WMI_TPC_CONFIG_EVENT_FLAG_TABLE_STBC)) {
4075 ath10k_dbg(ar, ATH10K_DBG_WMI, "STBC not supported\n");
4076 tpc_stats->flag[type] = ATH10K_TPC_TABLE_TYPE_FLAG;
4077 return;
4078 }
4079 break;
4080 case WMI_TPC_TABLE_TYPE_TXBF:
4081 if (!(flags & WMI_TPC_CONFIG_EVENT_FLAG_TABLE_TXBF)) {
4082 ath10k_dbg(ar, ATH10K_DBG_WMI, "TXBF not supported\n");
4083 tpc_stats->flag[type] = ATH10K_TPC_TABLE_TYPE_FLAG;
4084 return;
4085 }
4086 break;
4087 default:
4088 ath10k_dbg(ar, ATH10K_DBG_WMI,
4089 "invalid table type in wmi tpc event: %d\n", type);
4090 return;
4091 }
4092
4093 pream_idx = 0;
4094 for (i = 0; i < __le32_to_cpu(ev->rate_max); i++) {
4095 memset(tpc_value, 0, sizeof(tpc_value));
4096 memset(buff, 0, sizeof(buff));
4097 if (i == pream_table[pream_idx])
4098 pream_idx++;
4099
4100 for (j = 0; j < WMI_TPC_TX_N_CHAIN; j++) {
4101 if (j >= __le32_to_cpu(ev->num_tx_chain))
4102 break;
4103
4104 tpc[j] = ath10k_tpc_config_get_rate(ar, ev, i, j + 1,
4105 rate_code[i],
4106 type);
4107 snprintf(buff, sizeof(buff), "%8d ", tpc[j]);
4108 strncat(tpc_value, buff, strlen(buff));
4109 }
4110 tpc_stats->tpc_table[type].pream_idx[i] = pream_idx;
4111 tpc_stats->tpc_table[type].rate_code[i] = rate_code[i];
4112 memcpy(tpc_stats->tpc_table[type].tpc_value[i],
4113 tpc_value, sizeof(tpc_value));
4114 }
4115}
4116
Michal Kazior0226d602014-12-03 10:11:22 +02004117void ath10k_wmi_event_pdev_tpc_config(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004118{
Maharaja Kennadyrajan29542662015-10-05 17:56:38 +03004119 u32 i, j, pream_idx, num_tx_chain;
4120 u8 rate_code[WMI_TPC_RATE_MAX], rate_idx;
4121 u16 pream_table[WMI_TPC_PREAM_TABLE_MAX];
4122 struct wmi_pdev_tpc_config_event *ev;
4123 struct ath10k_tpc_stats *tpc_stats;
4124
4125 ev = (struct wmi_pdev_tpc_config_event *)skb->data;
4126
4127 tpc_stats = kzalloc(sizeof(*tpc_stats), GFP_ATOMIC);
4128 if (!tpc_stats)
4129 return;
4130
4131 /* Create the rate code table based on the chains supported */
4132 rate_idx = 0;
4133 pream_idx = 0;
4134
4135 /* Fill CCK rate code */
4136 for (i = 0; i < 4; i++) {
4137 rate_code[rate_idx] =
4138 ATH10K_HW_RATECODE(i, 0, WMI_RATE_PREAMBLE_CCK);
4139 rate_idx++;
4140 }
4141 pream_table[pream_idx] = rate_idx;
4142 pream_idx++;
4143
4144 /* Fill OFDM rate code */
4145 for (i = 0; i < 8; i++) {
4146 rate_code[rate_idx] =
4147 ATH10K_HW_RATECODE(i, 0, WMI_RATE_PREAMBLE_OFDM);
4148 rate_idx++;
4149 }
4150 pream_table[pream_idx] = rate_idx;
4151 pream_idx++;
4152
4153 num_tx_chain = __le32_to_cpu(ev->num_tx_chain);
4154
4155 /* Fill HT20 rate code */
4156 for (i = 0; i < num_tx_chain; i++) {
4157 for (j = 0; j < 8; j++) {
4158 rate_code[rate_idx] =
4159 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_HT);
4160 rate_idx++;
4161 }
4162 }
4163 pream_table[pream_idx] = rate_idx;
4164 pream_idx++;
4165
4166 /* Fill HT40 rate code */
4167 for (i = 0; i < num_tx_chain; i++) {
4168 for (j = 0; j < 8; j++) {
4169 rate_code[rate_idx] =
4170 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_HT);
4171 rate_idx++;
4172 }
4173 }
4174 pream_table[pream_idx] = rate_idx;
4175 pream_idx++;
4176
4177 /* Fill VHT20 rate code */
4178 for (i = 0; i < __le32_to_cpu(ev->num_tx_chain); i++) {
4179 for (j = 0; j < 10; j++) {
4180 rate_code[rate_idx] =
4181 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_VHT);
4182 rate_idx++;
4183 }
4184 }
4185 pream_table[pream_idx] = rate_idx;
4186 pream_idx++;
4187
4188 /* Fill VHT40 rate code */
4189 for (i = 0; i < num_tx_chain; i++) {
4190 for (j = 0; j < 10; j++) {
4191 rate_code[rate_idx] =
4192 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_VHT);
4193 rate_idx++;
4194 }
4195 }
4196 pream_table[pream_idx] = rate_idx;
4197 pream_idx++;
4198
4199 /* Fill VHT80 rate code */
4200 for (i = 0; i < num_tx_chain; i++) {
4201 for (j = 0; j < 10; j++) {
4202 rate_code[rate_idx] =
4203 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_VHT);
4204 rate_idx++;
4205 }
4206 }
4207 pream_table[pream_idx] = rate_idx;
4208 pream_idx++;
4209
4210 rate_code[rate_idx++] =
4211 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_CCK);
4212 rate_code[rate_idx++] =
4213 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_OFDM);
4214 rate_code[rate_idx++] =
4215 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_CCK);
4216 rate_code[rate_idx++] =
4217 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_OFDM);
4218 rate_code[rate_idx++] =
4219 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_OFDM);
4220
4221 pream_table[pream_idx] = ATH10K_TPC_PREAM_TABLE_END;
4222
4223 tpc_stats->chan_freq = __le32_to_cpu(ev->chan_freq);
4224 tpc_stats->phy_mode = __le32_to_cpu(ev->phy_mode);
4225 tpc_stats->ctl = __le32_to_cpu(ev->ctl);
4226 tpc_stats->reg_domain = __le32_to_cpu(ev->reg_domain);
4227 tpc_stats->twice_antenna_gain = a_sle32_to_cpu(ev->twice_antenna_gain);
4228 tpc_stats->twice_antenna_reduction =
4229 __le32_to_cpu(ev->twice_antenna_reduction);
4230 tpc_stats->power_limit = __le32_to_cpu(ev->power_limit);
4231 tpc_stats->twice_max_rd_power = __le32_to_cpu(ev->twice_max_rd_power);
4232 tpc_stats->num_tx_chain = __le32_to_cpu(ev->num_tx_chain);
4233 tpc_stats->rate_max = __le32_to_cpu(ev->rate_max);
4234
4235 ath10k_tpc_config_disp_tables(ar, ev, tpc_stats,
4236 rate_code, pream_table,
4237 WMI_TPC_TABLE_TYPE_CDD);
4238 ath10k_tpc_config_disp_tables(ar, ev, tpc_stats,
4239 rate_code, pream_table,
4240 WMI_TPC_TABLE_TYPE_STBC);
4241 ath10k_tpc_config_disp_tables(ar, ev, tpc_stats,
4242 rate_code, pream_table,
4243 WMI_TPC_TABLE_TYPE_TXBF);
4244
4245 ath10k_debug_tpc_stats_process(ar, tpc_stats);
4246
4247 ath10k_dbg(ar, ATH10K_DBG_WMI,
4248 "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",
4249 __le32_to_cpu(ev->chan_freq),
4250 __le32_to_cpu(ev->phy_mode),
4251 __le32_to_cpu(ev->ctl),
4252 __le32_to_cpu(ev->reg_domain),
4253 a_sle32_to_cpu(ev->twice_antenna_gain),
4254 __le32_to_cpu(ev->twice_antenna_reduction),
4255 __le32_to_cpu(ev->power_limit),
4256 __le32_to_cpu(ev->twice_max_rd_power) / 2,
4257 __le32_to_cpu(ev->num_tx_chain),
4258 __le32_to_cpu(ev->rate_max));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004259}
4260
Michal Kazior0226d602014-12-03 10:11:22 +02004261void ath10k_wmi_event_pdev_ftm_intg(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004262{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004263 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_FTM_INTG_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004264}
4265
Michal Kazior0226d602014-12-03 10:11:22 +02004266void ath10k_wmi_event_gtk_offload_status(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004267{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004268 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_OFFLOAD_STATUS_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004269}
4270
Michal Kazior0226d602014-12-03 10:11:22 +02004271void ath10k_wmi_event_gtk_rekey_fail(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004272{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004273 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_REKEY_FAIL_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004274}
4275
Michal Kazior0226d602014-12-03 10:11:22 +02004276void ath10k_wmi_event_delba_complete(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004277{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004278 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_DELBA_COMPLETE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004279}
4280
Michal Kazior0226d602014-12-03 10:11:22 +02004281void ath10k_wmi_event_addba_complete(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004282{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004283 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_ADDBA_COMPLETE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004284}
4285
Michal Kazior0226d602014-12-03 10:11:22 +02004286void ath10k_wmi_event_vdev_install_key_complete(struct ath10k *ar,
4287 struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004288{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004289 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID\n");
Kalle Valo5e3dd152013-06-12 20:52:10 +03004290}
4291
Michal Kazior0226d602014-12-03 10:11:22 +02004292void ath10k_wmi_event_inst_rssi_stats(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004293{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004294 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_INST_RSSI_STATS_EVENTID\n");
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004295}
4296
Michal Kazior0226d602014-12-03 10:11:22 +02004297void ath10k_wmi_event_vdev_standby_req(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004298{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004299 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STANDBY_REQ_EVENTID\n");
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004300}
4301
Michal Kazior0226d602014-12-03 10:11:22 +02004302void ath10k_wmi_event_vdev_resume_req(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004303{
Michal Kazior7aa7a722014-08-25 12:09:38 +02004304 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_RESUME_REQ_EVENTID\n");
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004305}
4306
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004307static int ath10k_wmi_alloc_host_mem(struct ath10k *ar, u32 req_id,
Kalle Valo5b07e072014-09-14 12:50:06 +03004308 u32 num_units, u32 unit_len)
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004309{
4310 dma_addr_t paddr;
4311 u32 pool_size;
4312 int idx = ar->wmi.num_mem_chunks;
4313
4314 pool_size = num_units * round_up(unit_len, 4);
4315
4316 if (!pool_size)
4317 return -EINVAL;
4318
4319 ar->wmi.mem_chunks[idx].vaddr = dma_alloc_coherent(ar->dev,
4320 pool_size,
4321 &paddr,
Raja Manic8ecfc12015-07-29 11:40:38 +03004322 GFP_KERNEL);
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004323 if (!ar->wmi.mem_chunks[idx].vaddr) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02004324 ath10k_warn(ar, "failed to allocate memory chunk\n");
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004325 return -ENOMEM;
4326 }
4327
4328 memset(ar->wmi.mem_chunks[idx].vaddr, 0, pool_size);
4329
4330 ar->wmi.mem_chunks[idx].paddr = paddr;
4331 ar->wmi.mem_chunks[idx].len = pool_size;
4332 ar->wmi.mem_chunks[idx].req_id = req_id;
4333 ar->wmi.num_mem_chunks++;
4334
4335 return 0;
4336}
4337
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05304338static bool
4339ath10k_wmi_is_host_mem_allocated(struct ath10k *ar,
4340 const struct wlan_host_mem_req **mem_reqs,
4341 u32 num_mem_reqs)
4342{
4343 u32 req_id, num_units, unit_size, num_unit_info;
4344 u32 pool_size;
4345 int i, j;
4346 bool found;
4347
4348 if (ar->wmi.num_mem_chunks != num_mem_reqs)
4349 return false;
4350
4351 for (i = 0; i < num_mem_reqs; ++i) {
4352 req_id = __le32_to_cpu(mem_reqs[i]->req_id);
4353 num_units = __le32_to_cpu(mem_reqs[i]->num_units);
4354 unit_size = __le32_to_cpu(mem_reqs[i]->unit_size);
4355 num_unit_info = __le32_to_cpu(mem_reqs[i]->num_unit_info);
4356
4357 if (num_unit_info & NUM_UNITS_IS_NUM_ACTIVE_PEERS) {
4358 if (ar->num_active_peers)
4359 num_units = ar->num_active_peers + 1;
4360 else
4361 num_units = ar->max_num_peers + 1;
4362 } else if (num_unit_info & NUM_UNITS_IS_NUM_PEERS) {
4363 num_units = ar->max_num_peers + 1;
4364 } else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS) {
4365 num_units = ar->max_num_vdevs + 1;
4366 }
4367
4368 found = false;
4369 for (j = 0; j < ar->wmi.num_mem_chunks; j++) {
4370 if (ar->wmi.mem_chunks[j].req_id == req_id) {
4371 pool_size = num_units * round_up(unit_size, 4);
4372 if (ar->wmi.mem_chunks[j].len == pool_size) {
4373 found = true;
4374 break;
4375 }
4376 }
4377 }
4378 if (!found)
4379 return false;
4380 }
4381
4382 return true;
4383}
4384
Michal Kaziord7579d12014-12-03 10:10:54 +02004385static int
4386ath10k_wmi_main_op_pull_svc_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
4387 struct wmi_svc_rdy_ev_arg *arg)
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004388{
4389 struct wmi_service_ready_event *ev;
4390 size_t i, n;
4391
4392 if (skb->len < sizeof(*ev))
4393 return -EPROTO;
4394
4395 ev = (void *)skb->data;
4396 skb_pull(skb, sizeof(*ev));
4397 arg->min_tx_power = ev->hw_min_tx_power;
4398 arg->max_tx_power = ev->hw_max_tx_power;
4399 arg->ht_cap = ev->ht_cap_info;
4400 arg->vht_cap = ev->vht_cap_info;
4401 arg->sw_ver0 = ev->sw_version;
4402 arg->sw_ver1 = ev->sw_version_1;
4403 arg->phy_capab = ev->phy_capability;
4404 arg->num_rf_chains = ev->num_rf_chains;
4405 arg->eeprom_rd = ev->hal_reg_capabilities.eeprom_rd;
4406 arg->num_mem_reqs = ev->num_mem_reqs;
4407 arg->service_map = ev->wmi_service_bitmap;
Michal Kazior2a3e60d2014-11-27 10:11:15 +01004408 arg->service_map_len = sizeof(ev->wmi_service_bitmap);
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004409
4410 n = min_t(size_t, __le32_to_cpu(arg->num_mem_reqs),
4411 ARRAY_SIZE(arg->mem_reqs));
4412 for (i = 0; i < n; i++)
4413 arg->mem_reqs[i] = &ev->mem_reqs[i];
4414
4415 if (skb->len <
4416 __le32_to_cpu(arg->num_mem_reqs) * sizeof(arg->mem_reqs[0]))
4417 return -EPROTO;
4418
4419 return 0;
4420}
4421
Michal Kaziord7579d12014-12-03 10:10:54 +02004422static int
4423ath10k_wmi_10x_op_pull_svc_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
4424 struct wmi_svc_rdy_ev_arg *arg)
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004425{
4426 struct wmi_10x_service_ready_event *ev;
4427 int i, n;
4428
4429 if (skb->len < sizeof(*ev))
4430 return -EPROTO;
4431
4432 ev = (void *)skb->data;
4433 skb_pull(skb, sizeof(*ev));
4434 arg->min_tx_power = ev->hw_min_tx_power;
4435 arg->max_tx_power = ev->hw_max_tx_power;
4436 arg->ht_cap = ev->ht_cap_info;
4437 arg->vht_cap = ev->vht_cap_info;
4438 arg->sw_ver0 = ev->sw_version;
4439 arg->phy_capab = ev->phy_capability;
4440 arg->num_rf_chains = ev->num_rf_chains;
4441 arg->eeprom_rd = ev->hal_reg_capabilities.eeprom_rd;
4442 arg->num_mem_reqs = ev->num_mem_reqs;
4443 arg->service_map = ev->wmi_service_bitmap;
Michal Kazior2a3e60d2014-11-27 10:11:15 +01004444 arg->service_map_len = sizeof(ev->wmi_service_bitmap);
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004445
4446 n = min_t(size_t, __le32_to_cpu(arg->num_mem_reqs),
4447 ARRAY_SIZE(arg->mem_reqs));
4448 for (i = 0; i < n; i++)
4449 arg->mem_reqs[i] = &ev->mem_reqs[i];
4450
4451 if (skb->len <
4452 __le32_to_cpu(arg->num_mem_reqs) * sizeof(arg->mem_reqs[0]))
4453 return -EPROTO;
4454
4455 return 0;
4456}
4457
Raja Manic8ecfc12015-07-29 11:40:38 +03004458static void ath10k_wmi_event_service_ready_work(struct work_struct *work)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004459{
Raja Manic8ecfc12015-07-29 11:40:38 +03004460 struct ath10k *ar = container_of(work, struct ath10k, svc_rdy_work);
4461 struct sk_buff *skb = ar->svc_rdy_skb;
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004462 struct wmi_svc_rdy_ev_arg arg = {};
4463 u32 num_units, req_id, unit_size, num_mem_reqs, num_unit_info, i;
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004464 int ret;
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05304465 bool allocated;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004466
Raja Manic8ecfc12015-07-29 11:40:38 +03004467 if (!skb) {
4468 ath10k_warn(ar, "invalid service ready event skb\n");
4469 return;
4470 }
4471
Michal Kaziord7579d12014-12-03 10:10:54 +02004472 ret = ath10k_wmi_pull_svc_rdy(ar, skb, &arg);
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004473 if (ret) {
4474 ath10k_warn(ar, "failed to parse service ready: %d\n", ret);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004475 return;
4476 }
4477
Michal Kaziord7579d12014-12-03 10:10:54 +02004478 memset(&ar->wmi.svc_map, 0, sizeof(ar->wmi.svc_map));
4479 ath10k_wmi_map_svc(ar, arg.service_map, ar->wmi.svc_map,
4480 arg.service_map_len);
4481
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004482 ar->hw_min_tx_power = __le32_to_cpu(arg.min_tx_power);
4483 ar->hw_max_tx_power = __le32_to_cpu(arg.max_tx_power);
4484 ar->ht_cap_info = __le32_to_cpu(arg.ht_cap);
4485 ar->vht_cap_info = __le32_to_cpu(arg.vht_cap);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004486 ar->fw_version_major =
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004487 (__le32_to_cpu(arg.sw_ver0) & 0xff000000) >> 24;
4488 ar->fw_version_minor = (__le32_to_cpu(arg.sw_ver0) & 0x00ffffff);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004489 ar->fw_version_release =
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004490 (__le32_to_cpu(arg.sw_ver1) & 0xffff0000) >> 16;
4491 ar->fw_version_build = (__le32_to_cpu(arg.sw_ver1) & 0x0000ffff);
4492 ar->phy_capability = __le32_to_cpu(arg.phy_capab);
4493 ar->num_rf_chains = __le32_to_cpu(arg.num_rf_chains);
4494 ar->ath_common.regulatory.current_rd = __le32_to_cpu(arg.eeprom_rd);
4495
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004496 ath10k_dbg_dump(ar, ATH10K_DBG_WMI, NULL, "wmi svc: ",
Michal Kazior2a3e60d2014-11-27 10:11:15 +01004497 arg.service_map, arg.service_map_len);
Michal Kazior8865bee42013-07-24 12:36:46 +02004498
Kalle Valo1a222432013-09-27 19:55:07 +03004499 /* only manually set fw features when not using FW IE format */
4500 if (ar->fw_api == 1 && ar->fw_version_build > 636)
Michal Kazior0d9b0432013-08-09 10:13:33 +02004501 set_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features);
4502
Raja Mani5c8726e2015-06-22 20:22:26 +05304503 if (ar->num_rf_chains > ar->max_spatial_stream) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02004504 ath10k_warn(ar, "hardware advertises support for more spatial streams than it should (%d > %d)\n",
Raja Mani5c8726e2015-06-22 20:22:26 +05304505 ar->num_rf_chains, ar->max_spatial_stream);
4506 ar->num_rf_chains = ar->max_spatial_stream;
Michal Kazior8865bee42013-07-24 12:36:46 +02004507 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03004508
Rajkumar Manoharan166de3f2015-10-27 17:51:11 +05304509 if (!ar->cfg_tx_chainmask) {
4510 ar->cfg_tx_chainmask = (1 << ar->num_rf_chains) - 1;
4511 ar->cfg_rx_chainmask = (1 << ar->num_rf_chains) - 1;
4512 }
Michal Kaziorfdb959c2014-09-18 15:21:19 +02004513
Kalle Valo5e3dd152013-06-12 20:52:10 +03004514 if (strlen(ar->hw->wiphy->fw_version) == 0) {
4515 snprintf(ar->hw->wiphy->fw_version,
4516 sizeof(ar->hw->wiphy->fw_version),
4517 "%u.%u.%u.%u",
4518 ar->fw_version_major,
4519 ar->fw_version_minor,
4520 ar->fw_version_release,
4521 ar->fw_version_build);
4522 }
4523
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004524 num_mem_reqs = __le32_to_cpu(arg.num_mem_reqs);
4525 if (num_mem_reqs > WMI_MAX_MEM_REQS) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02004526 ath10k_warn(ar, "requested memory chunks number (%d) exceeds the limit\n",
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004527 num_mem_reqs);
4528 return;
Bartosz Markowski6f97d252013-09-26 17:47:09 +02004529 }
4530
Raja Manib0399412015-06-22 20:10:17 +05304531 if (test_bit(WMI_SERVICE_PEER_CACHING, ar->wmi.svc_map)) {
4532 ar->max_num_peers = TARGET_10_4_NUM_QCACHE_PEERS_MAX +
4533 TARGET_10_4_NUM_VDEVS;
4534 ar->num_active_peers = TARGET_10_4_QCACHE_ACTIVE_PEERS +
4535 TARGET_10_4_NUM_VDEVS;
4536 ar->num_tids = ar->num_active_peers * 2;
4537 ar->max_num_stations = TARGET_10_4_NUM_QCACHE_PEERS_MAX;
4538 }
4539
4540 /* TODO: Adjust max peer count for cases like WMI_SERVICE_RATECTRL_CACHE
4541 * and WMI_SERVICE_IRAM_TIDS, etc.
4542 */
4543
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05304544 allocated = ath10k_wmi_is_host_mem_allocated(ar, arg.mem_reqs,
4545 num_mem_reqs);
4546 if (allocated)
4547 goto skip_mem_alloc;
4548
4549 /* Either this event is received during boot time or there is a change
4550 * in memory requirement from firmware when compared to last request.
4551 * Free any old memory and do a fresh allocation based on the current
4552 * memory requirement.
4553 */
4554 ath10k_wmi_free_host_mem(ar);
4555
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004556 for (i = 0; i < num_mem_reqs; ++i) {
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004557 req_id = __le32_to_cpu(arg.mem_reqs[i]->req_id);
4558 num_units = __le32_to_cpu(arg.mem_reqs[i]->num_units);
4559 unit_size = __le32_to_cpu(arg.mem_reqs[i]->unit_size);
4560 num_unit_info = __le32_to_cpu(arg.mem_reqs[i]->num_unit_info);
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004561
Raja Manib0399412015-06-22 20:10:17 +05304562 if (num_unit_info & NUM_UNITS_IS_NUM_ACTIVE_PEERS) {
4563 if (ar->num_active_peers)
4564 num_units = ar->num_active_peers + 1;
4565 else
4566 num_units = ar->max_num_peers + 1;
4567 } else if (num_unit_info & NUM_UNITS_IS_NUM_PEERS) {
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004568 /* number of units to allocate is number of
4569 * peers, 1 extra for self peer on target */
4570 /* this needs to be tied, host and target
4571 * can get out of sync */
Raja Manib0399412015-06-22 20:10:17 +05304572 num_units = ar->max_num_peers + 1;
4573 } else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS) {
4574 num_units = ar->max_num_vdevs + 1;
4575 }
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004576
Michal Kazior7aa7a722014-08-25 12:09:38 +02004577 ath10k_dbg(ar, ATH10K_DBG_WMI,
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004578 "wmi mem_req_id %d num_units %d num_unit_info %d unit size %d actual units %d\n",
4579 req_id,
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004580 __le32_to_cpu(arg.mem_reqs[i]->num_units),
Bartosz Markowskib3effe62013-09-26 17:47:11 +02004581 num_unit_info,
4582 unit_size,
4583 num_units);
4584
4585 ret = ath10k_wmi_alloc_host_mem(ar, req_id, num_units,
4586 unit_size);
4587 if (ret)
4588 return;
4589 }
4590
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05304591skip_mem_alloc:
Michal Kazior7aa7a722014-08-25 12:09:38 +02004592 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kaziorca996ec2014-12-03 10:11:32 +02004593 "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 +02004594 __le32_to_cpu(arg.min_tx_power),
4595 __le32_to_cpu(arg.max_tx_power),
4596 __le32_to_cpu(arg.ht_cap),
4597 __le32_to_cpu(arg.vht_cap),
4598 __le32_to_cpu(arg.sw_ver0),
4599 __le32_to_cpu(arg.sw_ver1),
Michal Kaziorca996ec2014-12-03 10:11:32 +02004600 __le32_to_cpu(arg.fw_build),
Michal Kazior5c01aa3d2014-09-18 15:21:24 +02004601 __le32_to_cpu(arg.phy_capab),
4602 __le32_to_cpu(arg.num_rf_chains),
4603 __le32_to_cpu(arg.eeprom_rd),
4604 __le32_to_cpu(arg.num_mem_reqs));
Bartosz Markowski6f97d252013-09-26 17:47:09 +02004605
Raja Manic8ecfc12015-07-29 11:40:38 +03004606 dev_kfree_skb(skb);
4607 ar->svc_rdy_skb = NULL;
Bartosz Markowski6f97d252013-09-26 17:47:09 +02004608 complete(&ar->wmi.service_ready);
4609}
4610
Raja Manic8ecfc12015-07-29 11:40:38 +03004611void ath10k_wmi_event_service_ready(struct ath10k *ar, struct sk_buff *skb)
4612{
4613 ar->svc_rdy_skb = skb;
4614 queue_work(ar->workqueue_aux, &ar->svc_rdy_work);
4615}
4616
Michal Kaziord7579d12014-12-03 10:10:54 +02004617static int ath10k_wmi_op_pull_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
4618 struct wmi_rdy_ev_arg *arg)
Michal Kazior32653cf2014-12-03 10:10:26 +02004619{
4620 struct wmi_ready_event *ev = (void *)skb->data;
4621
4622 if (skb->len < sizeof(*ev))
4623 return -EPROTO;
4624
4625 skb_pull(skb, sizeof(*ev));
4626 arg->sw_version = ev->sw_version;
4627 arg->abi_version = ev->abi_version;
4628 arg->status = ev->status;
4629 arg->mac_addr = ev->mac_addr.addr;
4630
4631 return 0;
4632}
4633
Michal Kaziorc1a46542015-03-10 16:21:54 +02004634static int ath10k_wmi_op_pull_roam_ev(struct ath10k *ar, struct sk_buff *skb,
4635 struct wmi_roam_ev_arg *arg)
4636{
4637 struct wmi_roam_ev *ev = (void *)skb->data;
4638
4639 if (skb->len < sizeof(*ev))
4640 return -EPROTO;
4641
4642 skb_pull(skb, sizeof(*ev));
4643 arg->vdev_id = ev->vdev_id;
4644 arg->reason = ev->reason;
4645
4646 return 0;
4647}
4648
Michal Kazior0226d602014-12-03 10:11:22 +02004649int ath10k_wmi_event_ready(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004650{
Michal Kazior32653cf2014-12-03 10:10:26 +02004651 struct wmi_rdy_ev_arg arg = {};
4652 int ret;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004653
Michal Kaziord7579d12014-12-03 10:10:54 +02004654 ret = ath10k_wmi_pull_rdy(ar, skb, &arg);
Michal Kazior32653cf2014-12-03 10:10:26 +02004655 if (ret) {
4656 ath10k_warn(ar, "failed to parse ready event: %d\n", ret);
4657 return ret;
4658 }
Kalle Valo5e3dd152013-06-12 20:52:10 +03004659
Michal Kazior7aa7a722014-08-25 12:09:38 +02004660 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior32653cf2014-12-03 10:10:26 +02004661 "wmi event ready sw_version %u abi_version %u mac_addr %pM status %d\n",
4662 __le32_to_cpu(arg.sw_version),
4663 __le32_to_cpu(arg.abi_version),
4664 arg.mac_addr,
4665 __le32_to_cpu(arg.status));
Kalle Valo5e3dd152013-06-12 20:52:10 +03004666
Michal Kazior32653cf2014-12-03 10:10:26 +02004667 ether_addr_copy(ar->mac_addr, arg.mac_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004668 complete(&ar->wmi.unified_ready);
4669 return 0;
4670}
4671
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02004672static int ath10k_wmi_event_temperature(struct ath10k *ar, struct sk_buff *skb)
4673{
4674 const struct wmi_pdev_temperature_event *ev;
4675
4676 ev = (struct wmi_pdev_temperature_event *)skb->data;
4677 if (WARN_ON(skb->len < sizeof(*ev)))
4678 return -EPROTO;
4679
Rajkumar Manoharanac2953f2014-12-17 12:22:26 +02004680 ath10k_thermal_event_temperature(ar, __le32_to_cpu(ev->temperature));
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02004681 return 0;
4682}
4683
Michal Kaziord7579d12014-12-03 10:10:54 +02004684static void ath10k_wmi_op_rx(struct ath10k *ar, struct sk_buff *skb)
Kalle Valo5e3dd152013-06-12 20:52:10 +03004685{
4686 struct wmi_cmd_hdr *cmd_hdr;
4687 enum wmi_event_id id;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004688
4689 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
4690 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
4691
4692 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
Michal Kazior469d4792015-06-08 13:23:27 +02004693 goto out;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004694
Michal Kaziord35a6c12014-09-02 11:00:21 +03004695 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004696
4697 switch (id) {
4698 case WMI_MGMT_RX_EVENTID:
4699 ath10k_wmi_event_mgmt_rx(ar, skb);
4700 /* mgmt_rx() owns the skb now! */
4701 return;
4702 case WMI_SCAN_EVENTID:
4703 ath10k_wmi_event_scan(ar, skb);
4704 break;
4705 case WMI_CHAN_INFO_EVENTID:
4706 ath10k_wmi_event_chan_info(ar, skb);
4707 break;
4708 case WMI_ECHO_EVENTID:
4709 ath10k_wmi_event_echo(ar, skb);
4710 break;
4711 case WMI_DEBUG_MESG_EVENTID:
4712 ath10k_wmi_event_debug_mesg(ar, skb);
4713 break;
4714 case WMI_UPDATE_STATS_EVENTID:
4715 ath10k_wmi_event_update_stats(ar, skb);
4716 break;
4717 case WMI_VDEV_START_RESP_EVENTID:
4718 ath10k_wmi_event_vdev_start_resp(ar, skb);
4719 break;
4720 case WMI_VDEV_STOPPED_EVENTID:
4721 ath10k_wmi_event_vdev_stopped(ar, skb);
4722 break;
4723 case WMI_PEER_STA_KICKOUT_EVENTID:
4724 ath10k_wmi_event_peer_sta_kickout(ar, skb);
4725 break;
4726 case WMI_HOST_SWBA_EVENTID:
4727 ath10k_wmi_event_host_swba(ar, skb);
4728 break;
4729 case WMI_TBTTOFFSET_UPDATE_EVENTID:
4730 ath10k_wmi_event_tbttoffset_update(ar, skb);
4731 break;
4732 case WMI_PHYERR_EVENTID:
4733 ath10k_wmi_event_phyerr(ar, skb);
4734 break;
4735 case WMI_ROAM_EVENTID:
4736 ath10k_wmi_event_roam(ar, skb);
4737 break;
4738 case WMI_PROFILE_MATCH:
4739 ath10k_wmi_event_profile_match(ar, skb);
4740 break;
4741 case WMI_DEBUG_PRINT_EVENTID:
4742 ath10k_wmi_event_debug_print(ar, skb);
4743 break;
4744 case WMI_PDEV_QVIT_EVENTID:
4745 ath10k_wmi_event_pdev_qvit(ar, skb);
4746 break;
4747 case WMI_WLAN_PROFILE_DATA_EVENTID:
4748 ath10k_wmi_event_wlan_profile_data(ar, skb);
4749 break;
4750 case WMI_RTT_MEASUREMENT_REPORT_EVENTID:
4751 ath10k_wmi_event_rtt_measurement_report(ar, skb);
4752 break;
4753 case WMI_TSF_MEASUREMENT_REPORT_EVENTID:
4754 ath10k_wmi_event_tsf_measurement_report(ar, skb);
4755 break;
4756 case WMI_RTT_ERROR_REPORT_EVENTID:
4757 ath10k_wmi_event_rtt_error_report(ar, skb);
4758 break;
4759 case WMI_WOW_WAKEUP_HOST_EVENTID:
4760 ath10k_wmi_event_wow_wakeup_host(ar, skb);
4761 break;
4762 case WMI_DCS_INTERFERENCE_EVENTID:
4763 ath10k_wmi_event_dcs_interference(ar, skb);
4764 break;
4765 case WMI_PDEV_TPC_CONFIG_EVENTID:
4766 ath10k_wmi_event_pdev_tpc_config(ar, skb);
4767 break;
4768 case WMI_PDEV_FTM_INTG_EVENTID:
4769 ath10k_wmi_event_pdev_ftm_intg(ar, skb);
4770 break;
4771 case WMI_GTK_OFFLOAD_STATUS_EVENTID:
4772 ath10k_wmi_event_gtk_offload_status(ar, skb);
4773 break;
4774 case WMI_GTK_REKEY_FAIL_EVENTID:
4775 ath10k_wmi_event_gtk_rekey_fail(ar, skb);
4776 break;
4777 case WMI_TX_DELBA_COMPLETE_EVENTID:
4778 ath10k_wmi_event_delba_complete(ar, skb);
4779 break;
4780 case WMI_TX_ADDBA_COMPLETE_EVENTID:
4781 ath10k_wmi_event_addba_complete(ar, skb);
4782 break;
4783 case WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID:
4784 ath10k_wmi_event_vdev_install_key_complete(ar, skb);
4785 break;
4786 case WMI_SERVICE_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02004787 ath10k_wmi_event_service_ready(ar, skb);
Raja Manic8ecfc12015-07-29 11:40:38 +03004788 return;
Kalle Valo5e3dd152013-06-12 20:52:10 +03004789 case WMI_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02004790 ath10k_wmi_event_ready(ar, skb);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004791 break;
4792 default:
Michal Kazior7aa7a722014-08-25 12:09:38 +02004793 ath10k_warn(ar, "Unknown eventid: %d\n", id);
Kalle Valo5e3dd152013-06-12 20:52:10 +03004794 break;
4795 }
4796
Michal Kazior469d4792015-06-08 13:23:27 +02004797out:
Kalle Valo5e3dd152013-06-12 20:52:10 +03004798 dev_kfree_skb(skb);
4799}
4800
Michal Kaziord7579d12014-12-03 10:10:54 +02004801static void ath10k_wmi_10_1_op_rx(struct ath10k *ar, struct sk_buff *skb)
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004802{
4803 struct wmi_cmd_hdr *cmd_hdr;
4804 enum wmi_10x_event_id id;
Kalle Valo43d2a302014-09-10 18:23:30 +03004805 bool consumed;
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004806
4807 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
4808 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
4809
4810 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
Michal Kazior469d4792015-06-08 13:23:27 +02004811 goto out;
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004812
Michal Kaziord35a6c12014-09-02 11:00:21 +03004813 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004814
Kalle Valo43d2a302014-09-10 18:23:30 +03004815 consumed = ath10k_tm_event_wmi(ar, id, skb);
4816
4817 /* Ready event must be handled normally also in UTF mode so that we
4818 * know the UTF firmware has booted, others we are just bypass WMI
4819 * events to testmode.
4820 */
4821 if (consumed && id != WMI_10X_READY_EVENTID) {
4822 ath10k_dbg(ar, ATH10K_DBG_WMI,
4823 "wmi testmode consumed 0x%x\n", id);
4824 goto out;
4825 }
4826
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004827 switch (id) {
4828 case WMI_10X_MGMT_RX_EVENTID:
4829 ath10k_wmi_event_mgmt_rx(ar, skb);
4830 /* mgmt_rx() owns the skb now! */
4831 return;
4832 case WMI_10X_SCAN_EVENTID:
4833 ath10k_wmi_event_scan(ar, skb);
4834 break;
4835 case WMI_10X_CHAN_INFO_EVENTID:
4836 ath10k_wmi_event_chan_info(ar, skb);
4837 break;
4838 case WMI_10X_ECHO_EVENTID:
4839 ath10k_wmi_event_echo(ar, skb);
4840 break;
4841 case WMI_10X_DEBUG_MESG_EVENTID:
4842 ath10k_wmi_event_debug_mesg(ar, skb);
4843 break;
4844 case WMI_10X_UPDATE_STATS_EVENTID:
4845 ath10k_wmi_event_update_stats(ar, skb);
4846 break;
4847 case WMI_10X_VDEV_START_RESP_EVENTID:
4848 ath10k_wmi_event_vdev_start_resp(ar, skb);
4849 break;
4850 case WMI_10X_VDEV_STOPPED_EVENTID:
4851 ath10k_wmi_event_vdev_stopped(ar, skb);
4852 break;
4853 case WMI_10X_PEER_STA_KICKOUT_EVENTID:
4854 ath10k_wmi_event_peer_sta_kickout(ar, skb);
4855 break;
4856 case WMI_10X_HOST_SWBA_EVENTID:
4857 ath10k_wmi_event_host_swba(ar, skb);
4858 break;
4859 case WMI_10X_TBTTOFFSET_UPDATE_EVENTID:
4860 ath10k_wmi_event_tbttoffset_update(ar, skb);
4861 break;
4862 case WMI_10X_PHYERR_EVENTID:
4863 ath10k_wmi_event_phyerr(ar, skb);
4864 break;
4865 case WMI_10X_ROAM_EVENTID:
4866 ath10k_wmi_event_roam(ar, skb);
4867 break;
4868 case WMI_10X_PROFILE_MATCH:
4869 ath10k_wmi_event_profile_match(ar, skb);
4870 break;
4871 case WMI_10X_DEBUG_PRINT_EVENTID:
4872 ath10k_wmi_event_debug_print(ar, skb);
4873 break;
4874 case WMI_10X_PDEV_QVIT_EVENTID:
4875 ath10k_wmi_event_pdev_qvit(ar, skb);
4876 break;
4877 case WMI_10X_WLAN_PROFILE_DATA_EVENTID:
4878 ath10k_wmi_event_wlan_profile_data(ar, skb);
4879 break;
4880 case WMI_10X_RTT_MEASUREMENT_REPORT_EVENTID:
4881 ath10k_wmi_event_rtt_measurement_report(ar, skb);
4882 break;
4883 case WMI_10X_TSF_MEASUREMENT_REPORT_EVENTID:
4884 ath10k_wmi_event_tsf_measurement_report(ar, skb);
4885 break;
4886 case WMI_10X_RTT_ERROR_REPORT_EVENTID:
4887 ath10k_wmi_event_rtt_error_report(ar, skb);
4888 break;
4889 case WMI_10X_WOW_WAKEUP_HOST_EVENTID:
4890 ath10k_wmi_event_wow_wakeup_host(ar, skb);
4891 break;
4892 case WMI_10X_DCS_INTERFERENCE_EVENTID:
4893 ath10k_wmi_event_dcs_interference(ar, skb);
4894 break;
4895 case WMI_10X_PDEV_TPC_CONFIG_EVENTID:
4896 ath10k_wmi_event_pdev_tpc_config(ar, skb);
4897 break;
4898 case WMI_10X_INST_RSSI_STATS_EVENTID:
4899 ath10k_wmi_event_inst_rssi_stats(ar, skb);
4900 break;
4901 case WMI_10X_VDEV_STANDBY_REQ_EVENTID:
4902 ath10k_wmi_event_vdev_standby_req(ar, skb);
4903 break;
4904 case WMI_10X_VDEV_RESUME_REQ_EVENTID:
4905 ath10k_wmi_event_vdev_resume_req(ar, skb);
4906 break;
4907 case WMI_10X_SERVICE_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02004908 ath10k_wmi_event_service_ready(ar, skb);
Raja Manic8ecfc12015-07-29 11:40:38 +03004909 return;
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004910 case WMI_10X_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02004911 ath10k_wmi_event_ready(ar, skb);
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004912 break;
Kalle Valo43d2a302014-09-10 18:23:30 +03004913 case WMI_10X_PDEV_UTF_EVENTID:
4914 /* ignore utf events */
4915 break;
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004916 default:
Michal Kazior7aa7a722014-08-25 12:09:38 +02004917 ath10k_warn(ar, "Unknown eventid: %d\n", id);
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004918 break;
4919 }
4920
Kalle Valo43d2a302014-09-10 18:23:30 +03004921out:
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02004922 dev_kfree_skb(skb);
4923}
4924
Michal Kaziord7579d12014-12-03 10:10:54 +02004925static void ath10k_wmi_10_2_op_rx(struct ath10k *ar, struct sk_buff *skb)
Michal Kazior24c88f72014-07-25 13:32:17 +02004926{
4927 struct wmi_cmd_hdr *cmd_hdr;
4928 enum wmi_10_2_event_id id;
4929
4930 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
4931 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
4932
4933 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
Michal Kazior469d4792015-06-08 13:23:27 +02004934 goto out;
Michal Kazior24c88f72014-07-25 13:32:17 +02004935
Michal Kaziord35a6c12014-09-02 11:00:21 +03004936 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
Michal Kazior24c88f72014-07-25 13:32:17 +02004937
4938 switch (id) {
4939 case WMI_10_2_MGMT_RX_EVENTID:
4940 ath10k_wmi_event_mgmt_rx(ar, skb);
4941 /* mgmt_rx() owns the skb now! */
4942 return;
4943 case WMI_10_2_SCAN_EVENTID:
4944 ath10k_wmi_event_scan(ar, skb);
4945 break;
4946 case WMI_10_2_CHAN_INFO_EVENTID:
4947 ath10k_wmi_event_chan_info(ar, skb);
4948 break;
4949 case WMI_10_2_ECHO_EVENTID:
4950 ath10k_wmi_event_echo(ar, skb);
4951 break;
4952 case WMI_10_2_DEBUG_MESG_EVENTID:
4953 ath10k_wmi_event_debug_mesg(ar, skb);
4954 break;
4955 case WMI_10_2_UPDATE_STATS_EVENTID:
4956 ath10k_wmi_event_update_stats(ar, skb);
4957 break;
4958 case WMI_10_2_VDEV_START_RESP_EVENTID:
4959 ath10k_wmi_event_vdev_start_resp(ar, skb);
4960 break;
4961 case WMI_10_2_VDEV_STOPPED_EVENTID:
4962 ath10k_wmi_event_vdev_stopped(ar, skb);
4963 break;
4964 case WMI_10_2_PEER_STA_KICKOUT_EVENTID:
4965 ath10k_wmi_event_peer_sta_kickout(ar, skb);
4966 break;
4967 case WMI_10_2_HOST_SWBA_EVENTID:
4968 ath10k_wmi_event_host_swba(ar, skb);
4969 break;
4970 case WMI_10_2_TBTTOFFSET_UPDATE_EVENTID:
4971 ath10k_wmi_event_tbttoffset_update(ar, skb);
4972 break;
4973 case WMI_10_2_PHYERR_EVENTID:
4974 ath10k_wmi_event_phyerr(ar, skb);
4975 break;
4976 case WMI_10_2_ROAM_EVENTID:
4977 ath10k_wmi_event_roam(ar, skb);
4978 break;
4979 case WMI_10_2_PROFILE_MATCH:
4980 ath10k_wmi_event_profile_match(ar, skb);
4981 break;
4982 case WMI_10_2_DEBUG_PRINT_EVENTID:
4983 ath10k_wmi_event_debug_print(ar, skb);
4984 break;
4985 case WMI_10_2_PDEV_QVIT_EVENTID:
4986 ath10k_wmi_event_pdev_qvit(ar, skb);
4987 break;
4988 case WMI_10_2_WLAN_PROFILE_DATA_EVENTID:
4989 ath10k_wmi_event_wlan_profile_data(ar, skb);
4990 break;
4991 case WMI_10_2_RTT_MEASUREMENT_REPORT_EVENTID:
4992 ath10k_wmi_event_rtt_measurement_report(ar, skb);
4993 break;
4994 case WMI_10_2_TSF_MEASUREMENT_REPORT_EVENTID:
4995 ath10k_wmi_event_tsf_measurement_report(ar, skb);
4996 break;
4997 case WMI_10_2_RTT_ERROR_REPORT_EVENTID:
4998 ath10k_wmi_event_rtt_error_report(ar, skb);
4999 break;
5000 case WMI_10_2_WOW_WAKEUP_HOST_EVENTID:
5001 ath10k_wmi_event_wow_wakeup_host(ar, skb);
5002 break;
5003 case WMI_10_2_DCS_INTERFERENCE_EVENTID:
5004 ath10k_wmi_event_dcs_interference(ar, skb);
5005 break;
5006 case WMI_10_2_PDEV_TPC_CONFIG_EVENTID:
5007 ath10k_wmi_event_pdev_tpc_config(ar, skb);
5008 break;
5009 case WMI_10_2_INST_RSSI_STATS_EVENTID:
5010 ath10k_wmi_event_inst_rssi_stats(ar, skb);
5011 break;
5012 case WMI_10_2_VDEV_STANDBY_REQ_EVENTID:
5013 ath10k_wmi_event_vdev_standby_req(ar, skb);
5014 break;
5015 case WMI_10_2_VDEV_RESUME_REQ_EVENTID:
5016 ath10k_wmi_event_vdev_resume_req(ar, skb);
5017 break;
5018 case WMI_10_2_SERVICE_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02005019 ath10k_wmi_event_service_ready(ar, skb);
Raja Manic8ecfc12015-07-29 11:40:38 +03005020 return;
Michal Kazior24c88f72014-07-25 13:32:17 +02005021 case WMI_10_2_READY_EVENTID:
Michal Kaziorb34d2b32014-09-18 15:21:26 +02005022 ath10k_wmi_event_ready(ar, skb);
Michal Kazior24c88f72014-07-25 13:32:17 +02005023 break;
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02005024 case WMI_10_2_PDEV_TEMPERATURE_EVENTID:
5025 ath10k_wmi_event_temperature(ar, skb);
5026 break;
Michal Kazior24c88f72014-07-25 13:32:17 +02005027 case WMI_10_2_RTT_KEEPALIVE_EVENTID:
5028 case WMI_10_2_GPIO_INPUT_EVENTID:
5029 case WMI_10_2_PEER_RATECODE_LIST_EVENTID:
5030 case WMI_10_2_GENERIC_BUFFER_EVENTID:
5031 case WMI_10_2_MCAST_BUF_RELEASE_EVENTID:
5032 case WMI_10_2_MCAST_LIST_AGEOUT_EVENTID:
5033 case WMI_10_2_WDS_PEER_EVENTID:
Michal Kazior7aa7a722014-08-25 12:09:38 +02005034 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kazior24c88f72014-07-25 13:32:17 +02005035 "received event id %d not implemented\n", id);
5036 break;
5037 default:
Michal Kazior7aa7a722014-08-25 12:09:38 +02005038 ath10k_warn(ar, "Unknown eventid: %d\n", id);
Michal Kazior24c88f72014-07-25 13:32:17 +02005039 break;
5040 }
5041
Michal Kazior469d4792015-06-08 13:23:27 +02005042out:
Michal Kazior24c88f72014-07-25 13:32:17 +02005043 dev_kfree_skb(skb);
5044}
Bartosz Markowski8a6618b2013-09-26 17:47:08 +02005045
Raja Mani1c092962015-06-22 20:10:16 +05305046static void ath10k_wmi_10_4_op_rx(struct ath10k *ar, struct sk_buff *skb)
5047{
5048 struct wmi_cmd_hdr *cmd_hdr;
5049 enum wmi_10_4_event_id id;
5050
5051 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
5052 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
5053
5054 if (!skb_pull(skb, sizeof(struct wmi_cmd_hdr)))
5055 goto out;
5056
5057 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
5058
5059 switch (id) {
5060 case WMI_10_4_MGMT_RX_EVENTID:
5061 ath10k_wmi_event_mgmt_rx(ar, skb);
5062 /* mgmt_rx() owns the skb now! */
5063 return;
Raja Mani373b48c2015-06-22 20:22:22 +05305064 case WMI_10_4_ECHO_EVENTID:
5065 ath10k_wmi_event_echo(ar, skb);
5066 break;
5067 case WMI_10_4_DEBUG_MESG_EVENTID:
5068 ath10k_wmi_event_debug_mesg(ar, skb);
5069 break;
5070 case WMI_10_4_SERVICE_READY_EVENTID:
5071 ath10k_wmi_event_service_ready(ar, skb);
Raja Manic8ecfc12015-07-29 11:40:38 +03005072 return;
Raja Manib2297ba2015-06-22 20:22:23 +05305073 case WMI_10_4_SCAN_EVENTID:
5074 ath10k_wmi_event_scan(ar, skb);
5075 break;
5076 case WMI_10_4_CHAN_INFO_EVENTID:
5077 ath10k_wmi_event_chan_info(ar, skb);
5078 break;
Raja Mani2b0a2e02015-08-14 11:13:34 +03005079 case WMI_10_4_PHYERR_EVENTID:
5080 ath10k_wmi_event_phyerr(ar, skb);
5081 break;
Raja Manid02e7522015-06-22 20:10:18 +05305082 case WMI_10_4_READY_EVENTID:
5083 ath10k_wmi_event_ready(ar, skb);
5084 break;
Raja Mani373b48c2015-06-22 20:22:22 +05305085 case WMI_10_4_PEER_STA_KICKOUT_EVENTID:
5086 ath10k_wmi_event_peer_sta_kickout(ar, skb);
5087 break;
Raja Mani3cec3be2015-06-22 20:22:21 +05305088 case WMI_10_4_HOST_SWBA_EVENTID:
5089 ath10k_wmi_event_host_swba(ar, skb);
5090 break;
Raja Mani373b48c2015-06-22 20:22:22 +05305091 case WMI_10_4_TBTTOFFSET_UPDATE_EVENTID:
5092 ath10k_wmi_event_tbttoffset_update(ar, skb);
5093 break;
5094 case WMI_10_4_DEBUG_PRINT_EVENTID:
5095 ath10k_wmi_event_debug_print(ar, skb);
5096 break;
5097 case WMI_10_4_VDEV_START_RESP_EVENTID:
5098 ath10k_wmi_event_vdev_start_resp(ar, skb);
5099 break;
5100 case WMI_10_4_VDEV_STOPPED_EVENTID:
5101 ath10k_wmi_event_vdev_stopped(ar, skb);
5102 break;
5103 case WMI_10_4_WOW_WAKEUP_HOST_EVENTID:
5104 ath10k_dbg(ar, ATH10K_DBG_WMI,
5105 "received event id %d not implemented\n", id);
5106 break;
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02005107 case WMI_10_4_UPDATE_STATS_EVENTID:
5108 ath10k_wmi_event_update_stats(ar, skb);
5109 break;
Tamizh chelvam6dd46342015-10-31 11:20:32 +02005110 case WMI_10_4_PDEV_TEMPERATURE_EVENTID:
5111 ath10k_wmi_event_temperature(ar, skb);
5112 break;
Raja Mani1c092962015-06-22 20:10:16 +05305113 default:
5114 ath10k_warn(ar, "Unknown eventid: %d\n", id);
5115 break;
5116 }
5117
5118out:
5119 dev_kfree_skb(skb);
5120}
5121
Bartosz Markowskice428702013-09-26 17:47:05 +02005122static void ath10k_wmi_process_rx(struct ath10k *ar, struct sk_buff *skb)
5123{
Michal Kaziord7579d12014-12-03 10:10:54 +02005124 int ret;
5125
5126 ret = ath10k_wmi_rx(ar, skb);
5127 if (ret)
5128 ath10k_warn(ar, "failed to process wmi rx: %d\n", ret);
Bartosz Markowskice428702013-09-26 17:47:05 +02005129}
5130
Michal Kazior95bf21f2014-05-16 17:15:39 +03005131int ath10k_wmi_connect(struct ath10k *ar)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005132{
5133 int status;
5134 struct ath10k_htc_svc_conn_req conn_req;
5135 struct ath10k_htc_svc_conn_resp conn_resp;
5136
5137 memset(&conn_req, 0, sizeof(conn_req));
5138 memset(&conn_resp, 0, sizeof(conn_resp));
5139
5140 /* these fields are the same for all service endpoints */
5141 conn_req.ep_ops.ep_tx_complete = ath10k_wmi_htc_tx_complete;
5142 conn_req.ep_ops.ep_rx_complete = ath10k_wmi_process_rx;
Michal Kaziorbe8b3942013-09-13 14:16:54 +02005143 conn_req.ep_ops.ep_tx_credits = ath10k_wmi_op_ep_tx_credits;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005144
5145 /* connect to control service */
5146 conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL;
5147
Michal Kaziorcd003fa2013-07-05 16:15:13 +03005148 status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005149 if (status) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02005150 ath10k_warn(ar, "failed to connect to WMI CONTROL service status: %d\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +03005151 status);
5152 return status;
5153 }
5154
5155 ar->wmi.eid = conn_resp.eid;
5156 return 0;
5157}
5158
Michal Kaziord7579d12014-12-03 10:10:54 +02005159static struct sk_buff *
5160ath10k_wmi_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16 rd5g,
5161 u16 ctl2g, u16 ctl5g,
5162 enum wmi_dfs_region dfs_reg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005163{
5164 struct wmi_pdev_set_regdomain_cmd *cmd;
5165 struct sk_buff *skb;
5166
Michal Kazior7aa7a722014-08-25 12:09:38 +02005167 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005168 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005169 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005170
5171 cmd = (struct wmi_pdev_set_regdomain_cmd *)skb->data;
5172 cmd->reg_domain = __cpu_to_le32(rd);
5173 cmd->reg_domain_2G = __cpu_to_le32(rd2g);
5174 cmd->reg_domain_5G = __cpu_to_le32(rd5g);
5175 cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g);
5176 cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
5177
Michal Kazior7aa7a722014-08-25 12:09:38 +02005178 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005179 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x\n",
5180 rd, rd2g, rd5g, ctl2g, ctl5g);
Michal Kaziord7579d12014-12-03 10:10:54 +02005181 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005182}
5183
Michal Kaziord7579d12014-12-03 10:10:54 +02005184static struct sk_buff *
5185ath10k_wmi_10x_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16
5186 rd5g, u16 ctl2g, u16 ctl5g,
5187 enum wmi_dfs_region dfs_reg)
Marek Puzyniak821af6a2014-03-21 17:46:57 +02005188{
5189 struct wmi_pdev_set_regdomain_cmd_10x *cmd;
5190 struct sk_buff *skb;
5191
Michal Kazior7aa7a722014-08-25 12:09:38 +02005192 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Marek Puzyniak821af6a2014-03-21 17:46:57 +02005193 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005194 return ERR_PTR(-ENOMEM);
Marek Puzyniak821af6a2014-03-21 17:46:57 +02005195
5196 cmd = (struct wmi_pdev_set_regdomain_cmd_10x *)skb->data;
5197 cmd->reg_domain = __cpu_to_le32(rd);
5198 cmd->reg_domain_2G = __cpu_to_le32(rd2g);
5199 cmd->reg_domain_5G = __cpu_to_le32(rd5g);
5200 cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g);
5201 cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
5202 cmd->dfs_domain = __cpu_to_le32(dfs_reg);
5203
Michal Kazior7aa7a722014-08-25 12:09:38 +02005204 ath10k_dbg(ar, ATH10K_DBG_WMI,
Marek Puzyniak821af6a2014-03-21 17:46:57 +02005205 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x dfs_region %x\n",
5206 rd, rd2g, rd5g, ctl2g, ctl5g, dfs_reg);
Michal Kaziord7579d12014-12-03 10:10:54 +02005207 return skb;
Marek Puzyniak821af6a2014-03-21 17:46:57 +02005208}
5209
Michal Kaziord7579d12014-12-03 10:10:54 +02005210static struct sk_buff *
5211ath10k_wmi_op_gen_pdev_suspend(struct ath10k *ar, u32 suspend_opt)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005212{
5213 struct wmi_pdev_suspend_cmd *cmd;
5214 struct sk_buff *skb;
5215
Michal Kazior7aa7a722014-08-25 12:09:38 +02005216 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005217 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005218 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005219
5220 cmd = (struct wmi_pdev_suspend_cmd *)skb->data;
Marek Puzyniak00f54822014-02-10 17:14:24 +01005221 cmd->suspend_opt = __cpu_to_le32(suspend_opt);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005222
Michal Kaziord7579d12014-12-03 10:10:54 +02005223 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005224}
5225
Michal Kaziord7579d12014-12-03 10:10:54 +02005226static struct sk_buff *
5227ath10k_wmi_op_gen_pdev_resume(struct ath10k *ar)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005228{
5229 struct sk_buff *skb;
5230
Michal Kazior7aa7a722014-08-25 12:09:38 +02005231 skb = ath10k_wmi_alloc_skb(ar, 0);
Michal Kaziord7579d12014-12-03 10:10:54 +02005232 if (!skb)
5233 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005234
Michal Kaziord7579d12014-12-03 10:10:54 +02005235 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005236}
5237
Michal Kaziord7579d12014-12-03 10:10:54 +02005238static struct sk_buff *
5239ath10k_wmi_op_gen_pdev_set_param(struct ath10k *ar, u32 id, u32 value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005240{
5241 struct wmi_pdev_set_param_cmd *cmd;
5242 struct sk_buff *skb;
5243
Bartosz Markowski226a3392013-09-26 17:47:16 +02005244 if (id == WMI_PDEV_PARAM_UNSUPPORTED) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02005245 ath10k_warn(ar, "pdev param %d not supported by firmware\n",
5246 id);
Michal Kaziord7579d12014-12-03 10:10:54 +02005247 return ERR_PTR(-EOPNOTSUPP);
Bartosz Markowski226a3392013-09-26 17:47:16 +02005248 }
5249
Michal Kazior7aa7a722014-08-25 12:09:38 +02005250 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005251 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005252 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005253
5254 cmd = (struct wmi_pdev_set_param_cmd *)skb->data;
5255 cmd->param_id = __cpu_to_le32(id);
5256 cmd->param_value = __cpu_to_le32(value);
5257
Michal Kazior7aa7a722014-08-25 12:09:38 +02005258 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set param %d value %d\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +03005259 id, value);
Michal Kaziord7579d12014-12-03 10:10:54 +02005260 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005261}
5262
Michal Kazior0226d602014-12-03 10:11:22 +02005263void ath10k_wmi_put_host_mem_chunks(struct ath10k *ar,
5264 struct wmi_host_mem_chunks *chunks)
Michal Kaziorcf9fca82014-09-18 15:21:22 +02005265{
5266 struct host_memory_chunk *chunk;
5267 int i;
5268
5269 chunks->count = __cpu_to_le32(ar->wmi.num_mem_chunks);
5270
5271 for (i = 0; i < ar->wmi.num_mem_chunks; i++) {
5272 chunk = &chunks->items[i];
5273 chunk->ptr = __cpu_to_le32(ar->wmi.mem_chunks[i].paddr);
5274 chunk->size = __cpu_to_le32(ar->wmi.mem_chunks[i].len);
5275 chunk->req_id = __cpu_to_le32(ar->wmi.mem_chunks[i].req_id);
5276
5277 ath10k_dbg(ar, ATH10K_DBG_WMI,
5278 "wmi chunk %d len %d requested, addr 0x%llx\n",
5279 i,
5280 ar->wmi.mem_chunks[i].len,
5281 (unsigned long long)ar->wmi.mem_chunks[i].paddr);
5282 }
5283}
5284
Michal Kaziord7579d12014-12-03 10:10:54 +02005285static struct sk_buff *ath10k_wmi_op_gen_init(struct ath10k *ar)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005286{
5287 struct wmi_init_cmd *cmd;
5288 struct sk_buff *buf;
5289 struct wmi_resource_config config = {};
Bartosz Markowskib3effe62013-09-26 17:47:11 +02005290 u32 len, val;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005291
5292 config.num_vdevs = __cpu_to_le32(TARGET_NUM_VDEVS);
Michal Kaziorcfd10612014-11-25 15:16:05 +01005293 config.num_peers = __cpu_to_le32(TARGET_NUM_PEERS);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005294 config.num_offload_peers = __cpu_to_le32(TARGET_NUM_OFFLOAD_PEERS);
5295
5296 config.num_offload_reorder_bufs =
5297 __cpu_to_le32(TARGET_NUM_OFFLOAD_REORDER_BUFS);
5298
5299 config.num_peer_keys = __cpu_to_le32(TARGET_NUM_PEER_KEYS);
5300 config.num_tids = __cpu_to_le32(TARGET_NUM_TIDS);
5301 config.ast_skid_limit = __cpu_to_le32(TARGET_AST_SKID_LIMIT);
5302 config.tx_chain_mask = __cpu_to_le32(TARGET_TX_CHAIN_MASK);
5303 config.rx_chain_mask = __cpu_to_le32(TARGET_RX_CHAIN_MASK);
5304 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
5305 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
5306 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
5307 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_RX_TIMEOUT_HI_PRI);
David Liuccec9032015-07-24 20:25:32 +03005308 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005309 config.scan_max_pending_reqs =
5310 __cpu_to_le32(TARGET_SCAN_MAX_PENDING_REQS);
5311
5312 config.bmiss_offload_max_vdev =
5313 __cpu_to_le32(TARGET_BMISS_OFFLOAD_MAX_VDEV);
5314
5315 config.roam_offload_max_vdev =
5316 __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_VDEV);
5317
5318 config.roam_offload_max_ap_profiles =
5319 __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_AP_PROFILES);
5320
5321 config.num_mcast_groups = __cpu_to_le32(TARGET_NUM_MCAST_GROUPS);
5322 config.num_mcast_table_elems =
5323 __cpu_to_le32(TARGET_NUM_MCAST_TABLE_ELEMS);
5324
5325 config.mcast2ucast_mode = __cpu_to_le32(TARGET_MCAST2UCAST_MODE);
5326 config.tx_dbg_log_size = __cpu_to_le32(TARGET_TX_DBG_LOG_SIZE);
5327 config.num_wds_entries = __cpu_to_le32(TARGET_NUM_WDS_ENTRIES);
5328 config.dma_burst_size = __cpu_to_le32(TARGET_DMA_BURST_SIZE);
5329 config.mac_aggr_delim = __cpu_to_le32(TARGET_MAC_AGGR_DELIM);
5330
5331 val = TARGET_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
5332 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
5333
5334 config.vow_config = __cpu_to_le32(TARGET_VOW_CONFIG);
5335
5336 config.gtk_offload_max_vdev =
5337 __cpu_to_le32(TARGET_GTK_OFFLOAD_MAX_VDEV);
5338
5339 config.num_msdu_desc = __cpu_to_le32(TARGET_NUM_MSDU_DESC);
5340 config.max_frag_entries = __cpu_to_le32(TARGET_MAX_FRAG_ENTRIES);
5341
Bartosz Markowskib3effe62013-09-26 17:47:11 +02005342 len = sizeof(*cmd) +
5343 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5344
Michal Kazior7aa7a722014-08-25 12:09:38 +02005345 buf = ath10k_wmi_alloc_skb(ar, len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005346 if (!buf)
Michal Kaziord7579d12014-12-03 10:10:54 +02005347 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005348
5349 cmd = (struct wmi_init_cmd *)buf->data;
Bartosz Markowskib3effe62013-09-26 17:47:11 +02005350
Kalle Valo5e3dd152013-06-12 20:52:10 +03005351 memcpy(&cmd->resource_config, &config, sizeof(config));
Michal Kaziorcf9fca82014-09-18 15:21:22 +02005352 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005353
Michal Kazior7aa7a722014-08-25 12:09:38 +02005354 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02005355 return buf;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005356}
5357
Michal Kaziord7579d12014-12-03 10:10:54 +02005358static struct sk_buff *ath10k_wmi_10_1_op_gen_init(struct ath10k *ar)
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005359{
5360 struct wmi_init_cmd_10x *cmd;
5361 struct sk_buff *buf;
5362 struct wmi_resource_config_10x config = {};
5363 u32 len, val;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005364
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005365 config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS);
5366 config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS);
5367 config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS);
5368 config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS);
5369 config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT);
5370 config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK);
5371 config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK);
5372 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5373 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5374 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5375 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI);
David Liuccec9032015-07-24 20:25:32 +03005376 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005377 config.scan_max_pending_reqs =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005378 __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005379
5380 config.bmiss_offload_max_vdev =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005381 __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005382
5383 config.roam_offload_max_vdev =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005384 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005385
5386 config.roam_offload_max_ap_profiles =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005387 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005388
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005389 config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005390 config.num_mcast_table_elems =
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005391 __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005392
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005393 config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE);
5394 config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE);
5395 config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES);
5396 config.dma_burst_size = __cpu_to_le32(TARGET_10X_DMA_BURST_SIZE);
5397 config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005398
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005399 val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005400 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
5401
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005402 config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005403
Bartosz Markowskiec6a73f2013-09-26 17:47:14 +02005404 config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC);
5405 config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005406
5407 len = sizeof(*cmd) +
5408 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5409
Michal Kazior7aa7a722014-08-25 12:09:38 +02005410 buf = ath10k_wmi_alloc_skb(ar, len);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005411 if (!buf)
Michal Kaziord7579d12014-12-03 10:10:54 +02005412 return ERR_PTR(-ENOMEM);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005413
5414 cmd = (struct wmi_init_cmd_10x *)buf->data;
5415
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005416 memcpy(&cmd->resource_config, &config, sizeof(config));
Michal Kaziorcf9fca82014-09-18 15:21:22 +02005417 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005418
Michal Kazior7aa7a722014-08-25 12:09:38 +02005419 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10x\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02005420 return buf;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005421}
5422
Michal Kaziord7579d12014-12-03 10:10:54 +02005423static struct sk_buff *ath10k_wmi_10_2_op_gen_init(struct ath10k *ar)
Michal Kazior24c88f72014-07-25 13:32:17 +02005424{
5425 struct wmi_init_cmd_10_2 *cmd;
5426 struct sk_buff *buf;
5427 struct wmi_resource_config_10x config = {};
Sujith Manoharanb6c8e282015-01-12 12:30:02 +02005428 u32 len, val, features;
Michal Kazior24c88f72014-07-25 13:32:17 +02005429
5430 config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS);
5431 config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS);
5432 config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS);
5433 config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS);
5434 config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT);
5435 config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK);
5436 config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK);
5437 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5438 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5439 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5440 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI);
David Liuccec9032015-07-24 20:25:32 +03005441 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
Michal Kazior24c88f72014-07-25 13:32:17 +02005442
5443 config.scan_max_pending_reqs =
5444 __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS);
5445
5446 config.bmiss_offload_max_vdev =
5447 __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV);
5448
5449 config.roam_offload_max_vdev =
5450 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV);
5451
5452 config.roam_offload_max_ap_profiles =
5453 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES);
5454
5455 config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS);
5456 config.num_mcast_table_elems =
5457 __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS);
5458
5459 config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE);
5460 config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE);
5461 config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES);
Sujith Manoharanf6603ff2015-01-12 12:30:02 +02005462 config.dma_burst_size = __cpu_to_le32(TARGET_10_2_DMA_BURST_SIZE);
Michal Kazior24c88f72014-07-25 13:32:17 +02005463 config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM);
5464
5465 val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
5466 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
5467
5468 config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG);
5469
5470 config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC);
5471 config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES);
5472
5473 len = sizeof(*cmd) +
5474 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5475
Michal Kazior7aa7a722014-08-25 12:09:38 +02005476 buf = ath10k_wmi_alloc_skb(ar, len);
Michal Kazior24c88f72014-07-25 13:32:17 +02005477 if (!buf)
Michal Kaziord7579d12014-12-03 10:10:54 +02005478 return ERR_PTR(-ENOMEM);
Michal Kazior24c88f72014-07-25 13:32:17 +02005479
5480 cmd = (struct wmi_init_cmd_10_2 *)buf->data;
5481
Sujith Manoharanb6c8e282015-01-12 12:30:02 +02005482 features = WMI_10_2_RX_BATCH_MODE;
Yanbo Li844fa572015-10-31 11:07:21 +02005483
5484 if (test_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags) &&
5485 test_bit(WMI_SERVICE_COEX_GPIO, ar->wmi.svc_map))
Yanbo Lide0c7892015-04-15 15:28:08 +03005486 features |= WMI_10_2_COEX_GPIO;
Yanbo Li844fa572015-10-31 11:07:21 +02005487
Sujith Manoharanb6c8e282015-01-12 12:30:02 +02005488 cmd->resource_config.feature_mask = __cpu_to_le32(features);
5489
Michal Kazior24c88f72014-07-25 13:32:17 +02005490 memcpy(&cmd->resource_config.common, &config, sizeof(config));
Michal Kaziorcf9fca82014-09-18 15:21:22 +02005491 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
Michal Kazior24c88f72014-07-25 13:32:17 +02005492
Michal Kazior7aa7a722014-08-25 12:09:38 +02005493 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.2\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02005494 return buf;
Bartosz Markowski12b2b9e2013-09-26 17:47:13 +02005495}
5496
Raja Manid1e52a82015-06-22 20:10:15 +05305497static struct sk_buff *ath10k_wmi_10_4_op_gen_init(struct ath10k *ar)
5498{
5499 struct wmi_init_cmd_10_4 *cmd;
5500 struct sk_buff *buf;
5501 struct wmi_resource_config_10_4 config = {};
5502 u32 len;
5503
5504 config.num_vdevs = __cpu_to_le32(ar->max_num_vdevs);
5505 config.num_peers = __cpu_to_le32(ar->max_num_peers);
5506 config.num_active_peers = __cpu_to_le32(ar->num_active_peers);
5507 config.num_tids = __cpu_to_le32(ar->num_tids);
5508
5509 config.num_offload_peers = __cpu_to_le32(TARGET_10_4_NUM_OFFLOAD_PEERS);
5510 config.num_offload_reorder_buffs =
5511 __cpu_to_le32(TARGET_10_4_NUM_OFFLOAD_REORDER_BUFFS);
5512 config.num_peer_keys = __cpu_to_le32(TARGET_10_4_NUM_PEER_KEYS);
5513 config.ast_skid_limit = __cpu_to_le32(TARGET_10_4_AST_SKID_LIMIT);
5514 config.tx_chain_mask = __cpu_to_le32(TARGET_10_4_TX_CHAIN_MASK);
5515 config.rx_chain_mask = __cpu_to_le32(TARGET_10_4_RX_CHAIN_MASK);
5516
5517 config.rx_timeout_pri[0] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_LO_PRI);
5518 config.rx_timeout_pri[1] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_LO_PRI);
5519 config.rx_timeout_pri[2] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_LO_PRI);
5520 config.rx_timeout_pri[3] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_HI_PRI);
5521
Peter Ohbc27e8c2015-10-05 17:56:39 +03005522 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
Raja Manid1e52a82015-06-22 20:10:15 +05305523 config.scan_max_pending_req = __cpu_to_le32(TARGET_10_4_SCAN_MAX_REQS);
5524 config.bmiss_offload_max_vdev =
5525 __cpu_to_le32(TARGET_10_4_BMISS_OFFLOAD_MAX_VDEV);
5526 config.roam_offload_max_vdev =
5527 __cpu_to_le32(TARGET_10_4_ROAM_OFFLOAD_MAX_VDEV);
5528 config.roam_offload_max_ap_profiles =
5529 __cpu_to_le32(TARGET_10_4_ROAM_OFFLOAD_MAX_PROFILES);
5530 config.num_mcast_groups = __cpu_to_le32(TARGET_10_4_NUM_MCAST_GROUPS);
5531 config.num_mcast_table_elems =
5532 __cpu_to_le32(TARGET_10_4_NUM_MCAST_TABLE_ELEMS);
5533
5534 config.mcast2ucast_mode = __cpu_to_le32(TARGET_10_4_MCAST2UCAST_MODE);
5535 config.tx_dbg_log_size = __cpu_to_le32(TARGET_10_4_TX_DBG_LOG_SIZE);
5536 config.num_wds_entries = __cpu_to_le32(TARGET_10_4_NUM_WDS_ENTRIES);
5537 config.dma_burst_size = __cpu_to_le32(TARGET_10_4_DMA_BURST_SIZE);
5538 config.mac_aggr_delim = __cpu_to_le32(TARGET_10_4_MAC_AGGR_DELIM);
5539
5540 config.rx_skip_defrag_timeout_dup_detection_check =
5541 __cpu_to_le32(TARGET_10_4_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK);
5542
5543 config.vow_config = __cpu_to_le32(TARGET_10_4_VOW_CONFIG);
5544 config.gtk_offload_max_vdev =
5545 __cpu_to_le32(TARGET_10_4_GTK_OFFLOAD_MAX_VDEV);
5546 config.num_msdu_desc = __cpu_to_le32(TARGET_10_4_NUM_MSDU_DESC);
5547 config.max_frag_entries = __cpu_to_le32(TARGET_10_4_11AC_TX_MAX_FRAGS);
5548 config.max_peer_ext_stats =
5549 __cpu_to_le32(TARGET_10_4_MAX_PEER_EXT_STATS);
5550 config.smart_ant_cap = __cpu_to_le32(TARGET_10_4_SMART_ANT_CAP);
5551
5552 config.bk_minfree = __cpu_to_le32(TARGET_10_4_BK_MIN_FREE);
5553 config.be_minfree = __cpu_to_le32(TARGET_10_4_BE_MIN_FREE);
5554 config.vi_minfree = __cpu_to_le32(TARGET_10_4_VI_MIN_FREE);
5555 config.vo_minfree = __cpu_to_le32(TARGET_10_4_VO_MIN_FREE);
5556
5557 config.rx_batchmode = __cpu_to_le32(TARGET_10_4_RX_BATCH_MODE);
5558 config.tt_support =
5559 __cpu_to_le32(TARGET_10_4_THERMAL_THROTTLING_CONFIG);
5560 config.atf_config = __cpu_to_le32(TARGET_10_4_ATF_CONFIG);
5561 config.iphdr_pad_config = __cpu_to_le32(TARGET_10_4_IPHDR_PAD_CONFIG);
5562 config.qwrap_config = __cpu_to_le32(TARGET_10_4_QWRAP_CONFIG);
5563
5564 len = sizeof(*cmd) +
5565 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5566
5567 buf = ath10k_wmi_alloc_skb(ar, len);
5568 if (!buf)
5569 return ERR_PTR(-ENOMEM);
5570
5571 cmd = (struct wmi_init_cmd_10_4 *)buf->data;
5572 memcpy(&cmd->resource_config, &config, sizeof(config));
5573 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
5574
5575 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.4\n");
5576 return buf;
5577}
5578
Michal Kazior0226d602014-12-03 10:11:22 +02005579int ath10k_wmi_start_scan_verify(const struct wmi_start_scan_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005580{
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005581 if (arg->ie_len && !arg->ie)
5582 return -EINVAL;
5583 if (arg->n_channels && !arg->channels)
5584 return -EINVAL;
5585 if (arg->n_ssids && !arg->ssids)
5586 return -EINVAL;
5587 if (arg->n_bssids && !arg->bssids)
5588 return -EINVAL;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005589
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005590 if (arg->ie_len > WLAN_SCAN_PARAMS_MAX_IE_LEN)
5591 return -EINVAL;
5592 if (arg->n_channels > ARRAY_SIZE(arg->channels))
5593 return -EINVAL;
5594 if (arg->n_ssids > WLAN_SCAN_PARAMS_MAX_SSID)
5595 return -EINVAL;
5596 if (arg->n_bssids > WLAN_SCAN_PARAMS_MAX_BSSID)
5597 return -EINVAL;
5598
5599 return 0;
5600}
5601
5602static size_t
5603ath10k_wmi_start_scan_tlvs_len(const struct wmi_start_scan_arg *arg)
5604{
5605 int len = 0;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005606
5607 if (arg->ie_len) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03005608 len += sizeof(struct wmi_ie_data);
5609 len += roundup(arg->ie_len, 4);
5610 }
5611
5612 if (arg->n_channels) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03005613 len += sizeof(struct wmi_chan_list);
5614 len += sizeof(__le32) * arg->n_channels;
5615 }
5616
5617 if (arg->n_ssids) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03005618 len += sizeof(struct wmi_ssid_list);
5619 len += sizeof(struct wmi_ssid) * arg->n_ssids;
5620 }
5621
5622 if (arg->n_bssids) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03005623 len += sizeof(struct wmi_bssid_list);
5624 len += sizeof(struct wmi_mac_addr) * arg->n_bssids;
5625 }
5626
5627 return len;
5628}
5629
Michal Kazior0226d602014-12-03 10:11:22 +02005630void ath10k_wmi_put_start_scan_common(struct wmi_start_scan_common *cmn,
5631 const struct wmi_start_scan_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005632{
Kalle Valo5e3dd152013-06-12 20:52:10 +03005633 u32 scan_id;
5634 u32 scan_req_id;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005635
5636 scan_id = WMI_HOST_SCAN_REQ_ID_PREFIX;
5637 scan_id |= arg->scan_id;
5638
5639 scan_req_id = WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
5640 scan_req_id |= arg->scan_req_id;
5641
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005642 cmn->scan_id = __cpu_to_le32(scan_id);
5643 cmn->scan_req_id = __cpu_to_le32(scan_req_id);
5644 cmn->vdev_id = __cpu_to_le32(arg->vdev_id);
5645 cmn->scan_priority = __cpu_to_le32(arg->scan_priority);
5646 cmn->notify_scan_events = __cpu_to_le32(arg->notify_scan_events);
5647 cmn->dwell_time_active = __cpu_to_le32(arg->dwell_time_active);
5648 cmn->dwell_time_passive = __cpu_to_le32(arg->dwell_time_passive);
5649 cmn->min_rest_time = __cpu_to_le32(arg->min_rest_time);
5650 cmn->max_rest_time = __cpu_to_le32(arg->max_rest_time);
5651 cmn->repeat_probe_time = __cpu_to_le32(arg->repeat_probe_time);
5652 cmn->probe_spacing_time = __cpu_to_le32(arg->probe_spacing_time);
5653 cmn->idle_time = __cpu_to_le32(arg->idle_time);
5654 cmn->max_scan_time = __cpu_to_le32(arg->max_scan_time);
5655 cmn->probe_delay = __cpu_to_le32(arg->probe_delay);
5656 cmn->scan_ctrl_flags = __cpu_to_le32(arg->scan_ctrl_flags);
5657}
Kalle Valo5e3dd152013-06-12 20:52:10 +03005658
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005659static void
5660ath10k_wmi_put_start_scan_tlvs(struct wmi_start_scan_tlvs *tlvs,
5661 const struct wmi_start_scan_arg *arg)
5662{
5663 struct wmi_ie_data *ie;
5664 struct wmi_chan_list *channels;
5665 struct wmi_ssid_list *ssids;
5666 struct wmi_bssid_list *bssids;
5667 void *ptr = tlvs->tlvs;
5668 int i;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005669
5670 if (arg->n_channels) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005671 channels = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005672 channels->tag = __cpu_to_le32(WMI_CHAN_LIST_TAG);
5673 channels->num_chan = __cpu_to_le32(arg->n_channels);
5674
5675 for (i = 0; i < arg->n_channels; i++)
Michal Kazior24c88f72014-07-25 13:32:17 +02005676 channels->channel_list[i].freq =
5677 __cpu_to_le16(arg->channels[i]);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005678
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005679 ptr += sizeof(*channels);
5680 ptr += sizeof(__le32) * arg->n_channels;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005681 }
5682
5683 if (arg->n_ssids) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005684 ssids = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005685 ssids->tag = __cpu_to_le32(WMI_SSID_LIST_TAG);
5686 ssids->num_ssids = __cpu_to_le32(arg->n_ssids);
5687
5688 for (i = 0; i < arg->n_ssids; i++) {
5689 ssids->ssids[i].ssid_len =
5690 __cpu_to_le32(arg->ssids[i].len);
5691 memcpy(&ssids->ssids[i].ssid,
5692 arg->ssids[i].ssid,
5693 arg->ssids[i].len);
5694 }
5695
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005696 ptr += sizeof(*ssids);
5697 ptr += sizeof(struct wmi_ssid) * arg->n_ssids;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005698 }
5699
5700 if (arg->n_bssids) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005701 bssids = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005702 bssids->tag = __cpu_to_le32(WMI_BSSID_LIST_TAG);
5703 bssids->num_bssid = __cpu_to_le32(arg->n_bssids);
5704
5705 for (i = 0; i < arg->n_bssids; i++)
5706 memcpy(&bssids->bssid_list[i],
5707 arg->bssids[i].bssid,
5708 ETH_ALEN);
5709
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005710 ptr += sizeof(*bssids);
5711 ptr += sizeof(struct wmi_mac_addr) * arg->n_bssids;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005712 }
5713
5714 if (arg->ie_len) {
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005715 ie = ptr;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005716 ie->tag = __cpu_to_le32(WMI_IE_TAG);
5717 ie->ie_len = __cpu_to_le32(arg->ie_len);
5718 memcpy(ie->ie_data, arg->ie, arg->ie_len);
5719
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005720 ptr += sizeof(*ie);
5721 ptr += roundup(arg->ie_len, 4);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005722 }
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005723}
Kalle Valo5e3dd152013-06-12 20:52:10 +03005724
Michal Kaziord7579d12014-12-03 10:10:54 +02005725static struct sk_buff *
5726ath10k_wmi_op_gen_start_scan(struct ath10k *ar,
5727 const struct wmi_start_scan_arg *arg)
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005728{
Michal Kaziord7579d12014-12-03 10:10:54 +02005729 struct wmi_start_scan_cmd *cmd;
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005730 struct sk_buff *skb;
5731 size_t len;
5732 int ret;
5733
5734 ret = ath10k_wmi_start_scan_verify(arg);
5735 if (ret)
Michal Kaziord7579d12014-12-03 10:10:54 +02005736 return ERR_PTR(ret);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005737
Michal Kaziord7579d12014-12-03 10:10:54 +02005738 len = sizeof(*cmd) + ath10k_wmi_start_scan_tlvs_len(arg);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005739 skb = ath10k_wmi_alloc_skb(ar, len);
5740 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005741 return ERR_PTR(-ENOMEM);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005742
Michal Kaziord7579d12014-12-03 10:10:54 +02005743 cmd = (struct wmi_start_scan_cmd *)skb->data;
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005744
Michal Kaziord7579d12014-12-03 10:10:54 +02005745 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
5746 ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
Michal Kaziora6aa5da2014-09-18 15:21:27 +02005747
Michal Kaziord7579d12014-12-03 10:10:54 +02005748 cmd->burst_duration_ms = __cpu_to_le32(0);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005749
Michal Kazior7aa7a722014-08-25 12:09:38 +02005750 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi start scan\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02005751 return skb;
5752}
5753
5754static struct sk_buff *
5755ath10k_wmi_10x_op_gen_start_scan(struct ath10k *ar,
5756 const struct wmi_start_scan_arg *arg)
5757{
5758 struct wmi_10x_start_scan_cmd *cmd;
5759 struct sk_buff *skb;
5760 size_t len;
5761 int ret;
5762
5763 ret = ath10k_wmi_start_scan_verify(arg);
5764 if (ret)
5765 return ERR_PTR(ret);
5766
5767 len = sizeof(*cmd) + ath10k_wmi_start_scan_tlvs_len(arg);
5768 skb = ath10k_wmi_alloc_skb(ar, len);
5769 if (!skb)
5770 return ERR_PTR(-ENOMEM);
5771
5772 cmd = (struct wmi_10x_start_scan_cmd *)skb->data;
5773
5774 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
5775 ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
5776
5777 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi 10x start scan\n");
5778 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005779}
5780
5781void ath10k_wmi_start_scan_init(struct ath10k *ar,
5782 struct wmi_start_scan_arg *arg)
5783{
5784 /* setup commonly used values */
5785 arg->scan_req_id = 1;
5786 arg->scan_priority = WMI_SCAN_PRIORITY_LOW;
5787 arg->dwell_time_active = 50;
5788 arg->dwell_time_passive = 150;
5789 arg->min_rest_time = 50;
5790 arg->max_rest_time = 500;
5791 arg->repeat_probe_time = 0;
5792 arg->probe_spacing_time = 0;
5793 arg->idle_time = 0;
Bartosz Markowskic3228922013-10-02 08:48:52 +02005794 arg->max_scan_time = 20000;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005795 arg->probe_delay = 5;
5796 arg->notify_scan_events = WMI_SCAN_EVENT_STARTED
5797 | WMI_SCAN_EVENT_COMPLETED
5798 | WMI_SCAN_EVENT_BSS_CHANNEL
5799 | WMI_SCAN_EVENT_FOREIGN_CHANNEL
5800 | WMI_SCAN_EVENT_DEQUEUED;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005801 arg->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
5802 arg->n_bssids = 1;
5803 arg->bssids[0].bssid = "\xFF\xFF\xFF\xFF\xFF\xFF";
5804}
5805
Michal Kaziord7579d12014-12-03 10:10:54 +02005806static struct sk_buff *
5807ath10k_wmi_op_gen_stop_scan(struct ath10k *ar,
5808 const struct wmi_stop_scan_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005809{
5810 struct wmi_stop_scan_cmd *cmd;
5811 struct sk_buff *skb;
5812 u32 scan_id;
5813 u32 req_id;
5814
5815 if (arg->req_id > 0xFFF)
Michal Kaziord7579d12014-12-03 10:10:54 +02005816 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005817 if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF)
Michal Kaziord7579d12014-12-03 10:10:54 +02005818 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005819
Michal Kazior7aa7a722014-08-25 12:09:38 +02005820 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005821 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005822 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005823
5824 scan_id = arg->u.scan_id;
5825 scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX;
5826
5827 req_id = arg->req_id;
5828 req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
5829
5830 cmd = (struct wmi_stop_scan_cmd *)skb->data;
5831 cmd->req_type = __cpu_to_le32(arg->req_type);
5832 cmd->vdev_id = __cpu_to_le32(arg->u.vdev_id);
5833 cmd->scan_id = __cpu_to_le32(scan_id);
5834 cmd->scan_req_id = __cpu_to_le32(req_id);
5835
Michal Kazior7aa7a722014-08-25 12:09:38 +02005836 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005837 "wmi stop scan reqid %d req_type %d vdev/scan_id %d\n",
5838 arg->req_id, arg->req_type, arg->u.scan_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02005839 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005840}
5841
Michal Kaziord7579d12014-12-03 10:10:54 +02005842static struct sk_buff *
5843ath10k_wmi_op_gen_vdev_create(struct ath10k *ar, u32 vdev_id,
5844 enum wmi_vdev_type type,
5845 enum wmi_vdev_subtype subtype,
5846 const u8 macaddr[ETH_ALEN])
Kalle Valo5e3dd152013-06-12 20:52:10 +03005847{
5848 struct wmi_vdev_create_cmd *cmd;
5849 struct sk_buff *skb;
5850
Michal Kazior7aa7a722014-08-25 12:09:38 +02005851 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005852 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005853 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005854
5855 cmd = (struct wmi_vdev_create_cmd *)skb->data;
5856 cmd->vdev_id = __cpu_to_le32(vdev_id);
5857 cmd->vdev_type = __cpu_to_le32(type);
5858 cmd->vdev_subtype = __cpu_to_le32(subtype);
Kalle Valob25f32c2014-09-14 12:50:49 +03005859 ether_addr_copy(cmd->vdev_macaddr.addr, macaddr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005860
Michal Kazior7aa7a722014-08-25 12:09:38 +02005861 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005862 "WMI vdev create: id %d type %d subtype %d macaddr %pM\n",
5863 vdev_id, type, subtype, macaddr);
Michal Kaziord7579d12014-12-03 10:10:54 +02005864 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005865}
5866
Michal Kaziord7579d12014-12-03 10:10:54 +02005867static struct sk_buff *
5868ath10k_wmi_op_gen_vdev_delete(struct ath10k *ar, u32 vdev_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005869{
5870 struct wmi_vdev_delete_cmd *cmd;
5871 struct sk_buff *skb;
5872
Michal Kazior7aa7a722014-08-25 12:09:38 +02005873 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005874 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005875 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005876
5877 cmd = (struct wmi_vdev_delete_cmd *)skb->data;
5878 cmd->vdev_id = __cpu_to_le32(vdev_id);
5879
Michal Kazior7aa7a722014-08-25 12:09:38 +02005880 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005881 "WMI vdev delete id %d\n", vdev_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02005882 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005883}
5884
Michal Kaziord7579d12014-12-03 10:10:54 +02005885static struct sk_buff *
5886ath10k_wmi_op_gen_vdev_start(struct ath10k *ar,
5887 const struct wmi_vdev_start_request_arg *arg,
5888 bool restart)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005889{
5890 struct wmi_vdev_start_request_cmd *cmd;
5891 struct sk_buff *skb;
5892 const char *cmdname;
5893 u32 flags = 0;
5894
Kalle Valo5e3dd152013-06-12 20:52:10 +03005895 if (WARN_ON(arg->hidden_ssid && !arg->ssid))
Michal Kaziord7579d12014-12-03 10:10:54 +02005896 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005897 if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid)))
Michal Kaziord7579d12014-12-03 10:10:54 +02005898 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005899
Michal Kaziord7579d12014-12-03 10:10:54 +02005900 if (restart)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005901 cmdname = "restart";
5902 else
Michal Kaziord7579d12014-12-03 10:10:54 +02005903 cmdname = "start";
Kalle Valo5e3dd152013-06-12 20:52:10 +03005904
Michal Kazior7aa7a722014-08-25 12:09:38 +02005905 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005906 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005907 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005908
5909 if (arg->hidden_ssid)
5910 flags |= WMI_VDEV_START_HIDDEN_SSID;
5911 if (arg->pmf_enabled)
5912 flags |= WMI_VDEV_START_PMF_ENABLED;
5913
5914 cmd = (struct wmi_vdev_start_request_cmd *)skb->data;
5915 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
5916 cmd->disable_hw_ack = __cpu_to_le32(arg->disable_hw_ack);
5917 cmd->beacon_interval = __cpu_to_le32(arg->bcn_intval);
5918 cmd->dtim_period = __cpu_to_le32(arg->dtim_period);
5919 cmd->flags = __cpu_to_le32(flags);
5920 cmd->bcn_tx_rate = __cpu_to_le32(arg->bcn_tx_rate);
5921 cmd->bcn_tx_power = __cpu_to_le32(arg->bcn_tx_power);
5922
5923 if (arg->ssid) {
5924 cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len);
5925 memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len);
5926 }
5927
Michal Kazior2d667212014-09-18 15:21:21 +02005928 ath10k_wmi_put_wmi_channel(&cmd->chan, &arg->channel);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005929
Michal Kazior7aa7a722014-08-25 12:09:38 +02005930 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo8cc7f262014-09-14 12:50:39 +03005931 "wmi vdev %s id 0x%x flags: 0x%0X, freq %d, mode %d, ch_flags: 0x%0X, max_power: %d\n",
5932 cmdname, arg->vdev_id,
Marek Puzyniake8a50f82013-11-20 09:59:47 +02005933 flags, arg->channel.freq, arg->channel.mode,
5934 cmd->chan.flags, arg->channel.max_power);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005935
Michal Kaziord7579d12014-12-03 10:10:54 +02005936 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005937}
5938
Michal Kaziord7579d12014-12-03 10:10:54 +02005939static struct sk_buff *
5940ath10k_wmi_op_gen_vdev_stop(struct ath10k *ar, u32 vdev_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005941{
5942 struct wmi_vdev_stop_cmd *cmd;
5943 struct sk_buff *skb;
5944
Michal Kazior7aa7a722014-08-25 12:09:38 +02005945 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005946 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005947 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005948
5949 cmd = (struct wmi_vdev_stop_cmd *)skb->data;
5950 cmd->vdev_id = __cpu_to_le32(vdev_id);
5951
Michal Kazior7aa7a722014-08-25 12:09:38 +02005952 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi vdev stop id 0x%x\n", vdev_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02005953 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005954}
5955
Michal Kaziord7579d12014-12-03 10:10:54 +02005956static struct sk_buff *
5957ath10k_wmi_op_gen_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid,
5958 const u8 *bssid)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005959{
5960 struct wmi_vdev_up_cmd *cmd;
5961 struct sk_buff *skb;
5962
Michal Kazior7aa7a722014-08-25 12:09:38 +02005963 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005964 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005965 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005966
5967 cmd = (struct wmi_vdev_up_cmd *)skb->data;
5968 cmd->vdev_id = __cpu_to_le32(vdev_id);
5969 cmd->vdev_assoc_id = __cpu_to_le32(aid);
Kalle Valob25f32c2014-09-14 12:50:49 +03005970 ether_addr_copy(cmd->vdev_bssid.addr, bssid);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005971
Michal Kazior7aa7a722014-08-25 12:09:38 +02005972 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005973 "wmi mgmt vdev up id 0x%x assoc id %d bssid %pM\n",
5974 vdev_id, aid, bssid);
Michal Kaziord7579d12014-12-03 10:10:54 +02005975 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005976}
5977
Michal Kaziord7579d12014-12-03 10:10:54 +02005978static struct sk_buff *
5979ath10k_wmi_op_gen_vdev_down(struct ath10k *ar, u32 vdev_id)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005980{
5981 struct wmi_vdev_down_cmd *cmd;
5982 struct sk_buff *skb;
5983
Michal Kazior7aa7a722014-08-25 12:09:38 +02005984 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03005985 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02005986 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03005987
5988 cmd = (struct wmi_vdev_down_cmd *)skb->data;
5989 cmd->vdev_id = __cpu_to_le32(vdev_id);
5990
Michal Kazior7aa7a722014-08-25 12:09:38 +02005991 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03005992 "wmi mgmt vdev down id 0x%x\n", vdev_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02005993 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03005994}
5995
Michal Kaziord7579d12014-12-03 10:10:54 +02005996static struct sk_buff *
5997ath10k_wmi_op_gen_vdev_set_param(struct ath10k *ar, u32 vdev_id,
5998 u32 param_id, u32 param_value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03005999{
6000 struct wmi_vdev_set_param_cmd *cmd;
6001 struct sk_buff *skb;
6002
Bartosz Markowski6d1506e2013-09-26 17:47:15 +02006003 if (param_id == WMI_VDEV_PARAM_UNSUPPORTED) {
Michal Kazior7aa7a722014-08-25 12:09:38 +02006004 ath10k_dbg(ar, ATH10K_DBG_WMI,
Bartosz Markowski6d1506e2013-09-26 17:47:15 +02006005 "vdev param %d not supported by firmware\n",
6006 param_id);
Michal Kaziord7579d12014-12-03 10:10:54 +02006007 return ERR_PTR(-EOPNOTSUPP);
Bartosz Markowski6d1506e2013-09-26 17:47:15 +02006008 }
6009
Michal Kazior7aa7a722014-08-25 12:09:38 +02006010 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006011 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006012 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006013
6014 cmd = (struct wmi_vdev_set_param_cmd *)skb->data;
6015 cmd->vdev_id = __cpu_to_le32(vdev_id);
6016 cmd->param_id = __cpu_to_le32(param_id);
6017 cmd->param_value = __cpu_to_le32(param_value);
6018
Michal Kazior7aa7a722014-08-25 12:09:38 +02006019 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006020 "wmi vdev id 0x%x set param %d value %d\n",
6021 vdev_id, param_id, param_value);
Michal Kaziord7579d12014-12-03 10:10:54 +02006022 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006023}
6024
Michal Kaziord7579d12014-12-03 10:10:54 +02006025static struct sk_buff *
6026ath10k_wmi_op_gen_vdev_install_key(struct ath10k *ar,
6027 const struct wmi_vdev_install_key_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006028{
6029 struct wmi_vdev_install_key_cmd *cmd;
6030 struct sk_buff *skb;
6031
6032 if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL)
Michal Kaziord7579d12014-12-03 10:10:54 +02006033 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006034 if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL)
Michal Kaziord7579d12014-12-03 10:10:54 +02006035 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006036
Michal Kazior7aa7a722014-08-25 12:09:38 +02006037 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd) + arg->key_len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006038 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006039 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006040
6041 cmd = (struct wmi_vdev_install_key_cmd *)skb->data;
6042 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
6043 cmd->key_idx = __cpu_to_le32(arg->key_idx);
6044 cmd->key_flags = __cpu_to_le32(arg->key_flags);
6045 cmd->key_cipher = __cpu_to_le32(arg->key_cipher);
6046 cmd->key_len = __cpu_to_le32(arg->key_len);
6047 cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len);
6048 cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len);
6049
6050 if (arg->macaddr)
Kalle Valob25f32c2014-09-14 12:50:49 +03006051 ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006052 if (arg->key_data)
6053 memcpy(cmd->key_data, arg->key_data, arg->key_len);
6054
Michal Kazior7aa7a722014-08-25 12:09:38 +02006055 ath10k_dbg(ar, ATH10K_DBG_WMI,
Michal Kaziore0c508a2013-07-05 16:15:17 +03006056 "wmi vdev install key idx %d cipher %d len %d\n",
6057 arg->key_idx, arg->key_cipher, arg->key_len);
Michal Kaziord7579d12014-12-03 10:10:54 +02006058 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006059}
6060
Michal Kaziord7579d12014-12-03 10:10:54 +02006061static struct sk_buff *
6062ath10k_wmi_op_gen_vdev_spectral_conf(struct ath10k *ar,
6063 const struct wmi_vdev_spectral_conf_arg *arg)
Simon Wunderlich855aed12014-08-02 09:12:54 +03006064{
6065 struct wmi_vdev_spectral_conf_cmd *cmd;
6066 struct sk_buff *skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03006067
Michal Kazior7aa7a722014-08-25 12:09:38 +02006068 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Simon Wunderlich855aed12014-08-02 09:12:54 +03006069 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006070 return ERR_PTR(-ENOMEM);
Simon Wunderlich855aed12014-08-02 09:12:54 +03006071
6072 cmd = (struct wmi_vdev_spectral_conf_cmd *)skb->data;
6073 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
6074 cmd->scan_count = __cpu_to_le32(arg->scan_count);
6075 cmd->scan_period = __cpu_to_le32(arg->scan_period);
6076 cmd->scan_priority = __cpu_to_le32(arg->scan_priority);
6077 cmd->scan_fft_size = __cpu_to_le32(arg->scan_fft_size);
6078 cmd->scan_gc_ena = __cpu_to_le32(arg->scan_gc_ena);
6079 cmd->scan_restart_ena = __cpu_to_le32(arg->scan_restart_ena);
6080 cmd->scan_noise_floor_ref = __cpu_to_le32(arg->scan_noise_floor_ref);
6081 cmd->scan_init_delay = __cpu_to_le32(arg->scan_init_delay);
6082 cmd->scan_nb_tone_thr = __cpu_to_le32(arg->scan_nb_tone_thr);
6083 cmd->scan_str_bin_thr = __cpu_to_le32(arg->scan_str_bin_thr);
6084 cmd->scan_wb_rpt_mode = __cpu_to_le32(arg->scan_wb_rpt_mode);
6085 cmd->scan_rssi_rpt_mode = __cpu_to_le32(arg->scan_rssi_rpt_mode);
6086 cmd->scan_rssi_thr = __cpu_to_le32(arg->scan_rssi_thr);
6087 cmd->scan_pwr_format = __cpu_to_le32(arg->scan_pwr_format);
6088 cmd->scan_rpt_mode = __cpu_to_le32(arg->scan_rpt_mode);
6089 cmd->scan_bin_scale = __cpu_to_le32(arg->scan_bin_scale);
6090 cmd->scan_dbm_adj = __cpu_to_le32(arg->scan_dbm_adj);
6091 cmd->scan_chn_mask = __cpu_to_le32(arg->scan_chn_mask);
6092
Michal Kaziord7579d12014-12-03 10:10:54 +02006093 return skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03006094}
6095
Michal Kaziord7579d12014-12-03 10:10:54 +02006096static struct sk_buff *
6097ath10k_wmi_op_gen_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id,
6098 u32 trigger, u32 enable)
Simon Wunderlich855aed12014-08-02 09:12:54 +03006099{
6100 struct wmi_vdev_spectral_enable_cmd *cmd;
6101 struct sk_buff *skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03006102
Michal Kazior7aa7a722014-08-25 12:09:38 +02006103 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Simon Wunderlich855aed12014-08-02 09:12:54 +03006104 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006105 return ERR_PTR(-ENOMEM);
Simon Wunderlich855aed12014-08-02 09:12:54 +03006106
6107 cmd = (struct wmi_vdev_spectral_enable_cmd *)skb->data;
6108 cmd->vdev_id = __cpu_to_le32(vdev_id);
6109 cmd->trigger_cmd = __cpu_to_le32(trigger);
6110 cmd->enable_cmd = __cpu_to_le32(enable);
6111
Michal Kaziord7579d12014-12-03 10:10:54 +02006112 return skb;
Simon Wunderlich855aed12014-08-02 09:12:54 +03006113}
6114
Michal Kaziord7579d12014-12-03 10:10:54 +02006115static struct sk_buff *
6116ath10k_wmi_op_gen_peer_create(struct ath10k *ar, u32 vdev_id,
Marek Puzyniak7390ed32015-03-30 09:51:52 +03006117 const u8 peer_addr[ETH_ALEN],
6118 enum wmi_peer_type peer_type)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006119{
6120 struct wmi_peer_create_cmd *cmd;
6121 struct sk_buff *skb;
6122
Michal Kazior7aa7a722014-08-25 12:09:38 +02006123 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006124 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006125 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006126
6127 cmd = (struct wmi_peer_create_cmd *)skb->data;
6128 cmd->vdev_id = __cpu_to_le32(vdev_id);
Kalle Valob25f32c2014-09-14 12:50:49 +03006129 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006130
Michal Kazior7aa7a722014-08-25 12:09:38 +02006131 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006132 "wmi peer create vdev_id %d peer_addr %pM\n",
6133 vdev_id, peer_addr);
Michal Kaziord7579d12014-12-03 10:10:54 +02006134 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006135}
6136
Michal Kaziord7579d12014-12-03 10:10:54 +02006137static struct sk_buff *
6138ath10k_wmi_op_gen_peer_delete(struct ath10k *ar, u32 vdev_id,
6139 const u8 peer_addr[ETH_ALEN])
Kalle Valo5e3dd152013-06-12 20:52:10 +03006140{
6141 struct wmi_peer_delete_cmd *cmd;
6142 struct sk_buff *skb;
6143
Michal Kazior7aa7a722014-08-25 12:09:38 +02006144 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006145 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006146 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006147
6148 cmd = (struct wmi_peer_delete_cmd *)skb->data;
6149 cmd->vdev_id = __cpu_to_le32(vdev_id);
Kalle Valob25f32c2014-09-14 12:50:49 +03006150 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006151
Michal Kazior7aa7a722014-08-25 12:09:38 +02006152 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006153 "wmi peer delete vdev_id %d peer_addr %pM\n",
6154 vdev_id, peer_addr);
Michal Kaziord7579d12014-12-03 10:10:54 +02006155 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006156}
6157
Michal Kaziord7579d12014-12-03 10:10:54 +02006158static struct sk_buff *
6159ath10k_wmi_op_gen_peer_flush(struct ath10k *ar, u32 vdev_id,
6160 const u8 peer_addr[ETH_ALEN], u32 tid_bitmap)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006161{
6162 struct wmi_peer_flush_tids_cmd *cmd;
6163 struct sk_buff *skb;
6164
Michal Kazior7aa7a722014-08-25 12:09:38 +02006165 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006166 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006167 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006168
6169 cmd = (struct wmi_peer_flush_tids_cmd *)skb->data;
6170 cmd->vdev_id = __cpu_to_le32(vdev_id);
6171 cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap);
Kalle Valob25f32c2014-09-14 12:50:49 +03006172 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006173
Michal Kazior7aa7a722014-08-25 12:09:38 +02006174 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006175 "wmi peer flush vdev_id %d peer_addr %pM tids %08x\n",
6176 vdev_id, peer_addr, tid_bitmap);
Michal Kaziord7579d12014-12-03 10:10:54 +02006177 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006178}
6179
Michal Kaziord7579d12014-12-03 10:10:54 +02006180static struct sk_buff *
6181ath10k_wmi_op_gen_peer_set_param(struct ath10k *ar, u32 vdev_id,
6182 const u8 *peer_addr,
6183 enum wmi_peer_param param_id,
6184 u32 param_value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006185{
6186 struct wmi_peer_set_param_cmd *cmd;
6187 struct sk_buff *skb;
6188
Michal Kazior7aa7a722014-08-25 12:09:38 +02006189 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006190 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006191 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006192
6193 cmd = (struct wmi_peer_set_param_cmd *)skb->data;
6194 cmd->vdev_id = __cpu_to_le32(vdev_id);
6195 cmd->param_id = __cpu_to_le32(param_id);
6196 cmd->param_value = __cpu_to_le32(param_value);
Kalle Valob25f32c2014-09-14 12:50:49 +03006197 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006198
Michal Kazior7aa7a722014-08-25 12:09:38 +02006199 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006200 "wmi vdev %d peer 0x%pM set param %d value %d\n",
6201 vdev_id, peer_addr, param_id, param_value);
Michal Kaziord7579d12014-12-03 10:10:54 +02006202 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006203}
6204
Michal Kaziord7579d12014-12-03 10:10:54 +02006205static struct sk_buff *
6206ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
6207 enum wmi_sta_ps_mode psmode)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006208{
6209 struct wmi_sta_powersave_mode_cmd *cmd;
6210 struct sk_buff *skb;
6211
Michal Kazior7aa7a722014-08-25 12:09:38 +02006212 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006213 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006214 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006215
6216 cmd = (struct wmi_sta_powersave_mode_cmd *)skb->data;
6217 cmd->vdev_id = __cpu_to_le32(vdev_id);
6218 cmd->sta_ps_mode = __cpu_to_le32(psmode);
6219
Michal Kazior7aa7a722014-08-25 12:09:38 +02006220 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006221 "wmi set powersave id 0x%x mode %d\n",
6222 vdev_id, psmode);
Michal Kaziord7579d12014-12-03 10:10:54 +02006223 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006224}
6225
Michal Kaziord7579d12014-12-03 10:10:54 +02006226static struct sk_buff *
6227ath10k_wmi_op_gen_set_sta_ps(struct ath10k *ar, u32 vdev_id,
6228 enum wmi_sta_powersave_param param_id,
6229 u32 value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006230{
6231 struct wmi_sta_powersave_param_cmd *cmd;
6232 struct sk_buff *skb;
6233
Michal Kazior7aa7a722014-08-25 12:09:38 +02006234 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006235 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006236 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006237
6238 cmd = (struct wmi_sta_powersave_param_cmd *)skb->data;
6239 cmd->vdev_id = __cpu_to_le32(vdev_id);
6240 cmd->param_id = __cpu_to_le32(param_id);
6241 cmd->param_value = __cpu_to_le32(value);
6242
Michal Kazior7aa7a722014-08-25 12:09:38 +02006243 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006244 "wmi sta ps param vdev_id 0x%x param %d value %d\n",
6245 vdev_id, param_id, value);
Michal Kaziord7579d12014-12-03 10:10:54 +02006246 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006247}
6248
Michal Kaziord7579d12014-12-03 10:10:54 +02006249static struct sk_buff *
6250ath10k_wmi_op_gen_set_ap_ps(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6251 enum wmi_ap_ps_peer_param param_id, u32 value)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006252{
6253 struct wmi_ap_ps_peer_cmd *cmd;
6254 struct sk_buff *skb;
6255
6256 if (!mac)
Michal Kaziord7579d12014-12-03 10:10:54 +02006257 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006258
Michal Kazior7aa7a722014-08-25 12:09:38 +02006259 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006260 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006261 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006262
6263 cmd = (struct wmi_ap_ps_peer_cmd *)skb->data;
6264 cmd->vdev_id = __cpu_to_le32(vdev_id);
6265 cmd->param_id = __cpu_to_le32(param_id);
6266 cmd->param_value = __cpu_to_le32(value);
Kalle Valob25f32c2014-09-14 12:50:49 +03006267 ether_addr_copy(cmd->peer_macaddr.addr, mac);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006268
Michal Kazior7aa7a722014-08-25 12:09:38 +02006269 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valo5e3dd152013-06-12 20:52:10 +03006270 "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr %pM\n",
6271 vdev_id, param_id, value, mac);
Michal Kaziord7579d12014-12-03 10:10:54 +02006272 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006273}
6274
Michal Kaziord7579d12014-12-03 10:10:54 +02006275static struct sk_buff *
6276ath10k_wmi_op_gen_scan_chan_list(struct ath10k *ar,
6277 const struct wmi_scan_chan_list_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006278{
6279 struct wmi_scan_chan_list_cmd *cmd;
6280 struct sk_buff *skb;
6281 struct wmi_channel_arg *ch;
6282 struct wmi_channel *ci;
6283 int len;
6284 int i;
6285
6286 len = sizeof(*cmd) + arg->n_channels * sizeof(struct wmi_channel);
6287
Michal Kazior7aa7a722014-08-25 12:09:38 +02006288 skb = ath10k_wmi_alloc_skb(ar, len);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006289 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006290 return ERR_PTR(-EINVAL);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006291
6292 cmd = (struct wmi_scan_chan_list_cmd *)skb->data;
6293 cmd->num_scan_chans = __cpu_to_le32(arg->n_channels);
6294
6295 for (i = 0; i < arg->n_channels; i++) {
Kalle Valo5e3dd152013-06-12 20:52:10 +03006296 ch = &arg->channels[i];
6297 ci = &cmd->chan_info[i];
6298
Michal Kazior2d667212014-09-18 15:21:21 +02006299 ath10k_wmi_put_wmi_channel(ci, ch);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006300 }
6301
Michal Kaziord7579d12014-12-03 10:10:54 +02006302 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006303}
6304
Michal Kazior24c88f72014-07-25 13:32:17 +02006305static void
6306ath10k_wmi_peer_assoc_fill(struct ath10k *ar, void *buf,
6307 const struct wmi_peer_assoc_complete_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006308{
Michal Kazior24c88f72014-07-25 13:32:17 +02006309 struct wmi_common_peer_assoc_complete_cmd *cmd = buf;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006310
Kalle Valo5e3dd152013-06-12 20:52:10 +03006311 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
6312 cmd->peer_new_assoc = __cpu_to_le32(arg->peer_reassoc ? 0 : 1);
6313 cmd->peer_associd = __cpu_to_le32(arg->peer_aid);
6314 cmd->peer_flags = __cpu_to_le32(arg->peer_flags);
6315 cmd->peer_caps = __cpu_to_le32(arg->peer_caps);
6316 cmd->peer_listen_intval = __cpu_to_le32(arg->peer_listen_intval);
6317 cmd->peer_ht_caps = __cpu_to_le32(arg->peer_ht_caps);
6318 cmd->peer_max_mpdu = __cpu_to_le32(arg->peer_max_mpdu);
6319 cmd->peer_mpdu_density = __cpu_to_le32(arg->peer_mpdu_density);
6320 cmd->peer_rate_caps = __cpu_to_le32(arg->peer_rate_caps);
6321 cmd->peer_nss = __cpu_to_le32(arg->peer_num_spatial_streams);
6322 cmd->peer_vht_caps = __cpu_to_le32(arg->peer_vht_caps);
6323 cmd->peer_phymode = __cpu_to_le32(arg->peer_phymode);
6324
Kalle Valob25f32c2014-09-14 12:50:49 +03006325 ether_addr_copy(cmd->peer_macaddr.addr, arg->addr);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006326
6327 cmd->peer_legacy_rates.num_rates =
6328 __cpu_to_le32(arg->peer_legacy_rates.num_rates);
6329 memcpy(cmd->peer_legacy_rates.rates, arg->peer_legacy_rates.rates,
6330 arg->peer_legacy_rates.num_rates);
6331
6332 cmd->peer_ht_rates.num_rates =
6333 __cpu_to_le32(arg->peer_ht_rates.num_rates);
6334 memcpy(cmd->peer_ht_rates.rates, arg->peer_ht_rates.rates,
6335 arg->peer_ht_rates.num_rates);
6336
6337 cmd->peer_vht_rates.rx_max_rate =
6338 __cpu_to_le32(arg->peer_vht_rates.rx_max_rate);
6339 cmd->peer_vht_rates.rx_mcs_set =
6340 __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set);
6341 cmd->peer_vht_rates.tx_max_rate =
6342 __cpu_to_le32(arg->peer_vht_rates.tx_max_rate);
6343 cmd->peer_vht_rates.tx_mcs_set =
6344 __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set);
Michal Kazior24c88f72014-07-25 13:32:17 +02006345}
6346
6347static void
6348ath10k_wmi_peer_assoc_fill_main(struct ath10k *ar, void *buf,
6349 const struct wmi_peer_assoc_complete_arg *arg)
6350{
6351 struct wmi_main_peer_assoc_complete_cmd *cmd = buf;
6352
6353 ath10k_wmi_peer_assoc_fill(ar, buf, arg);
6354 memset(cmd->peer_ht_info, 0, sizeof(cmd->peer_ht_info));
6355}
6356
6357static void
6358ath10k_wmi_peer_assoc_fill_10_1(struct ath10k *ar, void *buf,
6359 const struct wmi_peer_assoc_complete_arg *arg)
6360{
6361 ath10k_wmi_peer_assoc_fill(ar, buf, arg);
6362}
6363
6364static void
6365ath10k_wmi_peer_assoc_fill_10_2(struct ath10k *ar, void *buf,
6366 const struct wmi_peer_assoc_complete_arg *arg)
6367{
6368 struct wmi_10_2_peer_assoc_complete_cmd *cmd = buf;
6369 int max_mcs, max_nss;
6370 u32 info0;
6371
6372 /* TODO: Is using max values okay with firmware? */
6373 max_mcs = 0xf;
6374 max_nss = 0xf;
6375
6376 info0 = SM(max_mcs, WMI_PEER_ASSOC_INFO0_MAX_MCS_IDX) |
6377 SM(max_nss, WMI_PEER_ASSOC_INFO0_MAX_NSS);
6378
6379 ath10k_wmi_peer_assoc_fill(ar, buf, arg);
6380 cmd->info0 = __cpu_to_le32(info0);
6381}
6382
Vasanthakumar Thiagarajanb54e16f2015-11-05 11:33:58 +05306383static void
6384ath10k_wmi_peer_assoc_fill_10_4(struct ath10k *ar, void *buf,
6385 const struct wmi_peer_assoc_complete_arg *arg)
6386{
6387 struct wmi_10_4_peer_assoc_complete_cmd *cmd = buf;
6388
6389 ath10k_wmi_peer_assoc_fill_10_2(ar, buf, arg);
6390 cmd->peer_bw_rxnss_override = 0;
6391}
6392
Michal Kaziord7579d12014-12-03 10:10:54 +02006393static int
6394ath10k_wmi_peer_assoc_check_arg(const struct wmi_peer_assoc_complete_arg *arg)
Michal Kazior24c88f72014-07-25 13:32:17 +02006395{
Michal Kazior24c88f72014-07-25 13:32:17 +02006396 if (arg->peer_mpdu_density > 16)
6397 return -EINVAL;
6398 if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES)
6399 return -EINVAL;
6400 if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES)
6401 return -EINVAL;
6402
Michal Kaziord7579d12014-12-03 10:10:54 +02006403 return 0;
6404}
6405
6406static struct sk_buff *
6407ath10k_wmi_op_gen_peer_assoc(struct ath10k *ar,
6408 const struct wmi_peer_assoc_complete_arg *arg)
6409{
6410 size_t len = sizeof(struct wmi_main_peer_assoc_complete_cmd);
6411 struct sk_buff *skb;
6412 int ret;
6413
6414 ret = ath10k_wmi_peer_assoc_check_arg(arg);
6415 if (ret)
6416 return ERR_PTR(ret);
Michal Kazior24c88f72014-07-25 13:32:17 +02006417
Michal Kazior7aa7a722014-08-25 12:09:38 +02006418 skb = ath10k_wmi_alloc_skb(ar, len);
Michal Kazior24c88f72014-07-25 13:32:17 +02006419 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006420 return ERR_PTR(-ENOMEM);
Michal Kazior24c88f72014-07-25 13:32:17 +02006421
Michal Kaziord7579d12014-12-03 10:10:54 +02006422 ath10k_wmi_peer_assoc_fill_main(ar, skb->data, arg);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006423
Michal Kazior7aa7a722014-08-25 12:09:38 +02006424 ath10k_dbg(ar, ATH10K_DBG_WMI,
Chun-Yeow Yeoh44d6fa92014-03-07 10:19:30 +02006425 "wmi peer assoc vdev %d addr %pM (%s)\n",
6426 arg->vdev_id, arg->addr,
6427 arg->peer_reassoc ? "reassociate" : "new");
Michal Kaziord7579d12014-12-03 10:10:54 +02006428 return skb;
6429}
6430
6431static struct sk_buff *
6432ath10k_wmi_10_1_op_gen_peer_assoc(struct ath10k *ar,
6433 const struct wmi_peer_assoc_complete_arg *arg)
6434{
6435 size_t len = sizeof(struct wmi_10_1_peer_assoc_complete_cmd);
6436 struct sk_buff *skb;
6437 int ret;
6438
6439 ret = ath10k_wmi_peer_assoc_check_arg(arg);
6440 if (ret)
6441 return ERR_PTR(ret);
6442
6443 skb = ath10k_wmi_alloc_skb(ar, len);
6444 if (!skb)
6445 return ERR_PTR(-ENOMEM);
6446
6447 ath10k_wmi_peer_assoc_fill_10_1(ar, skb->data, arg);
6448
6449 ath10k_dbg(ar, ATH10K_DBG_WMI,
6450 "wmi peer assoc vdev %d addr %pM (%s)\n",
6451 arg->vdev_id, arg->addr,
6452 arg->peer_reassoc ? "reassociate" : "new");
6453 return skb;
6454}
6455
6456static struct sk_buff *
6457ath10k_wmi_10_2_op_gen_peer_assoc(struct ath10k *ar,
6458 const struct wmi_peer_assoc_complete_arg *arg)
6459{
6460 size_t len = sizeof(struct wmi_10_2_peer_assoc_complete_cmd);
6461 struct sk_buff *skb;
6462 int ret;
6463
6464 ret = ath10k_wmi_peer_assoc_check_arg(arg);
6465 if (ret)
6466 return ERR_PTR(ret);
6467
6468 skb = ath10k_wmi_alloc_skb(ar, len);
6469 if (!skb)
6470 return ERR_PTR(-ENOMEM);
6471
6472 ath10k_wmi_peer_assoc_fill_10_2(ar, skb->data, arg);
6473
6474 ath10k_dbg(ar, ATH10K_DBG_WMI,
6475 "wmi peer assoc vdev %d addr %pM (%s)\n",
6476 arg->vdev_id, arg->addr,
6477 arg->peer_reassoc ? "reassociate" : "new");
6478 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006479}
6480
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02006481static struct sk_buff *
Vasanthakumar Thiagarajanb54e16f2015-11-05 11:33:58 +05306482ath10k_wmi_10_4_op_gen_peer_assoc(struct ath10k *ar,
6483 const struct wmi_peer_assoc_complete_arg *arg)
6484{
6485 size_t len = sizeof(struct wmi_10_4_peer_assoc_complete_cmd);
6486 struct sk_buff *skb;
6487 int ret;
6488
6489 ret = ath10k_wmi_peer_assoc_check_arg(arg);
6490 if (ret)
6491 return ERR_PTR(ret);
6492
6493 skb = ath10k_wmi_alloc_skb(ar, len);
6494 if (!skb)
6495 return ERR_PTR(-ENOMEM);
6496
6497 ath10k_wmi_peer_assoc_fill_10_4(ar, skb->data, arg);
6498
6499 ath10k_dbg(ar, ATH10K_DBG_WMI,
6500 "wmi peer assoc vdev %d addr %pM (%s)\n",
6501 arg->vdev_id, arg->addr,
6502 arg->peer_reassoc ? "reassociate" : "new");
6503 return skb;
6504}
6505
6506static struct sk_buff *
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02006507ath10k_wmi_10_2_op_gen_pdev_get_temperature(struct ath10k *ar)
6508{
6509 struct sk_buff *skb;
6510
6511 skb = ath10k_wmi_alloc_skb(ar, 0);
6512 if (!skb)
6513 return ERR_PTR(-ENOMEM);
6514
6515 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev get temperature\n");
6516 return skb;
6517}
6518
Michal Kazior748afc42014-01-23 12:48:21 +01006519/* This function assumes the beacon is already DMA mapped */
Michal Kaziord7579d12014-12-03 10:10:54 +02006520static struct sk_buff *
Michal Kazior9ad50182015-01-29 14:29:47 +02006521ath10k_wmi_op_gen_beacon_dma(struct ath10k *ar, u32 vdev_id, const void *bcn,
6522 size_t bcn_len, u32 bcn_paddr, bool dtim_zero,
6523 bool deliver_cab)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006524{
Michal Kazior748afc42014-01-23 12:48:21 +01006525 struct wmi_bcn_tx_ref_cmd *cmd;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006526 struct sk_buff *skb;
Michal Kazior748afc42014-01-23 12:48:21 +01006527 struct ieee80211_hdr *hdr;
Michal Kazior748afc42014-01-23 12:48:21 +01006528 u16 fc;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006529
Michal Kazior7aa7a722014-08-25 12:09:38 +02006530 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006531 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006532 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006533
Michal Kazior9ad50182015-01-29 14:29:47 +02006534 hdr = (struct ieee80211_hdr *)bcn;
Michal Kazior748afc42014-01-23 12:48:21 +01006535 fc = le16_to_cpu(hdr->frame_control);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006536
Michal Kazior748afc42014-01-23 12:48:21 +01006537 cmd = (struct wmi_bcn_tx_ref_cmd *)skb->data;
Michal Kazior9ad50182015-01-29 14:29:47 +02006538 cmd->vdev_id = __cpu_to_le32(vdev_id);
6539 cmd->data_len = __cpu_to_le32(bcn_len);
6540 cmd->data_ptr = __cpu_to_le32(bcn_paddr);
Michal Kazior748afc42014-01-23 12:48:21 +01006541 cmd->msdu_id = 0;
6542 cmd->frame_control = __cpu_to_le32(fc);
6543 cmd->flags = 0;
Michal Kazior24c88f72014-07-25 13:32:17 +02006544 cmd->antenna_mask = __cpu_to_le32(WMI_BCN_TX_REF_DEF_ANTENNA);
Michal Kazior748afc42014-01-23 12:48:21 +01006545
Michal Kazior9ad50182015-01-29 14:29:47 +02006546 if (dtim_zero)
Michal Kazior748afc42014-01-23 12:48:21 +01006547 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DTIM_ZERO);
6548
Michal Kazior9ad50182015-01-29 14:29:47 +02006549 if (deliver_cab)
Michal Kazior748afc42014-01-23 12:48:21 +01006550 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB);
6551
Michal Kaziord7579d12014-12-03 10:10:54 +02006552 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006553}
6554
Michal Kazior5e752e42015-01-19 09:53:41 +01006555void ath10k_wmi_set_wmm_param(struct wmi_wmm_params *params,
6556 const struct wmi_wmm_params_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006557{
6558 params->cwmin = __cpu_to_le32(arg->cwmin);
6559 params->cwmax = __cpu_to_le32(arg->cwmax);
6560 params->aifs = __cpu_to_le32(arg->aifs);
6561 params->txop = __cpu_to_le32(arg->txop);
6562 params->acm = __cpu_to_le32(arg->acm);
6563 params->no_ack = __cpu_to_le32(arg->no_ack);
6564}
6565
Michal Kaziord7579d12014-12-03 10:10:54 +02006566static struct sk_buff *
6567ath10k_wmi_op_gen_pdev_set_wmm(struct ath10k *ar,
Michal Kazior5e752e42015-01-19 09:53:41 +01006568 const struct wmi_wmm_params_all_arg *arg)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006569{
6570 struct wmi_pdev_set_wmm_params *cmd;
6571 struct sk_buff *skb;
6572
Michal Kazior7aa7a722014-08-25 12:09:38 +02006573 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006574 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006575 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006576
6577 cmd = (struct wmi_pdev_set_wmm_params *)skb->data;
Michal Kazior5e752e42015-01-19 09:53:41 +01006578 ath10k_wmi_set_wmm_param(&cmd->ac_be, &arg->ac_be);
6579 ath10k_wmi_set_wmm_param(&cmd->ac_bk, &arg->ac_bk);
6580 ath10k_wmi_set_wmm_param(&cmd->ac_vi, &arg->ac_vi);
6581 ath10k_wmi_set_wmm_param(&cmd->ac_vo, &arg->ac_vo);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006582
Michal Kazior7aa7a722014-08-25 12:09:38 +02006583 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set wmm params\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02006584 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006585}
6586
Michal Kaziord7579d12014-12-03 10:10:54 +02006587static struct sk_buff *
Michal Kaziorde23d3e2015-02-15 16:50:41 +02006588ath10k_wmi_op_gen_request_stats(struct ath10k *ar, u32 stats_mask)
Kalle Valo5e3dd152013-06-12 20:52:10 +03006589{
6590 struct wmi_request_stats_cmd *cmd;
6591 struct sk_buff *skb;
6592
Michal Kazior7aa7a722014-08-25 12:09:38 +02006593 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valo5e3dd152013-06-12 20:52:10 +03006594 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006595 return ERR_PTR(-ENOMEM);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006596
6597 cmd = (struct wmi_request_stats_cmd *)skb->data;
Michal Kaziorde23d3e2015-02-15 16:50:41 +02006598 cmd->stats_id = __cpu_to_le32(stats_mask);
Kalle Valo5e3dd152013-06-12 20:52:10 +03006599
Michal Kaziorde23d3e2015-02-15 16:50:41 +02006600 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi request stats 0x%08x\n",
6601 stats_mask);
Michal Kaziord7579d12014-12-03 10:10:54 +02006602 return skb;
Kalle Valo5e3dd152013-06-12 20:52:10 +03006603}
Michal Kazior9cfbce72013-07-16 09:54:36 +02006604
Michal Kaziord7579d12014-12-03 10:10:54 +02006605static struct sk_buff *
6606ath10k_wmi_op_gen_force_fw_hang(struct ath10k *ar,
6607 enum wmi_force_fw_hang_type type, u32 delay_ms)
Michal Kazior9cfbce72013-07-16 09:54:36 +02006608{
6609 struct wmi_force_fw_hang_cmd *cmd;
6610 struct sk_buff *skb;
6611
Michal Kazior7aa7a722014-08-25 12:09:38 +02006612 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Michal Kazior9cfbce72013-07-16 09:54:36 +02006613 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006614 return ERR_PTR(-ENOMEM);
Michal Kazior9cfbce72013-07-16 09:54:36 +02006615
6616 cmd = (struct wmi_force_fw_hang_cmd *)skb->data;
6617 cmd->type = __cpu_to_le32(type);
6618 cmd->delay_ms = __cpu_to_le32(delay_ms);
6619
Michal Kazior7aa7a722014-08-25 12:09:38 +02006620 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi force fw hang %d delay %d\n",
Michal Kazior9cfbce72013-07-16 09:54:36 +02006621 type, delay_ms);
Michal Kaziord7579d12014-12-03 10:10:54 +02006622 return skb;
Michal Kazior9cfbce72013-07-16 09:54:36 +02006623}
Kalle Valof118a3e2014-01-03 12:59:31 +02006624
Michal Kaziord7579d12014-12-03 10:10:54 +02006625static struct sk_buff *
SenthilKumar Jegadeesan467210a2015-01-29 14:36:52 +05306626ath10k_wmi_op_gen_dbglog_cfg(struct ath10k *ar, u32 module_enable,
6627 u32 log_level)
Kalle Valof118a3e2014-01-03 12:59:31 +02006628{
6629 struct wmi_dbglog_cfg_cmd *cmd;
6630 struct sk_buff *skb;
6631 u32 cfg;
6632
Michal Kazior7aa7a722014-08-25 12:09:38 +02006633 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
Kalle Valof118a3e2014-01-03 12:59:31 +02006634 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006635 return ERR_PTR(-ENOMEM);
Kalle Valof118a3e2014-01-03 12:59:31 +02006636
6637 cmd = (struct wmi_dbglog_cfg_cmd *)skb->data;
6638
6639 if (module_enable) {
SenthilKumar Jegadeesan467210a2015-01-29 14:36:52 +05306640 cfg = SM(log_level,
Kalle Valof118a3e2014-01-03 12:59:31 +02006641 ATH10K_DBGLOG_CFG_LOG_LVL);
6642 } else {
6643 /* set back defaults, all modules with WARN level */
6644 cfg = SM(ATH10K_DBGLOG_LEVEL_WARN,
6645 ATH10K_DBGLOG_CFG_LOG_LVL);
6646 module_enable = ~0;
6647 }
6648
6649 cmd->module_enable = __cpu_to_le32(module_enable);
6650 cmd->module_valid = __cpu_to_le32(~0);
6651 cmd->config_enable = __cpu_to_le32(cfg);
6652 cmd->config_valid = __cpu_to_le32(ATH10K_DBGLOG_CFG_LOG_LVL_MASK);
6653
Michal Kazior7aa7a722014-08-25 12:09:38 +02006654 ath10k_dbg(ar, ATH10K_DBG_WMI,
Kalle Valof118a3e2014-01-03 12:59:31 +02006655 "wmi dbglog cfg modules %08x %08x config %08x %08x\n",
6656 __le32_to_cpu(cmd->module_enable),
6657 __le32_to_cpu(cmd->module_valid),
6658 __le32_to_cpu(cmd->config_enable),
6659 __le32_to_cpu(cmd->config_valid));
Michal Kaziord7579d12014-12-03 10:10:54 +02006660 return skb;
Kalle Valof118a3e2014-01-03 12:59:31 +02006661}
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02006662
Michal Kaziord7579d12014-12-03 10:10:54 +02006663static struct sk_buff *
6664ath10k_wmi_op_gen_pktlog_enable(struct ath10k *ar, u32 ev_bitmap)
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006665{
6666 struct wmi_pdev_pktlog_enable_cmd *cmd;
6667 struct sk_buff *skb;
6668
6669 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6670 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006671 return ERR_PTR(-ENOMEM);
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006672
6673 ev_bitmap &= ATH10K_PKTLOG_ANY;
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006674
6675 cmd = (struct wmi_pdev_pktlog_enable_cmd *)skb->data;
6676 cmd->ev_bitmap = __cpu_to_le32(ev_bitmap);
Michal Kaziord7579d12014-12-03 10:10:54 +02006677
6678 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi enable pktlog filter 0x%08x\n",
6679 ev_bitmap);
6680 return skb;
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006681}
6682
Michal Kaziord7579d12014-12-03 10:10:54 +02006683static struct sk_buff *
6684ath10k_wmi_op_gen_pktlog_disable(struct ath10k *ar)
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006685{
6686 struct sk_buff *skb;
6687
6688 skb = ath10k_wmi_alloc_skb(ar, 0);
6689 if (!skb)
Michal Kaziord7579d12014-12-03 10:10:54 +02006690 return ERR_PTR(-ENOMEM);
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006691
6692 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi disable pktlog\n");
Michal Kaziord7579d12014-12-03 10:10:54 +02006693 return skb;
Rajkumar Manoharan90174452014-10-03 08:02:33 +03006694}
6695
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02006696static struct sk_buff *
6697ath10k_wmi_op_gen_pdev_set_quiet_mode(struct ath10k *ar, u32 period,
6698 u32 duration, u32 next_offset,
6699 u32 enabled)
6700{
6701 struct wmi_pdev_set_quiet_cmd *cmd;
6702 struct sk_buff *skb;
6703
6704 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6705 if (!skb)
6706 return ERR_PTR(-ENOMEM);
6707
6708 cmd = (struct wmi_pdev_set_quiet_cmd *)skb->data;
6709 cmd->period = __cpu_to_le32(period);
6710 cmd->duration = __cpu_to_le32(duration);
6711 cmd->next_start = __cpu_to_le32(next_offset);
6712 cmd->enabled = __cpu_to_le32(enabled);
6713
6714 ath10k_dbg(ar, ATH10K_DBG_WMI,
6715 "wmi quiet param: period %u duration %u enabled %d\n",
6716 period, duration, enabled);
6717 return skb;
6718}
6719
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02006720static struct sk_buff *
6721ath10k_wmi_op_gen_addba_clear_resp(struct ath10k *ar, u32 vdev_id,
6722 const u8 *mac)
6723{
6724 struct wmi_addba_clear_resp_cmd *cmd;
6725 struct sk_buff *skb;
6726
6727 if (!mac)
6728 return ERR_PTR(-EINVAL);
6729
6730 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6731 if (!skb)
6732 return ERR_PTR(-ENOMEM);
6733
6734 cmd = (struct wmi_addba_clear_resp_cmd *)skb->data;
6735 cmd->vdev_id = __cpu_to_le32(vdev_id);
6736 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6737
6738 ath10k_dbg(ar, ATH10K_DBG_WMI,
6739 "wmi addba clear resp vdev_id 0x%X mac_addr %pM\n",
6740 vdev_id, mac);
6741 return skb;
6742}
6743
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02006744static struct sk_buff *
6745ath10k_wmi_op_gen_addba_send(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6746 u32 tid, u32 buf_size)
6747{
6748 struct wmi_addba_send_cmd *cmd;
6749 struct sk_buff *skb;
6750
6751 if (!mac)
6752 return ERR_PTR(-EINVAL);
6753
6754 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6755 if (!skb)
6756 return ERR_PTR(-ENOMEM);
6757
6758 cmd = (struct wmi_addba_send_cmd *)skb->data;
6759 cmd->vdev_id = __cpu_to_le32(vdev_id);
6760 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6761 cmd->tid = __cpu_to_le32(tid);
6762 cmd->buffersize = __cpu_to_le32(buf_size);
6763
6764 ath10k_dbg(ar, ATH10K_DBG_WMI,
6765 "wmi addba send vdev_id 0x%X mac_addr %pM tid %u bufsize %u\n",
6766 vdev_id, mac, tid, buf_size);
6767 return skb;
6768}
6769
Rajkumar Manoharan11597412015-01-12 14:07:26 +02006770static struct sk_buff *
6771ath10k_wmi_op_gen_addba_set_resp(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6772 u32 tid, u32 status)
6773{
6774 struct wmi_addba_setresponse_cmd *cmd;
6775 struct sk_buff *skb;
6776
6777 if (!mac)
6778 return ERR_PTR(-EINVAL);
6779
6780 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6781 if (!skb)
6782 return ERR_PTR(-ENOMEM);
6783
6784 cmd = (struct wmi_addba_setresponse_cmd *)skb->data;
6785 cmd->vdev_id = __cpu_to_le32(vdev_id);
6786 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6787 cmd->tid = __cpu_to_le32(tid);
6788 cmd->statuscode = __cpu_to_le32(status);
6789
6790 ath10k_dbg(ar, ATH10K_DBG_WMI,
6791 "wmi addba set resp vdev_id 0x%X mac_addr %pM tid %u status %u\n",
6792 vdev_id, mac, tid, status);
6793 return skb;
6794}
6795
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02006796static struct sk_buff *
6797ath10k_wmi_op_gen_delba_send(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6798 u32 tid, u32 initiator, u32 reason)
6799{
6800 struct wmi_delba_send_cmd *cmd;
6801 struct sk_buff *skb;
6802
6803 if (!mac)
6804 return ERR_PTR(-EINVAL);
6805
6806 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6807 if (!skb)
6808 return ERR_PTR(-ENOMEM);
6809
6810 cmd = (struct wmi_delba_send_cmd *)skb->data;
6811 cmd->vdev_id = __cpu_to_le32(vdev_id);
6812 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6813 cmd->tid = __cpu_to_le32(tid);
6814 cmd->initiator = __cpu_to_le32(initiator);
6815 cmd->reasoncode = __cpu_to_le32(reason);
6816
6817 ath10k_dbg(ar, ATH10K_DBG_WMI,
6818 "wmi delba send vdev_id 0x%X mac_addr %pM tid %u initiator %u reason %u\n",
6819 vdev_id, mac, tid, initiator, reason);
6820 return skb;
6821}
6822
Maharaja Kennadyrajan29542662015-10-05 17:56:38 +03006823static struct sk_buff *
6824ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config(struct ath10k *ar, u32 param)
6825{
6826 struct wmi_pdev_get_tpc_config_cmd *cmd;
6827 struct sk_buff *skb;
6828
6829 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6830 if (!skb)
6831 return ERR_PTR(-ENOMEM);
6832
6833 cmd = (struct wmi_pdev_get_tpc_config_cmd *)skb->data;
6834 cmd->param = __cpu_to_le32(param);
6835
6836 ath10k_dbg(ar, ATH10K_DBG_WMI,
6837 "wmi pdev get tcp config param:%d\n", param);
6838 return skb;
6839}
6840
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03006841size_t ath10k_wmi_fw_stats_num_peers(struct list_head *head)
6842{
6843 struct ath10k_fw_stats_peer *i;
6844 size_t num = 0;
6845
6846 list_for_each_entry(i, head, list)
6847 ++num;
6848
6849 return num;
6850}
6851
6852size_t ath10k_wmi_fw_stats_num_vdevs(struct list_head *head)
6853{
6854 struct ath10k_fw_stats_vdev *i;
6855 size_t num = 0;
6856
6857 list_for_each_entry(i, head, list)
6858 ++num;
6859
6860 return num;
6861}
6862
6863static void
6864ath10k_wmi_fw_pdev_base_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
6865 char *buf, u32 *length)
6866{
6867 u32 len = *length;
6868 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
6869
6870 len += scnprintf(buf + len, buf_len - len, "\n");
6871 len += scnprintf(buf + len, buf_len - len, "%30s\n",
6872 "ath10k PDEV stats");
6873 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
6874 "=================");
6875
6876 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6877 "Channel noise floor", pdev->ch_noise_floor);
6878 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6879 "Channel TX power", pdev->chan_tx_power);
6880 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6881 "TX frame count", pdev->tx_frame_count);
6882 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6883 "RX frame count", pdev->rx_frame_count);
6884 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6885 "RX clear count", pdev->rx_clear_count);
6886 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6887 "Cycle count", pdev->cycle_count);
6888 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6889 "PHY error count", pdev->phy_err_count);
6890
6891 *length = len;
6892}
6893
6894static void
6895ath10k_wmi_fw_pdev_extra_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
6896 char *buf, u32 *length)
6897{
6898 u32 len = *length;
6899 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
6900
6901 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6902 "RTS bad count", pdev->rts_bad);
6903 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6904 "RTS good count", pdev->rts_good);
6905 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6906 "FCS bad count", pdev->fcs_bad);
6907 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6908 "No beacon count", pdev->no_beacons);
6909 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6910 "MIB int count", pdev->mib_int_count);
6911
6912 len += scnprintf(buf + len, buf_len - len, "\n");
6913 *length = len;
6914}
6915
6916static void
6917ath10k_wmi_fw_pdev_tx_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
6918 char *buf, u32 *length)
6919{
6920 u32 len = *length;
6921 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
6922
6923 len += scnprintf(buf + len, buf_len - len, "\n%30s\n",
6924 "ath10k PDEV TX stats");
6925 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
6926 "=================");
6927
6928 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6929 "HTT cookies queued", pdev->comp_queued);
6930 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6931 "HTT cookies disp.", pdev->comp_delivered);
6932 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6933 "MSDU queued", pdev->msdu_enqued);
6934 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6935 "MPDU queued", pdev->mpdu_enqued);
6936 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6937 "MSDUs dropped", pdev->wmm_drop);
6938 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6939 "Local enqued", pdev->local_enqued);
6940 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6941 "Local freed", pdev->local_freed);
6942 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6943 "HW queued", pdev->hw_queued);
6944 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6945 "PPDUs reaped", pdev->hw_reaped);
6946 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6947 "Num underruns", pdev->underrun);
6948 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6949 "PPDUs cleaned", pdev->tx_abort);
6950 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6951 "MPDUs requed", pdev->mpdus_requed);
6952 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6953 "Excessive retries", pdev->tx_ko);
6954 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6955 "HW rate", pdev->data_rc);
6956 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6957 "Sched self tiggers", pdev->self_triggers);
6958 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6959 "Dropped due to SW retries",
6960 pdev->sw_retry_failure);
6961 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6962 "Illegal rate phy errors",
6963 pdev->illgl_rate_phy_err);
6964 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6965 "Pdev continuous xretry", pdev->pdev_cont_xretry);
6966 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6967 "TX timeout", pdev->pdev_tx_timeout);
6968 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6969 "PDEV resets", pdev->pdev_resets);
6970 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6971 "PHY underrun", pdev->phy_underrun);
6972 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6973 "MPDU is more than txop limit", pdev->txop_ovf);
6974 *length = len;
6975}
6976
6977static void
6978ath10k_wmi_fw_pdev_rx_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
6979 char *buf, u32 *length)
6980{
6981 u32 len = *length;
6982 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
6983
6984 len += scnprintf(buf + len, buf_len - len, "\n%30s\n",
6985 "ath10k PDEV RX stats");
6986 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
6987 "=================");
6988
6989 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6990 "Mid PPDU route change",
6991 pdev->mid_ppdu_route_change);
6992 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6993 "Tot. number of statuses", pdev->status_rcvd);
6994 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6995 "Extra frags on rings 0", pdev->r0_frags);
6996 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6997 "Extra frags on rings 1", pdev->r1_frags);
6998 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6999 "Extra frags on rings 2", pdev->r2_frags);
7000 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7001 "Extra frags on rings 3", pdev->r3_frags);
7002 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7003 "MSDUs delivered to HTT", pdev->htt_msdus);
7004 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7005 "MPDUs delivered to HTT", pdev->htt_mpdus);
7006 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7007 "MSDUs delivered to stack", pdev->loc_msdus);
7008 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7009 "MPDUs delivered to stack", pdev->loc_mpdus);
7010 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7011 "Oversized AMSUs", pdev->oversize_amsdu);
7012 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7013 "PHY errors", pdev->phy_errs);
7014 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7015 "PHY errors drops", pdev->phy_err_drop);
7016 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7017 "MPDU errors (FCS, MIC, ENC)", pdev->mpdu_errs);
7018 *length = len;
7019}
7020
7021static void
7022ath10k_wmi_fw_vdev_stats_fill(const struct ath10k_fw_stats_vdev *vdev,
7023 char *buf, u32 *length)
7024{
7025 u32 len = *length;
7026 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7027 int i;
7028
7029 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7030 "vdev id", vdev->vdev_id);
7031 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7032 "beacon snr", vdev->beacon_snr);
7033 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7034 "data snr", vdev->data_snr);
7035 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7036 "num rx frames", vdev->num_rx_frames);
7037 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7038 "num rts fail", vdev->num_rts_fail);
7039 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7040 "num rts success", vdev->num_rts_success);
7041 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7042 "num rx err", vdev->num_rx_err);
7043 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7044 "num rx discard", vdev->num_rx_discard);
7045 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7046 "num tx not acked", vdev->num_tx_not_acked);
7047
7048 for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames); i++)
7049 len += scnprintf(buf + len, buf_len - len,
7050 "%25s [%02d] %u\n",
7051 "num tx frames", i,
7052 vdev->num_tx_frames[i]);
7053
7054 for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames_retries); i++)
7055 len += scnprintf(buf + len, buf_len - len,
7056 "%25s [%02d] %u\n",
7057 "num tx frames retries", i,
7058 vdev->num_tx_frames_retries[i]);
7059
7060 for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames_failures); i++)
7061 len += scnprintf(buf + len, buf_len - len,
7062 "%25s [%02d] %u\n",
7063 "num tx frames failures", i,
7064 vdev->num_tx_frames_failures[i]);
7065
7066 for (i = 0 ; i < ARRAY_SIZE(vdev->tx_rate_history); i++)
7067 len += scnprintf(buf + len, buf_len - len,
7068 "%25s [%02d] 0x%08x\n",
7069 "tx rate history", i,
7070 vdev->tx_rate_history[i]);
7071
7072 for (i = 0 ; i < ARRAY_SIZE(vdev->beacon_rssi_history); i++)
7073 len += scnprintf(buf + len, buf_len - len,
7074 "%25s [%02d] %u\n",
7075 "beacon rssi history", i,
7076 vdev->beacon_rssi_history[i]);
7077
7078 len += scnprintf(buf + len, buf_len - len, "\n");
7079 *length = len;
7080}
7081
7082static void
7083ath10k_wmi_fw_peer_stats_fill(const struct ath10k_fw_stats_peer *peer,
7084 char *buf, u32 *length)
7085{
7086 u32 len = *length;
7087 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7088
7089 len += scnprintf(buf + len, buf_len - len, "%30s %pM\n",
7090 "Peer MAC address", peer->peer_macaddr);
7091 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7092 "Peer RSSI", peer->peer_rssi);
7093 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7094 "Peer TX rate", peer->peer_tx_rate);
7095 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7096 "Peer RX rate", peer->peer_rx_rate);
7097 len += scnprintf(buf + len, buf_len - len, "\n");
7098 *length = len;
7099}
7100
7101void ath10k_wmi_main_op_fw_stats_fill(struct ath10k *ar,
7102 struct ath10k_fw_stats *fw_stats,
7103 char *buf)
7104{
7105 u32 len = 0;
7106 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7107 const struct ath10k_fw_stats_pdev *pdev;
7108 const struct ath10k_fw_stats_vdev *vdev;
7109 const struct ath10k_fw_stats_peer *peer;
7110 size_t num_peers;
7111 size_t num_vdevs;
7112
7113 spin_lock_bh(&ar->data_lock);
7114
7115 pdev = list_first_entry_or_null(&fw_stats->pdevs,
7116 struct ath10k_fw_stats_pdev, list);
7117 if (!pdev) {
7118 ath10k_warn(ar, "failed to get pdev stats\n");
7119 goto unlock;
7120 }
7121
7122 num_peers = ath10k_wmi_fw_stats_num_peers(&fw_stats->peers);
7123 num_vdevs = ath10k_wmi_fw_stats_num_vdevs(&fw_stats->vdevs);
7124
7125 ath10k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len);
7126 ath10k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len);
7127 ath10k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len);
7128
7129 len += scnprintf(buf + len, buf_len - len, "\n");
7130 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7131 "ath10k VDEV stats", num_vdevs);
7132 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7133 "=================");
7134
7135 list_for_each_entry(vdev, &fw_stats->vdevs, list) {
7136 ath10k_wmi_fw_vdev_stats_fill(vdev, buf, &len);
7137 }
7138
7139 len += scnprintf(buf + len, buf_len - len, "\n");
7140 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7141 "ath10k PEER stats", num_peers);
7142 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7143 "=================");
7144
7145 list_for_each_entry(peer, &fw_stats->peers, list) {
7146 ath10k_wmi_fw_peer_stats_fill(peer, buf, &len);
7147 }
7148
7149unlock:
7150 spin_unlock_bh(&ar->data_lock);
7151
7152 if (len >= buf_len)
7153 buf[len - 1] = 0;
7154 else
7155 buf[len] = 0;
7156}
7157
7158void ath10k_wmi_10x_op_fw_stats_fill(struct ath10k *ar,
7159 struct ath10k_fw_stats *fw_stats,
7160 char *buf)
7161{
7162 unsigned int len = 0;
7163 unsigned int buf_len = ATH10K_FW_STATS_BUF_SIZE;
7164 const struct ath10k_fw_stats_pdev *pdev;
7165 const struct ath10k_fw_stats_vdev *vdev;
7166 const struct ath10k_fw_stats_peer *peer;
7167 size_t num_peers;
7168 size_t num_vdevs;
7169
7170 spin_lock_bh(&ar->data_lock);
7171
7172 pdev = list_first_entry_or_null(&fw_stats->pdevs,
7173 struct ath10k_fw_stats_pdev, list);
7174 if (!pdev) {
7175 ath10k_warn(ar, "failed to get pdev stats\n");
7176 goto unlock;
7177 }
7178
7179 num_peers = ath10k_wmi_fw_stats_num_peers(&fw_stats->peers);
7180 num_vdevs = ath10k_wmi_fw_stats_num_vdevs(&fw_stats->vdevs);
7181
7182 ath10k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len);
7183 ath10k_wmi_fw_pdev_extra_stats_fill(pdev, buf, &len);
7184 ath10k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len);
7185 ath10k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len);
7186
7187 len += scnprintf(buf + len, buf_len - len, "\n");
7188 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7189 "ath10k VDEV stats", num_vdevs);
7190 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7191 "=================");
7192
7193 list_for_each_entry(vdev, &fw_stats->vdevs, list) {
7194 ath10k_wmi_fw_vdev_stats_fill(vdev, buf, &len);
7195 }
7196
7197 len += scnprintf(buf + len, buf_len - len, "\n");
7198 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7199 "ath10k PEER stats", num_peers);
7200 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7201 "=================");
7202
7203 list_for_each_entry(peer, &fw_stats->peers, list) {
7204 ath10k_wmi_fw_peer_stats_fill(peer, buf, &len);
7205 }
7206
7207unlock:
7208 spin_unlock_bh(&ar->data_lock);
7209
7210 if (len >= buf_len)
7211 buf[len - 1] = 0;
7212 else
7213 buf[len] = 0;
7214}
7215
Maharaja62f77f02015-10-21 11:49:18 +03007216static struct sk_buff *
7217ath10k_wmi_op_gen_pdev_enable_adaptive_cca(struct ath10k *ar, u8 enable,
7218 u32 detect_level, u32 detect_margin)
7219{
7220 struct wmi_pdev_set_adaptive_cca_params *cmd;
7221 struct sk_buff *skb;
7222
7223 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7224 if (!skb)
7225 return ERR_PTR(-ENOMEM);
7226
7227 cmd = (struct wmi_pdev_set_adaptive_cca_params *)skb->data;
7228 cmd->enable = __cpu_to_le32(enable);
7229 cmd->cca_detect_level = __cpu_to_le32(detect_level);
7230 cmd->cca_detect_margin = __cpu_to_le32(detect_margin);
7231
7232 ath10k_dbg(ar, ATH10K_DBG_WMI,
7233 "wmi pdev set adaptive cca params enable:%d detection level:%d detection margin:%d\n",
7234 enable, detect_level, detect_margin);
7235 return skb;
7236}
7237
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02007238void ath10k_wmi_10_4_op_fw_stats_fill(struct ath10k *ar,
7239 struct ath10k_fw_stats *fw_stats,
7240 char *buf)
7241{
7242 u32 len = 0;
7243 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7244 const struct ath10k_fw_stats_pdev *pdev;
7245 const struct ath10k_fw_stats_vdev *vdev;
7246 const struct ath10k_fw_stats_peer *peer;
7247 size_t num_peers;
7248 size_t num_vdevs;
7249
7250 spin_lock_bh(&ar->data_lock);
7251
7252 pdev = list_first_entry_or_null(&fw_stats->pdevs,
7253 struct ath10k_fw_stats_pdev, list);
7254 if (!pdev) {
7255 ath10k_warn(ar, "failed to get pdev stats\n");
7256 goto unlock;
7257 }
7258
7259 num_peers = ath10k_wmi_fw_stats_num_peers(&fw_stats->peers);
7260 num_vdevs = ath10k_wmi_fw_stats_num_vdevs(&fw_stats->vdevs);
7261
7262 ath10k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len);
7263 ath10k_wmi_fw_pdev_extra_stats_fill(pdev, buf, &len);
7264 ath10k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len);
7265
7266 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7267 "HW paused", pdev->hw_paused);
7268 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7269 "Seqs posted", pdev->seq_posted);
7270 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7271 "Seqs failed queueing", pdev->seq_failed_queueing);
7272 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7273 "Seqs completed", pdev->seq_completed);
7274 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7275 "Seqs restarted", pdev->seq_restarted);
7276 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7277 "MU Seqs posted", pdev->mu_seq_posted);
7278 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7279 "MPDUs SW flushed", pdev->mpdus_sw_flush);
7280 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7281 "MPDUs HW filtered", pdev->mpdus_hw_filter);
7282 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7283 "MPDUs truncated", pdev->mpdus_truncated);
7284 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7285 "MPDUs receive no ACK", pdev->mpdus_ack_failed);
7286 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7287 "MPDUs expired", pdev->mpdus_expired);
7288
7289 ath10k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len);
7290 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7291 "Num Rx Overflow errors", pdev->rx_ovfl_errs);
7292
7293 len += scnprintf(buf + len, buf_len - len, "\n");
7294 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7295 "ath10k VDEV stats", num_vdevs);
7296 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7297 "=================");
7298
7299 list_for_each_entry(vdev, &fw_stats->vdevs, list) {
7300 ath10k_wmi_fw_vdev_stats_fill(vdev, buf, &len);
7301 }
7302
7303 len += scnprintf(buf + len, buf_len - len, "\n");
7304 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7305 "ath10k PEER stats", num_peers);
7306 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7307 "=================");
7308
7309 list_for_each_entry(peer, &fw_stats->peers, list) {
7310 ath10k_wmi_fw_peer_stats_fill(peer, buf, &len);
7311 }
7312
7313unlock:
7314 spin_unlock_bh(&ar->data_lock);
7315
7316 if (len >= buf_len)
7317 buf[len - 1] = 0;
7318 else
7319 buf[len] = 0;
7320}
7321
Michal Kaziord7579d12014-12-03 10:10:54 +02007322static const struct wmi_ops wmi_ops = {
7323 .rx = ath10k_wmi_op_rx,
7324 .map_svc = wmi_main_svc_map,
7325
7326 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7327 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7328 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7329 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7330 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7331 .pull_swba = ath10k_wmi_op_pull_swba_ev,
Raja Mani991adf72015-08-14 11:13:29 +03007332 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
Michal Kaziord7579d12014-12-03 10:10:54 +02007333 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7334 .pull_svc_rdy = ath10k_wmi_main_op_pull_svc_rdy_ev,
7335 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
7336 .pull_fw_stats = ath10k_wmi_main_op_pull_fw_stats,
Michal Kaziorc1a46542015-03-10 16:21:54 +02007337 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02007338
7339 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7340 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7341 .gen_pdev_set_rd = ath10k_wmi_op_gen_pdev_set_rd,
7342 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7343 .gen_init = ath10k_wmi_op_gen_init,
7344 .gen_start_scan = ath10k_wmi_op_gen_start_scan,
7345 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7346 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7347 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7348 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7349 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7350 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7351 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7352 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7353 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7354 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7355 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
Michal Kazior6d492fe2015-01-28 09:57:22 +02007356 /* .gen_vdev_wmm_conf not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007357 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7358 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7359 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7360 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7361 .gen_peer_assoc = ath10k_wmi_op_gen_peer_assoc,
7362 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7363 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7364 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7365 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7366 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7367 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7368 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7369 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7370 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7371 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7372 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7373 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02007374 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02007375 /* .gen_pdev_get_temperature not implemented */
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02007376 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02007377 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02007378 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02007379 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03007380 .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
Michal Kaziorbe9ce9d2015-01-13 16:30:11 +02007381 /* .gen_bcn_tmpl not implemented */
Michal Kazior4c4955f2015-01-13 16:30:11 +02007382 /* .gen_prb_tmpl not implemented */
Michal Kazior369242b4e2015-01-13 16:30:11 +02007383 /* .gen_p2p_go_bcn_ie not implemented */
Michal Kazior5b272e32015-03-31 10:26:22 +00007384 /* .gen_adaptive_qcs not implemented */
Maharaja62f77f02015-10-21 11:49:18 +03007385 /* .gen_pdev_enable_adaptive_cca not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007386};
7387
7388static const struct wmi_ops wmi_10_1_ops = {
7389 .rx = ath10k_wmi_10_1_op_rx,
7390 .map_svc = wmi_10x_svc_map,
7391 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
7392 .pull_fw_stats = ath10k_wmi_10x_op_pull_fw_stats,
7393 .gen_init = ath10k_wmi_10_1_op_gen_init,
7394 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7395 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
7396 .gen_peer_assoc = ath10k_wmi_10_1_op_gen_peer_assoc,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02007397 /* .gen_pdev_get_temperature not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007398
7399 /* shared with main branch */
7400 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7401 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7402 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7403 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7404 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7405 .pull_swba = ath10k_wmi_op_pull_swba_ev,
Raja Mani991adf72015-08-14 11:13:29 +03007406 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
Michal Kaziord7579d12014-12-03 10:10:54 +02007407 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7408 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
Michal Kaziorc1a46542015-03-10 16:21:54 +02007409 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02007410
7411 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7412 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7413 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7414 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7415 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7416 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7417 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7418 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7419 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7420 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7421 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7422 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7423 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7424 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
Michal Kazior6d492fe2015-01-28 09:57:22 +02007425 /* .gen_vdev_wmm_conf not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007426 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7427 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7428 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7429 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7430 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7431 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7432 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7433 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7434 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7435 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7436 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7437 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7438 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7439 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7440 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7441 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02007442 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02007443 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02007444 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02007445 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02007446 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03007447 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
Michal Kaziorbe9ce9d2015-01-13 16:30:11 +02007448 /* .gen_bcn_tmpl not implemented */
Michal Kazior4c4955f2015-01-13 16:30:11 +02007449 /* .gen_prb_tmpl not implemented */
Michal Kazior369242b4e2015-01-13 16:30:11 +02007450 /* .gen_p2p_go_bcn_ie not implemented */
Michal Kazior5b272e32015-03-31 10:26:22 +00007451 /* .gen_adaptive_qcs not implemented */
Maharaja62f77f02015-10-21 11:49:18 +03007452 /* .gen_pdev_enable_adaptive_cca not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007453};
7454
7455static const struct wmi_ops wmi_10_2_ops = {
7456 .rx = ath10k_wmi_10_2_op_rx,
Michal Kazior20de2222015-01-24 12:14:49 +02007457 .pull_fw_stats = ath10k_wmi_10_2_op_pull_fw_stats,
Michal Kaziord7579d12014-12-03 10:10:54 +02007458 .gen_init = ath10k_wmi_10_2_op_gen_init,
7459 .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02007460 /* .gen_pdev_get_temperature not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007461
7462 /* shared with 10.1 */
7463 .map_svc = wmi_10x_svc_map,
7464 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02007465 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7466 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
7467
7468 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7469 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7470 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7471 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7472 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7473 .pull_swba = ath10k_wmi_op_pull_swba_ev,
Raja Mani991adf72015-08-14 11:13:29 +03007474 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
Michal Kaziord7579d12014-12-03 10:10:54 +02007475 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7476 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
Michal Kaziorc1a46542015-03-10 16:21:54 +02007477 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Michal Kaziord7579d12014-12-03 10:10:54 +02007478
7479 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7480 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7481 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7482 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7483 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7484 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7485 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7486 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7487 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7488 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7489 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7490 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7491 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7492 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
Michal Kazior6d492fe2015-01-28 09:57:22 +02007493 /* .gen_vdev_wmm_conf not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007494 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7495 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7496 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7497 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7498 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7499 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7500 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7501 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7502 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7503 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7504 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7505 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7506 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7507 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7508 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7509 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02007510 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02007511 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02007512 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02007513 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02007514 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03007515 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
Maharaja62f77f02015-10-21 11:49:18 +03007516 /* .gen_pdev_enable_adaptive_cca not implemented */
Michal Kaziord7579d12014-12-03 10:10:54 +02007517};
7518
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007519static const struct wmi_ops wmi_10_2_4_ops = {
7520 .rx = ath10k_wmi_10_2_op_rx,
Michal Kazior20de2222015-01-24 12:14:49 +02007521 .pull_fw_stats = ath10k_wmi_10_2_4_op_pull_fw_stats,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007522 .gen_init = ath10k_wmi_10_2_op_gen_init,
7523 .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02007524 .gen_pdev_get_temperature = ath10k_wmi_10_2_op_gen_pdev_get_temperature,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007525
7526 /* shared with 10.1 */
7527 .map_svc = wmi_10x_svc_map,
7528 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007529 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7530 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
7531
7532 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7533 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7534 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7535 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7536 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7537 .pull_swba = ath10k_wmi_op_pull_swba_ev,
Raja Mani991adf72015-08-14 11:13:29 +03007538 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007539 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7540 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
Michal Kaziorc1a46542015-03-10 16:21:54 +02007541 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007542
7543 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7544 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7545 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7546 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7547 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7548 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7549 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7550 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7551 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7552 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7553 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7554 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7555 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7556 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
7557 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7558 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7559 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7560 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7561 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7562 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7563 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7564 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7565 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7566 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7567 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7568 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7569 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7570 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7571 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7572 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02007573 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02007574 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02007575 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
Rajkumar Manoharan11597412015-01-12 14:07:26 +02007576 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02007577 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Maharaja Kennadyrajan29542662015-10-05 17:56:38 +03007578 .gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config,
Manikanta Pubbisettybc6f9ae2015-10-16 15:54:52 +03007579 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
Maharaja62f77f02015-10-21 11:49:18 +03007580 .gen_pdev_enable_adaptive_cca =
7581 ath10k_wmi_op_gen_pdev_enable_adaptive_cca,
Michal Kaziorbe9ce9d2015-01-13 16:30:11 +02007582 /* .gen_bcn_tmpl not implemented */
Michal Kazior4c4955f2015-01-13 16:30:11 +02007583 /* .gen_prb_tmpl not implemented */
Michal Kazior369242b4e2015-01-13 16:30:11 +02007584 /* .gen_p2p_go_bcn_ie not implemented */
Michal Kazior5b272e32015-03-31 10:26:22 +00007585 /* .gen_adaptive_qcs not implemented */
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007586};
7587
Raja Mani840357c2015-06-22 20:10:10 +05307588static const struct wmi_ops wmi_10_4_ops = {
Raja Mani1c092962015-06-22 20:10:16 +05307589 .rx = ath10k_wmi_10_4_op_rx,
Raja Mani840357c2015-06-22 20:10:10 +05307590 .map_svc = wmi_10_4_svc_map,
Raja Manib2297ba2015-06-22 20:22:23 +05307591
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02007592 .pull_fw_stats = ath10k_wmi_10_4_op_pull_fw_stats,
Raja Manib2297ba2015-06-22 20:22:23 +05307593 .pull_scan = ath10k_wmi_op_pull_scan_ev,
Raja Mani1c092962015-06-22 20:10:16 +05307594 .pull_mgmt_rx = ath10k_wmi_10_4_op_pull_mgmt_rx_ev,
Raja Manib2297ba2015-06-22 20:22:23 +05307595 .pull_ch_info = ath10k_wmi_10_4_op_pull_ch_info_ev,
Raja Mani373b48c2015-06-22 20:22:22 +05307596 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7597 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
Raja Mani3cec3be2015-06-22 20:22:21 +05307598 .pull_swba = ath10k_wmi_10_4_op_pull_swba_ev,
Raja Mani2b0a2e02015-08-14 11:13:34 +03007599 .pull_phyerr_hdr = ath10k_wmi_10_4_op_pull_phyerr_ev_hdr,
7600 .pull_phyerr = ath10k_wmi_10_4_op_pull_phyerr_ev,
Raja Mani1c092962015-06-22 20:10:16 +05307601 .pull_svc_rdy = ath10k_wmi_main_op_pull_svc_rdy_ev,
Raja Manid02e7522015-06-22 20:10:18 +05307602 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
Vivek Natarajan08e75ea2015-08-04 10:45:11 +05307603 .get_txbf_conf_scheme = ath10k_wmi_10_4_txbf_conf_scheme,
Raja Mani373b48c2015-06-22 20:22:22 +05307604
7605 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7606 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7607 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7608 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
Raja Manid1e52a82015-06-22 20:10:15 +05307609 .gen_init = ath10k_wmi_10_4_op_gen_init,
Raja Manib2297ba2015-06-22 20:22:23 +05307610 .gen_start_scan = ath10k_wmi_op_gen_start_scan,
7611 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
Raja Mani373b48c2015-06-22 20:22:22 +05307612 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7613 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7614 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7615 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7616 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7617 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7618 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7619 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
Raja Mani4535edb2015-08-20 10:29:05 +05307620 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7621 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
Raja Mani373b48c2015-06-22 20:22:22 +05307622 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7623 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7624 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7625 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
Vasanthakumar Thiagarajanb54e16f2015-11-05 11:33:58 +05307626 .gen_peer_assoc = ath10k_wmi_10_4_op_gen_peer_assoc,
Raja Mani373b48c2015-06-22 20:22:22 +05307627 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7628 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7629 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7630 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7631 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7632 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7633 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7634 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7635 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7636 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7637 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
7638 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
Vasanthakumar Thiagarajanb2887412015-08-13 21:10:54 +05307639 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
7640 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
7641 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
7642 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02007643 .fw_stats_fill = ath10k_wmi_10_4_op_fw_stats_fill,
Raja Mani373b48c2015-06-22 20:22:22 +05307644
7645 /* shared with 10.2 */
Manikanta Pubbisetty98dd2b92015-10-28 21:38:33 +02007646 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
Tamizh chelvam6dd46342015-10-31 11:20:32 +02007647 .gen_pdev_get_temperature = ath10k_wmi_10_2_op_gen_pdev_get_temperature,
Raja Mani840357c2015-06-22 20:10:10 +05307648};
7649
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007650int ath10k_wmi_attach(struct ath10k *ar)
7651{
Michal Kaziord7579d12014-12-03 10:10:54 +02007652 switch (ar->wmi.op_version) {
Raja Mani9bd21322015-06-22 20:10:09 +05307653 case ATH10K_FW_WMI_OP_VERSION_10_4:
Raja Mani840357c2015-06-22 20:10:10 +05307654 ar->wmi.ops = &wmi_10_4_ops;
Raja Mani2d491e62015-06-22 20:10:11 +05307655 ar->wmi.cmd = &wmi_10_4_cmd_map;
Raja Mani93841a12015-06-22 20:10:13 +05307656 ar->wmi.vdev_param = &wmi_10_4_vdev_param_map;
Raja Manid86561f2015-06-22 20:10:14 +05307657 ar->wmi.pdev_param = &wmi_10_4_pdev_param_map;
Tamizh chelvam3fab30f2015-10-29 14:27:37 +02007658 ar->wmi.peer_flags = &wmi_10_2_peer_flags_map;
Raja Mani9bd21322015-06-22 20:10:09 +05307659 break;
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007660 case ATH10K_FW_WMI_OP_VERSION_10_2_4:
7661 ar->wmi.cmd = &wmi_10_2_4_cmd_map;
7662 ar->wmi.ops = &wmi_10_2_4_ops;
7663 ar->wmi.vdev_param = &wmi_10_2_4_vdev_param_map;
7664 ar->wmi.pdev_param = &wmi_10_2_4_pdev_param_map;
Tamizh chelvam3fab30f2015-10-29 14:27:37 +02007665 ar->wmi.peer_flags = &wmi_10_2_peer_flags_map;
Rajkumar Manoharan4a16fbe2014-12-17 12:21:12 +02007666 break;
Michal Kaziord7579d12014-12-03 10:10:54 +02007667 case ATH10K_FW_WMI_OP_VERSION_10_2:
7668 ar->wmi.cmd = &wmi_10_2_cmd_map;
7669 ar->wmi.ops = &wmi_10_2_ops;
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007670 ar->wmi.vdev_param = &wmi_10x_vdev_param_map;
7671 ar->wmi.pdev_param = &wmi_10x_pdev_param_map;
Tamizh chelvam3fab30f2015-10-29 14:27:37 +02007672 ar->wmi.peer_flags = &wmi_10_2_peer_flags_map;
Michal Kaziord7579d12014-12-03 10:10:54 +02007673 break;
7674 case ATH10K_FW_WMI_OP_VERSION_10_1:
7675 ar->wmi.cmd = &wmi_10x_cmd_map;
7676 ar->wmi.ops = &wmi_10_1_ops;
7677 ar->wmi.vdev_param = &wmi_10x_vdev_param_map;
7678 ar->wmi.pdev_param = &wmi_10x_pdev_param_map;
Tamizh chelvam3fab30f2015-10-29 14:27:37 +02007679 ar->wmi.peer_flags = &wmi_10x_peer_flags_map;
Michal Kaziord7579d12014-12-03 10:10:54 +02007680 break;
7681 case ATH10K_FW_WMI_OP_VERSION_MAIN:
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007682 ar->wmi.cmd = &wmi_cmd_map;
Michal Kaziord7579d12014-12-03 10:10:54 +02007683 ar->wmi.ops = &wmi_ops;
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007684 ar->wmi.vdev_param = &wmi_vdev_param_map;
7685 ar->wmi.pdev_param = &wmi_pdev_param_map;
Tamizh chelvam3fab30f2015-10-29 14:27:37 +02007686 ar->wmi.peer_flags = &wmi_peer_flags_map;
Michal Kaziord7579d12014-12-03 10:10:54 +02007687 break;
Michal Kaziorca996ec2014-12-03 10:11:32 +02007688 case ATH10K_FW_WMI_OP_VERSION_TLV:
7689 ath10k_wmi_tlv_attach(ar);
7690 break;
Michal Kaziord7579d12014-12-03 10:10:54 +02007691 case ATH10K_FW_WMI_OP_VERSION_UNSET:
7692 case ATH10K_FW_WMI_OP_VERSION_MAX:
7693 ath10k_err(ar, "unsupported WMI op version: %d\n",
7694 ar->wmi.op_version);
7695 return -EINVAL;
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007696 }
7697
7698 init_completion(&ar->wmi.service_ready);
7699 init_completion(&ar->wmi.unified_ready);
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007700
Raja Manic8ecfc12015-07-29 11:40:38 +03007701 INIT_WORK(&ar->svc_rdy_work, ath10k_wmi_event_service_ready_work);
7702
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007703 return 0;
7704}
7705
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05307706void ath10k_wmi_free_host_mem(struct ath10k *ar)
Michal Kaziorb79b9ba2014-09-18 15:21:23 +02007707{
7708 int i;
7709
7710 /* free the host memory chunks requested by firmware */
7711 for (i = 0; i < ar->wmi.num_mem_chunks; i++) {
7712 dma_free_coherent(ar->dev,
7713 ar->wmi.mem_chunks[i].len,
7714 ar->wmi.mem_chunks[i].vaddr,
7715 ar->wmi.mem_chunks[i].paddr);
7716 }
7717
7718 ar->wmi.num_mem_chunks = 0;
7719}
Vasanthakumar Thiagarajana925a372015-08-28 17:21:34 +05307720
7721void ath10k_wmi_detach(struct ath10k *ar)
7722{
7723 cancel_work_sync(&ar->svc_rdy_work);
7724
7725 if (ar->svc_rdy_skb)
7726 dev_kfree_skb(ar->svc_rdy_skb);
7727}